@excalidraw/excalidraw 0.18.0-c6f8ef9 → 0.18.0-d1f3982
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/{chunk-QF5FRM6O.js → chunk-LLUJPE5U.js} +48 -26
- package/dist/dev/chunk-LLUJPE5U.js.map +7 -0
- package/dist/dev/chunk-PMQWN2AA.js +69 -0
- package/dist/dev/chunk-PMQWN2AA.js.map +7 -0
- package/dist/dev/{chunk-CRKRRBMD.js → chunk-QLBLBAF4.js} +50 -58
- package/dist/dev/chunk-QLBLBAF4.js.map +7 -0
- package/dist/dev/data/{image-IWGLHPIX.js → image-WN3C5VZT.js} +2 -2
- package/dist/dev/index.css +989 -592
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +5517 -3452
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{ar-SA-XORAP2EK.js → ar-SA-USQAA427.js} +299 -142
- package/dist/dev/locales/ar-SA-USQAA427.js.map +7 -0
- package/dist/dev/locales/{az-AZ-NAUU3Z4Y.js → az-AZ-CVQRXULV.js} +240 -83
- package/dist/dev/locales/az-AZ-CVQRXULV.js.map +7 -0
- package/dist/dev/locales/{bg-BG-AAABLFCY.js → bg-BG-E4I2JVOQ.js} +228 -71
- package/dist/dev/locales/bg-BG-E4I2JVOQ.js.map +7 -0
- package/dist/dev/locales/{bn-BD-PM4AC5WG.js → bn-BD-O55ROP2R.js} +208 -51
- package/dist/dev/locales/bn-BD-O55ROP2R.js.map +7 -0
- package/dist/dev/locales/bn-IN-OL7OUKTP.js +743 -0
- package/dist/dev/locales/bn-IN-OL7OUKTP.js.map +7 -0
- package/dist/dev/locales/{ca-ES-YNNMFRQX.js → ca-ES-73KY52DM.js} +274 -117
- package/dist/dev/locales/ca-ES-73KY52DM.js.map +7 -0
- package/dist/dev/locales/{cs-CZ-DGZA5IKG.js → cs-CZ-2YGHPQ24.js} +228 -71
- package/dist/dev/locales/cs-CZ-2YGHPQ24.js.map +7 -0
- package/dist/dev/locales/{da-DK-N76F4QAJ.js → da-DK-OEIZIPJU.js} +297 -140
- package/dist/dev/locales/da-DK-OEIZIPJU.js.map +7 -0
- package/dist/dev/locales/de-CH-4GJTW23D.js +743 -0
- package/dist/dev/locales/de-CH-4GJTW23D.js.map +7 -0
- package/dist/dev/locales/{de-DE-DMRXZ2SZ.js → de-DE-YRH6WMM5.js} +198 -41
- package/dist/dev/locales/de-DE-YRH6WMM5.js.map +7 -0
- package/dist/dev/locales/{el-GR-HIKPLEXI.js → el-GR-W7S64QNM.js} +273 -116
- package/dist/dev/locales/el-GR-W7S64QNM.js.map +7 -0
- package/dist/dev/locales/{en-SMAPCEOQ.js → en-YSPYSBUR.js} +4 -2
- package/dist/dev/locales/{es-ES-AQYVXC32.js → es-ES-7JEN5PTZ.js} +211 -54
- package/dist/dev/locales/es-ES-7JEN5PTZ.js.map +7 -0
- package/dist/dev/locales/{eu-ES-3TOEU5DE.js → eu-ES-HQNHU6VR.js} +209 -52
- package/dist/dev/locales/eu-ES-HQNHU6VR.js.map +7 -0
- package/dist/dev/locales/{fa-IR-527GAKUP.js → fa-IR-IN6XOPA6.js} +285 -128
- package/dist/dev/locales/fa-IR-IN6XOPA6.js.map +7 -0
- package/dist/dev/locales/{fi-FI-M3WLVDFP.js → fi-FI-5BAAYJDZ.js} +239 -82
- package/dist/dev/locales/fi-FI-5BAAYJDZ.js.map +7 -0
- package/dist/dev/locales/{fr-FR-YE4VDJFI.js → fr-FR-KCXBY2R4.js} +202 -45
- package/dist/dev/locales/fr-FR-KCXBY2R4.js.map +7 -0
- package/dist/dev/locales/{gl-ES-KMXUYGUN.js → gl-ES-5OPGWS6N.js} +211 -54
- package/dist/dev/locales/gl-ES-5OPGWS6N.js.map +7 -0
- package/dist/dev/locales/he-IL-3A6ZWK6L.js +743 -0
- package/dist/dev/locales/he-IL-3A6ZWK6L.js.map +7 -0
- package/dist/dev/locales/hi-IN-HZTBH6EG.js +743 -0
- package/dist/dev/locales/hi-IN-HZTBH6EG.js.map +7 -0
- package/dist/dev/locales/{hu-HU-VIYZI3X4.js → hu-HU-52IRZEAZ.js} +237 -80
- package/dist/dev/locales/hu-HU-52IRZEAZ.js.map +7 -0
- package/dist/dev/locales/{id-ID-22TWZNLA.js → id-ID-W6HBGXTS.js} +244 -87
- package/dist/dev/locales/id-ID-W6HBGXTS.js.map +7 -0
- package/dist/dev/locales/{it-IT-MDEQ2SG3.js → it-IT-AV75ICYT.js} +201 -44
- package/dist/dev/locales/it-IT-AV75ICYT.js.map +7 -0
- package/dist/dev/locales/{ja-JP-K2DI4W6B.js → ja-JP-SS4G3ZXF.js} +246 -89
- package/dist/dev/locales/ja-JP-SS4G3ZXF.js.map +7 -0
- package/dist/dev/locales/{kaa-6BPSNM3R.js → kaa-Y5BBB3IW.js} +201 -44
- package/dist/dev/locales/kaa-Y5BBB3IW.js.map +7 -0
- package/dist/dev/locales/{kab-KAB-2S7ZURK7.js → kab-KAB-KDVZQXBT.js} +209 -52
- package/dist/dev/locales/kab-KAB-KDVZQXBT.js.map +7 -0
- package/dist/dev/locales/{kk-KZ-UJPYGRQQ.js → kk-KZ-762YODLJ.js} +174 -17
- package/dist/dev/locales/kk-KZ-762YODLJ.js.map +7 -0
- package/dist/dev/locales/{km-KH-M5T5JKUE.js → km-KH-K2TE5MIK.js} +197 -40
- package/dist/dev/locales/km-KH-K2TE5MIK.js.map +7 -0
- package/dist/dev/locales/{ko-KR-RQX37SNF.js → ko-KR-75RUMBCO.js} +217 -60
- package/dist/dev/locales/ko-KR-75RUMBCO.js.map +7 -0
- package/dist/dev/locales/{ku-TR-5XJDIERL.js → ku-TR-E6DJ6LYM.js} +197 -40
- package/dist/dev/locales/ku-TR-E6DJ6LYM.js.map +7 -0
- package/dist/dev/locales/{lt-LT-MGUBX6CA.js → lt-LT-BYS5DA45.js} +178 -21
- package/dist/dev/locales/lt-LT-BYS5DA45.js.map +7 -0
- package/dist/dev/locales/{lv-LV-MD7N5VHD.js → lv-LV-SPQ2VWX3.js} +195 -38
- package/dist/dev/locales/lv-LV-SPQ2VWX3.js.map +7 -0
- package/dist/dev/locales/{mr-IN-4XWMNGQC.js → mr-IN-2HLK6LUA.js} +203 -46
- package/dist/dev/locales/mr-IN-2HLK6LUA.js.map +7 -0
- package/dist/dev/locales/{my-MM-O4Z74GN5.js → my-MM-P2LR44WR.js} +180 -23
- package/dist/dev/locales/my-MM-P2LR44WR.js.map +7 -0
- package/dist/dev/locales/{nb-NO-BMB73KRH.js → nb-NO-7YZHFFVS.js} +219 -62
- package/dist/dev/locales/nb-NO-7YZHFFVS.js.map +7 -0
- package/dist/dev/locales/{nl-NL-F2257BLQ.js → nl-NL-TF2OVIKN.js} +217 -60
- package/dist/dev/locales/nl-NL-TF2OVIKN.js.map +7 -0
- package/dist/dev/locales/{nn-NO-NCORG7TS.js → nn-NO-2BWEL2IS.js} +200 -43
- package/dist/dev/locales/nn-NO-2BWEL2IS.js.map +7 -0
- package/dist/dev/locales/{oc-FR-ATFBDMF6.js → oc-FR-5JYIFGLE.js} +212 -55
- package/dist/dev/locales/oc-FR-5JYIFGLE.js.map +7 -0
- package/dist/dev/locales/{pa-IN-D2I375G4.js → pa-IN-KBBGER76.js} +189 -32
- package/dist/dev/locales/pa-IN-KBBGER76.js.map +7 -0
- package/dist/dev/locales/{percentages-YKFLWNK2.js → percentages-2RAYDWNS.js} +2 -2
- package/dist/dev/locales/{pl-PL-YJHOWAAW.js → pl-PL-BWZ2X734.js} +213 -56
- package/dist/dev/locales/pl-PL-BWZ2X734.js.map +7 -0
- package/dist/dev/locales/{pt-BR-APOPYZJ7.js → pt-BR-ERVIQI63.js} +236 -79
- package/dist/dev/locales/pt-BR-ERVIQI63.js.map +7 -0
- package/dist/dev/locales/pt-PT-ZNJ5NB5S.js +743 -0
- package/dist/dev/locales/pt-PT-ZNJ5NB5S.js.map +7 -0
- package/dist/dev/locales/{ro-RO-L575VRQA.js → ro-RO-UYNXGUB7.js} +202 -45
- package/dist/dev/locales/ro-RO-UYNXGUB7.js.map +7 -0
- package/dist/dev/locales/{ru-RU-BLG6HZG5.js → ru-RU-F7LPIMGQ.js} +252 -95
- package/dist/dev/locales/ru-RU-F7LPIMGQ.js.map +7 -0
- package/dist/dev/locales/si-LK-5GF2DJUH.js +743 -0
- package/dist/dev/locales/si-LK-5GF2DJUH.js.map +7 -0
- package/dist/dev/locales/{sk-SK-DY6IPO5U.js → sk-SK-H6WE7IJX.js} +199 -42
- package/dist/dev/locales/sk-SK-H6WE7IJX.js.map +7 -0
- package/dist/dev/locales/{sl-SI-5DZSRA47.js → sl-SI-4PJ6LBI7.js} +196 -39
- package/dist/dev/locales/sl-SI-4PJ6LBI7.js.map +7 -0
- package/dist/dev/locales/{sv-SE-V32YHALQ.js → sv-SE-E5VQLCRE.js} +201 -44
- package/dist/dev/locales/sv-SE-E5VQLCRE.js.map +7 -0
- package/dist/dev/locales/{ta-IN-5JRAGQAO.js → ta-IN-2YWIVLKF.js} +256 -99
- package/dist/dev/locales/ta-IN-2YWIVLKF.js.map +7 -0
- package/dist/dev/locales/{th-TH-55ACRHDJ.js → th-TH-IV7RUTDK.js} +288 -131
- package/dist/dev/locales/th-TH-IV7RUTDK.js.map +7 -0
- package/dist/dev/locales/{tr-TR-7QYBXDBO.js → tr-TR-LEQWIQH7.js} +256 -99
- package/dist/dev/locales/tr-TR-LEQWIQH7.js.map +7 -0
- package/dist/dev/locales/{uk-UA-TJS2TMRH.js → uk-UA-DWVOQPTB.js} +228 -71
- package/dist/dev/locales/uk-UA-DWVOQPTB.js.map +7 -0
- package/dist/dev/locales/{si-LK-KT7GGO6D.js → uz-UZ-CKXQ3QKG.js} +211 -54
- package/dist/dev/locales/uz-UZ-CKXQ3QKG.js.map +7 -0
- package/dist/dev/locales/vi-VN-3P6DZOGS.js +743 -0
- package/dist/dev/locales/vi-VN-3P6DZOGS.js.map +7 -0
- package/dist/dev/locales/{zh-CN-4MXUOFTH.js → zh-CN-XXVG53TQ.js} +198 -41
- package/dist/dev/locales/zh-CN-XXVG53TQ.js.map +7 -0
- package/dist/dev/locales/{zh-HK-RBTGIU3U.js → zh-HK-JCHGKEUE.js} +174 -17
- package/dist/dev/locales/zh-HK-JCHGKEUE.js.map +7 -0
- package/dist/dev/locales/{zh-TW-U5VF4CCU.js → zh-TW-ARVT7RZU.js} +203 -46
- package/dist/dev/locales/zh-TW-ARVT7RZU.js.map +7 -0
- package/dist/prod/chunk-6GUG5R24.js +4 -0
- package/dist/prod/chunk-KRJFZ5JQ.js +1 -0
- package/dist/prod/chunk-RSFMSEP5.js +12 -0
- package/dist/prod/data/{image-4SM4COIL.js → image-AQDM7CNH.js} +1 -1
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +18 -18
- package/dist/prod/locales/ar-SA-F62BVQMB.js +8 -0
- package/dist/prod/locales/az-AZ-7PGSKYOB.js +1 -0
- package/dist/prod/locales/bg-BG-AAEXMUQ4.js +5 -0
- package/dist/prod/locales/bn-BD-ONOFQYIQ.js +3 -0
- package/dist/prod/locales/bn-IN-YT3I2M3F.js +3 -0
- package/dist/prod/locales/ca-ES-GG4YH2FN.js +8 -0
- package/dist/prod/locales/cs-CZ-IS5VTBOP.js +7 -0
- package/dist/prod/locales/da-DK-VPQ2KWAY.js +2 -0
- package/dist/prod/locales/de-CH-G4Y2G6IS.js +7 -0
- package/dist/prod/locales/de-DE-RAT2LIDI.js +7 -0
- package/dist/prod/locales/el-GR-DNJB2AZO.js +7 -0
- package/dist/prod/locales/en-SFRQHD7K.js +1 -0
- package/dist/prod/locales/es-ES-IMTENLBU.js +7 -0
- package/dist/prod/locales/eu-ES-XLOS36YS.js +7 -0
- package/dist/prod/locales/fa-IR-J6Z2YOGX.js +9 -0
- package/dist/prod/locales/fi-FI-B2IQ7SBP.js +6 -0
- package/dist/prod/locales/fr-FR-N5BRDCMI.js +12 -0
- package/dist/prod/locales/gl-ES-BOYALFRN.js +6 -0
- package/dist/prod/locales/he-IL-H7M7HGY5.js +8 -0
- package/dist/prod/locales/hi-IN-7AB5CA2Q.js +3 -0
- package/dist/prod/locales/hu-HU-ZZM7UJLP.js +3 -0
- package/dist/prod/locales/id-ID-RZ7JNCXA.js +8 -0
- package/dist/prod/locales/it-IT-ZX7HN56D.js +8 -0
- package/dist/prod/locales/ja-JP-NBNBUHIR.js +7 -0
- package/dist/prod/locales/kaa-QWYSGEM7.js +1 -0
- package/dist/prod/locales/kab-KAB-Q3HBKQ5I.js +4 -0
- package/dist/prod/locales/kk-KZ-HF2NTCRX.js +1 -0
- package/dist/prod/locales/km-KH-CN6HHF5U.js +7 -0
- package/dist/prod/locales/ko-KR-SJQMUXM7.js +5 -0
- package/dist/prod/locales/ku-TR-VM4BHTPC.js +6 -0
- package/dist/prod/locales/lt-LT-QIWZQ7AG.js +3 -0
- package/dist/prod/locales/lv-LV-YQFCB4WZ.js +4 -0
- package/dist/prod/locales/mr-IN-GR2ZJPSQ.js +9 -0
- package/dist/prod/locales/my-MM-M5XJDJQ2.js +1 -0
- package/dist/prod/locales/nb-NO-2RU2YF7H.js +8 -0
- package/dist/prod/locales/nl-NL-MUHXDQFK.js +7 -0
- package/dist/prod/locales/nn-NO-72RCA552.js +4 -0
- package/dist/prod/locales/oc-FR-65ITQYQ2.js +4 -0
- package/dist/prod/locales/pa-IN-WESENMFH.js +4 -0
- package/dist/prod/locales/percentages-OEPNEGCM.js +1 -0
- package/dist/prod/locales/pl-PL-7C4NGVUA.js +12 -0
- package/dist/prod/locales/pt-BR-QH23C2IX.js +6 -0
- package/dist/prod/locales/pt-PT-O5XBATXI.js +8 -0
- package/dist/prod/locales/ro-RO-QHCHEGM5.js +12 -0
- package/dist/prod/locales/ru-RU-FUMQ2LLB.js +6 -0
- package/dist/prod/locales/si-LK-JYUINGNN.js +1 -0
- package/dist/prod/locales/sk-SK-R25O52BS.js +7 -0
- package/dist/prod/locales/sl-SI-5KPVX4FS.js +6 -0
- package/dist/prod/locales/sv-SE-MVMXV6O4.js +8 -0
- package/dist/prod/locales/ta-IN-A32FQB4D.js +6 -0
- package/dist/prod/locales/th-TH-CXMWNVBY.js +1 -0
- package/dist/prod/locales/tr-TR-YHFI3W2D.js +4 -0
- package/dist/prod/locales/uk-UA-UTJIIKT5.js +6 -0
- package/dist/prod/locales/uz-UZ-H4EGTR7D.js +1 -0
- package/dist/prod/locales/vi-VN-XBV2ESZM.js +7 -0
- package/dist/prod/locales/zh-CN-CKCJ4HAO.js +11 -0
- package/dist/prod/locales/zh-HK-ISASRRMF.js +1 -0
- package/dist/prod/locales/zh-TW-KYRW5V3R.js +9 -0
- package/dist/types/common/src/constants.d.ts +18 -15
- package/dist/types/common/src/editorInterface.d.ts +34 -0
- package/dist/types/common/src/index.d.ts +1 -0
- package/dist/types/common/src/utils.d.ts +2 -1
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/delta.d.ts +0 -1
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/dist/types/element/src/renderElement.d.ts +4 -1
- package/dist/types/element/src/resizeTest.d.ts +5 -4
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/transformHandles.d.ts +5 -4
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +21 -9
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +94 -41
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +42 -18
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +22 -10
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionExport.d.ts +63 -27
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionFrame.d.ts +28 -12
- package/dist/types/excalidraw/actions/actionGroup.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +7 -369
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionProperties.d.ts +122 -53
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +7 -3
- package/dist/types/excalidraw/actions/index.d.ts +2 -2
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +5 -1
- package/dist/types/excalidraw/clipboard.d.ts +64 -1
- package/dist/types/excalidraw/components/Actions.d.ts +17 -3
- package/dist/types/excalidraw/components/App.d.ts +25 -21
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
- package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
- package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
- package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
- package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
- package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
- package/dist/types/excalidraw/components/Popover.d.ts +2 -1
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/TextField.d.ts +1 -0
- package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +5 -0
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +13 -1
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
- package/dist/types/excalidraw/components/shapes.d.ts +129 -1
- package/dist/types/excalidraw/data/blob.d.ts +3 -7
- package/dist/types/excalidraw/data/types.d.ts +4 -1
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
- package/dist/types/excalidraw/index.d.ts +2 -3
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/dist/types/excalidraw/scene/types.d.ts +3 -3
- package/dist/types/excalidraw/shortcut.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +18 -15
- package/dist/types/math/src/segment.d.ts +1 -0
- package/package.json +5 -5
- package/dist/dev/chunk-CRKRRBMD.js.map +0 -7
- package/dist/dev/chunk-MFAYKRVR.js +0 -66
- package/dist/dev/chunk-MFAYKRVR.js.map +0 -7
- package/dist/dev/chunk-QF5FRM6O.js.map +0 -7
- package/dist/dev/locales/ar-SA-XORAP2EK.js.map +0 -7
- package/dist/dev/locales/az-AZ-NAUU3Z4Y.js.map +0 -7
- package/dist/dev/locales/bg-BG-AAABLFCY.js.map +0 -7
- package/dist/dev/locales/bn-BD-PM4AC5WG.js.map +0 -7
- package/dist/dev/locales/ca-ES-YNNMFRQX.js.map +0 -7
- package/dist/dev/locales/cs-CZ-DGZA5IKG.js.map +0 -7
- package/dist/dev/locales/da-DK-N76F4QAJ.js.map +0 -7
- package/dist/dev/locales/de-DE-DMRXZ2SZ.js.map +0 -7
- package/dist/dev/locales/el-GR-HIKPLEXI.js.map +0 -7
- package/dist/dev/locales/es-ES-AQYVXC32.js.map +0 -7
- package/dist/dev/locales/eu-ES-3TOEU5DE.js.map +0 -7
- package/dist/dev/locales/fa-IR-527GAKUP.js.map +0 -7
- package/dist/dev/locales/fi-FI-M3WLVDFP.js.map +0 -7
- package/dist/dev/locales/fr-FR-YE4VDJFI.js.map +0 -7
- package/dist/dev/locales/gl-ES-KMXUYGUN.js.map +0 -7
- package/dist/dev/locales/he-IL-4MU5N22B.js +0 -586
- package/dist/dev/locales/he-IL-4MU5N22B.js.map +0 -7
- package/dist/dev/locales/hi-IN-ZHZNZWFC.js +0 -586
- package/dist/dev/locales/hi-IN-ZHZNZWFC.js.map +0 -7
- package/dist/dev/locales/hu-HU-VIYZI3X4.js.map +0 -7
- package/dist/dev/locales/id-ID-22TWZNLA.js.map +0 -7
- package/dist/dev/locales/it-IT-MDEQ2SG3.js.map +0 -7
- package/dist/dev/locales/ja-JP-K2DI4W6B.js.map +0 -7
- package/dist/dev/locales/kaa-6BPSNM3R.js.map +0 -7
- package/dist/dev/locales/kab-KAB-2S7ZURK7.js.map +0 -7
- package/dist/dev/locales/kk-KZ-UJPYGRQQ.js.map +0 -7
- package/dist/dev/locales/km-KH-M5T5JKUE.js.map +0 -7
- package/dist/dev/locales/ko-KR-RQX37SNF.js.map +0 -7
- package/dist/dev/locales/ku-TR-5XJDIERL.js.map +0 -7
- package/dist/dev/locales/lt-LT-MGUBX6CA.js.map +0 -7
- package/dist/dev/locales/lv-LV-MD7N5VHD.js.map +0 -7
- package/dist/dev/locales/mr-IN-4XWMNGQC.js.map +0 -7
- package/dist/dev/locales/my-MM-O4Z74GN5.js.map +0 -7
- package/dist/dev/locales/nb-NO-BMB73KRH.js.map +0 -7
- package/dist/dev/locales/nl-NL-F2257BLQ.js.map +0 -7
- package/dist/dev/locales/nn-NO-NCORG7TS.js.map +0 -7
- package/dist/dev/locales/oc-FR-ATFBDMF6.js.map +0 -7
- package/dist/dev/locales/pa-IN-D2I375G4.js.map +0 -7
- package/dist/dev/locales/pl-PL-YJHOWAAW.js.map +0 -7
- package/dist/dev/locales/pt-BR-APOPYZJ7.js.map +0 -7
- package/dist/dev/locales/pt-PT-W56WCN7P.js +0 -586
- package/dist/dev/locales/pt-PT-W56WCN7P.js.map +0 -7
- package/dist/dev/locales/ro-RO-L575VRQA.js.map +0 -7
- package/dist/dev/locales/ru-RU-BLG6HZG5.js.map +0 -7
- package/dist/dev/locales/si-LK-KT7GGO6D.js.map +0 -7
- package/dist/dev/locales/sk-SK-DY6IPO5U.js.map +0 -7
- package/dist/dev/locales/sl-SI-5DZSRA47.js.map +0 -7
- package/dist/dev/locales/sv-SE-V32YHALQ.js.map +0 -7
- package/dist/dev/locales/ta-IN-5JRAGQAO.js.map +0 -7
- package/dist/dev/locales/th-TH-55ACRHDJ.js.map +0 -7
- package/dist/dev/locales/tr-TR-7QYBXDBO.js.map +0 -7
- package/dist/dev/locales/uk-UA-TJS2TMRH.js.map +0 -7
- package/dist/dev/locales/vi-VN-Y5CQ2EKQ.js +0 -586
- package/dist/dev/locales/vi-VN-Y5CQ2EKQ.js.map +0 -7
- package/dist/dev/locales/zh-CN-4MXUOFTH.js.map +0 -7
- package/dist/dev/locales/zh-HK-RBTGIU3U.js.map +0 -7
- package/dist/dev/locales/zh-TW-U5VF4CCU.js.map +0 -7
- package/dist/prod/chunk-HHV2PJKY.js +0 -4
- package/dist/prod/chunk-I4UNSFV6.js +0 -12
- package/dist/prod/chunk-Z3N5DIM6.js +0 -1
- package/dist/prod/locales/ar-SA-G6X2FPQ2.js +0 -10
- package/dist/prod/locales/az-AZ-76LH7QW2.js +0 -1
- package/dist/prod/locales/bg-BG-XCXSNQG7.js +0 -5
- package/dist/prod/locales/bn-BD-2XOGV67Q.js +0 -5
- package/dist/prod/locales/ca-ES-6MX7JW3Y.js +0 -8
- package/dist/prod/locales/cs-CZ-2BRQDIVT.js +0 -11
- package/dist/prod/locales/da-DK-5WZEPLOC.js +0 -5
- package/dist/prod/locales/de-DE-XR44H4JA.js +0 -8
- package/dist/prod/locales/el-GR-BZB4AONW.js +0 -10
- package/dist/prod/locales/en-TYY6KWIJ.js +0 -1
- package/dist/prod/locales/es-ES-U4NZUMDT.js +0 -9
- package/dist/prod/locales/eu-ES-A7QVB2H4.js +0 -11
- package/dist/prod/locales/fa-IR-HGAKTJCU.js +0 -8
- package/dist/prod/locales/fi-FI-Z5N7JZ37.js +0 -6
- package/dist/prod/locales/fr-FR-RHASNOE6.js +0 -9
- package/dist/prod/locales/gl-ES-HMX3MZ6V.js +0 -10
- package/dist/prod/locales/he-IL-6SHJWFNN.js +0 -10
- package/dist/prod/locales/hi-IN-IWLTKZ5I.js +0 -4
- package/dist/prod/locales/hu-HU-A5ZG7DT2.js +0 -7
- package/dist/prod/locales/id-ID-SAP4L64H.js +0 -10
- package/dist/prod/locales/it-IT-JPQ66NNP.js +0 -11
- package/dist/prod/locales/ja-JP-DBVTYXUO.js +0 -8
- package/dist/prod/locales/kaa-6HZHGXH3.js +0 -1
- package/dist/prod/locales/kab-KAB-ZGHBKWFO.js +0 -8
- package/dist/prod/locales/kk-KZ-P5N5QNE5.js +0 -1
- package/dist/prod/locales/km-KH-HSX4SM5Z.js +0 -11
- package/dist/prod/locales/ko-KR-MTYHY66A.js +0 -9
- package/dist/prod/locales/ku-TR-6OUDTVRD.js +0 -9
- package/dist/prod/locales/lt-LT-XHIRWOB4.js +0 -3
- package/dist/prod/locales/lv-LV-5QDEKY6T.js +0 -7
- package/dist/prod/locales/mr-IN-CRQNXWMA.js +0 -13
- package/dist/prod/locales/my-MM-5M5IBNSE.js +0 -1
- package/dist/prod/locales/nb-NO-T6EIAALU.js +0 -10
- package/dist/prod/locales/nl-NL-IS3SIHDZ.js +0 -8
- package/dist/prod/locales/nn-NO-6E72VCQL.js +0 -8
- package/dist/prod/locales/oc-FR-POXYY2M6.js +0 -8
- package/dist/prod/locales/pa-IN-N4M65BXN.js +0 -4
- package/dist/prod/locales/percentages-BXMCSKIN.js +0 -1
- package/dist/prod/locales/pl-PL-T2D74RX3.js +0 -9
- package/dist/prod/locales/pt-BR-5N22H2LF.js +0 -9
- package/dist/prod/locales/pt-PT-UZXXM6DQ.js +0 -9
- package/dist/prod/locales/ro-RO-JPDTUUEW.js +0 -11
- package/dist/prod/locales/ru-RU-B4JR7IUQ.js +0 -9
- package/dist/prod/locales/si-LK-N5RQ5JYF.js +0 -1
- package/dist/prod/locales/sk-SK-C5VTKIMK.js +0 -6
- package/dist/prod/locales/sl-SI-NN7IZMDC.js +0 -6
- package/dist/prod/locales/sv-SE-XGPEYMSR.js +0 -10
- package/dist/prod/locales/ta-IN-2NMHFXQM.js +0 -9
- package/dist/prod/locales/th-TH-HPSO5L25.js +0 -2
- package/dist/prod/locales/tr-TR-DEFEU3FU.js +0 -7
- package/dist/prod/locales/uk-UA-QMV73CPH.js +0 -6
- package/dist/prod/locales/vi-VN-M7AON7JQ.js +0 -5
- package/dist/prod/locales/zh-CN-LNUGB5OW.js +0 -10
- package/dist/prod/locales/zh-HK-E62DVLB3.js +0 -1
- package/dist/prod/locales/zh-TW-RAJ6MFWO.js +0 -9
- /package/dist/dev/data/{image-IWGLHPIX.js.map → image-WN3C5VZT.js.map} +0 -0
- /package/dist/dev/locales/{en-SMAPCEOQ.js.map → en-YSPYSBUR.js.map} +0 -0
- /package/dist/dev/locales/{percentages-YKFLWNK2.js.map → percentages-2RAYDWNS.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import{$ as c1,A as um,B as qf,C as Jf,D as Qf,E as Pl,F as Wi,G as Al,H as Dl,I as e1,J as t1,K as Vi,L as o1,M as r1,N as n1,O as i1,P as _l,Q as fn,R as a1,S as KI,T as hm,U as ZI,V as bn,W as Xi,Y as l1,_ as s1,a as Kf,aa as Rl,b as Nr,ba as d1,c as uo,ca as Nl,d as Zf,da as gm,e as Ee,ea as Bl,f as $f,fa as m1,g as j,ga as fm,h as kl,ha as ko,i as Ko,ia as p1,j as lm,ja as bm,k as sm,ka as u1,l as un,la as h1,m as cm,ma as Fl,n as hn,na as xm,o as jf,oa as g1,p as dm,pa as f1,q as Zo,qa as b1,r as $o,ra as x1,s as bt,t as jt,u as gn,v as Ml,w as mm,x as Yi,y as Ll,z as pm}from"./chunk-HHV2PJKY.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as am}from"./chunk-I4UNSFV6.js";import{c as Xf}from"./chunk-Z3N5DIM6.js";import{b as Wf,c as Vf,d as I}from"./chunk-SRAX5OIU.js";import _G,{useEffect as RG}from"react";import{DEFAULT_UI_OPTIONS as WI,isShallowEqual as NG}from"@excalidraw/common";import vT from"clsx";import gz from"lodash.throttle";import So,{useContext as _r}from"react";import{flushSync as Bi}from"react-dom";import fz from"roughjs/bin/rough";import{nanoid as bz}from"nanoid";import{clamp as TT,pointFrom as ne,pointDistance as nn,vector as IT,pointRotateRads as jg,vectorScale as xz,vectorFromPoint as qg,vectorSubtract as CT,vectorDot as ST,vectorNormalize as kT}from"@excalidraw/math";import{COLOR_PALETTE as Ez,CODES as MT,shouldResizeFromCenter as LT,shouldMaintainAspectRatio as dl,shouldRotateWithDiscreteAngle as Jg,isArrowKey as Xd,KEYS as Y,APP_NAME as yz,CURSOR_TYPE as De,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as wz,DEFAULT_VERTICAL_ALIGN as PT,DRAGGING_THRESHOLD as vz,ELEMENT_SHIFT_TRANSLATE_AMOUNT as Tz,ELEMENT_TRANSLATE_AMOUNT as AT,EVENT as ee,FRAME_STYLE as Mr,IMAGE_MIME_TYPES as Iz,IMAGE_RENDER_TIMEOUT as Cz,isBrave as Sz,LINE_CONFIRM_THRESHOLD as Qg,MAX_ALLOWED_FILE_BYTES as DT,MIME_TYPES as Lr,MQ_MAX_HEIGHT_LANDSCAPE as kz,MQ_MAX_WIDTH_LANDSCAPE as Mz,MQ_MAX_WIDTH_PORTRAIT as Lz,MQ_RIGHT_SIDEBAR_MIN_WIDTH as Pz,POINTER_BUTTON as an,ROUNDNESS as Kd,SCROLL_TIMEOUT as Az,TAP_TWICE_TIMEOUT as Dz,TEXT_TO_CENTER_SNAP_THRESHOLD as _z,THEME as Zd,THEME_FILTER as Rz,TOUCH_CTX_MENU_TIMEOUT as Nz,VERTICAL_ALIGN as Bz,YOUTUBE_STATES as $d,ZOOM_STEP as Fz,POINTER_EVENTS as Fi,TOOL_TYPE as Co,isIOS as Oz,supportsResizeObserver as _T,DEFAULT_COLLISION_THRESHOLD as RT,DEFAULT_TEXT_ALIGN as zz,ARROW_TYPE as Pr,DEFAULT_REDUCED_GLOBAL_ALPHA as Hz,isSafari as Gz,isLocalLink as Uz,normalizeLink as ef,toValidURL as Yz,getGridPoint as nt,getLineHeight as NT,debounce as BT,distance as Oi,getFontString as tf,getNearestScrollableContainer as Wz,isInputLike as FT,isToolIcon as Vz,isWritableElement as ml,sceneCoordsToViewportCoords as jd,tupleToCoors as of,viewportCoordsToSceneCoords as Fe,wrapEvent as Xz,updateObject as rf,updateActiveTool as Vo,getShortcutKey as Kz,isTransparent as Zz,easeToValuesRAF as $z,muteFSAbortError as jz,isTestEnv as Cf,isDevEnv as vI,easeOut as qz,updateStable as pl,addEventListener as _e,normalizeEOL as Jz,getDateTime as OT,isShallowEqual as Qz,arrayToMap as zT,randomInteger as eH,CLASSES as tH,Emitter as ln,MINIMUM_ARROW_SIZE as HT}from"@excalidraw/common";import{getObservedAppState as oH,getCommonBounds as zi,maybeSuggestBindingsForLinearElementAtCoords as GT,getElementAbsoluteCoords as UT,bindOrUnbindLinearElements as YT,fixBindingsAfterDeletion as rH,getHoveredElementForBinding as nf,isBindingEnabled as af,shouldEnableBindingForPointerEvent as nH,updateBoundElements as lf,getSuggestedBindingsForArrows as sf,LinearElementEditor as Se,newElementWith as sn,newFrameElement as iH,newFreeDrawElement as aH,newEmbeddableElement as WT,newMagicFrameElement as VT,newIframeElement as lH,newArrowElement as sH,newElement as cH,newImageElement as dH,newLinearElement as mH,newTextElement as XT,refreshTextDimensions as pH,deepCopyElement as KT,duplicateElements as ZT,hasBoundTextElement as $T,isArrowElement as cf,isBindingElement as df,isBindingElementType as jT,isBoundToContainer as mf,isFrameLikeElement as Kt,isImageElement as cn,isEmbeddableElement as Ar,isInitializedImageElement as ul,isLinearElement as Zt,isLinearElementType as uH,isUsingAdaptiveRadius as hH,isIframeElement as Hi,isIframeLikeElement as hl,isMagicFrameElement as pf,isTextBindableContainer as qT,isElbowArrow as We,isFlowchartNodeElement as gH,isBindableElement as fH,isTextElement as co,getLockedLinearCursorAlignSize as JT,getNormalizedDimensions as bH,isElementCompletelyInViewport as uf,isElementInViewport as QT,isInvisiblySmallElement as eI,getCornerRadius as xH,isPathALoop as tI,createSrcDoc as oI,embeddableURLValidator as hf,maybeParseEmbedSrc as EH,getEmbedLink as qd,getInitializedImageElements as yH,normalizeSVG as rI,updateImageCache as wH,getBoundTextElement as gf,getContainerCenter as ff,getContainerElement as nI,isValidTextContainer as vH,redrawTextBoundingBox as TH,shouldShowBoundingBox as IH,getFrameChildren as iI,isCursorInFrame as aI,addElementsToFrame as bf,replaceAllElementsInFrame as CH,removeElementsFromFrame as SH,getElementsInResizingFrame as xf,getElementsInNewFrame as kH,getContainingFrame as Ef,elementOverlapsWithFrame as MH,updateFrameMembershipOfSelectedElements as lI,isElementInFrame as sI,getFrameLikeTitle as LH,getElementsOverlappingFrame as PH,filterElementsEligibleAsFrameChildren as AH,hitElementBoundText as DH,hitElementBoundingBoxOnly as _H,hitElementItself as gl,getVisibleSceneBounds as RH,FlowChartCreator as NH,FlowChartNavigator as BH,getLinkDirectionFromKey as cI,cropElement as FH,wrapText as OH,isElementLink as yf,parseElementLinkFromURL as zH,isMeasureTextSupported as HH,normalizeText as GH,measureText as dI,getLineHeightInPx as UH,getApproxMinLineWidth as YH,getApproxMinLineHeight as WH,getMinTextElementWidth as VH,ShapeCache as fl,getRenderOpacity as XH,editGroupForSelectedElement as KH,getElementsInGroup as bl,getSelectedGroupIdForElement as ZH,getSelectedGroupIds as $H,isElementInGroup as mI,isSelectedViaGroup as jH,selectGroupsForSelectedElements as mo,syncInvalidIndices as TI,syncMovedIndices as pI,excludeElementsInFramesFromSelection as qH,getSelectionStateForElements as JH,makeNextSelectedElementIds as ye,getResizeOffsetXY as QH,getResizeArrowDirection as eG,transformElements as tG,getCursorForResizingElement as uI,getElementWithTransformHandleType as hI,getTransformHandleTypeFromCoords as gI,dragNewElement as fI,dragSelectedElements as oG,getDragOffsetXY as rG,isNonDeletedElement as bI,Scene as xI,Store as nG,CaptureUpdateAction as mt,hitElementBoundingBox as iG,isLineElement as wf,isSimpleArrow as aG,StoreDelta as EI}from"@excalidraw/element";import{KEYS as Wm,updateActiveTool as sC}from"@excalidraw/common";import{getNonDeletedElements as Vm}from"@excalidraw/element";import{fixBindingsAfterDeletion as cC}from"@excalidraw/element";import{LinearElementEditor as mb}from"@excalidraw/element";import{newElementWith as ms}from"@excalidraw/element";import{getContainerElement as pb}from"@excalidraw/element";import{isBoundToContainer as cs,isElbowArrow as dC,isFrameLikeElement as mC}from"@excalidraw/element";import{getFrameChildren as pC}from"@excalidraw/element";import{getElementsInGroup as Xm,selectGroupsForSelectedElements as uC}from"@excalidraw/element";import{CaptureUpdateAction as ds}from"@excalidraw/element";import{isDevEnv as JI}from"@excalidraw/common";import{atom as me,createStore as $I}from"jotai";import{createIsolation as jI}from"jotai-scope";var E1=jI();var{useAtom:ie,useSetAtom:jo,useAtomValue:Ol,useStore:GG}=E1,y1=E1.Provider,ze=$I();var qI=Wf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-TYY6KWIJ.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var QI=85,ho={code:"en",label:"English"},En=[ho,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>Xf[e.code]>=QI).sort((e,o)=>e.label>o.label?1:-1)],Hl="__test__";JI()&&En.unshift({code:Hl,label:"test language"},{code:`${Hl}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var xn=ho,zl={},Gl=async e=>{if(xn=e,document.documentElement.dir=xn.rtl?"rtl":"ltr",document.documentElement.lang=xn.code,e.code.startsWith(Hl))zl={};else try{zl=await qI(`./locales/${xn.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),zl=am}ze.set(v1,e.code)},Mo=()=>xn,w1=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},g=(e,o,t)=>{if(xn.code.startsWith(Hl))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=w1(zl,r)||w1(am,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},v1=me(ho.code),Oe=()=>{let e=Ol(v1);return{t:g,langCode:e}};import eC from"clsx";import tC from"open-color";import et from"react";import{THEME as oC}from"@excalidraw/common";import{Fragment as be,jsx as h,jsxs as D}from"react/jsx-runtime";var qt=e=>"var(--icon-fill-color)",T1=e=>e===oC.LIGHT?tC.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:eC({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},z={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},te={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},rU=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),z),yn=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),I1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),C1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),z),S1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),Em=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),z),Br=M(D("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),te),wn=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),te),k1=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),M1=M(D(be,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),L1=M(D(be,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),P1=M(D(be,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),nU=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),A1=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Ki=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Ul=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),Yl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),z),Wl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),z),D1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),Vl=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),te),_1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),qo=M(D("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),te),vn=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),R1=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),te),N1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),ym=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),te),wm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),te),B1=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),z),Mt=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),te),vm=M(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),te),Zi=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),te),$i=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),te),ji=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...te,strokeWidth:1.5}),Xl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),Fr=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),te),Tn=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),F1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),Tm=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),te),Kl=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),te),O1=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),te),z1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),H1=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),qi=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),te),G1=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),U1=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),In=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),te),iU=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),Y1=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Zl=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),h("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),z),W1=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),z),$l=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),z),V1=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),aU=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),lU=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),X1=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),sU=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Im=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),te),Cm=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),te),K1=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),Z1=M(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),te),cU=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),dU=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),mU=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),z),pU=M(D(be,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),uU=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),$1=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),j1=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Sm=M(j1,z),km=M(j1,{...z,style:{transform:"rotate(180deg)"}}),Mm=M($1,z),Lm=M($1,{...z,style:{transform:"rotate(180deg)"}}),Pm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Am=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Dm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),_m=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),q1=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),J1=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Rm=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),te),Nm=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),te),jl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),hU=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),gU=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Bt=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),fU=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),bU=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),xU=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Bm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:qt(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:qt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:qt(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:qt(e),strokeWidth:"2"}),D("g",{fill:T1(e),stroke:qt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Fm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:qt(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:qt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:qt(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:qt(e),strokeWidth:"2"}),D("g",{fill:T1(e),stroke:qt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Q1=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),te),e0=M(D(be,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),te),t0=M(D(be,{children:[D("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),o0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...te,fill:"currentColor"}),Om=M(h(be,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),r0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),te),n0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),te),EU=et.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:qt(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),i0=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),z),a0=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),z),l0=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),te),s0=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),te),c0=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),te),d0=M(D("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),te),m0=M(D("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),p0=M(D("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),z),u0=et.memo(({flip:e=!1})=>M(D("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),h0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),g0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),f0=et.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),b0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),x0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),E0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),y0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),w0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),v0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),T0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),I0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),C0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),S0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),k0=M(h(be,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),Or=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),z),M0=M(h(be,{children:D("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),z),Ji=M(h(be,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),te),ql=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),L0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),P0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),A0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),D0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),_0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),R0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),Jl=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),z),N0=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),yU=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Ql=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),z),zm=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),z),Cn=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),B0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),z),F0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),wU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),z),vU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),z),O0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),z),z0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),z),H0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),z),G0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),z),zr=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),z),es=M(h("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),Sn=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),te),Qi=M(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),ts=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),TU=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),IU=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),z),U0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),kn=M(D("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),z),Y0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),z),W0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),V0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),Lt=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),z),X0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),K0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),Z0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),ea=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),$0=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),z),j0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),z),q0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),J0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),Hm=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),z),os=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),Q0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),eb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),z),tb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),z),ob=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),rb=M(D("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...z,strokeWidth:1.5}),CU=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),z),nb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),z),ib=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),z),ab=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),rs=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),z),ns=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),z),is=M(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),as=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),z),lb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),sb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),Gm=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),ls=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),z);import cb from"clsx";import Ym,{useEffect as iC,useRef as db,useState as aC}from"react";import{isPromiseLike as lC}from"@excalidraw/common";import rC from"react";import{jsx as Um}from"react/jsx-runtime";var nC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(rC.useRef(Date.now()).current%1600);return Um("div",{className:`Spinner ${r}`,children:Um("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Um("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},tt=nC;import{jsx as ta,jsxs as oa}from"react/jsx-runtime";var K=Ym.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=He(),a=Ym.useRef(null);Ym.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,d]=aC(!1),m=db(!0),c=async u=>{let f="onClick"in r&&r.onClick?.(u);if(lC(f))try{d(!0),await f}catch(b){if(b instanceof hn)console.warn(b);else throw b}finally{m.current&&d(!1)}};iC(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=db(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return oa("button",{className:cb("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type==="icon"}),style:r.style,"data-testid":r["data-testid"],hidden:r.hidden,title:r.title,"aria-label":r["aria-label"],type:u,onClick:c,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&oa("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&ta("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&ta(tt,{})]}),r.showAriaLabel&&oa("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&ta(tt,{})]}),r.children]})}return oa("label",{className:cb("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ta("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),oa("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&ta("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});K.displayName="ToolButton";var ss=[],B=e=>(ss=ss.concat(e),e);import{jsx as gC}from"react/jsx-runtime";var hC=(e,o,t)=>{let r=new Set(j(e.filter(m=>mC(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let c=pC(e,m);for(let p of c)if(!a.has(p.id)){if(cs(p)){let u=pb(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let c=cs(m)?pb(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):c?.frameId&&r.has(c?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&dC(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),ms(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,cs(m)||(n[m.id]=!0),ms(m,{frameId:null})):cs(m)&&o.selectedElementIds[m.containerId]?ms(m,{isDeleted:!0}):m}),d=o.editingGroupId;if(l&&o.editingGroupId){let m=Xm(s,o.editingGroupId).filter(c=>!c.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{d=null,m[0]&&(n[m[0].id]=!0);let c=m[0];if(c){let p=c.groupIds.findIndex(f=>f===o.editingGroupId),u=c.groupIds[p+1];if(u){let f=Xm(s,u).filter(b=>!b.isDeleted);f.length>1&&(d=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...uC({selectedElementIds:n,editingGroupId:d},s,o,null)}}},ub=(e,o)=>{if(e.editingGroupId){let t=Xm(Vm(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},ra=B({name:"deleteSelectedElements",label:"labels.delete",icon:Mt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:d}=o.selectedLinearElement,m=r.scene.getNonDeletedElementsMap(),c=mb.getElement(a,m);if(!c||l==null)return!1;if(l.length>=c.points.length){let u=e.map(b=>b.id===c.id?ms(b,{isDeleted:!0}):b),f=ub(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:ds.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(c.points.length-1)?null:d};return mb.deletePoints(c,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ds.IMMEDIATELY}}let{elements:n,appState:i}=hC(e,o,r);return cC(n,n.filter(a=>a.isDeleted)),i=ub(i,n),{elements:n,appState:{...i,activeTool:sC(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ee(Vm(e),o)?ds.IMMEDIATELY:ds.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===Wm.BACKSPACE||e.key===Wm.DELETE)&&!e[Wm.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>gC(K,{type:"button",icon:Mt,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:Ee(Vm(e),o)})});import{KEYS as Mn,CODES as Ln,getShortcutKey as Pn,isDarwin as ps}from"@excalidraw/common";import{moveOneLeft as fC,moveOneRight as bC,moveAllLeft as xC,moveAllRight as EC}from"@excalidraw/element";import{CaptureUpdateAction as us}from"@excalidraw/element";import{jsx as hs}from"react/jsx-runtime";var Km=B({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:km,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:fC(e,o,r.scene),appState:o,captureUpdate:us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Mn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ln.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Pn("CtrlOrCmd+[")}`,children:km})}),Zm=B({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Sm,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:bC(e,o,r.scene),appState:o,captureUpdate:us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Mn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ln.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Pn("CtrlOrCmd+]")}`,children:Sm})}),$m=B({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Lm,trackEvent:{category:"element"},perform:(e,o)=>({elements:xC(e,o),appState:o,captureUpdate:us.IMMEDIATELY}),keyTest:e=>ps?e[Mn.CTRL_OR_CMD]&&e.altKey&&e.code===Ln.BRACKET_LEFT:e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ln.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${ps?Pn("CtrlOrCmd+Alt+["):Pn("CtrlOrCmd+Shift+[")}`,children:Lm})}),jm=B({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Mm,trackEvent:{category:"element"},perform:(e,o)=>({elements:EC(e,o),appState:o,captureUpdate:us.IMMEDIATELY}),keyTest:e=>ps?e[Mn.CTRL_OR_CMD]&&e.altKey&&e.code===Ln.BRACKET_RIGHT:e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ln.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${ps?Pn("CtrlOrCmd+Alt+]"):Pn("CtrlOrCmd+Shift+]")}`,children:Mm})});import{getNonDeletedElements as yC}from"@excalidraw/element";import{LinearElementEditor as wC}from"@excalidraw/element";import{isLinearElement as vC,isTextElement as TC}from"@excalidraw/element";import{arrayToMap as IC,KEYS as hb}from"@excalidraw/common";import{selectGroupsForSelectedElements as CC}from"@excalidraw/element";import{CaptureUpdateAction as SC}from"@excalidraw/element";var qm=B({name:"selectAll",label:"labels.selectAll",icon:$0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(TC(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...CC({editingGroupId:null,selectedElementIds:n},yC(e),o,r),selectedLinearElement:Object.keys(n).length===1&&vC(e[0])?new wC(e[0],IC(e)):null},captureUpdate:SC.IMMEDIATELY}},keyTest:e=>e[hb.CTRL_OR_CMD]&&e.key===hb.A});import{DEFAULT_GRID_SIZE as gb,KEYS as fb,arrayToMap as bb,getShortcutKey as kC}from"@excalidraw/common";import{getNonDeletedElements as xb}from"@excalidraw/element";import{LinearElementEditor as MC}from"@excalidraw/element";import{getSelectedElements as LC,getSelectionStateForElements as PC}from"@excalidraw/element";import{syncMovedIndices as AC}from"@excalidraw/element";import{duplicateElements as DC}from"@excalidraw/element";import{CaptureUpdateAction as Eb}from"@excalidraw/element";import{jsx as _C}from"react/jsx-runtime";var Jm=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Zi,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=MC.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:Eb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=DC({type:"in-place",elements:e,idsOfElementsToDuplicate:bb(LC(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+gb/2,y:a.y+gb/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:AC(i,bb(n)),appState:{...o,...PC(n,xb(i),o)},captureUpdate:Eb.IMMEDIATELY}},keyTest:e=>e[fb.CTRL_OR_CMD]&&e.key===fb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>_C(K,{type:"button",icon:Zi,title:`${g("labels.duplicateSelection")} \u2014 ${kC("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:Ee(xb(e),o)})});import{pointFrom as R6}from"@excalidraw/math";import{useEffect as yp,useMemo as N6,useRef as wp,useState as B6}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as F6,DEFAULT_ELEMENT_BACKGROUND_PICKS as O6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as z6,DEFAULT_ELEMENT_STROKE_PICKS as H6,ARROW_TYPE as Po,DEFAULT_FONT_FAMILY as G6,DEFAULT_FONT_SIZE as U6,FONT_FAMILY as Y6,ROUNDNESS as As,STROKE_WIDTH as vp,VERTICAL_ALIGN as Ps,KEYS as Gn,randomInteger as W6,arrayToMap as Cp,getFontFamilyString as V6,getShortcutKey as X6,getLineHeight as K6,isTransparent as Z6,reduceToCommonValue as $6}from"@excalidraw/common";import{canBecomePolygon as j6,getNonDeletedElements as ax}from"@excalidraw/element";import{bindLinearElement as ox,calculateFixedPointForElbowArrowBinding as rx,updateBoundElements as q6}from"@excalidraw/element";import{LinearElementEditor as Tp}from"@excalidraw/element";import{newElementWith as Ke}from"@excalidraw/element";import{getBoundTextElement as ir,redrawTextBoundingBox as ua}from"@excalidraw/element";import{isArrowElement as Ds,isBoundToContainer as J6,isElbowArrow as lx,isLinearElement as Ip,isLineElement as nx,isTextElement as xt,isUsingAdaptiveRadius as Q6}from"@excalidraw/element";import{hasStrokeColor as e4}from"@excalidraw/element";import{updateElbowArrowPoints as t4,CaptureUpdateAction as Ze,toggleLinePolygonState as o4}from"@excalidraw/element";import{isDevEnv as RC}from"@excalidraw/common";var NC=new Set(["command_palette","export"]),re=(e,o,t,r)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!NC.has(e)||RC())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import zC from"clsx";import BC from"clsx";import{forwardRef as FC}from"react";import{jsx as OC}from"react/jsx-runtime";var An=FC((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return OC("button",{type:"button",ref:o,title:t,"data-testid":n,className:BC(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as GC,jsx as Qm,jsxs as HC}from"react/jsx-runtime";var Ft=e=>Qm(GC,{children:e.options.map(o=>e.type==="button"?Qm(An,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):HC("label",{className:zC({active:e.value===o.value}),title:o.text,children:[Qm("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as ws from"@radix-ui/react-popover";import HS from"clsx";import{useRef as GS}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as US,COLOR_PALETTE as Ob,isTransparent as YS}from"@excalidraw/common";import{jsx as UC}from"react/jsx-runtime";var gs=()=>UC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as KC,useRef as ZC}from"react";import{createPortal as $C}from"react-dom";import{EVENT as Qo,KEYS as jC,rgbToHex as qC}from"@excalidraw/common";import yb from"react";var ep=yb.createContext(null),ge=()=>yb.useContext(ep);import{useState as YC,useLayoutEffect as wb}from"react";import{THEME as WC}from"@excalidraw/common";var fs=e=>{let[o,t]=YC(null),r=se(),{theme:n}=ge(),{container:i}=He();return wb(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===WC.DARK))},[o,n,r.editor.isMobile,e?.className]),wb(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as VC}from"react";import{EVENT as bs}from"@excalidraw/common";function Dn(e,o,t){VC(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(bs.POINTER_DOWN,r),document.addEventListener(bs.TOUCH_START,r),()=>{document.removeEventListener(bs.POINTER_DOWN,r),document.removeEventListener(bs.TOUCH_START,r)}},[e,o,t])}import{useRef as XC}from"react";var Jo=e=>{let o=XC(e);return Object.assign(o.current,e),o.current};import{jsx as JC}from"react/jsx-runtime";var er=me(null),vb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=fs({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ge(),a=tr(),l=Re(),s=j(a,i),d=Jo({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=He();KC(()=>{let p=c.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:L})=>{let k=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return qC(k[0],k[1],k[2])},x=({clientX:S,clientY:L,altKey:k})=>{p.style.top=`${L+20}px`,p.style.left=`${S+20}px`;let A=b({clientX:S,clientY:L});u&&d.onChange(r,A,d.selectedElements,{altKey:k}),p.style.background=A},w=()=>{d.onCancel()},E=(S,L)=>{d.onSelect(S,L)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===jC.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:d.app.lastViewportPosition.x,clientY:d.app.lastViewportPosition.y,altKey:!1}),n.addEventListener(Qo.KEYDOWN,C),n.addEventListener(Qo.POINTER_DOWN,y),n.addEventListener(Qo.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(Qo.BLUR,w),()=>{u=!1,n.removeEventListener(Qo.KEYDOWN,C),n.removeEventListener(Qo.POINTER_DOWN,y),n.removeEventListener(Qo.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(Qo.BLUR,w)}},[d,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let c=ZC(null);return Dn(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?$C(JC("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),n):null};import*as _n from"@radix-ui/react-popover";import oS from"clsx";import rS from"react";import{isInteractive as nS}from"@excalidraw/common";import QC from"react";import eS from"clsx";import{jsx as tS}from"react/jsx-runtime";var Xe=QC.forwardRef(({children:e,padding:o,className:t,style:r},n)=>tS("div",{className:eS("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as tp,jsxs as iS}from"react/jsx-runtime";var xs=rS.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},d)=>{let m=se();return tp(_n.Portal,{container:o,children:iS(_n.Content,{ref:d,className:oS("focus-visible-none",e),"data-prevent-outside-click":!0,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-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:c=>{c.stopPropagation(),c.preventDefault(),o&&!nS(document.activeElement)&&o.focus(),n()},children:[tp(Xe,{padding:3,style:r,children:t}),tp(_n.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import lS from"clsx";import{useCallback as sS,useEffect as rp,useRef as Cb,useState as cS}from"react";import{KEYS as np,getShortcutKey as dS}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as aS}from"@excalidraw/common";var or=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},na=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),op=({color:e,palette:o})=>!Object.values(o).flat().includes(e),Ib=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return op({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,aS)},Ot=me(null),Tb=(e,o,t)=>(e*299+o*587+t*114)/1e3,Rn=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),d=parseInt(l[1]),m=parseInt(l[2]);return Tb(s,d,m)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return Tb(t,r,n)<o};import{Fragment as mS,jsx as Es,jsxs as Sb}from"react/jsx-runtime";var kb=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=se(),[a,l]=cS(e),[s,d]=ie(Ot);rp(()=>{l(e)},[e]);let m=sS(b=>{let x=b.toLowerCase(),w=Mb(x);w&&o(w),l(x)},[o]),c=Cb(null),p=Cb(null);rp(()=>{c.current&&c.current.focus()},[s]);let[u,f]=ie(er);return rp(()=>()=>{f(null)},[f]),Sb("div",{className:"color-picker__input-label",children:[Es("div",{className:"color-picker__input-hash",children:"#"}),Es("input",{ref:s==="hex"?c:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>d("hex"),onKeyDown:b=>{b.key!==np.TAB&&(b.key===np.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&Sb(mS,{children:[Es("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Es("div",{ref:p,className:lS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${np.I.toLocaleUpperCase()} or ${dS("Alt")} `,children:H0})]})]})};import sp,{useEffect as cp,useImperativeHandle as PS,useState as AS}from"react";import{EVENT as Rb}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as DS,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as _S,KEYS as RS}from"@excalidraw/common";import hS from"clsx";import{useEffect as gS,useRef as fS}from"react";import{jsxs as uS}from"react/jsx-runtime";var pS=({color:e,keyLabel:o,isShade:t=!1})=>uS("div",{className:"color-picker__button__hotkey-label",style:{color:Rn(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Nn=pS;import{jsx as ip,jsxs as bS}from"react/jsx-runtime";var Lb=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ie(Ot),a=fS(null);return gS(()=>{a.current&&a.current.focus()},[o,n]),ip("div",{className:"color-picker-content--default",children:e.map((l,s)=>bS("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:hS("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[ip("div",{className:"color-picker__button-outline"}),ip(Nn,{color:l,keyLabel:s+1})]},s))})};import xS from"clsx";import{useEffect as ES,useRef as yS}from"react";import{jsx as ap,jsxs as vS}from"react/jsx-runtime";var wS=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=or({color:o,palette:e}),[i,a]=ie(Ot),l=yS(null);return ES(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),ap("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,d],m)=>{let c=(Array.isArray(d)?d[r]:d)||"transparent",p=na[m],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return vS("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:xS("color-picker__button color-picker__button--large has-outline",{active:n?.colorName===s,"is-transparent":c==="transparent"||!c}),onClick:()=>{t(c),a("baseColors")},title:`${u}${c.startsWith("#")?` ${c}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:c?{"--swatch-color":c}:void 0,"data-testid":`color-${s}`,children:[ap("div",{className:"color-picker__button-outline"}),ap(Nn,{color:c,keyLabel:p})]},s)})})},Pb=wS;import{jsx as IS}from"react/jsx-runtime";var TS=({children:e})=>IS("div",{className:"color-picker__heading",children:e}),Bn=TS;import CS from"clsx";import{useEffect as SS,useRef as kS}from"react";import{jsx as ia,jsxs as Ab}from"react/jsx-runtime";var Db=({color:e,onChange:o,palette:t})=>{let r=or({color:e||"transparent",palette:t}),[n,i]=ie(Ot),a=kS(null);if(SS(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,d=t[l];if(Array.isArray(d))return ia("div",{className:"color-picker-content--default shades",children:d.map((m,c)=>Ab("button",{ref:c===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:CS("color-picker__button color-picker__button--large has-outline",{active:c===s}),"aria-label":"Shade",title:`${l} - ${c+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[ia("div",{className:"color-picker__button-outline"}),ia(Nn,{color:m,keyLabel:c+1,isShade:!0})]},c))})}return Ab("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[ia("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),ia("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Fn,COLOR_PALETTE as MS,KEYS as aa}from"@excalidraw/common";var lp=(e,o,t)=>{let r=Math.ceil(t/Fn);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+Fn;return n>=t?o%Fn:n}case"ArrowUp":{let n=o-Fn,i=n<0?Fn*r+n:n;return i>=t?void 0:i}}},LS=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(na.includes(e.key)){let l=na.indexOf(e.key),s=Object.keys(r)[l],d=r[s],m=Array.isArray(d)?d[a]:d;return t(m),i("baseColors"),!0}return!1},_b=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:m})=>{if(e[aa.CTRL_OR_CMD])return!1;if(e.key===aa.ESCAPE)return m(e),!0;if(e.key===aa.ALT)return d(!0),!0;if(e.key===aa.I)return d(),!0;let c=or({color:r,palette:t});if(e.key===aa.TAB){let p={custom:!!i.length,baseColors:!0,shades:c?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?n(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(MS.black)),e.preventDefault(),e.stopPropagation(),!0}if(LS({e,colorObj:c,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&c){let{shade:p}=c,u=lp(e.key,p,Fn);if(u!==void 0)return n(t[c.colorName][u]),!0}if(o==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(t),f=u.indexOf(p),b=lp(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return n(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=lp(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as Hr,jsxs as ys}from"react/jsx-runtime";var Nb=sp.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},d)=>{let[m]=sp.useState(()=>t==="canvasBackground"?[]:Ib(r,t,n)),[c,p]=ie(Ot),u=or({color:e,palette:n});cp(()=>{if(!c){let w=!!e&&op({color:e,palette:n}),E=w&&!m.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[c,e,n,p,u,m]);let[f,b]=AS(u?.shade??(t==="elementBackground"?DS:_S));cp(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===RS.ALT&&l(!1)};return document.addEventListener(Rb.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(Rb.KEYUP,w,{capture:!0})}},[u,l]);let x=sp.useRef(null);return PS(d,()=>x.current),cp(()=>{x?.current?.focus()},[]),Hr("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:ys("div",{ref:x,onKeyDown:w=>{_b({event:w,activeColorPickerSection:c,palette:n,color:e,onChange:o,onEyeDropperToggle:l,customColors:m,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&ys("div",{children:[Hr(Bn,{children:g("colorPicker.mostUsedCustomColors")}),Hr(Lb,{colors:m,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),ys("div",{children:[Hr(Bn,{children:g("colorPicker.colors")}),Hr(Pb,{color:e,palette:n,onChange:o,activeShade:f})]}),ys("div",{children:[Hr(Bn,{children:g("colorPicker.shades")}),Hr(Db,{color:e,onChange:o,palette:n})]}),a]})})});import NS from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as BS,DEFAULT_CANVAS_BACKGROUND_PICKS as FS,DEFAULT_ELEMENT_BACKGROUND_PICKS as OS,DEFAULT_ELEMENT_STROKE_PICKS as zS}from"@excalidraw/common";import{jsx as dp}from"react/jsx-runtime";var Bb=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=zS),o==="elementBackground"&&(n=OS),o==="canvasBackground"&&(n=FS),r&&(n=r),n?dp("div",{className:"color-picker__top-picks",children:n.map(i=>dp("button",{className:NS("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!Rn(i,BS)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:dp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Jt,jsxs as mp}from"react/jsx-runtime";var Fb=e=>{let o=new Option().style;return o.color=e,!!o.color},Mb=e=>YS(e)?e:Fb(`#${e}`)?`#${e}`:Fb(e)?e:null,WS=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Ob,updateData:a})=>{let{container:l}=He(),[,s]=ie(Ot),[d,m]=ie(er),c=mp("div",{children:[Jt(Bn,{children:g("colorPicker.hexCode")}),Jt(kb,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=GS(null),u=()=>{p.current?.focus()};return Jt(xs,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{d&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Jt(Nb,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{m(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{d?m(null):a({openPopup:null})},type:e,elements:n,updateData:a,children:c}):c})},VS=({label:e,color:o,type:t})=>Jt(ws.Trigger,{type:"button",className:HS("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Rn(o,US)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:Jt("div",{className:"color-picker__button-outline",children:!o&&W1})}),la=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Ob,topPicks:a,updateData:l,appState:s})=>Jt("div",{children:mp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Jt(Bb,{activeColor:o,onChange:t,type:e,topPicks:a}),Jt(gs,{}),mp(ws.Root,{open:s.openPopup===e,onOpenChange:d=>{l({openPopup:d?e:null})},children:[Jt(VS,{color:o,label:r,type:e}),s.openPopup===e&&Jt(WS,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as Zb from"@radix-ui/react-popover";import w6,{useCallback as v6,useMemo as T6}from"react";import{FONT_FAMILY as fp}from"@excalidraw/common";import m6,{useMemo as rr,useState as p6,useRef as u6,useEffect as h6,useCallback as g6}from"react";import{arrayToList as f6,debounce as b6,FONT_FAMILY as Gr,getFontFamilyString as x6}from"@excalidraw/common";import XS from"clsx";import KS from"react";import{jsx as ZS,jsxs as $S}from"react/jsx-runtime";var vs=KS.forwardRef(({className:e,placeholder:o,onChange:t},r)=>$S("div",{className:XS("QuickSearch__wrapper",e),children:[Lt,ZS("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import jS from"clsx";import{Children as qS}from"react";import{jsx as zb}from"react/jsx-runtime";var Ts=({className:e,placeholder:o,children:t})=>{let r=!qS.count(t);return zb("div",{className:jS("ScrollableList__wrapper",e),role:"menu",children:r?zb("div",{className:"empty",children:o}):t})};import{jsx as JS,jsxs as QS}from"react/jsx-runtime";var Hb=({children:e,className:o="",style:t,title:r})=>QS("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&JS("p",{className:"dropdown-menu-group-title",children:r}),e]}),sa=Hb;Hb.displayName="DropdownMenuGroup";import{useEffect as s6,useRef as c6}from"react";import{THEME as d6}from"@excalidraw/common";import{jsx as e6}from"react/jsx-runtime";var ca=({children:e,...o})=>e6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as o6,jsx as Is,jsxs as r6}from"react/jsx-runtime";var t6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=se();return r6(o6,{children:[o&&Is("div",{className:"dropdown-menu-item__icon",children:o}),Is("div",{style:e,className:"dropdown-menu-item__text",children:Is(ca,{children:r})}),t&&!n.editor.isMobile&&Is("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Cs=t6;import n6,{useContext as i6}from"react";import{EVENT as a6,composeEventHandlers as l6}from"@excalidraw/common";var pp=n6.createContext({}),Ss=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
-
${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),ks=(e,o)=>{let t=i6(pp);return l6(e,r=>{let n=new CustomEvent(a6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as up}from"react/jsx-runtime";var hp=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:d,onClick:m,...c})=>{let p=ks(m,d),u=c6(null);return s6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),up("button",{...c,ref:u,value:o,onClick:p,className:Ss(i,l,a),title:c.title??c["aria-label"],children:up(Cs,{textStyle:s,icon:e,shortcut:n,children:r})})};hp.displayName="DropdownMenuItem";var On={GREEN:"green",RED:"red",BLUE:"blue"},Ms=({type:e=On.BLUE,children:o})=>{let{theme:t}=go(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===d6.LIGHT?"1.5px solid white":"none"};switch(e){case On.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case On.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case On.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return up("div",{className:"DropDownMenuItemBadge",style:r,children:o})};Ms.displayName="DropdownMenuItemBadge";hp.Badge=Ms;var pt=hp;import{KEYS as zn}from"@excalidraw/common";var Gb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[zn.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===zn.F)return o.current?.focus(),!0;if(e.key===zn.ESCAPE)return n(),!0;if(e.key===zn.ENTER)return t?.value&&i(t.value),!0;if(e.key===zn.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===zn.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as da,jsxs as Ub}from"react/jsx-runtime";var E6=e=>{switch(e){case Gr.Excalifont:case Gr.Virgil:return qo;case Gr.Nunito:case Gr.Helvetica:return Ji;case Gr["Lilita One"]:return M0;case Gr["Comic Shanns"]:case Gr.Cascadia:return ql;default:return Ji}},Yb=m6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=He(),{fonts:s}=Re(),{showDeprecatedFonts:d}=fo(),[m,c]=p6(""),p=u6(null),u=rr(()=>Array.from(Zo.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:P}])=>{let N={value:k,icon:E6(k),text:P[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(N,{deprecated:A.deprecated,badge:{type:On.RED,placeholder:g("fontList.badge.old")}}),N}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),f=rr(()=>new Set(s.getSceneFamilies()),[e]),b=rr(()=>u.filter(k=>f.has(k.value)),[u,f]),x=rr(()=>u.filter(k=>!f.has(k.value)&&(d||!k.deprecated)),[u,f,d]),w=rr(()=>f6([...b,...x].filter(k=>k.text?.toLowerCase().includes(m))),[b,x,m]),E=rr(()=>{let k;return o?k=w.find(A=>A.value===o):e&&(k=w.find(A=>A.value===e)),!k&&m&&(w[0]?.value?r(w[0].value):n()),k},[o,e,m,w,r,n]),y=g6(k=>{Gb({event:k,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:r,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[E,w,t,r,a]);h6(()=>(i(),()=>{a()}),[]);let v=rr(()=>w.filter(k=>f.has(k.value)),[w,f]),C=rr(()=>w.filter(k=>!f.has(k.value)),[w,f]),S=(k,A)=>Ub(pt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:x6({fontFamily:k.value})},hovered:k.value===E?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{E?.value!==k.value&&r(k.value)},children:[k.text,k.badge&&da(Ms,{type:k.badge.type,children:k.badge.placeholder})]},k.value),L=[];return v.length&&L.push(da(sa,{title:g("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&L.push(da(sa,{title:g("fontList.availableFonts"),children:C.map((k,A)=>S(k,A+v.length))},"group_2")),Ub(xs,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[da(vs,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:b6(c,20)}),da(Ts,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:L.length?L:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Wb from"@radix-ui/react-popover";import{useMemo as y6}from"react";import{jsx as gp}from"react/jsx-runtime";var Vb=({selectedFontFamily:e})=>{let o=y6(()=>!!(e&&!Xb(e)),[e]);return gp(Wb.Trigger,{asChild:!0,children:gp("div",{children:gp(An,{standalone:!0,icon:vn,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as ma,jsxs as Kb}from"react/jsx-runtime";var $b=[{value:fp.Excalifont,icon:qo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:fp.Nunito,icon:Ji,text:g("labels.normal"),testId:"font-family-normal"},{value:fp["Comic Shanns"],icon:ql,text:g("labels.code"),testId:"font-family-code"}],I6=new Set($b.map(e=>e.value)),Xb=e=>e?I6.has(e):!1,jb=w6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=T6(()=>$b,[]),s=v6(d=>{d&&r(d)},[r]);return Kb("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[ma("div",{className:"buttonList",children:ma(Ft,{type:"button",options:l,value:o,onClick:s})}),ma(gs,{}),Kb(Zb.Root,{open:e,onOpenChange:a,children:[ma(Vb,{selectedFontFamily:o}),e&&ma(Yb,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Hn from"@radix-ui/react-popover";import M6 from"clsx";import Ls,{useEffect as L6}from"react";import{isArrowKey as P6,KEYS as Lo}from"@excalidraw/common";import{jsx as C6}from"react/jsx-runtime";var nr=({icon:e})=>C6("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:e});import{Fragment as k6,jsx as qb,jsxs as Jb}from"react/jsx-runtime";var S6=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>Jb(k6,{children:[Jb("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&qb(nr,{icon:o?lb:as})]}),o&&qb("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),pa=S6;import{jsx as Ur,jsxs as bp}from"react/jsx-runtime";var A6=me(!1);function D6({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=se(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)r(f.value),u.preventDefault();else if(u.key===Lo.TAB){let b=e.findIndex(w=>w.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(P6(u.key)){let b=Mo().rtl,x=e.findIndex(w=>w.value===o);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?Lo.ARROW_LEFT:Lo.ARROW_RIGHT):E=(x+1)%w;break;case(b?Lo.ARROW_RIGHT:Lo.ARROW_LEFT):E=(w+x-1)%w;break;case Lo.ARROW_DOWN:{E=(x+(i??1))%w;break}case Lo.ARROW_UP:{E=(w+x-(i??1))%w;break}}r(e[E].value)}u.preventDefault()}else(u.key===Lo.ESCAPE||u.key===Lo.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,d]=ie(A6),m=Ls.useMemo(()=>e.slice(0,i),[e,i]),c=Ls.useMemo(()=>e.slice(i),[e,i]);L6(()=>{m.some(u=>u.value===o)||d(!0)},[o,m,d]);let p=u=>Ur("div",{className:"picker-content",children:u.map((f,b)=>bp("button",{type:"button",className:M6("picker-option",{active:o===f.value}),onClick:x=>{r(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&Ur("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return Ur(Hn.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:bp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),c.length>0&&Ur(pa,{label:g("labels.more_options"),open:s,openTrigger:()=>{d(u=>!u)},className:"picker-collapsible",children:p(c)})]})})}function xp({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Ls.useState(!1),s=Ls.useRef(null);return Ur("div",{children:bp(Hn.Root,{open:a,onOpenChange:d=>l(d),children:[Ur(Hn.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(d=>d.value===e)?.icon}),a&&Ur(D6,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Qb,{useEffect as _6}from"react";import{jsx as Ep,jsxs as ex}from"react/jsx-runtime";var tx=({updateData:e,app:o,testId:t})=>{let r=Qb.useRef(null),n=Qb.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),d=i.reduce((m,c)=>(m!=null&&m!==c.opacity&&(a=!1),m==null||m>c.opacity?c.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return _6(()=>{if(r.current&&n.current){let m=r.current,c=n.current,p=m.offsetWidth,u=15,f=d/100*(p-u)+u/2;c.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${d}%, var(--button-bg) ${d}%, var(--button-bg) 100%)`}},[d]),ex("label",{className:"control-label",children:[g("labels.opacity"),ex("div",{className:"range-wrapper",children:[Ep("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:d,className:"range-input","data-testid":t}),Ep("div",{className:"value-bubble",ref:n,children:d!==0?d:null}),Ep("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as cx,jsx as Q,jsxs as yt}from"react/jsx-runtime";var sx=.1,ut=(e,o,t,r=!1)=>{let n=Cp(j(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Et=function(e,o,t,r,n){let i=o.state.editingTextElement,a=ax(e),l=null;if(i&&(l=t(i)),!l)if(Ee(a,o.state)){let d=o.scene.getSelectedElements(o.state),m=r===!0?d:d.filter(c=>r(c));l=$6(m,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},r4=(e,o,t)=>J6(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Sp=(e,o,t,r,n)=>{let i=new Set,a=ut(e,o,l=>{if(xt(l)){let s=r(l);i.add(s);let d=Ke(l,{fontSize:s});return ua(d,t.scene.getContainerElement(l),t.scene),d=r4(l,d,t.scene),d}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{xt(l)&&q6(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:Ze.IMMEDIATELY}},n4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:ut(e,o,r=>e4(r.type)?Ke(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?Ze.IMMEDIATELY:Ze.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt(cx,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.stroke")}),Q(la,{topPicks:H6,palette:z6,type:"elementStroke",label:g("labels.stroke"),color:Et(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),i4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Ze.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!Z6(t.currentItemBackgroundColor)&&i.every(l=>nx(l)&&j6(l.points))){let l=Cp(i);n=e.map(s=>l.has(s.id)&&nx(s)?Ke(s,{backgroundColor:t.currentItemBackgroundColor,...o4(s,!0)}):s)}else n=ut(e,o,l=>Ke(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt(cx,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.background")}),Q(la,{topPicks:O6,palette:F6,type:"elementBackground",label:g("labels.background"),color:Et(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),a4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(re("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:ut(e,o,n=>Ke(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=j(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return yt("fieldset",{children:[Q("legend",{children:g("labels.fill")}),Q("div",{className:"buttonList",children:Q(Ft,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${X6("Alt-Click")})`,icon:i?Q1:e0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:t0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:o0,testId:"fill-solid"}],value:Et(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(d=>d.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),l4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"stroke-width",options:[{value:vp.thin,text:g("labels.thin"),icon:Om,testId:"strokeWidth-thin"},{value:vp.bold,text:g("labels.bold"),icon:r0,testId:"strokeWidth-bold"},{value:vp.extraBold,text:g("labels.extraBold"),icon:n0,testId:"strokeWidth-extraBold"}],value:Et(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})})]})}),s4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{seed:W6(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:l0},{value:1,text:g("labels.artist"),icon:s0},{value:2,text:g("labels.cartoonist"),icon:c0}],value:Et(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})})]})}),x$=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:Om},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:i0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:a0}],value:Et(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})})]})}),c4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>Q(tx,{updateData:o,app:e,testId:"opacity"})}),d4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>Sp(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:I0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:C0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:S0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:k0,testId:"fontSize-veryLarge"}],value:Et(e,r,n=>{if(xt(n))return n.fontSize;let i=ir(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>xt(n)||ir(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||U6),onChange:n=>t(n)})})]})}),kp=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Or,trackEvent:!1,perform:(e,o,t,r)=>Sp(e,o,r,n=>Math.round(1/(1+sx)*n.fontSize)),keyTest:e=>e[Gn.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Gn.CHEVRON_LEFT||e.key===Gn.COMMA)}),Mp=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Or,trackEvent:!1,perform:(e,o,t,r)=>Sp(e,o,r,n=>Math.round(n.fontSize*(1+sx))),keyTest:e=>e[Gn.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Gn.CHEVRON_RIGHT||e.key===Gn.PERIOD)}),m4=B({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:ut(e,o,b=>{let x=n?.get(b.id);return x?Ke(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:Ze.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:d}=t,m=Ze.EVENTUALLY,c,p=!1;if(s)c=s,m=Ze.IMMEDIATELY;else if(d){c=d,m=Ze.EVENTUALLY;let f=j(e,o,{includeBoundTextElement:!0}).filter(b=>xt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(c&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(Zo.loadedFontsCache.values()),E=Object.entries(Y6).find(([C,S])=>S===c)?.[0];d&&E&&w.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:ut(e,o,C=>{if(xt(C)&&(C.fontFamily!==c||s)){let S=Ke(C,{fontFamily:c,lineHeight:K6(c)}),L=n?.get(C.containerId||"")||{},k=r.scene.getContainerElement(C);return a&&k&&L&&r.scene.mutateElement(k,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,k),S}return C},!0)});let y=`10px ${V6({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)ua(C,S,r.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,L]of f){let k=r.scene.getElement(S.id),A=L?r.scene.getElement(L.id):null;k&&ua(k,A,r.scene)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=wp(new Map),i=wp(null),[a,l]=B6({}),s=wp(!0),d=N6(()=>{let m=(c,p)=>Et(c,t,u=>{if(xt(u))return u.fontFamily;let f=ir(u,p);return f?f.fontFamily:null},u=>xt(u)||ir(u,p)!==null,u=>u?null:o.currentItemFontFamily||G6);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return yp(()=>{i.current=d},[d]),yp(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),yp(()=>(s.current=!1,()=>{s.current=!0}),[]),yt("fieldset",{children:[Q("legend",{children:g("labels.fontFamily")}),Q(jb,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:d,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:m=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),n.current.clear()},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:m=>{if(m){n.current.clear();let{editingTextElement:c}=o;if(c?.type==="text"){let p=t.scene.getElement(c.id);n.current.set(c.id,Ke(p||c,{},!0))}else{let p=j(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,Ke(u,{},!0))}l({openPopup:"fontFamily"})}else{let c={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...c}):l(c),n.current.clear()}}})]})}}),p4=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:ut(e,o,n=>{if(xt(n)){let i=Ke(n,{textAlign:t});return ua(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return yt("fieldset",{children:[Q("legend",{children:g("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:L0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:P0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:A0,testId:"align-right"}],value:Et(e,r,i=>{if(xt(i))return i.textAlign;let a=ir(i,n);return a?a.textAlign:null},i=>xt(i)||ir(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),u4=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:ut(e,o,n=>{if(xt(n)){let i=Ke(n,{verticalAlign:t});return ua(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Ft,{group:"text-align",options:[{value:Ps.TOP,text:g("labels.alignTop"),icon:Q(D0,{theme:o.theme}),testId:"align-top"},{value:Ps.MIDDLE,text:g("labels.centerVertically"),icon:Q(R0,{theme:o.theme}),testId:"align-middle"},{value:Ps.BOTTOM,text:g("labels.alignBottom"),icon:Q(_0,{theme:o.theme}),testId:"align-bottom"}],value:Et(e,r,n=>{if(xt(n)&&n.containerId)return n.verticalAlign;let i=ir(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>xt(n)||ir(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Ps.MIDDLE),onChange:n=>t(n)})})})}),E$=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>lx(r)?r:Ke(r,{roundness:t==="round"?{type:Q6(r.type)?As.ADAPTIVE_RADIUS:As.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=kl(ax(e),o).some(l=>l.roundness?.type===As.LEGACY);return yt("fieldset",{children:[Q("legend",{children:g("labels.edges")}),yt("div",{className:"buttonList",children:[Q(Ft,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:d0},{value:"round",text:g("labels.round"),icon:m0}],value:Et(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!Ds(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),ix=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:p0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(u0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:Q(b0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:Q(x0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:Q(h0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(g0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:Q(E0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:Q(y0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:Q(f0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:Q(v0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:Q(w0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:Q(T0,{flip:e}),keyBinding:"v"}],y$=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>{if(Ip(r)){let{position:n,type:i}=t;if(n==="start")return Ke(r,{startArrowhead:i});if(n==="end")return Ke(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Mo().rtl;return yt("fieldset",{children:[Q("legend",{children:g("labels.arrowheads")}),yt("div",{className:"iconSelectList buttonList",children:[Q(xp,{label:"arrowhead_start",options:ix(!n),value:Et(e,r,i=>Ip(i)&&un(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),Q(xp,{label:"arrowhead_end",group:"arrowheads",options:ix(!!n),value:Et(e,r,i=>Ip(i)&&un(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),w$=B({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=ut(e,o,l=>{if(!Ds(l))return l;let s=Ke(l,{roundness:t===Po.round?{type:As.PROPORTIONAL_RADIUS}:null,elbowed:t===Po.elbow,points:t===Po.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(lx(s)){s.fixedSegments=null;let d=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=Tp.getPointAtIndexGlobalCoordinates(s,0,d),c=Tp.getPointAtIndexGlobalCoordinates(s,-1,d),p=s.startBinding&&d.get(s.startBinding.elementId),u=s.endBinding&&d.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...rx(s,p,"start",d)}:null,b=u&&s.endBinding?{...s.endBinding,...rx(s,u,"end",d)}:null;s={...s,startBinding:f,endBinding:b,...t4(s,d,{points:[m,c].map(x=>R6(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let d=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=d.get(s.startBinding.elementId);m&&ox(s,m,"start",r.scene)}if(s.endBinding){let m=d.get(s.endBinding.elementId);m&&ox(s,m,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new Tp(l,Cp(e)))}return{elements:n,appState:i,captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"arrowtypes",options:[{value:Po.sharp,text:g("labels.arrowtype_sharp"),icon:rs,testId:"sharp-arrow"},{value:Po.round,text:g("labels.arrowtype_round"),icon:is,testId:"round-arrow"},{value:Po.elbow,text:g("labels.arrowtype_elbowed"),icon:ns,testId:"elbow-arrow"}],value:Et(e,r,n=>Ds(n)?n.elbowed?Po.elbow:n.roundness?Po.round:Po.sharp:null,n=>Ds(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{clamp as _p,roundToStep as y4}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as w4,CURSOR_TYPE as hx,MAX_ZOOM as gx,MIN_ZOOM as fx,THEME as ha,ZOOM_STEP as Rp,getShortcutKey as bx,updateActiveTool as Yn,CODES as xo,KEYS as Do}from"@excalidraw/common";import{getNonDeletedElements as v4}from"@excalidraw/element";import{newElementWith as T4}from"@excalidraw/element";import{getCommonBounds as I4}from"@excalidraw/element";import{CaptureUpdateAction as Qt}from"@excalidraw/element";import{useEffect as h4}from"react";import{jsx as f4}from"react/jsx-runtime";var Un=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},Lp=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},g4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();Lp(o,n)},Pt=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(h4(()=>()=>Un().classList.remove("excalidraw-tooltip--visible"),[]),n?null:f4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>g4(i.currentTarget,Un(),o,t),onPointerLeave:()=>Un().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import _s from"open-color";import{CURSOR_TYPE as Pp,MIME_TYPES as Ap,THEME as mx}from"@excalidraw/common";var px='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',b4='<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"/>',ux='<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"/>',x4=`data:${Ap.svg},${encodeURIComponent(`${px}${ux}</svg>`)}`,E4=`data:${Ap.svg},${encodeURIComponent(`${px}${b4}${ux}</svg>`)}`,zt=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},bo,dx,Dp=(e,o)=>{let r=()=>{let n=o===mx.DARK;bo=document.createElement("canvas"),bo.theme=o,bo.height=20,bo.width=20;let i=bo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(bo.width/2,bo.height/2,5,0,2*Math.PI),i.fillStyle=n?_s.black:_s.white,i.fill(),i.strokeStyle=n?_s.white:_s.black,i.stroke(),dx=bo.toDataURL(Ap.svg)};(!bo||bo.theme!==o)&&r(),xe(e,`url(${dx}) ${20/2} ${20/2}, auto`)},At=(e,o)=>{if(e)if(o.activeTool.type==="selection")zt(e);else if(jt(o))e.style.cursor=Pp.GRAB;else if(bt(o))Dp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===mx.LIGHT?x4:E4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Pp.AUTO):e.style.cursor=Pp.CROSSHAIR};var Ao=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),d=-(n-n/t),m=-(i-i/t);return{scrollX:l+d,scrollY:s+m,zoom:{value:t}}};import{jsx as Fs,jsxs as M4}from"react/jsx-runtime";var C4=B({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?Qt.IMMEDIATELY:Qt.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>Fs(la,{palette:null,topPicks:w4,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),_o=B({name:"clearCanvas",label:"labels.clearCanvas",icon:Mt,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>T4(n,{isDeleted:!0})),appState:{...$o(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:"selection"}:o.activeTool},captureUpdate:Qt.IMMEDIATELY})}),Rs=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:ym,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value+Rp)},o),userToFollow:null},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(K,{type:"button",className:"zoom-in-button zoom-button",icon:ym,title:`${g("buttons.zoomIn")} \u2014 ${bx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=gx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.EQUAL||e.code===xo.NUM_ADD)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),Ns=B({name:"zoomOut",label:"buttons.zoomOut",icon:wm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value-Rp)},o),userToFollow:null},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(K,{type:"button",className:"zoom-out-button zoom-button",icon:wm,title:`${g("buttons.zoomOut")} \u2014 ${bx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=fx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.MINUS||e.code===xo.NUM_SUBTRACT)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),Bs=B({name:"resetZoom",label:"buttons.resetZoom",icon:B1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(1)},o),userToFollow:null},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(Pt,{label:g("buttons.resetZoom"),style:{height:"100%"},children:M4(K,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===xo.ZERO||e.code===xo.NUM_ZERO)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),S4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,d=a-n,m=o.height/d,p=Math.min(s,m)*_p(t,.1,1);return Math.min(p,1)},xx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=_p(n,fx,gx);let[l,s,d,m]=e,c=(l+d)/2,p=(s+m)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(r){let S=d-l,L=m-s;y=Math.min(w/S,E/L)*n}else y=S4(e,{width:w,height:E},n);let v=uo(_p(y4(y,Rp,"floor"),i,a)),C=Kf({scenePoint:{x:c,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:Qt.EVENTUALLY}},ga=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=I4(v4(o));return xx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},rj=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:os,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return ga({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.TWO&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),nj=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:os,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return ga({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.THREE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),k4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:os,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>ga({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===xo.ONE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),Yr=B({name:"toggleTheme",label:(e,o)=>o.theme===ha.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ha.LIGHT?$i:ji,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===ha.LIGHT?ha.DARK:ha.LIGHT)},captureUpdate:Qt.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===xo.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),ij=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return bt(o)?t=Yn(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=Yn(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:Qt.IMMEDIATELY}},keyTest:e=>e.key===Do.E}),aj=B({name:"toggleLassoTool",label:"toolBar.lasso",icon:Ki,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=Yn(o,{type:"lasso",fromSelection:!1}),xe(r.interactiveCanvas,hx.CROSSHAIR)):n=Yn(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:Qt.NEVER}}}),Ex=B({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ql,viewMode:!1,perform:(e,o,t,r)=>{let n;return jt(o)?n=Yn(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Yn(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(r.interactiveCanvas,hx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:Qt.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Do.CTRL_OR_CMD]&&e.key===Do.H});import{updateActiveTool as yx}from"@excalidraw/common";import{CaptureUpdateAction as L4}from"@excalidraw/element";var P4=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=yx(o,{type:"embeddable"});return At(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:yx(o,{type:"embeddable"})},captureUpdate:L4.EVENTUALLY}}});import{pointFrom as A4}from"@excalidraw/math";import{maybeBindLinearElement as D4,bindOrUnbindLinearElement as wx,isBindingEnabled as _4}from"@excalidraw/element/binding";import{isValidPolygon as vx,LinearElementEditor as fa,newElementWith as Np}from"@excalidraw/element";import{isBindingElement as Os,isFreeDrawElement as Tx,isLinearElement as Ix,isLineElement as zs}from"@excalidraw/element";import{KEYS as Bp,arrayToMap as Fp,tupleToCoors as R4,updateActiveTool as Cx}from"@excalidraw/common";import{isPathALoop as N4}from"@excalidraw/element";import{isInvisiblySmallElement as Op}from"@excalidraw/element";import{CaptureUpdateAction as zp}from"@excalidraw/element";import{jsx as B4}from"react/jsx-runtime";var wt=B({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,{event:l,sceneCoords:s}=t??{},d=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=fa.handlePointerUp(l,o.selectedLinearElement,o,r.scene),{startBindingElement:f,endBindingElement:b}=u,x=r.scene.getElement(u.elementId);if(Os(x)&&wx(x,f,b,r.scene),u!==o.selectedLinearElement){let w=e;return x&&Op(x)&&(w=w.map(E=>E.id===x.id?Np(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:zp.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=fa.getElement(u,d);if(x)return Os(x)&&wx(x,f,b,a),zs(x)&&!vx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||Op(x)?e.map(w=>w.id===x.id?Np(w,{isDeleted:!0}):w):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new fa(x,Fp(d),!1)},captureUpdate:zp.IMMEDIATELY}}let m=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||Os(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=d.get(Object.keys(o.selectedElementIds)[0]);u&&(c=u)}if(c){if(o.multiElement&&c.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=c;(!f||u[u.length-1]!==f)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&Op(c)&&(m=m.map(u=>u.id===c?.id?Np(u,{isDeleted:!0}):u)),Ix(c)||Tx(c)){let u=N4(c.points,o.zoom.value);if(u&&(zs(c)||Tx(c))){let f=c.points,b=f[0],x=f.map((w,E)=>E===f.length-1?A4(b[0],b[1]):w);zs(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(zs(c)&&!vx(c.points)&&a.mutateElement(c,{polygon:!1}),Os(c)&&!u&&c.points.length>1&&_4(o)){let f=s??R4(fa.getPointAtIndexGlobalCoordinates(c,-1,Fp(e)));D4(c,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&zt(n);let p;return o.activeTool.type==="eraser"?p=Cx(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):p=Cx(o,{type:"selection"}),{elements:m,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:c&&Ix(c)?new fa(c,Fp(m)):o.selectedLinearElement},captureUpdate:zp.IMMEDIATELY}},keyTest:(e,o)=>e.key===Bp.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Bp.ESCAPE||e.key===Bp.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>B4(K,{type:"button",icon:X1,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as Xn,DEFAULT_EXPORT_PADDING as vk,EXPORT_SCALES as Tk,THEME as Up}from"@excalidraw/common";import{getNonDeletedElements as Ik}from"@excalidraw/element";import{CaptureUpdateAction as ro}from"@excalidraw/element";import F4 from"clsx";import{jsx as Sx,jsxs as O4}from"react/jsx-runtime";var ba=({children:e,checked:o,onChange:t,className:r})=>O4("div",{className:F4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Sx("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:H1}),Sx("div",{className:"Checkbox-label",children:e})]});import{THEME as xa}from"@excalidraw/common";import{jsx as Ea}from"react/jsx-runtime";var Mx=e=>{let o=e.title||(e.value===xa.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Ea(K,{type:"icon",icon:e.value===xa.LIGHT?kx.MOON:kx.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===xa.DARK?xa.LIGHT:xa.DARK),"data-testid":"toggle-dark-mode"})},kx={SUN:Ea("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ea("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:Ea("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ea("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as z4}from"react";import{focusNearestParent as H4,KEYS as G4}from"@excalidraw/common";import{jsx as Lx,jsxs as U4}from"react/jsx-runtime";var Px=e=>{let{id:o}=He(),[t,r]=z4(e.value),n=a=>{e.ignoreFocus||H4(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===G4.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return U4("div",{className:"ProjectName",children:[Lx("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Lx("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as uk,DEFAULT_FILENAME as hk,IMAGE_MIME_TYPES as Vx,isFirefox as gk,MIME_TYPES as fk,cloneJSON as bk,SVG_DOCUMENT_PREAMBLE as xk}from"@excalidraw/common";import{getNonDeletedElements as Ek}from"@excalidraw/element";import{isFrameLikeElement as yk}from"@excalidraw/element";import{getElementsOverlappingFrame as wk}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as Q4,EXPORT_DATA_TYPES as va,MIME_TYPES as to,arrayToMap as ek,isMemberOf as tk,isPromiseLike as ok}from"@excalidraw/common";import{mutateElement as rk}from"@excalidraw/element";import{deepCopyElement as nk}from"@excalidraw/element";import{isFrameLikeElement as ik,isInitializedImageElement as ak}from"@excalidraw/element";import{getContainingFrame as Gx}from"@excalidraw/element";import{pointFrom as ar}from"@excalidraw/math";import{COLOR_PALETTE as Dx,DEFAULT_CHART_COLOR_INDEX as Y4,getAllColorsSpecificShade as W4,DEFAULT_FONT_FAMILY as V4,DEFAULT_FONT_SIZE as _x,VERTICAL_ALIGN as X4,randomId as Rx,isDevEnv as Nx}from"@excalidraw/common";import{newTextElement as Hs,newLinearElement as wa,newElement as Gp}from"@excalidraw/element";var eo=32,we=12,lr=256,Bx=50,Wr="NOT_SPREADSHEET",Wn="VALID_SPREADSHEET",ya=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},Hp=(e,o)=>e.slice(1).every(t=>ya(t[o])!==null),Ax=e=>{let o=e[0].length;if(o>2)return{type:Wr,reason:"More than 2 columns"};if(o===1){if(!Hp(e,0))return{type:Wr,reason:"Value is not numeric"};let s=ya(e[0][0])===null,d=(s?e.slice(1):e).map(m=>ya(m[0]));return d.length<2?{type:Wr,reason:"Less than two rows"}:{type:Wn,spreadsheet:{title:s?e[0][0]:null,labels:null,values:d}}}let t=Hp(e,0),r=Hp(e,1);if(!t&&!r)return{type:Wr,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=ya(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Wr,reason:"Less than 2 rows"}:{type:Wn,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>ya(s[i]))}}},K4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},Fx=e=>{let o=e.trim().split(`
|
|
1
|
+
import{$ as Y1,A as ZC,B as A1,C as D1,D as _1,E as us,F as Ta,G as hs,H as gs,I as R1,J as N1,K as Ia,L as B1,M as F1,N as O1,O as z1,P as fs,Q as Nn,R as H1,S as jC,T as Gm,U as qC,V as Bn,W as Ca,Y as G1,_ as U1,a as k1,aa as bs,b as Qr,ba as W1,c as xo,ca as Um,d as M1,da as Ym,e as we,ea as xs,f as P1,fa as V1,g as Q,ga as Wm,h as An,ha as zo,i as Eo,ia as X1,j as Ea,ja as Vm,k as ya,ka as K1,l as Dn,la as $1,m as wa,ma as Es,n as _n,na as Xm,o as L1,oa as Z1,p as Om,pa as j1,q as dr,qa as q1,r as mr,ra as Sa,s as It,t as no,u as Rn,v as ms,w as zm,x as va,y as ps,z as Hm}from"./chunk-6GUG5R24.js";import{a as T}from"./chunk-A66AFZZU.js";import{K as Fm}from"./chunk-RSFMSEP5.js";import{c as S1}from"./chunk-KRJFZ5JQ.js";import{b as I1,c as C1,d as C}from"./chunk-SRAX5OIU.js";import qU,{useEffect as JU}from"react";import{DEFAULT_UI_OPTIONS as XC,isShallowEqual as QU}from"@excalidraw/common";import S5 from"clsx";import AH from"lodash.throttle";import Oo,{useContext as qr}from"react";import{flushSync as pa}from"react-dom";import DH from"roughjs/bin/rough";import{nanoid as _H}from"nanoid";import{clamp as k5,pointFrom as se,pointDistance as Xr,vector as M5,pointRotateRads as Lf,vectorScale as RH,vectorFromPoint as Af,vectorSubtract as P5,vectorDot as L5,vectorNormalize as A5}from"@excalidraw/math";import{COLOR_PALETTE as NH,CODES as D5,shouldResizeFromCenter as _5,shouldMaintainAspectRatio as jl,shouldRotateWithDiscreteAngle as Df,isArrowKey as Tm,KEYS as V,APP_NAME as BH,CURSOR_TYPE as Ne,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as FH,DEFAULT_VERTICAL_ALIGN as R5,DRAGGING_THRESHOLD as OH,ELEMENT_SHIFT_TRANSLATE_AMOUNT as zH,ELEMENT_TRANSLATE_AMOUNT as N5,EVENT as ne,FRAME_STYLE as Kr,IMAGE_MIME_TYPES as HH,IMAGE_RENDER_TIMEOUT as GH,LINE_CONFIRM_THRESHOLD as _f,MAX_ALLOWED_FILE_BYTES as B5,MIME_TYPES as Bo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as UH,POINTER_BUTTON as Cn,ROUNDNESS as Im,SCROLL_TIMEOUT as YH,TAP_TWICE_TIMEOUT as WH,TEXT_TO_CENTER_SNAP_THRESHOLD as VH,THEME as Cm,THEME_FILTER as XH,TOUCH_CTX_MENU_TIMEOUT as KH,VERTICAL_ALIGN as $H,YOUTUBE_STATES as Sm,ZOOM_STEP as ZH,POINTER_EVENTS as ua,TOOL_TYPE as Fo,supportsResizeObserver as jH,DEFAULT_COLLISION_THRESHOLD as F5,DEFAULT_TEXT_ALIGN as qH,ARROW_TYPE as $r,DEFAULT_REDUCED_GLOBAL_ALPHA as JH,isLocalLink as QH,normalizeLink as Rf,toValidURL as eG,getGridPoint as st,getLineHeight as O5,debounce as z5,distance as ha,getFontString as Nf,getNearestScrollableContainer as tG,isInputLike as H5,isToolIcon as oG,isWritableElement as ql,sceneCoordsToViewportCoords as km,tupleToCoors as Bf,viewportCoordsToSceneCoords as Ue,wrapEvent as rG,updateObject as Ff,updateActiveTool as ir,isTransparent as nG,easeToValuesRAF as iG,muteFSAbortError as aG,isTestEnv as TC,isDevEnv as IC,easeOut as lG,updateStable as Jl,addEventListener as Fe,normalizeEOL as sG,getDateTime as G5,isShallowEqual as cG,arrayToMap as Mm,randomInteger as dG,CLASSES as mG,Emitter as Sn,MINIMUM_ARROW_SIZE as U5,DOUBLE_TAP_POSITION_THRESHOLD as pG,createUserAgentDescriptor as CC,getFormFactor as uG,deriveStylesPanelMode as Am,isIOS as hG,isBrave as gG,isSafari as fG,loadDesktopUIModePreference as bG,setDesktopUIMode as xG}from"@excalidraw/common";import{getObservedAppState as EG,getCommonBounds as ga,maybeSuggestBindingsForLinearElementAtCoords as Y5,getElementAbsoluteCoords as W5,bindOrUnbindLinearElements as V5,fixBindingsAfterDeletion as yG,getHoveredElementForBinding as Of,isBindingEnabled as zf,shouldEnableBindingForPointerEvent as wG,updateBoundElements as Hf,getSuggestedBindingsForArrows as Gf,LinearElementEditor as Pe,newElementWith as Zr,newFrameElement as vG,newFreeDrawElement as TG,newEmbeddableElement as X5,newMagicFrameElement as K5,newIframeElement as IG,newArrowElement as CG,newElement as SG,newImageElement as kG,newLinearElement as MG,newTextElement as $5,refreshTextDimensions as PG,deepCopyElement as Z5,duplicateElements as Uf,hasBoundTextElement as j5,isArrowElement as Yf,isBindingElement as Wf,isBindingElementType as q5,isBoundToContainer as Vf,isFrameLikeElement as Lt,isImageElement as kn,isEmbeddableElement as ar,isInitializedImageElement as Ql,isLinearElement as At,isLinearElementType as LG,isUsingAdaptiveRadius as AG,isIframeElement as fa,isIframeLikeElement as es,isMagicFrameElement as Xf,isTextBindableContainer as J5,isElbowArrow as Ze,isFlowchartNodeElement as DG,isBindableElement as _G,isTextElement as bo,getLockedLinearCursorAlignSize as Q5,getNormalizedDimensions as RG,isElementCompletelyInViewport as Kf,isElementInViewport as eC,isInvisiblySmallElement as tC,getCornerRadius as NG,isPathALoop as oC,createSrcDoc as rC,embeddableURLValidator as $f,maybeParseEmbedSrc as BG,getEmbedLink as Pm,getInitializedImageElements as FG,normalizeSVG as nC,updateImageCache as OG,getBoundTextElement as Zf,getContainerCenter as jf,getContainerElement as iC,isValidTextContainer as zG,redrawTextBoundingBox as HG,hasBoundingBox as GG,getFrameChildren as qf,isCursorInFrame as aC,addElementsToFrame as Jf,replaceAllElementsInFrame as UG,removeElementsFromFrame as YG,getElementsInResizingFrame as Qf,getElementsInNewFrame as WG,getContainingFrame as e1,elementOverlapsWithFrame as VG,updateFrameMembershipOfSelectedElements as lC,isElementInFrame as sC,getFrameLikeTitle as XG,getElementsOverlappingFrame as KG,filterElementsEligibleAsFrameChildren as $G,hitElementBoundText as ZG,hitElementBoundingBoxOnly as jG,hitElementItself as ts,getVisibleSceneBounds as qG,FlowChartCreator as JG,FlowChartNavigator as QG,getLinkDirectionFromKey as cC,cropElement as eU,wrapText as tU,isElementLink as t1,parseElementLinkFromURL as oU,isMeasureTextSupported as rU,normalizeText as nU,measureText as dC,getLineHeightInPx as iU,getApproxMinLineWidth as aU,getApproxMinLineHeight as lU,getMinTextElementWidth as sU,ShapeCache as os,getRenderOpacity as cU,editGroupForSelectedElement as dU,getElementsInGroup as Mn,getSelectedGroupIdForElement as mU,getSelectedGroupIds as pU,isElementInGroup as mC,isSelectedViaGroup as uU,selectGroupsForSelectedElements as to,syncInvalidIndices as SC,syncMovedIndices as pC,excludeElementsInFramesFromSelection as hU,getSelectionStateForElements as gU,makeNextSelectedElementIds as Te,getResizeOffsetXY as fU,getResizeArrowDirection as bU,transformElements as xU,getCursorForResizingElement as uC,getElementWithTransformHandleType as hC,getTransformHandleTypeFromCoords as gC,dragNewElement as fC,dragSelectedElements as EU,getDragOffsetXY as yU,isNonDeletedElement as bC,Scene as xC,Store as wU,CaptureUpdateAction as Tt,hitElementBoundingBox as vU,isLineElement as o1,isSimpleArrow as TU,StoreDelta as EC,positionElementsOnGrid as yC}from"@excalidraw/element";import{KEYS as bp,MOBILE_ACTION_BUTTON_BG as mS,updateActiveTool as pS}from"@excalidraw/common";import{getNonDeletedElements as xp}from"@excalidraw/element";import{fixBindingsAfterDeletion as uS}from"@excalidraw/element";import{LinearElementEditor as Y0}from"@excalidraw/element";import{newElementWith as zs}from"@excalidraw/element";import{getContainerElement as W0}from"@excalidraw/element";import{isBoundToContainer as Fs,isElbowArrow as hS,isFrameLikeElement as gS}from"@excalidraw/element";import{getFrameChildren as fS}from"@excalidraw/element";import{getElementsInGroup as Ep,selectGroupsForSelectedElements as bS}from"@excalidraw/element";import{CaptureUpdateAction as Os}from"@excalidraw/element";import{isDevEnv as tS}from"@excalidraw/common";import{atom as he,createStore as JC}from"jotai";import{createIsolation as QC}from"jotai-scope";var J1=QC();var{useAtom:de,useSetAtom:pr,useAtomValue:ys,useStore:iY}=J1,Q1=J1.Provider,We=JC();var eS=I1({"./locales/ar-SA.json":()=>import("./locales/ar-SA-F62BVQMB.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-7PGSKYOB.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-AAEXMUQ4.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ONOFQYIQ.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-YT3I2M3F.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-GG4YH2FN.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-IS5VTBOP.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-VPQ2KWAY.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-G4Y2G6IS.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-RAT2LIDI.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-DNJB2AZO.js"),"./locales/en.json":()=>import("./locales/en-SFRQHD7K.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-IMTENLBU.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-XLOS36YS.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-J6Z2YOGX.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-B2IQ7SBP.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-N5BRDCMI.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-BOYALFRN.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-H7M7HGY5.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-7AB5CA2Q.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-ZZM7UJLP.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-RZ7JNCXA.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-ZX7HN56D.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-NBNBUHIR.js"),"./locales/kaa.json":()=>import("./locales/kaa-QWYSGEM7.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-Q3HBKQ5I.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-HF2NTCRX.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-CN6HHF5U.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-SJQMUXM7.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-VM4BHTPC.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-QIWZQ7AG.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-YQFCB4WZ.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-GR2ZJPSQ.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-M5XJDJQ2.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-2RU2YF7H.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-MUHXDQFK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-72RCA552.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-65ITQYQ2.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-WESENMFH.js"),"./locales/percentages.json":()=>import("./locales/percentages-OEPNEGCM.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-7C4NGVUA.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-QH23C2IX.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-O5XBATXI.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-QHCHEGM5.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-FUMQ2LLB.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-JYUINGNN.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-R25O52BS.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-5KPVX4FS.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-MVMXV6O4.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-A32FQB4D.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-CXMWNVBY.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-YHFI3W2D.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-UTJIIKT5.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-H4EGTR7D.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-XBV2ESZM.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-CKCJ4HAO.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ISASRRMF.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-KYRW5V3R.js")});var oS=85,yo={code:"en",label:"English"},On=[yo,...[{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=>S1[e.code]>=oS).sort((e,o)=>e.label>o.label?1:-1)],vs="__test__";tS()&&On.unshift({code:vs,label:"test language"},{code:`${vs}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Fn=yo,ws={},Ts=async e=>{if(Fn=e,document.documentElement.dir=Fn.rtl?"rtl":"ltr",document.documentElement.lang=Fn.code,e.code.startsWith(vs))ws={};else try{ws=await eS(`./locales/${Fn.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),ws=Fm}We.set(tb,e.code)},Ho=()=>Fn,eb=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},g=(e,o,t)=>{if(Fn.code.startsWith(vs))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=eb(ws,r)||eb(Fm,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},tb=he(yo.code),Be=()=>{let e=ys(tb);return{t:g,langCode:e}};import rS from"clsx";import nS from"open-color";import it from"react";import{THEME as iS}from"@excalidraw/common";import{Fragment as Ee,jsx as h,jsxs as N}from"react/jsx-runtime";var io=e=>"var(--icon-fill-color)",ob=e=>e===iS.LIGHT?nS.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:rS({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},z={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ie={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},wY=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),z),zn=M(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),rb=M(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),nb=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),z),ib=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),z),ab=M(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),Km=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),z),en=M(N("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),ie),Hn=M(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),ie),lb=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),sb=M(N(Ee,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),cb=M(N(Ee,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),db=M(N(Ee,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),vY=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),tn=M(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),ur=M(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Gn=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),Un=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),z),Yn=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),z),Is=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),Wn=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ie),mb=M(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),wo=M(N("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),ie),vo=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),pb=M(N("g",{stroke:"currentColor",strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),z),ka=M(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ie),Cs=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),$m=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ie),Zm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ie),ub=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),z),_t=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),ie),Vn=M(N("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ie),Ma=M(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),ie),Pa=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),ie),La=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...ie,strokeWidth:1.5}),hb=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),on=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),ie),Xn=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),gb=M(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),jm=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),ie),Ss=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),ie),fb=M(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),ie),bb=M(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),xb=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Aa=M(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),ie),Eb=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),yb=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Kn=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),ie),TY=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),IY=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),ks=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),h("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),z),wb=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),z),Ms=M(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),z),vb=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),CY=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),SY=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),Tb=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),kY=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),qm=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),ie),Jm=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),ie),Ib=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),Cb=M(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),ie),MY=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),PY=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),LY=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),z),AY=M(N(Ee,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),DY=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),Sb=N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),kb=N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Qm=M(kb,z),ep=M(kb,{...z,style:{transform:"rotate(180deg)"}}),tp=M(Sb,z),op=M(Sb,{...z,style:{transform:"rotate(180deg)"}}),rp=M(N(Ee,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),np=M(N(Ee,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),ip=M(N(Ee,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),ap=M(N(Ee,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Mb=M(N(Ee,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Pb=M(N(Ee,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),lp=M(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),ie),sp=M(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),ie),Ps=M(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),_Y=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),RY=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Ut=M(N(Ee,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),NY=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),BY=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),FY=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),cp=it.memo(({theme:e})=>M(N(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:io(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:io(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:io(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:io(e),strokeWidth:"2"}),N("g",{fill:ob(e),stroke:io(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),dp=it.memo(({theme:e})=>M(N(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:io(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:io(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:io(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:io(e),strokeWidth:"2"}),N("g",{fill:ob(e),stroke:io(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Lb=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),ie),Ab=M(N(Ee,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),ie),Db=M(N(Ee,{children:[N("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),_b=M(N(Ee,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ie,fill:"currentColor"}),mp=M(h(Ee,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),Rb=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ie),Nb=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ie),OY=it.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:io(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Bb=M(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),z),Fb=M(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),z),Ob=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),ie),zb=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),ie),Hb=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),ie),Gb=M(N("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),ie),Ub=M(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),Yb=M(N("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),z),Wb=it.memo(({flip:e=!1})=>M(N("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Vb=it.memo(({flip:e=!1})=>M(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Xb=it.memo(({flip:e=!1})=>M(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Kb=it.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),$b=it.memo(({flip:e=!1})=>M(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Zb=it.memo(({flip:e=!1})=>M(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),jb=it.memo(({flip:e=!1})=>M(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),qb=it.memo(({flip:e=!1})=>M(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Jb=it.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Qb=it.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),e0=it.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),t0=M(N(Ee,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),o0=M(N(Ee,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),r0=M(N(Ee,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),n0=M(h(Ee,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),rn=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),z),i0=M(h(Ee,{children:N("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),z),Da=M(h(Ee,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),ie),Ls=M(N(Ee,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),a0=M(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),l0=M(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),s0=M(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),c0=it.memo(({theme:e})=>M(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),d0=it.memo(({theme:e})=>M(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),m0=it.memo(({theme:e})=>M(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),As=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),z),p0=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),zY=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Ds=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),z),pp=M(N(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),z),$n=M(N(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),u0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),z),h0=M(N(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),HY=M(N(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),z),GY=M(N(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),z),g0=M(N(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),z),f0=M(N(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),z),b0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),z),_a=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),z),ao=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),z),Zn=M(h("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),jn=M(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ie),hr=M(N("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),nn=M(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),UY=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),YY=M(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),z),x0=M(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),qn=M(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),z),E0=M(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),z),y0=M(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),w0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),Rt=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),z),v0=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),T0=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),I0=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),z),Ra=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),C0=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),z),S0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),z),k0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),M0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),up=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),z),_s=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),P0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),L0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),z),A0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),z),D0=M(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),_0=M(N("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...z,strokeWidth:1.5}),WY=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),z),R0=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),z),N0=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),z),B0=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),Jn=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),z),Qn=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),z),ei=M(N("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),Rs=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),z),F0=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),O0=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),hp=M(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),Ns=M(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),z),VY=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),z),z0=M(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),z),H0=M(N("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),z);import G0 from"clsx";import fp,{useEffect as sS,useRef as U0,useState as cS}from"react";import{isPromiseLike as dS}from"@excalidraw/common";import aS from"react";import{jsx as gp}from"react/jsx-runtime";var lS=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(aS.useRef(Date.now()).current%1600);return gp("div",{className:`Spinner ${r}`,children:gp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:gp("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},at=lS;import{jsx as Na,jsxs as Ba}from"react/jsx-runtime";var K=fp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=Se(),a=fp.useRef(null);fp.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,d]=cS(!1),m=U0(!0),c=async u=>{let f="onClick"in r&&r.onClick?.(u);if(dS(f))try{d(!0),await f}catch(b){if(b instanceof _n)console.warn(b);else throw b}finally{m.current&&d(!1)}};sS(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=U0(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Ba("button",{className:G0("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type==="icon"}),style:r.style,"data-testid":r["data-testid"],hidden:r.hidden,title:r.title,"aria-label":r["aria-label"],type:u,onClick:c,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Ba("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&Na("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&Na(at,{})]}),r.showAriaLabel&&Ba("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&Na(at,{})]}),r.children]})}return Ba("label",{className:G0("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Na("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),Ba("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&Na("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});K.displayName="ToolButton";var Bs=[],O=e=>(Bs=Bs.concat(e),e);import{jsx as ES}from"react/jsx-runtime";var xS=(e,o,t)=>{let r=new Set(Q(e.filter(m=>gS(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let c=fS(e,m);for(let p of c)if(!a.has(p.id)){if(Fs(p)){let u=W0(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let c=Fs(m)?W0(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):c?.frameId&&r.has(c?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&hS(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),zs(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,Fs(m)||(n[m.id]=!0),zs(m,{frameId:null})):Fs(m)&&o.selectedElementIds[m.containerId]?zs(m,{isDeleted:!0}):m}),d=o.editingGroupId;if(l&&o.editingGroupId){let m=Ep(s,o.editingGroupId).filter(c=>!c.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{d=null,m[0]&&(n[m[0].id]=!0);let c=m[0];if(c){let p=c.groupIds.findIndex(f=>f===o.editingGroupId),u=c.groupIds[p+1];if(u){let f=Ep(s,u).filter(b=>!b.isDeleted);f.length>1&&(d=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...bS({selectedElementIds:n,editingGroupId:d},s,o,null)}}},V0=(e,o)=>{if(e.editingGroupId){let t=Ep(xp(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Fa=O({name:"deleteSelectedElements",label:"labels.delete",icon:_t,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:d}=o.selectedLinearElement,m=r.scene.getNonDeletedElementsMap(),c=Y0.getElement(a,m);if(!c||l==null)return!1;if(l.length>=c.points.length){let u=e.map(b=>b.id===c.id?zs(b,{isDeleted:!0}):b),f=V0(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:Os.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(c.points.length-1)?null:d};return Y0.deletePoints(c,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:Os.IMMEDIATELY}}let{elements:n,appState:i}=xS(e,o,r);return uS(n,n.filter(a=>a.isDeleted)),i=V0(i,n),{elements:n,appState:{...i,activeTool:pS(o,{type:r.state.preferredSelectionTool.type}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:we(xp(e),o)?Os.IMMEDIATELY:Os.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===bp.BACKSPACE||e.key===bp.DELETE)&&!e[bp.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=et()==="mobile";return ES(K,{type:"button",icon:_t,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),disabled:!we(xp(e),o),style:{...n&&o.openPopup!=="compactOtherProperties"?mS:{}}})}});import{KEYS as ti,CODES as oi,isDarwin as Hs}from"@excalidraw/common";import{moveOneLeft as yS,moveOneRight as wS,moveAllLeft as vS,moveAllRight as TS}from"@excalidraw/element";import{CaptureUpdateAction as Gs}from"@excalidraw/element";import{isDarwin as X0}from"@excalidraw/common";var _=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,X0?g("keys.option"):g("keys.alt")).replace(/\bShift\b/i,g("keys.shift")).replace(/\b(Enter|Return)\b/i,g("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,X0?g("keys.cmd"):g("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,g("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,g("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,g("keys.delete"));import{jsx as Us}from"react/jsx-runtime";var yp=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:ep,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:yS(e,o,r.scene),appState:o,captureUpdate:Gs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ti.CTRL_OR_CMD]&&!e.shiftKey&&e.code===oi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Us("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${_("CtrlOrCmd+[")}`,children:ep})}),wp=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Qm,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:wS(e,o,r.scene),appState:o,captureUpdate:Gs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ti.CTRL_OR_CMD]&&!e.shiftKey&&e.code===oi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Us("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${_("CtrlOrCmd+]")}`,children:Qm})}),vp=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:op,trackEvent:{category:"element"},perform:(e,o)=>({elements:vS(e,o),appState:o,captureUpdate:Gs.IMMEDIATELY}),keyTest:e=>Hs?e[ti.CTRL_OR_CMD]&&e.altKey&&e.code===oi.BRACKET_LEFT:e[ti.CTRL_OR_CMD]&&e.shiftKey&&e.code===oi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Us("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${Hs?_("CtrlOrCmd+Alt+["):_("CtrlOrCmd+Shift+[")}`,children:op})}),Tp=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:tp,trackEvent:{category:"element"},perform:(e,o)=>({elements:TS(e,o),appState:o,captureUpdate:Gs.IMMEDIATELY}),keyTest:e=>Hs?e[ti.CTRL_OR_CMD]&&e.altKey&&e.code===oi.BRACKET_RIGHT:e[ti.CTRL_OR_CMD]&&e.shiftKey&&e.code===oi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Us("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${Hs?_("CtrlOrCmd+Alt+]"):_("CtrlOrCmd+Shift+]")}`,children:tp})});import{getNonDeletedElements as IS}from"@excalidraw/element";import{LinearElementEditor as CS}from"@excalidraw/element";import{isLinearElement as SS,isTextElement as kS}from"@excalidraw/element";import{arrayToMap as MS,KEYS as K0}from"@excalidraw/common";import{selectGroupsForSelectedElements as PS}from"@excalidraw/element";import{CaptureUpdateAction as LS}from"@excalidraw/element";var Ip=O({name:"selectAll",label:"labels.selectAll",icon:C0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(kS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...PS({editingGroupId:null,selectedElementIds:n},IS(e),o,r),selectedLinearElement:Object.keys(n).length===1&&SS(e[0])?new CS(e[0],MS(e)):null},captureUpdate:LS.IMMEDIATELY}},keyTest:e=>e[K0.CTRL_OR_CMD]&&e.key===K0.A});import{DEFAULT_GRID_SIZE as $0,KEYS as Z0,MOBILE_ACTION_BUTTON_BG as AS,arrayToMap as j0}from"@excalidraw/common";import{getNonDeletedElements as q0}from"@excalidraw/element";import{LinearElementEditor as DS}from"@excalidraw/element";import{getSelectedElements as _S,getSelectionStateForElements as RS}from"@excalidraw/element";import{syncMovedIndices as NS}from"@excalidraw/element";import{duplicateElements as BS}from"@excalidraw/element";import{CaptureUpdateAction as J0}from"@excalidraw/element";import{jsx as FS}from"react/jsx-runtime";var Cp=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ma,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=DS.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:J0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=BS({type:"in-place",elements:e,idsOfElementsToDuplicate:j0(_S(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+$0/2,y:a.y+$0/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:NS(i,j0(n)),appState:{...o,...RS(n,q0(i),o)},captureUpdate:J0.IMMEDIATELY}},keyTest:e=>e[Z0.CTRL_OR_CMD]&&e.key===Z0.D,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=et()==="mobile";return FS(K,{type:"button",icon:Ma,title:`${g("labels.duplicateSelection")} \u2014 ${_("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),disabled:!we(q0(e),o),style:{...n&&o.openPopup!=="compactOtherProperties"?AS:{}}})}});import{pointFrom as B4}from"@excalidraw/math";import{useEffect as Kp,useMemo as F4,useRef as $p,useState as O4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as z4,DEFAULT_ELEMENT_BACKGROUND_PICKS as H4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as G4,DEFAULT_ELEMENT_STROKE_PICKS as U4,ARROW_TYPE as Yo,DEFAULT_FONT_FAMILY as Y4,DEFAULT_FONT_SIZE as W4,FONT_FAMILY as V4,ROUNDNESS as lc,STROKE_WIDTH as Zp,VERTICAL_ALIGN as ac,KEYS as pi,randomInteger as X4,arrayToMap as Jp,getFontFamilyString as K4,getLineHeight as $4,isTransparent as Z4,reduceToCommonValue as j4}from"@excalidraw/common";import{canBecomePolygon as q4,getNonDeletedElements as Wx}from"@excalidraw/element";import{bindLinearElement as Hx,calculateFixedPointForElbowArrowBinding as Gx,updateBoundElements as J4}from"@excalidraw/element";import{LinearElementEditor as jp}from"@excalidraw/element";import{newElementWith as qe}from"@excalidraw/element";import{getBoundTextElement as Tr,redrawTextBoundingBox as Za}from"@excalidraw/element";import{isArrowElement as sc,isBoundToContainer as Q4,isElbowArrow as Vx,isLinearElement as qp,isLineElement as Ux,isTextElement as Ct,isUsingAdaptiveRadius as ek}from"@excalidraw/element";import{hasStrokeColor as tk}from"@excalidraw/element";import{updateElbowArrowPoints as ok,CaptureUpdateAction as Je,toggleLinePolygonState as rk}from"@excalidraw/element";import{deriveStylesPanelMode as nk}from"@excalidraw/common";import{isDevEnv as OS}from"@excalidraw/common";var zS=new Set(["command_palette","export"]),ae=(e,o,t,r)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!zS.has(e)||OS())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import YS from"clsx";import HS from"clsx";import{forwardRef as GS}from"react";import{jsx as US}from"react/jsx-runtime";var ri=GS((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return US("button",{type:"button",ref:o,title:t,"data-testid":n,className:HS(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as VS,jsx as Sp,jsxs as WS}from"react/jsx-runtime";var Yt=e=>Sp(VS,{children:e.options.map(o=>e.type==="button"?Sp(ri,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):WS("label",{className:YS({active:e.value===o.value}),title:o.text,children:[Sp("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as qs from"@radix-ui/react-popover";import yx from"clsx";import{useRef as wx,useEffect as W6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as xx,COLOR_PALETTE as vx,isTransparent as V6,isWritableElement as X6}from"@excalidraw/common";import{jsx as XS}from"react/jsx-runtime";var Ys=()=>XS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as qS,useRef as JS}from"react";import{createPortal as QS}from"react-dom";import{EVENT as fr,KEYS as e6,rgbToHex as t6}from"@excalidraw/common";import Q0 from"react";var kp=Q0.createContext(null),xe=()=>Q0.useContext(kp);import{useState as KS,useLayoutEffect as ex}from"react";import{THEME as $S}from"@excalidraw/common";var Ws=e=>{let[o,t]=KS(null),r=pe(),{theme:n}=xe(),{container:i}=Se();return ex(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.formFactor==="phone"),o.classList.toggle("theme--dark",n===$S.DARK))},[o,n,r.formFactor,e?.className]),ex(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as ZS}from"react";import{EVENT as Vs}from"@excalidraw/common";function ni(e,o,t){ZS(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(Vs.POINTER_DOWN,r),document.addEventListener(Vs.TOUCH_START,r),()=>{document.removeEventListener(Vs.POINTER_DOWN,r),document.removeEventListener(Vs.TOUCH_START,r)}},[e,o,t])}import{useRef as jS}from"react";var gr=e=>{let o=jS(e);return Object.assign(o.current,e),o.current};import{jsx as o6}from"react/jsx-runtime";var br=he(null),tx=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=Ws({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=xe(),a=xr(),l=Oe(),s=Q(a,i),d=gr({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=Se();qS(()=>{let p=c.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:k,clientY:P})=>{let S=f.getImageData((k-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return t6(S[0],S[1],S[2])},x=({clientX:k,clientY:P,altKey:S})=>{p.style.top=`${P+20}px`,p.style.left=`${k+20}px`;let B=b({clientX:k,clientY:P});u&&d.onChange(r,B,d.selectedElements,{altKey:S}),p.style.background=B},w=()=>{d.onCancel()},E=(k,P)=>{d.onSelect(k,P)},y=k=>{u=!0,k.stopImmediatePropagation()},v=k=>{u=!1,m?.focus(),k.stopImmediatePropagation(),k.preventDefault(),E(b(k),k)},I=k=>{k.key===e6.ESCAPE&&(k.preventDefault(),k.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:d.app.lastViewportPosition.x,clientY:d.app.lastViewportPosition.y,altKey:!1}),n.addEventListener(fr.KEYDOWN,I),n.addEventListener(fr.POINTER_DOWN,y),n.addEventListener(fr.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(fr.BLUR,w),()=>{u=!1,n.removeEventListener(fr.KEYDOWN,I),n.removeEventListener(fr.POINTER_DOWN,y),n.removeEventListener(fr.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(fr.BLUR,w)}},[d,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let c=JS(null);return ni(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?QS(o6("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),n):null};import*as ii from"@radix-ui/react-popover";import a6 from"clsx";import l6 from"react";import{isInteractive as s6}from"@excalidraw/common";import r6 from"react";import n6 from"clsx";import{jsx as i6}from"react/jsx-runtime";var Ye=r6.forwardRef(({children:e,padding:o,className:t,style:r},n)=>i6("div",{className:n6("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Mp,jsxs as c6}from"react/jsx-runtime";var Go=l6.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:d=!1},m)=>{let c=pe(),p=c.formFactor==="phone"&&!c.isLandscape;return Mp(ii.Portal,{container:o,children:c6(ii.Content,{ref:m,className:a6("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:c.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:u=>{d&&c.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),o&&!s6(document.activeElement)&&o.focus(),n()},children:[Mp(Ye,{padding:3,style:r,children:t}),Mp(ii.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as d6,useCallback as Pp}from"react";var Xs=()=>document.querySelector(".excalidraw-wysiwyg"),Ks=()=>{let e=Xs();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Oa=e=>{setTimeout(()=>{let o=Xs();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},za=(e,o,t,r)=>{o&&r&&r();let n=o&&t?Ks():null;e(),o&&t&&Oa(n)},ox=()=>{let[e,o]=d6(null),t=Pp(()=>{let i=Ks();o(i)},[]),r=Pp(()=>{setTimeout(()=>{let i=Xs();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),n=Pp(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:r,clearSavedPosition:n,hasSavedPosition:!!e}},rx=(e=100)=>{let o=Xs();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import p6 from"clsx";import{useCallback as u6,useEffect as Ap,useRef as ax,useState as h6}from"react";import{KEYS as Dp}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as m6}from"@excalidraw/common";var Er=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},Ha=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Lp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),ix=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Lp({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,m6)},Wt=he(null),nx=(e,o,t)=>(e*299+o*587+t*114)/1e3,an=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),d=parseInt(l[1]),m=parseInt(l[2]);return nx(s,d,m)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return nx(t,r,n)<o};import{Fragment as g6,jsx as $s,jsxs as lx}from"react/jsx-runtime";var sx=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=pe(),[a,l]=h6(e),[s,d]=de(Wt);Ap(()=>{l(e)},[e]);let m=u6(b=>{let x=b.toLowerCase(),w=cx(x);w&&o(w),l(x)},[o]),c=ax(null),p=ax(null);Ap(()=>{c.current&&c.current.focus()},[s]);let[u,f]=de(br);return Ap(()=>()=>{f(null)},[f]),lx("div",{className:"color-picker__input-label",children:[$s("div",{className:"color-picker__input-hash",children:"#"}),$s("input",{ref:s==="hex"?c:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>d("hex"),onKeyDown:b=>{b.key!==Dp.TAB&&(b.key===Dp.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),i.formFactor!=="phone"&&lx(g6,{children:[$s("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),$s("div",{ref:p,className:p6("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${Dp.I.toLocaleUpperCase()} or ${_("Alt")} `,children:b0})]})]})};import Bp,{useEffect as Fp,useImperativeHandle as R6,useState as N6}from"react";import{EVENT as gx}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as B6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as F6,KEYS as O6}from"@excalidraw/common";import x6 from"clsx";import{useEffect as E6,useRef as y6}from"react";import{jsxs as b6}from"react/jsx-runtime";var f6=({color:e,keyLabel:o,isShade:t=!1})=>b6("div",{className:"color-picker__button__hotkey-label",style:{color:an(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ai=f6;import{jsx as _p,jsxs as w6}from"react/jsx-runtime";var dx=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=de(Wt),a=y6(null);return E6(()=>{a.current&&a.current.focus()},[o,n]),_p("div",{className:"color-picker-content--default",children:e.map((l,s)=>w6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:x6("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[_p("div",{className:"color-picker__button-outline"}),_p(ai,{color:l,keyLabel:s+1})]},s))})};import v6 from"clsx";import{useEffect as T6,useRef as I6}from"react";import{jsx as Rp,jsxs as S6}from"react/jsx-runtime";var C6=({palette:e,color:o,onChange:t,activeShade:r,showHotKey:n=!0})=>{let i=Er({color:o,palette:e}),[a,l]=de(Wt),s=I6(null);return T6(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),Rp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([d,m],c)=>{let p=(Array.isArray(m)?m[r]:m)||"transparent",u=Ha[c],f=g(`colors.${d.replace(/\d+/,"")}`,null,"");return S6("button",{ref:i?.colorName===d?s:void 0,tabIndex:-1,type:"button",className:v6("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===d,"is-transparent":p==="transparent"||!p}),onClick:()=>{t(p),l("baseColors")},title:`${f}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${f} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${d}`,children:[Rp("div",{className:"color-picker__button-outline"}),n&&Rp(ai,{color:p,keyLabel:u})]},d)})})},mx=C6;import{jsx as M6}from"react/jsx-runtime";var k6=({children:e})=>M6("div",{className:"color-picker__heading",children:e}),li=k6;import P6 from"clsx";import{useEffect as L6,useRef as A6}from"react";import{jsx as Ga,jsxs as px}from"react/jsx-runtime";var ux=({color:e,onChange:o,palette:t,showHotKey:r})=>{let n=Er({color:e||"transparent",palette:t}),[i,a]=de(Wt),l=A6(null);if(L6(()=>{l.current&&i==="shades"&&l.current.focus()},[n,i]),n){let{colorName:s,shade:d}=n,m=t[s];if(Array.isArray(m))return Ga("div",{className:"color-picker-content--default shades",children:m.map((c,p)=>px("button",{ref:p===d&&i==="shades"?l:void 0,tabIndex:-1,type:"button",className:P6("color-picker__button color-picker__button--large has-outline",{active:p===d}),"aria-label":"Shade",title:`${s} - ${p+1}`,style:c?{"--swatch-color":c}:void 0,onClick:()=>{o(c),a("shades")},children:[Ga("div",{className:"color-picker__button-outline"}),r&&Ga(ai,{color:c,keyLabel:p+1,isShade:!0})]},p))})}return px("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ga("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ga("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as si,COLOR_PALETTE as D6,KEYS as Ua}from"@excalidraw/common";var Np=(e,o,t)=>{let r=Math.ceil(t/si);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+si;return n>=t?o%si:n}case"ArrowUp":{let n=o-si,i=n<0?si*r+n:n;return i>=t?void 0:i}}},_6=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(Ha.includes(e.key)){let l=Ha.indexOf(e.key),s=Object.keys(r)[l],d=r[s],m=Array.isArray(d)?d[a]:d;return t(m),i("baseColors"),!0}return!1},hx=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:m})=>{if(e[Ua.CTRL_OR_CMD])return!1;if(e.key===Ua.ESCAPE)return m(e),!0;if(e.key===Ua.ALT)return d(!0),!0;if(e.key===Ua.I)return d(),!0;let c=Er({color:r,palette:t});if(e.key===Ua.TAB){let p={custom:!!i.length,baseColors:!0,shades:c?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?n(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(D6.black)),e.preventDefault(),e.stopPropagation(),!0}if(_6({e,colorObj:c,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&c){let{shade:p}=c,u=Np(e.key,p,si);if(u!==void 0)return n(t[c.colorName][u]),!0}if(o==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(t),f=u.indexOf(p),b=Np(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return n(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=Np(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as yr,jsxs as Zs}from"react/jsx-runtime";var fx=Bp.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,showTitle:l,onEyeDropperToggle:s,onEscape:d,showHotKey:m=!0},c)=>{let p=l?t==="elementStroke"?g("labels.stroke"):t==="elementBackground"?g("labels.background"):null:null,[u]=Bp.useState(()=>t==="canvasBackground"?[]:ix(r,t,n)),[f,b]=de(Wt),x=Er({color:e,palette:n});Fp(()=>{if(!f){let v=!!e&&Lp({color:e,palette:n}),I=v&&!u.includes(e);b(I?null:v?"custom":x?.shade!=null?"shades":"baseColors")}},[f,e,n,b,x,u]);let[w,E]=N6(x?.shade??(t==="elementBackground"?B6:F6));Fp(()=>{x?.shade!=null&&E(x.shade);let v=I=>{I.key===O6.ALT&&s(!1)};return document.addEventListener(gx.KEYUP,v,{capture:!0}),()=>{document.removeEventListener(gx.KEYUP,v,{capture:!0})}},[x,s]);let y=Bp.useRef(null);return R6(c,()=>y.current),Fp(()=>{y?.current?.focus()},[]),yr("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:Zs("div",{ref:y,onKeyDown:v=>{hx({event:v,activeColorPickerSection:f,palette:n,color:e,onChange:o,onEyeDropperToggle:s,customColors:u,setActiveColorPickerSection:b,updateData:i,activeShade:w,onEscape:d})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[p&&yr("div",{className:"color-picker__title",children:p}),!!u.length&&Zs("div",{children:[yr(li,{children:g("colorPicker.mostUsedCustomColors")}),yr(dx,{colors:u,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),Zs("div",{children:[yr(li,{children:g("colorPicker.colors")}),yr(mx,{color:e,palette:n,onChange:o,activeShade:w,showHotKey:m})]}),Zs("div",{children:[yr(li,{children:g("colorPicker.shades")}),yr(ux,{color:e,onChange:o,palette:n,showHotKey:m})]}),a]})})});import z6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as H6,DEFAULT_CANVAS_BACKGROUND_PICKS as G6,DEFAULT_ELEMENT_BACKGROUND_PICKS as U6,DEFAULT_ELEMENT_STROKE_PICKS as Y6}from"@excalidraw/common";import{jsx as Op}from"react/jsx-runtime";var bx=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=Y6),o==="elementBackground"&&(n=U6),o==="canvasBackground"&&(n=G6),r&&(n=r),n?Op("div",{className:"color-picker__top-picks",children:n.map(i=>Op("button",{className:z6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!an(i,H6)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Op("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Vt,jsxs as js}from"react/jsx-runtime";var Ex=e=>{let o=new Option().style;return o.color=e,!!o.color},cx=e=>V6(e)?e:Ex(`#${e}`)?`#${e}`:Ex(e)?e:null,K6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=vx,updateData:a,getOpenPopup:l,appState:s})=>{let{container:d}=Se(),m=et(),c=m!=="full",p=m==="mobile",[,u]=de(Wt),[f,b]=de(br),x=js("div",{children:[Vt(li,{children:g("colorPicker.hexCode")}),Vt(sx,{color:o||"",label:r,onChange:y=>{t(y)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),w=wx(null),E=()=>{w.current?.focus()};return Vt(Go,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:y=>{X6(y.target)||E(),y.preventDefault()},onPointerDownOutside:y=>{f&&y.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),u(null),s.editingTextElement&&setTimeout(()=>{let y=document.querySelector(".excalidraw-wysiwyg");y&&y.focus()},0)},children:i?Vt(fx,{ref:w,palette:i,color:o,onChange:y=>{let v=s.editingTextElement?Ks():null;t(y),s.editingTextElement&&v&&Oa(v)},onEyeDropperToggle:y=>{b(v=>y?(v=v||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},v.keepOpenOnAlt=!0,v):y===!1||v?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:y=>{f?b(null):a({openPopup:null})},type:e,elements:n,updateData:a,showTitle:c,showHotKey:!p,children:x}):x})},$6=({label:e,color:o,type:t,mode:r="background",onToggle:n,editingTextElement:i})=>{let a=et(),l=a!=="full",s=a==="mobile",d=m=>{m.preventDefault(),m.stopPropagation(),i&&rx(),n()};return js(qs.Trigger,{type:"button",className:yx("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!an(o,xx),"compact-sizing":l,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:d,children:[Vt("div",{className:"color-picker__button-outline",children:!o&&wb}),l&&o&&r==="stroke"&&Vt("div",{className:"color-picker__button-background",children:Vt("span",{style:{color:o&&an(o,xx)?"#fff":"#111"},children:H0})})]})},Ya=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=vx,topPicks:a,updateData:l,appState:s})=>{let d=wx(s.openPopup);W6(()=>{d.current=s.openPopup},[s.openPopup]);let c=et()!=="full";return Vt("div",{children:js("div",{role:"dialog","aria-modal":"true",className:yx("color-picker-container",{"color-picker-container--no-top-picks":c}),children:[!c&&Vt(bx,{activeColor:o,onChange:t,type:e,topPicks:a}),!c&&Vt(Ys,{}),js(qs.Root,{open:s.openPopup===e,onOpenChange:p=>{p&&l({openPopup:e})},children:[Vt($6,{color:o,label:r,type:e,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&Vt(K6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l,getOpenPopup:()=>d.current,appState:s})]})]})})};import*as Dx from"@radix-ui/react-popover";import T4 from"clsx";import I4,{useCallback as C4,useMemo as S4}from"react";import{FONT_FAMILY as Yp}from"@excalidraw/common";import h4,{useMemo as wr,useState as g4,useRef as f4,useEffect as b4,useCallback as Sx}from"react";import{arrayToList as x4,debounce as E4,FONT_FAMILY as ln,getFontFamilyString as y4}from"@excalidraw/common";import Z6 from"clsx";import j6 from"react";import{jsx as q6,jsxs as J6}from"react/jsx-runtime";var Js=j6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>J6("div",{className:Z6("QuickSearch__wrapper",e),children:[Rt,q6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import Q6 from"clsx";import{Children as e4}from"react";import{jsx as Tx}from"react/jsx-runtime";var Qs=({className:e,placeholder:o,children:t})=>{let r=!e4.count(t);return Tx("div",{className:Q6("ScrollableList__wrapper",e),role:"menu",children:r?Tx("div",{className:"empty",children:o}):t})};import{jsx as t4,jsxs as o4}from"react/jsx-runtime";var Ix=({children:e,className:o="",style:t,title:r})=>o4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&t4("p",{className:"dropdown-menu-group-title",children:r}),e]}),Wa=Ix;Ix.displayName="DropdownMenuGroup";import{useEffect as m4,useRef as p4}from"react";import{THEME as u4}from"@excalidraw/common";import{jsx as r4}from"react/jsx-runtime";var Va=({children:e,...o})=>r4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as i4,jsx as ec,jsxs as a4}from"react/jsx-runtime";var n4=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=pe();return a4(i4,{children:[o&&ec("div",{className:"dropdown-menu-item__icon",children:o}),ec("div",{style:e,className:"dropdown-menu-item__text",children:ec(Va,{children:r})}),t&&n.formFactor!=="phone"&&ec("div",{className:"dropdown-menu-item__shortcut",children:t})]})},tc=n4;import l4,{useContext as s4}from"react";import{EVENT as c4,composeEventHandlers as d4}from"@excalidraw/common";var zp=l4.createContext({}),oc=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
+
${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),rc=(e,o)=>{let t=s4(zp);return d4(e,r=>{let n=new CustomEvent(c4.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as Hp}from"react/jsx-runtime";var Gp=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:d,onClick:m,...c})=>{let p=rc(m,d),u=p4(null);return m4(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Hp("button",{...c,ref:u,value:o,onClick:p,className:oc(i,l,a),title:c.title??c["aria-label"],children:Hp(tc,{textStyle:s,icon:e,shortcut:n,children:r})})};Gp.displayName="DropdownMenuItem";var ci={GREEN:"green",RED:"red",BLUE:"blue"},nc=({type:e=ci.BLUE,children:o})=>{let{theme:t}=To(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===u4.LIGHT?"1.5px solid white":"none"};switch(e){case ci.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ci.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case ci.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Hp("div",{className:"DropDownMenuItemBadge",style:r,children:o})};nc.displayName="DropdownMenuItemBadge";Gp.Badge=nc;var gt=Gp;import{KEYS as di}from"@excalidraw/common";var Cx=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[di.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===di.F)return o.current?.focus(),!0;if(e.key===di.ESCAPE)return n(),!0;if(e.key===di.ENTER)return t?.value&&i(t.value),!0;if(e.key===di.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===di.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Xa,jsxs as kx}from"react/jsx-runtime";var w4=e=>{switch(e){case ln.Excalifont:case ln.Virgil:return wo;case ln.Nunito:case ln.Helvetica:return Da;case ln["Lilita One"]:return i0;case ln["Comic Shanns"]:case ln.Cascadia:return Ls;default:return Da}},Mx=h4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=Se(),s=Oe(),{fonts:d}=s,{showDeprecatedFonts:m}=Io(),c=et(),[p,u]=g4(""),f=f4(null),b=wr(()=>Array.from(dr.registered.entries()).filter(([L,{metadata:R}])=>!R.private&&!R.fallback).map(([L,{metadata:R,fontFaces:Y}])=>{let q={value:L,icon:w4(L),text:Y[0]?.fontFace?.family??"Unknown"};return R.deprecated&&Object.assign(q,{deprecated:R.deprecated,badge:{type:ci.RED,placeholder:g("fontList.badge.old")}}),q}).sort((L,R)=>L.text.toLowerCase()>R.text.toLowerCase()?1:-1),[]),x=wr(()=>new Set(d.getSceneFamilies()),[e]),w=wr(()=>b.filter(L=>x.has(L.value)),[b,x]),E=wr(()=>b.filter(L=>!x.has(L.value)&&(m||!L.deprecated)),[b,x,m]),y=wr(()=>x4([...w,...E].filter(L=>L.text?.toLowerCase().includes(p))),[w,E,p]),v=wr(()=>{let L;return o?L=y.find(R=>R.value===o):e&&(L=y.find(R=>R.value===e)),!L&&p&&(y[0]?.value?r(y[0].value):n()),L},[o,e,p,y,r,n]),I=Sx(L=>{let R=null;if(s.state.editingTextElement){let Y=document.querySelector(".excalidraw-wysiwyg");Y&&(R={start:Y.selectionStart,end:Y.selectionEnd})}t(L),s.state.editingTextElement&&R&&setTimeout(()=>{let Y=document.querySelector(".excalidraw-wysiwyg");Y&&R&&(Y.focus(),Y.selectionStart=R.start,Y.selectionEnd=R.end)},0)},[t,s.state.editingTextElement]),k=Sx(L=>{Cx({event:L,inputRef:f,hoveredFont:v,filteredFonts:y,onSelect:I,onHover:r,onClose:a})&&(L.preventDefault(),L.stopPropagation())},[v,y,I,r,a]);b4(()=>(i(),()=>{a()}),[]);let P=wr(()=>y.filter(L=>x.has(L.value)),[y,x]),S=wr(()=>y.filter(L=>!x.has(L.value)),[y,x]),B=(L,R)=>kx(gt,{icon:L.icon,value:L.value,order:R,textStyle:{fontFamily:y4({fontFamily:L.value})},hovered:L.value===v?.value,selected:L.value===e,tabIndex:L.value===e?0:-1,onClick:Y=>{I(Number(Y.currentTarget.value))},onMouseMove:()=>{v?.value!==L.value&&r(L.value)},children:[L.text,L.badge&&Xa(nc,{type:L.badge.type,children:L.badge.placeholder})]},L.value),A=[];return P.length&&A.push(Xa(Wa,{title:g("fontList.sceneFonts"),children:P.map(B)},"group_1")),S.length&&A.push(Xa(Wa,{title:g("fontList.availableFonts"),children:S.map((L,R)=>B(L,R+P.length))},"group_2")),kx(Go,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let L=document.querySelector(".excalidraw-wysiwyg");L&&L.focus()},0)},onPointerLeave:n,onKeyDown:k,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[c==="full"&&Xa(Js,{ref:f,placeholder:g("quickSearch.placeholder"),onChange:E4(u,20)}),Xa(Qs,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:A.length?A:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Px from"@radix-ui/react-popover";import{MOBILE_ACTION_BUTTON_BG as v4}from"@excalidraw/common";import{jsx as Up}from"react/jsx-runtime";var Lx=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let r=me(),n=t?{...v4,width:"2rem",height:"2rem"}:{};return Up(Px.Trigger,{asChild:!0,children:Up("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Up(ri,{standalone:!0,icon:vo,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{r(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...n}})})})};import{jsx as Ka,jsxs as Ax}from"react/jsx-runtime";var _x=[{value:Yp.Excalifont,icon:wo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Yp.Nunito,icon:Da,text:g("labels.normal"),testId:"font-family-normal"},{value:Yp["Comic Shanns"],icon:Ls,text:g("labels.code"),testId:"font-family-code"}],JZ=new Set(_x.map(e=>e.value));var Rx=I4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=S4(()=>_x,[]),d=C4(m=>{m&&r(m)},[r]);return Ax("div",{role:"dialog","aria-modal":"true",className:T4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Ka("div",{className:"buttonList",children:Ka(Yt,{type:"button",options:s,value:o,onClick:d})}),!l&&Ka(Ys,{}),Ax(Dx.Root,{open:e,onOpenChange:a,children:[Ka(Lx,{selectedFontFamily:o,isOpened:e,compactMode:l}),e&&Ka(Mx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:d,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as mi from"@radix-ui/react-popover";import L4 from"clsx";import ic,{useEffect as A4}from"react";import{isArrowKey as D4,KEYS as Uo}from"@excalidraw/common";import{jsx as k4}from"react/jsx-runtime";var vr=({className:e,icon:o,size:t="1em"})=>k4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as P4,jsx as Nx,jsxs as Bx}from"react/jsx-runtime";var M4=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>Bx(P4,{children:[Bx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&Nx(vr,{icon:o?F0:Rs})]}),o&&Nx("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),$a=M4;import{jsx as sn,jsxs as Wp}from"react/jsx-runtime";var _4=he(!1);function R4({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=pe(),{container:l}=Se(),s=b=>{let x=e.find(w=>w.keyBinding===b.key.toLowerCase());if(!(b.metaKey||b.altKey||b.ctrlKey)&&x)r(x.value),b.preventDefault();else if(b.key===Uo.TAB){let w=e.findIndex(y=>y.value===o),E=b.shiftKey?(e.length+w-1)%e.length:(w+1)%e.length;r(e[E].value)}else if(D4(b.key)){let w=Ho().rtl,E=e.findIndex(y=>y.value===o);if(E!==-1){let y=e.length,v=E;switch(b.key){case(w?Uo.ARROW_LEFT:Uo.ARROW_RIGHT):v=(E+1)%y;break;case(w?Uo.ARROW_RIGHT:Uo.ARROW_LEFT):v=(y+E-1)%y;break;case Uo.ARROW_DOWN:{v=(E+(i??1))%y;break}case Uo.ARROW_UP:{v=(y+E-(i??1))%y;break}}r(e[v].value)}b.preventDefault()}else(b.key===Uo.ESCAPE||b.key===Uo.ENTER)&&(b.preventDefault(),n());b.nativeEvent.stopImmediatePropagation(),b.stopPropagation()},[d,m]=de(_4),c=ic.useMemo(()=>e.slice(0,i),[e,i]),p=ic.useMemo(()=>e.slice(i),[e,i]);A4(()=>{c.some(b=>b.value===o)||m(!0)},[o,c,m]);let u=b=>sn("div",{className:"picker-content",children:b.map((x,w)=>Wp("button",{type:"button",className:L4("picker-option",{active:o===x.value}),onClick:E=>{r(x.value)},title:`${x.text} ${x.keyBinding&&`\u2014 ${x.keyBinding.toUpperCase()}`}`,"aria-label":x.text||"none","aria-keyshortcuts":x.keyBinding||void 0,ref:E=>{o===x.value&&setTimeout(()=>{E?.focus()},0)},children:[x.icon,x.keyBinding&&sn("span",{className:"picker-keybinding",children:x.keyBinding})]},x.text))}),f=a.formFactor==="phone";return sn(mi.Content,{side:f?"right":"bottom",align:"start",sideOffset:f?8:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:s,collisionBoundary:l??void 0,children:Wp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[u(c),p.length>0&&sn($a,{label:g("labels.more_options"),open:d,openTrigger:()=>{m(b=>!b)},className:"picker-collapsible",children:u(p)})]})})}function Vp({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=ic.useState(!1),s=ic.useRef(null);return sn("div",{children:Wp(mi.Root,{open:a,onOpenChange:d=>l(d),children:[sn(mi.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(d=>d.value===e)?.icon}),a&&sn(R4,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Fx,{useEffect as N4}from"react";import{jsx as Xp,jsxs as Ox}from"react/jsx-runtime";var zx=({updateData:e,app:o,testId:t})=>{let r=Fx.useRef(null),n=Fx.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),d=i.reduce((m,c)=>(m!=null&&m!==c.opacity&&(a=!1),m==null||m>c.opacity?c.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return N4(()=>{if(r.current&&n.current){let m=r.current,c=n.current,p=m.offsetWidth,u=15,f=d/100*(p-u)+u/2;c.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${d}%, var(--button-bg) ${d}%, var(--button-bg) 100%)`}},[d]),Ox("label",{className:"control-label",children:[g("labels.opacity"),Ox("div",{className:"range-wrapper",children:[Xp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:d,className:"range-input","data-testid":t}),Xp("div",{className:"value-bubble",ref:n,children:d!==0?d:null}),Xp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as ou,jsx as re,jsxs as bt}from"react/jsx-runtime";var Xx=.1,ui=e=>{let o=nk(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},ft=(e,o,t,r=!1)=>{let n=Jp(Q(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},dt=function(e,o,t,r,n){let i=o.state.editingTextElement,a=Wx(e),l=null;if(i&&(l=t(i)),!l)if(we(a,o.state)){let d=o.scene.getSelectedElements(o.state),m=r===!0?d:d.filter(c=>r(c));l=j4(m,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},ik=(e,o,t)=>Q4(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Qp=(e,o,t,r,n)=>{let i=new Set,a=ft(e,o,l=>{if(Ct(l)){let s=r(l);i.add(s);let d=qe(l,{fontSize:s});return Za(d,t.scene.getContainerElement(l),t.scene),d=ik(l,d,t.scene),d}return l},!0);return Q(e,o,{includeBoundTextElement:!0}).forEach(l=>{Ct(l)&&J4(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:Je.IMMEDIATELY}},ak=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:ft(e,o,r=>tk(r.type)?qe(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?Je.IMMEDIATELY:Je.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{stylesPanelMode:i}=ui(r);return bt(ou,{children:[i==="full"&&re("h3",{"aria-hidden":"true",children:g("labels.stroke")}),re(Ya,{topPicks:U4,palette:G4,type:"elementStroke",label:g("labels.stroke"),color:dt(e,r,a=>a.strokeColor,!0,a=>a?null:o.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:o,updateData:t})]})}}),lk=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Je.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!Z4(t.currentItemBackgroundColor)&&i.every(l=>Ux(l)&&q4(l.points))){let l=Jp(i);n=e.map(s=>l.has(s.id)&&Ux(s)?qe(s,{backgroundColor:t.currentItemBackgroundColor,...rk(s,!0)}):s)}else n=ft(e,o,l=>qe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{stylesPanelMode:i}=ui(r);return bt(ou,{children:[i==="full"&&re("h3",{"aria-hidden":"true",children:g("labels.background")}),re(Ya,{topPicks:H4,palette:z4,type:"elementBackground",label:g("labels.background"),color:dt(e,r,a=>a.backgroundColor,!0,a=>a?null:o.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:o,updateData:t})]})}}),sk=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(ae("element","changeFillStyle",`${t} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:ft(e,o,n=>qe(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Q(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return bt("fieldset",{children:[re("legend",{children:g("labels.fill")}),re("div",{className:"buttonList",children:re(Yt,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${_("Alt-Click")})`,icon:i?Lb:Ab,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:Db,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:_b,testId:"fill-solid"}],value:dt(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(d=>d.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),ck=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ft(e,o,r=>qe(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>bt("fieldset",{children:[re("legend",{children:g("labels.strokeWidth")}),re("div",{className:"buttonList",children:re(Yt,{group:"stroke-width",options:[{value:Zp.thin,text:g("labels.thin"),icon:mp,testId:"strokeWidth-thin"},{value:Zp.bold,text:g("labels.bold"),icon:Rb,testId:"strokeWidth-bold"},{value:Zp.extraBold,text:g("labels.extraBold"),icon:Nb,testId:"strokeWidth-extraBold"}],value:dt(e,r,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),dk=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ft(e,o,r=>qe(r,{seed:X4(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>bt("fieldset",{children:[re("legend",{children:g("labels.sloppiness")}),re("div",{className:"buttonList",children:re(Yt,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:Ob},{value:1,text:g("labels.artist"),icon:zb},{value:2,text:g("labels.cartoonist"),icon:Hb}],value:dt(e,r,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),oq=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ft(e,o,r=>qe(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>bt("fieldset",{children:[re("legend",{children:g("labels.strokeStyle")}),re("div",{className:"buttonList",children:re(Yt,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:mp},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:Bb},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:Fb}],value:dt(e,r,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),mk=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ft(e,o,r=>qe(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>re(zx,{updateData:o,app:e,testId:"opacity"})}),pk=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>Qp(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{isCompact:i}=ui(r);return bt("fieldset",{children:[re("legend",{children:g("labels.fontSize")}),re("div",{className:"buttonList",children:re(Yt,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:t0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:o0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:r0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:n0,testId:"fontSize-veryLarge"}],value:dt(e,r,a=>{if(Ct(a))return a.fontSize;let l=Tr(a,r.scene.getNonDeletedElementsMap());return l?l.fontSize:null},a=>Ct(a)||Tr(a,r.scene.getNonDeletedElementsMap())!==null,a=>a?null:o.currentItemFontSize||W4),onChange:a=>{za(()=>t(a),i,!!o.editingTextElement,n?.onPreventClose)}})})]})}}),eu=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:rn,trackEvent:!1,perform:(e,o,t,r)=>Qp(e,o,r,n=>Math.round(1/(1+Xx)*n.fontSize)),keyTest:e=>e[pi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===pi.CHEVRON_LEFT||e.key===pi.COMMA)}),tu=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:rn,trackEvent:!1,perform:(e,o,t,r)=>Qp(e,o,r,n=>Math.round(n.fontSize*(1+Xx))),keyTest:e=>e[pi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===pi.CHEVRON_RIGHT||e.key===pi.PERIOD)}),uk=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:ft(e,o,b=>{let x=n?.get(b.id);return x?qe(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:Je.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:d}=t,m=Je.EVENTUALLY,c,p=!1;if(s)c=s,m=Je.IMMEDIATELY;else if(d){c=d,m=Je.EVENTUALLY;let f=Q(e,o,{includeBoundTextElement:!0}).filter(b=>Ct(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(c&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(dr.loadedFontsCache.values()),E=Object.entries(V4).find(([I,k])=>k===c)?.[0];d&&E&&w.some(I=>I.startsWith(E))&&(x=!0),Object.assign(u,{elements:ft(e,o,I=>{if(Ct(I)&&(I.fontFamily!==c||s)){let k=qe(I,{fontFamily:c,lineHeight:$4(c)}),P=n?.get(I.containerId||"")||{},S=r.scene.getContainerElement(I);return a&&S&&P&&r.scene.mutateElement(S,{...P}),x||(b=new Set([...b,...Array.from(k.originalText)])),f.set(k,S),k}return I},!0)});let y=`10px ${K4({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[I,k]of f)Za(I,k,r.scene);else window.document.fonts.load(y,v).then(I=>{for(let[k,P]of f){let S=r.scene.getElement(k.id),B=P?r.scene.getElement(P.id):null;S&&Za(S,B,r.scene)}r.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=$p(new Map),i=$p(null),[a,l]=O4({}),s=$p(!0),{stylesPanelMode:d,isCompact:m}=ui(t),c=F4(()=>{let p=(u,f)=>dt(u,t,b=>{if(Ct(b))return b.fontFamily;let x=Tr(b,f);return x?x.fontFamily:null},b=>Ct(b)||Tr(b,f)!==null,b=>b?null:o.currentItemFontFamily||Y4);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?p(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Kp(()=>{i.current=c},[c]),Kp(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),Kp(()=>(s.current=!1,()=>{s.current=!0}),[]),bt(ou,{children:[d==="full"&&re("legend",{children:g("labels.fontFamily")}),re(Rx,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:d!=="full",onSelect:p=>{za(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),n.current.clear()},m,!!o.editingTextElement)},onHover:p=>{l({currentHoveredFontFamily:p,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:p=>{if(p){n.current.clear();let{editingTextElement:u}=o;if(u?.type==="text"){let f=t.scene.getElement(u.id);n.current.set(u.id,qe(f||u,{},!0))}else{let f=Q(e,o,{includeBoundTextElement:!0});for(let b of f)n.current.set(b.id,qe(b,{},!0))}l({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};l({...u}),n.current.clear(),m&&o.editingTextElement&&Oa(null)}}})]})}}),hk=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:ft(e,o,n=>{if(Ct(n)){let i=qe(n,{textAlign:t});return Za(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let i=r.scene.getNonDeletedElementsMap(),{isCompact:a}=ui(r);return bt("fieldset",{children:[re("legend",{children:g("labels.textAlign")}),re("div",{className:"buttonList",children:re(Yt,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:a0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:l0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:s0,testId:"align-right"}],value:dt(e,r,l=>{if(Ct(l))return l.textAlign;let s=Tr(l,i);return s?s.textAlign:null},l=>Ct(l)||Tr(l,i)!==null,l=>l?null:o.currentItemTextAlign),onChange:l=>{za(()=>t(l),a,!!o.editingTextElement,n?.onPreventClose)}})})]})}}),gk=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:ft(e,o,n=>{if(Ct(n)){let i=qe(n,{verticalAlign:t});return Za(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{isCompact:i}=ui(r);return re("fieldset",{children:re("div",{className:"buttonList",children:re(Yt,{group:"text-align",options:[{value:ac.TOP,text:g("labels.alignTop"),icon:re(c0,{theme:o.theme}),testId:"align-top"},{value:ac.MIDDLE,text:g("labels.centerVertically"),icon:re(m0,{theme:o.theme}),testId:"align-middle"},{value:ac.BOTTOM,text:g("labels.alignBottom"),icon:re(d0,{theme:o.theme}),testId:"align-bottom"}],value:dt(e,r,a=>{if(Ct(a)&&a.containerId)return a.verticalAlign;let l=Tr(a,r.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},a=>Ct(a)||Tr(a,r.scene.getNonDeletedElementsMap())!==null,a=>a?null:ac.MIDDLE),onChange:a=>{za(()=>t(a),i,!!o.editingTextElement,n?.onPreventClose)}})})})}}),rq=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ft(e,o,r=>Vx(r)?r:qe(r,{roundness:t==="round"?{type:ek(r.type)?lc.ADAPTIVE_RADIUS:lc.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=An(Wx(e),o).some(l=>l.roundness?.type===lc.LEGACY);return bt("fieldset",{children:[re("legend",{children:g("labels.edges")}),bt("div",{className:"buttonList",children:[re(Yt,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:Gb},{value:"round",text:g("labels.round"),icon:Ub}],value:dt(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!sc(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),Yx=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:Yb},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:re(Wb,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:re($b,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:re(Zb,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:re(Vb,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:re(Xb,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:re(jb,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:re(qb,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:re(Kb,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:re(Qb,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:re(Jb,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:re(e0,{flip:e}),keyBinding:"v"}],nq=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:ft(e,o,r=>{if(qp(r)){let{position:n,type:i}=t;if(n==="start")return qe(r,{startArrowhead:i});if(n==="end")return qe(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Ho().rtl;return bt("fieldset",{children:[re("legend",{children:g("labels.arrowheads")}),bt("div",{className:"iconSelectList buttonList",children:[re(Vp,{label:"arrowhead_start",options:Yx(!n),value:dt(e,r,i=>qp(i)&&Dn(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),re(Vp,{label:"arrowhead_end",group:"arrowheads",options:Yx(!!n),value:dt(e,r,i=>qp(i)&&Dn(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),fk=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,r)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>bt("div",{className:"selected-shape-actions",children:[n("changeArrowhead"),n("changeArrowType")]})}),iq=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=ft(e,o,l=>{if(!sc(l))return l;let s=qe(l,{roundness:t===Yo.round?{type:lc.PROPORTIONAL_RADIUS}:null,elbowed:t===Yo.elbow,points:t===Yo.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(Vx(s)){s.fixedSegments=null;let d=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=jp.getPointAtIndexGlobalCoordinates(s,0,d),c=jp.getPointAtIndexGlobalCoordinates(s,-1,d),p=s.startBinding&&d.get(s.startBinding.elementId),u=s.endBinding&&d.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Gx(s,p,"start",d)}:null,b=u&&s.endBinding?{...s.endBinding,...Gx(s,u,"end",d)}:null;s={...s,startBinding:f,endBinding:b,...ok(s,d,{points:[m,c].map(x=>B4(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let d=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=d.get(s.startBinding.elementId);m&&Hx(s,m,"start",r.scene)}if(s.endBinding){let m=d.get(s.endBinding.elementId);m&&Hx(s,m,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new jp(l,Jp(e)))}return{elements:n,appState:i,captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>bt("fieldset",{children:[re("legend",{children:g("labels.arrowtypes")}),re("div",{className:"buttonList",children:re(Yt,{group:"arrowtypes",options:[{value:Yo.sharp,text:g("labels.arrowtype_sharp"),icon:Jn,testId:"sharp-arrow"},{value:Yo.round,text:g("labels.arrowtype_round"),icon:ei,testId:"round-arrow"},{value:Yo.elbow,text:g("labels.arrowtype_elbowed"),icon:Qn,testId:"elbow-arrow"}],value:dt(e,r,n=>sc(n)?n.elbowed?Yo.elbow:n.roundness?Yo.round:Yo.sharp:null,n=>sc(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{clamp as lu,roundToStep as Tk}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as Ik,CURSOR_TYPE as qx,MAX_ZOOM as Jx,MIN_ZOOM as Qx,THEME as ja,ZOOM_STEP as su,updateActiveTool as gi,CODES as So,KEYS as Vo}from"@excalidraw/common";import{getNonDeletedElements as Ck}from"@excalidraw/element";import{newElementWith as Sk}from"@excalidraw/element";import{getCommonBounds as kk}from"@excalidraw/element";import{CaptureUpdateAction as lo}from"@excalidraw/element";import{useEffect as bk}from"react";import{jsx as Ek}from"react/jsx-runtime";var hi=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},ru=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},xk=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();ru(o,n)},Nt=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(bk(()=>()=>hi().classList.remove("excalidraw-tooltip--visible"),[]),n?null:Ek("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>xk(i.currentTarget,hi(),o,t),onPointerLeave:()=>hi().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import cc from"open-color";import{CURSOR_TYPE as nu,MIME_TYPES as iu,THEME as $x}from"@excalidraw/common";var Zx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',yk='<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"/>',jx='<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"/>',wk=`data:${iu.svg},${encodeURIComponent(`${Zx}${jx}</svg>`)}`,vk=`data:${iu.svg},${encodeURIComponent(`${Zx}${yk}${jx}</svg>`)}`,Xt=e=>{e&&(e.style.cursor="")},ye=(e,o)=>{e&&(e.style.cursor=o)},Co,Kx,au=(e,o)=>{let r=()=>{let n=o===$x.DARK;Co=document.createElement("canvas"),Co.theme=o,Co.height=20,Co.width=20;let i=Co.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Co.width/2,Co.height/2,5,0,2*Math.PI),i.fillStyle=n?cc.black:cc.white,i.fill(),i.strokeStyle=n?cc.white:cc.black,i.stroke(),Kx=Co.toDataURL(iu.svg)};(!Co||Co.theme!==o)&&r(),ye(e,`url(${Kx}) ${20/2} ${20/2}, auto`)},Bt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Xt(e);else if(no(o))e.style.cursor=nu.GRAB;else if(It(o))au(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===$x.LIGHT?wk:vk;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=nu.AUTO):e.style.cursor=nu.CROSSHAIR};var Wo=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),d=-(n-n/t),m=-(i-i/t);return{scrollX:l+d,scrollY:s+m,zoom:{value:t}}};import{jsx as uc,jsxs as Ak}from"react/jsx-runtime";var Mk=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?lo.IMMEDIATELY:lo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r,data:n})=>uc(Ya,{palette:null,topPicks:Ik,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Xo=O({name:"clearCanvas",label:"labels.clearCanvas",icon:_t,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>Sk(n,{isDeleted:!0})),appState:{...mr(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:r.state.preferredSelectionTool.type}:o.activeTool},captureUpdate:lo.IMMEDIATELY})}),dc=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:$m,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Wo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:xo(o.zoom.value+su)},o),userToFollow:null},captureUpdate:lo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>uc(K,{type:"button",className:"zoom-in-button zoom-button",icon:$m,title:`${g("buttons.zoomIn")} \u2014 ${_("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=Jx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===So.EQUAL||e.code===So.NUM_ADD)&&(e[Vo.CTRL_OR_CMD]||e.shiftKey)}),mc=O({name:"zoomOut",label:"buttons.zoomOut",icon:Zm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Wo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:xo(o.zoom.value-su)},o),userToFollow:null},captureUpdate:lo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>uc(K,{type:"button",className:"zoom-out-button zoom-button",icon:Zm,title:`${g("buttons.zoomOut")} \u2014 ${_("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Qx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===So.MINUS||e.code===So.NUM_SUBTRACT)&&(e[Vo.CTRL_OR_CMD]||e.shiftKey)}),pc=O({name:"resetZoom",label:"buttons.resetZoom",icon:ub,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Wo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:xo(1)},o),userToFollow:null},captureUpdate:lo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>uc(Nt,{label:g("buttons.resetZoom"),style:{height:"100%"},children:Ak(K,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===So.ZERO||e.code===So.NUM_ZERO)&&(e[Vo.CTRL_OR_CMD]||e.shiftKey)}),Pk=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,d=a-n,m=o.height/d,p=Math.min(s,m)*lu(t,.1,1);return Math.min(p,1)},eE=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=lu(n,Qx,Jx);let[l,s,d,m]=e,c=(l+d)/2,p=(s+m)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(r){let k=d-l,P=m-s;y=Math.min(w/k,E/P)*n}else y=Pk(e,{width:w,height:E},n);let v=xo(lu(Tk(y,su,"floor"),i,a)),I=k1({scenePoint:{x:c,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:v}},captureUpdate:lo.EVENTUALLY}},qa=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=kk(Ck(o));return eE({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},Uq=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:_s,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return qa({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===So.TWO&&e.shiftKey&&!e.altKey&&!e[Vo.CTRL_OR_CMD]}),Yq=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:_s,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return qa({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===So.THREE&&e.shiftKey&&!e.altKey&&!e[Vo.CTRL_OR_CMD]}),Lk=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:_s,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>qa({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===So.ONE&&e.shiftKey&&!e.altKey&&!e[Vo.CTRL_OR_CMD]}),cn=O({name:"toggleTheme",label:(e,o)=>o.theme===ja.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ja.LIGHT?Pa:La,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===ja.LIGHT?ja.DARK:ja.LIGHT)},captureUpdate:lo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===So.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),Wq=O({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return It(o)?n=gi(o,{...o.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):n=gi(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:lo.IMMEDIATELY}},keyTest:e=>e.key===Vo.E}),Vq=O({name:"toggleLassoTool",label:"toolBar.lasso",icon:ur,trackEvent:{category:"toolbar"},predicate:(e,o,t,r)=>r.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=gi(o,{type:"lasso",fromSelection:!1}),ye(r.interactiveCanvas,qx.CROSSHAIR)):n=gi(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:lo.NEVER}}}),tE=O({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ds,viewMode:!1,perform:(e,o,t,r)=>{let n;return no(o)?n=gi(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=gi(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ye(r.interactiveCanvas,qx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:lo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Vo.CTRL_OR_CMD]&&e.key===Vo.H});import{updateActiveTool as oE}from"@excalidraw/common";import{CaptureUpdateAction as Dk}from"@excalidraw/element";var _k=O({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=oE(o,{type:"embeddable"});return Bt(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:oE(o,{type:"embeddable"})},captureUpdate:Dk.EVENTUALLY}}});import{pointFrom as Rk}from"@excalidraw/math";import{maybeBindLinearElement as Nk,bindOrUnbindLinearElement as rE,isBindingEnabled as Bk}from"@excalidraw/element/binding";import{isValidPolygon as nE,LinearElementEditor as Ja,newElementWith as cu}from"@excalidraw/element";import{isBindingElement as hc,isFreeDrawElement as iE,isLinearElement as aE,isLineElement as gc}from"@excalidraw/element";import{KEYS as du,arrayToMap as mu,tupleToCoors as Fk,updateActiveTool as lE}from"@excalidraw/common";import{isPathALoop as Ok}from"@excalidraw/element";import{isInvisiblySmallElement as pu}from"@excalidraw/element";import{CaptureUpdateAction as uu}from"@excalidraw/element";import{jsx as zk}from"react/jsx-runtime";var Ft=O({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,{event:l,sceneCoords:s}=t??{},d=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=Ja.handlePointerUp(l,o.selectedLinearElement,o,r.scene),{startBindingElement:f,endBindingElement:b}=u,x=r.scene.getElement(u.elementId);if(hc(x)&&rE(x,f,b,r.scene),u!==o.selectedLinearElement){let w=e;return x&&pu(x)&&(w=w.map(E=>E.id===x.id?cu(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:uu.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=Ja.getElement(u,d);if(x)return hc(x)&&rE(x,f,b,a),gc(x)&&!nE(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||pu(x)?e.map(w=>w.id===x.id?cu(w,{isDeleted:!0}):w):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new Ja(x,mu(d),!1)},captureUpdate:uu.IMMEDIATELY}}let m=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||hc(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=d.get(Object.keys(o.selectedElementIds)[0]);u&&(c=u)}if(c){if(o.multiElement&&c.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=c;(!f||u[u.length-1]!==f)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&pu(c)&&(m=m.map(u=>u.id===c?.id?cu(u,{isDeleted:!0}):u)),aE(c)||iE(c)){let u=Ok(c.points,o.zoom.value);if(u&&(gc(c)||iE(c))){let f=c.points,b=f[0],x=f.map((w,E)=>E===f.length-1?Rk(b[0],b[1]):w);gc(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(gc(c)&&!nE(c.points)&&a.mutateElement(c,{polygon:!1}),hc(c)&&!u&&c.points.length>1&&Bk(o)){let f=s??Fk(Ja.getPointAtIndexGlobalCoordinates(c,-1,mu(e)));Nk(c,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Xt(n);let p;return o.activeTool.type==="eraser"?p=lE(o,{...o.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):p=lE(o,{type:r.state.preferredSelectionTool.type}),{elements:m,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:c&&aE(c)?new Ja(c,mu(m)):o.selectedLinearElement},captureUpdate:uu.IMMEDIATELY}},keyTest:(e,o)=>e.key===du.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===du.ESCAPE||e.key===du.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>zk(K,{type:"button",icon:Tb,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as xi,DEFAULT_EXPORT_PADDING as PM,EXPORT_SCALES as LM,THEME as fu}from"@excalidraw/common";import{getNonDeletedElements as AM}from"@excalidraw/element";import{CaptureUpdateAction as po}from"@excalidraw/element";import Hk from"clsx";import{jsx as sE,jsxs as Gk}from"react/jsx-runtime";var Qa=({children:e,checked:o,onChange:t,className:r})=>Gk("div",{className:Hk("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[sE("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:xb}),sE("div",{className:"Checkbox-label",children:e})]});import{THEME as el}from"@excalidraw/common";import{jsx as tl}from"react/jsx-runtime";var dE=e=>{let o=e.title||(e.value===el.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return tl(K,{type:"icon",icon:e.value===el.LIGHT?cE.MOON:cE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===el.DARK?el.LIGHT:el.DARK),"data-testid":"toggle-dark-mode"})},cE={SUN:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("path",{fill:"currentColor",d:"M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"})}),MOON:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as Uk}from"react";import{focusNearestParent as Yk,KEYS as Wk}from"@excalidraw/common";import{jsx as mE,jsxs as Vk}from"react/jsx-runtime";var pE=e=>{let{id:o}=Se(),[t,r]=Uk(e.value),n=a=>{e.ignoreFocus||Yk(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===Wk.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return Vk("div",{className:"ProjectName",children:[mE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),mE("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as yM,DEFAULT_FILENAME as wM,IMAGE_MIME_TYPES as ME,isFirefox as vM,MIME_TYPES as TM,cloneJSON as IM,SVG_DOCUMENT_PREAMBLE as CM}from"@excalidraw/common";import{getNonDeletedElements as SM}from"@excalidraw/element";import{isFrameLikeElement as kM}from"@excalidraw/element";import{getElementsOverlappingFrame as MM}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as oM,EXPORT_DATA_TYPES as nl,MIME_TYPES as co,arrayToMap as rM,isMemberOf as nM,isPromiseLike as iM,EVENT as xc}from"@excalidraw/common";import{mutateElement as aM}from"@excalidraw/element";import{deepCopyElement as lM}from"@excalidraw/element";import{isFrameLikeElement as sM,isInitializedImageElement as cM}from"@excalidraw/element";import{getContainingFrame as TE}from"@excalidraw/element";import{pointFrom as Ir}from"@excalidraw/math";import{COLOR_PALETTE as hE,DEFAULT_CHART_COLOR_INDEX as Xk,getAllColorsSpecificShade as Kk,DEFAULT_FONT_FAMILY as $k,DEFAULT_FONT_SIZE as gE,VERTICAL_ALIGN as Zk,randomId as fE,isDevEnv as bE}from"@excalidraw/common";import{newTextElement as fc,newLinearElement as rl,newElement as gu}from"@excalidraw/element";var so=32,Ie=12,Cr=256,xE=50,dn="NOT_SPREADSHEET",fi="VALID_SPREADSHEET",ol=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},hu=(e,o)=>e.slice(1).every(t=>ol(t[o])!==null),uE=e=>{let o=e[0].length;if(o>2)return{type:dn,reason:"More than 2 columns"};if(o===1){if(!hu(e,0))return{type:dn,reason:"Value is not numeric"};let s=ol(e[0][0])===null,d=(s?e.slice(1):e).map(m=>ol(m[0]));return d.length<2?{type:dn,reason:"Less than two rows"}:{type:fi,spreadsheet:{title:s?e[0][0]:null,labels:null,values:d}}}let t=hu(e,0),r=hu(e,1);if(!t&&!r)return{type:dn,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=ol(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:dn,reason:"Less than 2 rows"}:{type:fi,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>ol(s[i]))}}},jk=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},EE=e=>{let o=e.trim().split(`
|
|
3
3
|
`).map(i=>i.trim().split(" "));if(o.length&&o[0].length!==2&&(o=e.trim().split(`
|
|
4
|
-
`).map(i=>i.trim().split(","))),o.length===0)return{type:
|
|
5
|
-
`).trim()}:
|
|
4
|
+
`).map(i=>i.trim().split(","))),o.length===0)return{type:dn,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:dn,reason:"All rows don't have same number of columns"};let n=uE(o);if(n.type!==fi){let i=uE(jk(o));if(i.type===fi)return i}return n},bc=Kk(Xk),Kt={fillStyle:"hachure",fontFamily:$k,fontSize:gE,opacity:100,roughness:1,strokeColor:hE.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Zk.MIDDLE,locked:!1},yE=e=>{let o=(so+Ie)*e.values.length+Ie,t=Cr+Ie*2;return{chartWidth:o,chartHeight:t}},qk=(e,o,t,r,n)=>e.labels?.map((i,a)=>fc({groupIds:[r],backgroundColor:n,...Kt,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(so+Ie)+Ie*2,y:t+Ie/2,width:so,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],Jk=(e,o,t,r,n)=>{let i=fc({groupIds:[r],backgroundColor:n,...Kt,x:o-Ie,y:t-Ie,text:"0",textAlign:"right"}),a=fc({groupIds:[r],backgroundColor:n,...Kt,x:o-Ie,y:t-Cr-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},Qk=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=yE(e),l=rl({backgroundColor:n,groupIds:[r],...Kt,type:"line",x:o,y:t,width:i,points:[Ir(0,0),Ir(i,0)]}),s=rl({backgroundColor:n,groupIds:[r],...Kt,type:"line",x:o,y:t,height:a,points:[Ir(0,0),Ir(0,-a)]}),d=rl({backgroundColor:n,groupIds:[r],...Kt,type:"line",x:o,y:t-Cr-Ie,strokeStyle:"dotted",width:i,opacity:xE,points:[Ir(0,0),Ir(i,0)]});return[l,s,d]},wE=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=yE(e),s=e.title?fc({backgroundColor:n,groupIds:[r],...Kt,text:e.title,x:o+a/2,y:t-Cr-Ie*2-gE,roundness:null,textAlign:"center"}):null,d=i?gu({backgroundColor:n,groupIds:[r],...Kt,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:hE.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...s?[s]:[],...qk(e,o,t,r,n),...Jk(e,o,t,r,n),...Qk(e,o,t,r,n)]},eM=(e,o,t)=>{let r=Math.max(...e.values),n=fE(),i=bc[Math.floor(Math.random()*bc.length)];return[...e.values.map((l,s)=>{let d=l/r*Cr;return gu({backgroundColor:i,groupIds:[n],...Kt,type:"rectangle",x:o+s*(so+Ie)+Ie,y:t-d-Ie,width:so,height:d})}),...wE(e,o,t,n,i,bE())]},tM=(e,o,t)=>{let r=Math.max(...e.values),n=fE(),i=bc[Math.floor(Math.random()*bc.length)],a=0,l=[];for(let b of e.values){let x=a*(so+Ie),w=-(b/r)*Cr;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),d=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),c=Math.min(...l.map(b=>b[1])),p=rl({backgroundColor:i,groupIds:[n],...Kt,type:"line",x:o+Ie+so/2,y:t-Ie,height:d-c,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(so+Ie)+Ie/2,E=-(b/r)*Cr+Ie/2;return gu({backgroundColor:i,groupIds:[n],...Kt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+so/2,y:t+E-Ie*2,width:Ie,height:Ie})}),f=e.values.map((b,x)=>{let w=x*(so+Ie)+Ie/2,E=b/r*Cr+Ie/2+Ie;return rl({backgroundColor:i,groupIds:[n],...Kt,type:"line",x:o+w+so/2+Ie/2,y:t-E,height:E,strokeStyle:"dotted",opacity:xE,points:[Ir(0,0),Ir(0,E)]})});return[...wE(e,o,t,n,i,bE()),p,...f,...u]},vE=(e,o,t,r)=>e==="line"?tM(o,t,r):eM(o,t,r);var nQ="clipboard"in navigator&&"readText"in navigator.clipboard,Ec="clipboard"in navigator&&"writeText"in navigator.clipboard,bi="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,dM=e=>!!([nl.excalidraw,nl.excalidrawClipboard,nl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),IE=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(xc.PASTE,{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n),t.clipboardData?.items.add(n);continue}try{if(t.clipboardData?.items.add(n,r),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},mM=({elements:e,files:o})=>{let t=rM(e),r=new Set(e.filter(l=>sM(l))),n=!1,i=e.reduce((l,s)=>(cM(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:nl.excalidrawClipboard,elements:e.map(l=>{if(TE(l,t)&&!r.has(TE(l,t))){let s=lM(l);return aM(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},yc=async(e,o,t)=>{await mo(mM({elements:e,files:o}),t)},pM=e=>{let o=EE(e);return o.type===fi?{spreadsheet:o.spreadsheet}:null};function CE(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(CE(t));return o}var uM=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,co.html),r=CE(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},SE=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let r=await navigator.clipboard?.readText();if(r)return{[co.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(nM(oM,r))try{if(r===co.text||r===co.html)e[r]=await(await t.getType(r)).text();else if(W1(r)){let n=await t.getType(r),i=q1(n,r,void 0);e[r]=i}else throw new Om(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof Om?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},hM=async(e,o=!1)=>{try{let t=e.findByType(co.html),r=!o&&t&&uM(t);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.getData(co.text)??r.value.map(n=>n.value).join(`
|
|
5
|
+
`).trim()}:r:{type:"text",value:(e.getData(co.text)||"").trim()}}catch{return{type:"text",value:""}}},gM=function(e){return this.find(o=>o.type===e)||null},fM=function(e){return this.find(t=>t.type===e)?.value??null},bM=function(){return this.filter(e=>e.kind==="file")},il=async e=>{let o;EM(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async r=>{if(r.kind==="file"){let n=r.getAsFile();if(n){let i=await j1(r);return n=await Sa(n),{type:n.type,kind:"file",file:n,fileHandle:i}}}else if(r.kind==="string"){let{type:n}=r,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(n):i=await new Promise(a=>{r.getAsString(l=>a(l))}),{type:n,kind:"string",value:i}}return null}))).filter(r=>r!=null);return Object.assign(t,{findByType:gM,getData:fM,getFiles:bM})},kE=async(e,o=!1)=>{let t=await hM(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&pM(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===nl.excalidrawClipboardWithAPI;if(dM(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},wc=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[co.png]:e})])}catch(o){if(iM(e))await navigator.clipboard.write([new window.ClipboardItem({[co.png]:await e})]);else throw o}},mo=async(e,o)=>{if(Ec)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(co.text,e||""),o.clipboardData?.getData(co.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!xM(e))throw new Error("Error copying to clipboard.")},xM=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n},EM=e=>e.type===xc.PASTE||e.type===xc.COPY||e.type===xc.CUT;var mn=(e,{selectedElementIds:o},t)=>{e=SM(e);let r=t&&we(e,{selectedElementIds:o}),n=null,i=r?Q(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&kM(i[0])?(n=i[0],i=MM(e,n)):i.length>1&&(i=Q(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:IM(i)}},pn=async(e,o,t,r,{exportBackground:n,exportPadding:i=yM,viewBackgroundColor:a,name:l=t.name||wM,fileHandle:s=null,exportingFrame:d=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let c=Nn(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:d});if(e==="svg")return zm(c.then(p=>new Blob([CM+p.outerHTML],{type:TM.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ME.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await c.then(u=>u.outerHTML);try{await mo(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let m=fs(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:d});if(e==="png"){let c=zo(m);return t.exportEmbedScene&&(c=c.then(p=>import("./data/image-AQDM7CNH.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:va(o,t,r,"local")})))),zm(c,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ME.png],fileHandle:s})}else if(e==="clipboard")try{let c=zo(m);await wc(c)}catch(c){throw console.warn(c),c.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):vM&&c.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
|
|
6
6
|
|
|
7
|
-
${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Xx=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=s1(a);if(!a||!c1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:d}=Vr(e,o,!1);return await Xr(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:d}),{fileHandle:a}};import{Fragment as Ck,jsx as Ro,jsxs as Sk}from"react/jsx-runtime";var Yp=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>Ro(Px,{label:g("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),Kx=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Ik(e),i=Ee(r,o)?j(r,o):r;return Ro(Ck,{children:Tk.map(a=>{let[l,s]=a1(i,vk,a),d=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Ro(K,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:d,"aria-label":d,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Wp=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ro(ba,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),Xs=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Sk(ba,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Ro(Pt,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Ro("div",{className:"excalidraw-tooltip-icon",children:K1})})]})}),Kr=B({name:"saveToActiveFile",label:"buttons.save",icon:Fr,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=Rl(o.fileHandle)?await Xx(e,o,r.files,r.getName()):await Ll(e,o,r.files,r.getName());return{captureUpdate:ro.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e.key===Xn.S&&e[Xn.CTRL_OR_CMD]&&!e.shiftKey}),Ta=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Fr,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Ll(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:ro.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:g("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e.key===Xn.S&&e.shiftKey&&e[Xn.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Ro(K,{type:"button",icon:U1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:se().editor.isMobile,hidden:!gn,onClick:()=>e(null),"data-testid":"save-as-button"})}),Kn=B({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await pm(o,e);return{elements:n,appState:i,files:a,captureUpdate:ro.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e[Xn.CTRL_OR_CMD]&&e.key===Xn.O}),Zx=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ro("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Ro(Mx,{value:e.exportWithDarkMode?Up.DARK:Up.LIGHT,onChange:t=>{o(t===Up.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as kk,DEFAULT_FONT_FAMILY as Mk,DEFAULT_TEXT_ALIGN as Lk,CODES as $x,KEYS as jx,getLineHeight as Pk}from"@excalidraw/common";import{newElementWith as Ks}from"@excalidraw/element";import{hasBoundTextElement as Ak,canApplyRoundnessTypeToElement as Dk,getDefaultRoundnessTypeForElement as _k,isFrameLikeElement as Rk,isArrowElement as Nk,isExcalidrawElement as Bk,isTextElement as Vp}from"@excalidraw/element";import{getBoundTextElement as Fk,redrawTextBoundingBox as Ok}from"@excalidraw/element";import{CaptureUpdateAction as Xp}from"@excalidraw/element";var qx="{}",Kp=B({name:"copyStyles",label:"labels.copyStyles",icon:Hm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&Ak(i)){let a=Fk(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(qx=JSON.stringify(n)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:Xp.EVENTUALLY}},keyTest:e=>e[jx.CTRL_OR_CMD]&&e.altKey&&e.code===$x.C}),Zp=B({name:"pasteStyles",label:"labels.pasteStyles",icon:Hm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(qx),i=n[0],a=n[1];if(!Bk(i))return{elements:e,captureUpdate:Xp.EVENTUALLY};let l=j(e,o,{includeBoundTextElement:!0}),s=l.map(d=>d.id);return{elements:e.map(d=>{if(s.includes(d.id)){let m=i;if(Vp(d)&&d.containerId&&(m=a),!m)return d;let c=Ks(d,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?Dk(m.roundness.type,d)?m.roundness:_k(d):null});if(Vp(c)){let p=m.fontSize||kk,u=m.fontFamily||Mk;c=Ks(c,{fontSize:p,fontFamily:u,textAlign:m.textAlign||Lk,lineHeight:m.lineHeight||Pk(u)});let f=null;c.containerId&&(f=l.find(b=>Vp(c)&&b.id===c.containerId)||null),Ok(c,f,r.scene)}return c.type==="arrow"&&Nk(m)&&(c=Ks(c,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),Rk(d)&&(c=Ks(c,{roundness:null,backgroundColor:"transparent"})),c}return d}),captureUpdate:Xp.IMMEDIATELY}},keyTest:e=>e[jx.CTRL_OR_CMD]&&e.altKey&&e.code===$x.V});import{KEYS as zk}from"@excalidraw/common";import{getNonDeletedElements as Hk}from"@excalidraw/element";import{showSelectedShapeActions as Gk}from"@excalidraw/element";import{CaptureUpdateAction as $p}from"@excalidraw/element";import{jsx as Jx}from"react/jsx-runtime";var Uk=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:$p.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Jx(K,{type:"button",icon:Xl,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),Yk=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:$p.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>Jx(K,{visible:Gk(o,Hk(e)),type:"button",icon:Y1,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),Zr=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:F1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:$p.EVENTUALLY}),keyTest:e=>e.key===zk.QUESTION_MARK});import{getNonDeletedElements as $s}from"@excalidraw/element";import{newElementWith as tE}from"@excalidraw/element";import{isBoundToContainer as Wk}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as Vk,getElementsInResizingFrame as Xk,getFrameLikeElements as Kk,getRootElements as Zk,groupByFrameLikes as $k,removeElementsFromFrame as jk,replaceAllElementsInFrame as qk}from"@excalidraw/element";import{KEYS as js,randomId as Jk,arrayToMap as jp,getShortcutKey as oE}from"@excalidraw/common";import{getSelectedGroupIds as Zs,selectGroup as Qk,selectGroupsForSelectedElements as eM,getElementsInGroup as Qx,addToGroup as tM,removeFromSelectedGroups as oM,isElementInGroup as rE}from"@excalidraw/element";import{syncMovedIndices as rM}from"@excalidraw/element";import{CaptureUpdateAction as Ia}from"@excalidraw/element";import{jsx as Zn}from"react/jsx-runtime";var nM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&rE(n,t),!0))return!0}return!1},eE=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!nM(r)&&!Vk(r)},qp=B({name:"group",label:"labels.group",icon:e=>Zn(Bm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Zk(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:Ia.EVENTUALLY};let i=Zs(o);if(i.length===1){let x=i[0],w=new Set(Qx(e,x).map(v=>v.id)),E=new Set(n.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:Ia.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&$k(n).forEach((w,E)=>{jk(w,r.scene.getNonDeletedElementsMap())});let s=Jk(),d=jp(n);a=a.map(x=>d.get(x.id)?tE(x,{groupIds:tM(x.groupIds,s,o.editingGroupId)}):x);let m=Qx(a,s),c=m[m.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!rE(x,s)),b=rM([...f,...m,...u],jp(m));return{appState:{...o,...Qk(s,{...o,selectedGroupIds:{}},$s(a))},elements:b,captureUpdate:Ia.IMMEDIATELY}},predicate:(e,o,t,r)=>eE(e,o,r),keyTest:e=>!e.shiftKey&&e[js.CTRL_OR_CMD]&&e.key===js.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Zn(K,{hidden:!eE(e,o,r),type:"button",icon:Zn(Bm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${oE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ee($s(e),o)})}),Jp=B({name:"ungroup",label:"labels.ungroup",icon:e=>Zn(Fm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Zs(o),i=jp(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:Ia.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{Wk(p)&&l.push(p.id);let u=oM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:tE(p,{groupIds:u})});let s=eM(o,$s(a),o,null),d=r.scene.getSelectedElements(o),m=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return Kk(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=qk(a,Xk(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:Ia.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[js.CTRL_OR_CMD]&&e.key===js.G.toUpperCase(),predicate:(e,o)=>Zs(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Zn(K,{type:"button",hidden:Zs(o).length===0,icon:Zn(Fm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${oE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ee($s(e),o)})});import mM from"clsx";import{CaptureUpdateAction as sE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as iM,COLOR_VOICE_CALL as aM,COLOR_WHITE as Js,THEME as lM,UserIdleState as nE}from"@excalidraw/common";var qs=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function sM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var $r=(e,o)=>`hsl(${Math.abs(sM(o?.id||e))%37*10}, 100%, 83%)`,iE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},aE=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,d=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,c=14,p=l<0||l>r-m||s<0||s>n-c;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-c);let u=$r(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===nE.IDLE||f===nE.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===lM.DARK?"#2f6330":aM,w=d?.isSpeaking;w&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Js,e.strokeStyle=Js,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+m/2,v=(w?s+0:s)+c+2,C=5,S=3,L=e.measureText(E),k=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,A=Math.max(k,12),P=y-1,N=v-1,O=L.width+2+C*2+2,U=A+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,N,O,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=Js,e.stroke(),w&&(e.beginPath(),e.roundRect(P-2,N-2,O+4,U+4,8),e.strokeStyle=x,e.stroke())):qs(e,P,N,O,U,8,Js),e.fillStyle=iM,e.fillText(E,y+C+1,v+S+L.actualBoundingBoxAscent+Math.floor((A-k)/2)+2),w){e.fillStyle=x;let J=8,_=8,R=5;e.fillRect(P+O+_,N+(U/2-J/2),2,J),e.fillRect(P+O+_+R,N+(U/2-J*2/2),2,J*2),e.fillRect(P+O+_+R*2,N+(U/2-J/2),2,J)}}e.restore(),e.closePath()}};import cM from"clsx";import{useState as dM}from"react";import{jsx as lE}from"react/jsx-runtime";var Qp=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=iE(t),[a,l]=dM(!1),s=!a&&r,d=s?void 0:{background:e};return lE("div",{className:cM("Avatar",n),style:d,onClick:o,children:s?lE("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Eo,jsxs as Qs}from"react/jsx-runtime";var pM=B({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:sE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:sE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=$r(r,n),s=mM({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),d=n.isInCall?n.isSpeaking?Qs("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[Eo("div",{}),Eo("div",{}),Eo("div",{})]}):n.isMuted?Eo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:Z0}):Eo("div",{title:g("userList.hint.inCall"),children:K0}):null;return i?Qs("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Eo(Qp,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),Eo("div",{className:"UserList__collaborator-name",children:n.username}),Qs("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Eo("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:kn}),d]})]}):Qs("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Eo(Qp,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),d&&Eo("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{LIBRARY_DISABLED_TYPES as uM,randomId as hM}from"@excalidraw/common";import{deepCopyElement as gM}from"@excalidraw/element";import{CaptureUpdateAction as eu}from"@excalidraw/element";var tu=B({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of uM)if(n.some(a=>a.type===i))return{captureUpdate:eu.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:hM(),status:"unpublished",elements:n.map(gM),created:Date.now()},...i])).then(()=>({captureUpdate:eu.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:eu.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as $n}from"@excalidraw/element";import{isFrameLikeElement as fM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as bM}from"@excalidraw/element";import{KEYS as sr,arrayToMap as xM,getShortcutKey as ec}from"@excalidraw/common";import{alignElements as EM}from"@excalidraw/element";import{CaptureUpdateAction as jn}from"@excalidraw/element";import{getSelectedElementsByGroup as yM}from"@excalidraw/element";import{jsx as Jn}from"react/jsx-runtime";var vt=(e,o)=>{let t=o.scene.getSelectedElements(e);return yM(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(r=>fM(r))},qn=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=EM(n,r,t.scene,o),a=xM(i);return bM(e.map(l=>a.get(l.id)||l),o,t)},wM=B({name:"alignTop",label:"labels.alignTop",icon:Pm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"start",axis:"y"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Pm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${ec("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ee($n(e),o)})}),vM=B({name:"alignBottom",label:"labels.alignBottom",icon:Am,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"end",axis:"y"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Am,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${ec("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ee($n(e),o)})}),TM=B({name:"alignLeft",label:"labels.alignLeft",icon:Dm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"start",axis:"x"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Dm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${ec("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ee($n(e),o)})}),IM=B({name:"alignRight",label:"labels.alignRight",icon:_m,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"end",axis:"x"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:_m,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${ec("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ee($n(e),o)})}),CM=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Rm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"center",axis:"y"}),captureUpdate:jn.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Rm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ee($n(e),o)})}),SM=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Nm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"center",axis:"x"}),captureUpdate:jn.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Nm,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ee($n(e),o)})});import{getNonDeletedElements as cE}from"@excalidraw/element";import{isFrameLikeElement as kM}from"@excalidraw/element";import{CODES as dE,KEYS as mE,arrayToMap as MM,getShortcutKey as pE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as LM}from"@excalidraw/element";import{distributeElements as PM}from"@excalidraw/element";import{CaptureUpdateAction as uE}from"@excalidraw/element";import{getSelectedElementsByGroup as AM}from"@excalidraw/element";import{jsx as fE}from"react/jsx-runtime";var hE=(e,o)=>{let t=o.scene.getSelectedElements(e);return AM(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>kM(r))},gE=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=PM(n,t.scene.getNonDeletedElementsMap(),r,o),a=MM(i);return LM(e.map(l=>a.get(l.id)||l),o,t)},DM=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:gE(e,o,r,{space:"between",axis:"x"}),captureUpdate:uE.IMMEDIATELY}),keyTest:e=>!e[mE.CTRL_OR_CMD]&&e.altKey&&e.code===dE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fE(K,{hidden:!hE(o,r),type:"button",icon:q1,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${pE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ee(cE(e),o)})}),_M=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:gE(e,o,r,{space:"between",axis:"y"}),captureUpdate:uE.IMMEDIATELY}),keyTest:e=>!e[mE.CTRL_OR_CMD]&&e.altKey&&e.code===dE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fE(K,{hidden:!hE(o,r),type:"button",icon:J1,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${pE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ee(cE(e),o)})});import{getNonDeletedElements as RM}from"@excalidraw/element";import{bindOrUnbindLinearElements as NM,isBindingEnabled as BM}from"@excalidraw/element";import{getCommonBoundingBox as bE}from"@excalidraw/element";import{newElementWith as FM}from"@excalidraw/element";import{deepCopyElement as OM}from"@excalidraw/element";import{resizeMultipleElements as zM}from"@excalidraw/element";import{isArrowElement as HM,isElbowArrow as GM,isLinearElement as UM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as xE}from"@excalidraw/element";import{CODES as EE,KEYS as YM,arrayToMap as WM}from"@excalidraw/common";import{CaptureUpdateAction as yE}from"@excalidraw/element";var ou=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:J0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:xE(wE(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:yE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===EE.H}),ru=B({name:"flipVertical",label:"labels.flipVertical",icon:q0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:xE(wE(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:yE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===EE.V&&!e[YM.CTRL_OR_CMD]}),wE=(e,o,t,r,n)=>{let i=j(RM(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=VM(i,o,t,r,n),l=WM(a);return e.map(s=>l.get(s.id)||s)},VM=(e,o,t,r,n)=>{if(e.every(u=>HM(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return FM(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=bE(e);zM(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,OM(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),NM(e.filter(UM),BM(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>GM(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:d,midY:m}=bE(e),[c,p]=[i-d,a-m];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as XM}from"@excalidraw/element";import{getTextFromElements as KM}from"@excalidraw/element";import{CODES as ZM,KEYS as vE,isFirefox as $M}from"@excalidraw/common";import{CaptureUpdateAction as Dt}from"@excalidraw/element";var Qn=B({name:"copy",label:"labels.copy",icon:Zi,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Ys(n,r.files,t)}catch(i){return{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Dt.EVENTUALLY}},keyTest:void 0}),nu=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await Wx()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),$M?{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(Ux({types:n}))}catch(i){return console.error(i),{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Dt.EVENTUALLY}},keyTest:void 0}),tc=B({name:"cut",label:"labels.cut",icon:B0,trackEvent:{category:"element"},perform:(e,o,t,r)=>(Qn.perform(e,o,t,r),ra.perform(e,o,null,r)),keyTest:e=>e[vE.CTRL_OR_CMD]&&e.key===vE.X}),oc=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:Q0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Dt.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=Vr(e,o,!0);try{await Xr("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Dt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Dt.EVENTUALLY}}},predicate:e=>Us&&e.length>0,keywords:["svg","clipboard","copy"]}),rc=B({name:"copyAsPng",label:"labels.copyAsPng",icon:eb,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Dt.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Vr(e,o,!0);try{return await Xr("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:n.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Dt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Dt.EVENTUALLY}}},predicate:e=>Vn&&e.length>0,keyTest:e=>e.code===ZM.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),nc=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{oo(KM(n))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Dt.EVENTUALLY}},predicate:(e,o,t,r)=>Us&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(XM),keywords:["text","clipboard","copy"]});import{CODES as jM,KEYS as qM}from"@excalidraw/common";import{CaptureUpdateAction as JM}from"@excalidraw/element";var ic=B({name:"gridMode",icon:ib,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:JM.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[qM.CTRL_OR_CMD]&&e.code===jM.QUOTE});import{CODES as QM,KEYS as eL}from"@excalidraw/common";import{CaptureUpdateAction as tL}from"@excalidraw/element";var ei=B({name:"zenMode",label:"buttons.zenMode",icon:ob,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:tL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[eL.CTRL_OR_CMD]&&e.altKey&&e.code===QM.Z});import{CODES as oL,KEYS as rL}from"@excalidraw/common";import{CaptureUpdateAction as nL}from"@excalidraw/element";var iu=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:tb,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:nL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[rL.CTRL_OR_CMD]&&e.altKey&&e.code===oL.S});import{CODES as iL,KEYS as aL}from"@excalidraw/common";import{CaptureUpdateAction as lL}from"@excalidraw/element";var ti=B({name:"stats",label:"stats.fullTitle",icon:j0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:lL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[aL.CTRL_OR_CMD]&&e.altKey&&e.code===iL.SLASH});import{BOUND_TEXT_PADDING as TE,ROUNDNESS as IE,TEXT_ALIGN as SE,VERTICAL_ALIGN as kE,arrayToMap as ME,getFontString as sL}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as cL,resetOriginalContainerCache as dL,updateOriginalContainerCache as mL}from"@excalidraw/element";import{computeBoundTextPosition as pL,computeContainerDimensionForBoundText as CE,getBoundTextElement as LE,redrawTextBoundingBox as PE}from"@excalidraw/element";import{hasBoundTextElement as uL,isArrowElement as hL,isTextBindableContainer as au,isTextElement as Ca,isUsingAdaptiveRadius as gL}from"@excalidraw/element";import{measureText as fL}from"@excalidraw/element";import{syncMovedIndices as AE}from"@excalidraw/element";import{newElement as bL}from"@excalidraw/element";import{CaptureUpdateAction as lu}from"@excalidraw/element";var su=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>uL(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=LE(a,i);if(l){let{width:s,height:d}=fL(l.originalText,sL(l),l.lineHeight),m=cL(a.id);dL(a.id);let{x:c,y:p}=pL(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:c,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:lu.IMMEDIATELY}}}),cu=B({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=Ca(n[0])||Ca(n[1]),a;if(au(n[0])?a=n[0]:au(n[1])&&(a=n[1]),i&&a&&LE(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Ca(n[0])&&au(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:kE.MIDDLE,textAlign:SE.CENTER,autoResize:!0,angle:hL(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return PE(i,a,r.scene),mL(a.id,l),{elements:xL(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:lu.IMMEDIATELY}}}),xL=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),AE(r,ME([o,t])),r},EL=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),AE(r,ME([o,t])),r},DE=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Ca(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(Ca(l)){let s=bL({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:gL("rectangle")?IE.ADAPTIVE_RADIUS:IE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-TE,y:l.y-TE,width:CE(l.width,"rectangle"),height:CE(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let d=l.boundElements.filter(c=>c.type==="arrow").map(c=>c.id);i.filter(c=>d.includes(c.id)).forEach(c=>{let p=c.startBinding,u=c.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(c,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:kE.MIDDLE,boundElements:null,textAlign:SE.CENTER,autoResize:!0}),PE(l,s,r.scene),i=EL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:lu.IMMEDIATELY}}});import{isEmbeddableElement as BL}from"@excalidraw/element";import{KEYS as UE,getShortcutKey as FL}from"@excalidraw/common";import{CaptureUpdateAction as OL}from"@excalidraw/element";import{pointFrom as BE}from"@excalidraw/math";import yL from"clsx";import{useCallback as _E,useEffect as RE,useLayoutEffect as wL,useRef as vL,useState as TL}from"react";import{EVENT as du,HYPERLINK_TOOLTIP_DELAY as IL,KEYS as ac}from"@excalidraw/common";import{getElementAbsoluteCoords as gu}from"@excalidraw/element";import{hitElementBoundingBox as CL}from"@excalidraw/element";import{isElementLink as SL}from"@excalidraw/element";import{getEmbedLink as kL,embeddableURLValidator as ML}from"@excalidraw/element";import{sceneCoordsToViewportCoords as FE,viewportCoordsToSceneCoords as LL,wrapEvent as PL,isLocalLink as AL,normalizeLink as mu}from"@excalidraw/common";import{isEmbeddableElement as pu}from"@excalidraw/element";import{jsx as oi,jsxs as NE}from"react/jsx-runtime";var fu=380,DL=42,uu=5,OE=85,_L=500,hu=!1,lc=new Map,zE=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=go(),s=fo(),d=se(),m=e.link||"",[c,p]=TL(m),u=vL(null),f=l.showHyperlinkPopup==="editor",b=_E(()=>{if(!u.current)return;let v=mu(u.current.value)||null;if(!e.link&&v&&re("hyperlink","create"),pu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!ML(v,s.validateEmbeddable))v&&n({message:g("toast.unableToEmbed"),closable:!0}),e.link&&lc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,L=kL(v);L?.error instanceof URIError&&n({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=L?L.intrinsicSize.w/L.intrinsicSize.h:1,A=lc.get(e.id)!==e.link;o.mutateElement(e,{...A?{width:L?.type==="video"?C>S?C:S*k:C,height:L?.type==="video"&&C>S?C/k:S}:{},link:v}),i(e,!0),lc.has(e.id)&&lc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);wL(()=>()=>{b()},[b]),RE(()=>{f&&u?.current&&!(d.viewport.isMobile||d.isTouchScreen)&&u.current.select()},[f,d.viewport.isMobile,d.isTouchScreen]),RE(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),NL(e,a,l,BE(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},_L))};return window.addEventListener(du.POINTER_MOVE,C,!1),()=>{window.removeEventListener(du.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=_E(()=>{re("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{re("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=HE(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:NE("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:fu,padding:uu},children:[f?oi("input",{className:yL("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:c,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[ac.CTRL_OR_CMD]&&v.key===ac.K&&v.preventDefault(),(v.key===ac.ENTER||v.key===ac.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?oi("a",{href:mu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:AL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let C=PL(du.EXCALIDRAW_LINK,v.nativeEvent);r({...e,link:mu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):oi("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),NE("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&oi(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:qo}),oi(K,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:ls}),m&&!pu(e)&&oi(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Mt})]})]})},HE=(e,o,t)=>{let[r,n]=gu(e,t),{x:i,y:a}=FE({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-fu/2,s=a-o.offsetTop-OE;return{x:l,y:s}},bu=(e,o)=>{let t=j(e,o);return pu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Sa=null,GE=(e,o,t)=>{Sa&&clearTimeout(Sa),Sa=window.setTimeout(()=>RL(e,o,t),IL)},RL=(e,o,t)=>{if(!e.link)return;let r=Un();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=SL(e.link)?g("labels.link.goToElement"):e.link;let[n,i,a,l]=gu(e,t),[s,d,m,c]=Jf([n,i,a,l],e.angle,o),p=FE({sceneX:s,sceneY:d},o);Lp(r,{left:p.x,top:p.y,width:m,height:c},"top"),re("hyperlink","tooltip","link-icon"),hu=!0},xu=()=>{Sa&&clearTimeout(Sa),hu&&(hu=!1,Un().classList.remove("excalidraw-tooltip--visible"))},NL=(e,o,t,[r,n])=>{let{x:i,y:a}=LL({clientX:r,clientY:n},t),l=15/t.zoom.value;if(CL(BE(i,a),e,o))return!1;let[s,d,m]=gu(e,o);if(i>=s&&i<=m&&a>=d-OE&&a<=d)return!1;let{x:c,y:p}=HE(e,t,o);return!(r>=c-l&&r<=c+fu+uu*2+l&&n>=p-l&&n<=p+l+uu*2+DL)};import{jsx as zL}from"react/jsx-runtime";var ka=B({name:"hyperlink",label:(e,o)=>bu(e,o),icon:qi,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:OL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[UE.CTRL_OR_CMD]&&e.key===UE.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=j(e,o);return zL(K,{type:"button",icon:qi,"aria-label":g(bu(e,o)),title:`${BL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${FL("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});import{KEYS as YE,arrayToMap as yu,randomId as HL}from"@excalidraw/common";import{elementsAreInSameGroup as GL,newElementWith as WE,selectGroupsFromGivenElements as VE}from"@excalidraw/element";import{CaptureUpdateAction as XE}from"@excalidraw/element";var Eu=e=>e.every(o=>!o.locked),Ma=B({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Eu(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=j(o,e);return Eu(t)?wn:Br},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Eu(n),a=yu(n),l=n.length>1&&GL(n),d=n.length===1||l?null:HL(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let w=n[0].groupIds.at(-1);delete m[w]}let c=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?d&&(E=[...E,d]):E=E.filter(y=>!o.lockedMultiSelections[y]),WE(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=yu(c),u=i?{}:Object.fromEntries(n.map(w=>[w.id,!0])),f=n.map(w=>p.get(w.id)||w),b=i?{}:VE(f,o),x=i?d||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:c,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:XE.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===YE.L&&e[YE.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),KE=B({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Br,predicate:(e,o)=>j(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return WE(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=yu(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:VE(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:XE.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as oD,isLinearElement as rD,isLineElement as yi}from"@excalidraw/element";import{arrayToMap as nD,invariant as wh}from"@excalidraw/common";import{toggleLinePolygonState as iD,CaptureUpdateAction as K2}from"@excalidraw/element";import E2 from"clsx";import q8 from"fuzzy";import{useEffect as _c,useRef as J8,useState as Dc}from"react";import{DEFAULT_SIDEBAR as b2,EVENT as Nc,KEYS as io,capitalizeString as Q8,getShortcutKey as e7,isWritableElement as t7}from"@excalidraw/common";import{CaptureUpdateAction as TP}from"@excalidraw/element";import{useEffect as Aa,useMemo as ZE,useRef as Iu,useState as UL}from"react";import{getLinearElementSubType as ii,updateElbowArrowPoints as YL}from"@excalidraw/element";import{pointFrom as cc,pointRotateRads as WL}from"@excalidraw/math";import{hasBoundTextElement as VL,isArrowBoundToElement as XL,isArrowElement as KL,isElbowArrow as ZL,isLinearElement as Mu,isUsingAdaptiveRadius as $L}from"@excalidraw/element";import{getCommonBoundingBox as jL,getElementAbsoluteCoords as qL}from"@excalidraw/element";import{getBoundTextElement as QE,getBoundTextMaxHeight as JL,getBoundTextMaxWidth as QL,redrawTextBoundingBox as eP}from"@excalidraw/element";import{wrapText as tP}from"@excalidraw/element";import{assertNever as oP,CLASSES as rP,getFontString as wu,isProdEnv as nP,mapFind as iP,reduceToCommonValue as aP,updateActiveTool as $E}from"@excalidraw/common";import{measureText as jE}from"@excalidraw/element";import{LinearElementEditor as lP}from"@excalidraw/element";import{newArrowElement as vu,newElement as sP,newLinearElement as cP}from"@excalidraw/element";import{ShapeCache as dP}from"@excalidraw/element";import{updateBindings as mP}from"@excalidraw/element";import{jsx as ku}from"react/jsx-runtime";var pP=8,uP=10,La=["rectangle","diamond","ellipse"],Pa=["line","sharpArrow","curvedArrow","elbowArrow"],hP=new Set(La),gP=new Set(Pa),ai=e=>hP.has(e),mc=e=>e==="arrow"||gP.has(e),no=me(null),Da=new Map,_a=new Map,fP=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Iu(null);return Aa(()=>{if(o.length===0){e.updateEditorAtom(no,null);return}let r=li(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(no,null),t.current=null)},[o,e]),Aa(()=>()=>{Da.clear(),_a.clear()},[]),ku(bP,{app:e,elements:o})},bP=({app:e,elements:o})=>{let t=li(o),r=ZE(()=>t==="generic"?ty(o):[],[t,o]),n=ZE(()=>t==="linear"?Su(o):[],[t,o]),i=t==="generic"?r.every(c=>c.type===r[0].type):t==="linear"?n.every(c=>ii(c)===ii(n[0])):!1,[a,l]=UL({x:0,y:0}),s=Iu(""),d=Iu(null);Aa(()=>{let c=[...r,...n].sort((x,w)=>x.id.localeCompare(w.id)),p=`
|
|
8
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${c.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(c.length===1){let[x,,,w,E,y]=qL(c[0],e.scene.getNonDeletedElementsMap());u=WL(cc(x,w),cc(E,y),c[0].angle)}else{let{minX:x,maxY:w}=jL(c);u=cc(x,w)}let{x:f,y:b}=ry({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),Aa(()=>{for(let c of n){let p=Cu(c.id,vP(c));_a.has(p)||_a.set(p,c)}},[n]),Aa(()=>{for(let c of r)if(!Da.has(c.id)){let p=QE(c,e.scene.getNonDeletedElementsMap());p&&Da.set(c.id,{fontSize:p.fontSize})}},[r,e.scene]);let m=t==="linear"?[["line",Vl],["sharpArrow",rs],["curvedArrow",is],["elbowArrow",ns]]:t==="generic"?[["rectangle",Ul],["diamond",Yl],["ellipse",Wl]]:[];return ku("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(uP+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-pP}px`,zIndex:2},className:rP.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([c,p])=>{let u=i&&(t==="generic"&&r[0].type===c||t==="linear"&&ii(n[0])===c);return ku(K,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:c,keyBindingLabel:"","aria-label":c,"data-testid":`toolbar-${c}`,onChange:()=>{e.state.activeTool.type!==c&&re("convertElementType",c,"ui"),Lu(e,{conversionType:t,nextType:c}),d.current?.focus()}},`${o[0].id}${o[0].version}_${c}`)})})},xP=(e,o,t)=>{let r=QL(e,o),n=JL(e,o),i=tP(o.text,wu(o),r),a=jE(i,wu(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=jE(o.text,wu(s),o.lineHeight)}pc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),eP(o,e,t)},Lu=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=ty(n),d=l.every(m=>m.type===l[0].type)?La.indexOf(l[0].type):-1;if(t=t??La[(d+La.length+a)%La.length],t&&ai(t)){let m={};for(let p of l){let u=JE(p,t,e);m[u.id]=u}let c=[];for(let p of e.scene.getElementsIncludingDeleted())m[p.id]?c.push(m[p.id]):c.push(p);e.scene.replaceAllElements(c);for(let p of Object.values(m)){let u=QE(p,e.scene.getNonDeletedElementsMap());u&&(Da.get(p.id)&&pc(u,e.scene.getNonDeletedElementsMap(),{fontSize:Da.get(p.id)?.fontSize??u.fontSize}),xP(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:$E(p,{type:"selection"})}))}}if(o==="linear"){let l=Su(n);if(!t){let d=aP(l,ii),m=d?Pa.indexOf(d):-1;t=Pa[(m+Pa.length+a)%Pa.length]}if(mc(t)){let d=[],m=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=_a.get(Cu(c.id,t));if(p&&ii(p)===t)m.set(p.id,p),d.push(p);else{let u=JE(c,t,e);m.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(m);for(let c of d)if(Mu(c))if(ZL(c)){let p=EP(c);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=YL(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});pc(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=iP(["line","sharpArrow","curvedArrow"],u=>_a.get(Cu(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=Su(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new lP(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:$E(d,{type:"selection"})}))}return!0},li=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(ai(t.type))return"generic";ey(t)&&(o=!0)}return o?"linear":null},ey=e=>Mu(e)&&(!KL(e)||!XL(e)&&!VL(e)),Cu=(e,o)=>`${e}:${o}`,ty=e=>e.filter(o=>ai(o.type)),Su=e=>e.filter(o=>ey(o)),sc=20,ri=(e,o)=>e[0]===o[0],Tu=(e,o)=>e[1]===o[1],qE=(e,o)=>ri(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),EP=e=>{let o=[e.points[0]],t=yP(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<sc?l[0]=a[0]:Math.abs(l[1]-a[1])<sc&&(l[1]=a[1]),ri(a,l)||Tu(a,l)||o.push(cc(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)ri(o[i-1],o[i])&&ri(o[i],o[i+1])||Tu(o[i-1],o[i])&&Tu(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],d=ri(a,l),m=ri(l,s);if(d!==m){let c=qE(a,l),p=qE(l,s);if(c<sc||p<sc){if(p<c)d?s[0]=a[0]:s[1]=a[1];else if(m)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},yP=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},JE=(e,o,t)=>{if(!wP(e.type,o)){if(!nP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(dP.delete(e),ai(o)){let r=ni(sP({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:$L(o)?dc.ADAPTIVE_RADIUS:dc.PROPORTIONAL_RADIUS}:e.roundness}));return mP(r,t.scene),r}if(mc(o))switch(o){case"line":return ni(cP({...e,type:"line"}));case"sharpArrow":return ni(vu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return ni(vu({...e,type:"arrow",elbowed:!1,roundness:{type:dc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return ni(vu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return oP(o,`unhandled conversion type: ${o}`),e},wP=(e,o)=>!!(ai(e)&&ai(o)||mc(e)&&mc(o)),vP=e=>Mu(e)?ii(e):e.type,oy=fP;var ny=B({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return ze.set(no,{type:"panel"}),{captureUpdate:TP.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>li(e)!==null});import{canCreateLinkFromElements as Pu,defaultGetElementLinkFromSelection as IP,getLinkIdAndTypeFromSelection as CP}from"@excalidraw/element";import{CaptureUpdateAction as Ra}from"@excalidraw/element";var uc=B({name:"copyElementLink",label:"labels.copyElementLink",icon:Cn,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=j(e,o);try{if(window.location){let i=CP(n,o);return i?(await oo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):IP(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ra.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:Ra.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:Ra.EVENTUALLY}},predicate:(e,o)=>Pu(j(e,o))}),iy=B({name:"linkToElement",label:"labels.linkToElement",icon:ls,perform:(e,o,t,r)=>{let n=j(e,o);return n.length!==1||!Pu(n)?{elements:e,appState:o,app:r,captureUpdate:Ra.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:j(e,o)[0].id}},captureUpdate:Ra.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=j(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&Pu(n)},trackEvent:!1});import{isDarwin as ay,getShortcutKey as oe}from"@excalidraw/common";var SP={toggleTheme:[oe("Shift+Alt+D")],saveScene:[oe("CtrlOrCmd+S")],loadScene:[oe("CtrlOrCmd+O")],clearCanvas:[oe("CtrlOrCmd+Delete")],imageExport:[oe("CtrlOrCmd+Shift+E")],commandPalette:[oe("CtrlOrCmd+/"),oe("CtrlOrCmd+Shift+P")],cut:[oe("CtrlOrCmd+X")],copy:[oe("CtrlOrCmd+C")],paste:[oe("CtrlOrCmd+V")],copyStyles:[oe("CtrlOrCmd+Alt+C")],pasteStyles:[oe("CtrlOrCmd+Alt+V")],selectAll:[oe("CtrlOrCmd+A")],deleteSelectedElements:[oe("Delete")],duplicateSelection:[oe("CtrlOrCmd+D"),oe(`Alt+${g("helpDialog.drag")}`)],sendBackward:[oe("CtrlOrCmd+[")],bringForward:[oe("CtrlOrCmd+]")],sendToBack:[ay?oe("CtrlOrCmd+Alt+["):oe("CtrlOrCmd+Shift+[")],bringToFront:[ay?oe("CtrlOrCmd+Alt+]"):oe("CtrlOrCmd+Shift+]")],copyAsPng:[oe("Shift+Alt+C")],group:[oe("CtrlOrCmd+G")],ungroup:[oe("CtrlOrCmd+Shift+G")],gridMode:[oe("CtrlOrCmd+'")],zenMode:[oe("Alt+Z")],objectsSnapMode:[oe("Alt+S")],stats:[oe("Alt+/")],addToLibrary:[],flipHorizontal:[oe("Shift+H")],flipVertical:[oe("Shift+V")],viewMode:[oe("Alt+R")],hyperlink:[oe("CtrlOrCmd+K")],toggleElementLock:[oe("CtrlOrCmd+Shift+L")],resetZoom:[oe("CtrlOrCmd+0")],zoomOut:[oe("CtrlOrCmd+-")],zoomIn:[oe("CtrlOrCmd++")],zoomToFitSelection:[oe("Shift+3")],zoomToFit:[oe("Shift+1")],zoomToFitSelectionInViewport:[oe("Shift+2")],toggleEraserTool:[oe("E")],toggleHandTool:[oe("H")],setFrameAsActiveTool:[oe("F")],saveFileToDisk:[oe("CtrlOrCmd+S")],saveToActiveFile:[oe("CtrlOrCmd+S")],toggleShortcuts:[oe("?")],searchMenu:[oe("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Ne=(e,o=0)=>{let t=SP[e];return t&&t.length>0?t[o]||t[0]:""};var kP="\\u0300-\\u036f",MP="\\ufe20-\\ufe2f",LP="\\u20d0-\\u20ff",PP=kP+MP+LP,AP=`[${PP}]`,DP=RegExp(AP,"g"),_P=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,RP={\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"},Au=e=>e.replace(_P,o=>RP[o]||o).replace(DP,"");import T8 from"clsx";import{useEffect as I8,useState as C8}from"react";import{KEYS as S8,queryFocusableElements as n2}from"@excalidraw/common";import{useCallback as NP,useState as BP}from"react";var ly=()=>{let[e,o]=BP(null),t=NP(r=>o(r),[]);return[e,t]};import{useState as Jy,useCallback as Ku,useMemo as Qy,useEffect as $y,memo as e2,useRef as p8}from"react";import{LIBRARY_DISABLED_TYPES as u8,randomId as h8,isShallowEqual as g8}from"@excalidraw/common";import{useEffect as my,useRef as py}from"react";import{URL_HASH_KEYS as Ru,URL_QUERY_KEYS as Nu,APP_NAME as uy,EVENT as gc,DEFAULT_SIDEBAR as GP,LIBRARY_SIDEBAR_TAB as UP,arrayToMap as Bu,cloneJSON as YP,preventUnload as WP,promiseTry as hy,resolvablePromise as VP,toValidURL as XP,Queue as KP,Emitter as ZP}from"@excalidraw/common";import{hashElementsVersion as $P,hashString as jP}from"@excalidraw/element";import{getCommonBoundingBox as _u}from"@excalidraw/element";import{MIME_TYPES as jr}from"@excalidraw/common";var cr=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:d,viewBackgroundColor:m}=s;return _l(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(c,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=r<b?r/b:o?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},sy=async e=>{let{mimeType:o=jr.png,quality:t}=e;o===jr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${jr.png}" mimeType`),o==="image/jpg"&&(o=jr.jpg),o===jr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${jr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await cr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===jr.png&&e.appState?.exportEmbedScene&&(a=await l1({blob:a,metadata:Yi(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},si=async({elements:e,appState:o=$o(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:d}=bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),m={...d,exportPadding:r};return fn(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},FP=async e=>{if(e.type==="svg"){let o=await si(e);await oo(o.outerHTML)}else if(e.type==="png")await Vs(sy(e));else if(e.type==="json")await Ys(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as OP,useState as zP}from"react";import{COLOR_PALETTE as HP}from"@excalidraw/common";var Du=me(new Map),cy=async e=>await si({elements:e,appState:{exportBackground:!1,viewBackgroundColor:HP.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),dy=(e,o,t)=>{let[r,n]=zP();return OP(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await cy(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await cy(o);n(i)})()},[e,o,t,n]),r},hc=()=>{let[e]=ie(Du);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var qP=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],fy=new ZP,qr=me({status:"loaded",isInitialized:!1,libraryItems:[]}),Na=e=>YP(e),JP=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),by=(e,o)=>{let t=[];for(let r of o)JP(e,r)&&t.push(r);return[...t,...e]},xy=(e,o)=>{let t=Bu(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=Bu(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Fu=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",Na(this.currLibraryItems));I(this,"app");I(this,"updateQueue",[]);I(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);I(this,"notifyListeners",()=>{if(this.updateQueue.length>0)ze.set(qr,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{ze.set(qr,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Na(this.currLibraryItems);let t=Na(this.currLibraryItems);this.app.props.onLibraryChange?.(t),fy.trigger(xy(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],ze.set(Du,new Map)});I(this,"resetLibrary",()=>this.setLibrary([]));I(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Na(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:GP.name,tab:UP}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),d;s instanceof Blob?d=await fm(s,i):d=Xi(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:d.length}))?(t&&this.app.focusContainer(),a(r?by(this.currLibraryItems,d):d)):l(new hn)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Na(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Ey=Fu,xc=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=_u(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=_u(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,d=0,m=0,c=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,c=0,p++),c===0&&(s=n(p)),d=i(c);let{minX:f,minY:b,width:x,height:w}=_u(u.elements),E=(d-x)/2,y=(s-w)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=d+50,m++,c++}return r},QP=(e,o=qP)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Ou=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Ru.addLibrary)||new URLSearchParams(window.location.search).get(Nu.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},dr=class dr{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Xi(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?dr.queue.push(n):n()}getLibraryItems(o){return dr.getLibraryItems(this.adapter,o,!1)}};I(dr,"queue",new KP),I(dr,"run",async(o,t)=>{let r=new dr(o);return dr.queue.push(()=>t(r))});var ci=dr,Ba=0,fc=0,bc=e=>jP(e.map(o=>`${o.id}:${$P(o.elements)}`).sort().join()),gy=async(e,o)=>{try{return fc++,await ci.run(e,async t=>{let r=Bu(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=bc(i);return a!==Ba&&await e.save({libraryItems:i}),Ba=a,i})}finally{fc--}},eA=e=>{let{excalidrawAPI:o}=e,t=py(e);t.current=e;let r=py(!1);my(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let d=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=XP(l),QP(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();c(f)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(c=>{window.addEventListener("focus",()=>c(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:d,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(c){throw o.updateScene({appState:{errorMessage:c.message}}),c}finally{if(window.location.hash.includes(Ru.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(Ru.addLibrary),window.history.replaceState({},uy,`#${c.toString()}`)}else if(window.location.search.includes(Nu.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(Nu.addLibrary),window.history.replaceState({},uy,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=Ou();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Ou();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,d=VP();s?d.resolve(hy(s.load).then(async m=>{let c=null;try{if(!m)return ci.getLibraryItems(l,"load");c=Xi(m.libraryItems||[],"published");let p=await gy(l,xy([],c));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),c}}).catch(m=>(console.error(`error during library migration: ${m.message}`),ci.getLibraryItems(l,"load")))):d.resolve(hy(ci.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:d.then(m=>{let c=m||[];return Ba=bc(c),c}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(gc.HASHCHANGE,i),()=>{window.removeEventListener(gc.HASHCHANGE,i)}},[o]),my(()=>{let n=fy.on(async(a,l)=>{let s=r.current,d="adapter"in t.current&&t.current.adapter||null;try{d&&Ba!==bc(l)&&await gy(d,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{fc&&WP(a)};return window.addEventListener(gc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(gc.BEFORE_UNLOAD,i),n(),Ba=0,fc=0}},[])};import nA from"clsx";import{VERSIONS as tA}from"@excalidraw/common";import{jsx as rA}from"react/jsx-runtime";var oA=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return rA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${tA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},yy=oA;import{jsx as iA,jsxs as aA}from"react/jsx-runtime";var Ec=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>aA("div",{className:nA("library-menu-control-buttons",i),style:r,children:[iA(yy,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as pi,useEffect as n8,useMemo as Ky,useRef as i8,useState as a8}from"react";import{MIME_TYPES as l8,arrayToMap as s8}from"@excalidraw/common";import{duplicateElements as c8}from"@excalidraw/element";import lA from"lodash.throttle";import{useEffect as sA}from"react";var cA=me(0),wy=e=>{let[o,t]=ie(cA);return sA(()=>{let{current:r}=e;if(!r)return;let n=lA(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import GA from"clsx";import{useCallback as UA,useState as Uu}from"react";import{muteFSAbortError as YA}from"@excalidraw/common";import{flushSync as vy}from"react-dom";import dA from"clsx";import{jsx as yc,jsxs as pA}from"react/jsx-runtime";var mA=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return pA("button",{className:dA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&yc("div",{style:a?{visibility:"hidden"}:{},children:r}),yc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&yc("div",{style:{position:"absolute",inset:0},children:yc(tt,{})})]})},No=mA;import{jsx as Ty,jsxs as Iy}from"react/jsx-runtime";var uA=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=le(),d=jo(di),{container:m}=He();return Iy(Be,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,Iy("div",{className:"confirm-dialog-buttons",children:[Ty(No,{label:i,onClick:()=>{s({openMenu:null}),d(!1),vy(()=>{t()}),m?.focus()}}),Ty(No,{label:n,onClick:()=>{s({openMenu:null}),d(!1),vy(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},wc=uA;import Tc from"open-color";import{useCallback as yA,useEffect as Gu,useRef as Cy,useState as zu}from"react";import{EDITOR_LS_KEYS as Hu,EXPORT_DATA_TYPES as wA,MIME_TYPES as Sy,VERSIONS as vA,chunk as TA,getExportSource as IA}from"@excalidraw/common";var Gt=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};I(Gt,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),I(Gt,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import vc from"react";var hA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,gA=/{{([\w-]+)}}/,fA=/<([\w-]+)>/,bA=/<\/([\w-]+)>/,xA=(e,o)=>{let t=[{name:"",children:[]}];return e.split(hA).filter(Boolean).forEach(r=>{let n=r.match(fA),i=r.match(bA),a=r.match(gA);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),d=vc.createElement(vc.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(d))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},EA=({i18nKey:e,children:o,...t})=>{let{t:r}=Oe();return vc.createElement(vc.Fragment,{},...xA(r(e),t))},ht=EA;import{jsx as ae,jsxs as at}from"react/jsx-runtime";var CA=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=TA(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=Tc.white,l.fillRect(0,0,a.width,a.height);for(let[s,d]of e.entries()){let m=await cr({elements:d.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=m,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(m,f+(128-c)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=Tc.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await Fl(new File([await ko(a)],"preview",{type:Sy.png}),{outputType:Sy.jpg,maxWidthOrHeight:5e3})},SA=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=Cy(null),a=Cy(null);return Gu(()=>{let l=i.current;l&&(async()=>{let s=await si({elements:e.elements,appState:{...o,viewBackgroundColor:Tc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),at("div",{className:"single-library-item",children:[e.status==="published"&&ae("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ae("div",{ref:i,className:"single-library-item__svg"}),ae(K,{"aria-label":g("buttons.remove"),type:"button",icon:Bt,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:g("buttons.remove")}),at("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[at("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[at("div",{style:{padding:"0.5em 0"},children:[ae("span",{style:{fontWeight:500,color:Tc.gray[6]},children:g("publishDialog.itemName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),ae("span",{className:"error",children:e.error})]})]})},kA=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=zu({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[d,m]=zu(!1);Gu(()=>{let y=Gt.get(Hu.PUBLISH_LIBRARY);y&&s(y)},[]);let[c,p]=zu(o.slice());Gu(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),m(!0);let v=[],C=!1;if(c.forEach(N=>{let O="";N.name||(O=g("publishDialog.errors.required"),C=!0),v.push({...N,error:O})}),C){p(v),m(!1);return}let S=await CA(c),L={type:wA.excalidrawLibrary,version:vA.excalidrawLibrary,source:IA(),libraryItems:c},k=JSON.stringify(L,null,2),A=new Blob([k],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",A),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(N=>N.ok?N.json().then(({url:O})=>{Gt.delete(Hu.PUBLISH_LIBRARY),r({url:O,authorName:l.authorName,items:c})}):N.json().catch(()=>{throw new Error(N.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||N.statusText||"something went wrong")}),N=>{console.error(N),n(N),m(!1)}).catch(N=>{console.error(N),n(N),m(!1)})},b=()=>{let y=[];return c.forEach((v,C)=>{y.push(ae("div",{className:"single-library-item-wrapper",children:ae(SA,{libItem:v,appState:t,index:C,onChange:(S,L)=>{let k=c.slice();k[L].name=S,p(k)},onRemove:a})},C))}),ae("div",{className:"selected-library-items",children:y})},x=yA(()=>{i(c),Gt.set(Hu.PUBLISH_LIBRARY,l),e()},[c,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return ae(Be,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:w?at("form",{onSubmit:f,children:[ae("div",{className:"publish-library-note",children:ae(ht,{i18nKey:"publishDialog.noteDescription",link:y=>ae("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),ae("span",{className:"publish-library-note",children:ae(ht,{i18nKey:"publishDialog.noteGuidelines",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ae("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&ae("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),at("div",{className:"publish-library__fields",children:[at("label",{children:[at("div",{children:[ae("span",{children:g("publishDialog.libraryName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),at("label",{style:{alignItems:"flex-start"},children:[at("div",{children:[ae("span",{children:g("publishDialog.libraryDesc")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),at("label",{children:[at("div",{children:[ae("span",{children:g("publishDialog.authorName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),at("label",{children:[ae("span",{children:g("publishDialog.githubUsername")}),ae("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),at("label",{children:[ae("span",{children:g("publishDialog.twitterUsername")}),ae("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),at("label",{children:[ae("span",{children:g("publishDialog.website")}),ae("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ae("span",{className:"publish-library-note",children:ae(ht,{i18nKey:"publishDialog.noteLicense",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),at("div",{className:"publish-library__buttons",children:[ae(No,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ae(No,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:d})]})]}):ae("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},ky=kA;import PA from"clsx";import{useEffect as AA,useRef as DA}from"react";import{EVENT as Ay,KEYS as _A}from"@excalidraw/common";import{forwardRef as My}from"react";import Ly from"clsx";import{jsx as Py}from"react/jsx-runtime";var MA=My(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Py("div",{className:Ly("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),LA=My(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Py("div",{className:Ly("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),qe={Row:MA,Col:LA};import{jsx as Ic}from"react/jsx-runtime";var Dy=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=se(),a=DA(null),l=Jo({onClickOutside:o});Dn(a,()=>{l.onClickOutside?.()}),AA(()=>{let d=c=>{c.key===_A.ESCAPE&&(c.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener(Ay.KEYDOWN,d,m),()=>{document.removeEventListener(Ay.KEYDOWN,d,m)}},[l]);let s=PA(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Ic(pp.Provider,{value:{onSelect:r},children:Ic("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Ic(qe.Col,{className:"dropdown-menu-container",children:e}):Ic(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};Dy.displayName="DropdownMenuContent";var _y=Dy;import{jsx as NA}from"react/jsx-runtime";var RA=({children:e,className:o="",selected:t,...r})=>NA("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Ry=RA;import{jsx as Ny}from"react/jsx-runtime";var By=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let d=ks(s.onClick,n);return Ny("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:Ss(i,a),title:s.title??s["aria-label"],onClick:d,children:Ny(Cs,{icon:e,shortcut:o,children:r})})},mi=By;By.displayName="DropdownMenuItemLink";import{jsx as BA}from"react/jsx-runtime";var Fy=()=>BA("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Oy=Fy;Fy.displayName="DropdownMenuSeparator";import FA from"clsx";import{jsx as OA}from"react/jsx-runtime";var zy=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=se(),a=FA(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return OA("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},Hy=zy;zy.displayName="DropdownMenuTrigger";import Cc from"react";var Gy=e=>{let o=Cc.Children.toArray(e).find(t=>Cc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},Uy=e=>{let o=Cc.Children.toArray(e).find(t=>Cc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as zA,jsxs as HA}from"react/jsx-runtime";var Bo=({children:e,open:o})=>{let t=Gy(e),r=Uy(e);return HA(zA,{children:[t,o&&r]})};Bo.Trigger=Hy;Bo.Content=_y;Bo.Item=pt;Bo.ItemLink=mi;Bo.ItemCustom=Ry;Bo.Group=sa;Bo.Separator=Oy;var fe=Bo;Bo.displayName="DropdownMenu";import{jsx as Tt,jsxs as Sc}from"react/jsx-runtime";var WA=(e,o)=>e.filter(t=>o.includes(t.id)),VA=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ie(qr),[d,m]=ie(di),c=()=>{let P=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),N=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return Tt(wc,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:N,children:Tt("p",{children:P})})},[p,u]=Uu(!1),f=!!o.length,b=f?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,E]=Uu(!1),[y,v]=Uu(null),C=UA(()=>Sc(Be,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Tt("p",{children:Tt(ht,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>Tt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),Tt(K,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,N)=>{E(!1),v({url:P.url,authorName:P.authorName});let O=N.slice();O.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(O)},L=async()=>{try{await t.updateLibrary({libraryItems:Ml({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let P=f?b:await t.getLatestLibrary();qf(P).catch(YA).catch(N=>{e({errorMessage:N.message})})},A=()=>Sc(fe,{open:d,children:[Tt(fe.Trigger,{onToggle:()=>m(!d),children:C1}),Sc(fe.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&Tt(fe.Item,{onSelect:L,icon:In,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&Tt(fe.Item,{onSelect:k,icon:Fr,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&Tt(fe.Item,{onSelect:()=>u(!0),icon:Mt,children:x}),f&&Tt(fe.Item,{icon:N0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Sc("div",{className:GA("library-menu-dropdown-container",l),children:[A(),o.length>0&&Tt("div",{className:"library-actions-counter",children:o.length}),p&&c(),w&&Tt(ky,{onClose:()=>E(!1),libraryItems:WA(s.libraryItems,o),appState:a,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(N=>N!==P))}),y&&C()]})},Yu=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Re(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=hc(),a=ge(),l=le(),[s]=ie(qr),d=async c=>{let p=c.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Tt(VA,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>d(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as e8,useEffect as t8,useState as o8}from"react";import XA,{useCallback as KA}from"react";function ZA(){return[!1,KA(o=>o(),[])]}var Yy=XA.useTransition||ZA;import Wy from"clsx";import{memo as $A,useEffect as jA,useRef as qA,useState as JA}from"react";import{jsx as kc,jsxs as QA}from"react/jsx-runtime";var Vy=$A(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=qA(null),d=dy(e,o,l);jA(()=>{let f=s.current;if(f)return d&&(f.innerHTML=d.outerHTML),()=>{f.innerHTML=""}},[d]);let[m,c]=JA(!1),p=se().editor.isMobile,u=t&&kc("div",{className:"library-unit__adder",children:I1});return QA("div",{className:Wy("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!d}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[kc("div",{className:Wy("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}c(!1),a(e,f)}}),u,e&&o&&(m||p||n)&&kc(ba,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Xy=()=>kc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as r8,jsx as Mc}from"react/jsx-runtime";var Wu=({children:e})=>Mc("div",{className:"library-menu-items-container__grid",children:e}),Lc=e8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Yy(),[s,d]=o8(0);return t8(()=>{s<e.length&&l(()=>{d(s+a)})},[s,e.length,l,a]),Mc(r8,{children:e.map((m,c)=>c<s?Mc(Vy,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:i,id:m?.id,selected:r(m.id),onToggle:o,onDrag:t},m?.id??c):Mc(Xy,{},c))})});import{Fragment as Zy,jsx as It,jsxs as ui}from"react/jsx-runtime";var d8=17,m8=64;function Vu({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:d}){let m=i8(null),c=wy(m);n8(()=>{c>0&&m.current?.scrollTo(0,c)},[]);let{svgCache:p}=hc(),u=Ky(()=>o.filter(P=>P.status!=="published"),[o]),f=Ky(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[w,E]=a8(null),y=pi((P,N)=>{let O=!d.includes(P),U=[...u,...f];if(O){if(N.shiftKey&&w){let J=U.findIndex(Z=>Z.id===w),_=U.findIndex(Z=>Z.id===P);if(J===-1||_===-1){s([...d,P]);return}let R=s8(d),V=U.reduce((Z,W,ce)=>((ce>=J&&ce<=_||R.has(W.id))&&Z.push(W.id),Z),[]);s(V)}else s([...d,P]);E(P)}else E(null),s(d.filter(J=>J!==P))},[w,s,f,d,u]),v=pi(P=>{let N;return d.includes(P)?N=o.filter(O=>d.includes(O.id)):N=o.filter(O=>O.id===P),N.map(O=>({...O,elements:c8({type:"everything",elements:O.elements,randomizeSeed:!0}).duplicatedElements}))},[o,d]),C=pi((P,N)=>{N.dataTransfer.setData(l8.excalidrawlib,um(v(P)))},[v]),S=pi(P=>P?d.includes(P):!1,[d]),L=pi(()=>{t(n)},[n,t]),k=pi(P=>{P&&r(v(P))},[v,r]),A=p.size>=o.length?m8:d8;return ui("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&It(Yu,{selectedItems:d,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),ui(qe.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[ui(Zy,{children:[!x&&It("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&It("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:It(tt,{})}),!n.length&&!u.length?ui("div",{className:"library-menu-items__no-items",children:[It("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),It("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):ui(Wu,{children:[n.length>0&&It(Lc,{itemsRenderedPerBatch:A,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p}),It(Lc,{itemsRenderedPerBatch:A,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})]})]}),ui(Zy,{children:[(f.length>0||n.length>0||u.length>0)&&It("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?It(Wu,{children:It(Lc,{itemsRenderedPerBatch:A,items:f,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})}):u.length>0?It("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&It(Ec,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:It(Yu,{selectedItems:d,onSelectItems:s})})]})]})}import{jsx as mr,jsxs as qy}from"react/jsx-runtime";var di=me(!1),jy=({children:e})=>mr("div",{className:"layer-ui__library",children:e}),f8=e2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:d})=>{let[m]=ie(qr),c=Ku(f=>{(async(x,w)=>{re("element","addToLibrary","ui");for(let y of u8)if(x.some(v=>v.type===y))return r({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:h8(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{r({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,r,m.libraryItems]),p=Qy(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return mr(jy,{children:mr("div",{className:"layer-ui__library-message",children:qy("div",{children:[mr(tt,{size:"2em"}),mr("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return qy(jy,{children:[mr(Vu,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:d,selectedItems:s}),u&&mr(Ec,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Xu=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),b8=(e,o)=>{let t=tr(),[r,n]=Jy(()=>Xu(t,e.selectedElementIds)),i=p8(new Map);return $y(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),$y(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!g8(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Xu(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let d=l.get(s)?.version;if(d&&d!==i.current.get(s))return Xu(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},t2=e2(()=>{let e=Re(),{onInsertElements:o}=e,t=fo(),r=ge(),n=le(),[i,a]=Jy([]),l=Qy(()=>e.library,[e.library]),s=b8(r,e),d=Ku(c=>{o(xc(c))},[o]),m=Ku(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return mr(f8,{pendingElements:s,onInsertLibraryItems:d,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import x8 from"clsx";import{useRef as E8}from"react";import{createPortal as y8}from"react-dom";import{KEYS as w8}from"@excalidraw/common";import{jsx as o2,jsxs as v8}from"react/jsx-runtime";var r2=e=>{let{closeOnClickOutside:o=!0}=e,t=fs({className:"excalidraw-modal-container"}),r=E8(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===w8.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return y8(v8("div",{className:x8("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[o2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),o2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Fa,jsxs as M8}from"react/jsx-runtime";function k8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Be=e=>{let[o,t]=ly(),[r]=C8(document.activeElement),{id:n}=He(),i=se().viewport.isMobile;I8(()=>{if(!o)return;let d=n2(o);setTimeout(()=>{d.length>0&&e.autofocus!==!1&&(d[1]||d[0]).focus()});let m=c=>{if(c.key===S8.TAB){let p=n2(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&c.shiftKey?(p[p.length-1].focus(),c.preventDefault()):f===p.length-1&&!c.shiftKey&&(p[0].focus(),c.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=le(),l=jo(di),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return Fa(r2,{className:T8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:k8(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:M8(Xe,{ref:t,children:[e.title&&Fa("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Fa("span",{className:"Dialog__titleContent",children:e.title})}),i&&Fa("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Bt}),Fa("div",{className:"Dialog__content",children:e.children})]})})};import Zu from"clsx";import{forwardRef as D8,useRef as _8,useImperativeHandle as R8,useLayoutEffect as N8,useState as B8}from"react";import L8 from"clsx";import{composeEventHandlers as P8}from"@excalidraw/common";import{jsx as A8}from"react/jsx-runtime";var _t=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>A8("button",{onClick:P8(i.onClick,a=>{o()}),type:e,className:L8("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as $u,jsxs as i2}from"react/jsx-runtime";var hi=D8(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,...m},c)=>{let p=_8(null);R8(c,()=>p.current),N8(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=B8(!1);return i2("div",{className:Zu("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&$u("div",{className:"ExcTextField__label",children:o}),i2("div",{className:Zu("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[$u("input",{className:Zu({"is-redacted":"value"in m&&m.value&&l&&!u}),readOnly:n,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&$u(_t,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?Y0:kn})]})]})});import{KEYS as Ge}from"@excalidraw/common";var Oa=[{icon:A1,value:"selection",key:Ge.V,numericKey:Ge[1],fillable:!0},{icon:Ul,value:"rectangle",key:Ge.R,numericKey:Ge[2],fillable:!0},{icon:Yl,value:"diamond",key:Ge.D,numericKey:Ge[3],fillable:!0},{icon:Wl,value:"ellipse",key:Ge.O,numericKey:Ge[4],fillable:!0},{icon:D1,value:"arrow",key:Ge.A,numericKey:Ge[5],fillable:!0},{icon:Vl,value:"line",key:Ge.L,numericKey:Ge[6],fillable:!0},{icon:qo,value:"freedraw",key:[Ge.P,Ge.X],numericKey:Ge[7],fillable:!1},{icon:vn,value:"text",key:Ge.T,numericKey:Ge[8],fillable:!1},{icon:R1,value:"image",key:null,numericKey:Ge[9],fillable:!1},{icon:N1,value:"eraser",key:Ge.E,numericKey:Ge[0],fillable:!1}],a2=e=>Oa.find((t,r)=>t.numericKey!=null&&e===t.numericKey.toString()||t.key&&(typeof t.key=="string"?t.key===e:t.key.includes(e)))?.value||null;import Qu from"clsx";import{useState as z8}from"react";import{CLASSES as H8,KEYS as s2,capitalizeString as Ju,isTransparent as c2}from"@excalidraw/common";import{shouldAllowVerticalAlign as G8,suppportsHorizontalAlign as U8}from"@excalidraw/element";import{hasBoundTextElement as d2,isElbowArrow as Y8,isImageElement as W8,isLinearElement as V8,isTextElement as X8}from"@excalidraw/element";import{hasStrokeColor as m2,toolIsArrow as p2}from"@excalidraw/element";import{createIsolation as F8}from"jotai-scope";import ju from"react";import yo from"tunnel-rat";var qu=ju.createContext(null),ve=()=>ju.useContext(qu),O8=F8(),l2=()=>ju.useMemo(()=>({MainMenuTunnel:yo(),WelcomeScreenMenuHintTunnel:yo(),WelcomeScreenToolbarHintTunnel:yo(),WelcomeScreenHelpHintTunnel:yo(),WelcomeScreenCenterTunnel:yo(),FooterCenterTunnel:yo(),DefaultSidebarTriggerTunnel:yo(),DefaultSidebarTabTriggersTunnel:yo(),OverwriteConfirmDialogTunnel:yo(),TTDDialogTriggerTunnel:yo(),tunnelsJotai:O8}),[]);import{Fragment as Fo,jsx as Te,jsxs as $e}from"react/jsx-runtime";var eh=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return m2(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>m2(r.type))},th=(e,o)=>Ko(e.activeTool.type)||o.some(t=>Ko(t.type)),Pc=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=kl(o,e),i=!1;n.length===2&&(d2(n[0])||d2(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=se(),s=document.documentElement.getAttribute("dir")==="rtl",d=Ko(e.activeTool.type)&&!c2(e.currentItemBackgroundColor)||n.some(f=>Ko(f.type)&&!c2(f.backgroundColor)),m=n.length===1||i,c=!e.selectedLinearElement?.isEditing&&n.length===1&&V8(n[0])&&!Y8(n[0]),p=!e.croppingElementId&&n.length===1&&W8(n[0]),u=!i&&vt(e,r);return $e("div",{className:"selected-shape-actions",children:[Te("div",{children:eh(e,n)&&t("changeStrokeColor")}),th(e,n)&&Te("div",{children:t("changeBackgroundColor")}),d&&t("changeFillStyle"),(lm(e.activeTool.type)||n.some(f=>lm(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(sm(e.activeTool.type)||n.some(f=>sm(f.type)))&&$e(Fo,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(cm(e.activeTool.type)||n.some(f=>cm(f.type)))&&Te(Fo,{children:t("changeRoundness")}),(p2(e.activeTool.type)||n.some(f=>p2(f.type)))&&Te(Fo,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(X8))&&$e(Fo,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||U8(n,o))&&t("changeTextAlign")]}),G8(n,o)&&t("changeVerticalAlign"),(un(e.activeTool.type)||n.some(f=>un(f.type)))&&Te(Fo,{children:t("changeArrowhead")}),t("changeOpacity"),$e("fieldset",{children:[Te("legend",{children:g("labels.layers")}),$e("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&$e("fieldset",{children:[Te("legend",{children:g("labels.align")}),$e("div",{className:"buttonList",children:[s?$e(Fo,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):$e(Fo,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Te("div",{style:{flexBasis:"100%",height:0}}),$e("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&$e("fieldset",{children:[Te("legend",{children:g("labels.actions")}),$e("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),c&&t("toggleLinearEditor")]})]})]})},Ac=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=z8(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",d=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=ve();return $e(Fo,{children:[Oa.map(({value:c,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(r.tools?.[c]===!1)return null;let w=g(`toolBar.${c}`),E=u&&Ju(typeof u=="string"?u:u[0]),y=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return Te(K,{className:Qu("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===c,name:"editor-current-shape",title:`${Ju(w)} \u2014 ${y}`,keyBindingLabel:f||E,"aria-label":Ju(w),"aria-keyshortcuts":y,"data-testid":`toolbar-${c}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),c==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==c&&re("toolbar",c,"ui"),c==="image"?t.setActiveTool({type:c}):t.setActiveTool({type:c})}},c)}),Te("div",{className:"App-toolbar__divider"}),$e(fe,{open:n,children:[Te(fe.Trigger,{className:Qu("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||d||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:g("toolBar.extraTools"),children:a?zr:d?vm:l&&!t.props.isCollaborating?Qi:s?Ki:G0}),$e(fe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:zr,shortcut:s2.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:vm,"data-testid":"toolbar-embeddable",selected:d,children:g("toolBar.embeddable")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Qi,"data-testid":"toolbar-laser",selected:l,shortcut:s2.K.toLocaleUpperCase(),children:g("toolBar.laser")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Ki,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),Te("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Te(m.Out,{}),Te(fe.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:es,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Te(Fo,{children:$e(fe.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:ts,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),Te(fe.Item.Badge,{children:"AI"})]})})]})]})]})},u2=({renderAction:e,zoom:o})=>Te(qe.Col,{gap:1,className:H8.ZOOM_ACTIONS,children:$e(qe.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),h2=({renderAction:e,className:o})=>$e("div",{className:`undo-redo-buttons ${o}`,children:[Te("div",{className:"undo-button-container",children:Te(Pt,{label:g("buttons.undo"),children:e("undo")})}),Te("div",{className:"redo-button-container",children:$e(Pt,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),g2=({actionManager:e,showExitZenModeBtn:o})=>Te("button",{type:"button",className:Qu("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ei),children:g("buttons.exitZenMode")});import{useRef as K8}from"react";var oh=e=>{let o=K8({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as $8,jsxs as Z8}from"react/jsx-runtime";var Jr=me(null),f2=()=>{let[e,o]=ie(Jr),t=Ue();return e&&e==="clearCanvas"?$8(wc,{onConfirm:()=>{t.executeAction(_o),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:Z8("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var rh={};Vf(rh,{toggleTheme:()=>j8});var j8={...Yr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Yr,"commandPalette")}};import{jsx as lt,jsxs as wo}from"react/jsx-runtime";var o7=me(null),ke={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},r7=e=>{switch(e){case ke.app:return 1;case ke.export:return 2;case ke.editor:return 3;case ke.tools:return 4;case ke.elements:return 5;case ke.links:return 6;default:return 10}},Rc=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return wo("div",{className:E2("shortcut",o),children:[r.map((n,i)=>lt("div",{className:"shortcut-wrapper",children:lt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),lt("div",{className:"shortcut-desc",children:t})]})},y2=e=>!e.altKey&&e[io.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===io.P||e.key===io.SLASH),xce=Object.assign(e=>{let o=ge(),t=le();return _c(()=>{let r=n=>{y2(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&re("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Nc.KEYDOWN,r,{capture:!0}),()=>window.removeEventListener(Nc.KEYDOWN,r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:lt(n7,{...e})},{defaultItems:rh});function n7({customCommandPaletteItems:e}){let o=Re(),t=ge(),r=le(),n=fo(),i=Ue(),[a,l]=ie(o7),[s,d]=Dc(null),m=J8(null),c=Jo({uiAppState:t,customCommandPaletteItems:e,appProps:n});_c(()=>{let{uiAppState:S,customCommandPaletteItems:L,appProps:k}=c,A=U=>{let J="";return U.label&&(typeof U.label=="function"?J=g(U.label(o.scene.getNonDeletedElements(),S,o)):J=g(U.label)),J},P=U=>typeof U.icon=="function"?U.icon(S,o.scene.getNonDeletedElements()):U.icon,N=[],O=(U,J,_)=>{let R={label:A(U),icon:P(U),category:J,shortcut:Ne(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return _?_(R,U):R};if(S&&o.scene&&i){let U=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,ka,uc,iy].map(W=>O(W,ke.elements,(ce,he)=>({...ce,predicate:he.predicate?he.predicate:(de,it,po,mn)=>j(de,it).length>0}))),J=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(W=>O(W,ke.tools)),_=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(W=>O(W,ke.editor)),R=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(W=>O(W,ke.export));N=[...U,..._,{label:A(_o),icon:P(_o),shortcut:Ne(_o.name),category:ke.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{ze.set(Jr,"clearCanvas")}},{label:g("buttons.exportImage"),category:ke.export,icon:$l,shortcut:Ne("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...R];let V=[{label:g("toolBar.library"),category:ke.app,icon:yn,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:b2.name,tab:b2.defaultTab}})}},{label:g("search.title"),category:ke.app,icon:Lt,viewMode:!0,perform:()=>{i.executeAction(za)}},{label:g("labels.shapeSwitch"),category:ke.elements,icon:ea,perform:()=>{i.executeAction(ny)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:ke.elements,icon:Zl,viewMode:!1,predicate:(W,ce)=>{let he=j(W,ce);return he.length>0&&eh(ce,he)},perform:()=>{r(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Zl,category:ke.elements,viewMode:!1,predicate:(W,ce)=>{let he=j(W,ce);return he.length>0&&th(ce,he)},perform:()=>{r(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Zl,category:ke.editor,viewMode:!1,perform:()=>{r(W=>({openMenu:W.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Oa.reduce((W,ce)=>{let{value:he,icon:de,key:it,numericKey:po}=ce;if(k.UIOptions.tools?.[he]===!1)return W;let pn=it&&Q8(typeof it=="string"?it:it[0])||po,Cl={label:g(`toolBar.${he}`),category:ke.tools,shortcut:pn,icon:de,keywords:["toolbar"],viewMode:!1,perform:({event:nm})=>{he==="image"?o.setActiveTool({type:he}):o.setActiveTool({type:he})}};return W.push(Cl),W},[]),...J,{label:g("toolBar.lock"),category:ke.tools,icon:S.activeTool.locked?wn:Br,shortcut:io.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:ke.tools,icon:V0,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(W=>({...W,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:ke.tools,icon:es,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(W=>({...W,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Z=[...N,...V,...L||[]].map(W=>({...W,icon:W.icon||ea,order:W.order??r7(W.category),haystack:`${Au(W.label.toLocaleLowerCase())} ${W.keywords?.join(" ")||""}`}));d(Z),l(Z.find(W=>W.label===a?.label)??null)}},[c,o,i,d,a?.label,l,r]);let[p,u]=Dc(""),[f,b]=Dc(null),[x,w]=Dc({}),E=S=>{r({openDialog:null},S),u("")},y=(S,L)=>{t.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{S.perform({actionManager:i,event:L}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=oh(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),C=oh(S=>{let L=t7(S.target)||y2(S)||S.key===io.ESCAPE;if(L&&S.key!==io.ARROW_UP&&S.key!==io.ARROW_DOWN&&S.key!==io.ENTER)return;let k=Object.values(x).flat(),A=a&&!p&&v(a);if(S.key===io.ARROW_UP){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(P===0){b(a);return}if(f===a){let U=k[k.length-1];U&&b(U);return}}let N;P===-1?N=k.length-1:N=P===0?k.length-1:(P-1)%k.length;let O=k[N];O&&b(O);return}if(S.key===io.ARROW_DOWN){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(!f||P===k.length-1){b(a);return}if(f===a){let U=k[0];U&&b(U);return}}let N=(P+1)%k.length,O=k[N];O&&b(O);return}if(S.key===io.ENTER&&f&&setTimeout(()=>{y(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return _c(()=>(window.addEventListener(Nc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(Nc.KEYDOWN,C,{capture:!0})),[C]),_c(()=>{if(!s)return;let S=P=>{let N={};for(let O of P)N[O.category]?N[O.category].push(O):N[O.category]=[O];return N},L=s.filter(v).sort((P,N)=>P.order-N.order),k=!p&&a&&v(a);if(!p){w(S(k?L.filter(P=>P.label!==a?.label):L)),b(k?a:L[0]||null);return}let A=Au(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=q8.filter(A,L,{extract:P=>P.haystack}).sort((P,N)=>N.score-P.score).map(P=>P.original),w(S(L)),b(L[0]??null)},[p,s,v,a]),wo(Be,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[lt(hi,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&wo("div",{className:"shortcuts-wrapper",children:[lt(Rc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),lt(Rc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),lt(Rc,{shortcut:e7("Esc"),children:g("commandPalette.shortcuts.close")})]}),wo("div",{className:"commands",children:[a&&!p&&wo("div",{className:"command-category",children:[wo("div",{className:"command-category-title",children:[g("commandPalette.recents"),lt("div",{className:"icon",style:{marginLeft:"6px"},children:X0})]}),lt(x2,{command:a,isSelected:a.label===f?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,L)=>wo("div",{className:"command-category",children:[lt("div",{className:"command-category-title",children:S}),x[S].map(k=>lt(x2,{command:k,isSelected:k.label===f?.label,onClick:A=>y(k,A),onMouseMove:()=>b(k),showShortcut:!o.device.viewport.isMobile,appState:t},k.label))]},S)):s?wo("div",{className:"no-match",children:[lt("div",{className:"icon",children:Lt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var x2=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return wo("div",{className:E2("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?g("commandPalette.itemNotAvailable"):"",children:[wo("div",{className:"name",children:[e.icon&<(nr,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),lt(ca,{children:e.label})]}),i&&e.shortcut&<(Rc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as l1e,randomInteger as eD,getUpdatedTimestamp as tD}from"@excalidraw/common";import{simplify as W7}from"points-on-curve";import{pointsOnBezierCurves as Tce}from"points-on-curve";import{invariant as Cce}from"@excalidraw/common";import{curve as kce,lineSegment as Mce,pointFrom as Lce,pointDistance as Pce,pointFromArray as Ace,pointFromVector as Dce,pointRotateRads as _ce,polygon as Rce,polygonFromPoints as Nce,PRECISION as Bce,segmentsIntersectAt as Fce,vector as Oce,vectorAdd as zce,vectorFromPoint as Hce,vectorScale as Gce}from"@excalidraw/math";import{getElementAbsoluteCoords as Yce}from"@excalidraw/element";var nh=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as V7,pointDistance as U2,pointRotateRads as Vfe}from"@excalidraw/math";import{ROUGHNESS as X7,isTransparent as Wa,assertNever as K7,COLOR_PALETTE as Z7,LINE_POLYGON_POINT_MERGE_DISTANCE as Kfe}from"@excalidraw/common";import{RoughGenerator as $7}from"roughjs/bin/generator";import sfe from"roughjs/bin/rough";import{getStroke as F7}from"perfect-freehand";import{isRightAngleRads as mfe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as ufe,DEFAULT_REDUCED_GLOBAL_ALPHA as hfe,ELEMENT_READY_TO_ERASE_OPACITY as gfe,FRAME_STYLE as ffe,MIME_TYPES as O2,THEME as bfe,distance as xfe,getFontString as Efe,isRTL as yfe,getVerticalOffset as wfe}from"@excalidraw/common";import yhe from"roughjs/bin/rough";import{arrayToMap as vhe,invariant as P2,rescalePoints as The,sizeOf as Ihe}from"@excalidraw/common";import{degreesToRadians as fh,lineSegment as She,pointDistance as khe,pointFrom as ot,pointFromArray as w7,pointRotateRads as Ei}from"@excalidraw/math";import{pointsOnBezierCurves as Phe}from"points-on-curve";import{pointCenter as Oue,pointFrom as zue,pointRotateRads as Hue,pointsEqual as Gue,pointDistance as Uue,vectorFromPoint as Yue,curveLength as Wue,curvePointAtLength as Vue}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Zue,KEYS as $ue,shouldRotateWithDiscreteAngle as jue,getGridPoint as que,invariant as Jue,tupleToCoors as Que,viewportCoordsToSceneCoords as ehe}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as ohe,isPathALoop as rhe}from"@excalidraw/element";import{KEYS as Fpe,arrayToMap as Ope,isBindingFallthroughEnabled as zpe,tupleToCoors as Hpe,invariant as Gpe,isDevEnv as Upe,isTestEnv as Ype}from"@excalidraw/common";import{lineSegment as Vpe,pointFrom as Xpe,pointRotateRads as Kpe,vectorFromPoint as Zpe,pointDistanceSq as $pe,clamp as jpe,pointDistance as qpe,pointFromVector as Jpe,vectorScale as Qpe,vectorNormalize as eue,vectorCross as tue,pointsEqual as oue,lineSegmentIntersectionPoints as rue,PRECISION as nue}from"@excalidraw/math";import{isTransparent as ume}from"@excalidraw/common";import{curveIntersectLineSegment as gme,isPointWithinBounds as fme,lineSegment as bme,lineSegmentIntersectionPoints as xme,pointFrom as Eme,pointFromVector as yme,pointRotateRads as wme,pointsEqual as vme,vectorFromPoint as Tme,vectorNormalize as Ime,vectorScale as Cme}from"@excalidraw/math";import{ellipse as kme,ellipseSegmentInterceptPoints as Mme}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as i7,DEFAULT_PROPORTIONAL_RADIUS as ih,LINE_CONFIRM_THRESHOLD as a7,ROUNDNESS as ah}from"@excalidraw/common";import{curve as Zce,curveCatmullRomCubicApproxPoints as $ce,curveOffsetPoints as jce,lineSegment as qce,pointDistance as l7,pointFrom as Jce,pointFromArray as Qce,rectangle as ede}from"@excalidraw/math";var Bc=(e,o=1)=>{if(e.length>=3){let[t,r]=[e[0],e[e.length-1]];return l7(t,r)<=a7/o}return!1},Ha=(e,o)=>{if(o.roundness?.type===ah.PROPORTIONAL_RADIUS||o.roundness?.type===ah.LEGACY)return e*ih;if(o.roundness?.type===ah.ADAPTIVE_RADIUS){let t=o.roundness?.value??i7,r=t/ih;return e<=r?e*ih:t}return 0};import{ROUNDNESS as lde,assertNever as sde}from"@excalidraw/common";import{pointsEqual as dde}from"@excalidraw/math";var w2=e=>!!e&&e.type==="embeddable",v2=e=>!!e&&e.type==="iframe",sh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),Qr=e=>e!=null&&e.type==="text";var Fc=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var pr=e=>e!=null&&s7(e.type);var gi=e=>e!=null&&e.type==="arrow",Ga=e=>gi(e)&&e.elbowed;var s7=e=>e==="arrow"||e==="line";var fi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&Qr(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as zde,ARROW_LABEL_WIDTH_FRACTION as Hde,BOUND_TEXT_PADDING as Gde,DEFAULT_FONT_SIZE as Ude,TEXT_ALIGN as Yde,VERTICAL_ALIGN as Wde,getFontString as Vde,isProdEnv as Xde,invariant as Kde}from"@excalidraw/common";import{BOUND_TEXT_PADDING as fde,DEFAULT_FONT_SIZE as bde,DEFAULT_FONT_FAMILY as xde,getFontString as Ede,isTestEnv as yde,normalizeEOL as wde}from"@excalidraw/common";var vde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Lde,isTestEnv as Pde}from"@excalidraw/common";import{curvePointDistance as ome,distanceToLineSegment as rme,pointRotateRads as nme}from"@excalidraw/math";import{ellipse as ame,ellipseDistanceFromPoint as lme}from"@excalidraw/math/ellipse";import{invariant as Hme,isDevEnv as Gme,isTestEnv as Ume}from"@excalidraw/common";import{pointFrom as Wme,pointFromVector as Vme,pointRotateRads as Xme,pointScaleFromOrigin as Kme,pointsEqual as Zme,triangleIncludesPoint as $me,vectorCross as jme,vectorFromPoint as u7,vectorScale as qme}from"@excalidraw/math";var hh=[1,0],S2=[0,1],gh=[-1,0],k2=[0,-1],Oc=e=>{let[o,t]=e,r=Math.abs(o),n=Math.abs(t);return o>n?hh:o<=-n?gh:t>r?S2:k2},M2=(e,o)=>Oc(u7(e,o)),zc=(e,o)=>Hc(M2(e,o)),uh=(e,o)=>e[0]===o[0]&&e[1]===o[1],Hc=e=>uh(e,hh)||uh(e,gh);import{clamp as rpe,pointDistance as npe,pointFrom as ipe,pointScaleFromOrigin as ape,pointsEqual as lpe,pointTranslate as spe,vector as cpe,vectorCross as dpe,vectorFromPoint as mpe,vectorScale as ppe}from"@excalidraw/math";import{BinaryHeap as hpe,invariant as gpe,isAnyTrue as fpe,tupleToCoors as bpe,getSizeFromPoints as xpe,isDevEnv as Epe,arrayToMap as ype}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Eue,viewportCoordsToSceneCoords as yue}from"@excalidraw/common";import{normalizeRadians as vue,radiansBetweenAngles as Tue,radiansDifference as Iue}from"@excalidraw/math";import{pointsEqual as Sue}from"@excalidraw/math";var lh=e=>{let o=Math.floor(e.width/2)+1,t=0,r=e.width,n=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,r,n,i,a,0,n]};var v7=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},T7=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},bh=(e,o,t,r)=>{if(o.length<1)return null;let n=nh(o[0]);if(n.length<1)return null;let i=t==="start"?1:n.length-1,a=n[i].data;P2(a.length===6,"Op data length is not 6");let l=ot(a[4],a[5]),s=ot(a[2],a[3]),d=ot(a[0],a[1]),m=n[i-1],c=ot(0,0);if(m.op==="move"){let _=w7(m.data);P2(_!=null,"Op data is not a point"),c=_}else m.op==="bcurveTo"&&(c=ot(m.data[4],m.data[5]));let p=(_,R)=>Math.pow(1-_,3)*l[R]+3*_*Math.pow(1-_,2)*s[R]+3*Math.pow(_,2)*(1-_)*d[R]+c[R]*Math.pow(_,3),[u,f]=t==="start"?c:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=v7(r),C=0;{let[_,R]=t==="end"?e.points[e.points.length-1]:e.points[0],[V,Z]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-V,R-Z)}let L=Math.min(v,C*(r==="diamond"||r==="diamond_outline"?.25:.5)),k=u-E*L,A=f-y*L;if(r==="dot"||r==="circle"||r==="circle_outline"){let _=Math.hypot(A-f,k-u)+e.strokeWidth-2;return[u,f,_]}let P=T7(r);if(r==="crowfoot_many"||r==="crowfoot_one_or_many"){let[_,R]=Ei(ot(u,f),ot(k,A),fh(-P)),[V,Z]=Ei(ot(u,f),ot(k,A),fh(P));return[k,A,_,R,V,Z]}let[N,O]=Ei(ot(k,A),ot(u,f),-P*Math.PI/180),[U,J]=Ei(ot(k,A),ot(u,f),fh(P));if(r==="diamond"||r==="diamond_outline"){let _,R;if(t==="start"){let[V,Z]=e.points.length>1?e.points[1]:[0,0];[_,R]=Ei(ot(u+L*2,f),ot(u,f),Math.atan2(Z-f,V-u))}else{let[V,Z]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,R]=Ei(ot(u-L*2,f),ot(u,f),Math.atan2(f-Z,u-V))}return[u,f,N,O,_,R,U,J]}return[u,f,N,O,U,J]};import{pointFrom as Whe,pointCenter as Vhe,pointRotateRads as Xhe,vectorFromPoint as Khe,vectorNormalize as Zhe,vectorSubtract as $he,vectorAdd as jhe,vectorScale as qhe,pointFromVector as Jhe,clamp as Qhe,isCloseTo as ege}from"@excalidraw/math";import{arrayToMap as Hge}from"@excalidraw/common";import{isPointWithinBounds as Uge,pointFrom as Yge}from"@excalidraw/math";import{vectorCross as ige,vectorFromPoint as age}from"@excalidraw/math";import{arrayToMap as I7}from"@excalidraw/common";import{getElementBounds as C7}from"@excalidraw/element";import{isArrowElement as S7,isExcalidrawElement as k7,isFreeDrawElement as M7,isLinearElement as L7,isTextElement as P7}from"@excalidraw/element";import{rangeIncludesValue as Gc,pointFrom as zo,pointRotateRads as A7,rangeInclusive as Uc}from"@excalidraw/math";var D7=e=>e.type==="diamond"?[zo(e.width/2,0),zo(e.width,e.height/2),zo(e.width/2,e.height),zo(0,e.height/2)]:[zo(0,0),zo(0+e.width,0),zo(0+e.width,e.height),zo(0,e.height)],_7=e=>L7(e)||M7(e)?e.points:D7(e),D2=e=>{let o=e.reduce((t,[r,n])=>(t.minY=Math.min(t.minY,n),t.minX=Math.min(t.minX,r),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,n),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},_2=e=>{let o=_7(e),{cx:t,cy:r}=D2(o),n=zo(t,r),i=o.map(m=>A7(m,n,e.angle)),{minX:a,minY:l,maxX:s,maxY:d}=D2(i);return[a+e.x,l+e.y,s+e.x,d+e.y]},xh=(e,o,t=!1)=>{let r=_2(e),n=o[0]<=r[0]&&o[2]>=r[2]&&o[1]<=r[1]&&o[3]>=r[3];return t?n?!0:r[0]<=o[0]&&r[2]>=o[2]&&r[1]<=o[1]&&r[3]>=o[3]:n},R2=(e,o)=>{let t=_2(e);return(Gc(t[0],Uc(o[0],o[2]))||Gc(o[0],Uc(t[0],t[2])))&&(Gc(t[1],Uc(o[1],o[3]))||Gc(o[1],Uc(t[1],t[3])))},N2=({elements:e,bounds:o,type:t,errorMargin:r=0})=>{k7(o)&&(o=C7(o,I7(e)));let n=[o[0]-r,o[1]-r,o[2]+r,o[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?R2(a,n):t==="inside"?xh(a,n):xh(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);P7(a)&&a.containerId&&i.add(a.containerId),S7(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as vge,isShallowEqual as N7}from"@excalidraw/common";var R7=function(){let e=null,o=null,t=null,r=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let d={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];d[f]=!0}}let m={},c=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>d[b]);return f&&(p[u.id]=!0,Array.isArray(m[f])?m[f].push(u.id):m[f]=[u.id]),p},{});for(let p of Object.keys(m))m[p].length<2&&d[p]&&(d[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:d,selectedElementIds:Eh({...l.selectedElementIds,...c},s)},t},n=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):yh(a,i);return d.length?r(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Eh(i.selectedElementIds,l)}};return n.clearCache=()=>{o=null,e=null,t=null},n}();var Lge=function(){let e=null,o=null,t=null,r=(n,i)=>(t!=null&&n===e&&i.selectedElementIds===o||(t=n.some(a=>i.selectedElementIds[a.id]),e=n,o=i.selectedElementIds),t);return r.clearCache=()=>{e=null,o=null,t=null},r}(),yh=(e,o,t)=>{let r=new Set,n=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){n.push(i),r.add(i.id);continue}if(t?.includeBoundTextElement&&fi(i)&&o.selectedElementIds[i?.containerId]){n.push(i),r.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return n.forEach(a=>{Fc(a)&&B2(e,a.id).forEach(l=>!r.has(l.id)&&i.push(l)),i.push(a)}),i}return n};var Eh=(e,o)=>N7(o.selectedElementIds,e)?o.selectedElementIds:e;var B2=(e,o)=>{let t=[];for(let r of e.values())r.frameId===o&&t.push(r);return t};var O7=typeof document<"u"?document.createElement("img"):{src:""};O7.src=`data:${O2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var z7=typeof document<"u"?document.createElement("img"):{src:""};z7.src=`data:${O2.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var z2=new WeakMap;var H7=new WeakMap([]);function H2(e){let o=G7(e),t=new Path2D(o);return H7.set(e,t),t}function G7(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([r,n],i)=>[r,n,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return Y7(F7(o,t))}function F2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var U7=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function Y7(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,r,n,i)=>(n===o?t.push(r,F2(r,i[0]),"L",i[0],"Z"):t.push(r,F2(r,i[n+1])),t),["M",e[0],"Q"]).join(" ").replace(U7,"$1")}var G2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var st=class st{};I(st,"rg",new $7),I(st,"cache",new WeakMap),I(st,"get",o=>st.cache.get(o)),I(st,"set",(o,t)=>st.cache.set(o,t)),I(st,"delete",o=>st.cache.delete(o)),I(st,"destroy",()=>{st.cache=new WeakMap}),I(st,"generateElementShape",(o,t)=>{let r=t?.isExporting?void 0:st.get(o);if(r!==void 0)return r;z2.delete(o);let n=J7(o,st.rg,t||{isExporting:!1,canvasBackgroundColor:Z7.white,embedsValidationStatus:null});return st.cache.set(o,n),n});var xi=st,j7=e=>[8,8+e],V2=e=>[1.5,6+e];function q7(e){let o=e.roughness,t=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&t>=50||r>=15&&e.roundness&&G2(e.type)||pr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Oo=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?j7(e.strokeWidth):e.strokeStyle==="dotted"?V2(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:q7(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<X7.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=Wa(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return Bc(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},Y2=(e,o,t)=>sh(e)&&(o||w2(e)&&t?.get(e.id)!==!0)&&Wa(e.backgroundColor)&&Wa(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:v2(e)?{...e,strokeColor:Wa(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Wa(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,W2=(e,o,t,r,n,i,a)=>{let l=bh(e,o,t,r);if(l===null)return[];let s=(d,m)=>{if(d===null)return[];let[,,c,p,u,f]=d;return[n.line(c,p,u,f,m)]};switch(r){case"dot":case"circle":case"circle_outline":{let[d,m,c]=l;return delete i.strokeLineDash,[n.circle(d,m,c,{...i,fill:r==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[d,m,c,p,u,f]=l;return delete i.strokeLineDash,[n.polygon([[d,m],[c,p],[u,f],[d,m]],{...i,fill:r==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[d,m,c,p,u,f,b,x]=l;return delete i.strokeLineDash,[n.polygon([[d,m],[c,p],[u,f],[b,x],[d,m]],{...i,fill:r==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[d,m,c,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=V2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(c,p,d,m,i),n.line(u,f,d,m,i),...r==="crowfoot_one_or_many"?s(bh(e,o,t,"crowfoot_one"),i):[]]}}};var J7=(e,o,{isExporting:t,canvasBackgroundColor:r,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=Ha(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Oo(Y2(e,t,n),!0))}else i=o.rectangle(0,0,e.width,e.height,Oo(Y2(e,t,n),!1));return i}case"diamond":{let i,[a,l,s,d,m,c,p,u]=lh(e);if(e.roundness){let f=Ha(Math.abs(a-p),e),b=Ha(Math.abs(d-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${d-b}
|
|
7
|
+
${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var PE=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=U1(a);if(!a||!Y1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:d}=mn(e,o,!1);return await pn(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:d}),{fileHandle:a}};import{Fragment as DM,jsx as Ko,jsxs as _M}from"react/jsx-runtime";var bu=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>Ko(pE,{label:g("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),LE=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=AM(e),i=we(r,o)?Q(r,o):r;return Ko(DM,{children:LM.map(a=>{let[l,s]=H1(i,PM,a),d=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Ko(K,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:d,"aria-label":d,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),xu=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ko(Qa,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),vc=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>_M(Qa,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Ko(Nt,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Ko("div",{className:"excalidraw-tooltip-icon",children:Ib})})]})}),un=O({name:"saveToActiveFile",label:"buttons.save",icon:on,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=bs(o.fileHandle)?await PE(e,o,r.files,r.getName()):await ps(e,o,r.files,r.getName());return{captureUpdate:po.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:po.EVENTUALLY}}},keyTest:e=>e.key===xi.S&&e[xi.CTRL_OR_CMD]&&!e.shiftKey}),al=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:on,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await ps(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:po.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:g("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:po.EVENTUALLY}}},keyTest:e=>e.key===xi.S&&e.shiftKey&&e[xi.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Ko(K,{type:"button",icon:yb,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:pe().formFactor==="phone",hidden:!Rn,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ei=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await Hm(o,e);return{elements:n,appState:i,files:a,captureUpdate:po.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:po.EVENTUALLY}}},keyTest:e=>e[xi.CTRL_OR_CMD]&&e.key===xi.O}),AE=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ko("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Ko(dE,{value:e.exportWithDarkMode?fu.DARK:fu.LIGHT,onChange:t=>{o(t===fu.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as RM,DEFAULT_FONT_FAMILY as NM,DEFAULT_TEXT_ALIGN as BM,CODES as DE,KEYS as _E,getLineHeight as FM}from"@excalidraw/common";import{newElementWith as Tc}from"@excalidraw/element";import{hasBoundTextElement as OM,canApplyRoundnessTypeToElement as zM,getDefaultRoundnessTypeForElement as HM,isFrameLikeElement as GM,isArrowElement as UM,isExcalidrawElement as YM,isTextElement as Eu}from"@excalidraw/element";import{getBoundTextElement as WM,redrawTextBoundingBox as VM}from"@excalidraw/element";import{CaptureUpdateAction as yu}from"@excalidraw/element";var RE="{}",wu=O({name:"copyStyles",label:"labels.copyStyles",icon:up,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&OM(i)){let a=WM(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(RE=JSON.stringify(n)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:yu.EVENTUALLY}},keyTest:e=>e[_E.CTRL_OR_CMD]&&e.altKey&&e.code===DE.C}),vu=O({name:"pasteStyles",label:"labels.pasteStyles",icon:up,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(RE),i=n[0],a=n[1];if(!YM(i))return{elements:e,captureUpdate:yu.EVENTUALLY};let l=Q(e,o,{includeBoundTextElement:!0}),s=l.map(d=>d.id);return{elements:e.map(d=>{if(s.includes(d.id)){let m=i;if(Eu(d)&&d.containerId&&(m=a),!m)return d;let c=Tc(d,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?zM(m.roundness.type,d)?m.roundness:HM(d):null});if(Eu(c)){let p=m.fontSize||RM,u=m.fontFamily||NM;c=Tc(c,{fontSize:p,fontFamily:u,textAlign:m.textAlign||BM,lineHeight:m.lineHeight||FM(u)});let f=null;c.containerId&&(f=l.find(b=>Eu(c)&&b.id===c.containerId)||null),VM(c,f,r.scene)}return c.type==="arrow"&&UM(m)&&(c=Tc(c,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),GM(d)&&(c=Tc(c,{roundness:null,backgroundColor:"transparent"})),c}return d}),captureUpdate:yu.IMMEDIATELY}},keyTest:e=>e[_E.CTRL_OR_CMD]&&e.altKey&&e.code===DE.V});import{KEYS as XM}from"@excalidraw/common";import{CaptureUpdateAction as KM}from"@excalidraw/element";var hn=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:gb,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:KM.EVENTUALLY}),keyTest:e=>e.key===XM.QUESTION_MARK});import{getNonDeletedElements as Cc}from"@excalidraw/element";import{newElementWith as FE}from"@excalidraw/element";import{isBoundToContainer as $M}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as ZM,getElementsInResizingFrame as jM,getFrameLikeElements as qM,getRootElements as JM,groupByFrameLikes as QM,removeElementsFromFrame as eP,replaceAllElementsInFrame as tP}from"@excalidraw/element";import{KEYS as Sc,randomId as oP,arrayToMap as Tu}from"@excalidraw/common";import{getSelectedGroupIds as Ic,selectGroup as rP,selectGroupsForSelectedElements as nP,getElementsInGroup as NE,addToGroup as iP,removeFromSelectedGroups as aP,isElementInGroup as OE}from"@excalidraw/element";import{syncMovedIndices as lP}from"@excalidraw/element";import{CaptureUpdateAction as ll}from"@excalidraw/element";import{jsx as yi}from"react/jsx-runtime";var sP=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&OE(n,t),!0))return!0}return!1},BE=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!sP(r)&&!ZM(r)},Iu=O({name:"group",label:"labels.group",icon:e=>yi(cp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JM(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:ll.EVENTUALLY};let i=Ic(o);if(i.length===1){let x=i[0],w=new Set(NE(e,x).map(v=>v.id)),E=new Set(n.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:ll.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&QM(n).forEach((w,E)=>{eP(w,r.scene.getNonDeletedElementsMap())});let s=oP(),d=Tu(n);a=a.map(x=>d.get(x.id)?FE(x,{groupIds:iP(x.groupIds,s,o.editingGroupId)}):x);let m=NE(a,s),c=m[m.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!OE(x,s)),b=lP([...f,...m,...u],Tu(m));return{appState:{...o,...rP(s,{...o,selectedGroupIds:{}},Cc(a))},elements:b,captureUpdate:ll.IMMEDIATELY}},predicate:(e,o,t,r)=>BE(e,o,r),keyTest:e=>!e.shiftKey&&e[Sc.CTRL_OR_CMD]&&e.key===Sc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yi(K,{hidden:!BE(e,o,r),type:"button",icon:yi(cp,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${_("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:we(Cc(e),o)})}),Cu=O({name:"ungroup",label:"labels.ungroup",icon:e=>yi(dp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Ic(o),i=Tu(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:ll.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{$M(p)&&l.push(p.id);let u=aP(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:FE(p,{groupIds:u})});let s=nP(o,Cc(a),o,null),d=r.scene.getSelectedElements(o),m=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return qM(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=tP(a,jM(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:ll.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Sc.CTRL_OR_CMD]&&e.key===Sc.G.toUpperCase(),predicate:(e,o)=>Ic(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>yi(K,{type:"button",hidden:Ic(o).length===0,icon:yi(dp,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${_("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:we(Cc(e),o)})});import gP from"clsx";import{CaptureUpdateAction as YE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as cP,COLOR_VOICE_CALL as dP,COLOR_WHITE as Mc,THEME as mP,UserIdleState as zE}from"@excalidraw/common";var kc=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function pP(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var gn=(e,o)=>`hsl(${Math.abs(pP(o?.id||e))%37*10}, 100%, 83%)`,HE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},GE=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,d=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,c=14,p=l<0||l>r-m||s<0||s>n-c;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-c);let u=gn(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===zE.IDLE||f===zE.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===mP.DARK?"#2f6330":dP,w=d?.isSpeaking;w&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Mc,e.strokeStyle=Mc,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+m/2,v=(w?s+0:s)+c+2,I=5,k=3,P=e.measureText(E),S=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,B=Math.max(S,12),A=y-1,L=v-1,R=P.width+2+I*2+2,Y=B+2+k*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(A,L,R,Y,8),e.fillStyle=u,e.fill(),e.strokeStyle=Mc,e.stroke(),w&&(e.beginPath(),e.roundRect(A-2,L-2,R+4,Y+4,8),e.strokeStyle=x,e.stroke())):kc(e,A,L,R,Y,8,Mc),e.fillStyle=cP,e.fillText(E,y+I+1,v+k+P.actualBoundingBoxAscent+Math.floor((B-S)/2)+2),w){e.fillStyle=x;let q=8,D=8,F=5;e.fillRect(A+R+D,L+(Y/2-q/2),2,q),e.fillRect(A+R+D+F,L+(Y/2-q*2/2),2,q*2),e.fillRect(A+R+D+F*2,L+(Y/2-q/2),2,q)}}e.restore(),e.closePath()}};import uP from"clsx";import{useState as hP}from"react";import{jsx as UE}from"react/jsx-runtime";var Su=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=HE(t),[a,l]=hP(!1),s=!a&&r,d=s?void 0:{background:e};return UE("div",{className:uP("Avatar",n),style:d,onClick:o,children:s?UE("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as ko,jsxs as Pc}from"react/jsx-runtime";var fP=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:YE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:YE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=gn(r,n),s=gP({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),d=n.isInCall?n.isSpeaking?Pc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[ko("div",{}),ko("div",{}),ko("div",{})]}):n.isMuted?ko("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:I0}):ko("div",{title:g("userList.hint.inCall"),children:T0}):null;return i?Pc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[ko(Su,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),ko("div",{className:"UserList__collaborator-name",children:n.username}),Pc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&ko("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:qn}),d]})]}):Pc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[ko(Su,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),d&&ko("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{LIBRARY_DISABLED_TYPES as bP,randomId as xP}from"@excalidraw/common";import{deepCopyElement as EP}from"@excalidraw/element";import{CaptureUpdateAction as ku}from"@excalidraw/element";var Mu=O({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of bP)if(n.some(a=>a.type===i))return{captureUpdate:ku.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:xP(),status:"unpublished",elements:n.map(EP),created:Date.now()},...i])).then(()=>({captureUpdate:ku.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:ku.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as wi}from"@excalidraw/element";import{isFrameLikeElement as yP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as wP}from"@excalidraw/element";import{KEYS as Sr,arrayToMap as vP}from"@excalidraw/common";import{alignElements as TP}from"@excalidraw/element";import{CaptureUpdateAction as vi}from"@excalidraw/element";import{getSelectedElementsByGroup as IP}from"@excalidraw/element";import{jsx as Ii}from"react/jsx-runtime";var xt=(e,o)=>{let t=o.scene.getSelectedElements(e);return IP(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(r=>yP(r))},Ti=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=TP(n,r,t.scene,o),a=vP(i);return wP(e.map(l=>a.get(l.id)||l),o,t)},CP=O({name:"alignTop",label:"labels.alignTop",icon:rp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>xt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ti(e,o,r,{position:"start",axis:"y"}),captureUpdate:vi.IMMEDIATELY}),keyTest:e=>e[Sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ii(K,{hidden:!xt(o,r),type:"button",icon:rp,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${_("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:we(wi(e),o)})}),SP=O({name:"alignBottom",label:"labels.alignBottom",icon:np,trackEvent:{category:"element"},predicate:(e,o,t,r)=>xt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ti(e,o,r,{position:"end",axis:"y"}),captureUpdate:vi.IMMEDIATELY}),keyTest:e=>e[Sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ii(K,{hidden:!xt(o,r),type:"button",icon:np,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${_("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:we(wi(e),o)})}),kP=O({name:"alignLeft",label:"labels.alignLeft",icon:ip,trackEvent:{category:"element"},predicate:(e,o,t,r)=>xt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ti(e,o,r,{position:"start",axis:"x"}),captureUpdate:vi.IMMEDIATELY}),keyTest:e=>e[Sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ii(K,{hidden:!xt(o,r),type:"button",icon:ip,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${_("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:we(wi(e),o)})}),MP=O({name:"alignRight",label:"labels.alignRight",icon:ap,trackEvent:{category:"element"},predicate:(e,o,t,r)=>xt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ti(e,o,r,{position:"end",axis:"x"}),captureUpdate:vi.IMMEDIATELY}),keyTest:e=>e[Sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Sr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ii(K,{hidden:!xt(o,r),type:"button",icon:ap,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${_("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:we(wi(e),o)})}),PP=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:lp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>xt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ti(e,o,r,{position:"center",axis:"y"}),captureUpdate:vi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ii(K,{hidden:!xt(o,r),type:"button",icon:lp,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:we(wi(e),o)})}),LP=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:sp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>xt(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ti(e,o,r,{position:"center",axis:"x"}),captureUpdate:vi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ii(K,{hidden:!xt(o,r),type:"button",icon:sp,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:we(wi(e),o)})});import{getNonDeletedElements as WE}from"@excalidraw/element";import{isFrameLikeElement as AP}from"@excalidraw/element";import{CODES as VE,KEYS as XE,arrayToMap as DP}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as _P}from"@excalidraw/element";import{distributeElements as RP}from"@excalidraw/element";import{CaptureUpdateAction as KE}from"@excalidraw/element";import{getSelectedElementsByGroup as NP}from"@excalidraw/element";import{jsx as jE}from"react/jsx-runtime";var $E=(e,o)=>{let t=o.scene.getSelectedElements(e);return NP(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>AP(r))},ZE=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=RP(n,t.scene.getNonDeletedElementsMap(),r,o),a=DP(i);return _P(e.map(l=>a.get(l.id)||l),o,t)},BP=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:ZE(e,o,r,{space:"between",axis:"x"}),captureUpdate:KE.IMMEDIATELY}),keyTest:e=>!e[XE.CTRL_OR_CMD]&&e.altKey&&e.code===VE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>jE(K,{hidden:!$E(o,r),type:"button",icon:Mb,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${_("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:we(WE(e),o)})}),FP=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:ZE(e,o,r,{space:"between",axis:"y"}),captureUpdate:KE.IMMEDIATELY}),keyTest:e=>!e[XE.CTRL_OR_CMD]&&e.altKey&&e.code===VE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>jE(K,{hidden:!$E(o,r),type:"button",icon:Pb,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${_("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:we(WE(e),o)})});import{getNonDeletedElements as OP}from"@excalidraw/element";import{bindOrUnbindLinearElements as zP,isBindingEnabled as HP}from"@excalidraw/element";import{getCommonBoundingBox as qE}from"@excalidraw/element";import{newElementWith as GP}from"@excalidraw/element";import{deepCopyElement as UP}from"@excalidraw/element";import{resizeMultipleElements as YP}from"@excalidraw/element";import{isArrowElement as WP,isElbowArrow as VP,isLinearElement as XP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as JE}from"@excalidraw/element";import{CODES as QE,KEYS as KP,arrayToMap as $P}from"@excalidraw/common";import{CaptureUpdateAction as ey}from"@excalidraw/element";var Pu=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:M0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:JE(ty(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:ey.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===QE.H}),Lu=O({name:"flipVertical",label:"labels.flipVertical",icon:k0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:JE(ty(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:ey.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===QE.V&&!e[KP.CTRL_OR_CMD]}),ty=(e,o,t,r,n)=>{let i=Q(OP(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=ZP(i,o,t,r,n),l=$P(a);return e.map(s=>l.get(s.id)||s)},ZP=(e,o,t,r,n)=>{if(e.every(u=>WP(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return GP(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=qE(e);YP(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,UP(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),zP(e.filter(XP),HP(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>VP(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:d,midY:m}=qE(e),[c,p]=[i-d,a-m];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as jP}from"@excalidraw/element";import{getTextFromElements as qP}from"@excalidraw/element";import{CODES as JP,KEYS as oy,isFirefox as QP}from"@excalidraw/common";import{CaptureUpdateAction as Ot}from"@excalidraw/element";var Ci=O({name:"copy",label:"labels.copy",icon:Ma,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await yc(n,r.files,t)}catch(i){return{captureUpdate:Ot.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Ot.EVENTUALLY}},keyTest:void 0}),Au=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await SE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),QP?{captureUpdate:Ot.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Ot.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(IE({types:n}))}catch(i){return console.error(i),{captureUpdate:Ot.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Ot.EVENTUALLY}},keyTest:void 0}),Lc=O({name:"cut",label:"labels.cut",icon:u0,trackEvent:{category:"element"},perform:(e,o,t,r)=>(Ci.perform(e,o,t,r),Fa.perform(e,o,null,r)),keyTest:e=>e[oy.CTRL_OR_CMD]&&e.key===oy.X}),Ac=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:P0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Ot.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=mn(e,o,!0);try{await pn("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Ot.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Ot.EVENTUALLY}}},predicate:e=>Ec&&e.length>0,keywords:["svg","clipboard","copy"]}),Dc=O({name:"copyAsPng",label:"labels.copyAsPng",icon:L0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Ot.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=mn(e,o,!0);try{return await pn("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:n.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Ot.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Ot.EVENTUALLY}}},predicate:e=>bi&&e.length>0,keyTest:e=>e.code===JP.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),_c=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{mo(qP(n))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Ot.EVENTUALLY}},predicate:(e,o,t,r)=>Ec&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(jP),keywords:["text","clipboard","copy"]});import{CODES as eL,KEYS as tL}from"@excalidraw/common";import{CaptureUpdateAction as oL}from"@excalidraw/element";var Rc=O({name:"gridMode",icon:N0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:oL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[tL.CTRL_OR_CMD]&&e.code===eL.QUOTE});import{CODES as rL,KEYS as nL}from"@excalidraw/common";import{CaptureUpdateAction as iL}from"@excalidraw/element";var Si=O({name:"zenMode",label:"buttons.zenMode",icon:D0,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:iL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[nL.CTRL_OR_CMD]&&e.altKey&&e.code===rL.Z});import{CODES as aL,KEYS as lL}from"@excalidraw/common";import{CaptureUpdateAction as sL}from"@excalidraw/element";var Du=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:A0,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:sL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[lL.CTRL_OR_CMD]&&e.altKey&&e.code===aL.S});import{CODES as cL,KEYS as dL}from"@excalidraw/common";import{CaptureUpdateAction as mL}from"@excalidraw/element";var ki=O({name:"stats",label:"stats.fullTitle",icon:S0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:mL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[dL.CTRL_OR_CMD]&&e.altKey&&e.code===cL.SLASH});import{BOUND_TEXT_PADDING as ry,ROUNDNESS as ny,TEXT_ALIGN as ly,VERTICAL_ALIGN as sy,arrayToMap as cy,getFontString as pL}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as uL,isBoundToContainer as iy,resetOriginalContainerCache as hL,updateOriginalContainerCache as gL}from"@excalidraw/element";import{computeBoundTextPosition as fL,computeContainerDimensionForBoundText as ay,getBoundTextElement as dy,redrawTextBoundingBox as my}from"@excalidraw/element";import{hasBoundTextElement as bL,isArrowElement as xL,isTextBindableContainer as _u,isTextElement as sl,isUsingAdaptiveRadius as EL}from"@excalidraw/element";import{measureText as yL}from"@excalidraw/element";import{syncMovedIndices as py}from"@excalidraw/element";import{newElement as wL}from"@excalidraw/element";import{CaptureUpdateAction as Ru}from"@excalidraw/element";var Nu=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>bL(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=dy(a,i);if(l){let{width:s,height:d}=yL(l.originalText,pL(l),l.lineHeight),m=uL(a.id);hL(a.id);let{x:c,y:p}=fL(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:c,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:Ru.IMMEDIATELY}}}),Bu=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=sl(n[0])||sl(n[1]),a;if(_u(n[0])?a=n[0]:_u(n[1])&&(a=n[1]),i&&a&&dy(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;sl(n[0])&&_u(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:sy.MIDDLE,textAlign:ly.CENTER,autoResize:!0,angle:xL(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return my(i,a,r.scene),gL(a.id,l),{elements:vL(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:Ru.IMMEDIATELY}}}),vL=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),py(r,cy([o,t])),r},TL=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),py(r,cy([o,t])),r},uy=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>sl(a)&&!iy(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(sl(l)&&!iy(l)){let s=wL({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:EL("rectangle")?ny.ADAPTIVE_RADIUS:ny.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-ry,y:l.y-ry,width:ay(l.width,"rectangle"),height:ay(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let d=l.boundElements.filter(c=>c.type==="arrow").map(c=>c.id);i.filter(c=>d.includes(c.id)).forEach(c=>{let p=c.startBinding,u=c.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(c,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:sy.MIDDLE,boundElements:null,textAlign:ly.CENTER,autoResize:!0}),my(l,s,r.scene),i=TL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:Ru.IMMEDIATELY}}});import{isEmbeddableElement as HL}from"@excalidraw/element";import{KEYS as Ty}from"@excalidraw/common";import{CaptureUpdateAction as GL}from"@excalidraw/element";import{pointFrom as by}from"@excalidraw/math";import IL from"clsx";import{useCallback as hy,useEffect as gy,useLayoutEffect as CL,useRef as SL,useState as kL}from"react";import{EVENT as Fu,HYPERLINK_TOOLTIP_DELAY as ML,KEYS as Nc}from"@excalidraw/common";import{getElementAbsoluteCoords as Uu}from"@excalidraw/element";import{hitElementBoundingBox as PL}from"@excalidraw/element";import{isElementLink as LL}from"@excalidraw/element";import{getEmbedLink as AL,embeddableURLValidator as DL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as xy,viewportCoordsToSceneCoords as _L,wrapEvent as RL,isLocalLink as NL,normalizeLink as Ou}from"@excalidraw/common";import{isEmbeddableElement as zu}from"@excalidraw/element";import{jsx as Mi,jsxs as fy}from"react/jsx-runtime";var Yu=380,BL=42,Hu=5,Ey=85,FL=500,Gu=!1,Bc=new Map,yy=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=To(),s=Io(),d=pe(),m=e.link||"",[c,p]=kL(m),u=SL(null),f=l.showHyperlinkPopup==="editor",b=hy(()=>{if(!u.current)return;let v=Ou(u.current.value)||null;if(!e.link&&v&&ae("hyperlink","create"),zu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!DL(v,s.validateEmbeddable))v&&n({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Bc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:I,height:k}=e,P=AL(v);P?.error instanceof URIError&&n({message:g("toast.unrecognizedLinkFormat"),closable:!0});let S=P?P.intrinsicSize.w/P.intrinsicSize.h:1,B=Bc.get(e.id)!==e.link;o.mutateElement(e,{...B?{width:P?.type==="video"?I>k?I:k*S:I,height:P?.type==="video"&&I>k?I/S:k}:{},link:v}),i(e,!0),Bc.has(e.id)&&Bc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);CL(()=>()=>{b()},[b]),gy(()=>{f&&u?.current&&!(d.formFactor==="phone"||d.isTouchScreen)&&u.current.select()},[f,d.formFactor,d.isTouchScreen]),gy(()=>{let v=null,I=k=>{if(f)return;v&&clearTimeout(v),zL(e,a,l,by(k.clientX,k.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},FL))};return window.addEventListener(Fu.POINTER_MOVE,I,!1),()=>{window.removeEventListener(Fu.POINTER_MOVE,I,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=hy(()=>{ae("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{ae("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=wy(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:fy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:Yu,padding:Hu},children:[f?Mi("input",{className:IL("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:c,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Nc.CTRL_OR_CMD]&&v.key===Nc.K&&v.preventDefault(),(v.key===Nc.ENTER||v.key===Nc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?Mi("a",{href:Ou(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:NL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let I=RL(Fu.EXCALIDRAW_LINK,v.nativeEvent);r({...e,link:Ou(e.link)},I),I.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Mi("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),fy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&Mi(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:wo}),Mi(K,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Ns}),m&&!zu(e)&&Mi(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:_t})]})]})},wy=(e,o,t)=>{let[r,n]=Uu(e,t),{x:i,y:a}=xy({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-Yu/2,s=a-o.offsetTop-Ey;return{x:l,y:s}},Wu=(e,o)=>{let t=Q(e,o);return zu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},cl=null,vy=(e,o,t)=>{cl&&clearTimeout(cl),cl=window.setTimeout(()=>OL(e,o,t),ML)},OL=(e,o,t)=>{if(!e.link)return;let r=hi();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=LL(e.link)?g("labels.link.goToElement"):e.link;let[n,i,a,l]=Uu(e,t),[s,d,m,c]=D1([n,i,a,l],e.angle,o),p=xy({sceneX:s,sceneY:d},o);ru(r,{left:p.x,top:p.y,width:m,height:c},"top"),ae("hyperlink","tooltip","link-icon"),Gu=!0},Vu=()=>{cl&&clearTimeout(cl),Gu&&(Gu=!1,hi().classList.remove("excalidraw-tooltip--visible"))},zL=(e,o,t,[r,n])=>{let{x:i,y:a}=_L({clientX:r,clientY:n},t),l=15/t.zoom.value;if(PL(by(i,a),e,o))return!1;let[s,d,m]=Uu(e,o);if(i>=s&&i<=m&&a>=d-Ey&&a<=d)return!1;let{x:c,y:p}=wy(e,t,o);return!(r>=c-l&&r<=c+Yu+Hu*2+l&&n>=p-l&&n<=p+l+Hu*2+BL)};import{jsx as UL}from"react/jsx-runtime";var dl=O({name:"hyperlink",label:(e,o)=>Wu(e,o),icon:Aa,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:GL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Ty.CTRL_OR_CMD]&&e.key===Ty.K,predicate:(e,o)=>Q(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Q(e,o);return UL(K,{type:"button",icon:Aa,"aria-label":g(Wu(e,o)),title:`${HL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${_("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});import{KEYS as Iy,arrayToMap as Ku,randomId as YL}from"@excalidraw/common";import{elementsAreInSameGroup as WL,newElementWith as Cy,selectGroupsFromGivenElements as Sy}from"@excalidraw/element";import{CaptureUpdateAction as ky}from"@excalidraw/element";var Xu=e=>e.every(o=>!o.locked),ml=O({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Xu(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=Q(o,e);return Xu(t)?Hn:en},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Xu(n),a=Ku(n),l=n.length>1&&WL(n),d=n.length===1||l?null:YL(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let w=n[0].groupIds.at(-1);delete m[w]}let c=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?d&&(E=[...E,d]):E=E.filter(y=>!o.lockedMultiSelections[y]),Cy(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=Ku(c),u=i?{}:Object.fromEntries(n.map(w=>[w.id,!0])),f=n.map(w=>p.get(w.id)||w),b=i?{}:Sy(f,o),x=i?d||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:c,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:ky.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===Iy.L&&e[Iy.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),My=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:en,predicate:(e,o)=>Q(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return Cy(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=Ku(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:Sy(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:ky.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as i_,isLinearElement as a_,isLineElement as Zi}from"@excalidraw/element";import{arrayToMap as l_,invariant as $h}from"@excalidraw/common";import{toggleLinePolygonState as s_,CaptureUpdateAction as V2}from"@excalidraw/element";import f2 from"clsx";import Q7 from"fuzzy";import{useEffect as md,useRef as b2,useMemo as eD,useState as dd}from"react";import{DEFAULT_SIDEBAR as u2,EVENT as ud,KEYS as ho,capitalizeString as tD,isWritableElement as oD}from"@excalidraw/common";import{CaptureUpdateAction as SA}from"@excalidraw/element";import{useEffect as hl,useMemo as Py,useRef as qu,useState as VL}from"react";import{getLinearElementSubType as Ai,updateElbowArrowPoints as XL}from"@excalidraw/element";import{pointFrom as Oc,pointRotateRads as KL}from"@excalidraw/math";import{hasBoundTextElement as $L,isArrowBoundToElement as ZL,isArrowElement as jL,isElbowArrow as qL,isLinearElement as th,isUsingAdaptiveRadius as JL}from"@excalidraw/element";import{getCommonBoundingBox as QL,getElementAbsoluteCoords as eA}from"@excalidraw/element";import{getBoundTextElement as Ry,getBoundTextMaxHeight as tA,getBoundTextMaxWidth as oA,redrawTextBoundingBox as rA}from"@excalidraw/element";import{wrapText as nA}from"@excalidraw/element";import{assertNever as iA,CLASSES as aA,getFontString as $u,isProdEnv as lA,mapFind as sA,reduceToCommonValue as cA,updateActiveTool as Ly}from"@excalidraw/common";import{measureText as Ay}from"@excalidraw/element";import{LinearElementEditor as dA}from"@excalidraw/element";import{newArrowElement as Zu,newElement as mA,newLinearElement as pA}from"@excalidraw/element";import{ShapeCache as uA}from"@excalidraw/element";import{updateBindings as hA}from"@excalidraw/element";import{jsx as eh}from"react/jsx-runtime";var gA=8,fA=10,pl=["rectangle","diamond","ellipse"],ul=["line","sharpArrow","curvedArrow","elbowArrow"],bA=new Set(pl),xA=new Set(ul),Di=e=>bA.has(e),Hc=e=>e==="arrow"||xA.has(e),uo=he(null),gl=new Map,fl=new Map,EA=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=qu(null);return hl(()=>{if(o.length===0){e.updateEditorAtom(uo,null);return}let r=_i(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(uo,null),t.current=null)},[o,e]),hl(()=>()=>{gl.clear(),fl.clear()},[]),eh(yA,{app:e,elements:o})},yA=({app:e,elements:o})=>{let t=_i(o),r=Py(()=>t==="generic"?By(o):[],[t,o]),n=Py(()=>t==="linear"?Qu(o):[],[t,o]),i=t==="generic"?r.every(c=>c.type===r[0].type):t==="linear"?n.every(c=>Ai(c)===Ai(n[0])):!1,[a,l]=VL({x:0,y:0}),s=qu(""),d=qu(null);hl(()=>{let c=[...r,...n].sort((x,w)=>x.id.localeCompare(w.id)),p=`
|
|
8
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${c.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(c.length===1){let[x,,,w,E,y]=eA(c[0],e.scene.getNonDeletedElementsMap());u=KL(Oc(x,w),Oc(E,y),c[0].angle)}else{let{minX:x,maxY:w}=QL(c);u=Oc(x,w)}let{x:f,y:b}=Oy({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),hl(()=>{for(let c of n){let p=Ju(c.id,CA(c));fl.has(p)||fl.set(p,c)}},[n]),hl(()=>{for(let c of r)if(!gl.has(c.id)){let p=Ry(c,e.scene.getNonDeletedElementsMap());p&&gl.set(c.id,{fontSize:p.fontSize})}},[r,e.scene]);let m=t==="linear"?[["line",Wn],["sharpArrow",Jn],["curvedArrow",ei],["elbowArrow",Qn]]:t==="generic"?[["rectangle",Gn],["diamond",Un],["ellipse",Yn]]:[];return eh("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(fA+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-gA}px`,zIndex:2},className:aA.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([c,p])=>{let u=i&&(t==="generic"&&r[0].type===c||t==="linear"&&Ai(n[0])===c);return eh(K,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:c,keyBindingLabel:"","aria-label":c,"data-testid":`toolbar-${c}`,onChange:()=>{e.state.activeTool.type!==c&&ae("convertElementType",c,"ui"),oh(e,{conversionType:t,nextType:c}),d.current?.focus()}},`${o[0].id}${o[0].version}_${c}`)})})},wA=(e,o,t)=>{let r=oA(e,o),n=tA(e,o),i=nA(o.text,$u(o),r),a=Ay(i,$u(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=Ay(o.text,$u(s),o.lineHeight)}Gc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),rA(o,e,t)},oh=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=By(n),d=l.every(m=>m.type===l[0].type)?pl.indexOf(l[0].type):-1;if(t=t??pl[(d+pl.length+a)%pl.length],t&&Di(t)){let m={};for(let p of l){let u=_y(p,t,e);m[u.id]=u}let c=[];for(let p of e.scene.getElementsIncludingDeleted())m[p.id]?c.push(m[p.id]):c.push(p);e.scene.replaceAllElements(c);for(let p of Object.values(m)){let u=Ry(p,e.scene.getNonDeletedElementsMap());u&&(gl.get(p.id)&&Gc(u,e.scene.getNonDeletedElementsMap(),{fontSize:gl.get(p.id)?.fontSize??u.fontSize}),wA(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Ly(p,{type:"selection"})}))}}if(o==="linear"){let l=Qu(n);if(!t){let d=cA(l,Ai),m=d?ul.indexOf(d):-1;t=ul[(m+ul.length+a)%ul.length]}if(Hc(t)){let d=[],m=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=fl.get(Ju(c.id,t));if(p&&Ai(p)===t)m.set(p.id,p),d.push(p);else{let u=_y(c,t,e);m.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(m);for(let c of d)if(th(c))if(qL(c)){let p=vA(c);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=XL(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Gc(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=sA(["line","sharpArrow","curvedArrow"],u=>fl.get(Ju(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=Qu(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new dA(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Ly(d,{type:"selection"})}))}return!0},_i=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(Di(t.type))return"generic";Ny(t)&&(o=!0)}return o?"linear":null},Ny=e=>th(e)&&(!jL(e)||!ZL(e)&&!$L(e)),Ju=(e,o)=>`${e}:${o}`,By=e=>e.filter(o=>Di(o.type)),Qu=e=>e.filter(o=>Ny(o)),Fc=20,Pi=(e,o)=>e[0]===o[0],ju=(e,o)=>e[1]===o[1],Dy=(e,o)=>Pi(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),vA=e=>{let o=[e.points[0]],t=TA(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Fc?l[0]=a[0]:Math.abs(l[1]-a[1])<Fc&&(l[1]=a[1]),Pi(a,l)||ju(a,l)||o.push(Oc(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)Pi(o[i-1],o[i])&&Pi(o[i],o[i+1])||ju(o[i-1],o[i])&&ju(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],d=Pi(a,l),m=Pi(l,s);if(d!==m){let c=Dy(a,l),p=Dy(l,s);if(c<Fc||p<Fc){if(p<c)d?s[0]=a[0]:s[1]=a[1];else if(m)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},TA=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},_y=(e,o,t)=>{if(!IA(e.type,o)){if(!lA())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(uA.delete(e),Di(o)){let r=Li(mA({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:JL(o)?zc.ADAPTIVE_RADIUS:zc.PROPORTIONAL_RADIUS}:e.roundness}));return hA(r,t.scene),r}if(Hc(o))switch(o){case"line":return Li(pA({...e,type:"line"}));case"sharpArrow":return Li(Zu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Li(Zu({...e,type:"arrow",elbowed:!1,roundness:{type:zc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Li(Zu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return iA(o,`unhandled conversion type: ${o}`),e},IA=(e,o)=>!!(Di(e)&&Di(o)||Hc(e)&&Hc(o)),CA=e=>th(e)?Ai(e):e.type,Fy=EA;var zy=O({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return We.set(uo,{type:"panel"}),{captureUpdate:SA.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>_i(e)!==null});import{canCreateLinkFromElements as rh,defaultGetElementLinkFromSelection as kA,getLinkIdAndTypeFromSelection as MA}from"@excalidraw/element";import{CaptureUpdateAction as bl}from"@excalidraw/element";var Uc=O({name:"copyElementLink",label:"labels.copyElementLink",icon:$n,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=Q(e,o);try{if(window.location){let i=MA(n,o);return i?(await mo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):kA(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:bl.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:bl.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:bl.EVENTUALLY}},predicate:(e,o)=>rh(Q(e,o))}),Hy=O({name:"linkToElement",label:"labels.linkToElement",icon:Ns,perform:(e,o,t,r)=>{let n=Q(e,o);return n.length!==1||!rh(n)?{elements:e,appState:o,app:r,captureUpdate:bl.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:Q(e,o)[0].id}},captureUpdate:bl.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=Q(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&rh(n)},trackEvent:!1});import{isDarwin as Gy}from"@excalidraw/common";var PA={toggleTheme:[_("Shift+Alt+D")],saveScene:[_("CtrlOrCmd+S")],loadScene:[_("CtrlOrCmd+O")],clearCanvas:[_("CtrlOrCmd+Delete")],imageExport:[_("CtrlOrCmd+Shift+E")],commandPalette:[_("CtrlOrCmd+/"),_("CtrlOrCmd+Shift+P")],cut:[_("CtrlOrCmd+X")],copy:[_("CtrlOrCmd+C")],paste:[_("CtrlOrCmd+V")],copyStyles:[_("CtrlOrCmd+Alt+C")],pasteStyles:[_("CtrlOrCmd+Alt+V")],selectAll:[_("CtrlOrCmd+A")],deleteSelectedElements:[_("Delete")],duplicateSelection:[_("CtrlOrCmd+D"),_(`Alt+${g("helpDialog.drag")}`)],sendBackward:[_("CtrlOrCmd+[")],bringForward:[_("CtrlOrCmd+]")],sendToBack:[Gy?_("CtrlOrCmd+Alt+["):_("CtrlOrCmd+Shift+[")],bringToFront:[Gy?_("CtrlOrCmd+Alt+]"):_("CtrlOrCmd+Shift+]")],copyAsPng:[_("Shift+Alt+C")],group:[_("CtrlOrCmd+G")],ungroup:[_("CtrlOrCmd+Shift+G")],gridMode:[_("CtrlOrCmd+'")],zenMode:[_("Alt+Z")],objectsSnapMode:[_("Alt+S")],stats:[_("Alt+/")],addToLibrary:[],flipHorizontal:[_("Shift+H")],flipVertical:[_("Shift+V")],viewMode:[_("Alt+R")],hyperlink:[_("CtrlOrCmd+K")],toggleElementLock:[_("CtrlOrCmd+Shift+L")],resetZoom:[_("CtrlOrCmd+0")],zoomOut:[_("CtrlOrCmd+-")],zoomIn:[_("CtrlOrCmd++")],zoomToFitSelection:[_("Shift+3")],zoomToFit:[_("Shift+1")],zoomToFitSelectionInViewport:[_("Shift+2")],toggleEraserTool:[_("E")],toggleHandTool:[_("H")],setFrameAsActiveTool:[_("F")],saveFileToDisk:[_("CtrlOrCmd+S")],saveToActiveFile:[_("CtrlOrCmd+S")],toggleShortcuts:[_("?")],searchMenu:[_("CtrlOrCmd+F")],wrapSelectionInFrame:[]},ze=(e,o=0)=>{let t=PA[e];return t&&t.length>0?t[o]||t[0]:""};var LA="\\u0300-\\u036f",AA="\\ufe20-\\ufe2f",DA="\\u20d0-\\u20ff",_A=LA+AA+DA,RA=`[${_A}]`,NA=RegExp(RA,"g"),BA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,FA={\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"},fn=e=>e.replace(BA,o=>FA[o]||o).replace(NA,"");import N7 from"clsx";import{useEffect as B7,useState as F7}from"react";import{KEYS as O7,queryFocusableElements as Yw}from"@excalidraw/common";import{useCallback as OA,useState as zA}from"react";var Uy=()=>{let[e,o]=zA(null),t=OA(r=>o(r),[]);return[e,t]};import{useState as Fw,useCallback as vh,useMemo as Ow,useEffect as Th,memo as zw,useRef as y7}from"react";import{LIBRARY_DISABLED_TYPES as w7,randomId as v7,isShallowEqual as T7,KEYS as I7,isWritableElement as C7,addEventListener as S7,EVENT as k7,CLASSES as Rw}from"@excalidraw/common";import{useEffect as Xy,useRef as Ky}from"react";import{URL_HASH_KEYS as ah,URL_QUERY_KEYS as lh,APP_NAME as $y,EVENT as Wc,DEFAULT_SIDEBAR as YA,LIBRARY_SIDEBAR_TAB as WA,arrayToMap as sh,cloneJSON as VA,preventUnload as XA,promiseTry as Zy,resolvablePromise as KA,toValidURL as $A,Queue as ZA,Emitter as jA}from"@excalidraw/common";import{hashElementsVersion as qA,hashString as JA}from"@excalidraw/element";import{getCommonBoundingBox as ih}from"@excalidraw/element";import{MIME_TYPES as bn}from"@excalidraw/common";var kr=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:d,viewBackgroundColor:m}=s;return fs(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(c,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=r<b?r/b:o?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},Yy=async e=>{let{mimeType:o=bn.png,quality:t}=e;o===bn.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${bn.png}" mimeType`),o==="image/jpg"&&(o=bn.jpg),o===bn.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${bn.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await kr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===bn.png&&e.appState?.exportEmbedScene&&(a=await G1({blob:a,metadata:va(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},Ri=async({elements:e,appState:o=mr(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:d}=Bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),m={...d,exportPadding:r};return Nn(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},HA=async e=>{if(e.type==="svg"){let o=await Ri(e);await mo(o.outerHTML)}else if(e.type==="png")await wc(Yy(e));else if(e.type==="json")await yc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as Wy,useState as GA}from"react";import{COLOR_PALETTE as UA}from"@excalidraw/common";var nh=he(new Map),Vy=async e=>await Ri({elements:e,appState:{exportBackground:!1,viewBackgroundColor:UA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Yc=(e,o,t,r)=>{let[n,i]=GA();return Wy(()=>{if(o)if(e){let a=t.get(e);a?i(a):(async()=>{let l=await Vy(o);l.querySelector(".style-fonts")?.remove(),l&&(t.set(e,l),i(l))})()}else(async()=>{let a=await Vy(o);i(a)})()},[e,o,t,i]),Wy(()=>{let a=r.current;if(a)return n&&(a.innerHTML=n.outerHTML),()=>{a.innerHTML=""}},[n,r]),n},Ni=()=>{let[e]=de(nh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var QA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],qy=new jA,$o=he({status:"loaded",isInitialized:!1,libraryItems:[]}),xl=e=>VA(e),e8=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),Jy=(e,o)=>{let t=[];for(let r of o)e8(e,r)&&t.push(r);return[...t,...e]},Qy=(e,o)=>{let t=sh(o),r={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=sh(e);for(let i of o){let a=n.get(i.id);a?mh(a)!==mh(i)&&r.updatedItems.set(i.id,i):r.addedItems.set(i.id,i)}return r},ch=class{constructor(o){C(this,"currLibraryItems",[]);C(this,"prevLibraryItems",xl(this.currLibraryItems));C(this,"app");C(this,"updateQueue",[]);C(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);C(this,"notifyListeners",()=>{if(this.updateQueue.length>0)We.set($o,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{We.set($o,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=xl(this.currLibraryItems);let t=xl(this.currLibraryItems);this.app.props.onLibraryChange?.(t),qy.trigger(Qy(o,t),t)}catch(o){console.error(o)}}});C(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],We.set(nh,new Map)});C(this,"resetLibrary",()=>this.setLibrary([]));C(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(xl(t))}catch{return o(this.currLibraryItems)}}));C(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:YA.name,tab:WA}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),d;s instanceof Blob?d=await Wm(s,i):d=Ca(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:d.length}))?(t&&this.app.focusContainer(),a(r?Jy(this.currLibraryItems,d):d)):l(new _n)}catch(s){l(s)}}))));C(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=xl(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},ew=ch,Fi=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=ih(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=ih(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,d=0,m=0,c=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,c=0,p++),c===0&&(s=n(p)),d=i(c);let{minX:f,minY:b,width:x,height:w}=ih(u.elements),E=(d-x)/2,y=(s-w)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=d+50,m++,c++}return r},t8=(e,o=QA)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},dh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(ah.addLibrary)||new URLSearchParams(window.location.search).get(lh.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Mr=class Mr{constructor(o){C(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Ca(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?Mr.queue.push(n):n()}getLibraryItems(o){return Mr.getLibraryItems(this.adapter,o,!1)}};C(Mr,"queue",new ZA),C(Mr,"run",async(o,t)=>{let r=new Mr(o);return Mr.queue.push(()=>t(r))});var Bi=Mr,El=0,Vc=0,mh=e=>`${e.id}:${e.name||""}:${qA(e.elements)}`,Xc=e=>JA(e.map(o=>mh(o)).sort().join()),jy=async(e,o)=>{try{return Vc++,await Bi.run(e,async t=>{let r=sh(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);if(o.updatedItems)for(let[l,s]of o.updatedItems)r.set(l,s);let i=n.concat(Array.from(r.values())),a=Xc(i);return a!==El&&await e.save({libraryItems:i}),El=a,i})}finally{Vc--}},o8=e=>{let{excalidrawAPI:o}=e,t=Ky(e);t.current=e;let r=Ky(!1);Xy(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let d=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=$A(l),t8(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();c(f)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(c=>{window.addEventListener("focus",()=>c(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:d,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(c){throw o.updateScene({appState:{errorMessage:c.message}}),c}finally{if(window.location.hash.includes(ah.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(ah.addLibrary),window.history.replaceState({},$y,`#${c.toString()}`)}else if(window.location.search.includes(lh.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(lh.addLibrary),window.history.replaceState({},$y,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=dh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=dh();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,d=KA();s?d.resolve(Zy(s.load).then(async m=>{let c=null;try{if(!m)return Bi.getLibraryItems(l,"load");c=Ca(m.libraryItems||[],"published");let p=await jy(l,Qy([],c));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),c}}).catch(m=>(console.error(`error during library migration: ${m.message}`),Bi.getLibraryItems(l,"load")))):d.resolve(Zy(Bi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:d.then(m=>{let c=m||[];return El=Xc(c),c}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(Wc.HASHCHANGE,i),()=>{window.removeEventListener(Wc.HASHCHANGE,i)}},[o]),Xy(()=>{let n=qy.on(async(a,l)=>{let s=r.current,d="adapter"in t.current&&t.current.adapter||null;try{d&&El!==Xc(l)&&await jy(d,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Vc&&XA(a)};return window.addEventListener(Wc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(Wc.BEFORE_UNLOAD,i),n(),El=0,Vc=0}},[])};import a8 from"clsx";import{VERSIONS as r8}from"@excalidraw/common";import{jsx as i8}from"react/jsx-runtime";var n8=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return i8("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${r8.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},tw=n8;import{jsx as l8,jsxs as s8}from"react/jsx-runtime";var Kc=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>s8("div",{className:a8("library-menu-control-buttons",i),style:r,children:[l8(tw,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Hi,useEffect as xh,useMemo as Eh,useRef as Aw,useState as Dw}from"react";import{MIME_TYPES as u7,arrayToMap as h7,nextAnimationFrame as g7}from"@excalidraw/common";import{duplicateElements as f7}from"@excalidraw/element";import b7 from"clsx";import c8 from"lodash.throttle";import{useEffect as d8}from"react";var m8=he(0),ow=e=>{let[o,t]=de(m8);return d8(()=>{let{current:r}=e;if(!r)return;let n=c8(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import Y8 from"clsx";import{useCallback as W8,useState as gh}from"react";import{muteFSAbortError as V8}from"@excalidraw/common";import{flushSync as rw}from"react-dom";import p8 from"clsx";import{jsx as $c,jsxs as h8}from"react/jsx-runtime";var u8=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return h8("button",{className:p8("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&$c("div",{style:a?{visibility:"hidden"}:{},children:r}),$c("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&$c("div",{style:{position:"absolute",inset:0},children:$c(at,{})})]})},Zo=u8;import{jsx as nw,jsxs as iw}from"react/jsx-runtime";var g8=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=me(),d=pr(Oi),{container:m}=Se();return iw(He,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,iw("div",{className:"confirm-dialog-buttons",children:[nw(Zo,{label:i,onClick:()=>{s({openMenu:null}),d(!1),rw(()=>{t()}),m?.focus()}}),nw(Zo,{label:n,onClick:()=>{s({openMenu:null}),d(!1),rw(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Zc=g8;import qc from"open-color";import{useCallback as v8,useEffect as hh,useRef as aw,useState as ph}from"react";import{EDITOR_LS_KEYS as uh,EXPORT_DATA_TYPES as T8,MIME_TYPES as lw,VERSIONS as I8,chunk as C8,getExportSource as S8}from"@excalidraw/common";var $t=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};C($t,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),C($t,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import jc from"react";var f8=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,b8=/{{([\w-]+)}}/,x8=/<([\w-]+)>/,E8=/<\/([\w-]+)>/,y8=(e,o)=>{let t=[{name:"",children:[]}];return e.split(f8).filter(Boolean).forEach(r=>{let n=r.match(x8),i=r.match(E8),a=r.match(b8);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),d=jc.createElement(jc.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(d))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},w8=({i18nKey:e,children:o,...t})=>{let{t:r}=Be();return jc.createElement(jc.Fragment,{},...y8(r(e),t))},Et=w8;import{jsx as ue,jsxs as mt}from"react/jsx-runtime";var k8=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=C8(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=qc.white,l.fillRect(0,0,a.width,a.height);for(let[s,d]of e.entries()){let m=await kr({elements:d.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=m,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(m,f+(128-c)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=qc.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await Es(new File([await zo(a)],"preview",{type:lw.png}),{outputType:lw.jpg,maxWidthOrHeight:5e3})},M8=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=aw(null),a=aw(null);return hh(()=>{let l=i.current;l&&(async()=>{let s=await Ri({elements:e.elements,appState:{...o,viewBackgroundColor:qc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),mt("div",{className:"single-library-item",children:[e.status==="published"&&ue("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ue("div",{ref:i,className:"single-library-item__svg"}),ue(K,{"aria-label":g("buttons.remove"),type:"button",icon:Ut,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:g("buttons.remove")}),mt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[mt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[mt("div",{style:{padding:"0.5em 0"},children:[ue("span",{style:{fontWeight:500,color:qc.gray[6]},children:g("publishDialog.itemName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),ue("span",{className:"error",children:e.error})]})]})},P8=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=ph({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[d,m]=ph(!1);hh(()=>{let y=$t.get(uh.PUBLISH_LIBRARY);y&&s(y)},[]);let[c,p]=ph(o.slice());hh(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),m(!0);let v=[],I=!1;if(c.forEach(L=>{let R="";L.name||(R=g("publishDialog.errors.required"),I=!0),v.push({...L,error:R})}),I){p(v),m(!1);return}let k=await k8(c),P={type:T8.excalidrawLibrary,version:I8.excalidrawLibrary,source:S8(),libraryItems:c},S=JSON.stringify(P,null,2),B=new Blob([S],{type:"application/json"}),A=new FormData;A.append("excalidrawLib",B),A.append("previewImage",k),A.append("previewImageType",k.type),A.append("title",l.name),A.append("authorName",l.authorName),A.append("githubHandle",l.githubHandle),A.append("name",l.name),A.append("description",l.description),A.append("twitterHandle",l.twitterHandle),A.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:A}).then(L=>L.ok?L.json().then(({url:R})=>{$t.delete(uh.PUBLISH_LIBRARY),r({url:R,authorName:l.authorName,items:c})}):L.json().catch(()=>{throw new Error(L.statusText||"something went wrong")}).then(R=>{throw new Error(R.message||L.statusText||"something went wrong")}),L=>{console.error(L),n(L),m(!1)}).catch(L=>{console.error(L),n(L),m(!1)})},b=()=>{let y=[];return c.forEach((v,I)=>{y.push(ue("div",{className:"single-library-item-wrapper",children:ue(M8,{libItem:v,appState:t,index:I,onChange:(k,P)=>{let S=c.slice();S[P].name=k,p(S)},onRemove:a})},I))}),ue("div",{className:"selected-library-items",children:y})},x=v8(()=>{i(c),$t.set(uh.PUBLISH_LIBRARY,l),e()},[c,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return ue(He,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:w?mt("form",{onSubmit:f,children:[ue("div",{className:"publish-library-note",children:ue(Et,{i18nKey:"publishDialog.noteDescription",link:y=>ue("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),ue("span",{className:"publish-library-note",children:ue(Et,{i18nKey:"publishDialog.noteGuidelines",link:y=>ue("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ue("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&ue("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),mt("div",{className:"publish-library__fields",children:[mt("label",{children:[mt("div",{children:[ue("span",{children:g("publishDialog.libraryName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),mt("label",{style:{alignItems:"flex-start"},children:[mt("div",{children:[ue("span",{children:g("publishDialog.libraryDesc")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),mt("label",{children:[mt("div",{children:[ue("span",{children:g("publishDialog.authorName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),mt("label",{children:[ue("span",{children:g("publishDialog.githubUsername")}),ue("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),mt("label",{children:[ue("span",{children:g("publishDialog.twitterUsername")}),ue("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),mt("label",{children:[ue("span",{children:g("publishDialog.website")}),ue("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ue("span",{className:"publish-library-note",children:ue(Et,{i18nKey:"publishDialog.noteLicense",link:y=>ue("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),mt("div",{className:"publish-library__buttons",children:[ue(Zo,{label:g("buttons.saveLibNames"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ue(Zo,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:d})]})]}):ue("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},sw=P8;import Iw from"react";import D8 from"clsx";import{useEffect as _8,useRef as R8}from"react";import{EVENT as pw,KEYS as N8}from"@excalidraw/common";import{forwardRef as cw}from"react";import dw from"clsx";import{jsx as mw}from"react/jsx-runtime";var L8=cw(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>mw("div",{className:dw("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),A8=cw(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>mw("div",{className:dw("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),St={Row:L8,Col:A8};import{jsx as Jc}from"react/jsx-runtime";var uw=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n,placement:i="bottom"})=>{let a=pe(),l=R8(null),s=gr({onClickOutside:o});ni(l,()=>{s.onClickOutside?.()}),_8(()=>{let m=p=>{p.key===N8.ESCAPE&&(p.stopImmediatePropagation(),s.onClickOutside?.())},c={capture:!0};return document.addEventListener(pw.KEYDOWN,m,c),()=>{document.removeEventListener(pw.KEYDOWN,m,c)}},[s]);let d=D8(`dropdown-menu ${t}`,{"dropdown-menu--mobile":a.formFactor==="phone","dropdown-menu--placement-top":i==="top"}).trim();return Jc(zp.Provider,{value:{onSelect:r},children:Jc("div",{ref:l,className:d,style:n,"data-testid":"dropdown-menu",children:a.formFactor==="phone"?Jc(St.Col,{className:"dropdown-menu-container",children:e}):Jc(Ye,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};uw.displayName="DropdownMenuContent";var hw=uw;import{jsx as F8}from"react/jsx-runtime";var B8=({children:e,className:o="",selected:t,...r})=>F8("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),gw=B8;import{jsx as fw}from"react/jsx-runtime";var bw=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let d=rc(s.onClick,n);return fw("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:oc(i,a),title:s.title??s["aria-label"],onClick:d,children:fw(tc,{icon:e,shortcut:o,children:r})})},zi=bw;bw.displayName="DropdownMenuItemLink";import{jsx as O8}from"react/jsx-runtime";var xw=()=>O8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0",flex:"0 0 auto"}}),Ew=xw;xw.displayName="DropdownMenuSeparator";import z8 from"clsx";import{jsx as H8}from"react/jsx-runtime";var yw=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=pe(),a=z8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return H8("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},ww=yw;yw.displayName="DropdownMenuTrigger";import Qc from"react";var vw=e=>{let o=Qc.Children.toArray(e).find(t=>Qc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},Tw=e=>{let o=Qc.Children.toArray(e).find(t=>Qc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as G8,jsxs as U8}from"react/jsx-runtime";var jo=({children:e,open:o,placement:t})=>{let r=vw(e),n=Tw(e),i=n&&Iw.isValidElement(n)?Iw.cloneElement(n,{placement:t}):n;return U8(G8,{children:[r,o&&i]})};jo.Trigger=ww;jo.Content=hw;jo.Item=gt;jo.ItemLink=zi;jo.ItemCustom=gw;jo.Group=Wa;jo.Separator=Ew;var le=jo;jo.displayName="DropdownMenu";import{jsx as kt,jsxs as ed}from"react/jsx-runtime";var X8=(e,o)=>e.filter(t=>o.includes(t.id)),K8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=de($o),[d,m]=de(Oi),c=()=>{let A=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),L=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return kt(Zc,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:L,children:kt("p",{children:A})})},[p,u]=gh(!1),f=!!o.length,b=f?s.libraryItems.filter(A=>o.includes(A.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,E]=gh(!1),[y,v]=gh(null),I=W8(()=>ed(He,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[kt("p",{children:kt(Et,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:A=>kt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:A})})}),kt(K,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),k=(A,L)=>{E(!1),v({url:A.url,authorName:A.authorName});let R=L.slice();R.forEach(Y=>{o.includes(Y.id)&&(Y.status="published")}),t.setLibrary(R)},P=async()=>{try{await t.updateLibrary({libraryItems:ms({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(A){if(A?.name==="AbortError"){console.warn(A);return}e({errorMessage:g("errors.importLibraryError")})}},S=async()=>{let A=f?b:await t.getLatestLibrary();A1(A).catch(V8).catch(L=>{e({errorMessage:L.message})})},B=()=>ed(le,{open:d,children:[kt(le.Trigger,{onToggle:()=>m(!d),children:nb}),ed(le.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&kt(le.Item,{onSelect:P,icon:Kn,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&kt(le.Item,{onSelect:S,icon:on,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),f&&kt(le.Item,{icon:p0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")}),!!b.length&&kt(le.Item,{onSelect:()=>u(!0),icon:_t,children:x})]})]});return ed("div",{className:Y8("library-menu-dropdown-container",l),children:[B(),o.length>0&&kt("div",{className:"library-actions-counter",children:o.length}),p&&c(),w&&kt(sw,{onClose:()=>E(!1),libraryItems:X8(s.libraryItems,o),appState:a,onSuccess:A=>k(A,s.libraryItems),onError:A=>window.alert(A),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:A=>i(o.filter(L=>L!==A))}),y&&I()]})},Cw=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Oe(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Ni(),a=xe(),l=me(),[s]=de($o),d=async c=>{let p=c.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return kt(K8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>d(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as t7,useEffect as o7,useState as r7}from"react";import $8,{useCallback as Z8}from"react";function j8(){return[!1,Z8(o=>o(),[])]}var Sw=$8.useTransition||j8;import kw from"clsx";import{memo as q8,useRef as J8,useState as Q8}from"react";import{jsx as td,jsxs as e7}from"react/jsx-runtime";var Mw=q8(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=J8(null),d=Yc(e,o,l,s),[m,c]=Q8(!1),p=pe().formFactor==="phone",u=t&&td("div",{className:"library-unit__adder",children:rb});return e7("div",{className:kw("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!d}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[td("div",{className:kw("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}c(!1),a(e,f)}}),u,e&&o&&(m||p||n)&&td(Qa,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Pw=()=>td("div",{className:"library-unit library-unit--skeleton"});import{Fragment as n7,jsx as od}from"react/jsx-runtime";var rd=({children:e})=>od("div",{className:"library-menu-items-container__grid",children:e}),yl=t7(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Sw(),[s,d]=r7(0);return o7(()=>{s<e.length&&l(()=>{d(s+a)})},[s,e.length,l,a]),od(n7,{children:e.map((m,c)=>c<s?od(Mw,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:i,id:m?.id,selected:r(m.id),onToggle:o,onDrag:t},m?.id??c):od(Pw,{},c))})});import fh from"clsx";import{forwardRef as s7,useRef as c7,useImperativeHandle as d7,useLayoutEffect as m7,useState as p7}from"react";import i7 from"clsx";import{composeEventHandlers as a7}from"@excalidraw/common";import{jsx as l7}from"react/jsx-runtime";var yt=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>l7("button",{onClick:a7(i.onClick,a=>{o()}),type:e,className:i7("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as bh,jsxs as Lw}from"react/jsx-runtime";var Pr=s7(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,type:m,...c},p)=>{let u=c7(null);d7(p,()=>u.current),m7(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[f,b]=p7(!1);return Lw("div",{className:fh("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,o&&bh("div",{className:"ExcTextField__label",children:o}),Lw("div",{className:fh("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[bh("input",{className:fh({"is-redacted":"value"in c&&c.value&&l&&!f}),readOnly:n,value:"value"in c?c.value:void 0,defaultValue:"defaultValue"in c?c.defaultValue:void 0,placeholder:r,ref:u,onChange:x=>e?.(x.target.value),onKeyDown:a,type:m}),l&&bh(yt,{onSelect:()=>b(!f),style:{border:0,userSelect:"none"},children:f?E0:qn})]})]})});import{Fragment as _w,jsx as tt,jsxs as Mo}from"react/jsx-runtime";var x7=17,E7=64;function yh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:d}){let m=pe(),c=Aw(null),p=ow(c);xh(()=>{p>0&&c.current?.scrollTo(0,p)},[]);let{svgCache:u}=Ni(),[f,b]=Dw(null),[x,w]=Dw(""),E=!o.length&&!n.length,y=!E&&!!x.trim(),v=Eh(()=>{let G=fn(x.trim().toLowerCase());return G?o.filter(Z=>{let te=Z.name||"";return te.trim()&&fn(te.toLowerCase()).includes(G)}):[]},[o,x]),I=Eh(()=>o.filter(G=>G.status!=="published"),[o]),k=Eh(()=>o.filter(G=>G.status==="published"),[o]),P=Hi((G,Z)=>{let te=!d.includes(G),oe=[...I,...k];if(te){if(Z.shiftKey&&f){let $=oe.findIndex(ro=>ro.id===f),J=oe.findIndex(ro=>ro.id===G);if($===-1||J===-1){s([...d,G]);return}let be=h7(d),ct=Math.min($,J),Dt=Math.max($,J),lr=oe.reduce((ro,sr,Ln)=>((Ln>=ct&&Ln<=Dt||be.has(sr.id))&&ro.push(sr.id),ro),[]);s(lr)}else s([...d,G]);b(G)}else b(null),s(d.filter($=>$!==G))},[f,s,k,d,I]);xh(()=>{d.length||b(null)},[d]);let S=Hi(G=>{let Z;return d.includes(G)?Z=o.filter(te=>d.includes(te.id)):Z=o.filter(te=>te.id===G),Z.map(te=>({...te,elements:f7({type:"everything",elements:te.elements,randomizeSeed:!0}).duplicatedElements}))},[o,d]),B=Hi((G,Z)=>{let te={itemIds:d.includes(G)?d:[G]};Z.dataTransfer.setData(u7.excalidrawlibIds,JSON.stringify(te))},[d]),A=Hi(G=>G?d.includes(G):!1,[d]),L=Hi(()=>{t(n)},[n,t]),R=Hi(G=>{G&&r(S(G))},[S,r]),Y=u.size>=(v.length?v:o).length?E7:x7,q=Aw(null);xh(()=>{g7(()=>{q.current?.focus()})},[]);let D=!y&&Mo(_w,{children:[!E&&tt("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),!n.length&&!I.length?Mo("div",{className:"library-menu-items__no-items",children:[!k.length&&tt("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),tt("div",{className:"library-menu-items__no-items__hint",children:k.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):Mo(rd,{children:[n.length>0&&tt(yl,{itemsRenderedPerBatch:Y,items:[{id:null,elements:n}],onItemSelectToggle:P,onItemDrag:B,onClick:L,isItemSelected:A,svgCache:u}),tt(yl,{itemsRenderedPerBatch:Y,items:I,onItemSelectToggle:P,onItemDrag:B,onClick:R,isItemSelected:A,svgCache:u})]}),k.length>0&&tt("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:g("labels.excalidrawLib")}),k.length>0&&tt(rd,{children:tt(yl,{itemsRenderedPerBatch:Y,items:k,onItemSelectToggle:P,onItemDrag:B,onClick:R,isItemSelected:A,svgCache:u})})]}),F=y&&Mo(_w,{children:[Mo("div",{className:"library-menu-items-container__header",children:[g("library.search.heading"),!e&&Mo("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:G=>G.preventDefault(),onClick:G=>{w("")},children:[tt("kbd",{children:"esc"})," to clear"]})]}),v.length>0?tt(rd,{children:tt(yl,{itemsRenderedPerBatch:Y,items:v,onItemSelectToggle:P,onItemDrag:B,onClick:R,isItemSelected:A,svgCache:u})}):Mo("div",{className:"library-menu-items__no-items",children:[tt("div",{className:"library-menu-items__no-items__hint",children:g("library.search.noResults")}),tt(yt,{onPointerDown:G=>G.preventDefault(),onSelect:()=>{w("")},style:{width:"auto",marginTop:"1rem"},children:g("library.search.clearSearch")})]})]});return Mo("div",{className:"library-menu-items-container",style:n.length||I.length||k.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[Mo("div",{className:"library-menu-items-header",children:[!E&&tt(Pr,{ref:q,type:"search",className:b7("library-menu-items-container__search",{hideCancelButton:m.formFactor!=="phone"}),placeholder:g("library.search.inputPlaceholder"),value:x,onChange:G=>w(G)}),tt(Cw,{selectedItems:d,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),Mo(St.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:k.length>0?1:"0 1 auto",margin:E?"auto":0},ref:c,children:[e&&tt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:tt(at,{})}),D,F,E&&tt(Kc,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i})]})]})}import{jsx as Lr,jsxs as Bw}from"react/jsx-runtime";var Oi=he(!1),Nw=({children:e})=>Lr("div",{className:"layer-ui__library",children:e}),M7=zw(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:d})=>{let[m]=de($o),c=vh(f=>{(async(x,w)=>{ae("element","addToLibrary","ui");for(let y of w7)if(x.some(v=>v.type===y))return r({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:v7(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{r({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,r,m.libraryItems]),p=Ow(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return Lr(Nw,{children:Lr("div",{className:"layer-ui__library-message",children:Bw("div",{children:[Lr(at,{size:"2em"}),Lr("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return Bw(Nw,{children:[Lr(yh,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:d,selectedItems:s}),u&&Lr(Kc,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),wh=(e,o)=>({elements:e,pending:Q(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),P7=(e,o)=>{let t=xr(),[r,n]=Fw(()=>wh(t,e.selectedElementIds)),i=y7(new Map);return Th(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),Th(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!T7(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),wh(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let d=l.get(s)?.version;if(d&&d!==i.current.get(s))return wh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},Hw=zw(()=>{let e=Oe(),{onInsertElements:o}=e,t=Io(),r=xe(),n=me(),[i,a]=Fw([]),l=Ow(()=>e.library,[e.library]),s=P7(r,e);Th(()=>S7(document,k7.KEYDOWN,c=>{if(c.key===I7.ESCAPE&&c.target instanceof HTMLElement){let p=c.target;if(p.closest(`.${Rw.SIDEBAR}`))i.length>0?(c.stopPropagation(),a([])):C7(p)&&p instanceof HTMLInputElement&&!p.value&&(c.stopPropagation(),n({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:f}=e.lastViewportPosition;document.elementFromPoint(u,f)?.closest(`.${Rw.SIDEBAR}`)&&(c.stopPropagation(),a([]))}}},{capture:!0}),[i,n,e]);let d=vh(c=>{o(Fi(c)),e.focusContainer()},[o,e]),m=vh(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return Lr(M7,{pendingElements:s,onInsertLibraryItems:d,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import L7 from"clsx";import{useRef as A7}from"react";import{createPortal as D7}from"react-dom";import{KEYS as _7}from"@excalidraw/common";import{jsx as Gw,jsxs as R7}from"react/jsx-runtime";var Uw=e=>{let{closeOnClickOutside:o=!0}=e,t=Ws({className:"excalidraw-modal-container"}),r=A7(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===_7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return D7(R7("div",{className:L7("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Gw("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Gw("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as wl,jsxs as H7}from"react/jsx-runtime";function z7(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var He=e=>{let[o,t]=Uy(),[r]=F7(document.activeElement),{id:n}=Se(),i=pe().formFactor==="phone";B7(()=>{if(!o)return;let d=Yw(o);setTimeout(()=>{d.length>0&&e.autofocus!==!1&&(d[1]||d[0]).focus()});let m=c=>{if(c.key===O7.TAB){let p=Yw(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&c.shiftKey?(p[p.length-1].focus(),c.preventDefault()):f===p.length-1&&!c.shiftKey&&(p[0].focus(),c.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=me(),l=pr(Oi),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return wl(Uw,{className:N7("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:z7(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:H7(Ye,{ref:t,children:[e.title&&wl("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:wl("span",{className:"Dialog__titleContent",children:e.title})}),i&&wl("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Ut}),wl("div",{className:"Dialog__content",children:e.children})]})})};import{KEYS as Ge}from"@excalidraw/common";var nd=[{icon:tn,value:"selection",key:Ge.V,numericKey:Ge[1],fillable:!0},{icon:Gn,value:"rectangle",key:Ge.R,numericKey:Ge[2],fillable:!0},{icon:Un,value:"diamond",key:Ge.D,numericKey:Ge[3],fillable:!0},{icon:Yn,value:"ellipse",key:Ge.O,numericKey:Ge[4],fillable:!0},{icon:Is,value:"arrow",key:Ge.A,numericKey:Ge[5],fillable:!0},{icon:Wn,value:"line",key:Ge.L,numericKey:Ge[6],fillable:!0},{icon:wo,value:"freedraw",key:[Ge.P,Ge.X],numericKey:Ge[7],fillable:!1},{icon:vo,value:"text",key:Ge.T,numericKey:Ge[8],fillable:!1},{icon:ka,value:"image",key:null,numericKey:Ge[9],fillable:!1},{icon:Cs,value:"eraser",key:Ge.E,numericKey:Ge[0],fillable:!1}],Ih=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:tn,key:Ge.V,numericKey:Ge[1],fillable:!0},...nd.slice(1)]:nd,Ww=(e,o)=>Ih(o).find((r,n)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;import Lo from"clsx";import{useRef as X7,useState as K7}from"react";import*as Ao from"@radix-ui/react-popover";import{CLASSES as qw,KEYS as $w,capitalizeString as Yi,isTransparent as ad}from"@excalidraw/common";import{shouldAllowVerticalAlign as Jw,suppportsHorizontalAlign as Qw,hasBoundTextElement as ld,isElbowArrow as kh,isImageElement as e2,isLinearElement as Mh,isTextElement as cd,isArrowElement as Zw,hasStrokeColor as jw,toolIsArrow as sd}from"@excalidraw/element";import{createIsolation as G7}from"jotai-scope";import Ch from"react";import Po from"tunnel-rat";var Sh=Ch.createContext(null),Ce=()=>Ch.useContext(Sh),U7=G7(),Vw=()=>Ch.useMemo(()=>({MainMenuTunnel:Po(),WelcomeScreenMenuHintTunnel:Po(),WelcomeScreenToolbarHintTunnel:Po(),WelcomeScreenHelpHintTunnel:Po(),WelcomeScreenCenterTunnel:Po(),FooterCenterTunnel:Po(),DefaultSidebarTriggerTunnel:Po(),DefaultSidebarTabTriggersTunnel:Po(),OverwriteConfirmDialogTunnel:Po(),TTDDialogTriggerTunnel:Po(),tunnelsJotai:U7}),[]);import{useEffect as Y7,useState as W7}from"react";import Xw from"clsx";import{capitalizeString as Kw}from"@excalidraw/common";import*as Gi from"@radix-ui/react-popover";import{jsx as id,jsxs as V7}from"react/jsx-runtime";var Ui=({app:e,options:o,activeTool:t,defaultOption:r,className:n="Shape",namePrefix:i,title:a,"data-testid":l,onToolChange:s,displayedOption:d,fillable:m=!1})=>{let[c,p]=W7(!1),u=t.type,f=d.type===u,b=32/2+10,{container:x}=Se();return!o.some(w=>w.type===u)&&c&&p(!1),Y7(()=>{let w=e.onPointerDownEmitter.on(()=>{p(!1)});return()=>w?.()},[e]),V7(Gi.Root,{open:c,children:[id(Gi.Trigger,{asChild:!0,children:id(K,{className:Xw(n,{fillable:m,active:o.some(w=>w.type===t.type)}),type:"radio",icon:d.icon,checked:f,name:"editor-current-shape",title:a,"aria-label":a,"data-testid":l,onPointerDown:()=>{p(w=>!w),s(r)}})}),id(Gi.Content,{className:"tool-popover-content",sideOffset:b,collisionBoundary:x??void 0,children:o.map(({type:w,icon:E,title:y})=>id(K,{className:Xw(n,{active:u===w}),type:"radio",icon:E,checked:u===w,name:`${i}-option`,title:y||Kw(w),keyBindingLabel:"","aria-label":y||Kw(w),"data-testid":`toolbar-${w}`,onChange:()=>{e.state.activeTool.type!==w&&ae("toolbar",w,"ui"),e.setActiveTool({type:w}),s?.(w)}},w))})]})};import{Fragment as zt,jsx as X,jsxs as ce}from"react/jsx-runtime";var Ph=Lo([qw.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),vl=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return jw(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>jw(r.type))},Tl=(e,o)=>Eo(e.activeTool.type)||o.some(t=>Eo(t.type)),t2=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=An(o,e),i=!1;n.length===2&&(ld(n[0])||ld(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=pe(),s=document.documentElement.getAttribute("dir")==="rtl",d=Eo(e.activeTool.type)&&!ad(e.currentItemBackgroundColor)||n.some(f=>Eo(f.type)&&!ad(f.backgroundColor)),m=n.length===1||i,c=!e.selectedLinearElement?.isEditing&&n.length===1&&Mh(n[0])&&!kh(n[0]),p=!e.croppingElementId&&n.length===1&&e2(n[0]),u=!i&&xt(e,r);return ce("div",{className:"selected-shape-actions",children:[X("div",{children:vl(e,n)&&t("changeStrokeColor")}),Tl(e,n)&&X("div",{children:t("changeBackgroundColor")}),d&&t("changeFillStyle"),(Ea(e.activeTool.type)||n.some(f=>Ea(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(ya(e.activeTool.type)||n.some(f=>ya(f.type)))&&ce(zt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(wa(e.activeTool.type)||n.some(f=>wa(f.type)))&&X(zt,{children:t("changeRoundness")}),(sd(e.activeTool.type)||n.some(f=>sd(f.type)))&&X(zt,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(cd))&&ce(zt,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||Qw(n,o))&&t("changeTextAlign")]}),Jw(n,o)&&t("changeVerticalAlign"),(Dn(e.activeTool.type)||n.some(f=>Dn(f.type)))&&X(zt,{children:t("changeArrowhead")}),t("changeOpacity"),ce("fieldset",{children:[X("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&ce("fieldset",{children:[X("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[s?ce(zt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ce(zt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),X("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&ce("fieldset",{children:[X("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[l.formFactor!=="phone"&&t("duplicateSelection"),l.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),c&&t("toggleLinearEditor")]})]})]})},o2=({appState:e,renderAction:o,setAppState:t,targetElements:r,container:n})=>{let i=Eo(e.activeTool.type)&&!ad(e.currentItemBackgroundColor)||r.some(s=>Eo(s.type)&&!ad(s.backgroundColor)),a=r.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",l=e.openPopup==="compactStrokeStyles";return a?X("div",{className:"compact-action-item",children:ce(Ao.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[X(Ao.Trigger,{asChild:!0,children:X("button",{type:"button",className:Lo("compact-action-button properties-trigger",{active:l}),title:g("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactStrokeStyles"})},children:z0})}),l&&X(Go,{className:Ph,container:n,style:{maxWidth:"13rem"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[i&&o("changeFillStyle"),(Ea(e.activeTool.type)||r.some(s=>Ea(s.type)))&&o("changeStrokeWidth"),(ya(e.activeTool.type)||r.some(s=>ya(s.type)))&&ce(zt,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(wa(e.activeTool.type)||r.some(s=>wa(s.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},r2=({appState:e,renderAction:o,setAppState:t,targetElements:r,container:n,app:i})=>{let a=sd(e.activeTool.type)||r.some(s=>sd(s.type)),l=e.openPopup==="compactArrowProperties";return a?X("div",{className:"compact-action-item",children:ce(Ao.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[X(Ao.Trigger,{asChild:!0,children:X("button",{type:"button",className:Lo("compact-action-button properties-trigger",{active:l}),title:g("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=dt(r,i,d=>Zw(d)?d.elbowed?"elbow":d.roundness?"round":"sharp":null,d=>Zw(d),d=>d?null:e.currentItemArrowType);return s==="elbow"?Qn:s==="round"?ei:Jn})()})}),l&&X(Go,{container:n,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},n2=({appState:e,renderAction:o,setAppState:t,targetElements:r,container:n,elementsMap:i})=>{let{saveCaretPosition:a,restoreCaretPosition:l}=ox(),s=e.openPopup==="compactTextProperties";return X("div",{className:"compact-action-item",children:ce(Ao.Root,{open:s,onOpenChange:d=>{d?(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&l())},children:[X(Ao.Trigger,{asChild:!0,children:X("button",{type:"button",className:Lo("compact-action-button properties-trigger",{active:s}),title:g("labels.textAlign"),onClick:d=>{d.preventDefault(),d.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"}))},children:pb})}),e.openPopup==="compactTextProperties"&&X(Go,{className:Ph,container:n,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:ce("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||r.some(cd))&&o("changeFontSize"),(e.activeTool.type==="text"||Qw(r,i))&&o("changeTextAlign"),Jw(r,i)&&o("changeVerticalAlign")]})})]})})},i2=({appState:e,renderAction:o,targetElements:t,setAppState:r,container:n,app:i,showDuplicate:a,showDelete:l})=>{let s=!!(e.editingTextElement||e.newElement),d=!e.croppingElementId&&t.length===1&&e2(t[0]),m=t.length===1,c=xt(e,i),p=!1;t.length===2&&(ld(t[0])||ld(t[1]))&&(p=!0);let u=document.documentElement.getAttribute("dir")==="rtl",f=e.openPopup==="compactOtherProperties";return s||t.length===0?null:X("div",{className:"compact-action-item",children:ce(Ao.Root,{open:f,onOpenChange:b=>{r(b?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[X(Ao.Trigger,{asChild:!0,children:X("button",{type:"button",className:Lo("compact-action-button properties-trigger",{active:f}),title:g("labels.actions"),onClick:b=>{b.preventDefault(),b.stopPropagation(),r({openPopup:f?null:"compactOtherProperties"})},children:ib})}),f&&X(Go,{className:Ph,container:n,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[ce("fieldset",{children:[X("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),c&&!p&&ce("fieldset",{children:[X("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[u?ce(zt,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):ce(zt,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),X("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically")]})]})]}),ce("fieldset",{children:[X("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[o("group"),o("ungroup"),m&&o("hyperlink"),d&&o("cropEditor"),a&&o("duplicateSelection"),l&&o("deleteSelectedElements")]})]})]})})]})})},$7=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&Mh(t[0])&&!kh(t[0])?X("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,a2=({appState:e,elementsMap:o,renderAction:t,app:r,setAppState:n})=>{let i=An(o,e),{container:a}=Se(),l=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&i.length===1&&Mh(i[0])&&!kh(i[0]);return ce("div",{className:"compact-shape-actions",children:[vl(e,i)&&X("div",{className:Lo("compact-action-item"),children:t("changeStrokeColor")}),Tl(e,i)&&X("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),X(o2,{appState:e,renderAction:t,setAppState:n,targetElements:i,container:a}),X(r2,{appState:e,renderAction:t,setAppState:n,targetElements:i,container:a,app:r}),s&&X("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(cd))&&ce(zt,{children:[X("div",{className:"compact-action-item",children:t("changeFontFamily")}),X(n2,{appState:e,renderAction:t,setAppState:n,targetElements:i,container:a,elementsMap:o})]}),!l&&i.length>0&&X("div",{className:"compact-action-item",children:t("duplicateSelection")}),!l&&i.length>0&&X("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),X(i2,{appState:e,renderAction:t,targetElements:i,setAppState:n,container:a,app:r})]})},l2=({appState:e,elementsMap:o,renderAction:t,app:r,setAppState:n})=>{let i=An(o,e),{container:a}=Se(),l=X7(null),s=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,c=32,p=d*c+(d-1)*m,u=c+m,f=s>=p+u,b=s>=p+2*u;return ce(Ye,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:c*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[ce("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[vl(e,i)&&X("div",{className:Lo("compact-action-item"),children:t("changeStrokeColor")}),Tl(e,i)&&X("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),X(o2,{appState:e,renderAction:t,setAppState:n,targetElements:i,container:a}),X(r2,{appState:e,renderAction:t,setAppState:n,targetElements:i,container:a,app:r}),X($7,{appState:e,renderAction:t,targetElements:i}),(e.activeTool.type==="text"||i.some(cd))&&ce(zt,{children:[X("div",{className:"compact-action-item",children:t("changeFontFamily")}),X(n2,{appState:e,renderAction:t,setAppState:n,targetElements:i,container:a,elementsMap:o})]}),X(i2,{appState:e,renderAction:t,targetElements:i,setAppState:n,container:a,app:r,showDuplicate:!b,showDelete:!f})]}),ce("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[X("div",{className:"compact-action-item",children:t("undo")}),X("div",{className:"compact-action-item",children:t("redo")}),b&&X("div",{className:"compact-action-item",children:t("duplicateSelection")}),f&&X("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},s2=({activeTool:e,setAppState:o,app:t,UIOptions:r})=>{let[n,i]=K7(!1),a=et(),l=a==="full",s=a==="compact",d=[{type:"selection",icon:tn,title:Yi(g("toolBar.selection"))},{type:"lasso",icon:ur,title:Yi(g("toolBar.lasso"))}],m=e.type==="frame",c=e.type==="laser",p=l&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",u=e.type==="embeddable",{TTDDialogTriggerTunnel:f}=Ce();return ce(zt,{children:[Ih(t).map(({value:b,icon:x,key:w,numericKey:E,fillable:y},v)=>{if(r.tools?.[b]===!1)return null;let I=g(`toolBar.${b}`),k=w&&Yi(typeof w=="string"?w:w[0]),P=k?`${k} ${g("helpDialog.or")} ${E}`:`${E}`;return(b==="selection"||b==="lasso")&&s?X(Ui,{app:t,options:d,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Yi(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:S=>{(S==="selection"||S==="lasso")&&(t.setActiveTool({type:S}),o({preferredSelectionTool:{type:S,initialized:!0}}))},displayedOption:d.find(S=>S.type===t.state.preferredSelectionTool.type)||d[0],fillable:e.type==="selection"},"selection-popover"):X(K,{className:Lo("Shape",{fillable:y}),type:"radio",icon:x,checked:e.type===b,name:"editor-current-shape",title:`${Yi(I)} \u2014 ${P}`,keyBindingLabel:E||k,"aria-label":Yi(I),"aria-keyshortcuts":P,"data-testid":`toolbar-${b}`,onPointerDown:({pointerType:S})=>{!t.state.penDetected&&S==="pen"&&t.togglePenMode(!0),b==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:S})=>{t.state.activeTool.type!==b&&ae("toolbar",b,"ui"),b==="image"?t.setActiveTool({type:b}):t.setActiveTool({type:b})}},b)}),X("div",{className:"App-toolbar__divider"}),ce(le,{open:n,children:[X(le.Trigger,{className:Lo("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":m||u||p||c&&!t.props.isCollaborating}),onToggle:()=>{i(!n),o({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),children:m?ao:u?Vn:c&&!t.props.isCollaborating?hr:p?ur:_a}),ce(le.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[X(le.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:ao,shortcut:$w.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:m,children:g("toolBar.frame")}),X(le.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Vn,"data-testid":"toolbar-embeddable",selected:u,children:g("toolBar.embeddable")}),X(le.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:hr,"data-testid":"toolbar-laser",selected:c,shortcut:$w.K.toLocaleUpperCase(),children:g("toolBar.laser")}),l&&X(le.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:ur,"data-testid":"toolbar-lasso",selected:p,children:g("toolBar.lasso")}),X("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&X(f.Out,{}),X(le.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Zn,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&ce(le.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:nn,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),X(le.Item.Badge,{children:"AI"})]})]})]})]})},c2=({renderAction:e,zoom:o})=>X(St.Col,{gap:1,className:qw.ZOOM_ACTIONS,children:ce(St.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),d2=({renderAction:e,className:o})=>ce("div",{className:`undo-redo-buttons ${o}`,children:[X("div",{className:"undo-button-container",children:X(Nt,{label:g("buttons.undo"),children:e("undo")})}),X("div",{className:"redo-button-container",children:ce(Nt,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),m2=({actionManager:e,showExitZenModeBtn:o})=>X("button",{type:"button",className:Lo("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(Si),children:g("buttons.exitZenMode")});import{useRef as Z7}from"react";var Lh=e=>{let o=Z7({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as q7,jsxs as j7}from"react/jsx-runtime";var xn=he(null),p2=()=>{let[e,o]=de(xn),t=Ve();return e&&e==="clearCanvas"?q7(Zc,{onConfirm:()=>{t.executeAction(Xo),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:j7("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var Ah={};C1(Ah,{toggleTheme:()=>J7});var J7={...cn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(cn,"commandPalette")}};import{jsx as ot,jsxs as Do}from"react/jsx-runtime";var rD=he(null),Le={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},h2=e=>{switch(e){case Le.app:return 1;case Le.export:return 2;case Le.editor:return 3;case Le.tools:return 4;case Le.elements:return 5;case Le.links:return 6;default:return 10}},pd=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return Do("div",{className:f2("shortcut",o),children:[r.map((n,i)=>ot("div",{className:"shortcut-wrapper",children:ot("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),ot("div",{className:"shortcut-desc",children:t})]})},x2=e=>!e.altKey&&e[ho.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===ho.P||e.key===ho.SLASH),kme=Object.assign(e=>{let o=xe(),t=me();return md(()=>{let r=n=>{x2(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ae("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(ud.KEYDOWN,r,{capture:!0}),()=>window.removeEventListener(ud.KEYDOWN,r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:ot(nD,{...e})},{defaultItems:Ah});function nD({customCommandPaletteItems:e}){let o=Oe(),t=xe(),r=me(),n=Io(),i=Ve(),[a,l]=de(rD),[s,d]=dd(null),m=b2(null),c=gr({uiAppState:t,customCommandPaletteItems:e,appProps:n}),[p]=de($o),u=eD(()=>p.libraryItems?.filter(S=>!!S.name).map(S=>({label:S.name,icon:ot(iD,{id:S.id,elements:S.elements}),category:"Library",order:h2("Library"),haystack:fn(S.name),perform:()=>{o.onInsertElements(Fi([S]))}}))||[],[o,p.libraryItems]);md(()=>{let{uiAppState:S,customCommandPaletteItems:B,appProps:A}=c,L=D=>{let F="";return D.label&&(typeof D.label=="function"?F=g(D.label(o.scene.getNonDeletedElements(),S,o)):F=g(D.label)),F},R=D=>typeof D.icon=="function"?D.icon(S,o.scene.getNonDeletedElements()):D.icon,Y=[],q=(D,F,G)=>{let Z={label:L(D),icon:R(D),category:F,shortcut:ze(D.name),keywords:D.keywords,predicate:D.predicate,viewMode:D.viewMode,perform:()=>{i.executeAction(D,"commandPalette")}};return G?G(Z,D):Z};if(S&&o.scene&&i){let D=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,dl,Uc,Hy].map($=>q($,Le.elements,(J,be)=>({...J,predicate:be.predicate?be.predicate:(ct,Dt,lr,ro)=>Q(ct,Dt).length>0}))),F=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map($=>q($,Le.tools)),G=[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($=>q($,Le.editor)),Z=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map($=>q($,Le.export));Y=[...D,...G,{label:L(Xo),icon:R(Xo),shortcut:ze(Xo.name),category:Le.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{We.set(xn,"clearCanvas")}},{label:g("buttons.exportImage"),category:Le.export,icon:Ms,shortcut:ze("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...Z];let te=[{label:g("toolBar.library"),category:Le.app,icon:zn,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:u2.name,tab:u2.defaultTab}})}},{label:g("search.title"),category:Le.app,icon:Rt,viewMode:!0,perform:()=>{i.executeAction(Il)}},{label:g("labels.shapeSwitch"),category:Le.elements,icon:Ra,perform:()=>{i.executeAction(zy)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Le.elements,icon:ks,viewMode:!1,predicate:($,J)=>{let be=Q($,J);return be.length>0&&vl(J,be)},perform:()=>{r($=>({openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:ks,category:Le.elements,viewMode:!1,predicate:($,J)=>{let be=Q($,J);return be.length>0&&Tl(J,be)},perform:()=>{r($=>({openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:ks,category:Le.editor,viewMode:!1,perform:()=>{r($=>({openMenu:$.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...nd.reduce(($,J)=>{let{value:be,icon:ct,key:Dt,numericKey:lr}=J;if(A.UIOptions.tools?.[be]===!1)return $;let sr=Dt&&tD(typeof Dt=="string"?Dt:Dt[0])||lr,Ln={label:g(`toolBar.${be}`),category:Le.tools,shortcut:sr,icon:ct,keywords:["toolbar"],viewMode:!1,perform:({event:Bm})=>{be==="image"?o.setActiveTool({type:be}):o.setActiveTool({type:be})}};return $.push(Ln),$},[]),...F,{label:g("toolBar.lock"),category:Le.tools,icon:S.activeTool.locked?Hn:en,shortcut:ho.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Le.tools,icon:w0,viewMode:!1,predicate:A.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Le.tools,icon:Zn,viewMode:!1,predicate:A.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"mermaid"}}))}}],oe=[...Y,...te,...B||[]].map($=>({...$,icon:$.icon||Ra,order:$.order??h2($.category),haystack:`${fn($.label.toLocaleLowerCase())} ${$.keywords?.join(" ")||""}`}));d(oe),l([...oe,...u].find($=>$.label===a?.label)??null)}},[c,o,i,d,a?.label,l,r,u]);let[f,b]=dd(""),[x,w]=dd(null),[E,y]=dd({}),v=S=>{r({openDialog:null},S),b("")},I=(S,B)=>{t.openDialog?.name==="commandPalette"&&(B.stopPropagation(),B.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),v(()=>{S.perform({actionManager:i,event:B}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},k=Lh(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),P=Lh(S=>{let B=oD(S.target)||x2(S)||S.key===ho.ESCAPE;if(B&&S.key!==ho.ARROW_UP&&S.key!==ho.ARROW_DOWN&&S.key!==ho.ENTER)return;let A=Object.values(E).flat(),L=a&&!f&&k(a);if(S.key===ho.ARROW_UP){S.preventDefault();let R=A.findIndex(D=>D.label===x?.label);if(L){if(R===0){w(a);return}if(x===a){let D=A[A.length-1];D&&w(D);return}}let Y;R===-1?Y=A.length-1:Y=R===0?A.length-1:(R-1)%A.length;let q=A[Y];q&&w(q);return}if(S.key===ho.ARROW_DOWN){S.preventDefault();let R=A.findIndex(D=>D.label===x?.label);if(L){if(!x||R===A.length-1){w(a);return}if(x===a){let D=A[0];D&&w(D);return}}let Y=(R+1)%A.length,q=A[Y];q&&w(q);return}if(S.key===ho.ENTER&&x&&setTimeout(()=>{I(x,S)}),!B){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return md(()=>(window.addEventListener(ud.KEYDOWN,P,{capture:!0}),()=>window.removeEventListener(ud.KEYDOWN,P,{capture:!0})),[P]),md(()=>{if(!s)return;let S=R=>{let Y={};for(let q of R)Y[q.category]?Y[q.category].push(q):Y[q.category]=[q];return Y},B=f?.length>1?[...s.filter(k).sort((R,Y)=>R.order-Y.order),...u]:s.filter(k).sort((R,Y)=>R.order-Y.order),A=!f&&a&&k(a);if(!f){y(S(A?B.filter(R=>R.label!==a?.label):B)),w(A?a:B[0]||null);return}let L=fn(f.toLocaleLowerCase().replace(/[<>_| -]/g,""));B=Q7.filter(L,B,{extract:R=>R.haystack??""}).sort((R,Y)=>Y.score-R.score).map(R=>R.original),y(S(B)),w(B[0]??null)},[f,s,k,a,u]),Do(He,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[ot(Pr,{value:f,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{b(S)},selectOnRender:!0,ref:m}),o.editorInterface.formFactor!=="phone"&&Do("div",{className:"shortcuts-wrapper",children:[ot(pd,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),ot(pd,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),ot(pd,{shortcut:_("Esc"),children:g("commandPalette.shortcuts.close")})]}),Do("div",{className:"commands",children:[a&&!f&&Do("div",{className:"command-category",children:[Do("div",{className:"command-category-title",children:[g("commandPalette.recents"),ot("div",{className:"icon",style:{marginLeft:"6px"},children:v0})]}),ot(g2,{command:a,isSelected:a.label===x?.label,onClick:S=>I(a,S),disabled:!k(a),onMouseMove:()=>w(a),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(E).length>0?Object.keys(E).map((S,B)=>Do("div",{className:"command-category",children:[ot("div",{className:"command-category-title",children:S}),E[S].map(A=>ot(g2,{command:A,isSelected:A.label===x?.label,onClick:L=>I(A,L),onMouseMove:()=>w(A),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:S==="Library"?"large":"small"},A.label))]},S)):s?Do("div",{className:"no-match",children:[ot("div",{className:"icon",children:Rt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var iD=({id:e,elements:o})=>{let t=b2(null),{svgCache:r}=Ni();return Yc(e,o,r,t),ot("div",{className:"library-item-icon",ref:t})},g2=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a,size:l="small"})=>{let s=()=>{};return Do("div",{className:f2("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":l==="large"}),ref:d=>{o&&!t&&d?.scrollIntoView?.({block:"nearest"})},onClick:t?s:n,onMouseMove:t?s:r,title:t?g("commandPalette.itemNotAvailable"):"",children:[Do("div",{className:"name",children:[e.icon&&ot(vr,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(a):e.icon}),ot(Va,{children:e.label})]}),i&&e.shortcut&&ot(pd,{shortcut:e.shortcut})]})};import{getSizeFromPoints as v0e,randomInteger as r_,getUpdatedTimestamp as n_}from"@excalidraw/common";import{simplify as KD}from"points-on-curve";import{pointsOnBezierCurves as Dme}from"points-on-curve";import{invariant as Rme}from"@excalidraw/common";import{curve as Bme,lineSegment as Fme,pointFrom as Ome,pointDistance as zme,pointFromArray as Hme,pointFromVector as Gme,pointRotateRads as Ume,polygon as Yme,polygonFromPoints as Wme,PRECISION as Vme,segmentsIntersectAt as Xme,vector as Kme,vectorAdd as $me,vectorFromPoint as Zme,vectorScale as jme}from"@excalidraw/math";import{getElementAbsoluteCoords as Jme}from"@excalidraw/element";var Dh=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as $D,pointDistance as H2,pointRotateRads as a0e}from"@excalidraw/math";import{ROUGHNESS as ZD,isTransparent as Pl,assertNever as jD,COLOR_PALETTE as qD,LINE_POLYGON_POINT_MERGE_DISTANCE as s0e}from"@excalidraw/common";import{RoughGenerator as JD}from"roughjs/bin/generator";import Ebe from"roughjs/bin/rough";import{getStroke as zD}from"perfect-freehand";import{isRightAngleRads as vbe,lineSegment as Tbe,pointFrom as Ibe,pointRotateRads as Cbe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as kbe,DEFAULT_REDUCED_GLOBAL_ALPHA as Mbe,ELEMENT_READY_TO_ERASE_OPACITY as Pbe,FRAME_STYLE as Lbe,MIME_TYPES as B2,THEME as Abe,distance as Dbe,getFontString as _be,isRTL as Rbe,getVerticalOffset as Nbe,invariant as Bbe}from"@excalidraw/common";import Afe from"roughjs/bin/rough";import{arrayToMap as _fe,invariant as M2,rescalePoints as Rfe,sizeOf as Nfe}from"@excalidraw/common";import{degreesToRadians as Yh,lineSegment as Ffe,pointDistance as Ofe,pointFrom as lt,pointFromArray as TD,pointRotateRads as $i}from"@excalidraw/math";import{pointsOnBezierCurves as Gfe}from"points-on-curve";import{pointCenter as Zge,pointFrom as jge,pointRotateRads as qge,pointsEqual as Jge,pointDistance as Qge,vectorFromPoint as efe,curveLength as tfe,curvePointAtLength as ofe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as ife,KEYS as afe,shouldRotateWithDiscreteAngle as lfe,getGridPoint as sfe,invariant as cfe,tupleToCoors as dfe,viewportCoordsToSceneCoords as mfe}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as ufe,isPathALoop as hfe}from"@excalidraw/element";import{KEYS as Zhe,arrayToMap as jhe,isBindingFallthroughEnabled as qhe,tupleToCoors as Jhe,invariant as Qhe,isDevEnv as ege,isTestEnv as tge}from"@excalidraw/common";import{lineSegment as rge,pointFrom as nge,pointRotateRads as ige,vectorFromPoint as age,pointDistanceSq as lge,clamp as sge,pointDistance as cge,pointFromVector as dge,vectorScale as mge,vectorNormalize as pge,vectorCross as uge,pointsEqual as hge,lineSegmentIntersectionPoints as gge,PRECISION as fge}from"@excalidraw/math";import{isTransparent as Cue}from"@excalidraw/common";import{curveIntersectLineSegment as kue,isPointWithinBounds as Mue,lineSegment as Pue,lineSegmentIntersectionPoints as Lue,pointFrom as Aue,pointFromVector as Due,pointRotateRads as _ue,pointsEqual as Rue,vectorFromPoint as Nue,vectorNormalize as Bue,vectorScale as Fue}from"@excalidraw/math";import{ellipse as zue,ellipseSegmentInterceptPoints as Hue}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as aD,DEFAULT_PROPORTIONAL_RADIUS as _h,LINE_CONFIRM_THRESHOLD as lD,ROUNDNESS as Rh}from"@excalidraw/common";import{curve as rpe,curveCatmullRomCubicApproxPoints as npe,curveOffsetPoints as ipe,lineSegment as ape,pointDistance as sD,pointFrom as lpe,pointFromArray as spe,rectangle as cpe}from"@excalidraw/math";var hd=(e,o=1)=>{if(e.length>=3){let[t,r]=[e[0],e[e.length-1]];return sD(t,r)<=lD/o}return!1},Cl=(e,o)=>{if(o.roundness?.type===Rh.PROPORTIONAL_RADIUS||o.roundness?.type===Rh.LEGACY)return e*_h;if(o.roundness?.type===Rh.ADAPTIVE_RADIUS){let t=o.roundness?.value??aD,r=t/_h;return e<=r?e*_h:t}return 0};import{ROUNDNESS as fpe,assertNever as bpe}from"@excalidraw/common";import{pointsEqual as Epe}from"@excalidraw/math";var E2=e=>!!e&&e.type==="embeddable",y2=e=>!!e&&e.type==="iframe",Bh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),En=e=>e!=null&&e.type==="text";var gd=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var Ar=e=>e!=null&&cD(e.type);var Wi=e=>e!=null&&e.type==="arrow",Sl=e=>Wi(e)&&e.elbowed;var cD=e=>e==="arrow"||e==="line";var Vi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&En(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as $pe,ARROW_LABEL_WIDTH_FRACTION as Zpe,BOUND_TEXT_PADDING as jpe,DEFAULT_FONT_SIZE as qpe,TEXT_ALIGN as Jpe,VERTICAL_ALIGN as Qpe,getFontString as eue,isProdEnv as tue,invariant as oue}from"@excalidraw/common";import{pointFrom as nue,pointRotateRads as iue}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Cpe,DEFAULT_FONT_SIZE as Spe,DEFAULT_FONT_FAMILY as kpe,getFontString as Mpe,isTestEnv as Ppe,normalizeEOL as Lpe}from"@excalidraw/common";var Ape="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ope,isTestEnv as zpe}from"@excalidraw/common";import{curvePointDistance as hue,distanceToLineSegment as gue,pointRotateRads as fue}from"@excalidraw/math";import{ellipse as xue,ellipseDistanceFromPoint as Eue}from"@excalidraw/math/ellipse";import{invariant as Jue,isDevEnv as Que,isTestEnv as ehe}from"@excalidraw/common";import{pointFrom as ohe,pointFromVector as rhe,pointRotateRads as nhe,pointScaleFromOrigin as ihe,pointsEqual as ahe,triangleIncludesPoint as lhe,vectorCross as she,vectorFromPoint as hD,vectorScale as che}from"@excalidraw/math";var Gh=[1,0],I2=[0,1],Uh=[-1,0],C2=[0,-1],bd=e=>{let[o,t]=e,r=Math.abs(o),n=Math.abs(t);return o>n?Gh:o<=-n?Uh:t>r?I2:C2},S2=(e,o)=>bd(hD(e,o)),xd=(e,o)=>Ed(S2(e,o)),Hh=(e,o)=>e[0]===o[0]&&e[1]===o[1],Ed=e=>Hh(e,Gh)||Hh(e,Uh);import{clamp as ghe,pointDistance as fhe,pointFrom as bhe,pointScaleFromOrigin as xhe,pointsEqual as Ehe,pointTranslate as yhe,vector as whe,vectorCross as vhe,vectorFromPoint as The,vectorScale as Ihe}from"@excalidraw/math";import{BinaryHeap as She,invariant as khe,isAnyTrue as Mhe,tupleToCoors as Phe,getSizeFromPoints as Lhe,isDevEnv as Ahe,arrayToMap as Dhe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Age,viewportCoordsToSceneCoords as Dge}from"@excalidraw/common";import{normalizeRadians as Rge,radiansBetweenAngles as Nge,radiansDifference as Bge}from"@excalidraw/math";import{pointsEqual as Oge}from"@excalidraw/math";var Nh=e=>{let o=Math.floor(e.width/2)+1,t=0,r=e.width,n=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,r,n,i,a,0,n]};var ID=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},CD=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Wh=(e,o,t,r)=>{if(o.length<1)return null;let n=Dh(o[0]);if(n.length<1)return null;let i=t==="start"?1:n.length-1,a=n[i].data;M2(a.length===6,"Op data length is not 6");let l=lt(a[4],a[5]),s=lt(a[2],a[3]),d=lt(a[0],a[1]),m=n[i-1],c=lt(0,0);if(m.op==="move"){let D=TD(m.data);M2(D!=null,"Op data is not a point"),c=D}else m.op==="bcurveTo"&&(c=lt(m.data[4],m.data[5]));let p=(D,F)=>Math.pow(1-D,3)*l[F]+3*D*Math.pow(1-D,2)*s[F]+3*Math.pow(D,2)*(1-D)*d[F]+c[F]*Math.pow(D,3),[u,f]=t==="start"?c:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=ID(r),I=0;{let[D,F]=t==="end"?e.points[e.points.length-1]:e.points[0],[G,Z]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];I=Math.hypot(D-G,F-Z)}let P=Math.min(v,I*(r==="diamond"||r==="diamond_outline"?.25:.5)),S=u-E*P,B=f-y*P;if(r==="dot"||r==="circle"||r==="circle_outline"){let D=Math.hypot(B-f,S-u)+e.strokeWidth-2;return[u,f,D]}let A=CD(r);if(r==="crowfoot_many"||r==="crowfoot_one_or_many"){let[D,F]=$i(lt(u,f),lt(S,B),Yh(-A)),[G,Z]=$i(lt(u,f),lt(S,B),Yh(A));return[S,B,D,F,G,Z]}let[L,R]=$i(lt(S,B),lt(u,f),-A*Math.PI/180),[Y,q]=$i(lt(S,B),lt(u,f),Yh(A));if(r==="diamond"||r==="diamond_outline"){let D,F;if(t==="start"){let[G,Z]=e.points.length>1?e.points[1]:[0,0];[D,F]=$i(lt(u+P*2,f),lt(u,f),Math.atan2(Z-f,G-u))}else{let[G,Z]=e.points.length>1?e.points[e.points.length-2]:[0,0];[D,F]=$i(lt(u-P*2,f),lt(u,f),Math.atan2(f-Z,u-G))}return[u,f,L,R,D,F,Y,q]}return[u,f,L,R,Y,q]};import{pointFrom as t1e,pointCenter as o1e,pointRotateRads as r1e,vectorFromPoint as n1e,vectorNormalize as i1e,vectorSubtract as a1e,vectorAdd as l1e,vectorScale as s1e,pointFromVector as c1e,clamp as d1e,isCloseTo as m1e}from"@excalidraw/math";import{arrayToMap as q1e}from"@excalidraw/common";import{isPointWithinBounds as Q1e,pointFrom as ebe}from"@excalidraw/math";import{vectorCross as f1e,vectorFromPoint as b1e}from"@excalidraw/math";import{arrayToMap as SD}from"@excalidraw/common";import{getElementBounds as kD}from"@excalidraw/element";import{isArrowElement as MD,isExcalidrawElement as PD,isFreeDrawElement as LD,isLinearElement as AD,isTextElement as DD}from"@excalidraw/element";import{rangeIncludesValue as yd,pointFrom as Jo,pointRotateRads as _D,rangeInclusive as wd}from"@excalidraw/math";var RD=e=>e.type==="diamond"?[Jo(e.width/2,0),Jo(e.width,e.height/2),Jo(e.width/2,e.height),Jo(0,e.height/2)]:[Jo(0,0),Jo(0+e.width,0),Jo(0+e.width,e.height),Jo(0,e.height)],ND=e=>AD(e)||LD(e)?e.points:RD(e),L2=e=>{let o=e.reduce((t,[r,n])=>(t.minY=Math.min(t.minY,n),t.minX=Math.min(t.minX,r),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,n),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},A2=e=>{let o=ND(e),{cx:t,cy:r}=L2(o),n=Jo(t,r),i=o.map(m=>_D(m,n,e.angle)),{minX:a,minY:l,maxX:s,maxY:d}=L2(i);return[a+e.x,l+e.y,s+e.x,d+e.y]},Vh=(e,o,t=!1)=>{let r=A2(e),n=o[0]<=r[0]&&o[2]>=r[2]&&o[1]<=r[1]&&o[3]>=r[3];return t?n?!0:r[0]<=o[0]&&r[2]>=o[2]&&r[1]<=o[1]&&r[3]>=o[3]:n},D2=(e,o)=>{let t=A2(e);return(yd(t[0],wd(o[0],o[2]))||yd(o[0],wd(t[0],t[2])))&&(yd(t[1],wd(o[1],o[3]))||yd(o[1],wd(t[1],t[3])))},_2=({elements:e,bounds:o,type:t,errorMargin:r=0})=>{PD(o)&&(o=kD(o,SD(e)));let n=[o[0]-r,o[1]-r,o[2]+r,o[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?D2(a,n):t==="inside"?Vh(a,n):Vh(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);DD(a)&&a.containerId&&i.add(a.containerId),MD(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as _1e,isShallowEqual as FD}from"@excalidraw/common";var BD=function(){let e=null,o=null,t=null,r=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let d={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];d[f]=!0}}let m={},c=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>d[b]);return f&&(p[u.id]=!0,Array.isArray(m[f])?m[f].push(u.id):m[f]=[u.id]),p},{});for(let p of Object.keys(m))m[p].length<2&&d[p]&&(d[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:d,selectedElementIds:Xh({...l.selectedElementIds,...c},s)},t},n=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Kh(a,i);return d.length?r(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Xh(i.selectedElementIds,l)}};return n.clearCache=()=>{o=null,e=null,t=null},n}();var H1e=function(){let e=null,o=null,t=null,r=(n,i)=>(t!=null&&n===e&&i.selectedElementIds===o||(t=n.some(a=>i.selectedElementIds[a.id]),e=n,o=i.selectedElementIds),t);return r.clearCache=()=>{e=null,o=null,t=null},r}(),Kh=(e,o,t)=>{let r=new Set,n=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){n.push(i),r.add(i.id);continue}if(t?.includeBoundTextElement&&Vi(i)&&o.selectedElementIds[i?.containerId]){n.push(i),r.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return n.forEach(a=>{gd(a)&&R2(e,a.id).forEach(l=>!r.has(l.id)&&i.push(l)),i.push(a)}),i}return n};var Xh=(e,o)=>FD(o.selectedElementIds,e)?o.selectedElementIds:e;var R2=(e,o)=>{let t=[];for(let r of e.values())r.frameId===o&&t.push(r);return t};var HD=typeof document<"u"?document.createElement("img"):{src:""};HD.src=`data:${B2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var GD=typeof document<"u"?document.createElement("img"):{src:""};GD.src=`data:${B2.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var F2=new WeakMap;var UD=new WeakMap([]);function O2(e){let o=YD(e),t=new Path2D(o);return UD.set(e,t),t}function YD(e){return XD(WD(e))}function WD(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([r,n],i)=>[r,n,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return zD(o,t)}function N2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var VD=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function XD(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,r,n,i)=>(n===o?t.push(r,N2(r,i[0]),"L",i[0],"Z"):t.push(r,N2(r,i[n+1])),t),["M",e[0],"Q"]).join(" ").replace(VD,"$1")}var z2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var pt=class pt{};C(pt,"rg",new JD),C(pt,"cache",new WeakMap),C(pt,"get",o=>pt.cache.get(o)),C(pt,"set",(o,t)=>pt.cache.set(o,t)),C(pt,"delete",o=>pt.cache.delete(o)),C(pt,"destroy",()=>{pt.cache=new WeakMap}),C(pt,"generateElementShape",(o,t)=>{let r=t?.isExporting?void 0:pt.get(o);if(r!==void 0)return r;F2.delete(o);let n=t_(o,pt.rg,t||{isExporting:!1,canvasBackgroundColor:qD.white,embedsValidationStatus:null});return pt.cache.set(o,n),n});var Ki=pt,QD=e=>[8,8+e],Y2=e=>[1.5,6+e];function e_(e){let o=e.roughness,t=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&t>=50||r>=15&&e.roundness&&z2(e.type)||Ar(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var qo=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?QD(e.strokeWidth):e.strokeStyle==="dotted"?Y2(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:e_(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<ZD.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=Pl(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return hd(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},G2=(e,o,t)=>Bh(e)&&(o||E2(e)&&t?.get(e.id)!==!0)&&Pl(e.backgroundColor)&&Pl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:y2(e)?{...e,strokeColor:Pl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Pl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,U2=(e,o,t,r,n,i,a)=>{let l=Wh(e,o,t,r);if(l===null)return[];let s=(d,m)=>{if(d===null)return[];let[,,c,p,u,f]=d;return[n.line(c,p,u,f,m)]};switch(r){case"dot":case"circle":case"circle_outline":{let[d,m,c]=l;return delete i.strokeLineDash,[n.circle(d,m,c,{...i,fill:r==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[d,m,c,p,u,f]=l;return delete i.strokeLineDash,[n.polygon([[d,m],[c,p],[u,f],[d,m]],{...i,fill:r==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[d,m,c,p,u,f,b,x]=l;return delete i.strokeLineDash,[n.polygon([[d,m],[c,p],[u,f],[b,x],[d,m]],{...i,fill:r==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[d,m,c,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=Y2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(c,p,d,m,i),n.line(u,f,d,m,i),...r==="crowfoot_one_or_many"?s(Wh(e,o,t,"crowfoot_one"),i):[]]}}};var t_=(e,o,{isExporting:t,canvasBackgroundColor:r,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=Cl(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,qo(G2(e,t,n),!0))}else i=o.rectangle(0,0,e.width,e.height,qo(G2(e,t,n),!1));return i}case"diamond":{let i,[a,l,s,d,m,c,p,u]=Nh(e);if(e.roundness){let f=Cl(Math.abs(a-p),e),b=Cl(Math.abs(d-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${d-b}
|
|
9
9
|
C ${s} ${d}, ${s} ${d}, ${s-f} ${d+b}
|
|
10
10
|
L ${m+f} ${c-b}
|
|
11
11
|
C ${m} ${c}, ${m} ${c}, ${m-f} ${c-b}
|
|
12
12
|
L ${p+f} ${u+b}
|
|
13
13
|
C ${p} ${u}, ${p} ${u}, ${p+f} ${u-b}
|
|
14
14
|
L ${a-f} ${l+b}
|
|
15
|
-
C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,Oo(e,!0))}else i=o.polygon([[a,l],[s,d],[m,c],[p,u]],Oo(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Oo(e));case"line":case"arrow":{let i,a=Oo(e),l=e.points.length?e.points:[V7(0,0)];if(Ga(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(Q7(l,16),Oo(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:d="arrow"}=e;if(s!==null){let m=W2(e,i,"start",s,o,a,r);i.push(...m)}if(d!==null){let m=W2(e,i,"end",d,o,a,r);i.push(...m)}}return i}case"freedraw":{let i;if(H2(e),Bc(e.points)){let a=W7(e.points,.75);i=o.curve(a,{...Oo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return K7(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},Q7=(e,o)=>{let t=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],l=e[n],s=zc(l,i),d=zc(a,l),m=Math.min(o,U2(e[n],a)/2,U2(e[n],i)/2);s?i[0]<l[0]?t.push([e[n][0]-m,e[n][1]]):t.push([e[n][0]+m,e[n][1]]):i[1]<l[1]?t.push([e[n][0],e[n][1]-m]):t.push([e[n][0],e[n][1]+m]),t.push(e[n]),d?a[0]<l[0]?t.push([e[n][0]-m,e[n][1]]):t.push([e[n][0]+m,e[n][1]]):a[1]<l[1]?t.push([e[n][0],e[n][1]-m]):t.push([e[n][0],e[n][1]+m])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<t.length;n+=3)r.push(`L ${t[n][0]} ${t[n][1]}`),r.push(`Q ${t[n+1][0]} ${t[n+1][1]}, ${t[n+2][0]} ${t[n+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(" ")};var X2=(e,o,t=!1)=>{let r=!1;for(let n in o){let i=o[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;r=!0}}return!r&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??eD(),updated:tD()}};import{jsx as Z2}from"react/jsx-runtime";var wi=B({name:"toggleLinearEditor",category:ke.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&rD(n[0])&&!oD(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];wh(n,"No selected element found"),wh(o.selectedLinearElement,"No selected linear element found"),wh(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:K2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=g(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return Z2(K,{type:"button",icon:ab,title:n,"aria-label":n,onClick:()=>o(null)})}}),T1e=B({name:"togglePolygon",category:ke.elements,icon:Em,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!yi(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>yi(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!yi(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=nD(i);return{elements:e.map(s=>!l.has(s.id)||!yi(s)?s:X2(s,{backgroundColor:a?s.backgroundColor:"transparent",...iD(s,a)})),appState:o,captureUpdate:K2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!yi(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>yi(a)&&a.polygon),i=g(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Z2(An,{icon:Em,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as $2,CANVAS_SEARCH_TAB as j2,CLASSES as aD,DEFAULT_SIDEBAR as q2}from"@excalidraw/common";import{CaptureUpdateAction as lD}from"@excalidraw/element";var za=B({name:"searchMenu",icon:Lt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===q2.name&&o.openSidebar.tab===j2){let n=r.excalidrawContainerValue.container?.querySelector(`.${aD.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:q2.name,tab:j2},openDialog:null},captureUpdate:lD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[$2.CTRL_OR_CMD]&&e.key===$2.F});import{isImageElement as sD}from"@excalidraw/element";import{CaptureUpdateAction as cD}from"@excalidraw/element";import{jsx as dD}from"react/jsx-runtime";var vh=B({name:"cropEditor",label:"helpDialog.cropStart",icon:Gm,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:cD.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&sD(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=g("helpDialog.cropStart");return dD(K,{type:"button",icon:Gm,title:r,"aria-label":r,onClick:()=>o(null)})}});import{getNonDeletedElements as mD}from"@excalidraw/element";import{mutateElement as pD}from"@excalidraw/element";import{newFrameElement as uD}from"@excalidraw/element";import{isFrameLikeElement as Yc}from"@excalidraw/element";import{addElementsToFrame as hD,removeAllElementsFromFrame as gD}from"@excalidraw/element";import{getFrameChildren as fD}from"@excalidraw/element";import{KEYS as J2,updateActiveTool as Q2}from"@excalidraw/common";import{getElementsInGroup as bD}from"@excalidraw/element";import{getCommonBounds as xD}from"@excalidraw/element";import{CaptureUpdateAction as en}from"@excalidraw/element";var ew=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Yc(t[0])},tw=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(Yc(n)){let i=fD(mD(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:en.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:en.EVENTUALLY}},predicate:(e,o,t,r)=>ew(o,r)}),ow=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return Yc(n)?{elements:gD(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:en.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:en.EVENTUALLY}},predicate:(e,o,t,r)=>ew(o,r)}),D0e=B({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:en.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),_0e=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:zr,viewMode:!1,perform:(e,o,t,r)=>{let n=Q2(o,{type:"frame"});return At(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Q2(o,{type:"frame"})},captureUpdate:en.EVENTUALLY}},keyTest:e=>!e[J2.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===J2.F}),rw=B({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=j(e,o);return n.length>0&&!n.some(i=>Yc(i))},perform:(e,o,t,r)=>{let n=j(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,d]=xD(n,i),m=16,c=uD({x:a-m,y:l-m,width:s-a+m*2,height:d-l+m*2});if(o.editingGroupId){let u=bD(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);pD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:hD([...r.scene.getElementsIncludingDeleted(),c],n,c,o),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:en.IMMEDIATELY}}});import{isWindows as CD,KEYS as Xa,matchKey as Ch,arrayToMap as nw}from"@excalidraw/common";import{CaptureUpdateAction as Ih}from"@excalidraw/element";import{orderByFractionalIndex as SD}from"@excalidraw/element";import{Emitter as ED}from"@excalidraw/common";import{CaptureUpdateAction as yD,StoreChange as wD,StoreDelta as vD}from"@excalidraw/element";var vi=class extends vD{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},tn=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Va=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new ED);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof vi)return;let t=vi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new tn(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=yD.IMMEDIATELY,l=this.store.snapshot,s=o,d=t,m=!1;for(;i;){try{[s,d,m]=i.applyTo(s,d,l);let c=l.elements,p=l.maybeClone(a,s,d),u=wD.create(l,p),f=vi.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(m)break;i=r()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new tn(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=vi.inverse(t);return o.push(r)}};import{useEffect as TD,useState as ID}from"react";var Th=(e,o)=>{let[t,r]=ID(o);return TD(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as sw}from"react/jsx-runtime";var iw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:Ih.EVENTUALLY};let[n,i]=r,a=SD(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:Ih.NEVER}}return{captureUpdate:Ih.EVENTUALLY}},aw=e=>({name:"undo",label:"buttons.undo",icon:Im,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>iw(n,t,()=>e.undo(nw(o),t)),keyTest:o=>o[Xa.CTRL_OR_CMD]&&Ch(o,Xa.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=Th(e.onHistoryChangedEmitter,new tn(e.isUndoStackEmpty,e.isRedoStackEmpty));return sw(K,{type:"button",icon:Im,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),lw=e=>({name:"redo",label:"buttons.redo",icon:Cm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>iw(n,t,()=>e.redo(nw(o),t)),keyTest:o=>o[Xa.CTRL_OR_CMD]&&o.shiftKey&&Ch(o,Xa.Z)||CD&&o.ctrlKey&&!o.shiftKey&&Ch(o,Xa.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=Th(e.onHistoryChangedEmitter,new tn(e.isUndoStackEmpty,e.isRedoStackEmpty));return sw(K,{type:"button",icon:Cm,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});import{getFontString as kD}from"@excalidraw/common";import{newElementWith as MD}from"@excalidraw/element";import{measureText as LD}from"@excalidraw/element";import{isTextElement as cw}from"@excalidraw/element";import{CaptureUpdateAction as PD}from"@excalidraw/element";var dw=B({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=j(e,o);return n.length===1&&cw(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=j(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&cw(i)){let a=LD(i.originalText,kD(i),i.lineHeight);return MD(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:PD.IMMEDIATELY}}});import{CODES as AD,KEYS as DD}from"@excalidraw/common";import{CaptureUpdateAction as _D}from"@excalidraw/element";var Sh=B({name:"viewMode",label:"labels.viewMode",icon:kn,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:_D.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[DD.CTRL_OR_CMD]&&e.altKey&&e.code===AD.R});import{isPromiseLike as RD}from"@excalidraw/common";import{jsx as ND}from"react/jsx-runtime";var kh=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&re(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Wc=class{constructor(o,t,r,n){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=d=>{kh(n,"ui",l,a,this.app,d),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),d,this.app))};return ND(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(RD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,d)=>(d.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return kh(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();kh(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Vc=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Mh=e=>{let o=Array.from(e.values());return{x:mw(o,t=>t.x)/o.length,y:mw(o,t=>t.y)/o.length}},Lh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),mw=(e,o)=>e.reduce((t,r)=>t+o(r),0);import{pointFrom as H,pointRotateRads as ur,rangeInclusive as Ut,rangeIntersection as Xc,rangesOverlap as Kc}from"@excalidraw/math";import{TOOL_TYPE as on,KEYS as pw}from"@excalidraw/common";import{getCommonBounds as Ph,getDraggedElementsBounds as Ah,getElementAbsoluteCoords as BD}from"@excalidraw/element";import{isBoundToContainer as fw}from"@excalidraw/element";import{getMaximumGroups as bw}from"@excalidraw/element";import{getSelectedElements as FD,getVisibleAndNonSelectedElements as xw}from"@excalidraw/element";var OD=8,uw=99999,Zc=e=>OD/e,gt=class gt{};I(gt,"referenceSnapPoints",null),I(gt,"visibleGaps",null),I(gt,"setReferenceSnapPoints",o=>{gt.referenceSnapPoints=o}),I(gt,"getReferenceSnapPoints",()=>gt.referenceSnapPoints),I(gt,"setVisibleGaps",o=>{gt.visibleGaps=o}),I(gt,"getVisibleGaps",()=>gt.visibleGaps),I(gt,"destroy",()=>{gt.referenceSnapPoints=null,gt.visibleGaps=null});var Yt=gt,hr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Ho=({event:e,app:o,selectedElements:t})=>e?o.state.activeTool.type!=="lasso"&&(o.state.objectsSnapModeEnabled&&!e[pw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[pw.CTRL_OR_CMD]&&!hr(o)):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,zD=(e,o,t=.01)=>Math.abs(e-o)<=t,Ka=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,m,c,p]=BD(a,o);n&&(l+=n.x,d+=n.x,c+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(d-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=ur(H(l,s+f),H(c,p),a.angle),x=ur(H(l+u,s),H(c,p),a.angle),w=ur(H(d,s+f),H(c,p),a.angle),E=ur(H(l+u,m),H(c,p),a.angle),y=H(c,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=ur(H(l,s),H(c,p),a.angle),x=ur(H(d,s),H(c,p),a.angle),w=ur(H(l,m),H(c,p),a.angle),E=ur(H(d,m),H(c,p),a.angle),y=H(c,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,d]=Ah(e,n??{x:0,y:0}),m=s-a,c=d-l,p=H(a,l),u=H(s,l),f=H(a,d),b=H(s,d),x=H(a+m/2,l+c/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>H(Le(a[0]),Le(a[1])))},Ew=(e,o,t,r)=>xw(e,o,t,r),yw=(e,o,t,r)=>{let n=Ew(e,o,t,r),i=bw(n,r).filter(c=>!(c.length===1&&fw(c[0]))).map(c=>Ph(c).map(p=>Le(p))),a=i.sort((c,p)=>c[0]-p[0]),l=[],s=0;e:for(let c=0;c<a.length;c++){let p=a[c];for(let u=c+1;u<a.length;u++){if(++s>uw)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Kc(Ut(b,w),Ut(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[H(x,b),H(x,w)],endSide:[H(E,y),H(E,v)],length:E-x,overlap:Xc(Ut(b,w),Ut(y,v))})}}let d=i.sort((c,p)=>c[1]-p[1]),m=[];s=0;e:for(let c=0;c<d.length;c++){let p=d[c];for(let u=c+1;u<d.length;u++){if(++s>uw)break e;let f=d[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Kc(Ut(b,x),Ut(E,v))&&m.push({startBounds:p,endBounds:f,startSide:[H(b,w),H(x,w)],endSide:[H(E,y),H(v,y)],length:y-w,overlap:Xc(Ut(b,x),Ut(E,v))})}}return{horizontalGaps:l,verticalGaps:m}},hw=(e,o,t,r,n,i,a)=>{if(!Ho({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Yt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[m,c,p,u]=Ah(e,o).map(x=>Le(x)),f=(m+p)/2,b=(c+u)/2;for(let x of s){if(!Kc(Ut(c,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Le(w-f);if(x.length>p-m&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(n.length=0),a.x=Math.abs(E);let P={type:"gap",direction:"center_horizontal",gap:x,offset:E};n.push(P);continue}let[,,v]=x.endBounds,C=m-v,S=Le(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[L,,,]=x.startBounds,k=L-p,A=Le(k-x.length);if(Math.abs(A)<=a.x){Math.abs(A)<a.x&&(n.length=0),a.x=Math.abs(A);let P={type:"gap",direction:"side_left",gap:x,offset:A};n.push(P);continue}}for(let x of d){if(!Kc(Ut(m,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Le(w-b);if(x.length>u-c&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let P={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,S=Le(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,L]=x.endBounds,k=Le(c-L),A=x.length-k;if(Math.abs(A)<=a.y){Math.abs(A)<a.y&&(i.length=0),a.y=Math.abs(A);let P={type:"gap",direction:"side_bottom",gap:x,offset:A};i.push(P);continue}}}},ww=(e,o,t,r)=>{let n=Ew(e,o,t,r);return bw(n,r).filter(i=>!(i.length===1&&fw(i[0]))).flatMap(i=>Ka(i,r))},Ti=(e,o,t,r,n,i,a)=>{if(!Ho({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Yt.getReferenceSnapPoints();if(l)for(let s of o)for(let d of l){let m=d[0]-s[0],c=d[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(n.length=0),n.push({type:"point",points:[s,d],offset:m}),a.x=Math.abs(m)),Math.abs(c)<=a.y&&(Math.abs(c)<a.y&&(i.length=0),i.push({type:"point",points:[s,d],offset:c}),a.y=Math.abs(c))}},vw=(e,o,t,r,n)=>{let i=t.state,a=FD(e,i);if(!Ho({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Le(o.x),o.y=Le(o.y);let l=[],s=[],d=Zc(i.zoom.value),m={x:d,y:d},c=Ka(a,n,{dragOffset:o});Ti(a,c,t,r,l,s,m),hw(a,o,t,r,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:Le(o.x+p.x),y:Le(o.y+p.y)};Ti(a,Ka(a,n,{dragOffset:u}),t,r,l,s,m),hw(a,u,t,r,l,s,m);let f=Dh(l,s),b=GD(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Le=e=>Math.round(e*10**6)/10**6,gw=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},Dh=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Le(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>H(Le(a[0]),Le(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Le(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>H(Le(a[0]),Le(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:gw(i.map(a=>H(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:gw(i.map(a=>H(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},HD=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Le(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},GD=(e,o,t)=>{let[r,n,i,a]=Ah(e,o),l=[];for(let s of t){let[d,m,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Xc(Ut(n,a),s.gap.overlap),E=Xc(Ut(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(s.gap.startSide[0][0],y),H(r,y)]},{type:"gap",direction:"horizontal",points:[H(i,y),H(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,s.gap.startSide[0][1]),H(y,n)]},{type:"gap",direction:"vertical",points:[H(y,a),H(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(c,y),H(u,y)]},{type:"gap",direction:"horizontal",points:[H(b,y),H(r,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(i,y),H(d,y)]},{type:"gap",direction:"horizontal",points:[H(c,y),H(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,a),H(y,m)]},{type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]},{type:"gap",direction:"vertical",points:[H(y,x),H(y,n)]})}break}}}return HD(l.map(s=>({...s,points:s.points.map(d=>H(Le(d[0]),Le(d[1])))})))},_h=(e,o,t,r,n,i)=>{if(!Ho({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!zD(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=Ph(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(d+=n.y));let m=[];if(i)switch(i){case"e":{m.push(H(s,l),H(s,d));break}case"w":{m.push(H(a,l),H(a,d));break}case"n":{m.push(H(a,l),H(s,l));break}case"s":{m.push(H(a,d),H(s,d));break}case"ne":{m.push(H(s,l));break}case"nw":{m.push(H(a,l));break}case"se":{m.push(H(s,d));break}case"sw":{m.push(H(a,d));break}}let c=Zc(t.state.zoom.value),p={x:c,y:c},u=[],f=[];Ti(o,m,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=Ph(e).map(S=>Le(S)),v=[H(x,w),H(x,y),H(E,w),H(E,y)];Ti(e,v,t,r,u,f,p);let C=Dh(u,f);return{snapOffset:b,snapLines:C}},Tw=(e,o,t,r,n,i)=>{if(!Ho({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[H(r.x+n.x,r.y+n.y)],l=Zc(o.state.zoom.value),s={x:l,y:l},d=[],m=[];Ti([e],a,o,t,d,m,s);let c={x:d[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,d.length=0,m.length=0;let p=Ka([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ti([e],p,o,t,d,m,s);let u=Dh(d,m);return{snapOffset:c,snapLines:u}},Iw=(e,o,t,r,n)=>{if(!Ho({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=xw(e,[],o.state,n),a=Zc(o.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let m of i){let c=Ka([m],n);for(let p of c){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(d.length=0),d.push({type:"pointer",points:[p,H(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,H(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:d.length>0?d[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...d,...s]}},Cw=e=>e===on.rectangle||e===on.ellipse||e===on.diamond||e===on.frame||e===on.magicframe||e===on.image||e===on.text;import{pointFrom as $c}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as UD,DEFAULT_FONT_SIZE as YD,TEXT_ALIGN as WD,VERTICAL_ALIGN as VD,getSizeFromPoints as XD,randomId as KD,arrayToMap as ZD,assertNever as Rh,cloneJSON as Mw,getFontString as $D,isDevEnv as jD,toBrandedType as qD,getLineHeight as JD}from"@excalidraw/common";import{bindLinearElement as Sw}from"@excalidraw/element";import{newArrowElement as QD,newElement as Nh,newFrameElement as e_,newImageElement as t_,newLinearElement as o_,newMagicFrameElement as r_,newTextElement as qc}from"@excalidraw/element";import{measureText as n_,normalizeText as i_}from"@excalidraw/element";import{isArrowElement as a_}from"@excalidraw/element";import{syncInvalidIndices as l_}from"@excalidraw/element";import{redrawTextBoundingBox as s_}from"@excalidraw/element";import{LinearElementEditor as c_}from"@excalidraw/element";import{getCommonBounds as d_}from"@excalidraw/element";import{Scene as m_}from"@excalidraw/element";var jc={width:100,height:0},gr=100,p_=(e,o,t)=>{let r=qc({x:0,y:0,textAlign:WD.CENTER,verticalAlign:VD.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),s_(r,e,t),[e,r]},kw=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??gr,c=o?.height??gr,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-m,f=o.y||e.y-c/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=qc({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Nh({x:u,y:f,width:m,height:c,...p,...o,type:b});break}default:Rh(e,`Unhandled element start type "${o.type}"`,!0)}Sw(e,i,"start",n)}}if(t){let m=t?.height??gr,c=t?.width??gr,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-m/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=qc({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Nh({x:u,y:f,width:c,height:m,...p,...t,type:b});break}default:Rh(e,`Unhandled element end type "${b}"`,!0)}Sw(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,d=Mw(e.points);return e.points[l][0]>e.points[l-1][0]&&(d[0][0]=s,d[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(d[0][0]=-s,d[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(d[0][1]=s,d[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(d[0][1]=-s,d[l][1]+=s),Object.assign(e,c_.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:i,endBoundElement:a}},Bh=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>l_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>qD(ZD(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ii=(e,o)=>{if(!e)return[];let t=Mw(e),r=new Bh,n=new Map,i=new Map;for(let s of t){let d,m=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:KD()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||gr,u=s?.label?.text&&s.height===void 0?0:s?.height||gr;d=Nh({...s,width:p,height:u});break}case"line":{let p=s.width||jc.width,u=s.height||jc.height;d=o_({width:p,height:u,points:[$c(0,0),$c(p,u)],...s});break}case"arrow":{let p=s.width||jc.width,u=s.height||jc.height;d=QD({width:p,height:u,endArrowhead:"arrow",points:[$c(0,0),$c(p,u)],...s,type:"arrow"}),Object.assign(d,XD(d.points));break}case"text":{let p=s?.fontFamily||UD,u=s?.fontSize||YD,f=s?.lineHeight||JD(p),b=s.text??"",x=i_(b),w=n_(x,$D({fontFamily:p,fontSize:u}),f);d=qc({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{d=t_({width:s?.width||gr,height:s?.height||gr,...s});break}case"frame":{d=e_({x:0,y:0,...s});break}case"magicframe":{d=r_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{d=s;break}default:d=s,Rh(s,`Unhandled element type "${s.type}"`,!0)}r.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(r.add(d),n.set(d.id,s),m&&i.set(m,d.id))}let a=r.getElementsMap(),l=new m_(a);for(let[s,d]of n){let m=r.getElement(s);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[c,p]=p_(m,d?.label,l);if(r.add(c),r.add(p),a_(c)){let u=d.type==="arrow"?d?.start:void 0,f=d.type==="arrow"?d?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=kw(c,u,f,r,l);c=b,r.add(b),r.add(x),r.add(w)}}else switch(d.type){case"arrow":{let{start:c,end:p}=d;if(c&&c.id){let x=i.get(c.id);Object.assign(c,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=kw(m,c,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,d]of n){if(d.type!=="frame"&&d.type!=="magicframe")continue;let m=r.getElement(s);if(!m)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let c=[];d.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=r.getElement(S);if(!L)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(L,{frameId:m.id}),L?.boundElements?.forEach(k=>{let A=r.getElement(k.id);if(!A)throw new Error(`Bound element with id ${k.id} doesn't exist`);Object.assign(A,{frameId:m.id}),c.push(A)}),c.push(L)});let[p,u,f,b]=d_(c),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=m?.x||p,E=m?.y||u,y=m?.width||f-p,v=m?.height||b-u;Object.assign(m,{x:w,y:E,width:y,height:v}),jD()&&d.children.length&&(m?.x||m?.y||m?.width||m?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import{isElementInViewport as U_}from"@excalidraw/element";import{memoize as Y_,toBrandedType as W_}from"@excalidraw/common";import{pointFrom as y_,pointsEqual as w_}from"@excalidraw/math";import Qc from"open-color";import{arrayToMap as v_,DEFAULT_TRANSFORM_HANDLE_SPACING as Wh,FRAME_STYLE as Nw,invariant as Bw,THEME as T_,throttleRAF as I_}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as Oh,maxBindingGap as Uw}from"@excalidraw/element";import{LinearElementEditor as fr}from"@excalidraw/element";import{getOmitSidesForDevice as zh,getTransformHandles as C_,getTransformHandlesFromCoords as S_,shouldShowBoundingBox as k_}from"@excalidraw/element";import{isElbowArrow as Za,isFrameLikeElement as Fw,isImageElement as Ow,isLinearElement as M_,isLineElement as L_,isTextElement as zw}from"@excalidraw/element";import{renderSelectionElement as P_}from"@excalidraw/element";import{getElementsInGroup as Uh,getSelectedGroupIds as A_,isSelectedViaGroup as D_,selectGroupsFromGivenElements as __}from"@excalidraw/element";import{getCommonBounds as Yh,getElementAbsoluteCoords as $a}from"@excalidraw/element";import{pointFrom as ct}from"@excalidraw/math";import{THEME as u_}from"@excalidraw/common";var h_="#ff6b6b",g_="#ff0000",Lw=1,Pw=2,Aw=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===u_.LIGHT||o.zenModeEnabled?h_:g_,r=(o.zenModeEnabled?Lw*1.5:Lw)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,b_(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,x_(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,f_(n,e,o));e.restore()},f_=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Wt(r,n,o)}for(let r of e.points)Dw(r,t,o)},b_=(e,o,t)=>{Dw(e.points[0],t,o),t.zenModeEnabled||Wt(e.points[0],e.points[1],o)},Dw=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?Pw*1.5:Pw)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},Wt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},x_=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||Wt(ct(e[0],e[1]-i),ct(e[0],e[1]+i),n),Wt(ct(s[0]-l,s[1]-a),ct(s[0]-l,s[1]+a),n),Wt(ct(s[0]+l,s[1]-a),ct(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Wt(ct(o[0],o[1]-i),ct(o[0],o[1]+i),n),Wt(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Wt(ct(e[0]-i,e[1]),ct(e[0]+i,e[1]),n),Wt(ct(s[0]-a,s[1]-l),ct(s[0]+a,s[1]-l),n),Wt(ct(s[0]-a,s[1]+l),ct(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Wt(ct(o[0]-i,o[1]),ct(o[0]+i,o[1]),n),Wt(e,o,n))}};import{getGlobalCSSVariable as Jc}from"@excalidraw/common";import{getCommonBounds as E_}from"@excalidraw/element";var ao=4,Ct=6,_w="rgba(0,0,0,0.3)",Rw=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=E_(e),s=o/r.zoom.value,d=t/r.zoom.value,m={top:parseInt(Jc("sat"))||0,bottom:parseInt(Jc("sab"))||0,left:parseInt(Jc("sal"))||0,right:parseInt(Jc("sar"))||0},c=Mo().rtl,p=-r.scrollX+m.left,u=-r.scrollY+m.top,f=p+s-m.right,b=u+d-m.bottom,x=Math.min(n,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-n,C=l-i,S=E-x,L=y-w,k=Math.max(ao*2,m.left+m.right)+Ct*2,A=o*(s/S)-k,P=Math.max(ao*2,m.top+m.bottom)+Ct*2,N=t*(d/L)-P,O=S>v?S*r.zoom.value/(A+k):o/(A+k),U=L>C?L*r.zoom.value/(N+P):t/(N+P);return{horizontal:p===x&&f===E?null:{x:Math.max(m.left,ao)+Ct+(p-x)/S*o,y:t-Ct-Math.max(ao,m.bottom),width:A,height:Ct,deltaMultiplier:O},vertical:u===w&&b===y?null:{x:c?Math.max(m.left,ao):o-Ct-Math.max(m.right,ao),y:Math.max(m.top,ao)+Ct+(u-w)/L*t,width:Ct,height:N,deltaMultiplier:U}}},Fh=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var R_=(e,o)=>{Bw(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;Bw(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Yw(t,e,o),e.restore()},N_=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let i=fr.getElement(r,t);if(!i)return;let a=fr.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Yw(a,e,o),e.restore()},Yw=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Wi(o,e[0],e[1],fr.POINT_HANDLE_SIZE/t.zoom.value,!1)},Hh=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Wi(e,t[0],t[1],(a?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!i,!a||n)},B_=(e,o,t,r)=>{let n=Uw(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":e1(e,o,t,n);break;case"diamond":o1(e,n,o,t);break;case"ellipse":{let[i,a,l,s]=$a(o,t),d=l-i,m=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=n-Oh,t1(e,d+n+Oh,m+n+Oh,i+d/2,a+m/2,o.angle);break}}},F_=(e,o,t,r)=>{let[n,i,a]=o,l=Uw(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(d=>{let[m,c]=fr.getPointAtIndexGlobalCoordinates(n,d,t);Wi(e,m,c,l,!0)})},Ww=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:m,dashed:c,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??Wh*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],c&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,Vi(e,n-x,i-x,u+x*2,f+x*2,d,m,r);e.restore()},O_=(e,o,t,r)=>{let n=Array.isArray(t)?F_:B_;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},z_=(e,o,t,r)=>{let[n,i,a,l]=$a(t,r),s=a-n,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Nw.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Vi(e,n,i,s,d,n+s/2,i+d/2,t.angle,!1,Nw.radius/o.zoom.value),e.restore()},Hw=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[c,p,u,f]=Yh(m);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},d=m=>{let c=Uh(t,m);return s(c)};Object.entries(__(l,o)).filter(([m,c])=>c).map(([m,c])=>m).map(m=>d(m)).concat(a.map(m=>s([m]))).forEach(m=>Ww(e,o,m))},Gh=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=fr.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=fr,a=o.selectedLinearElement?.isEditing?i:i/2,l=Za(t),s=L_(t);if(n.forEach((d,m)=>{if(l&&m!==0&&m!==n.length-1)return;let c=m>0&&(m!==n.length-1||!s||!t.polygon)&&w_(d,m===n.length-1?n[0]:n[m-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!p&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Hh(e,o,d,a,p,!1,c)}),Za(t)){let d=t.fixedSegments?.map(m=>m.index)||[];n.slice(0,-1).forEach((m,c)=>{fr.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||Hh(e,o,y_((m[0]+n[c+1][0])/2,(m[1]+n[c+1][1])/2),i/2,!1,!d.includes(c+1),!1)})}else fr.getEditorMidPoints(t,r,o).filter((m,c,p)=>m!==null&&!(Za(t)&&(c===0||c===p.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||n.length===2)&&Hh(e,o,m,i/2,!1,!0,!1)});e.restore()},Gw=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,d,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Wi(e,l+d/2,s+m/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,d,m,2/t.zoom.value),e.fill(),e.stroke()):Vi(e,l,s,d,m,l+d/2,s+m/2,n,!0),e.restore()}})},H_=(e,o,t,r,n)=>{let[i,a,,,l,s]=$a(r,n),d=3,m=20,c=d/t.zoom.value,p=c/2,u=l-i+c,f=s-a+c,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=c,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[C,S],[L,k],[A,P],[N,O]]=E;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+L,v+k),e.stroke(),e.beginPath(),e.moveTo(y+A,v+P),e.lineTo(y+N,v+O),e.stroke(),e.restore()}),e.restore()},G_=(e,o,t,r)=>{o.save();let n=Wh*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,d=-(i/2+n),m=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(d,m,i,a),o.restore()},Vw=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[d,m]=Al(e,i),c=Dl({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m});c.save(),c.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&Gh(c,a,p,o),a.selectionElement&&!a.isCropping)try{P_(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&zw(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&G_(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{O_(c,a,b,o)}),a.frameToHighlight&&z_(c,a,a.frameToHighlight,o),a.elementsToHighlight&&Hw(c,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:Uh(n,a.activeLockedId);Hw(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>Fw(b));if(r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&Gh(c,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?R_(c,a):(Za(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&N_(c,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=k_(r,a),x=r.length===1&&M_(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Gh(c,a,r[0],o);let w=l.selectionColor||Qc.black;if(b){let E=v_(r),y=[];for(let C of o.values()){let S=[],L=l.remoteSelectedElementIds.get(C.id);if(x&&Za(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!D_(a,C)&&S.push(w),L&&S.push(...L.map(k=>$r(k,a.collaborators.get(k))))),S.length){let[k,A,P,N,O,U]=$a(C,o,!0);y.push({angle:C.angle,x1:k,y1:A,x2:P,y2:N,selectionColors:C.locked?["#ced4da"]:S,dashed:!!L||C.locked,cx:O,cy:U,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||Ow(C)?0:void 0})}}let v=C=>{let S=Uh(o,C),[L,k,A,P]=Yh(S);y.push({angle:0,x1:L,x2:A,y1:k,y2:P,selectionColors:S.some(N=>N.locked)?["#ced4da"]:[Qc.black],dashed:!0,cx:L+(A-L)/2,cy:k+(P-k)/2,activeEmbeddable:!1})};for(let C of A_(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Ww(c,a,C))}if(c.save(),c.translate(a.scrollX,a.scrollY),r.length===1){c.fillStyle=Qc.white;let E=C_(r[0],a.zoom,o,"mouse",zh(s));if(!a.viewModeEnabled&&b&&!zw(a.editingTextElement)&&!a.croppingElementId&&Gw(c,l,a,E,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&Ow(y)&&H_(c,l,a,y,o)}}else if(r.length>1&&!a.isRotating&&!r.some(E=>E.locked)){let E=Wh*2/a.zoom.value;c.fillStyle=Qc.white;let[y,v,C,S]=Yh(r,o),L=c.getLineDash();c.setLineDash([2/a.zoom.value]);let k=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=w,Vi(c,y-E,v-E,C-y+E*2,S-v+E*2,(y+C)/2,(v+S)/2,0),c.lineWidth=k,c.setLineDash(L);let A=S_([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...zh(s),rotation:!0}:zh(s));r.some(P=>!P.locked)&&Gw(c,l,a,A,0)}c.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,C,S]=$a(E,o,!0);c.save(),a.theme===T_.LIGHT?x?c.fillStyle="rgba(255, 124, 0, 0.4)":c.fillStyle="rgba(255, 226, 0, 0.4)":x?c.fillStyle="rgba(229, 82, 0, 0.4)":c.fillStyle="rgba(99, 52, 0, 0.4)";let L=Fw(E)?a.zoom.value:1;c.translate(a.scrollX,a.scrollY),c.translate(C,S),c.rotate(E.angle),w.forEach(k=>{(k.showOnCanvas||x)&&c.fillRect(y+k.offsetX/L-C,v+k.offsetY/L-S,k.width/L,k.height/L)}),c.restore()}}),Aw(c,a),c.restore(),aE({context:c,renderConfig:l,appState:a,normalizedWidth:d,normalizedHeight:m});let f;return l.renderScrollbars&&(f=Rw(o,d,m,a),c.save(),c.fillStyle=_w,c.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&qs(c,b.x,b.y,b.width,b.height,Ct/2)}),c.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},Vh=I_(e=>{let o=Vw(e);e.callback?.(o)},{trailing:!0}),Xw=(e,o)=>{if(o){Vh(e);return}let t=Vw(e);return e.callback(t),t};var ja=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:d,width:m})=>{let c=[];for(let p of r.values())U_(p,m,d,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&c.push(p);return c},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=W_(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return Y_(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d,editingTextElement:m,newElementId:c,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:m,newElementId:c}),b=o({elementsMap:f,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){Vh.cancel(),n1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as V_}from"@excalidraw/common";import{getElementAbsoluteCoords as X_}from"@excalidraw/element";import{jsx as $_}from"react/jsx-runtime";var K_=5,Z_=(e,o,t)=>{let[r,n]=X_(e,t),{x:i,y:a}=V_({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Xh=({children:e,element:o,elementsMap:t})=>{let r=go();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=Z_(o,r,t);return $_("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:K_},children:e})};import{DEFAULT_LASER_COLOR as Q_,easeOut as Zw}from"@excalidraw/common";import{LaserPointer as j_}from"@excalidraw/laser-pointer";import{SVG_NS as Kw,getSvgPathFromStroke as q_,sceneCoordsToViewportCoords as J_}from"@excalidraw/common";var Go=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Kw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Kw,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new j_(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=J_({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return q_(n,!0)}};var ed=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Go(o,t,{...this.getTrailOptions(),fill:()=>Q_})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Zw(i),Zw(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new Go(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||$r(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as eR}from"react";import{unstable_batchedUpdates as $w}from"react-dom";import{throttleRAF as tR}from"@excalidraw/common";var Pe=e=>o=>{$w(e,o)},td=e=>tR(o=>{$w(e,o)}),Ci=(()=>{let e;try{let t=eR.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Kh,KEYS as qa,CLASSES as jw,POINTER_BUTTON as oR,isWritableElement as rR,getFontString as qw,getFontFamilyString as Jw,isTestEnv as Qw}from"@excalidraw/common";import{originalContainerCache as nR,updateOriginalContainerCache as ev}from"@excalidraw/element";import{LinearElementEditor as iR}from"@excalidraw/element";import{bumpVersion as aR}from"@excalidraw/element";import{getBoundTextElementId as lR,getContainerElement as Zh,getTextElementAngle as sR,redrawTextBoundingBox as cR,getBoundTextMaxHeight as dR,getBoundTextMaxWidth as tv,computeContainerDimensionForBoundText as ov,computeBoundTextPosition as mR,getBoundTextElement as pR}from"@excalidraw/element";import{getTextWidth as uR}from"@excalidraw/element";import{normalizeText as rv}from"@excalidraw/element";import{wrapText as hR}from"@excalidraw/element";import{isArrowElement as od,isBoundToContainer as gR,isTextElement as nv}from"@excalidraw/element";var fR=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,d=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${s}px, ${d}px) scale(${a.value}) rotate(${l}deg)`},iv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let d=(_,R)=>{if(!R.style.fontFamily||!R.style.fontSize)return!1;let V=R.style.fontFamily.replace(/"/g,"");return Jw({fontFamily:_.fontFamily})!==V||`${_.fontSize}px`!==R.style.fontSize},m=()=>{let _=l.state,R=l.scene.getElement(e);if(!R)return;let{textAlign:V,verticalAlign:Z}=R,W=l.scene.getNonDeletedElementsMap();if(R&&nv(R)){let ce=R.x,he=R.y,de=Zh(R,l.scene.getNonDeletedElementsMap()),it=R.width,po=R.height,mn=R.width,pn=R.height;if(de&&R.containerId){if(od(de)){let Xo=iR.getBoundTextElementPosition(de,R,W);ce=Xo.x,he=Xo.y}let Sl=d(R,c),Ui;if(Sl?Ui=ev(de.id,de.height):(Ui=nR[de.id],Ui||(Ui=ev(de.id,de.height))),mn=tv(de,R),pn=dR(de,R),!od(de)&&po>pn){let Xo=ov(po,de.type);l.scene.mutateElement(de,{height:Xo});return}else if(!od(de)&&de.height>Ui.height&&po<pn){let Xo=ov(po,de.type);l.scene.mutateElement(de,{height:Xo})}else{let{y:Xo}=mR(de,R,W);he=Xo}}let[Cl,nm]=r(ce,he),VI=c.selectionStart,im=c.selectionEnd,Uf=c.value.length;if(VI===im&&im!==Uf){let Sl=Uf-im;c.selectionStart=c.value.length-Sl,c.selectionEnd=c.value.length-Sl}de?it+=.5:(mn=(_.width-8-Cl)/_.zoom.value,it=Math.min(it,mn)),po*=1.05;let XI=qw(R),Yf=(_.height-nm)/_.zoom.value;Object.assign(c.style,{font:XI,lineHeight:R.lineHeight,width:`${it}px`,height:`${po}px`,left:`${Cl}px`,top:`${nm}px`,transform:fR(it,po,sR(R,de),_,mn,Yf),textAlign:V,verticalAlign:Z,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Yf}px`}),c.scrollTop=0,Qw()&&(c.style.fontFamily=Jw(R)),l.scene.mutateElement(R,{x:ce,y:he})}},c=document.createElement("textarea");c.dir="auto",c.tabIndex=0,c.dataset.type="wysiwyg",c.wrap="off",c.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(gR(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(c.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),c.value=n.originalText,m(),o&&(c.onpaste=async _=>{let R=await Ws(_,!0);if(!R.text)return;let V=rv(R.text);if(!V)return;let Z=Zh(n,l.scene.getNonDeletedElementsMap()),W=qw({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let ce=pR(Z,l.scene.getNonDeletedElementsMap()),he=hR(`${c.value}${V}`,W,tv(Z,ce)),de=uR(he,W);c.style.width=`${de}px`}},c.oninput=()=>{let _=rv(c.value);if(c.value!==_){let R=c.selectionStart;c.value=_,c.selectionStart=R,c.selectionEnd=R}o(c.value)}),c.onkeydown=_=>{if(!_.shiftKey&&Rs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Rs),m();else if(!_.shiftKey&&Ns.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ns),m();else if(!_.shiftKey&&Bs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Bs),m();else if(kp.keyTest(_))l.actionManager.executeAction(kp);else if(Mp.keyTest(_))l.actionManager.executeAction(Mp);else if(_.key===qa.ESCAPE)_.preventDefault(),C=!0,S();else if(Kr.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction(Kr);else if(_.key===qa.ENTER&&_[qa.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===qa.TAB||_[qa.CTRL_OR_CMD]&&(_.code===Kh.BRACKET_LEFT||_.code===Kh.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===Kh.BRACKET_LEFT?E():w(),c.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:_,selectionEnd:R}=c,V=y(),Z=c.value;V.forEach(W=>{let ce=Z.slice(0,W),he=Z.slice(W);Z=`${ce}${b}${he}`}),c.value=Z,c.selectionStart=_+f,c.selectionEnd=R+f*V.length},E=()=>{let{selectionStart:_,selectionEnd:R}=c,V=y(),Z=[],W=c.value;V.forEach(ce=>{let he=W.slice(ce,ce+f).match(x);if(he){let de=W.slice(0,ce),it=W.slice(ce+he[0].length);W=`${de}${it}`,Z.push(ce)}}),c.value=W,Z.length&&(_>Z[Z.length-1]?c.selectionStart=Math.max(_-f,Z[Z.length-1]):c.selectionStart=_,c.selectionEnd=Math.max(c.selectionStart,R-f*Z.length))},y=()=>{let{selectionStart:_,selectionEnd:R,value:V}=c,Z=V.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-Z,V.slice(_,R).split(`
|
|
16
|
-
`).reduce((ce,he,de,it)=>ce.concat(de?ce[de-1]+it[de-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(U)return;U=!0,L();let _=l.scene.getElement(n.id);if(!_)return;let R=Zh(_,l.scene.getNonDeletedElementsMap());if(R){if(c.value.trim()){let V=lR(R);!V||V!==n.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:n.id})}):od(R)&&aR(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(V=>!nv(V))});cR(_,R,l.scene)}t({viaKeyboard:C,nextOriginalText:c.value})},L=()=>{c.onblur=null,c.oninput=null,c.onkeydown=null,J&&J.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",k),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),N(),O(),c.remove()},k=_=>{window.removeEventListener("pointerup",k);let R=_?.target,V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");setTimeout(()=>{c.onblur=S,V||c.focus()})},A=()=>{c.onblur=null,window.addEventListener("pointerup",k),window.addEventListener("blur",S)},P=_=>{let R=_?.target;if(_.button===oR.WHEEL){R instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),A();return}let V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${jw.SHAPE_ACTIONS_MENU}, .${jw.ZOOM_ACTIONS}`)&&!rR(_.target)||V?A():_.target instanceof HTMLCanvasElement&&!Qw()&&requestAnimationFrame(()=>{S()})},N=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||c.focus()}),O=l.onScrollChangeEmitter.on(()=>{m()}),U=!1;s&&c.select(),k();let J=null;return i&&"ResizeObserver"in window?(J=new window.ResizeObserver(()=>{m()}),J.observe(i)):window.addEventListener("resize",m),c.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(c),S};var av=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as SR}from"@excalidraw/math";import{getElementLineSegments as kR}from"@excalidraw/element";import{LinearElementEditor as MR}from"@excalidraw/element";import{isFrameLikeElement as LR,isLinearElement as PR,isTextElement as AR}from"@excalidraw/element";import{getFrameChildren as DR}from"@excalidraw/element";import{selectGroupsForSelectedElements as _R}from"@excalidraw/element";import{getContainerElement as RR}from"@excalidraw/element";import{arrayToMap as NR,easeOut as dv,isShallowEqual as BR}from"@excalidraw/common";import{simplify as bR}from"points-on-curve";import{polygonFromPoints as xR,lineSegment as lv,polygonIncludesPointNonZero as ER}from"@excalidraw/math";import{computeBoundTextPosition as yR,doBoundsIntersect as wR,getBoundTextElement as vR,getElementBounds as TR,intersectElementWithLineSegment as sv}from"@excalidraw/element";var cv=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=bR(o,l));let d=t.filter(p=>!p.locked);a.clear(),i.clear();let m=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of d){let u=TR(p,r);wR(m,u)&&!i.has(p.id)&&!a.has(p.id)&&(IR(s,p,n)?a.add(p.id):CR(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},IR=(e,o,t)=>{let r=xR(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>ER(a,r))):!1},CR=(e,o,t)=>{let r=e.slice(1).map((i,a)=>lv(e[a],i)).concat([lv(e[e.length-1],e[0])]),n=vR(o,t);return r.some(i=>sv(o,t,i,0,!0).length>0||!!n&&sv({...n,...yR(o,n,t)},t,i,0,!0).length>0)};var rd=class extends Go{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(dv(s),dv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let d=this.app.scene.getNonDeletedElement(s);if(d&&AR(d)){let m=RR(d,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[d.id])}}for(let[s]of Object.entries(n)){let d=this.app.scene.getNonDeletedElement(s);if(d&&LR(d)){let m=DR(this.app.scene.getNonDeletedElementsMap(),d.id);for(let c of m)delete n[c.id]}}let i=_R({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&PR(this.app.scene.getNonDeletedElement(a[0]))?new MR(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>SR(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!BR(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=NR(this.app.visibleElements);for(let i of this.app.visibleElements){let a=kR(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=cv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as FR,easeOut as mv,THEME as OR}from"@excalidraw/common";import{computeBoundTextPosition as zR,getBoundTextElement as HR,intersectElementWithLineSegment as pv,isPointInElement as GR}from"@excalidraw/element";import{lineSegment as UR,pointFrom as YR}from"@excalidraw/math";import{getElementsInGroup as uv}from"@excalidraw/element";import{shouldTestInside as WR}from"@excalidraw/element";import{hasBoundTextElement as hv,isBoundToContainer as gv}from"@excalidraw/element";import{getBoundTextElementId as fv}from"@excalidraw/element";var nd=class extends Go{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(mv(s),mv(l))},fill:()=>r.state.theme===OR.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>YR(l[0],l[1]))||[];if(r.length<2)return[];let n=UR(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=FR(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(bv(n,l,a)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let m=uv(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.delete(c.id);this.groupsToErase.delete(d)}if(gv(l)&&this.elementsToErase.delete(l.containerId),hv(l)){let m=fv(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&bv(n,l,a)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let m=uv(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.add(c.id);this.groupsToErase.add(d)}if(hv(l)){let m=fv(l);m&&this.elementsToErase.add(m)}gv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},bv=(e,o,t)=>{let r=e[1];if(WR(o)&&GR(r,o,t))return!0;let n=HR(o,t);return pv(o,t,e,0,!0).length>0||!!n&&pv({...n,...zR(o,n,t)},t,e,0,!0).length>0};import{jsx as Vt,jsxs as xv}from"react/jsx-runtime";var VR=()=>xv("div",{"data-testid":"brave-measure-text-error",children:[Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Vt("span",{style:{fontWeight:600},children:e})})}),Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Vt("span",{style:{fontWeight:600},children:e})})}),Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Vt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Vt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>xv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Ev=VR;import qR from"clsx";import JR from"react";import{useLayoutEffect as XR,useRef as yv,useEffect as wv}from"react";import{unstable_batchedUpdates as KR}from"react-dom";import{KEYS as ZR,queryFocusableElements as $R}from"@excalidraw/common";import{jsx as jR}from"react/jsx-runtime";var vv=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let d=yv(null);wv(()=>{let c=d.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=u=>{if(u.key===ZR.TAB){let f=$R(c),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===c?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return c.addEventListener("keydown",p),()=>c.removeEventListener("keydown",p)},[]);let m=yv(null);return XR(()=>{if(n&&d.current&&t!=null&&o!=null){let c=d.current,{width:p,height:u}=c.getBoundingClientRect();if(m.current?.top===t&&m.current?.left===o)return;m.current={top:t,left:o},p>=l?(c.style.width=`${l}px`,c.style.left="0px",c.style.overflowX="scroll"):o+p-i>l?c.style.left=`${l-p-10}px`:c.style.left=`${o}px`,u>=s?(c.style.height=`${s-20}px`,c.style.top="10px",c.style.overflowY="scroll"):t+u-a>s?c.style.top=`${s-u}px`:c.style.top=`${t}px`}},[t,o,n,l,s,i,a]),wv(()=>{if(r){let c=p=>{d.current?.contains(p.target)||KR(()=>r(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[r]),jR("div",{className:"popover",ref:d,tabIndex:-1,children:e})};import{jsx as Si,jsxs as QR}from"react/jsx-runtime";var Ye="separator",Tv=JR.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=go(),a=tr(),l=o.reduce((s,d)=>(d&&(d===Ye||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s),[]);return Si(vv,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Si("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,d)=>{if(s===Ye)return!l[d-1]||l[d-1]===Ye?null:Si("hr",{className:"context-menu-item-separator"},d);let m=s.name,c="";return s.label&&(typeof s.label=="function"?c=g(s.label(a,i,e.app)):c=g(s.label)),Si("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:QR("button",{type:"button",className:qR("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Si("div",{className:"context-menu-item__label",children:c}),Si("kbd",{className:"context-menu-item__shortcut",children:m?Ne(m):""})]})},d)})})})});import{jsx as $h,jsxs as Iv}from"react/jsx-runtime";var e9=({height:e,width:o,userToFollow:t,onDisconnect:r})=>$h("div",{className:"follow-mode",style:{width:o,height:e},children:Iv("div",{className:"follow-mode__badge",children:[Iv("div",{className:"follow-mode__badge__label",children:["Following"," ",$h("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),$h("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Bt})]})}),Cv=e9;import cl from"clsx";import EO from"react";import{CLASSES as yO,DEFAULT_SIDEBAR as Kg,TOOL_TYPE as rT,arrayToMap as wO,capitalizeString as vO,isShallowEqual as Wd}from"@excalidraw/common";import{mutateElement as TO}from"@excalidraw/element";import{showSelectedShapeActions as IO}from"@excalidraw/element";import{ShapeCache as CO}from"@excalidraw/element";import t9 from"clsx";import{useState as o9,useEffect as r9}from"react";import{THEME as n9}from"@excalidraw/common";import{jsx as jh,jsxs as i9}from"react/jsx-runtime";var id=({delay:e,theme:o})=>{let[t,r]=o9(!!e);return r9(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:i9("div",{className:t9("LoadingMessage",{"LoadingMessage--dark":o===n9.DARK}),children:[jh("div",{children:jh(tt,{})}),jh("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import a9 from"clsx";import{jsx as kv,jsxs as s9}from"react/jsx-runtime";var l9="medium",Sv={CHECKED:wn,UNCHECKED:Br},ad=e=>s9("label",{className:a9("ToolIcon ToolIcon__lock",`ToolIcon_size_${l9}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[kv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),kv("div",{className:"ToolIcon__icon",children:e.checked?Sv.CHECKED:Sv.UNCHECKED})]});import{showSelectedShapeActions as S9}from"@excalidraw/element";import c9 from"clsx";import{jsx as d9}from"react/jsx-runtime";var ld=({children:e,side:o,className:t})=>d9("div",{className:c9("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import m9 from"clsx";import{KEYS as Mv}from"@excalidraw/common";import{jsx as p9}from"react/jsx-runtime";var sd=e=>p9(K,{className:m9("Shape",{fillable:!1}),type:"radio",icon:Ql,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:Mv.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":Mv.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as u9,DEFAULT_SIDEBAR as h9}from"@excalidraw/common";import{isFlowchartNodeElement as g9,isImageElement as Lv,isLinearElement as Pv,isLineElement as f9,isTextBindableContainer as b9,isTextElement as x9}from"@excalidraw/element";import{getShortcutKey as qh}from"@excalidraw/common";import{isNodeInFlowchart as E9}from"@excalidraw/element";import{jsx as Av}from"react/jsx-runtime";var y9=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===h9.name&&e.openSidebar.tab===u9&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(bt(e))return g("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?g("hints.linearElementMulti"):n.type==="arrow"?g("hints.arrowTool",{arrowShortcut:qh("A")}):g("hints.linearElement");if(n.type==="freedraw")return g("hints.freeDraw");if(n.type==="text")return g("hints.text");if(n.type==="embeddable")return g("hints.embeddable");let d=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&d.length===1){let m=d[0];return Pv(m)&&m.points.length===2?g("hints.lockAngle"):Lv(m)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(d.length===1&&x9(d[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(d.length===1&&Lv(d[0]))return g("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(hr(r)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!d.length&&!o)return[g("hints.canvasPanning")];if(d.length===1){if(Pv(d[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):f9(d[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&b9(d[0]))return g9(d[0])?E9(d[0],r.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},cd=({appState:e,isMobile:o,device:t,app:r})=>{let n=y9({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>qh(a).replace(/\. ?$/,"")).join(". "):qh(n);return Av("div",{className:"HintViewer",children:Av("span",{children:i})})};import w9 from"clsx";import{jsx as Dv,jsxs as T9}from"react/jsx-runtime";var v9="medium",dd=e=>e.penDetected?T9("label",{className:w9("ToolIcon ToolIcon__penMode",`ToolIcon_size_${v9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Dv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Dv("div",{className:"ToolIcon__icon",children:_1})]}):null;import{Fragment as I9,jsx as _v,jsxs as C9}from"react/jsx-runtime";var br=({heading:e,children:o,...t})=>{let{id:r}=He(),n=_v("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:g(`headings.${e}`)});return _v("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):C9(I9,{children:[n,o]})})};import{Fragment as k9,jsx as rt,jsxs as Uo}from"react/jsx-runtime";var Rv=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:d,device:m,renderWelcomeScreen:c,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=ve(),w=()=>Uo(ld,{side:"top",className:"App-top-bar",children:[c&&rt(f.Out,{}),rt(br,{heading:"shapes",children:y=>rt(qe.Col,{gap:4,align:"center",children:Uo(qe.Row,{gap:1,className:"App-toolbar-container",children:[Uo(Xe,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,rt(qe.Row,{gap:1,children:rt(Ac,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Uo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&rt(x.Out,{}),rt(dd,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),rt(ad,{checked:e.activeTool.locked,onChange:n,title:g("toolBar.lock"),isMobile:!0}),rt(sd,{checked:jt(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),rt(cd,{appState:e,isMobile:!0,device:m,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?rt("div",{className:"App-toolbar-content",children:rt(b.Out,{})}):Uo("div",{className:"App-toolbar-content",children:[rt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Uo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Uo(k9,{children:[d(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&w(),rt("div",{className:"App-bottom-bar",style:{marginBottom:Ct+ao*2,marginLeft:Ct+ao*2,marginRight:Ct+ao*2},children:Uo(Xe,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&S9(e,o)?rt(br,{className:"App-mobile-menu",heading:"selectedShapeActions",children:rt(Pc,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Uo("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&rt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...Nr(o,y)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import M9 from"open-color";import L9,{useLayoutEffect as P9,useRef as A9,useState as D9}from"react";import{jsx as Ja,jsxs as _9}from"react/jsx-runtime";var Nv=e=>{let o=A9(null),[t,r]=D9(null);return P9(()=>{if(!e.spreadsheet)return;let n=Hx(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await fn(n,{exportBackground:!1,viewBackgroundColor:M9.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Ja("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Ja("div",{ref:o})})},Bv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Re(),n=L9.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),re("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ja(Be,{size:"small",onCloseRequest:n,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:_9("div",{className:"container",children:[Ja(Nv,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Ja(Nv,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as xr from"@radix-ui/react-popover";import Fv from"clsx";import md,{useLayoutEffect as R9}from"react";import{supportsResizeObserver as N9,isShallowEqual as B9}from"@excalidraw/common";import{Fragment as G9,jsx as vo,jsxs as pd}from"react/jsx-runtime";var F9=4,O9=8,z9=({shouldWrap:e,children:o,username:t})=>e?vo(Pt,{label:t||"Unknown user",children:o}):vo(G9,{children:o}),Jh=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return vo(z9,{username:o.username,shouldWrap:n,children:l},t)},H9=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],ud=md.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=Ue(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=md.useState(""),d=a.filter(b=>b.username?.toLowerCase().includes(l)),m=md.useRef(null);R9(()=>{if(m.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(m.current.clientWidth),!N9)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[c,p]=md.useState(F9),f=a.slice(0,c-1).map(b=>Jh({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?vo("div",{className:Fv("UserList UserList_mobile",e),children:a.map(b=>Jh({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):vo("div",{className:"UserList__wrapper",ref:m,children:pd("div",{className:Fv("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&pd(xr.Root,{children:[pd(xr.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),vo(xr.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:pd(Xe,{padding:2,children:[a.length>=O9&&vo(vs,{placeholder:g("quickSearch.placeholder"),onChange:s}),vo(Ts,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:d.length>0?[vo("div",{className:"hint",children:g("userList.hint.text")}),d.map(b=>Jh({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),vo(xr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!B9(n,i,H9))return!1}return!0});import Qh from"clsx";import{jsx as U9}from"react/jsx-runtime";var Ov=e=>U9("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Tn});import{jsx as Yo,jsxs as eg}from"react/jsx-runtime";var zv=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=ve();return eg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Yo("div",{className:Qh("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Yo(qe.Col,{gap:2,children:eg(br,{heading:"canvasActions",children:[Yo(u2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Yo(h2,{renderAction:o.renderAction,className:Qh("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Yo(n.Out,{}),Yo("div",{className:Qh("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:eg("div",{style:{position:"relative"},children:[r&&Yo(i.Out,{}),Yo(Ov,{onClick:()=>o.executeAction(Zr)})]})}),Yo(g2,{actionManager:o,showExitZenModeBtn:t})]})},Hv=zv;zv.displayName="Footer";import j9 from"clsx";import{useEffect as qv,useLayoutEffect as Jv,useRef as cg,useState as q9,forwardRef as Qv,useImperativeHandle as J9,useCallback as Zv}from"react";import{EVENT as $v,isDevEnv as Q9,KEYS as eN,updateObject as tN}from"@excalidraw/common";import W9 from"clsx";import{useContext as V9}from"react";import Y9 from"react";var hd=Y9.createContext({});import{jsx as tg,jsxs as Gv}from"react/jsx-runtime";var og=({children:e,className:o})=>{let t=se(),r=V9(hd),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return Gv("div",{className:W9("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Gv("div",{className:"sidebar__header__buttons",children:[n&&tg(Pt,{label:g("labels.sidebarLock"),children:tg(_t,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:S1})}),tg(_t,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":g("buttons.close"),children:Bt})]})]})};og.displayName="SidebarHeader";import*as Yv from"@radix-ui/react-tabs";import{jsx as Uv}from"react/jsx-runtime";var rg=({children:e,tab:o,onSelect:t,...r})=>Uv(Yv.Trigger,{value:o,asChild:!0,onSelect:t,children:Uv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});rg.displayName="SidebarTabTrigger";import*as Wv from"@radix-ui/react-tabs";import{jsx as X9}from"react/jsx-runtime";var ng=({children:e,...o})=>X9(Wv.List,{className:"sidebar-triggers",...o,children:e});ng.displayName="SidebarTabTriggers";import K9 from"clsx";import{jsx as ig,jsxs as Vv}from"react/jsx-runtime";var ag=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=le(),d=ge();return Vv("label",{title:r,className:"sidebar-trigger__label-element",children:[ig("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let c=m.target.checked;s({openSidebar:c?{name:e,tab:o}:null}),i?.(c)},checked:d.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),Vv("div",{className:K9("sidebar-trigger",a),style:l,children:[t&&ig("div",{children:t}),n&&ig("div",{className:"sidebar-trigger__label",children:n})]})]})};ag.displayName="SidebarTrigger";import*as Xv from"@radix-ui/react-tabs";import{jsx as Z9}from"react/jsx-runtime";var lg=({children:e,...o})=>{let t=ge(),r=le();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return Z9(Xv.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};lg.displayName="SidebarTabs";import*as Kv from"@radix-ui/react-tabs";import{jsx as $9}from"react/jsx-runtime";var sg=({tab:e,children:o,...t})=>$9(Kv.Content,{...t,value:e,"data-testid":e,children:o});sg.displayName="SidebarTab";import{jsx as jv}from"react/jsx-runtime";import{createElement as oN}from"react";var Qa=me(!1),e3=Qv(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{Q9()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=le(),s=jo(Qa);Jv(()=>(s(!!r),()=>{s(!1)}),[s,r]);let d=cg({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=tN(d.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=cg(null);J9(a,()=>m.current);let c=se(),p=Zv(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Dn(m,Zv(u=>{u.target.closest(".sidebar-trigger")||(!r||!c.editor.canFitSidebar)&&p()},[p,r,c.editor.canFitSidebar])),qv(()=>{let u=f=>{f.key===eN.ESCAPE&&(!r||!c.editor.canFitSidebar)&&p()};return document.addEventListener($v.KEYDOWN,u),()=>{document.removeEventListener($v.KEYDOWN,u)}},[p,r,c.editor.canFitSidebar]),jv(Xe,{...i,className:j9("sidebar",{"sidebar--docked":r},n),ref:m,children:jv(hd.Provider,{value:d.current,children:o})})});e3.displayName="SidebarInner";var Xt=Object.assign(Qv((e,o)=>{let t=ge(),{onStateChange:r}=e,n=cg(t.openSidebar);qv(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=q9(!1);return Jv(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?oN(e3,{...e,ref:o,key:e.name}):null}),{Header:og,TabTriggers:ng,TabTrigger:rg,Tabs:lg,Tab:sg,Trigger:ag});Xt.displayName="Sidebar";import{composeEventHandlers as mN}from"@excalidraw/common";import{useLayoutEffect as rN,useRef as nN}from"react";import{jsx as iN}from"react/jsx-runtime";var Wo=(e,o)=>{let t=me(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=ve(),[,a]=i(t),l=nN({preferHost:!1,counter:0});return rN(()=>{let s=l.current;return a(d=>{let m=d+1;return s.counter=m,m}),()=>{a(d=>{let m=d-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:iN(o,{...n})};return r.displayName=e,r};var pg={};Vf(pg,{ChangeCanvasBackground:()=>h3,ClearCanvas:()=>p3,CommandPalette:()=>c3,Export:()=>g3,Help:()=>m3,LiveCollaborationTrigger:()=>b3,LoadScene:()=>a3,SaveAsImage:()=>s3,SaveToActiveFile:()=>l3,SearchMenu:()=>d3,Socials:()=>f3,ToggleTheme:()=>u3});import cN from"clsx";import{THEME as Er}from"@excalidraw/common";var dg=me({active:!1});async function t3({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{ze.set(dg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import aN from"clsx";import{jsx as o3,jsxs as lN}from"react/jsx-runtime";var gd=function({onChange:e,value:o,choices:t,name:r}){return o3("div",{className:"RadioGroup",children:t.map(n=>lN("div",{className:aN("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[o3("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as sN,jsx as mg,jsxs as r3}from"react/jsx-runtime";var n3=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=se();return r3(sN,{children:[r3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[mg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),mg(gd,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&mg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};n3.displayName="DropdownMenuItemContentRadio";var i3=n3;import{Fragment as dN,jsx as je,jsxs as x3}from"react/jsx-runtime";var a3=()=>{let{t:e}=Oe(),o=Ue(),t=tr();return o.isActionEnabled(Kn)?je(pt,{icon:In,onSelect:async()=>{(!t.length||await t3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:je(ht,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>je("strong",{children:n}),br:()=>je("br",{})})}))&&o.executeAction(Kn)},"data-testid":"load-button",shortcut:Ne("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};a3.displayName="LoadScene";var l3=()=>{let{t:e}=Oe(),o=Ue();return o.isActionEnabled(Kr)?je(pt,{shortcut:Ne("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Kr),icon:G1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};l3.displayName="SaveToActiveFile";var s3=()=>{let e=le(),{t:o}=Oe();return je(pt,{icon:$l,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ne("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};s3.displayName="SaveAsImage";var c3=e=>{let o=le(),{t}=Oe();return je(pt,{icon:ea,"data-testid":"command-palette-button",onSelect:()=>{re("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Ne("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};c3.displayName="CommandPalette";var d3=e=>{let{t:o}=Oe(),t=Ue();return je(pt,{icon:Lt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(za)},shortcut:Ne("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};d3.displayName="SearchMenu";var m3=()=>{let{t:e}=Oe(),o=Ue();return je(pt,{"data-testid":"help-menu-item",icon:Tn,onSelect:()=>o.executeAction(Zr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};m3.displayName="Help";var p3=()=>{let{t:e}=Oe(),o=jo(Jr);return Ue().isActionEnabled(_o)?je(pt,{icon:Mt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};p3.displayName="ClearCanvas";var u3=e=>{let{t:o}=Oe(),t=ge(),r=Ue(),n=Ne("toggleTheme");return r.isActionEnabled(Yr)?e?.allowSystemTheme?je(i3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Er.LIGHT,label:ji,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:Er.DARK,label:$i,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:rb,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):je(pt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Er.DARK?Er.LIGHT:Er.DARK);else return r.executeAction(Yr)},icon:t.theme===Er.DARK?ji:$i,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===Er.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Er.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};u3.displayName="ToggleTheme";var h3=()=>{let{t:e}=Oe(),o=ge(),t=Ue(),r=fo();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:x3("div",{style:{marginTop:"0.5rem"},children:[je("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),je("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};h3.displayName="ChangeCanvasBackground";var g3=()=>{let{t:e}=Oe(),o=le();return je(pt,{icon:Fr,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};g3.displayName="Export";var f3=()=>{let{t:e}=Oe();return x3(dN,{children:[je(mi,{icon:Kl,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),je(mi,{icon:z1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),je(mi,{icon:O1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};f3.displayName="Socials";var b3=({onSelect:e,isCollaborating:o})=>{let{t}=Oe();return je(pt,{"data-testid":"collab-button",icon:jl,className:cN({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};b3.displayName="LiveCollaborationTrigger";import{jsx as fd,jsxs as ug}from"react/jsx-runtime";var pN=Object.assign(Wo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=ve(),r=se(),n=ge(),i=le(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return fd(t.In,{children:ug(fe,{open:n.openMenu==="canvas",children:[fd(fe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Xl}),ug(fe.Content,{onClickOutside:a,onSelect:mN(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&ug("fieldset",{className:"UserList-Wrapper",children:[fd("legend",{children:g("labels.collaborators")}),fd(ud,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:fe.Trigger,Item:fe.Item,ItemLink:fe.ItemLink,ItemCustom:fe.ItemCustom,Group:fe.Group,Separator:fe.Separator,DefaultItems:pg}),dt=pN;import uN from"clsx";import{forwardRef as hN,useState as gN}from"react";import{isPromiseLike as fN}from"@excalidraw/common";import{jsx as bd,jsxs as bN}from"react/jsx-runtime";var yr=hN(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d},m)=>{let[c,p]=gN(!1),u=async b=>{let x=t?.(b);if(fN(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof hn)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=c?"loading":d;return i=f==="success"?"success":i,bd("button",{className:uN("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:f==="loading"||f==="success",children:bN("div",{className:"ExcButton__contents",children:[f==="loading"?bd(tt,{className:"ExcButton__statusIcon"}):f==="success"&&bd("div",{className:"ExcButton__statusIcon",children:O0}),o&&bd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as ki,jsxs as yN}from"react/jsx-runtime";var xd=({title:e,children:o,actionLabel:t,onClick:r})=>yN("div",{className:"OverwriteConfirm__Actions__Action",children:[ki("h4",{children:e}),ki("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ki(yr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),xN=()=>{let{t:e}=Oe(),o=Ue(),t=le();return ki(xd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Xs,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},EN=()=>{let{t:e}=Oe(),o=Ue();return ki(xd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Ta,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},hg=Object.assign(({children:e})=>ki("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:xN,SaveToDisk:EN});import{jsx as wr,jsxs as E3}from"react/jsx-runtime";var Ed=Object.assign(Wo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=ve(),[t,r]=ie(dg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return wr(o.In,{children:wr(Be,{onCloseRequest:n,title:!1,size:916,children:E3("div",{className:"OverwriteConfirm",children:[wr("h3",{children:t.title}),E3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[wr("div",{className:"OverwriteConfirm__Description__icon",children:z0}),wr("div",{children:t.description}),wr("div",{className:"OverwriteConfirm__Description__spacer"}),wr(yr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),wr(hg,{children:e})]})})})}),{Actions:hg,Action:xd});import UN from"clsx";import{CANVAS_SEARCH_TAB as Eg,DEFAULT_SIDEBAR as YN,LIBRARY_SIDEBAR_TAB as L3,composeEventHandlers as WN}from"@excalidraw/common";import{round as wN}from"@excalidraw/math";import vN from"clsx";import TN from"lodash.debounce";import{Fragment as IN,memo as CN,useEffect as el,useMemo as y3,useRef as gg,useState as w3}from"react";import{CLASSES as SN,EVENT as kN,FONT_FAMILY as fg,FRAME_STYLE as bg,getLineHeight as MN}from"@excalidraw/common";import{isElementCompletelyInViewport as LN}from"@excalidraw/element";import{measureText as tl}from"@excalidraw/element";import{KEYS as Mi,randomInteger as v3,addEventListener as PN,getFontString as yd}from"@excalidraw/common";import{newTextElement as AN}from"@excalidraw/element";import{isTextElement as S3,isFrameLikeElement as wd}from"@excalidraw/element";import{getDefaultFrameName as k3}from"@excalidraw/element/frame";import{Fragment as GN,jsx as Je,jsxs as To}from"react/jsx-runtime";var DN=me(""),xg=me(null),_N=350,M3=()=>{let e=Re(),o=le(),t=gg(null),[r,n]=ie(DN),i=r.trim(),[a,l]=w3(!1),[s,d]=w3({nonce:null,items:[]}),m=gg(null),c=gg(void 0),[p,u]=ie(xg),f=e.scene.getNonDeletedElementsMap();el(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==c.current)&&(m.current=null,C3(i,e,(y,v)=>{d({nonce:v3(),items:y}),m.current=i,c.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,c]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};el(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),el(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=AN({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:wd(y.element)?bg.nameFontSize:y.element.fontSize,fontFamily:wd(y.element)?fg.Assistant:y.element.fontFamily}),S=14,L=C.fontSize,k=L*v<S;if(!LN([C],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||k){let A;k?L>=S?A={fitToContent:!0}:A={fitToViewport:!0,maxZoom:wN(S/L,1)}:A={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...A,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),el(()=>()=>{u(null),m.current=null,c.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=Jo({goToNextItem:b,goToPreviousItem:x,searchMatches:s});el(()=>{let y=v=>{if(v.key===Mi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[Mi.CTRL_OR_CMD]&&v.key===Mi.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===Mi.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===Mi.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===Mi.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return PN(window,kN.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return To("div",{className:"layer-ui__search",children:[Je("div",{className:"layer-ui__search-header",children:Je(hi,{className:SN.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:g("search.placeholder"),icon:Lt,onChange:y=>{n(y),l(!0);let v=y.trim();C3(v,e,(C,S)=>{d({nonce:v3(),items:C}),u(S),m.current=v,c.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(L=>({id:L.element.id,focus:!1,matchedLines:L.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),To("div",{className:"layer-ui__search-count",children:[s.items.length>0&&To(GN,{children:[p!==null&&p>-1?To("div",{children:[p+1," / ",E]}):Je("div",{children:E}),To("div",{className:"result-nav",children:[Je(_t,{onSelect:()=>{b()},className:"result-nav-btn",children:as}),Je(_t,{onSelect:()=>{x()},className:"result-nav-btn",children:sb})]})]}),s.items.length===0&&i&&m.current&&Je("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),Je(BN,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},T3=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return Je("div",{tabIndex:-1,className:vN("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Je("div",{className:"preview-text",children:o.flatMap((t,r)=>Je(IN,{children:r===2?Je("b",{children:t}):t},r))})})},RN=e=>{let o=y3(()=>e.matches.items.filter(r=>wd(r.element)),[e.matches]),t=y3(()=>e.matches.items.filter(r=>S3(r.element)),[e.matches]);return To("div",{children:[o.length>0&&To("div",{className:"layer-ui__search-result-container",children:[To("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:zr}),Je("div",{children:g("search.frames")})]}),o.map((r,n)=>Je(T3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&Je("div",{className:"layer-ui__divider"})]}),t.length>0&&To("div",{className:"layer-ui__search-result-container",children:[To("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:vn}),Je("div",{children:g("search.texts")})]}),t.map((r,n)=>Je(T3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},NN=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,BN=CN(RN,NN),I3=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),d=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;d=d.length>m?d.slice(-m):d;let c=e.slice(o+t.length),p=c.split(/\s+/),u=!c.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:d.length,previewText:d+t+b,moreBefore:s>0,moreAfter:p.length>f}},FN=(e,o)=>{let t=e.split(`
|
|
15
|
+
C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,qo(e,!0))}else i=o.polygon([[a,l],[s,d],[m,c],[p,u]],qo(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,qo(e));case"line":case"arrow":{let i,a=qo(e),l=e.points.length?e.points:[$D(0,0)];if(Sl(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(o_(l,16),qo(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:d="arrow"}=e;if(s!==null){let m=U2(e,i,"start",s,o,a,r);i.push(...m)}if(d!==null){let m=U2(e,i,"end",d,o,a,r);i.push(...m)}}return i}case"freedraw":{let i;if(O2(e),hd(e.points)){let a=KD(e.points,.75);i=o.curve(a,{...qo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return jD(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},o_=(e,o)=>{let t=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],l=e[n],s=xd(l,i),d=xd(a,l),m=Math.min(o,H2(e[n],a)/2,H2(e[n],i)/2);s?i[0]<l[0]?t.push([e[n][0]-m,e[n][1]]):t.push([e[n][0]+m,e[n][1]]):i[1]<l[1]?t.push([e[n][0],e[n][1]-m]):t.push([e[n][0],e[n][1]+m]),t.push(e[n]),d?a[0]<l[0]?t.push([e[n][0]-m,e[n][1]]):t.push([e[n][0]+m,e[n][1]]):a[1]<l[1]?t.push([e[n][0],e[n][1]-m]):t.push([e[n][0],e[n][1]+m])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<t.length;n+=3)r.push(`L ${t[n][0]} ${t[n][1]}`),r.push(`Q ${t[n+1][0]} ${t[n+1][1]}, ${t[n+2][0]} ${t[n+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(" ")};var W2=(e,o,t=!1)=>{let r=!1;for(let n in o){let i=o[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;r=!0}}return!r&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??r_(),updated:n_()}};import{jsx as X2}from"react/jsx-runtime";var ji=O({name:"toggleLinearEditor",category:Le.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&a_(n[0])&&!i_(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];$h(n,"No selected element found"),$h(o.selectedLinearElement,"No selected linear element found"),$h(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:V2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!r)return null;let n=g(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return X2(K,{type:"button",icon:B0,title:n,"aria-label":n,onClick:()=>o(null)})}}),O0e=O({name:"togglePolygon",category:Le.elements,icon:Km,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Zi(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>Zi(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!Zi(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=l_(i);return{elements:e.map(s=>!l.has(s.id)||!Zi(s)?s:W2(s,{backgroundColor:a?s.backgroundColor:"transparent",...s_(s,a)})),appState:o,captureUpdate:V2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!Zi(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>Zi(a)&&a.polygon),i=g(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return X2(ri,{icon:Km,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as K2,CANVAS_SEARCH_TAB as $2,CLASSES as c_,DEFAULT_SIDEBAR as Z2}from"@excalidraw/common";import{CaptureUpdateAction as d_}from"@excalidraw/element";var Il=O({name:"searchMenu",icon:Rt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===Z2.name&&o.openSidebar.tab===$2){let n=r.excalidrawContainerValue.container?.querySelector(`.${c_.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:Z2.name,tab:$2},openDialog:null},captureUpdate:d_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[K2.CTRL_OR_CMD]&&e.key===K2.F});import{isImageElement as m_}from"@excalidraw/element";import{CaptureUpdateAction as p_}from"@excalidraw/element";import{jsx as u_}from"react/jsx-runtime";var Zh=O({name:"cropEditor",label:"helpDialog.cropStart",icon:hp,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:p_.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&m_(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=g("helpDialog.cropStart");return u_(K,{type:"button",icon:hp,title:r,"aria-label":r,onClick:()=>o(null)})}});import{getNonDeletedElements as h_}from"@excalidraw/element";import{mutateElement as g_}from"@excalidraw/element";import{newFrameElement as f_}from"@excalidraw/element";import{isFrameLikeElement as vd}from"@excalidraw/element";import{addElementsToFrame as b_,removeAllElementsFromFrame as x_}from"@excalidraw/element";import{getFrameChildren as E_}from"@excalidraw/element";import{KEYS as j2,updateActiveTool as q2}from"@excalidraw/common";import{getElementsInGroup as y_}from"@excalidraw/element";import{getCommonBounds as w_}from"@excalidraw/element";import{CaptureUpdateAction as yn}from"@excalidraw/element";var J2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&vd(t[0])},Q2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(vd(n)){let i=E_(h_(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:yn.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:yn.EVENTUALLY}},predicate:(e,o,t,r)=>J2(o,r)}),ev=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return vd(n)?{elements:x_(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:yn.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:yn.EVENTUALLY}},predicate:(e,o,t,r)=>J2(o,r)}),Kxe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:yn.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),$xe=O({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:ao,viewMode:!1,perform:(e,o,t,r)=>{let n=q2(o,{type:"frame"});return Bt(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:q2(o,{type:"frame"})},captureUpdate:yn.EVENTUALLY}},keyTest:e=>!e[j2.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===j2.F}),tv=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=Q(e,o);return n.length>0&&!n.some(i=>vd(i))},perform:(e,o,t,r)=>{let n=Q(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,d]=w_(n,i),m=16,c=f_({x:a-m,y:l-m,width:s-a+m*2,height:d-l+m*2});if(o.editingGroupId){let u=y_(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);g_(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:b_([...r.scene.getElementsIncludingDeleted(),c],n,c,o),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:yn.IMMEDIATELY}}});import{isWindows as M_,KEYS as Al,matchKey as Jh,arrayToMap as ov,MOBILE_ACTION_BUTTON_BG as rv}from"@excalidraw/common";import{CaptureUpdateAction as qh}from"@excalidraw/element";import{orderByFractionalIndex as P_}from"@excalidraw/element";import{Emitter as v_}from"@excalidraw/common";import{CaptureUpdateAction as T_,StoreChange as I_,StoreDelta as C_}from"@excalidraw/element";var qi=class extends C_{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},wn=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Ll=class e{constructor(o){this.store=o;C(this,"onHistoryChangedEmitter",new v_);C(this,"undoStack",[]);C(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof qi)return;let t=qi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new wn(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=T_.IMMEDIATELY,l=this.store.snapshot,s=o,d=t,m=!1;for(;i;){try{[s,d,m]=i.applyTo(s,d,l);let c=l.elements,p=l.maybeClone(a,s,d),u=I_.create(l,p),f=qi.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(m)break;i=r()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new wn(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=qi.inverse(t);return o.push(r)}};import{useEffect as S_,useState as k_}from"react";var jh=(e,o)=>{let[t,r]=k_(o);return S_(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as lv}from"react/jsx-runtime";var nv=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:qh.EVENTUALLY};let[n,i]=r,a=P_(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:qh.NEVER}}return{captureUpdate:qh.EVENTUALLY}},iv=e=>({name:"undo",label:"buttons.undo",icon:qm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>nv(n,t,()=>e.undo(ov(o),t)),keyTest:o=>o[Al.CTRL_OR_CMD]&&Jh(o,Al.Z)&&!o.shiftKey,PanelComponent:({appState:o,updateData:t,data:r,app:n})=>{let{isUndoStackEmpty:i}=jh(e.onHistoryChangedEmitter,new wn(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=et()==="mobile";return lv(K,{type:"button",icon:qm,"aria-label":g("buttons.undo"),onClick:t,size:r?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?rv:{}}})}}),av=e=>({name:"redo",label:"buttons.redo",icon:Jm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>nv(n,t,()=>e.redo(ov(o),t)),keyTest:o=>o[Al.CTRL_OR_CMD]&&o.shiftKey&&Jh(o,Al.Z)||M_&&o.ctrlKey&&!o.shiftKey&&Jh(o,Al.Y),PanelComponent:({appState:o,updateData:t,data:r,app:n})=>{let{isRedoStackEmpty:i}=jh(e.onHistoryChangedEmitter,new wn(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=et()==="mobile";return lv(K,{type:"button",icon:Jm,"aria-label":g("buttons.redo"),onClick:t,size:r?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?rv:{}}})}});import{getFontString as L_}from"@excalidraw/common";import{newElementWith as A_}from"@excalidraw/element";import{measureText as D_}from"@excalidraw/element";import{isTextElement as sv}from"@excalidraw/element";import{CaptureUpdateAction as __}from"@excalidraw/element";var cv=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=Q(e,o);return n.length===1&&sv(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=Q(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&sv(i)){let a=D_(i.originalText,L_(i),i.lineHeight);return A_(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:__.IMMEDIATELY}}});import{CODES as R_,KEYS as N_}from"@excalidraw/common";import{CaptureUpdateAction as B_}from"@excalidraw/element";var Qh=O({name:"viewMode",label:"labels.viewMode",icon:qn,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:B_.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[N_.CTRL_OR_CMD]&&e.altKey&&e.code===R_.R});import{isPromiseLike as F_}from"@excalidraw/common";import{jsx as O_}from"react/jsx-runtime";var eg=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&ae(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Td=class{constructor(o,t,r,n){C(this,"actions",{});C(this,"updater");C(this,"getAppState");C(this,"getElementsIncludingDeleted");C(this,"app");C(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=d=>{eg(n,"ui",l,a,this.app,d),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),d,this.app))};return O_(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});C(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(F_(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,d)=>(d.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return eg(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();eg(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Id=class{constructor(){C(this,"targets",new WeakMap);C(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var tg=e=>{let o=Array.from(e.values());return{x:dv(o,t=>t.x)/o.length,y:dv(o,t=>t.y)/o.length}},og=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),dv=(e,o)=>e.reduce((t,r)=>t+o(r),0);import{pointFrom as U,pointRotateRads as Dr,rangeInclusive as Zt,rangeIntersection as Cd,rangesOverlap as Sd}from"@excalidraw/math";import{TOOL_TYPE as vn,KEYS as mv}from"@excalidraw/common";import{getCommonBounds as rg,getDraggedElementsBounds as ng,getElementAbsoluteCoords as z_}from"@excalidraw/element";import{isBoundToContainer as gv}from"@excalidraw/element";import{getMaximumGroups as fv}from"@excalidraw/element";import{getSelectedElements as H_,getVisibleAndNonSelectedElements as bv}from"@excalidraw/element";var G_=8,pv=99999,kd=e=>G_/e,wt=class wt{};C(wt,"referenceSnapPoints",null),C(wt,"visibleGaps",null),C(wt,"setReferenceSnapPoints",o=>{wt.referenceSnapPoints=o}),C(wt,"getReferenceSnapPoints",()=>wt.referenceSnapPoints),C(wt,"setVisibleGaps",o=>{wt.visibleGaps=o}),C(wt,"getVisibleGaps",()=>wt.visibleGaps),C(wt,"destroy",()=>{wt.referenceSnapPoints=null,wt.visibleGaps=null});var jt=wt,_r=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Qo=({event:e,app:o,selectedElements:t})=>{if(e){let r=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||r)&&(o.state.objectsSnapModeEnabled&&!e[mv.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[mv.CTRL_OR_CMD]&&!_r(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},U_=(e,o,t=.01)=>Math.abs(e-o)<=t,Dl=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,m,c,p]=z_(a,o);n&&(l+=n.x,d+=n.x,c+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(d-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=Dr(U(l,s+f),U(c,p),a.angle),x=Dr(U(l+u,s),U(c,p),a.angle),w=Dr(U(d,s+f),U(c,p),a.angle),E=Dr(U(l+u,m),U(c,p),a.angle),y=U(c,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=Dr(U(l,s),U(c,p),a.angle),x=Dr(U(d,s),U(c,p),a.angle),w=Dr(U(l,m),U(c,p),a.angle),E=Dr(U(d,m),U(c,p),a.angle),y=U(c,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,d]=ng(e,n??{x:0,y:0}),m=s-a,c=d-l,p=U(a,l),u=U(s,l),f=U(a,d),b=U(s,d),x=U(a+m/2,l+c/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>U(De(a[0]),De(a[1])))},xv=(e,o,t,r)=>bv(e,o,t,r),Ev=(e,o,t,r)=>{let n=xv(e,o,t,r),i=fv(n,r).filter(c=>!(c.length===1&&gv(c[0]))).map(c=>rg(c).map(p=>De(p))),a=i.sort((c,p)=>c[0]-p[0]),l=[],s=0;e:for(let c=0;c<a.length;c++){let p=a[c];for(let u=c+1;u<a.length;u++){if(++s>pv)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Sd(Zt(b,w),Zt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[U(x,b),U(x,w)],endSide:[U(E,y),U(E,v)],length:E-x,overlap:Cd(Zt(b,w),Zt(y,v))})}}let d=i.sort((c,p)=>c[1]-p[1]),m=[];s=0;e:for(let c=0;c<d.length;c++){let p=d[c];for(let u=c+1;u<d.length;u++){if(++s>pv)break e;let f=d[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Sd(Zt(b,x),Zt(E,v))&&m.push({startBounds:p,endBounds:f,startSide:[U(b,w),U(x,w)],endSide:[U(E,y),U(v,y)],length:y-w,overlap:Cd(Zt(b,x),Zt(E,v))})}}return{horizontalGaps:l,verticalGaps:m}},uv=(e,o,t,r,n,i,a)=>{if(!Qo({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=jt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[m,c,p,u]=ng(e,o).map(x=>De(x)),f=(m+p)/2,b=(c+u)/2;for(let x of s){if(!Sd(Zt(c,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=De(w-f);if(x.length>p-m&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(n.length=0),a.x=Math.abs(E);let A={type:"gap",direction:"center_horizontal",gap:x,offset:E};n.push(A);continue}let[,,v]=x.endBounds,I=m-v,k=De(x.length-I);if(Math.abs(k)<=a.x){Math.abs(k)<a.x&&(n.length=0),a.x=Math.abs(k);let A={type:"gap",direction:"side_right",gap:x,offset:k};n.push(A);continue}let[P,,,]=x.startBounds,S=P-p,B=De(S-x.length);if(Math.abs(B)<=a.x){Math.abs(B)<a.x&&(n.length=0),a.x=Math.abs(B);let A={type:"gap",direction:"side_left",gap:x,offset:B};n.push(A);continue}}for(let x of d){if(!Sd(Zt(m,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=De(w-b);if(x.length>u-c&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let A={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(A);continue}let[,v,,]=x.startBounds,I=v-u,k=De(I-x.length);if(Math.abs(k)<=a.y){Math.abs(k)<a.y&&(i.length=0),a.y=Math.abs(k);let A={type:"gap",direction:"side_top",gap:x,offset:k};i.push(A);continue}let[,,,P]=x.endBounds,S=De(c-P),B=x.length-S;if(Math.abs(B)<=a.y){Math.abs(B)<a.y&&(i.length=0),a.y=Math.abs(B);let A={type:"gap",direction:"side_bottom",gap:x,offset:B};i.push(A);continue}}}},yv=(e,o,t,r)=>{let n=xv(e,o,t,r);return fv(n,r).filter(i=>!(i.length===1&&gv(i[0]))).flatMap(i=>Dl(i,r))},Ji=(e,o,t,r,n,i,a)=>{if(!Qo({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=jt.getReferenceSnapPoints();if(l)for(let s of o)for(let d of l){let m=d[0]-s[0],c=d[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(n.length=0),n.push({type:"point",points:[s,d],offset:m}),a.x=Math.abs(m)),Math.abs(c)<=a.y&&(Math.abs(c)<a.y&&(i.length=0),i.push({type:"point",points:[s,d],offset:c}),a.y=Math.abs(c))}},wv=(e,o,t,r,n)=>{let i=t.state,a=H_(e,i);if(!Qo({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=De(o.x),o.y=De(o.y);let l=[],s=[],d=kd(i.zoom.value),m={x:d,y:d},c=Dl(a,n,{dragOffset:o});Ji(a,c,t,r,l,s,m),uv(a,o,t,r,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:De(o.x+p.x),y:De(o.y+p.y)};Ji(a,Dl(a,n,{dragOffset:u}),t,r,l,s,m),uv(a,u,t,r,l,s,m);let f=ig(l,s),b=W_(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},De=e=>Math.round(e*10**6)/10**6,hv=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},ig=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=De(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>U(De(a[0]),De(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=De(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>U(De(a[0]),De(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:hv(i.map(a=>U(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:hv(i.map(a=>U(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},Y_=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[De(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},W_=(e,o,t)=>{let[r,n,i,a]=ng(e,o),l=[];for(let s of t){let[d,m,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Cd(Zt(n,a),s.gap.overlap),E=Cd(Zt(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(s.gap.startSide[0][0],y),U(r,y)]},{type:"gap",direction:"horizontal",points:[U(i,y),U(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[U(y,s.gap.startSide[0][1]),U(y,n)]},{type:"gap",direction:"vertical",points:[U(y,a),U(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(c,y),U(u,y)]},{type:"gap",direction:"horizontal",points:[U(b,y),U(r,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(i,y),U(d,y)]},{type:"gap",direction:"horizontal",points:[U(c,y),U(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[U(y,a),U(y,m)]},{type:"gap",direction:"vertical",points:[U(y,p),U(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[U(y,p),U(y,f)]},{type:"gap",direction:"vertical",points:[U(y,x),U(y,n)]})}break}}}return Y_(l.map(s=>({...s,points:s.points.map(d=>U(De(d[0]),De(d[1])))})))},ag=(e,o,t,r,n,i)=>{if(!Qo({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!U_(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=rg(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(d+=n.y));let m=[];if(i)switch(i){case"e":{m.push(U(s,l),U(s,d));break}case"w":{m.push(U(a,l),U(a,d));break}case"n":{m.push(U(a,l),U(s,l));break}case"s":{m.push(U(a,d),U(s,d));break}case"ne":{m.push(U(s,l));break}case"nw":{m.push(U(a,l));break}case"se":{m.push(U(s,d));break}case"sw":{m.push(U(a,d));break}}let c=kd(t.state.zoom.value),p={x:c,y:c},u=[],f=[];Ji(o,m,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=rg(e).map(k=>De(k)),v=[U(x,w),U(x,y),U(E,w),U(E,y)];Ji(e,v,t,r,u,f,p);let I=ig(u,f);return{snapOffset:b,snapLines:I}},vv=(e,o,t,r,n,i)=>{if(!Qo({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[U(r.x+n.x,r.y+n.y)],l=kd(o.state.zoom.value),s={x:l,y:l},d=[],m=[];Ji([e],a,o,t,d,m,s);let c={x:d[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,d.length=0,m.length=0;let p=Dl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ji([e],p,o,t,d,m,s);let u=ig(d,m);return{snapOffset:c,snapLines:u}},Tv=(e,o,t,r,n)=>{if(!Qo({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=bv(e,[],o.state,n),a=kd(o.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let m of i){let c=Dl([m],n);for(let p of c){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(d.length=0),d.push({type:"pointer",points:[p,U(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,U(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:d.length>0?d[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...d,...s]}},Iv=e=>e===vn.rectangle||e===vn.ellipse||e===vn.diamond||e===vn.frame||e===vn.magicframe||e===vn.image||e===vn.text;import{pointFrom as Md}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as V_,DEFAULT_FONT_SIZE as X_,TEXT_ALIGN as K_,VERTICAL_ALIGN as $_,getSizeFromPoints as Z_,randomId as j_,arrayToMap as q_,assertNever as lg,cloneJSON as kv,getFontString as J_,isDevEnv as Q_,toBrandedType as eR,getLineHeight as tR}from"@excalidraw/common";import{bindLinearElement as Cv}from"@excalidraw/element";import{newArrowElement as oR,newElement as sg,newFrameElement as rR,newImageElement as nR,newLinearElement as iR,newMagicFrameElement as aR,newTextElement as Ld}from"@excalidraw/element";import{measureText as lR,normalizeText as sR}from"@excalidraw/element";import{isArrowElement as cR}from"@excalidraw/element";import{syncInvalidIndices as dR}from"@excalidraw/element";import{redrawTextBoundingBox as mR}from"@excalidraw/element";import{LinearElementEditor as pR}from"@excalidraw/element";import{getCommonBounds as uR}from"@excalidraw/element";import{Scene as hR}from"@excalidraw/element";var Pd={width:100,height:0},Rr=100,gR=(e,o,t)=>{let r=Ld({x:0,y:0,textAlign:K_.CENTER,verticalAlign:$_.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),mR(r,e,t),[e,r]},Sv=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??Rr,c=o?.height??Rr,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-m,f=o.y||e.y-c/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Ld({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=sg({x:u,y:f,width:m,height:c,...p,...o,type:b});break}default:lg(e,`Unhandled element start type "${o.type}"`,!0)}Cv(e,i,"start",n)}}if(t){let m=t?.height??Rr,c=t?.width??Rr,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-m/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Ld({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=sg({x:u,y:f,width:c,height:m,...p,...t,type:b});break}default:lg(e,`Unhandled element end type "${b}"`,!0)}Cv(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,d=kv(e.points);return e.points[l][0]>e.points[l-1][0]&&(d[0][0]=s,d[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(d[0][0]=-s,d[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(d[0][1]=s,d[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(d[0][1]=-s,d[l][1]+=s),Object.assign(e,pR.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:i,endBoundElement:a}},cg=class{constructor(){C(this,"excalidrawElements",new Map);C(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});C(this,"getElements",()=>dR(Array.from(this.excalidrawElements.values())));C(this,"getElementsMap",()=>eR(q_(this.getElements())));C(this,"getElement",o=>this.excalidrawElements.get(o))}},Qi=(e,o)=>{if(!e)return[];let t=kv(e),r=new cg,n=new Map,i=new Map;for(let s of t){let d,m=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:j_()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||Rr,u=s?.label?.text&&s.height===void 0?0:s?.height||Rr;d=sg({...s,width:p,height:u});break}case"line":{let p=s.width||Pd.width,u=s.height||Pd.height;d=iR({width:p,height:u,points:[Md(0,0),Md(p,u)],...s});break}case"arrow":{let p=s.width||Pd.width,u=s.height||Pd.height;d=oR({width:p,height:u,endArrowhead:"arrow",points:[Md(0,0),Md(p,u)],...s,type:"arrow"}),Object.assign(d,Z_(d.points));break}case"text":{let p=s?.fontFamily||V_,u=s?.fontSize||X_,f=s?.lineHeight||tR(p),b=s.text??"",x=sR(b),w=lR(x,J_({fontFamily:p,fontSize:u}),f);d=Ld({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{d=nR({width:s?.width||Rr,height:s?.height||Rr,...s});break}case"frame":{d=rR({x:0,y:0,...s});break}case"magicframe":{d=aR({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{d=s;break}default:d=s,lg(s,`Unhandled element type "${s.type}"`,!0)}r.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(r.add(d),n.set(d.id,s),m&&i.set(m,d.id))}let a=r.getElementsMap(),l=new hR(a);for(let[s,d]of n){let m=r.getElement(s);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[c,p]=gR(m,d?.label,l);if(r.add(c),r.add(p),cR(c)){let u=d.type==="arrow"?d?.start:void 0,f=d.type==="arrow"?d?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=Sv(c,u,f,r,l);c=b,r.add(b),r.add(x),r.add(w)}}else switch(d.type){case"arrow":{let{start:c,end:p}=d;if(c&&c.id){let x=i.get(c.id);Object.assign(c,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=Sv(m,c,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,d]of n){if(d.type!=="frame"&&d.type!=="magicframe")continue;let m=r.getElement(s);if(!m)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let c=[];d.children.forEach(I=>{let k=i.get(I);if(!k)throw new Error(`Element with ${I} wasn't mapped correctly`);let P=r.getElement(k);if(!P)throw new Error(`Frame element with id ${k} doesn't exist`);Object.assign(P,{frameId:m.id}),P?.boundElements?.forEach(S=>{let B=r.getElement(S.id);if(!B)throw new Error(`Bound element with id ${S.id} doesn't exist`);Object.assign(B,{frameId:m.id}),c.push(B)}),c.push(P)});let[p,u,f,b]=uR(c),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=m?.x||p,E=m?.y||u,y=m?.width||f-p,v=m?.height||b-u;Object.assign(m,{x:w,y:E,width:y,height:v}),Q_()&&d.children.length&&(m?.x||m?.y||m?.width||m?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import{isElementInViewport as VR}from"@excalidraw/element";import{memoize as XR,toBrandedType as KR}from"@excalidraw/common";import{pointFrom as TR,pointsEqual as IR}from"@excalidraw/math";import Dd from"open-color";import{arrayToMap as CR,DEFAULT_TRANSFORM_HANDLE_SPACING as bg,FRAME_STYLE as Rv,invariant as Nv,THEME as SR,throttleRAF as kR}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as mg,maxBindingGap as Gv}from"@excalidraw/element";import{LinearElementEditor as Nr}from"@excalidraw/element";import{getOmitSidesForEditorInterface as pg,getTransformHandles as MR,getTransformHandlesFromCoords as PR,hasBoundingBox as LR}from"@excalidraw/element";import{isElbowArrow as _l,isFrameLikeElement as Bv,isImageElement as Fv,isLinearElement as AR,isLineElement as DR,isTextElement as Ov}from"@excalidraw/element";import{renderSelectionElement as _R}from"@excalidraw/element";import{getElementsInGroup as gg,getSelectedGroupIds as RR,isSelectedViaGroup as NR,selectGroupsFromGivenElements as BR}from"@excalidraw/element";import{getCommonBounds as fg,getElementAbsoluteCoords as Rl}from"@excalidraw/element";import{pointFrom as ut}from"@excalidraw/math";import{THEME as fR}from"@excalidraw/common";var bR="#ff6b6b",xR="#ff0000",Mv=1,Pv=2,Lv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===fR.LIGHT||o.zenModeEnabled?bR:xR,r=(o.zenModeEnabled?Mv*1.5:Mv)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,yR(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,wR(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,ER(n,e,o));e.restore()},ER=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];qt(r,n,o)}for(let r of e.points)Av(r,t,o)},yR=(e,o,t)=>{Av(e.points[0],t,o),t.zenModeEnabled||qt(e.points[0],e.points[1],o)},Av=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?Pv*1.5:Pv)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},qt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},wR=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||qt(ut(e[0],e[1]-i),ut(e[0],e[1]+i),n),qt(ut(s[0]-l,s[1]-a),ut(s[0]-l,s[1]+a),n),qt(ut(s[0]+l,s[1]-a),ut(s[0]+l,s[1]+a),n),r.zenModeEnabled||(qt(ut(o[0],o[1]-i),ut(o[0],o[1]+i),n),qt(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||qt(ut(e[0]-i,e[1]),ut(e[0]+i,e[1]),n),qt(ut(s[0]-a,s[1]-l),ut(s[0]+a,s[1]-l),n),qt(ut(s[0]-a,s[1]+l),ut(s[0]+a,s[1]+l),n),r.zenModeEnabled||(qt(ut(o[0]-i,o[1]),ut(o[0]+i,o[1]),n),qt(e,o,n))}};import{getGlobalCSSVariable as Ad}from"@excalidraw/common";import{getCommonBounds as vR}from"@excalidraw/element";var er=4,Jt=6,Dv="rgba(0,0,0,0.3)",_v=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=vR(e),s=o/r.zoom.value,d=t/r.zoom.value,m={top:parseInt(Ad("sat"))||0,bottom:parseInt(Ad("sab"))||0,left:parseInt(Ad("sal"))||0,right:parseInt(Ad("sar"))||0},c=Ho().rtl,p=-r.scrollX+m.left,u=-r.scrollY+m.top,f=p+s-m.right,b=u+d-m.bottom,x=Math.min(n,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-n,I=l-i,k=E-x,P=y-w,S=Math.max(er*2,m.left+m.right)+Jt*2,B=o*(s/k)-S,A=Math.max(er*2,m.top+m.bottom)+Jt*2,L=t*(d/P)-A,R=k>v?k*r.zoom.value/(B+S):o/(B+S),Y=P>I?P*r.zoom.value/(L+A):t/(L+A);return{horizontal:p===x&&f===E?null:{x:Math.max(m.left,er)+Jt+(p-x)/k*o,y:t-Jt-Math.max(er,m.bottom),width:B,height:Jt,deltaMultiplier:R},vertical:u===w&&b===y?null:{x:c?Math.max(m.left,er):o-Jt-Math.max(m.right,er),y:Math.max(m.top,er)+Jt+(u-w)/P*t,width:Jt,height:L,deltaMultiplier:Y}}},dg=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var FR=(e,o)=>{Nv(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;Nv(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Uv(t,e,o),e.restore()},OR=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let i=Nr.getElement(r,t);if(!i)return;let a=Nr.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Uv(a,e,o),e.restore()},Uv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Ta(o,e[0],e[1],Nr.POINT_HANDLE_SIZE/t.zoom.value,!1)},ug=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Ta(e,t[0],t[1],(a?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!i,!a||n)},zR=(e,o,t,r)=>{let n=Gv(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":R1(e,o,t,n);break;case"diamond":B1(e,n,o,t);break;case"ellipse":{let[i,a,l,s]=Rl(o,t),d=l-i,m=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=n-mg,N1(e,d+n+mg,m+n+mg,i+d/2,a+m/2,o.angle);break}}},HR=(e,o,t,r)=>{let[n,i,a]=o,l=Gv(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(d=>{let[m,c]=Nr.getPointAtIndexGlobalCoordinates(n,d,t);Ta(e,m,c,l,!0)})},Yv=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:m,dashed:c,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??bg*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],c&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,Ia(e,n-x,i-x,u+x*2,f+x*2,d,m,r);e.restore()},GR=(e,o,t,r)=>{let n=Array.isArray(t)?HR:zR;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},UR=(e,o,t,r)=>{let[n,i,a,l]=Rl(t,r),s=a-n,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Rv.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Ia(e,n,i,s,d,n+s/2,i+d/2,t.angle,!1,Rv.radius/o.zoom.value),e.restore()},zv=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[c,p,u,f]=fg(m);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},d=m=>{let c=gg(t,m);return s(c)};Object.entries(BR(l,o)).filter(([m,c])=>c).map(([m,c])=>m).map(m=>d(m)).concat(a.map(m=>s([m]))).forEach(m=>Yv(e,o,m))},hg=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=Nr.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=Nr,a=o.selectedLinearElement?.isEditing?i:i/2,l=_l(t),s=DR(t);if(n.forEach((d,m)=>{if(l&&m!==0&&m!==n.length-1)return;let c=m>0&&(m!==n.length-1||!s||!t.polygon)&&IR(d,m===n.length-1?n[0]:n[m-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!p&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),ug(e,o,d,a,p,!1,c)}),_l(t)){let d=t.fixedSegments?.map(m=>m.index)||[];n.slice(0,-1).forEach((m,c)=>{Nr.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||ug(e,o,TR((m[0]+n[c+1][0])/2,(m[1]+n[c+1][1])/2),i/2,!1,!d.includes(c+1),!1)})}else Nr.getEditorMidPoints(t,r,o).filter((m,c,p)=>m!==null&&!(_l(t)&&(c===0||c===p.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||n.length===2)&&ug(e,o,m,i/2,!1,!0,!1)});e.restore()},Hv=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,d,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Ta(e,l+d/2,s+m/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,d,m,2/t.zoom.value),e.fill(),e.stroke()):Ia(e,l,s,d,m,l+d/2,s+m/2,n,!0),e.restore()}})},YR=(e,o,t,r,n)=>{let[i,a,,,l,s]=Rl(r,n),d=3,m=20,c=d/t.zoom.value,p=c/2,u=l-i+c,f=s-a+c,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=c,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[I,k],[P,S],[B,A],[L,R]]=E;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+I,v+k),e.lineTo(y+P,v+S),e.stroke(),e.beginPath(),e.moveTo(y+B,v+A),e.lineTo(y+L,v+R),e.stroke(),e.restore()}),e.restore()},WR=(e,o,t,r)=>{o.save();let n=bg*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,d=-(i/2+n),m=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(d,m,i,a),o.restore()},Wv=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,editorInterface:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[d,m]=hs(e,i),c=gs({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m});c.save(),c.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&hg(c,a,p,o),a.selectionElement&&!a.isCropping)try{_R(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Ov(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&WR(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{GR(c,a,b,o)}),a.frameToHighlight&&UR(c,a,a.frameToHighlight,o),a.elementsToHighlight&&zv(c,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:gg(n,a.activeLockedId);zv(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>Bv(b));if(r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&hg(c,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?FR(c,a):(_l(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&OR(c,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=LR(r,a,s),x=r.length===1&&AR(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&hg(c,a,r[0],o);let w=l.selectionColor||Dd.black;if(b){let E=CR(r),y=[];for(let I of o.values()){let k=[],P=l.remoteSelectedElementIds.get(I.id);if(x&&_l(I)&&(I.startBinding||I.endBinding)||(E.has(I.id)&&!NR(a,I)&&k.push(w),P&&k.push(...P.map(S=>gn(S,a.collaborators.get(S))))),k.length){let[S,B,A,L,R,Y]=Rl(I,o,!0);y.push({angle:I.angle,x1:S,y1:B,x2:A,y2:L,selectionColors:I.locked?["#ced4da"]:k,dashed:!!P||I.locked,cx:R,cy:Y,activeEmbeddable:a.activeEmbeddable?.element===I&&a.activeEmbeddable.state==="active",padding:I.id===a.croppingElementId||Fv(I)?0:void 0})}}let v=I=>{let k=gg(o,I),[P,S,B,A]=fg(k);y.push({angle:0,x1:P,x2:B,y1:S,y2:A,selectionColors:k.some(L=>L.locked)?["#ced4da"]:[Dd.black],dashed:!0,cx:P+(B-P)/2,cy:S+(A-S)/2,activeEmbeddable:!1})};for(let I of RR(a))v(I);a.editingGroupId&&v(a.editingGroupId),y.forEach(I=>Yv(c,a,I))}if(c.save(),c.translate(a.scrollX,a.scrollY),r.length===1){c.fillStyle=Dd.white;let E=MR(r[0],a.zoom,o,"mouse",pg(s));if(!a.viewModeEnabled&&b&&!Ov(a.editingTextElement)&&!a.croppingElementId&&Hv(c,l,a,E,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&Fv(y)&&YR(c,l,a,y,o)}}else if(r.length>1&&!a.isRotating&&!r.some(E=>E.locked)){let E=bg*2/a.zoom.value;c.fillStyle=Dd.white;let[y,v,I,k]=fg(r,o),P=c.getLineDash();c.setLineDash([2/a.zoom.value]);let S=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=w,Ia(c,y-E,v-E,I-y+E*2,k-v+E*2,(y+I)/2,(v+k)/2,0),c.lineWidth=S,c.setLineDash(P);let B=PR([y,v,I,k,(y+I)/2,(v+k)/2],0,a.zoom,"mouse",u?{...pg(s),rotation:!0}:pg(s));r.some(A=>!A.locked)&&Hv(c,l,a,B,0)}c.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,I,k]=Rl(E,o,!0);c.save(),a.theme===SR.LIGHT?x?c.fillStyle="rgba(255, 124, 0, 0.4)":c.fillStyle="rgba(255, 226, 0, 0.4)":x?c.fillStyle="rgba(229, 82, 0, 0.4)":c.fillStyle="rgba(99, 52, 0, 0.4)";let P=Bv(E)?a.zoom.value:1;c.translate(a.scrollX,a.scrollY),c.translate(I,k),c.rotate(E.angle),w.forEach(S=>{(S.showOnCanvas||x)&&c.fillRect(y+S.offsetX/P-I,v+S.offsetY/P-k,S.width/P,S.height/P)}),c.restore()}}),Lv(c,a),c.restore(),GE({context:c,renderConfig:l,appState:a,normalizedWidth:d,normalizedHeight:m});let f;return l.renderScrollbars&&(f=_v(o,d,m,a),c.save(),c.fillStyle=Dv,c.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&kc(c,b.x,b.y,b.width,b.height,Jt/2)}),c.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},xg=kR(e=>{let o=Wv(e);e.callback?.(o)},{trailing:!0}),Vv=(e,o)=>{if(o){xg(e);return}let t=Wv(e);return e.callback(t),t};var Nl=class{constructor(o){C(this,"scene");C(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:d,width:m})=>{let c=[];for(let p of r.values())VR(p,m,d,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&c.push(p);return c},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=KR(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return XR(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d,editingTextElement:m,newElementId:c,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:m,newElementId:c}),b=o({elementsMap:f,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){xg.cancel(),O1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as $R}from"@excalidraw/common";import{getElementAbsoluteCoords as ZR}from"@excalidraw/element";import{jsx as JR}from"react/jsx-runtime";var jR=5,qR=(e,o,t)=>{let[r,n]=ZR(e,t),{x:i,y:a}=$R({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Eg=({children:e,element:o,elementsMap:t})=>{let r=To();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=qR(o,r,t);return JR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:jR},children:e})};import{DEFAULT_LASER_COLOR as o9,easeOut as Kv}from"@excalidraw/common";import{LaserPointer as QR}from"@excalidraw/laser-pointer";import{SVG_NS as Xv,getSvgPathFromStroke as e9,sceneCoordsToViewportCoords as t9}from"@excalidraw/common";var tr=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;C(this,"currentTrail");C(this,"pastTrails",[]);C(this,"container");C(this,"trailElement");C(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Xv,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Xv,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new QR(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=t9({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return e9(n,!0)}};var _d=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;C(this,"localTrail");C(this,"collabTrails",new Map);C(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new tr(o,t,{...this.getTrailOptions(),fill:()=>o9})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Kv(i),Kv(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new tr(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||gn(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as r9}from"react";import{unstable_batchedUpdates as $v}from"react-dom";import{throttleRAF as n9}from"@excalidraw/common";var _e=e=>o=>{$v(e,o)},Rd=e=>n9(o=>{$v(e,o)}),ea=(()=>{let e;try{let t=r9.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as yg,KEYS as Bl,CLASSES as wg,POINTER_BUTTON as i9,isWritableElement as a9,getFontString as Zv,getFontFamilyString as jv,isTestEnv as qv,MIME_TYPES as l9}from"@excalidraw/common";import{originalContainerCache as s9,updateOriginalContainerCache as Jv}from"@excalidraw/element";import{LinearElementEditor as c9}from"@excalidraw/element";import{bumpVersion as d9}from"@excalidraw/element";import{getBoundTextElementId as m9,getContainerElement as vg,getTextElementAngle as p9,redrawTextBoundingBox as u9,getBoundTextMaxHeight as h9,getBoundTextMaxWidth as Qv,computeContainerDimensionForBoundText as e3,computeBoundTextPosition as g9,getBoundTextElement as f9}from"@excalidraw/element";import{getTextWidth as b9}from"@excalidraw/element";import{normalizeText as t3}from"@excalidraw/element";import{wrapText as x9}from"@excalidraw/element";import{isArrowElement as Nd,isBoundToContainer as E9,isTextElement as o3}from"@excalidraw/element";var y9=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,d=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${s}px, ${d}px) scale(${a.value}) rotate(${l}deg)`},r3=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let d=(D,F)=>{if(!F.style.fontFamily||!F.style.fontSize)return!1;let G=F.style.fontFamily.replace(/"/g,"");return jv({fontFamily:D.fontFamily})!==G||`${D.fontSize}px`!==F.style.fontSize},m=()=>{let D=l.state,F=l.scene.getElement(e);if(!F)return;let{textAlign:G,verticalAlign:Z}=F,te=l.scene.getNonDeletedElementsMap();if(F&&o3(F)){let oe=F.x,$=F.y,J=vg(F,l.scene.getNonDeletedElementsMap()),be=F.width,ct=F.height,Dt=F.width,lr=F.height;if(J&&F.containerId){if(Nd(J)){let cr=c9.getBoundTextElementPosition(J,F,te);oe=cr.x,$=cr.y}let KC=d(F,c),xa;if(KC?xa=Jv(J.id,J.height):(xa=s9[J.id],xa||(xa=Jv(J.id,J.height))),Dt=Qv(J,F),lr=h9(J,F),!Nd(J)&&ct>lr){let cr=e3(ct,J.type);l.scene.mutateElement(J,{height:cr});return}else if(!Nd(J)&&J.height>xa.height&&ct<lr){let cr=e3(ct,J.type);l.scene.mutateElement(J,{height:cr})}else{let{x:cr,y:$C}=g9(J,F,te);oe=cr,$=$C}}let[ro,sr]=r(oe,$);J?be+=.5:(Dt=(D.width-8-ro)/D.zoom.value,be=Math.min(be,Dt)),ct*=1.05;let Ln=Zv(F),Bm=(D.height-sr)/D.zoom.value;Object.assign(c.style,{font:Ln,lineHeight:F.lineHeight,width:`${be}px`,height:`${ct}px`,left:`${ro}px`,top:`${sr}px`,transform:y9(be,ct,p9(F,J),D,Dt,Bm),textAlign:G,verticalAlign:Z,color:F.strokeColor,opacity:F.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Bm}px`}),c.scrollTop=0,qv()&&(c.style.fontFamily=jv(F)),l.scene.mutateElement(F,{x:oe,y:$})}},c=document.createElement("textarea");c.dir="auto",c.tabIndex=0,c.dataset.type="wysiwyg",c.wrap="off",c.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(E9(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(c.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),c.value=n.originalText,m(),o&&(c.onpaste=async D=>{let F=(await il(D)).findByType(l9.text);if(!F)return;let G=t3(F.value);if(!G)return;let Z=vg(n,l.scene.getNonDeletedElementsMap()),te=Zv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let oe=f9(Z,l.scene.getNonDeletedElementsMap()),$=x9(`${c.value}${G}`,te,Qv(Z,oe)),J=b9($,te);c.style.width=`${J}px`}},c.oninput=()=>{let D=t3(c.value);if(c.value!==D){let F=c.selectionStart;c.value=D,c.selectionStart=F,c.selectionEnd=F}o(c.value)}),c.onkeydown=D=>{if(!D.shiftKey&&dc.keyTest(D))D.preventDefault(),l.actionManager.executeAction(dc),m();else if(!D.shiftKey&&mc.keyTest(D))D.preventDefault(),l.actionManager.executeAction(mc),m();else if(!D.shiftKey&&pc.keyTest(D))D.preventDefault(),l.actionManager.executeAction(pc),m();else if(eu.keyTest(D))l.actionManager.executeAction(eu);else if(tu.keyTest(D))l.actionManager.executeAction(tu);else if(D.key===Bl.ESCAPE)D.preventDefault(),I=!0,k();else if(un.keyTest(D))D.preventDefault(),k(),l.actionManager.executeAction(un);else if(D.key===Bl.ENTER&&D[Bl.CTRL_OR_CMD]){if(D.preventDefault(),D.isComposing||D.keyCode===229)return;I=!0,k()}else if(D.key===Bl.TAB||D[Bl.CTRL_OR_CMD]&&(D.code===yg.BRACKET_LEFT||D.code===yg.BRACKET_RIGHT)){if(D.preventDefault(),D.isComposing)return;D.shiftKey||D.code===yg.BRACKET_LEFT?E():w(),c.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:D,selectionEnd:F}=c,G=y(),Z=c.value;G.forEach(te=>{let oe=Z.slice(0,te),$=Z.slice(te);Z=`${oe}${b}${$}`}),c.value=Z,c.selectionStart=D+f,c.selectionEnd=F+f*G.length},E=()=>{let{selectionStart:D,selectionEnd:F}=c,G=y(),Z=[],te=c.value;G.forEach(oe=>{let $=te.slice(oe,oe+f).match(x);if($){let J=te.slice(0,oe),be=te.slice(oe+$[0].length);te=`${J}${be}`,Z.push(oe)}}),c.value=te,Z.length&&(D>Z[Z.length-1]?c.selectionStart=Math.max(D-f,Z[Z.length-1]):c.selectionStart=D,c.selectionEnd=Math.max(c.selectionStart,F-f*Z.length))},y=()=>{let{selectionStart:D,selectionEnd:F,value:G}=c,Z=G.slice(0,D).match(/[^\n]*$/)[0].length;return D=D-Z,G.slice(D,F).split(`
|
|
16
|
+
`).reduce((oe,$,J,be)=>oe.concat(J?oe[J-1]+be[J-1].length+1:D),[]).reverse()},v=D=>{D.target instanceof HTMLCanvasElement&&(D.preventDefault(),D.stopPropagation())},I=!1,k=()=>{if(Y)return;Y=!0,P();let D=l.scene.getElement(n.id);if(!D)return;let F=vg(D,l.scene.getNonDeletedElementsMap());if(F){if(c.value.trim()){let G=m9(F);!G||G!==n.id?l.scene.mutateElement(F,{boundElements:(F.boundElements||[]).concat({type:"text",id:n.id})}):Nd(F)&&d9(F)}else l.scene.mutateElement(F,{boundElements:F.boundElements?.filter(G=>!o3(G))});u9(D,F,l.scene)}t({viaKeyboard:I,nextOriginalText:c.value})},P=()=>{c.onblur=null,c.oninput=null,c.onkeydown=null,q&&q.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",A),window.removeEventListener("pointerup",S),window.removeEventListener("blur",k),window.removeEventListener("beforeunload",k),L(),R(),c.remove()},S=D=>{window.removeEventListener("pointerup",S);let F=D?.target,G=F instanceof HTMLElement&&F.classList.contains("properties-trigger"),Z=(F instanceof HTMLElement||F instanceof SVGElement)&&!!F.closest(".properties-content"),te=(F instanceof HTMLElement||F instanceof SVGElement)&&(!!F.closest(`.${wg.SHAPE_ACTIONS_MENU}`)||!!F.closest(".compact-shape-actions-island"));setTimeout(()=>{te||G||Z||(c.onblur=k,c.focus())})},B=()=>{c.onblur=null,window.addEventListener("pointerup",S),window.addEventListener("blur",k)},A=D=>{let F=D?.target;if(D.button===i9.WHEEL){F instanceof HTMLTextAreaElement&&(D.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(D)),B();return}let G=F instanceof HTMLElement&&F.classList.contains("properties-trigger"),Z=(F instanceof HTMLElement||F instanceof SVGElement)&&!!F.closest(".properties-content");(D.target instanceof HTMLElement||D.target instanceof SVGElement)&&(D.target.closest(`.${wg.SHAPE_ACTIONS_MENU}, .${wg.ZOOM_ACTIONS}`)||D.target.closest(".compact-shape-actions-island"))&&!a9(D.target)||G||Z?B():D.target instanceof HTMLCanvasElement&&!qv()&&requestAnimationFrame(()=>{k()})},L=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||c.focus()}),R=l.onScrollChangeEmitter.on(()=>{m()}),Y=!1;s&&c.select(),S();let q=null;return i&&"ResizeObserver"in window?(q=new window.ResizeObserver(()=>{m()}),q.observe(i)):window.addEventListener("resize",m),c.onpointerdown=D=>D.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",A,{capture:!0})}),window.addEventListener("beforeunload",k),a?.querySelector(".excalidraw-textEditorContainer").appendChild(c),k};var n3=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as L9}from"@excalidraw/math";import{getElementLineSegments as A9}from"@excalidraw/element";import{LinearElementEditor as D9}from"@excalidraw/element";import{isFrameLikeElement as _9,isLinearElement as R9,isTextElement as N9}from"@excalidraw/element";import{getFrameChildren as B9}from"@excalidraw/element";import{selectGroupsForSelectedElements as F9}from"@excalidraw/element";import{getContainerElement as O9}from"@excalidraw/element";import{arrayToMap as z9,easeOut as s3,isShallowEqual as H9}from"@excalidraw/common";import{simplify as w9}from"points-on-curve";import{polygonFromPoints as v9,lineSegment as i3,polygonIncludesPointNonZero as T9}from"@excalidraw/math";import{computeBoundTextPosition as I9,doBoundsIntersect as C9,getBoundTextElement as S9,getElementBounds as k9,intersectElementWithLineSegment as a3}from"@excalidraw/element";var l3=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=w9(o,l));let d=t.filter(p=>!p.locked);a.clear(),i.clear();let m=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of d){let u=k9(p,r);C9(m,u)&&!i.has(p.id)&&!a.has(p.id)&&(M9(s,p,n)?a.add(p.id):P9(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},M9=(e,o,t)=>{let r=v9(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>T9(a,r))):!1},P9=(e,o,t)=>{let r=e.slice(1).map((i,a)=>i3(e[a],i)).concat([i3(e[e.length-1],e[0])]),n=S9(o,t);return r.some(i=>a3(o,t,i,0,!0).length>0||!!n&&a3({...n,...I9(o,n,t)},t,i,0,!0).length>0)};var Bd=class extends tr{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(s3(s),s3(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});C(this,"intersectedElements",new Set);C(this,"enclosedElements",new Set);C(this,"elementsSegments",null);C(this,"canvasTranslate",null);C(this,"keepPreviousSelection",!1);C(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let d=this.app.scene.getNonDeletedElement(s);if(d&&N9(d)){let m=O9(d,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[d.id])}}for(let[s]of Object.entries(n)){let d=this.app.scene.getNonDeletedElement(s);if(d&&_9(d)){let m=B9(this.app.scene.getNonDeletedElementsMap(),d.id);for(let c of m)delete n[c.id]}}let i=F9({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&R9(this.app.scene.getNonDeletedElement(a[0]))?new D9(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});C(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});C(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>L9(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!H9(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=z9(this.app.visibleElements);for(let i of this.app.visibleElements){let a=A9(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=l3({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as G9,easeOut as c3,THEME as U9}from"@excalidraw/common";import{computeBoundTextPosition as Y9,doBoundsIntersect as W9,getBoundTextElement as V9,getElementBounds as X9,getElementLineSegments as K9,getFreedrawOutlineAsSegments as $9,getFreedrawOutlinePoints as Z9,intersectElementWithLineSegment as d3,isArrowElement as j9,isFreeDrawElement as m3,isLineElement as q9,isPointInElement as J9}from"@excalidraw/element";import{lineSegment as Q9,lineSegmentsDistance as p3,pointFrom as x3,polygon as eN,polygonIncludesPointNonZero as tN}from"@excalidraw/math";import{getElementsInGroup as u3}from"@excalidraw/element";import{shouldTestInside as oN}from"@excalidraw/element";import{hasBoundTextElement as h3,isBoundToContainer as g3}from"@excalidraw/element";import{getBoundTextElementId as f3}from"@excalidraw/element";var Fd=class extends tr{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(c3(s),c3(l))},fill:()=>r.state.theme===U9.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});C(this,"elementsToErase",new Set);C(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>x3(l[0],l[1]))||[];if(r.length<2)return[];let n=Q9(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=G9(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(b3(n,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let m=u3(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.delete(c.id);this.groupsToErase.delete(d)}if(g3(l)&&this.elementsToErase.delete(l.containerId),h3(l)){let m=f3(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&b3(n,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let m=u3(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.add(c.id);this.groupsToErase.add(d)}if(h3(l)){let m=f3(l);m&&this.elementsToErase.add(m)}g3(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},b3=(e,o,t,r)=>{let n=e[1],i=m3(o)?15:o.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],l=X9(o,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!W9(a,s))return!1;if(oN(o)&&J9(n,o,t))return!0;if(m3(o)){let m=Z9(o),c=$9(o,m,t),p=Math.max(2.25,5/r);for(let f of c)if(p3(f,e)<=p)return!0;let u=eN(...m.map(([f,b])=>x3(o.x+f,o.y+b)));return!!tN(e[0],u)}let d=V9(o,t);if(j9(o)||q9(o)&&!o.polygon){let m=Math.max(o.strokeWidth,o.strokeWidth*2/r),c=K9(o,t);for(let p of c)if(p3(p,e)<=m)return!0;return!1}return d3(o,t,e,0,!0).length>0||!!d&&d3({...d,...Y9(o,d,t)},t,e,0,!0).length>0};import{jsx as Qt,jsxs as E3}from"react/jsx-runtime";var rN=()=>E3("div",{"data-testid":"brave-measure-text-error",children:[Qt("p",{children:Qt(Et,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Qt("span",{style:{fontWeight:600},children:e})})}),Qt("p",{children:Qt(Et,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Qt("span",{style:{fontWeight:600},children:e})})}),Qt("p",{children:Qt(Et,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Qt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Qt("p",{children:Qt(Et,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Qt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>E3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),y3=rN;import dN from"clsx";import mN from"react";import{useLayoutEffect as nN,useRef as w3,useEffect as v3}from"react";import{unstable_batchedUpdates as iN}from"react-dom";import{KEYS as aN,queryFocusableElements as lN}from"@excalidraw/common";import sN from"clsx";import{jsx as cN}from"react/jsx-runtime";var T3=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight,className:d})=>{let m=w3(null);v3(()=>{let p=m.current;if(!p)return;p.contains(document.activeElement)||p.focus();let u=f=>{if(f.key===aN.TAB){let b=lN(p),{activeElement:x}=document,w=b.findIndex(E=>E===x);x===p?(f.shiftKey?b[b.length-1]?.focus():b[0].focus(),f.preventDefault(),f.stopImmediatePropagation()):w===0&&f.shiftKey?(b[b.length-1]?.focus(),f.preventDefault(),f.stopImmediatePropagation()):w===b.length-1&&!f.shiftKey&&(b[0]?.focus(),f.preventDefault(),f.stopImmediatePropagation())}};return p.addEventListener("keydown",u),()=>p.removeEventListener("keydown",u)},[]);let c=w3(null);return nN(()=>{if(n&&m.current&&t!=null&&o!=null){let p=m.current,{width:u,height:f}=p.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===o)return;c.current={top:t,left:o},u>=l?(p.style.width=`${l}px`,p.style.left="0px",p.style.overflowX="scroll"):o+u-i>l?p.style.left=`${l-u-10}px`:p.style.left=`${o}px`,f>=s?(p.style.height=`${s-20}px`,p.style.top="10px",p.style.overflowY="scroll"):t+f-a>s?p.style.top=`${s-f}px`:p.style.top=`${t}px`}},[t,o,n,l,s,i,a]),v3(()=>{if(r){let p=u=>{m.current?.contains(u.target)||iN(()=>r(u))};return document.addEventListener("pointerdown",p,!1),()=>document.removeEventListener("pointerdown",p,!1)}},[r]),cN("div",{className:sN("popover",d),ref:m,tabIndex:-1,children:e})};import{jsx as ta,jsxs as pN}from"react/jsx-runtime";var Xe="separator",I3=mN.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=To(),a=xr(),l=o.reduce((s,d)=>(d&&(d===Xe||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s),[]);return ta(T3,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:ta("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,d)=>{if(s===Xe)return!l[d-1]||l[d-1]===Xe?null:ta("hr",{className:"context-menu-item-separator"},d);let m=s.name,c="";return s.label&&(typeof s.label=="function"?c=g(s.label(a,i,e.app)):c=g(s.label)),ta("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:pN("button",{type:"button",className:dN("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[ta("div",{className:"context-menu-item__label",children:c}),ta("kbd",{className:"context-menu-item__shortcut",children:m?ze(m):""})]})},d)})})})});import{jsx as Tg,jsxs as C3}from"react/jsx-runtime";var uN=({height:e,width:o,userToFollow:t,onDisconnect:r})=>Tg("div",{className:"follow-mode",style:{width:o,height:e},children:C3("div",{className:"follow-mode__badge",children:[C3("div",{className:"follow-mode__badge__label",children:["Following"," ",Tg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Tg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Ut})]})}),S3=uN;import In from"clsx";import Rz from"react";import{CLASSES as Nz,DEFAULT_SIDEBAR as kf,MQ_MIN_WIDTH_DESKTOP as Bz,TOOL_TYPE as l5,arrayToMap as Fz,capitalizeString as Oz,isShallowEqual as wm}from"@excalidraw/common";import{mutateElement as zz}from"@excalidraw/element";import{showSelectedShapeActions as Hz}from"@excalidraw/element";import{ShapeCache as Gz}from"@excalidraw/element";import hN from"clsx";import{useState as gN,useEffect as fN}from"react";import{THEME as bN}from"@excalidraw/common";import{jsx as Ig,jsxs as xN}from"react/jsx-runtime";var Od=({delay:e,theme:o})=>{let[t,r]=gN(!!e);return fN(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:xN("div",{className:hN("LoadingMessage",{"LoadingMessage--dark":o===bN.DARK}),children:[Ig("div",{children:Ig(at,{})}),Ig("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import EN from"clsx";import{jsx as M3,jsxs as wN}from"react/jsx-runtime";var yN="medium",k3={CHECKED:Hn,UNCHECKED:en},P3=e=>wN("label",{className:EN("ToolIcon ToolIcon__lock",`ToolIcon_size_${yN}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[M3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),M3("div",{className:"ToolIcon__icon",children:e.checked?k3.CHECKED:k3.UNCHECKED})]});import{useState as Cg,useEffect as A3,useRef as IN}from"react";import oa from"clsx";import{KEYS as Sg,capitalizeString as $e}from"@excalidraw/common";import vN from"clsx";import{KEYS as L3}from"@excalidraw/common";import{jsx as TN}from"react/jsx-runtime";var zd=e=>TN(K,{className:vN("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:Ds,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:L3.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":L3.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{Fragment as CN,jsx as Ke,jsxs as Hd}from"react/jsx-runtime";var kg=[{type:"rectangle",icon:Gn,title:$e(g("toolBar.rectangle"))},{type:"diamond",icon:Un,title:$e(g("toolBar.diamond"))},{type:"ellipse",icon:Yn,title:$e(g("toolBar.ellipse"))}],Mg=[{type:"selection",icon:tn,title:$e(g("toolBar.selection"))},{type:"lasso",icon:ur,title:$e(g("toolBar.lasso"))}],Pg=[{type:"arrow",icon:Is,title:$e(g("toolBar.arrow"))},{type:"line",icon:Wn,title:$e(g("toolBar.line"))}],D3=({app:e,onHandToolToggle:o,setAppState:t})=>{let r=e.state.activeTool,[n,i]=Cg(!1),[a,l]=Cg("rectangle"),[s,d]=Cg("arrow"),m=IN(null);A3(()=>{(r.type==="rectangle"||r.type==="diamond"||r.type==="ellipse")&&l(r.type)},[r.type]),A3(()=>{(r.type==="arrow"||r.type==="line")&&d(r.type)},[r.type]);let c=r.type==="frame",p=r.type==="laser",u=r.type==="embeddable",{TTDDialogTriggerTunnel:f}=Ce(),b=(R,Y)=>{e.state.activeTool.type!==R&&ae("toolbar",R,"ui"),R==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:R})},x=m.current?.getBoundingClientRect()?.width??-8,w=36,E=4,y=7,v=y*w+(y-1)*E,I=w+E,k=x>=v+1*I,P=x>=v+2*I,S=x>=v+3*I,A=["text","frame","embeddable","laser","magicframe"].filter(R=>!(P&&R==="image"||S&&R==="frame")).includes(r.type),L=A?r.type==="frame"?ao:r.type==="embeddable"?Vn:r.type==="laser"?hr:r.type==="text"?vo:r.type==="magicframe"?nn:_a:_a;return Hd("div",{className:"mobile-toolbar",ref:m,children:[Ke(zd,{checked:no(e.state),onChange:o,title:g("toolBar.hand"),isMobile:!0}),Ke(Ui,{app:e,options:Mg,activeTool:r,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:$e(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:R=>{(R==="selection"||R==="lasso")&&(e.setActiveTool({type:R}),t({preferredSelectionTool:{type:R,initialized:!0}}))},displayedOption:Mg.find(R=>R.type===e.state.preferredSelectionTool.type)||Mg[0]}),Ke(K,{className:oa({active:r.type==="freedraw"}),type:"radio",icon:wo,checked:r.type==="freedraw",name:"editor-current-shape",title:`${$e(g("toolBar.freedraw"))}`,"aria-label":$e(g("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>b("freedraw")}),Ke(K,{className:oa({active:r.type==="eraser"}),type:"radio",icon:Cs,checked:r.type==="eraser",name:"editor-current-shape",title:`${$e(g("toolBar.eraser"))}`,"aria-label":$e(g("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>b("eraser")}),Ke(Ui,{app:e,options:kg,activeTool:r,defaultOption:a,namePrefix:"shapeType",title:$e(g(a==="rectangle"?"toolBar.rectangle":a==="diamond"?"toolBar.diamond":a==="ellipse"?"toolBar.ellipse":"toolBar.rectangle")),"data-testid":"toolbar-rectangle",onToolChange:R=>{(R==="rectangle"||R==="diamond"||R==="ellipse")&&(l(R),e.setActiveTool({type:R}))},displayedOption:kg.find(R=>R.type===a)||kg[0]}),Ke(Ui,{app:e,options:Pg,activeTool:r,defaultOption:s,namePrefix:"linearElementType",title:$e(g(s==="arrow"?"toolBar.arrow":"toolBar.line")),"data-testid":"toolbar-arrow",fillable:!0,onToolChange:R=>{(R==="arrow"||R==="line")&&(d(R),e.setActiveTool({type:R}))},displayedOption:Pg.find(R=>R.type===s)||Pg[0]}),k&&Ke(K,{className:oa({active:r.type==="text"}),type:"radio",icon:vo,checked:r.type==="text",name:"editor-current-shape",title:`${$e(g("toolBar.text"))}`,"aria-label":$e(g("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>b("text")}),P&&Ke(K,{className:oa({active:r.type==="image"}),type:"radio",icon:ka,checked:r.type==="image",name:"editor-current-shape",title:`${$e(g("toolBar.image"))}`,"aria-label":$e(g("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>b("image")}),S&&Ke(K,{className:oa({active:c}),type:"radio",icon:ao,checked:c,name:"editor-current-shape",title:`${$e(g("toolBar.frame"))}`,"aria-label":$e(g("toolBar.frame")),"data-testid":"toolbar-frame",onChange:()=>b("frame")}),Hd(le,{open:n,placement:"top",children:[Ke(le.Trigger,{className:oa("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":A||n}),onToggle:()=>{i(!n),t({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),style:{width:w,height:w,display:"flex",alignItems:"center",justifyContent:"center"},children:L}),Hd(le.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[!k&&Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:vo,shortcut:Sg.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:r.type==="text",children:g("toolBar.text")}),!P&&Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:ka,"data-testid":"toolbar-image",selected:r.type==="image",children:g("toolBar.image")}),!S&&Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:ao,shortcut:Sg.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,children:g("toolBar.frame")}),Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Vn,"data-testid":"toolbar-embeddable",selected:u,children:g("toolBar.embeddable")}),Ke(le.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:hr,"data-testid":"toolbar-laser",selected:p,shortcut:Sg.K.toLocaleUpperCase(),children:g("toolBar.laser")}),Ke("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&Ke(f.Out,{}),Ke(le.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Zn,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&Ke(CN,{children:Hd(le.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:nn,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),Ke(le.Item.Badge,{children:"AI"})]})})]})]})]})};import SN from"clsx";import{jsx as kN}from"react/jsx-runtime";var Gd=({children:e,side:o,className:t})=>kN("div",{className:SN("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import{Fragment as MN,jsx as or,jsxs as Fl}from"react/jsx-runtime";var _3=({appState:e,elements:o,actionManager:t,setAppState:r,onHandToolToggle:n,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:l,renderWelcomeScreen:s,UIOptions:d,app:m})=>{let{WelcomeScreenCenterTunnel:c,MainMenuTunnel:p,DefaultSidebarTriggerTunnel:u}=Ce(),f=()=>{let x=a?.(!0,e)??or(u.Out,{}),w=Fl("div",{className:"excalidraw-ui-top-left",children:[i?.(!0,e),or(p.Out,{})]});return e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?or("div",{className:"App-toolbar-content",children:w}):Fl("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[w,x]})},b=()=>or(D3,{app:m,onHandToolToggle:n,setAppState:r});return Fl(MN,{children:[l(),or("div",{className:"App-welcome-screen",children:s&&or(c.Out,{})}),Fl("div",{className:"App-bottom-bar",style:{marginBottom:Jt+er},children:[or(l2,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:m,setAppState:r}),Fl(Ye,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&b(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&or("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(x=>({...Qr(o,x)}))},children:g("buttons.scrollBackToContent")})]})]}),or(Gd,{side:"top",className:"App-top-bar",children:f()})]})};import PN from"open-color";import LN,{useLayoutEffect as AN,useRef as DN,useState as _N}from"react";import{jsx as Ol,jsxs as RN}from"react/jsx-runtime";var R3=e=>{let o=DN(null),[t,r]=_N(null);return AN(()=>{if(!e.spreadsheet)return;let n=vE(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await Nn(n,{exportBackground:!1,viewBackgroundColor:PN.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Ol("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Ol("div",{ref:o})})},N3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Oe(),n=LN.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),ae("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ol(He,{size:"small",onCloseRequest:n,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:RN("div",{className:"container",children:[Ol(R3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Ol(R3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import{Fragment as NN,jsx as B3,jsxs as BN}from"react/jsx-runtime";var zl=({heading:e,children:o,...t})=>{let{id:r}=Se(),n=B3("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:g(`headings.${e}`)});return B3("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):BN(NN,{children:[n,o]})})};import*as Br from"@radix-ui/react-popover";import F3 from"clsx";import Ud,{useLayoutEffect as FN}from"react";import{supportsResizeObserver as ON,isShallowEqual as zN}from"@excalidraw/common";import{Fragment as WN,jsx as _o,jsxs as Yd}from"react/jsx-runtime";var HN=4,GN=8,UN=({shouldWrap:e,children:o,username:t})=>e?_o(Nt,{label:t||"Unknown user",children:o}):_o(WN,{children:o}),Lg=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return _o(UN,{username:o.username,shouldWrap:n,children:l},t)},YN=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Wd=Ud.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=Ve(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Ud.useState(""),d=a.filter(b=>b.username?.toLowerCase().includes(l)),m=Ud.useRef(null);FN(()=>{if(m.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(m.current.clientWidth),!ON)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[c,p]=Ud.useState(HN),f=a.slice(0,c-1).map(b=>Lg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?_o("div",{className:F3("UserList UserList_mobile",e),children:a.map(b=>Lg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):_o("div",{className:"UserList__wrapper",ref:m,children:Yd("div",{className:F3("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&Yd(Br.Root,{children:[Yd(Br.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),_o(Br.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Yd(Ye,{padding:2,children:[a.length>=GN&&_o(Js,{placeholder:g("quickSearch.placeholder"),onChange:s}),_o(Qs,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:d.length>0?[_o("div",{className:"hint",children:g("userList.hint.text")}),d.map(b=>Lg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),_o(Br.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!zN(n,i,YN))return!1}return!0});import VN from"clsx";import{jsx as O3,jsxs as KN}from"react/jsx-runtime";var XN="medium",z3=e=>e.penDetected?KN("label",{className:VN("ToolIcon ToolIcon__penMode",`ToolIcon_size_${XN}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[O3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),O3("div",{className:"ToolIcon__icon",children:mb})]}):null;import Ag from"clsx";import{jsx as $N}from"react/jsx-runtime";var H3=e=>$N("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Xn});import{jsx as rr,jsxs as Dg}from"react/jsx-runtime";var G3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=Ce();return Dg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[rr("div",{className:Ag("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:rr(St.Col,{gap:2,children:Dg(zl,{heading:"canvasActions",children:[rr(c2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&rr(d2,{renderAction:o.renderAction,className:Ag("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),rr(n.Out,{}),rr("div",{className:Ag("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Dg("div",{style:{position:"relative"},children:[r&&rr(i.Out,{}),rr(H3,{onClick:()=>o.executeAction(hn)})]})}),rr(m2,{actionManager:o,showExitZenModeBtn:t})]})},U3=G3;G3.displayName="Footer";import oB from"clsx";import{useEffect as Q3,useLayoutEffect as eT,useRef as Gg,useState as rB,forwardRef as tT,useImperativeHandle as nB,useCallback as j3}from"react";import{CLASSES as iB,EVENT as q3,isDevEnv as aB,KEYS as lB,updateObject as sB}from"@excalidraw/common";import jN from"clsx";import{useContext as qN}from"react";import ZN from"react";var Vd=ZN.createContext({});import{jsx as _g,jsxs as Y3}from"react/jsx-runtime";var Rg=({children:e,className:o})=>{let t=pe(),r=qN(Vd),n=!!(t.canFitSidebar&&r.shouldRenderDockButton);return Y3("div",{className:jN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Y3("div",{className:"sidebar__header__buttons",children:[n&&_g(Nt,{label:g("labels.sidebarLock"),children:_g(yt,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:ab})}),_g(yt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":g("buttons.close"),children:Ut})]})]})};Rg.displayName="SidebarHeader";import*as V3 from"@radix-ui/react-tabs";import{jsx as W3}from"react/jsx-runtime";var Ng=({children:e,tab:o,onSelect:t,...r})=>W3(V3.Trigger,{value:o,asChild:!0,onSelect:t,children:W3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});Ng.displayName="SidebarTabTrigger";import*as X3 from"@radix-ui/react-tabs";import{jsx as JN}from"react/jsx-runtime";var Bg=({children:e,...o})=>JN(X3.List,{className:"sidebar-triggers",...o,children:e});Bg.displayName="SidebarTabTriggers";import QN from"clsx";import{jsx as Fg,jsxs as K3}from"react/jsx-runtime";var Og=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=me(),d=xe();return K3("label",{title:r,className:"sidebar-trigger__label-element",children:[Fg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let c=m.target.checked;s({openSidebar:c?{name:e,tab:o}:null,openMenu:null,openPopup:null}),i?.(c)},checked:d.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),K3("div",{className:QN("sidebar-trigger",a),style:l,children:[t&&Fg("div",{children:t}),n&&Fg("div",{className:"sidebar-trigger__label",children:n})]})]})};Og.displayName="SidebarTrigger";import*as $3 from"@radix-ui/react-tabs";import{jsx as eB}from"react/jsx-runtime";var zg=({children:e,...o})=>{let t=xe(),r=me();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return eB($3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};zg.displayName="SidebarTabs";import*as Z3 from"@radix-ui/react-tabs";import{jsx as tB}from"react/jsx-runtime";var Hg=({tab:e,children:o,...t})=>tB(Z3.Content,{...t,value:e,"data-testid":e,children:o});Hg.displayName="SidebarTab";import{jsx as J3}from"react/jsx-runtime";import{createElement as cB}from"react";var Hl=he(!1),oT=tT(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{aB()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=me(),s=pr(Hl);eT(()=>(s(!!r),()=>{s(!1)}),[s,r]);let d=Gg({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=sB(d.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=Gg(null);nB(a,()=>m.current);let c=pe(),p=j3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return ni(m,j3(u=>{u.target.closest(".sidebar-trigger")||(!r||!c.canFitSidebar)&&p()},[p,r,c.canFitSidebar])),Q3(()=>{let u=f=>{f.key===lB.ESCAPE&&(!r||!c.canFitSidebar)&&p()};return document.addEventListener(q3.KEYDOWN,u),()=>{document.removeEventListener(q3.KEYDOWN,u)}},[p,r,c.canFitSidebar]),J3(Ye,{...i,className:oB(iB.SIDEBAR,{"sidebar--docked":r},n),ref:m,children:J3(Vd.Provider,{value:d.current,children:o})})});oT.displayName="SidebarInner";var eo=Object.assign(tT((e,o)=>{let t=xe(),{onStateChange:r}=e,n=Gg(t.openSidebar);Q3(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=rB(!1);return eT(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?cB(oT,{...e,ref:o,key:e.name}):null}),{Header:Rg,TabTriggers:Bg,TabTrigger:Ng,Tabs:zg,Tab:Hg,Trigger:Og});eo.displayName="Sidebar";import{composeEventHandlers as xB}from"@excalidraw/common";import{useLayoutEffect as dB,useRef as mB}from"react";import{jsx as pB}from"react/jsx-runtime";var nr=(e,o)=>{let t=he(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Ce(),[,a]=i(t),l=mB({preferHost:!1,counter:0});return dB(()=>{let s=l.current;return a(d=>{let m=d+1;return s.counter=m,m}),()=>{a(d=>{let m=d-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:pB(o,{...n})};return r.displayName=e,r};var Wg={};C1(Wg,{ChangeCanvasBackground:()=>fT,ClearCanvas:()=>hT,CommandPalette:()=>mT,Export:()=>bT,Help:()=>uT,LiveCollaborationTrigger:()=>ET,LoadScene:()=>sT,SaveAsImage:()=>dT,SaveToActiveFile:()=>cT,SearchMenu:()=>pT,Socials:()=>xT,ToggleTheme:()=>gT});import fB from"clsx";import{THEME as Fr}from"@excalidraw/common";var Ug=he({active:!1});async function rT({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{We.set(Ug,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import uB from"clsx";import{jsx as nT,jsxs as hB}from"react/jsx-runtime";var Xd=function({onChange:e,value:o,choices:t,name:r}){return nT("div",{className:"RadioGroup",children:t.map(n=>hB("div",{className:uB("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[nT("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as gB,jsx as Yg,jsxs as iT}from"react/jsx-runtime";var aT=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=pe();return iT(gB,{children:[iT("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Yg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),Yg(Xd,{name:i,value:e,onChange:t,choices:r})]}),o&&a.formFactor!=="phone"&&Yg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};aT.displayName="DropdownMenuItemContentRadio";var lT=aT;import{Fragment as bB,jsx as Qe,jsxs as yT}from"react/jsx-runtime";var sT=()=>{let{t:e}=Be(),o=Ve(),t=xr();return o.isActionEnabled(Ei)?Qe(gt,{icon:Kn,onSelect:async()=>{(!t.length||await rT({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Qe(Et,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>Qe("strong",{children:n}),br:()=>Qe("br",{})})}))&&o.executeAction(Ei)},"data-testid":"load-button",shortcut:ze("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};sT.displayName="LoadScene";var cT=()=>{let{t:e}=Be(),o=Ve();return o.isActionEnabled(un)?Qe(gt,{shortcut:ze("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(un),icon:Eb,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};cT.displayName="SaveToActiveFile";var dT=()=>{let e=me(),{t:o}=Be();return Qe(gt,{icon:Ms,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:ze("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};dT.displayName="SaveAsImage";var mT=e=>{let o=me(),{t}=Be();return Qe(gt,{icon:Ra,"data-testid":"command-palette-button",onSelect:()=>{ae("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:ze("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};mT.displayName="CommandPalette";var pT=e=>{let{t:o}=Be(),t=Ve();return Qe(gt,{icon:Rt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Il)},shortcut:ze("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};pT.displayName="SearchMenu";var uT=()=>{let{t:e}=Be(),o=Ve();return Qe(gt,{"data-testid":"help-menu-item",icon:Xn,onSelect:()=>o.executeAction(hn),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};uT.displayName="Help";var hT=()=>{let{t:e}=Be(),o=pr(xn);return Ve().isActionEnabled(Xo)?Qe(gt,{icon:_t,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};hT.displayName="ClearCanvas";var gT=e=>{let{t:o}=Be(),t=xe(),r=Ve(),n=ze("toggleTheme");return r.isActionEnabled(cn)?e?.allowSystemTheme?Qe(lT,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Fr.LIGHT,label:La,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:Fr.DARK,label:Pa,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:_0,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):Qe(gt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Fr.DARK?Fr.LIGHT:Fr.DARK);else return r.executeAction(cn)},icon:t.theme===Fr.DARK?La:Pa,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===Fr.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Fr.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};gT.displayName="ToggleTheme";var fT=()=>{let{t:e}=Be(),o=xe(),t=Ve(),r=Io();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:yT("div",{style:{marginTop:"0.5rem"},children:[Qe("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),Qe("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};fT.displayName="ChangeCanvasBackground";var bT=()=>{let{t:e}=Be(),o=me();return Qe(gt,{icon:on,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};bT.displayName="Export";var xT=()=>{let{t:e}=Be();return yT(bB,{children:[Qe(zi,{icon:Ss,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Qe(zi,{icon:bb,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Qe(zi,{icon:fb,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};xT.displayName="Socials";var ET=({onSelect:e,isCollaborating:o})=>{let{t}=Be();return Qe(gt,{"data-testid":"collab-button",icon:Ps,className:fB({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};ET.displayName="LiveCollaborationTrigger";import{jsx as Kd,jsxs as Vg}from"react/jsx-runtime";var EB=Object.assign(nr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ce(),r=pe(),n=xe(),i=me();return Kd(t.In,{children:Vg(le,{open:n.openMenu==="canvas",children:[Kd(le.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:hb}),Vg(le.Content,{onClickOutside:()=>i({openMenu:null}),onSelect:xB(o,()=>{i({openMenu:null})}),placement:"bottom",className:r.formFactor==="phone"?"main-menu-dropdown":"",children:[e,r.formFactor==="phone"&&n.collaborators.size>0&&Vg("fieldset",{className:"UserList-Wrapper",children:[Kd("legend",{children:g("labels.collaborators")}),Kd(Wd,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:le.Trigger,Item:le.Item,ItemLink:le.ItemLink,ItemCustom:le.ItemCustom,Group:le.Group,Separator:le.Separator,DefaultItems:Wg}),ht=EB;import yB from"clsx";import{forwardRef as wB,useState as vB}from"react";import{isPromiseLike as TB}from"@excalidraw/common";import{jsx as $d,jsxs as IB}from"react/jsx-runtime";var Or=wB(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d},m)=>{let[c,p]=vB(!1),u=async b=>{let x=t?.(b);if(TB(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof _n)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=c?"loading":d;return i=f==="success"?"success":i,$d("button",{className:yB("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:f==="loading"||f==="success",children:IB("div",{className:"ExcButton__contents",children:[f==="loading"?$d(at,{className:"ExcButton__statusIcon"}):f==="success"&&$d("div",{className:"ExcButton__statusIcon",children:g0}),o&&$d("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as ra,jsxs as kB}from"react/jsx-runtime";var Zd=({title:e,children:o,actionLabel:t,onClick:r})=>kB("div",{className:"OverwriteConfirm__Actions__Action",children:[ra("h4",{children:e}),ra("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ra(Or,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),CB=()=>{let{t:e}=Be(),o=Ve(),t=me();return ra(Zd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(vc,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},SB=()=>{let{t:e}=Be(),o=Ve();return ra(Zd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(al,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Xg=Object.assign(({children:e})=>ra("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:CB,SaveToDisk:SB});import{jsx as zr,jsxs as wT}from"react/jsx-runtime";var jd=Object.assign(nr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ce(),[t,r]=de(Ug);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return zr(o.In,{children:zr(He,{onCloseRequest:n,title:!1,size:916,children:wT("div",{className:"OverwriteConfirm",children:[zr("h3",{children:t.title}),wT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[zr("div",{className:"OverwriteConfirm__Description__icon",children:f0}),zr("div",{children:t.description}),zr("div",{className:"OverwriteConfirm__Description__spacer"}),zr(Or,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),zr(Xg,{children:e})]})})})}),{Actions:Xg,Action:Zd});import ZB from"clsx";import{CANVAS_SEARCH_TAB as qg,DEFAULT_SIDEBAR as jB,LIBRARY_SIDEBAR_TAB as AT,composeEventHandlers as qB}from"@excalidraw/common";import{round as MB}from"@excalidraw/math";import PB from"clsx";import LB from"lodash.debounce";import{Fragment as AB,memo as DB,useEffect as Gl,useMemo as vT,useRef as Kg,useState as TT}from"react";import{CLASSES as _B,EVENT as RB,FONT_FAMILY as $g,FRAME_STYLE as Zg,getLineHeight as NB}from"@excalidraw/common";import{isElementCompletelyInViewport as BB}from"@excalidraw/element";import{measureText as Ul}from"@excalidraw/element";import{KEYS as na,randomInteger as IT,addEventListener as FB,getFontString as qd}from"@excalidraw/common";import{newTextElement as OB}from"@excalidraw/element";import{isTextElement as MT,isFrameLikeElement as Jd}from"@excalidraw/element";import{getDefaultFrameName as PT}from"@excalidraw/element/frame";import{Fragment as $B,jsx as rt,jsxs as Ro}from"react/jsx-runtime";var zB=he(""),jg=he(null),HB=350,LT=()=>{let e=Oe(),o=me(),t=Kg(null),[r,n]=de(zB),i=r.trim(),[a,l]=TT(!1),[s,d]=TT({nonce:null,items:[]}),m=Kg(null),c=Kg(void 0),[p,u]=de(jg),f=e.scene.getNonDeletedElementsMap();Gl(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==c.current)&&(m.current=null,kT(i,e,(y,v)=>{d({nonce:IT(),items:y}),m.current=i,c.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[a,i,f,e,o,u,c]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};Gl(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((I,k)=>k===p?{...I,focus:!0}:{...I,focus:!1})}}:null)},[p,o]),Gl(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,I=OB({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:Jd(y.element)?Zg.nameFontSize:y.element.fontSize,fontFamily:Jd(y.element)?$g.Assistant:y.element.fontFamily}),k=14,P=I.fontSize,S=P*v<k;if(!BB([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||S){let B;S?P>=k?B={fitToContent:!0}:B={fitToViewport:!0,maxZoom:MB(k/P,1)}:B={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,...B,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Gl(()=>()=>{u(null),m.current=null,c.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=gr({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Gl(()=>{let y=v=>{if(v.key===na.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[na.CTRL_OR_CMD]&&v.key===na.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===na.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===na.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===na.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return FB(window,RB.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return Ro("div",{className:"layer-ui__search",children:[rt("div",{className:"layer-ui__search-header",children:rt(Pr,{className:_B.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:g("search.placeholder"),icon:Rt,onChange:y=>{n(y),l(!0);let v=y.trim();kT(v,e,(I,k)=>{d({nonce:IT(),items:I}),u(k),m.current=v,c.current=e.scene.getSceneNonce(),o({searchMatches:I.length?{focusedId:null,matches:I.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Ro("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Ro($B,{children:[p!==null&&p>-1?Ro("div",{children:[p+1," / ",E]}):rt("div",{children:E}),Ro("div",{className:"result-nav",children:[rt(yt,{onSelect:()=>{b()},className:"result-nav-btn",children:Rs}),rt(yt,{onSelect:()=>{x()},className:"result-nav-btn",children:O0})]})]}),s.items.length===0&&i&&m.current&&rt("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),rt(YB,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},CT=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return rt("div",{tabIndex:-1,className:PB("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:rt("div",{className:"preview-text",children:o.flatMap((t,r)=>rt(AB,{children:r===2?rt("b",{children:t}):t},r))})})},GB=e=>{let o=vT(()=>e.matches.items.filter(r=>Jd(r.element)),[e.matches]),t=vT(()=>e.matches.items.filter(r=>MT(r.element)),[e.matches]);return Ro("div",{children:[o.length>0&&Ro("div",{className:"layer-ui__search-result-container",children:[Ro("div",{className:"layer-ui__search-result-title",children:[rt("div",{className:"title-icon",children:ao}),rt("div",{children:g("search.frames")})]}),o.map((r,n)=>rt(CT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&rt("div",{className:"layer-ui__divider"})]}),t.length>0&&Ro("div",{className:"layer-ui__search-result-container",children:[Ro("div",{className:"layer-ui__search-result-title",children:[rt("div",{className:"title-icon",children:vo}),rt("div",{children:g("search.texts")})]}),t.map((r,n)=>rt(CT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},UB=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,YB=DB(GB,UB),ST=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),d=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;d=d.length>m?d.slice(-m):d;let c=e.slice(o+t.length),p=c.split(/\s+/),u=!c.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:d.length,previewText:d+t+b,moreBefore:s>0,moreAfter:p.length>f}},WB=(e,o)=>{let t=e.split(`
|
|
17
17
|
`),r=[],n=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,n);if(s>a.length+n){let d=s-(a.length+n);for(;d>0;)a+=" ",d--}}r.push(a),n=n+a.length}return r.join(`
|
|
18
|
-
`)},
|
|
19
|
-
`),i=[],a=0,l=0;for(let c of n){let p=a,u=p+c.length-1;i.push({line:c,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,d=e.originalText.slice(t,t+o.length),m=[];for(let c of i){if(d==="")break;if(s>=c.startIndex&&s<=c.endIndex){let p=c.endIndex+1-s,u=c.line.slice(0,s-c.startIndex),f=d.slice(0,p);d=d.slice(p);let b=
|
|
18
|
+
`)},VB=(e,o,t)=>{let n=WB(e.text,e.originalText).split(`
|
|
19
|
+
`),i=[],a=0,l=0;for(let c of n){let p=a,u=p+c.length-1;i.push({line:c,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,d=e.originalText.slice(t,t+o.length),m=[];for(let c of i){if(d==="")break;if(s>=c.startIndex&&s<=c.endIndex){let p=c.endIndex+1-s,u=c.line.slice(0,s-c.startIndex),f=d.slice(0,p);d=d.slice(p);let b=Ul(u,qd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&c.line.length>0){let v=Ul(c.line,qd(e),e.lineHeight),I=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=I}let{width:x,height:w}=Ul(f,qd(e),e.lineHeight),E=b.width,y=c.lineNumber*b.height;m.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return m},XB=(e,o,t,r)=>{let n=e.name??PT(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=qd({fontSize:Zg.nameFontSize,fontFamily:$g.Assistant}),s=NB($g.Assistant),d=Ul(a,l,s);a===""&&(d.width=0);let m=Ul(i,l,s),c=d.width,p=-d.height-Zg.strokeWidth,u=m.width;return[{offsetX:c,offsetY:p,width:u,height:m.height,showOnCanvas:c+u<=e.width*r}]},KB=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),kT=LB((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>MT(p)),i=r.filter(p=>Jd(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(KB(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=ST(f,u.index,e),x=VB(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??PT(p);for(;(u=l.exec(f))!==null;){let b=ST(f,u.index,e),x=XB(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let d=new Set(o.visibleElements.map(p=>p.id)),m=[...s,...a],c=m.findIndex(p=>d.has(p.element.id))??null;t(m,c)},HB);import{jsx as go,jsxs as DT}from"react/jsx-runtime";import{createElement as JB}from"react";var _T=nr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ce();return go(o.In,{children:go(eo.Trigger,{...e,className:"default-sidebar-trigger",name:jB.name})})});_T.displayName="DefaultSidebarTrigger";var RT=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ce();return go(o.In,{children:e})};RT.displayName="DefaultTabTriggers";var Qd=Object.assign(nr("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=xe(),a=me(),{DefaultSidebarTabTriggersTunnel:l}=Ce(),s=i.openSidebar?.tab===qg;return JB(eo,{...n,name:"default",key:"default",className:ZB("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:qB(t,d=>{a({defaultSidebarDockedPreference:d})})},DT(eo.Tabs,{children:[go(eo.Header,{children:DT(eo.TabTriggers,{children:[go(eo.TabTrigger,{tab:qg,children:Rt}),go(eo.TabTrigger,{tab:AT,children:zn}),go(l.Out,{})]})}),go(eo.Tab,{tab:AT,children:go(Hw,{})}),go(eo.Tab,{tab:qg,children:go(LT,{})}),e]}))}),{Trigger:_T,TabTriggers:RT});import{useEffect as xF,useRef as ef,useState as cm}from"react";import{isFiniteNumber as tI}from"@excalidraw/math";import{useState as GT,useRef as UT,useEffect as YT,useDeferredValue as lF}from"react";import{EDITOR_LS_KEYS as sF,debounce as cF,isDevEnv as dF}from"@excalidraw/common";import{useEffect as QB,useRef as NT}from"react";import{EVENT as BT,KEYS as FT}from"@excalidraw/common";import{jsx as eF}from"react/jsx-runtime";var em=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=NT(null),i=NT(r);return i.current=r,QB(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[FT.CTRL_OR_CMD]&&s.key===FT.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(BT.KEYDOWN,l),()=>{a.removeEventListener(BT.KEYDOWN,l)}}},[]),eF("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as tm,jsxs as OT}from"react/jsx-runtime";var tF=({error:e})=>OT("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",tm("p",{children:e})]}),om=({error:e,canvasRef:o,loaded:t})=>OT("div",{className:"ttd-dialog-output-wrapper",children:[e&&tm(tF,{error:e.message}),t?tm("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):tm(at,{size:"2rem"})]});import zT from"clsx";import{jsx as Jg,jsxs as Yl}from"react/jsx-runtime";var ia=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Yl("div",{className:"ttd-dialog-panel",children:[Yl("div",{className:"ttd-dialog-panel__header",children:[Jg("label",{children:e}),i?.()]}),o,Yl("div",{className:zT("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[Yl(yt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[Yl("div",{className:zT({invisible:n}),children:[t?.label,t?.icon&&Jg("span",{children:t.icon})]}),n&&Jg(at,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as oF}from"react/jsx-runtime";var rm=({children:e})=>oF("div",{className:"ttd-dialog-panels",children:e});import{jsx as HT,jsxs as rF}from"react/jsx-runtime";var nm=()=>rF("div",{className:"ttd-dialog-submit-shortcut",children:[HT("div",{className:"ttd-dialog-submit-shortcut__key",children:_("CtrlOrCmd")}),HT("div",{className:"ttd-dialog-submit-shortcut__key",children:_("Enter")})]});import{DEFAULT_EXPORT_PADDING as nF,EDITOR_LS_KEYS as iF}from"@excalidraw/common";var aF=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},im=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){aF({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:d,files:m}=s;r(null),n.current={elements:Qi(d,{regenerateIds:!0}),files:m};let c=await kr({elements:n.current.elements,files:n.current.files,exportPadding:nF,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await zo(c)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(c)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},Wl=e=>{$t.set(iF.MERMAID_TO_EXCALIDRAW,e)},am=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&Wl(t))};import{Fragment as uF,jsx as No,jsxs as VT}from"react/jsx-runtime";var mF=`flowchart TD
|
|
20
20
|
A[Christmas] -->|Get money| B(Go shopping)
|
|
21
21
|
B --> C{Let me think}
|
|
22
22
|
C -->|One| D[Laptop]
|
|
23
23
|
C -->|Two| E[iPhone]
|
|
24
|
-
C -->|Three| F[Car]`,
|
|
25
|
-
TTD mermaid definition render errror: ${P.message}`,"color: yellow"),re("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let L=S.message;(!L||L==="Failed to fetch")&&(L="Request failed"),C(new Error(L))}finally{p(!1)}},x=vg(b);x.current=b;let[w,E]=Dd({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});mB(()=>{(async()=>{await w.api,E(L=>({...L,loaded:!0}))})()},[w.api]);let y=vg({elements:[],files:null}),[v,C]=Dd(null);return ft(Be,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:vr($3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?ft("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):vr(wg,{children:[ft(Pd,{tab:"text-to-diagram",children:vr("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),ft("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"})]})}),ft(Pd,{tab:"mermaid",children:"Mermaid"})]}),ft(Ad,{className:"ttd-dialog-content",tab:"mermaid",children:ft(V3,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&vr(Ad,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[ft("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."}),vr(Sd,{children:[ft(Li,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Sn},onTextSubmitInProgess:c,panelActionDisabled:d.length>Pi||u?.rateLimitRemaining===0,renderTopRight:()=>u?vr("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:()=>ft(kd,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return vr("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(rl(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",ft(nr,{icon:Sn})]});let S=d.length/Pi;return S>.8?vr("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",d.length,"/",Pi]}):null},children:ft(Td,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),ft(Li,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Ld({app:t,data:y})},label:"Insert",icon:Sn},children:ft(Cd,{canvasRef:n,error:v,loaded:w.loaded})})]})]})]})})});import{round as z5}from"@excalidraw/math";import kF from"clsx";import MF from"lodash.throttle";import{useEffect as H5,useMemo as Og,useState as LF,memo as PF}from"react";import{STATS_PANELS as Hd}from"@excalidraw/common";import{getCommonBounds as AF}from"@excalidraw/element";import{getUncroppedWidthAndHeight as DF}from"@excalidraw/element";import{isElbowArrow as _F,isImageElement as zg}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as RF}from"@excalidraw/element";import{elementsAreInSameGroup as NF}from"@excalidraw/element";import{degreesToRadians as a5,radiansToDegrees as d5}from"@excalidraw/math";import{getBoundTextElement as l5}from"@excalidraw/element";import{isArrowElement as s5,isElbowArrow as SB}from"@excalidraw/element";import{updateBindings as c5}from"@excalidraw/element";import yB from"clsx";import{useEffect as n5,useRef as Rd,useState as wB}from"react";import{EVENT as _i,KEYS as vB,cloneJSON as Cg}from"@excalidraw/common";import{deepCopyElement as TB}from"@excalidraw/element";import{CaptureUpdateAction as i5}from"@excalidraw/element";import{pointFrom as Tr,pointRotateRads as _d}from"@excalidraw/math";import{getBoundTextElement as gB}from"@excalidraw/element";import{isFrameLikeElement as o5}from"@excalidraw/element";import{getSelectedGroupIds as fB,getElementsInGroup as bB,isInGroup as xB}from"@excalidraw/element";import{getFrameChildren as EB}from"@excalidraw/element";import{updateBindings as t5}from"@excalidraw/element";var r5=.01,nl=10,St=(e,o)=>!(o==="angle"&&o5(e)),Me=(e,o)=>{let t=e+o/2;return t-t%o},Ai=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var rn=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,d]=[t.x+t.width/2,t.y+t.height/2],[m,c]=_d(Tr(t.x,t.y),Tr(s,d),t.angle),p=e-m,u=o-c,[f,b]=_d(Tr(e,o),Tr(s+p,d+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),t5(l,r);let x=gB(t,n);if(x){let w=a.get(x.id);w&&r.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(o5(t)){let w=EB(n,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=_d(Tr(E.x,E.y),Tr(v,C),E.angle),k=Math.round(S+p),A=Math.round(L+u),[P,N]=_d(Tr(k,A),Tr(v+p,C+u),-E.angle);r.mutateElement(y,{x:P,y:N},{informMutation:i,isDragging:!1}),t5(y,r,{simultaneouslyUpdated:w})})}},Di=(e,o)=>{let r=fB(o).map(n=>bB(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!xB(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Sg,jsxs as CB}from"react/jsx-runtime";var IB=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:m=1,dragFinishedCallback:c})=>{let p=Re(),u=le(),f=Rd(null),b=Rd(null),[x,w]=wB(r.toString()),E=Rd(null);E.current||(E.current={originalAppState:Cg(d),originalElements:n,lastUpdatedValue:x,updatePending:!1}),n5(()=>{let C=r.toString();w(C),E.current.lastUpdatedValue=C},[r]);let y=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(C);if(isNaN(k)){w(r.toString());return}let A=Number(k.toFixed(2)),P=Number(r);(isNaN(P)||Math.abs(A-P)>=r5)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:A,property:l,originalAppState:L,setInputValue:N=>w(String(N)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:i5.IMMEDIATELY}))},v=Rd({});return v.current.handleInputValue=y,n5(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(_i.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(_i.POINTER_UP,S.onPointerUp,!1)}},[i]),i?CB("div",{className:yB("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Sg("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(f.current.value);isNaN(S)&&(S=0);let L=null,k=p.scene.getNonDeletedElements().reduce((_,R)=>(_.set(R.id,TB(R)),_),new Map),A=n.map(_=>k.get(_.id)),P=Cg(d),N=0,O=0,U=_=>{if(L&&k!==null&&A!==null){let R=_.clientX-L.x;R!==0&&(O+=R,Math.abs(O)>=m&&(O=Math.sign(O)*Math.floor(Math.abs(O)/m),N+=O,t({accumulatedChange:N,instantChange:O,originalElements:A,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:P,setInputValue:V=>w(String(V)),app:p,setAppState:u}),O=0))}L={x:_.clientX,y:_.clientY}},J=()=>{window.removeEventListener(_i.POINTER_MOVE,U,!1),p.syncActionResult({captureUpdate:i5.IMMEDIATELY}),c?.({app:p,setAppState:u,originalElements:A,originalAppState:P}),L=null,N=0,O=0,A=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(_i.POINTER_UP,J,!1)};v.current.onPointerMove=U,v.current.onPointerUp=J,window.addEventListener(_i.POINTER_MOVE,U,!1),window.addEventListener(_i.POINTER_UP,J,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?Sg(nr,{icon:o}):e}),Sg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===vB.ENTER&&(y(S.value,n,d),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,w(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=n,E.current.originalAppState=Cg(d)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(r.toString())},disabled:!i})]}):null},Qe=IB;import{jsx as PB}from"react/jsx-runtime";var kB=15,MB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!SB(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=a5(r);n.mutateElement(l,{angle:u}),c5(l,n);let f=l5(l,i);f&&!s5(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(d5(a.angle)*100)/100,d=Math.round(e),m=(s+d)%360;t&&(m=Me(m,kB)),m=m<0?m+360:m;let c=a5(m);n.mutateElement(l,{angle:c}),c5(l,n);let p=l5(l,i);p&&!s5(l)&&n.mutateElement(p,{angle:c})}},LB=({element:e,scene:o,appState:t,property:r})=>PB(Qe,{label:"A",icon:Jl,value:Math.round(d5(e.angle)%360*100)/100,elements:[e],dragInputCallback:MB,editable:St(e,"angle"),scene:o,appState:t,property:r}),m5=LB;import{jsx as DB}from"react/jsx-runtime";var p5=5,AB=({property:e,scene:o,appState:t,setAppState:r})=>DB(Qe,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let d;return n?d=n:i&&(d=a?Me(s.gridStep+p5*Math.sign(i),p5):s.gridStep+i),d?(d=Zf(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),u5=AB;import{clamp as Nd,round as kg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Bd}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as h5,getUncroppedWidthAndHeight as b5}from"@excalidraw/element";import{resizeSingleElement as g5}from"@excalidraw/element";import{isImageElement as x5}from"@excalidraw/element";import{isFrameLikeElement as Mg}from"@excalidraw/element";import{getElementsInResizingFrame as Lg}from"@excalidraw/element";import{replaceAllElementsInFrame as E5}from"@excalidraw/element";import{jsx as FB}from"react/jsx-runtime";var f5=10,_B=e=>e.type==="image",RB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:d,app:m,setAppState:c})=>{let p=d.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=r||_B(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!x5(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:L}=b5(w),k=E.naturalWidth/S,A=E.naturalHeight/L,P=v?E.width+E.x:E.naturalWidth-E.x,N=C?E.height+E.y:E.naturalHeight-E.y,O=h5*k,U=h5*A;if(i!==void 0){if(a==="width"){let Z=i*k,W=Nd(Z,O,P);y={...y,width:W,x:v?E.x+E.width-W:E.x}}else if(a==="height"){let Z=i*A,W=Nd(Z,U,N);y={...y,height:W,y:C?E.y+E.height-W:E.y}}d.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}let J=a==="width"?s:0,_=a==="height"?s:0,R=Nd(E.width+J,O,P),V=Nd(E.height+_,O,N);y={...E,x:v?E.x+E.width-R:E.x,y:C?E.y+E.height-V:E.y,width:R,height:V},d.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,Bd),E=Math.max(a==="height"?i:b?i/x:u.height,Bd);if(g5(w,E,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Mg(f)){let y=Lg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap()),v=E5(d.getElementsIncludingDeleted(),y,f,m);d.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(n?y=Me(y,f5):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(n?v=Me(v,f5):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(Bd,v),y=Math.max(Bd,y),g5(y,v,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Mg(f)){let C=Lg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap());c({elementsToHighlight:C})}}}},NB=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&Mg(a)){let l=Lg(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=E5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},BB=({property:e,element:o,scene:t,appState:r})=>{let n=kg(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&x5(o)&&o.crop){let{width:i,height:a}=b5(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=kg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=kg(o.crop.height*l,2)}}return FB(Qe,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:RB,value:n,editable:St(o,e),scene:t,appState:r,property:e,dragFinishedCallback:NB})},Pg=BB;import{getBoundTextElement as OB,redrawTextBoundingBox as zB}from"@excalidraw/element";import{hasBoundTextElement as HB,isTextElement as w5}from"@excalidraw/element";import{jsx as WB}from"react/jsx-runtime";var y5=4,GB=4,UB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!w5(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),y5);else if(a.type==="text"){let d=Math.round(a.fontSize),m=Math.round(e);s=Math.max(d+m,y5),t&&(s=Me(s,GB))}s&&(n.mutateElement(l,{fontSize:s}),zB(l,n.getContainerElement(l),n))}},YB=({element:e,scene:o,appState:t,property:r})=>{let n=w5(e)?e:HB(e)?OB(e,o.getNonDeletedElementsMap()):null;return n?WB(Qe,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:UB,icon:Or,appState:t,scene:o,property:r}):null},v5=YB;import{degreesToRadians as T5,radiansToDegrees as S5}from"@excalidraw/math";import{getBoundTextElement as I5}from"@excalidraw/element";import{isArrowElement as C5}from"@excalidraw/element";import{isInGroup as Ag}from"@excalidraw/element";import{jsx as ZB}from"react/jsx-runtime";var VB=15,XB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(d=>a.get(d.id)).filter(d=>d&&!Ag(d)&&St(d,n)),s=o.filter(d=>!Ag(d)&&St(d,n));if(r!==void 0){let d=T5(r);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:d});let c=I5(m,a);c&&!C5(m)&&i.mutateElement(c,{angle:d})}i.triggerUpdate();return}for(let d=0;d<l.length;d++){let m=l[d];if(!m)continue;let c=s[d],p=Math.round(S5(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Me(f,VB)),f=f<0?f+360:f;let b=T5(f);i.mutateElement(m,{angle:b});let x=I5(m,a);x&&!C5(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},KB=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!Ag(s)&&St(s,"angle")),i=n.map(s=>Math.round(S5(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>St(s,"angle"));return ZB(Qe,{label:"A",icon:Jl,value:a,elements:e,dragInputCallback:XB,editable:l,appState:t,scene:o,property:r})},k5=KB;import{pointFrom as M5}from"@excalidraw/math";import{useMemo as $B}from"react";import{MIN_WIDTH_OR_HEIGHT as Ir}from"@excalidraw/common";import{getElementsInResizingFrame as Dg,isFrameLikeElement as _g,replaceAllElementsInFrame as A5,updateBoundElements as jB}from"@excalidraw/element";import{rescalePointsInElement as qB,resizeSingleElement as L5}from"@excalidraw/element";import{getBoundTextElement as JB,handleBindTextResize as QB}from"@excalidraw/element";import{isTextElement as D5}from"@excalidraw/element";import{getCommonBounds as Fd}from"@excalidraw/element";import{jsx as iF}from"react/jsx-runtime";var Ri=10,eF=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,d=o+i*t;return{width:a,height:l,x:s,y:d,...qB(r,a,l,!1),...D5(r)?{fontSize:r.fontSize*t}:{}}},tF=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=eF(e,o,r,i);l.mutateElement(n,d);let m=JB(i,a);if(m){let c=m.fontSize*r;jB(n,l,{newSize:{width:d.width,height:d.height}});let p=s.get(m.id);p&&D5(p)&&(l.mutateElement(p,{fontSize:c}),QB(n,l,t==="width"?"e":"s",!0))}},P5=(e,o,t,r,n,i,a,l,s,d)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];tF(n[0],n[1],i,m,u,p,s,d)}},oF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let m=a.getNonDeletedElementsMap(),c=Di(o,r);if(i!==void 0){for(let b of c){let x=Ai(b,m,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Fd(E),L=C-y,k=S-v,A=L/k,P=Math.max(Ir,l==="width"?Math.max(0,i):L),N=Math.max(Ir,l==="height"?Math.max(0,i):k);P5(P,N,k,A,M5(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&St(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(n?v=Me(v,Ri):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(n?C=Me(C,Ri):C=Math.round(C)),v=Math.max(Ir,v),C=Math.max(Ir,C),L5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),_g(E)){let S=Dg(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap()),L=A5(a.getElementsIncludingDeleted(),S,E,d);a.replaceAllElements(L)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of c){let x=Ai(b,m,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Fd(E),L=C-y,k=S-v,A=L/k,P=Math.max(0,L+p);l==="width"&&(n?P=Me(P,Ri):P=Math.round(P));let N=Math.max(0,k+u);l==="height"&&(n?N=Me(N,Ri):N=Math.round(N)),P=Math.max(Ir,P),N=Math.max(Ir,N),P5(P,N,k,A,M5(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&St(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(n?v=Me(v,Ri):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(n?C=Me(C,Ri):C=Math.round(C)),v=Math.max(Ir,v),C=Math.max(Ir,C),L5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),_g(E)){let S=Dg(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},rF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&_g(a)){let l=Dg(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=A5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},nF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=$B(()=>r.map(d=>{let m=Ai(d,t);if(m.length>1){let[p,u,f,b]=Fd(m.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[c]=m;return Math.round((e==="width"?c.latest.width:c.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return iF(Qe,{label:e==="width"?"W":"H",elements:o,dragInputCallback:oF,value:l,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:rF})},Rg=nF;import{getBoundTextElement as aF,redrawTextBoundingBox as _5}from"@excalidraw/element";import{hasBoundTextElement as lF,isTextElement as sF}from"@excalidraw/element";import{isInGroup as cF}from"@excalidraw/element";import{jsx as hF}from"react/jsx-runtime";var R5=4,dF=4,mF=(e,o)=>e.reduce((t,r)=>{if(!r||cF(r))return t;if(sF(r))return t.push(r),t;if(lF(r)){let n=aF(r,o);if(n)return t.push(n),t}return t},[]),pF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),R5);for(let s of a)n.mutateElement(s,{fontSize:l}),_5(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let d=0;d<a.length;d++){let m=a[d],c=s[d],p=Math.round(c.fontSize),u=Math.round(e),f=Math.max(p+u,R5);t&&(f=Me(f,dF)),n.mutateElement(m,{fontSize:f}),_5(m,n.getContainerElement(m),n)}n.triggerUpdate()}},uF=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=mF(e,n);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return hF(Qe,{label:"F",icon:Or,elements:i,dragInputCallback:pF,value:l,editable:s,scene:o,property:r,appState:t})},N5=uF;import{pointFrom as Cr,pointRotateRads as Od}from"@excalidraw/math";import{useMemo as gF}from"react";import{isTextElement as fF}from"@excalidraw/element";import{getCommonBounds as Ng}from"@excalidraw/element";import{jsx as wF}from"react/jsx-runtime";var bF=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,d]=[l.x+l.width/2,l.y+l.height/2],[m,c]=Od(Cr(l.x,l.y),Cr(s,d),l.angle),p=e==="x"?Math.round(m+o):m,u=e==="y"?Math.round(c+t):c;rn(p,u,l,i,n,!1)}},xF=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=Ng(t),s=e-a,d=o-l;for(let m=0;m<t.length;m++){let c=t[m],p=i.get(c.id);if(p&&(!fF(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=Od(Cr(p.x,p.y),Cr(u,f),p.angle);rn(b+s,x+d,c,n,r,!1)}}},EF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of Di(o,l)){let u=Ai(p,s,t);if(u.length>1){let[f,b,,]=Ng(u.map(E=>E.latest));xF(i==="x"?n:f,i==="y"?n:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&St(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=Od(Cr(f.x,f.y),Cr(x,w),f.angle);rn(i==="x"?n:E,i==="y"?n:y,f,a,t,!1)}}}a.triggerUpdate();return}let d=r?Me(e,nl):e;bF(i,i==="x"?d:0,i==="y"?d:0,o,t,a),a.triggerUpdate()},yF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=gF(()=>r.map(s=>{let d=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(d.length>1){let[b,x]=Ng(d);return Math.round((e==="x"?b:x)*100)/100}let[m]=d,[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=Od(Cr(m.x,m.y),Cr(c,p),m.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return wF(Qe,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:EF,value:l,property:e,scene:n,appState:i})},Bg=yF;import{clamp as il,pointFrom as zd,pointRotateRads as F5,round as B5}from"@excalidraw/math";import{getFlipAdjustedCropPosition as vF,getUncroppedWidthAndHeight as TF}from"@excalidraw/element";import{isImageElement as O5}from"@excalidraw/element";import{jsx as SF}from"react/jsx-runtime";var IF=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let d=l.getNonDeletedElementsMap(),m=t[0],[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=F5(zd(m.x,m.y),zd(c,p),m.angle);if(s.croppingElementId===m.id){let y=d.get(m.id);if(!y||!O5(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,L=y.scale[1]===-1,{width:k,height:A}=TF(y);if(i!==void 0){if(a==="x"){let O=i*(v.naturalWidth/k);S?C={...v,x:il(v.naturalWidth-O-v.width,0,v.naturalWidth-v.width)}:C={...v,x:il(i*(v.naturalWidth/k),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:il(i*(v.naturalHeight/A),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let P=(a==="x"?o:0)*(S?-1:1),N=(a==="y"?o:0)*(L?-1:1);C={...v,x:il(v.x+P,0,v.naturalWidth-v.width),y:il(v.y+N,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){rn(a==="x"?i:u,a==="y"?i:f,m,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(n?Me(m.x+b,nl):u+b):u,E=a==="y"?Math.round(n?Me(m.y+x,nl):f+x):f;rn(w,E,m,l,r)},CF=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=F5(zd(o.x,o.y),zd(o.x+o.width/2,o.y+o.height/2),o.angle),l=B5(e==="x"?i:a,2);if(n.croppingElementId===o.id&&O5(o)&&o.crop){let s=vF(o);s&&(l=B5(e==="x"?s.x:s.y,2))}return SF(Qe,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:IF,scene:r,value:l,property:e,appState:n})},Fg=CF;import{Fragment as Hg,jsx as q,jsxs as kt}from"react/jsx-runtime";var BF=50,al=e=>{let o=go(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=hr(e.app);return q(FF,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ie=({children:e,columns:o=1,heading:t,style:r,...n})=>q("div",{className:kF("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ie.displayName="StatsRow";var Gd=({children:e,order:o,style:t,...r})=>q("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Gd.displayName="StatsRows";al.StatsRow=Ie;al.StatsRows=Gd;var FF=PF(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),m=le(),c=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&zg(c),f=u?DF(c):null,[b,x]=LF({width:0,height:0}),w=Og(()=>MF(v=>{let C=AF(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},BF),[]);H5(()=>{w(s)},[i,s,w]),H5(()=>()=>w.cancel(),[w]);let E=Og(()=>Di(r,n),[r,n]),y=Og(()=>RF(r),[r]);return q("div",{className:"exc-stats",children:kt(Xe,{padding:3,children:[kt("div",{className:"title",children:[q("h2",{children:g("stats.title")}),q("div",{className:"close",onClick:o,children:Bt})]}),kt(pa,{label:q("h3",{children:g("stats.generalStats")}),open:!!(n.stats.panels&Hd.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Hd.generalStats}})),children:[kt(Gd,{children:[q(Ie,{heading:!0,children:g("stats.scene")}),kt(Ie,{columns:2,children:[q("div",{children:g("stats.shapes")}),q("div",{children:s.length})]}),kt(Ie,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:b.width})]}),kt(Ie,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:b.height})]}),a&&kt(Hg,{children:[q(Ie,{heading:!0,children:"Canvas"}),q(Ie,{children:q(u5,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&q("div",{id:"elementStats",style:{marginTop:12},children:q(pa,{label:q("h3",{children:g("stats.elementProperties")}),open:!!(n.stats.panels&Hd.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Hd.elementProperties}})),children:kt(Gd,{children:[c&&kt(Hg,{children:[u&&q(Ie,{heading:!0,children:g("labels.unCroppedDimension")}),n.croppingElementId&&zg(c)&&f&&kt(Ie,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:z5(f.width,2)})]}),n.croppingElementId&&zg(c)&&f&&kt(Ie,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:z5(f.height,2)})]}),q(Ie,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),q(Ie,{children:q(Fg,{element:c,property:"x",elementsMap:d,scene:l,appState:n})}),q(Ie,{children:q(Fg,{element:c,property:"y",elementsMap:d,scene:l,appState:n})}),q(Ie,{children:q(Pg,{property:"width",element:c,scene:l,appState:n})}),q(Ie,{children:q(Pg,{property:"height",element:c,scene:l,appState:n})}),!_F(c)&&q(Ie,{children:q(m5,{property:"angle",element:c,scene:l,appState:n})}),q(Ie,{children:q(v5,{property:"fontSize",element:c,scene:l,appState:n})})]}),p&&kt(Hg,{children:[NF(p)&&q(Ie,{heading:!0,children:g("element.group")}),kt(Ie,{columns:2,style:{margin:"0.3125rem 0"},children:[q("div",{children:g("stats.shapes")}),q("div",{children:r.length})]}),q(Ie,{children:q(Bg,{property:"x",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(Bg,{property:"y",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(Rg,{property:"width",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(Rg,{property:"height",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(k5,{property:"angle",elements:p,scene:l,appState:n})}),q(Ie,{children:q(N5,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:d})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as OF,useEffect as G5,useState as U5}from"react";import{normalizeLink as zF,KEYS as Gg}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as HF,getLinkIdAndTypeFromSelection as GF}from"@excalidraw/element";import{jsx as Ni,jsxs as Ud}from"react/jsx-runtime";var UF=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=HF})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=U5(a),[d,m]=U5(!1);G5(()=>{let p=j(i,t),u=a;if(p.length>0&&n){let f=GF(p,t);f&&(u=zF(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let c=OF(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&d&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,d,r,o]);return G5(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===Gg.ENTER&&c(),t.openDialog?.name==="elementLinkSelector"&&u.key===Gg.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,c]),Ud("div",{className:"ElementLinkDialog",children:[Ud("div",{className:"ElementLinkDialog__header",children:[Ni("h2",{children:g("elementLink.title")}),Ni("p",{children:g("elementLink.desc")})]}),Ud("div",{className:"ElementLinkDialog__input",children:[Ni(hi,{value:l??"",onChange:p=>{d||m(!0),s(p)},onKeyDown:p=>{p.key===Gg.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Ni(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:Mt})]}),Ud("div",{className:"ElementLinkDialog__actions",children:[Ni(No,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Ni(No,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},Y5=UF;import YF,{useState as WF}from"react";import{Fragment as VF,jsx as Ug}from"react/jsx-runtime";var W5=({children:e,onClose:o})=>{let[t,r]=WF(!!e),{container:n}=He(),i=YF.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Ug(VF,{children:t&&Ug(Be,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Ug("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import XF from"react";import{isDarwin as V5,isFirefox as X5,isWindows as KF}from"@excalidraw/common";import{KEYS as Ae,getShortcutKey as X}from"@excalidraw/common";import{Fragment as Z5,jsx as F,jsxs as Rt}from"react/jsx-runtime";var ZF=()=>Rt("div",{className:"HelpDialog__header",children:[Rt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Tm}),g("helpDialog.documentation")]}),Rt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Tm}),g("helpDialog.blog")]}),Rt("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:Kl}),g("helpDialog.github")]}),Rt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:nb}),"YouTube"]})]}),$F=e=>Rt(Z5,{children:[F("h3",{children:e.title}),F("div",{className:"HelpDialog__islands-container",children:e.children})]}),Yg=e=>Rt("div",{className:`HelpDialog__island ${e.className}`,children:[F("h4",{className:"HelpDialog__island-title",children:e.caption}),F("div",{className:"HelpDialog__island-content",children:e.children})]});function*jF(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var qF=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),G=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>F(JF,{children:qF(a)},a)));return Rt("div",{className:"HelpDialog__shortcut",children:[F("div",{children:e}),F("div",{className:"HelpDialog__key-container",children:[...jF(r,t?g("helpDialog.or"):null)]})]})},JF=e=>F("kbd",{className:"HelpDialog__key",...e}),K5=({onClose:e})=>{let o=XF.useCallback(()=>{e&&e()},[e]);return F(Z5,{children:Rt(Be,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[F(ZF,{}),Rt($F,{title:g("helpDialog.shortcuts"),children:[Rt(Yg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[F(G,{label:g("toolBar.hand"),shortcuts:[Ae.H]}),F(G,{label:g("toolBar.selection"),shortcuts:[Ae.V,Ae[1]]}),F(G,{label:g("toolBar.rectangle"),shortcuts:[Ae.R,Ae[2]]}),F(G,{label:g("toolBar.diamond"),shortcuts:[Ae.D,Ae[3]]}),F(G,{label:g("toolBar.ellipse"),shortcuts:[Ae.O,Ae[4]]}),F(G,{label:g("toolBar.arrow"),shortcuts:[Ae.A,Ae[5]]}),F(G,{label:g("toolBar.line"),shortcuts:[Ae.L,Ae[6]]}),F(G,{label:g("toolBar.freedraw"),shortcuts:[Ae.P,Ae[7]]}),F(G,{label:g("toolBar.text"),shortcuts:[Ae.T,Ae[8]]}),F(G,{label:g("toolBar.image"),shortcuts:[Ae[9]]}),F(G,{label:g("toolBar.eraser"),shortcuts:[Ae.E,Ae[0]]}),F(G,{label:g("toolBar.frame"),shortcuts:[Ae.F]}),F(G,{label:g("toolBar.laser"),shortcuts:[Ae.K]}),F(G,{label:g("labels.eyeDropper"),shortcuts:[Ae.I,"Shift+S","Shift+G"]}),F(G,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.editText"),shortcuts:[X("Enter")]}),F(G,{label:g("helpDialog.textNewLine"),shortcuts:[X("Enter"),X("Shift+Enter")]}),F(G,{label:g("helpDialog.textFinish"),shortcuts:[X("Esc"),X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),X("Enter")],isOr:!0}),F(G,{label:g("helpDialog.cropFinish"),shortcuts:[X("Enter"),X("Escape")],isOr:!0}),F(G,{label:g("toolBar.lock"),shortcuts:[Ae.Q]}),F(G,{label:g("helpDialog.preventBinding"),shortcuts:[X("CtrlOrCmd")]}),F(G,{label:g("toolBar.link"),shortcuts:[X("CtrlOrCmd+K")]}),F(G,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Rt(Yg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[F(G,{label:g("buttons.zoomIn"),shortcuts:[X("CtrlOrCmd++")]}),F(G,{label:g("buttons.zoomOut"),shortcuts:[X("CtrlOrCmd+-")]}),F(G,{label:g("buttons.resetZoom"),shortcuts:[X("CtrlOrCmd+0")]}),F(G,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),F(G,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),F(G,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),F(G,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),F(G,{label:g("buttons.zenMode"),shortcuts:[X("Alt+Z")]}),F(G,{label:g("buttons.objectsSnapMode"),shortcuts:[X("Alt+S")]}),F(G,{label:g("labels.toggleGrid"),shortcuts:[X("CtrlOrCmd+'")]}),F(G,{label:g("labels.viewMode"),shortcuts:[X("Alt+R")]}),F(G,{label:g("labels.toggleTheme"),shortcuts:[X("Alt+Shift+D")]}),F(G,{label:g("stats.fullTitle"),shortcuts:[X("Alt+/")]}),F(G,{label:g("search.title"),shortcuts:[Ne("searchMenu")]}),F(G,{label:g("commandPalette.title"),shortcuts:X5?[Ne("commandPalette")]:[Ne("commandPalette"),Ne("commandPalette",1)]})]}),Rt(Yg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[F(G,{label:g("helpDialog.createFlowchart"),shortcuts:[X("CtrlOrCmd+Arrow Key")],isOr:!0}),F(G,{label:g("helpDialog.navigateFlowchart"),shortcuts:[X("Alt+Arrow Key")],isOr:!0}),F(G,{label:g("labels.moveCanvas"),shortcuts:[X(`Space+${g("helpDialog.drag")}`),X(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),F(G,{label:g("buttons.clearReset"),shortcuts:[X("CtrlOrCmd+Delete")]}),F(G,{label:g("labels.delete"),shortcuts:[X("Delete")]}),F(G,{label:g("labels.cut"),shortcuts:[X("CtrlOrCmd+X")]}),F(G,{label:g("labels.copy"),shortcuts:[X("CtrlOrCmd+C")]}),F(G,{label:g("labels.paste"),shortcuts:[X("CtrlOrCmd+V")]}),F(G,{label:g("labels.pasteAsPlaintext"),shortcuts:[X("CtrlOrCmd+Shift+V")]}),F(G,{label:g("labels.selectAll"),shortcuts:[X("CtrlOrCmd+A")]}),F(G,{label:g("labels.multiSelect"),shortcuts:[X(`Shift+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepBoxSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(Vn||X5)&&F(G,{label:g("labels.copyAsPng"),shortcuts:[X("Shift+Alt+C")]}),F(G,{label:g("labels.copyStyles"),shortcuts:[X("CtrlOrCmd+Alt+C")]}),F(G,{label:g("labels.pasteStyles"),shortcuts:[X("CtrlOrCmd+Alt+V")]}),F(G,{label:g("labels.sendToBack"),shortcuts:[V5?X("CtrlOrCmd+Alt+["):X("CtrlOrCmd+Shift+[")]}),F(G,{label:g("labels.bringToFront"),shortcuts:[V5?X("CtrlOrCmd+Alt+]"):X("CtrlOrCmd+Shift+]")]}),F(G,{label:g("labels.sendBackward"),shortcuts:[X("CtrlOrCmd+[")]}),F(G,{label:g("labels.bringForward"),shortcuts:[X("CtrlOrCmd+]")]}),F(G,{label:g("labels.alignTop"),shortcuts:[X("CtrlOrCmd+Shift+Up")]}),F(G,{label:g("labels.alignBottom"),shortcuts:[X("CtrlOrCmd+Shift+Down")]}),F(G,{label:g("labels.alignLeft"),shortcuts:[X("CtrlOrCmd+Shift+Left")]}),F(G,{label:g("labels.alignRight"),shortcuts:[X("CtrlOrCmd+Shift+Right")]}),F(G,{label:g("labels.duplicateSelection"),shortcuts:[X("CtrlOrCmd+D"),X(`Alt+${g("helpDialog.drag")}`)]}),F(G,{label:g("helpDialog.toggleElementLock"),shortcuts:[X("CtrlOrCmd+Shift+L")]}),F(G,{label:g("buttons.undo"),shortcuts:[X("CtrlOrCmd+Z")]}),F(G,{label:g("buttons.redo"),shortcuts:KF?[X("CtrlOrCmd+Y"),X("CtrlOrCmd+Shift+Z")]:[X("CtrlOrCmd+Shift+Z")]}),F(G,{label:g("labels.group"),shortcuts:[X("CtrlOrCmd+G")]}),F(G,{label:g("labels.ungroup"),shortcuts:[X("CtrlOrCmd+Shift+G")]}),F(G,{label:g("labels.flipHorizontal"),shortcuts:[X("Shift+H")]}),F(G,{label:g("labels.flipVertical"),shortcuts:[X("Shift+V")]}),F(G,{label:g("labels.showStroke"),shortcuts:[X("S")]}),F(G,{label:g("labels.showBackground"),shortcuts:[X("G")]}),F(G,{label:g("labels.showFonts"),shortcuts:[X("Shift+F")]}),F(G,{label:g("labels.decreaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+<")]}),F(G,{label:g("labels.increaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as q5,useRef as nO,useState as Sr}from"react";import{DEFAULT_EXPORT_PADDING as iO,EXPORT_IMAGE_TYPES as Wg,isFirefox as aO,EXPORT_SCALES as lO,cloneJSON as J5}from"@excalidraw/common";import{useCallback as QF,useRef as eO,useState as tO}from"react";var oO=2e3,$5=()=>{let[e,o]=tO(null),t=eO(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},oO)},n=QF(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import rO from"clsx";import{jsx as j5}from"react/jsx-runtime";var ll=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>j5("div",{className:rO("Switch",{toggled:t,disabled:n}),children:j5("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Ce,jsxs as kr}from"react/jsx-runtime";var sO="filter"in document.createElement("canvas").getContext("2d"),cO=()=>kr("div",{children:[Ce("h3",{children:g("canvasError.cannotShowPreview")}),Ce("p",{children:Ce("span",{children:g("canvasError.canvasTooBig")})}),kr("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),dO=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=Ee(o,e),[l,s]=Sr(i),[d,m]=Sr(a),[c,p]=Sr(e.exportBackground),[u,f]=Sr(e.exportWithDarkMode),[b,x]=Sr(e.exportEmbedScene),[w,E]=Sr(e.exportScale),y=nO(null),[v,C]=Sr(null),{onCopy:S,copyStatus:L,resetCopyStatus:k}=$5();q5(()=>{k()},[l,c,u,w,b,k]);let{exportedElements:A,exportingFrame:P}=Vr(o,e,d);return q5(()=>{let N=y.current;if(!N)return;let O=N.offsetWidth,U=N.offsetHeight;O&&cr({elements:A,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:iO,maxWidthOrHeight:Math.max(O,U),exportingFrame:P}).then(J=>(C(null),ko(J).then(()=>{N.replaceChildren(J)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):_}))).catch(J=>{console.error(J),C(J)})},[e,t,A,P,l,c,u,w,b]),kr("div",{className:"ImageExportModal",children:[Ce("h3",{children:g("imageExportDialog.header")}),kr("div",{className:"ImageExportModal__preview",children:[Ce("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Ce(cO,{})}),Ce("div",{className:"ImageExportModal__preview__filename",children:!gn&&Ce("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:N=>{s(N.target.value),r.executeAction(Yp,"ui",N.target.value)}})})]}),kr("div",{className:"ImageExportModal__settings",children:[Ce("h3",{children:g("imageExportDialog.header")}),a&&Ce(sl,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ce(ll,{name:"exportOnlySelected",checked:d,onChange:N=>{m(N)}})}),Ce(sl,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ce(ll,{name:"exportBackgroundSwitch",checked:c,onChange:N=>{p(N),r.executeAction(Wp,"ui",N)}})}),sO&&Ce(sl,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ce(ll,{name:"exportDarkModeSwitch",checked:u,onChange:N=>{f(N),r.executeAction(Zx,"ui",N)}})}),Ce(sl,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ce(ll,{name:"exportEmbedSwitch",checked:b,onChange:N=>{x(N),r.executeAction(Xs,"ui",N)}})}),Ce(sl,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ce(gd,{name:"exportScale",value:w,onChange:N=>{E(N),r.executeAction(Kx,"ui",N)},choices:lO.map(N=>({value:N,label:`${N}\xD7`}))})}),kr("div",{className:"ImageExportModal__settings__buttons",children:[Ce(yr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>n(Wg.png,A,{exportingFrame:P}),icon:zm,children:g("imageExportDialog.button.exportToPng")}),Ce(yr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>n(Wg.svg,A,{exportingFrame:P}),icon:zm,children:g("imageExportDialog.button.exportToSvg")}),(Vn||aO)&&Ce(yr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await n(Wg.clipboard,A,{exportingFrame:P}),S()},icon:Cn,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},sl=({label:e,children:o,tooltip:t,name:r})=>kr("div",{className:"ImageExportModal__settings__setting",title:e,children:[kr("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ce(Pt,{label:t,long:!0,children:F0})]}),Ce("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),Q5=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Sr(()=>({appStateSnapshot:J5(o),elementsSnapshot:J5(e)}));return Ce(Be,{onCloseRequest:i,size:"wide",title:!1,children:Ce(dO,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import pO from"react";import{getFrame as uO}from"@excalidraw/common";import Vg from"open-color";import{jsx as mO}from"react/jsx-runtime";var Xg=({children:e,color:o})=>mO("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Vg[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Vg[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Vg[o][9]},children:e});import{Fragment as gO,jsx as so,jsxs as Yd}from"react/jsx-runtime";var hO=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return so("div",{className:"ExportDialog ExportDialog--json",children:Yd("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Yd(Xg,{color:"lime",children:[so("div",{className:"Card-icon",children:V1}),so("h2",{children:g("exportDialog.disk_title")}),Yd("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!gn&&n.renderAction("changeProjectName")]}),so(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Ta,"ui")}})]}),s&&Yd(Xg,{color:"pink",children:[so("div",{className:"Card-icon",children:qi}),so("h2",{children:g("exportDialog.link_title")}),so("div",{className:"Card-details",children:g("exportDialog.link_details")}),so(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{re("export","link",`ui (${uO()})`),await s(e,o,r),l()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},eT=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=pO.useCallback(()=>{a({openDialog:null})},[a]);return so(gO,{children:o.openDialog?.name==="jsonExport"&&so(Be,{onCloseRequest:l,title:g("buttons.export"),children:so(hO,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import fO from"clsx";import{jsx as tT,jsxs as xO}from"react/jsx-runtime";var bO="small",oT=e=>xO("label",{className:fO("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${bO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[tT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),tT("div",{className:"ToolIcon__icon",children:Qi})]});import{Fragment as iT,jsx as $,jsxs as Nt}from"react/jsx-runtime";var SO=({UIOptions:e})=>Nt(dt,{__fallback:!0,children:[$(dt.DefaultItems.LoadScene,{}),$(dt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(dt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(dt.DefaultItems.SaveAsImage,{}),$(dt.DefaultItems.SearchMenu,{}),$(dt.DefaultItems.Help,{}),$(dt.DefaultItems.ClearCanvas,{}),$(dt.Separator,{}),$(dt.Group,{title:"Excalidraw links",children:$(dt.DefaultItems.Socials,{})}),$(dt.Separator,{}),$(dt.DefaultItems.ToggleTheme,{}),$(dt.DefaultItems.ChangeCanvasBackground,{})]}),kO=()=>Nt(Ed,{__fallback:!0,children:[$(Ed.Actions.SaveToDisk,{}),$(Ed.Actions.ExportToImage,{})]}),MO=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:d,renderTopRightUI:m,renderCustomStats:c,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:w,generateLinkForSelection:E})=>{let y=se(),v=l2(),C=v.tunnelsJotai.Provider,[S,L]=ie(er),k=()=>p.canvasActions.export?$(eT,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,A=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(Q5,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>Nt("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),N=()=>$(br,{heading:"selectedShapeActions",className:cl("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:$(Xe,{className:yO.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(Pc,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),O=()=>{let R=IO(o,n),V=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(ld,{side:"top",children:Nt("div",{className:"App-menu App-menu_top",children:[Nt(qe.Col,{gap:6,className:cl("App-menu_top__left"),children:[P(),R&&N()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(br,{heading:"shapes",className:"shapes-section",children:Z=>Nt("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(qe.Col,{gap:4,align:"start",children:Nt(qe.Row,{gap:1,className:cl("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Nt(Xe,{padding:1,className:cl("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[$(cd,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),Z,Nt(qe.Row,{gap:1,children:[$(dd,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(ad,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(sd,{checked:jt(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$(Ac,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),w&&$(Xe,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:$(oT,{title:g("toolBar.laser"),checked:o.activeTool.type===rT.laser,onChange:()=>x.setActiveTool({type:rT.laser}),isMobile:!0})})]})})]})}),Nt("div",{className:cl("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&$(ud,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!J||o.openSidebar?.name!==Kg.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),V&&$(al,{app:x,onClose:()=>{e.executeAction(ti)},renderCustomStats:c})]})]})})},U=()=>$(vd,{__fallback:!0,onDock:R=>{re("sidebar",`toggleDock (${R?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),J=Ol(Qa),_=Nt(iT,{children:[b,$(SO,{UIOptions:p}),$(vd.Trigger,{__fallback:!0,icon:yn,title:vO(g("toolBar.library")),onToggle:R=>{R&&re("sidebar",`${Kg.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:Kg.defaultTab,children:g("toolBar.library")}),$(kO,{}),o.openDialog?.name==="ttd"&&$(Ig,{__fallback:!0}),o.isLoading&&$(id,{delay:250}),o.errorMessage&&$(W5,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&$(vb,{colorPickerType:S.colorPickerType,onCancel:()=>{L(null)},onChange:(R,V,Z,{altKey:W})=>{if(!(R!=="elementBackground"&&R!=="elementStroke"))if(Z.length){for(let ce of Z)TO(ce,wO(n),{[W&&S.swapPreviewOnAlt?R==="elementBackground"?"strokeColor":"backgroundColor":R==="elementBackground"?"backgroundColor":"strokeColor"]:V}),CO.delete(ce);x.scene.triggerUpdate()}else r(R==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(R,V)=>{L(Z=>Z?.keepOpenOnAlt&&V.altKey?Z:null),S?.onSelect?.(R,V)}}),o.openDialog?.name==="help"&&$(K5,{onClose:()=>{r({openDialog:null})}}),$(f2,{}),o.openDialog?.name==="elementLinkSelector"&&$(Y5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),A(),k(),o.pasteDialog.shown&&$(Bv,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&$(Rv,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:A,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:c,renderSidebars:U,device:y,renderWelcomeScreen:f,UIOptions:p}),!y.editor.isMobile&&Nt(iT,{children:[Nt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&J&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&$(v.WelcomeScreenCenterTunnel.Out,{}),O(),$(Hv,{appState:o,actionManager:e,showExitZenModeBtn:d,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(R=>({...Nr(n,R)}))},children:g("buttons.scrollBackToContent")})]}),U()]})]});return $(ep.Provider,{value:o,children:$(C,{children:$(qu.Provider,{value:v,children:_})})})},nT=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},LO=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Wd(nT(r),nT(a),{selectedElementIds:Wd,selectedGroupIds:Wd})&&Wd(n,l)},aT=EO.memo(MO,LO);import PO from"clsx";import{jsx as lT,jsxs as DO}from"react/jsx-runtime";var AO="small",Vd=e=>DO("label",{className:PO("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${AO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[lT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),lT("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as _O,useRef as RO}from"react";import{jsx as sT}from"react/jsx-runtime";var cT=({trails:e})=>{let o=RO(null);return _O(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),sT("div",{className:"SVGLayer",children:sT("svg",{ref:o})})};import NO,{useEffect as BO,useRef as FO}from"react";import{CURSOR_TYPE as dT,isShallowEqual as OO,sceneCoordsToViewportCoords as zO}from"@excalidraw/common";import{jsx as UO}from"react/jsx-runtime";var HO=e=>{let o=FO(!1);return BO(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,d)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))n.has(m)||n.set(m,[]),n.get(m).push(d);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(d,s.username),s.userState&&a.set(d,s.userState),r.set(d,zO({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(d,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Xw({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Ci())}),UO("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?dT.GRAB:dT.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},mT=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId}),GO=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:OO(mT(e.appState),mT(o.appState)),Zg=NO.memo(HO,GO);import YO,{useEffect as pT,useRef as uT}from"react";import{isShallowEqual as hT}from"@excalidraw/common";import{jsx as XO}from"react/jsx-runtime";var WO=e=>{let o=uT(null),t=uT(!1);return pT(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),pT(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),i1({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ci())}),XO("div",{className:"excalidraw__canvas-wrapper",ref:o})},gT=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),VO=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:hT(gT(e.appState),gT(o.appState))&&hT(e.renderConfig,o.renderConfig),$g=YO.memo(WO,VO);import{useEffect as QO,useRef as ez}from"react";import{throttleRAF as KO}from"@excalidraw/common";import{getTargetFrame as ZO,isInvisiblySmallElement as $O,renderElement as jO,shouldApplyFrameClip as qO}from"@excalidraw/element";var fT=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,d]=Al(e,i),m=Dl({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:d});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if($O(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=ZO(t,r,a);p&&qO(t,p,a,r)&&r1(p,m,l,a)}jO(t,r,n,o,m,l,a)}else m.clearRect(0,0,s,d);m.restore()}},JO=KO(e=>{fT(e)},{trailing:!0}),bT=(e,o)=>{if(o){JO(e);return}fT(e)};import{jsx as oz}from"react/jsx-runtime";var tz=e=>{let o=ez(null);return QO(()=>{o.current&&bT({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ci())}),oz("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},xT=tz;import{useCallback as rz,useEffect as nz,useRef as iz}from"react";import{jsx as ET,jsxs as lz}from"react/jsx-runtime";var az=5e3,yT=({message:e,onClose:o,closable:t=!1,duration:r=az,style:n})=>{let i=iz(0),a=r!==1/0,l=rz(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return nz(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),lz("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[ET("p",{className:"Toast__message",children:e}),t&&ET(K,{icon:Bt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as sz,getElementsInGroup as cz,selectGroupsFromGivenElements as dz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as mz}from"@excalidraw/common";import{flushSync as pz}from"react-dom";import{jsx as hz}from"react/jsx-runtime";var uz=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:cz(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=sz(r),{x:a,y:l}=mz({sceneX:n,sceneY:i},e.state);return hz("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{pz(()=>{let s=dz(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Ma)},title:g("labels.elementLock.unlock"),children:k1})},wT=uz;import{Fragment as sG,jsx as ue,jsxs as Qd}from"react/jsx-runtime";var II=So.createContext(null),CI=So.createContext(null),SI={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},kf=So.createContext(SI);kf.displayName="DeviceContext";var Mf=So.createContext({container:null,id:null});Mf.displayName="ExcalidrawContainerContext";var Lf=So.createContext([]);Lf.displayName="ExcalidrawElementsContext";var Pf=So.createContext({...$o(),width:0,height:0,offsetLeft:0,offsetTop:0});Pf.displayName="ExcalidrawAppStateContext";var Af=So.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Af.displayName="ExcalidrawSetAppStateContext";var Df=So.createContext(null);Df.displayName="ExcalidrawActionManagerContext";var Re=()=>_r(II),fo=()=>_r(CI),se=()=>_r(kf),He=()=>_r(Mf),tr=()=>_r(Lf),go=()=>_r(Pf),le=()=>_r(Af),Ue=()=>_r(Df),xl=!1,vf=0,dn=!1,El=!1,Tf=!1,yl={horizontal:null,vertical:null},Dr=0,wl=!1,If=new Map,Jd=!1,yI=0,wI=!1,vl=null,pe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Sf=class e extends So.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"device",SI);I(this,"excalidrawContainerRef",So.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"handleToastClose",()=>{this.setToast(null)});I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new NH);I(this,"flowChartNavigator",new BH);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastViewportPosition",{x:0,y:0});I(this,"animationFrameHandler",new Vc);I(this,"laserTrails",new ed(this.animationFrameHandler,this));I(this,"eraserTrail",new nd(this.animationFrameHandler,this));I(this,"lassoTrail",new rd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new ln);I(this,"onPointerDownEmitter",new ln);I(this,"onPointerUpEmitter",new ln);I(this,"onUserFollowEmitter",new ln);I(this,"onScrollChangeEmitter",new ln);I(this,"missingPointerEventCleanupEmitter",new ln);I(this,"onRemoveEventListenersEmitter",new ln);I(this,"updateEditorAtom",(t,...r)=>{let n=ze.set(t,...r);return this.triggerRender(),n});I(this,"getEffectiveGridSize",()=>hr(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),fl.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Ar(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=hf(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Hi(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=Fe({clientX:i.x,clientY:i.y},this.state),l=Fe({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Zd.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&Kt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!QT(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=jd({sceneX:i.x,sceneY:i.y},this.state),s=6,d,m=LH(i);if(i.id===this.state.editingFrame){let c=m;d=ue("input",{autoFocus:!0,value:c,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===Y.ESCAPE||p.key===Y.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?Rz:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Mr.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=m;return ue("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Mr.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Mr.nameFontSize,color:t?Mr.nameColorDarkTheme:Mr.nameColorLightTheme,lineHeight:Mr.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:De.MOVE,pointerEvents:this.state.viewModeEnabled?Fi.disabled:Fi.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{re("export",t,"ui");let i=await Xr(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(jz).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Rl(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Co.magicframe}),re("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&pf(t[0])&&t[0];if(!r&&t.some(i=>Kt(i)||i.frameId)){this.setActiveTool({type:Co.magicframe});return}re("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=zi(t),d=50;n=VT({...Mr,x:i-d,y:a-d,width:l-i+d*2,height:s-a+d*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)this.scene.mutateElement(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(er,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:mt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:mt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?sn(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:mt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Pe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||Zd.LIGHT,s=t?.appState?.name??this.state.name,d=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&bI(m)&&co(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let c=t.appState||{};return{...m,...c,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:d}}),r=!0}r||this.scene.triggerUpdate()}));I(this,"onBlur",Pe(()=>{dn=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Pe(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...$o(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async n=>{if(!n.files.length)return;let i=n.files[0],a=await i.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),i)}),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(n=>{console.error(n)})}catch(n){console.error(n),t={appState:{errorMessage:n.message||"Encountered an error during importing or restoring scene data"}}}let r=bn(t,null,null,{repairBindings:!0,deleteInvisibleElements:!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,...Nr(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:mt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),yf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,r)=>t<Lz||r<kz&&t<Mz);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=rf(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:Pz,a=this.device.editor,l=rf(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Pe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>fl.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),_T||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(yl=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",BT(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Az));I(this,"onCut",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ml(t.target)||(this.actionManager.executeAction(tc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ml(t.target)||(this.actionManager.executeAction(Qn,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(Oz&&t.preventDefault(),!xl){xl=!0,clearTimeout(vf),vf=window.setTimeout(e.resetTapTwice,Dz);return}if(xl&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),xl=!1,clearTimeout(vf)}t.touches.length===2&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}):pe.pointers.clear()});I(this,"pasteFromClipboard",Pe(async t=>{let r=!!Jd,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||ml(n)))return;let{x:l,y:s}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),d=t?.clipboardData?.files[0],m=await Ws(t,r);if(!d&&!r){if(m.mixedContent)return this.addElementsFromMixedContentPaste(m.mixedContent,{isPlainPaste:r,sceneX:l,sceneY:s});if(m.text){let c=m.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&(d=xm(c))}}if(Nl(d)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.createImageElement({sceneX:l,sceneY:s,imageFile:d});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(c){console.error(c)}if(m.errorMessage)this.setState({errorMessage:m.errorMessage});else if(m.spreadsheet&&!r)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let c=m.programmaticAPI?Ii(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:c,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&av(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:f,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Ii(f,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(f){console.warn(`parsing pasted text as mermaid definition failed: ${f.message}`)}}let c=Jz(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=c.map(u=>EH(u)).filter(u=>hf(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||qd(u)?.type==="video"));if(!Jd&&p.length>0&&p.length===c.length){let u=[];for(let f of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:ef(f)});x&&u.push(x)}u.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(u.map(f=>[f.id,!0]))}));return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=hm(t.elements,null,{deleteInvisibleElements:!0}),[n,i,a,l]=zi(r),s=Oi(n,a)/2,d=Oi(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,c=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Fe({clientX:m,clientY:c},this.state),f=p-s,b=u-d,[x,w]=nt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=ZT({type:"everything",elements:r.map(k=>sn(k,{x:k.x+x-n,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,pI(v,zT(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let k=AH(E,S);bf(v,k,S,this.state)}this.scene.replaceAllElements(v),E.forEach(k=>{if(co(k)&&mf(k)){let A=nI(k,this.scene.getElementsMapIncludingDeleted());TH(k,A,this.scene)}}),Gz&&Zo.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let L=qH(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&ze.get(Qa)?this.state.openSidebar:null,...mo({editingGroupId:null,selectedElementIds:L.reduce((k,A)=>(mf(A)||(k[A.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{Dr&&this.resetContextMenuTimer(),pe.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||re("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Vo(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Ex)});I(this,"zoomCanvas",t=>{this.setState({...Ao({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:uo(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(yf(t)?s=zH(t):s=t,s){let d=this.scene.getElementsFromId(s);d?.length?this.scrollToContent(d,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):yf(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=ga({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Nr(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,d=this.state.scrollY,m=this.state.zoom.value,c=$z({fromValues:{scrollX:s,scrollY:d,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,qz(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{c(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,yz,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Pe(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===Lr.svg))try{let s=u1(rI(h1(l.dataURL)),Lr.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});I(this,"updateScene",Pe(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?oH({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));I(this,"applyDeltas",(t,r)=>{let n=EI.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return EI.applyTo(n,a,i,r)});I(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Pe(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Mo().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});I(this,"onKeyDown",Pe(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!FT(t.target)){if((t.key===Y.ESCAPE||t.key===Y.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=j(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&cn(a[0])&&t.key===Y.ENTER){this.startImageCropping(a[0]);return}if(t.key===Y.ESCAPE)this.updateEditorAtom(no,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(tH.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=li(a);ze.get(no)?.type==="panel"&&Lu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(no,{type:"panel"})}if(t.key===Y.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Xd(t.key);if(t[Y.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&gH(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,cI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!uf(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=j(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let d=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),cI(t.key));if(d){this.setState(c=>({selectedElementIds:ye({[d]:!0},c)}));let m=this.scene.getNonDeletedElementsMap().get(d);m&&!uf([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[Y.CTRL_OR_CMD]&&t.key===Y.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Ne("commandPalette")})}),t.preventDefault();return}if(t[Y.CTRL_OR_CMD]&&t.key.toLowerCase()===Y.V&&(Jd=t.shiftKey,clearTimeout(yI),yI=window.setTimeout(()=>{Jd=!1},100)),t[Y.CTRL_OR_CMD]&&ml(t.target)&&(t.code===MT.MINUS||t.code===MT.EQUAL)){t.preventDefault();return}if(ml(t.target)&&t.key!==Y.ESCAPE||Xd(t.key)&&FT(t.target))return;if(t.key===Y.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Y.E&&t.shiftKey&&t[Y.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===Y.PAGE_UP||t.key===Y.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===Y.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[Y.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Xd(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(We),s=new Set;a.filter(We).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?AT:this.getEffectiveGridSize())||(t.shiftKey?Tz:AT),m=0,c=0;t.key===Y.ARROW_LEFT?m=-d:t.key===Y.ARROW_RIGHT?m=d:t.key===Y.ARROW_UP?c=-d:t.key===Y.ARROW_DOWN&&(c=d),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+c},{informMutation:!1,isDragging:!1}),lf(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:sf(a.filter(p=>p.id!==l?.id||d!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Y.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[Y.CTRL_OR_CMD]||wf(l))Zt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),We(l)||this.actionManager.executeAction(wi));else if(co(l)||vH(l)){let s;co(l)||(s=l);let d=ff(l,this.state,this.scene.getNonDeletedElementsMap()),m=d.x,c=d.y;this.startTextEditing({sceneX:m,sceneY:c,container:s}),t.preventDefault();return}else Kt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=a2(t.key);a?(this.state.activeTool.type!==a&&re("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Pr.sharp?Pr.round:l.currentItemArrowType===Pr.round?Pr.elbow:Pr.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===Y.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===Y.SPACE&&pe.pointers.size===0&&(dn=!0,xe(this.interactiveCanvas,De.GRAB),t.preventDefault()),(t.key===Y.G||t.key===Y.S)&&!t.altKey&&!t[Y.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===Y.G&&(Ko(this.state.activeTool.type)||a.some(l=>Ko(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Y.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Y.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Y.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>co(l)||gf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===Y.K&&!t.altKey&&!t[Y.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[Y.CTRL_OR_CMD]&&(t.key===Y.BACKSPACE||t.key===Y.DELETE)&&this.updateEditorAtom(Jr,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===Y.S&&t.shiftKey,i=t.key===Y.I||r===Y.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",Pe(t=>{if(t.key===Y.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?zt(this.interactiveCanvas):(At(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),dn=!1),!t[Y.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Xd(t.key)&&(YT(this.scene.getSelectedElements(this.state).filter(Zt),af(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:mt.IMMEDIATELY})),!t[Y.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:ye({[r.id]:!0},n)})),uf([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:mt.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=Vo(this.state,t);n.type==="hand"?xe(this.interactiveCanvas,De.GRAB):dn||At(this.interactiveCanvas,{...this.state,activeTool:n}),Vz(document.activeElement)&&this.focusContainer(),uH(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageAction(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{zt(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>pe.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${OT()}`);I(this,"onGestureStart",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null}),pe.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Pe(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=pe.initialScale;r&&this.setState(n=>({...Ao({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(r*t.scale)},n)}))}));I(this,"onGestureEnd",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}),pe.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(gf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=null,m=this.scene.getSelectedElements(this.state);m.length===1?co(m[0])?d=m[0]:i?d=gf(m[0],this.scene.getNonDeletedElementsMap()):d=this.getTextElementAtPosition(t,r):d=this.getTextElementAtPosition(t,r);let c=d?.fontFamily||this.state.currentItemFontFamily,p=d?.lineHeight||NT(c),u=this.state.currentItemFontSize;if(!d&&l&&i&&!cf(i)){let w=YH(tf({fontSize:u,fontFamily:c}),p),E=WH(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=d||XT({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Bz.MIDDLE:PT,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?cf(i)?0:i.angle:0,frameId:f?f.id:null});if(!d&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!d)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||d||i?this.handleTextWysiwyg(b,{isExistingElement:!!d}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Fe(t,this.state);if(r.length===1&&Zt(r[0])){let l=r[0];if((t[Y.CTRL_OR_CMD]&&aG(l)||wf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(wi);return}else if(this.state.selectedLinearElement&&We(r[0])){let s=Se.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=s?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Se.deleteFixedSegment(r[0],this.scene,d);let m=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=m?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:c,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&wf(l))return}if(r.length===1&&cn(r[0])){this.startImageCropping(r[0]);return}if(zt(this.interactiveCanvas),$H(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&ZH(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(d=>({...d,...mo({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(zt(this.interactiveCanvas),!t[Y.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(hl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&($T(s)||!Zz(s.backgroundColor)||gl({point:ne(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let d=ff(s,this.state,this.scene.getNonDeletedElementsMap());n=d.x,i=d.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&Pl(l,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=nn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>vz)return;let i=Fe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Pl(this.hitLinkElement,a,this.state,ne(i.x,i.y),this.device.editor.isMobile),s=Fe(this.lastPointerUpEvent,this.state),d=Pl(this.hitLinkElement,a,this.state,ne(s.x,s.y),this.device.editor.isMobile);if(l&&d){xu();let m=this.hitLinkElement.link;if(m){m=ef(m);let c;if(this.props.onLinkOpen&&(c=Xz(ee.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},c)),!c?.defaultPrevented){let p=Uz(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&aI(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,pe.pointers.has(t.pointerId)&&pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=pe.initialScale;if(pe.pointers.size===2&&pe.lastCenter&&r&&pe.initialDistance){let f=Mh(pe.pointers),b=f.x-pe.lastCenter.x,x=f.y-pe.lastCenter.y;pe.lastCenter=f;let w=Lh(Array.from(pe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/pe.initialDistance,y=E?uo(r*E):this.state.zoom.value;this.setState(v=>{let C=Ao({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/y),scrollY:C.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else pe.lastCenter=pe.initialDistance=pe.initialScale=null;if(dn||El||Tf||jt(this.state))return;let i=Fh(yl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?zt(this.interactiveCanvas):At(this.interactiveCanvas,this.state));let a=Fe(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Cw(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=Iw(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=pl(x.snapLines,b),E=x.originSnapOffset?pl(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Se.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Bi(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&jT(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(jT(this.state.activeTool.type)){let{newElement:f}=this.state;df(f,!1)?this.setState({suggestedBindings:GT(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(At(this.interactiveCanvas,this.state),y===E)nn(ne(l-b,s-x),y)>=Qg?this.scene.mutateElement(f,{points:[...w,ne(l-b,s-x)]},{informMutation:!1,isDragging:!1}):xe(this.interactiveCanvas,De.POINTER);else if(w.length>2&&E&&nn(ne(l-b,s-x),E)<Qg)xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=nt(l,s,t[Y.CTRL_OR_CMD]||We(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],k=v-b-S,A=C-x-L;Jg(t)&&({width:k,height:A}=JT(S+b,L+x,v,C)),tI(w,this.state.zoom.value)&&xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),ne(S+k,L+A)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(c.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(c.length===1&&We(c[0]))){let f=hI(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){xe(this.interactiveCanvas,uI(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=gI(zi(c),l,s,this.state.zoom,t.pointerType,this.device);if(f){xe(this.interactiveCanvas,uI({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!bt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(xe(this.interactiveCanvas,De.POINTER),GE(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(xu(),u&&(u.link||Ar(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,co(u)?De.TEXT:De.CROSSHAIR):this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.AUTO):i?xe(this.interactiveCanvas,De.AUTO):t[Y.CTRL_OR_CMD]?xe(this.interactiveCanvas,De.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,c))&&!u?.locked&&(u&&hl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(xe(this.interactiveCanvas,De.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!We(u)||!(u.startBinding||u.endBinding))&&(xe(this.interactiveCanvas,De.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:pl(f.hoveredElementIds,mo({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:pl(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});I(this,"handleTouchMove",t=>{wl=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(xg,null)),ze.get(no)&&this.updateEditorAtom(no,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let c=this.state.newElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==c.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ye(Object.keys(this.state.selectedElementIds).filter(p=>p!==c.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?mt.EVENTUALLY:mt.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.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=rf(this.device,{isTouchScreen:!0})),El||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===an.ERASER&&this.state.activeTool.type!==Co.eraser){this.setState({activeTool:Vo(this.state,{type:Co.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{p(),u?.(),bt(this.state)&&this.setState({activeTool:Vo(this.state,{...this.state.activeTool.lastActiveTool||{type:Co.selection},lastActiveToolBeforeEraser:null})})},p=_e(window,ee.POINTER_UP,c,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==an.MAIN&&t.button!==an.TOUCH&&t.button!==an.ERASER||pe.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;this.state.activeTool.type==="lasso"?this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey):this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?At(this.interactiveCanvas,this.state):this.state.activeTool.type===Co.frame||this.state.activeTool.type===Co.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i),this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),d=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(c=>s(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ee.POINTER_MOVE,l),window.addEventListener(ee.POINTER_UP,s),window.addEventListener(ee.KEYDOWN,d),window.addEventListener(ee.KEYUP,m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=d)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Fe({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(hl(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&hl(this.hitLinkElement)&&!Qf(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,ne(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(wl=!1,Dr?wl=!0:Dr=window.setTimeout(()=>{Dr=0,wl||this.handleCanvasContextMenu(t)},Nz))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Dr),Dr=0,wl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{vl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(pe.pointers.size<=1&&(t.button===an.WHEEL||t.button===an.MAIN&&dn||jt(this.state)||this.state.viewModeEnabled)))return!1;El=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,De.GRABBING);let{clientX:i,clientY:a}=t,l=td(d=>{let m=i-d.clientX,c=a-d.clientY;if(i=d.clientX,a=d.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(c)>1)){r=!0;let p=f=>{document.body.removeEventListener(ee.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ee.PASTE,p),window.removeEventListener(ee.POINTER_UP,u)},100)};document.body.addEventListener(ee.PASTE,p),window.addEventListener(ee.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-c/this.state.zoom.value})}),s=Pe(vl=()=>{vl=null,El=!1,dn||(this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):At(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,l),window.removeEventListener(ee.POINTER_UP,s),window.removeEventListener(ee.BLUR,s),l.flush()});return window.addEventListener(ee.BLUR,s),window.addEventListener(ee.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ee.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!We(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=hI(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=gI(zi(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=of(QH(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&Zt(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=eG(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Se.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),d=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,d),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let m=r.hit.element,c=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((m===null||!c)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ye({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(m!=null){if(t[Y.CTRL_OR_CMD])return t.altKey||(this.state.selectedElementIds[m.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...KH(p,m),previousSelectedElementIds:this.state.selectedElementIds}))),!1;this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!mI(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Kt(m))iI(f,m.id).forEach(b=>{delete u[b.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let b=m.groupIds,x=new Set(b.flatMap(w=>bl(this.scene.getNonDeletedElements(),w)).filter(w=>Kt(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>bl(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>p.selectedGroupIds[b])||(u={[m.id]:!0})),{...mo({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:m.link||Ar(m)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);$T(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Vo(this.state,{type:"selection"})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=nt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,d=aH({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[ne(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(d),this.setState(c=>{let p={...c.selectedElementIds};return delete p[d.id],{selectedElementIds:ye(p,c)}});let m=nf(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:d,startBoundElement:m,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=lH({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=qd(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=WT({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});I(this,"createImageElement",async({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0,imageFile:i})=>{let[a,l]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=n?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null,d=100/this.state.zoom.value,m=dH({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:s?s.id:null,x:a-d/2,y:l-d/2,width:d,height:d});return await this.insertImageElement(m,i)});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&tI(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(wt);return}if(We(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(wt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&nn(ne(n.origin.x-a,n.origin.y-l),s)<Qg){this.actionManager.executeAction(wt);return}this.setState(d=>({selectedElementIds:ye({...d.selectedElementIds,[i.id]:!0},d)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),xe(this.interactiveCanvas,De.POINTER)}else{let[i,a]=nt(n.origin.x,n.origin.y,t[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:d}=this.state,[m,c]=r==="arrow"?[s,d]:[null,null],p=r==="arrow"?sH({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Pr.round?{type:Kd.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Pr.elbow,fixedSegments:this.state.currentItemArrowType===Pr.elbow?[]:null}):mH({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Kd.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ye(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,ne(0,0)]});let u=nf(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,We(p),We(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=nt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=WT({type:"embeddable",...l}):s=cH({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=nt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Mr},l=r===Co.magicframe?VT(a):iH(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||mf(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,sn(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async(t,r)=>{if(!Nl(r))throw new Error(g("errors.unsupportedFileType"));let n=r.type;if(xe(this.interactiveCanvas,"wait"),n===Lr.svg)try{r=xm(rI(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(r)||p1(r));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{r=await Fl(r,{maxWidthOrHeight:wz})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>DT)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(DT/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await bm(r);return new Promise(async(s,d)=>{try{let m=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([m]);if(p.size)throw new Error("Image cache update resulted with an error.")}let c=await this.imageCache.get(i)?.image;if(c&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(m,c);Object.assign(m,p)}s(m)}catch(m){console.error(m),d(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,r)=>{let n=this.scene.getElement(t.id)??t;return sn(n,{fileId:r})});I(this,"insertImageElement",async(t,r)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{let n=await this.initializeImage(t,r),i=this.scene.getElementsIncludingDeleted().map(a=>a.id===n.id?n:a);return this.updateScene({captureUpdate:mt.IMMEDIATELY,elements:i,appState:{selectedElementIds:ye({[n.id]:!0},this.state)}}),n}catch(n){return this.store.scheduleAction(mt.NEVER),this.scene.mutateElement(t,{isDeleted:!0}),this.actionManager.executeAction(wt),this.setState({errorMessage:n.message||g("errors.imageInsertError")}),null}});I(this,"onImageAction",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Fe({clientX:t,clientY:r},this.state),a=await Ml({description:"Image",extensions:Object.keys(Iz)});await this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1,imageFile:a}),this.setState({},()=>{this.actionManager.executeAction(wt)})}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Vo(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(wt)})}});I(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,d=t.y+t.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await wH({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&(this.store.scheduleAction(mt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>ul(a)&&i.has(a.fileId)?sn(a,{status:"error"}):a))),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=yH(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&fl.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",gz(()=>{this.addNewImagesToImageCache()},Cz));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=nH(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=nf(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ee.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ee.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ee.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ee.TOUCH_END,this.onTouchEnd))});I(this,"handleAppOnDrop",async t=>{let{file:r,fileHandle:n}=await f1(t),{x:i,y:a}=Fe(t,this.state);try{if(Nl(r)&&this.isToolSupported("image")){if(r?.type===Lr.png||r?.type===Lr.svg)try{let s=await Bl(r,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...s,appState:{...s.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:mt.IMMEDIATELY});return}catch(s){if(s.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}this.createImageElement({sceneX:i,sceneY:a,imageFile:r});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(Lr.excalidrawlib);if(l&&typeof l=="string"){try{let s=m1(l);this.addElementsFromPasteOrLibrary({elements:xc(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,n),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&hf(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||qd(s)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:ef(s)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await x1(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await gm(t,this.state,n,r)}catch(a){let l=a instanceof jf;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Lr.excalidraw?(TI(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:mt.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:mt.IMMEDIATELY})):i.type===Lr.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==an.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=Fe(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",d=this.excalidrawContainerRef.current,{top:m,left:c}=d.getBoundingClientRect(),p=t.clientX-c,u=t.clientY-m;re("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...mo({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Zt(i)?new Se(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){fI({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Oi(t.origin.x,a.x),height:Oi(t.origin.y,a.y),shouldMaintainAspectRatio:dl(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,d]=nt(a.x,a.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=ul(l)&&this.imageCache.get(l.fileId)?.image,c=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=Tw(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,d+=p.y,this.setState({snapLines:u}),fI({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:d,width:Oi(t.originInGrid.x,s),height:Oi(t.originInGrid.y,d),shouldMaintainAspectRatio:cn(l)?!dl(r):dl(r),shouldResizeFromCenter:LT(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===Co.frame||this.state.activeTool.type===Co.magicframe)&&this.setState({elementsToHighlight:xf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=nt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&cn(s)){let d=t.originalElements.get(s.id),m=ul(s)&&this.imageCache.get(s.fileId)?.image;if(d&&cn(d)&&m&&!(m instanceof Promise)){let[c,p]=nt(i.x,i.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=_h([s],[d],this,r,u,n);this.scene.mutateElement(s,FH(s,this.scene.getNonDeletedElementsMap(),n,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,r.shiftKey?d.width/d.height:void 0)),lf(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(c=>Kt(c)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&We(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,d]=nt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(c=>{iI(this.scene.getNonDeletedElements(),c.id).forEach(u=>{m.set(c.id+u.id,{x:u.x-c.x,y:u.y-c.y})})}),!this.state.selectedElementsAreBeingDragged){let[c,p]=nt(l.x,l.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=_h(n,j(f,this.state),this,r,u,a);s+=b.x,d+=b.y,this.setState({snapLines:x})}if(tG(t.originalElements,a,n,this.scene,Jg(r),LT(r),n.some(c=>cn(c))?!dl(r):dl(r),s,d,t.resize.center.x,t.resize.center.y)){let c=sf(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{xf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:c}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(rc,oc),t==="canvas"?this.state.viewModeEnabled?[...r,ic,ei,Sh,ti]:[nu,Ye,rc,oc,nc,Ye,qm,KE,Ye,ic,iu,ei,Sh,ti]:(r.push(nc),this.state.viewModeEnabled?[Qn,...r]:[Ye,tc,Qn,nu,Ye,tw,ow,rw,Ye,vh,Ye,...r,Ye,Kp,Zp,Ye,qp,dw,su,cu,DE,Jp,Ye,tu,Ye,Km,Zm,$m,jm,Ye,ou,ru,Ye,wi,Ye,ka,uc,Ye,Jm,Ma,Ye,ra])});I(this,"handleWheel",Pe(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[Y.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),El)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=Fz*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let d=this.state.zoom.value-s/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Ao({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(d)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));I(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=Fe({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:pe.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",BT(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:d,offsetTop:m,offsetLeft:c}=this.state;if(n===s&&i===d&&a===c&&l===m){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=$o(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:d=r.theme,name:m=`${g("labels.untitled")}-${OT()}`}=t;if(this.state={...r,theme:d,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=bz(),this.library=new Ey(this),this.actionManager=new Wc(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new xI,this.canvas=document.createElement("canvas"),this.rc=fz.canvas(this.canvas),this.renderer=new ja(this.scene),this.visibleElements=[],this.store=new nG(this),this.history=new Va(this.store),n){let c={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Zo(this.scene),this.history=new Va(this.store),this.actionManager.registerAll(ss),this.actionManager.registerAction(aw(this.history)),this.actionManager.registerAction(lw(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values($d).includes(i)&&If.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Hi(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=If.get(t.id);switch(n||(If.set(t.id,$d.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case $d.PLAYING:case $d.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Ar(a)&&this.embedsValidationStatus.get(a.id)===!0||Hi(a));return ue(sG,{children:i.map(a=>{let{x:l,y:s}=jd({sceneX:a.x,sceneY:a.y},this.state),d=QT(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(d&&!m&&this.initializedEmbeds.add(a.id),!(d||m))return null;let p;if(Hi(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>oI(`
|
|
24
|
+
C -->|Three| F[Car]`,WT=cF(Wl,300),pF=({mermaidToExcalidrawLib:e})=>{let[o,t]=GT(()=>$t.get(sF.MERMAID_TO_EXCALIDRAW)||mF),r=lF(o.trim()),[n,i]=GT(null),a=UT(null),l=UT({elements:[],files:null}),s=Oe();YT(()=>{im({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(m=>{dF()&&console.error("Failed to parse mermaid definition",m)}),WT(r)},[r,e]),YT(()=>()=>{WT.flush()},[]);let d=()=>{am({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return VT(uF,{children:[No("div",{className:"ttd-dialog-desc",children:No(Et,{i18nKey:"mermaid.description",flowchartLink:m=>No("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>No("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>No("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),VT(rm,{children:[No(ia,{label:g("mermaid.syntax"),children:No(em,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{d()}})}),No(ia,{label:g("mermaid.preview"),panelAction:{action:()=>{d()},label:g("mermaid.button"),icon:jn},renderSubmitShortcut:()=>No(nm,{}),children:No(om,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},XT=pF;import*as $T from"@radix-ui/react-tabs";import{useRef as KT}from"react";import{isMemberOf as hF}from"@excalidraw/common";import{jsx as gF}from"react/jsx-runtime";var ZT=e=>{let o=me(),t=KT(null),r=KT(0);return gF($T.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&hF(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};ZT.displayName="TTDDialogTabs";var jT=ZT;import*as qT from"@radix-ui/react-tabs";import{jsx as fF}from"react/jsx-runtime";var Qg=({children:e,...o})=>fF(qT.List,{className:"ttd-dialog-triggers",...o,children:e});Qg.displayName="TTDDialogTabTriggers";import*as QT from"@radix-ui/react-tabs";import{jsx as JT}from"react/jsx-runtime";var lm=({children:e,tab:o,onSelect:t,...r})=>JT(QT.Trigger,{value:o,asChild:!0,onSelect:t,children:JT("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});lm.displayName="TTDDialogTabTrigger";import*as eI from"@radix-ui/react-tabs";import{jsx as bF}from"react/jsx-runtime";var sm=({tab:e,children:o,...t})=>bF(eI.Content,{...t,value:e,children:o});sm.displayName="TTDDialogTab";import{jsx as vt,jsxs as Hr}from"react/jsx-runtime";var tf=3,aa=1e3,EF=he(null),yF=he(null),of=e=>{let o=xe();return o.openDialog?.name!=="ttd"?null:vt(wF,{...e,tab:o.openDialog.tab})},wF=nr("TTDDialogBase",({tab:e,...o})=>{let t=Oe(),r=me(),n=ef(null),[i,a]=de(yF),[l,s]=cm(i?.prompt??""),d=l.trim(),m=k=>{s(k.target.value),a(P=>({generatedResponse:P?.generatedResponse??null,prompt:k.target.value}))},[c,p]=cm(!1),[u,f]=de(EF),b=async()=>{if(d.length>aa||d.length<tf||c||u?.rateLimitRemaining===0||"__fallback"in o){d.length<tf&&I(new Error(`Prompt is too short (min ${tf} characters)`)),d.length>aa&&I(new Error(`Prompt is too long (max ${aa} characters)`));return}try{p(!0),ae("ai","generate","ttd");let{generatedResponse:k,error:P,rateLimit:S,rateLimitRemaining:B}=await o.onTextSubmit(d);if(typeof k=="string"&&a(A=>({generatedResponse:k,prompt:A?.prompt??null})),tI(S)&&tI(B)&&f({rateLimit:S,rateLimitRemaining:B}),P){I(P);return}if(!k){I(new Error("Generation failed"));return}try{await im({canvasRef:n,data:y,mermaidToExcalidrawLib:w,setError:I,mermaidDefinition:k}),ae("ai","mermaid parse success","ttd")}catch(A){console.info(`%cTTD mermaid render errror: ${A.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
25
|
+
TTD mermaid definition render errror: ${A.message}`,"color: yellow"),ae("ai","mermaid parse failed","ttd"),I(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(k){let P=k.message;(!P||P==="Failed to fetch")&&(P="Request failed"),I(new Error(P))}finally{p(!1)}},x=ef(b);x.current=b;let[w,E]=cm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});xF(()=>{(async()=>{await w.api,E(P=>({...P,loaded:!0}))})()},[w.api]);let y=ef({elements:[],files:null}),[v,I]=cm(null);return vt(He,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Hr(jT,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?vt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Hr(Qg,{children:[vt(lm,{tab:"text-to-diagram",children:Hr("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),vt("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"})]})}),vt(lm,{tab:"mermaid",children:"Mermaid"})]}),vt(sm,{className:"ttd-dialog-content",tab:"mermaid",children:vt(XT,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&Hr(sm,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[vt("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."}),Hr(rm,{children:[vt(ia,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:jn},onTextSubmitInProgess:c,panelActionDisabled:d.length>aa||u?.rateLimitRemaining===0,renderTopRight:()=>u?Hr("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:()=>vt(nm,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Hr("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Wl(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",vt(vr,{icon:jn})]});let k=d.length/aa;return k>.8?Hr("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:k>1?"var(--color-danger)":void 0},children:["Length: ",d.length,"/",aa]}):null},children:vt(em,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),vt(ia,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),am({app:t,data:y})},label:"Insert",icon:jn},children:vt(om,{canvasRef:n,error:v,loaded:w.loaded})})]})]})]})})});import{round as HI}from"@excalidraw/math";import RO from"clsx";import NO from"lodash.throttle";import{useEffect as GI,useMemo as bf,useState as BO,memo as FO}from"react";import{STATS_PANELS as bm}from"@excalidraw/common";import{getCommonBounds as OO}from"@excalidraw/element";import{getUncroppedWidthAndHeight as zO}from"@excalidraw/element";import{isElbowArrow as HO,isImageElement as xf}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as GO}from"@excalidraw/element";import{elementsAreInSameGroup as UO}from"@excalidraw/element";import{degreesToRadians as lI,radiansToDegrees as mI}from"@excalidraw/math";import{getBoundTextElement as sI}from"@excalidraw/element";import{isArrowElement as cI,isElbowArrow as _F}from"@excalidraw/element";import{updateBindings as dI}from"@excalidraw/element";import kF from"clsx";import{useEffect as iI,useRef as mm,useState as MF}from"react";import{EVENT as ca,KEYS as PF,cloneJSON as rf}from"@excalidraw/common";import{deepCopyElement as LF}from"@excalidraw/element";import{CaptureUpdateAction as aI}from"@excalidraw/element";import{pointFrom as Gr,pointRotateRads as dm}from"@excalidraw/math";import{getBoundTextElement as vF}from"@excalidraw/element";import{isFrameLikeElement as rI}from"@excalidraw/element";import{getSelectedGroupIds as TF,getElementsInGroup as IF,isInGroup as CF}from"@excalidraw/element";import{getFrameChildren as SF}from"@excalidraw/element";import{updateBindings as oI}from"@excalidraw/element";var nI=.01,Vl=10,Mt=(e,o)=>!(o==="angle"&&rI(e)),Ae=(e,o)=>{let t=e+o/2;return t-t%o},la=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var Tn=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,d]=[t.x+t.width/2,t.y+t.height/2],[m,c]=dm(Gr(t.x,t.y),Gr(s,d),t.angle),p=e-m,u=o-c,[f,b]=dm(Gr(e,o),Gr(s+p,d+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),oI(l,r);let x=vF(t,n);if(x){let w=a.get(x.id);w&&r.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(rI(t)){let w=SF(n,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,I]=[E.x+E.width/2,E.y+E.height/2],[k,P]=dm(Gr(E.x,E.y),Gr(v,I),E.angle),S=Math.round(k+p),B=Math.round(P+u),[A,L]=dm(Gr(S,B),Gr(v+p,I+u),-E.angle);r.mutateElement(y,{x:A,y:L},{informMutation:i,isDragging:!1}),oI(y,r,{simultaneouslyUpdated:w})})}},sa=(e,o)=>{let r=TF(o).map(n=>IF(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!CF(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as nf,jsxs as DF}from"react/jsx-runtime";var AF=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:m=1,dragFinishedCallback:c})=>{let p=Oe(),u=me(),f=mm(null),b=mm(null),[x,w]=MF(r.toString()),E=mm(null);E.current||(E.current={originalAppState:rf(d),originalElements:n,lastUpdatedValue:x,updatePending:!1}),iI(()=>{let I=r.toString();w(I),E.current.lastUpdatedValue=I},[r]);let y=(I,k,P)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let S=Number(I);if(isNaN(S)){w(r.toString());return}let B=Number(S.toFixed(2)),A=Number(r);(isNaN(A)||Math.abs(B-A)>=nI)&&(E.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:k,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:B,property:l,originalAppState:P,setInputValue:L=>w(String(L)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:aI.IMMEDIATELY}))},v=mm({});return v.current.handleInputValue=y,iI(()=>{let I=f.current,k=v.current;return()=>{let P=I?.value;P&&k.handleInputValue?.(P,E.current.originalElements,E.current.originalAppState),window.removeEventListener(ca.POINTER_MOVE,k.onPointerMove,!1),window.removeEventListener(ca.POINTER_UP,k.onPointerUp,!1)}},[i]),i?DF("div",{className:kF("drag-input-container",!i&&"disabled"),"data-testid":e,children:[nf("div",{className:"drag-input-label",ref:b,onPointerDown:I=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let k=Number(f.current.value);isNaN(k)&&(k=0);let P=null,S=p.scene.getNonDeletedElements().reduce((D,F)=>(D.set(F.id,LF(F)),D),new Map),B=n.map(D=>S.get(D.id)),A=rf(d),L=0,R=0,Y=D=>{if(P&&S!==null&&B!==null){let F=D.clientX-P.x;F!==0&&(R+=F,Math.abs(R)>=m&&(R=Math.sign(R)*Math.floor(Math.abs(R)/m),L+=R,t({accumulatedChange:L,instantChange:R,originalElements:B,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:D.shiftKey,property:l,scene:s,originalAppState:A,setInputValue:G=>w(String(G)),app:p,setAppState:u}),R=0))}P={x:D.clientX,y:D.clientY}},q=()=>{window.removeEventListener(ca.POINTER_MOVE,Y,!1),p.syncActionResult({captureUpdate:aI.IMMEDIATELY}),c?.({app:p,setAppState:u,originalElements:B,originalAppState:A}),P=null,L=0,R=0,B=null,S=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(ca.POINTER_UP,q,!1)};v.current.onPointerMove=Y,v.current.onPointerUp=q,window.addEventListener(ca.POINTER_MOVE,Y,!1),window.addEventListener(ca.POINTER_UP,q,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?nf(vr,{icon:o}):e}),nf("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let k=I.target;k instanceof HTMLInputElement&&I.key===PF.ENTER&&(y(k.value,n,d),p.focusContainer())}},ref:f,value:x,onChange:I=>{E.current.updatePending=!0,w(I.target.value)},onFocus:I=>{I.target.select(),E.current.originalElements=n,E.current.originalAppState=rf(d)},onBlur:I=>{x?i&&y(I.target.value,E.current.originalElements,E.current.originalAppState):w(r.toString())},disabled:!i})]}):null},nt=AF;import{jsx as FF}from"react/jsx-runtime";var RF=15,NF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!_F(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=lI(r);n.mutateElement(l,{angle:u}),dI(l,n);let f=sI(l,i);f&&!cI(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(mI(a.angle)*100)/100,d=Math.round(e),m=(s+d)%360;t&&(m=Ae(m,RF)),m=m<0?m+360:m;let c=lI(m);n.mutateElement(l,{angle:c}),dI(l,n);let p=sI(l,i);p&&!cI(l)&&n.mutateElement(p,{angle:c})}},BF=({element:e,scene:o,appState:t,property:r})=>FF(nt,{label:"A",icon:As,value:Math.round(mI(e.angle)%360*100)/100,elements:[e],dragInputCallback:NF,editable:Mt(e,"angle"),scene:o,appState:t,property:r}),pI=BF;import{jsx as zF}from"react/jsx-runtime";var uI=5,OF=({property:e,scene:o,appState:t,setAppState:r})=>zF(nt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let d;return n?d=n:i&&(d=a?Ae(s.gridStep+uI*Math.sign(i),uI):s.gridStep+i),d?(d=M1(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),hI=OF;import{clamp as pm,round as af}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as um}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as gI,getUncroppedWidthAndHeight as xI}from"@excalidraw/element";import{resizeSingleElement as fI}from"@excalidraw/element";import{isImageElement as EI}from"@excalidraw/element";import{isFrameLikeElement as lf}from"@excalidraw/element";import{getElementsInResizingFrame as sf}from"@excalidraw/element";import{replaceAllElementsInFrame as yI}from"@excalidraw/element";import{jsx as WF}from"react/jsx-runtime";var bI=10,HF=e=>e.type==="image",GF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:d,app:m,setAppState:c})=>{let p=d.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=r||HF(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!EI(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,I=w.scale[1]===-1,{width:k,height:P}=xI(w),S=E.naturalWidth/k,B=E.naturalHeight/P,A=v?E.width+E.x:E.naturalWidth-E.x,L=I?E.height+E.y:E.naturalHeight-E.y,R=gI*S,Y=gI*B;if(i!==void 0){if(a==="width"){let Z=i*S,te=pm(Z,R,A);y={...y,width:te,x:v?E.x+E.width-te:E.x}}else if(a==="height"){let Z=i*B,te=pm(Z,Y,L);y={...y,height:te,y:I?E.y+E.height-te:E.y}}d.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/k),height:y.height/(E.naturalHeight/P)});return}let q=a==="width"?s:0,D=a==="height"?s:0,F=pm(E.width+q,R,A),G=pm(E.height+D,R,L);y={...E,x:v?E.x+E.width-F:E.x,y:I?E.y+E.height-G:E.y,width:F,height:G},d.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/k),height:y.height/(E.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,um),E=Math.max(a==="height"?i:b?i/x:u.height,um);if(fI(w,E,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),lf(f)){let y=sf(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap()),v=yI(d.getElementsIncludingDeleted(),y,f,m);d.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(n?y=Ae(y,bI):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(n?v=Ae(v,bI):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(um,v),y=Math.max(um,y),fI(y,v,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),lf(f)){let I=sf(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap());c({elementsToHighlight:I})}}}},UF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&lf(a)){let l=sf(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=yI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},YF=({property:e,element:o,scene:t,appState:r})=>{let n=af(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&EI(o)&&o.crop){let{width:i,height:a}=xI(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=af(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=af(o.crop.height*l,2)}}return WF(nt,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:GF,value:n,editable:Mt(o,e),scene:t,appState:r,property:e,dragFinishedCallback:UF})},cf=YF;import{getBoundTextElement as VF,redrawTextBoundingBox as XF}from"@excalidraw/element";import{hasBoundTextElement as KF,isTextElement as vI}from"@excalidraw/element";import{jsx as qF}from"react/jsx-runtime";var wI=4,$F=4,ZF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!vI(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),wI);else if(a.type==="text"){let d=Math.round(a.fontSize),m=Math.round(e);s=Math.max(d+m,wI),t&&(s=Ae(s,$F))}s&&(n.mutateElement(l,{fontSize:s}),XF(l,n.getContainerElement(l),n))}},jF=({element:e,scene:o,appState:t,property:r})=>{let n=vI(e)?e:KF(e)?VF(e,o.getNonDeletedElementsMap()):null;return n?qF(nt,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:ZF,icon:rn,appState:t,scene:o,property:r}):null},TI=jF;import{degreesToRadians as II,radiansToDegrees as kI}from"@excalidraw/math";import{getBoundTextElement as CI}from"@excalidraw/element";import{isArrowElement as SI}from"@excalidraw/element";import{isInGroup as df}from"@excalidraw/element";import{jsx as tO}from"react/jsx-runtime";var JF=15,QF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(d=>a.get(d.id)).filter(d=>d&&!df(d)&&Mt(d,n)),s=o.filter(d=>!df(d)&&Mt(d,n));if(r!==void 0){let d=II(r);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:d});let c=CI(m,a);c&&!SI(m)&&i.mutateElement(c,{angle:d})}i.triggerUpdate();return}for(let d=0;d<l.length;d++){let m=l[d];if(!m)continue;let c=s[d],p=Math.round(kI(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Ae(f,JF)),f=f<0?f+360:f;let b=II(f);i.mutateElement(m,{angle:b});let x=CI(m,a);x&&!SI(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},eO=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!df(s)&&Mt(s,"angle")),i=n.map(s=>Math.round(kI(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>Mt(s,"angle"));return tO(nt,{label:"A",icon:As,value:a,elements:e,dragInputCallback:QF,editable:l,appState:t,scene:o,property:r})},MI=eO;import{pointFrom as PI}from"@excalidraw/math";import{useMemo as oO}from"react";import{MIN_WIDTH_OR_HEIGHT as Ur}from"@excalidraw/common";import{getElementsInResizingFrame as mf,isFrameLikeElement as pf,replaceAllElementsInFrame as DI,updateBoundElements as rO}from"@excalidraw/element";import{rescalePointsInElement as nO,resizeSingleElement as LI}from"@excalidraw/element";import{getBoundTextElement as iO,handleBindTextResize as aO}from"@excalidraw/element";import{isTextElement as _I}from"@excalidraw/element";import{getCommonBounds as hm}from"@excalidraw/element";import{jsx as pO}from"react/jsx-runtime";var da=10,lO=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,d=o+i*t;return{width:a,height:l,x:s,y:d,...nO(r,a,l,!1),..._I(r)?{fontSize:r.fontSize*t}:{}}},sO=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=lO(e,o,r,i);l.mutateElement(n,d);let m=iO(i,a);if(m){let c=m.fontSize*r;rO(n,l,{newSize:{width:d.width,height:d.height}});let p=s.get(m.id);p&&_I(p)&&(l.mutateElement(p,{fontSize:c}),aO(n,l,t==="width"?"e":"s",!0))}},AI=(e,o,t,r,n,i,a,l,s,d)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];sO(n[0],n[1],i,m,u,p,s,d)}},cO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let m=a.getNonDeletedElementsMap(),c=sa(o,r);if(i!==void 0){for(let b of c){let x=la(b,m,t);if(x.length>1){let w=x.map(R=>R.latest),E=x.map(R=>R.original),[y,v,I,k]=hm(E),P=I-y,S=k-v,B=P/S,A=Math.max(Ur,l==="width"?Math.max(0,i):P),L=Math.max(Ur,l==="height"?Math.max(0,i):S);AI(A,L,S,B,PI(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&Mt(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(n?v=Ae(v,da):v=Math.round(v));let I=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(n?I=Ae(I,da):I=Math.round(I)),v=Math.max(Ur,v),I=Math.max(Ur,I),LI(v,I,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),pf(E)){let k=mf(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap()),P=DI(a.getElementsIncludingDeleted(),k,E,d);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of c){let x=la(b,m,t);if(x.length>1){let w=x.map(R=>R.latest),E=x.map(R=>R.original),[y,v,I,k]=hm(E),P=I-y,S=k-v,B=P/S,A=Math.max(0,P+p);l==="width"&&(n?A=Ae(A,da):A=Math.round(A));let L=Math.max(0,S+u);l==="height"&&(n?L=Ae(L,da):L=Math.round(L)),A=Math.max(Ur,A),L=Math.max(Ur,L),AI(A,L,S,B,PI(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&Mt(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(n?v=Ae(v,da):v=Math.round(v));let I=Math.max(0,y.height+u);if(l==="height"&&(n?I=Ae(I,da):I=Math.round(I)),v=Math.max(Ur,v),I=Math.max(Ur,I),LI(v,I,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),pf(E)){let k=mf(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap());f.push(...k)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},dO=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&pf(a)){let l=mf(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=DI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},mO=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=oO(()=>r.map(d=>{let m=la(d,t);if(m.length>1){let[p,u,f,b]=hm(m.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[c]=m;return Math.round((e==="width"?c.latest.width:c.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return pO(nt,{label:e==="width"?"W":"H",elements:o,dragInputCallback:cO,value:l,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:dO})},uf=mO;import{getBoundTextElement as uO,redrawTextBoundingBox as RI}from"@excalidraw/element";import{hasBoundTextElement as hO,isTextElement as gO}from"@excalidraw/element";import{isInGroup as fO}from"@excalidraw/element";import{jsx as wO}from"react/jsx-runtime";var NI=4,bO=4,xO=(e,o)=>e.reduce((t,r)=>{if(!r||fO(r))return t;if(gO(r))return t.push(r),t;if(hO(r)){let n=uO(r,o);if(n)return t.push(n),t}return t},[]),EO=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),NI);for(let s of a)n.mutateElement(s,{fontSize:l}),RI(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let d=0;d<a.length;d++){let m=a[d],c=s[d],p=Math.round(c.fontSize),u=Math.round(e),f=Math.max(p+u,NI);t&&(f=Ae(f,bO)),n.mutateElement(m,{fontSize:f}),RI(m,n.getContainerElement(m),n)}n.triggerUpdate()}},yO=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=xO(e,n);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return wO(nt,{label:"F",icon:rn,elements:i,dragInputCallback:EO,value:l,editable:s,scene:o,property:r,appState:t})},BI=yO;import{pointFrom as Yr,pointRotateRads as gm}from"@excalidraw/math";import{useMemo as vO}from"react";import{isTextElement as TO}from"@excalidraw/element";import{getCommonBounds as hf}from"@excalidraw/element";import{jsx as MO}from"react/jsx-runtime";var IO=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,d]=[l.x+l.width/2,l.y+l.height/2],[m,c]=gm(Yr(l.x,l.y),Yr(s,d),l.angle),p=e==="x"?Math.round(m+o):m,u=e==="y"?Math.round(c+t):c;Tn(p,u,l,i,n,!1)}},CO=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=hf(t),s=e-a,d=o-l;for(let m=0;m<t.length;m++){let c=t[m],p=i.get(c.id);if(p&&(!TO(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=gm(Yr(p.x,p.y),Yr(u,f),p.angle);Tn(b+s,x+d,c,n,r,!1)}}},SO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of sa(o,l)){let u=la(p,s,t);if(u.length>1){let[f,b,,]=hf(u.map(E=>E.latest));CO(i==="x"?n:f,i==="y"?n:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&Mt(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=gm(Yr(f.x,f.y),Yr(x,w),f.angle);Tn(i==="x"?n:E,i==="y"?n:y,f,a,t,!1)}}}a.triggerUpdate();return}let d=r?Ae(e,Vl):e;IO(i,i==="x"?d:0,i==="y"?d:0,o,t,a),a.triggerUpdate()},kO=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=vO(()=>r.map(s=>{let d=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(d.length>1){let[b,x]=hf(d);return Math.round((e==="x"?b:x)*100)/100}let[m]=d,[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=gm(Yr(m.x,m.y),Yr(c,p),m.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return MO(nt,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:SO,value:l,property:e,scene:n,appState:i})},gf=kO;import{clamp as Xl,pointFrom as fm,pointRotateRads as OI,round as FI}from"@excalidraw/math";import{getFlipAdjustedCropPosition as PO,getUncroppedWidthAndHeight as LO}from"@excalidraw/element";import{isImageElement as zI}from"@excalidraw/element";import{jsx as _O}from"react/jsx-runtime";var AO=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let d=l.getNonDeletedElementsMap(),m=t[0],[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=OI(fm(m.x,m.y),fm(c,p),m.angle);if(s.croppingElementId===m.id){let y=d.get(m.id);if(!y||!zI(y)||!y.crop)return;let v=y.crop,I=v,k=y.scale[0]===-1,P=y.scale[1]===-1,{width:S,height:B}=LO(y);if(i!==void 0){if(a==="x"){let R=i*(v.naturalWidth/S);k?I={...v,x:Xl(v.naturalWidth-R-v.width,0,v.naturalWidth-v.width)}:I={...v,x:Xl(i*(v.naturalWidth/S),0,v.naturalWidth-v.width)}}a==="y"&&(I={...v,y:Xl(i*(v.naturalHeight/B),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:I});return}let A=(a==="x"?o:0)*(k?-1:1),L=(a==="y"?o:0)*(P?-1:1);I={...v,x:Xl(v.x+A,0,v.naturalWidth-v.width),y:Xl(v.y+L,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:I});return}if(i!==void 0){Tn(a==="x"?i:u,a==="y"?i:f,m,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(n?Ae(m.x+b,Vl):u+b):u,E=a==="y"?Math.round(n?Ae(m.y+x,Vl):f+x):f;Tn(w,E,m,l,r)},DO=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=OI(fm(o.x,o.y),fm(o.x+o.width/2,o.y+o.height/2),o.angle),l=FI(e==="x"?i:a,2);if(n.croppingElementId===o.id&&zI(o)&&o.crop){let s=PO(o);s&&(l=FI(e==="x"?s.x:s.y,2))}return _O(nt,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:AO,scene:r,value:l,property:e,appState:n})},ff=DO;import{Fragment as Ef,jsx as ee,jsxs as Pt}from"react/jsx-runtime";var YO=50,Kl=e=>{let o=To(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=_r(e.app);return ee(WO,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},ke=({children:e,columns:o=1,heading:t,style:r,...n})=>ee("div",{className:RO("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});ke.displayName="StatsRow";var xm=({children:e,order:o,style:t,...r})=>ee("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});xm.displayName="StatsRows";Kl.StatsRow=ke;Kl.StatsRows=xm;var WO=FO(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),m=me(),c=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&xf(c),f=u?zO(c):null,[b,x]=BO({width:0,height:0}),w=bf(()=>NO(v=>{let I=OO(v);x({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},YO),[]);GI(()=>{w(s)},[i,s,w]),GI(()=>()=>w.cancel(),[w]);let E=bf(()=>sa(r,n),[r,n]),y=bf(()=>GO(r),[r]);return ee("div",{className:"exc-stats",children:Pt(Ye,{padding:3,children:[Pt("div",{className:"title",children:[ee("h2",{children:g("stats.title")}),ee("div",{className:"close",onClick:o,children:Ut})]}),Pt($a,{label:ee("h3",{children:g("stats.generalStats")}),open:!!(n.stats.panels&bm.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^bm.generalStats}})),children:[Pt(xm,{children:[ee(ke,{heading:!0,children:g("stats.scene")}),Pt(ke,{columns:2,children:[ee("div",{children:g("stats.shapes")}),ee("div",{children:s.length})]}),Pt(ke,{columns:2,children:[ee("div",{children:g("stats.width")}),ee("div",{children:b.width})]}),Pt(ke,{columns:2,children:[ee("div",{children:g("stats.height")}),ee("div",{children:b.height})]}),a&&Pt(Ef,{children:[ee(ke,{heading:!0,children:"Canvas"}),ee(ke,{children:ee(hI,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&ee("div",{id:"elementStats",style:{marginTop:12},children:ee($a,{label:ee("h3",{children:g("stats.elementProperties")}),open:!!(n.stats.panels&bm.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^bm.elementProperties}})),children:Pt(xm,{children:[c&&Pt(Ef,{children:[u&&ee(ke,{heading:!0,children:g("labels.unCroppedDimension")}),n.croppingElementId&&xf(c)&&f&&Pt(ke,{columns:2,children:[ee("div",{children:g("stats.width")}),ee("div",{children:HI(f.width,2)})]}),n.croppingElementId&&xf(c)&&f&&Pt(ke,{columns:2,children:[ee("div",{children:g("stats.height")}),ee("div",{children:HI(f.height,2)})]}),ee(ke,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),ee(ke,{children:ee(ff,{element:c,property:"x",elementsMap:d,scene:l,appState:n})}),ee(ke,{children:ee(ff,{element:c,property:"y",elementsMap:d,scene:l,appState:n})}),ee(ke,{children:ee(cf,{property:"width",element:c,scene:l,appState:n})}),ee(ke,{children:ee(cf,{property:"height",element:c,scene:l,appState:n})}),!HO(c)&&ee(ke,{children:ee(pI,{property:"angle",element:c,scene:l,appState:n})}),ee(ke,{children:ee(TI,{property:"fontSize",element:c,scene:l,appState:n})})]}),p&&Pt(Ef,{children:[UO(p)&&ee(ke,{heading:!0,children:g("element.group")}),Pt(ke,{columns:2,style:{margin:"0.3125rem 0"},children:[ee("div",{children:g("stats.shapes")}),ee("div",{children:r.length})]}),ee(ke,{children:ee(gf,{property:"x",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),ee(ke,{children:ee(gf,{property:"y",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),ee(ke,{children:ee(uf,{property:"width",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),ee(ke,{children:ee(uf,{property:"height",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),ee(ke,{children:ee(MI,{property:"angle",elements:p,scene:l,appState:n})}),ee(ke,{children:ee(BI,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:d})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as VO,useEffect as UI,useState as YI}from"react";import{normalizeLink as XO,KEYS as yf}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as KO,getLinkIdAndTypeFromSelection as $O}from"@excalidraw/element";import{jsx as ma,jsxs as Em}from"react/jsx-runtime";var ZO=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=KO})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=YI(a),[d,m]=YI(!1);UI(()=>{let p=Q(i,t),u=a;if(p.length>0&&n){let f=$O(p,t);f&&(u=XO(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let c=VO(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&d&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,d,r,o]);return UI(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===yf.ENTER&&c(),t.openDialog?.name==="elementLinkSelector"&&u.key===yf.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,c]),Em("div",{className:"ElementLinkDialog",children:[Em("div",{className:"ElementLinkDialog__header",children:[ma("h2",{children:g("elementLink.title")}),ma("p",{children:g("elementLink.desc")})]}),Em("div",{className:"ElementLinkDialog__input",children:[ma(Pr,{value:l??"",onChange:p=>{d||m(!0),s(p)},onKeyDown:p=>{p.key===yf.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&ma(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:_t})]}),Em("div",{className:"ElementLinkDialog__actions",children:[ma(Zo,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),ma(Zo,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},WI=ZO;import jO,{useState as qO}from"react";import{Fragment as JO,jsx as wf}from"react/jsx-runtime";var VI=({children:e,onClose:o})=>{let[t,r]=qO(!!e),{container:n}=Se(),i=jO.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return wf(JO,{children:t&&wf(He,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:wf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import QO from"react";import{isDarwin as XI,isFirefox as KI,isWindows as ez}from"@excalidraw/common";import{KEYS as Re}from"@excalidraw/common";import{Fragment as ZI,jsx as H,jsxs as Ht}from"react/jsx-runtime";var tz=()=>Ht("div",{className:"HelpDialog__header",children:[Ht("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[H("div",{className:"HelpDialog__link-icon",children:jm}),g("helpDialog.documentation")]}),Ht("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[H("div",{className:"HelpDialog__link-icon",children:jm}),g("helpDialog.blog")]}),Ht("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[H("div",{className:"HelpDialog__link-icon",children:Ss}),g("helpDialog.github")]}),Ht("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[H("div",{className:"HelpDialog__link-icon",children:R0}),"YouTube"]})]}),oz=e=>Ht(ZI,{children:[H("h3",{children:e.title}),H("div",{className:"HelpDialog__islands-container",children:e.children})]}),vf=e=>Ht("div",{className:`HelpDialog__island ${e.className}`,children:[H("h4",{className:"HelpDialog__island-title",children:e.caption}),H("div",{className:"HelpDialog__island-content",children:e.children})]});function*rz(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var nz=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),W=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>H(iz,{children:nz(a)},a)));return Ht("div",{className:"HelpDialog__shortcut",children:[H("div",{children:e}),H("div",{className:"HelpDialog__key-container",children:[...rz(r,t?g("helpDialog.or"):null)]})]})},iz=e=>H("kbd",{className:"HelpDialog__key",...e}),$I=({onClose:e})=>{let o=QO.useCallback(()=>{e&&e()},[e]);return H(ZI,{children:Ht(He,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[H(tz,{}),Ht(oz,{title:g("helpDialog.shortcuts"),children:[Ht(vf,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[H(W,{label:g("toolBar.hand"),shortcuts:[Re.H]}),H(W,{label:g("toolBar.selection"),shortcuts:[Re.V,Re[1]]}),H(W,{label:g("toolBar.rectangle"),shortcuts:[Re.R,Re[2]]}),H(W,{label:g("toolBar.diamond"),shortcuts:[Re.D,Re[3]]}),H(W,{label:g("toolBar.ellipse"),shortcuts:[Re.O,Re[4]]}),H(W,{label:g("toolBar.arrow"),shortcuts:[Re.A,Re[5]]}),H(W,{label:g("toolBar.line"),shortcuts:[Re.L,Re[6]]}),H(W,{label:g("toolBar.freedraw"),shortcuts:[Re.P,Re[7]]}),H(W,{label:g("toolBar.text"),shortcuts:[Re.T,Re[8]]}),H(W,{label:g("toolBar.image"),shortcuts:[Re[9]]}),H(W,{label:g("toolBar.eraser"),shortcuts:[Re.E,Re[0]]}),H(W,{label:g("toolBar.frame"),shortcuts:[Re.F]}),H(W,{label:g("toolBar.laser"),shortcuts:[Re.K]}),H(W,{label:g("labels.eyeDropper"),shortcuts:[Re.I,"Shift+S","Shift+G"]}),H(W,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[_("CtrlOrCmd+Enter")]}),H(W,{label:g("helpDialog.editText"),shortcuts:[_("Enter")]}),H(W,{label:g("helpDialog.textNewLine"),shortcuts:[_("Enter"),_("Shift+Enter")]}),H(W,{label:g("helpDialog.textFinish"),shortcuts:[_("Esc"),_("CtrlOrCmd+Enter")]}),H(W,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),H(W,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),H(W,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),_("Enter")],isOr:!0}),H(W,{label:g("helpDialog.cropFinish"),shortcuts:[_("Enter"),_("Escape")],isOr:!0}),H(W,{label:g("toolBar.lock"),shortcuts:[Re.Q]}),H(W,{label:g("helpDialog.preventBinding"),shortcuts:[_("CtrlOrCmd")]}),H(W,{label:g("toolBar.link"),shortcuts:[_("CtrlOrCmd+K")]}),H(W,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ht(vf,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[H(W,{label:g("buttons.zoomIn"),shortcuts:[_("CtrlOrCmd++")]}),H(W,{label:g("buttons.zoomOut"),shortcuts:[_("CtrlOrCmd+-")]}),H(W,{label:g("buttons.resetZoom"),shortcuts:[_("CtrlOrCmd+0")]}),H(W,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),H(W,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),H(W,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),H(W,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),H(W,{label:g("buttons.zenMode"),shortcuts:[_("Alt+Z")]}),H(W,{label:g("buttons.objectsSnapMode"),shortcuts:[_("Alt+S")]}),H(W,{label:g("labels.toggleGrid"),shortcuts:[_("CtrlOrCmd+'")]}),H(W,{label:g("labels.viewMode"),shortcuts:[_("Alt+R")]}),H(W,{label:g("labels.toggleTheme"),shortcuts:[_("Alt+Shift+D")]}),H(W,{label:g("stats.fullTitle"),shortcuts:[_("Alt+/")]}),H(W,{label:g("search.title"),shortcuts:[ze("searchMenu")]}),H(W,{label:g("commandPalette.title"),shortcuts:KI?[ze("commandPalette")]:[ze("commandPalette"),ze("commandPalette",1)]})]}),Ht(vf,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[H(W,{label:g("helpDialog.createFlowchart"),shortcuts:[_("CtrlOrCmd+Arrow Key")],isOr:!0}),H(W,{label:g("helpDialog.navigateFlowchart"),shortcuts:[_("Alt+Arrow Key")],isOr:!0}),H(W,{label:g("labels.moveCanvas"),shortcuts:[_(`Space+${g("helpDialog.drag")}`),_(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),H(W,{label:g("buttons.clearReset"),shortcuts:[_("CtrlOrCmd+Delete")]}),H(W,{label:g("labels.delete"),shortcuts:[_("Delete")]}),H(W,{label:g("labels.cut"),shortcuts:[_("CtrlOrCmd+X")]}),H(W,{label:g("labels.copy"),shortcuts:[_("CtrlOrCmd+C")]}),H(W,{label:g("labels.paste"),shortcuts:[_("CtrlOrCmd+V")]}),H(W,{label:g("labels.pasteAsPlaintext"),shortcuts:[_("CtrlOrCmd+Shift+V")]}),H(W,{label:g("labels.selectAll"),shortcuts:[_("CtrlOrCmd+A")]}),H(W,{label:g("labels.multiSelect"),shortcuts:[_(`Shift+${g("helpDialog.click")}`)]}),H(W,{label:g("helpDialog.deepSelect"),shortcuts:[_(`CtrlOrCmd+${g("helpDialog.click")}`)]}),H(W,{label:g("helpDialog.deepBoxSelect"),shortcuts:[_(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(bi||KI)&&H(W,{label:g("labels.copyAsPng"),shortcuts:[_("Shift+Alt+C")]}),H(W,{label:g("labels.copyStyles"),shortcuts:[_("CtrlOrCmd+Alt+C")]}),H(W,{label:g("labels.pasteStyles"),shortcuts:[_("CtrlOrCmd+Alt+V")]}),H(W,{label:g("labels.sendToBack"),shortcuts:[XI?_("CtrlOrCmd+Alt+["):_("CtrlOrCmd+Shift+[")]}),H(W,{label:g("labels.bringToFront"),shortcuts:[XI?_("CtrlOrCmd+Alt+]"):_("CtrlOrCmd+Shift+]")]}),H(W,{label:g("labels.sendBackward"),shortcuts:[_("CtrlOrCmd+[")]}),H(W,{label:g("labels.bringForward"),shortcuts:[_("CtrlOrCmd+]")]}),H(W,{label:g("labels.alignTop"),shortcuts:[_("CtrlOrCmd+Shift+Up")]}),H(W,{label:g("labels.alignBottom"),shortcuts:[_("CtrlOrCmd+Shift+Down")]}),H(W,{label:g("labels.alignLeft"),shortcuts:[_("CtrlOrCmd+Shift+Left")]}),H(W,{label:g("labels.alignRight"),shortcuts:[_("CtrlOrCmd+Shift+Right")]}),H(W,{label:g("labels.duplicateSelection"),shortcuts:[_("CtrlOrCmd+D"),_(`Alt+${g("helpDialog.drag")}`)]}),H(W,{label:g("helpDialog.toggleElementLock"),shortcuts:[_("CtrlOrCmd+Shift+L")]}),H(W,{label:g("buttons.undo"),shortcuts:[_("CtrlOrCmd+Z")]}),H(W,{label:g("buttons.redo"),shortcuts:ez?[_("CtrlOrCmd+Y"),_("CtrlOrCmd+Shift+Z")]:[_("CtrlOrCmd+Shift+Z")]}),H(W,{label:g("labels.group"),shortcuts:[_("CtrlOrCmd+G")]}),H(W,{label:g("labels.ungroup"),shortcuts:[_("CtrlOrCmd+Shift+G")]}),H(W,{label:g("labels.flipHorizontal"),shortcuts:[_("Shift+H")]}),H(W,{label:g("labels.flipVertical"),shortcuts:[_("Shift+V")]}),H(W,{label:g("labels.showStroke"),shortcuts:[_("S")]}),H(W,{label:g("labels.showBackground"),shortcuts:[_("G")]}),H(W,{label:g("labels.showFonts"),shortcuts:[_("Shift+F")]}),H(W,{label:g("labels.decreaseFontSize"),shortcuts:[_("CtrlOrCmd+Shift+<")]}),H(W,{label:g("labels.increaseFontSize"),shortcuts:[_("CtrlOrCmd+Shift+>")]})]})]})]})})};import{CANVAS_SEARCH_TAB as az,DEFAULT_SIDEBAR as lz}from"@excalidraw/common";import{isFlowchartNodeElement as sz,isImageElement as jI,isLinearElement as qI,isLineElement as cz,isTextBindableContainer as dz,isTextElement as mz}from"@excalidraw/element";import{isNodeInFlowchart as pz}from"@excalidraw/element";import{jsx as Tf}from"react/jsx-runtime";var ve=e=>Array.isArray(e)?`<kbd>${e.map(_).join(" + ")}</kbd>`:`<kbd>${_(e)}</kbd>`,uz=({appState:e,isMobile:o,editorInterface:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===lz.name&&e.openSidebar.tab===az&&e.searchMatches?.matches.length)return g("hints.dismissSearch",{shortcut:ve("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(It(e))return g("hints.eraserRevert",{shortcut:ve("Alt")});if(n.type==="arrow"||n.type==="line")return s?g("hints.linearElementMulti",{shortcut_1:ve("Escape"),shortcut_2:ve("Enter")}):n.type==="arrow"?g("hints.arrowTool",{shortcut:ve("A")}):g("hints.linearElement");if(n.type==="freedraw")return g("hints.freeDraw");if(n.type==="text")return g("hints.text");if(n.type==="embeddable")return g("hints.embeddable");let d=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&d.length===1){let m=d[0];return qI(m)&&m.points.length===2?g("hints.lockAngle",{shortcut:ve("Shift")}):jI(m)?g("hints.resizeImage",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):g("hints.resize",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")})}if(a&&l==="mouse")return g("hints.rotate",{shortcut:ve("Shift")});if(d.length===1&&mz(d[0]))return g("hints.text_selected",{shortcut:ve("Enter")});if(e.editingTextElement)return g("hints.text_editing",{shortcut_1:ve("Escape"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return g("hints.leaveCropEditor",{shortcut_1:ve("Enter"),shortcut_2:ve("Escape")});if(d.length===1&&jI(d[0]))return g("hints.enterCropEditor",{shortcut:ve("Enter")});if(n.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return g("hints.deepBoxSelect",{shortcut:ve("CtrlOrCmd")});if(_r(r)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping",{shortcut:ve("CtrlOrCmd")});if(!d.length&&!o)return g("hints.canvasPanning",{shortcut_1:ve(g("keys.mmb")),shortcut_2:ve("Space")});if(d.length===1){if(qI(d[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected",{shortcut_1:ve("Delete"),shortcut_2:ve(["CtrlOrCmd","D"])}):g("hints.lineEditor_nothingSelected",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):cz(d[0])?g("hints.lineEditor_line_info",{shortcut:ve("Enter")}):g("hints.lineEditor_info",{shortcut_1:ve("CtrlOrCmd"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&dz(d[0])){let m=g("hints.bindTextToElement",{shortcut:ve("Enter")}),c=g("hints.createFlowchart",{shortcut:ve(["CtrlOrCmd","\u2191\u2193"])});return sz(d[0])?pz(d[0],r.scene.getNonDeletedElementsMap())?[m,c]:[m,c]:m}}}return null},JI=({appState:e,isMobile:o,editorInterface:t,app:r})=>{let n=uz({appState:e,isMobile:o,editorInterface:t,app:r});if(!n)return null;let a=(Array.isArray(n)?n.map(l=>l.replace(/\. ?$/,"")).join(", "):n).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,s)=>{if(s%2===1){let d=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return Tf("kbd",{children:d?d[1]:l},s)}return l});return Tf("div",{className:"HintViewer",children:Tf("span",{children:a})})};import{useEffect as t5,useRef as Ez,useState as Wr}from"react";import{DEFAULT_EXPORT_PADDING as yz,EXPORT_IMAGE_TYPES as If,isFirefox as wz,EXPORT_SCALES as vz,cloneJSON as o5}from"@excalidraw/common";import{useCallback as hz,useRef as gz,useState as fz}from"react";var bz=2e3,QI=()=>{let[e,o]=fz(null),t=gz(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},bz)},n=hz(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import xz from"clsx";import{jsx as e5}from"react/jsx-runtime";var $l=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>e5("div",{className:xz("Switch",{toggled:t,disabled:n}),children:e5("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Me,jsxs as Vr}from"react/jsx-runtime";var Tz="filter"in document.createElement("canvas").getContext("2d"),Iz=()=>Vr("div",{children:[Me("h3",{children:g("canvasError.cannotShowPreview")}),Me("p",{children:Me("span",{children:g("canvasError.canvasTooBig")})}),Vr("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),Cz=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=we(o,e),[l,s]=Wr(i),[d,m]=Wr(a),[c,p]=Wr(e.exportBackground),[u,f]=Wr(e.exportWithDarkMode),[b,x]=Wr(e.exportEmbedScene),[w,E]=Wr(e.exportScale),y=Ez(null),[v,I]=Wr(null),{onCopy:k,copyStatus:P,resetCopyStatus:S}=QI();t5(()=>{S()},[l,c,u,w,b,S]);let{exportedElements:B,exportingFrame:A}=mn(o,e,d);return t5(()=>{let L=y.current;if(!L)return;let R=L.offsetWidth,Y=L.offsetHeight;R&&kr({elements:B,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:yz,maxWidthOrHeight:Math.max(R,Y),exportingFrame:A}).then(q=>(I(null),zo(q).then(()=>{L.replaceChildren(q)}).catch(D=>{throw D.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):D}))).catch(q=>{console.error(q),I(q)})},[e,t,B,A,l,c,u,w,b]),Vr("div",{className:"ImageExportModal",children:[Me("h3",{children:g("imageExportDialog.header")}),Vr("div",{className:"ImageExportModal__preview",children:[Me("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Me(Iz,{})}),Me("div",{className:"ImageExportModal__preview__filename",children:!Rn&&Me("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:L=>{s(L.target.value),r.executeAction(bu,"ui",L.target.value)}})})]}),Vr("div",{className:"ImageExportModal__settings",children:[Me("h3",{children:g("imageExportDialog.header")}),a&&Me(Zl,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Me($l,{name:"exportOnlySelected",checked:d,onChange:L=>{m(L)}})}),Me(Zl,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Me($l,{name:"exportBackgroundSwitch",checked:c,onChange:L=>{p(L),r.executeAction(xu,"ui",L)}})}),Tz&&Me(Zl,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Me($l,{name:"exportDarkModeSwitch",checked:u,onChange:L=>{f(L),r.executeAction(AE,"ui",L)}})}),Me(Zl,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Me($l,{name:"exportEmbedSwitch",checked:b,onChange:L=>{x(L),r.executeAction(vc,"ui",L)}})}),Me(Zl,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Me(Xd,{name:"exportScale",value:w,onChange:L=>{E(L),r.executeAction(LE,"ui",L)},choices:vz.map(L=>({value:L,label:`${L}\xD7`}))})}),Vr("div",{className:"ImageExportModal__settings__buttons",children:[Me(Or,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>n(If.png,B,{exportingFrame:A}),icon:pp,children:g("imageExportDialog.button.exportToPng")}),Me(Or,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>n(If.svg,B,{exportingFrame:A}),icon:pp,children:g("imageExportDialog.button.exportToSvg")}),(bi||wz)&&Me(Or,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await n(If.clipboard,B,{exportingFrame:A}),k()},icon:$n,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Zl=({label:e,children:o,tooltip:t,name:r})=>Vr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Vr("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Me(Nt,{label:t,long:!0,children:h0})]}),Me("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),r5=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Wr(()=>({appStateSnapshot:o5(o),elementsSnapshot:o5(e)}));return Me(He,{onCloseRequest:i,size:"wide",title:!1,children:Me(Cz,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import kz from"react";import{getFrame as Mz}from"@excalidraw/common";import Cf from"open-color";import{jsx as Sz}from"react/jsx-runtime";var Sf=({children:e,color:o})=>Sz("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Cf[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Cf[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Cf[o][9]},children:e});import{Fragment as Lz,jsx as fo,jsxs as ym}from"react/jsx-runtime";var Pz=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return fo("div",{className:"ExportDialog ExportDialog--json",children:ym("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&ym(Sf,{color:"lime",children:[fo("div",{className:"Card-icon",children:vb}),fo("h2",{children:g("exportDialog.disk_title")}),ym("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Rn&&n.renderAction("changeProjectName")]}),fo(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(al,"ui")}})]}),s&&ym(Sf,{color:"pink",children:[fo("div",{className:"Card-icon",children:Aa}),fo("h2",{children:g("exportDialog.link_title")}),fo("div",{className:"Card-details",children:g("exportDialog.link_details")}),fo(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ae("export","link",`ui (${Mz()})`),await s(e,o,r),l()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},n5=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=kz.useCallback(()=>{a({openDialog:null})},[a]);return fo(Lz,{children:o.openDialog?.name==="jsonExport"&&fo(He,{onCloseRequest:l,title:g("buttons.export"),children:fo(Pz,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import Az from"clsx";import{jsx as i5,jsxs as _z}from"react/jsx-runtime";var Dz="small",a5=e=>_z("label",{className:Az("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${Dz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[i5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),i5("div",{className:"ToolIcon__icon",children:hr})]});import{Fragment as c5,jsx as j,jsxs as Gt}from"react/jsx-runtime";var Uz=({UIOptions:e})=>Gt(ht,{__fallback:!0,children:[j(ht.DefaultItems.LoadScene,{}),j(ht.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&j(ht.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&j(ht.DefaultItems.SaveAsImage,{}),j(ht.DefaultItems.SearchMenu,{}),j(ht.DefaultItems.Help,{}),j(ht.DefaultItems.ClearCanvas,{}),j(ht.Separator,{}),j(ht.Group,{title:"Excalidraw links",children:j(ht.DefaultItems.Socials,{})}),j(ht.Separator,{}),j(ht.DefaultItems.ToggleTheme,{}),j(ht.DefaultItems.ChangeCanvasBackground,{})]}),Yz=()=>Gt(jd,{__fallback:!0,children:[j(jd.Actions.SaveToDisk,{}),j(jd.Actions.ExportToImage,{})]}),Wz=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:d,renderTopLeftUI:m,renderTopRightUI:c,renderCustomStats:p,UIOptions:u,onExportImage:f,renderWelcomeScreen:b,children:x,app:w,isCollaborating:E,generateLinkForSelection:y})=>{let v=pe(),I=et(),k=I==="compact",P=Vw(),S=k?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},B=P.tunnelsJotai.Provider,[A,L]=de(br),R=()=>u.canvasActions.export?j(n5,{elements:n,appState:o,files:t,actionManager:e,exportOpts:u.canvasActions.export,canvas:i,setAppState:r}):null,Y=()=>!u.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:j(r5,{elements:n,appState:o,files:t,actionManager:e,onExportImage:f,onCloseRequest:()=>r({openDialog:null}),name:w.getName()}),q=()=>Gt("div",{style:{position:"relative"},children:[j(P.MainMenuTunnel.Out,{}),b&&j(P.WelcomeScreenMenuHintTunnel.Out,{})]}),D=()=>{let oe=k;return j(zl,{heading:"selectedShapeActions",className:In("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:oe?j(Ye,{className:In("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:j(a2,{appState:o,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w,setAppState:r})}):j(Ye,{className:Nz.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:j(t2,{appState:o,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w})})})},F=()=>{let oe=Hz(o,n),$=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return j(Gd,{side:"top",children:Gt("div",{className:"App-menu App-menu_top",children:[Gt(St.Col,{gap:S.menuTopGap,className:In("App-menu_top__left"),children:[q(),j("div",{className:In("selected-shape-actions-container",{"selected-shape-actions-container--compact":k}),children:oe&&D()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&j(zl,{heading:"shapes",className:"shapes-section",children:J=>Gt("div",{style:{position:"relative"},children:[b&&j(P.WelcomeScreenToolbarHintTunnel.Out,{}),j(St.Col,{gap:S.toolbarColGap,align:"start",children:Gt(St.Row,{gap:S.toolbarRowGap,className:In("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Gt(Ye,{padding:S.islandPadding,className:In("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":k}),children:[j(JI,{appState:o,isMobile:v.formFactor==="phone",editorInterface:v,app:w}),J,Gt(St.Row,{gap:S.toolbarInnerRowGap,children:[j(z3,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),j(P3,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),j("div",{className:"App-toolbar__divider"}),j(zd,{checked:no(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),j(s2,{setAppState:r,activeTool:o.activeTool,UIOptions:u,app:w})]})]}),E&&j(Ye,{style:{marginLeft:S.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:j(a5,{title:g("toolBar.laser"),checked:o.activeTool.type===l5.laser,onChange:()=>w.setActiveTool({type:l5.laser}),isMobile:!0})})]})})]})}),Gt("div",{className:In("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":k}),children:[o.collaborators.size>0&&j(Wd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),c?.(v.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!Z||o.openSidebar?.name!==kf.name)&&j(P.DefaultSidebarTriggerTunnel.Out,{}),$&&j(Kl,{app:w,onClose:()=>{e.executeAction(ki)},renderCustomStats:p})]})]})})},G=()=>j(Qd,{__fallback:!0,onDock:oe=>{ae("sidebar",`toggleDock (${oe?"dock":"undock"})`,`(${v.formFactor==="phone"?"mobile":"desktop"})`)}}),Z=ys(Hl),te=Gt(c5,{children:[x,j(Uz,{UIOptions:u}),j(Qd.Trigger,{__fallback:!0,icon:zn,title:Oz(g("toolBar.library")),onToggle:oe=>{oe&&ae("sidebar",`${kf.name} (open)`,`button (${v.formFactor==="phone"?"mobile":"desktop"})`)},tab:kf.defaultTab,children:I==="full"&&o.width>=Bz&&g("toolBar.library")}),j(Yz,{}),o.openDialog?.name==="ttd"&&j(of,{__fallback:!0}),o.isLoading&&j(Od,{delay:250}),o.errorMessage&&j(VI,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),A&&v.formFactor!=="phone"&&j(tx,{colorPickerType:A.colorPickerType,onCancel:()=>{L(null)},onChange:(oe,$,J,{altKey:be})=>{if(!(oe!=="elementBackground"&&oe!=="elementStroke"))if(J.length){for(let ct of J)zz(ct,Fz(n),{[be&&A.swapPreviewOnAlt?oe==="elementBackground"?"strokeColor":"backgroundColor":oe==="elementBackground"?"backgroundColor":"strokeColor"]:$}),Gz.delete(ct);w.scene.triggerUpdate()}else r(oe==="elementBackground"?{currentItemBackgroundColor:$}:{currentItemStrokeColor:$})},onSelect:(oe,$)=>{L(J=>J?.keepOpenOnAlt&&$.altKey?J:null),A?.onSelect?.(oe,$)}}),o.openDialog?.name==="help"&&j($I,{onClose:()=>{r({openDialog:null})}}),j(p2,{}),o.openDialog?.name==="elementLinkSelector"&&j(WI,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:w.scene,appState:o,generateLinkForSelection:y}),j(P.OverwriteConfirmDialogTunnel.Out,{}),Y(),R(),o.pasteDialog.shown&&j(N3,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),v.formFactor==="phone"&&j(_3,{app:w,appState:o,elements:n,actionManager:e,renderJSONExportDialog:R,renderImageExportDialog:Y,setAppState:r,onHandToolToggle:l,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:c,renderSidebars:G,renderWelcomeScreen:b,UIOptions:u}),v.formFactor!=="phone"&&Gt(c5,{children:[Gt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&Z&&v.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[b&&j(P.WelcomeScreenCenterTunnel.Out,{}),F(),j(U3,{appState:o,actionManager:e,showExitZenModeBtn:d,renderWelcomeScreen:b}),o.scrolledOutside&&j("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(oe=>({...Qr(n,oe)}))},children:g("buttons.scrollBackToContent")})]}),G()]})]});return j(kp.Provider,{value:o,children:j(B,{children:j(Sh.Provider,{value:P,children:te})})})},s5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},Vz=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return wm(s5(r),s5(a),{selectedElementIds:wm,selectedGroupIds:wm})&&wm(n,l)},d5=Rz.memo(Wz,Vz);import Xz from"clsx";import{jsx as m5,jsxs as $z}from"react/jsx-runtime";var Kz="small",vm=e=>$z("label",{className:Xz("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${Kz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[m5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),m5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as Zz,useRef as jz}from"react";import{jsx as p5}from"react/jsx-runtime";var u5=({trails:e})=>{let o=jz(null);return Zz(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),p5("div",{className:"SVGLayer",children:p5("svg",{ref:o})})};import qz,{useEffect as Jz,useRef as Qz}from"react";import{CURSOR_TYPE as h5,isShallowEqual as eH,sceneCoordsToViewportCoords as tH}from"@excalidraw/common";import{jsx as nH}from"react/jsx-runtime";var oH=e=>{let o=Qz(!1);return Jz(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,d)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))n.has(m)||n.set(m,[]),n.get(m).push(d);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(d,s.username),s.userState&&a.set(d,s.userState),r.set(d,tH({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(d,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Vv({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback},ea())}),nH("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?h5.GRAB:h5.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},g5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId}),rH=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:eH(g5(e.appState),g5(o.appState)),Mf=qz.memo(oH,rH);import iH,{useEffect as f5,useRef as b5}from"react";import{isShallowEqual as x5}from"@excalidraw/common";import{jsx as sH}from"react/jsx-runtime";var aH=e=>{let o=b5(null),t=b5(!1);return f5(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),f5(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),z1({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},ea())}),sH("div",{className:"excalidraw__canvas-wrapper",ref:o})},E5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),lH=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:x5(E5(e.appState),E5(o.appState))&&x5(e.renderConfig,o.renderConfig),Pf=iH.memo(aH,lH);import{useEffect as gH,useRef as fH}from"react";import{throttleRAF as cH}from"@excalidraw/common";import{getTargetFrame as dH,isInvisiblySmallElement as mH,renderElement as pH,shouldApplyFrameClip as uH}from"@excalidraw/element";var y5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,d]=hs(e,i),m=gs({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:d});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(mH(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=dH(t,r,a);p&&uH(t,p,a,r)&&F1(p,m,l,a)}pH(t,r,n,o,m,l,a)}else m.clearRect(0,0,s,d);m.restore()}},hH=cH(e=>{y5(e)},{trailing:!0}),w5=(e,o)=>{if(o){hH(e);return}y5(e)};import{jsx as xH}from"react/jsx-runtime";var bH=e=>{let o=fH(null);return gH(()=>{o.current&&w5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},ea())}),xH("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},v5=bH;import{useCallback as EH,useEffect as yH,useRef as wH}from"react";import{jsx as T5,jsxs as TH}from"react/jsx-runtime";var vH=5e3,I5=({message:e,onClose:o,closable:t=!1,duration:r=vH,style:n})=>{let i=wH(0),a=r!==1/0,l=EH(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return yH(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),TH("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[T5("p",{className:"Toast__message",children:e}),t&&T5(K,{icon:Ut,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as IH,getElementsInGroup as CH,selectGroupsFromGivenElements as SH}from"@excalidraw/element";import{sceneCoordsToViewportCoords as kH}from"@excalidraw/common";import{flushSync as MH}from"react-dom";import{jsx as LH}from"react/jsx-runtime";var PH=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:CH(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=IH(r),{x:a,y:l}=kH({sceneX:n,sceneY:i},e.state);return LH("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{MH(()=>{let s=SH(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(ml)},title:g("labels.elementLock.unlock"),children:lb})},C5=PH;import{Fragment as CU,jsx as fe,jsxs as Lm}from"react/jsx-runtime";var kC=Oo.createContext(null),MC=Oo.createContext(null),l1={formFactor:"desktop",desktopUIMode:"full",userAgent:CC(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},c1=Oo.createContext(l1);c1.displayName="EditorInterfaceContext";var d1=Oo.createContext({container:null,id:null});d1.displayName="ExcalidrawContainerContext";var m1=Oo.createContext([]);m1.displayName="ExcalidrawElementsContext";var p1=Oo.createContext({...mr(),width:0,height:0,offsetLeft:0,offsetTop:0});p1.displayName="ExcalidrawAppStateContext";var u1=Oo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});u1.displayName="ExcalidrawSetAppStateContext";var h1=Oo.createContext(null);h1.displayName="ExcalidrawActionManagerContext";var Oe=()=>qr(kC),Io=()=>qr(MC),pe=()=>qr(c1),et=()=>Am(pe()),Se=()=>qr(d1),xr=()=>qr(m1),To=()=>qr(p1),me=()=>qr(u1),Ve=()=>qr(h1),rs=!1,r1=0,ns=null,Pn=!1,is=!1,n1=!1,as={horizontal:null,vertical:null},jr=0,ls=!1,i1=new Map,a1=!1,wC=0,vC=!1,ss=null,ge={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},s1=class e extends Oo.Component{constructor(t){super(t);C(this,"canvas");C(this,"interactiveCanvas",null);C(this,"rc");C(this,"unmounted",!1);C(this,"actionManager");C(this,"editorInterface",l1);C(this,"stylesPanelMode",Am(l1));C(this,"excalidrawContainerRef",Oo.createRef());C(this,"scene");C(this,"fonts");C(this,"renderer");C(this,"visibleElements");C(this,"resizeObserver");C(this,"nearestScrollableContainer");C(this,"library");C(this,"libraryItemsFromStorage");C(this,"id");C(this,"store");C(this,"history");C(this,"excalidrawContainerValue");C(this,"files",{});C(this,"imageCache",new Map);C(this,"iFrameRefs",new Map);C(this,"embedsValidationStatus",new Map);C(this,"initializedEmbeds",new Set);C(this,"handleToastClose",()=>{this.setToast(null)});C(this,"elementsPendingErasure",new Set);C(this,"flowChartCreator",new JG);C(this,"flowChartNavigator",new QG);C(this,"hitLinkElement");C(this,"lastPointerDownEvent",null);C(this,"lastPointerUpEvent",null);C(this,"lastPointerMoveEvent",null);C(this,"lastPointerMoveCoords",null);C(this,"lastViewportPosition",{x:0,y:0});C(this,"animationFrameHandler",new Id);C(this,"laserTrails",new _d(this.animationFrameHandler,this));C(this,"eraserTrail",new Fd(this.animationFrameHandler,this));C(this,"lassoTrail",new Bd(this.animationFrameHandler,this));C(this,"onChangeEmitter",new Sn);C(this,"onPointerDownEmitter",new Sn);C(this,"onPointerUpEmitter",new Sn);C(this,"onUserFollowEmitter",new Sn);C(this,"onScrollChangeEmitter",new Sn);C(this,"missingPointerEventCleanupEmitter",new Sn);C(this,"onRemoveEventListenersEmitter",new Sn);C(this,"updateEditorAtom",(t,...r)=>{let n=We.set(t,...r);return this.triggerRender(),n});C(this,"getEffectiveGridSize",()=>_r(this)?this.state.gridSize:null);C(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),os.delete(t)});C(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(ar(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=$f(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else fa(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});C(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);C(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=Ue({clientX:i.x,clientY:i.y},this.state),l=Ue({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});C(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});C(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Cm.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&Lt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!eC(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=km({sceneX:i.x,sceneY:i.y},this.state),s=6,d,m=XG(i);if(i.id===this.state.editingFrame){let c=m;d=fe("input",{autoFocus:!0,value:c,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===V.ESCAPE||p.key===V.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?XH:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Kr.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=m;return fe("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Kr.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Kr.nameFontSize,color:t?Kr.nameColorDarkTheme:Kr.nameColorLightTheme,lineHeight:Kr.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ne.MOVE,pointerEvents:this.state.viewModeEnabled?ua.disabled:ua.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},i.id)})});C(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});C(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());C(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());C(this,"getSceneElements",()=>this.scene.getNonDeletedElements());C(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});C(this,"onExportImage",async(t,r,n)=>{ae("export",t,"ui");let i=await pn(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(aG).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&bs(i)&&this.setState({fileHandle:i})});C(this,"magicGenerations",new Map);C(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});C(this,"plugins",{});C(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Fo.magicframe}),ae("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Xf(t[0])&&t[0];if(!r&&t.some(i=>Lt(i)||i.frameId)){this.setActiveTool({type:Fo.magicframe});return}ae("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ga(t),d=50;n=K5({...Kr,x:i-d,y:a-d,width:l-i+d*2,height:s-a+d*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)this.scene.mutateElement(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});C(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(br,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:Tt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:Tt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Zr(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:Tt.IMMEDIATELY})},keepOpenOnAlt:!1})});C(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});C(this,"syncActionResult",_e(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||Cm.LIGHT,s=t?.appState?.name??this.state.name,d=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&bC(m)&&bo(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let c=t.appState||{};return{...m,...c,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:d}}),r=!0}r||this.scene.triggerUpdate()}));C(this,"onBlur",_e(()=>{Pn=!1,this.setState({isBindingEnabled:!0})}));C(this,"onUnload",()=>{this.onBlur()});C(this,"disableEvent",t=>{t.preventDefault()});C(this,"resetHistory",()=>{this.history.clear()});C(this,"resetStore",()=>{this.store.clear()});C(this,"resetScene",_e(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...mr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));C(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let r=Bn(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=r.appState.activeTool;r.appState.preferredSelectionTool.initialized||(r.appState.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:n.type==="image"||n.type==="lasso"||n.type==="selection"?{...n,type:r.appState.preferredSelectionTool.type}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...Qr(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:Tt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),t1(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});C(this,"getFormFactor",(t,r)=>this.props.UIOptions.formFactor??uG(t,r));C(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=bG(),a=CC(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:UH,s=Ff(this.editorInterface,{desktopUIMode:this.props.UIOptions.desktopUIMode??i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(r,n),userAgent:a,canFitSidebar:r>l,isLandscape:r>n});this.editorInterface=s,this.reconcileStylesPanelMode(s)});C(this,"reconcileStylesPanelMode",t=>{let r=Am(t);if(r===this.stylesPanelMode)return;let n=this.stylesPanelMode;this.stylesPanelMode=r,n!=="full"&&r==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});C(this,"setDesktopUIMode",t=>{let r=xG(t);this.editorInterface=Ff(this.editorInterface,{desktopUIMode:r}),this.reconcileStylesPanelMode(this.editorInterface)});C(this,"onResize",_e(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>os.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));C(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});C(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(as=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});C(this,"onScroll",z5(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},YH));C(this,"onCut",_e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(t.target)||(this.actionManager.executeAction(Lc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));C(this,"onCopy",_e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(t.target)||(this.actionManager.executeAction(Ci,"keyboard",t),t.preventDefault(),t.stopPropagation())}));C(this,"onTouchStart",t=>{if(hG&&t.preventDefault(),!rs){rs=!0,t.touches.length===1&&(ns={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(r1),r1=window.setTimeout(e.resetTapTwice,WH);return}if(rs&&t.touches.length===1&&ns){let r=t.touches[0];Xr(se(r.clientX,r.clientY),se(ns.x,ns.y))<=pG&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY})),rs=!1,clearTimeout(r1)}t.touches.length===2&&this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null})});C(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Te(this.state.previousSelectedElementIds,this.state)}):ge.pointers.clear()});C(this,"pasteFromClipboard",_e(async t=>{let r=!!a1,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||ql(n)))return;let l=await il(t),s=l.getFiles(),d=await kE(l,r);if(this.props.onPaste)try{if(await this.props.onPaste(d,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(d,s,r),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));C(this,"addElementsFromPasteOrLibrary",t=>{let r=Gm(t.elements,null,{deleteInvisibleElements:!0}),[n,i,a,l]=ga(r),s=ha(n,a)/2,d=ha(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,c=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ue({clientX:m,clientY:c},this.state),f=p-s,b=u-d,[x,w]=st(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=Uf({type:"everything",elements:r.map(S=>Zr(S,{x:S.x+x-n,y:S.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,pC(v,Mm(E));let k=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(k){let S=$G(E,k);Jf(v,S,k,this.state)}this.scene.replaceAllElements(v),E.forEach(S=>{if(bo(S)&&Vf(S)){let B=iC(S,this.scene.getElementsMapIncludingDeleted());HG(S,B,this.scene)}}),fG&&dr.loadElementsFonts(E).then(S=>{this.fonts.onLoaded(S)}),t.files&&this.addMissingFiles(t.files);let P=hU(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&We.get(Hl)?this.state.openSidebar:null,...to({editingGroupId:null,selectedElementIds:P.reduce((S,B)=>(Vf(B)||(S[B.id]=!0),S),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});C(this,"setAppState",(t,r)=>{this.setState(t,r)});C(this,"removePointer",t=>{jr&&this.resetContextMenuTimer(),ge.pointers.delete(t.pointerId)});C(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ae("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...ir(this.state,r.activeTool.locked?{type:this.state.preferredSelectionTool.type}:r.activeTool),locked:!r.activeTool.locked}}))});C(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});C(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});C(this,"onHandToolToggle",()=>{this.actionManager.executeAction(tE)});C(this,"zoomCanvas",t=>{this.setState({...Wo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:xo(t)},this.state)})});C(this,"cancelInProgressAnimation",null);C(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(t1(t)?s=oU(t):s=t,s){let d=this.scene.getElementsFromId(s);d?.length?this.scrollToContent(d,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):t1(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=qa({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Qr(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,d=this.state.scrollY,m=this.state.zoom.value,c=iG({fromValues:{scrollX:s,scrollY:d,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,lG(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{c(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});C(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});C(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});C(this,"setToast",t=>{this.setState({toast:t})});C(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,BH,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});C(this,"addFiles",_e(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));C(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===Bo.svg))try{let s=K1(nC($1(l.dataURL)),Bo.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});C(this,"updateScene",_e(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?EG({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));C(this,"applyDeltas",(t,r)=>{let n=EC.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return EC.applyTo(n,a,i,r)});C(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));C(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});C(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});C(this,"updateCurrentCursorPosition",_e(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));C(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Ho().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});C(this,"onKeyDown",_e(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!H5(t.target)){if((t.key===V.ESCAPE||t.key===V.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=Q(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&kn(a[0])&&t.key===V.ENTER){this.startImageCropping(a[0]);return}if(t.key===V.ESCAPE)this.updateEditorAtom(uo,null);else if(t.key===V.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(mG.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=_i(a);We.get(uo)?.type==="panel"&&oh(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(uo,{type:"panel"})}if(t.key===V.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Tm(t.key);if(t[V.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=Q(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&DG(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,cC(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Kf(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=Q(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let d=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),cC(t.key));if(d){this.setState(c=>({selectedElementIds:Te({[d]:!0},c)}));let m=this.scene.getNonDeletedElementsMap().get(d);m&&!Kf([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[V.CTRL_OR_CMD]&&t.key===V.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:ze("commandPalette")})}),t.preventDefault();return}if(t[V.CTRL_OR_CMD]&&t.key.toLowerCase()===V.V&&(a1=t.shiftKey,clearTimeout(wC),wC=window.setTimeout(()=>{a1=!1},100)),t[V.CTRL_OR_CMD]&&ql(t.target)&&(t.code===D5.MINUS||t.code===D5.EQUAL)){t.preventDefault();return}if(ql(t.target)&&t.key!==V.ESCAPE||Tm(t.key)&&H5(t.target))return;if(t.key===V.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===V.E&&t.shiftKey&&t[V.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===V.PAGE_UP||t.key===V.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===V.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[V.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Tm(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(Ze),s=new Set;a.filter(Ze).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?N5:this.getEffectiveGridSize())||(t.shiftKey?zH:N5),m=0,c=0;t.key===V.ARROW_LEFT?m=-d:t.key===V.ARROW_RIGHT?m=d:t.key===V.ARROW_UP?c=-d:t.key===V.ARROW_DOWN&&(c=d),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+c},{informMutation:!1,isDragging:!1}),Hf(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:Gf(a.filter(p=>p.id!==l?.id||d!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===V.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[V.CTRL_OR_CMD]||o1(l))At(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Ze(l)||this.actionManager.executeAction(ji));else if(bo(l)||zG(l)){let s;bo(l)||(s=l);let d=jf(l,this.state,this.scene.getNonDeletedElementsMap()),m=d.x,c=d.y;this.startTextEditing({sceneX:m,sceneY:c,container:s}),t.preventDefault();return}else Lt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=Ww(t.key,this);a?(this.state.activeTool.type!==a&&ae("toolbar",a,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===$r.sharp?$r.round:l.currentItemArrowType===$r.round?$r.elbow:$r.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===V.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===V.SPACE&&ge.pointers.size===0&&(Pn=!0,ye(this.interactiveCanvas,Ne.GRAB),t.preventDefault()),(t.key===V.G||t.key===V.S)&&!t.altKey&&!t[V.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===V.G&&(Eo(this.state.activeTool.type)||a.some(l=>Eo(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===V.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[V.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===V.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>bo(l)||Zf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===V.K&&!t.altKey&&!t[V.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:"laser"});return}t[V.CTRL_OR_CMD]&&(t.key===V.BACKSPACE||t.key===V.DELETE)&&this.updateEditorAtom(xn,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===V.S&&t.shiftKey,i=t.key===V.I||r===V.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));C(this,"onKeyUp",_e(t=>{if(t.key===V.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Ne.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Xt(this.interactiveCanvas):(Bt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Pn=!1),!t[V.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Tm(t.key)&&(V5(this.scene.getSelectedElements(this.state).filter(At),zf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Tt.IMMEDIATELY})),!t[V.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:Te({[r.id]:!0},n)})),Kf([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Tt.IMMEDIATELY})}}));C(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);C(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=ir(this.state,t);n.type==="hand"?ye(this.interactiveCanvas,Ne.GRAB):Pn||Bt(this.interactiveCanvas,{...this.state,activeTool:n}),oG(document.activeElement)&&this.focusContainer(),LG(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:Te({},i),selectedGroupIds:Te({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:Te({},i),selectedGroupIds:Te({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});C(this,"setOpenDialog",t=>{this.setState({openDialog:t})});C(this,"setCursor",t=>{ye(this.interactiveCanvas,t)});C(this,"resetCursor",()=>{Xt(this.interactiveCanvas)});C(this,"isTouchScreenMultiTouchGesture",()=>ge.pointers.size>=2);C(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${G5()}`);C(this,"onGestureStart",_e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null}),ge.initialScale=this.state.zoom.value}));C(this,"onGestureChange",_e(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=ge.initialScale;r&&this.setState(n=>({...Wo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:xo(r*t.scale)},n)}))}));C(this,"onGestureEnd",_e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Te(this.state.previousSelectedElementIds,this.state)}),ge.initialScale=null}));C(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(Zf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=null,m=this.scene.getSelectedElements(this.state);m.length===1?bo(m[0])?d=m[0]:i?d=Zf(m[0],this.scene.getNonDeletedElementsMap()):d=this.getTextElementAtPosition(t,r):d=this.getTextElementAtPosition(t,r);let c=d?.fontFamily||this.state.currentItemFontFamily,p=d?.lineHeight||O5(c),u=this.state.currentItemFontSize;if(!d&&l&&i&&!Yf(i)){let w=aU(Nf({fontSize:u,fontFamily:c}),p),E=lU(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=d||$5({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?$H.MIDDLE:R5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Yf(i)?0:i.angle:0,frameId:f?f.id:null});if(!d&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!d)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||d||i?this.handleTextWysiwyg(b,{isExistingElement:!!d}):this.setState({newElement:b,multiElement:null})});C(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});C(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});C(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Ue(t,this.state);if(r.length===1&&At(r[0])){let l=r[0];if((t[V.CTRL_OR_CMD]&&TU(l)||o1(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(ji);return}else if(this.state.selectedLinearElement&&Ze(r[0])){let s=Pe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=s?Pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Pe.deleteFixedSegment(r[0],this.scene,d);let m=Pe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=m?Pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:c,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&o1(l))return}if(r.length===1&&kn(r[0])){this.startImageCropping(r[0]);return}if(Xt(this.interactiveCanvas),pU(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&mU(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(d=>({...d,...to({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(Xt(this.interactiveCanvas),!t[V.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(es(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(j5(s)||!nG(s.backgroundColor)||ts({point:se(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let d=jf(s,this.state,this.scene.getNonDeletedElementsMap());n=d.x,i=d.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});C(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&us(l,this.scene.getNonDeletedElementsMap(),this.state,se(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});C(this,"redirectToLink",(t,r)=>{let n=Xr(se(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),se(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>OH)return;let i=Ue(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=us(this.hitLinkElement,a,this.state,se(i.x,i.y),this.editorInterface.formFactor==="phone"),s=Ue(this.lastPointerUpEvent,this.state),d=us(this.hitLinkElement,a,this.state,se(s.x,s.y),this.editorInterface.formFactor==="phone");if(l&&d){Vu();let m=this.hitLinkElement.link;if(m){m=Rf(m);let c;if(this.props.onLinkOpen&&(c=rG(ne.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},c)),!c?.defaultPrevented){let p=QH(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});C(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&aC(t,i,r));return n.length?n[n.length-1]:null});C(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,ge.pointers.has(t.pointerId)&&ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=ge.initialScale;if(ge.pointers.size===2&&ge.lastCenter&&r&&ge.initialDistance){let f=tg(ge.pointers),b=f.x-ge.lastCenter.x,x=f.y-ge.lastCenter.y;ge.lastCenter=f;let w=og(Array.from(ge.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/ge.initialDistance,y=E?xo(r*E):this.state.zoom.value;this.setState(v=>{let I=Wo({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:I.zoom,scrollX:I.scrollX+2*(b/y),scrollY:I.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else ge.lastCenter=ge.initialDistance=ge.initialScale=null;if(Pn||is||n1||no(this.state))return;let i=dg(as,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Xt(this.interactiveCanvas):Bt(this.interactiveCanvas,this.state));let a=Ue(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Iv(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=Tv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=Jl(x.snapLines,b),E=x.originSnapOffset?Jl(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Pe.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&pa(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&q5(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(q5(this.state.activeTool.type)){let{newElement:f}=this.state;Wf(f,!1)?this.setState({suggestedBindings:Y5(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(Bt(this.interactiveCanvas,this.state),y===E)Xr(se(l-b,s-x),y)>=_f?this.scene.mutateElement(f,{points:[...w,se(l-b,s-x)]},{informMutation:!1,isDragging:!1}):ye(this.interactiveCanvas,Ne.POINTER);else if(w.length>2&&E&&Xr(se(l-b,s-x),E)<_f)ye(this.interactiveCanvas,Ne.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,I]=st(l,s,t[V.CTRL_OR_CMD]||Ze(f)?null:this.getEffectiveGridSize()),[k,P]=f?.lastCommittedPoint??[0,0],S=v-b-k,B=I-x-P;Df(t)&&({width:S,height:B}=Q5(k+b,P+x,v,I)),oC(w,this.state.zoom.value)&&ye(this.interactiveCanvas,Ne.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),se(k+S,P+B)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(c.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(c.length===1&&Ze(c[0]))&&!(At(c[0])&&(this.editorInterface.userAgent.isMobileDevice||c[0].points.length===2))){let f=hC(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(f&&f.transformHandleType){ye(this.interactiveCanvas,uC(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=gC(ga(c),l,s,this.state.zoom,t.pointerType,this.editorInterface);if(f){ye(this.interactiveCanvas,uC({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!It(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(ye(this.interactiveCanvas,Ne.POINTER),vy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Vu(),u&&(u.link||ar(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ye(this.interactiveCanvas,bo(u)?Ne.TEXT:Ne.CROSSHAIR):this.state.viewModeEnabled?ye(this.interactiveCanvas,Ne.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Ne.AUTO):i?ye(this.interactiveCanvas,Ne.AUTO):t[V.CTRL_OR_CMD]?ye(this.interactiveCanvas,Ne.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,c))&&!u?.locked&&(u&&es(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(ye(this.interactiveCanvas,Ne.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!Ze(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||c.length>0)&&ye(this.interactiveCanvas,Ne.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:Jl(f.hoveredElementIds,to({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:Jl(f.hoveredElementIds,{})})))});C(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});C(this,"handleTouchMove",t=>{ls=!0});C(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(jg,null)),We.get(uo)&&this.updateEditorAtom(uo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let c=this.state.newElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==c.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Te(Object.keys(this.state.selectedElementIds).filter(p=>p!==c.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Tt.EVENTUALLY:Tt.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=Ff(this.editorInterface,{isTouchScreen:!0})),is||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Cn.ERASER&&this.state.activeTool.type!==Fo.eraser){this.setState({activeTool:ir(this.state,{type:Fo.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{p(),u?.(),It(this.state)&&this.setState({activeTool:ir(this.state,{...this.state.activeTool.lastActiveTool||{type:Fo.selection},lastActiveToolBeforeEraser:null})})},p=Fe(window,ne.POINTER_UP,c,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==Cn.MAIN&&t.button!==Cn.TOUCH&&t.button!==Cn.ERASER||ge.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let c=i.hit.element&&this.isASelectedElement(i.hit.element);!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!c&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&i.hit.element&&!c&&(this.setState(p=>{let u={...p.selectedElementIds,[i.hit.element.id]:!0},f=[];Object.keys(p.selectedElementIds).forEach(x=>{let w=this.scene.getElement(x);w&&f.push(w)});let b=i.hit.element;if(Lt(b))qf(f,b.id).forEach(x=>{delete u[x.id]});else if(b.frameId)u[b.frameId]&&delete u[b.id];else{let x=b.groupIds,w=new Set(x.flatMap(E=>Mn(this.scene.getNonDeletedElements(),E)).filter(E=>Lt(E)).map(E=>E.id));w.size>0&&f.forEach(E=>{E.frameId&&w.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(y=>Mn(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return{...to({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:b.link||ar(b)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Bt(this.interactiveCanvas,this.state):this.state.activeTool.type===Fo.frame||this.state.activeTool.type===Fo.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),d=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(c=>s(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ne.POINTER_MOVE,l),window.addEventListener(ne.POINTER_UP,s),window.addEventListener(ne.KEYDOWN,d),window.addEventListener(ne.KEYUP,m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=d)});C(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Ue({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.editorInterface.formFactor==="phone"&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(es(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.editorInterface.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&es(this.hitLinkElement)&&!_1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,se(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.editorInterface.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});C(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(ls=!1,jr?ls=!0:jr=window.setTimeout(()=>{jr=0,ls||this.handleCanvasContextMenu(t)},KH))});C(this,"resetContextMenuTimer",()=>{clearTimeout(jr),jr=0,ls=!1});C(this,"maybeCleanupAfterMissingPointerUp",t=>{ss?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});C(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ge.pointers.size<=1&&(t.button===Cn.WHEEL||t.button===Cn.MAIN&&Pn||no(this.state)||this.state.viewModeEnabled)))return!1;is=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ye(this.interactiveCanvas,Ne.GRABBING);let{clientX:i,clientY:a}=t,l=Rd(d=>{let m=i-d.clientX,c=a-d.clientY;if(i=d.clientX,a=d.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(c)>1)){r=!0;let p=f=>{document.body.removeEventListener(ne.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ne.PASTE,p),window.removeEventListener(ne.POINTER_UP,u)},100)};document.body.addEventListener(ne.PASTE,p),window.addEventListener(ne.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-c/this.state.zoom.value})}),s=_e(ss=()=>{ss=null,is=!1,Pn||(this.state.viewModeEnabled?ye(this.interactiveCanvas,Ne.GRAB):Bt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ne.POINTER_MOVE,l),window.removeEventListener(ne.POINTER_UP,s),window.removeEventListener(ne.BLUR,s),l.flush()});return window.addEventListener(ne.BLUR,s),window.addEventListener(ne.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ne.POINTER_UP,s),!0});C(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});C(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Ze(a[0])&&!(At(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=hC(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=gC(ga(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=Bf(fU(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&At(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=bU(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Pe.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),d=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,d),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let m=r.hit.element,c=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((m===null||!c)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:Te({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(m!=null){if(t[V.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(r.origin.x,r.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...dU(p,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!mC(m,this.state.editingGroupId)&&this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Lt(m))qf(f,m.id).forEach(b=>{delete u[b.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let b=m.groupIds,x=new Set(b.flatMap(w=>Mn(this.scene.getNonDeletedElements(),w)).filter(w=>Lt(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>Mn(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>p.selectedGroupIds[b])||(u={[m.id]:!0})),{...to({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:m.link||ar(m)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});C(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);j5(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Xt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:ir(this.state,{type:this.state.preferredSelectionTool.type})})});C(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=st(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,d=TG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[se(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(d),this.setState(c=>{let p={...c.selectedElementIds};return delete p[d.id],{selectedElementIds:Te(p,c)}});let m=Of(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:d,startBoundElement:m,suggestedBindings:[]})});C(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=IG({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});C(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Pm(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=X5({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});C(this,"newImagePlaceholder",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return kG({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});C(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&oC(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Ft);return}if(Ze(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Ft);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Xr(se(n.origin.x-a,n.origin.y-l),s)<_f){this.actionManager.executeAction(Ft);return}this.setState(d=>({selectedElementIds:Te({...d.selectedElementIds,[i.id]:!0},d)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),ye(this.interactiveCanvas,Ne.POINTER)}else{let[i,a]=st(n.origin.x,n.origin.y,t[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:d}=this.state,[m,c]=r==="arrow"?[s,d]:[null,null],p=r==="arrow"?CG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===$r.round?{type:Im.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===$r.elbow,fixedSegments:this.state.currentItemArrowType===$r.elbow?[]:null}):MG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Im.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:Te(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,se(0,0)]});let u=Of(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,Ze(p),Ze(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});C(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=st(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=X5({type:"embeddable",...l}):s=SG({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});C(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=st(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Kr},l=r===Fo.magicframe?K5(a):vG(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});C(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});C(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||Vf(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,Zr(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});C(this,"initializeImage",async(t,r)=>{if(!Um(r))throw new Error(g("errors.unsupportedFileType"));let n=r.type;if(ye(this.interactiveCanvas,"wait"),n===Bo.svg)try{r=Xm(nC(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(r)||X1(r));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{r=await Es(r,{maxWidthOrHeight:FH})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>B5)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(B5/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await Vm(r);return new Promise(async(s,d)=>{try{let m=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([m]);if(p.size)throw new Error("Image cache update resulted with an error.")}let c=await this.imageCache.get(i)?.image;if(c&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(m,c);Object.assign(m,p)}s(m)}catch(m){console.error(m),d(new Error(g("errors.imageInsertError")))}})});C(this,"getLatestInitializedImageElement",(t,r)=>{let n=this.scene.getElement(t.id)??t;return Zr(n,{fileId:r})});C(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Ue({clientX:t,clientY:r},this.state),a=await ms({description:"Image",extensions:Object.keys(HH),multiple:!0});this.insertImages(a,n,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:ir(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(Ft)})}});C(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,d=t.y+t.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});C(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await OG({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&(this.store.scheduleAction(Tt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Ql(a)&&i.has(a.fileId)?Zr(a,{status:"error"}):a))),{updatedFiles:n,erroredFiles:i}});C(this,"addNewImagesToImageCache",async(t=FG(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&os.delete(a);i.size&&this.scene.triggerUpdate()}});C(this,"scheduleImageRefresh",AH(()=>{this.addNewImagesToImageCache()},GH));C(this,"updateBindingEnabledOnPointerMove",t=>{let r=wG(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});C(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=Of(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});C(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ne.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ne.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ne.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ne.TOUCH_END,this.onTouchEnd))});C(this,"insertImages",async(t,r,n)=>{let i=50/this.state.zoom.value,a=yC(t.map(()=>this.newImagePlaceholder({sceneX:r,sceneY:n})),r,n,i);a.forEach(p=>this.scene.insertElement(p));let l=await Promise.all(a.map(async(p,u)=>{try{return await this.initializeImage(p,await Sa(t[u]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Zr(p,{isDeleted:!0})}})),s=Mm(l),d=yC(l.filter(p=>!p.isDeleted),r,n,i),m=Mm(d),c=this.scene.getElementsIncludingDeleted().map(p=>m.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:Te(Object.fromEntries(d.map(p=>[p.id,!0])),this.state)},elements:c,captureUpdate:Tt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(Ft)})});C(this,"handleAppOnDrop",async t=>{let{x:r,y:n}=Ue(t,this.state),i=await il(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:p}=a[0];if(c&&(c.type===Bo.png||c.type===Bo.svg))try{let u=await xs(c,this.state,this.scene.getElementsIncludingDeleted(),p);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Tt.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>Um(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,r,n);let s=i.getData(Bo.excalidrawlibIds),d=i.getData(Bo.excalidrawlib);if(s||d){try{let c=null;if(s){let{itemIds:p}=JSON.parse(s);c=(await this.library.getLatestLibrary()).filter(f=>p.includes(f.id))}else d&&(c=V1(d));c?.length&&(c=c.map(p=>({...p,elements:Uf({type:"everything",elements:p.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Fi(c),position:t,files:null}))}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:p}=a[0];c&&await this.loadFileToCanvas(c,p)}let m=i.findByType(Bo.text);if(m){let c=m.value;if(c&&$f(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Pm(c)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:r,sceneY:n,link:Rf(c)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});C(this,"loadFileToCanvas",async(t,r)=>{t=await Sa(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await Ym(t,this.state,n,r)}catch(a){let l=a instanceof L1;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Bo.excalidraw?(SC(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:Tt.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Tt.IMMEDIATELY})):i.type===Bo.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});C(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Cn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:r,y:n}=Ue(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",d=this.excalidrawContainerRef.current,{top:m,left:c}=d.getBoundingClientRect(),p=t.clientX-c,u=t.clientY-m;ae("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...to({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:At(i)?new Pe(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});C(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){fC({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:ha(t.origin.x,a.x),height:ha(t.origin.y,a.y),shouldMaintainAspectRatio:jl(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,d]=st(a.x,a.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Ql(l)&&this.imageCache.get(l.fileId)?.image,c=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=vv(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,d+=p.y,this.setState({snapLines:u}),fC({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:d,width:ha(t.originInGrid.x,s),height:ha(t.originInGrid.y,d),shouldMaintainAspectRatio:kn(l)?!jl(r):jl(r),shouldResizeFromCenter:_5(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===Fo.frame||this.state.activeTool.type===Fo.magicframe)&&this.setState({elementsToHighlight:Qf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});C(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=st(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&kn(s)){let d=t.originalElements.get(s.id),m=Ql(s)&&this.imageCache.get(s.fileId)?.image;if(d&&kn(d)&&m&&!(m instanceof Promise)){let[c,p]=st(i.x,i.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=ag([s],[d],this,r,u,n);this.scene.mutateElement(s,eU(s,this.scene.getNonDeletedElementsMap(),n,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,r.shiftKey?d.width/d.height:void 0)),Hf(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});C(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(c=>Lt(c)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&Ze(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,d]=st(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(c=>{qf(this.scene.getNonDeletedElements(),c.id).forEach(u=>{m.set(c.id+u.id,{x:u.x-c.x,y:u.y-c.y})})}),!this.state.selectedElementsAreBeingDragged){let[c,p]=st(l.x,l.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=ag(n,Q(f,this.state),this,r,u,a);s+=b.x,d+=b.y,this.setState({snapLines:x})}if(xU(t.originalElements,a,n,this.scene,Df(r),_5(r),n.some(c=>kn(c))?!jl(r):jl(r),s,d,t.resize.center.x,t.resize.center.y)){let c=Gf(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{Qf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:c}),!0}return!1});C(this,"getContextMenuItems",t=>{let r=[];if(r.push(Dc,Ac),t==="canvas")return this.state.viewModeEnabled?[...r,Rc,Si,Qh,ki]:[Au,Xe,Dc,Ac,_c,Xe,Ip,My,Xe,Rc,Du,Si,Qh,ki];if(r.push(_c),this.state.viewModeEnabled)return[Ci,...r];let n=this.editorInterface.formFactor==="desktop"?[Xe,yp,wp,vp,Tp]:[];return[Xe,Lc,Ci,Au,Xe,Q2,ev,tv,Xe,Zh,Xe,...r,Xe,wu,vu,Xe,Iu,cv,Nu,Bu,uy,Cu,Xe,Mu,...n,Xe,Pu,Lu,Xe,ji,Xe,dl,Uc,Xe,Cp,ml,Xe,Fa]});C(this,"handleWheel",_e(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[V.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),is)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=ZH*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let d=this.state.zoom.value-s/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Wo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:xo(d)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));C(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=Ue({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:ge.pointers})});C(this,"resetShouldCacheIgnoreZoomDebounced",z5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));C(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:d,offsetTop:m,offsetLeft:c}=this.state;if(n===s&&i===d&&a===c&&l===m){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});C(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=mr(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:d=r.theme,name:m=`${g("labels.untitled")}-${G5()}`}=t;if(this.state={...r,theme:d,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=Am(this.editorInterface),this.id=_H(),this.library=new ew(this),this.actionManager=new Td(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new xC,this.canvas=document.createElement("canvas"),this.rc=DH.canvas(this.canvas),this.renderer=new Nl(this.scene),this.visibleElements=[],this.store=new wU(this),this.history=new Ll(this.store),n){let c={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new dr(this.scene),this.history=new Ll(this.store),this.actionManager.registerAll(Bs),this.actionManager.registerAction(iv(this.history)),this.actionManager.registerAction(av(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(Sm).includes(i)&&i1.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),fa(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=i1.get(t.id);switch(n||(i1.set(t.id,Sm.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case Sm.PLAYING:case Sm.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>ar(a)&&this.embedsValidationStatus.get(a.id)===!0||fa(a));return fe(CU,{children:i.map(a=>{let{x:l,y:s}=km({sceneX:a.x,sceneY:a.y},this.state),d=eC(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(d&&!m&&this.initializedEmbeds.add(a.id),!(d||m))return null;let p;if(fa(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>rC(`
|
|
26
26
|
<style>
|
|
27
27
|
html, body {
|
|
28
28
|
width: 100%;
|
|
29
29
|
height: 100%;
|
|
30
|
-
color: ${this.state.theme===
|
|
30
|
+
color: ${this.state.theme===Cm.DARK?"white":"black"};
|
|
31
31
|
}
|
|
32
32
|
body {
|
|
33
33
|
display: flex;
|
|
@@ -94,7 +94,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),re("ai","me
|
|
|
94
94
|
</svg>
|
|
95
95
|
</div>
|
|
96
96
|
<div>Generating...</div>
|
|
97
|
-
`)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>
|
|
97
|
+
`)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>rC(`
|
|
98
98
|
<style>
|
|
99
99
|
html, body {
|
|
100
100
|
height: 100%;
|
|
@@ -104,7 +104,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),re("ai","me
|
|
|
104
104
|
flex-direction: column;
|
|
105
105
|
align-items: center;
|
|
106
106
|
justify-content: center;
|
|
107
|
-
color: ${
|
|
107
|
+
color: ${NH.red[3]};
|
|
108
108
|
}
|
|
109
109
|
h1, h3 {
|
|
110
110
|
margin-top: 0;
|
|
@@ -113,7 +113,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),re("ai","me
|
|
|
113
113
|
</style>
|
|
114
114
|
<h1>Error!</h1>
|
|
115
115
|
<h3>${x}</h3>
|
|
116
|
-
`)}}}else p=qd(Yz(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return ue("div",{className:vT("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:d?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:d?"block":"none",opacity:XH(a,Ef(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?Hz:1),"--embeddable-radius":`${xH(Math.min(a.width,a.height),a)}px`},children:Qd("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Fi.enabled:Fi.disabled},children:[f&&ue("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),ue("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Ar(a)?this.props.renderEmbeddable?.(a,this.state):null)??ue("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),d="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0],c=ze.get(no)?.type==="panel";return ue("div",{className:vT("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":d?Fi.disabled:Fi.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:ue(II.Provider,{value:this,children:ue(CI.Provider,{value:this.props,children:ue(Mf.Provider,{value:this.excalidrawContainerValue,children:ue(kf.Provider,{value:this.device,children:ue(Af.Provider,{value:this.setAppState,children:ue(Pf.Provider,{value:this.state,children:Qd(Lf.Provider,{value:this.scene.getNonDeletedElements(),children:[Qd(Df.Provider,{value:this.actionManager,children:[ue(aT,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Mo().code,renderTopRightUI:r,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),ue("div",{className:"excalidraw-textEditorContainer"}),ue("div",{className:"excalidraw-contextMenuContainer"}),ue("div",{className:"excalidraw-eye-dropper-container"}),ue(cT,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ue(zE,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&pf(m)&&ue(Xh,{element:m,elementsMap:a,children:ue(Vd,{title:g("labels.convertToCode"),icon:ts,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&Hi(m)&&m.customData?.generationData?.status==="done"&&Qd(Xh,{element:m,elementsMap:a,children:[ue(Vd,{title:g("labels.copySource"),icon:Cn,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),ue(Vd,{title:"Enter fullscreen",icon:U0,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(m);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&ue(yT,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&ue(Tv,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),ue($g,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:hr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ue(xT,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),ue(Zg,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&ue(Cv,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ue(wT,{app:this,activeLockedId:this.state.activeLockedId}),c&&ue(oy,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=PH(this.scene.getNonDeletedElements(),t).filter(l=>!pf(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),re("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),re("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(re("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){re("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(oo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{ul(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),fl.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Cf()||vI()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Cf()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),_T&&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),Sz()&&!HH()&&this.setState({errorMessage:ue(Ev,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new xI,this.fonts=new Zo(this.scene),this.renderer=new ja(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),fl.destroy(),Yt.destroy(),clearTimeout(Dr),Ee.clearCache(),mo.clearCache(),Dr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(_e(document,ee.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(window,ee.MESSAGE,this.onWindowMessage,!1),_e(document,ee.POINTER_UP,this.removePointer,{passive:!1}),_e(document,ee.COPY,this.onCopy,{passive:!1}),_e(document,ee.KEYUP,this.onKeyUp,{passive:!0}),_e(document,ee.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),_e(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),_e(document,ee.GESTURE_START,this.onGestureStart,!1),_e(document,ee.GESTURE_CHANGE,this.onGestureChange,!1),_e(document,ee.GESTURE_END,this.onGestureEnd,!1),_e(window,ee.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(_e(document,ee.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),_e(document,ee.PASTE,this.pasteFromClipboard,{passive:!1}),_e(document,ee.CUT,this.onCut,{passive:!1}),_e(window,ee.RESIZE,this.onResize,!1),_e(window,ee.UNLOAD,this.onUnload,!1),_e(window,ee.BLUR,this.onBlur,!1),_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(this.excalidrawContainerRef.current,ee.DRAG_OVER,this.disableEvent,!1),_e(this.excalidrawContainerRef.current,ee.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(_e(Wz(this.excalidrawContainerRef.current),ee.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&bt(this.state)&&this.setState({activeTool:Vo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Dp(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),bt(r)&&!bt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Zd.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(wt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){xl=!1}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await g1(p)}}catch(u){let f=u.message;return u.cause==="FETCH_ERROR"?f=g("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(f=g("errors.unsupportedFileType")),{errorMessage:f}}})),s=i,d=!1,m={};for(let p of l)if(p.file){let u=await this.createImageElement({sceneX:n,sceneY:s,imageFile:p.file});u&&(d||(d=!0,s-=u.height/2),this.scene.mutateElement(u,{y:s},{informMutation:!1,isDragging:!1}),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:ye(m,this.state)});let c=l.find(p=>!!p.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
116
|
+
`)}}}else p=Pm(eG(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return fe("div",{className:S5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:d?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:d?"block":"none",opacity:cU(a,e1(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?JH:1),"--embeddable-radius":`${NG(Math.min(a.width,a.height),a)}px`},children:Lm("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?ua.enabled:ua.disabled},children:[f&&fe("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),fe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(ar(a)?this.props.renderEmbeddable?.(a,this.state):null)??fe("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderTopLeftUI:n,renderCustomStats:i}=this.props,a=this.scene.getSceneNonce(),{elementsMap:l,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:a,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=s;let d=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",c=t[0],p=We.get(uo)?.type==="panel";return fe("div",{className:S5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone"}),style:{"--ui-pointerEvents":m?ua.disabled:ua.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:fe(kC.Provider,{value:this,children:fe(MC.Provider,{value:this.props,children:fe(d1.Provider,{value:this.excalidrawContainerValue,children:fe(c1.Provider,{value:this.editorInterface,children:fe(u1.Provider,{value:this.setAppState,children:fe(p1.Provider,{value:this.state,children:Lm(m1.Provider,{value:this.scene.getNonDeletedElements(),children:[Lm(h1.Provider,{value:this.actionManager,children:[fe(d5,{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:Ho().code,renderTopLeftUI:n,renderTopRightUI:r,renderCustomStats:i,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),fe("div",{className:"excalidraw-textEditorContainer"}),fe("div",{className:"excalidraw-contextMenuContainer"}),fe("div",{className:"excalidraw-eye-dropper-container"}),fe(u5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&fe(yy,{element:c,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&Xf(c)&&fe(Eg,{element:c,elementsMap:l,children:fe(vm,{title:g("labels.convertToCode"),icon:nn,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&fa(c)&&c.customData?.generationData?.status==="done"&&Lm(Eg,{element:c,elementsMap:l,children:[fe(vm,{title:g("labels.copySource"),icon:$n,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),fe(vm,{title:"Enter fullscreen",icon:x0,checked:!1,onChange:()=>{let u=this.getHTMLIFrameElement(c);if(u)try{u.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(f){console.warn(f),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&fe(I5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&fe(I3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:u=>{this.setState({contextMenu:null},()=>{this.focusContainer(),u?.()})}}),fe(Pf,{canvas:this.canvas,rc:this.rc,elementsMap:l,allElementsMap:d,visibleElements:s,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:_r(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&fe(v5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:l,allElementsMap:d,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),fe(Mf,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:l,visibleElements:s,allElementsMap:d,selectedElements:t,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,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&&fe(S3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&fe(C5,{app:this,activeLockedId:this.state.activeLockedId}),p&&fe(Fy,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=KG(this.scene.getNonDeletedElements(),t).filter(l=>!Xf(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ae("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),ae("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(ae("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){ae("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(mo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{Ql(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),os.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,TC()||IC()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),jH&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),gG()&&!rU()&&this.setState({errorMessage:fe(y3,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new xC,this.fonts=new dr(this.scene),this.renderer=new Nl(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),os.destroy(),jt.destroy(),clearTimeout(jr),we.clearCache(),to.clearCache(),jr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Fe(document,ne.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Fe(this.excalidrawContainerRef.current,ne.WHEEL,this.handleWheel,{passive:!1}),Fe(window,ne.MESSAGE,this.onWindowMessage,!1),Fe(document,ne.POINTER_UP,this.removePointer,{passive:!1}),Fe(document,ne.COPY,this.onCopy,{passive:!1}),Fe(document,ne.KEYUP,this.onKeyUp,{passive:!0}),Fe(document,ne.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Fe(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Fe(document,ne.GESTURE_START,this.onGestureStart,!1),Fe(document,ne.GESTURE_CHANGE,this.onGestureChange,!1),Fe(document,ne.GESTURE_END,this.onGestureEnd,!1),Fe(window,ne.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Fe(document,ne.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Fe(document,ne.PASTE,this.pasteFromClipboard,{passive:!1}),Fe(document,ne.CUT,this.onCut,{passive:!1}),Fe(window,ne.RESIZE,this.onResize,!1),Fe(window,ne.UNLOAD,this.onUnload,!1),Fe(window,ne.BLUR,this.onBlur,!1),Fe(this.excalidrawContainerRef.current,ne.WHEEL,this.handleWheel,{passive:!1}),Fe(this.excalidrawContainerRef.current,ne.DRAG_OVER,this.disableEvent,!1),Fe(this.excalidrawContainerRef.current,ne.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Fe(tG(this.excalidrawContainerRef.current),ne.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),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&&It(this.state)&&this.setState({activeTool:ir(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&au(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(),It(r)&&!It(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Cm.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(Ft)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){rs=!1,ns=null}async insertClipboardContent(t,r,n){let{x:i,y:a}=Ue({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(r.length===0&&!n&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:n,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!n){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=r.map(m=>m.file);if(l.length===0&&t.text&&!n){let m=t.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&l.push(Xm(m))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let m=t.programmaticAPI?Qi(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:m,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:n});return}if(!t.text)return;if(!n&&n3(t.text)){let m=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:c,files:p}=await m.parseMermaidToExcalidraw(t.text),u=Qi(c,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:this.editorInterface.formFactor==="desktop"?"cursor":"center"});return}catch(c){console.warn(`parsing pasted text as mermaid definition failed: ${c.message}`)}}let s=sG(t.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),d=s.map(m=>BG(m)).filter(m=>$f(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||Pm(m)?.type==="video"));if(!n&&d.length>0&&d.length===s.length){let m=[];for(let c of d){let p=m[m.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Rf(c)});u&&m.push(u)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(c=>[c.id,!0]))}));return}this.addTextFromPaste(t.text,n)}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(m=>m.type==="imageUrl").map(m=>m.value),l=await Promise.all(a.map(async m=>{try{return{file:await Z1(m)}}catch(c){let p=c.message;return c.cause==="FETCH_ERROR"?p=g("errors.failedToFetchImage"):c.cause==="UNSUPPORTED"&&(p=g("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,n,i);let d=l.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
117
117
|
|
|
118
|
-
`),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=
|
|
119
|
-
`),b=f.reduce((x,w,E)=>{let y=GH(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=dI(y,l,s),S=C.width>c,L=S?OH(y,l,c):y;C=S?dI(L,l,s):C;let k=n-C.width/2,A=u-C.height/2,P=XT({...a,x:k,y:A,text:L,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else f[E-1]?.trim()&&(u+=UH(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ye(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&wI===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:Kz("CtrlOrCmd+Shift+V")}),duration:5e3}),wI=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&co(s)?sn(s,{originalText:a,isDeleted:l??s.isDeleted,...pH(s,nI(s,n),n,a)}):s)])};iv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:d}=jd({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Pe(a=>{i(a,!1),bI(t)&&lf(t,this.scene)}),onSubmit:Pe(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let d=t.containerId?t.containerId:t.id;Bi(()=>{this.setState(m=>({selectedElementIds:ye({...m.selectedElementIds,[d]:!0},m)}))})}s&&rH(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),Bi(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&At(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&co(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return gl({point:ne(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Kt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(co(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let d=Ef(s,a);return d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?aI({x:t,y:r},d,a):!0}).filter(s=>Hi(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(RT/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&IH([n],this.state)&&iG(ne(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||DH(ne(t,r),n,this.scene.getNonDeletedElementsMap())?!0:gl({point:ne(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Kt(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return qT(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,d,m,c]=UT(n[l],this.scene.getNonDeletedElementsMap());if(cf(n[l])&&gl({point:ne(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<m&&d<r&&r<c){a=n[l];break}}return qT(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=Se.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;gl({point:ne(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Se.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=Se.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(We(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,De.POINTER):this.hitElement(r,n,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&xe(this.interactiveCanvas,De.MOVE)):this.hitElement(r,n,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&xe(this.interactiveCanvas,De.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Se.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else xe(this.interactiveCanvas,De.AUTO)}updateGestureOnPointerDown(t){pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),pe.pointers.size===2&&(pe.lastCenter=Mh(pe.pointers),pe.initialScale=this.state.zoom.value,pe.initialDistance=Lh(Array.from(pe.pointers.values())))}initialPointerDownState(t){let r=Fe(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=zi(n),d=n.findIndex(We)===0;return{origin:r,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:of(nt(r.x,r.y,t[Y.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:Fh(yl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,c)=>(m.set(c.id,KT(c)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r}},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;Tf=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=td(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=Pe(()=>{vl=null,Tf=!1,At(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,n),window.removeEventListener(ee.POINTER_UP,i),n.flush()});return vl=i,window.addEventListener(ee.POINTER_MOVE,n),window.addEventListener(ee.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(RT/this.state.zoom.value,1),[i,a,l,s]=zi(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:hH(t)?Kd.ADAPTIVE_RADIUS:Kd.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Ho({event:t,app:this,selectedElements:r})&&(n||!Yt.getReferenceSnapPoints())&&Yt.setReferenceSnapPoints(ww(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Ho({event:t,app:this,selectedElements:r})&&(n||!Yt.getVisibleGaps())&&Yt.setVisibleGaps(yw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Pe(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return Pe(r=>{r.key===Y.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return td(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Fe(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=nt(n.x,n.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Se.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=of(rG(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(bt(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=nt(n.x,n.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&nn(ne(n.x,n.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value<HT)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Se.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,d)){let f=Se.addMidpoint(this.state.selectedLinearElement,n,this,!r[Y.CTRL_OR_CMD],this.scene);if(!f)return;Bi(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Se.handlePointDragging(r,this,n.x,n.y,p);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState(u);return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>Kt(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Bi(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},w=[...t.originalElements.values()],E=r.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),L=E&&C<S,k=E&&C>S;L&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&cn(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,L=ul(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let k=xz(IT(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[A,P,N,O,U,J]=UT(C,d),_=qg(jg(ne(A,P),ne(U,J),C.angle)),R=qg(jg(ne(N,P),ne(U,J),C.angle)),V=qg(jg(ne(A,O),ne(U,J),C.angle)),Z=kT(CT(R,_)),W=kT(CT(V,_)),ce=IT(ST(k,Z),ST(k,W)),he={...S,x:TT(S.x-ce[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:TT(S.y-ce[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:he});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=vw(w,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||oG(t,p,x,this.scene,y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!We(p[0]))&&this.setState({suggestedBindings:sf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!L.find(R=>R.id===S.id)&&L.push(S);let k=new Map(L.map(R=>[R.id,R])),{duplicatedElements:A,duplicateElementsMap:P,elementsWithDuplicates:N,origIdToDuplicateId:O}=ZT({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:R,origElement:V})=>({frameId:R.frameId??V.frameId,seed:eH()})});A.forEach(R=>{t.originalElements.set(R.id,KT(R))});let U=N.map(R=>{if(k.has(R.id)){let V=t.originalElements.get(R.id);if(V)return sn(R,{x:V.x,y:V.y})}return R}),J=this.props.onDuplicate?.(U,C),_=pI(J||U,zT(A));Bi(()=>{if(t.hit.element){let R=O.get(t.hit.element.id),V=R&&P.get(R);t.hit.element=V||null}t.hit.allHitElements=t.hit.allHitElements.reduce((R,V)=>{let Z=O.get(V.id),W=Z&&P.get(Z);return W&&R.push(W),R},[]),t.drag.origin=Fe(r,this.state),this.setState(R=>({...JH(A,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(r,L,!0),this.maybeCacheReferenceSnapPoints(r,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,ne(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Zt(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Jg(r)&&u.length===2&&({width:f,height:b}=JT(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,ne(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&We(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),ne(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),df(p,!1)&&this.setState({suggestedBindings:GT(p,[n],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Se.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&Ee(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>mo({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?$f(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...mo({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Zt(f[0])?new Se(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||Ar(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(yl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(yl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return Pe(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:d,isRotating:m,isCropping:c}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:pl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Yt.setReferenceSnapPoints(null),Yt.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements,u=Fe({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);fH(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>We(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(wt);else{let E=Se.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Se.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(wt,"ui",{event:r,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ee.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ee.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ee.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ee.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let E=Fe(r,this.state),y=n.points,v=E.x-n.x,C=E.y-n.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...y,ne(v,C)],pressures:S,lastCommittedPoint:ne(v,C)}),this.actionManager.executeAction(wt);return}if(Zt(n)){n.points.length>1&&this.store.scheduleCapture();let E=Fe(r,this.state),y=nn(ne(E.x,E.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<HT)&&n&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(n,{x:n.x-v/2,points:[ne(0,0),ne(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(wt)}else{let v=E.x-n.x,C=E.y-n.y;this.scene.mutateElement(n,{points:[...n.points,ne(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})}else t.drag.hasOccurred&&!l&&(af(this.state)&&df(n,!1)&&this.actionManager.executeAction(wt,"ui",{event:r,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(zt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Vo(this.state,{type:"selection"}),selectedElementIds:ye({...v.selectedElementIds,[n.id]:!0},v),selectedLinearElement:new Se(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(co(n)){let E=VH(tf({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&eI(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:mt.NEVER});return}if(Kt(n)){let E=kH(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(bf(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,bH(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Fe(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=Ef(y,f);v&&y&&(MH(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),SH([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let k of L){let A=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,A)},{informMutation:!1,isDragging:!1})}C.forEach(k=>{k.groupIds.length&&bl(C,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let L=v.filter(k=>k.frameId!==y.id&&sI(k,C,this.state));this.state.editingGroupId&&S(L),C=bf(C,L,y,this.state)}else if(!y&&this.state.editingGroupId){let L=v.filter(k=>k.frameId&&!sI(k,C,this.state));S(L)}C=lI(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&eI(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:mt.NEVER}),t.resize.isResizing){let E=lI(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Kt(v));for(let v of y)E=CH(E,xf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Zt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Se(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!c||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(bt(this.state)&&x&&w){if(this.eraserTrail.endPath(),nn(ne(x.clientX,x.clientY),ne(w.clientX,w.clientY))===0){let y=Fe({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?jH(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>bl(this.scene.getNonDeletedElements(),C)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ye(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=j(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...mo({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&Zt(v[0])?new Se(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>bl(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...mo({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||Ar(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...mo({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Zt(b)&&E.selectedLinearElement?.elementId!==b.id?new Se(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&We(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&_H({point:ne(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Kt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(wi):this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,De.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:Ar(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||Ee(this.scene.getNonDeletedElements(),this.state)||!Qz(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||c){let E=this.scene.getSelectedElements(this.state).filter(Zt);YT(E,af(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(zt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Vo(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&pe.pointers.size<=1&&hl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(r=>({selectedElementIds:ye({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&mI(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=ff(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<_z){let{x:c,y:p}=jd({sceneX:a,sceneY:l},n);return{viewportX:c,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=En.find(r=>r.code===this.props.langCode)||ho;await Gl(t),this.setAppState({})}},lG=()=>{(Cf()||vI())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(TI(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};lG();var kI=Sf;import{useEffect as cG,useState as dG}from"react";import{jsx as mG}from"react/jsx-runtime";var MI=e=>{let[o,t]=dG(!0);return cG(()=>{let r=async()=>{await Gl(n),t(!1)},n=En.find(i=>i.code===e.langCode)||ho;r()},[e.langCode]),o?mG(id,{theme:e.theme}):e.children};import pG from"clsx";import{jsx as LI}from"react/jsx-runtime";var PI=({children:e})=>{let{FooterCenterTunnel:o}=ve(),t=ge();return LI(o.In,{children:LI("div",{className:pG("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},uG=PI;PI.displayName="FooterCenter";import hG from"clsx";import{jsx as fG,jsxs as bG}from"react/jsx-runtime";var AI=({isCollaborating:e,onSelect:o,...t})=>{let r=ge(),n=r.width<830;return bG(_t,{...t,className:hG("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:g("labels.liveCollaboration"),children:[n?Z1:g("labels.share"),r.collaborators.size>0&&fG("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},gG=AI;AI.displayName="LiveCollaborationTrigger";import{jsx as Rr,jsxs as _I}from"react/jsx-runtime";var xG=()=>Rr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Rr("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"})}),EG=()=>_I("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Rr("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)"}),Rr("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)"}),Rr("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)"}),Rr("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)"})]}),DI=({style:e,size:o="small",withText:t})=>_I("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Rr(xG,{}),t&&Rr(EG,{})]});import{Fragment as BI,jsx as Ve,jsxs as _f}from"react/jsx-runtime";var Rf=({icon:e,shortcut:o,children:t})=>{let r=se();return _f(BI,{children:[Ve("div",{className:"welcome-screen-menu-item__icon",children:e}),Ve("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&Ve("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Rf.displayName="WelcomeScreenMenuItemContent";var Tl=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>Ve("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ve(Rf,{icon:t,shortcut:r,children:o})});Tl.displayName="WelcomeScreenMenuItem";var RI=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>Ve("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:Ve(Rf,{icon:t,shortcut:r,children:e})});RI.displayName="WelcomeScreenMenuItemLink";var $t=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=ve();return Ve(o.In,{children:Ve("div",{className:"welcome-screen-center",children:e||_f(BI,{children:[Ve(Nf,{}),Ve(Bf,{children:g("welcomeScreen.defaults.center_heading")}),_f(Ff,{children:[Ve(zf,{}),Ve(Of,{})]})]})})})};$t.displayName="Center";var Nf=({children:e})=>Ve("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ve(DI,{withText:!0})});Nf.displayName="Logo";var Bf=({children:e})=>Ve("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Bf.displayName="Heading";var Ff=({children:e})=>Ve("div",{className:"welcome-screen-menu",children:e});Ff.displayName="Menu";var Of=()=>{let e=Ue();return Ve(Tl,{onSelect:()=>e.executeAction(Zr),shortcut:"?",icon:Tn,children:g("helpDialog.title")})};Of.displayName="MenuItemHelp";var zf=()=>{let e=ge(),o=Ue();return e.viewModeEnabled?null:Ve(Tl,{onSelect:()=>o.executeAction(Kn),shortcut:Ne("loadScene"),icon:In,children:g("buttons.load")})};zf.displayName="MenuItemLoadScene";var NI=({onSelect:e})=>{let{t:o}=Oe();return Ve(Tl,{shortcut:null,onSelect:e,icon:jl,children:o("labels.liveCollaboration")})};NI.displayName="MenuItemLiveCollaborationTrigger";$t.Logo=Nf;$t.Heading=Bf;$t.Menu=Ff;$t.MenuItem=Tl;$t.MenuItemLink=RI;$t.MenuItemHelp=Of;$t.MenuItemLoadScene=zf;$t.MenuItemLiveCollaborationTrigger=NI;import{jsx as Gi,jsxs as Hf}from"react/jsx-runtime";var em=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=ve();return Gi(o.In,{children:Hf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[M1,Gi("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};em.displayName="MenuHint";var tm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=ve();return Gi(o.In,{children:Hf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Gi("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),P1]})})};tm.displayName="ToolbarHint";var om=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=ve();return Gi(o.In,{children:Hf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Gi("div",{children:e||g("welcomeScreen.defaults.helpHint")}),L1]})})};om.displayName="HelpHint";import{Fragment as FI,jsx as Il,jsxs as wG}from"react/jsx-runtime";var rm=e=>Il(FI,{children:e.children||wG(FI,{children:[Il($t,{}),Il(em,{}),Il(tm,{}),Il(om,{})]})});rm.displayName="WelcomeScreen";rm.Center=$t;rm.Hints={MenuHint:em,ToolbarHint:tm,HelpHint:om};var yG=rm;var vG=()=>{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)})},OI=vG;import{getSceneVersion as U8e,hashElementsVersion as Y8e,hashString as W8e,getNonDeletedElements as V8e}from"@excalidraw/element";import{getTextFromElements as K8e}from"@excalidraw/element";import{isInvisiblySmallElement as $8e}from"@excalidraw/element";import TG from"lodash.throttle";import{arrayToMap as IG,isDevEnv as zI,isTestEnv as HI}from"@excalidraw/common";import{orderByFractionalIndex as CG,syncInvalidIndices as GI,validateFractionalIndices as SG}from"@excalidraw/element";var kG=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),MG=TG((e,o,t)=>{if(zI()||HI()||window?.DEBUG_FRACTIONAL_INDICES){let r=GI(e.map(n=>({...n})));SG(r,{shouldThrow:HI()||zI(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),LG=(e,o,t)=>{let r=IG(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),d=kG(t,s,l);s&&d?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=CG(n);return MG(a,e,o),GI(a),a};import{getFreeDrawSvgPath as r7e}from"@excalidraw/element";import{isLinearElement as a7e}from"@excalidraw/element";import{FONT_FAMILY as s7e,THEME as c7e,MIME_TYPES as d7e,ROUNDNESS as dc,DEFAULT_LASER_COLOR as m7e,UserIdleState as p7e,normalizeLink as u7e}from"@excalidraw/common";import{mutateElement as pc,newElementWith as g7e,bumpVersion as ni}from"@excalidraw/element";import{CaptureUpdateAction as b7e}from"@excalidraw/element";import{sceneCoordsToViewportCoords as ry,viewportCoordsToSceneCoords as y7e}from"@excalidraw/common";import{jsx as UI,jsxs as PG}from"react/jsx-runtime";var YI=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=ve(),r=le();return UI(t.In,{children:PG(fe.Item,{onSelect:()=>{re("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??W0,children:[e??g("labels.textToDiagram"),UI(fe.Item.Badge,{children:"AI"})]})})};YI.displayName="TTDDialogTrigger";import{getCommonBounds as D7e,getVisibleSceneBounds as _7e}from"@excalidraw/element";import{useLayoutEffect as AG}from"react";var DG=e=>{let o=Re();return AG(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as O7e}from"@excalidraw/element";import{setCustomTextMetricsProvider as H7e}from"@excalidraw/element";import{jsx as Gf}from"react/jsx-runtime";OI();var BG=e=>{let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=ho.code,viewModeEnabled:d,zenModeEnabled:m,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:w=!0,handleKeyboardGlobally:E=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,children:O,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_,showDeprecatedFonts:R,renderScrollbars:V}=e,Z=e.UIOptions?.canvasActions,W={...e.UIOptions,canvasActions:{...WI.canvasActions,...Z},tools:{image:e.UIOptions?.tools?.image??!0}};return Z?.export&&(W.canvasActions.export.saveFileToDisk=Z.export?.saveFileToDisk??WI.canvasActions.export.saveFileToDisk),W.canvasActions.toggleTheme===null&&typeof u>"u"&&(W.canvasActions.toggleTheme=!0),RG(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let he=de=>{typeof de.scale=="number"&&de.scale!==1&&de.preventDefault()};return document.addEventListener("touchmove",he,{passive:!1}),()=>{document.removeEventListener("touchmove",he)}},[]),Gf(y1,{store:ze,children:Gf(MI,{langCode:s,theme:u,children:Gf(kI,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:d,zenModeEnabled:m,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:W,onPaste:x,detectScroll:w,handleKeyboardGlobally:E,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_!==!1,showDeprecatedFonts:R,renderScrollbars:V,children:O})})})},FG=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),d=Object.keys(a);return s.length!==d.length?!1:s.every(c=>c==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[c]===a[c])&&NG(n,l)},OG=_G.memo(BG,FG);OG.displayName="Excalidraw";export{_t as Button,b7e as CaptureUpdateAction,m7e as DEFAULT_LASER_COLOR,vd as DefaultSidebar,DG as DiagramToCodePlugin,ca as Ellipsify,OG as Excalidraw,s7e as FONT_FAMILY,uG as Footer,gG as LiveCollaborationTrigger,d7e as MIME_TYPES,dt as MainMenu,dc as ROUNDNESS,Xt as Sidebar,al as Stats,c7e as THEME,Ig as TTDDialog,YI as TTDDialogTrigger,p7e as UserIdleState,yG as WelcomeScreen,ni as bumpVersion,Ii as convertToExcalidrawElements,ho as defaultLang,R2 as elementPartiallyOverlapsWithOrContainsBBox,N2 as elementsOverlappingBBox,sy as exportToBlob,cr as exportToCanvas,FP as exportToClipboard,si as exportToSvg,D7e as getCommonBounds,bm as getDataURL,r7e as getFreeDrawSvgPath,bc as getLibraryItemsHash,V8e as getNonDeletedElements,U8e as getSceneVersion,K8e as getTextFromElements,_7e as getVisibleSceneBounds,Y8e as hashElementsVersion,W8e as hashString,xh as isElementInsideBBox,O7e as isElementLink,$8e as isInvisiblySmallElement,a7e as isLinearElement,En as languages,Bl as loadFromBlob,fm as loadLibraryFromBlob,gm as loadSceneOrLibraryFromBlob,by as mergeLibraryItems,pc as mutateElement,g7e as newElementWith,u7e as normalizeLink,Ou as parseLibraryTokensFromUrl,LG as reconcileElements,bn as restore,ZI as restoreAppState,KI as restoreElement,hm as restoreElements,Xi as restoreLibraryItems,ry as sceneCoordsToViewportCoords,Yi as serializeAsJSON,um as serializeLibraryAsJSON,H7e as setCustomTextMetricsProvider,se as useDevice,eA as useHandleLibrary,Oe as useI18n,y7e as viewportCoordsToSceneCoords,xx as zoomToFitBounds};
|
|
118
|
+
`),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=Ue({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:qH,verticalAlign:R5,locked:!1},l=Nf({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=O5(a.fontFamily),[d,,m]=qG(this.state),c=Math.max(Math.min((m-d)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
|
|
119
|
+
`),b=f.reduce((x,w,E)=>{let y=nU(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),I=dC(y,l,s),k=I.width>c,P=k?tU(y,l,c):y;I=k?dC(P,l,s):I;let S=n-I.width/2,B=u-I.height/2,A=$5({...a,x:S,y:B,text:P,originalText:y,lineHeight:s,autoResize:!k,frameId:v?v.id:null});x.push(A),u+=A.height+p}else f[E-1]?.trim()&&(u+=iU(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:Te(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&vC===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:_("CtrlOrCmd+Shift+V")}),duration:5e3}),vC=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&bo(s)?Zr(s,{originalText:a,isDeleted:l??s.isDeleted,...PG(s,iC(s,n),n,a)}):s)])};r3({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:d}=km({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,d-this.state.offsetTop]},onChange:_e(a=>{i(a,!1),bC(t)&&Hf(t,this.scene)}),onSubmit:_e(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let d=t.containerId?t.containerId:t.id;pa(()=>{this.setState(m=>({selectedElementIds:Te({...m.selectedElementIds,[d]:!0},m)}))})}s&&yG(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),pa(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Bt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&bo(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return ts({point:se(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(bo(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let d=e1(s,a);return d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?aC({x:t,y:r},d,a):!0}).filter(s=>fa(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(F5/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&GG([n],this.state,this.editorInterface)&&vU(se(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||ZG(se(t,r),n,this.scene.getNonDeletedElementsMap())?!0:ts({point:se(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lt(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return J5(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,d,m,c]=W5(n[l],this.scene.getNonDeletedElementsMap());if(Yf(n[l])&&ts({point:se(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<m&&d<r&&r<c){a=n[l];break}}return J5(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=Pe.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;ts({point:se(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Pe.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=Pe.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(Ze(a)?l===0||l===a.points.length-1:l>=0)||s?ye(this.interactiveCanvas,Ne.POINTER):this.hitElement(r,n,a)&&(!Ze(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Ne.MOVE)):this.hitElement(r,n,a)&&(!Ze(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Ne.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Pe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else ye(this.interactiveCanvas,Ne.AUTO)}updateGestureOnPointerDown(t){ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ge.pointers.size===2&&(ge.lastCenter=tg(ge.pointers),ge.initialScale=this.state.zoom.value,ge.initialDistance=og(Array.from(ge.pointers.values())))}initialPointerDownState(t){let r=Ue(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ga(n),d=n.findIndex(Ze)===0;return{origin:r,withCmdOrCtrl:t[V.CTRL_OR_CMD],originInGrid:Bf(st(r.x,r.y,t[V.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:dg(as,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,c)=>(m.set(c.id,Z5(c)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;n1=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=Rd(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=_e(()=>{ss=null,n1=!1,Bt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ne.POINTER_MOVE,n),window.removeEventListener(ne.POINTER_UP,i),n.flush()});return ss=i,window.addEventListener(ne.POINTER_MOVE,n),window.addEventListener(ne.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(F5/this.state.zoom.value,1),[i,a,l,s]=ga(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:AG(t)?Im.ADAPTIVE_RADIUS:Im.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Qo({event:t,app:this,selectedElements:r})&&(n||!jt.getReferenceSnapPoints())&&jt.setReferenceSnapPoints(yv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Qo({event:t,app:this,selectedElements:r})&&(n||!jt.getVisibleGaps())&&jt.setVisibleGaps(Ev(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return _e(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return _e(r=>{r.key===V.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return Rd(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Ue(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=st(n.x,n.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Pe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Pe.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=Bf(yU(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(It(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=st(n.x,n.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Xr(se(n.x,n.y),se(t.origin.x,t.origin.y))*this.state.zoom.value<U5)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Pe.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,d)){let f=Pe.addMidpoint(this.state.selectedLinearElement,n,this,!r[V.CTRL_OR_CMD],this.scene);if(!f)return;pa(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Pe.handlePointDragging(r,this,n.x,n.y,p);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState(u);return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>Lt(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&pa(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},w=[...t.originalElements.values()],E=r.shiftKey;if(E){let I=Math.abs(x.x),k=Math.abs(x.y),P=E&&I<k,S=E&&I>k;P&&(x.x=0),S&&(x.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&kn(I)&&I.crop!==null&&t.hit.element===I){let k=I.crop,P=Ql(I)&&this.imageCache.get(I.fileId)?.image;if(P&&!(P instanceof Promise)){let S=RH(M5(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[B,A,L,R,Y,q]=W5(I,d),D=Af(Lf(se(B,A),se(Y,q),I.angle)),F=Af(Lf(se(L,A),se(Y,q),I.angle)),G=Af(Lf(se(B,R),se(Y,q),I.angle)),Z=A5(P5(F,D)),te=A5(P5(G,D)),oe=M5(L5(S,Z),L5(S,te)),$={...k,x:k5(k.x-oe[0]*Math.sign(I.scale[0]),0,P.naturalWidth-k.width),y:k5(k.y-oe[1]*Math.sign(I.scale[1]),0,P.naturalHeight-k.height)};this.scene.mutateElement(I,{crop:$});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=wv(w,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||EU(t,p,x,this.scene,y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!Ze(p[0]))&&this.setState({suggestedBindings:Gf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),k=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});k&&t.hit.wasAddedToSelection&&!P.find(F=>F.id===k.id)&&P.push(k);let S=new Map(P.map(F=>[F.id,F])),{duplicatedElements:B,duplicateElementsMap:A,elementsWithDuplicates:L,origIdToDuplicateId:R}=Uf({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:S,overrides:({duplicateElement:F,origElement:G})=>({frameId:F.frameId??G.frameId,seed:dG()})});B.forEach(F=>{t.originalElements.set(F.id,Z5(F))});let Y=L.map(F=>{if(S.has(F.id)){let G=t.originalElements.get(F.id);if(G)return Zr(F,{x:G.x,y:G.y})}return F}),q=this.props.onDuplicate?.(Y,I),D=pC(q||Y,Mm(B));pa(()=>{if(t.hit.element){let F=R.get(t.hit.element.id),G=F&&A.get(F);t.hit.element=G||null}t.hit.allHitElements=t.hit.allHitElements.reduce((F,G)=>{let Z=R.get(G.id),te=Z&&A.get(Z);return te&&F.push(te),F},[]),t.drag.origin=Ue(r,this.state),this.setState(F=>({...gU(B,this.scene.getNonDeletedElements(),F)})),this.scene.replaceAllElements(D),this.maybeCacheVisibleGaps(r,P,!0),this.maybeCacheReferenceSnapPoints(r,P,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,se(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(At(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Df(r)&&u.length===2&&({width:f,height:b}=Q5(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,se(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&Ze(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),se(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Wf(p,!1)&&this.setState({suggestedBindings:Y5(p,[n],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Pe.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&we(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>to({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?P1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...to({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&At(f[0])?new Pe(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||ar(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(as.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(as.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return _e(r=>{this.removePointer(r),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:d,isRotating:m,isCropping:c}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Jl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,jt.setReferenceSnapPoints(null),jt.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements,u=Ue({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);_G(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>Ze(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(Ft);else{let E=Pe.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Pe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(Ft,"ui",{event:r,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ne.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ne.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ne.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ne.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let E=Ue(r,this.state),y=n.points,v=E.x-n.x,I=E.y-n.y;v===y[0][0]&&I===y[0][1]&&(I+=1e-4,v+=1e-4);let k=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...y,se(v,I)],pressures:k,lastCommittedPoint:se(v,I)}),this.actionManager.executeAction(Ft);return}if(At(n)){n.points.length>1&&this.store.scheduleCapture();let E=Ue(r,this.state),y=Xr(se(E.x,E.y),se(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<U5)&&n&&!l)if(this.editorInterface.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(n,{x:n.x-v/2,points:[se(0,0),se(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(Ft)}else{let v=E.x-n.x,I=E.y-n.y;this.scene.mutateElement(n,{points:[...n.points,se(v,I)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})}else t.drag.hasOccurred&&!l&&(zf(this.state)&&Wf(n,!1)&&this.actionManager.executeAction(Ft,"ui",{event:r,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Xt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:ir(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Te({...v.selectedElementIds,[n.id]:!0},v),selectedLinearElement:new Pe(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(bo(n)){let E=sU(Nf({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&tC(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:Tt.NEVER});return}if(Lt(n)){let E=WG(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Jf(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,RG(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Ue(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=e1(y,f);v&&y&&(VG(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),YG([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),I=this.scene.getElementsMapIncludingDeleted(),k=P=>{if(P.length>0){for(let S of P){let B=S.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(S,{groupIds:S.groupIds.slice(0,B)},{informMutation:!1,isDragging:!1})}I.forEach(S=>{S.groupIds.length&&Mn(I,S.groupIds[S.groupIds.length-1]).length<2&&this.scene.mutateElement(S,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let P=v.filter(S=>S.frameId!==y.id&&sC(S,I,this.state));this.state.editingGroupId&&k(P),I=Jf(I,P,y,this.state)}else if(!y&&this.state.editingGroupId){let P=v.filter(S=>S.frameId&&!sC(S,I,this.state));k(P)}I=lC(I,this.state,this),this.scene.replaceAllElements(I)}}if(i&&this.store.scheduleCapture(),i&&tC(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:Tt.NEVER}),t.resize.isResizing){let E=lC(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Lt(v));for(let v of y)E=UG(E,Qf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&At(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Pe(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!c||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(It(this.state)&&x&&w){if(this.eraserTrail.endPath(),Xr(se(x.clientX,x.clientY),se(w.clientX,w.clientY))===0){let y=Ue({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(I=>this.elementsPendingErasure.add(I.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?uU(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(I=>Mn(this.scene.getNonDeletedElements(),I)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,I)=>({...v,...I}),{})},selectedElementIds:Te(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=Q(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...to({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&At(v[0])?new Pe(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>Mn(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...to({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||ar(b)?"info":!1}}):this.setState(E=>({selectedElementIds:Te({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...to({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:At(b)&&E.selectedLinearElement?.elementId!==b.id?new Pe(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&Ze(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&jG({point:se(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Lt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(ji):this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),ye(this.interactiveCanvas,Ne.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:Te({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:ar(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||we(this.scene.getNonDeletedElements(),this.state)||!cG(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||c){let E=this.scene.getSelectedElements(this.state).filter(At);V5(E,zf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(Xt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:ir(this.state,{type:this.state.preferredSelectionTool.type})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&ge.pointers.size<=1&&es(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(r=>({selectedElementIds:Te({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&mC(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=jf(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<VH){let{x:c,y:p}=km({sceneX:a,sceneY:l},n);return{viewportX:c,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=On.find(r=>r.code===this.props.langCode)||yo;await Ts(t),this.setAppState({})}},IU=()=>{(TC()||IC())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(SC(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};IU();var PC=s1;import{useEffect as SU,useState as kU}from"react";import{jsx as MU}from"react/jsx-runtime";var LC=e=>{let[o,t]=kU(!0);return SU(()=>{let r=async()=>{await Ts(n),t(!1)},n=On.find(i=>i.code===e.langCode)||yo;r()},[e.langCode]),o?MU(Od,{theme:e.theme}):e.children};import PU from"clsx";import{jsx as AC}from"react/jsx-runtime";var DC=({children:e})=>{let{FooterCenterTunnel:o}=Ce(),t=xe();return AC(o.In,{children:AC("div",{className:PU("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},LU=DC;DC.displayName="FooterCenter";import AU from"clsx";import{MQ_MIN_WIDTH_DESKTOP as DU}from"@excalidraw/common";import{jsx as RU,jsxs as NU}from"react/jsx-runtime";var _C=({isCollaborating:e,onSelect:o,editorInterface:t,...r})=>{let n=xe(),i=t?.formFactor!=="desktop"||n.width<DU;return NU(yt,{...r,className:AU("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:i?void 0:"auto"},title:g("labels.liveCollaboration"),children:[i?Cb:g("labels.share"),n.collaborators.size>0&&RU("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},_U=_C;_C.displayName="LiveCollaborationTrigger";import{jsx as Jr,jsxs as NC}from"react/jsx-runtime";var BU=()=>Jr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Jr("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"})}),FU=()=>NC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Jr("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)"}),Jr("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)"}),Jr("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)"}),Jr("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)"})]}),RC=({style:e,size:o="small",withText:t})=>NC("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Jr(BU,{}),t&&Jr(FU,{})]});import{Fragment as OC,jsx as je,jsxs as g1}from"react/jsx-runtime";var f1=({icon:e,shortcut:o,children:t})=>{let r=pe();return g1(OC,{children:[je("div",{className:"welcome-screen-menu-item__icon",children:e}),je("div",{className:"welcome-screen-menu-item__text",children:t}),o&&r.formFactor!=="phone"&&je("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};f1.displayName="WelcomeScreenMenuItemContent";var cs=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>je("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:je(f1,{icon:t,shortcut:r,children:o})});cs.displayName="WelcomeScreenMenuItem";var BC=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>je("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:je(f1,{icon:t,shortcut:r,children:e})});BC.displayName="WelcomeScreenMenuItemLink";var oo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ce();return je(o.In,{children:je("div",{className:"welcome-screen-center",children:e||g1(OC,{children:[je(b1,{}),je(x1,{children:g("welcomeScreen.defaults.center_heading")}),g1(E1,{children:[je(w1,{}),je(y1,{})]})]})})})};oo.displayName="Center";var b1=({children:e})=>je("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||je(RC,{withText:!0})});b1.displayName="Logo";var x1=({children:e})=>je("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});x1.displayName="Heading";var E1=({children:e})=>je("div",{className:"welcome-screen-menu",children:e});E1.displayName="Menu";var y1=()=>{let e=Ve();return je(cs,{onSelect:()=>e.executeAction(hn),shortcut:"?",icon:Xn,children:g("helpDialog.title")})};y1.displayName="MenuItemHelp";var w1=()=>{let e=xe(),o=Ve();return e.viewModeEnabled?null:je(cs,{onSelect:()=>o.executeAction(Ei),shortcut:ze("loadScene"),icon:Kn,children:g("buttons.load")})};w1.displayName="MenuItemLoadScene";var FC=({onSelect:e})=>{let{t:o}=Be();return je(cs,{shortcut:null,onSelect:e,icon:Ps,children:o("labels.liveCollaboration")})};FC.displayName="MenuItemLiveCollaborationTrigger";oo.Logo=b1;oo.Heading=x1;oo.Menu=E1;oo.MenuItem=cs;oo.MenuItemLink=BC;oo.MenuItemHelp=y1;oo.MenuItemLoadScene=w1;oo.MenuItemLiveCollaborationTrigger=FC;import{jsx as ba,jsxs as v1}from"react/jsx-runtime";var Dm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ce();return ba(o.In,{children:v1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[sb,ba("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};Dm.displayName="MenuHint";var _m=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ce();return ba(o.In,{children:v1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ba("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),db]})})};_m.displayName="ToolbarHint";var Rm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ce();return ba(o.In,{children:v1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ba("div",{children:e||g("welcomeScreen.defaults.helpHint")}),cb]})})};Rm.displayName="HelpHint";import{Fragment as zC,jsx as ds,jsxs as zU}from"react/jsx-runtime";var Nm=e=>ds(zC,{children:e.children||zU(zC,{children:[ds(oo,{}),ds(Dm,{}),ds(_m,{}),ds(Rm,{})]})});Nm.displayName="WelcomeScreen";Nm.Center=oo;Nm.Hints={MenuHint:Dm,ToolbarHint:_m,HelpHint:Rm};var OU=Nm;var HU=()=>{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)})},HC=HU;import{getSceneVersion as y_e,hashElementsVersion as w_e,hashString as v_e,getNonDeletedElements as T_e}from"@excalidraw/element";import{getTextFromElements as C_e}from"@excalidraw/element";import{isInvisiblySmallElement as k_e}from"@excalidraw/element";import GU from"lodash.throttle";import{arrayToMap as UU,isDevEnv as GC,isTestEnv as UC}from"@excalidraw/common";import{orderByFractionalIndex as YU,syncInvalidIndices as YC,validateFractionalIndices as WU}from"@excalidraw/element";var VU=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),XU=GU((e,o,t)=>{if(GC()||UC()||window?.DEBUG_FRACTIONAL_INDICES){let r=YC(e.map(n=>({...n})));WU(r,{shouldThrow:UC()||GC(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),KU=(e,o,t)=>{let r=UU(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),d=VU(t,s,l);s&&d?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=YU(n);return XU(a,e,o),YC(a),a};import{getFreeDrawSvgPath as N_e}from"@excalidraw/element";import{isLinearElement as O_e}from"@excalidraw/element";import{FONT_FAMILY as H_e,THEME as G_e,MIME_TYPES as U_e,ROUNDNESS as zc,DEFAULT_LASER_COLOR as Y_e,UserIdleState as W_e,normalizeLink as V_e,sceneCoordsToViewportCoords as Oy,viewportCoordsToSceneCoords as X_e,getFormFactor as K_e}from"@excalidraw/common";import{mutateElement as Gc,newElementWith as Z_e,bumpVersion as Li}from"@excalidraw/element";import{CaptureUpdateAction as q_e}from"@excalidraw/element";import{jsx as WC,jsxs as $U}from"react/jsx-runtime";var VC=({children:e,icon:o})=>{let{t}=Be(),{TTDDialogTriggerTunnel:r}=Ce(),n=me();return WC(r.In,{children:$U(le.Item,{onSelect:()=>{ae("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??y0,children:[e??t("labels.textToDiagram"),WC(le.Item.Badge,{children:"AI"})]})})};VC.displayName="TTDDialogTrigger";import{getCommonBounds as dRe,getVisibleSceneBounds as mRe}from"@excalidraw/element";import{useLayoutEffect as ZU}from"react";var jU=e=>{let o=Oe();return ZU(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as fRe}from"@excalidraw/element";import{setCustomTextMetricsProvider as xRe}from"@excalidraw/element";import{jsx as T1}from"react/jsx-runtime";HC();var eY=e=>{let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:d=yo.code,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:p,libraryReturnUrl:u,theme:f,name:b,renderCustomStats:x,onPaste:w,detectScroll:E=!0,handleKeyboardGlobally:y=!1,onLibraryChange:v,autoFocus:I=!1,generateIdForFile:k,onLinkOpen:P,generateLinkForSelection:S,onPointerDown:B,onPointerUp:A,onScrollChange:L,onDuplicate:R,children:Y,validateEmbeddable:q,renderEmbeddable:D,aiEnabled:F,showDeprecatedFonts:G,renderScrollbars:Z}=e,te=e.UIOptions?.canvasActions,oe={...e.UIOptions,canvasActions:{...XC.canvasActions,...te},tools:{image:e.UIOptions?.tools?.image??!0}};return te?.export&&(oe.canvasActions.export.saveFileToDisk=te.export?.saveFileToDisk??XC.canvasActions.export.saveFileToDisk),oe.canvasActions.toggleTheme===null&&typeof f>"u"&&(oe.canvasActions.toggleTheme=!0),JU(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let J=be=>{typeof be.scale=="number"&&be.scale!==1&&be.preventDefault()};return document.addEventListener("touchmove",J,{passive:!1}),()=>{document.removeEventListener("touchmove",J)}},[]),T1(Q1,{store:We,children:T1(LC,{langCode:d,theme:f,children:T1(PC,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:d,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:p,libraryReturnUrl:u,theme:f,name:b,renderCustomStats:x,UIOptions:oe,onPaste:w,detectScroll:E,handleKeyboardGlobally:y,onLibraryChange:v,autoFocus:I,generateIdForFile:k,onLinkOpen:P,generateLinkForSelection:S,onPointerDown:B,onPointerUp:A,onScrollChange:L,onDuplicate:R,validateEmbeddable:q,renderEmbeddable:D,aiEnabled:F!==!1,showDeprecatedFonts:G,renderScrollbars:Z,children:Y})})})},tY=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),d=Object.keys(a);return s.length!==d.length?!1:s.every(c=>c==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[c]===a[c])&&QU(n,l)},oY=qU.memo(eY,tY);oY.displayName="Excalidraw";export{yt as Button,q_e as CaptureUpdateAction,Y_e as DEFAULT_LASER_COLOR,Qd as DefaultSidebar,jU as DiagramToCodePlugin,Va as Ellipsify,oY as Excalidraw,H_e as FONT_FAMILY,LU as Footer,_U as LiveCollaborationTrigger,U_e as MIME_TYPES,ht as MainMenu,zc as ROUNDNESS,eo as Sidebar,Kl as Stats,G_e as THEME,of as TTDDialog,VC as TTDDialogTrigger,W_e as UserIdleState,OU as WelcomeScreen,Li as bumpVersion,Qi as convertToExcalidrawElements,yo as defaultLang,D2 as elementPartiallyOverlapsWithOrContainsBBox,_2 as elementsOverlappingBBox,Yy as exportToBlob,kr as exportToCanvas,HA as exportToClipboard,Ri as exportToSvg,dRe as getCommonBounds,Vm as getDataURL,K_e as getFormFactor,N_e as getFreeDrawSvgPath,Xc as getLibraryItemsHash,T_e as getNonDeletedElements,y_e as getSceneVersion,C_e as getTextFromElements,mRe as getVisibleSceneBounds,w_e as hashElementsVersion,v_e as hashString,Vh as isElementInsideBBox,fRe as isElementLink,k_e as isInvisiblySmallElement,O_e as isLinearElement,On as languages,xs as loadFromBlob,Wm as loadLibraryFromBlob,Ym as loadSceneOrLibraryFromBlob,Jy as mergeLibraryItems,Gc as mutateElement,Z_e as newElementWith,V_e as normalizeLink,dh as parseLibraryTokensFromUrl,KU as reconcileElements,Bn as restore,qC as restoreAppState,jC as restoreElement,Gm as restoreElements,Ca as restoreLibraryItems,Oy as sceneCoordsToViewportCoords,va as serializeAsJSON,ZC as serializeLibraryAsJSON,xRe as setCustomTextMetricsProvider,pe as useEditorInterface,o8 as useHandleLibrary,Be as useI18n,et as useStylesPanelMode,X_e as viewportCoordsToSceneCoords,eE as zoomToFitBounds};
|