js-draw 1.3.1 → 1.4.1
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/README.md +2 -2
- package/dist/Editor.css +55 -13
- package/dist/bundle.js +2 -2
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/Editor.d.ts +36 -3
- package/dist/cjs/Editor.js +63 -26
- package/dist/cjs/commands/Erase.js +1 -1
- package/dist/cjs/commands/UnresolvedCommand.d.ts +1 -1
- package/dist/cjs/components/AbstractComponent.d.ts +1 -1
- package/dist/cjs/components/AbstractComponent.js +1 -1
- package/dist/cjs/components/BackgroundComponent.d.ts +1 -1
- package/dist/cjs/components/BackgroundComponent.js +13 -7
- package/dist/cjs/components/SVGGlobalAttributesObject.d.ts +2 -2
- package/dist/cjs/components/SVGGlobalAttributesObject.js +10 -14
- package/dist/cjs/{EditorImage.d.ts → image/EditorImage.d.ts} +30 -8
- package/dist/cjs/{EditorImage.js → image/EditorImage.js} +51 -7
- package/dist/cjs/image/export/adjustExportedSVGSize.d.ts +6 -0
- package/dist/cjs/image/export/adjustExportedSVGSize.js +22 -0
- package/dist/cjs/image/export/editorImageToSVG.d.ts +8 -0
- package/dist/cjs/image/export/editorImageToSVG.js +63 -0
- package/dist/cjs/image/lib.d.ts +1 -0
- package/dist/cjs/image/lib.js +8 -0
- package/dist/cjs/lib.d.ts +1 -1
- package/dist/cjs/lib.js +2 -3
- package/dist/cjs/localizations/comments.d.ts +6 -0
- package/dist/cjs/localizations/comments.js +10 -0
- package/dist/cjs/localizations/es.js +68 -48
- package/dist/cjs/rendering/caching/RenderingCache.d.ts +1 -1
- package/dist/cjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/cjs/rendering/caching/RenderingCacheNode.js +4 -3
- package/dist/cjs/rendering/renderers/AbstractRenderer.d.ts +1 -0
- package/dist/cjs/rendering/renderers/AbstractRenderer.js +8 -0
- package/dist/cjs/rendering/renderers/SVGRenderer.d.ts +28 -1
- package/dist/cjs/rendering/renderers/SVGRenderer.js +58 -7
- package/dist/cjs/toolbar/AbstractToolbar.d.ts +11 -3
- package/dist/cjs/toolbar/AbstractToolbar.js +20 -6
- package/dist/cjs/toolbar/EdgeToolbar.js +5 -6
- package/dist/cjs/toolbar/IconProvider.d.ts +1 -0
- package/dist/cjs/toolbar/IconProvider.js +43 -0
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.d.ts +3 -1
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.js +19 -1
- package/dist/cjs/toolbar/widgets/BaseToolWidget.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/BaseToolWidget.js +3 -0
- package/dist/cjs/toolbar/widgets/BaseWidget.d.ts +5 -0
- package/dist/cjs/toolbar/widgets/BaseWidget.js +30 -2
- package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +1 -1
- package/dist/cjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/HandToolWidget.js +6 -0
- package/dist/cjs/toolbar/widgets/InsertImageWidget.js +1 -1
- package/dist/cjs/toolbar/widgets/OverflowWidget.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/OverflowWidget.js +3 -0
- package/dist/cjs/toolbar/widgets/SaveActionWidget.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/SaveActionWidget.js +3 -0
- package/dist/cjs/tools/BaseTool.d.ts +3 -0
- package/dist/cjs/tools/BaseTool.js +13 -2
- package/dist/cjs/tools/FindTool.d.ts +1 -0
- package/dist/cjs/tools/FindTool.js +4 -1
- package/dist/cjs/tools/PanZoom.d.ts +1 -0
- package/dist/cjs/tools/PanZoom.js +4 -0
- package/dist/cjs/tools/Pen.d.ts +0 -1
- package/dist/cjs/tools/Pen.js +1 -4
- package/dist/cjs/tools/PipetteTool.d.ts +1 -0
- package/dist/cjs/tools/PipetteTool.js +3 -0
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -0
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +3 -0
- package/dist/cjs/tools/SelectionTool/Selection.d.ts +2 -0
- package/dist/cjs/tools/SelectionTool/Selection.js +44 -8
- package/dist/cjs/tools/SelectionTool/SelectionHandle.d.ts +14 -6
- package/dist/cjs/tools/SelectionTool/SelectionHandle.js +26 -8
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +5 -0
- package/dist/cjs/tools/SoundUITool.d.ts +1 -0
- package/dist/cjs/tools/SoundUITool.js +4 -1
- package/dist/cjs/tools/TextTool.js +2 -2
- package/dist/cjs/tools/ToolController.d.ts +2 -0
- package/dist/cjs/tools/ToolController.js +13 -2
- package/dist/cjs/tools/ToolSwitcherShortcut.d.ts +1 -0
- package/dist/cjs/tools/ToolSwitcherShortcut.js +3 -0
- package/dist/cjs/types.d.ts +9 -4
- package/dist/cjs/types.js +4 -3
- package/dist/cjs/util/ReactiveValue.d.ts +1 -1
- package/dist/cjs/util/ReactiveValue.js +2 -2
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/Editor.d.ts +36 -3
- package/dist/mjs/Editor.mjs +64 -27
- package/dist/mjs/Editor.toSVGAsync.test.d.ts +1 -0
- package/dist/mjs/commands/Erase.mjs +1 -1
- package/dist/mjs/commands/UnresolvedCommand.d.ts +1 -1
- package/dist/mjs/components/AbstractComponent.d.ts +1 -1
- package/dist/mjs/components/AbstractComponent.mjs +1 -1
- package/dist/mjs/components/BackgroundComponent.d.ts +1 -1
- package/dist/mjs/components/BackgroundComponent.mjs +13 -7
- package/dist/mjs/components/SVGGlobalAttributesObject.d.ts +2 -2
- package/dist/mjs/components/SVGGlobalAttributesObject.mjs +10 -14
- package/dist/mjs/{EditorImage.d.ts → image/EditorImage.d.ts} +30 -8
- package/dist/mjs/{EditorImage.mjs → image/EditorImage.mjs} +51 -7
- package/dist/mjs/image/EditorImage.test.d.ts +1 -0
- package/dist/mjs/image/export/adjustExportedSVGSize.d.ts +6 -0
- package/dist/mjs/image/export/adjustExportedSVGSize.mjs +20 -0
- package/dist/mjs/image/export/editorImageToSVG.d.ts +8 -0
- package/dist/mjs/image/export/editorImageToSVG.mjs +55 -0
- package/dist/mjs/image/lib.d.ts +1 -0
- package/dist/mjs/image/lib.mjs +1 -0
- package/dist/mjs/lib.d.ts +1 -1
- package/dist/mjs/lib.mjs +1 -1
- package/dist/mjs/localizations/comments.d.ts +6 -0
- package/dist/mjs/localizations/comments.mjs +8 -0
- package/dist/mjs/localizations/es.mjs +68 -48
- package/dist/mjs/rendering/caching/RenderingCache.d.ts +1 -1
- package/dist/mjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/mjs/rendering/caching/RenderingCacheNode.mjs +4 -3
- package/dist/mjs/rendering/renderers/AbstractRenderer.d.ts +1 -0
- package/dist/mjs/rendering/renderers/AbstractRenderer.mjs +8 -0
- package/dist/mjs/rendering/renderers/SVGRenderer.d.ts +28 -1
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +58 -7
- package/dist/mjs/toolbar/AbstractToolbar.d.ts +11 -3
- package/dist/mjs/toolbar/AbstractToolbar.mjs +20 -6
- package/dist/mjs/toolbar/EdgeToolbar.mjs +5 -6
- package/dist/mjs/toolbar/IconProvider.d.ts +1 -0
- package/dist/mjs/toolbar/IconProvider.mjs +43 -0
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.d.ts +3 -1
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.mjs +21 -2
- package/dist/mjs/toolbar/widgets/BaseToolWidget.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +3 -0
- package/dist/mjs/toolbar/widgets/BaseWidget.d.ts +5 -0
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +30 -2
- package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +1 -1
- package/dist/mjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +6 -0
- package/dist/mjs/toolbar/widgets/InsertImageWidget.mjs +1 -1
- package/dist/mjs/toolbar/widgets/OverflowWidget.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/OverflowWidget.mjs +3 -0
- package/dist/mjs/toolbar/widgets/SaveActionWidget.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/SaveActionWidget.mjs +3 -0
- package/dist/mjs/tools/BaseTool.d.ts +3 -0
- package/dist/mjs/tools/BaseTool.mjs +13 -2
- package/dist/mjs/tools/FindTool.d.ts +1 -0
- package/dist/mjs/tools/FindTool.mjs +4 -1
- package/dist/mjs/tools/PanZoom.d.ts +1 -0
- package/dist/mjs/tools/PanZoom.mjs +4 -0
- package/dist/mjs/tools/Pen.d.ts +0 -1
- package/dist/mjs/tools/Pen.mjs +1 -4
- package/dist/mjs/tools/PipetteTool.d.ts +1 -0
- package/dist/mjs/tools/PipetteTool.mjs +3 -0
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -0
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +3 -0
- package/dist/mjs/tools/SelectionTool/Selection.d.ts +2 -0
- package/dist/mjs/tools/SelectionTool/Selection.mjs +45 -9
- package/dist/mjs/tools/SelectionTool/SelectionHandle.d.ts +14 -6
- package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +25 -7
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +5 -0
- package/dist/mjs/tools/SoundUITool.d.ts +1 -0
- package/dist/mjs/tools/SoundUITool.mjs +4 -1
- package/dist/mjs/tools/TextTool.mjs +2 -2
- package/dist/mjs/tools/ToolController.d.ts +2 -0
- package/dist/mjs/tools/ToolController.mjs +13 -2
- package/dist/mjs/tools/ToolSwitcherShortcut.d.ts +1 -0
- package/dist/mjs/tools/ToolSwitcherShortcut.mjs +3 -0
- package/dist/mjs/types.d.ts +9 -4
- package/dist/mjs/types.mjs +4 -3
- package/dist/mjs/util/ReactiveValue.d.ts +1 -1
- package/dist/mjs/util/ReactiveValue.mjs +2 -2
- package/dist/mjs/version.mjs +1 -1
- package/package.json +5 -5
- package/src/Editor.scss +6 -0
- package/src/toolbar/EdgeToolbar.scss +19 -2
- package/src/tools/SelectionTool/SelectionTool.scss +74 -0
- package/src/tools/tools.scss +1 -1
- package/src/tools/SelectionTool/SelectionTool.css +0 -35
- /package/dist/cjs/{EditorImage.test.d.ts → Editor.toSVGAsync.test.d.ts} +0 -0
- /package/dist/{mjs → cjs/image}/EditorImage.test.d.ts +0 -0
package/dist/bundle.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(()=>{var e={489:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var o=n(9601),i=n.n(o),r=n(2609),s=n.n(r)()(i());s.push([t.id,'.clr-picker {\n display: none;\n flex-wrap: wrap;\n position: absolute;\n width: 200px;\n z-index: 1000;\n border-radius: 10px;\n background-color: #fff;\n justify-content: flex-end;\n direction: ltr;\n box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1);\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.clr-picker.clr-open,\n.clr-picker[data-inline="true"] {\n display: flex;\n}\n\n.clr-picker[data-inline="true"] {\n position: relative;\n}\n\n.clr-gradient {\n position: relative;\n width: 100%;\n height: 100px;\n margin-bottom: 15px;\n border-radius: 3px 3px 0 0;\n background-image: linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor);\n cursor: pointer;\n}\n\n.clr-marker {\n position: absolute;\n width: 12px;\n height: 12px;\n margin: -6px 0 0 -6px;\n border: 1px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n cursor: pointer;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-runnable-track {\n width: 100%;\n height: 16px;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-thumb {\n width: 16px;\n height: 16px;\n -webkit-appearance: none;\n}\n\n.clr-picker input[type="range"]::-moz-range-track {\n width: 100%;\n height: 16px;\n border: 0;\n}\n\n.clr-picker input[type="range"]::-moz-range-thumb {\n width: 16px;\n height: 16px;\n border: 0;\n}\n\n.clr-hue {\n background-image: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);\n}\n\n.clr-hue,\n.clr-alpha {\n position: relative;\n width: calc(100% - 40px);\n height: 8px;\n margin: 5px 20px;\n border-radius: 4px;\n}\n\n.clr-alpha span {\n display: block;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n background-image: linear-gradient(90deg, rgba(0,0,0,0), currentColor);\n}\n\n.clr-hue input,\n.clr-alpha input {\n position: absolute;\n width: calc(100% + 32px);\n height: 16px;\n left: -16px;\n top: -4px;\n margin: 0;\n background-color: transparent;\n opacity: 0;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n\n.clr-hue div,\n.clr-alpha div {\n position: absolute;\n width: 16px;\n height: 16px;\n left: 0;\n top: 50%;\n margin-left: -8px;\n transform: translateY(-50%);\n border: 2px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n box-shadow: 0 0 1px #888;\n pointer-events: none;\n}\n\n.clr-alpha div:before {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border-radius: 50%;\n background-color: currentColor;\n}\n\n.clr-format {\n display: none;\n order: 1;\n width: calc(100% - 40px);\n margin: 0 20px 20px;\n}\n\n.clr-segmented {\n display: flex;\n position: relative;\n width: 100%;\n margin: 0;\n padding: 0;\n border: 1px solid #ddd;\n border-radius: 15px;\n box-sizing: border-box;\n color: #999;\n font-size: 12px;\n}\n\n.clr-segmented input,\n.clr-segmented legend {\n position: absolute;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n left: 0;\n top: 0;\n opacity: 0;\n pointer-events: none;\n}\n\n.clr-segmented label {\n flex-grow: 1;\n margin: 0;\n padding: 4px 0;\n font-size: inherit;\n font-weight: normal;\n line-height: initial;\n text-align: center;\n cursor: pointer;\n}\n\n.clr-segmented label:first-of-type {\n border-radius: 10px 0 0 10px;\n}\n\n.clr-segmented label:last-of-type {\n border-radius: 0 10px 10px 0;\n}\n\n.clr-segmented input:checked + label {\n color: #fff;\n background-color: #666;\n}\n\n.clr-swatches {\n order: 2;\n width: calc(100% - 32px);\n margin: 0 16px;\n}\n\n.clr-swatches div {\n display: flex;\n flex-wrap: wrap;\n padding-bottom: 12px;\n justify-content: center;\n}\n\n.clr-swatches button {\n position: relative;\n width: 20px;\n height: 20px;\n margin: 0 4px 6px 4px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n cursor: pointer;\n}\n\n.clr-swatches button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\ninput.clr-color {\n order: 1;\n width: calc(100% - 80px);\n height: 32px;\n margin: 15px 20px 20px auto;\n padding: 0 10px;\n border: 1px solid #ddd;\n border-radius: 16px;\n color: #444;\n background-color: #fff;\n font-family: sans-serif;\n font-size: 14px;\n text-align: center;\n box-shadow: none;\n}\n\ninput.clr-color:focus {\n outline: none;\n border: 1px solid #1e90ff;\n}\n\n.clr-close,\n.clr-clear {\n display: none;\n order: 2;\n height: 24px;\n margin: 0 20px 20px;\n padding: 0 20px;\n border: 0;\n border-radius: 12px;\n color: #fff;\n background-color: #666;\n font-family: inherit;\n font-size: 12px;\n font-weight: 400;\n cursor: pointer;\n}\n\n.clr-close {\n display: block;\n margin: 0 20px 20px auto;\n}\n\n.clr-preview {\n position: relative;\n width: 32px;\n height: 32px;\n margin: 15px 0 20px 20px;\n border-radius: 50%;\n overflow: hidden;\n}\n\n.clr-preview:before,\n.clr-preview:after {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border: 1px solid #fff;\n border-radius: 50%;\n}\n\n.clr-preview:after {\n border: 0;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\n.clr-preview button {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 1;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 50%;\n outline-offset: -2px;\n background-color: transparent;\n text-indent: -9999px;\n cursor: pointer;\n overflow: hidden;\n}\n\n.clr-marker,\n.clr-hue div,\n.clr-alpha div,\n.clr-color {\n box-sizing: border-box;\n}\n\n.clr-field {\n display: inline-block;\n position: relative;\n color: transparent;\n}\n\n.clr-field input {\n margin: 0;\n direction: ltr;\n}\n\n.clr-field.clr-rtl input {\n text-align: right;\n}\n\n.clr-field button {\n position: absolute;\n width: 30px;\n height: 100%;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n margin: 0;\n padding: 0;\n border: 0;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n pointer-events: none;\n}\n\n.clr-field.clr-rtl button {\n right: auto;\n left: 0;\n}\n\n.clr-field button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 1px rgba(0,0,0,.5);\n}\n\n.clr-alpha,\n.clr-alpha div,\n.clr-swatches button,\n.clr-preview:before,\n.clr-field button {\n background-image: repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa), repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position: 0 0, 4px 4px;\n background-size: 8px 8px;\n}\n\n.clr-marker:focus {\n outline: none;\n}\n\n.clr-keyboard-nav .clr-marker:focus,\n.clr-keyboard-nav .clr-hue input:focus + div,\n.clr-keyboard-nav .clr-alpha input:focus + div,\n.clr-keyboard-nav .clr-segmented input:focus + label {\n outline: none;\n box-shadow: 0 0 0 2px #1e90ff, 0 0 2px 2px #fff;\n}\n\n.clr-picker[data-alpha="false"] .clr-alpha {\n display: none;\n}\n\n.clr-picker[data-minimal="true"] {\n padding-top: 16px;\n}\n\n.clr-picker[data-minimal="true"] .clr-gradient,\n.clr-picker[data-minimal="true"] .clr-hue,\n.clr-picker[data-minimal="true"] .clr-alpha,\n.clr-picker[data-minimal="true"] .clr-color,\n.clr-picker[data-minimal="true"] .clr-preview {\n display: none;\n}\n\n/** Dark theme **/\n\n.clr-dark {\n background-color: #444;\n}\n\n.clr-dark .clr-segmented {\n border-color: #777;\n}\n\n.clr-dark .clr-swatches button:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);\n}\n\n.clr-dark input.clr-color {\n color: #fff;\n border-color: #777;\n background-color: #555;\n}\n\n.clr-dark input.clr-color:focus {\n border-color: #1e90ff;\n}\n\n.clr-dark .clr-preview:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);\n}\n\n.clr-dark .clr-alpha,\n.clr-dark .clr-alpha div,\n.clr-dark .clr-swatches button,\n.clr-dark .clr-preview:before {\n background-image: repeating-linear-gradient(45deg, #666 25%, transparent 25%, transparent 75%, #888 75%, #888), repeating-linear-gradient(45deg, #888 25%, #444 25%, #444 75%, #888 75%, #888);\n}\n\n/** Polaroid theme **/\n\n.clr-picker.clr-polaroid {\n border-radius: 6px;\n box-shadow: 0 0 5px rgba(0,0,0,.1), 0 5px 30px rgba(0,0,0,.2);\n}\n\n.clr-picker.clr-polaroid:before {\n content: \'\';\n display: block;\n position: absolute;\n width: 16px;\n height: 10px;\n left: 20px;\n top: -10px;\n border: solid transparent;\n border-width: 0 8px 10px 8px;\n border-bottom-color: currentColor;\n box-sizing: border-box;\n color: #fff;\n filter: drop-shadow(0 -4px 3px rgba(0,0,0,.1));\n pointer-events: none;\n}\n\n.clr-picker.clr-polaroid.clr-dark:before {\n color: #444;\n}\n\n.clr-picker.clr-polaroid.clr-left:before {\n left: auto;\n right: 20px;\n}\n\n.clr-picker.clr-polaroid.clr-top:before {\n top: auto;\n bottom: -10px;\n transform: rotateZ(180deg);\n}\n\n.clr-polaroid .clr-gradient {\n width: calc(100% - 20px);\n height: 120px;\n margin: 10px;\n border-radius: 3px;\n}\n\n.clr-polaroid .clr-hue,\n.clr-polaroid .clr-alpha {\n width: calc(100% - 30px);\n height: 10px;\n margin: 6px 15px;\n border-radius: 5px;\n}\n\n.clr-polaroid .clr-hue div,\n.clr-polaroid .clr-alpha div {\n box-shadow: 0 0 5px rgba(0,0,0,.2);\n}\n\n.clr-polaroid .clr-format {\n width: calc(100% - 20px);\n margin: 0 10px 15px;\n}\n\n.clr-polaroid .clr-swatches {\n width: calc(100% - 12px);\n margin: 0 6px;\n}\n.clr-polaroid .clr-swatches div {\n padding-bottom: 10px;\n}\n\n.clr-polaroid .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n.clr-polaroid input.clr-color {\n width: calc(100% - 60px);\n margin: 10px 10px 15px auto;\n}\n\n.clr-polaroid .clr-clear {\n margin: 0 10px 15px 10px;\n}\n\n.clr-polaroid .clr-close {\n margin: 0 10px 15px auto;\n}\n\n.clr-polaroid .clr-preview {\n margin: 10px 0 15px 10px;\n}\n\n/** Large theme **/\n\n.clr-picker.clr-large {\n width: 275px;\n}\n\n.clr-large .clr-gradient {\n height: 150px;\n}\n\n.clr-large .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n/** Pill (horizontal) theme **/\n\n.clr-picker.clr-pill {\n width: 380px;\n padding-left: 180px;\n box-sizing: border-box;\n}\n\n.clr-pill .clr-gradient {\n position: absolute;\n width: 180px;\n height: 100%;\n left: 0;\n top: 0;\n margin-bottom: 0;\n border-radius: 3px 0 0 3px;\n}\n\n.clr-pill .clr-hue {\n margin-top: 20px;\n}',""]);const a=s},4245:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var o=n(9601),i=n.n(o),r=n(2609),s=n.n(r)()(i());s.push([t.id,':root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content>div>div{padding:5px}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content>div{min-height:0}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content img{max-width:min(50vw,75%);max-height:50vh;display:block;margin-left:auto;margin-right:auto}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content .action-button-row{margin-top:4px;display:flex;flex-direction:row;justify-content:flex-end;padding-bottom:0;margin-bottom:0}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content .action-button-row>button{flex-grow:1;text-align:end;max-width:50%;min-width:min(100%,40px)}.toolbar-overflow-widget-overflow-list{display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center}.toolbar-overflow-widget-overflow-list>.toolbar-toolContainer>.toolbar-button{height:var(--toolbar-button-height)}.toolbar-overflow-widget.horizontal .toolbar-overflow-widget-overflow-list{flex-direction:row}.toolbar-overflow-widget.horizontal>.toolbar-dropdown{max-width:100%;left:15px;right:15px;margin-left:0 !important;translate:none !important;padding:4px}.toolbar-zoomLevelEditor{display:flex;flex-direction:row;align-items:center}.toolbar-zoomLevelEditor .zoomDisplay{flex-grow:1}.toolbar-zoomLevelEditor button{min-width:48px}.selection-format-menu.disabled{opacity:.5}.toolbar-document-properties-widget button.about-button{width:100%;text-align:end}.toolbar-document-properties-widget>*{--align-items-to-x: 120px}.toolbar-document-properties-widget .js-draw-size-input-row.js-draw-size-input-row{display:flex}.toolbar-document-properties-widget .js-draw-size-input-row.js-draw-size-input-row.size-input-row--automatic-size{display:none}.toolbar-thicknessSliderContainer{display:flex;flex-direction:row}.toolbar-thicknessSliderContainer input{flex-grow:1}.toolbar-element .clr-field *{cursor:pointer}.toolbar-element .clr-field button{width:1.2em;height:1.2em;top:50%;left:0;border-radius:50%;margin-left:0;margin-right:0}.toolbar-element .clr-field input{opacity:0}.color-input-container{display:inline-flex;flex-direction:row}.color-input-container.picker-open .clr-field{pointer-events:none}:root .color-input-container>button.pipetteButton{width:30px;height:30px;padding:0;display:inline-flex}.color-input-container .pipetteButton>svg{width:100%}.color-input-container .pipetteButton .pickColorInstructions{display:none;font-size:1em;position:absolute;margin-left:30px;background-color:var(--background-color-1);border-radius:30px;padding:4px;opacity:0;transition:.2s ease opacity}@media(prefers-reduced-motion: reduce){.color-input-container .pipetteButton .pickColorInstructions{transition:none}}.color-input-container .pipetteButton.active{background-color:var(--selection-background-color);--icon-color: var(--selection-foreground-color)}.color-input-container .pipetteButton.active .pickColorInstructions{display:block;opacity:.8}.tool-dropdown-separator{--border-color: rgba(100, 100, 100, 0.2);--border-color: color-mix(in srgb, var(--foreground-color-1), rgba(0, 0, 0, 0) 80%);border-top:1px solid var(--border-color);padding-left:2px;margin-top:10px;margin-bottom:10px}.toolbar-element .toolbar--file-input-container{display:flex}.toolbar-element .toolbar--file-input-container>input[type=file]{opacity:0;width:0;min-width:0 !important;max-width:0;height:0}.toolbar-element .toolbar--file-input-container>label{display:block;flex-grow:1;padding:0 !important;padding-bottom:5px;--active-border-color: rgba(100, 100, 100, 0.5);--active-border-color: color-mix( in srgb, var(--foreground-color-1), transparent )}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description{background-color:var(--background-color-3);color:var(--foreground-color-3);border:1px dashed var(--active-border-color);padding:10px;margin-top:10px;display:flex;flex-direction:column;align-items:center;text-align:center;--action-color: var(--primary-action-foreground-color);--icon-color: var(--action-color)}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description>span{white-space:pre-wrap}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description>span>b{color:var(--action-color);cursor:pointer}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description>.icon{width:min(50vw,42px);height:min(50vw,42px);margin-bottom:8px;display:block}.toolbar-element .toolbar--file-input-container>label:active,.toolbar-element .toolbar--file-input-container>label:hover,.toolbar-element .toolbar--file-input-container>label.drag-target{--active-border-color: var(--foreground-color-1)}.toolbar-element .toolbar--file-input-container>label.drag-target>.toolbar--file-input-description{border-width:2px}.toolbar-grid-selector{position:relative}.toolbar-grid-selector>div{display:flex;flex-direction:row;max-width:350px;flex-wrap:wrap;--button-size: 48px}.toolbar-grid-selector .choice-button{display:flex;flex-direction:column-reverse;box-sizing:border-box;flex-shrink:1;margin:2px}.toolbar-grid-selector .choice-button.focus-visible{outline:2px solid var(--foreground-color-1)}.toolbar-grid-selector .choice-button input{opacity:0;height:0}.toolbar-grid-selector .choice-button label{display:flex;flex-direction:column;box-sizing:border-box;width:var(--button-size);height:var(--button-size);font-size:.7rem;align-items:center;justify-content:center;padding:4px;user-select:none;-webkit-user-select:none}.toolbar-grid-selector .choice-button .icon{flex-grow:1;flex-shrink:1;width:100%}.toolbar-grid-selector .choice-button.checked{background-color:var(--selection-background-color);color:var(--selection-foreground-color);--icon-color: var(--selection-foreground-color)}.toolbar-root{background-color:var(--background-color-1);--icon-color: var(--foreground-color-1);--toolbar-button-height: min(20vh, 60px);flex-wrap:wrap;box-sizing:border-box;width:100%;display:flex;flex-direction:row;justify-content:center}.toolbar-element{z-index:1;font-family:system-ui,-apple-system,sans-serif}.toolbar-element details>summary{cursor:pointer}.toolbar-element>.toolbar-toolContainer>.toolbar-button,.toolbar-element>.toolbar-toolContainer>*>button,.toolbar-element>.toolbar-buttonGroup>button,.toolbar-element>.toolbar-button{white-space:pre;height:var(--toolbar-button-height)}.toolbar-dropdown .toolbar-button>.toolbar-icon{max-width:50px;width:100%}.toolbar-button.disabled{filter:opacity(0.5) sepia(0.2);cursor:unset}.toolbar-button,.toolbar-element button{cursor:pointer;text-align:center;border-radius:6px;border:none;box-shadow:0px 0px 2px var(--shadow-color);user-select:none;-webkit-user-select:none;transition:background-color .15s ease,box-shadow .25s ease,opacity .2s ease}.toolbar-button,.toolbar-buttonGroup>button,.toolbar-toolContainer>*>button,.toolbar-root>button{display:flex;flex-direction:column;align-items:center;justify-content:center;padding-left:3px;padding-right:3px;min-width:40px;max-width:105px;width:min-content;font-size:1em}.toolbar-button>label{cursor:inherit;user-select:none;-webkit-user-select:none}.toolbar-root>.toolbar-toolContainer>.toolbar-button>label.long-label{font-size:.75em}.toolbar-dropdown>.toolbar-toolContainer>button,.toolbar-dropdown>.toolbar-toolContainer>.toolbar-button{width:6em}.toolbar-button:not(.disabled):hover,.toolbar-root button:not(:disabled):hover{box-shadow:0px 2px 4px var(--shadow-color)}.toolbar-root button:disabled{cursor:inherit;filter:opacity(0.5)}.toolbar-root .toolbar-icon{flex-shrink:1;user-select:none;width:100%;min-width:20px;min-height:20px}.toolbar-toolContainer.selected>.toolbar-button{background-color:var(--selection-background-color);color:var(--selection-foreground-color);--icon-color: var(--selection-foreground-color)}.toolbar-toolContainer:not(.selected):not(.dropdownShowable)>.toolbar-button>.toolbar-showHideDropdownIcon{display:none}.toolbar-toolContainer>.toolbar-button>.toolbar-showHideDropdownIcon{height:15px;transition:transform .25s ease}.toolbar-toolContainer.dropdownVisible>.toolbar-button>.toolbar-showHideDropdownIcon{transform:rotate(180deg)}.toolbar-dropdown.hidden,.toolbar-toolContainer:not(.selected):not(.dropdownShowable)>.toolbar-dropdown:not(.hiding){display:none}.toolbar-dropdown{position:absolute;padding:15px;padding-top:5px;display:flex;flex-wrap:wrap;flex-direction:column;max-height:80vh;max-width:fit-content;z-index:2;background-color:var(--background-color-1);box-shadow:0px 3px 3px var(--shadow-color)}@keyframes dropdown-transition-in{0%{opacity:0;transform:scale(1, 0)}100%{opacity:1;transform:scale(1, 1)}}@keyframes dropdown-transition-out{0%{opacity:1;transform:scale(1, 1)}100%{opacity:0;transform:scale(1, 0)}}.toolbar-dropdown{transform-origin:top left;--dropdown-show-animation: dropdown-transition-in;--dropdown-hide-animation: dropdown-transition-out}@media(prefers-reduced-motion: reduce){.toolbar-dropdown{--dropdown-show-animation: none;--dropdown-hide-animation: none}.toolbar-dropdown.hiding{display:none}.toolbar-toolContainer>.toolbar-button>.toolbar-showHideDropdownIcon{transition:none}:root .toolbar-button,.toolbar-root button{transition:none}}.toolbar-buttonGroup{display:flex;flex-direction:row;justify-content:center}.toolbar-closeColorPickerOverlay{display:none;position:fixed;top:0;left:0;bottom:0;right:0;touch-action:none;background-color:var(--background-color-1);opacity:.3;z-index:2}.toolbar-spacedList>*{padding-bottom:5px;padding-top:5px}.toolbar-indentedList{padding-left:10px}@media print{.toolbar-element{display:none}}@keyframes toolbar--edgemenu-transition-in{from{transform:translate(0, 100%)}to{transform:translate(0, 0)}}@keyframes toolbar--edgemenu-transition-out{to{transform:translate(0, 100%)}}@keyframes toolbar--edgemenu-container-transition-in{from{overflow-y:hidden}to{overflow-y:hidden}}@keyframes toolbar--edgemenu-container-transition-out{from{overflow-y:hidden}to{overflow-y:hidden}}.toolbar-edge-toolbar{--toolbar-button-height: min(20vh, 48px);--toolbar-button-size: var(--toolbar-button-height);--label-hover-offset-size: calc(14px + var(--toolbar-button-height));box-sizing:border-box;flex-direction:row;justify-content:space-around;--button-label-hover-offset-y: var(--label-hover-offset-size);--button-label-hover-offset-x: 0}@media screen and (min-width: 610px){.toolbar-edge-toolbar{flex-wrap:nowrap}.toolbar-edge-toolbar>.toolbar-action-row{max-width:50vw}}@media screen and (max-width: 700px){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline{font-size:.9em}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline .toolbar-button label{opacity:0;animation:.2s linear hide-initially}@keyframes hide-initially{from{opacity:0}to{opacity:0}}@keyframes rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}}@media screen and (max-width: 700px)and (hover: hover){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline .toolbar-button:hover>label{opacity:.8;animation:1s ease show-label}}@media screen and (max-width: 700px){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline .toolbar-button:active>label{opacity:.8;animation:.5s ease show-label}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline .toolbar-button:focus-visible>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline .toolbar-button:has(:focus-visible)>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline .toolbar-button>label{opacity:0;position:absolute;margin-top:var(--button-label-hover-offset-y);margin-left:var(--button-label-hover-offset-x);pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.2s ease opacity,.2s ease margin-top}}@media screen and (max-width: 700px)and (prefers-reduced-motion: reduce){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline .toolbar-button>label{transition:none}}.toolbar-edge-toolbar>div.toolbar-element{flex-direction:row;display:flex;flex-grow:1;justify-content:center;background-color:var(--background-color-2);color:var(--foreground-color-2);--icon-color: var(--foreground-color-2);--extra-left-right-padding: 0px}.toolbar-edge-toolbar>div.toolbar-element::-webkit-scrollbar{width:3px;height:3px}.toolbar-edge-toolbar>div.toolbar-element::-webkit-scrollbar-thumb{background-color:var(--shadow-color)}.toolbar-edge-toolbar>div.toolbar-element.toolbar-tool-row{overflow-x:auto;overflow-y:hidden;flex-grow:100}.toolbar-edge-toolbar>div.toolbar-element.toolbar-action-row{z-index:2;background-color:var(--background-color-3);color:var(--foreground-color-3);--icon-color: var(--foreground-color-3)}.toolbar-edge-toolbar>div.toolbar-element.has-scroll{justify-content:start;position:relative;--button-label-hover-offset-y: 0;--button-label-hover-offset-x: calc(0px - var(--label-hover-offset-size))}.toolbar-edge-toolbar>div.toolbar-element.has-scroll>:nth-child(1){--button-label-hover-offset-x: var(--label-hover-offset-size)}.toolbar-edge-toolbar .toolbar-toolContainer.selected>.toolbar-button{background-color:var(--selection-background-color);color:var(--selection-foreground-color);--icon-color: var(--selection-foreground-color)}.toolbar-edge-toolbar .toolbar-button{box-sizing:border-box;background-color:rgba(0,0,0,0)}.toolbar-edge-toolbar .toolbar-button .toolbar-showHideDropdownIcon{flex-shrink:.01;height:12px}.toolbar-edge-toolbar .toolbar-toolContainer{order:1}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline{flex-grow:1;display:flex;--button-flex-direction: row}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline.label-left{justify-content:end;--button-flex-direction: row-reverse;order:100}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline.label-left>.toolbar-button>.toolbar-icon{margin-left:10px;margin-right:0}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline.label-right{order:-1}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline>.toolbar-button{width:auto;flex-direction:var(--button-flex-direction)}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline>.toolbar-button>.toolbar-icon{height:100%;margin-right:10px;margin-left:0}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button{width:calc(var(--toolbar-button-size) + var(--extra-left-right-padding));height:var(--toolbar-button-size)}@keyframes rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}@media(hover: hover){.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:hover>label{opacity:.8;animation:1s ease show-label}}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:active>label{opacity:.8;animation:.5s ease show-label}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:focus-visible>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:has(:focus-visible)>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button>label{opacity:0;position:absolute;margin-top:var(--button-label-hover-offset-y);margin-left:var(--button-label-hover-offset-x);pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.2s ease opacity,.2s ease margin-top}@media(prefers-reduced-motion: reduce){.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button>label{transition:none}}.toolbar-edge-toolbar>div>.toolbar-toolContainer:not(.selected):not(.dropdownShowable)>.toolbar-button>.toolbar-showHideDropdownIcon{display:block;visibility:hidden}.toolbar-edge-toolbar .toolbar-toolContainer>.toolbar-button{margin:0;border-radius:0;padding:8px;box-shadow:none}.toolbar-edge-toolbar .toolbar-toolContainer>.toolbar-button.has-dropdown{padding-left:8px;padding-right:8px;padding-top:8px;padding-bottom:0px}.imageEditorContainer.pipette--color-selection-in-progress .toolbar-edgemenu-container{height:0;background-color:rgba(0,0,0,0);opacity:.9}.imageEditorContainer.pipette--color-selection-in-progress .toolbar-edgemenu-container .toolbar-edgemenu{position:absolute}.toolbar-edgemenu-container{background-color:var(--background-color-transparent);transition:.15s ease-in-out height,.15s ease-in-out background-color,.2s ease-in-out opacity;position:absolute;width:var(--editor-current-width-px);height:var(--editor-current-height-px);box-sizing:border-box;display:flex;flex-direction:column-reverse;align-items:center;z-index:2}@media(prefers-reduced-motion: reduce){.toolbar-edgemenu-container{transition:none}}.toolbar-edgemenu-container.dropdown-below-edge{overflow-y:hidden}.toolbar-edgemenu-container button{font-size:1.2em;box-shadow:none;border:none;padding:10px;color:var(--foreground-color-1);transition:.2s ease box-shadow;font-weight:bold;color:var(--primary-action-foreground-color)}.toolbar-edgemenu-container button:hover{box-shadow:0 1px 2px var(--shadow-color)}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button{--button-label-hover-offset-y: var(--button-size)}@keyframes rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}@media(hover: hover){.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:hover>label>.button-label-text{opacity:.8;animation:1s ease show-label}}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:active>label>.button-label-text{opacity:.8;animation:.5s ease show-label}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:focus-visible>label>.button-label-text{animation:1.5s ease rehide-label;opacity:0}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:has(:focus-visible)>label>.button-label-text{animation:1.5s ease rehide-label;opacity:0}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button>label>.button-label-text{opacity:0;position:absolute;margin-top:var(--button-label-hover-offset-y);margin-left:var(--button-label-hover-offset-x);pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.2s ease opacity,.2s ease margin-top}@media(prefers-reduced-motion: reduce){.toolbar-edgemenu-container .toolbar-grid-selector .choice-button>label>.button-label-text{transition:none}}.toolbar-edgemenu-container .toolbar-edgemenu{--toolbar-button-height: 48px;touch-action:none;user-select:none;background-color:var(--background-color-2);color:var(--foreground-color-2);--icon-color: var(--foreground-color-2);box-shadow:0px 0px 1px var(--shadow-color);padding-left:10px;padding-right:10px;width:min(400px,100vw);box-sizing:border-box;border-top-left-radius:30px;border-top-right-radius:30px;transition:transform .1s ease,padding-bottom .1s ease}.toolbar-edgemenu-container .toolbar-edgemenu input,.toolbar-edgemenu-container .toolbar-edgemenu textarea{user-select:auto}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer{display:inline-block}.toolbar-edgemenu-container .toolbar-edgemenu button{background-color:rgba(0,0,0,0)}.toolbar-edgemenu-container .toolbar-edgemenu>button.drag-elem{height:40px;display:block;cursor:ns-resize;position:relative;margin-top:-15px;margin-bottom:10px;width:100%;border:none;box-shadow:none;background:rgba(0,0,0,0)}.toolbar-edgemenu-container .toolbar-edgemenu>button.drag-elem::before{content:"";background-color:var(--icon-color);opacity:.2;display:block;position:relative;top:10px;height:5px;border-radius:5px;width:min(80%,40px);margin-left:auto;margin-right:auto}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer{display:block}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button{flex-direction:row;max-width:unset;width:100%;box-sizing:border-box;justify-content:flex-start;box-shadow:none;padding:2px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button>.toolbar-icon{width:25px;height:25px;padding:13px;margin-right:15px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button label,.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button>label.long-label{font-size:1em}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-nonbutton-controls-main-list{padding-left:10px;padding-right:10px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList{box-sizing:border-box;--align-items-to-x: 105px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div{display:flex;align-items:center;margin-top:5px;min-height:35px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div>label{padding-right:35px;min-width:var(--align-items-to-x);flex-shrink:1;box-sizing:border-box}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div>input[type=checkbox]{width:20px;height:20px;margin-left:0}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div>input:not([type=checkbox]){flex-grow:1;min-width:48px;flex-shrink:1}.toolbar-dropdown-toolbar button,.toolbar-dropdown-toolbar .toolbar-button{background-color:var(--background-color-2);color:var(--foreground-color-2);--icon-color: var(--foreground-color-2)}.toolbar-dropdown-toolbar,.toolbar-dropdown-toolbar .toolbar-dropdown{background-color:var(--background-color-3);color:var(--foreground-color-3)}.toolbar-dropdown-toolbar .toolbar-spacedList>div>label{padding-right:10px;min-width:50px}.toolbar-dropdown-toolbar .clr-field button{width:100%;height:100%;top:50%;left:0;border-radius:5px}.toolbar-dropdown-toolbar .toolbar-grid-selector>div{--button-size: 57px}.toolbar-dropdown-toolbar .toolbar-dropdown>div>.toolbar-toolContainer{display:inline-block}.ScrollbarTool-overlay{width:0;height:0;overflow:visible;opacity:.2;pointer-events:none;--fade-out-animation: 1s ease 0s fade-out;--scrollbar-size: 3px}@media(prefers-reduced-motion: reduce){.ScrollbarTool-overlay{--fade-out-animation: none !important}}@keyframes fade-out{from{opacity:.2}to{opacity:0}}.ScrollbarTool-overlay:not(.just-updated){animation:var(--fade-out-animation);opacity:0}.ScrollbarTool-overlay .vertical-scrollbar,.ScrollbarTool-overlay .horizontal-scrollbar{width:var(--scrollbar-size);height:var(--scrollbar-size);min-width:var(--scrollbar-size);min-height:var(--scrollbar-size);background-color:var(--foreground-color-1);border-radius:var(--scrollbar-size);position:absolute}.ScrollbarTool-overlay .vertical-scrollbar.represents-no-scroll,.ScrollbarTool-overlay .horizontal-scrollbar.represents-no-scroll{animation:var(--fade-out-animation);opacity:0}.ScrollbarTool-overlay:not(.scrollbar-left) .vertical-scrollbar{margin-left:calc(var(--editor-current-display-width-px) - var(--scrollbar-size))}.ScrollbarTool-overlay:not(.scrollbar-top) .horizontal-scrollbar{margin-top:calc(var(--editor-current-display-height-px) - var(--scrollbar-size))}.selection-tool-selection-background{background-color:var(--selection-background-color);opacity:.5;overflow:visible;position:absolute}.selection-tool-handle{border:1px solid var(--foreground-color-1);background:var(--background-color-1);position:absolute;cursor:grab}.selection-tool-handle.selection-tool-circle{border-radius:100%}.overlay.handleOverlay{height:0;overflow:visible}@keyframes selection-duplicated-animation{0%{transform:scale(1, 1)}50%{transform:scale(1.02, 1.02)}100%{transform:scale(1, 1)}}@media(prefers-reduced-motion: reduce){@keyframes selection-duplicated-animation{}}.find-tool-overlay{order:-1;position:absolute}.js-draw-sound-ui-toggle{width:0px;height:0px;overflow:hidden}.js-draw-sound-ui-toggle button{margin-top:1px}.js-draw-sound-ui-toggle:focus-within,.js-draw-sound-ui-toggle.sound-ui-tool-enabled{overflow:visible;z-index:5}.js-draw-sound-ui-toggle:not(:focus-within):not(:hover).sound-ui-tool-enabled{opacity:.5}.about-dialog-container dialog{display:flex;flex-direction:column}.about-dialog-container dialog .close-button{display:block;margin-left:auto;margin-right:auto}.about-dialog-container dialog .about-entry-container{flex-grow:1;flex-shrink:1;overflow-y:auto;margin-left:20px;margin-right:20px;padding-bottom:20px;white-space:pre-wrap;font-family:monospace}.about-dialog-container dialog .about-entry-container>h2,.about-dialog-container dialog .about-entry-container>details>summary{cursor:pointer;margin-top:15px;font-size:1.2em;font-weight:bold}.about-dialog-container dialog .about-entry-container>h2 a,.about-dialog-container dialog .about-entry-container>details>summary a{color:var(--foreground-color-1);text-decoration:underline}.dialog-container.dialog-container{background-color:var(--background-color-transparent);backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px);position:absolute;z-index:3;width:var(--editor-current-width-px);height:var(--editor-current-height-px);display:flex;flex-direction:column-reverse;align-items:center;justify-content:center}.dialog-container.dialog-container dialog{background-color:var(--background-color-1);color:var(--foreground-color-1);border:none;outline:none;box-shadow:0 0 2px var(--shadow-color);border-radius:8px;max-height:90vh;width:min(100%,500px);box-sizing:border-box}#clr-picker{--clr-slider-size: 30px}#clr-picker #clr-color-area,#clr-picker .clr_hue{touch-action:none}#clr-picker .clr-alpha{margin-top:15px;margin-bottom:15px}#clr-picker.clr-picker input[type=range]::-moz-range-thumb{width:var(--clr-slider-size);height:var(--clr-slider-size)}#clr-picker.clr-picker input[type=range]::-webkit-slider-thumb{width:var(--clr-slider-size);height:var(--clr-slider-size)}#clr-picker.clr-picker input[type=range]::-webkit-slider-runnable-track{height:var(--clr-slider-size)}#clr-picker.clr-picker input[type=range]::-moz-range-track{height:var(--clr-slider-size)}.imageEditorContainer{--background-color-1: white;--foreground-color-1: black;--background-color-2: #f5f5f5;--foreground-color-2: #2c303a;--background-color-3: #e5e5e5;--foreground-color-3: #1c202a;--selection-background-color: #cbdaf1;--selection-foreground-color: #2c303a;--background-color-transparent: rgba(105, 100, 100, 0.5);--shadow-color: rgba(0, 0, 0, 0.5);--primary-action-foreground-color: #15b}@media(prefers-color-scheme: dark){.imageEditorContainer{--background-color-1: #151515;--foreground-color-1: white;--background-color-2: #222;--foreground-color-2: #efefef;--background-color-3: #272627;--foreground-color-3: #eee;--selection-background-color: #607;--selection-foreground-color: white;--shadow-color: rgba(250, 250, 250, 0.5);--background-color-transparent: rgba(50, 50, 50, 0.5);--primary-action-foreground-color: #7ae}}.imageEditorContainer{color:var(--foreground-color-1);font-family:system-ui,-apple-system,sans-serif;background-color:var(--background-color-1);width:100%;height:400px;min-height:220px;min-width:100px;box-sizing:border-box;display:flex;flex-direction:column-reverse}.imageEditorContainer input{accent-color:var(--primary-action-foreground-color)}.imageEditorContainer .imageEditorRenderArea{display:grid;grid-template-columns:1fr;flex-grow:2;flex-shrink:1;min-height:100px;min-width:0;width:100%;height:100%}.imageEditorContainer .imageEditorRenderArea canvas{grid-row:1/1;grid-column:1/1;touch-action:none;box-sizing:border-box;width:100%;height:100%;min-width:0;max-width:inherit;min-height:0px;max-height:inherit}.imageEditorContainer .loadingMessage{position:fixed;text-align:center;font-size:2em;bottom:0;left:0;right:0}.imageEditorContainer .accessibilityAnnouncement{opacity:0;width:0;height:0;overflow:hidden;pointer-events:none}.imageEditorContainer .textRendererOutputContainer{width:1px;height:1px;overflow:hidden}.imageEditorContainer .textRendererOutputContainer:focus-within{overflow:visible;z-index:5}@media print{.imageEditorContainer .loadingMessage{display:none}.imageEditorContainer .imageEditorRenderArea canvas{width:100%;height:initial}}',""]);const a=s},2609:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var d=[].concat(t[c]);o&&s[d[0]]||(void 0!==r&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),e.push(d))}},e}},9601:t=>{"use strict";t.exports=function(t){return t[1]}},6062:t=>{"use strict";var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=o.base?l[0]+o.base:l[0],d=r[c]||0,h="".concat(c," ").concat(d);r[c]=d+1;var u=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==u)e[u].references++,e[u].updater(p);else{var f=i(p,o);o.byIndex=a,e.splice(a,0,{identifier:h,updater:f,references:1})}s.push(h)}return s}function i(t,e){var n=e.domAPI(e);n.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,i){var r=o(t=t||[],i=i||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=o(t,i),c=0;c<r.length;c++){var d=n(r[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}r=l}}},6793:t=>{"use strict";var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},1173:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},7892:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},4036:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,i&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},2464:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},5146:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Editor=void 0;const a=s(n(7551)),l=s(n(8169)),c=n(3173),d=n(7520),h=s(n(5155)),u=s(n(5566)),p=s(n(1785)),f=n(5097),m=r(n(3012)),g=s(n(2001)),b=r(n(1697)),y=s(n(4318)),v=s(n(1906)),w=s(n(8282)),x=s(n(7717)),S=s(n(7395)),T=s(n(9070)),C=s(n(1456)),P=s(n(7591)),k=s(n(9721)),E=r(n(1847)),z=s(n(1380)),M=s(n(5376)),_=s(n(5221)),I=s(n(9542)),B=s(n(1993)),L=s(n(9784)),R=s(n(2674));class O{constructor(t,e={}){if(this.eventListenerTargets=[],this.previousAccessibilityAnnouncement="",this.pointers={},this.announceUndoCallback=t=>{this.announceForAccessibility(this.localization.undoAnnouncement(t.description(this,this.localization)))},this.announceRedoCallback=t=>{this.announceForAccessibility(this.localization.redoAnnouncement(t.description(this,this.localization)))},this.nextRerenderListeners=[],this.rerenderQueued=!1,this.closeAboutDialog=null,this.localization={...(0,v.default)(),...e.localization},this.settings={wheelEventsEnabled:e.wheelEventsEnabled??!0,renderingMode:e.renderingMode??m.RenderingMode.CanvasRenderer,localization:this.localization,minZoom:e.minZoom??2e-10,maxZoom:e.maxZoom??1e12,keyboardShortcutOverrides:e.keyboardShortcutOverrides??{},iconProvider:e.iconProvider??new w.default,notices:[]},this.settings.minZoom>this.settings.maxZoom)throw new Error("Minimum zoom must be lesser than maximum zoom!");this.icons=this.settings.iconProvider,this.shortcuts=new M.default(this.settings.keyboardShortcutOverrides),this.container=document.createElement("div"),this.renderingRegion=document.createElement("div"),this.container.appendChild(this.renderingRegion),this.container.classList.add("imageEditorContainer","js-draw"),this.loadingWarning=document.createElement("div"),this.loadingWarning.classList.add("loadingMessage"),this.loadingWarning.ariaLive="polite",this.container.appendChild(this.loadingWarning),this.accessibilityControlArea=document.createElement("textarea"),this.accessibilityControlArea.setAttribute("placeholder",this.localization.accessibilityInputInstructions),this.accessibilityControlArea.style.opacity="0",this.accessibilityControlArea.style.width="0",this.accessibilityControlArea.style.height="0",this.accessibilityControlArea.style.position="absolute",this.accessibilityAnnounceArea=document.createElement("div"),this.accessibilityAnnounceArea.setAttribute("aria-live","assertive"),this.accessibilityAnnounceArea.className="accessibilityAnnouncement",this.container.appendChild(this.accessibilityAnnounceArea),this.renderingRegion.style.touchAction="none",this.renderingRegion.className="imageEditorRenderArea",this.renderingRegion.appendChild(this.accessibilityControlArea),this.renderingRegion.setAttribute("tabIndex","0"),this.renderingRegion.setAttribute("alt",""),this.notifier=new p.default,this.viewport=new u.default(((t,e)=>{this.notifier.dispatch(c.EditorEventType.ViewportChanged,{kind:c.EditorEventType.ViewportChanged,newTransform:e,oldTransform:t})})),this.display=new m.default(this,this.settings.renderingMode,this.renderingRegion),this.image=new a.default,this.history=new h.default(this,this.announceRedoCallback,this.announceUndoCallback),this.toolController=new l.default(this,this.localization),this.toolController.addInputMapper(I.default.fromEditor(this)),t.appendChild(this.container),this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.registerListeners(),this.queueRerender(),this.hideLoadingWarning(),this.notifier.on(c.EditorEventType.ViewportChanged,(t=>{if(t.kind===c.EditorEventType.ViewportChanged){const e=t.newTransform.transformVec3(f.Vec2.unitX).length();if(e>this.settings.maxZoom||e<this.settings.minZoom){const e=t.oldTransform.transformVec3(f.Vec2.unitX).length();let n=f.Mat33.identity;n=e<=this.settings.maxZoom&&e>=this.settings.minZoom?t.oldTransform:f.Mat33.scaling2D((this.settings.minZoom+this.settings.maxZoom)/2),this.viewport.resetTransform(n)}}}))}getRootElement(){return this.container}showLoadingWarning(t){const e=Math.round(100*t);this.loadingWarning.innerText=this.localization.loading(e),this.loadingWarning.style.display="block"}hideLoadingWarning(){this.loadingWarning.style.display="none",this.announceForAccessibility(this.localization.doneLoading)}announceForAccessibility(t){t===this.previousAccessibilityAnnouncement&&(t+=". "),this.accessibilityAnnounceArea.innerText=t,this.previousAccessibilityAnnouncement=t}addToolbar(t=!0){const e=new _.default(this,this.container,this.localization);return t&&e.addDefaults(),e}registerListeners(){this.handlePointerEventsFrom(this.renderingRegion),this.handleKeyEventsFrom(this.renderingRegion),this.handlePointerEventsFrom(this.accessibilityAnnounceArea),this.container.addEventListener("wheel",(t=>{let e=f.Vec3.of(t.deltaX,t.deltaY,t.deltaZ);if(!t.ctrlKey&&!t.metaKey){if(!this.settings.wheelEventsEnabled)return;if("only-if-focused"===this.settings.wheelEventsEnabled){if(!this.container.querySelector(":focus"))return}}t.deltaMode===WheelEvent.DOM_DELTA_LINE?e=e.times(15):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e=e.times(100)),(t.ctrlKey||t.metaKey)&&(e=f.Vec3.of(0,0,t.deltaY));const n=this.renderingRegion.getBoundingClientRect(),o=f.Vec2.of(t.clientX,t.clientY).minus(f.Vec2.of(n.left,n.top));return!!this.toolController.dispatchInputEvent({kind:d.InputEvtType.WheelEvt,delta:e,screenPos:o})&&(t.preventDefault(),!0)}));const t=()=>{this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.rerender(),this.updateEditorSizeVariables()};if("ResizeObserver"in window){const e=new ResizeObserver(t);e.observe(this.renderingRegion),e.observe(this.container)}else addEventListener("resize",t);this.accessibilityControlArea.addEventListener("input",(()=>{this.accessibilityControlArea.value=""})),document.addEventListener("copy",(t=>{if(!this.isEventSink(document.querySelector(":focus")))return;const e=t.clipboardData;this.toolController.dispatchInputEvent({kind:d.InputEvtType.CopyEvent,setData:(t,n)=>{e?.setData(t,n)}})&&t.preventDefault()})),document.addEventListener("paste",(t=>{this.handlePaste(t)}))}updateEditorSizeVariables(){this.container.style.setProperty("--editor-current-width-px",`${this.container.clientWidth}px`),this.container.style.setProperty("--editor-current-height-px",`${this.container.clientHeight}px`),this.container.style.setProperty("--editor-current-display-width-px",`${this.renderingRegion.clientWidth}px`),this.container.style.setProperty("--editor-current-display-height-px",`${this.renderingRegion.clientHeight}px`)}getPointerList(){const t=performance.now(),e=[];for(const n in this.pointers){const o=2e3;this.pointers[n]&&t-this.pointers[n].timeStamp<o&&e.push(this.pointers[n])}return e}handleHTMLPointerEvent(t,e){const n=this.renderingRegion,o=e.target??this.renderingRegion;if("pointerdown"===t){const t=y.default.ofEvent(e,!0,this.viewport,n);this.pointers[t.id]=t,o.setPointerCapture(t.id);const i={kind:d.InputEvtType.PointerDownEvt,current:t,allPointers:this.getPointerList()};return this.toolController.dispatchInputEvent(i),!0}if("pointermove"===t){const t=y.default.ofEvent(e,this.pointers[e.pointerId]?.down??!1,this.viewport,n);if(t.down){const n=this.pointers[t.id];if(n){if(t.screenPos.minus(n.screenPos).magnitude()<2)return!1}this.pointers[t.id]=t,this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerMoveEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault()}return!0}if("pointercancel"===t||"pointerup"===t){const t=y.default.ofEvent(e,!1,this.viewport,n);return!!this.pointers[t.id]&&(this.pointers[t.id]=t,o.releasePointerCapture(t.id),this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerUpEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault(),delete this.pointers[t.id],!0)}return t}isEventSink(t){let e=t;for(;null!==e;){for(const t of this.eventListenerTargets)if(t===e)return!0;e=e.parentElement}return!1}async handlePaste(t){const e=document.querySelector(":focus")??t.target;if(!this.isEventSink(e))return;const n=t.dataTransfer??t.clipboardData;if(!n)return;for(const e of n.files)if("image/svg+xml"===e.type.toLowerCase()){const n=await e.text();if(this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e.type,data:n}))return void t.preventDefault()}for(const e of n.files){const n=e.type.toLowerCase();if("image/png"===n||"image/jpg"===n){this.showLoadingWarning(0);const o=t=>{this.showLoadingWarning(t.loaded/t.total)};try{const i=await(0,T.default)(e,o);if(i&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:n,data:i}))return t.preventDefault(),void this.hideLoadingWarning()}catch(t){console.error("Error reading image:",t)}this.hideLoadingWarning()}}const o=["image/svg+xml","text/plain"];for(const e of o){const o=n.getData(e);if(o&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e,data:o}))return void t.preventDefault()}}handlePointerEventsFrom(t,e,n){const o={touchstart:t=>{n&&!n("touchstart",t)||t.preventDefault()},contextmenu:t=>{n&&!n("contextmenu",t)||t.preventDefault()}},i=["pointerdown","pointermove","pointerup","pointercancel"];for(const t of i)o[t]=n=>{const o=n;if(!e||e(t,o))return this.handleHTMLPointerEvent(t,o)};for(const e in o)t.addEventListener(e,o[e]);return{remove:()=>{for(const e in o)t.removeEventListener(e,o[e])}}}handlePointerEventsExceptClicksFrom(t,e,n){const o=Object.create(null);return this.handlePointerEventsFrom(t,((n,i)=>{if(e&&!e(n,i))return!1;const r=f.Vec2.of(i.pageX,i.pageY),s=i.pointerId??0;let a=!0;if("pointerdown"===n)o[s]={eventBuffer:[[n,i]],startPoint:r},t.setPointerCapture(i.pointerId),a=!1;else if("pointermove"===n&&o[s]){const t=o[s].startPoint,e=o[s].eventBuffer,l=10;if(t&&r.minus(t).magnitude()<l)e.push([n,i]),a=!1;else{for(const[t,n]of e)this.handleHTMLPointerEvent(t,n);o[s].eventBuffer=[],a=!0}}else"pointermove"===n?a=!0:("pointerup"===n||"pointercancel"===n)&&o[s]&&o[s].eventBuffer.length>0&&(t.releasePointerCapture(i.pointerId),a=!1,delete o[s]);return a}),n)}handleKeyEventsFrom(t,e=(()=>!0)){let n=[];const o=(t,e)=>t.key===e.key&&t.code===e.code;t.addEventListener("keydown",(t=>{if(!e(t))return;const i=(0,d.keyPressEventFromHTMLEvent)(t);n.some((t=>o(t,i)))||n.push(i),"t"===i.key||"T"===i.key?(t.preventDefault(),this.display.rerenderAsText()):this.toolController.dispatchInputEvent(i)?t.preventDefault():"Escape"===i.key&&this.renderingRegion.blur()})),t.addEventListener("keyup",(t=>{if(n=n.filter((e=>!o(e,t))),!e(t))return;const i=(0,d.keyUpEventFromHTMLEvent)(t);this.toolController.dispatchInputEvent(i)&&t.preventDefault()})),t.addEventListener("blur",(()=>{for(const t of n)this.toolController.dispatchInputEvent({...t,kind:d.InputEvtType.KeyUpEvent})})),t.ondragover=t=>{t.preventDefault()},t.ondrop=t=>{t.preventDefault(),this.handlePaste(t)},this.eventListenerTargets.push(t)}dispatch(t,e=!0){const n=this.dispatchNoAnnounce(t,e);return this.announceForAccessibility(t.description(this,this.localization)),n}dispatchNoAnnounce(t,e=!1){const n=t.apply(this);if(e){const e=!1;this.history.push(t,e)}return n}async asyncApplyOrUnapplyCommands(t,e,n){console.assert(n>0),this.display.setDraftMode(!0);for(let o=0;o<t.length;o+=n){this.showLoadingWarning(o/t.length);for(let i=o;i<t.length&&i<o+n;i++){const n=t[i];e?n.apply(this):n.unapply(this)}o+n<t.length&&await new Promise((t=>{this.rerender(),requestAnimationFrame(t)}))}this.display.setDraftMode(!1),this.hideLoadingWarning()}asyncApplyCommands(t,e){return this.asyncApplyOrUnapplyCommands(t,!0,e)}asyncUnapplyCommands(t,e,n=!1){return n&&(t=[...t]).reverse(),this.asyncApplyOrUnapplyCommands(t,!1,e)}queueRerender(){return this.rerenderQueued||(this.rerenderQueued=!0,requestAnimationFrame((()=>{this.rerenderQueued&&(this.rerender(),this.rerenderQueued=!1)}))),new Promise((t=>{this.nextRerenderListeners.push((()=>t()))}))}isRerenderQueued(){return this.rerenderQueued}rerender(t=!0){if(this.display.startRerender(),0===this.display.width||0===this.display.height)return;const e=this.display.getDryInkRenderer();if(this.image.renderWithCache(e,this.display.getCache(),this.viewport),t&&!this.image.getAutoresizeEnabled()){const t={fill:f.Color4.fromHex("#44444455")},n=5*this.viewport.getSizeOfPixelOnCanvas();e.drawRect(this.getImportExportRect(),n,t)}this.rerenderQueued=!1,this.nextRerenderListeners.forEach((t=>t())),this.nextRerenderListeners=[]}drawWetInk(...t){for(const e of t)this.display.getWetInkRenderer().drawPath(e)}clearWetInk(){this.display.getWetInkRenderer().clear()}focus(){this.renderingRegion.focus()}createHTMLOverlay(t){return t.classList.add("overlay","js-draw-editor-overlay"),this.container.appendChild(t),{remove:()=>t.remove()}}addStyleSheet(t){const e=document.createElement("style");return e.innerText=t,this.container.appendChild(e),e}sendKeyboardEvent(t,e,n=!1,o=!1,i=void 0){i??=e.toUpperCase()===e&&e.toLowerCase()!==e,this.toolController.dispatchInputEvent({kind:t,key:e,code:(0,B.default)(e),ctrlKey:n,altKey:o,shiftKey:i})}sendPenEvent(t,e,n){(0,z.default)(this,t,e,n)}async addAndCenterComponents(t,e=!0){let n=null;for(const e of t)n=n?n.union(e.getBBox()):e.getBBox();if(!n)return;const o=this.viewport.visibleRect,i=o.width/n.width,r=o.height/n.height;let s=i;(n.width*s>o.width||n.height*s>o.height)&&(s=r),s*=2/3,s=u.default.roundScaleRatio(s);const l=f.Mat33.translation(o.center.minus(n.center)).rightMul(f.Mat33.scaling2D(s,n.center)),c=[];for(const e of t)c.push(a.default.addElement(e)),c.push(e.transformBy(l));if(await this.dispatch((0,C.default)(c,100),!0),e)for(const e of this.toolController.getMatchingTools(P.default))e.setEnabled(!0),e.setSelection(t)}toDataURL(t="image/png",e){const n=document.createElement("canvas"),o=this.image.getImportExportViewport(),i=o.getScreenRectSize(),r=e??i;n.width=r.x,n.height=r.y;const s=n.getContext("2d"),a=Math.min(r.x/i.x,r.y/i.y);s.scale(a,a);const l=new x.default(s,o);this.image.renderAll(l);return n.toDataURL(t)}toSVG(){const t=this.image.getImportExportViewport().getTemporaryClone(),{element:e,renderer:n}=g.default.fromViewport(t,!1),o=t.canvasToScreenTransform;t.resetTransform(f.Mat33.identity),this.image.renderAll(n),t.resetTransform(o);const i=t.visibleRect;return e.setAttribute("viewBox",[i.x,i.y,i.w,i.h].map((t=>(0,f.toRoundedString)(t))).join(" ")),e.setAttribute("width",(0,f.toRoundedString)(i.w)),e.setAttribute("height",(0,f.toRoundedString)(i.h)),this.image.getAutoresizeEnabled()?e.classList.add(b.svgLoaderAutoresizeClassName):e.classList.remove(b.svgLoaderAutoresizeClassName),e}async loadFrom(t){this.showLoadingWarning(0),this.display.setDraftMode(!0);const e=this.image.getBackgroundComponents(),n=new k.default(e);let o=!1;await t.start((async t=>{await this.dispatchNoAnnounce(a.default.addElement(t))}),((t,e)=>t%500==0?(this.showLoadingWarning(t/e),this.rerender(),(0,S.default)()):null),((t,e)=>{this.dispatchNoAnnounce(this.setImportExportRect(t),!1),this.dispatchNoAnnounce(this.viewport.zoomTo(t),!1),e&&(o=e.autoresize)})),this.dispatchNoAnnounce(this.image.setAutoresizeEnabled(o),!1),this.image.getBackgroundComponents().length!==e.length&&await this.dispatchNoAnnounce(n),this.hideLoadingWarning(),this.display.setDraftMode(!1),this.queueRerender()}getTopmostBackgroundComponent(){let t=null;for(const e of this.image.getBackgroundComponents())e instanceof E.default&&(t=e);return t}setBackgroundColor(t){let e=this.getTopmostBackgroundComponent();if(e)return e.updateStyle({color:t});{const n=t.eq(f.Color4.transparent)?E.BackgroundType.None:E.BackgroundType.SolidColor;return e=new E.default(n,t),this.image.addElement(e)}}estimateBackgroundColor(){const t=[];for(const e of this.image.getBackgroundComponents())e instanceof E.default&&t.push(e.getStyle().color??f.Color4.transparent);return f.Color4.average(t)}getImportExportRect(){return this.image.getImportExportViewport().visibleRect}setImportExportRect(t){return this.image.setImportExportRect(t)}async loadFromSVG(t,e=!1){const n=b.default.fromString(t,e);await this.loadFrom(n)}showAboutDialog(){const t=this.icons.licenseInfo(),e=[];e.push({heading:"js-draw",text:[`v${R.default.number}`,"","Image debug information (from when this dialog was opened):",` ${this.viewport.getScaleFactor()}x zoom, ${180/Math.PI*this.viewport.getRotationAngle()} rotation`,` ${this.image.estimateNumElements()} components`,` ${this.getImportExportRect().w}x${this.getImportExportRect().h} size`].join("\n")}),e.push({heading:"Libraries",text:["js-draw uses several libraries at runtime. Particularly noteworthy are:"," - The Coloris color picker: https://github.com/mdbassit/Coloris"," - The bezier.js Bézier curve library: https://github.com/Pomax/bezierjs"].join("\n"),minimized:!0}),t&&e.push({heading:"Icon Pack",text:t,minimized:!0}),e.push(...this.settings.notices),this.closeAboutDialog?.(),this.closeAboutDialog=(0,L.default)(this,e).close}remove(){this.container.remove()}}e.Editor=O,e.default=O},7551:function(t,e,n){"use strict";var o,i,r=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),s=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return s(e,t),e},l=this&&this.__setFunctionName||function(t,e,n){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RootImageNode=e.ImageNode=e.EditorImageEventType=e.sortLeavesByZIndex=void 0;const d=c(n(5566)),h=a(n(2655)),u=n(5097),p=c(n(6669)),f=c(n(1785)),m=n(6585),g=c(n(2216));var b;e.sortLeavesByZIndex=t=>{t.sort(((t,e)=>t.getContent().getZIndex()-e.getContent().getZIndex()))},function(t){t[t.ExportViewportChanged=0]="ExportViewportChanged",t[t.AutoresizeModeChanged=1]="AutoresizeModeChanged"}(b||(e.EditorImageEventType=b={}));class y{constructor(){this.componentCount=0,this.settingExportRect=!1,this.root=new w,this.background=new w,this.componentsById={},this.notifier=new f.default,this.importExportViewport=new d.default((()=>{this.onExportViewportChanged()})),this.importExportViewport.updateScreenSize(u.Vec2.of(500,500)),this.shouldAutoresizeExportViewport=!1}getBackgroundComponents(){const t=[],n=this.background.getLeaves();(0,e.sortLeavesByZIndex)(n);for(const e of n){const n=e.getContent();n&&t.push(n)}return t}findParent(t){return this.background.getChildWithContent(t)??this.root.getChildWithContent(t)}queueRerenderOf(t){const e=this.findParent(t);e&&(e.remove(),this.addElementDirectly(t))}renderWithCache(t,e,n){this.background.render(t,n.visibleRect),e.render(t,this.root,n)}render(t,e){this.background.render(t,e?.visibleRect),this.root.render(t,e?.visibleRect)}renderAll(t){this.render(t,null)}getAllElements(){const t=this.root.getLeaves();return(0,e.sortLeavesByZIndex)(t),t.map((t=>t.getContent()))}estimateNumElements(){return this.componentCount}getElementsIntersectingRegion(t,n=!1){let o=this.root.getLeavesIntersectingRegion(t);return n&&(o=o.concat(this.background.getLeavesIntersectingRegion(t))),(0,e.sortLeavesByZIndex)(o),o.map((t=>t.getContent()))}onDestroyElement(t){this.componentCount--,delete this.componentsById[t.getId()],this.autoresizeExportViewport()}onElementAdded(t){this.componentCount++,this.componentsById[t.getId()]=t,this.autoresizeExportViewport()}lookupElement(t){return this.componentsById[t]??null}addElementDirectly(t){t.onAddToImage(this);const e=(t.isBackground()?this.background:this.root).addLeaf(t);return this.onElementAdded(t),e}removeElementDirectly(t){const e=this.findParent(t);return e?.remove(),!!e&&(this.onDestroyElement(t),!0)}static addElement(t,e=!1){return new y.AddElementCommand(t,e)}addElement(t,e){return y.addElement(t,e)}getImportExportViewport(){return this.importExportViewport}getImportExportRect(){return this.getImportExportViewport().visibleRect}setImportExportRect(t){return y.SetImportExportRectCommand.of(this,t,!1)}getAutoresizeEnabled(){return this.shouldAutoresizeExportViewport}setAutoresizeEnabled(t){if(t===this.shouldAutoresizeExportViewport)return g.default.empty;const e=this.root.getBBox();return y.SetImportExportRectCommand.of(this,e,t)}setAutoresizeEnabledDirectly(t){t!==this.shouldAutoresizeExportViewport&&(this.shouldAutoresizeExportViewport=t,this.notifier.dispatch(b.AutoresizeModeChanged,{image:this}))}autoresizeExportViewport(){this.shouldAutoresizeExportViewport&&this.setExportRectDirectly(this.root.getBBox())}setExportRectDirectly(t){const e=this.getImportExportViewport(),n=e.getScreenRectSize(),o=e.canvasToScreenTransform,i=u.Mat33.translation(t.topLeft.times(-1));return(!n.eq(t.size)||!o.eq(i))&&(this.settingExportRect=!0,e.updateScreenSize(t.size),e.resetTransform(i),this.settingExportRect=!1,this.onExportViewportChanged(),!0)}onExportViewportChanged(){this.settingExportRect||this.notifier.dispatch(b.ExportViewportChanged,{image:this})}}y.AddElementCommand=(l(o=class extends p.default{constructor(t,e=!1){if(super("add-element"),this.element=t,this.applyByFlattening=e,this.serializedElem=null,this.serializedElem=null,isNaN(t.getBBox().area))throw new Error("Elements in the image cannot have NaN bounding boxes")}apply(t){t.image.addElementDirectly(this.element),this.applyByFlattening?(this.applyByFlattening=!1,t.display.flatten()):t.queueRerender()}unapply(t){t.image.removeElementDirectly(this.element),t.queueRerender()}description(t,e){return e.addElementAction(this.element.description(e))}serializeToJSON(){return{elemData:this.serializedElem??this.element.serialize()}}},"AddElementCommand"),p.default.register("add-element",((t,e)=>{const n=t.elemData.id,o=e.image.lookupElement(n)??h.default.deserialize(t.elemData),i=new y.AddElementCommand(o);return i.serializedElem=t.elemData,i})),o),y.SetImportExportRectCommand=(l(i=class extends p.default{constructor(t,e,n,o,i){super(y.SetImportExportRectCommand.commandId),this.originalSize=t,this.originalTransform=e,this.originalAutoresize=n,this.newExportRect=o,this.newAutoresize=i}static of(t,e,n){const o=t.getImportExportViewport(),i=o.visibleRect.size,r=o.canvasToScreenTransform,s=t.getAutoresizeEnabled();return new y.SetImportExportRectCommand(i,r,s,e,n)}apply(t){t.image.setAutoresizeEnabledDirectly(this.newAutoresize),t.image.setExportRectDirectly(this.newExportRect),t.queueRerender()}unapply(t){const e=t.image.getImportExportViewport();t.image.setAutoresizeEnabledDirectly(this.originalAutoresize),e.updateScreenSize(this.originalSize),e.resetTransform(this.originalTransform),t.queueRerender()}description(t,e){return this.newAutoresize!==this.originalAutoresize?this.newAutoresize?e.enabledAutoresizeOutputCommand:e.disabledAutoresizeOutputCommand:e.resizeOutputCommand(this.newExportRect)}serializeToJSON(){return{originalSize:this.originalSize.xy,originalTransform:this.originalTransform.toArray(),newRegion:{x:this.newExportRect.x,y:this.newExportRect.y,w:this.newExportRect.w,h:this.newExportRect.h},autoresize:this.newAutoresize,originalAutoresize:this.originalAutoresize}}},"SetImportExportRectCommand"),i.commandId="set-import-export-rect",(()=>{const t=i.commandId;p.default.register(t,((t,e)=>{(0,m.assertIsNumber)(t.originalSize.x),(0,m.assertIsNumber)(t.originalSize.y),(0,m.assertIsNumberArray)(t.originalTransform),(0,m.assertIsNumberArray)([t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h]),(0,m.assertIsBoolean)(t.autoresize??!1),(0,m.assertIsBoolean)(t.originalAutoresize??!1);const n=u.Vec2.ofXY(t.originalSize),o=new u.Mat33(...t.originalTransform),i=new u.Rect2(t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h),r=t.autoresize??!1,s=t.originalAutoresize??!1;return new y.SetImportExportRectCommand(n,o,s,i,r)}))})(),i),e.default=y;class v{constructor(t=null){this.parent=t,this.targetChildCount=30,this.children=[],this.bbox=u.Rect2.empty,this.content=null,this.id=v.idCounter++}getId(){return this.id}onContentChange(){this.id=v.idCounter++}getContent(){return this.content}getParent(){return this.parent}getChildrenIntersectingRegion(t,e){return this.children.filter((n=>{const o=n.getBBox();return!e?.(o)&&o.intersects(t)}))}getChildrenOrSelfIntersectingRegion(t){return this.content?[this]:this.getChildrenIntersectingRegion(t)}getLeavesIntersectingRegion(t,e){const n=[],o=[];for(o.push(this);o.length>0;){const i=o.pop();null!==i.content&&n.push(i),o.push(...i.getChildrenIntersectingRegion(t,e))}return n}getChildWithContent(t){const e=this.getLeavesIntersectingRegion(t.getBBox());for(const n of e)if(n.getContent()===t)return n;return null}getLeaves(){if(this.content)return[this];const t=[];for(const e of this.children)t.push(...e.getLeaves());return t}addLeaf(t){if(this.onContentChange(),null===this.content&&0===this.children.length)return this.content=t,this.recomputeBBox(!0),this;if(null!==this.content){console.assert(0===this.children.length);const t=new v(this);t.content=this.content,this.content=null,this.children.push(t),t.recomputeBBox(!1)}const e=t.getBBox();if(e.containsRect(this.getBBox())){const e=new v(this);if(this.children.length<this.targetChildCount)this.children.push(e);else{const t=new v(this);t.children=this.children,this.children=[e,t],t.recomputeBBox(!0),t.updateParents()}return e.addLeaf(t)}const n=this.children.filter((t=>t.getBBox().containsRect(e)));if(n.length>0&&this.children.length>=this.targetChildCount){n.sort(((t,e)=>t.getBBox().area-e.getBBox().area));const e=n[0].addLeaf(t);return e.rebalance(),e}const o=v.createLeafNode(this,t);return this.children.push(o),o.recomputeBBox(!0),o}static createLeafNode(t,e){const n=new v(t);return n.content=e,n}getBBox(){return this.bbox}recomputeBBox(t){const e=this.bbox;null!==this.content?this.bbox=this.content.getBBox():this.bbox=u.Rect2.union(...this.children.map((t=>t.getBBox()))),t&&!e.eq(this.bbox)&&(this.bbox.containsRect(e)?this.parent?.recomputeBBox(!0):this.parent?.unionBBoxWith(this.bbox))}unionBBoxWith(t){this.bbox=this.bbox.union(t),this.parent?.unionBBoxWith(t)}updateParents(t=!1){for(const e of this.children)e.parent=this,t&&e.updateParents(t)}rebalance(){if(this.parent&&1===this.parent.children.length){console.assert(null===this.parent.content),console.assert(this.parent.children[0]===this);const t=this.parent;null!==t.parent?(t.children=[],this.parent=t.parent,this.parent.children.push(this),t.parent=null,this.parent.recomputeBBox(!1)):null===this.content&&(this.parent.children=this.children,this.parent.updateParents(),this.parent=null)}}removeChild(t){const e=this.children.length;this.children=this.children.filter((e=>e!==t)),console.assert(this.children.length===e-1,`${e-1} ≠ ${this.children.length} after removing all nodes equal to ${t}. Nodes should only be removed once.`),this.children.forEach((t=>{t.rebalance()})),this.recomputeBBox(!0)}remove(){if(this.content?.onRemoveFromImage(),!this.parent)return this.content=null,void(this.children=[]);this.parent.removeChild(this),this.parent=null,this.content=null,this.children=[]}render(t,n){let o;o=n?this.getLeavesIntersectingRegion(n,(e=>t.isTooSmallToRender(e))):this.getLeaves(),(0,e.sortLeavesByZIndex)(o);for(const e of o)e.getContent().render(t,n)}renderDebugBoundingBoxes(t,e,n=0){const o=this.getBBox(),i=1/(t.getSizeOfCanvasPixelOnScreen()||1);if(o.maxDimension<3*i||!o.intersects(e))return;t.startObject(o);const r=!!this.content,s=r?u.Color4.ofRGBA(1,0,1,.4):u.Color4.ofRGBA(0,1,Math.sin(n),.6),a=r?1*i:2*i;t.drawRect(o.intersection(e),a,{fill:s}),t.endObject();for(const o of this.children)o.renderDebugBoundingBoxes(t,e,n+1)}}e.ImageNode=v,v.idCounter=0;class w extends v{constructor(){super(...arguments),this.fullscreenChildren=[],this.dataComponents=[]}getChildrenIntersectingRegion(t,e){const n=super.getChildrenIntersectingRegion(t);for(const t of this.fullscreenChildren)n.push(t);return n}getLeaves(){const t=super.getLeaves();return this.dataComponents.concat(this.fullscreenChildren,t)}removeChild(t){let e=!1;const n=n=>{const o=n===t;return e||=o,!o};this.dataComponents=this.dataComponents.filter(n),this.fullscreenChildren=this.fullscreenChildren.filter(n),e||super.removeChild(t)}getChildWithContent(t){const e=()=>{const e=this.fullscreenChildren.concat(this.dataComponents);for(const n of e)if(n.getContent()===t)return n;return null};return t.getSizingMode(),h.ComponentSizingMode.BoundingBox,super.getChildWithContent(t)??e()}addLeaf(t){const e=t.getSizingMode();if(e===h.ComponentSizingMode.BoundingBox)return super.addLeaf(t);if(e===h.ComponentSizingMode.FillScreen){this.onContentChange();const e=v.createLeafNode(this,t);return this.fullscreenChildren.push(e),e}if(e===h.ComponentSizingMode.Anywhere){this.onContentChange();const e=v.createLeafNode(this,t);return this.dataComponents.push(e),e}throw new Error(`Invalid sizing mode, ${e}`)}}e.RootImageNode=w},1785:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.listeners={}}dispatch(t,e){const n=this.listeners[t];if(n)for(let t=0;t<n.length;t++)n[t](e)}on(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),{remove:()=>{const n=this.listeners[t];return this.off(t,e),n.length!==this.listeners[t].length}}}off(t,e){const n=this.listeners[t];n&&(this.listeners[t]=n.filter((t=>t!==e)))}}},4318:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointerDevice=void 0;const o=n(5097);var i;!function(t){t[t.Pen=0]="Pen",t[t.Eraser=1]="Eraser",t[t.Touch=2]="Touch",t[t.PrimaryButtonMouse=3]="PrimaryButtonMouse",t[t.RightButtonMouse=4]="RightButtonMouse",t[t.Other=5]="Other"}(i||(e.PointerDevice=i={}));class r{constructor(t,e,n,o,i,r,s,a){this.screenPos=t,this.canvasPos=e,this.pressure=n,this.isPrimary=o,this.down=i,this.device=r,this.id=s,this.timeStamp=a}snappedToGrid(t){const e=t.snapToGrid(this.canvasPos);return this.withCanvasPosition(e,t)}lockedToXYAxesScreen(t,e){const n=this.screenPos.minus(t),i=o.Vec2.unitX.times(n.x),r=o.Vec2.unitY.times(n.y);let s;return s=n.dot(i)>n.dot(r)?i:r,s=s.plus(t),this.withScreenPosition(s,e)}withScreenPosition(t,e){const n=e.screenToCanvas(t);return this.withCanvasPosition(n,e)}withTimestamp(t){return new r(this.screenPos,this.canvasPos,this.pressure,this.isPrimary,this.down,this.device,this.id,t)}withCanvasPosition(t,e){const n=e.canvasToScreen(t);return new r(n,t,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(t,e,n,s){let a=o.Vec2.of(t.clientX,t.clientY);if(s){const t=s.getBoundingClientRect();a=a.minus(o.Vec2.of(t.left,t.top))}let l={mouse:i.PrimaryButtonMouse,pen:i.Pen,touch:i.Touch}[t.pointerType]??i.Other;l===i.Pen&&0!=(32&t.buttons)&&(l=i.Eraser);const c=t.timeStamp,d=n.roundPoint(n.screenToCanvas(a));return l===i.PrimaryButtonMouse&&2&t.buttons&&(l=i.RightButtonMouse),new r(a,d,t.pressure??null,t.isPrimary,e,l,t.pointerId,c)}static ofCanvasPoint(t,e,n,o=0,s=i.Pen,a=!0,l=null){const c=n.canvasToScreen(t),d=(new Date).getTime();return new r(c,t,l,a,e,s,o,d)}}e.default=r},1697:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.svgLoaderAutoresizeClassName=e.svgLoaderAttributeContainerID=e.svgStyleAttributesDataKey=e.svgAttributesDataKey=e.defaultSVGViewRect=void 0;const a=n(5097),l=r(n(1847)),c=s(n(7077)),d=s(n(9964)),h=s(n(2413)),u=r(n(3167)),p=s(n(9025)),f=n(7444);e.defaultSVGViewRect=new a.Rect2(0,0,500,500),e.svgAttributesDataKey="svgAttrs",e.svgStyleAttributesDataKey="svgStyleAttrs",e.svgLoaderAttributeContainerID="svgContainerID",e.svgLoaderAutoresizeClassName="js-draw--autoresize";const m=["stroke","fill","stroke-width"];class g{constructor(t,e,n){this.source=t,this.onFinish=e,this.onAddComponent=null,this.onProgress=null,this.onDetermineExportRect=null,this.processedCount=0,this.totalToProcess=0,this.containerGroupIDs=[],this.encounteredIDs=[],this.storeUnknown=!n.sanitize,this.disableUnknownObjectWarnings=!!n.disableUnknownObjectWarnings}getStyle(t,e){let n,o=a.Color4.transparent;const i=t.getAttribute("fill")??e?.fill??t.style.fill;if(i)try{o=a.Color4.fromString(i)}catch(t){console.error("Unknown fill color,",i)}const r=t.getAttribute("stroke")??e?.stroke??t.style.stroke,s=t.getAttribute("stroke-width")??e?.strokeWidth??t.style.strokeWidth;if(r&&s)try{let t=parseFloat(s??"1");isFinite(t)||(t=0);const e=a.Color4.fromString(r);e.a>0&&(n={width:t,color:e})}catch(t){console.error("Error parsing stroke data:",t)}return{fill:o,stroke:n}}strokeDataFromElem(t){const e=[],n=t.getAttribute("d")??"",o=this.getStyle(t),i=n.split("M");let r=!0;for(const t of i){const n=/^[0-9., \t\n]+$/.exec(t);if(""!==t&&!n){const n=r?t:`M${t}`,i=a.Path.fromString(n),s=(0,f.pathToRenderable)(i,o);e.push(s)}r=!1}return e}attachUnrecognisedAttrs(t,n,o,i){if(this.storeUnknown){for(const r of n.getAttributeNames())o.has(r)||"style"===r&&i||t.attachLoadSaveData(e.svgAttributesDataKey,[r,n.getAttribute(r)]);if(i&&n.style)for(let o=0;o<n.style.length;o++){const r=n.style[o];""!==r&&r&&(i.has(r)||t.attachLoadSaveData(e.svgStyleAttributesDataKey,{key:r,value:n.style.getPropertyValue(r),priority:n.style.getPropertyPriority(r)}))}}}async addPath(t){let e;try{const n=this.strokeDataFromElem(t);e=new d.default(n),this.attachUnrecognisedAttrs(e,t,new Set([...m,"d"]),new Set(m))}catch(n){if(console.error("Invalid path in node",t,"\nError:",n,"\nAdding as an unknown object."),!this.storeUnknown)return;e=new p.default(t)}await this.addComponent(e)}async addBackground(t){if(t.classList.contains(l.backgroundTypeToClassNameMap[l.BackgroundType.Grid])){let e,n,o,i,r;if("g"===t.tagName.toLowerCase()){if(2!==t.children.length)return void await this.addUnknownNode(t);const i=t.children[0],r=t.children[1];n=i.getAttribute("fill"),e=r.getAttribute("stroke"),o=r.getAttribute("stroke-width")}else n=t.getAttribute("fill"),e=t.getAttribute("stroke"),o=t.getAttribute("stroke-width");if(n??=a.Color4.transparent.toHexString(),!e)return void await this.addUnknownNode(t);for(const e of t.classList)if(e.startsWith(l.imageBackgroundGridSizeCSSPrefix)){const t=e.substring(l.imageBackgroundGridSizeCSSPrefix.length);i=parseFloat(t.replace(/p/g,"."))}o&&(r=parseFloat(o));const s=a.Color4.fromString(n);let c=a.Color4.fromString(e);t.classList.contains(l.imageBackgroundNonAutomaticSecondaryColorCSSClassName)||(c=void 0);const d=l.default.ofGrid(s,i,c,r);await this.addComponent(d)}else if("path"===t.tagName.toLowerCase()){const e=a.Color4.fromString(t.getAttribute("fill")??t.style.fill??"black"),n=new l.default(l.BackgroundType.SolidColor,e);await this.addComponent(n)}else await this.addUnknownNode(t)}getTransform(t,e,n){const o="data-highp-transform",i=t.getAttribute(o);let r;if(i)try{r=a.Mat33.fromCSSMatrix(i),e?.push(o)}catch(t){console.warn(`Unable to parse raw transform data, ${i}. Falling back to CSS data.`)}if(!r){n??=window.getComputedStyle(t);let o=n.transform;""!==o&&"none"!==o||(o=t.style.transform||"none");try{r=a.Mat33.fromCSSMatrix(t.style.transform)}catch(t){console.warn("matrix parse error",t),r=a.Mat33.fromCSSMatrix(o)}const i=t.getAttribute("x"),s=t.getAttribute("y");if(i||s){const t=parseFloat(i??"0"),n=parseFloat(s??"0");isNaN(t)||isNaN(n)||(e?.push("x","y"),r=r.rightMul(a.Mat33.translation(a.Vec2.of(t,n))))}}return r}makeText(t){const e=[];for(const n of t.childNodes)if(n.nodeType===Node.TEXT_NODE)e.push(n.nodeValue??"");else{if(n.nodeType!==Node.ELEMENT_NODE)throw new Error(`Unrecognized text child node: ${n}.`);{const t=n;if("tspan"!==t.tagName.toLowerCase())throw new Error(`Unrecognized text child element: ${t}`);e.push(this.makeText(t))}}0===e.length&&e.push("");const n=window.getComputedStyle(t),o=/^([-0-9.e]+)px/i;let i=o.exec(t.style.fontSize);!i&&"tspan"===t.tagName.toLowerCase()&&t.parentElement&&(i=o.exec(t.parentElement.style.fontSize)),i||(i=o.exec(n.fontSize));const r=["fontFamily","transform",...m];let s=12;i&&(r.push("fontSize"),s=parseFloat(i[1]));const l={size:s,fontFamily:n.fontFamily||t.style.fontFamily||"sans-serif",fontWeight:n.fontWeight||t.style.fontWeight||void 0,fontStyle:n.fontStyle||t.style.fontStyle||void 0,renderingStyle:this.getStyle(t,n)},c=[];let d=this.getTransform(t,c,n),h=u.TextTransformMode.ABSOLUTE_XY;const p=t.getAttribute("dx");p&&(h=u.TextTransformMode.RELATIVE_X_ABSOLUTE_Y,d=d.rightMul(a.Mat33.translation(a.Vec2.of(parseFloat(p),0))),c.push("dx"));const f=t.getAttribute("dy");f&&(h=h===u.TextTransformMode.RELATIVE_X_ABSOLUTE_Y?u.TextTransformMode.RELATIVE_XY:u.TextTransformMode.RELATIVE_Y_ABSOLUTE_X,d=d.rightMul(a.Mat33.translation(a.Vec2.of(0,parseFloat(f)))),c.push("dy"));const g=new u.default(e,d,l,h);return this.attachUnrecognisedAttrs(g,t,new Set(c),new Set(r)),g}async addText(t){try{const e=this.makeText(t);await this.addComponent(e)}catch(e){console.error("Invalid text object in node",t,". Continuing.... Error:",e),this.addUnknownNode(t)}}async addImage(t){const e=new Image;e.src=t.getAttribute("xlink:href")??t.href.baseVal,e.setAttribute("alt",t.getAttribute("aria-label")??"");try{const n=[],o=this.getTransform(t,n),i=await c.default.fromImage(e,o);this.attachUnrecognisedAttrs(i,t,new Set(n),new Set(["transform"])),await this.addComponent(i)}catch(e){console.error("Error loading image:",e,". Element: ",t,". Continuing..."),await this.addUnknownNode(t)}}async addUnknownNode(t){if(this.storeUnknown){const e=new p.default(t);await this.addComponent(e)}}async startGroup(t){let e=(t=t.cloneNode(!1)).id||`id-${this.encounteredIDs.length}`,n=0,o="";for(;this.encounteredIDs.includes(e+o);)n++,o="--"+n;e+=o,t.replaceChildren(),t.id=e;const i=new p.default(t);this.addComponent(i),this.containerGroupIDs.push(t.id),this.encounteredIDs.push(t.id)}async endGroup(){this.containerGroupIDs.pop()}async addComponent(t){this.containerGroupIDs.length>0&&t.attachLoadSaveData(e.svgLoaderAttributeContainerID,[...this.containerGroupIDs]),await(this.onAddComponent?.(t))}updateViewBox(t){const n=t.getAttribute("viewBox");if(this.rootViewBox||!n)return;const o=n.split(/[ \t\n,]+/),i=parseFloat(o[0]),r=parseFloat(o[1]),s=parseFloat(o[2]),l=parseFloat(o[3]);if(isNaN(i)||isNaN(r)||isNaN(s)||isNaN(l))return void console.warn(`node ${t} has an unparsable viewbox. Viewbox: ${n}. Match: ${o}.`);const c=t.classList.contains(e.svgLoaderAutoresizeClassName);this.rootViewBox=new a.Rect2(i,r,s,l),this.onDetermineExportRect?.(this.rootViewBox,{autoresize:c})}async updateSVGAttrs(t){this.storeUnknown&&await(this.onAddComponent?.(new h.default(this.getSourceAttrs(t))))}async visit(t){this.totalToProcess+=t.childElementCount;let e=!0;switch(t.tagName.toLowerCase()){case"g":t.classList.contains(l.imageBackgroundCSSClassName)?(await this.addBackground(t),e=!1):await this.startGroup(t);break;case"path":t.classList.contains(l.imageBackgroundCSSClassName)?await this.addBackground(t):await this.addPath(t);break;case"text":await this.addText(t),e=!1;break;case"image":await this.addImage(t),e=!1;break;case"svg":this.updateViewBox(t),this.updateSVGAttrs(t);break;case"style":await this.addUnknownNode(t);break;default:return this.disableUnknownObjectWarnings||(console.warn("Unknown SVG element,",t,t.tagName),t instanceof SVGElement||console.warn("Element",t,"is not an SVGElement!",this.storeUnknown?"Continuing anyway.":"Skipping.")),void await this.addUnknownNode(t)}if(e){for(const e of t.children)await this.visit(e);"g"===t.tagName.toLowerCase()&&await this.endGroup()}this.processedCount++,await(this.onProgress?.(this.processedCount,this.totalToProcess))}getSourceAttrs(t){return t.getAttributeNames().map((e=>[e,t.getAttribute(e)]))}async start(t,n,o=null){this.onAddComponent=t,this.onProgress=n,this.onDetermineExportRect=o,this.totalToProcess=this.source.childElementCount,this.processedCount=0,this.rootViewBox=null,await this.visit(this.source);this.rootViewBox||this.onDetermineExportRect?.(e.defaultSVGViewRect),this.onFinish?.()}static fromString(t,e=!1){const n=document.createElement("iframe");if(n.src="about:blank",n.setAttribute("sandbox","allow-same-origin"),n.setAttribute("csp","default-src 'about:blank'"),n.style.display="none",document.body.appendChild(n),!n.hasAttribute("sandbox"))throw n.remove(),new Error("SVG loading iframe is not sandboxed.");const o=n.contentWindow?.document??n.contentDocument;if(null==o)throw new Error("Unable to open a sandboxed iframe!");o.open(),o.write("\n\t\t\t<!DOCTYPE html>\n\t\t\t<html>\n\t\t\t\t<head>\n\t\t\t\t\t<title>SVG Loading Sandbox</title>\n\t\t\t\t\t<meta name='viewport' conent='width=device-width,initial-scale=1.0'/>\n\t\t\t\t\t<meta charset='utf-8'/>\n\t\t\t\t</head>\n\t\t\t\t<body style='font-size: 12px;'>\n\t\t\t\t\t<script>\n\t\t\t\t\t\tconsole.error('JavaScript should not be able to run here!');\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The SVG sandbox is broken! Please double-check the sandboxing setting.'\n\t\t\t\t\t\t);\n\t\t\t\t\t<\/script>\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t"),o.close();const i=o.createElementNS("http://www.w3.org/2000/svg","svg");let r,s;return i.innerHTML=t,o.body.appendChild(i),"boolean"==typeof e?(r=e,s=!1):(r=e.sanitize??!1,s=e.disableUnknownObjectWarnings??!1),new g(i,(()=>{i.remove(),n.remove()}),{sanitize:r,disableUnknownObjectWarnings:s})}}e.default=g},5155:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const a=n(3173);o=new WeakMap,i=new WeakMap,e.default=class{constructor(t,e,n){this.editor=t,this.announceRedoCallback=e,this.announceUndoCallback=n,o.set(this,void 0),i.set(this,void 0),this.maxUndoRedoStackSize=700,r(this,o,[],"f"),r(this,i,[],"f")}fireUpdateEvent(t,e){this.editor.notifier.dispatch(a.EditorEventType.UndoRedoStackUpdated,{kind:a.EditorEventType.UndoRedoStackUpdated,undoStackSize:s(this,o,"f").length,redoStackSize:s(this,i,"f").length,command:e,stackUpdateType:t})}push(t,e=!0){e&&t.apply(this.editor),s(this,o,"f").push(t);for(const t of s(this,i,"f"))t.onDrop(this.editor);if(r(this,i,[],"f"),s(this,o,"f").length>this.maxUndoRedoStackSize){const t=Math.ceil(this.maxUndoRedoStackSize/100);s(this,o,"f").splice(0,t).forEach((t=>t.onDrop(this.editor)))}this.fireUpdateEvent(a.UndoEventType.CommandDone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandDone,{kind:a.EditorEventType.CommandDone,command:t})}undo(){const t=s(this,o,"f").pop();if(t){s(this,i,"f").push(t);const e=t.unapply(this.editor);return this.announceUndoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandUndone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandUndone,{kind:a.EditorEventType.CommandUndone,command:t}),e}}redo(){const t=s(this,i,"f").pop();if(t){s(this,o,"f").push(t);const e=t.apply(this.editor);return this.announceRedoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandRedone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandDone,{kind:a.EditorEventType.CommandDone,command:t}),e}}get undoStackSize(){return s(this,o,"f").length}get redoStackSize(){return s(this,i,"f").length}}},5566:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Viewport=e.ViewportTransform=void 0;const l=a(n(2216)),c=n(5097);class d extends l.default{}e.ViewportTransform=d;class h{constructor(t){this.onTransformChangeCallback=t,this.resetTransform(c.Mat33.identity),this.screenRect=c.Rect2.empty}getTemporaryClone(){const t=new h((()=>{}));return t.transform=this.transform,t.inverseTransform=this.inverseTransform,t.screenRect=this.screenRect,t}updateScreenSize(t){this.screenRect=this.screenRect.resizedTo(t)}get visibleRect(){return this.screenRect.transformedBoundingBox(this.inverseTransform)}screenToCanvas(t){return this.inverseTransform.transformVec2(t)}canvasToScreen(t){return this.transform.transformVec2(t)}static transformBy(t){return new h.ViewportTransform(t)}resetTransform(t=c.Mat33.identity){const e=this.transform;this.transform=t,this.inverseTransform=t.inverse(),this.onTransformChangeCallback?.(e,t)}get screenToCanvasTransform(){return this.inverseTransform}get canvasToScreenTransform(){return this.transform}getScreenRectSize(){return this.screenRect.size}getResolution(){return this.getScreenRectSize()}getScaleFactor(){return this.transform.transformVec3(c.Vec3.unitX).magnitude()}getScaleFactorToNearestPowerOfTen(){return this.getScaleFactorToNearestPowerOf(10)}getScaleFactorToNearestPowerOf(t){const e=this.getScaleFactor();return Math.pow(t,Math.round(Math.log(e)/Math.log(t)))}static getGridSize(t){return 50/t}snapToGrid(t){const e=this.getScaleFactorToNearestPowerOf(2),n=t=>{const n=1/h.getGridSize(e);return Math.round(t*n)/n};return c.Vec2.of(n(t.x),n(t.y))}getSizeOfPixelOnCanvas(){return 1/this.getScaleFactor()}getRotationAngle(){return this.transform.transformVec3(c.Vec3.unitX).angle()}static roundPoint(t,e){const n=10**Math.floor(Math.log10(e)),o=t=>Math.round(t/n)*n;return"number"==typeof t?o(t):t.map(o)}roundPoint(t){return h.roundPoint(t,1/this.getScaleFactor())}static roundScaleRatio(t,e=1){if(Math.abs(t)<=1e-12)return 0;const n=10**Math.floor(Math.log10(Math.abs(t))),o=2**e;return t=Math.round(t/n*o)/o*n}computeZoomToTransform(t,e=!0,n=!0){let o=c.Mat33.identity;if(0===t.w||0===t.h){let o=Math.max(t.w,t.h);0===o&&(o=50,e=!1,n=!1),t=new c.Rect2(t.x,t.y,o,o)}if(isNaN(t.size.magnitude()))throw new Error(`${t.toString()} rectangle has NaN size! Cannot zoom to!`);const i=()=>{const t=this.visibleRect.transformedBoundingBox(o.inverse());return t.transformedBoundingBox(c.Mat33.scaling2D(.8,t.center))};let r=i();const s=r.w<t.w||r.h<t.h,a=t.maxDimension/r.maxDimension<1/3;if(s&&n||a&&e){const e=Math.max(t.w/r.w,t.h/r.h),n=c.Mat33.scaling2D(e,r.topLeft).inverse();o=o.rightMul(n)}if(r=i(),!r.containsRect(t)){const e=t.center.minus(r.center),n=c.Mat33.translation(e).inverse();o=o.rightMul(n)}return o.invertable()||(console.warn("Unable to zoom to ",t,"! Computed transform",o,"is singular."),o=c.Mat33.identity),o}zoomTo(t,e=!0,n=!0){const o=this.computeZoomToTransform(t,e,n);return new h.ViewportTransform(o)}}e.Viewport=h,h.ViewportTransform=(i=class extends d{constructor(t){super(),this.transform=t,o.set(this,void 0),r(this,o,t.inverse(),"f")}apply(t){const e=t.viewport;e.resetTransform(e.transform.rightMul(this.transform)),t.queueRerender()}unapply(t){const e=t.viewport;e.resetTransform(e.transform.rightMul(s(this,o,"f"))),t.queueRerender()}description(t,e){const n=[],o=t.viewport.visibleRect.center,i=this.transform.transformVec3(c.Vec2.unitX),r=this.transform.transformVec2(o),s=i.magnitude(),a=180/Math.PI*i.angle(),l=r.minus(o);s>1.2?n.push(e.zoomedIn):s<.8&&n.push(e.zoomedOut),Math.floor(Math.abs(a))>0&&n.push(e.rotatedBy(Math.round(a)));const d=1e-4;return l.x>d?n.push(e.movedLeft):l.x<-1e-4&&n.push(e.movedRight),l.y<-1e-4?n.push(e.movedDown):l.y>d&&n.push(e.movedUp),n.join("; ")}},o=new WeakMap,i),e.default=h},7783:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),n(9143);const s=r(n(5146));i(n(6209),e),e.default=s.default},2216:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Command=void 0;class n{onDrop(t){}static union(t,e){return new class extends n{apply(n){t.apply(n),e.apply(n)}unapply(n){e.unapply(n),t.unapply(n)}description(n,o){const i=t.description(n,o),r=e.description(n,o);return i===r?i:`${i}, ${r}`}}}}e.Command=n,n.empty=new class extends n{description(t,e){return""}apply(t){}unapply(t){}},e.default=n},1365:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(2944)),r=o(n(9721)),s=o(n(6669));class a extends s.default{constructor(t){super("duplicate"),this.toDuplicate=t,this.duplicates=t.map((t=>t.clone())),this.reverse=new r.default(this.duplicates)}apply(t){this.reverse.unapply(t)}unapply(t){this.reverse.apply(t)}onDrop(t){this.reverse.onDrop(t)}description(t,e){return 0===this.duplicates.length?e.duplicatedNoElements:e.duplicateAction((0,i.default)(e,this.duplicates)??e.elements,this.duplicates.length)}serializeToJSON(){return this.toDuplicate.map((t=>t.getId()))}}s.default.register("duplicate",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t)));return new a(n)})),e.default=a},9721:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(2944)),r=o(n(7551)),s=o(n(6669));class a extends s.default{constructor(t){super("erase"),this.toRemove=t.map((t=>t)),this.applied=!1}apply(t){for(const e of this.toRemove){const n=t.image.findParent(e);n&&(n.remove(),t.image.onDestroyElement(e))}this.applied=!0,t.queueRerender()}unapply(t){for(const e of this.toRemove)t.image.findParent(e)||r.default.addElement(e).apply(t);this.applied=!1,t.queueRerender()}onDrop(t){if(this.applied)for(const e of this.toRemove)t.image.onDestroyElement(e)}description(t,e){if(0===this.toRemove.length)return e.erasedNoElements;const n=(0,i.default)(e,this.toRemove)??e.elements;return e.eraseAction(n,this.toRemove.length)}serializeToJSON(){return this.toRemove.map((t=>t.getId()))}}s.default.register("erase",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t))).filter((t=>null!==t));return new a(n)})),e.default=a},6669:function(t,e,n){"use strict";var o,i=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(2216));class l extends a.default{constructor(t){if(super(),o.set(this,void 0),!(t in l.deserializationCallbacks))throw new Error(`Command ${t} must have a registered deserialization callback. To do this, call SerializableCommand.register.`);i(this,o,t,"f")}serialize(){return{data:this.serializeToJSON(),commandType:r(this,o,"f")}}static deserialize(t,e){const n="string"==typeof t?JSON.parse(t):t,o=n.commandType;if(!(o in l.deserializationCallbacks))throw new Error(`Unrecognised command type ${o}!`);return l.deserializationCallbacks[o](n.data,e)}static register(t,e){l.deserializationCallbacks[t]=e}}o=new WeakMap,l.deserializationCallbacks={},e.default=l},8859:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(6669));class r extends i.default{constructor(t,e,n){super(t),this.component=n??null,this.componentID=e}resolveComponent(t){if(this.component)return;const e=t.lookupElement(this.componentID);if(!e)throw new Error(`Unable to resolve component with ID ${this.componentID}`);this.component=e}}e.default=r},2242:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(2216)),r=o(n(6669)),s=t=>{if(t instanceof r.default)return new class extends r.default{serializeToJSON(){return t.serialize()}apply(e){t.unapply(e)}unapply(e){t.unapply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}("inverse");return new class extends i.default{apply(e){t.unapply(e)}unapply(e){t.apply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}};r.default.register("inverse",((t,e)=>s(r.default.deserialize(t,e)))),e.default=s},7601:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.uniteCommands=e.invertCommand=e.SerializableCommand=e.Erase=e.Duplicate=e.Command=void 0;const i=o(n(2216));e.Command=i.default;const r=o(n(1365));e.Duplicate=r.default;const s=o(n(9721));e.Erase=s.default;const a=o(n(2242));e.invertCommand=a.default;const l=o(n(6669));e.SerializableCommand=l.default;const c=o(n(1456));e.uniteCommands=c.default},6985:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultCommandLocalization=void 0,e.defaultCommandLocalization={updatedViewport:"Transformed Viewport",transformedElements:t=>`Transformed ${t} element${1===t?"":"s"}`,resizeOutputCommand:t=>`Resized image to ${t.w}x${t.h}`,enabledAutoresizeOutputCommand:"Enabled output autoresize",disabledAutoresizeOutputCommand:"Disabled output autoresize",addElementAction:t=>`Added ${t}`,eraseAction:(t,e)=>`Erased ${e} ${t}`,duplicateAction:(t,e)=>`Duplicated ${e} ${t}`,unionOf:(t,e)=>`Union: ${e} ${t}`,inverseOf:t=>`Inverse of ${t}`,elements:"Elements",erasedNoElements:"Erased nothing",duplicatedNoElements:"Duplicated nothing",rotatedBy:t=>`Rotated by ${Math.abs(t)} degrees ${t<0?"clockwise":"counter-clockwise"}`,movedLeft:"Moved left",movedUp:"Moved up",movedDown:"Moved down",movedRight:"Moved right",zoomedOut:"Zoomed out",zoomedIn:"Zoomed in",selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`}},1456:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7129)),r=o(n(2216)),s=o(n(6669));class a extends r.default{constructor(t,e){super(),this.commands=t,this.applyChunkSize=e}apply(t){if(void 0===this.applyChunkSize){const e=this.commands.map((e=>e.apply(t)));return(0,i.default)(e)}return t.asyncApplyCommands(this.commands,this.applyChunkSize)}unapply(t){const e=[...this.commands];if(e.reverse(),void 0===this.applyChunkSize){const n=e.map((e=>e.unapply(t)));return(0,i.default)(n)}return t.asyncUnapplyCommands(e,this.applyChunkSize,!1)}onDrop(t){this.commands.forEach((e=>e.onDrop(t)))}description(t,e){const n=[];let o=null,i=0;for(const r of this.commands){const s=r.description(t,e);s!==o&&null!==o&&(n.push(e.unionOf(o,i)),o=null,i=0),i++,o??=s}return i>1?n.push(e.unionOf(o,i)):1===i&&n.push(o),n.join(", ")}}class l extends s.default{constructor(t,e){super("union"),this.commands=t,this.applyChunkSize=e,this.nonserializableCommand=new a(t,e)}serializeToJSON(){return this.serializedData?this.serializedData:{applyChunkSize:this.applyChunkSize,data:this.commands.map((t=>t.serialize()))}}apply(t){return this.serializedData=this.serializeToJSON(),this.nonserializableCommand.apply(t)}unapply(t){return this.nonserializableCommand.unapply(t)}onDrop(t){this.nonserializableCommand.onDrop(t)}description(t,e){return this.nonserializableCommand.description(t,e)}}const c=(t,e)=>{let n=!0;for(const e of t)if(!(e instanceof s.default)){n=!1;break}if(n){return new l(t,e)}return new a(t,e)};s.default.register("union",((t,e)=>{if("number"!=typeof t.data.length)throw new Error("Unions of commands must serialize to lists of serialization data.");const n=t.applyChunkSize;if("number"!=typeof n&&void 0!==n)throw new Error("serialized applyChunkSize is neither undefined nor a number.");const o=[];for(const n of t.data)o.push(s.default.deserialize(n,e));return c(o,n)})),e.default=c},2655:function(t,e,n){"use strict";var o,i=this&&this.__setFunctionName||function(t,e,n){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ComponentSizingMode=void 0;const s=r(n(6669)),a=r(n(7551)),l=n(5097),c=r(n(8859));var d;!function(t){t[t.BoundingBox=0]="BoundingBox",t[t.FillScreen=1]="FillScreen",t[t.Anywhere=2]="Anywhere"}(d||(e.ComponentSizingMode=d={}));class h{constructor(t,e){if(this.componentKind=t,this.loadSaveData={},this.lastChangedTime=(new Date).getTime(),this.zIndex=void 0!==e?e:h.zIndexCounter++,this.id=`${(new Date).getTime()}-${Math.random()}`,void 0===h.deserializationCallbacks[t])throw new Error(`Component ${t} has not been registered using AbstractComponent.registerComponent`)}getId(){return this.id}static registerComponent(t,e){this.deserializationCallbacks[t]=e??null}attachLoadSaveData(t,e){this.loadSaveData[t]||(this.loadSaveData[t]=[]),this.loadSaveData[t].push(e)}getLoadSaveData(){return this.loadSaveData}getZIndex(){return this.zIndex}getBBox(){return this.contentBBox}getExactBBox(){return this.getBBox()}getSizingMode(){return d.BoundingBox}onAddToImage(t){}onRemoveFromImage(){}intersectsRect(t){if(t.containsRect(this.getExactBBox()))return!0;return t.getEdges().some((t=>this.intersects(t)))}transformBy(t){return new h.TransformElementCommand(t,this.getId(),this)}setZIndex(t){return new h.TransformElementCommand(l.Mat33.identity,this.getId(),this,t,this.getZIndex())}isSelectable(){return!0}isBackground(){return!1}getProportionalRenderingTime(){return 1}clone(){const t=this.createClone();for(const e in this.loadSaveData)for(const n of this.loadSaveData[e])t.attachLoadSaveData(e,n);return t}serialize(){const t=this.serializeToJSON();if(null===t)throw new Error(`${this} cannot be serialized.`);return{name:this.componentKind,zIndex:this.zIndex,id:this.id,loadSaveData:this.loadSaveData,data:t}}static isNotDeserializable(t){return"string"==typeof t&&(t=JSON.parse(t)),"object"!=typeof t||(!this.deserializationCallbacks[t?.name]||!t.data)}static deserialize(t){if("string"==typeof t&&(t=JSON.parse(t)),h.isNotDeserializable(t))throw new Error(`Element with data ${t} cannot be deserialized.`);const e=this.deserializationCallbacks[t.name](t.data);return e.zIndex=t.zIndex,e.id=t.id,e}}h.zIndexCounter=0,h.deserializationCallbacks={},h.transformElementCommandId="transform-element",h.TransformElementCommand=(i(o=class extends c.default{constructor(t,e,n,o,i){super(h.transformElementCommandId,e,n),this.affineTransfm=t,this.origZIndex=i,this.targetZIndex=o??h.zIndexCounter++,this.targetZIndex>=h.zIndexCounter&&(h.zIndexCounter=this.targetZIndex+1),n&&void 0===i&&(this.origZIndex=n.getZIndex())}resolveComponent(t){this.component||(super.resolveComponent(t),this.origZIndex??=this.component.getZIndex())}updateTransform(t,e){if(!this.component)throw new Error("this.component is undefined or null!");const n=t.image.findParent(this.component);let o=!1;n&&(n.remove(),o=!0),this.component.applyTransformation(e),this.component.lastChangedTime=(new Date).getTime(),o&&a.default.addElement(this.component).apply(t)}apply(t){this.resolveComponent(t.image),this.component.zIndex=this.targetZIndex,this.updateTransform(t,this.affineTransfm),t.queueRerender()}unapply(t){this.resolveComponent(t.image),this.component.zIndex=this.origZIndex,this.updateTransform(t,this.affineTransfm.inverse()),t.queueRerender()}description(t,e){return e.transformedElements(1)}serializeToJSON(){return{id:this.componentID,transfm:this.affineTransfm.toArray(),targetZIndex:this.targetZIndex,origZIndex:this.origZIndex}}},"TransformElementCommand"),s.default.register(h.transformElementCommandId,((t,e)=>{const n=e.image.lookupElement(t.id)??void 0,o=new l.Mat33(...t.transfm),i=t.targetZIndex,r=t.origZIndex??void 0;return new h.TransformElementCommand(o,t.id,n,i,r)})),o),e.default=h},1847:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.backgroundTypeToClassNameMap=e.imageBackgroundNonAutomaticSecondaryColorCSSClassName=e.imageBackgroundGridSizeCSSPrefix=e.imageBackgroundCSSClassName=e.BackgroundType=void 0;const a=n(7551),l=n(5097),c=r(n(2655)),d=n(739),h=s(n(5566)),u=n(7444);var p;!function(t){t[t.SolidColor=0]="SolidColor",t[t.Grid=1]="Grid",t[t.None=2]="None"}(p||(e.BackgroundType=p={})),e.imageBackgroundCSSClassName="js-draw-image-background",e.imageBackgroundGridSizeCSSPrefix="js-draw-image-background-grid-",e.imageBackgroundNonAutomaticSecondaryColorCSSClassName="js-draw-image-background-non-automatic-secondary-color",e.backgroundTypeToClassNameMap={[p.Grid]:"js-draw-image-background-grid",[p.SolidColor]:e.imageBackgroundCSSClassName,[p.None]:""};class f extends c.default{constructor(t,e){super("image-background",0),this.backgroundType=t,this.mainColor=e,this.viewportSizeChangeListener=null,this.autoresizeChangedListener=null,this.fillsScreen=!1,this.gridSize=h.default.getGridSize(2),this.gridStrokeWidth=.7,this.secondaryColor=null,this.isRestylableComponent=!0,this.contentBBox=l.Rect2.empty}static ofGrid(t,e,n,o){const i=new f(p.Grid,t);return void 0!==e&&(i.gridSize=e),void 0!==n&&(i.secondaryColor=n),void 0!==o&&(i.gridStrokeWidth=o),i}getBackgroundType(){return this.backgroundType}getMainColor(){return this.mainColor}getSecondaryColor(){return this.secondaryColor}getGridSize(){return this.gridSize}getStyle(){let t=this.mainColor;return this.backgroundType===p.None&&(t=void 0),{color:t}}updateStyle(t){return(0,d.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){const n=t.color;n&&(this.mainColor=n,n.eq(l.Color4.transparent)&&this.backgroundType===p.SolidColor?this.backgroundType=p.None:this.backgroundType===p.None&&(this.backgroundType=p.SolidColor),e&&(e.image.queueRerenderOf(this),e.queueRerender()))}onAddToImage(t){this.viewportSizeChangeListener&&(console.warn("onAddToImage called when background is already in an image"),this.onRemoveFromImage()),this.viewportSizeChangeListener=t.notifier.on(a.EditorImageEventType.ExportViewportChanged,(()=>{this.recomputeBBox(t)})),this.autoresizeChangedListener=t.notifier.on(a.EditorImageEventType.AutoresizeModeChanged,(()=>{this.recomputeBBox(t)})),this.recomputeBBox(t)}onRemoveFromImage(){this.viewportSizeChangeListener?.remove(),this.autoresizeChangedListener?.remove(),this.viewportSizeChangeListener=null,this.autoresizeChangedListener=null}recomputeBBox(t){const e=t.getImportExportViewport().visibleRect;let n=!1;this.contentBBox.eq(e)||(this.contentBBox=e,n=!0);const o=t.getAutoresizeEnabled();o!==this.fillsScreen&&(this.fillsScreen=o,n=!0),n&&t.queueRerenderOf(this)}generateGridPath(t){const e=this.getFullBoundingBox(t),n=(t?.intersection(e)??e).grownBy(this.gridStrokeWidth/2),o=t=>Math.floor(t/this.gridSize)*this.gridSize,i=t=>Math.ceil(t/this.gridSize)*this.gridSize,r=i(n.y),s=o(n.y+n.h),a=i(n.x),c=o(n.x+n.w),d=[],h=(s-r)/this.gridSize,u=(c-a)/this.gridSize;if(h>1e3||u>1e3)return l.Path.empty;const p=l.Vec2.of(n.x,r);for(let t=r;t<=s;t+=this.gridSize)d.push({kind:l.PathCommandType.MoveTo,point:l.Vec2.of(n.x,t)}),d.push({kind:l.PathCommandType.LineTo,point:l.Vec2.of(n.x+n.w,t)});for(let t=a;t<=c;t+=this.gridSize)d.push({kind:l.PathCommandType.MoveTo,point:l.Vec2.of(t,n.y)}),d.push({kind:l.PathCommandType.LineTo,point:l.Vec2.of(t,n.y+n.h)});return new l.Path(p,d)}getFullBoundingBox(t){return(this.fillsScreen?t:this.contentBBox)??this.contentBBox}render(t,n){if(this.backgroundType===p.None)return;const o=this.backgroundType===p.Grid,i=this.getFullBoundingBox(n);if(t.startObject(i,o),this.backgroundType===p.SolidColor||this.backgroundType===p.Grid)if(n){const e=n.intersection(i);e&&t.fillRect(e,this.mainColor)}else t.fillRect(i,this.mainColor);if(this.backgroundType===p.Grid){let e=this.secondaryColor;e??=l.Color4.ofRGBA(1-this.mainColor.r,1-this.mainColor.g,1-this.mainColor.b,.2),0===this.mainColor.a&&(e=l.Color4.ofRGBA(.5,.5,.5,.2));const o={fill:l.Color4.transparent,stroke:{width:this.gridStrokeWidth,color:e}};t.drawPath((0,u.pathToRenderable)(this.generateGridPath(n),o))}const r=e.backgroundTypeToClassNameMap[this.backgroundType],s=[e.imageBackgroundCSSClassName];if(r!==e.imageBackgroundCSSClassName){s.push(r);const t=(0,l.toRoundedString)(this.gridSize).replace(/[.]/g,"p");s.push(e.imageBackgroundGridSizeCSSPrefix+t)}null!==this.secondaryColor&&s.push(e.imageBackgroundNonAutomaticSecondaryColorCSSClassName),t.endObject(this.getLoadSaveData(),s)}intersects(t){return this.contentBBox.getEdges().some((e=>e.intersects(t)))}isSelectable(){return!1}isBackground(){return!0}getSizingMode(){return this.fillsScreen?c.ComponentSizingMode.FillScreen:c.ComponentSizingMode.BoundingBox}serializeToJSON(){return{mainColor:this.mainColor.toHexString(),secondaryColor:this.secondaryColor?.toHexString(),backgroundType:this.backgroundType,gridSize:this.gridSize,gridStrokeWidth:this.gridStrokeWidth}}applyTransformation(t){}description(t){if(this.backgroundType===p.SolidColor)return t.filledBackgroundWithColor(this.mainColor.toString());if(this.backgroundType===p.None)return t.emptyBackground;if(this.backgroundType===p.Grid)return t.gridBackground;return this.backgroundType}createClone(){return new f(this.backgroundType,this.mainColor)}static deserializeFromJSON(t){if("string"==typeof t&&(t=JSON.parse(t)),"string"!=typeof t.mainColor)throw new Error("Error deserializing — mainColor must be of type string.");let e;const n=t.backgroundType;if(n!==p.None&&n!==p.Grid&&n!==p.SolidColor){return n}e=n;const o=l.Color4.fromHex(t.mainColor),i=t.secondaryColor?l.Color4.fromHex(t.secondaryColor):null,r=t.gridSize??void 0,s=t.gridStrokeWidth??void 0,a=new f(e,o);return a.secondaryColor=i,r&&(a.gridSize=r),s&&(a.gridStrokeWidth=s),a}}e.default=f,c.default.registerComponent("image-background",f.deserializeFromJSON)},7077:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(6585),s=o(n(2655));class a extends s.default{constructor(t){super("image-component"),this.image={...t,label:t.label??t.image.getAttribute("alt")??t.image.getAttribute("aria-label")??void 0};void 0===t.image.getAttribute("src")||t.image.complete||(t.image.onload=()=>this.recomputeBBox()),this.recomputeBBox()}getImageRect(){return new i.Rect2(0,0,this.image.image.width,this.image.image.height)}recomputeBBox(){this.contentBBox=this.getImageRect(),this.contentBBox=this.contentBBox.transformedBoundingBox(this.image.transform)}static async fromImage(t,e){let n,o,i;t.complete||await new Promise(((e,n)=>{t.onload=e,t.onerror=n,t.onabort=n})),"number"==typeof t.width&&"number"==typeof t.height&&0!==t.width&&0!==t.height?(n=t.width,o=t.height):(n=t.clientWidth,o=t.clientHeight);let r=t.src??"";if(r.startsWith("data:image/"))i=new Image,i.src=r,i.width=n,i.height=o;else{const e=document.createElement("canvas");e.width=n,e.height=o;e.getContext("2d").drawImage(t,0,0,e.width,e.height),r=e.toDataURL(),i=e}return i.setAttribute("alt",t.getAttribute("alt")??""),i.setAttribute("aria-label",t.getAttribute("aria-label")??""),new a({image:i,base64Url:r,transform:e})}render(t,e){t.startObject(this.contentBBox),t.drawImage(this.image),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return 10}intersects(t){const e=this.getImageRect().getEdges().map((t=>t.transformedBy(this.image.transform)));for(const n of e)if(n.intersects(t))return!0;return!1}applyTransformation(t){this.image.transform=t.rightMul(this.image.transform),this.recomputeBBox()}description(t){return this.image.label?t.imageNode(this.image.label):t.unlabeledImageNode}getAltText(){return this.image.label}getURL(){return this.image.base64Url}getTransformation(){return this.image.transform}createClone(){return new a({...this.image})}serializeToJSON(){return{src:this.image.base64Url,label:this.image.label,width:this.image.image.width,height:this.image.image.height,transform:this.image.transform.toArray()}}static deserializeFromJSON(t){if("string"!=typeof t.src)throw new Error(`${t} has invalid format! Expected src property.`);(0,r.assertIsNumberArray)(t.transform),(0,r.assertIsNumber)(t.width),(0,r.assertIsNumber)(t.height);const e=new Image;e.src=t.src,e.width=t.width,e.height=t.height;const n=new i.Mat33(...t.transform);return new a({image:e,base64Url:t.src,label:t.label,transform:n})}}e.default=a,s.default.registerComponent("image-component",a.deserializeFromJSON)},739:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.isRestylableComponent=e.createRestyleComponentCommand=void 0;const i=n(5097),r=o(n(6669)),s=o(n(8859)),a=n(2788),l=t=>{const e={};return t.color&&(e.color=t.color.toHexString()),t.textStyle&&(e.textStyle=(0,a.textStyleToJSON)(t.textStyle)),e},c=t=>({color:t.color?i.Color4.fromHex(t.color):void 0,textStyle:t.textStyle?(0,a.textStyleFromJSON)(t.textStyle):void 0});e.createRestyleComponentCommand=(t,e,n)=>new h(t,e,n.getId(),n);e.isRestylableComponent=t=>!!("getStyle"in t&&"updateStyle"in t&&"forceStyle"in t)&&!(!("isRestylableComponent"in t)||!t.isRestylableComponent);const d="default-restyle-element";class h extends s.default{constructor(t,e,n,o){super(d,n,o),this.originalStyle=t,this.newStyle=e}getComponent(t){this.resolveComponent(t.image);const e=this.component;if(!e||!e.forceStyle||!e.updateStyle)throw new Error("this.component is missing forceStyle and/or updateStyle methods!");return e}apply(t){this.getComponent(t).forceStyle(this.newStyle,t)}unapply(t){this.getComponent(t).forceStyle(this.originalStyle,t)}description(t,e){return e.restyledElement(this.getComponent(t).description(e))}serializeToJSON(){return{id:this.componentID,originalStyle:l(this.originalStyle),newStyle:l(this.newStyle)}}}r.default.register(d,((t,e)=>{const n=c(t.originalStyle),o=c(t.newStyle),i=t.id;if("string"!=typeof t.id)throw new Error(`json.id is of type ${typeof t.id}, not string.`);return new h(n,o,i)}))},2413:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=s(n(2001)),c=r(n(2655)),d="svg-global-attributes";class h extends c.default{constructor(t){super(d),this.attrs=t,this.contentBBox=a.Rect2.empty}render(t,e){if(t instanceof l.default)for(const[e,n]of this.attrs)t.setRootSVGAttribute(e,n)}intersects(t){return!1}applyTransformation(t){}isSelectable(){return!1}getSizingMode(){return c.ComponentSizingMode.Anywhere}createClone(){return new h(this.attrs)}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify(this.attrs)}static deserializeFromString(t){const e=JSON.parse(t),n=[],o=/^[ \t\n0-9.-eE]+$/;for(const[t,i]of e)"viewBox"!==t&&"width"!==t&&"height"!==t||i&&o.exec(i)&&n.push([t,i]);return new h(n)}}e.default=h,c.default.registerComponent(d,h.deserializeFromString)},9964:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(2500),s=o(n(2655)),a=n(739),l=n(7444);class c extends s.default{constructor(t){super("stroke"),this.isRestylableComponent=!0,this.approximateRenderingTime=0,this.parts=[];for(const e of t){const t=(0,l.pathFromRenderable)(e),n=this.bboxForPart(t.bbox,e.style);this.contentBBox?this.contentBBox=this.contentBBox.union(n):this.contentBBox=n,this.parts.push({path:t,startPoint:t.startPoint,style:e.style,commands:t.parts}),this.approximateRenderingTime+=t.parts.length}this.contentBBox??=i.Rect2.empty}getStyle(){if(0===this.parts.length)return{};const t=this.parts[0];return void 0===t.style.stroke||0===t.style.stroke.width?{color:t.style.fill}:{color:t.style.stroke.color}}updateStyle(t){return(0,a.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){t.color&&(this.parts=this.parts.map((e=>{const n={...e.style,stroke:e.style.stroke?{...e.style.stroke}:void 0};return n.stroke&&n.stroke.width>0?n.stroke.color=t.color:n.fill=t.color,{path:e.path,startPoint:e.startPoint,commands:e.commands,style:n}})),e&&(e.image.queueRerenderOf(this),e.queueRerender()))}intersects(t){for(const e of this.parts){const n=e.style.stroke?.width,o=n?n/2:void 0;if(e.path.intersection(t,o).length>0)return!0}return!1}intersectsRect(t){if(!t.intersects(this.getBBox()))return!1;for(const e of this.parts){const n=t.grownBy(-(e.style.stroke?.width??0));if(0!==n.area)for(const t of e.path.startEndPoints())if(n.containsPoint(t))return!0}return super.intersectsRect(t)}render(t,e){t.startObject(this.getBBox());for(const n of this.parts){const o=this.bboxForPart(n.path.bbox,n.style);if(e){if(!o.intersects(e))continue;if((o.size.x>3*e.size.x||o.size.y>3*e.size.y)&&!n.path.roughlyIntersects(e,n.style.stroke?.width??0))continue}t.drawPath(n)}t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.approximateRenderingTime}bboxForPart(t,e){return e.stroke?t.grownBy(e.stroke.width/2):t}getExactBBox(){let t=null;for(const{path:e,style:n}of this.parts){const o=this.bboxForPart(e.getExactBBox(),n);t??=o,t=t.union(o)}return t??i.Rect2.empty}applyTransformation(t){this.contentBBox=i.Rect2.empty;let e=!0;this.parts=this.parts.map((n=>{const o=n.path.transformedBy(t),i={...n.style,stroke:n.style.stroke?{...n.style.stroke}:void 0};if(i.stroke){const e=t.getScaleFactor();i.stroke.width*=e}const r=this.bboxForPart(o.bbox,i);return e?(this.contentBBox=r,e=!1):this.contentBBox=this.contentBBox.union(r),{path:o,startPoint:o.startPoint,commands:o.parts,style:i}}))}getPath(){let t=null;for(const e of this.parts)t?t=t.union(e.path):t??=e.path;return t??i.Path.empty}description(t){return t.stroke}createClone(){return new c(this.parts)}serializeToJSON(){return this.parts.map((t=>({style:(0,r.styleToJSON)(t.style),path:t.path.serialize()})))}static deserializeFromJSON(t){if("string"==typeof t&&(t=JSON.parse(t)),"object"!=typeof t||"number"!=typeof t.length)throw new Error(`${t} is missing required field, parts, or parts is of the wrong type.`);const e=t.map((t=>{const e=(0,r.styleFromJSON)(t.style);return(0,l.pathToRenderable)(i.Path.fromString(t.path),e)}));return new c(e)}}e.default=c,s.default.registerComponent("stroke",c.deserializeFromJSON)},3167:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTransformMode=void 0;const i=n(5097),r=n(2788),s=o(n(2655)),a=n(739),l="text";var c;!function(t){t[t.ABSOLUTE_XY=0]="ABSOLUTE_XY",t[t.RELATIVE_XY=1]="RELATIVE_XY",t[t.RELATIVE_X_ABSOLUTE_Y=2]="RELATIVE_X_ABSOLUTE_Y",t[t.RELATIVE_Y_ABSOLUTE_X=3]="RELATIVE_Y_ABSOLUTE_X"}(c||(e.TextTransformMode=c={}));class d extends s.default{constructor(t,e,n,o=c.ABSOLUTE_XY){super(l),this.textObjects=t,this.transform=e,this.style=n,this.transformMode=o,this.isRestylableComponent=!0,this.recomputeBBox();!t.some((t=>"string"==typeof t))&&t.length>0&&(this.style=t[0].getTextStyle())}static applyTextStyles(t,e){const n=e.fontFamily.match(/\s/)?e.fontFamily.replace(/["]/g,'\\"'):e.fontFamily;t.font=[e.fontStyle??"",e.fontWeight??"",(e.size??12)+"px",`${n}`].join(" "),t.textAlign="left"}static estimateTextDimens(t,e){const n=t.length*e.size,o=e.size;return new i.Rect2(0,2*-o/3,n,o)}static getTextMetrics(t,e){if(d.textMeasuringCtx??=document.createElement("canvas").getContext("2d")??null,!d.textMeasuringCtx)return null;const n=d.textMeasuringCtx;return d.applyTextStyles(n,e),n.measureText(t)}static getTextDimens(t,e){const n=this.getTextMetrics(t,e);if(!n)return this.estimateTextDimens(t,e);const o=-n.actualBoundingBoxAscent,r=n.actualBoundingBoxAscent+n.actualBoundingBoxDescent;return new i.Rect2(0,o,n.width,r)}static getFontHeight(t){return t.size}computeUntransformedBBoxOfPart(t){return"string"==typeof t?d.getTextDimens(t,this.style):t.contentBBox}recomputeBBox(){let t=null;const e=new d.TextCursor(this.transform,this.style);for(const n of this.textObjects){const o=e.update(n),i=this.computeUntransformedBBoxOfPart(n).transformedBoundingBox(o);t??=i,t=t.union(i)}this.contentBBox=t??i.Rect2.empty}renderInternal(t){const e=new d.TextCursor(this.transform,this.style);for(const n of this.textObjects){const o=e.update(n);"string"==typeof n?t.drawText(n,o,this.style):(t.pushTransform(o),n.renderInternal(t),t.popTransform())}}render(t,e){t.startObject(this.contentBBox),this.renderInternal(t),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(t){const e=new d.TextCursor(this.transform,this.style);for(const n of this.textObjects){const o=e.update(n).inverse(),i=t.transformedBy(o);if("string"==typeof n){if(d.getTextDimens(n,this.style).getEdges().some((t=>null!==i.intersection(t))))return!0}else if(n.intersects(i))return!0}return!1}getStyle(){return{color:this.style.renderingStyle.fill,textStyle:{...this.style,renderingStyle:{...this.style.renderingStyle}}}}updateStyle(t){return(0,a.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){if(t.textStyle)this.style=(0,r.cloneTextStyle)(t.textStyle);else{if(!t.color)return;this.style={...this.style,renderingStyle:{...this.style.renderingStyle,fill:t.color}}}for(const n of this.textObjects)n instanceof d&&n.forceStyle(t,e);e&&(e.image.queueRerenderOf(this),e.queueRerender())}getTextStyle(){return(0,r.cloneTextStyle)(this.style)}getBaselinePos(){return this.transform.transformVec2(i.Vec2.zero)}getTransform(){return this.transform}applyTransformation(t){this.transform=t.rightMul(this.transform),this.recomputeBBox()}createClone(){const t=this.textObjects.map((t=>"string"==typeof t?t:t.createClone()));return new d(t,this.transform,this.style)}getText(){const t=[];for(const e of this.textObjects)"string"==typeof e?t.push(e):t.push(e.getText());return t.join("\n")}description(t){return t.text(this.getText())}serializeToJSON(){const t=(0,r.textStyleToJSON)(this.style);return{textObjects:this.textObjects.map((t=>"string"==typeof t?{text:t}:{json:t.serializeToJSON()})),transform:this.transform.toArray(),style:t}}static deserializeFromString(t){"string"==typeof t&&(t=JSON.parse(t));const e=(0,r.textStyleFromJSON)(t.style),n=t.textObjects.map((t=>null!==(t.text??null)?t.text:d.deserializeFromString(t.json)));if(t.transform=t.transform.filter((t=>"number"==typeof t)),9!==t.transform.length)throw new Error(`Unable to deserialize transform, ${t.transform}.`);const o=t.transform,s=new i.Mat33(...o);return new d(n,s,e)}static fromLines(t,e,n){let o=null;const r=[],s=Math.round(this.getFontHeight(n));let a=i.Vec2.zero;for(const e of t){o&&(a=a.plus(i.Vec2.unitY.times(s)));const t=new d([e],i.Mat33.translation(a),n);r.push(t),o=t}return new d(r,e,n)}}d.textMeasuringCtx=null,d.TextCursor=class{constructor(t=i.Mat33.identity,e){this.parentTransform=t,this.parentStyle=e,this.transform=i.Mat33.identity}update(t){let e,n=i.Mat33.identity,o=i.Mat33.identity;"string"==typeof t?e=d.getTextDimens(t,this.parentStyle):(o=t.transform,e=t.getBBox());const r="string"==typeof t?c.RELATIVE_XY:t.transformMode;if(r===c.RELATIVE_XY)n=this.transform.rightMul(n);else if(r===c.RELATIVE_X_ABSOLUTE_Y||r===c.RELATIVE_Y_ABSOLUTE_X){n=this.transform.mapEntries(((t,[e,n])=>{if(r===c.RELATIVE_X_ABSOLUTE_Y)return 1===e&&2===n?0:t;if(r===c.RELATIVE_Y_ABSOLUTE_X)return 0===e&&2===n?0:t;throw new Error("Unreachable")})).rightMul(n)}const s=i.Mat33.translation(i.Vec2.of(e.width,0));return this.transform=n.rightMul(o).rightMul(s),this.parentTransform.rightMul(n)}},e.default=d,s.default.registerComponent(l,(t=>d.deserializeFromString(t)))},9025:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=s(n(2001)),c=r(n(2655)),d="unknown-svg-object";class h extends c.default{constructor(t){super(d),this.svgObject=t,this.contentBBox=a.Rect2.of(t.getBoundingClientRect())}render(t,e){t instanceof l.default&&(t.startObject(this.contentBBox),t.drawSVGElem(this.svgObject),t.endObject(this.getLoadSaveData()))}intersects(t){return this.contentBBox.getEdges().some((e=>null!==e.intersection(t)))}applyTransformation(t){}isSelectable(){return!1}getSizingMode(){return c.ComponentSizingMode.Anywhere}createClone(){return new h(this.svgObject.cloneNode(!0))}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify({html:this.svgObject.outerHTML})}}e.default=h,c.default.registerComponent(d,null)},9274:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeArrowBuilder=void 0;const i=n(5097),r=o(n(9964));e.makeArrowBuilder=(t,e)=>new s(t,e);class s{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getLineWidth(){return Math.max(this.endPoint.width,this.startPoint.width)}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),o=e.minus(t).length(),s=Math.min(this.getLineWidth(),o/2),a=this.startPoint.width/2,l=this.endPoint.width/2,c=e.minus(n.times(s)),d=n.orthog(),h=d.times(a),u=d.times(l),p=new i.Path(c.minus(u),[{kind:i.PathCommandType.LineTo,point:t.minus(h)},{kind:i.PathCommandType.LineTo,point:t.plus(h)},{kind:i.PathCommandType.LineTo,point:c.plus(u)},{kind:i.PathCommandType.LineTo,point:c.plus(d.times(s).plus(u))},{kind:i.PathCommandType.LineTo,point:e.plus(n.times(l))},{kind:i.PathCommandType.LineTo,point:c.plus(d.times(-s).minus(u))},{kind:i.PathCommandType.LineTo,point:c.minus(u)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new r.default([{startPoint:p.startPoint,commands:p.parts,style:{fill:this.startPoint.color}}])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=s},7973:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedCircleBuilder=void 0;const i=n(5097),r=n(7444),s=o(n(5566)),a=o(n(9964));e.makeOutlinedCircleBuilder=(t,e)=>new l(t,e);class l{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=[],e=2*Math.PI/6,n=s.default.roundPoint(this.endPoint.width,5/this.viewport.getScaleFactor()),o=this.startPoint.pos.lerp(this.endPoint.pos,.5),l=this.endPoint.pos.minus(o).length()-n/2,c=o.plus(i.Vec2.of(l,0));for(let n=e;n<=2*Math.PI;n+=e){const r=i.Vec2.of(l*Math.cos(n),-l*Math.sin(n)).plus(o),s=1.141,a=i.Vec2.of(Math.cos(n-e/2),-Math.sin(n-e/2)).times(l*s).plus(o);t.push({kind:i.PathCommandType.QuadraticBezierTo,controlPoint:a,endPoint:r})}t.push({kind:i.PathCommandType.LineTo,point:c});const d=new i.Path(c,t).mapPoints((t=>this.viewport.roundPoint(t)));return new a.default([(0,r.pathToRenderable)(d,{fill:i.Color4.transparent,stroke:{width:n,color:this.endPoint.color}})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}},6951:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeFreehandLineBuilder=void 0;const i=n(5097),r=o(n(9964)),s=o(n(5566)),a=n(1003);e.makeFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),o=e.getSizeOfPixelOnCanvas();return new l(t,o,n,e)};class l{constructor(t,e,n,o){this.startPoint=t,this.minFitAllowed=e,this.viewport=o,this.isFirstSegment=!0,this.parts=[],this.widthAverageNumSamples=1,this.curveFitter=new a.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.averageWidth=t.width,this.bbox=new i.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:i.Color4.transparent,stroke:{color:this.startPoint.color,width:this.roundDistance(this.averageWidth)}}}previewCurrentPath(){const t=[...this.parts.slice(),...this.curveToPathCommands(this.curveFitter.preview())];return{startPoint:this.startPoint.pos,commands:t,style:this.getRenderingStyle()}}previewFullPath(){const t=this.previewCurrentPath();return t?[t]:null}previewStroke(){const t=this.previewFullPath();return t?new r.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.previewStroke()}getMinFit(){let t=Math.min(this.minFitAllowed,this.averageWidth/3);return t<1e-10&&(t=this.minFitAllowed),t}roundPoint(t){const e=this.getMinFit();return s.default.roundPoint(t,e)}roundDistance(t){const e=this.getMinFit();return s.default.roundPoint(t,e)}curveToPathCommands(t){if(!t){if(!this.isFirstSegment)return[];const t=s.default.roundPoint(this.averageWidth/10,Math.min(this.minFitAllowed,this.averageWidth/10)),e=this.roundPoint(this.startPoint.pos);return[{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(t,t)),endPoint:e.plus(i.Vec2.of(0,t))},{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(-t,t)),endPoint:e.plus(i.Vec2.of(-t,0))},{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(-t,-t)),endPoint:e.plus(i.Vec2.of(0,-t))},{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(t,-t)),endPoint:e.plus(i.Vec2.of(t,0))}]}const e=[];return this.isFirstSegment&&e.push({kind:i.PathCommandType.MoveTo,point:this.roundPoint(t.startPoint)}),e.push({kind:i.PathCommandType.QuadraticBezierTo,controlPoint:this.roundPoint(t.controlPoint),endPoint:this.roundPoint(t.endPoint)}),e}addCurve(t){const e=this.curveToPathCommands(t);this.parts.push(...e),this.isFirstSegment&&(this.isFirstSegment=!1)}addPoint(t){this.curveFitter.addPoint(t),this.widthAverageNumSamples++,this.averageWidth=this.averageWidth*(this.widthAverageNumSamples-1)/this.widthAverageNumSamples+t.width/this.widthAverageNumSamples}}e.default=l},725:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeLineBuilder=void 0;const i=n(5097),r=n(7444),s=o(n(9964));e.makeLineBuilder=(t,e)=>new a(t,e);class a{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),o=this.startPoint.width/2,a=this.endPoint.width/2,l=n.orthog(),c=l.times(o),d=l.times(a),h=t.minus(c),u=new i.Path(h,[{kind:i.PathCommandType.LineTo,point:t.plus(c)},{kind:i.PathCommandType.LineTo,point:e.plus(d)},{kind:i.PathCommandType.LineTo,point:e.minus(d)},{kind:i.PathCommandType.LineTo,point:t.minus(c)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new s.default([(0,r.pathToRenderable)(u,{fill:this.startPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=a},823:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makePressureSensitiveFreehandLineBuilder=void 0;const i=n(4232),r=n(5097),s=o(n(9964)),a=o(n(5566)),l=n(1003);e.makePressureSensitiveFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),o=e.getSizeOfPixelOnCanvas();return new c(t,o,n,e)};class c{constructor(t,e,n,o){this.startPoint=t,this.minFitAllowed=e,this.viewport=o,this.isFirstSegment=!0,this.pathStartConnector=null,this.mostRecentConnector=null,this.lastUpperBezier=null,this.lastLowerBezier=null,this.parts=[],this.upperSegments=[],this.lowerSegments=[],this.curveFitter=new l.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.curveStartWidth=t.width,this.bbox=new r.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:this.startPoint.color??null}}previewCurrentPath(){const t=this.upperSegments.slice(),e=this.lowerSegments.slice();let n,o;const i=this.curveFitter.preview();if(i){const{upperCurveCommand:r,lowerToUpperConnector:s,upperToLowerConnector:a,lowerCurveCommand:l}=this.segmentToPath(i);t.push(r),e.push(l),n=s,o=this.pathStartConnector??a}else{if(null===this.mostRecentConnector||null===this.pathStartConnector)return null;n=this.mostRecentConnector,o=this.pathStartConnector}let s;const a=e[e.length-1];return s=a.kind===r.PathCommandType.LineTo||a.kind===r.PathCommandType.MoveTo?a.point:a.endPoint,{startPoint:s,commands:[n,...t.reverse(),o,...e],style:this.getRenderingStyle()}}previewFullPath(){const t=this.previewCurrentPath();return t?[...this.parts,t]:null}previewStroke(){const t=this.previewFullPath();return t?new s.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.isFirstSegment&&this.addCurve(null),this.previewStroke()}roundPoint(t){let e=Math.min(this.minFitAllowed,this.curveStartWidth/3);return e<1e-10&&(e=this.minFitAllowed),a.default.roundPoint(t,e)}shouldStartNewSegment(t,e){if(!this.lastLowerBezier||!this.lastUpperBezier)return!1;const n=(t,e)=>{const n=t.intersects(e);if(!n||0===n.length)return null;const o=n[0],i=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(o);if(!i)throw new Error(`Incorrect format returned by .intersects: ${n} should be array of "number/number"!`);const s=parseFloat(i[1]);return r.Vec2.ofXY(t.get(s))},o=t=>r.Vec2.ofXY(t.points[2]).minus(r.Vec2.ofXY(t.points[1])).normalized(),i=t=>r.Vec2.ofXY(t.points[1]).minus(r.Vec2.ofXY(t.points[0])).normalized();if(i(e).dot(o(this.lastUpperBezier))<.3||i(t).dot(o(this.lastLowerBezier))<.3||i(e).dot(o(e))<0||i(t).dot(o(t))<0)return!0;const s=n(t,this.lastUpperBezier),a=n(e,this.lastLowerBezier);return!(!s&&!a)}addCurve(t){if(!t){if(!this.isFirstSegment)return;const t=a.default.roundPoint(this.startPoint.width/2.2,Math.min(this.minFitAllowed,this.startPoint.width/4)),e=this.roundPoint(this.startPoint.pos),n=this.startPoint.pos.plus(r.Vec2.of(t,0));return this.lowerSegments.push({kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,t)),endPoint:e.plus(r.Vec2.of(0,t))},{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,t)),endPoint:e.plus(r.Vec2.of(-t,0))},{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,-t)),endPoint:e.plus(r.Vec2.of(0,-t))},{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,-t)),endPoint:e.plus(r.Vec2.of(t,0))}),this.pathStartConnector={kind:r.PathCommandType.LineTo,point:n},void(this.mostRecentConnector=this.pathStartConnector)}const{upperCurveCommand:e,lowerToUpperConnector:n,upperToLowerConnector:o,lowerCurveCommand:i,lowerCurve:s,upperCurve:l}=this.segmentToPath(t),c=this.shouldStartNewSegment(s,l);if(c){const t=this.previewCurrentPath();t&&(this.parts.push(t),this.upperSegments=[],this.lowerSegments=[])}(this.isFirstSegment||c)&&(this.pathStartConnector=o,this.isFirstSegment=!1),this.mostRecentConnector=n,this.lowerSegments.push(i),this.upperSegments.push(e),this.lastLowerBezier=s,this.lastUpperBezier=l,this.curveStartWidth=t.startWidth}segmentToPath(t){const e=new i.Bezier(t.startPoint.xy,t.controlPoint.xy,t.endPoint.xy);let n=r.Vec2.ofXY(e.normal(0)).normalized(),o=r.Vec2.ofXY(e.normal(1)).normalized();n=n.times(t.startWidth/2),o=o.times(t.endWidth/2),isFinite(n.magnitude())||(console.error("Warning: startVec is NaN or ∞",n,o,t),n=o);const s=t.startPoint,a=t.endPoint,l=t.controlPoint;let c=e.project(l.xy).t;c||(c=s.minus(l).magnitudeSquared()<a.minus(l).magnitudeSquared()?.1:.9);const d=c,h=r.Vec2.ofXY(e.normal(d)).normalized().times(t.startWidth/2*d+t.endWidth/2*(1-d)),u=this.roundPoint(s.plus(n)),p=this.roundPoint(l.plus(h)),f=this.roundPoint(a.plus(o)),m=this.roundPoint(l.minus(h)),g=this.roundPoint(a.minus(o)),b=this.roundPoint(s.minus(n)),y={kind:r.PathCommandType.QuadraticBezierTo,controlPoint:p,endPoint:f},v={kind:r.PathCommandType.LineTo,point:u},w={kind:r.PathCommandType.LineTo,point:g};return{upperCurveCommand:{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:m,endPoint:b},upperToLowerConnector:v,lowerToUpperConnector:w,lowerCurveCommand:y,upperCurve:new i.Bezier(g,m,b),lowerCurve:new i.Bezier(u,p,f)}}addPoint(t){this.curveFitter.addPoint(t)}}e.default=c},4666:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedRectangleBuilder=e.makeFilledRectangleBuilder=void 0;const i=n(5097),r=n(7444),s=o(n(9964));e.makeFilledRectangleBuilder=(t,e)=>new a(t,!0,e);e.makeOutlinedRectangleBuilder=(t,e)=>new a(t,!1,e);class a{constructor(t,e,n){this.startPoint=t,this.filled=e,this.viewport=n,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.viewport.getRotationAngle(),e=i.Mat33.zRotation(-t),n=e.inverse().transformVec2(this.startPoint.pos),o=e.inverse().transformVec2(this.endPoint.pos),a=i.Rect2.fromCorners(n,o),l=i.Path.fromRect(a,this.filled?null:this.endPoint.width).transformedBy(e).mapPoints((t=>this.viewport.roundPoint(t)));return new s.default([(0,r.pathToRenderable)(l,{fill:this.endPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=a},1024:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1576:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ImageComponent=e.BackgroundComponentBackgroundType=e.BackgroundComponent=e.StrokeComponent=e.Text=e.TextComponent=e.isRestylableComponent=e.createRestyleComponentCommand=e.Stroke=e.AbstractComponent=e.StrokeSmoother=e.makeOutlinedCircleBuilder=e.makePressureSensitiveFreehandLineBuilder=e.makeFreehandLineBuilder=void 0,r(n(1024),e);var l=n(6951);Object.defineProperty(e,"makeFreehandLineBuilder",{enumerable:!0,get:function(){return l.makeFreehandLineBuilder}});var c=n(823);Object.defineProperty(e,"makePressureSensitiveFreehandLineBuilder",{enumerable:!0,get:function(){return c.makePressureSensitiveFreehandLineBuilder}});var d=n(7973);Object.defineProperty(e,"makeOutlinedCircleBuilder",{enumerable:!0,get:function(){return d.makeOutlinedCircleBuilder}});var h=n(1003);Object.defineProperty(e,"StrokeSmoother",{enumerable:!0,get:function(){return a(h).default}}),r(n(2655),e);var u=n(2655);Object.defineProperty(e,"AbstractComponent",{enumerable:!0,get:function(){return a(u).default}});const p=a(n(9964));e.Stroke=p.default,e.StrokeComponent=p.default;const f=a(n(3167));e.TextComponent=f.default,e.Text=f.default;const m=a(n(7077));e.ImageComponent=m.default;const g=n(739);Object.defineProperty(e,"createRestyleComponentCommand",{enumerable:!0,get:function(){return g.createRestyleComponentCommand}}),Object.defineProperty(e,"isRestylableComponent",{enumerable:!0,get:function(){return g.isRestylableComponent}});const b=s(n(1847));e.BackgroundComponent=b.default,Object.defineProperty(e,"BackgroundComponentBackgroundType",{enumerable:!0,get:function(){return b.BackgroundType}})},7708:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultComponentLocalization=void 0,e.defaultComponentLocalization={unlabeledImageNode:"Unlabeled image node",stroke:"Stroke",svgObject:"SVG Object",emptyBackground:"Empty background",gridBackground:"Grid background",filledBackgroundWithColor:t=>`Filled background (${t})`,text:t=>`Text object: ${t}`,imageNode:t=>`Image: ${t}`,restyledElement:t=>`Restyled ${t}`}},1003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StrokeSmoother=void 0;const o=n(5097);class i{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.maxFitAllowed=n,this.onCurveAdded=i,this.isFirstSegment=!0,this.lastExitingVec=null,this.currentCurve=null,this.lastPoint=this.startPoint,this.buffer=[this.startPoint.pos],this.momentum=o.Vec2.zero,this.currentCurve=null,this.curveStartWidth=t.width,this.bbox=new o.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}preview(){return this.currentCurve?this.currentSegmentToPath():null}approxCurrentCurveLength(){if(!this.currentCurve)return 0;const t=this.currentCurve.p0,e=this.currentCurve.p1,n=this.currentCurve.p2;return t.minus(e).length()+n.minus(e).length()}finalizeCurrentCurve(){if(!this.currentCurve)return;this.onCurveAdded(this.currentSegmentToPath());const t=this.buffer[this.buffer.length-1];this.lastExitingVec=this.currentCurve.p2.minus(this.currentCurve.p1),console.assert(0!==this.lastExitingVec.magnitude(),"lastExitingVec has zero length!"),this.buffer=[this.buffer[this.buffer.length-2],t],this.currentCurve=null,this.isFirstSegment=!1}currentSegmentToPath(){if(null==this.currentCurve)throw new Error("Invalid State: currentCurve is null!");const t=this.currentCurve.normal(0).normalized();if(!isFinite(t.magnitude()))throw new Error(`startVec(${t}) is NaN or ∞`);const e=this.currentCurve.at(0),n=this.currentCurve.at(1);return{startPoint:e,controlPoint:this.currentCurve.p1,endPoint:n,startWidth:this.curveStartWidth,endWidth:this.curveEndWidth}}computeExitingVec(){return this.momentum.normalized().times(this.lastPoint.width/2)}addPoint(t){if(this.lastPoint){const e=1e-10,n=t.time-this.lastPoint.time;if(t.pos.eq(this.lastPoint.pos,e)||0===n)return;if(isNaN(t.pos.magnitude()))return void console.warn("Discarding NaN point.",t);const o=Math.min(this.lastPoint.width,t.width)/3;if(this.startPoint.pos.minus(t.pos).magnitude()<o&&this.isFirstSegment)return;const i=n/1e3,r=t.pos.minus(this.lastPoint.pos).times(1/i);this.momentum=r}const e=this.lastPoint??t;this.lastPoint=t,this.buffer.push(t.pos);const n=t.width,i=this.curveEndWidth;if(this.curveEndWidth=n,this.bbox=this.bbox.grownToPoint(t.pos,n),null===this.currentCurve){const r=e.pos,s=e.pos.plus(this.lastExitingVec??o.Vec2.unitX),a=t.pos;this.currentCurve=new o.QuadraticBezier(r,s,a),console.assert(!isNaN(r.magnitude())&&!isNaN(s.magnitude())&&!isNaN(a.magnitude()),"Expected !NaN"),this.isFirstSegment?this.curveStartWidth=(this.curveStartWidth+n)/2:this.curveStartWidth=i}let r=this.lastExitingVec;if(!r){let t=Math.ceil(this.buffer.length/2);(0===t||t>=this.buffer.length)&&(t=this.buffer.length-1),r=this.buffer[t].minus(this.buffer[0])}let s=this.computeExitingVec();const a=this.buffer[0],l=t.pos,c=l.minus(a).magnitude(),d=2.4*c;if(0===d||0===s.magnitude()||!isFinite(s.magnitude()))return;console.assert(isFinite(r.magnitude()),"Pre-normalized enteringVec has NaN or ∞ magnitude!"),r=r.normalized(),s=s.normalized(),console.assert(isFinite(r.magnitude()),"Normalized enteringVec has NaN or ∞ magnitude!");const h=new o.LineSegment2(a,a.plus(r.times(d))),u=new o.LineSegment2(l.minus(s.times(d)),l).intersection(h);let p=null;u&&(p=u.point),(!p||a.eq(p)||l.eq(p))&&(p=a.plus(r.times(c/4))),console.assert(!a.eq(p,1e-11),"Start and control points are equal!"),console.assert(!p.eq(l,1e-11),"Control and end points are equal!");const f=this.currentCurve;this.currentCurve=new o.QuadraticBezier(a,p,l),isNaN(this.currentCurve.normal(0).magnitude())&&(console.error("NaN normal at 0. Curve:",this.currentCurve),this.currentCurve=f);const m=t=>{const e=Math.min(Math.max(Math.min(this.curveStartWidth,this.curveEndWidth)/4,this.minFitAllowed),this.maxFitAllowed),n=e;let o=0;for(const i of this.buffer){let r=t.approximateDistance(i);if(r>e&&(r=t.distance(i),o+=Math.max(0,r-e),o>n))return!1}return!0};return this.buffer.length>3&&this.approxCurrentCurveLength()>this.curveStartWidth/2&&!m(this.currentCurve)?(this.currentCurve=f,this.curveEndWidth=i,this.lastPoint=e,void this.finalizeCurrentCurve()):void 0}}e.StrokeSmoother=i,e.default=i},2944:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{if(0===e.length)return null;const n=e[0].description(t);for(const o of e)if(o.description(t)!==n)return null;return n}},9784:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=document.createElement("div"),{remove:o}=t.createHTMLOverlay(n);n.classList.add("dialog-container","about-dialog-container");const i=document.createElement("dialog"),r=document.createElement("h1");r.innerText=t.localization.about,r.setAttribute("autofocus","true");const s=document.createElement("button");s.innerText=t.localization.closeDialog,s.classList.add("close-button"),s.onclick=()=>o(),n.onclick=t=>{t.target===n&&o()};const a=document.createElement("div");a.classList.add("about-entry-container"),a.onwheel=t=>t.stopPropagation();for(const t of e){const e=document.createElement(t.minimized?"details":"div");e.classList.add("about-entry");const n=document.createElement(t.minimized?"summary":"h2");if("string"==typeof t.heading)n.innerText=t.heading;else{const e=document.createElement("a");e.href=t.heading.href.replace(/^javascript:/i,""),e.text=t.heading.text,n.appendChild(e)}if(e.appendChild(n),t.text){const n=document.createElement("div");n.innerText=t.text,e.appendChild(n)}a.appendChild(e)}return i.replaceChildren(r,a,s),n.replaceChildren(i),i.show(),{close:()=>{o()}}}},7520:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.isPointerEvt=e.keyPressEventFromHTMLEvent=e.keyUpEventFromHTMLEvent=e.InputEvtType=void 0,function(t){t[t.PointerDownEvt=0]="PointerDownEvt",t[t.PointerMoveEvt=1]="PointerMoveEvt",t[t.PointerUpEvt=2]="PointerUpEvt",t[t.GestureCancelEvt=3]="GestureCancelEvt",t[t.WheelEvt=4]="WheelEvt",t[t.KeyPressEvent=5]="KeyPressEvent",t[t.KeyUpEvent=6]="KeyUpEvent",t[t.CopyEvent=7]="CopyEvent",t[t.PasteEvent=8]="PasteEvent"}(n||(e.InputEvtType=n={}));const o=(t,e)=>({kind:t,key:e.key,code:e.code,ctrlKey:e.ctrlKey||e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey});e.keyUpEventFromHTMLEvent=t=>o(n.KeyUpEvent,t);e.keyPressEventFromHTMLEvent=t=>o(n.KeyPressEvent,t);e.isPointerEvt=t=>t.kind===n.PointerDownEvt||t.kind===n.PointerMoveEvt||t.kind===n.PointerUpEvt},6209:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.HTMLToolbar=e.AbstractToolbar=e.Editor=e.__js_draw__version=e.UndoRedoHistory=e.PointerDevice=e.Pointer=e.EventDispatcher=e.Viewport=e.SVGLoader=e.matchingLocalizationTable=e.getLocalizationTable=e.EditorImage=void 0;const s=r(n(5146));e.Editor=s.default;var a=n(7551);Object.defineProperty(e,"EditorImage",{enumerable:!0,get:function(){return r(a).default}}),i(n(3173),e),i(n(7520),e);var l=n(1906);Object.defineProperty(e,"getLocalizationTable",{enumerable:!0,get:function(){return r(l).default}}),Object.defineProperty(e,"matchingLocalizationTable",{enumerable:!0,get:function(){return l.matchingLocalizationTable}}),i(n(8167),e);var c=n(1697);Object.defineProperty(e,"SVGLoader",{enumerable:!0,get:function(){return r(c).default}});var d=n(5566);Object.defineProperty(e,"Viewport",{enumerable:!0,get:function(){return r(d).default}}),i(n(5097),e),i(n(1576),e),i(n(7601),e),i(n(1709),e),i(n(2994),e),i(n(2670),e),i(n(1797),e),i(n(6843),e);var h=n(1785);Object.defineProperty(e,"EventDispatcher",{enumerable:!0,get:function(){return r(h).default}});var u=n(4318);Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return r(u).default}}),Object.defineProperty(e,"PointerDevice",{enumerable:!0,get:function(){return u.PointerDevice}});var p=n(5155);Object.defineProperty(e,"UndoRedoHistory",{enumerable:!0,get:function(){return r(p).default}}),i(n(3662),e);var f=n(2674);Object.defineProperty(e,"__js_draw__version",{enumerable:!0,get:function(){return r(f).default}});const m=r(n(2339));e.AbstractToolbar=m.default,e.HTMLToolbar=m.default,e.default=s.default},8167:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultEditorLocalization=void 0;const o=n(6985),i=n(7708),r=n(49),s=n(9746),a=n(3376);e.defaultEditorLocalization={...s.defaultToolbarLocalization,...a.defaultToolLocalization,...o.defaultCommandLocalization,...i.defaultComponentLocalization,...r.defaultTextRendererLocalization,accessibilityInputInstructions:['Press "t" to read the contents of the viewport as text.',"Use the arrow keys to move the viewport, click and drag to draw strokes.",'Press "w" to zoom in and "s" to zoom out.'].join(" "),loading:t=>`Loading ${t}%...`,imageEditor:"Image Editor",doneLoading:"Done loading",undoAnnouncement:t=>`Undid ${t}`,redoAnnouncement:t=>`Redid ${t}`}},4540:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={...n(8167).defaultEditorLocalization,pen:"Stift",eraser:"Radierer",select:"Auswahl",handTool:"Verschieben",zoom:"Vergrößerung",image:"Bild",inputAltText:"Alt-Text: ",chooseFile:"Wähle Datei: ",submit:"Absenden",cancel:"Abbrechen",resetView:"Ansicht zurücksetzen",thicknessLabel:"Dicke: ",colorLabel:"Farbe: ",fontLabel:"Schriftart: ",textSize:"Größe: ",resizeImageToSelection:"Bildgröße an Auswahl anpassen",deleteSelection:"Auswahl löschen",duplicateSelection:"Auswahl duplizieren",undo:"Rückgängig",redo:"Wiederholen",pickColorFromScreen:"Farbe von Bildschirm auswählen",clickToPickColorAnnouncement:"Klicke auf den Bildschirm, um eine Farbe auszuwählen",selectionToolKeyboardShortcuts:"Auswahl-Werkzeug: Verwende die Pfeiltasten, um ausgewählte Elemente zu verschieben und ‚i‘ und ‚o‘, um ihre Größe zu ändern.",touchPanning:"Ansicht mit Touchscreen verschieben",anyDevicePanning:"Ansicht mit jedem Eingabegerät verschieben",selectPenTip:"Objekt-Typ: ",roundedTipPen:"Freihand",flatTipPen:"Stift (druckempfindlich)",arrowPen:"Pfeil",linePen:"Linie",outlinedRectanglePen:"Umrissenes Rechteck",filledRectanglePen:"Ausgefülltes Rechteck",lockRotation:"Sperre Rotation",paste:"Einfügen",dropdownShown:t=>`Dropdown-Menü für ${t} angezeigt`,dropdownHidden:t=>`Dropdown-Menü für ${t} versteckt`,zoomLevel:t=>`Vergößerung: ${t}%`,colorChangedAnnouncement:t=>`Farbe zu ${t} geändert`,imageSize:(t,e)=>`Bild-Größe: ${t} ${e}`,imageLoadError:t=>`Fehler beim Laden des Bildes: ${t}`,errorImageHasZeroSize:"Fehler: Bild hat Größe Null",penTool:t=>`Stift ${t}`,selectionTool:"Auswahl",eraserTool:"Radiergummi",touchPanTool:"Ansicht mit Touchscreen verschieben",twoFingerPanZoomTool:"Ansicht verschieben und vergrößern",undoRedoTool:"Rückgängig/Wiederholen",rightClickDragPanTool:"Rechtsklick-Ziehen",pipetteTool:"Farbe von Bildschirm auswählen",keyboardPanZoom:"Tastaturkürzel zum Verschieben/Vergrößern der Ansicht",textTool:"Text",enterTextToInsert:"Einzufügender Text",changeTool:"Wechsle Werkzeug",pasteHandler:"Copy-Paste-Handler",findLabel:"Finde",toNextMatch:"Nächstes",closeDialog:"Schließen",findDialogShown:"Finde-Dialog angezeigt",findDialogHidden:"Finde-Dialog versteckt",focusedFoundText:(t,e)=>`Sieh Treffer ${t} von ${e} an`,toolEnabledAnnouncement:t=>`${t} aktiviert`,toolDisabledAnnouncement:t=>`${t} deaktiviert`,updatedViewport:"Transformierte Ansicht",transformedElements:t=>`${t} Element${1===t?"":"e"} transformiert`,resizeOutputCommand:t=>`Bildgröße auf ${t.w}x${t.h} geändert`,addElementAction:t=>`${t} hinzugefügt`,eraseAction:(t,e)=>`${e} ${t} gelöscht`,duplicateAction:(t,e)=>`${e} ${t} dupliziert`,inverseOf:t=>`${t} umgekehrt`,elements:"Elemente",erasedNoElements:"Nichts entfernt",duplicatedNoElements:"Nichts dupliziert",rotatedBy:t=>`${Math.abs(t)} Grad ${t<0?"im Uhrzeigersinn":"gegen den Uhrzeigersinn"} gedreht`,movedLeft:"Nacht links bewegt",movedUp:"Nacht oben bewegt",movedDown:"Nacht unten bewegt",movedRight:"Nacht rechts bewegt",zoomedOut:"Ansicht verkleinert",zoomedIn:"Ansicht vergrößert",selectedElements:t=>`${t} Element${1===t?"":"e"} ausgewählt`,stroke:"Strich",svgObject:"SVG-Objekt",text:t=>`Text-Objekt: ${t}`,pathNodeCount:t=>`Es gibt ${t} sichtbare Pfad-Objekte.`,textNodeCount:t=>`Es gibt ${t} sichtbare Text-Knotenpunkte.`,textNode:t=>`Text: ${t}`,imageNodeCount:t=>`Es gibt ${t} sichtbare Bild-Knoten.`,imageNode:t=>`Bild: ${t}`,unlabeledImageNode:"Bild ohne Label",rerenderAsText:"Als Text darstellen",accessibilityInputInstructions:"Drücke ‚t‘, um den Inhalt des Ansichtsfensters als Text zu lesen. Verwende die Pfeiltasten, um die Ansicht zu verschieben, und klicke und ziehe, um Striche zu zeichnen. Drücke ‚w‘ zum Vergrößern und ‚s‘ zum Verkleinern der Ansicht.",loading:t=>`Laden ${t}%...`,doneLoading:"Laden fertig",imageEditor:"Bild-Editor",undoAnnouncement:t=>`${t} rückgängig gemacht`,redoAnnouncement:t=>`${t} wiederholt`,reformatSelection:"Formatiere Auswahl",documentProperties:"Seite",backgroundColor:"Hintergrundfarbe: ",imageWidthOption:"Breite: ",imageHeightOption:"Höhe: ",useGridOption:"Gitter: ",toggleOverflow:"Mehr",selectAllTool:"Alle auswählen",soundExplorer:"Klangbasierte Bilderkundung",disableAccessibilityExploreTool:"Deaktiviere klangbasierte Erkundung",enableAccessibilityExploreTool:"Aktiviere klangbasierte Erkundung",copied:(t,e)=>`${t} ${e} kopiert`,pasted:(t,e)=>`${t} ${e} eingefügt`,unionOf:(t,e)=>`Vereinigung: ${e} ${t}`,emptyBackground:"Leerer Hintergrund",filledBackgroundWithColor:t=>`Gefüllter Hintergrund (${t})`,restyledElement:t=>`${t} umgestaltet`};e.default=o},512:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={...n(8167).defaultEditorLocalization};e.default=o},7003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={...n(8167).defaultEditorLocalization,loading:t=>`Cargando: ${t}%...`,imageEditor:"Editor de dibujos",undoAnnouncement:t=>`${t} fue deshecho`,redoAnnouncement:t=>`${t} fue rehecho`,undo:"Deshace",redo:"Rehace",pen:"Lapiz",eraser:"Borrador",select:"Selecciona",thicknessLabel:"Tamaño",colorLabel:"Color",doneLoading:"El cargado terminó",fontLabel:"Fuente: ",anyDevicePanning:"Mover la pantalla con todo dispotivo",touchPanning:"Mover la pantalla con un dedo",touchPanTool:"Instrumento de mover la pantalla con un dedo",outlinedRectanglePen:"Rectángulo con nada más que un borde",filledRectanglePen:"Rectángulo sin borde",linePen:"Línea",arrowPen:"Flecha",roundedTipPen:"Lapiz Redondeado",selectPenTip:"Forma de dibuja",handTool:"Mover",zoom:"Zoom",resetView:"Reiniciar vista",resizeImageToSelection:"Redimensionar la imagen a lo que está seleccionado",deleteSelection:"Borra la selección",duplicateSelection:"Duplica la selección",pickColorFromScreen:"Selecciona un color de la pantalla",clickToPickColorAnnouncement:"Haga un clic en la pantalla para seleccionar un color",dropdownShown:t=>`Menú por ${t} es visible`,dropdownHidden:function(t){return`Menú por ${t} fue ocultado`},colorChangedAnnouncement:function(t){return`Color fue cambiado a ${t}`},keyboardPanZoom:"Mover la pantalla con el teclado",penTool:function(t){return`Lapiz ${t}`},selectionTool:"Selecciona",eraserTool:"Borrador",textTool:"Texto",enterTextToInsert:"Entra texto",textSize:"Tamaño",rerenderAsText:"Redibuja la pantalla al texto",lockRotation:"Bloquea rotación",image:"Imagen",imageSize:(t,e)=>`Tamaño del imagen: ${t} ${e}`,imageLoadError:t=>`Error cargando imagen: ${t}`,toggleOverflow:"Más",documentProperties:"Fondo",imageWidthOption:"Ancho",imageHeightOption:"Alto",backgroundColor:"Color de fondo: "};e.default=o},1906:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.matchingLocalizationTable=e.allLocales=void 0;const i=n(8167),r=o(n(4540)),s=o(n(512)),a=o(n(7003));e.allLocales={de:r.default,en:s.default,es:a.default};const l=t=>{const e=/^(\w+)[_-](\w+)$/.exec(t);return e?e[1]:t};e.matchingLocalizationTable=(t,e,n)=>{let o;for(const n of t){const t=l(n);if(o&&t!==o&&o in e)return e[o];if(n in e)return e[n];o=t}return o&&o in e?e[o]:n};e.default=t=>(t??=navigator.languages,(0,e.matchingLocalizationTable)(t,e.allLocales,i.defaultEditorLocalization))},3012:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RenderingMode=void 0;const i=o(n(7717)),r=n(3173),s=o(n(6377)),a=n(5097),l=o(n(5630)),c=o(n(1263));var d;!function(t){t[t.DummyRenderer=0]="DummyRenderer",t[t.CanvasRenderer=1]="CanvasRenderer"}(d||(e.RenderingMode=d={}));e.default=class{constructor(t,e,n){if(this.editor=t,this.parent=n,this.textRerenderOutput=null,this.getColorAt=t=>null,e===d.CanvasRenderer)this.initializeCanvasRendering();else{if(e!==d.DummyRenderer)throw new Error(`Unknown rendering mode, ${e}!`);this.dryInkRenderer=new s.default(t.viewport),this.wetInkRenderer=new s.default(t.viewport)}this.textRenderer=new c.default(t.viewport,t.localization),this.initializeTextRendering();const o=a.Vec2.of(600,600);this.cache=new l.default({createRenderer:()=>{if(e===d.DummyRenderer)return new s.default(t.viewport);if(e!==d.CanvasRenderer)throw new Error("Unspported rendering mode");const n=document.createElement("canvas");n.width=o.x+1,n.height=o.y+1;const r=n.getContext("2d");return new i.default(r,t.viewport)},isOfCorrectType:t=>this.dryInkRenderer.canRenderFromWithoutDataLoss(t),blockResolution:o,cacheSize:1296e5,maxScale:1.3,minProportionalRenderTimePerCache:80,minProportionalRenderTimeToUseCache:420}),this.editor.notifier.on(r.EditorEventType.DisplayResized,(t=>{if(t.kind!==r.EditorEventType.DisplayResized)throw new Error("Mismatched event.kinds!");this.resizeSurfacesCallback?.()}))}get width(){return this.dryInkRenderer.displaySize().x}get height(){return this.dryInkRenderer.displaySize().y}getCache(){return this.cache}initializeCanvasRendering(){const t=document.createElement("canvas"),e=document.createElement("canvas"),n=t.getContext("2d"),o=e.getContext("2d");this.dryInkRenderer=new i.default(n,this.editor.viewport),this.wetInkRenderer=new i.default(o,this.editor.viewport),t.className="dryInkCanvas",e.className="wetInkCanvas",this.parent&&(this.parent.appendChild(t),this.parent.appendChild(e)),this.resizeSurfacesCallback=()=>{const n=t=>t.clientHeight!==t.height||t.clientWidth!==t.width;(n(t)||n(e))&&(t.width=t.clientWidth,t.height=t.clientHeight,e.width=e.clientWidth,e.height=e.clientHeight,this.editor.notifier.dispatch(r.EditorEventType.DisplayResized,{kind:r.EditorEventType.DisplayResized,newSize:a.Vec2.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{n.drawImage(e,0,0)},this.getColorAt=t=>{const e=n.getImageData(t.x,t.y,1,1),o=e?.data;if(o){return a.Color4.ofRGBA(o[0]/255,o[1]/255,o[2]/255,o[3]/255)}return null}}initializeTextRendering(){const t=document.createElement("div");t.classList.add("textRendererOutputContainer");const e=document.createElement("button");e.classList.add("rerenderButton"),e.innerText=this.editor.localization.rerenderAsText,this.textRerenderOutput=document.createElement("div"),this.textRerenderOutput.setAttribute("aria-live","polite"),e.onclick=()=>{this.rerenderAsText()},t.replaceChildren(e,this.textRerenderOutput),this.editor.createHTMLOverlay(t)}rerenderAsText(){this.textRenderer.clear(),this.editor.image.render(this.textRenderer,this.editor.viewport),this.textRerenderOutput&&(this.textRerenderOutput.innerText=this.textRenderer.getDescription())}startRerender(){return this.resizeSurfacesCallback?.(),this.dryInkRenderer.clear(),this.dryInkRenderer}setDraftMode(t){this.dryInkRenderer.setDraftMode(t)}getDryInkRenderer(){return this.dryInkRenderer}getWetInkRenderer(){return this.wetInkRenderer}flatten(){this.flattenCallback?.()}}},7444:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.visualEquivalent=e.pathToRenderable=e.pathFromRenderable=void 0;const o=n(5097);e.pathFromRenderable=t=>t.path?t.path:new o.Path(t.startPoint,t.commands);e.pathToRenderable=(t,e)=>({startPoint:t.startPoint,style:e,commands:t.parts,path:t});e.visualEquivalent=(t,n)=>{const i=(0,e.pathFromRenderable)(t),r=t.style.stroke?.width??0,s=r>0&&0===t.style.fill.a;if(n.grownBy(r).transformedBoundingBox(o.Mat33.scaling2D(4,n.center)).containsRect(i.bbox.grownBy(r)))return t;const a=[];let l=i.startPoint;for(const t of i.parts){const e=o.Path.computeBBoxForSegment(l,t).grownBy(r);let i;i=t.kind===o.PathCommandType.LineTo||t.kind===o.PathCommandType.MoveTo?t.point:t.endPoint;e.intersects(n)?a.push(t):s||t.kind===o.PathCommandType.MoveTo?a.push({kind:o.PathCommandType.MoveTo,point:i}):a.push({kind:o.PathCommandType.LineTo,point:i}),l=i}return(0,e.pathToRenderable)(new o.Path(i.startPoint,a),t.style)}},2500:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.styleFromJSON=e.styleToJSON=e.stylesEqual=e.cloneStyle=void 0;const o=n(5097);e.cloneStyle=t=>({fill:t.fill,stroke:t.stroke?{...t.stroke}:void 0});e.stylesEqual=(t,e)=>(t===e||t.fill.eq(e.fill)&&null==t.stroke==(null==e.stroke)&&(t.stroke?.color?.eq(e.stroke?.color)??!0)&&t.stroke?.width===e.stroke?.width)??!1;e.styleToJSON=t=>{const e=t.stroke?{color:t.stroke.color.toHexString(),width:t.stroke.width}:void 0;return{fill:t.fill.toHexString(),stroke:e}};e.styleFromJSON=t=>{const e=t.stroke?{color:o.Color4.fromHex(t.stroke.color),width:t.stroke.width}:void 0;return{fill:o.Color4.fromHex(t.fill),stroke:e}}},2788:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.textStyleToJSON=e.textStyleFromJSON=e.cloneTextStyle=void 0;const o=n(2500);e.cloneTextStyle=t=>({...t,renderingStyle:(0,o.cloneStyle)(t.renderingStyle)});e.textStyleFromJSON=t=>{if("string"==typeof t&&(t=JSON.parse(t)),"string"!=typeof t.fontFamily)throw new Error("Serialized textStyle missing string fontFamily attribute!");return{renderingStyle:(0,o.styleFromJSON)(t.renderingStyle),size:t.size,fontWeight:t.fontWeight,fontVariant:t.fontVariant,fontFamily:t.fontFamily}};e.textStyleToJSON=t=>({...t,renderingStyle:(0,o.styleToJSON)(t.renderingStyle)})},4619:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097);e.default=class{constructor(t,e){this.onBeforeDeallocCallback=t,this.cacheState=e,this.allocd=!1,this.allocCount=0,this.renderer=e.props.createRenderer(),this.lastUsedCycle=-1,this.allocd=!0}startRender(){if(this.lastUsedCycle=this.cacheState.currentRenderingCycle,!this.allocd)throw new Error("Only alloc'd canvases can be rendered to");return this.renderer}dealloc(){this.onBeforeDeallocCallback?.(),this.allocd=!1,this.onBeforeDeallocCallback=null,this.lastUsedCycle=0}isAllocd(){return this.allocd}realloc(t){this.allocd&&this.dealloc(),this.allocd=!0,this.onBeforeDeallocCallback=t,this.lastUsedCycle=this.cacheState.currentRenderingCycle,this.allocCount++}getLastUsedCycle(){return this.lastUsedCycle}getTransform(t){return o.Mat33.scaling2D(this.cacheState.props.blockResolution.x/t.size.x).rightMul(o.Mat33.translation(t.topLeft.times(-1)))}setRenderingRegion(t){this.renderer.setTransform(this.getTransform(t))}}},8182:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CacheRecordManager=void 0;const i=o(n(4619));e.CacheRecordManager=class{constructor(t){this.cacheRecords=[],this.maxCanvases=Math.ceil(t.cacheSize/4/t.blockResolution.x/t.blockResolution.y)}setSharedState(t){this.cacheState=t}allocCanvas(t,e){if(this.cacheRecords.length<this.maxCanvases){const n=new i.default(e,this.cacheState);return n.setRenderingRegion(t),this.cacheRecords.push(n),n}{const n=this.getLeastRecentlyUsedRecord();return n.realloc(e),n.setRenderingRegion(t),n}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort(((t,e)=>t.getLastUsedCycle()-e.getLastUsedCycle())),this.cacheRecords[0]}}},5630:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(1310)),s=n(8182);e.default=class{constructor(t){this.recordManager=new s.CacheRecordManager(t),this.sharedState={props:t,currentRenderingCycle:0,recordManager:this.recordManager},this.recordManager.setSharedState(this.sharedState)}render(t,e,n){const o=n.visibleRect;if(this.sharedState.currentRenderingCycle++,!this.sharedState.props.isOfCorrectType(t))return void e.render(t,o);if(!this.rootNode){const t=this.sharedState.props.blockResolution,e=o.topLeft;this.rootNode=new r.default(new i.Rect2(e.x,e.y,t.x,t.y),this.sharedState)}for(;!this.rootNode.region.containsRect(o);)this.rootNode=this.rootNode.generateParent();this.rootNode=this.rootNode.smallestChildContaining(o)??this.rootNode;const s=e.getLeavesIntersectingRegion(n.visibleRect,(e=>t.isTooSmallToRender(e)));let a=0;for(const t of s)a+=t.getContent().getProportionalRenderingTime();a>this.sharedState.props.minProportionalRenderTimeToUseCache?this.rootNode.renderItems(t,[e],n):e.render(t,o)}}},1310:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(7551),i=n(5097),r=!1;class s{constructor(t,e){this.region=t,this.cacheState=e,this.instantiatedChildren=[],this.parent=null,this.cachedRenderer=null,this.renderedIds=[],this.renderedMaxZIndex=null}generateParent(){if(this.parent)return this.parent;const t=i.Rect2.fromCorners(this.region.topLeft.minus(this.region.size),this.region.bottomRight.plus(this.region.size)),e=new s(t,this.cacheState);e.generateChildren();const n=this.region.maxDimension/100,o=(e.instantiatedChildren.length-1)/2;if(!e.instantiatedChildren[o].region.eq(this.region,n))throw console.error(e.instantiatedChildren[o].region,"≠",this.region),new Error("Logic error: [this] is not contained within its parent's center child");return e.instantiatedChildren[o]=this,this.parent=e,e}generateChildren(){if(0===this.instantiatedChildren.length){const t=this.region.divideIntoGrid(3,3);if(0===this.region.size.x||0===this.region.size.y)return void console.warn("Cache element has zero size! Not generating children.");for(const e of t){const t=new s(e,this.cacheState);t.parent=this,this.instantiatedChildren.push(t)}}this.checkRep()}getChildren(){return this.checkRep(),this.generateChildren(),this.instantiatedChildren}smallestChildContaining(t){const e=t.maxDimension>this.region.maxDimension/3;if(!this.region.containsRect(t)||e)return null;for(const e of this.getChildren())if(e.region.containsRect(t))return e.smallestChildContaining(t)??e;return null}renderingWouldBeHighEnoughResolution(t){const e=this.region.w/this.cacheState.props.blockResolution.x;return!(t.getScaleFactor()*e>this.cacheState.props.maxScale)}allChildrenCanRender(t,e){if(0===this.instantiatedChildren.length)return!1;for(const n of this.instantiatedChildren)if(n.region.intersects(t.visibleRect)&&!n.renderingIsUpToDate(this.idsOfIntersecting(e)))return!1;return!0}computeSortedByLeafIds(t){const e=t.slice();return e.sort(((t,e)=>t.getId()-e.getId())),e}idsOfIntersecting(t){const e=[];for(const n of t)n.getBBox().intersects(this.region)&&e.push(n.getId());return e}allRenderedIdsIn(t){if(this.renderedIds.length>t.length)return!1;for(let e=0;e<this.renderedIds.length;e++)if(t[e]!==this.renderedIds[e])return!1;return!0}renderingIsUpToDate(t){return null!==this.cachedRenderer&&t.length===this.renderedIds.length&&this.allRenderedIdsIn(t)}renderItems(t,e,n){if(!n.visibleRect.intersects(this.region)||0===e.length)return;const s=[];for(const t of e){const e=t.getBBox();e.intersects(this.region)&&(e.maxDimension>=this.region.maxDimension?s.push(...t.getChildrenOrSelfIntersectingRegion(this.region)):s.push(t))}if(e=s,!this.cacheState.props.isOfCorrectType(t))return void e.forEach((e=>e.render(t,n.visibleRect)));if(this.renderingWouldBeHighEnoughResolution(n)){const s=t=>t.w/this.region.w<1/this.cacheState.props.blockResolution.x,a=[];for(const t of e)a.push(...t.getLeavesIntersectingRegion(this.region,s));(0,o.sortLeavesByZIndex)(a);const l=this.computeSortedByLeafIds(a);if(0===l.length)return;const c=l.map((t=>t.getId()));let d;if(this.renderingIsUpToDate(c))d=this.cachedRenderer.startRender();else{if(this.allChildrenCanRender(n,l)){for(const o of this.getChildren())o.renderItems(t,e,n);return}let o=0;for(const t of l)o+=t.getContent().getProportionalRenderingTime();if(o>this.cacheState.props.minProportionalRenderTimePerCache){let t=!0;if(this.cachedRenderer)if(l.length>this.renderedIds.length&&this.allRenderedIdsIn(c)&&null!==this.renderedMaxZIndex){const e=[];let n=null;for(let t=0;t<l.length;t++){const o=l[t],i=o.getContent().getZIndex();(t>=this.renderedIds.length||o.getId()!==this.renderedIds[t])&&(e.push(o),(null===n||i<n)&&(n=i))}if(null!==n&&n>this.renderedMaxZIndex){t=!1,d=this.cachedRenderer.startRender();for(let t=0;t<a.length;t++){const e=a[t],n=e.getContent().getZIndex();n>this.renderedMaxZIndex&&(e.render(d,this.region),this.renderedMaxZIndex=n)}r}}else r;else this.cachedRenderer=this.cacheState.recordManager.allocCanvas(this.region,(()=>this.onRegionDealloc()));if(t){d=this.cachedRenderer.startRender(),d.clear(),this.renderedMaxZIndex=null;for(const t of a){const e=t.getContent();this.renderedMaxZIndex??=e.getZIndex(),this.renderedMaxZIndex=Math.max(this.renderedMaxZIndex,e.getZIndex()),t.render(d,this.region)}r}this.renderedIds=c}else{this.cachedRenderer?.dealloc();const e=n.getSizeOfPixelOnCanvas(),o=new i.Rect2(this.region.x,this.region.y,this.region.w+e,this.region.h+e),r=!0;t.startObject(o,r);for(const e of a)e.render(t,this.region.intersection(n.visibleRect));t.endObject()}}if(d){const e=this.cachedRenderer.getTransform(this.region).inverse();t.renderFromOtherOfSameType(e,d)}this.instantiatedChildren.every((t=>t.isEmpty()))&&(this.instantiatedChildren=[])}else for(const o of this.getChildren())o.renderItems(t,e.filter((t=>t.getBBox().intersects(o.region))),n);this.checkRep()}isEmpty(){return null===this.cachedRenderer&&this.instantiatedChildren.every((t=>t.isEmpty()))}onRegionDealloc(){this.cachedRenderer=null,this.isEmpty()&&(this.instantiatedChildren=[])}checkRep(){if(9!==this.instantiatedChildren.length&&0!==this.instantiatedChildren.length)throw new Error(`Repcheck: Wrong number of children. Got ${this.instantiatedChildren.length}`);if(void 0!==this.renderedIds[1]&&this.renderedIds[0]>=this.renderedIds[1])throw console.error(this.renderedIds),new Error("Repcheck: First two ids are not in ascending order!");for(const t of this.instantiatedChildren)if(t.parent!==this)throw new Error("Children should be linked to their parents!");if(this.cachedRenderer&&!this.cachedRenderer.isAllocd())throw new Error("this' cachedRenderer != null, but is dealloc'd")}}e.default=s},2670:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.pathVisualEquivalent=e.pathFromRenderable=e.pathToRenderable=e.RenderingMode=e.Display=e.CanvasRenderer=e.SVGRenderer=e.DummyRenderer=e.AbstractRenderer=void 0;var i=n(7369);Object.defineProperty(e,"AbstractRenderer",{enumerable:!0,get:function(){return o(i).default}});var r=n(6377);Object.defineProperty(e,"DummyRenderer",{enumerable:!0,get:function(){return o(r).default}});var s=n(2001);Object.defineProperty(e,"SVGRenderer",{enumerable:!0,get:function(){return o(s).default}});var a=n(7717);Object.defineProperty(e,"CanvasRenderer",{enumerable:!0,get:function(){return o(a).default}});var l=n(3012);Object.defineProperty(e,"Display",{enumerable:!0,get:function(){return o(l).default}}),Object.defineProperty(e,"RenderingMode",{enumerable:!0,get:function(){return l.RenderingMode}});var c=n(7444);Object.defineProperty(e,"pathToRenderable",{enumerable:!0,get:function(){return c.pathToRenderable}}),Object.defineProperty(e,"pathFromRenderable",{enumerable:!0,get:function(){return c.pathFromRenderable}}),Object.defineProperty(e,"pathVisualEquivalent",{enumerable:!0,get:function(){return c.visualEquivalent}})},49:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTextRendererLocalization=void 0,e.defaultTextRendererLocalization={pathNodeCount:t=>`There are ${t} visible path objects.`,textNodeCount:t=>`There are ${t} visible text nodes.`,imageNodeCount:t=>`There are ${t} visible image nodes.`,textNode:t=>`Text: ${t}`,imageNode:t=>`Image: ${t}`,unlabeledImageNode:"Unlabeled image",rerenderAsText:"Re-render as text"}},7369:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097),i=n(2500),r=n(7444);e.default=class{constructor(t){this.viewport=t,this.selfTransform=null,this.transformStack=[],this.objectLevel=0,this.currentPaths=null}getViewport(){return this.viewport}setDraftMode(t){}flushPath(){if(!this.currentPaths)return;let t=null;for(const e of this.currentPaths){const{startPoint:n,commands:r,style:s}=e;t&&(0,i.stylesEqual)(t,s)?this.moveTo(n):(t&&this.endPath(t),this.beginPath(n),t=s);for(const t of r)t.kind===o.PathCommandType.LineTo?this.lineTo(t.point):t.kind===o.PathCommandType.MoveTo?this.moveTo(t.point):t.kind===o.PathCommandType.CubicBezierTo?this.traceCubicBezierCurve(t.controlPoint1,t.controlPoint2,t.endPoint):t.kind===o.PathCommandType.QuadraticBezierTo&&this.traceQuadraticBezierCurve(t.controlPoint,t.endPoint)}t&&this.endPath(t),this.currentPaths=[]}drawPath(t){0===this.objectLevel||null===this.currentPaths?(this.currentPaths=[t],this.flushPath(),this.currentPaths=null):this.currentPaths.push(t)}drawRect(t,e,n){const i=o.Path.fromRect(t,e);this.drawPath((0,r.pathToRenderable)(i,n))}fillRect(t,e){const n=o.Path.fromRect(t);this.drawPath((0,r.pathToRenderable)(n,{fill:e}))}startObject(t,e){this.objectLevel>0&&this.flushPath(),this.currentPaths=[],this.objectLevel++}endObject(t,e){if(this.flushPath(),this.currentPaths=null,this.objectLevel--,this.objectLevel<0)throw new Error("More objects have ended than have been started (negative object nesting level)!")}getNestingLevel(){return this.objectLevel}canRenderFromWithoutDataLoss(t){return!1}renderFromOtherOfSameType(t,e){throw new Error(`Unable to render from ${e}: Not implemented`)}setTransform(t){this.selfTransform=t}pushTransform(t){this.transformStack.push(this.selfTransform),this.setTransform(this.getCanvasToScreenTransform().rightMul(t))}popTransform(){if(0===this.transformStack.length)throw new Error("Unable to pop more transforms than have been pushed!");this.setTransform(this.transformStack.pop()??null)}getCanvasToScreenTransform(){return this.selfTransform?this.selfTransform:this.viewport.canvasToScreenTransform}canvasToScreen(t){return this.getCanvasToScreenTransform().transformVec2(t)}getSizeOfCanvasPixelOnScreen(){return this.getCanvasToScreenTransform().transformVec3(o.Vec2.unitX).length()}}},7717:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=n(5097),s=o(n(7369)),a=n(7444);class l extends s.default{constructor(t,e){super(e),this.ctx=t,this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1,this.currentObjectBBox=null,this.clipLevels=[],this.setDraftMode(!1)}transformBy(t){this.ctx.transform(t.a1,t.b1,t.a2,t.b2,t.a3,t.b3)}canRenderFromWithoutDataLoss(t){return t instanceof l}renderFromOtherOfSameType(t,e){if(!(e instanceof l))throw new Error(`${e} cannot be rendered onto ${this}`);t=this.getCanvasToScreenTransform().rightMul(t),this.ctx.save(),this.transformBy(t),this.ctx.drawImage(e.ctx.canvas,0,0),this.ctx.restore()}setDraftMode(t){t?(this.minSquareCurveApproxDist=9,this.minRenderSizeBothDimens=2,this.minRenderSizeAnyDimen=.5):(this.minSquareCurveApproxDist=.5,this.minRenderSizeBothDimens=.2,this.minRenderSizeAnyDimen=1e-6)}displaySize(){return r.Vec2.of(this.ctx.canvas.clientWidth,this.ctx.canvas.clientHeight)}clear(){this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}beginPath(t){t=this.canvasToScreen(t),this.ctx.beginPath(),this.ctx.moveTo(t.x,t.y)}endPath(t){t.fill.a>0&&(this.ctx.fillStyle=t.fill.toHexString(),this.ctx.fill()),t.stroke&&(this.ctx.strokeStyle=t.stroke.color.toHexString(),this.ctx.lineWidth=this.getSizeOfCanvasPixelOnScreen()*t.stroke.width,this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.stroke(),this.ctx.lineWidth=1),this.ctx.closePath()}lineTo(t){t=this.canvasToScreen(t),this.ctx.lineTo(t.x,t.y)}moveTo(t){t=this.canvasToScreen(t),this.ctx.moveTo(t.x,t.y)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n);const o=e.minus(t),i=n.minus(e);o.magnitudeSquared()<this.minSquareCurveApproxDist&&i.magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(n.x,n.y):this.ctx.bezierCurveTo(t.x,t.y,e.x,e.y,n.x,n.y)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e);t.minus(e).magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(e.x,e.y):this.ctx.quadraticCurveTo(t.x,t.y,e.x,e.y)}drawPath(t){this.ignoringObject||(this.currentObjectBBox?.containsRect(this.getViewport().visibleRect)&&(t=(0,a.visualEquivalent)(t,this.getViewport().visibleRect)),super.drawPath(t))}drawText(t,e,n){this.ctx.save(),e=this.getCanvasToScreenTransform().rightMul(e),this.transformBy(e),i.default.applyTextStyles(this.ctx,n),0!==n.renderingStyle.fill.a&&(this.ctx.fillStyle=n.renderingStyle.fill.toHexString(),this.ctx.fillText(t,0,0)),n.renderingStyle.stroke&&(this.ctx.strokeStyle=n.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=n.renderingStyle.stroke.width,this.ctx.strokeText(t,0,0)),this.ctx.restore()}drawImage(t){this.ctx.save();const e=this.getCanvasToScreenTransform().rightMul(t.transform);this.transformBy(e),this.ctx.drawImage(t.image,0,0),this.ctx.restore()}startObject(t,e){if(this.isTooSmallToRender(t)&&(this.ignoreObjectsAboveLevel=this.getNestingLevel(),this.ignoringObject=!0),super.startObject(t),this.currentObjectBBox=t,!this.ignoringObject&&e){if(!t.containsRect(this.getViewport().visibleRect)){this.clipLevels.push(this.objectLevel),this.ctx.save(),this.ctx.beginPath();for(const e of t.corners){const t=this.canvasToScreen(e);this.ctx.lineTo(t.x,t.y)}this.ctx.clip()}}}endObject(){const t=this.objectLevel;this.currentObjectBBox=null,super.endObject(),!this.ignoringObject&&this.clipLevels.length>0&&this.clipLevels[this.clipLevels.length-1]===t&&(this.ctx.restore(),this.clipLevels.pop()),null!==this.ignoreObjectsAboveLevel&&this.getNestingLevel()<=this.ignoreObjectsAboveLevel&&(this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1)}drawPoints(...t){for(let e=0;e<t.length;e++){const n=this.canvasToScreen(t[e]);this.ctx.beginPath(),this.ctx.arc(n.x,n.y,10,0,2*Math.PI),this.ctx.fillStyle=r.Color4.ofRGBA(.5+Math.sin(e)/2,1,.5+Math.cos(.2*e)/4,.5).toHexString(),this.ctx.lineWidth=2,this.ctx.fill(),this.ctx.stroke(),this.ctx.closePath(),this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillStyle="black",this.ctx.fillText(`${e}`,n.x,n.y,20)}}isTooSmallToRender(t){const e=this.getCanvasToScreenTransform().transformVec3(t.size),n=this.minRenderSizeBothDimens,o=Math.abs(e.x)<n&&Math.abs(e.y)<n,i=this.minRenderSizeAnyDimen,r=Math.abs(e.x)<i||Math.abs(e.y)<i;return o||r}}e.default=l},6377:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(7369));class s extends r.default{constructor(t){super(t),this.clearedCount=0,this.renderedPathCount=0,this.lastFillStyle=null,this.lastPoint=null,this.objectNestingLevel=0,this.lastText=null,this.lastImage=null,this.pointBuffer=[]}displaySize(){const t=this.getViewport().getScreenRectSize();return 0===t.x||0===t.y?i.Vec2.of(640,480):t}clear(){if(this.clearedCount++,this.renderedPathCount=0,this.pointBuffer=[],this.lastText=null,this.lastImage=null,this.objectNestingLevel>0)throw new Error(`Within an object while clearing! Nesting level: ${this.objectNestingLevel}`)}beginPath(t){this.lastPoint=t,this.pointBuffer.push(t)}endPath(t){this.renderedPathCount++,this.lastFillStyle=t}lineTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}moveTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n),this.lastPoint=n,this.pointBuffer.push(t,e,n)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(t,e)}drawPoints(...t){}drawText(t,e,n){this.lastText=t}drawImage(t){this.lastImage=t}startObject(t,e){super.startObject(t),this.objectNestingLevel+=1}endObject(){super.endObject(),this.objectNestingLevel-=1}isTooSmallToRender(t){return!1}canRenderFromWithoutDataLoss(t){return t instanceof s}renderFromOtherOfSameType(t,e){if(!(e instanceof s))throw new Error(`${e} cannot be rendered onto ${this}`);this.renderedPathCount+=e.renderedPathCount,this.lastFillStyle=e.lastFillStyle,this.lastPoint=e.lastPoint,this.pointBuffer.push(...e.pointBuffer.map((e=>t.transformVec2(e))))}}e.default=s},2001:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.renderedStylesheetId=void 0;const i=n(5097),r=n(1697),s=n(2500),a=o(n(7369)),l=n(7444),c=o(n(8315));e.renderedStylesheetId="js-draw-style-sheet";const d="http://www.w3.org/2000/svg",h={fontWeight:"400",fontStyle:"normal"};class u extends a.default{constructor(t,e,n=!1){super(e),this.elem=t,this.sanitize=n,this.lastPathStyle=null,this.lastPathString=[],this.lastContainerIDList=[],this.objectElems=null,this.overwrittenAttrs={},this.textContainer=null,this.textContainerTransform=null,this.textParentStyle=h,this.clear(),this.addStyleSheet()}addStyleSheet(){if(!this.elem.querySelector(`#${e.renderedStylesheetId}`)){const t=document.createElementNS("http://www.w3.org/2000/svg","style");t.innerHTML="\n\t\t\t\tpath {\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t}\n\n\t\t\t\ttext {\n\t\t\t\t\twhite-space: pre;\n\t\t\t\t}\n\t\t\t".replace(/\s+/g,""),t.setAttribute("id",e.renderedStylesheetId),this.elem.appendChild(t)}}setRootSVGAttribute(t,e){this.sanitize||(t in this.overwrittenAttrs||(this.overwrittenAttrs[t]=this.elem.getAttribute(t)),null!==e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t))}displaySize(){return i.Vec2.of(this.elem.clientWidth,this.elem.clientHeight)}clear(){if(this.lastPathString=[],this.lastContainerIDList=[],!this.sanitize){for(const t in this.overwrittenAttrs){const e=this.overwrittenAttrs[t];e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t)}this.overwrittenAttrs={}}}addPathToSVG(){if(!this.lastPathStyle||0===this.lastPathString.length)return null;const t=document.createElementNS(d,"path");t.setAttribute("d",this.lastPathString.join(" "));const e=this.lastPathStyle;return e.fill.a>0?t.setAttribute("fill",e.fill.toHexString()):t.setAttribute("fill","none"),e.stroke&&(t.setAttribute("stroke",e.stroke.color.toHexString()),t.setAttribute("stroke-width",(0,i.toRoundedString)(e.stroke.width))),this.elem.appendChild(t),this.objectElems?.push(t),t}drawPath(t){const e=t.style,n=(0,l.pathFromRenderable)(t).transformedBy(this.getCanvasToScreenTransform());0!==this.lastPathString.length&&this.lastPathStyle&&(0,s.stylesEqual)(this.lastPathStyle,e)||(this.addPathToSVG(),this.lastPathStyle=e,this.lastPathString=[]),this.lastPathString.push(n.toString())}transformFrom(t,e,n=!1){const o=n?t:this.getCanvasToScreenTransform().rightMul(t);if(o.eq(i.Mat33.identity))e.style.transform="";else{const t=o.toCSSMatrix();e.style.transform=t,e.setAttribute("data-highp-transform",t)}}drawText(t,e,n){const o=(t,e)=>{e.fontFamily!==this.textParentStyle?.fontFamily&&(t.style.fontFamily=e.fontFamily),e.fontVariant!==this.textParentStyle?.fontVariant&&(t.style.fontVariant=e.fontVariant??""),e.fontWeight!==this.textParentStyle?.fontWeight&&(t.style.fontWeight=e.fontWeight??""),e.fontStyle!==this.textParentStyle?.fontStyle&&(t.style.fontStyle=e.fontStyle??""),e.size!==this.textParentStyle?.size&&(t.style.fontSize=e.size+"px");const n=e.renderingStyle.fill.toHexString();if(t.style.fill=n,e.renderingStyle.stroke){const n=e.renderingStyle.stroke;t.style.stroke=n.color.toHexString(),t.style.strokeWidth=n.width+"px"}};if(e=this.getCanvasToScreenTransform().rightMul(e),this.textContainer){const r=document.createElementNS(d,"tspan");r.appendChild(document.createTextNode(t)),this.textContainer.appendChild(r);const s=(e=this.textContainerTransform.inverse().rightMul(e)).transformVec2(i.Vec2.zero);r.setAttribute("x",`${(0,i.toRoundedString)(s.x)}`),r.setAttribute("y",`${(0,i.toRoundedString)(s.y)}`),o(r,n)}else{const i=document.createElementNS(d,"text");i.appendChild(document.createTextNode(t)),this.transformFrom(e,i,!0),o(i,n),this.elem.appendChild(i),this.objectElems?.push(i),this.objectLevel>0&&(this.textContainer=i,this.textContainerTransform=e,this.textParentStyle={...h,...n})}}drawImage(t){let e=t.label??t.image.getAttribute("aria-label")??"";""===e&&(e=t.image.getAttribute("alt")??"");const n=document.createElementNS(d,"image");n.setAttribute("href",t.base64Url),n.setAttribute("width",t.image.getAttribute("width")??""),n.setAttribute("height",t.image.getAttribute("height")??""),n.setAttribute("aria-label",e),this.transformFrom(t.transform,n),this.elem.appendChild(n),this.objectElems?.push(n)}startObject(t){super.startObject(t),this.lastPathString=[],this.lastPathStyle=null,this.textContainer=null,this.textParentStyle=h,this.objectElems=[]}endObject(t,e){if(super.endObject(t),this.addPathToSVG(),this.objectElems){if(t&&!this.sanitize){for(const e of this.objectElems){const n=t[r.svgAttributesDataKey],o=t[r.svgStyleAttributesDataKey];if(n)for(const[t,o]of n)e.setAttribute(t,o);if(o)for(const t of o)e.style.setProperty(t.key,t.value,t.priority)}const e=t[r.svgLoaderAttributeContainerID];let n=[];if(e&&e[0]&&e[0].length&&(n=e[0]),n.length>0&&(0,c.default)(this.lastContainerIDList,n)&&this.lastContainerIDList.length>=n.length-1){const t=n[n.length-1],e=this.elem.querySelectorAll(`g#${t}`);if(e.length>=1){const t=e[0];if(0===t.children.length||this.lastContainerIDList.length>=n.length)for(const e of this.objectElems)e.remove(),t.appendChild(e);else n=[]}}else n=[];this.lastContainerIDList=n}if(e&&this.objectElems)if(1===this.objectElems.length)this.objectElems[0].classList.add(...e);else{const t=document.createElementNS(d,"g");t.classList.add(...e);for(const e of this.objectElems)e.remove(),t.appendChild(e);this.elem.appendChild(t)}}}unimplementedMessage(){throw new Error("Not implemenented!")}beginPath(t){this.unimplementedMessage()}endPath(t){this.unimplementedMessage()}lineTo(t){this.unimplementedMessage()}moveTo(t){this.unimplementedMessage()}traceCubicBezierCurve(t,e,n){this.unimplementedMessage()}traceQuadraticBezierCurve(t,e){this.unimplementedMessage()}drawPoints(...t){t.map((t=>{const e=document.createElementNS(d,"circle");e.setAttribute("cx",`${t.x}`),e.setAttribute("cy",`${t.y}`),e.setAttribute("r","15"),this.elem.appendChild(e)}))}drawSVGElem(t){if(this.sanitize)return;if("style"===t.tagName.toLowerCase()&&t.getAttribute("id")===e.renderedStylesheetId)return;const n=t.cloneNode(!0);this.elem.appendChild(n),this.objectElems?.push(n)}isTooSmallToRender(t){return!1}static fromViewport(t,e=!0){const n="http://www.w3.org/2000/svg",o=document.createElementNS(n,"svg"),r=t.getScreenRectSize();return o.setAttribute("viewBox",[0,0,r.x,r.y].map((t=>(0,i.toRoundedString)(t))).join(" ")),o.setAttribute("width",(0,i.toRoundedString)(r.x)),o.setAttribute("height",(0,i.toRoundedString)(r.y)),o.setAttribute("version","1.1"),o.setAttribute("baseProfile","full"),o.setAttribute("xmlns",n),{element:o,renderer:new u(o,t,e)}}}e.default=u},1263:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(7369));class s extends r.default{constructor(t,e){super(t),this.localizationTable=e,this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}displaySize(){return i.Vec2.of(500,500)}clear(){this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}getDescription(){return[this.localizationTable.pathNodeCount(this.pathCount),...this.textNodeCount>0?[this.localizationTable.textNodeCount(this.textNodeCount)]:[],...this.imageNodeCount>0?[this.localizationTable.imageNodeCount(this.imageNodeCount)]:[],...this.descriptionBuilder].join("\n")}beginPath(t){}endPath(t){this.pathCount++}lineTo(t){}moveTo(t){}traceCubicBezierCurve(t,e,n){}traceQuadraticBezierCurve(t,e){}drawText(t,e,n){this.descriptionBuilder.push(this.localizationTable.textNode(t)),this.textNodeCount++}drawImage(t){const e=t.label?this.localizationTable.imageNode(t.label):this.localizationTable.unlabeledImageNode;this.descriptionBuilder.push(e),this.imageNodeCount++}isTooSmallToRender(t){return t.maxDimension<15/this.getSizeOfCanvasPixelOnScreen()}drawPoints(...t){}}e.default=s},7:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=t=>t.toUpperCase()===t&&t.toLowerCase()!==t&&1===t.length,o=t=>t.toLowerCase()===t&&t.toUpperCase()!==t&&1===t.length;class i{constructor(t){this.key=t.key,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.controlOrMeta=t.controlOrMeta}matchesEvent(t){const e=t.key?.toLowerCase(),i=n(t.key??""),r=o(t.key??""),s=(t.ctrlKey??!1)||"control"===e,a=(t.altKey??!1)||"alt"===e,l=(t.metaKey??!1)||"meta"===e,c=(t.shiftKey??i)||"shift"===e,d=t.controlOrMeta||t.ctrlKey||t.metaKey||!1;if(this.key!==t.code){if(this.key.toLowerCase()!==e)return!1;if((i||r)&&this.key!==t.key){if(!(!0===this.shiftKey&&this.key.toUpperCase()===t.key))return!1}}const h=this.controlOrMeta;return(s===this.ctrlKey&&l===this.metaKey&&!h||h&&d)&&a===this.altKey&&(c===this.shiftKey||void 0===this.shiftKey)}toString(){const t=[];return this.ctrlKey&&"control"!==this.key&&t.push("Ctrl"),this.controlOrMeta&&t.push("CtrlOrMeta"),this.altKey&&"alt"!==this.key&&t.push("Alt"),this.metaKey&&"meta"!==this.key&&t.push("Meta"),this.shiftKey&&"shift"!==this.key&&t.push("Shift"),t.push(this.key),t.join("+")}static fromString(t){const e=t=>{let e;n(t)?e=!0:(o(t)||t.length>1)&&(e=!1);const i=t.toLowerCase();return"shift"===i&&(e=!0),{shiftKey:e,ctrlKey:"control"===i||"ctrl"===i,altKey:"alt"===i,metaKey:"meta"===i,controlOrMeta:"control or meta"===i||"ctrlormeta"===i}};if(-1===t.search(/[-+]/)||1===t.length){const n=e(t);return new i({key:t,...n})}const r=/^(.*[-+])?(.+)$/g.exec(t);if(!r)throw new Error(`Invalid shortcut expression, ${t}!`);const s=r[2],a=e(s),l=(r[1]??"").split(/[-+]/);let c=a.shiftKey,d=a.ctrlKey,h=a.altKey,u=a.metaKey,p=a.controlOrMeta;for(const e of l)if(""!==e)switch(e.toLowerCase()){case"shift":c=!0;break;case"anyshift":c=void 0;break;case"ctrl":case"control":d=!0;break;case"meta":u=!0;break;case"ctrlormeta":case"ctrl or meta":case"controlormeta":p=!0;break;case"alt":h=!0;break;default:throw new Error(`Unknown modifier: "${e}" in shortcut ${t}.`)}return new i({key:s,shiftKey:c,ctrlKey:d,altKey:h,metaKey:u,controlOrMeta:p})}}e.default=i},5376:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(1906),r=o(n(7));class s{constructor(t){this.shortcutOverrides=Object.create(null);for(const e in t)this.overrideShortcut(e,t[e])}overrideShortcut(t,e){this.shortcutOverrides[t]=[...e]}matchesShortcut(t,e){let n=this.shortcutOverrides[t];if(!n){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);n=s.shortcuts[t]}for(const t of n)if(t.matchesEvent(e))return!0;return!1}static registerDefaultKeyboardShortcut(t,e,n){if(t in s.shortcuts)return!1;const o=e.map((t=>"string"==typeof t?r.default.fromString(t):t));return s.shortcuts[t]=[...o],s.shortcutDefaultDescriptions[t]=n,!0}static provideShortcutDescription(t,e,n){e in s.shortcutLocalizedDescriptions||(s.shortcutLocalizedDescriptions[e]=Object.create(null)),s.shortcutLocalizedDescriptions[e][t]=n}static getAllShortcutIds(){const t=[];for(const e in this.shortcuts)t.push(e);return t}static getShortcutDefaultKeybindings(t){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);return s.shortcuts[t]}static getShortcutDescription(t,e){return(0,i.matchingLocalizationTable)(e??[],this.shortcutLocalizedDescriptions,this.shortcutDefaultDescriptions)[t]??this.shortcutDefaultDescriptions[t]??null}}s.shortcuts=Object.create(null),s.shortcutDefaultDescriptions=Object.create(null),s.shortcutLocalizedDescriptions=Object.create(null),e.default=s},6843:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBinding=e.KeyboardShortcutManager=void 0;var i=n(5376);Object.defineProperty(e,"KeyboardShortcutManager",{enumerable:!0,get:function(){return o(i).default}});var r=n(7);Object.defineProperty(e,"KeyBinding",{enumerable:!0,get:function(){return o(r).default}})},3311:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{let e=0;const n=t.map((t=>t.id));n.sort();for(const t of n)e===t&&(e=t+1);return e}},1797:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.sendTouchEvent=e.sendPenEvent=void 0;var i=n(1380);Object.defineProperty(e,"sendPenEvent",{enumerable:!0,get:function(){return o(i).default}});var r=n(8783);Object.defineProperty(e,"sendTouchEvent",{enumerable:!0,get:function(){return o(r).default}})},1380:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(4318)),r=n(7520),s=o(n(3311));e.default=(t,e,n,o)=>{const a=(0,s.default)(o??[]),l=i.default.ofCanvasPoint(n,e!==r.InputEvtType.PointerUpEvt,t.viewport,a);return t.toolController.dispatchInputEvent({kind:e,allPointers:o??[l],current:l}),l}},8783:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=r(n(4318)),l=n(7520),c=s(n(3311));e.default=(t,e,n,o)=>{const i=t.viewport.screenToCanvas(n),r=(0,c.default)(o??[]),s=a.default.ofCanvasPoint(i,e!==l.InputEvtType.PointerUpEvt,t.viewport,r,a.PointerDevice.Touch);return t.toolController.dispatchInputEvent({kind:e,allPointers:[...o??[],s],current:s}),s}},2339:function(t,e,n){"use strict";var o,i,r,s,a=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},l=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const d=n(3173),h=n(5381),u=n(9746),p=c(n(7591)),f=c(n(4735)),m=c(n(4321)),g=c(n(6416)),b=c(n(2133)),y=c(n(7998)),v=c(n(9944)),w=c(n(5001)),x=c(n(5730)),S=c(n(7956)),T=n(3258),C=c(n(3534)),P=c(n(6318)),k=c(n(5771)),E=n(5097),z=n(5698),M=c(n(78));class _{constructor(t,e=u.defaultToolbarLocalization){this.editor=t,this.localizationTable=e,o.set(this,[]),i.set(this,{}),r.set(this,[]),s.set(this,null),this.closeColorPickerOverlay=null,_.colorisStarted||((0,h.init)(),_.colorisStarted=!0),this.setupColorPickers()}setupCloseColorPickerOverlay(){this.closeColorPickerOverlay||(this.closeColorPickerOverlay=document.createElement("div"),this.closeColorPickerOverlay.className=`${z.toolbarCSSPrefix}closeColorPickerOverlay`,this.editor.createHTMLOverlay(this.closeColorPickerOverlay),a(this,o,"f").push(this.editor.handlePointerEventsExceptClicksFrom(this.closeColorPickerOverlay,(t=>("pointerdown"===t&&(0,h.close)(),"pointerup"===t&&this.editor.focus(),!0)))))}setupColorPickers(){if(a(this,s,"f"))return void a(this,s,"f").call(this);this.setupCloseColorPickerOverlay();const t=[E.Color4.red.toHexString(),E.Color4.purple.toHexString(),E.Color4.blue.toHexString(),E.Color4.clay.toHexString(),E.Color4.black.toHexString(),E.Color4.white.toHexString()],e=t.length;let n=!1;const i=()=>{try{(0,h.coloris)({el:".coloris_input",format:"hex",selectInput:!1,focusInput:!1,themeMode:"auto",swatches:t})}catch(t){console.warn("Failed to initialize Coloris. Error: ",t),n||(n=!0,document.addEventListener("load",(()=>{i()}),{once:!0}))}};i(),l(this,s,i,"f");a(this,o,"f").push(this.editor.notifier.on(d.EditorEventType.ColorPickerToggled,(t=>{t.kind===d.EditorEventType.ColorPickerToggled&&this.closeColorPickerOverlay&&(this.closeColorPickerOverlay.style.display=t.open?"block":"none")}))),a(this,o,"f").push(this.editor.notifier.on(d.EditorEventType.ColorPickerColorSelected,(n=>{n.kind===d.EditorEventType.ColorPickerColorSelected&&(n=>{let o=!1;for(const e of t)e===n&&(o=!0);o||(t.push(n),t.length>12&&t.splice(e,1),i())})(n.color.toHexString())})))}closeColorPickers(){(0,h.close)?.()}getWidgetUniqueId(t){return t.getUniqueIdIn(a(this,i,"f"))}getWidgetFromId(t){return a(this,i,"f")[t]}getAllWidgets(){return a(this,r,"f")}addWidget(t){const e=t.getUniqueIdIn(a(this,i,"f"));a(this,i,"f")[e]=t,a(this,r,"f").push(t),this.addWidgetInternal(t),this.setupColorPickers()}removeWidget(t){const e=t.getUniqueIdIn(a(this,i,"f"));this.removeWidgetInternal(t),delete a(this,i,"f")[e],l(this,r,a(this,r,"f").filter((e=>e!==t)),"f")}serializeState(){const t={};for(const e in a(this,i,"f"))t[e]=a(this,i,"f")[e].serializeState();return t[_.rootToolbarId]=this.serializeInternal(),JSON.stringify(t)}deserializeState(t){const e=JSON.parse(t),n=_.rootToolbarId;this.deserializeInternal(e[n]);for(const t in e)t!==n&&(t in a(this,i,"f")?a(this,i,"f")[t].deserializeFrom(e[t]):console.warn(`Unable to deserialize widget ${t} — no such widget.`))}serializeInternal(){}deserializeInternal(t){}makeActionButton(t,e,n=!0){const o="string"==typeof t?t:t.label;return new C.default(this.editor,"action-button",(()=>"string"==typeof t?null:t.icon),o,e,this.editor.localization,n)}addActionButton(t,e,n=!0){const o=this.makeActionButton(t,e,n);return this.addWidget(o),o}addTaggedActionButton(t,e,n,o=!0){const i=this.makeActionButton(e,n,o);return i.setTags(t),this.addWidget(i),i}addSaveButton(t){const e=new M.default(this.editor,this.localizationTable,t);return e.setTags([T.ToolbarWidgetTag.Save]),this.addWidget(e),e}addExitButton(t){return this.addTaggedActionButton([T.ToolbarWidgetTag.Exit],{label:this.editor.localization.exit,icon:this.editor.icons.makeCloseIcon()},(()=>{t()}))}addUndoRedoButtons(t=!0){const e=()=>this.addTaggedActionButton([T.ToolbarWidgetTag.Undo],{label:this.localizationTable.undo,icon:this.editor.icons.makeUndoIcon()},(()=>{this.editor.history.undo()})),n=()=>this.addTaggedActionButton([T.ToolbarWidgetTag.Redo],{label:this.localizationTable.redo,icon:this.editor.icons.makeRedoIcon()},(()=>{this.editor.history.redo()}));let o,i;t?(o=e(),i=n()):(i=n(),o=e()),o.setDisabled(!0),i.setDisabled(!0),this.editor.notifier.on(d.EditorEventType.UndoRedoStackUpdated,(t=>{if(t.kind!==d.EditorEventType.UndoRedoStackUpdated)throw new Error("Wrong event type!");o.setDisabled(0===t.undoStackSize),i.setDisabled(0===t.redoStackSize)}))}addDefaultToolWidgets(){const t=this.editor.toolController;for(const e of t.getMatchingTools(b.default)){const t=new y.default(this.editor,e,this.localizationTable);this.addWidget(t)}for(const e of t.getMatchingTools(g.default))this.addWidget(new v.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(p.default))this.addWidget(new w.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(m.default))this.addWidget(new x.default(this.editor,e,this.localizationTable));const e=t.getMatchingTools(f.default)[0];e&&this.addWidget(new S.default(this.editor,e,this.localizationTable)),this.addWidget(new k.default(this.editor,this.localizationTable)),this.addWidget(new P.default(this.editor,this.localizationTable))}addDefaultActionButtons(){this.addUndoRedoButtons()}remove(){this.closeColorPickerOverlay?.remove();for(const t of a(this,o,"f"))t.remove();l(this,o,[],"f"),this.onRemove()}manageListener(t){a(this,o,"f").push(t)}}o=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,_.colorisStarted=!1,_.rootToolbarId="root-toolbar--",e.default=_},9997:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeDropdownToolbar=void 0;const i=n(9746),r=o(n(3359)),s=o(n(2339)),a=n(5698);e.makeDropdownToolbar=t=>new l(t,t.getRootElement());class l extends s.default{constructor(t,e,n=i.defaultToolbarLocalization){super(t,n),this.widgetOrderCounter=0,this.overflowWidget=null,this.reLayoutQueued=!1,this.container=document.createElement("div"),this.container.classList.add(`${a.toolbarCSSPrefix}root`),this.container.classList.add(`${a.toolbarCSSPrefix}element`),this.container.classList.add(`${a.toolbarCSSPrefix}dropdown-toolbar`),this.container.setAttribute("role","toolbar"),e.appendChild(this.container),"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver((t=>{this.reLayout()})),this.resizeObserver.observe(this.container)):console.warn("ResizeObserver not supported. Toolbar will not resize.")}queueReLayout(){this.reLayoutQueued||(this.reLayoutQueued=!0,requestAnimationFrame((()=>this.reLayout())))}reLayout(){if(this.reLayoutQueued=!1,!this.overflowWidget)return;const t=t=>{let e=0;for(const n of t)n.isHidden()||(e+=n.getButtonWidth());return e},e=this.getAllWidgets();let n=t(this.overflowWidget.getChildWidgets()),o=t(e)-n,i=.87*this.container.clientWidth;window.innerHeight>1.75*i&&(i*=1.75);let r=!1;if((t=>{const e=this.overflowWidget?.getChildWidgets()??[];return 0!==e.length&&e[0].getButtonWidth()<=t})(i-o)){const t=this.overflowWidget.clearChildren();for(const e of t)e.addTo(this.container),e.setIsToplevel(!0),e.isHidden()||(o+=e.getButtonWidth());n=0,r=!0}if(o>=i){for(let t=e.length-1;t>=0&&o>=i;t--){const n=e[t];this.overflowWidget.hasAsChild(n)||n.canBeInOverflowMenu()&&(o-=n.getButtonWidth(),this.overflowWidget.addToOverflow(n))}r=!0}this.overflowWidget.setHidden(0===this.overflowWidget.getChildWidgets().length),r&&this.setupColorPickers()}addWidgetInternal(t){t.addTo(this.container).style.order=""+this.widgetOrderCounter++,this.queueReLayout()}removeWidgetInternal(t){t.remove(),this.queueReLayout()}addSpacer(t={}){const e=document.createElement("div");e.classList.add(`${a.toolbarCSSPrefix}spacer`),t.grow&&(e.style.flexGrow=`${t.grow}`),t.minSize&&(e.style.minWidth=t.minSize),t.maxSize&&(e.style.maxWidth=t.maxSize),e.style.order=""+this.widgetOrderCounter++,this.container.appendChild(e)}addOverflowWidget(){this.overflowWidget=new r.default(this.editor,this.localizationTable),this.addWidget(this.overflowWidget)}addDefaults(){this.addDefaultToolWidgets(),this.addOverflowWidget(),this.addDefaultActionButtons()}onRemove(){this.container.remove(),this.resizeObserver.disconnect()}}e.default=l},5221:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeEdgeToolbar=void 0;const i=n(3258),r=n(5698),s=o(n(5132)),a=n(1151),l=o(n(2339)),c=o(n(9441));e.makeEdgeToolbar=t=>new d(t,t.getRootElement(),t.localization);class d extends l.default{constructor(t,e,n){super(t,n),this.toolbarContainer=document.createElement("div"),this.toolbarContainer.classList.add(`${r.toolbarCSSPrefix}root`),this.toolbarContainer.classList.add(`${r.toolbarCSSPrefix}element`),this.toolbarContainer.classList.add(`${r.toolbarCSSPrefix}edge-toolbar`),this.toolbarContainer.setAttribute("role","toolbar"),this.toolbarActionRow=document.createElement("div"),this.toolbarActionRow.classList.add("toolbar-element","toolbar-action-row"),this.toolbarToolRow=document.createElement("div"),this.toolbarToolRow.classList.add("toolbar-element","toolbar-tool-row"),(0,c.default)(this.toolbarToolRow),"ResizeObserver"in window?(this.toolRowResizeObserver=new ResizeObserver((t=>{this.onToolbarRowResize()})),this.toolRowResizeObserver.observe(this.toolbarToolRow)):console.warn("ResizeObserver not supported. Toolbar will not resize."),this.toolbarContainer.replaceChildren(this.toolbarActionRow,this.toolbarToolRow),e.appendChild(this.toolbarContainer),this.sidebarVisible=a.ReactiveValue.fromInitialValue(!1),this.sidebarY=a.ReactiveValue.fromInitialValue(0),this.menuContainer=document.createElement("div"),this.menuContainer.classList.add(`${r.toolbarCSSPrefix}edgemenu-container`),this.sidebarContainer=document.createElement("div"),this.sidebarContainer.classList.add(`${r.toolbarCSSPrefix}edgemenu`,`${r.toolbarCSSPrefix}element`),this.sidebarContainer.classList.add(`${r.toolbarCSSPrefix}tool-properties`),this.sidebarContent=document.createElement("div"),this.sidebarY.onUpdateAndNow((t=>{const e="dropdown-below-edge";t>0?(this.sidebarContainer.style.transform=`translate(0, ${t}px)`,this.sidebarContainer.style.paddingBottom="",this.menuContainer.classList.add(e)):(this.sidebarContainer.style.transform="",this.sidebarContainer.style.paddingBottom=-t+"px",this.menuContainer.classList.remove(e))})),this.closeButton=document.createElement("button"),this.closeButton.classList.add("drag-elem"),this.editor.handleKeyEventsFrom(this.closeButton,(t=>"Space"!==t.code&&"Enter"!==t.code&&"Tab"!==t.code)),this.sidebarContainer.addEventListener("keyup",(t=>{t.defaultPrevented||"Escape"!==t.code||(this.sidebarVisible.set(!1),t.preventDefault())})),this.initDragListeners();this.sidebarTitle=a.MutableReactiveValue.fromInitialValue(""),this.layoutManager=new s.default(((...t)=>{this.sidebarContent.replaceChildren(...t),this.setupColorPickers()}),this.sidebarTitle,this.sidebarVisible,t.announceForAccessibility.bind(t),n),this.sidebarTitle.onUpdateAndNow((t=>{this.closeButton.setAttribute("aria-label",n.closeSidebar(t))})),this.listenForVisibilityChanges(),this.sidebarContainer.replaceChildren(this.closeButton,this.sidebarContent),this.menuContainer.replaceChildren(this.sidebarContainer),e.appendChild(this.menuContainer)}listenForVisibilityChanges(){let t=null;this.sidebarVisible.get()||(this.menuContainer.style.display="none",this.menuContainer.style.opacity="0"),this.sidebarVisible.onUpdate((e=>{const n="170ms ease";e?(this.sidebarY.set(this.snappedSidebarY()),t&&(clearTimeout(t),t=null),this.menuContainer.style.display="",this.sidebarContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-transition-in`,this.menuContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-container-transition-in`,this.menuContainer.style.opacity="1",this.closeButton.focus()):(this.closeColorPickers(),null===t&&(this.sidebarContainer.style.animation=` ${n} ${r.toolbarCSSPrefix}-edgemenu-transition-out`,this.menuContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-container-transition-out`,this.menuContainer.style.opacity="0",this.editor.announceForAccessibility(this.localizationTable.dropdownHidden(this.sidebarTitle.get())),t=setTimeout((()=>{this.menuContainer.style.display="none",this.menuContainer.style.overflowY="",t=null}),170)))}))}onToolbarRowResize(){const t=()=>{const t=this.toolbarToolRow.clientWidth;let e=0,n=0,o=0;for(const i of this.toolbarToolRow.children){const r=i.clientHeight;if(e+=r,o++,e>t){n=t-e+r/2,n<0&&(n+=r);break}}const i=Math.round(n/o*10)/10;this.toolbarToolRow.style.setProperty("--extra-left-right-padding",`${i}px`)},e=this.toolbarActionRow.getBoundingClientRect(),n=this.toolbarToolRow.getBoundingClientRect(),o=e.y===n.y;e.y+e.height<=n.y?this.toolbarContainer.classList.remove("one-row"):this.toolbarContainer.classList.add("one-row"),this.toolbarToolRow.clientWidth<this.toolbarToolRow.scrollWidth?(this.toolbarToolRow.classList.add("has-scroll"),o||t()):this.toolbarToolRow.classList.remove("has-scroll","extra-padding")}addSpacer(t){}addUndoRedoButtons(){super.addUndoRedoButtons(!1)}addDefaults(){this.addDefaultActionButtons(),this.addDefaultToolWidgets()}updateWidgetCSSClasses(t){const e=t.getTags();t.removeCSSClassFromContainer("label-inline"),t.removeCSSClassFromContainer("label-left"),t.removeCSSClassFromContainer("label-right"),e.includes(i.ToolbarWidgetTag.Save)&&(t.addCSSClassToContainer("label-inline"),t.addCSSClassToContainer("label-right")),e.includes(i.ToolbarWidgetTag.Exit)&&(t.addCSSClassToContainer("label-inline"),t.addCSSClassToContainer("label-left"))}addWidgetInternal(t){this.updateWidgetCSSClasses(t),t.setLayoutManager(this.layoutManager),t.mustBeInToplevelMenu()?t.addTo(this.toolbarActionRow):t.addTo(this.toolbarToolRow)}removeWidgetInternal(t){t.remove()}onRemove(){this.toolbarContainer.remove(),this.menuContainer.remove(),this.toolRowResizeObserver.disconnect()}initDragListeners(){let t=0,e=0,n=0,o=0,i=!1,r=null;const s=[this.closeButton,this.sidebarContainer,this.sidebarContent];this.manageListener(this.editor.handlePointerEventsExceptClicksFrom(this.menuContainer,((t,e)=>e.target===this.menuContainer?("pointerdown"===t&&this.sidebarVisible.set(!1),"pointerup"===t&&this.editor.focus(),!0):!this.sidebarVisible.get()),((t,e)=>e.target===this.menuContainer)));const a=t=>{if(!t)return!1;if(s.includes(t))return!0;const e=["INPUT","SELECT","IMG"];let n=!1,o=t.parentElement;for(;o&&!e.includes(o.tagName);){if(o===this.sidebarContainer){n=!0;break}o=o.parentElement}return!e.includes(t.tagName)&&n},l=()=>Math.hypot(t-n,e-o)<5;let c=!1;this.sidebarContainer.addEventListener("pointerdown",(s=>{!s.defaultPrevented&&a(s.target)&&s.isPrimary&&(c=!1,t=s.clientX,e=s.clientY,n=s.clientX,o=s.clientY,r=null,i=!0)}),{passive:!0});let d=0;const h=t=>{i&&(d=performance.now(),null!==r&&(this.sidebarContainer.releasePointerCapture(r),r=null),this.finalizeDrag(),i=!1,c=!1)};this.sidebarContainer.onpointermove=n=>{if(!n.isPrimary||!i)return;if("mouse"===n.pointerType&&0===n.buttons)return void h();null!==r||l()||(this.sidebarContainer.setPointerCapture(n.pointerId),r=n.pointerId);const s=n.clientX,a=n.clientY,d=s-t,u=a-e;(Math.abs(a-o)>5||c)&&(this.handleDrag(d,u),t=s,e=a,c=!0)},this.sidebarContainer.onpointerleave=t=>{null===r&&i&&t.isPrimary&&(this.sidebarContainer.setPointerCapture(t.pointerId),r=t.pointerId)},this.closeButton.onclick=()=>{const t=performance.now()-d<100,e=l();(t&&e||!t)&&this.sidebarVisible.set(!1)},this.sidebarContainer.onpointerup=h,this.sidebarContainer.onpointercancel=h}handleDrag(t,e){this.sidebarContainer.style.transition="none",this.sidebarY.set(this.sidebarY.get()+e)}snappedSidebarY(t){const e=t??this.sidebarY.get(),n=[-100,0];this.sidebarContainer.clientHeight>window.innerHeight&&n.push(100);let o=n[0];for(const t of n)Math.abs(t-e)<Math.abs(o-e)&&(o=t);return o}finalizeDrag(){this.sidebarContainer.style.transition="",this.sidebarY.get()>this.sidebarContainer.clientHeight/2?this.sidebarVisible.set(!1):this.sidebarY.set(this.snappedSidebarY())}serializeInternal(){return{menuSizeY:this.snappedSidebarY()}}deserializeInternal(t){"object"==typeof t&&"number"==typeof t.menuSizeY&&this.sidebarY.set(this.snappedSidebarY(t.menuSizeY))}}e.default=d},8282:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=s(n(2001)),c=s(n(5566)),d=n(6951),h="http://www.w3.org/2000/svg",u="\n\tstyle='fill: var(--icon-color);'\n";let p=0;const f=()=>{const t="checkerboard-"+p++;return{patternDef:`\n\t\t<pattern\n\t\t\tid='${t}'\n\t\t\tviewBox='0,0,10,10'\n\t\t\twidth='20%'\n\t\t\theight='20%'\n\t\t\tpatternUnits='userSpaceOnUse'\n\t\t>\n\t\t\t<rect x='0' y='0' width='10' height='10' fill='white'/>\n\t\t\t<rect x='0' y='0' width='5' height='5' fill='gray'/>\n\t\t\t<rect x='5' y='5' width='5' height='5' fill='gray'/>\n\t\t</pattern>\n\t`,patternRef:`url(#${t})`}},m=t=>{const e=document.createElementNS(h,"svg");return e.innerHTML=`\n\t\t<style>\n\t\t\t.toolbar-svg-undo-redo-icon {\n\t\t\t\tstroke: var(--icon-color);\n\t\t\t\tstroke-width: 12;\n\t\t\t\tstroke-linejoin: round;\n\t\t\t\tstroke-linecap: round;\n\t\t\t\tfill: none;\n\n\t\t\t\ttransform-origin: center;\n\t\t\t}\n\t\t</style>\n\t\t<path\n\t\t\td='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'\n\t\t\tclass='toolbar-svg-undo-redo-icon'\n\t\t\tstyle='${t?"transform: scale(-1, 1);":""}'/>\n\t`,e.setAttribute("viewBox","0 0 100 100"),e};o=new WeakSet,i=function(){return this.makeIconFromPath("\n\t\t\tM 15,15 85,85\n\t\t\tM 15,85 85,15\n\t\t","none","var(--icon-color)","6px")},e.default=class{constructor(){o.add(this)}makeUndoIcon(){return m(!0)}makeRedoIcon(){return m(!1)}makeDropdownIcon(){const t=document.createElementNS(h,"svg");return t.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\td='M5,10 L50,90 L95,10 Z'\n\t\t\t\t${u}\n\t\t\t/>\n\t\t</g>\n\t\t`,t.setAttribute("viewBox","-10 -10 110 110"),t}makeEraserIcon(t){const e=document.createElementNS(h,"svg");t??=10;const n=t/4;return e.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\tstyle="fill:#ff70af"\n\t\t\t\tstroke="black"\n\t\t\t\ttransform="rotate(41.35)"\n\t\t\t\td="M 52.5 27\n\t\t\t\t\tC 50 28.9 48.9 31.7 48.9 34.8\n\t\t\t\t\tL 48.9 39.8\n\t\t\t\t\tC 48.9 45.3 53.4 49.8 58.9 49.8\n\t\t\t\t\tL 103.9 49.8\n\t\t\t\t\tC 105.8 49.8 107.6 49.2 109.1 48.3\n\t\t\t\t\tL 110.2 ${n+49.5} L 159.7 ${n+5}\n\t\t\t\t\tL 157.7 ${5.2-n} L 112.4 ${49.5-n}\n\t\t\t\t\tC 113.4 43.5 113.9 41.7 113.9 39.8\n\t\t\t\t\tL 113.9 34.8\n\t\t\t\t\tC 113.9 29.3 109.4 24.8 103.9 24.8\n\t\t\t\t\tL 58.9 24.8\n\t\t\t\t\tC 56.5 24.8 54.3 25.7 52.5 27\n\t\t\t\t\tz "\n\t\t\t\tid="path438" />\n\n\t\t\t<rect\n\t\t\t\tstroke="#cc8077"\n\t\t\t\t${u}\n\t\t\t\tid="rect218"\n\t\t\t\twidth="65"\n\t\t\t\theight="75"\n\t\t\t\tx="48.9"\n\t\t\t\ty="-38.7"\n\t\t\t\ttransform="rotate(41.35)" />\n\t\t</g>\n\t\t`,e.setAttribute("viewBox","0 0 120 120"),e}makeSelectionIcon(){const t=document.createElementNS(h,"svg");return t.innerHTML="\n\t\t<g>\n\t\t\t<rect x=10 y=10 width=70 height=70 fill='pink' stroke='black'/>\n\t\t\t<rect x=75 y=75 width=10 height=10 fill='white' stroke='black'/>\n\t\t</g>\n\t\t",t.setAttribute("viewBox","0 0 100 100"),t}makeHandToolIcon(){return this.makeIconFromPath("\n\t\t\tm 10,60\n\t\t\t\t5,30\n\t\t\tH 90\n\t\t\tV 30\n\t\t\tC 90,20 75,20 75,30\n\t\t\tV 60\n\t\t\t\t20\n\t\t\tC 75,10 60,10 60,20\n\t\t\tV 60\n\t\t\t\t15\n\t\t\tC 60,5 45,5 45,15\n\t\t\tV 60\n\t\t\t\t25\n\t\t\tC 45,15 30,15 30,25\n\t\t\tV 60\n\t\t\t\t75\n\t\t\tL 25,60\n\t\t\tC 20,45 10,50 10,60\n\t\t\tZ\n\t\t","none","var(--icon-color)","3")}makeTouchPanningIcon(){return this.makeIconFromPath("\n\t\t\tM 5,5.5\n\t\t\tV 17.2\n\t\t\tL 16.25,5.46\n\t\t\tZ\n\t\n\t\t\tm 33.75,0\n\t\t\tL 50,17\n\t\t\tV 5.5\n\t\t\tZ\n\t\n\t\t\tM 5,40.7\n\t\t\tv 11.7\n\t\t\th 11.25\n\t\t\tz\n\t\n\t\t\tM 26,19\n\t\t\tC 19.8,19.4 17.65,30.4 21.9,34.8\n\t\t\tL 50,70\n\t\t\tH 27.5\n\t\t\tc -11.25,0 -11.25,17.6 0,17.6\n\t\t\tH 61.25\n\t\t\tC 94.9,87.8 95,87.6 95,40.7 78.125,23 67,29 55.6,46.5\n\t\t\tL 33.1,23\n\t\t\tC 30.3125,20.128192 27.9,19 25.830078,19.119756\n\t\t\tZ\n\t\t","none","var(--icon-color)","3")}makeAllDevicePanningIcon(){return this.makeIconFromPath("\n\t\t\tM 5 5\n\t\t\tL 5 17.5\n\t\t\t\t17.5 5\n\t\t\t\t5 5\n\t\t\tz\n\t\n\t\t\tM 42.5 5\n\t\t\tL 55 17.5\n\t\t\t\t55 5\n\t\t\t\t42.5 5\n\t\t\tz\n\t\n\t\t\tM 70 10\n\t\t\tL 70 21\n\t\t\t\t61 15\n\t\t\t\t55.5 23\n\t\t\t\t66 30\n\t\t\t\t56 37\n\t\t\t\t61 45\n\t\t\t\t70 39\n\t\t\t\t70 50\n\t\t\t\t80 50\n\t\t\t\t80 39\n\t\t\t\t89 45\n\t\t\t\t95 36\n\t\t\t\t84 30\n\t\t\t\t95 23\n\t\t\t\t89 15\n\t\t\t\t80 21\n\t\t\t\t80 10\n\t\t\t\t70 10\n\t\t\tz\n\t\n\t\t\tM 27.5 26.25\n\t\t\tL 27.5 91.25\n\t\t\tL 43.75 83.125\n\t\t\tL 52 99\n\t\t\tL 68 91\n\t\t\tL 60 75\n\t\t\tL 76.25 66.875\n\t\t\tL 27.5 26.25\n\t\t\tz\n\t\n\t\t\tM 5 42.5\n\t\t\tL 5 55\n\t\t\tL 17.5 55\n\t\t\tL 5 42.5\n\t\t\tz\n\t\t","none","var(--icon-color)","3")}makeZoomIcon(){const t=document.createElementNS(h,"svg");t.setAttribute("viewBox","0 0 100 100");const e=(e,n,o)=>{const i=document.createElementNS(h,"text");i.appendChild(document.createTextNode(e)),i.setAttribute("x",n.toString()),i.setAttribute("y",o.toString()),i.style.textAlign="center",i.style.textAnchor="middle",i.style.fontSize="55px",i.style.fill="var(--icon-color)",i.style.fontFamily="monospace",t.appendChild(i)};return e("+",40,45),e("-",70,75),t}makeRotationLockIcon(){const t=this.makeIconFromPath("\n\t\t\tM 40.1 25.1 \n\t\t\tC 32.5 25 27.9 34.1 27.9 34.1 \n\t\t\tL 25.7 30 \n\t\t\tL 28 44.7 \n\t\t\tL 36.6 40.3 \n\t\t\tL 32.3 38.3 \n\t\t\tC 33.6 28 38.1 25.2 45.1 31.8 \n\t\t\tL 49.4 29.6 \n\t\t\tC 45.9 26.3 42.8 25.1 40.1 25.1 \n\t\t\tz\n\n\t\t\tM 51.7 34.2 \n\t\t\tL 43.5 39.1 \n\t\t\tL 48 40.8 \n\t\t\tC 47.4 51.1 43.1 54.3 35.7 48.2 \n\t\t\tL 31.6 50.7 \n\t\t\tC 45.5 62.1 52.6 44.6 52.6 44.6 \n\t\t\tL 55.1 48.6 \n\t\t\tL 51.7 34.2 \n\t\t\tz\n\n\t\t\tM 56.9 49.9 \n\t\t\tC 49.8 49.9 49.2 57.3 49.3 60.9 \n\t\t\tL 47.6 60.9 \n\t\t\tL 47.6 73.7 \n\t\t\tL 66.1 73.7 \n\t\t\tL 66.1 60.9 \n\t\t\tL 64.4 60.9 \n\t\t\tC 64.5 57.3 63.9 49.9 56.9 49.9 \n\t\t\tz\n\n\t\t\tM 56.9 53.5 \n\t\t\tC 60.8 53.5 61 58.2 60.8 60.9 \n\t\t\tL 52.9 60.9 \n\t\t\tC 52.7 58.2 52.9 53.5 56.9 53.5 \n\t\t\tz\n\t\t");return t.setAttribute("viewBox","10 10 70 70"),t}makeInsertImageIcon(){return this.makeIconFromPath("\n\t\t\tM 5 10 L 5 90 L 95 90 L 95 10 L 5 10 z\n\t\t\tM 10 15 L 90 15 L 90 50 L 70 75 L 40 50 L 10 75 L 10 15 z\n\t\t\tM 22.5 25 A 7.5 7.5 0 0 0 15 32.5 A 7.5 7.5 0 0 0 22.5 40 A 7.5 7.5 0 0 0 30 32.5 A 7.5 7.5 0 0 0 22.5 25 z \n\t\t")}makeUploadFileIcon(){return this.makeIconFromPath("\n\t\t\tM 48,10 32,34 43,33 42,68\n\t\t\tH 54\n\t\t\tL 53,33 64,34 Z\n\t\n\t\t\tM 8,66 V 86 H 88 V 66 H 78 V 76 H 18 V 66 Z\n\t\t")}makeTextIcon(t){const e=document.createElementNS(h,"svg");e.setAttribute("viewBox","0 0 100 100");const n=document.createElementNS(h,"text");return n.appendChild(document.createTextNode("T")),n.style.fontFamily=t.fontFamily,n.style.fontWeight=t.fontWeight??"",n.style.fontVariant=t.fontVariant??"",n.style.fill=t.renderingStyle.fill.toHexString(),n.style.textAnchor="middle",n.setAttribute("x","50"),n.setAttribute("y","75"),n.style.fontSize="65px",n.style.filter="drop-shadow(0px 0px 10px var(--shadow-color))",e.appendChild(n),e}makePenIcon(t){const e=Math.round(4*Math.sqrt(t.thickness)),n=t.color,o=this.isRoundedTipPen(t),i=document.createElementNS(h,"svg");i.setAttribute("viewBox","0 0 100 100");const r=e/2,s=`\n\t\t\tM ${15-r},${80-r}\n\t\t\t ${15-r},${80+r}\n\t\t\t 30,83\n\t\t\t 15,65\n\t\t\tZ\n\t\t`,l=80+r,c=`\n\t\t\tm ${15-1.1*r},${l}\n\t\t\tc 35,10 55,15 60,30\n\t\t\tl ${35+1.2*r},${-10-r}\n\t\t\tC 80.47,98.32 50.5,${90+r} 20,${l} Z\n\t\t`,d="\n\t\t\tM 72.45,35.67\n\t\t\tA 10,15 41.8 0 1 55,40.2 10,15 41.8 0 1 57.55,22.3 10,15 41.8 0 1 75,17.8 10,15 41.8 0 1 72.5,35.67\n\t\t\tZ\n\t\t";let u="M 85,-25 25,35 h 10 v 10 h 10 v 10 h 10 v 10 h 10 l -5,10 60,-60 z",p="M 25,35 H 35 L 90,-15 85,-25 Z",m="M 60,75 65,65 H 55 l 55,-55 10,5 z";o&&(u="M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z",p="m 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z",m="M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z");const g=`M 25,35 ${10-r/4},${70-r/2} 20,75 25,85 60,75 70,55 45,25 Z`,b=a.Color4.fromHex("#f4d7d7").mix(n,r/40-.1).toHexString(),y=f(),v=`\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${n}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${n}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t`,w=`\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${b}"\n\t\t\t\tstroke="${n}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t`,x=`\n\t\t\t<path\n\t\t\t\t\n\tstyle='fill: var(--icon-color); stroke: var(--icon-color);'\n\n\t\t\t\td="${u}"\n\t\t\t/>\n\n\t\t\t\x3c!-- shadows --\x3e\n\t\t\t<path\n\t\t\t\tfill="rgba(150, 150, 150, 0.3)"\n\t\t\t\td="${p}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="rgba(100, 100, 100, 0.2)"\n\t\t\t\td="${m}"\n\t\t\t/>\n\n\t\t\t\x3c!-- color bubble --\x3e\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${d}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${n}"\n\t\t\t\td="${d}"\n\t\t\t/>\n\t\t`;return i.innerHTML=`\n\t\t<defs>\n\t\t\t${y.patternDef}\n\t\t</defs>\n\t\t<g>\n\t\t\t${v}\n\t\t\t${w}\n\t\t\t${x}\n\t\t</g>\n\t\t`,i}makeIconFromFactory(t){const e=3*Math.sqrt(t.thickness),n=performance.now(),o={pos:a.Vec2.of(10,10),width:e,color:t.color,time:n-100},i={pos:a.Vec2.of(90,90),width:e,color:t.color,time:n},r=new c.default((()=>{})),s=t.factory(o,r);s.addPoint(i);const d=document.createElementNS(h,"svg");let u;d.setAttribute("viewBox","0 0 100 100"),r.updateScreenSize(a.Vec2.of(100,100));if(t.color.a<1){const t=f(),e=document.createElementNS(h,"defs");e.innerHTML=t.patternDef,d.appendChild(e);const n=document.createElementNS(h,"g");d.appendChild(n),u=new class extends l.default{constructor(){super(d,r)}addPathToSVG(){const e=super.addPathToSVG();if(e){const o=e.cloneNode(!0);o.style.zIndex="-1",o.hasAttribute("stroke")?o.setAttribute("stroke",t.patternRef):o.hasAttribute("fill")&&o.setAttribute("fill",t.patternRef),n.appendChild(o)}return e}}}else u=new l.default(d,r);s.preview(u);const p=s.getBBox();return d.setAttribute("viewBox",`${p.x} ${p.y} ${p.w} ${p.h}`),d}makePipetteIcon(t){const e=document.createElementNS(h,"svg"),n=document.createElementNS(h,"g");n.style.rotate="45deg",n.style.transformOrigin="center";const o=document.createElementNS(h,"g");if(o.innerHTML='\n\t\t<path\n\t\t\tstyle="fill: var(--icon-color); stroke-linecap:round; stroke-linejoin:round;"\n\t\t\td="\n\t\t\t\tm 32,12 v 68\n\t\t\t\tc 0,1 0.5,2 1.33,2.5 1.67,1.15 3.67,2.1 5.17,3.2 1.4,1.1 2.3,2.1 2.5,3.1 0.6,2.1 1,4.6 1,6.2 0,3.7 5.45,4.1 6,0.4 l 0.9,-6.8\n\t\t\t\tc 0.3,-0.9 1.1,-1.9 2.6,-2.9 1.5,-1.1 3.4,-2 5.1,-3.2\n\t\t\t\tC 57.5,82 58,81 58,80\n\t\t\t\tV 12 Z m 20,25 v 41.3\n\t\t\t\tc 0,1.7 -2.5,1.6 -4,2.7 -1,0.76 -2.1,1.5 -3,2.6\n\t\t\t\tC 44,82.5 43.02,81.75 42,81 40.51,79.92 38,80 38,78.34\n\t\t\t\tV 51 Z\n\t\t\t"\n\t\t/>\n\t\t<rect\n\t\t\tstyle="fill: var(--icon-color);"\n\t\t\twidth="32"\n\t\t\theight="9"\n\t\t\tx="29"\n\t\t\ty="2"\n\t\t\try="4.5"\n\t\t/>\n\t\t<path\n\t\t\tstyle="fill: var(--icon-color);"\n\t\t\td="m 45,-25 c -5.54,0 -11,4.26 -11,9 V 0 h 22 v -16 c 0,-4.74 -5.46,-9 -11,-9 z"\n\t\t/>\n\t\t',t){const o=f(),i=document.createElementNS(h,"defs");i.innerHTML=o.patternDef,e.appendChild(i);const r=document.createElementNS(h,"path"),s=document.createElementNS(h,"path"),a="\n\t\t\t\tM 35,36 H 55 V 78.678012 83 L 45,87 35,83 Z\n\t\t\t";s.setAttribute("d",a),r.setAttribute("d",a),s.style.fill=t.toHexString(),r.style.fill=o.patternRef,n.appendChild(r),n.appendChild(s)}return n.appendChild(o),e.appendChild(n),e.setAttribute("viewBox","5 -40 140 140"),e}makeFormatSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 5 10\n\t\t\tL 5 20 L 10 20 L 10 15 L 20 15 L 20 40 L 15 40 L 15 45 L 35 45 L 35 40 L 30 40 L 30 15 L 40 15 L 40 20 L 45 20 L 45 15 L 45 10 L 5 10 z\n\t\t\tM 90 10 C 90 10 86.5 13.8 86 14 C 86 14 76.2 24.8 76 25 L 60 25 L 60 65 C 75 70 85 70 90 65 L 90 25 L 80 25 L 76.7 25 L 90 10 z\n\t\t\tM 60 25 L 55 25 L 50 30 L 60 25 z\n\t\t\tM 10 55 L 10 90 L 41 90 L 41 86 L 45 86 L 45 55 L 10 55 z\n\t\t\tM 42 87 L 42 93 L 48 93 L 48 87 L 42 87 z \n\t\t")}makeResizeImageToSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 75 5 75 10 90 10 90 25 95 25 95 5 75 5 z\n\t\t\tM 15 15 15 30 20 30 20 20 30 20 30 15 15 15 z\n\t\t\tM 84 15 82 17 81 16 81 20 85 20 84 19 86 17 84 15 z\n\t\t\tM 26 24 24 26 26 28 25 29 29 29 29 25 28 26 26 24 z\n\t\t\tM 25 71 26 72 24 74 26 76 28 74 29 75 29 71 25 71 z\n\t\t\tM 15 75 15 85 25 85 25 80 20 80 20 75 15 75 z\n\t\t\tM 90 75 90 90 75 90 75 95 95 95 95 75 90 75 z\n\t\t\tM 81 81 81 85 82 84 84 86 86 84 84 82 85 81 81 81 z\n\t\t")}makeResizeViewportIcon(){return this.makeResizeImageToSelectionIcon()}makeDuplicateSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 45,10 45,55 90,55 90,10 45,10 z\n\t\t\tM 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z \n\t\t")}makePasteIcon(){const t=this.makeIconFromPath("\n\t\t\tM 50 0 L 50 5 L 35 5 L 40 24.75 L 20 25 L 20 100 L 85 100 L 100 90 L 100 24 L 75.1 24.3 L 80 5 L 65 5 L 65 0 L 50 0 z\n\t\t\tM 10 15 L 10 115 L 110 115 L 110 15 L 85 15 L 83 20 L 105 20 L 105 110 L 15 110 L 15 20 L 32 20 L 30 15 L 10 15 z\n\t\t\tM 25 35 L 90 35 L 90 40 L 25 40 L 25 35 z\n\t\t\tM 25 45 L 90 45 L 90 50 L 25 50 L 25 45 z\n\t\t\tM 25 55 L 85 55 L 85 60 L 25 60 L 25 55 z\n\t\t\tM 25 65 L 90 65 L 90 70 L 25 70 L 25 65 z \n\t\t");return t.setAttribute("viewBox","0 0 120 120"),t}makeDeleteSelectionIcon(){return r(this,o,"m",i).call(this)}makeCloseIcon(){return r(this,o,"m",i).call(this)}makeSaveIcon(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.innerHTML="\n\t\t\t<style>\n\t\t\t\t.toolbar-save-icon {\n\t\t\t\t\tstroke: var(--icon-color);\n\t\t\t\t\tstroke-width: 6;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tfill: none;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<path\n\t\t\t\td='\n\t\t\t\t\tM 15,55 30,70 85,20\n\t\t\t\t'\n\t\t\t\tclass='toolbar-save-icon'\n\t\t\t/>\n\t\t",t.setAttribute("viewBox","0 0 100 100"),t}makeConfigureDocumentIcon(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.innerHTML="\n\t\t\t<path\n\t\t\t\td='\n\t\t\t\t\tM 5,5 V 95 H 95 V 5 Z m 5,5 H 90 V 90 H 10 Z\n\t\t\t\t\tm 5,10 V 30 H 50 V 25 H 20 v -5 z\n\t\t\t\t\tm 40,0 V 50 H 85 V 20 Z\n\t\t\t\t\tm 2,2 H 83 V 39 L 77,28 70,42 64,35 57,45 Z\n\t\t\t\t\tm 8.5,5 C 64.67,27 64,27.67 64,28.5 64,29.33 64.67,30 65.5,30 66.33,30 67,29.33 67,28.5 67,27.67 66.33,27 65.5,27 Z\n\t\t\t\t\tM 15,40 v 5 h 35 v -5 z\n\t\t\t\t\tm 0,15 v 5 h 70 v -5 z\n\t\t\t\t\tm 0,15 v 5 h 70 v -5 z\n\t\t\t\t'\n\t\t\t\tstyle='fill: var(--icon-color);'\n\t\t\t/>\n\t\t",t.setAttribute("viewBox","0 0 100 100"),t}makeOverflowIcon(){return this.makeIconFromPath("\n\t\t\tM 15 40\n\t\t\tA 12.5 12.5 0 0 0 2.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 15 65\n\t\t\tA 12.5 12.5 0 0 0 27.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 15 40\n\t\t\tz\n\t\n\t\t\tM 50 40\n\t\t\tA 12.5 12.5 0 0 0 37.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 50 65\n\t\t\tA 12.5 12.5 0 0 0 62.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 50 40\n\t\t\tz\n\t\t\t\n\t\t\tM 85 40\n\t\t\tA 12.5 12.5 0 0 0 72.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 85 65\n\t\t\tA 12.5 12.5 0 0 0 97.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 85 40\n\t\t\tz\n\t\t")}makeIconFromPath(t,e="var(--icon-color)",n="none",o="0px"){const i=document.createElementNS(h,"svg"),r=document.createElementNS(h,"path");return r.setAttribute("d",t),r.style.fill=e,r.style.stroke=n,r.style.strokeWidth=o,i.appendChild(r),i.setAttribute("viewBox","0 0 100 100"),i}makeCheckerboardPattern(){return f()}isRoundedTipPen(t){return t.factory===d.makeFreehandLineBuilder}licenseInfo(){return null}}},5698:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toolbarCSSPrefix=void 0,e.toolbarCSSPrefix="toolbar-"},2994:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeEdgeToolbar=e.makeDropdownToolbar=e.IconProvider=void 0,i(n(7321),e),i(n(425),e);var s=n(8282);Object.defineProperty(e,"IconProvider",{enumerable:!0,get:function(){return r(s).default}});var a=n(9997);Object.defineProperty(e,"makeDropdownToolbar",{enumerable:!0,get:function(){return a.makeDropdownToolbar}});var l=n(5221);Object.defineProperty(e,"makeEdgeToolbar",{enumerable:!0,get:function(){return l.makeEdgeToolbar}})},9746:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarLocalization=void 0,e.defaultToolbarLocalization={pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text",chooseFile:"Choose file",dragAndDropHereOrBrowse:"Drag and drop here\nor\n{{browse}}",submit:"Submit",cancel:"Cancel",resetView:"Reset view",thicknessLabel:"Thickness",colorLabel:"Color",fontLabel:"Font",textSize:"Size",resizeImageToSelection:"Resize image to selection",deleteSelection:"Delete selection",duplicateSelection:"Duplicate selection",exit:"Exit",save:"Save",undo:"Undo",redo:"Redo",selectPenTip:"Pen tip",selectShape:"Shape",pickColorFromScreen:"Pick color from screen",clickToPickColorAnnouncement:"Click on the screen to pick a color",colorSelectionCanceledAnnouncement:"Color selection canceled",selectionToolKeyboardShortcuts:"Selection tool: Use arrow keys to move selected items, lowercase/uppercase ‘i’ and ‘o’ to resize.",documentProperties:"Page",backgroundColor:"Background color",imageWidthOption:"Width",imageHeightOption:"Height",useGridOption:"Grid",enableAutoresizeOption:"Auto-resize",toggleOverflow:"More",about:"About",inputStabilization:"Input stabilization",touchPanning:"Touchscreen panning",roundedTipPen:"Round",flatTipPen:"Flat",arrowPen:"Arrow",linePen:"Line",outlinedRectanglePen:"Outlined rectangle",filledRectanglePen:"Filled rectangle",outlinedCirclePen:"Outlined circle",lockRotation:"Lock rotation",paste:"Paste",closeSidebar:t=>`Close sidebar for ${t}`,dropdownShown:t=>`Menu for ${t} shown`,dropdownHidden:t=>`Menu for ${t} hidden`,zoomLevel:t=>`Zoom: ${t}%`,colorChangedAnnouncement:t=>`Color changed to ${t}`,imageSize:(t,e)=>`Image size: ${t} ${e}`,errorImageHasZeroSize:"Error: Image has zero size",imageLoadError:t=>`Error loading image: ${t}`}},3534:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3258));class r extends i.default{constructor(t,e,n,o,i,r,s=!1){super(t,e,r),this.makeIcon=n,this.title=o,this.clickAction=i,this.mustBeToplevel=s}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}mustBeInToplevelMenu(){return this.mustBeToplevel}}e.default=r},1421:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=o(n(3258)),s=n(5698);class a extends r.default{constructor(t,e,n,o){super(t,n,o),this.targetTool=e,t.notifier.on(i.EditorEventType.ToolEnabled,(t=>{if(t.kind!==i.EditorEventType.ToolEnabled)throw new Error("Incorrect event type! (Expected ToolEnabled)");t.tool===e&&(this.setSelected(!0),(()=>{const t=[...document.querySelectorAll("*:focus")];return t.length&&t.some((t=>t.classList.contains(`${s.toolbarCSSPrefix}button`)))})()&&this.focus())})),t.notifier.on(i.EditorEventType.ToolDisabled,(t=>{if(t.kind!==i.EditorEventType.ToolDisabled)throw new Error("Incorrect event type! (Expected ToolDisabled)");t.tool===e&&(this.setSelected(!1),this.setDropdownVisible(!1))}))}handleClick(){this.hasDropdown?this.targetTool.isEnabled()?this.setDropdownVisible(!this.isDropdownVisible()):(this.targetTool.setEnabled(!0),this.activateDropdown()):this.targetTool.setEnabled(!this.targetTool.isEnabled())}onKeyPress(t){return!(!this.isSelected()||" "!==t.key||!this.hasDropdown)&&(this.handleClick(),!0)}addTo(t){const e=super.addTo(t);return this.setSelected(this.targetTool.isEnabled()),e}}e.default=a},3258:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ToolbarWidgetTag=void 0;const l=a(n(6390)),c=n(7520),d=n(5698),h=a(n(4477));var u;!function(t){t.Save="save",t.Exit="exit",t.Undo="undo",t.Redo="redo"}(u||(e.ToolbarWidgetTag=u={}));class p{constructor(t,e,n){this.editor=t,this.id=e,this.dropdown=null,o.set(this,void 0),this.disabled=!1,i.set(this,[]),this.subWidgets={},this.toplevel=!0,this.localizationTable=n??t.localization;const s=new h.default((t=>this.editor.announceForAccessibility(t)),this.localizationTable);s.connectToEditorNotifier(t.notifier),this.layoutManager=s,this.icon=null,this.container=document.createElement("div"),this.container.classList.add(`${d.toolbarCSSPrefix}toolContainer`,`${d.toolbarCSSPrefix}toolButtonContainer`),this.dropdownContent=document.createElement("div"),r(this,o,!1,"f"),this.button=document.createElement("div"),this.button.classList.add(`${d.toolbarCSSPrefix}button`),this.label=document.createElement("label"),this.button.setAttribute("role","button"),this.button.tabIndex=0,this.button.oncontextmenu=t=>{t.preventDefault()};const a=this.editor.toolController.getMatchingTools(l.default);a.length>0&&this.onKeyPress!==p.prototype.onKeyPress&&a[0].registerListener((t=>this.onKeyPress(t)))}getId(){return this.id}setTags(t){const e=t=>`toolwidget-tag--${t}`;for(const t of s(this,i,"f"))this.container.classList.remove(e(t));r(this,i,[...t],"f");for(const t of s(this,i,"f"))this.container.classList.add(e(t))}getTags(){return[...s(this,i,"f")]}getUniqueIdIn(t){let e=this.getId(),n=0;for(;e in t&&t[e]!==this;)e=this.getId()+"-"+n.toString(),n++;return e}fillDropdown(t){if(0===Object.keys(this.subWidgets).length)return!1;for(const e in this.subWidgets){const n=this.subWidgets[e];n.addTo(t),n.setIsToplevel(!1)}return!0}setupActionBtnClickListener(t){return this.setUpButtonEventListeners(t)}setUpButtonEventListeners(t){const e={Enter:!0," ":!0};t.onkeydown=t=>{let n=!1;if(t.key in e&&(this.disabled||(this.handleClick(),n=!0)),!n){const e=(0,c.keyPressEventFromHTMLEvent)(t);n=this.editor.toolController.dispatchInputEvent(e)}n&&t.preventDefault()},t.onkeyup=t=>{if(t.key in e)return;const n=(0,c.keyUpEventFromHTMLEvent)(t);this.editor.toolController.dispatchInputEvent(n)&&t.preventDefault()},t.onclick=()=>{this.disabled||this.handleClick()},t.ondblclick=t=>{t.preventDefault()}}onKeyPress(t){return!1}get hasDropdown(){return s(this,o,"f")}addSubWidget(t){const e=t.getUniqueIdIn(this.subWidgets);this.subWidgets[e]=t}setLayoutManager(t){t!==this.layoutManager&&(this.layoutManager=t,this.container.parentElement&&this.addTo(this.container.parentElement))}addTo(t){this.icon=null,this.updateIcon(),this.label.innerText=this.getTitle();const e="long-label";return this.label.innerText.length>7?this.label.classList.add(e):this.label.classList.remove(e),this.setUpButtonEventListeners(this.button),this.container.replaceChildren(),this.button.replaceChildren(this.icon,this.label),this.container.appendChild(this.button),this.dropdownContent.replaceChildren(),r(this,o,this.fillDropdown(this.dropdownContent),"f"),s(this,o,"f")&&(this.button.classList.add("has-dropdown"),this.dropdown?.destroy(),this.dropdownIcon=this.createDropdownIcon(),this.button.appendChild(this.dropdownIcon),this.dropdown=this.layoutManager.createToolMenu({target:this.button,getTitle:()=>this.getTitle(),isToplevel:()=>this.toplevel}),this.dropdown.visible.onUpdate((t=>{t?this.container.classList.add("dropdownVisible"):this.container.classList.remove("dropdownVisible"),t||this.focus()})),this.dropdown.appendChild(this.dropdownContent)),this.setDropdownVisible(!1),this.container.parentElement&&this.container.remove(),t.appendChild(this.container),this.container}focus(){this.button.focus()}addCSSClassToContainer(t){this.container.classList.add(t)}removeCSSClassFromContainer(t){this.container.classList.remove(t)}remove(){this.container.remove()}updateIcon(){let t=this.createIcon();t?this.container.classList.remove("no-icon"):(t=document.createElement("div"),this.container.classList.add("no-icon")),this.icon?.replaceWith(t),this.icon=t,this.icon.classList.add(`${d.toolbarCSSPrefix}icon`)}setDisabled(t){this.disabled=t,this.disabled?(this.button.classList.add("disabled"),this.button.setAttribute("aria-disabled","true")):(this.button.classList.remove("disabled"),this.button.removeAttribute("aria-disabled"))}setSelected(t){this.isSelected()!==t&&(this.button.setAttribute("role","switch"),t?(this.container.classList.add("selected"),this.button.setAttribute("aria-checked","true")):(this.container.classList.remove("selected"),this.button.setAttribute("aria-checked","false")))}setDropdownVisible(t){t?this.dropdown?.requestShow():this.dropdown?.requestHide()}activateDropdown(){this.dropdown?.onActivated()}mustBeInToplevelMenu(){return!1}canBeInOverflowMenu(){return!this.mustBeInToplevelMenu()}getButtonWidth(){return this.button.clientWidth}isHidden(){return"none"===this.container.style.display}setHidden(t){this.container.style.display=t?"none":""}setIsToplevel(t){this.toplevel=t}isDropdownVisible(){return this.dropdown?.visible?.get()??!1}isSelected(){return this.container.classList.contains("selected")}createDropdownIcon(){const t=this.editor.icons.makeDropdownIcon();return t.classList.add(`${d.toolbarCSSPrefix}showHideDropdownIcon`),t}serializeState(){const t={};for(const e in this.subWidgets)t[e]=this.subWidgets[e].serializeState();return{subwidgetState:t}}deserializeFrom(t){if(t.subwidgetState)for(const e in t.subwidgetState)e in this.subWidgets&&this.subWidgets[e].deserializeFrom(t.subwidgetState[e])}}o=new WeakMap,i=new WeakMap,e.default=p},5771:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(9721)),l=s(n(1456)),c=r(n(1847)),d=n(7551),h=n(5097),u=n(3173),p=n(5698),f=s(n(425)),m=s(n(3258));class g extends m.default{constructor(t,e){super(t,"document-properties-widget",e),this.updateDropdownContent=()=>{},this.dropdownUpdateQueued=!1,this.container.classList.add("dropdownShowable"),this.editor.notifier.on(u.EditorEventType.UndoRedoStackUpdated,(()=>{this.queueDropdownUpdate()})),this.editor.image.notifier.on(d.EditorImageEventType.ExportViewportChanged,(()=>{this.queueDropdownUpdate()}))}getTitle(){return this.localizationTable.documentProperties}createIcon(){return this.editor.icons.makeConfigureDocumentIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible()),this.queueDropdownUpdate()}queueDropdownUpdate(){this.dropdownUpdateQueued||(requestAnimationFrame((()=>this.updateDropdown())),this.dropdownUpdateQueued=!0)}updateDropdown(){this.dropdownUpdateQueued=!1,this.isDropdownVisible()&&this.updateDropdownContent()}setBackgroundColor(t){this.editor.dispatch(this.editor.setBackgroundColor(t))}getBackgroundColor(){return this.editor.estimateBackgroundColor()}removeBackgroundComponents(){const t=[];for(const e of this.editor.image.getBackgroundComponents())e instanceof c.default&&t.push(e);return new a.default(t)}setBackgroundType(t){const e=this.editor.estimateBackgroundColor(),n=new c.default(t,e),o=this.editor.image.addElement(n);return(0,l.default)([this.removeBackgroundComponents(),o])}getBackgroundType(){const t=this.editor.image.getBackgroundComponents();for(let e=t.length-1;e>=0;e--){const n=t[e];if(n instanceof c.default)return n.getBackgroundType()}return c.BackgroundType.None}updateImportExportRectSize(t){const e=t=>(void 0!==t&&(!isFinite(t)||t<=0)&&(t=100),t),n=e(t.width),o=e(t.height),i=this.editor.getImportExportRect(),r=new h.Rect2(i.x,i.y,n??i.w,o??i.h);this.editor.dispatch(this.editor.image.setImportExportRect(r)),this.editor.queueRerender()}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}spacedList`,`${p.toolbarCSSPrefix}nonbutton-controls-main-list`,`${p.toolbarCSSPrefix}document-properties-widget`);const{backgroundColorRow:n,setBgColorInputValue:o}=(()=>{const t=document.createElement("div"),e=document.createElement("label");e.innerText=this.localizationTable.backgroundColor;const{input:n,container:o,setValue:i}=(0,f.default)(this.editor,(t=>{t.eq(this.getBackgroundColor())||this.setBackgroundColor(t)}));return n.id=`${p.toolbarCSSPrefix}docPropertiesColorInput-${g.idCounter++}`,e.htmlFor=n.id,t.replaceChildren(e,o),{setBgColorInputValue:i,backgroundColorRow:t}})(),i=(t,e)=>{const n=document.createElement("div"),o=document.createElement("label"),i=document.createElement("input");return i.id=`${p.toolbarCSSPrefix}docPropertiesCheckbox-${g.idCounter++}`,o.htmlFor=i.id,i.type="checkbox",o.innerText=t,i.oninput=()=>{e(i.checked)},n.replaceChildren(o,i),{container:n,checkbox:i}},{container:r,checkbox:s}=i(this.localizationTable.useGridOption,(t=>{if(this.getBackgroundType()===c.BackgroundType.Grid===t)return;let e=c.BackgroundType.SolidColor;t&&(e=c.BackgroundType.Grid),this.editor.dispatch(this.setBackgroundType(e))})),a=(t,e)=>{const n=document.createElement("div"),o=document.createElement("label"),i=document.createElement("input");return o.innerText=t,i.type="number",i.min="0",i.id=`${p.toolbarCSSPrefix}docPropertiesDimensionRow-${g.idCounter++}`,o.htmlFor=i.id,i.style.flexGrow="2",i.style.width="25px",i.oninput=()=>{e(parseFloat(i.value))},n.classList.add("js-draw-size-input-row"),n.replaceChildren(o,i),{setValue:t=>{i.value=t.toString()},setIsAutomaticSize:t=>{i.disabled=t;const e="size-input-row--automatic-size";t?n.classList.add(e):n.classList.remove(e)},element:n}},l=a(this.localizationTable.imageWidthOption,(t=>{this.updateImportExportRectSize({width:t})})),d=a(this.localizationTable.imageHeightOption,(t=>{this.updateImportExportRectSize({height:t})})),{container:h,checkbox:u}=i(this.localizationTable.enableAutoresizeOption,(t=>{const e=this.editor.image;this.editor.dispatch(e.setAutoresizeEnabled(t))})),m=document.createElement("button");return m.classList.add("about-button"),m.innerText=this.localizationTable.about,m.onclick=()=>{this.editor.showAboutDialog()},this.updateDropdownContent=()=>{o(this.getBackgroundColor());const t=this.editor.image.getAutoresizeEnabled(),e=this.editor.getImportExportRect();l.setValue(e.width),d.setValue(e.height),u.checked=t,l.setIsAutomaticSize(t),d.setIsAutomaticSize(t),s.checked=this.getBackgroundType()===c.BackgroundType.Grid},this.updateDropdownContent(),e.replaceChildren(n,r,l.element,d.element,h,m),t.replaceChildren(e),!0}}g.idCounter=0,e.default=g},9944:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=n(5698),s=o(n(1421)),a=o(n(8392));class l extends s.default{constructor(t,e,n){super(t,e,"eraser-tool-widget",n),this.tool=e,this.updateInputs=()=>{},this.editor.notifier.on(i.EditorEventType.ToolUpdated,(t=>{t.kind===i.EditorEventType.ToolUpdated&&t.tool===this.tool&&(this.updateInputs(),this.updateIcon())}))}getTitle(){return this.localizationTable.eraser}createIcon(){return this.editor.icons.makeEraserIcon(this.tool.getThickness())}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${r.toolbarCSSPrefix}spacedList`,`${r.toolbarCSSPrefix}nonbutton-controls-main-list`);const n=(0,a.default)(this.editor,(t=>{this.tool.setThickness(t)}));n.setBounds(10,55),this.updateInputs=()=>{n.setValue(this.tool.getThickness())},this.updateInputs();const o=document.createElement("div");return o.style.height="5px",e.replaceChildren(n.container,o),t.replaceChildren(e),!0}serializeState(){return{...super.serializeState(),thickness:this.tool.getThickness()}}deserializeFrom(t){if(super.deserializeFrom(t),t.thickness){const e=parseFloat(t.thickness);if("number"!=typeof e||!isFinite(e))throw new Error(`Deserializing property ${e} is not a number or is not finite.`);this.tool.setThickness(e)}}}e.default=l},7956:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=r(n(4735)),c=n(3173),d=s(n(5566)),h=n(5698),u=s(n(1421)),p=s(n(3258)),f=s(n(3595));class m extends p.default{constructor(t,e,n,o,i,r){super(t,`pan-mode-${n}`,r),this.tool=e,this.flag=n,this.makeIcon=o,this.title=i,t.notifier.on(c.EditorEventType.ToolUpdated,(t=>{if(t.kind===c.EditorEventType.ToolUpdated&&t.tool===e){const t=!!(e.getMode()&l.PanZoomMode.SinglePointerGestures);this.setSelected(!!(e.getMode()&n)||t),this.setDisabled(t&&n!==l.PanZoomMode.SinglePointerGestures)}})),this.setSelected(!1)}setModeFlag(t){this.tool.setModeEnabled(this.flag,t)}handleClick(){this.setModeFlag(!this.isSelected())}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}}class g extends u.default{constructor(t,e,n){const o=g.getPrimaryHandTool(t.toolController);super(t,o??e,"hand-tool-widget",n),this.overridePanZoomTool=e,this.allowTogglingBaseTool=null!==o,this.allowTogglingBaseTool||this.container.classList.add("dropdownShowable");const i=new m(t,e,l.PanZoomMode.OneFingerTouchGestures,(()=>this.editor.icons.makeTouchPanningIcon()),n.touchPanning,n),r=new m(t,e,l.PanZoomMode.RotationLocked,(()=>this.editor.icons.makeRotationLockIcon()),n.lockRotation,n);this.addSubWidget(i),this.addSubWidget(r)}static getPrimaryHandTool(t){return t.getPrimaryTools().filter((t=>t instanceof l.default))[0]}getTitle(){return this.localizationTable.handTool}createIcon(){return this.editor.icons.makeHandToolIcon()}handleClick(){this.allowTogglingBaseTool?super.handleClick():this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){super.fillDropdown(t);const e=document.createElement("div");return e.classList.add(`${h.toolbarCSSPrefix}nonbutton-controls-main-list`),(0,f.default)().addTo(e),e.appendChild(((t,e)=>{const n=document.createElement("div"),o=document.createElement("button"),i=document.createElement("button"),r=document.createElement("button"),s=document.createElement("span");let l;o.innerText="+",i.innerText="-",r.innerText=t.resetView,n.replaceChildren(s,o,i,r),n.classList.add(`${h.toolbarCSSPrefix}zoomLevelEditor`),s.classList.add("zoomDisplay");const u=()=>{let n=100*e.viewport.getScaleFactor();n=n>.1?Math.round(10*n)/10:Math.round(1e3*n)/1e3,n!==l&&(s.innerText=t.zoomLevel(n),l=n)};u(),e.notifier.on(c.EditorEventType.ViewportChanged,(t=>{t.kind===c.EditorEventType.ViewportChanged&&(u(),r.disabled=t.newTransform.eq(a.Mat33.identity))}));const p=t=>{const n=e.viewport.visibleRect.center,o=a.Mat33.scaling2D(t,n);e.dispatch(d.default.transformBy(o),!1)};return o.onclick=()=>{p(5/4)},i.onclick=()=>{p(.8)},r.onclick=()=>{e.dispatch(d.default.transformBy(e.viewport.canvasToScreenTransform.inverse()),!1)},n})(this.localizationTable,this.editor)),t.appendChild(e),!0}setSelected(t){this.allowTogglingBaseTool&&super.setSelected(t)}serializeState(){const t=this.overridePanZoomTool.getMode();return{...super.serializeState(),touchPanning:t&l.PanZoomMode.OneFingerTouchGestures,rotationLocked:t&l.PanZoomMode.RotationLocked}}deserializeFrom(t){void 0!==t.touchPanning&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.OneFingerTouchGestures,t.touchPanning),void 0!==t.rotationLocked&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.RotationLocked,t.rotationLocked),super.deserializeFrom(t)}}e.default=g},6318:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7077)),r=o(n(9721)),s=o(n(7551)),a=o(n(1456)),l=o(n(7591)),c=n(5097),d=o(n(9070)),h=o(n(3258)),u=n(3173),p=n(5698),f=o(n(7993));class m extends h.default{constructor(t,e){e??=t.localization,super(t,"insert-image-widget",e),this.container.classList.add("dropdownShowable"),t.notifier.on(u.EditorEventType.SelectionUpdated,(t=>{t.kind===u.EditorEventType.SelectionUpdated&&this.isDropdownVisible()&&this.updateInputs()}))}getTitle(){return this.localizationTable.image}createIcon(){return this.editor.icons.makeInsertImageIcon()}setDropdownVisible(t){super.setDropdownVisible(t),this.isDropdownVisible()&&this.updateInputs()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){const e=document.createElement("div");e.classList.add("insert-image-widget-dropdown-content",`${p.toolbarCSSPrefix}spacedList`,`${p.toolbarCSSPrefix}nonbutton-controls-main-list`);const{container:n,selectedFiles:o}=(0,f.default)(this.localizationTable.chooseFile,this.editor,"image/*"),i=document.createElement("div");this.imagePreview=document.createElement("img"),this.statusView=document.createElement("div");const r=document.createElement("div");r.classList.add("action-button-row"),this.submitButton=document.createElement("button"),this.selectedFiles=o,this.imageAltTextInput=document.createElement("input");const s=document.createElement("label"),a="insert-image-alt-text-input-"+m.nextInputId++;return this.imageAltTextInput.setAttribute("id",a),s.htmlFor=a,s.innerText=this.localizationTable.inputAltText,this.imageAltTextInput.type="text",this.statusView.setAttribute("aria-live","polite"),this.submitButton.innerText=this.localizationTable.submit,this.selectedFiles.onUpdateAndNow((async t=>{if(0===t.length)return this.imagePreview.style.display="none",this.submitButton.disabled=!0,void(this.submitButton.style.display="none");this.imagePreview.style.display="block";const e=t[0];let n=null;try{n=await(0,d.default)(e)}catch(t){this.statusView.innerText=this.localizationTable.imageLoadError(t)}this.imageBase64URL=n,n?(this.imagePreview.src=n,this.submitButton.disabled=!1,this.submitButton.style.display="",this.updateImageSizeDisplay()):(this.submitButton.disabled=!0,this.submitButton.style.display="none",this.statusView.innerText="")})),i.replaceChildren(s,this.imageAltTextInput),r.replaceChildren(this.submitButton),e.replaceChildren(n,i,this.imagePreview,this.statusView,r),t.replaceChildren(e),!0}hideDialog(){this.setDropdownVisible(!1)}updateImageSizeDisplay(){const t=(this.imageBase64URL??"").length/1024,e=t/1024;let n="KiB",o=t;e>=1&&(o=e,n="MiB"),this.statusView.innerText=this.localizationTable.imageSize(Math.round(o),n)}updateInputs(){(()=>{this.selectedFiles?.set([]),this.imageAltTextInput.value="",this.imagePreview.style.display="none",this.submitButton.disabled=!0,this.statusView.innerText="",this.submitButton.style.display="",this.imageAltTextInput.oninput=null})();const t=this.editor.toolController.getMatchingTools(l.default),e=t.map((t=>t.getSelectedObjects())).flat();let n=null;1===e.length&&e[0]instanceof i.default?(n=e[0],this.imageAltTextInput.value=n.getAltText()??"",this.imagePreview.style.display="block",this.submitButton.disabled=!1,this.imageBase64URL=n.getURL(),this.imagePreview.src=this.imageBase64URL,this.updateImageSizeDisplay()):e.length>0&&t.forEach((t=>t.clearSelection())),this.submitButton.style.display="none",this.imageAltTextInput.oninput=()=>{this.imagePreview.src?.length>0&&(this.submitButton.style.display="")},this.submitButton.onclick=async()=>{if(!this.imageBase64URL)return;const e=new Image;e.src=this.imageBase64URL,e.setAttribute("alt",this.imageAltTextInput.value);const o=await i.default.fromImage(e,c.Mat33.identity);if(0!==o.getBBox().area)if(this.hideDialog(),n){const e=new r.default([n]);await this.editor.dispatch((0,a.default)([s.default.addElement(o),o.transformBy(n.getTransformation()),o.setZIndex(n.getZIndex()),e])),t[0]?.setSelection([o])}else await this.editor.addAndCenterComponents([o]);else this.statusView.innerText=this.localizationTable.errorImageHasZeroSize}}}m.nextInputId=0,e.default=m},3359:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3258));class r extends i.default{constructor(t,e){super(t,"overflow-widget",e),this.overflowChildren=[],this.container.classList.add("toolbar-overflow-widget"),this.container.classList.add("dropdownShowable"),this.overflowContainer??=document.createElement("div")}getTitle(){return this.localizationTable.toggleOverflow}createIcon(){return this.editor.icons.makeOverflowIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){return this.overflowContainer??=document.createElement("div"),this.overflowContainer.parentElement&&this.overflowContainer.remove(),this.overflowContainer.classList.add("toolbar-overflow-widget-overflow-list"),t.appendChild(this.overflowContainer),!0}clearChildren(){this.overflowContainer.replaceChildren(),this.container.classList.remove("horizontal");const t=this.overflowChildren;return this.overflowChildren=[],t}getChildWidgets(){return[...this.overflowChildren]}hasAsChild(t){for(const e of this.overflowChildren)if(t===e)return!0;return!1}addToOverflow(t){this.overflowChildren.push(t),t.addTo(this.overflowContainer),t.setIsToplevel(!1),this.overflowChildren.length>2&&this.container.classList.add("horizontal")}canBeInOverflowMenu(){return!1}}e.default=r},7998:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(9274),r=n(6951),s=n(823),a=n(725),l=n(4666),c=n(7973),d=n(3173),h=o(n(425)),u=o(n(1421)),p=n(5097),f=n(3240),m=n(5698),g=o(n(8392)),b=o(n(8650));class y extends u.default{constructor(t,e,n){super(t,e,"pen",n),this.tool=e,this.updateInputs=()=>{},this.shapelikeIDs=["pressure-sensitive-pen","freehand-pen"],this.penTypes=[{name:this.localizationTable.flatTipPen,id:"pressure-sensitive-pen",factory:s.makePressureSensitiveFreehandLineBuilder},{name:this.localizationTable.roundedTipPen,id:"freehand-pen",factory:r.makeFreehandLineBuilder},{name:this.localizationTable.arrowPen,id:"arrow",isShapeBuilder:!0,factory:i.makeArrowBuilder},{name:this.localizationTable.linePen,id:"line",isShapeBuilder:!0,factory:a.makeLineBuilder},{name:this.localizationTable.filledRectanglePen,id:"filled-rectangle",isShapeBuilder:!0,factory:l.makeFilledRectangleBuilder},{name:this.localizationTable.outlinedRectanglePen,id:"outlined-rectangle",isShapeBuilder:!0,factory:l.makeOutlinedRectangleBuilder},{name:this.localizationTable.outlinedCirclePen,id:"outlined-circle",isShapeBuilder:!0,factory:c.makeOutlinedCircleBuilder}],this.editor.notifier.on(d.EditorEventType.ToolUpdated,(t=>{if(t.kind!==d.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");t.tool===this.tool&&(this.updateIcon(),this.updateInputs())}))}getTitle(){return this.targetTool.description}getCurrentPenTypeIdx(){const t=this.tool.getStrokeFactory();for(let e=0;e<this.penTypes.length;e++)if(this.penTypes[e].factory===t)return e;return-1}getCurrentPenType(){for(const t of this.penTypes)if(t.factory===this.tool.getStrokeFactory())return t;return null}createIconForRecord(t){const e={...this.tool.getStyleValue().get()};t?.factory&&(e.factory=t.factory);const n=t?.factory;return n&&n!==r.makeFreehandLineBuilder&&n!==s.makePressureSensitiveFreehandLineBuilder?this.editor.icons.makeIconFromFactory(e):this.editor.icons.makePenIcon(e)}createIcon(){return this.createIconForRecord(this.getCurrentPenType())}createPenTypeSelector(){const t=this.penTypes.map(((t,e)=>({id:e,makeIcon:()=>this.createIconForRecord(t),title:t.name,isShapeBuilder:t.isShapeBuilder??!1}))),e=(0,b.default)(this.localizationTable.selectPenTip,this.getCurrentPenTypeIdx(),t.filter((t=>!t.isShapeBuilder))),n=(0,b.default)(this.localizationTable.selectShape,this.getCurrentPenTypeIdx(),t.filter((t=>t.isShapeBuilder))),o=t=>{this.tool.setStrokeFactory(this.penTypes[t].factory)};return e.value.onUpdate(o),n.value.onUpdate(o),{setValue:t=>{e.value.set(t),n.value.set(t)},updateIcons:()=>{e.updateIcons(),n.updateIcons()},addTo:t=>{e.addTo(t),n.addTo(t)}}}setInputStabilizationEnabled(t){this.tool.setHasStabilization(t)}createStabilizationOption(){const t=document.createElement("div"),e=document.createElement("input"),n=document.createElement("label");return n.innerText=this.localizationTable.inputStabilization,e.type="checkbox",e.id=`${m.toolbarCSSPrefix}-penInputStabilizationCheckbox-${y.idCounter++}`,n.htmlFor=e.id,t.replaceChildren(n,e),e.oninput=()=>{this.setInputStabilizationEnabled(e.checked)},{update:()=>{e.checked=!!this.tool.getInputMapper()},addTo:e=>{e.appendChild(t)}}}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${m.toolbarCSSPrefix}spacedList`,`${m.toolbarCSSPrefix}nonbutton-controls-main-list`);const{container:n,setValue:o}=(0,g.default)(this.editor,(t=>{this.tool.setThickness(t)})),i=this.createPenTypeSelector(),r=document.createElement("div"),s=document.createElement("label"),{input:a,container:l,setValue:c}=(0,h.default)(this.editor,(t=>{this.tool.setColor(t)}));a.id=`${m.toolbarCSSPrefix}colorInput${y.idCounter++}`,s.innerText=this.localizationTable.colorLabel,s.setAttribute("for",a.id),r.appendChild(s),r.appendChild(l);const d=this.createStabilizationOption();return this.updateInputs=()=>{c(this.tool.getColor()),o(this.tool.getThickness()),i.updateIcons(),i.setValue(this.getCurrentPenTypeIdx()),d.update()},this.updateInputs(),e.replaceChildren(r,n),i.addTo(e),d.addTo(e),t.replaceChildren(e),!0}onKeyPress(t){if(!this.isSelected())return!1;for(let e=0;e<f.selectStrokeTypeKeyboardShortcutIds.length;e++){const n=f.selectStrokeTypeKeyboardShortcutIds[e];if(this.editor.shortcuts.matchesShortcut(n,t)){const t=e;if(t<this.penTypes.length)return this.tool.setStrokeFactory(this.penTypes[t].factory),!0}}return!!super.onKeyPress(t)}serializeState(){return{...super.serializeState(),color:this.tool.getColor().toHexString(),thickness:this.tool.getThickness(),strokeFactoryId:this.getCurrentPenType()?.id,inputStabilization:!!this.tool.getInputMapper()}}deserializeFrom(t){super.deserializeFrom(t);const e=(e,n)=>{const o=typeof t[e];if(o!==n)throw new Error(`Deserializing property ${e}: Invalid type. Expected ${n}, was ${o}.`)};if(t.color&&(e("color","string"),this.tool.setColor(p.Color4.fromHex(t.color))),t.thickness&&(e("thickness","number"),this.tool.setThickness(t.thickness)),t.strokeFactoryId){e("strokeFactoryId","string");const n=t.strokeFactoryId;for(const t of this.penTypes)if(n===t.id){this.tool.setStrokeFactory(t.factory);break}}void 0!==t.inputStabilization&&this.setInputStabilizationEnabled(!!t.inputStabilization)}}y.idCounter=0,e.default=y},78:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3534)),r=n(3258),s=n(3240);class a extends i.default{constructor(t,e,n){super(t,"save-button",t.icons.makeSaveIcon,e.save,n),this.setTags([r.ToolbarWidgetTag.Save])}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(s.saveKeyboardShortcut,t)?(this.clickAction(),!0):super.onKeyPress(t)}mustBeInToplevelMenu(){return!0}}e.default=a},5001:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(739),s=o(n(1456)),a=n(3173),l=o(n(425)),c=o(n(3534)),d=o(n(1421)),h=n(3240),u=o(n(3595)),p=n(5698);class f extends d.default{constructor(t,e,n){super(t,e,"selection-tool-widget",n),this.tool=e,this.updateFormatMenu=()=>{};const o=new c.default(t,"resize-btn",(()=>t.icons.makeResizeImageToSelectionIcon()),this.localizationTable.resizeImageToSelection,(()=>{this.resizeImageToSelection()}),n),i=new c.default(t,"delete-btn",(()=>t.icons.makeDeleteSelectionIcon()),this.localizationTable.deleteSelection,(()=>{const t=this.tool.getSelection();this.editor.dispatch(t.deleteSelectedObjects()),this.tool.clearSelection()}),n),r=new c.default(t,"duplicate-btn",(()=>t.icons.makeDuplicateSelectionIcon()),this.localizationTable.duplicateSelection,(async()=>{const t=this.tool.getSelection();this.editor.dispatch(await t.duplicateSelectedObjects()),this.setDropdownVisible(!1)}),n);this.addSubWidget(o),this.addSubWidget(i),this.addSubWidget(r);const s=t=>{o.setDisabled(t),i.setDisabled(t),r.setDisabled(t)};s(!0),this.editor.notifier.on(a.EditorEventType.ToolUpdated,(t=>{if(t.kind!==a.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");if(t.tool===this.tool){const t=this.tool.getSelection(),e=t&&t.getSelectedItemCount()>0;s(!e),this.updateFormatMenu()}}))}resizeImageToSelection(){const t=this.tool.getSelection();t&&this.editor.dispatch(this.editor.setImportExportRect(t.region))}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(h.resizeImageToSelectionKeyboardShortcut,t)?(this.resizeImageToSelection(),!0):!!super.onKeyPress(t)}getTitle(){return this.localizationTable.select}createIcon(){return this.editor.icons.makeSelectionIcon()}fillDropdown(t){super.fillDropdown(t);const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}nonbutton-controls-main-list`),t.appendChild(e),(0,u.default)(this.localizationTable.reformatSelection).addTo(e);const n=((t,e,n)=>{const o=document.createElement("div");o.classList.add("selection-format-menu",`${p.toolbarCSSPrefix}spacedList`,`${p.toolbarCSSPrefix}indentedList`);const a=document.createElement("div"),c=document.createElement("label"),{input:d,container:h,setValue:u}=(0,l.default)(t,(n=>{const o=e.getSelection();if(o){const e=[];for(const t of o.getSelectedObjects())(0,r.isRestylableComponent)(t)&&e.push(t.updateStyle({color:n}));const i=(0,s.default)(e);t.dispatch(i)}}));return c.innerText=n.colorLabel,a.replaceChildren(c,h),o.replaceChildren(a),{addTo:t=>{t.appendChild(o)},update:()=>{const t=e.getSelection();if(t&&t.getSelectedItemCount()>0){d.disabled=!1,o.classList.remove("disabled");const e=[];for(const n of t.getSelectedObjects())if((0,r.isRestylableComponent)(n)){const t=n.getStyle().color;t&&e.push(t)}u(i.Color4.average(e))}else d.disabled=!0,o.classList.add("disabled"),u(i.Color4.transparent)}}})(this.editor,this.tool,this.localizationTable);return n.addTo(e),this.updateFormatMenu=()=>n.update(),n.update(),!0}}e.default=f},5730:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(3173),s=n(5698),a=o(n(425)),l=o(n(1421));class c extends l.default{constructor(t,e,n){super(t,e,"text-tool-widget",n),this.tool=e,this.updateDropdownInputs=null,t.notifier.on(r.EditorEventType.ToolUpdated,(t=>{t.kind===r.EditorEventType.ToolUpdated&&t.tool===e&&(this.updateIcon(),this.updateDropdownInputs?.())}))}getTitle(){return this.targetTool.description}createIcon(){const t=this.tool.getTextStyle();return this.editor.icons.makeTextIcon(t)}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${s.toolbarCSSPrefix}spacedList`,`${s.toolbarCSSPrefix}nonbutton-controls-main-list`);const n=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div"),r=document.createElement("select"),l=document.createElement("label"),d=document.createElement("input"),h=document.createElement("label"),{input:u,container:p,setValue:f}=(0,a.default)(this.editor,(t=>{this.tool.setColor(t)})),m=document.createElement("label"),g=new Set,b=t=>{const e=document.createElement("option");e.value=t,e.textContent=t,r.appendChild(e),g.add(t)};return d.setAttribute("type","number"),d.min="1",d.max="128",l.innerText=this.localizationTable.fontLabel,m.innerText=this.localizationTable.colorLabel,h.innerText=this.localizationTable.textSize,u.id=`${s.toolbarCSSPrefix}-text-color-input-${c.idCounter++}`,m.setAttribute("for",u.id),d.id=`${s.toolbarCSSPrefix}-text-size-input-${c.idCounter++}`,h.setAttribute("for",d.id),b("monospace"),b("serif"),b("sans-serif"),r.id=`${s.toolbarCSSPrefix}-text-font-input-${c.idCounter++}`,l.setAttribute("for",r.id),r.onchange=()=>{this.tool.setFontFamily(r.value)},d.onchange=()=>{const t=parseInt(d.value);!isNaN(t)&&t>0&&this.tool.setFontSize(t)},o.appendChild(m),o.appendChild(p),n.appendChild(l),n.appendChild(r),i.appendChild(h),i.appendChild(d),this.updateDropdownInputs=()=>{const t=this.tool.getTextStyle();f(t.renderingStyle.fill),g.has(t.fontFamily)||b(t.fontFamily),r.value=t.fontFamily,d.value=`${t.size}`},this.updateDropdownInputs(),e.replaceChildren(o,i,n),t.appendChild(e),!0}serializeState(){const t=this.tool.getTextStyle();return{...super.serializeState(),fontFamily:t.fontFamily,textSize:t.size,color:t.renderingStyle.fill.toHexString()}}deserializeFrom(t){t.fontFamily&&"string"==typeof t.fontFamily&&this.tool.setFontFamily(t.fontFamily),t.color&&"string"==typeof t.color&&this.tool.setColor(i.Color4.fromHex(t.color)),t.textSize&&"number"==typeof t.textSize&&this.tool.setFontSize(t.textSize),super.deserializeFrom(t)}}c.idCounter=0,e.default=c},425:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeColorInput=void 0;const i=n(5097),r=o(n(5248)),s=n(3173);e.makeColorInput=(t,e)=>{const n=document.createElement("span"),o=document.createElement("input");o.type="button",o.classList.add("coloris_input"),n.classList.add("color-input-container"),n.appendChild(o);const r=a(t,n,(t=>{o.value=t.toHexString(),d();const e=o.parentElement;e&&e.classList.contains("clr-field")&&(e.style.color=o.value)}));let l;const c=()=>{l=i.Color4.fromHex(o.value)},d=()=>{c(),l&&(t.announceForAccessibility(t.localization.colorChangedAnnouncement(l.toHexString())),e(l),t.notifier.dispatch(s.EditorEventType.ColorPickerColorSelected,{kind:s.EditorEventType.ColorPickerColorSelected,color:l}))};o.oninput=c;let h=!1;o.addEventListener("open",(()=>{h=!0,t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!0}),r.cancel(),n.classList.add("picker-open");const e=document.querySelector("#clr-picker #clr-hue-slider");e?.focus()}));o.addEventListener("close",(()=>{h=!1,t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!1}),d(),o.focus(),n.classList.remove("picker-open")}));return{input:o,container:n,setValue:t=>{"object"==typeof t&&(t=t.toHexString()),o.value=t,o.dispatchEvent(new Event("input",{bubbles:!0}))},closePicker:()=>{h&&d()}}};const a=(t,e,n)=>{const o=document.createElement("button");o.classList.add("pipetteButton"),o.title=t.localization.pickColorFromScreen,o.setAttribute("alt",o.title);const i=document.createElement("span");i.classList.add("pickColorInstructions"),i.innerText=t.localization.clickToPickColorAnnouncement;const s=e=>{o.replaceChildren(t.icons.makePipetteIcon(e),i)};s();const a=t.toolController.getMatchingTools(r.default)[0],l=()=>{a?.clearColorListener(),s(),o.classList.remove("active")},c=t=>{l(),t&&n(t)},d=t=>{t?s(t):s()};return o.onclick=()=>{if(o.classList.contains("active"))return l(),void t.announceForAccessibility(t.localization.colorSelectionCanceledAnnouncement);a?.setColorListener(d,c),a&&(o.classList.add("active"),t.announceForAccessibility(t.localization.clickToPickColorAnnouncement))},e.appendChild(o),{cancel:()=>{l()}}};e.default=e.makeColorInput},7993:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(1151));let r=0;e.default=(t,e,n="*")=>{const o=document.createElement("div"),s=document.createElement("label"),a=document.createElement("input"),l=document.createElement("div");l.classList.add("toolbar--file-input-description");const c=document.createElement("span");o.classList.add("toolbar--file-input-container"),s.appendChild(document.createTextNode(t)),a.accept=n,a.type="file";const d="js-draw-file-input-"+r++;a.setAttribute("id",d),s.htmlFor=d;const h=e.icons.makeUploadFileIcon();h.classList.add("icon"),l.replaceChildren(h,c),s.appendChild(l),o.replaceChildren(s,a);const u=i.default.fromInitialValue([]);return s.addEventListener("dragover",(t=>{t.preventDefault(),s.classList.add("drag-target")})),s.addEventListener("dragenter",(t=>{t.preventDefault(),s.classList.add("drag-target")})),s.addEventListener("dragleave",(t=>{t.preventDefault();const e=t.relatedTarget;e&&s.contains(e)||s.classList.remove("drag-target")})),s.addEventListener("drop",(t=>{t.preventDefault(),s.classList.remove("drag-target");const e=[];t.dataTransfer&&e.push(...t.dataTransfer.files),u.set(e)})),a.addEventListener("change",(()=>{const t=a.files??[];u.set([...t])})),u.onUpdate((t=>{0===t.length&&a.files&&a.files.length>0&&(a.value="")})),u.onUpdateAndNow((t=>{if(t.length>0)c.innerText=t.map((t=>t.name)).join("\n"),h.style.display="none";else{h.style.display="";const t=e.localization.dragAndDropHereOrBrowse.split(/[{]{2}(.*)[}]{2}/g);c.replaceChildren();for(let e=0;e<t.length;e++)if(e%2==1){const n=document.createElement("b");n.innerText=t[e],c.appendChild(n)}else c.appendChild(document.createTextNode(t[e]))}})),{container:o,input:a,selectedFiles:u,addTo:t=>{t.appendChild(o)}}}},8650:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(1151),r=o(n(9441)),s=n(5698);let a=0;e.default=(t,e,n)=>{const o=document.createElement("div");o.classList.add(`${s.toolbarCSSPrefix}grid-selector`);const l=i.MutableReactiveValue.fromInitialValue(e),c=document.createElement("div");c.setAttribute("role","menu"),c.id=`${s.toolbarCSSPrefix}-grid-select-id-${a++}`,(0,r.default)(c);const d=document.createElement("label");d.innerText=t,d.htmlFor=c.id,o.appendChild(d);let h=`${s.toolbarCSSPrefix}-grid-selector-${a++}`;const u=t=>{const e=document.createElement("div");e.classList.add("choice-button");const n=document.createElement("input");n.type="radio",n.id=`${s.toolbarCSSPrefix}-grid-select-button-${a++}`;const o=document.createElement("label"),i=()=>{o.setAttribute("title",t.title);const e=document.createElement("span");e.classList.add("button-label-text");const i=t.makeIcon();i.classList.add("icon"),e.innerText=t.title,o.htmlFor=n.id,o.replaceChildren(i,e)};i();const r=()=>{n.name=h};r();const d=()=>{n.checked?e.classList.add("checked"):e.classList.remove("checked")};n.oninput=()=>{n.checked&&l.set(t.id),d()},n.onfocus=()=>{e.querySelector(":focus-visible")&&e.classList.add("focus-visible")},n.onblur=()=>{e.classList.remove("focus-visible")},e.replaceChildren(n,o),c.appendChild(e);const u=t=>{n.checked=t,d()};u(!1);return{choiceRecord:t,setChecked:u,updateIcon:()=>{i()},updateButtonRadiogroupName:r}},p=[];for(const t of n)p.push(u(t));o.appendChild(c),l.onUpdateAndNow((t=>{for(let e=0;e<p.length;e++)p[e].setChecked(p[e].choiceRecord.id===t)}));const f={value:l,_radiogroupName:h,linkWith:t=>{f._radiogroupName=t._radiogroupName,h=t._radiogroupName;for(const t of p)t.updateButtonRadiogroupName()},updateIcons:()=>{p.forEach((t=>t.updateIcon()))},addTo:t=>{t.appendChild(o)}};return f}},3595:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t="")=>{const e=document.createElement("div");return e.classList.add("tool-dropdown-separator"),e.innerText=t,{addTo:t=>{t.appendChild(e)}}}},8392:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097),i=n(5698);let r=0;e.default=(t,e)=>{const n=document.createElement("div"),s=document.createElement("label"),a=document.createElement("input");n.classList.add(`${i.toolbarCSSPrefix}thicknessSliderContainer`),a.id=`${i.toolbarCSSPrefix}thicknessInput${r++}`,s.innerText=t.localization.thicknessLabel,s.setAttribute("for",a.id);const l=t=>Math.log10(t);a.type="range",a.oninput=()=>{e((t=>10**t)(parseFloat(a.value)))},n.appendChild(s),n.appendChild(a);const c=(t,e)=>{const n=(t,e)=>(e?Math.ceil:Math.floor)(100*t)/100,i=n(l(t),!1),r=n(l(e),!0);a.min=`${i}`,a.max=`${r}`,a.step=`${(0,o.toRoundedString)((r-i)/20)}`};return c(2,262),{container:n,addTo:t=>{t.appendChild(n)},setBounds:c,setValue:t=>{a.value=l(t).toString()}}}},3240:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.saveKeyboardShortcut=e.selectStrokeTypeKeyboardShortcutIds=e.resizeImageToSelectionKeyboardShortcut=void 0;const i=o(n(5376));e.resizeImageToSelectionKeyboardShortcut="jsdraw.toolbar.SelectionTool.resizeImageToSelection",i.default.registerDefaultKeyboardShortcut(e.resizeImageToSelectionKeyboardShortcut,["ctrlOrMeta+r"],"Resize image to selection"),e.selectStrokeTypeKeyboardShortcutIds=[1,2,3,4,5,6,7].map((t=>`jsdraw.toolbar.PenTool.select-pen-${t}`));for(let t=0;t<e.selectStrokeTypeKeyboardShortcutIds.length;t++){const n=e.selectStrokeTypeKeyboardShortcutIds[t];i.default.registerDefaultKeyboardShortcut(n,[`CtrlOrMeta+Digit${t+1}`],"Select pen style "+(t+1))}e.saveKeyboardShortcut="jsdraw.toolbar.SaveActionWidget.save",i.default.registerDefaultKeyboardShortcut(e.saveKeyboardShortcut,["ctrlOrMeta+KeyS"],"Save")},4477:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=o(n(1785)),s=n(5698),a=n(1151);var l;!function(t){t[t.DropdownShown=0]="DropdownShown",t[t.DropdownHidden=1]="DropdownHidden"}(l||(l={}));class c{constructor(t,e,n){this.parent=t,this.notifier=e,this.onDestroy=n,this.dropdownToggleListener=null,this.hideDropdownTimeout=null,this.visible=a.ReactiveValue.fromInitialValue(!1),this.dropdownContainer=document.createElement("div"),this.dropdownContainer.classList.add(`${s.toolbarCSSPrefix}dropdown`),this.dropdownContainer.classList.add("hidden"),t.target.insertAdjacentElement("afterend",this.dropdownContainer),this.dropdownToggleListener=this.notifier.on(l.DropdownShown,(t=>{t.dropdown!==this&&t.fromToplevelDropdown&&this.setVisible(!1)}))}onActivated(){}repositionDropdown(){const t=this.dropdownContainer.getBoundingClientRect(),e=document.scrollingElement?.clientWidth??document.body.clientHeight,n=document.scrollingElement?.clientHeight??document.body.clientHeight;let o,i;if(t.left>e/2){o=`calc(${this.parent.target.clientWidth+"px"} - 100%)`}if(t.bottom>n&&t.top-t.height>0){i=`calc(-${this.parent.target.clientHeight}px - 100%)`}this.dropdownContainer.style.translate=o||i?`${o??"0"} ${i??"0"}`:""}setVisible(t){if(this.visible.get()===t)return;this.hideDropdownTimeout&&(clearTimeout(this.hideDropdownTimeout),this.hideDropdownTimeout=null,this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown());if(this.visible.set(t),t)this.dropdownContainer.classList.remove("hidden"),this.notifier.dispatch(l.DropdownShown,{dropdown:this,fromToplevelDropdown:this.parent.isToplevel()}),this.repositionDropdown();else{this.notifier.dispatch(l.DropdownHidden,{dropdown:this,fromToplevelDropdown:this.parent.isToplevel()}),this.dropdownContainer.classList.add("hiding");const t=142.5;this.hideDropdownTimeout=setTimeout((()=>{this.dropdownContainer.classList.add("hidden"),this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown()}),t)}const e=`var(--dropdown-${t?"show":"hide"}-animation)`;this.dropdownContainer.style.animation=`150ms ease ${e}`}requestShow(){this.setVisible(!0)}requestHide(){this.setVisible(!1)}appendChild(t){this.dropdownContainer.appendChild(t)}clearChildren(){this.dropdownContainer.replaceChildren()}destroy(){this.setVisible(!1),this.dropdownContainer.remove(),this.dropdownToggleListener?.remove(),this.clearChildren(),this.onDestroy()}}e.default=class{constructor(t,e){this.localization=e,this.dropdowns=new Set,this.listeners=[],this.connectedNotifiers=[],this.notifier=new r.default,this.notifier.on(l.DropdownShown,(({dropdown:e,fromToplevelDropdown:n})=>{e&&(t(this.localization.dropdownShown(e.parent.getTitle())),this.connectedNotifiers.forEach((t=>{t.dispatch(i.EditorEventType.ToolbarDropdownShown,{kind:i.EditorEventType.ToolbarDropdownShown,fromToplevelDropdown:n,layoutManager:this})})))})),this.notifier.on(l.DropdownHidden,(({dropdown:e})=>{e&&t(this.localization.dropdownHidden(e.parent.getTitle()))}))}connectToEditorNotifier(t){this.connectedNotifiers.push(t),this.refreshListeners()}createToolMenu(t){const e=new c(t,this.notifier,(()=>{this.dropdowns.delete(e),this.refreshListeners()}));return this.dropdowns.add(e),this.refreshListeners(),e}refreshListeners(){const t=()=>{this.listeners.forEach((t=>t.remove())),this.listeners=[]};0===this.dropdowns.size?t():this.listeners.length!==this.connectedNotifiers.length&&(t(),this.listeners=this.connectedNotifiers.map((t=>t.on(i.EditorEventType.ToolbarDropdownShown,(t=>{t.kind===i.EditorEventType.ToolbarDropdownShown&&t.layoutManager!==this&&this.notifier.dispatch(l.DropdownShown,{fromToplevelDropdown:t.fromToplevelDropdown})})))))}}},5132:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(1151);e.default=class{constructor(t,e,n,i,r){this.setSidebarContent=t,this.sidebarTitle=e,this.sidebarVisibility=n,this.announceForAccessibility=i,this.localization=r,this.visibleWidgetContent=o.ReactiveValue.fromInitialValue(null)}createToolMenu(t){const e=document.createElement("div");let n=null;const i=o.ReactiveValue.fromCallback((()=>this.visibleWidgetContent.get()===n&&this.sidebarVisibility.get()),[this.visibleWidgetContent,this.sidebarVisibility]);return n={visible:i,requestShow:()=>{this.setSidebarContent(e),this.sidebarTitle.set(t.getTitle()),this.visibleWidgetContent.set(n),this.sidebarVisibility.set(!0),this.announceForAccessibility(this.localization.dropdownShown(t.getTitle()))},onActivated:()=>{},requestHide:()=>{i.get()&&this.sidebarVisibility.set(!1)},appendChild:t=>{e.appendChild(t)},clearChildren:()=>{e.replaceChildren()},destroy:()=>{n?.requestHide(),e.parentElement&&e.remove(),this.visibleWidgetContent.get()===n&&this.visibleWidgetContent.set(null)}},n}}},7321:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.DocumentPropertiesWidget=e.InsertImageWidget=e.EraserToolWidget=e.SelectionToolWidget=e.HandToolWidget=e.TextToolWidget=e.PenToolWidget=e.ToolbarWidgetTag=e.BaseWidget=e.BaseToolWidget=e.ActionButtonWidget=void 0;var i=n(3534);Object.defineProperty(e,"ActionButtonWidget",{enumerable:!0,get:function(){return o(i).default}});var r=n(1421);Object.defineProperty(e,"BaseToolWidget",{enumerable:!0,get:function(){return o(r).default}});var s=n(3258);Object.defineProperty(e,"BaseWidget",{enumerable:!0,get:function(){return o(s).default}}),Object.defineProperty(e,"ToolbarWidgetTag",{enumerable:!0,get:function(){return s.ToolbarWidgetTag}});var a=n(7998);Object.defineProperty(e,"PenToolWidget",{enumerable:!0,get:function(){return o(a).default}});var l=n(5730);Object.defineProperty(e,"TextToolWidget",{enumerable:!0,get:function(){return o(l).default}});var c=n(7956);Object.defineProperty(e,"HandToolWidget",{enumerable:!0,get:function(){return o(c).default}});var d=n(5001);Object.defineProperty(e,"SelectionToolWidget",{enumerable:!0,get:function(){return o(d).default}});var h=n(9944);Object.defineProperty(e,"EraserToolWidget",{enumerable:!0,get:function(){return o(h).default}});var u=n(6318);Object.defineProperty(e,"InsertImageWidget",{enumerable:!0,get:function(){return o(u).default}});var p=n(5771);Object.defineProperty(e,"DocumentPropertiesWidget",{enumerable:!0,get:function(){return o(p).default}})},7564:function(t,e,n){"use strict";var o,i,r,s=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},a=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const l=n(3173),c=n(7520),d=n(1151);o=new WeakMap,i=new WeakMap,r=new WeakMap,e.default=class{constructor(t,e){this.notifier=t,this.description=e,o.set(this,void 0),i.set(this,null),r.set(this,null),s(this,o,d.ReactiveValue.fromInitialValue(!0),"f"),a(this,o,"f").onUpdate((t=>{t?(a(this,i,"f")?.notifyEnabled(this),this.notifier.dispatch(l.EditorEventType.ToolEnabled,{kind:l.EditorEventType.ToolEnabled,tool:this})):this.notifier.dispatch(l.EditorEventType.ToolDisabled,{kind:l.EditorEventType.ToolDisabled,tool:this})}))}setInputMapper(t){s(this,r,t,"f"),t&&t.setEmitListener((t=>this.dispatchEventToCallback(t)))}getInputMapper(){return a(this,r,"f")}dispatchEventToCallback(t){let e;switch(t.kind){case c.InputEvtType.PointerDownEvt:return this.onPointerDown(t);case c.InputEvtType.PointerMoveEvt:this.onPointerMove(t);break;case c.InputEvtType.PointerUpEvt:return this.onPointerUp(t)??!1;case c.InputEvtType.GestureCancelEvt:this.onGestureCancel(t);break;case c.InputEvtType.WheelEvt:return this.onWheel(t);case c.InputEvtType.KeyPressEvent:return this.onKeyPress(t);case c.InputEvtType.KeyUpEvent:return this.onKeyUp(t);case c.InputEvtType.CopyEvent:return this.onCopy(t);case c.InputEvtType.PasteEvent:return this.onPaste(t);default:return e=t,e}return!0}onEvent(t){return a(this,r,"f")?a(this,r,"f").onEvent(t):this.dispatchEventToCallback(t)}onPointerDown(t){return!1}onPointerMove(t){}onPointerUp(t){}onGestureCancel(t){}onWheel(t){return!1}onCopy(t){return!1}onPaste(t){return!1}onKeyPress(t){return!1}onKeyUp(t){return!1}eventCanBeDeliveredToNonActiveTool(t){return!0}setEnabled(t){a(this,o,"f").set(t)}isEnabled(){return a(this,o,"f").get()}enabledValue(){return a(this,o,"f")}setToolGroup(t){this.isEnabled()&&t.notifyEnabled(this),s(this,i,t,"f")}getToolGroup(){return a(this,i,"f")?a(this,i,"f"):null}}},6416:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=o(n(7564)),s=n(5097),a=o(n(9721)),l=n(4318),c=n(3348),d=n(1151);class h extends r.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastPoint=null,this.isFirstEraseEvt=!0,this.thickness=10,this.partialCommands=[],this.thicknessValue=d.ReactiveValue.fromInitialValue(this.thickness),this.thicknessValue.onUpdate((t=>{this.thickness=t,this.editor.notifier.dispatch(i.EditorEventType.ToolUpdated,{kind:i.EditorEventType.ToolUpdated,tool:this})}))}clearPreview(){this.editor.clearWetInk()}getSizeOnCanvas(){return this.thickness/this.editor.viewport.getScaleFactor()}drawPreviewAt(t){this.clearPreview();const e=this.getSizeOnCanvas(),n=this.editor.display.getWetInkRenderer(),o=this.getEraserRect(t),i={fill:s.Color4.gray};n.drawRect(o,e/4,i)}getEraserRect(t){const e=this.getSizeOnCanvas(),n=s.Vec2.of(e/2,e/2);return s.Rect2.fromCorners(t.minus(n),t.plus(n))}eraseTo(t){if(!this.isFirstEraseEvt&&0===t.minus(this.lastPoint).magnitude())return;this.isFirstEraseEvt=!1;const e=this.getEraserRect(t),n=new s.LineSegment2(this.lastPoint,t),o=s.Rect2.union(n.bbox,e),i=this.editor.image.getElementsIntersectingRegion(o).filter((t=>t.intersects(n)||t.intersectsRect(e))).filter((t=>t.isSelectable()));this.toRemove.push(...i);const r=i.map((t=>new a.default([t])));r.forEach((t=>t.apply(this.editor))),this.partialCommands.push(...r),this.drawPreviewAt(t),this.lastPoint=t}onPointerDown(t){return(1===t.allPointers.length||t.current.device===l.PointerDevice.Eraser)&&(this.lastPoint=t.current.canvasPos,this.toRemove=[],this.isFirstEraseEvt=!0,this.drawPreviewAt(t.current.canvasPos),!0)}onPointerMove(t){const e=t.current.canvasPos;this.eraseTo(e)}onPointerUp(t){if(this.eraseTo(t.current.canvasPos),this.toRemove.length>0){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[];const t=new a.default(this.toRemove);this.editor.dispatch(t)}this.clearPreview()}onGestureCancel(){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[],this.clearPreview()}onKeyPress(t){const e=this.editor.shortcuts;let n;return e.matchesShortcut(c.decreaseSizeKeyboardShortcutId,t)?n=2*this.getThickness()/3:e.matchesShortcut(c.increaseSizeKeyboardShortcutId,t)&&(n=3*this.getThickness()/2),void 0!==n&&(n=Math.min(Math.max(1,n),200),this.setThickness(n),!0)}getThickness(){return this.thickness}getThicknessValue(){return this.thicknessValue}setThickness(t){this.thicknessValue.set(t)}}e.default=h},5805:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=o(n(7564)),s=n(3348),a="find-tool";class l extends r.default{constructor(t){super(t.notifier,t.localization.findLabel),this.editor=t,this.currentMatchIdx=0,this.overlay=document.createElement("div"),this.fillOverlay(),t.createHTMLOverlay(this.overlay),this.overlay.style.display="none",this.overlay.classList.add(`${a}-overlay`)}getMatches(t){t=t.toLocaleLowerCase();return this.editor.image.getAllElements().filter((t=>t instanceof i.default)).filter((e=>-1!==e.getText().toLocaleLowerCase().indexOf(t))).map((t=>t.getBBox()))}focusCurrentMatch(){const t=this.getMatches(this.searchInput.value);let e=this.currentMatchIdx%t.length;if(e<0&&(e=t.length+e),e<t.length){const n=!1;this.editor.dispatch(this.editor.viewport.zoomTo(t[e],!0,!0),n),this.editor.announceForAccessibility(this.editor.localization.focusedFoundText(e+1,t.length))}}toNextMatch(){this.currentMatchIdx++,this.focusCurrentMatch()}toPrevMatch(){this.currentMatchIdx--,this.focusCurrentMatch()}fillOverlay(){const t=document.createElement("label");this.searchInput=document.createElement("input");const e=document.createElement("button"),n=document.createElement("button");this.searchInput.setAttribute("id",`${a}-searchInput-${Math.random()}`),t.htmlFor=this.searchInput.getAttribute("id"),t.innerText=this.editor.localization.findLabel,e.innerText=this.editor.localization.toNextMatch,n.innerText=this.editor.localization.closeDialog,this.searchInput.onkeydown=t=>{"Enter"===t.key?t.shiftKey?this.toPrevMatch():this.toNextMatch():"Escape"===t.key?this.setVisible(!1):this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(t.preventDefault(),this.toggleVisible())},e.onclick=()=>{this.toNextMatch()},n.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(t,this.searchInput,e,n)}isVisible(){return"none"!==this.overlay.style.display}setVisible(t){t!==this.isVisible()&&(this.overlay.style.display=t?"block":"none",t?(this.searchInput.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogShown)):(this.editor.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogHidden)))}toggleVisible(){this.setVisible(!this.isVisible())}onKeyPress(t){return!!this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(this.toggleVisible(),!0)}setEnabled(t){super.setEnabled(t),t&&this.setVisible(!1)}}e.default=l},7810:function(t,e){"use strict";var n,o=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},i=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});n=new WeakMap,e.default=class{constructor(){n.set(this,null)}setEmitListener(t){o(this,n,t&&"object"==typeof t?e=>t.onEvent(e)??!1:t,"f")}emit(t){return i(this,n,"f")?.call(this,t)??!1}}},3135:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},s=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const l=a(n(7810));class c extends l.default{constructor(){super(...arguments),o.set(this,null),i.set(this,null)}onEvent(t){return null===r(this,o,"f")?this.emit(t):r(this,o,"f").onEvent(t)}addToTail(t){r(this,i,"f")?(r(this,i,"f").setEmitListener(t),s(this,i,t,"f")):(s(this,o,t,"f"),s(this,i,r(this,o,"f"),"f")),r(this,i,"f").setEmitListener((t=>this.emit(t)))}}o=new WeakMap,i=new WeakMap,e.default=c},2785:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(7520),r=o(n(7810)),s=n(5097),a=o(n(7395));var l;!function(t){t[t.IntertialStabilizer=0]="IntertialStabilizer"}(l||(l={}));const c={kind:l.IntertialStabilizer,mass:.4,springConstant:100,frictionCoefficient:.28,maxPointDist:10,inertiaFraction:.75,minSimilarityToFinalize:0,velocityDecayFactor:.1};class d{constructor(t,e,n){this.updatePointer=e,this.options=n,this.runLoop=!0,this.lastUpdateTime=0,this.velocity=s.Vec2.zero,this.strokePoint=t,this.targetPoint=t,this.targetInterval=10,this.loop()}async loop(){for(this.lastUpdateTime=performance.now();this.runLoop;)this.update(!1),await(0,a.default)()}setTarget(t){this.targetPoint=t}getNextVelocity(t){const e=this.targetPoint.minus(this.strokePoint),n=e.times(this.options.springConstant),o=10*this.options.mass,i=this.velocity.normalizedOrZero().times(-this.options.frictionCoefficient*o),r=n.plus(i).times(1/this.options.mass),s=this.options.velocityDecayFactor,a=this.velocity.times(1-s).plus(r.times(t/1e3));return e.normalizedOrZero().times(a.length()).lerp(a,this.options.inertiaFraction)}update(t){const e=performance.now(),n=e-this.lastUpdateTime,o=this.strokePoint.eq(this.targetPoint);if(n>this.targetInterval||t){if(!o){let t,o,i=1;do{t=this.getNextVelocity(n/i),o=t.times(n/1e3),i++}while(o.magnitude()>this.options.maxPointDist&&i<10);for(let t=0;t<i;t++)this.velocity=this.getNextVelocity(n/i),o=this.velocity.times(n/1e3),this.strokePoint=this.strokePoint.plus(o),t<i-1&&this.updatePointer(this.strokePoint,e)}if(this.lastUpdateTime=e,t||!o)return this.updatePointer(this.strokePoint,e)}return!1}finish(){this.runLoop=!1;const t=this.targetPoint.minus(this.strokePoint);this.velocity.dot(t)>this.options.minSimilarityToFinalize&&this.updatePointer(this.targetPoint,performance.now())}cancel(){this.runLoop=!1}}class h extends r.default{constructor(t,e=c){super(),this.viewport=t,this.options=e,this.stabilizer=null,this.lastPointerEvent=null}mapPointerEvent(t){return(0,i.isPointerEvt)(t)&&t.kind!==i.InputEvtType.PointerUpEvt&&(this.lastPointerEvent=t),t.kind===i.InputEvtType.GestureCancelEvt||t.allPointers.length>1||null===this.stabilizer?this.emit(t):(this.stabilizer.setTarget(t.current.screenPos),t.kind===i.InputEvtType.PointerMoveEvt?this.stabilizer.update(!0):t.kind===i.InputEvtType.PointerUpEvt?(this.stabilizer.finish(),this.emit(t)):this.emit(t))}emitPointerMove(t,e){if(!this.lastPointerEvent)return!1;const n=this.lastPointerEvent.current.withScreenPosition(t,this.viewport).withTimestamp(e),o={kind:i.InputEvtType.PointerMoveEvt,current:n,allPointers:[n]};return this.emit(o)}onEvent(t){if((0,i.isPointerEvt)(t)||t.kind===i.InputEvtType.GestureCancelEvt){t.kind===i.InputEvtType.PointerDownEvt&&(null===this.stabilizer?this.stabilizer=new d(t.current.screenPos,((t,e)=>this.emitPointerMove(t,e)),this.options):t.allPointers.length>1&&(this.stabilizer.cancel(),this.stabilizer=null));const e=this.mapPointerEvent(t);return t.kind!==i.InputEvtType.PointerUpEvt&&t.kind!==i.InputEvtType.GestureCancelEvt||(this.stabilizer?.cancel(),this.stabilizer=null),e}return this.emit(t)}static fromEditor(t){return new h(t.viewport)}}e.default=h},9542:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(7520),r=o(n(7810)),s=n(3348);class a extends r.default{constructor(t,e){super(),this.shortcuts=t,this.viewport=e,this.snapToGridEnabled=!1,this.angleLockEnabled=!1,this.startPointCanvas=null}xyAxesSnap(t){if(!this.startPointCanvas)return t;const e=this.viewport.canvasToScreen(this.startPointCanvas);return t.lockedToXYAxesScreen(e,this.viewport)}mapPointerEvent(t){const e=e=>t.allPointers.length>1?e:this.snapToGridEnabled?e.snappedToGrid(this.viewport):this.angleLockEnabled&&this.startPointCanvas?this.xyAxesSnap(e):e;return{kind:t.kind,current:e(t.current),allPointers:t.allPointers.map(e)}}onEvent(t){const e=this.shortcuts;t.kind!==i.InputEvtType.PointerDownEvt&&t.kind!==i.InputEvtType.PointerMoveEvt&&t.kind!==i.InputEvtType.PointerUpEvt||(t.kind===i.InputEvtType.PointerDownEvt&&(this.startPointCanvas=t.current.canvasPos),t=this.mapPointerEvent(t));let n=this.emit(t);if(t.kind===i.InputEvtType.KeyUpEvent||!n&&t.kind===i.InputEvtType.KeyPressEvent){const o=t.kind===i.InputEvtType.KeyPressEvent;e.matchesShortcut(s.snapToGridKeyboardShortcutId,t)&&(this.snapToGridEnabled=o,n=!0),e.matchesShortcut(s.lineLockKeyboardShortcutId,t)&&(this.angleLockEnabled=o,n=!0)}return n}static fromEditor(t){return new a(t.shortcuts,t.viewport)}}e.default=a},4735:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanZoomMode=void 0;const i=n(5097),r=n(4318),s=n(3173),a=o(n(7395)),l=n(5566),c=o(n(7564)),d=n(3348);var h;!function(t){t[t.OneFingerTouchGestures=1]="OneFingerTouchGestures",t[t.TwoFingerTouchGestures=2]="TwoFingerTouchGestures",t[t.RightClickDrags=4]="RightClickDrags",t[t.SinglePointerGestures=8]="SinglePointerGestures",t[t.Keyboard=16]="Keyboard",t[t.RotationLocked=32]="RotationLocked"}(h||(e.PanZoomMode=h={}));class u{constructor(t,e,n){this.initialVelocity=t,this.scrollBy=e,this.onComplete=n,this.running=!1,this.start()}async start(){if(this.running)return;this.currentVelocity=this.initialVelocity;let t=performance.now();this.running=!0;for(this.currentVelocity.magnitude()>5e3&&(this.currentVelocity=this.currentVelocity.normalized().times(5e3));this.running&&this.currentVelocity.magnitude()>200;){const e=performance.now(),n=(e-t)/1e3;this.currentVelocity=this.currentVelocity.times(Math.pow(1/8,n)),this.scrollBy(this.currentVelocity.times(n)),await(0,a.default)(),t=e}this.running&&this.stop()}getCurrentVelocity(){return this.running?this.currentVelocity:null}stop(){this.running&&(this.running=!1,this.onComplete())}}class p extends c.default{constructor(t,e,n){super(t.notifier,n),this.editor=t,this.mode=e,this.transform=null,this.lastPointerDownTimestamp=0,this.initialTouchAngle=0,this.initialViewportRotation=0,this.isScaling=!1,this.inertialScroller=null,this.velocity=null}computePinchData(t,e){if(t.id<e.id){const n=t;t=e,e=n}const n=e.screenPos.minus(t.screenPos),o=n.angle(),i=n.magnitude();return{canvasCenter:e.canvasPos.plus(t.canvasPos).times(.5),screenCenter:e.screenPos.plus(t.screenPos).times(.5),angle:o,dist:i}}allPointersAreOfType(t,e){return t.every((t=>t.device===e))}onPointerDown({allPointers:t,current:e}){let n=!1;const o=this.inertialScroller?.getCurrentVelocity()??i.Vec2.zero;this.inertialScroller?.stop(),this.velocity=o,this.lastPointerDownTimestamp=e.timeStamp;const s=this.allPointersAreOfType(t,r.PointerDevice.Touch),a=this.allPointersAreOfType(t,r.PointerDevice.RightButtonMouse);if(s&&2===t.length&&this.mode&h.TwoFingerTouchGestures){const{screenCenter:e,angle:o,dist:i}=this.computePinchData(t[0],t[1]);this.lastDist=i,this.startDist=i,this.lastScreenCenter=e,this.initialTouchAngle=o,this.initialViewportRotation=this.editor.viewport.getRotationAngle(),this.isScaling=!1,n=!0}else 1===t.length&&(this.mode&h.OneFingerTouchGestures&&s||a&&this.mode&h.RightClickDrags||this.mode&h.SinglePointerGestures)&&(this.lastScreenCenter=t[0].screenPos,this.isScaling=!1,n=!0);return n&&(this.lastTimestamp=performance.now(),this.transform??=l.Viewport.transformBy(i.Mat33.identity),this.editor.display.setDraftMode(!0)),n}updateVelocity(t){const e=t.minus(this.lastScreenCenter);let n=(performance.now()-this.lastTimestamp)/1e3;if(0===e.magnitude()&&n<.1)return;if(0===n)return;n=Math.max(n,.01);const o=e.times(1/n);let i=o;this.velocity&&(i=this.velocity.lerp(o,.5)),this.velocity=i}getCenterDelta(t){return this.editor.viewport.screenToCanvasTransform.transformVec3(t.minus(this.lastScreenCenter))}toSnappedRotationDelta(t){let e=t-this.initialTouchAngle+this.initialViewportRotation;const n=Math.PI/2,o=Math.round(e/n)*n;return Math.abs(e-o)<.07&&(e=o,0!==e&&(e+=1e-4)),e-this.editor.viewport.getRotationAngle()}handleTwoFingerMove(t){const{screenCenter:e,canvasCenter:n,angle:o,dist:r}=this.computePinchData(t[0],t[1]),s=this.getCenterDelta(e);let a;a=this.isRotationLocked()?0:this.toSnappedRotationDelta(o),this.updateVelocity(e);let c=1;if(this.isScaling)c=r/this.lastDist;else{const t=r/this.startDist;(t>1.05||t<.95)&&(c=t,this.isScaling=!0)}const d=i.Mat33.translation(s).rightMul(i.Mat33.scaling2D(c,n)).rightMul(i.Mat33.zRotation(a,n));return this.lastScreenCenter=e,this.lastDist=r,this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(d)),d}handleOneFingerMove(t){const e=this.getCenterDelta(t.screenPos),n=i.Mat33.translation(e);return this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(n)),this.updateVelocity(t.screenPos),this.lastScreenCenter=t.screenPos,n}onPointerMove({allPointers:t}){this.transform??=l.Viewport.transformBy(i.Mat33.identity);let e=i.Mat33.identity;2===t.length?e=this.handleTwoFingerMove(t):1===t.length&&(e=this.handleOneFingerMove(t[0])),l.Viewport.transformBy(e).apply(this.editor),this.lastTimestamp=performance.now()}onPointerUp(t){const e=()=>{this.transform&&(this.transform.unapply(this.editor),this.editor.dispatch(this.transform,!1)),this.editor.display.setDraftMode(!1),this.transform=null,this.velocity=i.Vec2.zero};if(t.current.device===r.PointerDevice.Touch&&1===t.allPointers.length&&null!==this.velocity&&t.current.timeStamp-this.lastPointerDownTimestamp>30&&null!==this.velocity){const n=this.velocity;this.updateVelocity(t.current.screenPos),n.magnitude()<this.velocity.magnitude()&&(this.velocity=n),this.inertialScroller?.stop(),this.inertialScroller=new u(this.velocity,(t=>{if(!this.transform)return;const e=this.editor.viewport.screenToCanvasTransform.transformVec3(t);this.transform.unapply(this.editor),this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(i.Mat33.translation(e))),this.transform.apply(this.editor)}),e)}else e()}onGestureCancel(){this.inertialScroller?.stop(),this.velocity=i.Vec2.zero,this.transform?.unapply(this.editor),this.editor.display.setDraftMode(!1),this.transform=null}updateTransform(t,e=!1){let n=t;this.transform&&(n=this.transform.transform.rightMul(t)),this.transform?.unapply(this.editor),this.transform=l.Viewport.transformBy(n),this.transform.apply(this.editor),e&&this.editor.announceForAccessibility(this.transform.description(this.editor,this.editor.localization))}onWheel({delta:t,screenPos:e}){this.inertialScroller?.stop(),this.transform=l.Viewport.transformBy(i.Mat33.identity);const n=this.editor.viewport.screenToCanvas(e),o=this.editor.viewport.screenToCanvasTransform.transformVec3(i.Vec3.of(-t.x,-t.y,0));let r=t.z;r=2*Math.atan(r/2);const s=i.Mat33.scaling2D(Math.max(.4,Math.min(Math.pow(1.04,-r),4)),n).rightMul(i.Mat33.translation(o));return this.updateTransform(s,!0),!0}onKeyPress(t){if(this.inertialScroller?.stop(),!(this.mode&h.Keyboard))return!1;this.transform=l.Viewport.transformBy(i.Mat33.identity);let e=i.Vec2.zero,n=1,o=0;const r=this.editor.shortcuts;if(r.matchesShortcut(d.moveLeftKeyboardShortcutId,t))e=i.Vec2.of(-1,0);else if(r.matchesShortcut(d.moveRightKeyboardShortcutId,t))e=i.Vec2.of(1,0);else if(r.matchesShortcut(d.moveUpKeyboardShortcutId,t))e=i.Vec2.of(0,-1);else if(r.matchesShortcut(d.moveDownKeyboardShortcutId,t))e=i.Vec2.of(0,1);else if(r.matchesShortcut(d.zoomInKeyboardShortcutId,t))n=.5;else if(r.matchesShortcut(d.zoomOutKeyboardShortcutId,t))n=2;else if(r.matchesShortcut(d.rotateClockwiseKeyboardShortcutId,t))o=1;else{if(!r.matchesShortcut(d.rotateCounterClockwiseKeyboardShortcutId,t))return!1;o=-1}e=e.times(30),o*=Math.PI/8,e=e.times(-1),o*=-1,n=1/n,0!==o&&(o+=1e-4),this.isRotationLocked()&&(o=0);e=this.editor.viewport.screenToCanvasTransform.transformVec3(e);const s=this.editor.viewport.visibleRect.center,a=i.Mat33.scaling2D(n,s).rightMul(i.Mat33.zRotation(o,s)).rightMul(i.Mat33.translation(e));return this.updateTransform(a,!0),!0}isRotationLocked(){return!!(this.mode&h.RotationLocked)}setModeEnabled(t,e){let n=this.mode;e?n|=t:n&=~t,this.setMode(n)}setMode(t){t!==this.mode&&(this.mode=t,this.editor.notifier.dispatch(s.EditorEventType.ToolUpdated,{kind:s.EditorEventType.ToolUpdated,tool:this}))}getMode(){return this.mode}}e.default=p},2719:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=o(n(1697)),s=n(5097),a=o(n(7564)),l=o(n(4321)),c=o(n(7077));class d extends a.default{constructor(t){super(t.notifier,t.localization.pasteHandler),this.editor=t}onPaste(t){const e=t.mime.toLowerCase();return"image/svg+xml"===e?(this.doSVGPaste(t.data),!0):"text/plain"===e?(this.doTextPaste(t.data),!0):("image/png"===e||"image/jpeg"===e)&&(this.doImagePaste(t.data),!0)}async addComponentsFromPaste(t){await this.editor.addAndCenterComponents(t)}async doSVGPaste(t){const e=r.default.fromString(t,!0),n=[];await e.start((t=>{n.push(t)}),((t,e)=>null)),await this.addComponentsFromPaste(n)}async doTextPaste(t){const e=this.editor.toolController.getMatchingTools(l.default);e.sort(((t,e)=>!t.isEnabled()&&e.isEnabled()?-1:!e.isEnabled()&&t.isEnabled()?1:0));const n={size:12,fontFamily:"sans",renderingStyle:{fill:s.Color4.red}},o=e[0]?.getTextStyle()??n,r=t.split("\n");await this.addComponentsFromPaste([i.default.fromLines(r,s.Mat33.identity,o)])}async doImagePaste(t){const e=new Image;e.src=t;const n=await c.default.fromImage(e,s.Mat33.identity);await this.addComponentsFromPaste([n])}}e.default=d},2133:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(7551)),s=n(4318),a=n(6951),l=n(3173),c=o(n(7564)),d=n(3348),h=n(3348),u=o(n(2785)),p=n(1151);class f extends c.default{constructor(t,e,n){super(t.notifier,e),this.editor=t,this.builder=null,this.lastPoint=null,this.startPoint=null,this.currentDeviceType=null,this.styleValue=p.ReactiveValue.fromInitialValue({factory:a.makeFreehandLineBuilder,color:i.Color4.blue,thickness:4,...n}),this.styleValue.onUpdateAndNow((t=>{this.style=t,this.noteUpdated()}))}getPressureMultiplier(){const t=this.style.thickness;return 1/this.editor.viewport.getScaleFactor()*t}toStrokePoint(t){let e=Math.max(t.pressure??1,.3);isFinite(e)||(console.warn("Non-finite pressure!",t),e=.3),console.assert(isFinite(t.canvasPos.length()),"Non-finite canvas position!"),console.assert(isFinite(t.screenPos.length()),"Non-finite screen position!"),console.assert(isFinite(t.timeStamp),"Non-finite timeStamp on pointer!");return{pos:t.canvasPos,width:e*this.getPressureMultiplier(),color:this.style.color,time:t.timeStamp}}previewStroke(){this.editor.clearWetInk(),this.builder?.preview(this.editor.display.getWetInkRenderer())}addPointToStroke(t){if(!this.builder)throw new Error("No stroke is currently being generated.");this.builder.addPoint(t),this.lastPoint=t,this.previewStroke()}onPointerDown(t){const{current:e,allPointers:n}=t,o=e.device===s.PointerDevice.Eraser;let i=!1;for(const t of n)if(t.device===s.PointerDevice.Pen){i=!0;break}return!(!this.builder||this.eventCanCancelStroke(t))||!((1!==n.length||o)&&!i)&&(this.startPoint=this.toStrokePoint(e),this.builder=this.style.factory(this.startPoint,this.editor.viewport),this.currentDeviceType=e.device,!0)}eventCanCancelStroke(t){const e=this.lastPoint?.time??0;if(t.current.timeStamp-e>1e3)return!0;const n=this.currentDeviceType===s.PointerDevice.Pen,o=t.current.device===s.PointerDevice.Touch;return!n||!o}eventCanBeDeliveredToNonActiveTool(t){return this.eventCanCancelStroke(t)}onPointerMove({current:t}){this.builder&&t.device===this.currentDeviceType&&this.addPointToStroke(this.toStrokePoint(t))}onPointerUp({current:t}){if(!this.builder)return!1;if(t.device!==this.currentDeviceType)return!0;const e=this.toStrokePoint(t),n={...e,width:this.lastPoint?.width??e.width};return this.addPointToStroke(n),t.isPrimary&&this.finalizeStroke(),!1}onGestureCancel(){this.builder=null,this.editor.clearWetInk()}finalizeStroke(){if(this.builder){const t=this.builder.build();if(this.previewStroke(),t.getBBox().area>0){const e=!0,n=r.default.addElement(t,e);this.editor.dispatch(n)}else console.warn("Pen: Not adding empty stroke",t,"to the canvas.")}this.builder=null,this.lastPoint=null,this.editor.clearWetInk()}noteUpdated(){this.editor.notifier.dispatch(l.EditorEventType.ToolUpdated,{kind:l.EditorEventType.ToolUpdated,tool:this})}setColor(t){t.toHexString()!==this.style.color.toHexString()&&this.styleValue.set({...this.style,color:t})}setThickness(t){t!==this.style.thickness&&this.styleValue.set({...this.style,thickness:t})}setStrokeFactory(t){t!==this.style.factory&&this.styleValue.set({...this.style,factory:t})}setHasStabilization(t){const e=!!this.getInputMapper();t!==e&&(e?this.setInputMapper(null):this.setInputMapper(new u.default(this.editor.viewport)),this.noteUpdated())}getThickness(){return this.style.thickness}getColor(){return this.style.color}getStrokeFactory(){return this.style.factory}getStyleValue(){return this.styleValue}setEnabled(t){super.setEnabled(t)}onKeyPress(t){const e=this.editor.shortcuts,n=e.matchesShortcut(d.undoKeyboardShortcutId,t);if(this.builder&&n)return this.finalizeStroke(),!1;let o;return e.matchesShortcut(h.decreaseSizeKeyboardShortcutId,t)?o=2*this.getThickness()/3:e.matchesShortcut(h.increaseSizeKeyboardShortcutId,t)&&(o=3*this.getThickness()/2),void 0!==o&&(o=Math.min(Math.max(1,o),256),this.setThickness(o),!0)}}e.default=f},5248:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564));class r extends i.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.colorPreviewListener=null,this.colorSelectListener=null,this.enabledValue().onUpdateAndNow((()=>{this.updateSelectingStatus()}))}updateSelectingStatus(){const t="pipette--color-selection-in-progress";this.isEnabled()&&this.colorSelectListener&&this.colorPreviewListener?this.editor.getRootElement().classList.add(t):this.editor.getRootElement().classList.remove(t)}setColorListener(t,e){this.colorPreviewListener=t,this.colorSelectListener=e,this.updateSelectingStatus()}clearColorListener(){this.colorPreviewListener=null,this.colorSelectListener=null,this.updateSelectingStatus()}onPointerDown({current:t,allPointers:e}){return!(!this.colorPreviewListener||1!==e.length)&&(this.colorPreviewListener(this.editor.display.getColorAt(t.screenPos)),!0)}onPointerMove({current:t}){this.colorPreviewListener?.(this.editor.display.getColorAt(t.screenPos))}onPointerUp({current:t}){this.colorSelectListener?.(this.editor.display.getColorAt(t.screenPos))}onGestureCancel(){this.colorSelectListener?.(null)}}e.default=r},8311:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(3173),s=o(n(7564));class a extends s.default{constructor(t){super(t.notifier,"scrollbar"),this.editor=t,this.fadeOutTimeout=null,this.scrollbarOverlay=document.createElement("div"),this.scrollbarOverlay.classList.add("ScrollbarTool-overlay"),this.verticalScrollbar=document.createElement("div"),this.verticalScrollbar.classList.add("vertical-scrollbar"),this.horizontalScrollbar=document.createElement("div"),this.horizontalScrollbar.classList.add("horizontal-scrollbar"),this.scrollbarOverlay.replaceChildren(this.verticalScrollbar,this.horizontalScrollbar);let e=null,n=null;this.enabledValue().onUpdateAndNow((o=>{e?.remove(),n?.remove(),n=null,e=null,o&&(n=t.notifier.on(r.EditorEventType.ViewportChanged,(t=>{this.updateScrollbars()})),this.updateScrollbars(),e=t.createHTMLOverlay(this.scrollbarOverlay))}))}updateScrollbars(){const t=this.editor.viewport,e=t.getScreenRectSize(),n=new i.Rect2(0,0,e.x,e.y),o=this.editor.getImportExportRect().transformedBoundingBox(t.canvasToScreenTransform).union(n),r=n.width/o.width*e.x,s=n.height/o.height*e.y,a=(n.x-o.x)/o.width*e.x,l=(n.y-o.y)/o.height*e.y;this.horizontalScrollbar.style.width=`${r}px`,this.verticalScrollbar.style.height=`${s}px`,this.horizontalScrollbar.style.marginLeft=`${a}px`,this.verticalScrollbar.style.marginTop=`${l}px`;const c=(t,e,n)=>{const o="represents-no-scroll";Math.abs(e-n)<1e-8?t.classList.add(o):t.classList.remove(o)};c(this.horizontalScrollbar,r,e.x),c(this.verticalScrollbar,s,e.y),null!==this.fadeOutTimeout&&clearTimeout(this.fadeOutTimeout);this.fadeOutTimeout=setTimeout((()=>{this.scrollbarOverlay.classList.remove("just-updated")}),3e3),this.scrollbarOverlay.classList.add("just-updated")}}e.default=a},8519:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564)),r=n(3348),s=o(n(7591));class a extends i.default{constructor(t){super(t.notifier,t.localization.selectAllTool),this.editor=t}onKeyPress(t){if(this.editor.shortcuts.matchesShortcut(r.selectAllKeyboardShortcut,t)){const t=this.editor.toolController.getMatchingTools(s.default);if(t.length>0){const e=t[0];return e.setEnabled(!0),e.setSelection(this.editor.image.getAllElements()),!0}}return!1}}e.default=a},2129:function(t,e,n){"use strict";var o,i=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const l=a(n(6669)),c=n(5097),d=s(n(370)),h=n(7591),u=a(n(5566)),p=a(n(9721)),f=a(n(1365)),m=n(8862),g=n(3968),b=a(n(7551));class y{constructor(t,e){this.editor=e,this.transform=c.Mat33.identity,this.selectedElems=[],this.hasParent=!0,this.removedFromImage={},this.targetHandle=null,this.backgroundDragging=!1,this.selectionDuplicatedAnimationTimeout=null,this.originalRegion=new c.Rect2(t.x,t.y,0,0),this.transformers={drag:new m.DragTransformer(e,this),resize:new m.ResizeTransformer(e,this),rotate:new m.RotateTransformer(e,this)},this.container=document.createElement("div"),this.backgroundElem=document.createElement("div"),this.backgroundElem.classList.add(`${h.cssPrefix}selection-background`),this.container.appendChild(this.backgroundElem);const n=new d.default(d.HandleShape.Square,c.Vec2.of(1,.5),this,this.editor.viewport,(t=>this.transformers.resize.onDragStart(t,g.ResizeMode.HorizontalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),o=new d.default(d.HandleShape.Square,c.Vec2.of(.5,1),this,this.editor.viewport,(t=>this.transformers.resize.onDragStart(t,g.ResizeMode.VerticalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),i=new d.default(d.HandleShape.Square,c.Vec2.of(1,1),this,this.editor.viewport,(t=>this.transformers.resize.onDragStart(t,g.ResizeMode.Both)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),r=new d.default(d.HandleShape.Circle,c.Vec2.of(.5,0),this,this.editor.viewport,(t=>this.transformers.rotate.onDragStart(t)),(t=>this.transformers.rotate.onDragUpdate(t)),(()=>this.transformers.rotate.onDragEnd()));this.handles=[i,n,o,r];for(const t of this.handles)t.addTo(this.backgroundElem)}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){const t=c.Mat33.zRotation(this.regionRotation,this.originalRegion.center),e=this.transform.rightMul(t.inverse());return this.originalRegion.transformedBoundingBox(e)}computeTightBoundingBox(){return this.selectedElems.reduce(((t,e)=>(t??e.getBBox()).union(e.getBBox())),null)??c.Rect2.empty}get regionRotation(){return this.transform.transformVec3(c.Vec2.unitX).angle()}get preTransformedScreenRegion(){const t=t=>this.editor.viewport.canvasToScreen(t);return c.Rect2.fromCorners(t(this.preTransformRegion.topLeft),t(this.preTransformRegion.bottomRight))}get preTransformedScreenRegionRotation(){return this.editor.viewport.getRotationAngle()}get screenRegion(){const t=this.editor.viewport.canvasToScreenTransform,e=this.editor.viewport.getScaleFactor(),n=t.transformVec2(this.region.center);return new c.Rect2(n.x,n.y,e*this.region.width,e*this.region.height).translatedBy(this.region.size.times(-e/2))}get screenRegionRotation(){return this.regionRotation+this.editor.viewport.getRotationAngle()}setTransform(t,e=!0){this.transform=t,e&&this.hasParent&&(this.scrollTo(),this.previewTransformCmds())}async finalizeTransform(){const t=this.transform,e=this.selectedElems;this.originalRegion=this.originalRegion.transformedBoundingBox(this.transform),this.transform=c.Mat33.identity,await this.editor.dispatch(new y.ApplyTransformationCommand(this,e,t));this.editor.display.getWetInkRenderer().clear()}previewTransformCmds(){if(this.selectedElems.length>500)return void this.updateUI();const t=this.editor.display.getWetInkRenderer();t.clear(),t.pushTransform(this.transform);const e=this.editor.viewport.visibleRect.transformedBoundingBox(this.transform.inverse());for(const n of this.selectedElems)n.render(t,e);t.popTransform(),this.updateUI()}resolveToObjects(){let t=!1;if(this.transform=c.Mat33.identity,0===this.region.w||0===this.region.h){const e=this.editor.viewport.visibleRect.maxDimension/200;this.originalRegion=c.Rect2.bboxOf(this.region.corners,e),t=!0}return this.selectedElems=this.editor.image.getElementsIntersectingRegion(this.region).filter((t=>t.intersectsRect(this.region)&&t.isSelectable())),t&&this.selectedElems.length>0&&(this.selectedElems=[this.selectedElems[this.selectedElems.length-1]]),!!this.recomputeRegion()&&(this.updateUI(),!0)}recomputeRegion(){const t=this.computeTightBoundingBox();if(!t)return this.cancelSelection(),!1;this.originalRegion=t;const e=this.getMinCanvasSize();if(this.originalRegion.w<e||this.originalRegion.h<e){const t=e/2;this.originalRegion=c.Rect2.bboxOf(this.originalRegion.corners,t)}return!0}getMinCanvasSize(){return 2*(d.handleSize/this.editor.viewport.getScaleFactor())}getSelectedItemCount(){return this.selectedElems.length}updateUI(){if(!this.hasParent)return;this.backgroundElem.style.marginLeft=`${this.screenRegion.topLeft.x}px`,this.backgroundElem.style.marginTop=`${this.screenRegion.topLeft.y}px`,this.backgroundElem.style.width=`${this.screenRegion.width}px`,this.backgroundElem.style.height=`${this.screenRegion.height}px`;const t=180*this.screenRegionRotation/Math.PI;this.backgroundElem.style.transform=`rotate(${t}deg)`,this.backgroundElem.style.transformOrigin="center";for(const t of this.handles)t.updatePosition()}addRemoveSelectionFromImage(t){if(t||!(this.selectedElems.length>500)){for(const e of this.selectedElems){const n=this.editor.image.findParent(e);!t&&n?(this.removedFromImage[e.getId()]=!0,n.remove()):!n&&this.removedFromImage[e.getId()]&&(b.default.addElement(e).apply(this.editor),this.removedFromImage[e.getId()]=!1,delete this.removedFromImage[e.getId()])}this.editor.queueRerender().then((()=>{t||this.previewTransformCmds()}))}}removeDeletedElemsFromSelection(){this.selectedElems=this.selectedElems.filter((t=>{const e=!!this.editor.image.findParent(t),n=this.removedFromImage[t.getId()];return e||n}))}onDragStart(t){document.getSelection()?.removeAllRanges(),this.targetHandle=null;let e=!1;for(const n of this.handles)n.containsPoint(t.canvasPos)&&(this.targetHandle=n,e=!0);return this.backgroundDragging=!1,this.region.containsPoint(t.canvasPos)&&(this.backgroundDragging=!0,e=!0),e&&(this.removeDeletedElemsFromSelection(),this.addRemoveSelectionFromImage(!1)),this.targetHandle&&this.targetHandle.handleDragStart(t),this.backgroundDragging&&this.transformers.drag.onDragStart(t.canvasPos),e}onDragUpdate(t){this.backgroundDragging&&this.transformers.drag.onDragUpdate(t.canvasPos),this.targetHandle&&this.targetHandle.handleDragUpdate(t)}onDragEnd(){this.backgroundDragging?this.transformers.drag.onDragEnd():this.targetHandle&&this.targetHandle.handleDragEnd(),this.addRemoveSelectionFromImage(!0),this.backgroundDragging=!1,this.targetHandle=null,this.updateUI()}onDragCancel(){this.backgroundDragging=!1,this.targetHandle=null,this.setTransform(c.Mat33.identity),this.addRemoveSelectionFromImage(!0)}async scrollTo(){if(0===this.selectedElems.length)return;const t=new c.Rect2(0,0,this.editor.display.width,this.editor.display.height);if(!t.containsPoint(this.screenRegion.center)){const e=t.getClosestPointOnBoundaryTo(this.screenRegion.center),n=this.screenRegion.center.minus(e),o=this.editor.viewport.screenToCanvasTransform.transformVec3(n);await this.editor.dispatchNoAnnounce(u.default.transformBy(c.Mat33.translation(o.times(-1))),!1),await this.editor.queueRerender(),this.previewTransformCmds()}}deleteSelectedObjects(){return(this.backgroundDragging||this.targetHandle)&&this.onDragEnd(),new p.default(this.selectedElems)}runSelectionDuplicatedAnimation(){this.selectionDuplicatedAnimationTimeout&&clearTimeout(this.selectionDuplicatedAnimationTimeout);this.backgroundElem.style.animation="400ms ease selection-duplicated-animation",this.selectionDuplicatedAnimationTimeout=setTimeout((()=>{this.backgroundElem.style.animation="",this.selectionDuplicatedAnimationTimeout=null}),400)}async duplicateSelectedObjects(){const t=this.backgroundDragging||this.targetHandle;let e=null;if(t||this.runSelectionDuplicatedAnimation(),t){const t=null;e=new y.ApplyTransformationCommand(t,this.selectedElems,this.transform),await e.apply(this.editor),this.addRemoveSelectionFromImage(!0)}const n=new f.default(this.selectedElems);return t&&(await(e?.unapply(this.editor)),this.addRemoveSelectionFromImage(!1),this.previewTransformCmds(),this.updateUI()),n}addTo(t){this.container.parentElement&&this.container.remove(),t.appendChild(this.container),this.hasParent=!0}setToPoint(t){this.originalRegion=this.originalRegion.grownToPoint(t),this.updateUI()}cancelSelection(){this.container.parentElement&&this.container.remove(),this.originalRegion=c.Rect2.empty,this.hasParent=!1}setSelectedObjects(t,e){this.addRemoveSelectionFromImage(!0),this.originalRegion=e,this.selectedElems=t.filter((t=>t.isSelectable())),this.updateUI()}getSelectedObjects(){return[...this.selectedElems]}}o=y,l.default.register("selection-tool-transform",((t,e)=>{const n=new c.Mat33(...t.transform),i=t.elems??[];return new o.ApplyTransformationCommand(null,i,n)})),y.ApplyTransformationCommand=class extends l.default{constructor(t,e,n){super("selection-tool-transform"),this.selection=t,this.fullTransform=n;"string"==typeof e[0]?this.selectedElemIds=e:(this.selectedElemIds=e.map((t=>t.getId())),this.transformCommands=e.map((t=>t.transformBy(this.fullTransform))))}resolveToElems(t){this.transformCommands||(this.transformCommands=this.selectedElemIds.map((e=>{const n=t.image.lookupElement(e);if(!n)throw new Error(`Unable to find element with ID, ${e}.`);return n.transformBy(this.fullTransform)})))}async apply(t){this.resolveToElems(t),this.selection?.setTransform(this.fullTransform,!1),this.selection?.updateUI(),await t.asyncApplyCommands(this.transformCommands,100),this.selection?.setTransform(c.Mat33.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}async unapply(t){this.resolveToElems(t),this.selection?.setTransform(this.fullTransform.inverse(),!1),this.selection?.updateUI(),await t.asyncUnapplyCommands(this.transformCommands,100,!0),this.selection?.setTransform(c.Mat33.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray()}}description(t,e){return e.transformedElements(this.selectedElemIds.length)}},e.default=y},370:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.handleSize=e.HandleShape=void 0;const o=n(6585),i=n(5097),r=n(7591);var s;!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square"}(s||(e.HandleShape=s={})),e.handleSize=30;e.default=class{constructor(t,e,n,i,a,l,c){switch(this.shape=t,this.parentSide=e,this.parent=n,this.viewport=i,this.onDragStart=a,this.onDragUpdate=l,this.onDragEnd=c,this.dragLastPos=null,this.element=document.createElement("div"),this.element.classList.add(`${r.cssPrefix}handle`),t){case s.Circle:this.element.classList.add(`${r.cssPrefix}circle`);break;case s.Square:this.element.classList.add(`${r.cssPrefix}square`);break;default:(0,o.assertUnreachable)(t)}this.updatePosition()}addTo(t){t.appendChild(this.element)}getBBoxParentCoords(){const t=this.parent.screenRegion,n=i.Vec2.of(e.handleSize,e.handleSize),o=t.size.scale(this.parentSide).minus(n.times(.5));return new i.Rect2(o.x,o.y,n.x,n.y)}getBBoxCanvasCoords(){const t=this.parent.region,n=i.Vec2.of(e.handleSize,e.handleSize).times(1/this.viewport.getScaleFactor()),o=t.size.scale(this.parentSide).minus(n.times(.5));return new i.Rect2(o.x,o.y,n.x,n.y).translatedBy(t.topLeft)}updatePosition(){const t=this.getBBoxParentCoords();this.element.style.marginLeft=`${t.topLeft.x}px`,this.element.style.marginTop=`${t.topLeft.y}px`,this.element.style.width=`${t.w}px`,this.element.style.height=`${t.h}px`}containsPoint(t){const e=this.getBBoxCanvasCoords(),n=t.minus(e.center),o=e.size.x/2;let i;return i=this.shape===s.Circle?n.magnitude()<=o:Math.abs(n.x)<=o&&Math.abs(n.y)<=o,i}handleDragStart(t){this.onDragStart(t.canvasPos),this.dragLastPos=t.canvasPos}handleDragUpdate(t){this.dragLastPos&&this.onDragUpdate(t.canvasPos)}handleDragEnd(){this.dragLastPos&&this.onDragEnd()}setSnapToGrid(t){this.snapToGrid=t}isSnappingToGrid(){return this.snapToGrid}}},7591:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.cssPrefix=void 0;const i=n(5097),r=n(3173),s=o(n(5566)),a=o(n(7564)),l=o(n(2001)),c=o(n(2129)),d=o(n(3167)),h=n(3348);e.cssPrefix="selection-tool-";class u extends a.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.startPoint=null,this.expandingSelectionBox=!1,this.shiftKeyPressed=!1,this.snapToGrid=!1,this.selectionBoxHandlingEvt=!1,this.lastSelectedObjects=[],this.handleOverlay=document.createElement("div"),t.createHTMLOverlay(this.handleOverlay),this.handleOverlay.style.display="none",this.handleOverlay.classList.add("handleOverlay"),t.notifier.on(r.EditorEventType.ViewportChanged,(t=>{this.editor.clearWetInk(),this.selectionBox?.updateUI()})),this.editor.handleKeyEventsFrom(this.handleOverlay),this.editor.handlePointerEventsFrom(this.handleOverlay)}makeSelectionBox(t){this.prevSelectionBox=this.selectionBox,this.selectionBox=new c.default(t,this.editor),this.expandingSelectionBox||this.prevSelectionBox?.cancelSelection(),this.selectionBox.addTo(this.handleOverlay)}snapSelectionToGrid(){if(!this.selectionBox)throw new Error("No selection to snap!");const t=this.selectionBox.computeTightBoundingBox().topLeft,e=this.editor.viewport.snapToGrid(t).minus(t),n=this.selectionBox.getTransform();this.selectionBox.setTransform(n.rightMul(i.Mat33.translation(e))),this.selectionBox.finalizeTransform()}onPointerDown({allPointers:t,current:e}){const n=this.snapToGrid;if(n&&(e=e.snappedToGrid(this.editor.viewport)),1===t.length&&e.isPrimary){this.startPoint=e.canvasPos;let t=!1;if(this.selectionBox){n&&this.snapSelectionToGrid();this.selectionBox.onDragStart(e)&&(t=!0,this.selectionBoxHandlingEvt=!0,this.expandingSelectionBox=!1)}return t||(this.expandingSelectionBox=this.shiftKeyPressed,this.makeSelectionBox(e.canvasPos)),!0}return!1}onPointerMove(t){if(!this.selectionBox)return;let e=t.current;if(!this.expandingSelectionBox&&this.shiftKeyPressed&&this.startPoint){const t=this.editor.viewport.canvasToScreen(this.startPoint);e=e.lockedToXYAxesScreen(t,this.editor.viewport)}this.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox.onDragUpdate(e):this.selectionBox.setToPoint(e.canvasPos)}onGestureEnd(){this.selectionBox&&(this.selectionBoxHandlingEvt?this.selectionBox.onDragEnd():(this.selectionBox.resolveToObjects(),this.onSelectionUpdated()),this.selectionBoxHandlingEvt=!1)}onPointerUp(t){if(!this.selectionBox)return;let e=t.current;this.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBox.setToPoint(e.canvasPos),this.expandingSelectionBox&&this.prevSelectionBox?(this.expandingSelectionBox=!1,this.selectionBox.resolveToObjects(),this.setSelection([...this.selectionBox.getSelectedObjects(),...this.prevSelectionBox.getSelectedObjects()])):this.onGestureEnd()}onGestureCancel(){this.selectionBoxHandlingEvt?this.selectionBox?.onDragCancel():(this.selectionBox?.cancelSelection(),this.selectionBox=this.prevSelectionBox,this.selectionBox?.addTo(this.handleOverlay),this.selectionBox?.recomputeRegion(),this.prevSelectionBox=null),this.expandingSelectionBox=!1}onSelectionUpdated(){const t=this.selectionBox?.getSelectedItemCount()??0,e=this.selectionBox?.getSelectedObjects()??[];(this.lastSelectedObjects.length!==t||e.some(((t,e)=>this.lastSelectedObjects[e]!==t)))&&(this.lastSelectedObjects=e,this.editor.notifier.dispatch(r.EditorEventType.ToolUpdated,{kind:r.EditorEventType.ToolUpdated,tool:this}),this.editor.notifier.dispatch(r.EditorEventType.SelectionUpdated,{kind:r.EditorEventType.SelectionUpdated,selectedComponents:e,tool:this}),t>0&&(this.editor.announceForAccessibility(this.editor.localization.selectedElements(t)),this.zoomToSelection())),0===t&&this.selectionBox&&(this.selectionBox.cancelSelection(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null)}zoomToSelection(){if(this.selectionBox){const t=this.selectionBox.region;this.editor.dispatchNoAnnounce(this.editor.viewport.zoomTo(t,!1),!1)}}onKeyPress(t){const e=this.editor.shortcuts;if(e.matchesShortcut(h.snapToGridKeyboardShortcutId,t))return this.snapToGrid=!0,!0;if(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t))return!0;if(e.matchesShortcut(h.selectAllKeyboardShortcut,t))return this.setSelection(this.editor.image.getAllElements()),!0;if(t.ctrlKey)return!1;if("Shift"===t.key)return this.shiftKeyPressed=!0,!0;let n=0,o=0,r=0,a=0,l=0;switch(t.key){case"a":case"h":case"ArrowLeft":o-=1;break;case"d":case"l":case"ArrowRight":o+=1;break;case"q":case"k":case"ArrowUp":r-=1;break;case"e":case"j":case"ArrowDown":r+=1;break;case"r":n+=1;break;case"R":n-=1;break;case"i":a-=1;break;case"I":a+=1;break;case"o":l-=1;break;case"O":l+=1}let c=0!==o||0!==r||0!==n||0!==a||0!==l;if(this.selectionBox){if(c){const t=10*this.editor.viewport.getSizeOfPixelOnCanvas(),e=Math.PI/8,c=5/4,d=this.selectionBox.region,h=i.Vec2.of(c**a,c**l),u=i.Mat33.zRotation(n*e).mapEntries((t=>s.default.roundScaleRatio(t))),p=this.editor.viewport.roundPoint(d.center),f=i.Mat33.scaling2D(h,this.editor.viewport.roundPoint(d.topLeft)).rightMul(i.Mat33.translation(p).rightMul(u).rightMul(i.Mat33.translation(p.times(-1)))).rightMul(i.Mat33.translation(this.editor.viewport.roundPoint(i.Vec2.of(o,r).times(t)))),m=this.selectionBox.getTransform();this.selectionBox.setTransform(m.rightMul(f))}}else c=!1;return!this.selectionBox||c||"Delete"!==t.key&&"Backspace"!==t.key||(this.editor.dispatch(this.selectionBox.deleteSelectedObjects()),this.clearSelection(),c=!0),c}onKeyUp(t){const e=this.editor.shortcuts;return e.matchesShortcut(h.snapToGridKeyboardShortcutId,t)?(this.snapToGrid=!1,!0):!!e.matchesShortcut(h.selectAllKeyboardShortcut,t)||(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t)?(this.selectionBox.duplicateSelectedObjects().then((t=>{this.editor.dispatch(t)})),!0):"Shift"===t.key?(this.shiftKeyPressed=!1,!0):!(!this.selectionBox||!u.handleableKeys.some((e=>e===t.key)))&&(this.selectionBox.finalizeTransform(),!0))}onCopy(t){if(!this.selectionBox)return!1;const e=this.selectionBox.getSelectedObjects(),n=this.selectionBox.region;if(0===e.length)return!1;const o=new s.default((()=>{}));o.updateScreenSize(i.Vec2.of(n.w,n.h)),o.resetTransform(i.Mat33.translation(n.topLeft.times(-1)));const{element:r,renderer:a}=l.default.fromViewport(o,!0),c=[];for(const t of e)t.render(a),t instanceof d.default&&c.push(t.getText());return t.setData("image/svg+xml",r.outerHTML),t.setData("text/html",r.outerHTML),c.length>0&&t.setData("text/plain",c.join("\n")),!0}setEnabled(t){super.setEnabled(t),this.selectionBox?.cancelSelection(),this.onSelectionUpdated(),this.handleOverlay.replaceChildren(),this.selectionBox=null,this.shiftKeyPressed=!1,this.snapToGrid=!1,this.handleOverlay.style.display=t?"block":"none",t?(this.handleOverlay.tabIndex=0,this.handleOverlay.setAttribute("aria-label",this.editor.localization.selectionToolKeyboardShortcuts)):this.handleOverlay.tabIndex=-1}getSelection(){return this.selectionBox}getSelectedObjects(){return this.selectionBox?.getSelectedObjects()??[]}setSelection(t){(t=t.filter((t=>t.isSelectable()))).sort(((t,e)=>t.getZIndex()-e.getZIndex())),t=t.filter(((e,n)=>!(n>0)||e!==t[n-1]));let e=null;for(const n of t)e=e?e.union(n.getBBox()):n.getBBox();e&&(this.clearSelection(),this.selectionBox||this.makeSelectionBox(e.topLeft),this.selectionBox.setSelectedObjects(t,e),this.onSelectionUpdated())}clearSelection(){this.handleOverlay.replaceChildren(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null,this.onSelectionUpdated()}}u.handleableKeys=["a","h","ArrowLeft","d","l","ArrowRight","q","k","ArrowUp","e","j","ArrowDown","r","R","i","I","o","O","Control","Meta"],e.default=u},8862:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RotateTransformer=e.ResizeTransformer=e.DragTransformer=void 0;const i=n(5097),r=o(n(5566)),s=n(3968);e.DragTransformer=class{constructor(t,e){this.editor=t,this.selection=e}onDragStart(t){this.selection.setTransform(i.Mat33.identity),this.dragStartPoint=t}onDragUpdate(t){const e=this.editor.viewport.roundPoint(t.minus(this.dragStartPoint));this.selection.setTransform(i.Mat33.translation(e))}onDragEnd(){this.selection.finalizeTransform()}};e.ResizeTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.mode=s.ResizeMode.Both}onDragStart(t,e){this.selection.setTransform(i.Mat33.identity),this.mode=e,this.dragStartPoint=t}onDragUpdate(t){const e=t.minus(this.dragStartPoint),n=this.selection.preTransformRegion.width,o=this.selection.preTransformRegion.height;let a=i.Vec2.of(1,1);if(this.mode===s.ResizeMode.HorizontalOnly){const t=n+e.x;a=i.Vec2.of(t/n,a.y)}if(this.mode===s.ResizeMode.VerticalOnly){const t=o+e.y;a=i.Vec2.of(a.x,t/o)}if(this.mode===s.ResizeMode.Both){const t=n+(Math.abs(e.x)>Math.abs(e.y)?e.x:e.y);a=i.Vec2.of(t/n,t/n)}if(a=a.map((t=>r.default.roundScaleRatio(t,2))),0!==a.x&&0!==a.y){const t=this.editor.viewport.roundPoint(this.selection.preTransformRegion.topLeft);this.selection.setTransform(i.Mat33.scaling2D(a,t))}}onDragEnd(){this.selection.finalizeTransform()}};e.RotateTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.startAngle=0}getAngle(t){const e=this.selection.preTransformRegion.center;return t.minus(e).angle()}roundAngle(t){const e=8/Math.PI;return Math.round(t*e)/e}onDragStart(t){this.selection.setTransform(i.Mat33.identity),this.startAngle=this.getAngle(t)}onDragUpdate(t){const e=this.roundAngle(this.getAngle(t)-this.startAngle),n=this.editor.viewport.roundPoint(this.selection.preTransformRegion.center),o=i.Mat33.zRotation(e).mapEntries((t=>r.default.roundScaleRatio(t))),s=i.Mat33.translation(n).rightMul(o).rightMul(i.Mat33.translation(n.times(-1)));this.selection.setTransform(s)}onDragEnd(){this.selection.finalizeTransform()}}},3968:(t,e)=>{"use strict";var n,o;Object.defineProperty(e,"__esModule",{value:!0}),e.TransformMode=e.ResizeMode=void 0,function(t){t[t.Both=0]="Both",t[t.HorizontalOnly=1]="HorizontalOnly",t[t.VerticalOnly=2]="VerticalOnly"}(n||(e.ResizeMode=n={})),function(t){t[t.Snap=0]="Snap",t[t.NoSnap=1]="NoSnap"}(o||(e.TransformMode=o={}))},7893:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(7564));class s{constructor(){if(this.closed=!1,!window.AudioContext)return console.warn("Accessibility sound UI: Unable to open AudioContext."),void(this.closed=!0);this.ctx=new AudioContext,this.colorOscHue=this.ctx.createOscillator(),this.colorOscValue=this.ctx.createOscillator(),this.colorOscSaturation=this.ctx.createOscillator(),this.colorOscHue.type="triangle",this.colorOscSaturation.type="sine",this.colorOscValue.type="sawtooth",this.valueGain=this.ctx.createGain(),this.colorOscValue.connect(this.valueGain),this.valueGain.gain.setValueAtTime(.18,this.ctx.currentTime),this.colorGain=this.ctx.createGain(),this.colorOscHue.connect(this.colorGain),this.valueGain.connect(this.colorGain),this.colorOscSaturation.connect(this.colorGain),this.colorGain.connect(this.ctx.destination),this.boundaryGain=this.ctx.createGain(),this.boundaryOsc=this.ctx.createOscillator(),this.boundaryOsc.type="sawtooth",this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryOsc.connect(this.boundaryGain),this.boundaryGain.connect(this.ctx.destination),this.colorOscHue.start(),this.colorOscSaturation.start(),this.colorOscValue.start(),this.boundaryOsc.start(),this.pause()}pause(){this.closed||(this.colorGain.gain.setValueAtTime(0,this.ctx.currentTime),this.ctx.suspend())}play(){this.closed||this.ctx.resume()}setColor(t){const e=t.asHSV(),n=220*-Math.cos(e.x/2)+440,o=440*e.y+220,i=440*(e.z+.1),r=.25*Math.min(1,t.a)/(1+Math.exp(3*-(e.z-.5)));this.colorOscHue.frequency.setValueAtTime(n,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(o,this.ctx.currentTime),this.colorOscValue.frequency.setValueAtTime(i,this.ctx.currentTime),this.valueGain.gain.setValueAtTime(.4*(1-e.z),this.ctx.currentTime),this.colorGain.gain.setValueAtTime(r,this.ctx.currentTime)}announceBoundaryCross(t){this.boundaryGain.gain.cancelScheduledValues(this.ctx.currentTime),this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(.018,this.ctx.currentTime+.1),this.boundaryOsc.frequency.setValueAtTime(440+100*Math.atan(t/2),this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(0,this.ctx.currentTime+.25)}close(){this.ctx.close(),this.closed=!0}}class a extends r.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.soundFeedback=null,this.toggleButtonContainer=document.createElement("div"),this.toggleButtonContainer.classList.add("js-draw-sound-ui-toggle"),this.toggleButton=document.createElement("button"),this.toggleButton.onclick=()=>{this.setEnabled(!this.isEnabled())},this.toggleButtonContainer.appendChild(this.toggleButton),this.updateToggleButtonText(),t.createHTMLOverlay(this.toggleButtonContainer)}updateToggleButtonText(){const t="sound-ui-tool-enabled";this.isEnabled()?(this.toggleButton.innerText=this.editor.localization.disableAccessibilityExploreTool,this.toggleButtonContainer.classList.add(t)):(this.toggleButton.innerText=this.editor.localization.enableAccessibilityExploreTool,this.toggleButtonContainer.classList.remove(t))}setEnabled(t){super.setEnabled(t),t?this.editor.announceForAccessibility(this.editor.localization.soundExplorerUsageAnnouncement):(this.soundFeedback?.close(),this.soundFeedback=null),this.updateToggleButtonText()}onKeyPress(t){return"Escape"===t.code&&(this.setEnabled(!1),!0)}onPointerDown({current:t,allPointers:e}){return this.soundFeedback||(this.soundFeedback=new s),!(e.length>=2)&&(this.soundFeedback?.play(),this.soundFeedback?.setColor(this.editor.display.getColorAt(t.screenPos)??i.Color4.black),this.lastPointerPos=t.canvasPos,!0)}onPointerMove({current:t}){this.soundFeedback?.setColor(this.editor.display.getColorAt(t.screenPos)??i.Color4.black);const e=new i.LineSegment2(this.lastPointerPos,t.canvasPos),n=this.editor.image.getElementsIntersectingRegion(e.bbox).filter((t=>t.intersects(e)));this.lastPointerPos=t.canvasPos,n.length>0&&this.soundFeedback?.announceBoundaryCross(n.length)}onPointerUp(t){this.soundFeedback?.pause()}onGestureCancel(){this.soundFeedback?.pause()}}e.default=a},4321:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=o(n(7551)),s=n(5097),a=n(4318),l=n(3173),c=o(n(7564)),d=o(n(9721)),h=o(n(1456)),u=n(1151),p="textEditorOverlay";class f extends c.default{constructor(t,e,n){super(t.notifier,e),this.editor=t,this.localizationTable=n,this.textInputElem=null,this.textTargetPosition=null,this.textMeasuringCtx=null,this.textScale=s.Vec2.of(1,1),this.removeExistingCommand=null,this.textStyleValue=u.ReactiveValue.fromInitialValue({size:32,fontFamily:"sans-serif",renderingStyle:{fill:s.Color4.purple}}),this.textStyleValue.onUpdateAndNow((()=>{this.textStyle=this.textStyleValue.get(),this.updateTextInput(),this.editor.notifier.dispatch(l.EditorEventType.ToolUpdated,{kind:l.EditorEventType.ToolUpdated,tool:this})})),this.textEditOverlay=document.createElement("div"),this.textEditOverlay.classList.add(p),this.editor.addStyleSheet(`\n\t\t\t.${p} {\n\t\t\t\theight: 0;\n\t\t\t\toverflow: visible;\n\t\t\t}\n\n\t\t\t.${p} textarea {\n\t\t\t\tbackground-color: rgba(0, 0, 0, 0);\n\n\t\t\t\twhite-space: pre;\n\t\t\t\toverflow: hidden;\n\n\t\t\t\tpadding: 0;\n\t\t\t\tmargin: 0;\n\t\t\t\tborder: none;\n\t\t\t\tpadding: 0;\n\n\t\t\t\tmin-width: 100px;\n\t\t\t\tmin-height: 1.1em;\n\t\t\t}\n\t\t`),this.editor.createHTMLOverlay(this.textEditOverlay),this.editor.notifier.on(l.EditorEventType.ViewportChanged,(()=>this.updateTextInput()))}initTextMeasuringCanvas(){this.textMeasuringCtx??=document.createElement("canvas").getContext("2d")}getTextAscent(t,e){if(this.initTextMeasuringCanvas(),this.textMeasuringCtx){this.textMeasuringCtx.textBaseline="alphabetic",i.default.applyTextStyles(this.textMeasuringCtx,e);const n=this.textMeasuringCtx.measureText(t);return n.fontBoundingBoxAscent??n.actualBoundingBoxAscent}return 2*e.size/3}flushInput(t=!0){if(this.textInputElem&&this.textTargetPosition){const e=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",t){const t=this.textInputElem;this.textInputElem=null,t.remove()}if(""===e)return;const n=s.Mat33.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(s.Mat33.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(s.Mat33.zRotation(this.textRotation)),o=i.default.fromLines(e.split("\n"),n,this.textStyle),a=r.default.addElement(o);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch((0,h.default)([this.removeExistingCommand,a])),this.removeExistingCommand=null):this.editor.dispatch(a)}}getTextScaleMatrix(){return s.Mat33.scaling2D(this.textScale.times(1/this.editor.viewport.getSizeOfPixelOnCanvas()))}updateTextInput(){if(!this.textInputElem||!this.textTargetPosition)return void this.textInputElem?.remove();const t=this.editor.viewport,e=t.canvasToScreen(this.textTargetPosition);this.textInputElem.placeholder=this.localizationTable.enterTextToInsert,this.textInputElem.style.fontFamily=this.textStyle.fontFamily,this.textInputElem.style.fontStyle=this.textStyle.fontStyle??"",this.textInputElem.style.fontVariant=this.textStyle.fontVariant??"",this.textInputElem.style.fontWeight=this.textStyle.fontWeight??"",this.textInputElem.style.fontSize=`${this.textStyle.size}px`,this.textInputElem.style.color=this.textStyle.renderingStyle.fill.toHexString(),this.textInputElem.style.position="relative",this.textInputElem.style.left=`${e.x}px`,this.textInputElem.style.top=`${e.y}px`,this.textInputElem.style.margin="0",this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`;const n=this.getTextAscent("Testing!",this.textStyle),o=this.textRotation+t.getRotationAngle(),i=this.getTextScaleMatrix();this.textInputElem.style.transform=`${i.toCSSMatrix()} rotate(${180*o/Math.PI}deg) translate(0, ${-n}px)`,this.textInputElem.style.transformOrigin="top left";const r=Math.floor(this.textStyle.size);this.textInputElem.style.lineHeight=`${r}px`}startTextInput(t,e){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=e,this.textInputElem.style.display="inline-block",this.textTargetPosition=this.editor.viewport.roundPoint(t),this.textRotation=-this.editor.viewport.getRotationAngle(),this.textScale=s.Vec2.of(1,1).times(this.editor.viewport.getSizeOfPixelOnCanvas()),this.updateTextInput(),setTimeout((()=>this.updateTextInput()),0),this.textInputElem.oninput=()=>{this.textInputElem&&(this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`)},this.textInputElem.onblur=()=>{const t=this.textInputElem;this.flushInput(!1),this.textInputElem=null,setTimeout((()=>{t?.remove()}),0)},this.textInputElem.onkeyup=t=>{"Enter"!==t.key||t.shiftKey?"Escape"===t.key&&(this.textInputElem?.remove(),this.textInputElem=null,this.editor.focus(),this.removeExistingCommand?.unapply(this.editor),this.removeExistingCommand=null):(this.flushInput(),this.editor.focus())},this.textEditOverlay.replaceChildren(this.textInputElem),setTimeout((()=>this.textInputElem?.focus()),0)}setEnabled(t){super.setEnabled(t),t||this.flushInput(),this.textEditOverlay.style.display=t?"block":"none"}onPointerDown({current:t,allPointers:e}){if(t.device===a.PointerDevice.Eraser)return!1;if(1===e.length){const e=t.canvasPos,n=s.Vec2.of(2.5,2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas()),o=s.Rect2.fromCorners(e.minus(n),e.plus(n));let r=this.editor.image.getElementsIntersectingRegion(o).filter((t=>t instanceof i.default));const a=this.editor.viewport.visibleRect;if(r=r.filter((t=>!t.getBBox().containsRect(a))),this.flushInput(),r.length>0){const t=r[r.length-1];this.setTextStyle(t.getTextStyle()),this.removeExistingCommand=new d.default([t]),this.removeExistingCommand.apply(this.editor),this.startTextInput(t.getBaselinePos(),t.getText());const e=t.getTransform();this.textRotation=e.transformVec3(s.Vec2.unitX).angle();const n=e.transformVec3(s.Vec2.unitX).magnitude();this.textScale=s.Vec2.of(1,1).times(n),this.updateTextInput()}else this.removeExistingCommand=null,this.startTextInput(t.canvasPos,"");return!0}return!1}onGestureCancel(){this.flushInput(),this.editor.focus()}setFontFamily(t){t!==this.textStyle.fontFamily&&this.textStyleValue.set({...this.textStyle,fontFamily:t})}setColor(t){t.eq(this.textStyle.renderingStyle.fill)||this.textStyleValue.set({...this.textStyle,renderingStyle:{...this.textStyle.renderingStyle,fill:t}})}setFontSize(t){t!==this.textStyle.size&&this.textStyleValue.set({...this.textStyle,size:t})}getTextStyle(){return this.textStyle}getStyleValue(){return this.textStyleValue}setTextStyle(t){this.textStyleValue.set(t)}}e.default=f},8169:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(3173),l=n(5097),c=r(n(4735)),d=s(n(2133)),h=s(n(6122)),u=s(n(6416)),p=s(n(7591)),f=s(n(4074)),m=s(n(4321)),g=s(n(5248)),b=s(n(3448)),y=s(n(2719)),v=s(n(6390)),w=n(823),x=s(n(5805)),S=s(n(8519)),T=s(n(7893)),C=n(7520),P=s(n(3135)),k=s(n(2785)),E=s(n(8311));e.default=class{constructor(t,e){this.activeTool=null,this.inputPipeline=new P.default,this.inputPipeline.setEmitListener((t=>this.onEventInternal(t)));const n=new h.default;this.primaryToolGroup=n;const o=new c.default(t,c.PanZoomMode.TwoFingerTouchGestures|c.PanZoomMode.RightClickDrags,e.touchPanTool),i=new c.default(t,c.PanZoomMode.Keyboard,e.keyboardPanZoom),r=new d.default(t,e.penTool(1),{color:l.Color4.purple,thickness:8}),s=new d.default(t,e.penTool(2),{color:l.Color4.clay,thickness:4});s.setInputMapper(new k.default(t.viewport));const C=[r,s,new d.default(t,e.penTool(3),{color:l.Color4.ofRGBA(1,1,0,.5),thickness:40,factory:w.makePressureSensitiveFreehandLineBuilder}),new u.default(t,e.eraserTool),new p.default(t,e.selectionTool),new m.default(t,e.textTool,e),new c.default(t,c.PanZoomMode.SinglePointerGestures,e.anyDevicePanning)],z=new T.default(t,e.soundExplorer);z.setEnabled(!1),this.tools=[new E.default(t),new g.default(t,e.pipetteTool),z,o,...C,i,new f.default(t),new v.default(t),new b.default(t),new x.default(t),new y.default(t),new S.default(t)],C.forEach((t=>t.setToolGroup(n))),o.setEnabled(!0),r.setEnabled(!0),t.notifier.on(a.EditorEventType.ToolEnabled,(n=>{n.kind===a.EditorEventType.ToolEnabled&&t.announceForAccessibility(e.toolEnabledAnnouncement(n.tool.description))})),t.notifier.on(a.EditorEventType.ToolDisabled,(n=>{n.kind===a.EditorEventType.ToolDisabled&&t.announceForAccessibility(e.toolDisabledAnnouncement(n.tool.description))})),this.activeTool=null}setTools(t,e){this.tools=t,this.primaryToolGroup=e??new h.default}addPrimaryTool(t){t.setToolGroup(this.primaryToolGroup),t.isEnabled()&&this.primaryToolGroup.notifyEnabled(t),this.addTool(t)}getPrimaryTools(){return this.tools.filter((t=>t.getToolGroup()===this.primaryToolGroup))}addTool(t){this.tools.push(t)}onEventInternal(t){let e=!1;if(t.kind===C.InputEvtType.PointerDownEvt){let n=!1;this.activeTool&&!this.activeTool.eventCanBeDeliveredToNonActiveTool(t)&&(n=!0);for(const o of this.tools)if((!n||o===this.activeTool)&&o.isEnabled()&&o.onEvent(t)){this.activeTool!==o&&this.activeTool?.onEvent({kind:C.InputEvtType.GestureCancelEvt}),this.activeTool=o,e=!0;break}}else if(t.kind===C.InputEvtType.PointerUpEvt){const n=this.activeTool?.onEvent(t);n&&t.allPointers.length>1||(this.activeTool=null),e=!0}else if(t.kind===C.InputEvtType.PointerMoveEvt)null!==this.activeTool&&(this.activeTool.onEvent(t),e=!0);else if(t.kind===C.InputEvtType.GestureCancelEvt)null!==this.activeTool&&(this.activeTool.onEvent(t),this.activeTool=null);else for(const n of this.tools)if(n.isEnabled()&&(e=n.onEvent(t),e))break;return e}onEvent(t){return this.dispatchInputEvent(t)}dispatchInputEvent(t){return this.inputPipeline.onEvent(t)}addInputMapper(t){this.inputPipeline.addToTail(t)}getMatchingTools(t){return this.tools.filter((e=>e instanceof t))}}},6122:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){}notifyEnabled(t){t!==this.activeTool&&(this.activeTool?.setEnabled(!1),this.activeTool=t)}}},3448:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564));class r extends i.default{constructor(t){super(t.notifier,t.localization.changeTool),this.editor=t}onKeyPress({key:t}){const e=this.editor.toolController.getPrimaryTools(),n=/^[0-9]$/.exec(t);let o;if(n){o=e[parseInt(n[0],10)-1]}return!!o&&(o.setEnabled(!0),!0)}}e.default=r},6390:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564));class r extends i.default{constructor(t){super(t.notifier,t.localization.changeTool),this.listeners=new Set([])}registerListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}onKeyPress(t){const e=Array.from(this.listeners.values());for(const n of e)if(n(t))return!0;return!1}}e.default=r},4074:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564)),r=n(3348);class s extends i.default{constructor(t){super(t.notifier,t.localization.undoRedoTool),this.editor=t}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(r.undoKeyboardShortcutId,t)?(this.editor.history.undo(),!0):!!this.editor.shortcuts.matchesShortcut(r.redoKeyboardShortcutId,t)&&(this.editor.history.redo(),!0)}}e.default=s},3348:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.duplicateSelectionShortcut=e.selectAllKeyboardShortcut=e.zoomOutKeyboardShortcutId=e.zoomInKeyboardShortcutId=e.rotateCounterClockwiseKeyboardShortcutId=e.rotateClockwiseKeyboardShortcutId=e.moveDownKeyboardShortcutId=e.moveUpKeyboardShortcutId=e.moveRightKeyboardShortcutId=e.moveLeftKeyboardShortcutId=e.toggleFindVisibleShortcutId=e.lineLockKeyboardShortcutId=e.snapToGridKeyboardShortcutId=e.decreaseSizeKeyboardShortcutId=e.increaseSizeKeyboardShortcutId=e.redoKeyboardShortcutId=e.undoKeyboardShortcutId=void 0;const i=o(n(5376));e.undoKeyboardShortcutId="jsdraw.tools.undo",e.redoKeyboardShortcutId="jsdaw.tools.redo",i.default.registerDefaultKeyboardShortcut(e.undoKeyboardShortcutId,["CtrlOrMeta+KeyZ"],"Undo"),i.default.registerDefaultKeyboardShortcut(e.redoKeyboardShortcutId,["CtrlOrMeta+Shift+KeyZ","CtrlOrMeta+KeyY"],"Redo"),e.increaseSizeKeyboardShortcutId="jsdraw.tools.increaseSize",i.default.registerDefaultKeyboardShortcut(e.increaseSizeKeyboardShortcutId,["Equal","Shift+Equal"],"Increase pen/eraser size"),e.decreaseSizeKeyboardShortcutId="jsdraw.tools.decreaseSize",i.default.registerDefaultKeyboardShortcut(e.decreaseSizeKeyboardShortcutId,["Minus","Shift+Minus"],"Decrease pen/eraser size"),e.snapToGridKeyboardShortcutId="jsdraw.tools.snapToGrid",i.default.registerDefaultKeyboardShortcut(e.snapToGridKeyboardShortcutId,["Control","Meta"],"Snap to grid (press and hold)"),e.lineLockKeyboardShortcutId="jsdraw.tools.lockToLine",i.default.registerDefaultKeyboardShortcut(e.lineLockKeyboardShortcutId,["Shift"],"Snap to XY axes (press and hold)"),e.toggleFindVisibleShortcutId="js-draw.tools.FindTool.toggleVisible",i.default.registerDefaultKeyboardShortcut(e.toggleFindVisibleShortcutId,["CtrlOrMeta+KeyF"],"Shows/hides the find tool"),e.moveLeftKeyboardShortcutId="jsdraw.tools.PanZoom.moveLeft",i.default.registerDefaultKeyboardShortcut(e.moveLeftKeyboardShortcutId,["ArrowLeft","KeyH","KeyA"],"Pan left"),e.moveRightKeyboardShortcutId="jsdraw.tools.PanZoom.moveRight",i.default.registerDefaultKeyboardShortcut(e.moveRightKeyboardShortcutId,["ArrowRight","KeyL","KeyD"],"Pan right"),e.moveUpKeyboardShortcutId="jsdraw.tools.PanZoom.moveUp",i.default.registerDefaultKeyboardShortcut(e.moveUpKeyboardShortcutId,["ArrowUp","KeyK","KeyQ"],"Pan up"),e.moveDownKeyboardShortcutId="jsdraw.tools.PanZoom.moveDown",i.default.registerDefaultKeyboardShortcut(e.moveDownKeyboardShortcutId,["ArrowDown","KeyJ","KeyE"],"Pan down"),e.rotateClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewClockwise",i.default.registerDefaultKeyboardShortcut(e.rotateClockwiseKeyboardShortcutId,["Shift+KeyR"],"Rotate viewport clockwise"),e.rotateCounterClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewCounterClockwise",i.default.registerDefaultKeyboardShortcut(e.rotateCounterClockwiseKeyboardShortcutId,["KeyR"],"Rotate viewport counter-clockwise"),e.zoomInKeyboardShortcutId="jsdraw.tools.PanZoom.zoomIn",i.default.registerDefaultKeyboardShortcut(e.zoomInKeyboardShortcutId,["KeyW"],"Zoom in"),e.zoomOutKeyboardShortcutId="jsdraw.tools.PanZoom.zoomOut",i.default.registerDefaultKeyboardShortcut(e.zoomOutKeyboardShortcutId,["KeyS"],"Zoom out"),e.selectAllKeyboardShortcut="jsdraw.tools.SelectionTool.selectAll",i.default.registerDefaultKeyboardShortcut(e.selectAllKeyboardShortcut,["CtrlOrMeta+KeyA"],"Select all"),e.duplicateSelectionShortcut="jsdraw.tools.SelectionTool.duplicateSelection",i.default.registerDefaultKeyboardShortcut(e.duplicateSelectionShortcut,["CtrlOrMeta+KeyD"],"Duplicate selection")},1709:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ToolbarShortcutHandler=e.SoundUITool=e.PasteHandler=e.EraserTool=e.SelectAllShortcutHandler=e.SelectionTool=e.TextTool=e.PenTool=e.PanZoomMode=e.PanZoomTool=e.ToolSwitcherShortcut=e.UndoRedoShortcut=e.ToolEnabledGroup=e.ToolController=e.BaseTool=void 0;var i=n(7564);Object.defineProperty(e,"BaseTool",{enumerable:!0,get:function(){return o(i).default}});var r=n(8169);Object.defineProperty(e,"ToolController",{enumerable:!0,get:function(){return o(r).default}});var s=n(6122);Object.defineProperty(e,"ToolEnabledGroup",{enumerable:!0,get:function(){return o(s).default}});var a=n(4074);Object.defineProperty(e,"UndoRedoShortcut",{enumerable:!0,get:function(){return o(a).default}});var l=n(3448);Object.defineProperty(e,"ToolSwitcherShortcut",{enumerable:!0,get:function(){return o(l).default}});var c=n(4735);Object.defineProperty(e,"PanZoomTool",{enumerable:!0,get:function(){return o(c).default}}),Object.defineProperty(e,"PanZoomMode",{enumerable:!0,get:function(){return c.PanZoomMode}});var d=n(2133);Object.defineProperty(e,"PenTool",{enumerable:!0,get:function(){return o(d).default}});var h=n(4321);Object.defineProperty(e,"TextTool",{enumerable:!0,get:function(){return o(h).default}});var u=n(7591);Object.defineProperty(e,"SelectionTool",{enumerable:!0,get:function(){return o(u).default}});var p=n(8519);Object.defineProperty(e,"SelectAllShortcutHandler",{enumerable:!0,get:function(){return o(p).default}});var f=n(6416);Object.defineProperty(e,"EraserTool",{enumerable:!0,get:function(){return o(f).default}});var m=n(2719);Object.defineProperty(e,"PasteHandler",{enumerable:!0,get:function(){return o(m).default}});var g=n(7893);Object.defineProperty(e,"SoundUITool",{enumerable:!0,get:function(){return o(g).default}});var b=n(6390);Object.defineProperty(e,"ToolbarShortcutHandler",{enumerable:!0,get:function(){return o(b).default}})},3376:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolLocalization=void 0,e.defaultToolLocalization={penTool:t=>`Pen ${t}`,selectionTool:"Selection",selectAllTool:"Select all shortcut",eraserTool:"Eraser",touchPanTool:"Touch panning",twoFingerPanZoomTool:"Panning and zooming",undoRedoTool:"Undo/Redo",rightClickDragPanTool:"Right-click drag",pipetteTool:"Pick color from screen",keyboardPanZoom:"Keyboard pan/zoom shortcuts",textTool:"Text",enterTextToInsert:"Text to insert",changeTool:"Change tool",pasteHandler:"Copy paste handler",soundExplorer:"Sound-based image exploration",disableAccessibilityExploreTool:"Disable sound-based exploration",enableAccessibilityExploreTool:"Enable sound-based exploration",soundExplorerUsageAnnouncement:"Sound-based image exploration enabled: Click/drag the screen to play a sound representation of different parts of the image.",findLabel:"Find",toNextMatch:"Next",closeDialog:"Close",findDialogShown:"Find dialog shown",findDialogHidden:"Find dialog hidden",focusedFoundText:(t,e)=>`Viewing match ${t} of ${e}`,anyDevicePanning:"Any device panning",copied:(t,e)=>`Copied ${t} ${e}`,pasted:(t,e)=>`Pasted ${t} ${e}`,toolEnabledAnnouncement:t=>`${t} enabled`,toolDisabledAnnouncement:t=>`${t} disabled`}},3173:(t,e)=>{"use strict";var n,o;Object.defineProperty(e,"__esModule",{value:!0}),e.UndoEventType=e.EditorEventType=void 0,function(t){t[t.ToolEnabled=0]="ToolEnabled",t[t.ToolDisabled=1]="ToolDisabled",t[t.ToolUpdated=2]="ToolUpdated",t[t.UndoRedoStackUpdated=3]="UndoRedoStackUpdated",t[t.CommandDone=4]="CommandDone",t[t.CommandUndone=5]="CommandUndone",t[t.ObjectAdded=6]="ObjectAdded",t[t.ViewportChanged=7]="ViewportChanged",t[t.DisplayResized=8]="DisplayResized",t[t.SelectionUpdated=9]="SelectionUpdated",t[t.ColorPickerToggled=10]="ColorPickerToggled",t[t.ColorPickerColorSelected=11]="ColorPickerColorSelected",t[t.ToolbarDropdownShown=12]="ToolbarDropdownShown"}(n||(e.EditorEventType=n={})),function(t){t[t.CommandDone=0]="CommandDone",t[t.CommandUndone=1]="CommandUndone",t[t.CommandRedone=2]="CommandRedone"}(o||(e.UndoEventType=o={}))},1151:function(t,e){"use strict";var n,o,i=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0}),e.MutableReactiveValue=e.ReactiveValue=void 0;const s={remove(){}},a=()=>s;class l{static fromInitialValue(t){return new d(t)}static fromImmutable(t){return{get:()=>t,onUpdate:a,onUpdateAndNow:e=>(e(t),s)}}static fromCallback(t,e){const n=new d(t()),o=window.WeakRef?new WeakRef(n):{deref:()=>n};for(const n of e){const e=n.onUpdate((()=>{const n=o.deref();n?n.set(t()):e.remove()}))}return n}static map(t,e,n){const o=l.fromInitialValue(e(t.get()));let i=o.get();return t.onUpdate((t=>{i=e(t),o.set(i)})),n&&o.onUpdate((e=>{e!==i&&t.set(n(e))})),o}}e.ReactiveValue=l;class c extends l{static fromProperty(t,e){const n=l.fromInitialValue(t.get()[e]),o=window.WeakRef?new WeakRef(n):{deref:()=>n},i=t.onUpdate((t=>{const n=o.deref();n?n.set(t[e]):i.remove()}));return n.onUpdate((n=>{t.set({...t.get(),[e]:n})})),n}}e.MutableReactiveValue=c;class d extends c{constructor(t){super(),n.set(this,void 0),o.set(this,void 0),i(this,n,t,"f"),i(this,o,[],"f")}set(t){if(r(this,n,"f")!==t){i(this,n,t,"f");for(const e of r(this,o,"f"))e(t)}}get(){return r(this,n,"f")}onUpdate(t){return r(this,o,"f").push(t),{remove:()=>{i(this,o,r(this,o,"f").filter((e=>e!==t)),"f")}}}onUpdateAndNow(t){return t(this.get()),this.onUpdate(t)}}n=new WeakMap,o=new WeakMap,e.default=l},438:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097);e.default=(t,e)=>{const n=t.getRootElement(),i=[["--background-color-1","--foreground-color-1",!0,!0],["--background-color-2","--foreground-color-2",!0,!0],["--background-color-3","--foreground-color-3",!0,!0],["--background-color-2","--primary-action-foreground-color",!1,!0],["--selection-background-color","--selection-foreground-color",!1,!0]];if(!e?.dontClearOverrides)for(const[t,e]of i)n.style.setProperty(t,null),n.style.setProperty(e,null);const r=getComputedStyle(n),s=Object.create(null),a=(t,e,i,a,l)=>{let c=s[t]?s[t]:o.Color4.fromString(r.getPropertyValue(t)),d=s[e]?s[e]:o.Color4.fromString(r.getPropertyValue(e));if(c.relativeLuminance()<d.relativeLuminance()){const n=c;c=d,d=n;const o=e;e=t,t=o;const i=a;a=l,l=i}let h=!1,u=o.Color4.contrastRatio(c,d),p=0;for(;u<i&&p<8;){const t=o.Vec3.of(.1,.1,.1);a&&(d.eq(o.Color4.white)&&!l&&(d=o.Color4.black),c=o.Color4.fromRGBVector(c.rgb.plus(t))),l&&(d.eq(o.Color4.black)&&!a&&(d=o.Color4.white),d=o.Color4.fromRGBVector(d.rgb.minus(t))),u=o.Color4.contrastRatio(c,d),h=!0,p++}h&&(n.style.setProperty(t,c.toHexString()),n.style.setProperty(e,d.toHexString()),s[t]=c,s[e]=d)};a("--selection-background-color","--background-color-2",1.29,!0,!1);for(const[t,e,n,o]of i){a(t,e,4.5,n,o)}}},6585:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertIsBoolean=e.assertIsNumberArray=e.assertIsNumber=e.assertUnreachable=void 0;e.assertUnreachable=t=>{throw new Error(`Should be unreachable. Key: ${t}.`)};e.assertIsNumber=(t,e=!1)=>{if("number"!=typeof t||!e&&isNaN(t))throw new Error("Given value is not a number");return!0};e.assertIsNumberArray=(t,n=!1)=>{if("object"!=typeof t)throw new Error("Asserting isNumberArray: Given entity is not an array");if(!(0,e.assertIsNumber)(t.length))return!1;for(const o of t)if(!(0,e.assertIsNumber)(o,n))return!1;return!0};e.assertIsBoolean=t=>{if("boolean"!=typeof t)throw new Error("Given value is not a boolean");return!0}},9070:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=new FileReader;return new Promise(((o,i)=>{n.onload=()=>o(n.result),n.onerror=i,n.onabort=i,n.onprogress=t=>{e?.(t)},n.readAsDataURL(t)}))}},1993:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n={Control:"ControlLeft","=":"Equal","-":"Minus",";":"Semicolon"," ":"Space"};e.default=t=>{const e=t.toUpperCase();return"A"<=e&&e<="Z"?`Key${e}`:"0"<=t&&t<="9"?`Digit${t}`:t in n?n[t]:t}},3662:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.adjustEditorThemeForContrast=void 0;var i=n(438);Object.defineProperty(e,"adjustEditorThemeForContrast",{enumerable:!0,get:function(){return o(i).default}})},8315:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=t.length<e.length?t:e,o=n===t?e:t;for(let t=0;t<n.length;t++)if(n[t]!==o[t])return!1;return!0}},9441:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{t.onwheel=e=>{const n=t.clientWidth!==t.scrollWidth&&0!==e.deltaX,o=t.scrollLeft+e.deltaX<=0,i=t.scrollLeft+t.clientWidth+e.deltaX>t.scrollWidth;!n||o||i||e.stopPropagation()}}},7395:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=()=>new Promise((t=>{requestAnimationFrame((()=>t()))}))},7129:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{if(t.some((t=>t&&t.then)))return Promise.all(t).then((()=>{}))}},2674:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={number:"1.3.1"}},9143:(t,e,n)=>{"use strict";n.r(e);var o=n(6062),i=n.n(o),r=n(4036),s=n.n(r),a=n(6793),l=n.n(a),c=n(7892),d=n.n(c),h=n(1173),u=n.n(h),p=n(2464),f=n.n(p),m=n(4245),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u();i()(m.Z,g);m.Z&&m.Z.locals&&m.Z.locals;var b=n(489),y={};y.styleTagTransform=f(),y.setAttributes=d(),y.insert=l().bind(null,"head"),y.domAPI=s(),y.insertStyleElement=u();i()(b.Z,y);b.Z&&b.Z.locals&&b.Z.locals},8463:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Color4=void 0;const i=o(n(3505));class r{constructor(t,e,n,o){this.r=t,this.g=e,this.b=n,this.a=o,this.hexString=null}static ofRGB(t,e,n){return r.ofRGBA(t,e,n,1)}static ofRGBA(t,e,n,o){return t=Math.max(0,Math.min(t,1)),e=Math.max(0,Math.min(e,1)),n=Math.max(0,Math.min(n,1)),o=Math.max(0,Math.min(o,1)),new r(t,e,n,o)}static fromHex(t){if(!(t=(t=(t.match(/^[#]?(.*)$/)??[])[1]).toUpperCase()).match(/^[0-9A-F]+$/))throw new Error(`${t} is not in a valid format.`);if(3===t.length||4===t.length){const e=t.split("");t=e.map((t=>`${t}0`)).join("")}6===t.length&&(t+="FF");const e=[];for(let n=2;n<=t.length;n+=2){const o=t.substring(n-2,n);e.push(parseInt(o,16)/255)}if(4!==e.length)throw new Error(`Unable to parse ${t}: Wrong number of components.`);return r.ofRGBA(e[0],e[1],e[2],e[3])}static fromString(t){if(t.startsWith("#"))return r.fromHex(t);if("none"===t||"transparent"===t)return r.transparent;if(""===t)return r.black;const e=t.replace(/\s*/g,"").match(/^rgba?\(([,0-9.]+)\)$/i);if(e){const n=e[1],o=JSON.parse(`[ ${n} ]`);if(3===o.length)return r.ofRGB(o[0]/255,o[1]/255,o[2]/255);if(4===o.length)return r.ofRGBA(o[0]/255,o[1]/255,o[2]/255,o[3]);throw new Error(`RGB string, ${t}, has wrong number of components: ${o.length}`)}const n=document.createElement("canvas");n.width=1,n.height=1;const o=n.getContext("2d");if(!o)return r.black;o.fillStyle=t,o.fillRect(0,0,1,1);const i=o.getImageData(0,0,1,1),s=i.data[0]/255,a=i.data[1]/255,l=i.data[2]/255,c=i.data[3]/255;return r.ofRGBA(s,a,l,c)}eq(t){return null!=t&&(0===this.a&&0===t.a||this.toHexString()===t.toHexString())}mix(t,e){const n=1-(e=Math.min(Math.max(e,0),1));return new r(this.r*n+t.r*e,this.g*n+t.g*e,this.b*n+t.b*e,this.a*n+t.a*e)}get rgb(){return i.default.of(this.r,this.g,this.b)}relativeLuminance(){const t=[this.r,this.g,this.b].map((t=>t<.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)));return.2126*t[0]+.7152*t[1]+.0722*t[2]}static contrastRatio(t,e){const n=t.relativeLuminance(),o=e.relativeLuminance();return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}static average(t){let e=0,n=0,o=0,i=0;for(const r of t)e+=r.a,n+=r.r,o+=r.g,i+=r.b;return t.length>0&&(e/=t.length,n/=t.length,o/=t.length,i/=t.length),new r(n,o,i,e)}asHSV(){const t=Math.min(this.r,this.g,this.b),e=Math.max(this.r,this.g,this.b),n=e-t;let o;o=0===n?0:this.r>=this.g&&this.r>=this.b?(this.g-this.b)/n%6:this.g>=this.r&&this.g>=this.b?(this.b-this.r)/n+2:(this.r-this.g)/n+4,o*=60,o*=Math.PI/180,o<0&&(o+=2*Math.PI);const r=e,s=r>0?n/r:0;return i.default.of(o,s,r)}static fromHSV(t,e,n){t<0&&(t+=2*Math.PI),t%=2*Math.PI;const o=(n=Math.max(0,Math.min(1,n)))*(e=Math.max(0,Math.min(1,e))),i=t/(Math.PI/3),s=o*(1-Math.abs(i%2-1));let a;a=i<1?[o,s,0]:i<2?[s,o,0]:i<3?[0,o,s]:i<4?[0,s,o]:i<5?[s,0,o]:[o,0,s];const l=n-o;return r.ofRGB(a[0]+l,a[1]+l,a[2]+l)}static fromRGBVector(t,e){return r.ofRGBA(t.x,t.y,t.z,e??1)}toHexString(){if(this.hexString)return this.hexString;const t=t=>{const e=Math.round(255*t).toString(16);return 1===e.length?`0${e}`:e},e=t(this.a),n=t(this.r),o=t(this.g),i=t(this.b);return"ff"===e?`#${n}${o}${i}`:(this.hexString=`#${n}${o}${i}${e}`,this.hexString)}toString(){return this.toHexString()}}e.Color4=r,r.transparent=r.ofRGBA(0,0,0,0),r.red=r.ofRGB(1,0,0),r.orange=r.ofRGB(1,.65,0),r.green=r.ofRGB(0,1,0),r.blue=r.ofRGB(0,0,1),r.purple=r.ofRGB(.5,.2,.5),r.yellow=r.ofRGB(1,1,.1),r.clay=r.ofRGB(.8,.4,.2),r.black=r.ofRGB(0,0,0),r.gray=r.ofRGB(.5,.5,.5),r.white=r.ofRGB(1,1,1),e.default=r},3380:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Mat33=void 0;const i=n(1728),r=o(n(3505)),s=n(8207);class a{constructor(t,e,n,o,i,s,a,l,c){this.a1=t,this.a2=e,this.a3=n,this.b1=o,this.b2=i,this.b3=s,this.c1=a,this.c2=l,this.c3=c,this.cachedInverse=void 0,this.rows=[r.default.of(t,e,n),r.default.of(o,i,s),r.default.of(a,l,c)]}static ofRows(t,e,n){return new a(t.x,t.y,t.z,e.x,e.y,e.z,n.x,n.y,n.z)}inverse(){return this.computeInverse()??a.identity}invertable(){return null!==this.computeInverse()}computeInverse(){if(void 0!==this.cachedInverse)return this.cachedInverse;const t=[this.rows[0],this.rows[1],this.rows[2]],e=[r.default.unitX,r.default.unitY,r.default.unitZ];for(let n=0;n<3;n++){let o=t[n].at(n);const i=1e-10;if(Math.abs(o)<i){let r=-1;for(let e=1;e<=2;e++){const o=(n+e)%3;if(Math.abs(t[o].at(n))>=i){r=o;break}}if(-1===r)return this.cachedInverse=null,null;const s=t[n],a=e[n];t[n]=t[r],e[n]=e[r],t[r]=s,e[r]=a,o=t[n].at(n)}let r=1/o;t[n]=t[n].times(r),e[n]=e[n].times(r);const s=t[n],a=e[n];for(let o=1;o<=2;o++){const i=(n+o)%3;r=-t[i].at(n),t[i]=t[i].plus(s.times(r)),e[i]=e[i].plus(a.times(r))}}const n=a.ofRows(e[0],e[1],e[2]);return this.cachedInverse=n,n}transposed(){return new a(this.a1,this.b1,this.c1,this.a2,this.b2,this.c2,this.a3,this.b3,this.c3)}rightMul(t){t=t.transposed();const e=(e,n)=>this.rows[e].dot(t.rows[n]);return new a(e(0,0),e(0,1),e(0,2),e(1,0),e(1,1),e(1,2),e(2,0),e(2,1),e(2,2))}transformVec2(t){let e=r.default.of(t.x,t.y,1);return e=this.transformVec3(e),i.Vec2.of(e.x,e.y)}transformVec3(t){return r.default.of(this.rows[0].dot(t),this.rows[1].dot(t),this.rows[2].dot(t))}isIdentity(){return this===a.identity||this.eq(a.identity)}eq(t,e=0){for(let n=0;n<3;n++)if(!this.rows[n].eq(t.rows[n],e))return!1;return!0}toString(){let t="";const e=[0,0,0];for(const t of this.rows)for(let n=0;n<3;n++)e[n]=Math.max(e[0],`${t.at(n)}`.length);for(let n=0;n<3;n++){t+=0===n?"⎡ ":1===n?"⎢ ":"⎣ ";for(let o=0;o<3;o++){const i=this.rows[n].at(o).toString();let r="";for(let t=i.length;t<e[o];t++)r+=" ";t+=i+", "+r}t+=0===n?" ⎤":1===n?" ⎥":" ⎦",t+="\n"}return t.trimEnd()}toArray(){return[this.a1,this.a2,this.a3,this.b1,this.b2,this.b3,this.c1,this.c2,this.c3]}mapEntries(t){return new a(t(this.a1,[0,0]),t(this.a2,[0,1]),t(this.a3,[0,2]),t(this.b1,[1,0]),t(this.b2,[1,1]),t(this.b3,[1,2]),t(this.c1,[2,0]),t(this.c2,[2,1]),t(this.c3,[2,2]))}getScaleFactor(){return Math.hypot(this.a1,this.a2)}getColumn(t){return r.default.of(this.rows[0].at(t),this.rows[1].at(t),this.rows[2].at(t))}maximumEntryMagnitude(){let t=Math.abs(this.a1);for(const e of this.toArray())t=Math.max(t,Math.abs(e));return t}static translation(t){return new a(1,0,t.x,0,1,t.y,0,0,1)}static zRotation(t,e=i.Vec2.zero){if(0===t)return a.identity;const n=Math.cos(t),o=Math.sin(t);let r=a.translation(e);return r=r.rightMul(new a(n,-o,0,o,n,0,0,0,1)),r.rightMul(a.translation(e.times(-1)))}static scaling2D(t,e=i.Vec2.zero){let n,o,r=a.translation(e);return"number"==typeof t?(n=t,o=t):(n=t.x,o=t.y),r=r.rightMul(new a(n,0,0,0,o,0,0,0,1)),r.rightMul(a.translation(e.times(-1)))}toCSSMatrix(){return`matrix(${this.a1},${this.b1},${this.a2},${this.b2},${this.a3},${this.b3})`}toSafeCSSTransformList(){const t=i.Vec2.of(this.a3,this.b3),e=(0,s.toRoundedString)(t.x),n=(0,s.toRoundedString)(t.y),o=/[^0-9]+/g,r=e.replace(o,"").length,l=n.replace(o,"").length;if(r<=5&&l<=5)return this.toCSSMatrix();let c=new a(this.a1,this.a2,0,this.b1,this.b2,0,0,0,1);const d=[];let h=null;const u=t=>{if(h){const e=h.scale(t);if(e.maximumEntryMagnitude()<1e7){const n=d.pop();console.assert(n.startsWith("scale"),"Invalid state: Merging scale commands"),t=e}}t.x===t.y?d.push(`scale(${(0,s.toRoundedString)(t.x)})`):d.push(`scale(${(0,s.toRoundedString)(t.x)}, ${(0,s.toRoundedString)(t.y)})`),h=t},p=t=>{const e=(t=>{let e=t.indexOf(".");return-1===e&&(e=t.length),t.substring(0,e).replace(o,"").length})(t),n=(t.match(/[.](\d*)/)??["",""])[1].length-e,i=e+n;return n+(4-Math.max(i,4))},f=(t,e=0)=>{const n=(0,s.toRoundedString)(t.x),o=(0,s.toRoundedString)(t.y),r=p(n),a=p(o),l=i.Vec2.of(Math.pow(10,r),Math.pow(10,a)),c=i.Vec2.of(Math.pow(10,-r),Math.pow(10,-a));u(c);const m=t.scale(l),g=i.Vec2.of(Math.floor(m.x),Math.floor(m.y));return(t=>{h=null,t.eq(i.Vec2.zero)||d.push(`translate(${(0,s.toRoundedString)(t.x)}px, ${(0,s.toRoundedString)(t.y)}px)`)})(g),!g.eq(m)&&e<3&&f(m.minus(g),e+1),u(l),t};return f(t),(()=>{if(h){c.rightMul(a.scaling2D(h)).maximumEntryMagnitude()<1e12&&(d.pop(),c=c.rightMul(a.scaling2D(h)),h=null)}})(),c.eq(a.identity)||d.push(c.toCSSMatrix()),d.join(" ")}static fromCSSMatrix(t){if(""===t||"none"===t)return a.identity;const e=t=>t.split(/[, \t\n]+/g).map((e=>{let n=!1;e.endsWith("%")&&(n=!0,e=e.substring(0,e.length-1)),e=e.replace(/px$/gi,"");if(!/^[-]?\d*(?:\.\d*)?(?:[eE][-+]?\d+)?$/i.exec(e))throw new Error(`All arguments to transform functions must be numeric (state: ${JSON.stringify({currentArgument:e,allArguments:t})})`);let o=parseFloat(e);return n&&(o/=100),o})),n={matrix:t=>{if(6!==t.length)throw new Error(`Invalid matrix argument: ${t}. Must have length 6`);const e=t[0],n=t[1],o=t[2],i=t[3],r=t[4],s=t[5];return new a(e,o,r,n,i,s,0,0,1)},scale:t=>{let e,n;if(1===t.length)e=t[0],n=t[0];else{if(2!==t.length)throw new Error(`The scale() function only supports two arguments. Given: ${t}`);e=t[0],n=t[1]}return a.scaling2D(i.Vec2.of(e,n))},translate:t=>{let e=0,n=0;if(1===t.length)e=t[0];else{if(2!==t.length)throw new Error(`The translate() function requires either 1 or 2 arguments. Given ${t}`);e=t[0],n=t[1]}return a.translation(i.Vec2.of(e,n))}},o=/\s*(\w+)\s*\(([^)]*)\)/gi;let r,s=null;for(;null!==(r=o.exec(t));){const t=r[1].toLowerCase();if(!(t in n))throw new Error(`Unsupported CSS transform action: ${t}`);const o=e(r[2]),i=n[t](o);s=s?s.rightMul(i):i}return s??a.identity}}e.Mat33=a,a.identity=new a(1,0,0,0,1,0,0,0,1),e.default=a},1728:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Vec2=void 0;const i=o(n(3505));var r;!function(t){t.of=(t,e)=>i.default.of(t,e,0),t.ofXY=({x:t,y:e})=>i.default.of(t,e,0),t.unitX=t.of(1,0),t.unitY=t.of(0,1),t.zero=t.of(0,0)}(r||(e.Vec2=r={}))},3505:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Vec3=void 0;class n{constructor(t,e,n){this.x=t,this.y=e,this.z=n}get xy(){return{x:this.x,y:this.y}}static of(t,e,o){return new n(t,e,o)}at(t){if(0===t)return this.x;if(1===t)return this.y;if(2===t)return this.z;throw new Error(`${t} out of bounds!`)}length(){return this.magnitude()}magnitude(){return Math.sqrt(this.dot(this))}magnitudeSquared(){return this.dot(this)}maximumEntryMagnitude(){return Math.max(Math.abs(this.x),Math.max(Math.abs(this.y),Math.abs(this.z)))}angle(){return Math.atan2(this.y,this.x)}normalized(){const t=this.magnitude();return n.of(this.x/t,this.y/t,this.z/t)}normalizedOrZero(){return this.eq(n.zero)?n.zero:this.normalized()}times(t){return n.of(this.x*t,this.y*t,this.z*t)}plus(t){return n.of(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){return n.of(this.x-t.x,this.y-t.y,this.z-t.z)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){return n.of(this.y*t.z-t.y*this.z,t.x*this.z-this.x*t.z,this.x*t.y-t.x*this.y)}scale(t){return"number"==typeof t?this.times(t):n.of(this.x*t.x,this.y*t.y,this.z*t.z)}orthog(){return 0===this.dot(n.unitX)&&0===this.dot(n.unitY)?0===this.dot(n.unitX)?n.unitX:this.cross(n.unitX).normalized():this.cross(n.unitZ.times(-1)).normalized()}extend(t,e){return this.plus(e.normalized().times(t))}lerp(t,e){return this.times(1-e).plus(t.times(e))}zip(t,e){return n.of(e(t.x,this.x),e(t.y,this.y),e(t.z,this.z))}map(t){return n.of(t(this.x,0),t(this.y,1),t(this.z,2))}asArray(){return[this.x,this.y,this.z]}eq(t,e=1e-10){for(let n=0;n<3;n++)if(Math.abs(t.at(n)-this.at(n))>e)return!1;return!0}toString(){return`Vec(${this.x}, ${this.y}, ${this.z})`}}e.Vec3=n,n.unitX=n.of(1,0,0),n.unitY=n.of(0,1,0),n.unitZ=n.of(0,0,1),n.zero=n.of(0,0,0),e.default=n},5097:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toRoundedString=e.Color4=e.Vec3=e.Vec2=e.Mat33=e.QuadraticBezier=e.Rect2=e.PathCommandType=e.Path=e.LineSegment2=void 0;var o=n(4610);Object.defineProperty(e,"LineSegment2",{enumerable:!0,get:function(){return o.LineSegment2}});var i=n(3305);Object.defineProperty(e,"Path",{enumerable:!0,get:function(){return i.Path}}),Object.defineProperty(e,"PathCommandType",{enumerable:!0,get:function(){return i.PathCommandType}});var r=n(4221);Object.defineProperty(e,"Rect2",{enumerable:!0,get:function(){return r.Rect2}});var s=n(1798);Object.defineProperty(e,"QuadraticBezier",{enumerable:!0,get:function(){return s.QuadraticBezier}});var a=n(3380);Object.defineProperty(e,"Mat33",{enumerable:!0,get:function(){return a.Mat33}});var l=n(1728);Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return l.Vec2}});var c=n(3505);Object.defineProperty(e,"Vec3",{enumerable:!0,get:function(){return c.Vec3}});var d=n(8463);Object.defineProperty(e,"Color4",{enumerable:!0,get:function(){return d.Color4}});var h=n(8207);Object.defineProperty(e,"toRoundedString",{enumerable:!0,get:function(){return h.toRoundedString}})},8432:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e,n)=>{if(0===t){let t;return t=0===e?0===n?0:NaN:-n/e,[t,t]}const o=e*e-4*t*n;if(o<0)return[NaN,NaN];const i=Math.sqrt(o),r=(-e+i)/(2*t),s=(-e-i)/(2*t);return r>s?[r,s]:[s,r]}},8207:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toStringOfSamePrecision=e.getLenAfterDecimal=e.toRoundedString=e.cleanUpNumber=void 0;e.cleanUpNumber=t=>{if(t.indexOf("e")>0&&t.match(/[eE][-]\d{2,}$/))return"0";const e=t.charAt(t.length-1);"0"!==e&&"."!==e||(t=(t=(t=t.replace(/([.]\d*[^0]+)0+$/,"$1")).replace(/[.]0+$/,".")).replace(/[.]$/,""));const n=t.charAt(0);return"0"!==n&&"-"!==n||(t=(t=(t=t.replace(/^(0+)[.]/,".")).replace(/^-(0+)[.]/,"-.")).replace(/^(-?)0+$/,"$10")),"-0"===t?"0":t};e.toRoundedString=t=>{let n=t.toString(10);if(-1===n.indexOf("."))return n;const o=/^([-]?)(\d*)\.(\d{3,}9{4,})\d{1,4}$/.exec(n);if(o){const t=o[1],e=o[3],i=parseInt(e.charAt(e.length-1),10),r=parseInt(e,10),s=parseInt(o[2],10),a=o[3];let l=(r+10-i).toString(),c=0;for(l.length>r.toString().length&&(l=l.substring(1),c=1);l.length<a.length;)l=c.toString(10)+l,c=0;n=`${t+(s+c).toString()}.${l}`}return n=n.replace(/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,"$1"),(0,e.cleanUpNumber)(n)};const n=/^([-]?)(\d*)[.](\d+)$/;e.getLenAfterDecimal=t=>{const e=n.exec(t);if(!e)return-1!==t.search(/[eE]/)||/^[a-zA-Z]+$/.exec(t)?-1:0;return e[3].length};e.toStringOfSamePrecision=(t,...o)=>{const i=t.toString(10),r=n.exec(i);if(!r)return i;let s=-1;for(const t of o)s=Math.max((0,e.getLenAfterDecimal)(t),s);if(-1===s)return(0,e.toRoundedString)(t);let a=r[3].substring(0,s),l=r[2];const c=r[3].charAt(s);if(""!==c){if(parseInt(c,10)>=5){if(a.length>0){const t=/^(0+)(\d*)$/.exec(a);let e="",n=a;t&&(e=t[1],n=t[2]),a=(parseInt(a)+1).toString(),a.length>n.length&&e.length>0&&(e=e.substring(1)),a=e+a}(0===a.length||a.length>s)&&(l=(parseInt(l)+1).toString(),a=a.substring(1))}}const d=r[1];return(0,e.cleanUpNumber)(`${d}${l}.${a}`)}},1631:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{distance(t){return Math.abs(this.signedDistance(t))}containsPoint(t,e=n.smallValue){return this.signedDistance(t)<e}getLooseBoundingBox(){return this.getTightBoundingBox()}}n.smallValue=1e-12,e.default=n},4657:function(t,e,n){"use strict";var o,i=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},r=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(4232),l=n(1728),c=s(n(1631)),d=s(n(4221));class h extends c.default{constructor(){super(...arguments),o.set(this,null)}getBezier(){return i(this,o,"f")||r(this,o,new a.Bezier(this.getPoints().map((t=>t.xy))),"f"),i(this,o,"f")}signedDistance(t){return this.getBezier().project(t.xy).d}distance(t){return this.signedDistance(t)}at(t){return l.Vec2.ofXY(this.getBezier().get(t))}derivativeAt(t){return l.Vec2.ofXY(this.getBezier().derivative(t))}normal(t){return l.Vec2.ofXY(this.getBezier().normal(t))}getTightBoundingBox(){const t=this.getBezier().bbox(),e=t.x.max-t.x.min,n=t.y.max-t.y.min;return new d.default(t.x.min,t.y.min,e,n)}intersectsLineSegment(t){const e=this.getBezier();return e.intersects(t).map((n=>{"string"==typeof n&&(n=parseFloat(n));const o=l.Vec2.ofXY(e.get(n));return o.minus(t.p1).magnitude()>t.length||o.minus(t.p2).magnitude()>t.length?null:o})).filter((t=>null!==t))}}o=new WeakMap,e.default=h},9383:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(4657)),r=o(n(4221));class s extends i.default{constructor(t,e,n,o){super(),this.p0=t,this.p1=e,this.p2=n,this.p3=o}getPoints(){return[this.p0,this.p1,this.p2,this.p3]}getLooseBoundingBox(){return r.default.bboxOf([this.p0,this.p1,this.p2,this.p3])}}e.default=s},4610:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.LineSegment2=void 0;const i=o(n(4221)),r=n(1728),s=o(n(1631));class a extends s.default{constructor(t,e){super(),this.point1=t,this.point2=e,this.bbox=i.default.bboxOf([t,e]),this.direction=e.minus(t),this.length=this.direction.magnitude(),this.length>0&&(this.direction=this.direction.times(1/this.length))}get p1(){return this.point1}get p2(){return this.point2}get(t){return this.point1.plus(this.direction.times(t))}at(t){return this.get(t*this.length)}intersection(t){let e,n;if(0===this.direction.x){if(0===t.direction.x||0===this.direction.y)return null;const o=this.point1.x,i=(this.point1.x-t.point1.x)*t.direction.y/t.direction.x+t.point1.y;e=r.Vec2.of(o,i),n=(i-this.point1.y)/this.direction.y}else{const o=(this.point1.y-t.point1.y)*this.direction.x*t.direction.x+this.direction.x*t.direction.y*t.point1.x-this.direction.y*t.direction.x*this.point1.x,i=t.direction.y*this.direction.x-this.direction.y*t.direction.x;if(0===i)return null;const s=o/i,a=(s-this.point1.x)/this.direction.x,l=this.point1.y+this.direction.y*a;e=r.Vec2.of(s,l),n=(s-this.point1.x)/this.direction.x}const o=e.minus(this.point1).magnitude(),i=e.minus(this.point2).magnitude(),s=e.minus(t.point1).magnitude(),a=e.minus(t.point2).magnitude();return o>this.length||i>this.length||s>t.length||a>t.length?null:{point:e,t:n}}intersects(t){return null!==this.intersection(t)}intersectsLineSegment(t){const e=this.intersection(t);return e?[e.point]:[]}closestPointTo(t){const e=t.minus(this.p1).dot(this.direction),n=this.length-e,o=this.p1.plus(this.direction.times(e));return e>0&&e<this.length?o:Math.abs(n)<Math.abs(e)?this.p2:this.p1}signedDistance(t){return this.closestPointTo(t).minus(t).magnitude()}transformedBy(t){return new a(t.transformVec2(this.p1),t.transformVec2(this.p2))}getTightBoundingBox(){return this.bbox}toString(){return`LineSegment(${this.p1.toString()}, ${this.p2.toString()})`}}e.LineSegment2=a,e.default=a},3305:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Path=e.PathCommandType=void 0;const i=n(8207),r=o(n(4610)),s=o(n(4221)),a=n(1728),l=o(n(9383)),c=o(n(1798)),d=o(n(4495));var h;!function(t){t[t.LineTo=0]="LineTo",t[t.MoveTo=1]="MoveTo",t[t.CubicBezierTo=2]="CubicBezierTo",t[t.QuadraticBezierTo=3]="QuadraticBezierTo"}(h||(e.PathCommandType=h={}));class u{constructor(t,e){this.startPoint=t,this.parts=e,this.cachedGeometry=null,this.cachedPolylineApproximation=null,this.cachedStringVersion=null,this.bbox=s.default.bboxOf([t]);for(const n of e)this.bbox=this.bbox.union(u.computeBBoxForSegment(t,n))}getExactBBox(){const t=[];for(const e of this.geometry)t.push(e.getTightBoundingBox());return s.default.union(...t)}get geometry(){if(this.cachedGeometry)return this.cachedGeometry;let t=this.startPoint;const e=[];for(const n of this.parts){let o;switch(n.kind){case h.CubicBezierTo:e.push(new l.default(t,n.controlPoint1,n.controlPoint2,n.endPoint)),t=n.endPoint;break;case h.QuadraticBezierTo:e.push(new c.default(t,n.controlPoint,n.endPoint)),t=n.endPoint;break;case h.LineTo:e.push(new r.default(t,n.point)),t=n.point;break;case h.MoveTo:e.push(new d.default(n.point)),t=n.point;break;default:return o=n,o}}return this.cachedGeometry=e,this.cachedGeometry}*startEndPoints(){yield this.startPoint;for(const t of this.parts){let e;switch(t.kind){case h.CubicBezierTo:case h.QuadraticBezierTo:yield t.endPoint;break;case h.LineTo:case h.MoveTo:yield t.point;break;default:return e=t,e}}}polylineApproximation(){if(this.cachedPolylineApproximation)return this.cachedPolylineApproximation;const t=[];for(const e of this.parts)switch(e.kind){case h.CubicBezierTo:t.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:t.push(e.controlPoint,e.endPoint);break;case h.MoveTo:case h.LineTo:t.push(e.point)}const e=[];let n=this.startPoint;for(const o of t)e.push(new r.default(n,o)),n=o;return e}static computeBBoxForSegment(t,e){const n=[t];let o;switch(e.kind){case h.MoveTo:case h.LineTo:n.push(e.point);break;case h.CubicBezierTo:n.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:n.push(e.controlPoint,e.endPoint);break;default:return o=e,o}return s.default.bboxOf(n)}raymarchIntersectionWith(t,e,n=[]){if(!t.bbox.intersects(this.bbox.grownBy(e)))return[];const o=t.length,i=[];for(const n of this.geometry){const r=n.getTightBoundingBox().grownBy(e);if(!r.intersects(t.bbox))continue;const s=t=>n.signedDistance(t),a=t=>s(t)-e;a(t.p1)>o&&a(t.p2)>o||i.push({part:n,distFn:s,bbox:r})}if(0===i.length)return[];const r=t=>{let n=1/0,o=null;const r=[];for(const e of i){const{part:i,distFn:s,bbox:a}=e;if(!a.containsPoint(t)){r.push(e);continue}const l=s(t);l<=n&&(n=l,o=i)}for(const{part:e,distFn:i,bbox:s}of r){if(!s.grownBy(n).containsPoint(t))continue;const r=i(t);r<=n&&(n=r,o=e)}return[o,n-e]},s=[t.p1,...n,t.p2],a=e=>e.minus(t.p1).dot(t.direction);s.sort(((t,e)=>a(t)-a(e)));const l=[],c=e/1e3,d=(e,n,i)=>{let s=e,[d,h]=r(s),u=a(s);if(h>o)return u;const p=t.direction.times(n);for(let t=0;t<7;t++){const t=h;if(s=s.plus(p.times(t)),u=a(s),u<=i)return u;const[e,n]=r(s);if(Math.abs(n)>Math.abs(h))return null;if(h=n,d=e,Math.abs(h)<c)break}return d&&(u>=0&&u<=o)&&Math.abs(h)<c&&l.push({point:s,parameterValue:NaN,curve:d}),u};let h=0;for(let t=0;t<s.length;t++){const e=s[t];h=Math.max(h,d(e,1,h)??h),h=Math.max(h,d(e,-1,h)??h)}return l}intersection(t,e){let n=[];if(!t.bbox.intersects(this.bbox.grownBy(e??0)))return[];for(const e of this.geometry){const o=e.intersectsLineSegment(t);o.length>0&&n.push({curve:e,point:o[0]})}if(e&&e>1e-8){const o=n.map((t=>t.point));n=this.raymarchIntersectionWith(t,e,o)}return n}static mapPathCommand(t,e){switch(t.kind){case h.MoveTo:case h.LineTo:return{kind:t.kind,point:e(t.point)};case h.CubicBezierTo:return{kind:t.kind,controlPoint1:e(t.controlPoint1),controlPoint2:e(t.controlPoint2),endPoint:e(t.endPoint)};case h.QuadraticBezierTo:return{kind:t.kind,controlPoint:e(t.controlPoint),endPoint:e(t.endPoint)}}return t}mapPoints(t){const e=t(this.startPoint),n=[];for(const e of this.parts)n.push(u.mapPathCommand(e,t));return new u(e,n)}transformedBy(t){return t.isIdentity()?this:this.mapPoints((e=>t.transformVec2(e)))}union(t){return t?new u(this.startPoint,[...this.parts,{kind:h.MoveTo,point:t.startPoint},...t.parts]):this}getEndPoint(){if(0===this.parts.length)return this.startPoint;const t=this.parts[this.parts.length-1];return t.kind===h.QuadraticBezierTo||t.kind===h.CubicBezierTo?t.endPoint:t.point}roughlyIntersects(t,e=0){if(0===this.parts.length)return t.containsPoint(this.startPoint);if(this.startPoint.eq(this.getEndPoint())&&0===e)return this.closedRoughlyIntersects(t);if(t.containsRect(this.bbox))return!0;let n=this.startPoint;for(const o of this.parts){const i=u.computeBBoxForSegment(n,o).grownBy(e);if(n=o.kind===h.LineTo||o.kind===h.MoveTo?o.point:o.endPoint,t.intersects(i))return!0}return!1}closedRoughlyIntersects(t){if(t.containsRect(this.bbox))return!0;const e=this.bbox.topLeft.minus(a.Vec2.of(1,1)),n=t.corners,o=this.polylineApproximation();for(const t of n){const n=new r.default(t,e);let i=0;for(const t of o)t.intersects(n)&&i++;if(i%2==1)return!0}const i=t.grownBy(Math.min(t.size.x,t.size.y)),s=[];for(const t of i.divideIntoGrid(4,4))s.push(...t.getEdges());for(const t of s)for(const e of o)if(t.intersects(e))return!0;return!1}static fromRect(t,e=null){const n=[];let o,i;if(null!==e){const n=a.Vec2.of(e,e).times(.5),r=s.default.fromCorners(t.topLeft.plus(n),t.bottomRight.minus(n)),l=s.default.fromCorners(t.topLeft.minus(n),t.bottomRight.plus(n));o=[r.corners[3],...r.corners,...l.corners.reverse()],i=l.corners[3]}else o=t.corners.slice(1),i=t.corners[0];for(const t of o)n.push({kind:h.LineTo,point:t});return n.push({kind:h.LineTo,point:i}),new u(i,n)}toString(t){if(this.cachedStringVersion)return this.cachedStringVersion;void 0===t&&(t=Math.abs(this.bbox.topLeft.x)>10&&Math.abs(this.bbox.topLeft.y)>10);const e=u.toString(this.startPoint,this.parts,!t);return this.cachedStringVersion=e,e}serialize(){return this.toString()}static toString(t,e,n){const o=[];let r;const s=(t,...e)=>{const s=[],a=[],l=!r||n,c=r?(0,i.toRoundedString)(r.x):"",d=r?(0,i.toRoundedString)(r.y):"";for(const t of e){const e=(0,i.toRoundedString)(t.x),n=(0,i.toRoundedString)(t.y);if(l)s.push(`${e},${n}`);else{const o=(0,i.toStringOfSamePrecision)(t.x-r.x,e,c,d),s=(0,i.toStringOfSamePrecision)(t.y-r.y,n,c,d);"-"===s.charAt(0)?a.push(`${o}${s}`):a.push(`${o},${s}`)}}let h;h=l?`${t}${s.join(" ")}`:`${t.toLowerCase()}${a.join(" ")}`,"l0,0"!==h&&"m0,0"!==h&&(o.push(h),e.length>0&&(r=e[e.length-1]))};let a;e[0]?.kind!==h.MoveTo&&s("M",t);for(let t=0;t<e.length;t++){const n=e[t];switch(n.kind){case h.MoveTo:s("M",n.point);break;case h.LineTo:s("L",n.point);break;case h.CubicBezierTo:s("C",n.controlPoint1,n.controlPoint2,n.endPoint);break;case h.QuadraticBezierTo:s("Q",n.controlPoint,n.endPoint);break;default:return a=n,a}}return o.join("")}static fromString(t){t=t.split("\n").join(" ");let e=a.Vec2.zero,n=null,o=null,i=!0;const r=[],s=t=>{i?i=!1:r.push({kind:h.LineTo,point:t})},l={m:1,l:1,c:3,q:2,z:0,h:1,v:1},c=/([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/gi;let d;for(;null!==(d=c.exec(t));){const t=d[2].trim().split(/[^0-9Ee.-]/).filter((t=>t.length>0)).reduce(((t,e)=>{const n=(e=e.replace(/([^eE])[-]/g,"$1 -")).split(" -");return""!==n[0]&&t.push(n[0]),t.push(...n.slice(1).map((t=>`-${t}`))),t}),[]);let c=t.map((t=>parseFloat(t))),u=d[1].toLowerCase(),v=d[1]!==u;if("v"===u||"h"===u)c=c.reduce(((t,n)=>"v"===u?t.concat(v?e.x:0,n):t.concat(n,v?e.y:0)),[]),u="l";else if("z"===u){if(!n)continue;c=[n.x,n.y],n=e,v=!0,u="l"}const w=l[u]??0,x=c.reduce(((t,e,n,o)=>{if(n%2!=0){const i=e,r=o[n-1];return t.concat(a.Vec2.of(r,i))}return t}),[]).map(((t,n)=>{let o;return o=v?t:e.plus(t),(n+1)%w==0&&(e=o),o}));if(x.length%w!=0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(x)} with a length of ${x.length} ≠ ${w}k, k ∈ ℤ.`,`The number of arguments to ${u} must be a multiple of ${w}!`,`Command: ${d[0]}`].join("\n"));for(let t=0;t<x.length;t+=w){const e=x.slice(t,t+w);switch(u.toLowerCase()){case"m":0===t?(y=e[0],i?i=!1:r.push({kind:h.MoveTo,point:y})):s(e[0]);break;case"l":s(e[0]);break;case"c":m=e[0],g=e[1],b=e[2],r.push({kind:h.CubicBezierTo,controlPoint1:m,controlPoint2:g,endPoint:b});break;case"q":p=e[0],f=e[1],r.push({kind:h.QuadraticBezierTo,controlPoint:p,endPoint:f});break;default:throw new Error(`Unknown path command ${u}`)}i=!1}x.length>0&&(n??=x[0],o??=n,e=x[x.length-1])}var p,f,m,g,b,y;const v=new u(o??a.Vec2.zero,r);return v.cachedStringVersion=t,v}}e.Path=u,u.empty=new u(a.Vec2.zero,[]),e.default=u},4495:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(1631)),r=o(n(4221));class s extends i.default{constructor(t){super(),this.p=t}signedDistance(t){return this.p.minus(t).magnitude()}intersectsLineSegment(t,e){return t.containsPoint(this.p,e)?[this.p]:[]}getTightBoundingBox(){return new r.default(this.p.x,this.p.y,0,0)}}e.default=s},1798:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.QuadraticBezier=void 0;const i=n(1728),r=o(n(8432)),s=o(n(4657)),a=o(n(4221));class l extends s.default{constructor(t,e,n){super(),this.p0=t,this.p1=e,this.p2=n}static componentAt(t,e,n,o){return e+t*(-2*e+2*n)+t*t*(e-2*n+o)}static derivativeComponentAt(t,e,n,o){return-2*e+2*n+2*t*(e-2*n+o)}at(t){const e=this.p0,n=this.p1,o=this.p2;return i.Vec2.of(l.componentAt(t,e.x,n.x,o.x),l.componentAt(t,e.y,n.y,o.y))}derivativeAt(t){const e=this.p0,n=this.p1,o=this.p2;return i.Vec2.of(l.derivativeComponentAt(t,e.x,n.x,o.x),l.derivativeComponentAt(t,e.y,n.y,o.y))}normal(t){return this.derivativeAt(t).orthog().normalized()}getLooseBoundingBox(){return a.default.bboxOf([this.p0,this.p1,this.p2])}approximateDistance(t){const e=this.p0.x-t.x,n=-2*this.p0.x+2*this.p1.x,o=this.p0.x-2*this.p1.x+this.p2.x,i=this.p0.y-t.y,s=-2*this.p0.y+2*this.p1.y,a=this.p0.y-2*this.p1.y+this.p2.y,l=2*e*n+2*i*s-t.x*n-t.y*s,c=2*n*n+2*s*s+2*o*e+2*a*i-t.x*o-t.y*a,d=2*(2*s*a+2*n*o+2*o*n+2*a*s);let[h,u]=(0,r.default)(d/2,c,l);isNaN(h)&&(h=.25),isNaN(u)&&(u=.75);const p=this.at(h),f=this.at(u),m=p.minus(t).magnitudeSquared(),g=f.minus(t).magnitudeSquared(),b=this.at(0).minus(t).magnitudeSquared(),y=this.at(1).minus(t).magnitudeSquared();return Math.sqrt(Math.min(m,g,b,y))}getPoints(){return[this.p0,this.p1,this.p2]}}e.QuadraticBezier=l,e.default=l},4221:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Rect2=void 0;const i=o(n(4610)),r=n(1728),s=o(n(1631));class a extends s.default{constructor(t,e,n,o){super(),this.x=t,this.y=e,this.w=n,this.h=o,n<0&&(this.x+=n,this.w=Math.abs(n)),o<0&&(this.y+=o,this.h=Math.abs(o)),this.topLeft=r.Vec2.of(this.x,this.y),this.size=r.Vec2.of(this.w,this.h),this.area=this.w*this.h}translatedBy(t){return new a(t.x+this.x,t.y+this.y,this.w,this.h)}resizedTo(t){return new a(this.x,this.y,t.x,t.y)}containsPoint(t){return this.x<=t.x&&this.y<=t.y&&this.x+this.w>=t.x&&this.y+this.h>=t.y}containsRect(t){return this.x<=t.x&&this.y<=t.y&&this.x+this.w>=t.x+t.w&&this.y+this.h>=t.y+t.h}intersects(t){const e=this.x,n=e+this.w,o=t.x,i=t.x+t.w;if(n<o||e>i)return!1;const r=this.y,s=r+this.h,a=t.y,l=t.y+t.h;return!(s<a||r>l)}intersection(t){if(!this.intersects(t))return null;const e=this.topLeft.zip(t.topLeft,Math.max),n=this.bottomRight.zip(t.bottomRight,Math.min);return a.fromCorners(e,n)}union(t){return a.union(this,t)}divideIntoGrid(t,e){const n=[];if(t<=0||e<=0)return n;const o=this.w/t,i=this.h/e;0===o&&(t=1),0===i&&(e=1);for(let r=0;r<e;r++)for(let e=0;e<t;e++){const t=o*e+this.x,s=i*r+this.y;n.push(new a(t,s,o,i))}return n}grownToPoint(t,e=0){const n=new a(t.x-e,t.y-e,2*e,2*e);return this.union(n)}grownBy(t){if(0===t)return this;if(t<0){const e=-Math.min(-t,this.w/2),n=-Math.min(-t,this.h/2);return new a(this.x-e,this.y-n,this.w+2*e,this.h+2*n)}return new a(this.x-t,this.y-t,this.w+2*t,this.h+2*t)}getClosestPointOnBoundaryTo(t){const e=this.getEdges().map((e=>e.closestPointTo(t)));let n=null,o=null;for(const i of e){const e=i.minus(t).length();(null===o||e<o)&&(n=i,o=e)}return n}get corners(){return[this.bottomRight,this.topRight,this.topLeft,this.bottomLeft]}get maxDimension(){return Math.max(this.w,this.h)}get bottomRight(){return this.topLeft.plus(this.size)}get topRight(){return this.bottomRight.plus(r.Vec2.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(r.Vec2.of(0,this.h))}get width(){return this.w}get height(){return this.h}get center(){return this.topLeft.plus(this.size.times(.5))}getEdges(){const t=this.corners;return[new i.default(t[0],t[1]),new i.default(t[1],t[2]),new i.default(t[2],t[3]),new i.default(t[3],t[0])]}intersectsLineSegment(t){const e=[];for(const n of this.getEdges()){n.intersectsLineSegment(t).forEach((t=>e.push(t)))}return e}signedDistance(t){const e=this.getClosestPointOnBoundaryTo(t),n=t.minus(e).magnitude();return this.containsPoint(t)?-n:n}getTightBoundingBox(){return this}transformedBoundingBox(t){return a.bboxOf(this.corners.map((e=>t.transformVec2(e))))}eq(t,e=0){return this.topLeft.eq(t.topLeft,e)&&this.size.eq(t.size,e)}toString(){return`Rect(point(${this.x}, ${this.y}), size(${this.w}, ${this.h}))`}static fromCorners(t,e){return new a(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.abs(t.x-e.x),Math.abs(t.y-e.y))}static bboxOf(t,e=0){let n=0,o=0,i=0,s=0,l=!0;for(const e of t)l&&(n=e.x,o=e.y,i=e.x,s=e.y,l=!1),n=Math.min(n,e.x),o=Math.min(o,e.y),i=Math.max(i,e.x),s=Math.max(s,e.y);return a.fromCorners(r.Vec2.of(n-e,o-e),r.Vec2.of(i+e,s+e))}static union(...t){if(0===t.length)return a.empty;const e=t[0];let n=e.x,o=e.y,i=e.x+e.w,r=e.y+e.h;for(let e=1;e<t.length;e++){const s=t[e];n=Math.min(n,s.x),o=Math.min(o,s.y),i=Math.max(i,s.x+s.w),r=Math.max(r,s.y+s.h)}return new a(n,o,i-n,r-o)}static of(t){const e=t.width??t.w??0,n=t.height??t.h??0;return new a(t.x,t.y,e,n)}}e.Rect2=a,a.empty=new a(0,0,0,0),a.unitSquare=new a(0,0,1,1),e.default=a},5381:(t,e)=>{var n,o,i;"undefined"!=typeof self&&self,o=[],void 0===(i="function"==typeof(n=function(){
|
1
|
+
(()=>{var e={489:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var o=n(9601),i=n.n(o),r=n(2609),s=n.n(r)()(i());s.push([t.id,'.clr-picker {\n display: none;\n flex-wrap: wrap;\n position: absolute;\n width: 200px;\n z-index: 1000;\n border-radius: 10px;\n background-color: #fff;\n justify-content: flex-end;\n direction: ltr;\n box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1);\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.clr-picker.clr-open,\n.clr-picker[data-inline="true"] {\n display: flex;\n}\n\n.clr-picker[data-inline="true"] {\n position: relative;\n}\n\n.clr-gradient {\n position: relative;\n width: 100%;\n height: 100px;\n margin-bottom: 15px;\n border-radius: 3px 3px 0 0;\n background-image: linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor);\n cursor: pointer;\n}\n\n.clr-marker {\n position: absolute;\n width: 12px;\n height: 12px;\n margin: -6px 0 0 -6px;\n border: 1px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n cursor: pointer;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-runnable-track {\n width: 100%;\n height: 16px;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-thumb {\n width: 16px;\n height: 16px;\n -webkit-appearance: none;\n}\n\n.clr-picker input[type="range"]::-moz-range-track {\n width: 100%;\n height: 16px;\n border: 0;\n}\n\n.clr-picker input[type="range"]::-moz-range-thumb {\n width: 16px;\n height: 16px;\n border: 0;\n}\n\n.clr-hue {\n background-image: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);\n}\n\n.clr-hue,\n.clr-alpha {\n position: relative;\n width: calc(100% - 40px);\n height: 8px;\n margin: 5px 20px;\n border-radius: 4px;\n}\n\n.clr-alpha span {\n display: block;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n background-image: linear-gradient(90deg, rgba(0,0,0,0), currentColor);\n}\n\n.clr-hue input,\n.clr-alpha input {\n position: absolute;\n width: calc(100% + 32px);\n height: 16px;\n left: -16px;\n top: -4px;\n margin: 0;\n background-color: transparent;\n opacity: 0;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n\n.clr-hue div,\n.clr-alpha div {\n position: absolute;\n width: 16px;\n height: 16px;\n left: 0;\n top: 50%;\n margin-left: -8px;\n transform: translateY(-50%);\n border: 2px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n box-shadow: 0 0 1px #888;\n pointer-events: none;\n}\n\n.clr-alpha div:before {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border-radius: 50%;\n background-color: currentColor;\n}\n\n.clr-format {\n display: none;\n order: 1;\n width: calc(100% - 40px);\n margin: 0 20px 20px;\n}\n\n.clr-segmented {\n display: flex;\n position: relative;\n width: 100%;\n margin: 0;\n padding: 0;\n border: 1px solid #ddd;\n border-radius: 15px;\n box-sizing: border-box;\n color: #999;\n font-size: 12px;\n}\n\n.clr-segmented input,\n.clr-segmented legend {\n position: absolute;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n left: 0;\n top: 0;\n opacity: 0;\n pointer-events: none;\n}\n\n.clr-segmented label {\n flex-grow: 1;\n margin: 0;\n padding: 4px 0;\n font-size: inherit;\n font-weight: normal;\n line-height: initial;\n text-align: center;\n cursor: pointer;\n}\n\n.clr-segmented label:first-of-type {\n border-radius: 10px 0 0 10px;\n}\n\n.clr-segmented label:last-of-type {\n border-radius: 0 10px 10px 0;\n}\n\n.clr-segmented input:checked + label {\n color: #fff;\n background-color: #666;\n}\n\n.clr-swatches {\n order: 2;\n width: calc(100% - 32px);\n margin: 0 16px;\n}\n\n.clr-swatches div {\n display: flex;\n flex-wrap: wrap;\n padding-bottom: 12px;\n justify-content: center;\n}\n\n.clr-swatches button {\n position: relative;\n width: 20px;\n height: 20px;\n margin: 0 4px 6px 4px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n cursor: pointer;\n}\n\n.clr-swatches button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\ninput.clr-color {\n order: 1;\n width: calc(100% - 80px);\n height: 32px;\n margin: 15px 20px 20px auto;\n padding: 0 10px;\n border: 1px solid #ddd;\n border-radius: 16px;\n color: #444;\n background-color: #fff;\n font-family: sans-serif;\n font-size: 14px;\n text-align: center;\n box-shadow: none;\n}\n\ninput.clr-color:focus {\n outline: none;\n border: 1px solid #1e90ff;\n}\n\n.clr-close,\n.clr-clear {\n display: none;\n order: 2;\n height: 24px;\n margin: 0 20px 20px;\n padding: 0 20px;\n border: 0;\n border-radius: 12px;\n color: #fff;\n background-color: #666;\n font-family: inherit;\n font-size: 12px;\n font-weight: 400;\n cursor: pointer;\n}\n\n.clr-close {\n display: block;\n margin: 0 20px 20px auto;\n}\n\n.clr-preview {\n position: relative;\n width: 32px;\n height: 32px;\n margin: 15px 0 20px 20px;\n border-radius: 50%;\n overflow: hidden;\n}\n\n.clr-preview:before,\n.clr-preview:after {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border: 1px solid #fff;\n border-radius: 50%;\n}\n\n.clr-preview:after {\n border: 0;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\n.clr-preview button {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 1;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 50%;\n outline-offset: -2px;\n background-color: transparent;\n text-indent: -9999px;\n cursor: pointer;\n overflow: hidden;\n}\n\n.clr-marker,\n.clr-hue div,\n.clr-alpha div,\n.clr-color {\n box-sizing: border-box;\n}\n\n.clr-field {\n display: inline-block;\n position: relative;\n color: transparent;\n}\n\n.clr-field input {\n margin: 0;\n direction: ltr;\n}\n\n.clr-field.clr-rtl input {\n text-align: right;\n}\n\n.clr-field button {\n position: absolute;\n width: 30px;\n height: 100%;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n margin: 0;\n padding: 0;\n border: 0;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n pointer-events: none;\n}\n\n.clr-field.clr-rtl button {\n right: auto;\n left: 0;\n}\n\n.clr-field button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 1px rgba(0,0,0,.5);\n}\n\n.clr-alpha,\n.clr-alpha div,\n.clr-swatches button,\n.clr-preview:before,\n.clr-field button {\n background-image: repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa), repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position: 0 0, 4px 4px;\n background-size: 8px 8px;\n}\n\n.clr-marker:focus {\n outline: none;\n}\n\n.clr-keyboard-nav .clr-marker:focus,\n.clr-keyboard-nav .clr-hue input:focus + div,\n.clr-keyboard-nav .clr-alpha input:focus + div,\n.clr-keyboard-nav .clr-segmented input:focus + label {\n outline: none;\n box-shadow: 0 0 0 2px #1e90ff, 0 0 2px 2px #fff;\n}\n\n.clr-picker[data-alpha="false"] .clr-alpha {\n display: none;\n}\n\n.clr-picker[data-minimal="true"] {\n padding-top: 16px;\n}\n\n.clr-picker[data-minimal="true"] .clr-gradient,\n.clr-picker[data-minimal="true"] .clr-hue,\n.clr-picker[data-minimal="true"] .clr-alpha,\n.clr-picker[data-minimal="true"] .clr-color,\n.clr-picker[data-minimal="true"] .clr-preview {\n display: none;\n}\n\n/** Dark theme **/\n\n.clr-dark {\n background-color: #444;\n}\n\n.clr-dark .clr-segmented {\n border-color: #777;\n}\n\n.clr-dark .clr-swatches button:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);\n}\n\n.clr-dark input.clr-color {\n color: #fff;\n border-color: #777;\n background-color: #555;\n}\n\n.clr-dark input.clr-color:focus {\n border-color: #1e90ff;\n}\n\n.clr-dark .clr-preview:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);\n}\n\n.clr-dark .clr-alpha,\n.clr-dark .clr-alpha div,\n.clr-dark .clr-swatches button,\n.clr-dark .clr-preview:before {\n background-image: repeating-linear-gradient(45deg, #666 25%, transparent 25%, transparent 75%, #888 75%, #888), repeating-linear-gradient(45deg, #888 25%, #444 25%, #444 75%, #888 75%, #888);\n}\n\n/** Polaroid theme **/\n\n.clr-picker.clr-polaroid {\n border-radius: 6px;\n box-shadow: 0 0 5px rgba(0,0,0,.1), 0 5px 30px rgba(0,0,0,.2);\n}\n\n.clr-picker.clr-polaroid:before {\n content: \'\';\n display: block;\n position: absolute;\n width: 16px;\n height: 10px;\n left: 20px;\n top: -10px;\n border: solid transparent;\n border-width: 0 8px 10px 8px;\n border-bottom-color: currentColor;\n box-sizing: border-box;\n color: #fff;\n filter: drop-shadow(0 -4px 3px rgba(0,0,0,.1));\n pointer-events: none;\n}\n\n.clr-picker.clr-polaroid.clr-dark:before {\n color: #444;\n}\n\n.clr-picker.clr-polaroid.clr-left:before {\n left: auto;\n right: 20px;\n}\n\n.clr-picker.clr-polaroid.clr-top:before {\n top: auto;\n bottom: -10px;\n transform: rotateZ(180deg);\n}\n\n.clr-polaroid .clr-gradient {\n width: calc(100% - 20px);\n height: 120px;\n margin: 10px;\n border-radius: 3px;\n}\n\n.clr-polaroid .clr-hue,\n.clr-polaroid .clr-alpha {\n width: calc(100% - 30px);\n height: 10px;\n margin: 6px 15px;\n border-radius: 5px;\n}\n\n.clr-polaroid .clr-hue div,\n.clr-polaroid .clr-alpha div {\n box-shadow: 0 0 5px rgba(0,0,0,.2);\n}\n\n.clr-polaroid .clr-format {\n width: calc(100% - 20px);\n margin: 0 10px 15px;\n}\n\n.clr-polaroid .clr-swatches {\n width: calc(100% - 12px);\n margin: 0 6px;\n}\n.clr-polaroid .clr-swatches div {\n padding-bottom: 10px;\n}\n\n.clr-polaroid .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n.clr-polaroid input.clr-color {\n width: calc(100% - 60px);\n margin: 10px 10px 15px auto;\n}\n\n.clr-polaroid .clr-clear {\n margin: 0 10px 15px 10px;\n}\n\n.clr-polaroid .clr-close {\n margin: 0 10px 15px auto;\n}\n\n.clr-polaroid .clr-preview {\n margin: 10px 0 15px 10px;\n}\n\n/** Large theme **/\n\n.clr-picker.clr-large {\n width: 275px;\n}\n\n.clr-large .clr-gradient {\n height: 150px;\n}\n\n.clr-large .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n/** Pill (horizontal) theme **/\n\n.clr-picker.clr-pill {\n width: 380px;\n padding-left: 180px;\n box-sizing: border-box;\n}\n\n.clr-pill .clr-gradient {\n position: absolute;\n width: 180px;\n height: 100%;\n left: 0;\n top: 0;\n margin-bottom: 0;\n border-radius: 3px 0 0 3px;\n}\n\n.clr-pill .clr-hue {\n margin-top: 20px;\n}',""]);const a=s},4245:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var o=n(9601),i=n.n(o),r=n(2609),s=n.n(r)()(i());s.push([t.id,':root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content>div>div{padding:5px}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content>div{min-height:0}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content img{max-width:min(50vw,75%);max-height:50vh;display:block;margin-left:auto;margin-right:auto}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content .action-button-row{margin-top:4px;display:flex;flex-direction:row;justify-content:flex-end;padding-bottom:0;margin-bottom:0}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content .action-button-row>button{flex-grow:1;text-align:end;max-width:50%;min-width:min(100%,40px)}.toolbar-overflow-widget-overflow-list{display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center}.toolbar-overflow-widget-overflow-list>.toolbar-toolContainer>.toolbar-button{height:var(--toolbar-button-height)}.toolbar-overflow-widget.horizontal .toolbar-overflow-widget-overflow-list{flex-direction:row}.toolbar-overflow-widget.horizontal>.toolbar-dropdown{max-width:100%;left:15px;right:15px;margin-left:0 !important;translate:none !important;padding:4px}.toolbar-zoomLevelEditor{display:flex;flex-direction:row;align-items:center}.toolbar-zoomLevelEditor .zoomDisplay{flex-grow:1}.toolbar-zoomLevelEditor button{min-width:48px}.selection-format-menu.disabled{opacity:.5}.toolbar-document-properties-widget button.about-button{width:100%;text-align:end}.toolbar-document-properties-widget>*{--align-items-to-x: 120px}.toolbar-document-properties-widget .js-draw-size-input-row.js-draw-size-input-row{display:flex}.toolbar-document-properties-widget .js-draw-size-input-row.js-draw-size-input-row.size-input-row--automatic-size{display:none}.toolbar-thicknessSliderContainer{display:flex;flex-direction:row}.toolbar-thicknessSliderContainer input{flex-grow:1}.toolbar-element .clr-field *{cursor:pointer}.toolbar-element .clr-field button{width:1.2em;height:1.2em;top:50%;left:0;border-radius:50%;margin-left:0;margin-right:0}.toolbar-element .clr-field input{opacity:0}.color-input-container{display:inline-flex;flex-direction:row}.color-input-container.picker-open .clr-field{pointer-events:none}:root .color-input-container>button.pipetteButton{width:30px;height:30px;padding:0;display:inline-flex}.color-input-container .pipetteButton>svg{width:100%}.color-input-container .pipetteButton .pickColorInstructions{display:none;font-size:1em;position:absolute;margin-left:30px;background-color:var(--background-color-1);border-radius:30px;padding:4px;opacity:0;transition:.2s ease opacity}@media(prefers-reduced-motion: reduce){.color-input-container .pipetteButton .pickColorInstructions{transition:none}}.color-input-container .pipetteButton.active{background-color:var(--selection-background-color);--icon-color: var(--selection-foreground-color)}.color-input-container .pipetteButton.active .pickColorInstructions{display:block;opacity:.8}.tool-dropdown-separator{--border-color: rgba(100, 100, 100, 0.2);--border-color: color-mix(in srgb, var(--foreground-color-1), rgba(0, 0, 0, 0) 80%);border-top:1px solid var(--border-color);padding-left:2px;margin-top:10px;margin-bottom:10px}.toolbar-element .toolbar--file-input-container{display:flex}.toolbar-element .toolbar--file-input-container>input[type=file]{opacity:0;width:0;min-width:0 !important;max-width:0;height:0}.toolbar-element .toolbar--file-input-container>label{display:block;flex-grow:1;padding:0 !important;padding-bottom:5px;--active-border-color: rgba(100, 100, 100, 0.5);--active-border-color: color-mix( in srgb, var(--foreground-color-1), transparent )}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description{background-color:var(--background-color-3);color:var(--foreground-color-3);border:1px dashed var(--active-border-color);padding:10px;margin-top:10px;display:flex;flex-direction:column;align-items:center;text-align:center;--action-color: var(--primary-action-foreground-color);--icon-color: var(--action-color)}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description>span{white-space:pre-wrap}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description>span>b{color:var(--action-color);cursor:pointer}.toolbar-element .toolbar--file-input-container>label>.toolbar--file-input-description>.icon{width:min(50vw,42px);height:min(50vw,42px);margin-bottom:8px;display:block}.toolbar-element .toolbar--file-input-container>label:active,.toolbar-element .toolbar--file-input-container>label:hover,.toolbar-element .toolbar--file-input-container>label.drag-target{--active-border-color: var(--foreground-color-1)}.toolbar-element .toolbar--file-input-container>label.drag-target>.toolbar--file-input-description{border-width:2px}.toolbar-grid-selector{position:relative}.toolbar-grid-selector>div{display:flex;flex-direction:row;max-width:350px;flex-wrap:wrap;--button-size: 48px}.toolbar-grid-selector .choice-button{display:flex;flex-direction:column-reverse;box-sizing:border-box;flex-shrink:1;margin:2px}.toolbar-grid-selector .choice-button.focus-visible{outline:2px solid var(--foreground-color-1)}.toolbar-grid-selector .choice-button input{opacity:0;height:0}.toolbar-grid-selector .choice-button label{display:flex;flex-direction:column;box-sizing:border-box;width:var(--button-size);height:var(--button-size);font-size:.7rem;align-items:center;justify-content:center;padding:4px;user-select:none;-webkit-user-select:none}.toolbar-grid-selector .choice-button .icon{flex-grow:1;flex-shrink:1;width:100%}.toolbar-grid-selector .choice-button.checked{background-color:var(--selection-background-color);color:var(--selection-foreground-color);--icon-color: var(--selection-foreground-color)}.toolbar-root{background-color:var(--background-color-1);--icon-color: var(--foreground-color-1);--toolbar-button-height: min(20vh, 60px);flex-wrap:wrap;box-sizing:border-box;width:100%;display:flex;flex-direction:row;justify-content:center}.toolbar-element{z-index:1;font-family:system-ui,-apple-system,sans-serif}.toolbar-element details>summary{cursor:pointer}.toolbar-element>.toolbar-toolContainer>.toolbar-button,.toolbar-element>.toolbar-toolContainer>*>button,.toolbar-element>.toolbar-buttonGroup>button,.toolbar-element>.toolbar-button{white-space:pre;height:var(--toolbar-button-height)}.toolbar-dropdown .toolbar-button>.toolbar-icon{max-width:50px;width:100%}.toolbar-button.disabled{filter:opacity(0.5) sepia(0.2);cursor:unset}.toolbar-button,.toolbar-element button{cursor:pointer;text-align:center;border-radius:6px;border:none;box-shadow:0px 0px 2px var(--shadow-color);user-select:none;-webkit-user-select:none;transition:background-color .15s ease,box-shadow .25s ease,opacity .2s ease}.toolbar-button,.toolbar-buttonGroup>button,.toolbar-toolContainer>*>button,.toolbar-root>button{display:flex;flex-direction:column;align-items:center;justify-content:center;padding-left:3px;padding-right:3px;min-width:40px;max-width:105px;width:min-content;font-size:1em}.toolbar-button>label{cursor:inherit;user-select:none;-webkit-user-select:none}.toolbar-root>.toolbar-toolContainer>.toolbar-button>label.long-label{font-size:.75em}.toolbar-dropdown>.toolbar-toolContainer>button,.toolbar-dropdown>.toolbar-toolContainer>.toolbar-button{width:6em}.toolbar-button:not(.disabled):hover,.toolbar-root button:not(:disabled):hover{box-shadow:0px 2px 4px var(--shadow-color)}.toolbar-root button:disabled{cursor:inherit;filter:opacity(0.5)}.toolbar-root .toolbar-icon{flex-shrink:1;user-select:none;width:100%;min-width:20px;min-height:20px}.toolbar-toolContainer.selected>.toolbar-button{background-color:var(--selection-background-color);color:var(--selection-foreground-color);--icon-color: var(--selection-foreground-color)}.toolbar-toolContainer:not(.selected):not(.dropdownShowable)>.toolbar-button>.toolbar-showHideDropdownIcon{display:none}.toolbar-toolContainer>.toolbar-button>.toolbar-showHideDropdownIcon{height:15px;transition:transform .25s ease}.toolbar-toolContainer.dropdownVisible>.toolbar-button>.toolbar-showHideDropdownIcon{transform:rotate(180deg)}.toolbar-dropdown.hidden,.toolbar-toolContainer:not(.selected):not(.dropdownShowable)>.toolbar-dropdown:not(.hiding){display:none}.toolbar-dropdown{position:absolute;padding:15px;padding-top:5px;display:flex;flex-wrap:wrap;flex-direction:column;max-height:80vh;max-width:fit-content;z-index:2;background-color:var(--background-color-1);box-shadow:0px 3px 3px var(--shadow-color)}@keyframes dropdown-transition-in{0%{opacity:0;transform:scale(1, 0)}100%{opacity:1;transform:scale(1, 1)}}@keyframes dropdown-transition-out{0%{opacity:1;transform:scale(1, 1)}100%{opacity:0;transform:scale(1, 0)}}.toolbar-dropdown{transform-origin:top left;--dropdown-show-animation: dropdown-transition-in;--dropdown-hide-animation: dropdown-transition-out}@media(prefers-reduced-motion: reduce){.toolbar-dropdown{--dropdown-show-animation: none;--dropdown-hide-animation: none}.toolbar-dropdown.hiding{display:none}.toolbar-toolContainer>.toolbar-button>.toolbar-showHideDropdownIcon{transition:none}:root .toolbar-button,.toolbar-root button{transition:none}}.toolbar-buttonGroup{display:flex;flex-direction:row;justify-content:center}.toolbar-closeColorPickerOverlay{display:none;position:fixed;top:0;left:0;bottom:0;right:0;touch-action:none;background-color:var(--background-color-1);opacity:.3;z-index:2}.toolbar-spacedList>*{padding-bottom:5px;padding-top:5px}.toolbar-indentedList{padding-left:10px}@media print{.toolbar-element{display:none}}@keyframes toolbar--edgemenu-transition-in{from{transform:translate(0, 100%)}to{transform:translate(0, 0)}}@keyframes toolbar--edgemenu-transition-out{to{transform:translate(0, 100%)}}@keyframes toolbar--edgemenu-container-transition-in{from{overflow-y:hidden}to{overflow-y:hidden}}@keyframes toolbar--edgemenu-container-transition-out{from{overflow-y:hidden}to{overflow-y:hidden}}.toolbar-edge-toolbar{--toolbar-button-height: min(20vh, 48px);--toolbar-button-size: var(--toolbar-button-height);--label-hover-offset-size: calc(14px + var(--toolbar-button-height));box-sizing:border-box;flex-direction:row;justify-content:space-around;--button-label-hover-offset-y: var(--label-hover-offset-size);--button-label-hover-offset-x: 0}@media screen and (min-width: 540px){.toolbar-edge-toolbar{flex-wrap:nowrap}.toolbar-edge-toolbar>.toolbar-action-row{max-width:50vw;flex-grow:0;flex-shrink:0}}@media screen and (max-width: 700px){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline{font-size:.9em}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button{width:var(--toolbar-button-size)}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button label{opacity:0;animation:.2s linear hide-initially}@keyframes hide-initially{from{opacity:0}to{opacity:0}}@keyframes rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}}@media screen and (max-width: 700px)and (hover: hover){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:hover>label{opacity:.8;animation:1s ease show-label}}@media screen and (max-width: 700px){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:active>label{opacity:.8;animation:.5s ease show-label}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:focus-visible>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:has(:focus-visible)>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button>label{opacity:0;position:absolute;margin-top:var(--button-label-hover-offset-y);margin-left:var(--button-label-hover-offset-x);pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.2s ease opacity,.2s ease margin-top}}@media screen and (max-width: 700px)and (prefers-reduced-motion: reduce){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button>label{transition:none}}@media screen and (max-width: 700px){.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button>.toolbar-icon.toolbar-icon{margin-left:0;margin-right:0}}.toolbar-edge-toolbar>div.toolbar-element{flex-direction:row;display:flex;flex-grow:1;justify-content:center;background-color:var(--background-color-2);color:var(--foreground-color-2);--icon-color: var(--foreground-color-2);--extra-left-right-padding: 0px}.toolbar-edge-toolbar>div.toolbar-element::-webkit-scrollbar{width:3px;height:3px}.toolbar-edge-toolbar>div.toolbar-element::-webkit-scrollbar-thumb{background-color:var(--shadow-color)}.toolbar-edge-toolbar>div.toolbar-element.toolbar-tool-row{overflow-x:auto;overflow-y:hidden;flex-grow:100}.toolbar-edge-toolbar>div.toolbar-element.toolbar-action-row{z-index:2;background-color:var(--background-color-3);color:var(--foreground-color-3);--icon-color: var(--foreground-color-3)}.toolbar-edge-toolbar>div.toolbar-element.has-scroll{justify-content:start;position:relative;--button-label-hover-offset-y: 0;--button-label-hover-offset-x: calc(0px - var(--label-hover-offset-size))}.toolbar-edge-toolbar>div.toolbar-element.has-scroll>:nth-child(1){--button-label-hover-offset-x: var(--label-hover-offset-size)}.toolbar-edge-toolbar .toolbar-toolContainer.selected>.toolbar-button{background-color:var(--selection-background-color);color:var(--selection-foreground-color);--icon-color: var(--selection-foreground-color)}.toolbar-edge-toolbar .toolbar-button{box-sizing:border-box;background-color:rgba(0,0,0,0)}.toolbar-edge-toolbar .toolbar-button .toolbar-showHideDropdownIcon{flex-shrink:.01;height:12px}.toolbar-edge-toolbar .toolbar-toolContainer{order:1}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline{flex-grow:1;display:flex;--button-flex-direction: row}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline.label-left{justify-content:end;--button-flex-direction: row-reverse;order:100}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline.label-left>.toolbar-button>.toolbar-icon{margin-left:10px;margin-right:0}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline.label-right{order:-1}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline>.toolbar-button{width:auto;flex-direction:var(--button-flex-direction)}.toolbar-edge-toolbar .toolbar-toolContainer.label-inline>.toolbar-button>.toolbar-icon{height:100%;margin-right:10px;margin-left:0}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button{width:calc(var(--toolbar-button-size) + var(--extra-left-right-padding));height:var(--toolbar-button-size)}@keyframes rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}@media(hover: hover){.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:hover>label{opacity:.8;animation:1s ease show-label}}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:active>label{opacity:.8;animation:.5s ease show-label}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:focus-visible>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:has(:focus-visible)>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button>label{opacity:0;position:absolute;margin-top:var(--button-label-hover-offset-y);margin-left:var(--button-label-hover-offset-x);pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.2s ease opacity,.2s ease margin-top}@media(prefers-reduced-motion: reduce){.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button>label{transition:none}}.toolbar-edge-toolbar>div>.toolbar-toolContainer:not(.selected):not(.dropdownShowable)>.toolbar-button>.toolbar-showHideDropdownIcon{display:block;visibility:hidden}.toolbar-edge-toolbar .toolbar-toolContainer>.toolbar-button{margin:0;border-radius:0;padding:8px;box-shadow:none}.toolbar-edge-toolbar .toolbar-toolContainer>.toolbar-button.has-dropdown{padding-left:8px;padding-right:8px;padding-top:8px;padding-bottom:0px}.imageEditorContainer.pipette--color-selection-in-progress .toolbar-edgemenu-container{height:0;background-color:rgba(0,0,0,0);opacity:.9}.imageEditorContainer.pipette--color-selection-in-progress .toolbar-edgemenu-container .toolbar-edgemenu{position:absolute}.toolbar-edgemenu-container{background-color:var(--background-color-transparent);transition:.15s ease-in-out height,.15s ease-in-out background-color,.2s ease-in-out opacity;position:absolute;width:var(--editor-current-width-px);height:var(--editor-current-height-px);box-sizing:border-box;display:flex;flex-direction:column-reverse;align-items:center;z-index:2}@media(prefers-reduced-motion: reduce){.toolbar-edgemenu-container{transition:none}}.toolbar-edgemenu-container.dropdown-below-edge{overflow-y:hidden}.toolbar-edgemenu-container button{font-size:1.2em;box-shadow:none;border:none;padding:10px;color:var(--foreground-color-1);transition:.2s ease box-shadow;font-weight:bold;color:var(--primary-action-foreground-color)}.toolbar-edgemenu-container button:hover{box-shadow:0 1px 2px var(--shadow-color)}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button{--button-label-hover-offset-y: var(--button-size)}@keyframes rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}@media(hover: hover){.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:hover>label>.button-label-text{opacity:.8;animation:1s ease show-label}}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:active>label>.button-label-text{opacity:.8;animation:.5s ease show-label}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:focus-visible>label>.button-label-text{animation:1.5s ease rehide-label;opacity:0}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:has(:focus-visible)>label>.button-label-text{animation:1.5s ease rehide-label;opacity:0}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button>label>.button-label-text{opacity:0;position:absolute;margin-top:var(--button-label-hover-offset-y);margin-left:var(--button-label-hover-offset-x);pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.2s ease opacity,.2s ease margin-top}@media(prefers-reduced-motion: reduce){.toolbar-edgemenu-container .toolbar-grid-selector .choice-button>label>.button-label-text{transition:none}}.toolbar-edgemenu-container .toolbar-edgemenu{--toolbar-button-height: 48px;touch-action:none;user-select:none;background-color:var(--background-color-2);color:var(--foreground-color-2);--icon-color: var(--foreground-color-2);box-shadow:0px 0px 1px var(--shadow-color);padding-left:10px;padding-right:10px;width:min(400px,100vw);box-sizing:border-box;border-top-left-radius:30px;border-top-right-radius:30px;transition:transform .1s ease,padding-bottom .1s ease}.toolbar-edgemenu-container .toolbar-edgemenu input,.toolbar-edgemenu-container .toolbar-edgemenu textarea{user-select:auto}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer{display:inline-block}.toolbar-edgemenu-container .toolbar-edgemenu button{background-color:rgba(0,0,0,0)}.toolbar-edgemenu-container .toolbar-edgemenu>button.drag-elem{height:40px;display:block;cursor:ns-resize;position:relative;margin-top:-15px;margin-bottom:10px;width:100%;border:none;box-shadow:none;background:rgba(0,0,0,0)}.toolbar-edgemenu-container .toolbar-edgemenu>button.drag-elem::before{content:"";background-color:var(--icon-color);opacity:.2;display:block;position:relative;top:10px;height:5px;border-radius:5px;width:min(80%,40px);margin-left:auto;margin-right:auto}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer{display:block}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button{flex-direction:row;max-width:unset;width:100%;box-sizing:border-box;justify-content:flex-start;box-shadow:none;padding:2px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button>.toolbar-icon{width:25px;height:25px;padding:13px;margin-right:15px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button label,.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-toolContainer .toolbar-button>label.long-label{font-size:1em}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-nonbutton-controls-main-list{padding-left:10px;padding-right:10px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList{box-sizing:border-box;--align-items-to-x: 105px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div{display:flex;align-items:center;margin-top:5px;min-height:35px}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div>label{padding-right:35px;min-width:var(--align-items-to-x);flex-shrink:1;box-sizing:border-box}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div>input[type=checkbox]{width:20px;height:20px;margin-left:0}.toolbar-edgemenu-container .toolbar-edgemenu .toolbar-spacedList>div>input:not([type=checkbox]){flex-grow:1;min-width:48px;flex-shrink:1}.toolbar-dropdown-toolbar button,.toolbar-dropdown-toolbar .toolbar-button{background-color:var(--background-color-2);color:var(--foreground-color-2);--icon-color: var(--foreground-color-2)}.toolbar-dropdown-toolbar,.toolbar-dropdown-toolbar .toolbar-dropdown{background-color:var(--background-color-3);color:var(--foreground-color-3)}.toolbar-dropdown-toolbar .toolbar-spacedList>div>label{padding-right:10px;min-width:50px}.toolbar-dropdown-toolbar .clr-field button{width:100%;height:100%;top:50%;left:0;border-radius:5px}.toolbar-dropdown-toolbar .toolbar-grid-selector>div{--button-size: 57px}.toolbar-dropdown-toolbar .toolbar-dropdown>div>.toolbar-toolContainer{display:inline-block}.ScrollbarTool-overlay{width:0;height:0;overflow:visible;opacity:.2;pointer-events:none;--fade-out-animation: 1s ease 0s fade-out;--scrollbar-size: 3px}@media(prefers-reduced-motion: reduce){.ScrollbarTool-overlay{--fade-out-animation: none !important}}@keyframes fade-out{from{opacity:.2}to{opacity:0}}.ScrollbarTool-overlay:not(.just-updated){animation:var(--fade-out-animation);opacity:0}.ScrollbarTool-overlay .vertical-scrollbar,.ScrollbarTool-overlay .horizontal-scrollbar{width:var(--scrollbar-size);height:var(--scrollbar-size);min-width:var(--scrollbar-size);min-height:var(--scrollbar-size);background-color:var(--foreground-color-1);border-radius:var(--scrollbar-size);position:absolute}.ScrollbarTool-overlay .vertical-scrollbar.represents-no-scroll,.ScrollbarTool-overlay .horizontal-scrollbar.represents-no-scroll{animation:var(--fade-out-animation);opacity:0}.ScrollbarTool-overlay:not(.scrollbar-left) .vertical-scrollbar{margin-left:calc(var(--editor-current-display-width-px) - var(--scrollbar-size))}.ScrollbarTool-overlay:not(.scrollbar-top) .horizontal-scrollbar{margin-top:calc(var(--editor-current-display-height-px) - var(--scrollbar-size))}.selection-tool-selection-background{background-color:var(--selection-background-color);opacity:.5;overflow:visible;position:absolute}.selection-tool-handle{border:1px solid var(--foreground-color-1);background:var(--background-color-1);position:absolute;box-sizing:border-box;padding:3px}.selection-tool-handle .icon{width:100%;height:100%}.selection-tool-handle.selection-tool-circle{border-radius:100%}.selection-tool-handle.selection-tool-rotate{cursor:grab}.selection-tool-handle.selection-tool-resize-x{cursor:ew-resize}.selection-tool-handle.selection-tool-resize-y{cursor:ns-resize}.selection-tool-handle.selection-tool-resize-xy{cursor:nw-resize}.selection-tool-rotated-near-perpendicular .selection-tool-handle.selection-tool-resize-x{cursor:ns-resize}.selection-tool-rotated-near-perpendicular .selection-tool-handle.selection-tool-resize-y{cursor:ew-resize}.selection-tool-rotated-near-perpendicular .selection-tool-handle.selection-tool-resize-xy{cursor:sw-resize}.overlay.handleOverlay{height:0;overflow:visible}@keyframes selection-duplicated-animation{0%{scale:1 1}50%{scale:1.02 1.02}100%{scale:1 1}}@media(prefers-reduced-motion: reduce){@keyframes selection-duplicated-animation{}}.find-tool-overlay{order:-1;position:absolute}.js-draw-sound-ui-toggle{width:0px;height:0px;overflow:hidden}.js-draw-sound-ui-toggle button{margin-top:1px}.js-draw-sound-ui-toggle:focus-within,.js-draw-sound-ui-toggle.sound-ui-tool-enabled{overflow:visible;z-index:5}.js-draw-sound-ui-toggle:not(:focus-within):not(:hover).sound-ui-tool-enabled{opacity:.5}.about-dialog-container dialog{display:flex;flex-direction:column}.about-dialog-container dialog .close-button{display:block;margin-left:auto;margin-right:auto}.about-dialog-container dialog .about-entry-container{flex-grow:1;flex-shrink:1;overflow-y:auto;margin-left:20px;margin-right:20px;padding-bottom:20px;white-space:pre-wrap;font-family:monospace}.about-dialog-container dialog .about-entry-container>h2,.about-dialog-container dialog .about-entry-container>details>summary{cursor:pointer;margin-top:15px;font-size:1.2em;font-weight:bold}.about-dialog-container dialog .about-entry-container>h2 a,.about-dialog-container dialog .about-entry-container>details>summary a{color:var(--foreground-color-1);text-decoration:underline}.dialog-container.dialog-container{background-color:var(--background-color-transparent);backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px);position:absolute;z-index:3;width:var(--editor-current-width-px);height:var(--editor-current-height-px);display:flex;flex-direction:column-reverse;align-items:center;justify-content:center}.dialog-container.dialog-container dialog{background-color:var(--background-color-1);color:var(--foreground-color-1);border:none;outline:none;box-shadow:0 0 2px var(--shadow-color);border-radius:8px;max-height:90vh;width:min(100%,500px);box-sizing:border-box}#clr-picker{--clr-slider-size: 30px}#clr-picker #clr-color-area,#clr-picker .clr_hue{touch-action:none}#clr-picker .clr-alpha{margin-top:15px;margin-bottom:15px}#clr-picker.clr-picker input[type=range]::-moz-range-thumb{width:var(--clr-slider-size);height:var(--clr-slider-size)}#clr-picker.clr-picker input[type=range]::-webkit-slider-thumb{width:var(--clr-slider-size);height:var(--clr-slider-size)}#clr-picker.clr-picker input[type=range]::-webkit-slider-runnable-track{height:var(--clr-slider-size)}#clr-picker.clr-picker input[type=range]::-moz-range-track{height:var(--clr-slider-size)}.imageEditorContainer{--background-color-1: white;--foreground-color-1: black;--background-color-2: #f5f5f5;--foreground-color-2: #2c303a;--background-color-3: #e5e5e5;--foreground-color-3: #1c202a;--selection-background-color: #cbdaf1;--selection-foreground-color: #2c303a;--background-color-transparent: rgba(105, 100, 100, 0.5);--shadow-color: rgba(0, 0, 0, 0.5);--primary-action-foreground-color: #15b}@media(prefers-color-scheme: dark){.imageEditorContainer{--background-color-1: #151515;--foreground-color-1: white;--background-color-2: #222;--foreground-color-2: #efefef;--background-color-3: #272627;--foreground-color-3: #eee;--selection-background-color: #607;--selection-foreground-color: white;--shadow-color: rgba(250, 250, 250, 0.5);--background-color-transparent: rgba(50, 50, 50, 0.5);--primary-action-foreground-color: #7ae}}.imageEditorContainer{--icon-color: var(--foreground-color-1)}.imageEditorContainer{color:var(--foreground-color-1);font-family:system-ui,-apple-system,sans-serif;background-color:var(--background-color-1);width:100%;height:400px;min-height:220px;min-width:100px;box-sizing:border-box;display:flex;flex-direction:column-reverse}.imageEditorContainer input{accent-color:var(--primary-action-foreground-color)}.imageEditorContainer .imageEditorRenderArea{display:grid;grid-template-columns:1fr;flex-grow:2;flex-shrink:1;min-height:100px;min-width:0;width:100%;height:100%}.imageEditorContainer .imageEditorRenderArea canvas{grid-row:1/1;grid-column:1/1;touch-action:none;box-sizing:border-box;width:100%;height:100%;min-width:0;max-width:inherit;min-height:0px;max-height:inherit}.imageEditorContainer .loadingMessage{position:fixed;text-align:center;font-size:2em;bottom:0;left:0;right:0}.imageEditorContainer .accessibilityAnnouncement{opacity:0;width:0;height:0;overflow:hidden;pointer-events:none}.imageEditorContainer .textRendererOutputContainer{width:1px;height:1px;overflow:hidden}.imageEditorContainer .textRendererOutputContainer:focus-within{overflow:visible;z-index:5}@media print{.imageEditorContainer .loadingMessage{display:none}.imageEditorContainer .imageEditorRenderArea canvas{width:100%;height:initial}}',""]);const a=s},2609:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var d=[].concat(t[c]);o&&s[d[0]]||(void 0!==r&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),e.push(d))}},e}},9601:t=>{"use strict";t.exports=function(t){return t[1]}},6062:t=>{"use strict";var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=o.base?l[0]+o.base:l[0],d=r[c]||0,h="".concat(c," ").concat(d);r[c]=d+1;var u=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==u)e[u].references++,e[u].updater(p);else{var f=i(p,o);o.byIndex=a,e.splice(a,0,{identifier:h,updater:f,references:1})}s.push(h)}return s}function i(t,e){var n=e.domAPI(e);n.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,i){var r=o(t=t||[],i=i||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=o(t,i),c=0;c<r.length;c++){var d=n(r[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}r=l}}},6793:t=>{"use strict";var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},1173:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},7892:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},4036:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,i&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},2464:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},5146:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Editor=void 0;const a=s(n(505)),l=s(n(8169)),c=n(3173),d=n(7520),h=s(n(5155)),u=s(n(5566)),p=s(n(1785)),f=n(5097),m=r(n(3012)),g=s(n(1697)),b=s(n(4318)),y=s(n(1906)),v=s(n(8282)),w=s(n(7717)),x=s(n(7395)),S=s(n(9070)),T=s(n(1456)),C=s(n(7591)),P=s(n(9721)),k=r(n(1847)),E=s(n(1380)),z=s(n(5376)),M=s(n(5221)),_=s(n(9542)),I=s(n(1993)),R=s(n(9784)),B=s(n(2674)),L=n(2460),O=n(1151);class D{constructor(t,e={}){if(this.eventListenerTargets=[],this.previousAccessibilityAnnouncement="",this.pointers={},this.announceUndoCallback=t=>{this.announceForAccessibility(this.localization.undoAnnouncement(t.description(this,this.localization)))},this.announceRedoCallback=t=>{this.announceForAccessibility(this.localization.redoAnnouncement(t.description(this,this.localization)))},this.nextRerenderListeners=[],this.rerenderQueued=!1,this.closeAboutDialog=null,this.localization={...(0,y.default)(),...e.localization},this.settings={wheelEventsEnabled:e.wheelEventsEnabled??!0,renderingMode:e.renderingMode??m.RenderingMode.CanvasRenderer,localization:this.localization,minZoom:e.minZoom??2e-10,maxZoom:e.maxZoom??1e12,keyboardShortcutOverrides:e.keyboardShortcutOverrides??{},iconProvider:e.iconProvider??new v.default,notices:[]},this.settings.minZoom>this.settings.maxZoom)throw new Error("Minimum zoom must be lesser than maximum zoom!");this.readOnly=O.MutableReactiveValue.fromInitialValue(!1),this.icons=this.settings.iconProvider,this.shortcuts=new z.default(this.settings.keyboardShortcutOverrides),this.container=document.createElement("div"),this.renderingRegion=document.createElement("div"),this.container.appendChild(this.renderingRegion),this.container.classList.add("imageEditorContainer","js-draw"),this.loadingWarning=document.createElement("div"),this.loadingWarning.classList.add("loadingMessage"),this.loadingWarning.ariaLive="polite",this.container.appendChild(this.loadingWarning),this.accessibilityControlArea=document.createElement("textarea"),this.accessibilityControlArea.setAttribute("placeholder",this.localization.accessibilityInputInstructions),this.accessibilityControlArea.style.opacity="0",this.accessibilityControlArea.style.width="0",this.accessibilityControlArea.style.height="0",this.accessibilityControlArea.style.position="absolute",this.accessibilityAnnounceArea=document.createElement("div"),this.accessibilityAnnounceArea.setAttribute("aria-live","assertive"),this.accessibilityAnnounceArea.className="accessibilityAnnouncement",this.container.appendChild(this.accessibilityAnnounceArea),this.renderingRegion.style.touchAction="none",this.renderingRegion.className="imageEditorRenderArea",this.renderingRegion.appendChild(this.accessibilityControlArea),this.renderingRegion.setAttribute("tabIndex","0"),this.renderingRegion.setAttribute("alt",""),this.notifier=new p.default,this.viewport=new u.default(((t,e)=>{this.notifier.dispatch(c.EditorEventType.ViewportChanged,{kind:c.EditorEventType.ViewportChanged,newTransform:e,oldTransform:t})})),this.display=new m.default(this,this.settings.renderingMode,this.renderingRegion),this.image=new a.default,this.history=new h.default(this,this.announceRedoCallback,this.announceUndoCallback),this.toolController=new l.default(this,this.localization),this.toolController.addInputMapper(_.default.fromEditor(this)),t.appendChild(this.container),this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.registerListeners(),this.queueRerender(),this.hideLoadingWarning(),this.notifier.on(c.EditorEventType.ViewportChanged,(t=>{if(t.kind===c.EditorEventType.ViewportChanged){const e=t.newTransform.transformVec3(f.Vec2.unitX).length();if(e>this.settings.maxZoom||e<this.settings.minZoom){const e=t.oldTransform.transformVec3(f.Vec2.unitX).length();let n=f.Mat33.identity;n=e<=this.settings.maxZoom&&e>=this.settings.minZoom?t.oldTransform:f.Mat33.scaling2D((this.settings.minZoom+this.settings.maxZoom)/2),this.viewport.resetTransform(n)}}}))}getRootElement(){return this.container}showLoadingWarning(t){const e=Math.round(100*t);this.loadingWarning.innerText=this.localization.loading(e),this.loadingWarning.style.display="block"}hideLoadingWarning(){this.loadingWarning.style.display="none",this.announceForAccessibility(this.localization.doneLoading)}announceForAccessibility(t){t===this.previousAccessibilityAnnouncement&&(t+=". "),this.accessibilityAnnounceArea.innerText=t,this.previousAccessibilityAnnouncement=t}addToolbar(t=!0){const e=new M.default(this,this.container,this.localization);return t&&e.addDefaults(),e}registerListeners(){this.handlePointerEventsFrom(this.renderingRegion),this.handleKeyEventsFrom(this.renderingRegion),this.handlePointerEventsFrom(this.accessibilityAnnounceArea),this.container.addEventListener("wheel",(t=>{let e=f.Vec3.of(t.deltaX,t.deltaY,t.deltaZ);if(!t.ctrlKey&&!t.metaKey){if(!this.settings.wheelEventsEnabled)return;if("only-if-focused"===this.settings.wheelEventsEnabled){if(!this.container.querySelector(":focus"))return}}t.deltaMode===WheelEvent.DOM_DELTA_LINE?e=e.times(15):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e=e.times(100)),(t.ctrlKey||t.metaKey)&&(e=f.Vec3.of(0,0,t.deltaY));const n=this.renderingRegion.getBoundingClientRect(),o=f.Vec2.of(t.clientX,t.clientY).minus(f.Vec2.of(n.left,n.top));return!!this.toolController.dispatchInputEvent({kind:d.InputEvtType.WheelEvt,delta:e,screenPos:o})&&(t.preventDefault(),!0)}));const t=()=>{this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.rerender(),this.updateEditorSizeVariables()};if("ResizeObserver"in window){const e=new ResizeObserver(t);e.observe(this.renderingRegion),e.observe(this.container)}else addEventListener("resize",t);this.accessibilityControlArea.addEventListener("input",(()=>{this.accessibilityControlArea.value=""})),document.addEventListener("copy",(t=>{if(!this.isEventSink(document.querySelector(":focus")))return;const e=t.clipboardData;this.toolController.dispatchInputEvent({kind:d.InputEvtType.CopyEvent,setData:(t,n)=>{e?.setData(t,n)}})&&t.preventDefault()})),document.addEventListener("paste",(t=>{this.handlePaste(t)}))}updateEditorSizeVariables(){this.container.style.setProperty("--editor-current-width-px",`${this.container.clientWidth}px`),this.container.style.setProperty("--editor-current-height-px",`${this.container.clientHeight}px`),this.container.style.setProperty("--editor-current-display-width-px",`${this.renderingRegion.clientWidth}px`),this.container.style.setProperty("--editor-current-display-height-px",`${this.renderingRegion.clientHeight}px`)}getPointerList(){const t=performance.now(),e=[];for(const n in this.pointers){const o=2e3;this.pointers[n]&&t-this.pointers[n].timeStamp<o&&e.push(this.pointers[n])}return e}handleHTMLPointerEvent(t,e){const n=this.renderingRegion,o=e.target??this.renderingRegion;if("pointerdown"===t){const t=b.default.ofEvent(e,!0,this.viewport,n);this.pointers[t.id]=t,o.setPointerCapture(t.id);const i={kind:d.InputEvtType.PointerDownEvt,current:t,allPointers:this.getPointerList()};return this.toolController.dispatchInputEvent(i),!0}if("pointermove"===t){const t=b.default.ofEvent(e,this.pointers[e.pointerId]?.down??!1,this.viewport,n);if(t.down){const n=this.pointers[t.id];if(n){if(t.screenPos.minus(n.screenPos).magnitude()<2)return!1}this.pointers[t.id]=t,this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerMoveEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault()}return!0}if("pointercancel"===t||"pointerup"===t){const t=b.default.ofEvent(e,!1,this.viewport,n);return!!this.pointers[t.id]&&(this.pointers[t.id]=t,o.releasePointerCapture(t.id),this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerUpEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault(),delete this.pointers[t.id],!0)}return t}isEventSink(t){let e=t;for(;null!==e;){for(const t of this.eventListenerTargets)if(t===e)return!0;e=e.parentElement}return!1}async handlePaste(t){const e=document.querySelector(":focus")??t.target;if(!this.isEventSink(e))return;const n=t.dataTransfer??t.clipboardData;if(!n)return;for(const e of n.files)if("image/svg+xml"===e.type.toLowerCase()){const n=await e.text();if(this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e.type,data:n}))return void t.preventDefault()}for(const e of n.files){const n=e.type.toLowerCase();if("image/png"===n||"image/jpg"===n){this.showLoadingWarning(0);const o=t=>{this.showLoadingWarning(t.loaded/t.total)};try{const i=await(0,S.default)(e,o);if(i&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:n,data:i}))return t.preventDefault(),void this.hideLoadingWarning()}catch(t){console.error("Error reading image:",t)}this.hideLoadingWarning()}}const o=["image/svg+xml","text/plain"];for(const e of o){const o=n.getData(e);if(o&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e,data:o}))return void t.preventDefault()}}handlePointerEventsFrom(t,e,n){const o={touchstart:t=>{n&&!n("touchstart",t)||t.preventDefault()},contextmenu:t=>{n&&!n("contextmenu",t)||t.preventDefault()}},i=["pointerdown","pointermove","pointerup","pointercancel"];for(const t of i)o[t]=n=>{const o=n;if(!e||e(t,o))return this.handleHTMLPointerEvent(t,o)};for(const e in o)t.addEventListener(e,o[e]);return{remove:()=>{for(const e in o)t.removeEventListener(e,o[e])}}}handlePointerEventsExceptClicksFrom(t,e,n){const o=Object.create(null);return this.handlePointerEventsFrom(t,((n,i)=>{if(e&&!e(n,i))return!1;const r=f.Vec2.of(i.pageX,i.pageY),s=i.pointerId??0;let a=!0;if("pointerdown"===n)o[s]={eventBuffer:[[n,i]],startPoint:r},t.setPointerCapture(i.pointerId),a=!1;else if("pointermove"===n&&o[s]){const t=o[s].startPoint,e=o[s].eventBuffer,l=10;if(t&&r.minus(t).magnitude()<l)e.push([n,i]),a=!1;else{for(const[t,n]of e)this.handleHTMLPointerEvent(t,n);o[s].eventBuffer=[],a=!0}}else"pointermove"===n?a=!0:("pointerup"===n||"pointercancel"===n)&&o[s]&&o[s].eventBuffer.length>0&&(t.releasePointerCapture(i.pointerId),a=!1,delete o[s]);return a}),n)}handleKeyEventsFrom(t,e=(()=>!0)){let n=[];const o=(t,e)=>t.key===e.key&&t.code===e.code;t.addEventListener("keydown",(t=>{if(!e(t))return;const i=(0,d.keyPressEventFromHTMLEvent)(t);n.some((t=>o(t,i)))||n.push(i),"t"===i.key||"T"===i.key?(t.preventDefault(),this.display.rerenderAsText()):this.toolController.dispatchInputEvent(i)?t.preventDefault():"Escape"===i.key&&this.renderingRegion.blur()})),t.addEventListener("keyup",(t=>{if(n=n.filter((e=>!o(e,t))),!e(t))return;const i=(0,d.keyUpEventFromHTMLEvent)(t);this.toolController.dispatchInputEvent(i)&&t.preventDefault()})),t.addEventListener("blur",(()=>{for(const t of n)this.toolController.dispatchInputEvent({...t,kind:d.InputEvtType.KeyUpEvent})})),t.ondragover=t=>{t.preventDefault()},t.ondrop=t=>{t.preventDefault(),this.handlePaste(t)},this.eventListenerTargets.push(t)}setReadOnly(t){t!==this.readOnly.get()&&(this.readOnly.set(t),this.notifier.dispatch(c.EditorEventType.ReadOnlyModeToggled,{kind:c.EditorEventType.ReadOnlyModeToggled,editorIsReadOnly:t}))}isReadOnlyReactiveValue(){return this.readOnly}isReadOnly(){return this.readOnly}dispatch(t,e=!0){const n=this.dispatchNoAnnounce(t,e);return this.announceForAccessibility(t.description(this,this.localization)),n}dispatchNoAnnounce(t,e=!1){const n=t.apply(this);if(e){const e=!1;this.history.push(t,e)}return n}async asyncApplyOrUnapplyCommands(t,e,n){console.assert(n>0),this.display.setDraftMode(!0);for(let o=0;o<t.length;o+=n){this.showLoadingWarning(o/t.length);for(let i=o;i<t.length&&i<o+n;i++){const n=t[i];e?n.apply(this):n.unapply(this)}o+n<t.length&&await new Promise((t=>{this.rerender(),requestAnimationFrame(t)}))}this.display.setDraftMode(!1),this.hideLoadingWarning()}asyncApplyCommands(t,e){return this.asyncApplyOrUnapplyCommands(t,!0,e)}asyncUnapplyCommands(t,e,n=!1){return n&&(t=[...t]).reverse(),this.asyncApplyOrUnapplyCommands(t,!1,e)}queueRerender(){return this.rerenderQueued||(this.rerenderQueued=!0,requestAnimationFrame((()=>{this.rerenderQueued&&(this.rerender(),this.rerenderQueued=!1)}))),new Promise((t=>{this.nextRerenderListeners.push((()=>t()))}))}isRerenderQueued(){return this.rerenderQueued}rerender(t=!0){if(this.display.startRerender(),0===this.display.width||0===this.display.height)return;const e=this.display.getDryInkRenderer();if(this.image.renderWithCache(e,this.display.getCache(),this.viewport),t&&!this.image.getAutoresizeEnabled()){const t={fill:f.Color4.fromHex("#44444455")},n=5*this.viewport.getSizeOfPixelOnCanvas();e.drawRect(this.getImportExportRect(),n,t)}this.rerenderQueued=!1,this.nextRerenderListeners.forEach((t=>t())),this.nextRerenderListeners=[]}drawWetInk(...t){for(const e of t)this.display.getWetInkRenderer().drawPath(e)}clearWetInk(){this.display.getWetInkRenderer().clear()}focus(){this.renderingRegion.focus()}createHTMLOverlay(t){return t.classList.add("overlay","js-draw-editor-overlay"),this.container.appendChild(t),{remove:()=>t.remove()}}addStyleSheet(t){const e=document.createElement("style");return e.innerText=t,this.container.appendChild(e),e}sendKeyboardEvent(t,e,n=!1,o=!1,i=void 0){i??=e.toUpperCase()===e&&e.toLowerCase()!==e,this.toolController.dispatchInputEvent({kind:t,key:e,code:(0,I.default)(e),ctrlKey:n,altKey:o,shiftKey:i})}sendPenEvent(t,e,n){(0,E.default)(this,t,e,n)}async addAndCenterComponents(t,e=!0){let n=null;for(const e of t)n=n?n.union(e.getBBox()):e.getBBox();if(!n)return;const o=this.viewport.visibleRect,i=o.width/n.width,r=o.height/n.height;let s=i;(n.width*s>o.width||n.height*s>o.height)&&(s=r),s*=2/3,s=u.default.roundScaleRatio(s);const l=f.Mat33.translation(o.center.minus(n.center)).rightMul(f.Mat33.scaling2D(s,n.center)),c=[];for(const e of t)c.push(a.default.addElement(e)),c.push(e.transformBy(l));if(await this.dispatch((0,T.default)(c,100),!0),e)for(const e of this.toolController.getMatchingTools(C.default))e.setEnabled(!0),e.setSelection(t)}toDataURL(t="image/png",e){const n=document.createElement("canvas"),o=this.image.getImportExportViewport(),i=o.getScreenRectSize(),r=e??i;n.width=r.x,n.height=r.y;const s=n.getContext("2d"),a=Math.min(r.x/i.x,r.y/i.y);s.scale(a,a);const l=new w.default(s,o);this.image.renderAll(l);return n.toDataURL(t)}toSVG(t){return(0,L.editorImageToSVGSync)(this.image,t??{})}async toSVGAsync(t={}){const e=t.pauseAfterCount??100;return await(0,L.editorImageToSVGAsync)(this.image,(async(n,o,i)=>{if(t.onProgress){if(!1===await t.onProgress(o,i))return!1}return o%e==0&&await(0,x.default)(),!0}),{minDimension:t.minDimension})}async loadFrom(t){this.showLoadingWarning(0),this.display.setDraftMode(!0);const e=this.image.getBackgroundComponents(),n=new P.default(e);let o=!1;await t.start((async t=>{await this.dispatchNoAnnounce(a.default.addElement(t))}),((t,e)=>t%500==0?(this.showLoadingWarning(t/e),this.rerender(),(0,x.default)()):null),((t,e)=>{this.dispatchNoAnnounce(this.setImportExportRect(t),!1),this.dispatchNoAnnounce(this.viewport.zoomTo(t),!1),e&&(o=e.autoresize)})),this.dispatchNoAnnounce(this.image.setAutoresizeEnabled(o),!1),this.image.getBackgroundComponents().length!==e.length&&await this.dispatchNoAnnounce(n),this.hideLoadingWarning(),this.display.setDraftMode(!1),this.queueRerender()}getTopmostBackgroundComponent(){let t=null;for(const e of this.image.getBackgroundComponents())e instanceof k.default&&(t=e);return t}setBackgroundColor(t){let e=this.getTopmostBackgroundComponent();if(e)return e.updateStyle({color:t});{const n=t.eq(f.Color4.transparent)?k.BackgroundType.None:k.BackgroundType.SolidColor;return e=new k.default(n,t),this.image.addElement(e)}}estimateBackgroundColor(){const t=[];for(const e of this.image.getBackgroundComponents())e instanceof k.default&&t.push(e.getStyle().color??f.Color4.transparent);return f.Color4.average(t)}getImportExportRect(){return this.image.getImportExportViewport().visibleRect}setImportExportRect(t){return this.image.setImportExportRect(t)}async loadFromSVG(t,e=!1){const n=g.default.fromString(t,e);await this.loadFrom(n)}showAboutDialog(){const t=this.icons.licenseInfo(),e=[];e.push({heading:"js-draw",text:[`v${B.default.number}`,"","Image debug information (from when this dialog was opened):",` ${this.viewport.getScaleFactor()}x zoom, ${180/Math.PI*this.viewport.getRotationAngle()} rotation`,` ${this.image.estimateNumElements()} components`,` ${this.getImportExportRect().w}x${this.getImportExportRect().h} size`].join("\n")}),e.push({heading:"Libraries",text:["js-draw uses several libraries at runtime. Particularly noteworthy are:"," - The Coloris color picker: https://github.com/mdbassit/Coloris"," - The bezier.js Bézier curve library: https://github.com/Pomax/bezierjs"].join("\n"),minimized:!0}),t&&e.push({heading:"Icon Pack",text:t,minimized:!0}),e.push(...this.settings.notices),this.closeAboutDialog?.(),this.closeAboutDialog=(0,R.default)(this,e).close}remove(){this.container.remove(),this.toolController.onEditorDestroyed()}}e.Editor=D,e.default=D},1785:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.listeners={}}dispatch(t,e){const n=this.listeners[t];if(n)for(let t=0;t<n.length;t++)n[t](e)}on(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),{remove:()=>{const n=this.listeners[t];return this.off(t,e),n.length!==this.listeners[t].length}}}off(t,e){const n=this.listeners[t];n&&(this.listeners[t]=n.filter((t=>t!==e)))}}},4318:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointerDevice=void 0;const o=n(5097);var i;!function(t){t[t.Pen=0]="Pen",t[t.Eraser=1]="Eraser",t[t.Touch=2]="Touch",t[t.PrimaryButtonMouse=3]="PrimaryButtonMouse",t[t.RightButtonMouse=4]="RightButtonMouse",t[t.Other=5]="Other"}(i||(e.PointerDevice=i={}));class r{constructor(t,e,n,o,i,r,s,a){this.screenPos=t,this.canvasPos=e,this.pressure=n,this.isPrimary=o,this.down=i,this.device=r,this.id=s,this.timeStamp=a}snappedToGrid(t){const e=t.snapToGrid(this.canvasPos);return this.withCanvasPosition(e,t)}lockedToXYAxesScreen(t,e){const n=this.screenPos.minus(t),i=o.Vec2.unitX.times(n.x),r=o.Vec2.unitY.times(n.y);let s;return s=n.dot(i)>n.dot(r)?i:r,s=s.plus(t),this.withScreenPosition(s,e)}withScreenPosition(t,e){const n=e.screenToCanvas(t);return this.withCanvasPosition(n,e)}withTimestamp(t){return new r(this.screenPos,this.canvasPos,this.pressure,this.isPrimary,this.down,this.device,this.id,t)}withCanvasPosition(t,e){const n=e.canvasToScreen(t);return new r(n,t,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(t,e,n,s){let a=o.Vec2.of(t.clientX,t.clientY);if(s){const t=s.getBoundingClientRect();a=a.minus(o.Vec2.of(t.left,t.top))}let l={mouse:i.PrimaryButtonMouse,pen:i.Pen,touch:i.Touch}[t.pointerType]??i.Other;l===i.Pen&&0!=(32&t.buttons)&&(l=i.Eraser);const c=t.timeStamp,d=n.roundPoint(n.screenToCanvas(a));return l===i.PrimaryButtonMouse&&2&t.buttons&&(l=i.RightButtonMouse),new r(a,d,t.pressure??null,t.isPrimary,e,l,t.pointerId,c)}static ofCanvasPoint(t,e,n,o=0,s=i.Pen,a=!0,l=null){const c=n.canvasToScreen(t),d=(new Date).getTime();return new r(c,t,l,a,e,s,o,d)}}e.default=r},1697:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.svgLoaderAutoresizeClassName=e.svgLoaderAttributeContainerID=e.svgStyleAttributesDataKey=e.svgAttributesDataKey=e.defaultSVGViewRect=void 0;const a=n(5097),l=r(n(1847)),c=s(n(7077)),d=s(n(9964)),h=s(n(2413)),u=r(n(3167)),p=s(n(9025)),f=n(7444);e.defaultSVGViewRect=new a.Rect2(0,0,500,500),e.svgAttributesDataKey="svgAttrs",e.svgStyleAttributesDataKey="svgStyleAttrs",e.svgLoaderAttributeContainerID="svgContainerID",e.svgLoaderAutoresizeClassName="js-draw--autoresize";const m=["stroke","fill","stroke-width"];class g{constructor(t,e,n){this.source=t,this.onFinish=e,this.onAddComponent=null,this.onProgress=null,this.onDetermineExportRect=null,this.processedCount=0,this.totalToProcess=0,this.containerGroupIDs=[],this.encounteredIDs=[],this.storeUnknown=!n.sanitize,this.disableUnknownObjectWarnings=!!n.disableUnknownObjectWarnings}getStyle(t,e){let n,o=a.Color4.transparent;const i=t.getAttribute("fill")??e?.fill??t.style.fill;if(i)try{o=a.Color4.fromString(i)}catch(t){console.error("Unknown fill color,",i)}const r=t.getAttribute("stroke")??e?.stroke??t.style.stroke,s=t.getAttribute("stroke-width")??e?.strokeWidth??t.style.strokeWidth;if(r&&s)try{let t=parseFloat(s??"1");isFinite(t)||(t=0);const e=a.Color4.fromString(r);e.a>0&&(n={width:t,color:e})}catch(t){console.error("Error parsing stroke data:",t)}return{fill:o,stroke:n}}strokeDataFromElem(t){const e=[],n=t.getAttribute("d")??"",o=this.getStyle(t),i=n.split("M");let r=!0;for(const t of i){const n=/^[0-9., \t\n]+$/.exec(t);if(""!==t&&!n){const n=r?t:`M${t}`,i=a.Path.fromString(n),s=(0,f.pathToRenderable)(i,o);e.push(s)}r=!1}return e}attachUnrecognisedAttrs(t,n,o,i){if(this.storeUnknown){for(const r of n.getAttributeNames())o.has(r)||"style"===r&&i||t.attachLoadSaveData(e.svgAttributesDataKey,[r,n.getAttribute(r)]);if(i&&n.style)for(let o=0;o<n.style.length;o++){const r=n.style[o];""!==r&&r&&(i.has(r)||t.attachLoadSaveData(e.svgStyleAttributesDataKey,{key:r,value:n.style.getPropertyValue(r),priority:n.style.getPropertyPriority(r)}))}}}async addPath(t){let e;try{const n=this.strokeDataFromElem(t);e=new d.default(n),this.attachUnrecognisedAttrs(e,t,new Set([...m,"d"]),new Set(m))}catch(n){if(console.error("Invalid path in node",t,"\nError:",n,"\nAdding as an unknown object."),!this.storeUnknown)return;e=new p.default(t)}await this.addComponent(e)}async addBackground(t){if(t.classList.contains(l.backgroundTypeToClassNameMap[l.BackgroundType.Grid])){let e,n,o,i,r;if("g"===t.tagName.toLowerCase()){if(2!==t.children.length)return void await this.addUnknownNode(t);const i=t.children[0],r=t.children[1];n=i.getAttribute("fill"),e=r.getAttribute("stroke"),o=r.getAttribute("stroke-width")}else n=t.getAttribute("fill"),e=t.getAttribute("stroke"),o=t.getAttribute("stroke-width");if(n??=a.Color4.transparent.toHexString(),!e)return void await this.addUnknownNode(t);for(const e of t.classList)if(e.startsWith(l.imageBackgroundGridSizeCSSPrefix)){const t=e.substring(l.imageBackgroundGridSizeCSSPrefix.length);i=parseFloat(t.replace(/p/g,"."))}o&&(r=parseFloat(o));const s=a.Color4.fromString(n);let c=a.Color4.fromString(e);t.classList.contains(l.imageBackgroundNonAutomaticSecondaryColorCSSClassName)||(c=void 0);const d=l.default.ofGrid(s,i,c,r);await this.addComponent(d)}else if("path"===t.tagName.toLowerCase()){const e=a.Color4.fromString(t.getAttribute("fill")??t.style.fill??"black"),n=new l.default(l.BackgroundType.SolidColor,e);await this.addComponent(n)}else await this.addUnknownNode(t)}getTransform(t,e,n){const o="data-highp-transform",i=t.getAttribute(o);let r;if(i)try{r=a.Mat33.fromCSSMatrix(i),e?.push(o)}catch(t){console.warn(`Unable to parse raw transform data, ${i}. Falling back to CSS data.`)}if(!r){n??=window.getComputedStyle(t);let o=n.transform;""!==o&&"none"!==o||(o=t.style.transform||"none");try{r=a.Mat33.fromCSSMatrix(t.style.transform)}catch(t){console.warn("matrix parse error",t),r=a.Mat33.fromCSSMatrix(o)}const i=t.getAttribute("x"),s=t.getAttribute("y");if(i||s){const t=parseFloat(i??"0"),n=parseFloat(s??"0");isNaN(t)||isNaN(n)||(e?.push("x","y"),r=r.rightMul(a.Mat33.translation(a.Vec2.of(t,n))))}}return r}makeText(t){const e=[];for(const n of t.childNodes)if(n.nodeType===Node.TEXT_NODE)e.push(n.nodeValue??"");else{if(n.nodeType!==Node.ELEMENT_NODE)throw new Error(`Unrecognized text child node: ${n}.`);{const t=n;if("tspan"!==t.tagName.toLowerCase())throw new Error(`Unrecognized text child element: ${t}`);e.push(this.makeText(t))}}0===e.length&&e.push("");const n=window.getComputedStyle(t),o=/^([-0-9.e]+)px/i;let i=o.exec(t.style.fontSize);!i&&"tspan"===t.tagName.toLowerCase()&&t.parentElement&&(i=o.exec(t.parentElement.style.fontSize)),i||(i=o.exec(n.fontSize));const r=["fontFamily","transform",...m];let s=12;i&&(r.push("fontSize"),s=parseFloat(i[1]));const l={size:s,fontFamily:n.fontFamily||t.style.fontFamily||"sans-serif",fontWeight:n.fontWeight||t.style.fontWeight||void 0,fontStyle:n.fontStyle||t.style.fontStyle||void 0,renderingStyle:this.getStyle(t,n)},c=[];let d=this.getTransform(t,c,n),h=u.TextTransformMode.ABSOLUTE_XY;const p=t.getAttribute("dx");p&&(h=u.TextTransformMode.RELATIVE_X_ABSOLUTE_Y,d=d.rightMul(a.Mat33.translation(a.Vec2.of(parseFloat(p),0))),c.push("dx"));const f=t.getAttribute("dy");f&&(h=h===u.TextTransformMode.RELATIVE_X_ABSOLUTE_Y?u.TextTransformMode.RELATIVE_XY:u.TextTransformMode.RELATIVE_Y_ABSOLUTE_X,d=d.rightMul(a.Mat33.translation(a.Vec2.of(0,parseFloat(f)))),c.push("dy"));const g=new u.default(e,d,l,h);return this.attachUnrecognisedAttrs(g,t,new Set(c),new Set(r)),g}async addText(t){try{const e=this.makeText(t);await this.addComponent(e)}catch(e){console.error("Invalid text object in node",t,". Continuing.... Error:",e),this.addUnknownNode(t)}}async addImage(t){const e=new Image;e.src=t.getAttribute("xlink:href")??t.href.baseVal,e.setAttribute("alt",t.getAttribute("aria-label")??"");try{const n=[],o=this.getTransform(t,n),i=await c.default.fromImage(e,o);this.attachUnrecognisedAttrs(i,t,new Set(n),new Set(["transform"])),await this.addComponent(i)}catch(e){console.error("Error loading image:",e,". Element: ",t,". Continuing..."),await this.addUnknownNode(t)}}async addUnknownNode(t){if(this.storeUnknown){const e=new p.default(t);await this.addComponent(e)}}async startGroup(t){let e=(t=t.cloneNode(!1)).id||`id-${this.encounteredIDs.length}`,n=0,o="";for(;this.encounteredIDs.includes(e+o);)n++,o="--"+n;e+=o,t.replaceChildren(),t.id=e;const i=new p.default(t);this.addComponent(i),this.containerGroupIDs.push(t.id),this.encounteredIDs.push(t.id)}async endGroup(){this.containerGroupIDs.pop()}async addComponent(t){this.containerGroupIDs.length>0&&t.attachLoadSaveData(e.svgLoaderAttributeContainerID,[...this.containerGroupIDs]),await(this.onAddComponent?.(t))}updateViewBox(t){const n=t.getAttribute("viewBox");if(this.rootViewBox||!n)return;const o=n.split(/[ \t\n,]+/),i=parseFloat(o[0]),r=parseFloat(o[1]),s=parseFloat(o[2]),l=parseFloat(o[3]);if(isNaN(i)||isNaN(r)||isNaN(s)||isNaN(l))return void console.warn(`node ${t} has an unparsable viewbox. Viewbox: ${n}. Match: ${o}.`);const c=t.classList.contains(e.svgLoaderAutoresizeClassName);this.rootViewBox=new a.Rect2(i,r,s,l),this.onDetermineExportRect?.(this.rootViewBox,{autoresize:c})}async updateSVGAttrs(t){this.storeUnknown&&await(this.onAddComponent?.(new h.default(this.getSourceAttrs(t))))}async visit(t){this.totalToProcess+=t.childElementCount;let e=!0;switch(t.tagName.toLowerCase()){case"g":t.classList.contains(l.imageBackgroundCSSClassName)?(await this.addBackground(t),e=!1):await this.startGroup(t);break;case"path":t.classList.contains(l.imageBackgroundCSSClassName)?await this.addBackground(t):await this.addPath(t);break;case"text":await this.addText(t),e=!1;break;case"image":await this.addImage(t),e=!1;break;case"svg":this.updateViewBox(t),this.updateSVGAttrs(t);break;case"style":await this.addUnknownNode(t);break;default:return this.disableUnknownObjectWarnings||(console.warn("Unknown SVG element,",t,t.tagName),t instanceof SVGElement||console.warn("Element",t,"is not an SVGElement!",this.storeUnknown?"Continuing anyway.":"Skipping.")),void await this.addUnknownNode(t)}if(e){for(const e of t.children)await this.visit(e);"g"===t.tagName.toLowerCase()&&await this.endGroup()}this.processedCount++,await(this.onProgress?.(this.processedCount,this.totalToProcess))}getSourceAttrs(t){return t.getAttributeNames().map((e=>[e,t.getAttribute(e)]))}async start(t,n,o=null){this.onAddComponent=t,this.onProgress=n,this.onDetermineExportRect=o,this.totalToProcess=this.source.childElementCount,this.processedCount=0,this.rootViewBox=null,await this.visit(this.source);this.rootViewBox||this.onDetermineExportRect?.(e.defaultSVGViewRect),this.onFinish?.()}static fromString(t,e=!1){const n=document.createElement("iframe");if(n.src="about:blank",n.setAttribute("sandbox","allow-same-origin"),n.setAttribute("csp","default-src 'about:blank'"),n.style.display="none",document.body.appendChild(n),!n.hasAttribute("sandbox"))throw n.remove(),new Error("SVG loading iframe is not sandboxed.");const o=n.contentWindow?.document??n.contentDocument;if(null==o)throw new Error("Unable to open a sandboxed iframe!");o.open(),o.write("\n\t\t\t<!DOCTYPE html>\n\t\t\t<html>\n\t\t\t\t<head>\n\t\t\t\t\t<title>SVG Loading Sandbox</title>\n\t\t\t\t\t<meta name='viewport' conent='width=device-width,initial-scale=1.0'/>\n\t\t\t\t\t<meta charset='utf-8'/>\n\t\t\t\t</head>\n\t\t\t\t<body style='font-size: 12px;'>\n\t\t\t\t\t<script>\n\t\t\t\t\t\tconsole.error('JavaScript should not be able to run here!');\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The SVG sandbox is broken! Please double-check the sandboxing setting.'\n\t\t\t\t\t\t);\n\t\t\t\t\t<\/script>\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t"),o.close();const i=o.createElementNS("http://www.w3.org/2000/svg","svg");let r,s;return i.innerHTML=t,o.body.appendChild(i),"boolean"==typeof e?(r=e,s=!1):(r=e.sanitize??!1,s=e.disableUnknownObjectWarnings??!1),new g(i,(()=>{i.remove(),n.remove()}),{sanitize:r,disableUnknownObjectWarnings:s})}}e.default=g},5155:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const a=n(3173);o=new WeakMap,i=new WeakMap,e.default=class{constructor(t,e,n){this.editor=t,this.announceRedoCallback=e,this.announceUndoCallback=n,o.set(this,void 0),i.set(this,void 0),this.maxUndoRedoStackSize=700,r(this,o,[],"f"),r(this,i,[],"f")}fireUpdateEvent(t,e){this.editor.notifier.dispatch(a.EditorEventType.UndoRedoStackUpdated,{kind:a.EditorEventType.UndoRedoStackUpdated,undoStackSize:s(this,o,"f").length,redoStackSize:s(this,i,"f").length,command:e,stackUpdateType:t})}push(t,e=!0){e&&t.apply(this.editor),s(this,o,"f").push(t);for(const t of s(this,i,"f"))t.onDrop(this.editor);if(r(this,i,[],"f"),s(this,o,"f").length>this.maxUndoRedoStackSize){const t=Math.ceil(this.maxUndoRedoStackSize/100);s(this,o,"f").splice(0,t).forEach((t=>t.onDrop(this.editor)))}this.fireUpdateEvent(a.UndoEventType.CommandDone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandDone,{kind:a.EditorEventType.CommandDone,command:t})}undo(){const t=s(this,o,"f").pop();if(t){s(this,i,"f").push(t);const e=t.unapply(this.editor);return this.announceUndoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandUndone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandUndone,{kind:a.EditorEventType.CommandUndone,command:t}),e}}redo(){const t=s(this,i,"f").pop();if(t){s(this,o,"f").push(t);const e=t.apply(this.editor);return this.announceRedoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandRedone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandDone,{kind:a.EditorEventType.CommandDone,command:t}),e}}get undoStackSize(){return s(this,o,"f").length}get redoStackSize(){return s(this,i,"f").length}}},5566:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Viewport=e.ViewportTransform=void 0;const l=a(n(2216)),c=n(5097);class d extends l.default{}e.ViewportTransform=d;class h{constructor(t){this.onTransformChangeCallback=t,this.resetTransform(c.Mat33.identity),this.screenRect=c.Rect2.empty}getTemporaryClone(){const t=new h((()=>{}));return t.transform=this.transform,t.inverseTransform=this.inverseTransform,t.screenRect=this.screenRect,t}updateScreenSize(t){this.screenRect=this.screenRect.resizedTo(t)}get visibleRect(){return this.screenRect.transformedBoundingBox(this.inverseTransform)}screenToCanvas(t){return this.inverseTransform.transformVec2(t)}canvasToScreen(t){return this.transform.transformVec2(t)}static transformBy(t){return new h.ViewportTransform(t)}resetTransform(t=c.Mat33.identity){const e=this.transform;this.transform=t,this.inverseTransform=t.inverse(),this.onTransformChangeCallback?.(e,t)}get screenToCanvasTransform(){return this.inverseTransform}get canvasToScreenTransform(){return this.transform}getScreenRectSize(){return this.screenRect.size}getResolution(){return this.getScreenRectSize()}getScaleFactor(){return this.transform.transformVec3(c.Vec3.unitX).magnitude()}getScaleFactorToNearestPowerOfTen(){return this.getScaleFactorToNearestPowerOf(10)}getScaleFactorToNearestPowerOf(t){const e=this.getScaleFactor();return Math.pow(t,Math.round(Math.log(e)/Math.log(t)))}static getGridSize(t){return 50/t}snapToGrid(t){const e=this.getScaleFactorToNearestPowerOf(2),n=t=>{const n=1/h.getGridSize(e);return Math.round(t*n)/n};return c.Vec2.of(n(t.x),n(t.y))}getSizeOfPixelOnCanvas(){return 1/this.getScaleFactor()}getRotationAngle(){return this.transform.transformVec3(c.Vec3.unitX).angle()}static roundPoint(t,e){const n=10**Math.floor(Math.log10(e)),o=t=>Math.round(t/n)*n;return"number"==typeof t?o(t):t.map(o)}roundPoint(t){return h.roundPoint(t,1/this.getScaleFactor())}static roundScaleRatio(t,e=1){if(Math.abs(t)<=1e-12)return 0;const n=10**Math.floor(Math.log10(Math.abs(t))),o=2**e;return t=Math.round(t/n*o)/o*n}computeZoomToTransform(t,e=!0,n=!0){let o=c.Mat33.identity;if(0===t.w||0===t.h){let o=Math.max(t.w,t.h);0===o&&(o=50,e=!1,n=!1),t=new c.Rect2(t.x,t.y,o,o)}if(isNaN(t.size.magnitude()))throw new Error(`${t.toString()} rectangle has NaN size! Cannot zoom to!`);const i=()=>{const t=this.visibleRect.transformedBoundingBox(o.inverse());return t.transformedBoundingBox(c.Mat33.scaling2D(.8,t.center))};let r=i();const s=r.w<t.w||r.h<t.h,a=t.maxDimension/r.maxDimension<1/3;if(s&&n||a&&e){const e=Math.max(t.w/r.w,t.h/r.h),n=c.Mat33.scaling2D(e,r.topLeft).inverse();o=o.rightMul(n)}if(r=i(),!r.containsRect(t)){const e=t.center.minus(r.center),n=c.Mat33.translation(e).inverse();o=o.rightMul(n)}return o.invertable()||(console.warn("Unable to zoom to ",t,"! Computed transform",o,"is singular."),o=c.Mat33.identity),o}zoomTo(t,e=!0,n=!0){const o=this.computeZoomToTransform(t,e,n);return new h.ViewportTransform(o)}}e.Viewport=h,h.ViewportTransform=(i=class extends d{constructor(t){super(),this.transform=t,o.set(this,void 0),r(this,o,t.inverse(),"f")}apply(t){const e=t.viewport;e.resetTransform(e.transform.rightMul(this.transform)),t.queueRerender()}unapply(t){const e=t.viewport;e.resetTransform(e.transform.rightMul(s(this,o,"f"))),t.queueRerender()}description(t,e){const n=[],o=t.viewport.visibleRect.center,i=this.transform.transformVec3(c.Vec2.unitX),r=this.transform.transformVec2(o),s=i.magnitude(),a=180/Math.PI*i.angle(),l=r.minus(o);s>1.2?n.push(e.zoomedIn):s<.8&&n.push(e.zoomedOut),Math.floor(Math.abs(a))>0&&n.push(e.rotatedBy(Math.round(a)));const d=1e-4;return l.x>d?n.push(e.movedLeft):l.x<-1e-4&&n.push(e.movedRight),l.y<-1e-4?n.push(e.movedDown):l.y>d&&n.push(e.movedUp),n.join("; ")}},o=new WeakMap,i),e.default=h},7783:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),n(9143);const s=r(n(5146));i(n(6209),e),e.default=s.default},2216:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Command=void 0;class n{onDrop(t){}static union(t,e){return new class extends n{apply(n){t.apply(n),e.apply(n)}unapply(n){e.unapply(n),t.unapply(n)}description(n,o){const i=t.description(n,o),r=e.description(n,o);return i===r?i:`${i}, ${r}`}}}}e.Command=n,n.empty=new class extends n{description(t,e){return""}apply(t){}unapply(t){}},e.default=n},1365:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(2944)),r=o(n(9721)),s=o(n(6669));class a extends s.default{constructor(t){super("duplicate"),this.toDuplicate=t,this.duplicates=t.map((t=>t.clone())),this.reverse=new r.default(this.duplicates)}apply(t){this.reverse.unapply(t)}unapply(t){this.reverse.apply(t)}onDrop(t){this.reverse.onDrop(t)}description(t,e){return 0===this.duplicates.length?e.duplicatedNoElements:e.duplicateAction((0,i.default)(e,this.duplicates)??e.elements,this.duplicates.length)}serializeToJSON(){return this.toDuplicate.map((t=>t.getId()))}}s.default.register("duplicate",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t)));return new a(n)})),e.default=a},9721:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(2944)),r=o(n(505)),s=o(n(6669));class a extends s.default{constructor(t){super("erase"),this.toRemove=t.map((t=>t)),this.applied=!1}apply(t){for(const e of this.toRemove){const n=t.image.findParent(e);n&&(n.remove(),t.image.onDestroyElement(e))}this.applied=!0,t.queueRerender()}unapply(t){for(const e of this.toRemove)t.image.findParent(e)||r.default.addElement(e).apply(t);this.applied=!1,t.queueRerender()}onDrop(t){if(this.applied)for(const e of this.toRemove)t.image.onDestroyElement(e)}description(t,e){if(0===this.toRemove.length)return e.erasedNoElements;const n=(0,i.default)(e,this.toRemove)??e.elements;return e.eraseAction(n,this.toRemove.length)}serializeToJSON(){return this.toRemove.map((t=>t.getId()))}}s.default.register("erase",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t))).filter((t=>null!==t));return new a(n)})),e.default=a},6669:function(t,e,n){"use strict";var o,i=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(2216));class l extends a.default{constructor(t){if(super(),o.set(this,void 0),!(t in l.deserializationCallbacks))throw new Error(`Command ${t} must have a registered deserialization callback. To do this, call SerializableCommand.register.`);i(this,o,t,"f")}serialize(){return{data:this.serializeToJSON(),commandType:r(this,o,"f")}}static deserialize(t,e){const n="string"==typeof t?JSON.parse(t):t,o=n.commandType;if(!(o in l.deserializationCallbacks))throw new Error(`Unrecognised command type ${o}!`);return l.deserializationCallbacks[o](n.data,e)}static register(t,e){l.deserializationCallbacks[t]=e}}o=new WeakMap,l.deserializationCallbacks={},e.default=l},8859:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(6669));class r extends i.default{constructor(t,e,n){super(t),this.component=n??null,this.componentID=e}resolveComponent(t){if(this.component)return;const e=t.lookupElement(this.componentID);if(!e)throw new Error(`Unable to resolve component with ID ${this.componentID}`);this.component=e}}e.default=r},2242:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(2216)),r=o(n(6669)),s=t=>{if(t instanceof r.default)return new class extends r.default{serializeToJSON(){return t.serialize()}apply(e){t.unapply(e)}unapply(e){t.unapply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}("inverse");return new class extends i.default{apply(e){t.unapply(e)}unapply(e){t.apply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}};r.default.register("inverse",((t,e)=>s(r.default.deserialize(t,e)))),e.default=s},7601:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.uniteCommands=e.invertCommand=e.SerializableCommand=e.Erase=e.Duplicate=e.Command=void 0;const i=o(n(2216));e.Command=i.default;const r=o(n(1365));e.Duplicate=r.default;const s=o(n(9721));e.Erase=s.default;const a=o(n(2242));e.invertCommand=a.default;const l=o(n(6669));e.SerializableCommand=l.default;const c=o(n(1456));e.uniteCommands=c.default},6985:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultCommandLocalization=void 0,e.defaultCommandLocalization={updatedViewport:"Transformed Viewport",transformedElements:t=>`Transformed ${t} element${1===t?"":"s"}`,resizeOutputCommand:t=>`Resized image to ${t.w}x${t.h}`,enabledAutoresizeOutputCommand:"Enabled output autoresize",disabledAutoresizeOutputCommand:"Disabled output autoresize",addElementAction:t=>`Added ${t}`,eraseAction:(t,e)=>`Erased ${e} ${t}`,duplicateAction:(t,e)=>`Duplicated ${e} ${t}`,unionOf:(t,e)=>`Union: ${e} ${t}`,inverseOf:t=>`Inverse of ${t}`,elements:"Elements",erasedNoElements:"Erased nothing",duplicatedNoElements:"Duplicated nothing",rotatedBy:t=>`Rotated by ${Math.abs(t)} degrees ${t<0?"clockwise":"counter-clockwise"}`,movedLeft:"Moved left",movedUp:"Moved up",movedDown:"Moved down",movedRight:"Moved right",zoomedOut:"Zoomed out",zoomedIn:"Zoomed in",selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`}},1456:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7129)),r=o(n(2216)),s=o(n(6669));class a extends r.default{constructor(t,e){super(),this.commands=t,this.applyChunkSize=e}apply(t){if(void 0===this.applyChunkSize){const e=this.commands.map((e=>e.apply(t)));return(0,i.default)(e)}return t.asyncApplyCommands(this.commands,this.applyChunkSize)}unapply(t){const e=[...this.commands];if(e.reverse(),void 0===this.applyChunkSize){const n=e.map((e=>e.unapply(t)));return(0,i.default)(n)}return t.asyncUnapplyCommands(e,this.applyChunkSize,!1)}onDrop(t){this.commands.forEach((e=>e.onDrop(t)))}description(t,e){const n=[];let o=null,i=0;for(const r of this.commands){const s=r.description(t,e);s!==o&&null!==o&&(n.push(e.unionOf(o,i)),o=null,i=0),i++,o??=s}return i>1?n.push(e.unionOf(o,i)):1===i&&n.push(o),n.join(", ")}}class l extends s.default{constructor(t,e){super("union"),this.commands=t,this.applyChunkSize=e,this.nonserializableCommand=new a(t,e)}serializeToJSON(){return this.serializedData?this.serializedData:{applyChunkSize:this.applyChunkSize,data:this.commands.map((t=>t.serialize()))}}apply(t){return this.serializedData=this.serializeToJSON(),this.nonserializableCommand.apply(t)}unapply(t){return this.nonserializableCommand.unapply(t)}onDrop(t){this.nonserializableCommand.onDrop(t)}description(t,e){return this.nonserializableCommand.description(t,e)}}const c=(t,e)=>{let n=!0;for(const e of t)if(!(e instanceof s.default)){n=!1;break}if(n){return new l(t,e)}return new a(t,e)};s.default.register("union",((t,e)=>{if("number"!=typeof t.data.length)throw new Error("Unions of commands must serialize to lists of serialization data.");const n=t.applyChunkSize;if("number"!=typeof n&&void 0!==n)throw new Error("serialized applyChunkSize is neither undefined nor a number.");const o=[];for(const n of t.data)o.push(s.default.deserialize(n,e));return c(o,n)})),e.default=c},2655:function(t,e,n){"use strict";var o,i=this&&this.__setFunctionName||function(t,e,n){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ComponentSizingMode=void 0;const s=r(n(6669)),a=r(n(505)),l=n(5097),c=r(n(8859));var d;!function(t){t[t.BoundingBox=0]="BoundingBox",t[t.FillScreen=1]="FillScreen",t[t.Anywhere=2]="Anywhere"}(d||(e.ComponentSizingMode=d={}));class h{constructor(t,e){if(this.componentKind=t,this.loadSaveData={},this.lastChangedTime=(new Date).getTime(),this.zIndex=void 0!==e?e:h.zIndexCounter++,this.id=`${(new Date).getTime()}-${Math.random()}`,void 0===h.deserializationCallbacks[t])throw new Error(`Component ${t} has not been registered using AbstractComponent.registerComponent`)}getId(){return this.id}static registerComponent(t,e){this.deserializationCallbacks[t]=e??null}attachLoadSaveData(t,e){this.loadSaveData[t]||(this.loadSaveData[t]=[]),this.loadSaveData[t].push(e)}getLoadSaveData(){return this.loadSaveData}getZIndex(){return this.zIndex}getBBox(){return this.contentBBox}getExactBBox(){return this.getBBox()}getSizingMode(){return d.BoundingBox}onAddToImage(t){}onRemoveFromImage(){}intersectsRect(t){if(t.containsRect(this.getExactBBox()))return!0;return t.getEdges().some((t=>this.intersects(t)))}transformBy(t){return new h.TransformElementCommand(t,this.getId(),this)}setZIndex(t){return new h.TransformElementCommand(l.Mat33.identity,this.getId(),this,t,this.getZIndex())}isSelectable(){return!0}isBackground(){return!1}getProportionalRenderingTime(){return 1}clone(){const t=this.createClone();for(const e in this.loadSaveData)for(const n of this.loadSaveData[e])t.attachLoadSaveData(e,n);return t}serialize(){const t=this.serializeToJSON();if(null===t)throw new Error(`${this} cannot be serialized.`);return{name:this.componentKind,zIndex:this.zIndex,id:this.id,loadSaveData:this.loadSaveData,data:t}}static isNotDeserializable(t){return"string"==typeof t&&(t=JSON.parse(t)),"object"!=typeof t||(!this.deserializationCallbacks[t?.name]||!t.data)}static deserialize(t){if("string"==typeof t&&(t=JSON.parse(t)),h.isNotDeserializable(t))throw new Error(`Element with data ${t} cannot be deserialized.`);const e=this.deserializationCallbacks[t.name](t.data);return e.zIndex=t.zIndex,e.id=t.id,e}}h.zIndexCounter=0,h.deserializationCallbacks={},h.transformElementCommandId="transform-element",h.TransformElementCommand=(i(o=class extends c.default{constructor(t,e,n,o,i){super(h.transformElementCommandId,e,n),this.affineTransfm=t,this.origZIndex=i,this.targetZIndex=o??h.zIndexCounter++,this.targetZIndex>=h.zIndexCounter&&(h.zIndexCounter=this.targetZIndex+1),n&&void 0===i&&(this.origZIndex=n.getZIndex())}resolveComponent(t){this.component||(super.resolveComponent(t),this.origZIndex??=this.component.getZIndex())}updateTransform(t,e){if(!this.component)throw new Error("this.component is undefined or null!");const n=t.image.findParent(this.component);let o=!1;n&&(n.remove(),o=!0),this.component.applyTransformation(e),this.component.lastChangedTime=(new Date).getTime(),o&&a.default.addElement(this.component).apply(t)}apply(t){this.resolveComponent(t.image),this.component.zIndex=this.targetZIndex,this.updateTransform(t,this.affineTransfm),t.queueRerender()}unapply(t){this.resolveComponent(t.image),this.component.zIndex=this.origZIndex,this.updateTransform(t,this.affineTransfm.inverse()),t.queueRerender()}description(t,e){return e.transformedElements(1)}serializeToJSON(){return{id:this.componentID,transfm:this.affineTransfm.toArray(),targetZIndex:this.targetZIndex,origZIndex:this.origZIndex}}},"TransformElementCommand"),s.default.register(h.transformElementCommandId,((t,e)=>{const n=e.image.lookupElement(t.id)??void 0,o=new l.Mat33(...t.transfm),i=t.targetZIndex,r=t.origZIndex??void 0;return new h.TransformElementCommand(o,t.id,n,i,r)})),o),e.default=h},1847:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.backgroundTypeToClassNameMap=e.imageBackgroundNonAutomaticSecondaryColorCSSClassName=e.imageBackgroundGridSizeCSSPrefix=e.imageBackgroundCSSClassName=e.BackgroundType=void 0;const a=n(505),l=n(5097),c=r(n(2655)),d=n(739),h=s(n(5566)),u=n(7444);var p;!function(t){t[t.SolidColor=0]="SolidColor",t[t.Grid=1]="Grid",t[t.None=2]="None"}(p||(e.BackgroundType=p={})),e.imageBackgroundCSSClassName="js-draw-image-background",e.imageBackgroundGridSizeCSSPrefix="js-draw-image-background-grid-",e.imageBackgroundNonAutomaticSecondaryColorCSSClassName="js-draw-image-background-non-automatic-secondary-color",e.backgroundTypeToClassNameMap={[p.Grid]:"js-draw-image-background-grid",[p.SolidColor]:e.imageBackgroundCSSClassName,[p.None]:""};class f extends c.default{constructor(t,e){super("image-background",0),this.backgroundType=t,this.mainColor=e,this.viewportSizeChangeListener=null,this.autoresizeChangedListener=null,this.fillsScreen=!1,this.gridSize=h.default.getGridSize(2),this.gridStrokeWidth=.7,this.secondaryColor=null,this.isRestylableComponent=!0,this.contentBBox=l.Rect2.empty}static ofGrid(t,e,n,o){const i=new f(p.Grid,t);return void 0!==e&&(i.gridSize=e),void 0!==n&&(i.secondaryColor=n),void 0!==o&&(i.gridStrokeWidth=o),i}getBackgroundType(){return this.backgroundType}getMainColor(){return this.mainColor}getSecondaryColor(){return this.secondaryColor}getGridSize(){return this.gridSize}getStyle(){let t=this.mainColor;return this.backgroundType===p.None&&(t=void 0),{color:t}}updateStyle(t){return(0,d.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){const n=t.color;n&&(this.mainColor=n,n.eq(l.Color4.transparent)&&this.backgroundType===p.SolidColor?this.backgroundType=p.None:this.backgroundType===p.None&&(this.backgroundType=p.SolidColor),e&&(e.image.queueRerenderOf(this),e.queueRerender()))}onAddToImage(t){this.viewportSizeChangeListener&&(console.warn("onAddToImage called when background is already in an image"),this.onRemoveFromImage()),this.viewportSizeChangeListener=t.notifier.on(a.EditorImageEventType.ExportViewportChanged,(()=>{this.recomputeBBox(t)})),this.autoresizeChangedListener=t.notifier.on(a.EditorImageEventType.AutoresizeModeChanged,(()=>{this.recomputeBBox(t)})),this.recomputeBBox(t)}onRemoveFromImage(){this.viewportSizeChangeListener?.remove(),this.autoresizeChangedListener?.remove(),this.viewportSizeChangeListener=null,this.autoresizeChangedListener=null}recomputeBBox(t){const e=t.getImportExportViewport().visibleRect;let n=!1;this.contentBBox.eq(e)||(this.contentBBox=e,n=!0);const o=t.getAutoresizeEnabled();o!==this.fillsScreen&&(this.fillsScreen=o,n=!0),n&&t.queueRerenderOf(this)}generateGridPath(t){const e=this.getFullBoundingBox(t),n=(t?.intersection(e)??e).grownBy(this.gridStrokeWidth/2),o=t=>Math.floor(t/this.gridSize)*this.gridSize,i=t=>Math.ceil(t/this.gridSize)*this.gridSize,r=i(n.y),s=o(n.y+n.h),a=i(n.x),c=o(n.x+n.w),d=[],h=(s-r)/this.gridSize,u=(c-a)/this.gridSize;if(h>1e3||u>1e3)return l.Path.empty;const p=l.Vec2.of(n.x,r);for(let t=r;t<=s;t+=this.gridSize)d.push({kind:l.PathCommandType.MoveTo,point:l.Vec2.of(n.x,t)}),d.push({kind:l.PathCommandType.LineTo,point:l.Vec2.of(n.x+n.w,t)});for(let t=a;t<=c;t+=this.gridSize)d.push({kind:l.PathCommandType.MoveTo,point:l.Vec2.of(t,n.y)}),d.push({kind:l.PathCommandType.LineTo,point:l.Vec2.of(t,n.y+n.h)});return new l.Path(p,d)}getFullBoundingBox(t){return(this.fillsScreen?t:this.contentBBox)??this.contentBBox}render(t,n){if(this.backgroundType===p.None)return;const o=!n;this.fillsScreen&&(n??=t.getVisibleRect());const i=this.backgroundType===p.Grid,r=this.getFullBoundingBox(n);if(t.startObject(r,i),this.backgroundType===p.SolidColor||this.backgroundType===p.Grid){const e=n?.intersection(r);e?t.fillRect(e,this.mainColor):o&&t.fillRect(r,this.mainColor)}if(this.backgroundType===p.Grid){let e=this.secondaryColor;e??=l.Color4.ofRGBA(1-this.mainColor.r,1-this.mainColor.g,1-this.mainColor.b,.2),0===this.mainColor.a&&(e=l.Color4.ofRGBA(.5,.5,.5,.2));const o={fill:l.Color4.transparent,stroke:{width:this.gridStrokeWidth,color:e}};t.drawPath((0,u.pathToRenderable)(this.generateGridPath(n),o))}const s=e.backgroundTypeToClassNameMap[this.backgroundType],a=[e.imageBackgroundCSSClassName];if(s!==e.imageBackgroundCSSClassName){a.push(s);const t=(0,l.toRoundedString)(this.gridSize).replace(/[.]/g,"p");a.push(e.imageBackgroundGridSizeCSSPrefix+t)}null!==this.secondaryColor&&a.push(e.imageBackgroundNonAutomaticSecondaryColorCSSClassName),t.endObject(this.getLoadSaveData(),a)}intersects(t){return this.contentBBox.getEdges().some((e=>e.intersects(t)))}isSelectable(){return!1}isBackground(){return!0}getSizingMode(){return this.fillsScreen?c.ComponentSizingMode.FillScreen:c.ComponentSizingMode.BoundingBox}serializeToJSON(){return{mainColor:this.mainColor.toHexString(),secondaryColor:this.secondaryColor?.toHexString(),backgroundType:this.backgroundType,gridSize:this.gridSize,gridStrokeWidth:this.gridStrokeWidth}}applyTransformation(t){}description(t){if(this.backgroundType===p.SolidColor)return t.filledBackgroundWithColor(this.mainColor.toString());if(this.backgroundType===p.None)return t.emptyBackground;if(this.backgroundType===p.Grid)return t.gridBackground;return this.backgroundType}createClone(){return new f(this.backgroundType,this.mainColor)}static deserializeFromJSON(t){if("string"==typeof t&&(t=JSON.parse(t)),"string"!=typeof t.mainColor)throw new Error("Error deserializing — mainColor must be of type string.");let e;const n=t.backgroundType;if(n!==p.None&&n!==p.Grid&&n!==p.SolidColor){return n}e=n;const o=l.Color4.fromHex(t.mainColor),i=t.secondaryColor?l.Color4.fromHex(t.secondaryColor):null,r=t.gridSize??void 0,s=t.gridStrokeWidth??void 0,a=new f(e,o);return a.secondaryColor=i,r&&(a.gridSize=r),s&&(a.gridStrokeWidth=s),a}}e.default=f,c.default.registerComponent("image-background",f.deserializeFromJSON)},7077:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(6585),s=o(n(2655));class a extends s.default{constructor(t){super("image-component"),this.image={...t,label:t.label??t.image.getAttribute("alt")??t.image.getAttribute("aria-label")??void 0};void 0===t.image.getAttribute("src")||t.image.complete||(t.image.onload=()=>this.recomputeBBox()),this.recomputeBBox()}getImageRect(){return new i.Rect2(0,0,this.image.image.width,this.image.image.height)}recomputeBBox(){this.contentBBox=this.getImageRect(),this.contentBBox=this.contentBBox.transformedBoundingBox(this.image.transform)}static async fromImage(t,e){let n,o,i;t.complete||await new Promise(((e,n)=>{t.onload=e,t.onerror=n,t.onabort=n})),"number"==typeof t.width&&"number"==typeof t.height&&0!==t.width&&0!==t.height?(n=t.width,o=t.height):(n=t.clientWidth,o=t.clientHeight);let r=t.src??"";if(r.startsWith("data:image/"))i=new Image,i.src=r,i.width=n,i.height=o;else{const e=document.createElement("canvas");e.width=n,e.height=o;e.getContext("2d").drawImage(t,0,0,e.width,e.height),r=e.toDataURL(),i=e}return i.setAttribute("alt",t.getAttribute("alt")??""),i.setAttribute("aria-label",t.getAttribute("aria-label")??""),new a({image:i,base64Url:r,transform:e})}render(t,e){t.startObject(this.contentBBox),t.drawImage(this.image),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return 10}intersects(t){const e=this.getImageRect().getEdges().map((t=>t.transformedBy(this.image.transform)));for(const n of e)if(n.intersects(t))return!0;return!1}applyTransformation(t){this.image.transform=t.rightMul(this.image.transform),this.recomputeBBox()}description(t){return this.image.label?t.imageNode(this.image.label):t.unlabeledImageNode}getAltText(){return this.image.label}getURL(){return this.image.base64Url}getTransformation(){return this.image.transform}createClone(){return new a({...this.image})}serializeToJSON(){return{src:this.image.base64Url,label:this.image.label,width:this.image.image.width,height:this.image.image.height,transform:this.image.transform.toArray()}}static deserializeFromJSON(t){if("string"!=typeof t.src)throw new Error(`${t} has invalid format! Expected src property.`);(0,r.assertIsNumberArray)(t.transform),(0,r.assertIsNumber)(t.width),(0,r.assertIsNumber)(t.height);const e=new Image;e.src=t.src,e.width=t.width,e.height=t.height;const n=new i.Mat33(...t.transform);return new a({image:e,base64Url:t.src,label:t.label,transform:n})}}e.default=a,s.default.registerComponent("image-component",a.deserializeFromJSON)},739:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.isRestylableComponent=e.createRestyleComponentCommand=void 0;const i=n(5097),r=o(n(6669)),s=o(n(8859)),a=n(2788),l=t=>{const e={};return t.color&&(e.color=t.color.toHexString()),t.textStyle&&(e.textStyle=(0,a.textStyleToJSON)(t.textStyle)),e},c=t=>({color:t.color?i.Color4.fromHex(t.color):void 0,textStyle:t.textStyle?(0,a.textStyleFromJSON)(t.textStyle):void 0});e.createRestyleComponentCommand=(t,e,n)=>new h(t,e,n.getId(),n);e.isRestylableComponent=t=>!!("getStyle"in t&&"updateStyle"in t&&"forceStyle"in t)&&!(!("isRestylableComponent"in t)||!t.isRestylableComponent);const d="default-restyle-element";class h extends s.default{constructor(t,e,n,o){super(d,n,o),this.originalStyle=t,this.newStyle=e}getComponent(t){this.resolveComponent(t.image);const e=this.component;if(!e||!e.forceStyle||!e.updateStyle)throw new Error("this.component is missing forceStyle and/or updateStyle methods!");return e}apply(t){this.getComponent(t).forceStyle(this.newStyle,t)}unapply(t){this.getComponent(t).forceStyle(this.originalStyle,t)}description(t,e){return e.restyledElement(this.getComponent(t).description(e))}serializeToJSON(){return{id:this.componentID,originalStyle:l(this.originalStyle),newStyle:l(this.newStyle)}}}r.default.register(d,((t,e)=>{const n=c(t.originalStyle),o=c(t.newStyle),i=t.id;if("string"!=typeof t.id)throw new Error(`json.id is of type ${typeof t.id}, not string.`);return new h(n,o,i)}))},2413:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=s(n(2001)),c=r(n(2655)),d="svg-global-attributes";class h extends c.default{constructor(t){super(d),this.contentBBox=a.Rect2.empty;const e=["viewBox","width","height"];this.attrs=t.filter((([t,n])=>!e.includes(t)))}render(t,e){if(t instanceof l.default)for(const[e,n]of this.attrs)t.setRootSVGAttribute(e,n)}intersects(t){return!1}applyTransformation(t){}isSelectable(){return!1}getSizingMode(){return c.ComponentSizingMode.Anywhere}createClone(){return new h(this.attrs)}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify(this.attrs)}static deserializeFromString(t){return new h([])}}e.default=h,c.default.registerComponent(d,h.deserializeFromString)},9964:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(2500),s=o(n(2655)),a=n(739),l=n(7444);class c extends s.default{constructor(t){super("stroke"),this.isRestylableComponent=!0,this.approximateRenderingTime=0,this.parts=[];for(const e of t){const t=(0,l.pathFromRenderable)(e),n=this.bboxForPart(t.bbox,e.style);this.contentBBox?this.contentBBox=this.contentBBox.union(n):this.contentBBox=n,this.parts.push({path:t,startPoint:t.startPoint,style:e.style,commands:t.parts}),this.approximateRenderingTime+=t.parts.length}this.contentBBox??=i.Rect2.empty}getStyle(){if(0===this.parts.length)return{};const t=this.parts[0];return void 0===t.style.stroke||0===t.style.stroke.width?{color:t.style.fill}:{color:t.style.stroke.color}}updateStyle(t){return(0,a.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){t.color&&(this.parts=this.parts.map((e=>{const n={...e.style,stroke:e.style.stroke?{...e.style.stroke}:void 0};return n.stroke&&n.stroke.width>0?n.stroke.color=t.color:n.fill=t.color,{path:e.path,startPoint:e.startPoint,commands:e.commands,style:n}})),e&&(e.image.queueRerenderOf(this),e.queueRerender()))}intersects(t){for(const e of this.parts){const n=e.style.stroke?.width,o=n?n/2:void 0;if(e.path.intersection(t,o).length>0)return!0}return!1}intersectsRect(t){if(!t.intersects(this.getBBox()))return!1;for(const e of this.parts){const n=t.grownBy(-(e.style.stroke?.width??0));if(0!==n.area)for(const t of e.path.startEndPoints())if(n.containsPoint(t))return!0}return super.intersectsRect(t)}render(t,e){t.startObject(this.getBBox());for(const n of this.parts){const o=this.bboxForPart(n.path.bbox,n.style);if(e){if(!o.intersects(e))continue;if((o.size.x>3*e.size.x||o.size.y>3*e.size.y)&&!n.path.roughlyIntersects(e,n.style.stroke?.width??0))continue}t.drawPath(n)}t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.approximateRenderingTime}bboxForPart(t,e){return e.stroke?t.grownBy(e.stroke.width/2):t}getExactBBox(){let t=null;for(const{path:e,style:n}of this.parts){const o=this.bboxForPart(e.getExactBBox(),n);t??=o,t=t.union(o)}return t??i.Rect2.empty}applyTransformation(t){this.contentBBox=i.Rect2.empty;let e=!0;this.parts=this.parts.map((n=>{const o=n.path.transformedBy(t),i={...n.style,stroke:n.style.stroke?{...n.style.stroke}:void 0};if(i.stroke){const e=t.getScaleFactor();i.stroke.width*=e}const r=this.bboxForPart(o.bbox,i);return e?(this.contentBBox=r,e=!1):this.contentBBox=this.contentBBox.union(r),{path:o,startPoint:o.startPoint,commands:o.parts,style:i}}))}getPath(){let t=null;for(const e of this.parts)t?t=t.union(e.path):t??=e.path;return t??i.Path.empty}description(t){return t.stroke}createClone(){return new c(this.parts)}serializeToJSON(){return this.parts.map((t=>({style:(0,r.styleToJSON)(t.style),path:t.path.serialize()})))}static deserializeFromJSON(t){if("string"==typeof t&&(t=JSON.parse(t)),"object"!=typeof t||"number"!=typeof t.length)throw new Error(`${t} is missing required field, parts, or parts is of the wrong type.`);const e=t.map((t=>{const e=(0,r.styleFromJSON)(t.style);return(0,l.pathToRenderable)(i.Path.fromString(t.path),e)}));return new c(e)}}e.default=c,s.default.registerComponent("stroke",c.deserializeFromJSON)},3167:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTransformMode=void 0;const i=n(5097),r=n(2788),s=o(n(2655)),a=n(739),l="text";var c;!function(t){t[t.ABSOLUTE_XY=0]="ABSOLUTE_XY",t[t.RELATIVE_XY=1]="RELATIVE_XY",t[t.RELATIVE_X_ABSOLUTE_Y=2]="RELATIVE_X_ABSOLUTE_Y",t[t.RELATIVE_Y_ABSOLUTE_X=3]="RELATIVE_Y_ABSOLUTE_X"}(c||(e.TextTransformMode=c={}));class d extends s.default{constructor(t,e,n,o=c.ABSOLUTE_XY){super(l),this.textObjects=t,this.transform=e,this.style=n,this.transformMode=o,this.isRestylableComponent=!0,this.recomputeBBox();!t.some((t=>"string"==typeof t))&&t.length>0&&(this.style=t[0].getTextStyle())}static applyTextStyles(t,e){const n=e.fontFamily.match(/\s/)?e.fontFamily.replace(/["]/g,'\\"'):e.fontFamily;t.font=[e.fontStyle??"",e.fontWeight??"",(e.size??12)+"px",`${n}`].join(" "),t.textAlign="left"}static estimateTextDimens(t,e){const n=t.length*e.size,o=e.size;return new i.Rect2(0,2*-o/3,n,o)}static getTextMetrics(t,e){if(d.textMeasuringCtx??=document.createElement("canvas").getContext("2d")??null,!d.textMeasuringCtx)return null;const n=d.textMeasuringCtx;return d.applyTextStyles(n,e),n.measureText(t)}static getTextDimens(t,e){const n=this.getTextMetrics(t,e);if(!n)return this.estimateTextDimens(t,e);const o=-n.actualBoundingBoxAscent,r=n.actualBoundingBoxAscent+n.actualBoundingBoxDescent;return new i.Rect2(0,o,n.width,r)}static getFontHeight(t){return t.size}computeUntransformedBBoxOfPart(t){return"string"==typeof t?d.getTextDimens(t,this.style):t.contentBBox}recomputeBBox(){let t=null;const e=new d.TextCursor(this.transform,this.style);for(const n of this.textObjects){const o=e.update(n),i=this.computeUntransformedBBoxOfPart(n).transformedBoundingBox(o);t??=i,t=t.union(i)}this.contentBBox=t??i.Rect2.empty}renderInternal(t){const e=new d.TextCursor(this.transform,this.style);for(const n of this.textObjects){const o=e.update(n);"string"==typeof n?t.drawText(n,o,this.style):(t.pushTransform(o),n.renderInternal(t),t.popTransform())}}render(t,e){t.startObject(this.contentBBox),this.renderInternal(t),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(t){const e=new d.TextCursor(this.transform,this.style);for(const n of this.textObjects){const o=e.update(n).inverse(),i=t.transformedBy(o);if("string"==typeof n){if(d.getTextDimens(n,this.style).getEdges().some((t=>null!==i.intersection(t))))return!0}else if(n.intersects(i))return!0}return!1}getStyle(){return{color:this.style.renderingStyle.fill,textStyle:{...this.style,renderingStyle:{...this.style.renderingStyle}}}}updateStyle(t){return(0,a.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){if(t.textStyle)this.style=(0,r.cloneTextStyle)(t.textStyle);else{if(!t.color)return;this.style={...this.style,renderingStyle:{...this.style.renderingStyle,fill:t.color}}}for(const n of this.textObjects)n instanceof d&&n.forceStyle(t,e);e&&(e.image.queueRerenderOf(this),e.queueRerender())}getTextStyle(){return(0,r.cloneTextStyle)(this.style)}getBaselinePos(){return this.transform.transformVec2(i.Vec2.zero)}getTransform(){return this.transform}applyTransformation(t){this.transform=t.rightMul(this.transform),this.recomputeBBox()}createClone(){const t=this.textObjects.map((t=>"string"==typeof t?t:t.createClone()));return new d(t,this.transform,this.style)}getText(){const t=[];for(const e of this.textObjects)"string"==typeof e?t.push(e):t.push(e.getText());return t.join("\n")}description(t){return t.text(this.getText())}serializeToJSON(){const t=(0,r.textStyleToJSON)(this.style);return{textObjects:this.textObjects.map((t=>"string"==typeof t?{text:t}:{json:t.serializeToJSON()})),transform:this.transform.toArray(),style:t}}static deserializeFromString(t){"string"==typeof t&&(t=JSON.parse(t));const e=(0,r.textStyleFromJSON)(t.style),n=t.textObjects.map((t=>null!==(t.text??null)?t.text:d.deserializeFromString(t.json)));if(t.transform=t.transform.filter((t=>"number"==typeof t)),9!==t.transform.length)throw new Error(`Unable to deserialize transform, ${t.transform}.`);const o=t.transform,s=new i.Mat33(...o);return new d(n,s,e)}static fromLines(t,e,n){let o=null;const r=[],s=Math.round(this.getFontHeight(n));let a=i.Vec2.zero;for(const e of t){o&&(a=a.plus(i.Vec2.unitY.times(s)));const t=new d([e],i.Mat33.translation(a),n);r.push(t),o=t}return new d(r,e,n)}}d.textMeasuringCtx=null,d.TextCursor=class{constructor(t=i.Mat33.identity,e){this.parentTransform=t,this.parentStyle=e,this.transform=i.Mat33.identity}update(t){let e,n=i.Mat33.identity,o=i.Mat33.identity;"string"==typeof t?e=d.getTextDimens(t,this.parentStyle):(o=t.transform,e=t.getBBox());const r="string"==typeof t?c.RELATIVE_XY:t.transformMode;if(r===c.RELATIVE_XY)n=this.transform.rightMul(n);else if(r===c.RELATIVE_X_ABSOLUTE_Y||r===c.RELATIVE_Y_ABSOLUTE_X){n=this.transform.mapEntries(((t,[e,n])=>{if(r===c.RELATIVE_X_ABSOLUTE_Y)return 1===e&&2===n?0:t;if(r===c.RELATIVE_Y_ABSOLUTE_X)return 0===e&&2===n?0:t;throw new Error("Unreachable")})).rightMul(n)}const s=i.Mat33.translation(i.Vec2.of(e.width,0));return this.transform=n.rightMul(o).rightMul(s),this.parentTransform.rightMul(n)}},e.default=d,s.default.registerComponent(l,(t=>d.deserializeFromString(t)))},9025:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=s(n(2001)),c=r(n(2655)),d="unknown-svg-object";class h extends c.default{constructor(t){super(d),this.svgObject=t,this.contentBBox=a.Rect2.of(t.getBoundingClientRect())}render(t,e){t instanceof l.default&&(t.startObject(this.contentBBox),t.drawSVGElem(this.svgObject),t.endObject(this.getLoadSaveData()))}intersects(t){return this.contentBBox.getEdges().some((e=>null!==e.intersection(t)))}applyTransformation(t){}isSelectable(){return!1}getSizingMode(){return c.ComponentSizingMode.Anywhere}createClone(){return new h(this.svgObject.cloneNode(!0))}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify({html:this.svgObject.outerHTML})}}e.default=h,c.default.registerComponent(d,null)},9274:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeArrowBuilder=void 0;const i=n(5097),r=o(n(9964));e.makeArrowBuilder=(t,e)=>new s(t,e);class s{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getLineWidth(){return Math.max(this.endPoint.width,this.startPoint.width)}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),o=e.minus(t).length(),s=Math.min(this.getLineWidth(),o/2),a=this.startPoint.width/2,l=this.endPoint.width/2,c=e.minus(n.times(s)),d=n.orthog(),h=d.times(a),u=d.times(l),p=new i.Path(c.minus(u),[{kind:i.PathCommandType.LineTo,point:t.minus(h)},{kind:i.PathCommandType.LineTo,point:t.plus(h)},{kind:i.PathCommandType.LineTo,point:c.plus(u)},{kind:i.PathCommandType.LineTo,point:c.plus(d.times(s).plus(u))},{kind:i.PathCommandType.LineTo,point:e.plus(n.times(l))},{kind:i.PathCommandType.LineTo,point:c.plus(d.times(-s).minus(u))},{kind:i.PathCommandType.LineTo,point:c.minus(u)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new r.default([{startPoint:p.startPoint,commands:p.parts,style:{fill:this.startPoint.color}}])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=s},7973:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedCircleBuilder=void 0;const i=n(5097),r=n(7444),s=o(n(5566)),a=o(n(9964));e.makeOutlinedCircleBuilder=(t,e)=>new l(t,e);class l{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=[],e=2*Math.PI/6,n=s.default.roundPoint(this.endPoint.width,5/this.viewport.getScaleFactor()),o=this.startPoint.pos.lerp(this.endPoint.pos,.5),l=this.endPoint.pos.minus(o).length()-n/2,c=o.plus(i.Vec2.of(l,0));for(let n=e;n<=2*Math.PI;n+=e){const r=i.Vec2.of(l*Math.cos(n),-l*Math.sin(n)).plus(o),s=1.141,a=i.Vec2.of(Math.cos(n-e/2),-Math.sin(n-e/2)).times(l*s).plus(o);t.push({kind:i.PathCommandType.QuadraticBezierTo,controlPoint:a,endPoint:r})}t.push({kind:i.PathCommandType.LineTo,point:c});const d=new i.Path(c,t).mapPoints((t=>this.viewport.roundPoint(t)));return new a.default([(0,r.pathToRenderable)(d,{fill:i.Color4.transparent,stroke:{width:n,color:this.endPoint.color}})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}},6951:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeFreehandLineBuilder=void 0;const i=n(5097),r=o(n(9964)),s=o(n(5566)),a=n(1003);e.makeFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),o=e.getSizeOfPixelOnCanvas();return new l(t,o,n,e)};class l{constructor(t,e,n,o){this.startPoint=t,this.minFitAllowed=e,this.viewport=o,this.isFirstSegment=!0,this.parts=[],this.widthAverageNumSamples=1,this.curveFitter=new a.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.averageWidth=t.width,this.bbox=new i.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:i.Color4.transparent,stroke:{color:this.startPoint.color,width:this.roundDistance(this.averageWidth)}}}previewCurrentPath(){const t=[...this.parts.slice(),...this.curveToPathCommands(this.curveFitter.preview())];return{startPoint:this.startPoint.pos,commands:t,style:this.getRenderingStyle()}}previewFullPath(){const t=this.previewCurrentPath();return t?[t]:null}previewStroke(){const t=this.previewFullPath();return t?new r.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.previewStroke()}getMinFit(){let t=Math.min(this.minFitAllowed,this.averageWidth/3);return t<1e-10&&(t=this.minFitAllowed),t}roundPoint(t){const e=this.getMinFit();return s.default.roundPoint(t,e)}roundDistance(t){const e=this.getMinFit();return s.default.roundPoint(t,e)}curveToPathCommands(t){if(!t){if(!this.isFirstSegment)return[];const t=s.default.roundPoint(this.averageWidth/10,Math.min(this.minFitAllowed,this.averageWidth/10)),e=this.roundPoint(this.startPoint.pos);return[{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(t,t)),endPoint:e.plus(i.Vec2.of(0,t))},{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(-t,t)),endPoint:e.plus(i.Vec2.of(-t,0))},{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(-t,-t)),endPoint:e.plus(i.Vec2.of(0,-t))},{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(i.Vec2.of(t,-t)),endPoint:e.plus(i.Vec2.of(t,0))}]}const e=[];return this.isFirstSegment&&e.push({kind:i.PathCommandType.MoveTo,point:this.roundPoint(t.startPoint)}),e.push({kind:i.PathCommandType.QuadraticBezierTo,controlPoint:this.roundPoint(t.controlPoint),endPoint:this.roundPoint(t.endPoint)}),e}addCurve(t){const e=this.curveToPathCommands(t);this.parts.push(...e),this.isFirstSegment&&(this.isFirstSegment=!1)}addPoint(t){this.curveFitter.addPoint(t),this.widthAverageNumSamples++,this.averageWidth=this.averageWidth*(this.widthAverageNumSamples-1)/this.widthAverageNumSamples+t.width/this.widthAverageNumSamples}}e.default=l},725:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeLineBuilder=void 0;const i=n(5097),r=n(7444),s=o(n(9964));e.makeLineBuilder=(t,e)=>new a(t,e);class a{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),o=this.startPoint.width/2,a=this.endPoint.width/2,l=n.orthog(),c=l.times(o),d=l.times(a),h=t.minus(c),u=new i.Path(h,[{kind:i.PathCommandType.LineTo,point:t.plus(c)},{kind:i.PathCommandType.LineTo,point:e.plus(d)},{kind:i.PathCommandType.LineTo,point:e.minus(d)},{kind:i.PathCommandType.LineTo,point:t.minus(c)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new s.default([(0,r.pathToRenderable)(u,{fill:this.startPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=a},823:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makePressureSensitiveFreehandLineBuilder=void 0;const i=n(4232),r=n(5097),s=o(n(9964)),a=o(n(5566)),l=n(1003);e.makePressureSensitiveFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),o=e.getSizeOfPixelOnCanvas();return new c(t,o,n,e)};class c{constructor(t,e,n,o){this.startPoint=t,this.minFitAllowed=e,this.viewport=o,this.isFirstSegment=!0,this.pathStartConnector=null,this.mostRecentConnector=null,this.lastUpperBezier=null,this.lastLowerBezier=null,this.parts=[],this.upperSegments=[],this.lowerSegments=[],this.curveFitter=new l.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.curveStartWidth=t.width,this.bbox=new r.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:this.startPoint.color??null}}previewCurrentPath(){const t=this.upperSegments.slice(),e=this.lowerSegments.slice();let n,o;const i=this.curveFitter.preview();if(i){const{upperCurveCommand:r,lowerToUpperConnector:s,upperToLowerConnector:a,lowerCurveCommand:l}=this.segmentToPath(i);t.push(r),e.push(l),n=s,o=this.pathStartConnector??a}else{if(null===this.mostRecentConnector||null===this.pathStartConnector)return null;n=this.mostRecentConnector,o=this.pathStartConnector}let s;const a=e[e.length-1];return s=a.kind===r.PathCommandType.LineTo||a.kind===r.PathCommandType.MoveTo?a.point:a.endPoint,{startPoint:s,commands:[n,...t.reverse(),o,...e],style:this.getRenderingStyle()}}previewFullPath(){const t=this.previewCurrentPath();return t?[...this.parts,t]:null}previewStroke(){const t=this.previewFullPath();return t?new s.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.isFirstSegment&&this.addCurve(null),this.previewStroke()}roundPoint(t){let e=Math.min(this.minFitAllowed,this.curveStartWidth/3);return e<1e-10&&(e=this.minFitAllowed),a.default.roundPoint(t,e)}shouldStartNewSegment(t,e){if(!this.lastLowerBezier||!this.lastUpperBezier)return!1;const n=(t,e)=>{const n=t.intersects(e);if(!n||0===n.length)return null;const o=n[0],i=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(o);if(!i)throw new Error(`Incorrect format returned by .intersects: ${n} should be array of "number/number"!`);const s=parseFloat(i[1]);return r.Vec2.ofXY(t.get(s))},o=t=>r.Vec2.ofXY(t.points[2]).minus(r.Vec2.ofXY(t.points[1])).normalized(),i=t=>r.Vec2.ofXY(t.points[1]).minus(r.Vec2.ofXY(t.points[0])).normalized();if(i(e).dot(o(this.lastUpperBezier))<.3||i(t).dot(o(this.lastLowerBezier))<.3||i(e).dot(o(e))<0||i(t).dot(o(t))<0)return!0;const s=n(t,this.lastUpperBezier),a=n(e,this.lastLowerBezier);return!(!s&&!a)}addCurve(t){if(!t){if(!this.isFirstSegment)return;const t=a.default.roundPoint(this.startPoint.width/2.2,Math.min(this.minFitAllowed,this.startPoint.width/4)),e=this.roundPoint(this.startPoint.pos),n=this.startPoint.pos.plus(r.Vec2.of(t,0));return this.lowerSegments.push({kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,t)),endPoint:e.plus(r.Vec2.of(0,t))},{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,t)),endPoint:e.plus(r.Vec2.of(-t,0))},{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,-t)),endPoint:e.plus(r.Vec2.of(0,-t))},{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,-t)),endPoint:e.plus(r.Vec2.of(t,0))}),this.pathStartConnector={kind:r.PathCommandType.LineTo,point:n},void(this.mostRecentConnector=this.pathStartConnector)}const{upperCurveCommand:e,lowerToUpperConnector:n,upperToLowerConnector:o,lowerCurveCommand:i,lowerCurve:s,upperCurve:l}=this.segmentToPath(t),c=this.shouldStartNewSegment(s,l);if(c){const t=this.previewCurrentPath();t&&(this.parts.push(t),this.upperSegments=[],this.lowerSegments=[])}(this.isFirstSegment||c)&&(this.pathStartConnector=o,this.isFirstSegment=!1),this.mostRecentConnector=n,this.lowerSegments.push(i),this.upperSegments.push(e),this.lastLowerBezier=s,this.lastUpperBezier=l,this.curveStartWidth=t.startWidth}segmentToPath(t){const e=new i.Bezier(t.startPoint.xy,t.controlPoint.xy,t.endPoint.xy);let n=r.Vec2.ofXY(e.normal(0)).normalized(),o=r.Vec2.ofXY(e.normal(1)).normalized();n=n.times(t.startWidth/2),o=o.times(t.endWidth/2),isFinite(n.magnitude())||(console.error("Warning: startVec is NaN or ∞",n,o,t),n=o);const s=t.startPoint,a=t.endPoint,l=t.controlPoint;let c=e.project(l.xy).t;c||(c=s.minus(l).magnitudeSquared()<a.minus(l).magnitudeSquared()?.1:.9);const d=c,h=r.Vec2.ofXY(e.normal(d)).normalized().times(t.startWidth/2*d+t.endWidth/2*(1-d)),u=this.roundPoint(s.plus(n)),p=this.roundPoint(l.plus(h)),f=this.roundPoint(a.plus(o)),m=this.roundPoint(l.minus(h)),g=this.roundPoint(a.minus(o)),b=this.roundPoint(s.minus(n)),y={kind:r.PathCommandType.QuadraticBezierTo,controlPoint:p,endPoint:f},v={kind:r.PathCommandType.LineTo,point:u},w={kind:r.PathCommandType.LineTo,point:g};return{upperCurveCommand:{kind:r.PathCommandType.QuadraticBezierTo,controlPoint:m,endPoint:b},upperToLowerConnector:v,lowerToUpperConnector:w,lowerCurveCommand:y,upperCurve:new i.Bezier(g,m,b),lowerCurve:new i.Bezier(u,p,f)}}addPoint(t){this.curveFitter.addPoint(t)}}e.default=c},4666:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedRectangleBuilder=e.makeFilledRectangleBuilder=void 0;const i=n(5097),r=n(7444),s=o(n(9964));e.makeFilledRectangleBuilder=(t,e)=>new a(t,!0,e);e.makeOutlinedRectangleBuilder=(t,e)=>new a(t,!1,e);class a{constructor(t,e,n){this.startPoint=t,this.filled=e,this.viewport=n,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.viewport.getRotationAngle(),e=i.Mat33.zRotation(-t),n=e.inverse().transformVec2(this.startPoint.pos),o=e.inverse().transformVec2(this.endPoint.pos),a=i.Rect2.fromCorners(n,o),l=i.Path.fromRect(a,this.filled?null:this.endPoint.width).transformedBy(e).mapPoints((t=>this.viewport.roundPoint(t)));return new s.default([(0,r.pathToRenderable)(l,{fill:this.endPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=a},1024:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1576:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ImageComponent=e.BackgroundComponentBackgroundType=e.BackgroundComponent=e.StrokeComponent=e.Text=e.TextComponent=e.isRestylableComponent=e.createRestyleComponentCommand=e.Stroke=e.AbstractComponent=e.StrokeSmoother=e.makeOutlinedCircleBuilder=e.makePressureSensitiveFreehandLineBuilder=e.makeFreehandLineBuilder=void 0,r(n(1024),e);var l=n(6951);Object.defineProperty(e,"makeFreehandLineBuilder",{enumerable:!0,get:function(){return l.makeFreehandLineBuilder}});var c=n(823);Object.defineProperty(e,"makePressureSensitiveFreehandLineBuilder",{enumerable:!0,get:function(){return c.makePressureSensitiveFreehandLineBuilder}});var d=n(7973);Object.defineProperty(e,"makeOutlinedCircleBuilder",{enumerable:!0,get:function(){return d.makeOutlinedCircleBuilder}});var h=n(1003);Object.defineProperty(e,"StrokeSmoother",{enumerable:!0,get:function(){return a(h).default}}),r(n(2655),e);var u=n(2655);Object.defineProperty(e,"AbstractComponent",{enumerable:!0,get:function(){return a(u).default}});const p=a(n(9964));e.Stroke=p.default,e.StrokeComponent=p.default;const f=a(n(3167));e.TextComponent=f.default,e.Text=f.default;const m=a(n(7077));e.ImageComponent=m.default;const g=n(739);Object.defineProperty(e,"createRestyleComponentCommand",{enumerable:!0,get:function(){return g.createRestyleComponentCommand}}),Object.defineProperty(e,"isRestylableComponent",{enumerable:!0,get:function(){return g.isRestylableComponent}});const b=s(n(1847));e.BackgroundComponent=b.default,Object.defineProperty(e,"BackgroundComponentBackgroundType",{enumerable:!0,get:function(){return b.BackgroundType}})},7708:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultComponentLocalization=void 0,e.defaultComponentLocalization={unlabeledImageNode:"Unlabeled image node",stroke:"Stroke",svgObject:"SVG Object",emptyBackground:"Empty background",gridBackground:"Grid background",filledBackgroundWithColor:t=>`Filled background (${t})`,text:t=>`Text object: ${t}`,imageNode:t=>`Image: ${t}`,restyledElement:t=>`Restyled ${t}`}},1003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StrokeSmoother=void 0;const o=n(5097);class i{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.maxFitAllowed=n,this.onCurveAdded=i,this.isFirstSegment=!0,this.lastExitingVec=null,this.currentCurve=null,this.lastPoint=this.startPoint,this.buffer=[this.startPoint.pos],this.momentum=o.Vec2.zero,this.currentCurve=null,this.curveStartWidth=t.width,this.bbox=new o.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}preview(){return this.currentCurve?this.currentSegmentToPath():null}approxCurrentCurveLength(){if(!this.currentCurve)return 0;const t=this.currentCurve.p0,e=this.currentCurve.p1,n=this.currentCurve.p2;return t.minus(e).length()+n.minus(e).length()}finalizeCurrentCurve(){if(!this.currentCurve)return;this.onCurveAdded(this.currentSegmentToPath());const t=this.buffer[this.buffer.length-1];this.lastExitingVec=this.currentCurve.p2.minus(this.currentCurve.p1),console.assert(0!==this.lastExitingVec.magnitude(),"lastExitingVec has zero length!"),this.buffer=[this.buffer[this.buffer.length-2],t],this.currentCurve=null,this.isFirstSegment=!1}currentSegmentToPath(){if(null==this.currentCurve)throw new Error("Invalid State: currentCurve is null!");const t=this.currentCurve.normal(0).normalized();if(!isFinite(t.magnitude()))throw new Error(`startVec(${t}) is NaN or ∞`);const e=this.currentCurve.at(0),n=this.currentCurve.at(1);return{startPoint:e,controlPoint:this.currentCurve.p1,endPoint:n,startWidth:this.curveStartWidth,endWidth:this.curveEndWidth}}computeExitingVec(){return this.momentum.normalized().times(this.lastPoint.width/2)}addPoint(t){if(this.lastPoint){const e=1e-10,n=t.time-this.lastPoint.time;if(t.pos.eq(this.lastPoint.pos,e)||0===n)return;if(isNaN(t.pos.magnitude()))return void console.warn("Discarding NaN point.",t);const o=Math.min(this.lastPoint.width,t.width)/3;if(this.startPoint.pos.minus(t.pos).magnitude()<o&&this.isFirstSegment)return;const i=n/1e3,r=t.pos.minus(this.lastPoint.pos).times(1/i);this.momentum=r}const e=this.lastPoint??t;this.lastPoint=t,this.buffer.push(t.pos);const n=t.width,i=this.curveEndWidth;if(this.curveEndWidth=n,this.bbox=this.bbox.grownToPoint(t.pos,n),null===this.currentCurve){const r=e.pos,s=e.pos.plus(this.lastExitingVec??o.Vec2.unitX),a=t.pos;this.currentCurve=new o.QuadraticBezier(r,s,a),console.assert(!isNaN(r.magnitude())&&!isNaN(s.magnitude())&&!isNaN(a.magnitude()),"Expected !NaN"),this.isFirstSegment?this.curveStartWidth=(this.curveStartWidth+n)/2:this.curveStartWidth=i}let r=this.lastExitingVec;if(!r){let t=Math.ceil(this.buffer.length/2);(0===t||t>=this.buffer.length)&&(t=this.buffer.length-1),r=this.buffer[t].minus(this.buffer[0])}let s=this.computeExitingVec();const a=this.buffer[0],l=t.pos,c=l.minus(a).magnitude(),d=2.4*c;if(0===d||0===s.magnitude()||!isFinite(s.magnitude()))return;console.assert(isFinite(r.magnitude()),"Pre-normalized enteringVec has NaN or ∞ magnitude!"),r=r.normalized(),s=s.normalized(),console.assert(isFinite(r.magnitude()),"Normalized enteringVec has NaN or ∞ magnitude!");const h=new o.LineSegment2(a,a.plus(r.times(d))),u=new o.LineSegment2(l.minus(s.times(d)),l).intersection(h);let p=null;u&&(p=u.point),(!p||a.eq(p)||l.eq(p))&&(p=a.plus(r.times(c/4))),console.assert(!a.eq(p,1e-11),"Start and control points are equal!"),console.assert(!p.eq(l,1e-11),"Control and end points are equal!");const f=this.currentCurve;this.currentCurve=new o.QuadraticBezier(a,p,l),isNaN(this.currentCurve.normal(0).magnitude())&&(console.error("NaN normal at 0. Curve:",this.currentCurve),this.currentCurve=f);const m=t=>{const e=Math.min(Math.max(Math.min(this.curveStartWidth,this.curveEndWidth)/4,this.minFitAllowed),this.maxFitAllowed),n=e;let o=0;for(const i of this.buffer){let r=t.approximateDistance(i);if(r>e&&(r=t.distance(i),o+=Math.max(0,r-e),o>n))return!1}return!0};return this.buffer.length>3&&this.approxCurrentCurveLength()>this.curveStartWidth/2&&!m(this.currentCurve)?(this.currentCurve=f,this.curveEndWidth=i,this.lastPoint=e,void this.finalizeCurrentCurve()):void 0}}e.StrokeSmoother=i,e.default=i},2944:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{if(0===e.length)return null;const n=e[0].description(t);for(const o of e)if(o.description(t)!==n)return null;return n}},9784:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=document.createElement("div"),{remove:o}=t.createHTMLOverlay(n);n.classList.add("dialog-container","about-dialog-container");const i=document.createElement("dialog"),r=document.createElement("h1");r.innerText=t.localization.about,r.setAttribute("autofocus","true");const s=document.createElement("button");s.innerText=t.localization.closeDialog,s.classList.add("close-button"),s.onclick=()=>o(),n.onclick=t=>{t.target===n&&o()};const a=document.createElement("div");a.classList.add("about-entry-container"),a.onwheel=t=>t.stopPropagation();for(const t of e){const e=document.createElement(t.minimized?"details":"div");e.classList.add("about-entry");const n=document.createElement(t.minimized?"summary":"h2");if("string"==typeof t.heading)n.innerText=t.heading;else{const e=document.createElement("a");e.href=t.heading.href.replace(/^javascript:/i,""),e.text=t.heading.text,n.appendChild(e)}if(e.appendChild(n),t.text){const n=document.createElement("div");n.innerText=t.text,e.appendChild(n)}a.appendChild(e)}return i.replaceChildren(r,a,s),n.replaceChildren(i),i.show(),{close:()=>{o()}}}},505:function(t,e,n){"use strict";var o,i,r=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),s=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return s(e,t),e},l=this&&this.__setFunctionName||function(t,e,n){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RootImageNode=e.ImageNode=e.EditorImageEventType=e.sortLeavesByZIndex=void 0;const d=c(n(5566)),h=a(n(2655)),u=n(5097),p=c(n(6669)),f=c(n(1785)),m=n(6585),g=c(n(2216));var b;e.sortLeavesByZIndex=t=>{t.sort(((t,e)=>t.getContent().getZIndex()-e.getContent().getZIndex()))},function(t){t[t.ExportViewportChanged=0]="ExportViewportChanged",t[t.AutoresizeModeChanged=1]="AutoresizeModeChanged"}(b||(e.EditorImageEventType=b={}));class y{constructor(){this.componentCount=0,this.settingExportRect=!1,this.root=new w,this.background=new w,this.componentsById={},this.notifier=new f.default,this.importExportViewport=new d.default((()=>{this.onExportViewportChanged()})),this.importExportViewport.updateScreenSize(u.Vec2.of(500,500)),this.shouldAutoresizeExportViewport=!1}getBackgroundComponents(){const t=[],n=this.background.getLeaves();(0,e.sortLeavesByZIndex)(n);for(const e of n){const n=e.getContent();n&&t.push(n)}return t}findParent(t){return this.background.getChildWithContent(t)??this.root.getChildWithContent(t)}queueRerenderOf(t){const e=this.findParent(t);e&&(e.remove(),this.addElementDirectly(t))}renderWithCache(t,e,n){this.background.render(t,n.visibleRect),e.render(t,this.root,n)}render(t,e){this.background.render(t,e?.visibleRect),this.root.render(t,e?.visibleRect)}async renderAllAsync(t,e){return!!await this.background.renderAllAsync(t,e)&&await this.root.renderAllAsync(t,e)}renderAll(t){this.render(t,null)}getAllElements(){const t=this.root.getLeaves();return(0,e.sortLeavesByZIndex)(t),t.map((t=>t.getContent()))}estimateNumElements(){return this.componentCount}getElementsIntersectingRegion(t,n=!1){let o=this.root.getLeavesIntersectingRegion(t);return n&&(o=o.concat(this.background.getLeavesIntersectingRegion(t))),(0,e.sortLeavesByZIndex)(o),o.map((t=>t.getContent()))}onDestroyElement(t){this.componentCount--,delete this.componentsById[t.getId()],this.autoresizeExportViewport()}onElementAdded(t){this.componentCount++,this.componentsById[t.getId()]=t,this.autoresizeExportViewport()}lookupElement(t){return this.componentsById[t]??null}addElementDirectly(t){t.onAddToImage(this);const e=(t.isBackground()?this.background:this.root).addLeaf(t);return this.onElementAdded(t),e}removeElementDirectly(t){const e=this.findParent(t);return e?.remove(),!!e&&(this.onDestroyElement(t),!0)}static addElement(t,e=!1){return new y.AddElementCommand(t,e)}addElement(t,e){return y.addElement(t,e)}getImportExportViewport(){return this.importExportViewport}getImportExportRect(){return this.getImportExportViewport().visibleRect}setImportExportRect(t){return y.SetImportExportRectCommand.of(this,t,!1)}getAutoresizeEnabled(){return this.shouldAutoresizeExportViewport}setAutoresizeEnabled(t){if(t===this.shouldAutoresizeExportViewport)return g.default.empty;const e=this.root.getBBox();return y.SetImportExportRectCommand.of(this,e,t)}setAutoresizeEnabledDirectly(t){t!==this.shouldAutoresizeExportViewport&&(this.shouldAutoresizeExportViewport=t,this.notifier.dispatch(b.AutoresizeModeChanged,{image:this}))}autoresizeExportViewport(){this.shouldAutoresizeExportViewport&&this.setExportRectDirectly(this.root.getBBox())}setExportRectDirectly(t){const e=this.getImportExportViewport(),n=e.getScreenRectSize(),o=e.canvasToScreenTransform,i=u.Mat33.translation(t.topLeft.times(-1));return(!n.eq(t.size)||!o.eq(i))&&(this.settingExportRect=!0,e.updateScreenSize(t.size),e.resetTransform(i),this.settingExportRect=!1,this.onExportViewportChanged(),!0)}onExportViewportChanged(){this.settingExportRect||this.notifier.dispatch(b.ExportViewportChanged,{image:this})}}y.AddElementCommand=(l(o=class extends p.default{constructor(t,e=!1){if(super("add-element"),this.element=t,this.applyByFlattening=e,this.serializedElem=null,this.serializedElem=null,isNaN(t.getBBox().area))throw new Error("Elements in the image cannot have NaN bounding boxes")}apply(t){t.image.addElementDirectly(this.element),this.applyByFlattening?(this.applyByFlattening=!1,t.display.flatten()):t.queueRerender()}unapply(t){t.image.removeElementDirectly(this.element),t.queueRerender()}description(t,e){return e.addElementAction(this.element.description(e))}serializeToJSON(){return{elemData:this.serializedElem??this.element.serialize()}}},"AddElementCommand"),p.default.register("add-element",((t,e)=>{const n=t.elemData.id,o=e.image.lookupElement(n)??h.default.deserialize(t.elemData),i=new y.AddElementCommand(o);return i.serializedElem=t.elemData,i})),o),y.SetImportExportRectCommand=(l(i=class extends p.default{constructor(t,e,n,o,i){super(y.SetImportExportRectCommand.commandId),this.originalSize=t,this.originalTransform=e,this.originalAutoresize=n,this.newExportRect=o,this.newAutoresize=i}static of(t,e,n){const o=t.getImportExportViewport(),i=o.visibleRect.size,r=o.canvasToScreenTransform,s=t.getAutoresizeEnabled();return new y.SetImportExportRectCommand(i,r,s,e,n)}apply(t){t.image.setAutoresizeEnabledDirectly(this.newAutoresize),t.image.setExportRectDirectly(this.newExportRect),t.queueRerender()}unapply(t){const e=t.image.getImportExportViewport();t.image.setAutoresizeEnabledDirectly(this.originalAutoresize),e.updateScreenSize(this.originalSize),e.resetTransform(this.originalTransform),t.queueRerender()}description(t,e){return this.newAutoresize!==this.originalAutoresize?this.newAutoresize?e.enabledAutoresizeOutputCommand:e.disabledAutoresizeOutputCommand:e.resizeOutputCommand(this.newExportRect)}serializeToJSON(){return{originalSize:this.originalSize.xy,originalTransform:this.originalTransform.toArray(),newRegion:{x:this.newExportRect.x,y:this.newExportRect.y,w:this.newExportRect.w,h:this.newExportRect.h},autoresize:this.newAutoresize,originalAutoresize:this.originalAutoresize}}},"SetImportExportRectCommand"),i.commandId="set-import-export-rect",(()=>{const t=i.commandId;p.default.register(t,((t,e)=>{(0,m.assertIsNumber)(t.originalSize.x),(0,m.assertIsNumber)(t.originalSize.y),(0,m.assertIsNumberArray)(t.originalTransform),(0,m.assertIsNumberArray)([t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h]),(0,m.assertIsBoolean)(t.autoresize??!1),(0,m.assertIsBoolean)(t.originalAutoresize??!1);const n=u.Vec2.ofXY(t.originalSize),o=new u.Mat33(...t.originalTransform),i=new u.Rect2(t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h),r=t.autoresize??!1,s=t.originalAutoresize??!1;return new y.SetImportExportRectCommand(n,o,s,i,r)}))})(),i),e.default=y;class v{constructor(t=null){this.parent=t,this.targetChildCount=30,this.children=[],this.bbox=u.Rect2.empty,this.content=null,this.id=v.idCounter++}getId(){return this.id}onContentChange(){this.id=v.idCounter++}getContent(){return this.content}getParent(){return this.parent}getChildrenIntersectingRegion(t,e){return this.children.filter((n=>{const o=n.getBBox();return!e?.(o)&&o.intersects(t)}))}getChildrenOrSelfIntersectingRegion(t){return this.content?[this]:this.getChildrenIntersectingRegion(t)}getLeavesIntersectingRegion(t,e){const n=[],o=[];for(o.push(this);o.length>0;){const i=o.pop();null!==i.content&&n.push(i),o.push(...i.getChildrenIntersectingRegion(t,e))}return n}getChildWithContent(t){const e=this.getLeavesIntersectingRegion(t.getBBox());for(const n of e)if(n.getContent()===t)return n;return null}getLeaves(){if(this.content)return[this];const t=[];for(const e of this.children)t.push(...e.getLeaves());return t}addLeaf(t){if(this.onContentChange(),null===this.content&&0===this.children.length)return this.content=t,this.recomputeBBox(!0),this;if(null!==this.content){console.assert(0===this.children.length);const t=new v(this);t.content=this.content,this.content=null,this.children.push(t),t.recomputeBBox(!1)}const e=t.getBBox();if(e.containsRect(this.getBBox())){const e=new v(this);if(this.children.length<this.targetChildCount)this.children.push(e);else{const t=new v(this);t.children=this.children,this.children=[e,t],t.recomputeBBox(!0),t.updateParents()}return e.addLeaf(t)}const n=this.children.filter((t=>t.getBBox().containsRect(e)));if(n.length>0&&this.children.length>=this.targetChildCount){n.sort(((t,e)=>t.getBBox().area-e.getBBox().area));const e=n[0].addLeaf(t);return e.rebalance(),e}const o=v.createLeafNode(this,t);return this.children.push(o),o.recomputeBBox(!0),o}static createLeafNode(t,e){const n=new v(t);return n.content=e,n}getBBox(){return this.bbox}recomputeBBox(t){const e=this.bbox;null!==this.content?this.bbox=this.content.getBBox():this.bbox=u.Rect2.union(...this.children.map((t=>t.getBBox()))),t&&!e.eq(this.bbox)&&(this.bbox.containsRect(e)?this.parent?.recomputeBBox(!0):this.parent?.unionBBoxWith(this.bbox))}unionBBoxWith(t){this.bbox=this.bbox.union(t),this.parent?.unionBBoxWith(t)}updateParents(t=!1){for(const e of this.children)e.parent=this,t&&e.updateParents(t)}rebalance(){if(this.parent&&1===this.parent.children.length){console.assert(null===this.parent.content),console.assert(this.parent.children[0]===this);const t=this.parent;null!==t.parent?(t.children=[],this.parent=t.parent,this.parent.children.push(this),t.parent=null,this.parent.recomputeBBox(!1)):null===this.content&&(this.parent.children=this.children,this.parent.updateParents(),this.parent=null)}}removeChild(t){const e=this.children.length;this.children=this.children.filter((e=>e!==t)),console.assert(this.children.length===e-1,`${e-1} ≠ ${this.children.length} after removing all nodes equal to ${t}. Nodes should only be removed once.`),this.children.forEach((t=>{t.rebalance()})),this.recomputeBBox(!0)}remove(){if(this.content?.onRemoveFromImage(),!this.parent)return this.content=null,void(this.children=[]);this.parent.removeChild(this),this.parent=null,this.content=null,this.children=[]}async renderAllAsync(t,n){const o=this.getLeaves();(0,e.sortLeavesByZIndex)(o);const i=o.length;for(let e=0;e<i;e++){const r=o[e].getContent();if(!r)continue;if(!await n(r,e,i))return!1;r.render(t,void 0)}return!0}render(t,n){let o;o=n?this.getLeavesIntersectingRegion(n,(e=>t.isTooSmallToRender(e))):this.getLeaves(),(0,e.sortLeavesByZIndex)(o);for(const e of o)e.getContent().render(t,n)}renderDebugBoundingBoxes(t,e,n=0){const o=this.getBBox(),i=1/(t.getSizeOfCanvasPixelOnScreen()||1);if(o.maxDimension<3*i||!o.intersects(e))return;t.startObject(o);const r=!!this.content,s=r?u.Color4.ofRGBA(1,0,1,.4):u.Color4.ofRGBA(0,1,Math.sin(n),.6),a=r?1*i:2*i;t.drawRect(o.intersection(e),a,{fill:s}),t.endObject();for(const o of this.children)o.renderDebugBoundingBoxes(t,e,n+1)}}e.ImageNode=v,v.idCounter=0;class w extends v{constructor(){super(...arguments),this.fullscreenChildren=[],this.dataComponents=[]}getChildrenIntersectingRegion(t,e){const n=super.getChildrenIntersectingRegion(t);for(const t of this.fullscreenChildren)n.push(t);return n}getLeaves(){const t=super.getLeaves();return this.dataComponents.concat(this.fullscreenChildren,t)}removeChild(t){let e=!1;const n=n=>{const o=n===t;return e||=o,!o};this.dataComponents=this.dataComponents.filter(n),this.fullscreenChildren=this.fullscreenChildren.filter(n),e||super.removeChild(t)}getChildWithContent(t){const e=()=>{const e=this.fullscreenChildren.concat(this.dataComponents);for(const n of e)if(n.getContent()===t)return n;return null};return t.getSizingMode(),h.ComponentSizingMode.BoundingBox,super.getChildWithContent(t)??e()}addLeaf(t){const e=t.getSizingMode();if(e===h.ComponentSizingMode.BoundingBox)return super.addLeaf(t);if(e===h.ComponentSizingMode.FillScreen){this.onContentChange();const e=v.createLeafNode(this,t);return this.fullscreenChildren.push(e),e}if(e===h.ComponentSizingMode.Anywhere){this.onContentChange();const e=v.createLeafNode(this,t);return this.dataComponents.push(e),e}throw new Error(`Invalid sizing mode, ${e}`)}}e.RootImageNode=w},5870:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097);e.default=(t,e,n)=>{let i=e.w,r=e.h;if(n?.minDimension&&i<n.minDimension){const t=n.minDimension;r*=t/(i||1),i=t}if(n?.minDimension&&r<n.minDimension){const t=n.minDimension;i*=t/(r||1),r=t}t.setAttribute("width",(0,o.toRoundedString)(i)),t.setAttribute("height",(0,o.toRoundedString)(r))}},2460:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.editorImageToSVGAsync=e.editorImageToSVGSync=void 0;const i=n(5097),r=o(n(2001)),s=n(1697),a=o(n(5870)),l=(t,e,n)=>{const o=t.getImportExportViewport().getTemporaryClone();if(n?.minDimension){const t=o.visibleRect;let e=t;e.w<=0&&(e=new i.Rect2(e.x,e.y,n.minDimension,e.h)),e.h<=0&&(e=new i.Rect2(e.x,e.y,e.w,n.minDimension)),e.eq(t)||o.updateScreenSize(e.size)}const{element:l,renderer:c}=r.default.fromViewport(o,{sanitize:n.sanitize??!1,useViewBoxForPositioning:!0});return e(c,(()=>{t.getAutoresizeEnabled()?l.classList.add(s.svgLoaderAutoresizeClassName):l.classList.remove(s.svgLoaderAutoresizeClassName);const e=o.visibleRect;return(0,a.default)(l,e,n),l})),l};e.editorImageToSVGSync=(t,e)=>l(t,((e,n)=>{t.renderAll(e),n()}),e);e.editorImageToSVGAsync=(t,e,n)=>new Promise((o=>{l(t,(async(n,i)=>{await t.renderAllAsync(n,e);const r=i();o(r)}),n)}))},6338:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.EditorImage=void 0;var i=n(505);Object.defineProperty(e,"EditorImage",{enumerable:!0,get:function(){return o(i).default}})},7520:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.isPointerEvt=e.keyPressEventFromHTMLEvent=e.keyUpEventFromHTMLEvent=e.InputEvtType=void 0,function(t){t[t.PointerDownEvt=0]="PointerDownEvt",t[t.PointerMoveEvt=1]="PointerMoveEvt",t[t.PointerUpEvt=2]="PointerUpEvt",t[t.GestureCancelEvt=3]="GestureCancelEvt",t[t.WheelEvt=4]="WheelEvt",t[t.KeyPressEvent=5]="KeyPressEvent",t[t.KeyUpEvent=6]="KeyUpEvent",t[t.CopyEvent=7]="CopyEvent",t[t.PasteEvent=8]="PasteEvent"}(n||(e.InputEvtType=n={}));const o=(t,e)=>({kind:t,key:e.key,code:e.code,ctrlKey:e.ctrlKey||e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey});e.keyUpEventFromHTMLEvent=t=>o(n.KeyUpEvent,t);e.keyPressEventFromHTMLEvent=t=>o(n.KeyPressEvent,t);e.isPointerEvt=t=>t.kind===n.PointerDownEvt||t.kind===n.PointerMoveEvt||t.kind===n.PointerUpEvt},6209:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.HTMLToolbar=e.AbstractToolbar=e.Editor=e.__js_draw__version=e.UndoRedoHistory=e.PointerDevice=e.Pointer=e.EventDispatcher=e.Viewport=e.SVGLoader=e.matchingLocalizationTable=e.getLocalizationTable=void 0;const s=r(n(5146));e.Editor=s.default,i(n(6338),e),i(n(3173),e),i(n(7520),e);var a=n(1906);Object.defineProperty(e,"getLocalizationTable",{enumerable:!0,get:function(){return r(a).default}}),Object.defineProperty(e,"matchingLocalizationTable",{enumerable:!0,get:function(){return a.matchingLocalizationTable}}),i(n(8167),e);var l=n(1697);Object.defineProperty(e,"SVGLoader",{enumerable:!0,get:function(){return r(l).default}});var c=n(5566);Object.defineProperty(e,"Viewport",{enumerable:!0,get:function(){return r(c).default}}),i(n(5097),e),i(n(1576),e),i(n(7601),e),i(n(1709),e),i(n(2994),e),i(n(2670),e),i(n(1797),e),i(n(6843),e);var d=n(1785);Object.defineProperty(e,"EventDispatcher",{enumerable:!0,get:function(){return r(d).default}});var h=n(4318);Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return r(h).default}}),Object.defineProperty(e,"PointerDevice",{enumerable:!0,get:function(){return h.PointerDevice}});var u=n(5155);Object.defineProperty(e,"UndoRedoHistory",{enumerable:!0,get:function(){return r(u).default}}),i(n(3662),e);var p=n(2674);Object.defineProperty(e,"__js_draw__version",{enumerable:!0,get:function(){return r(p).default}});const f=r(n(2339));e.AbstractToolbar=f.default,e.HTMLToolbar=f.default,e.default=s.default},8167:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultEditorLocalization=void 0;const o=n(6985),i=n(7708),r=n(49),s=n(9746),a=n(3376);e.defaultEditorLocalization={...s.defaultToolbarLocalization,...a.defaultToolLocalization,...o.defaultCommandLocalization,...i.defaultComponentLocalization,...r.defaultTextRendererLocalization,accessibilityInputInstructions:['Press "t" to read the contents of the viewport as text.',"Use the arrow keys to move the viewport, click and drag to draw strokes.",'Press "w" to zoom in and "s" to zoom out.'].join(" "),loading:t=>`Loading ${t}%...`,imageEditor:"Image Editor",doneLoading:"Done loading",undoAnnouncement:t=>`Undid ${t}`,redoAnnouncement:t=>`Redid ${t}`}},4540:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={...n(8167).defaultEditorLocalization,pen:"Stift",eraser:"Radierer",select:"Auswahl",handTool:"Verschieben",zoom:"Vergrößerung",image:"Bild",inputAltText:"Alt-Text: ",chooseFile:"Wähle Datei: ",submit:"Absenden",cancel:"Abbrechen",resetView:"Ansicht zurücksetzen",thicknessLabel:"Dicke: ",colorLabel:"Farbe: ",fontLabel:"Schriftart: ",textSize:"Größe: ",resizeImageToSelection:"Bildgröße an Auswahl anpassen",deleteSelection:"Auswahl löschen",duplicateSelection:"Auswahl duplizieren",undo:"Rückgängig",redo:"Wiederholen",pickColorFromScreen:"Farbe von Bildschirm auswählen",clickToPickColorAnnouncement:"Klicke auf den Bildschirm, um eine Farbe auszuwählen",selectionToolKeyboardShortcuts:"Auswahl-Werkzeug: Verwende die Pfeiltasten, um ausgewählte Elemente zu verschieben und ‚i‘ und ‚o‘, um ihre Größe zu ändern.",touchPanning:"Ansicht mit Touchscreen verschieben",anyDevicePanning:"Ansicht mit jedem Eingabegerät verschieben",selectPenTip:"Objekt-Typ: ",roundedTipPen:"Freihand",flatTipPen:"Stift (druckempfindlich)",arrowPen:"Pfeil",linePen:"Linie",outlinedRectanglePen:"Umrissenes Rechteck",filledRectanglePen:"Ausgefülltes Rechteck",lockRotation:"Sperre Rotation",paste:"Einfügen",dropdownShown:t=>`Dropdown-Menü für ${t} angezeigt`,dropdownHidden:t=>`Dropdown-Menü für ${t} versteckt`,zoomLevel:t=>`Vergößerung: ${t}%`,colorChangedAnnouncement:t=>`Farbe zu ${t} geändert`,imageSize:(t,e)=>`Bild-Größe: ${t} ${e}`,imageLoadError:t=>`Fehler beim Laden des Bildes: ${t}`,errorImageHasZeroSize:"Fehler: Bild hat Größe Null",penTool:t=>`Stift ${t}`,selectionTool:"Auswahl",eraserTool:"Radiergummi",touchPanTool:"Ansicht mit Touchscreen verschieben",twoFingerPanZoomTool:"Ansicht verschieben und vergrößern",undoRedoTool:"Rückgängig/Wiederholen",rightClickDragPanTool:"Rechtsklick-Ziehen",pipetteTool:"Farbe von Bildschirm auswählen",keyboardPanZoom:"Tastaturkürzel zum Verschieben/Vergrößern der Ansicht",textTool:"Text",enterTextToInsert:"Einzufügender Text",changeTool:"Wechsle Werkzeug",pasteHandler:"Copy-Paste-Handler",findLabel:"Finde",toNextMatch:"Nächstes",closeDialog:"Schließen",findDialogShown:"Finde-Dialog angezeigt",findDialogHidden:"Finde-Dialog versteckt",focusedFoundText:(t,e)=>`Sieh Treffer ${t} von ${e} an`,toolEnabledAnnouncement:t=>`${t} aktiviert`,toolDisabledAnnouncement:t=>`${t} deaktiviert`,updatedViewport:"Transformierte Ansicht",transformedElements:t=>`${t} Element${1===t?"":"e"} transformiert`,resizeOutputCommand:t=>`Bildgröße auf ${t.w}x${t.h} geändert`,addElementAction:t=>`${t} hinzugefügt`,eraseAction:(t,e)=>`${e} ${t} gelöscht`,duplicateAction:(t,e)=>`${e} ${t} dupliziert`,inverseOf:t=>`${t} umgekehrt`,elements:"Elemente",erasedNoElements:"Nichts entfernt",duplicatedNoElements:"Nichts dupliziert",rotatedBy:t=>`${Math.abs(t)} Grad ${t<0?"im Uhrzeigersinn":"gegen den Uhrzeigersinn"} gedreht`,movedLeft:"Nacht links bewegt",movedUp:"Nacht oben bewegt",movedDown:"Nacht unten bewegt",movedRight:"Nacht rechts bewegt",zoomedOut:"Ansicht verkleinert",zoomedIn:"Ansicht vergrößert",selectedElements:t=>`${t} Element${1===t?"":"e"} ausgewählt`,stroke:"Strich",svgObject:"SVG-Objekt",text:t=>`Text-Objekt: ${t}`,pathNodeCount:t=>`Es gibt ${t} sichtbare Pfad-Objekte.`,textNodeCount:t=>`Es gibt ${t} sichtbare Text-Knotenpunkte.`,textNode:t=>`Text: ${t}`,imageNodeCount:t=>`Es gibt ${t} sichtbare Bild-Knoten.`,imageNode:t=>`Bild: ${t}`,unlabeledImageNode:"Bild ohne Label",rerenderAsText:"Als Text darstellen",accessibilityInputInstructions:"Drücke ‚t‘, um den Inhalt des Ansichtsfensters als Text zu lesen. Verwende die Pfeiltasten, um die Ansicht zu verschieben, und klicke und ziehe, um Striche zu zeichnen. Drücke ‚w‘ zum Vergrößern und ‚s‘ zum Verkleinern der Ansicht.",loading:t=>`Laden ${t}%...`,doneLoading:"Laden fertig",imageEditor:"Bild-Editor",undoAnnouncement:t=>`${t} rückgängig gemacht`,redoAnnouncement:t=>`${t} wiederholt`,reformatSelection:"Formatiere Auswahl",documentProperties:"Seite",backgroundColor:"Hintergrundfarbe: ",imageWidthOption:"Breite: ",imageHeightOption:"Höhe: ",useGridOption:"Gitter: ",toggleOverflow:"Mehr",selectAllTool:"Alle auswählen",soundExplorer:"Klangbasierte Bilderkundung",disableAccessibilityExploreTool:"Deaktiviere klangbasierte Erkundung",enableAccessibilityExploreTool:"Aktiviere klangbasierte Erkundung",copied:(t,e)=>`${t} ${e} kopiert`,pasted:(t,e)=>`${t} ${e} eingefügt`,unionOf:(t,e)=>`Vereinigung: ${e} ${t}`,emptyBackground:"Leerer Hintergrund",filledBackgroundWithColor:t=>`Gefüllter Hintergrund (${t})`,restyledElement:t=>`${t} umgestaltet`};e.default=o},512:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={...n(8167).defaultEditorLocalization};e.default=o},7003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={...n(8167).defaultEditorLocalization,pen:"Lapiz",eraser:"Borrador",select:"Selecciona",handTool:"Mover",image:"Imagen",chooseFile:"Seleccionar archivo",cancel:"Cancelar",resetView:"Reiniciar vista",thicknessLabel:"Tamaño",fontLabel:"Fuente:",textSize:"Tamaño",resizeImageToSelection:"Redimensionar la imagen a lo que está seleccionado",deleteSelection:"Borra la selección",duplicateSelection:"Duplica la selección",exit:"Salir",save:"Guardar",undo:"Deshace",redo:"Rehace",selectPenTip:"Punta",selectShape:"Forma",pickColorFromScreen:"Selecciona un color de la pantalla",clickToPickColorAnnouncement:"Haga un clic en la pantalla para seleccionar un color",documentProperties:"Fondo",backgroundColor:"Color de fondo",imageWidthOption:"Ancho",imageHeightOption:"Alto",toggleOverflow:"Más",touchPanning:"Mover la pantalla con un dedo",roundedTipPen:"Lapiz Redondeado",arrowPen:"Flecha",linePen:"Línea",outlinedRectanglePen:"Rectángulo delineado",filledRectanglePen:"Rectángulo sin borde",lockRotation:"Bloquea rotación",paste:"Pegar",closeSidebar:t=>`Close sidebar for ${t}`,dropdownShown:t=>`Menú por ${t} es visible`,dropdownHidden:t=>`Menú por ${t} fue ocultado`,zoomLevel:t=>`Zoom: ${t}%`,colorChangedAnnouncement:t=>`Color fue cambiado a ${t}`,imageSize:(t,e)=>`Tamaño del imagen: ${t} ${e}`,imageLoadError:t=>`Error cargando imagen: ${t}`,penTool:t=>`Lapiz ${t}`,selectionTool:"Selecciona",eraserTool:"Borrador",touchPanTool:"Instrumento de mover la pantalla con un dedo",pipetteTool:"Seleccione un color de la pantalla",keyboardPanZoom:"Mover la pantalla con el teclado",textTool:"Texto",enterTextToInsert:"Entra texto",findLabel:"Buscar",toNextMatch:"Próxima",closeDialog:"Cerrar",focusedFoundText:(t,e)=>`Viewing match ${t} of ${e}`,anyDevicePanning:"Mover la pantalla con todo dispotivo",copied:(t,e)=>`Copied ${t} ${e}`,pasted:(t,e)=>`Pasted ${t} ${e}`,toolEnabledAnnouncement:t=>`${t} enabled`,toolDisabledAnnouncement:t=>`${t} disabled`,transformedElements:t=>`Transformed ${t} element${1===t?"":"s"}`,resizeOutputCommand:t=>`Resized image to ${t.w}x${t.h}`,addElementAction:t=>`Added ${t}`,eraseAction:(t,e)=>`Erased ${e} ${t}`,duplicateAction:(t,e)=>`Duplicated ${e} ${t}`,unionOf:(t,e)=>`Union: ${e} ${t}`,inverseOf:t=>`Inverse of ${t}`,rotatedBy:t=>`Rotated by ${Math.abs(t)} degrees ${t<0?"clockwise":"counter-clockwise"}`,selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`,filledBackgroundWithColor:t=>`Filled background (${t})`,text:t=>`Text object: ${t}`,imageNode:t=>`Image: ${t}`,restyledElement:t=>`Restyled ${t}`,pathNodeCount:t=>`There are ${t} visible path objects.`,textNodeCount:t=>`There are ${t} visible text nodes.`,imageNodeCount:t=>`There are ${t} visible image nodes.`,textNode:t=>`Text: ${t}`,rerenderAsText:"Redibuja la pantalla al texto",loading:t=>`Cargando: ${t}%...`,imageEditor:"Editor de dibujos",doneLoading:"El cargado terminó",undoAnnouncement:t=>`${t} fue deshecho`,redoAnnouncement:t=>`${t} fue rehecho`};e.default=o},1906:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.matchingLocalizationTable=e.allLocales=void 0;const i=n(8167),r=o(n(4540)),s=o(n(512)),a=o(n(7003));e.allLocales={de:r.default,en:s.default,es:a.default};const l=t=>{const e=/^(\w+)[_-](\w+)$/.exec(t);return e?e[1]:t};e.matchingLocalizationTable=(t,e,n)=>{let o;for(const n of t){const t=l(n);if(o&&t!==o&&o in e)return e[o];if(n in e)return e[n];o=t}return o&&o in e?e[o]:n};e.default=t=>(t??=navigator.languages,(0,e.matchingLocalizationTable)(t,e.allLocales,i.defaultEditorLocalization))},3012:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RenderingMode=void 0;const i=o(n(7717)),r=n(3173),s=o(n(6377)),a=n(5097),l=o(n(5630)),c=o(n(1263));var d;!function(t){t[t.DummyRenderer=0]="DummyRenderer",t[t.CanvasRenderer=1]="CanvasRenderer"}(d||(e.RenderingMode=d={}));e.default=class{constructor(t,e,n){if(this.editor=t,this.parent=n,this.textRerenderOutput=null,this.getColorAt=t=>null,e===d.CanvasRenderer)this.initializeCanvasRendering();else{if(e!==d.DummyRenderer)throw new Error(`Unknown rendering mode, ${e}!`);this.dryInkRenderer=new s.default(t.viewport),this.wetInkRenderer=new s.default(t.viewport)}this.textRenderer=new c.default(t.viewport,t.localization),this.initializeTextRendering();const o=a.Vec2.of(600,600);this.cache=new l.default({createRenderer:()=>{if(e===d.DummyRenderer)return new s.default(t.viewport);if(e!==d.CanvasRenderer)throw new Error("Unspported rendering mode");const n=document.createElement("canvas");n.width=o.x+1,n.height=o.y+1;const r=n.getContext("2d");return new i.default(r,t.viewport)},isOfCorrectType:t=>this.dryInkRenderer.canRenderFromWithoutDataLoss(t),blockResolution:o,cacheSize:1296e5,maxScale:1.3,minProportionalRenderTimePerCache:80,minProportionalRenderTimeToUseCache:420}),this.editor.notifier.on(r.EditorEventType.DisplayResized,(t=>{if(t.kind!==r.EditorEventType.DisplayResized)throw new Error("Mismatched event.kinds!");this.resizeSurfacesCallback?.()}))}get width(){return this.dryInkRenderer.displaySize().x}get height(){return this.dryInkRenderer.displaySize().y}getCache(){return this.cache}initializeCanvasRendering(){const t=document.createElement("canvas"),e=document.createElement("canvas"),n=t.getContext("2d"),o=e.getContext("2d");this.dryInkRenderer=new i.default(n,this.editor.viewport),this.wetInkRenderer=new i.default(o,this.editor.viewport),t.className="dryInkCanvas",e.className="wetInkCanvas",this.parent&&(this.parent.appendChild(t),this.parent.appendChild(e)),this.resizeSurfacesCallback=()=>{const n=t=>t.clientHeight!==t.height||t.clientWidth!==t.width;(n(t)||n(e))&&(t.width=t.clientWidth,t.height=t.clientHeight,e.width=e.clientWidth,e.height=e.clientHeight,this.editor.notifier.dispatch(r.EditorEventType.DisplayResized,{kind:r.EditorEventType.DisplayResized,newSize:a.Vec2.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{n.drawImage(e,0,0)},this.getColorAt=t=>{const e=n.getImageData(t.x,t.y,1,1),o=e?.data;if(o){return a.Color4.ofRGBA(o[0]/255,o[1]/255,o[2]/255,o[3]/255)}return null}}initializeTextRendering(){const t=document.createElement("div");t.classList.add("textRendererOutputContainer");const e=document.createElement("button");e.classList.add("rerenderButton"),e.innerText=this.editor.localization.rerenderAsText,this.textRerenderOutput=document.createElement("div"),this.textRerenderOutput.setAttribute("aria-live","polite"),e.onclick=()=>{this.rerenderAsText()},t.replaceChildren(e,this.textRerenderOutput),this.editor.createHTMLOverlay(t)}rerenderAsText(){this.textRenderer.clear(),this.editor.image.render(this.textRenderer,this.editor.viewport),this.textRerenderOutput&&(this.textRerenderOutput.innerText=this.textRenderer.getDescription())}startRerender(){return this.resizeSurfacesCallback?.(),this.dryInkRenderer.clear(),this.dryInkRenderer}setDraftMode(t){this.dryInkRenderer.setDraftMode(t)}getDryInkRenderer(){return this.dryInkRenderer}getWetInkRenderer(){return this.wetInkRenderer}flatten(){this.flattenCallback?.()}}},7444:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.visualEquivalent=e.pathToRenderable=e.pathFromRenderable=void 0;const o=n(5097);e.pathFromRenderable=t=>t.path?t.path:new o.Path(t.startPoint,t.commands);e.pathToRenderable=(t,e)=>({startPoint:t.startPoint,style:e,commands:t.parts,path:t});e.visualEquivalent=(t,n)=>{const i=(0,e.pathFromRenderable)(t),r=t.style.stroke?.width??0,s=r>0&&0===t.style.fill.a;if(n.grownBy(r).transformedBoundingBox(o.Mat33.scaling2D(4,n.center)).containsRect(i.bbox.grownBy(r)))return t;const a=[];let l=i.startPoint;for(const t of i.parts){const e=o.Path.computeBBoxForSegment(l,t).grownBy(r);let i;i=t.kind===o.PathCommandType.LineTo||t.kind===o.PathCommandType.MoveTo?t.point:t.endPoint;e.intersects(n)?a.push(t):s||t.kind===o.PathCommandType.MoveTo?a.push({kind:o.PathCommandType.MoveTo,point:i}):a.push({kind:o.PathCommandType.LineTo,point:i}),l=i}return(0,e.pathToRenderable)(new o.Path(i.startPoint,a),t.style)}},2500:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.styleFromJSON=e.styleToJSON=e.stylesEqual=e.cloneStyle=void 0;const o=n(5097);e.cloneStyle=t=>({fill:t.fill,stroke:t.stroke?{...t.stroke}:void 0});e.stylesEqual=(t,e)=>(t===e||t.fill.eq(e.fill)&&null==t.stroke==(null==e.stroke)&&(t.stroke?.color?.eq(e.stroke?.color)??!0)&&t.stroke?.width===e.stroke?.width)??!1;e.styleToJSON=t=>{const e=t.stroke?{color:t.stroke.color.toHexString(),width:t.stroke.width}:void 0;return{fill:t.fill.toHexString(),stroke:e}};e.styleFromJSON=t=>{const e=t.stroke?{color:o.Color4.fromHex(t.stroke.color),width:t.stroke.width}:void 0;return{fill:o.Color4.fromHex(t.fill),stroke:e}}},2788:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.textStyleToJSON=e.textStyleFromJSON=e.cloneTextStyle=void 0;const o=n(2500);e.cloneTextStyle=t=>({...t,renderingStyle:(0,o.cloneStyle)(t.renderingStyle)});e.textStyleFromJSON=t=>{if("string"==typeof t&&(t=JSON.parse(t)),"string"!=typeof t.fontFamily)throw new Error("Serialized textStyle missing string fontFamily attribute!");return{renderingStyle:(0,o.styleFromJSON)(t.renderingStyle),size:t.size,fontWeight:t.fontWeight,fontVariant:t.fontVariant,fontFamily:t.fontFamily}};e.textStyleToJSON=t=>({...t,renderingStyle:(0,o.styleToJSON)(t.renderingStyle)})},4619:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097);e.default=class{constructor(t,e){this.onBeforeDeallocCallback=t,this.cacheState=e,this.allocd=!1,this.allocCount=0,this.renderer=e.props.createRenderer(),this.lastUsedCycle=-1,this.allocd=!0}startRender(){if(this.lastUsedCycle=this.cacheState.currentRenderingCycle,!this.allocd)throw new Error("Only alloc'd canvases can be rendered to");return this.renderer}dealloc(){this.onBeforeDeallocCallback?.(),this.allocd=!1,this.onBeforeDeallocCallback=null,this.lastUsedCycle=0}isAllocd(){return this.allocd}realloc(t){this.allocd&&this.dealloc(),this.allocd=!0,this.onBeforeDeallocCallback=t,this.lastUsedCycle=this.cacheState.currentRenderingCycle,this.allocCount++}getLastUsedCycle(){return this.lastUsedCycle}getTransform(t){return o.Mat33.scaling2D(this.cacheState.props.blockResolution.x/t.size.x).rightMul(o.Mat33.translation(t.topLeft.times(-1)))}setRenderingRegion(t){this.renderer.setTransform(this.getTransform(t))}}},8182:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CacheRecordManager=void 0;const i=o(n(4619));e.CacheRecordManager=class{constructor(t){this.cacheRecords=[],this.maxCanvases=Math.ceil(t.cacheSize/4/t.blockResolution.x/t.blockResolution.y)}setSharedState(t){this.cacheState=t}allocCanvas(t,e){if(this.cacheRecords.length<this.maxCanvases){const n=new i.default(e,this.cacheState);return n.setRenderingRegion(t),this.cacheRecords.push(n),n}{const n=this.getLeastRecentlyUsedRecord();return n.realloc(e),n.setRenderingRegion(t),n}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort(((t,e)=>t.getLastUsedCycle()-e.getLastUsedCycle())),this.cacheRecords[0]}}},5630:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(1310)),s=n(8182);e.default=class{constructor(t){this.recordManager=new s.CacheRecordManager(t),this.sharedState={props:t,currentRenderingCycle:0,recordManager:this.recordManager},this.recordManager.setSharedState(this.sharedState)}render(t,e,n){const o=n.visibleRect;if(this.sharedState.currentRenderingCycle++,!this.sharedState.props.isOfCorrectType(t))return void e.render(t,o);if(!this.rootNode){const t=this.sharedState.props.blockResolution,e=o.topLeft;this.rootNode=new r.default(new i.Rect2(e.x,e.y,t.x,t.y),this.sharedState)}for(;!this.rootNode.region.containsRect(o);)this.rootNode=this.rootNode.generateParent();this.rootNode=this.rootNode.smallestChildContaining(o)??this.rootNode;const s=e.getLeavesIntersectingRegion(n.visibleRect,(e=>t.isTooSmallToRender(e)));let a=0;for(const t of s)a+=t.getContent().getProportionalRenderingTime();a>this.sharedState.props.minProportionalRenderTimeToUseCache?this.rootNode.renderItems(t,[e],n):e.render(t,o)}}},1310:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(505),i=n(5097),r=!1;class s{constructor(t,e){this.region=t,this.cacheState=e,this.instantiatedChildren=[],this.parent=null,this.cachedRenderer=null,this.renderedIds=[],this.renderedMaxZIndex=null}generateParent(){if(this.parent)return this.parent;const t=i.Rect2.fromCorners(this.region.topLeft.minus(this.region.size),this.region.bottomRight.plus(this.region.size)),e=new s(t,this.cacheState);e.generateChildren();const n=this.region.maxDimension/100,o=(e.instantiatedChildren.length-1)/2;if(!e.instantiatedChildren[o].region.eq(this.region,n))throw console.error(e.instantiatedChildren[o].region,"≠",this.region),new Error("Logic error: [this] is not contained within its parent's center child");return e.instantiatedChildren[o]=this,this.parent=e,e}generateChildren(){if(0===this.instantiatedChildren.length){if(this.region.size.x/3==0||this.region.size.y/3==0)return void console.warn("Cache element has zero size! Not generating children.");const t=this.region.divideIntoGrid(3,3);console.assert(9===t.length,"Warning: divideIntoGrid created the wrong number of subrectangles!");for(const e of t){const t=new s(e,this.cacheState);t.parent=this,this.instantiatedChildren.push(t)}}this.checkRep()}getChildren(){return this.checkRep(),this.generateChildren(),this.instantiatedChildren}smallestChildContaining(t){const e=t.maxDimension>this.region.maxDimension/3;if(!this.region.containsRect(t)||e)return null;for(const e of this.getChildren())if(e.region.containsRect(t))return e.smallestChildContaining(t)??e;return null}renderingWouldBeHighEnoughResolution(t){const e=this.region.w/this.cacheState.props.blockResolution.x;return!(t.getScaleFactor()*e>this.cacheState.props.maxScale)}allChildrenCanRender(t,e){if(0===this.instantiatedChildren.length)return!1;for(const n of this.instantiatedChildren)if(n.region.intersects(t.visibleRect)&&!n.renderingIsUpToDate(this.idsOfIntersecting(e)))return!1;return!0}computeSortedByLeafIds(t){const e=t.slice();return e.sort(((t,e)=>t.getId()-e.getId())),e}idsOfIntersecting(t){const e=[];for(const n of t)n.getBBox().intersects(this.region)&&e.push(n.getId());return e}allRenderedIdsIn(t){if(this.renderedIds.length>t.length)return!1;for(let e=0;e<this.renderedIds.length;e++)if(t[e]!==this.renderedIds[e])return!1;return!0}renderingIsUpToDate(t){return null!==this.cachedRenderer&&t.length===this.renderedIds.length&&this.allRenderedIdsIn(t)}renderItems(t,e,n){if(!n.visibleRect.intersects(this.region)||0===e.length)return;const s=[];for(const t of e){const e=t.getBBox();e.intersects(this.region)&&(e.maxDimension>=this.region.maxDimension?s.push(...t.getChildrenOrSelfIntersectingRegion(this.region)):s.push(t))}if(e=s,!this.cacheState.props.isOfCorrectType(t))return void e.forEach((e=>e.render(t,n.visibleRect)));if(this.renderingWouldBeHighEnoughResolution(n)){const s=t=>t.w/this.region.w<1/this.cacheState.props.blockResolution.x,a=[];for(const t of e)a.push(...t.getLeavesIntersectingRegion(this.region,s));(0,o.sortLeavesByZIndex)(a);const l=this.computeSortedByLeafIds(a);if(0===l.length)return;const c=l.map((t=>t.getId()));let d;if(this.renderingIsUpToDate(c))d=this.cachedRenderer.startRender();else{if(this.allChildrenCanRender(n,l)){for(const o of this.getChildren())o.renderItems(t,e,n);return}let o=0;for(const t of l)o+=t.getContent().getProportionalRenderingTime();if(o>this.cacheState.props.minProportionalRenderTimePerCache){let t=!0;if(this.cachedRenderer)if(l.length>this.renderedIds.length&&this.allRenderedIdsIn(c)&&null!==this.renderedMaxZIndex){const e=[];let n=null;for(let t=0;t<l.length;t++){const o=l[t],i=o.getContent().getZIndex();(t>=this.renderedIds.length||o.getId()!==this.renderedIds[t])&&(e.push(o),(null===n||i<n)&&(n=i))}if(null!==n&&n>this.renderedMaxZIndex){t=!1,d=this.cachedRenderer.startRender();for(let t=0;t<a.length;t++){const e=a[t],n=e.getContent().getZIndex();n>this.renderedMaxZIndex&&(e.render(d,this.region),this.renderedMaxZIndex=n)}r}}else r;else this.cachedRenderer=this.cacheState.recordManager.allocCanvas(this.region,(()=>this.onRegionDealloc()));if(t){d=this.cachedRenderer.startRender(),d.clear(),this.renderedMaxZIndex=null;for(const t of a){const e=t.getContent();this.renderedMaxZIndex??=e.getZIndex(),this.renderedMaxZIndex=Math.max(this.renderedMaxZIndex,e.getZIndex()),t.render(d,this.region)}r}this.renderedIds=c}else{this.cachedRenderer?.dealloc();const e=n.getSizeOfPixelOnCanvas(),o=new i.Rect2(this.region.x,this.region.y,this.region.w+e,this.region.h+e),r=!0;t.startObject(o,r);for(const e of a)e.render(t,this.region.intersection(n.visibleRect));t.endObject()}}if(d){const e=this.cachedRenderer.getTransform(this.region).inverse();t.renderFromOtherOfSameType(e,d)}this.instantiatedChildren.every((t=>t.isEmpty()))&&(this.instantiatedChildren=[])}else for(const o of this.getChildren())o.renderItems(t,e.filter((t=>t.getBBox().intersects(o.region))),n);this.checkRep()}isEmpty(){return null===this.cachedRenderer&&this.instantiatedChildren.every((t=>t.isEmpty()))}onRegionDealloc(){this.cachedRenderer=null,this.isEmpty()&&(this.instantiatedChildren=[])}checkRep(){if(9!==this.instantiatedChildren.length&&0!==this.instantiatedChildren.length)throw new Error(`Repcheck: Wrong number of children. Got ${this.instantiatedChildren.length}`);if(void 0!==this.renderedIds[1]&&this.renderedIds[0]>=this.renderedIds[1])throw console.error(this.renderedIds),new Error("Repcheck: First two ids are not in ascending order!");for(const t of this.instantiatedChildren)if(t.parent!==this)throw new Error("Children should be linked to their parents!");if(this.cachedRenderer&&!this.cachedRenderer.isAllocd())throw new Error("this' cachedRenderer != null, but is dealloc'd")}}e.default=s},2670:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.pathVisualEquivalent=e.pathFromRenderable=e.pathToRenderable=e.RenderingMode=e.Display=e.CanvasRenderer=e.SVGRenderer=e.DummyRenderer=e.AbstractRenderer=void 0;var i=n(7369);Object.defineProperty(e,"AbstractRenderer",{enumerable:!0,get:function(){return o(i).default}});var r=n(6377);Object.defineProperty(e,"DummyRenderer",{enumerable:!0,get:function(){return o(r).default}});var s=n(2001);Object.defineProperty(e,"SVGRenderer",{enumerable:!0,get:function(){return o(s).default}});var a=n(7717);Object.defineProperty(e,"CanvasRenderer",{enumerable:!0,get:function(){return o(a).default}});var l=n(3012);Object.defineProperty(e,"Display",{enumerable:!0,get:function(){return o(l).default}}),Object.defineProperty(e,"RenderingMode",{enumerable:!0,get:function(){return l.RenderingMode}});var c=n(7444);Object.defineProperty(e,"pathToRenderable",{enumerable:!0,get:function(){return c.pathToRenderable}}),Object.defineProperty(e,"pathFromRenderable",{enumerable:!0,get:function(){return c.pathFromRenderable}}),Object.defineProperty(e,"pathVisualEquivalent",{enumerable:!0,get:function(){return c.visualEquivalent}})},49:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTextRendererLocalization=void 0,e.defaultTextRendererLocalization={pathNodeCount:t=>`There are ${t} visible path objects.`,textNodeCount:t=>`There are ${t} visible text nodes.`,imageNodeCount:t=>`There are ${t} visible image nodes.`,textNode:t=>`Text: ${t}`,imageNode:t=>`Image: ${t}`,unlabeledImageNode:"Unlabeled image",rerenderAsText:"Re-render as text"}},7369:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097),i=n(2500),r=n(7444);e.default=class{constructor(t){this.viewport=t,this.selfTransform=null,this.transformStack=[],this.objectLevel=0,this.currentPaths=null}getViewport(){return this.viewport}setDraftMode(t){}flushPath(){if(!this.currentPaths)return;let t=null;for(const e of this.currentPaths){const{startPoint:n,commands:r,style:s}=e;t&&(0,i.stylesEqual)(t,s)?this.moveTo(n):(t&&this.endPath(t),this.beginPath(n),t=s);for(const t of r)t.kind===o.PathCommandType.LineTo?this.lineTo(t.point):t.kind===o.PathCommandType.MoveTo?this.moveTo(t.point):t.kind===o.PathCommandType.CubicBezierTo?this.traceCubicBezierCurve(t.controlPoint1,t.controlPoint2,t.endPoint):t.kind===o.PathCommandType.QuadraticBezierTo&&this.traceQuadraticBezierCurve(t.controlPoint,t.endPoint)}t&&this.endPath(t),this.currentPaths=[]}drawPath(t){0===this.objectLevel||null===this.currentPaths?(this.currentPaths=[t],this.flushPath(),this.currentPaths=null):this.currentPaths.push(t)}drawRect(t,e,n){const i=o.Path.fromRect(t,e);this.drawPath((0,r.pathToRenderable)(i,n))}fillRect(t,e){const n=o.Path.fromRect(t);this.drawPath((0,r.pathToRenderable)(n,{fill:e}))}startObject(t,e){this.objectLevel>0&&this.flushPath(),this.currentPaths=[],this.objectLevel++}endObject(t,e){if(this.flushPath(),this.currentPaths=null,this.objectLevel--,this.objectLevel<0)throw new Error("More objects have ended than have been started (negative object nesting level)!")}getNestingLevel(){return this.objectLevel}canRenderFromWithoutDataLoss(t){return!1}renderFromOtherOfSameType(t,e){throw new Error(`Unable to render from ${e}: Not implemented`)}setTransform(t){this.selfTransform=t}pushTransform(t){this.transformStack.push(this.selfTransform),this.setTransform(this.getCanvasToScreenTransform().rightMul(t))}popTransform(){if(0===this.transformStack.length)throw new Error("Unable to pop more transforms than have been pushed!");this.setTransform(this.transformStack.pop()??null)}getCanvasToScreenTransform(){return this.selfTransform?this.selfTransform:this.viewport.canvasToScreenTransform}canvasToScreen(t){return this.getCanvasToScreenTransform().transformVec2(t)}getSizeOfCanvasPixelOnScreen(){return this.getCanvasToScreenTransform().transformVec3(o.Vec2.unitX).length()}getVisibleRect(){return this.viewport.visibleRect}}},7717:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=n(5097),s=o(n(7369)),a=n(7444);class l extends s.default{constructor(t,e){super(e),this.ctx=t,this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1,this.currentObjectBBox=null,this.clipLevels=[],this.setDraftMode(!1)}transformBy(t){this.ctx.transform(t.a1,t.b1,t.a2,t.b2,t.a3,t.b3)}canRenderFromWithoutDataLoss(t){return t instanceof l}renderFromOtherOfSameType(t,e){if(!(e instanceof l))throw new Error(`${e} cannot be rendered onto ${this}`);t=this.getCanvasToScreenTransform().rightMul(t),this.ctx.save(),this.transformBy(t),this.ctx.drawImage(e.ctx.canvas,0,0),this.ctx.restore()}setDraftMode(t){t?(this.minSquareCurveApproxDist=9,this.minRenderSizeBothDimens=2,this.minRenderSizeAnyDimen=.5):(this.minSquareCurveApproxDist=.5,this.minRenderSizeBothDimens=.2,this.minRenderSizeAnyDimen=1e-6)}displaySize(){return r.Vec2.of(this.ctx.canvas.clientWidth,this.ctx.canvas.clientHeight)}clear(){this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}beginPath(t){t=this.canvasToScreen(t),this.ctx.beginPath(),this.ctx.moveTo(t.x,t.y)}endPath(t){t.fill.a>0&&(this.ctx.fillStyle=t.fill.toHexString(),this.ctx.fill()),t.stroke&&(this.ctx.strokeStyle=t.stroke.color.toHexString(),this.ctx.lineWidth=this.getSizeOfCanvasPixelOnScreen()*t.stroke.width,this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.stroke(),this.ctx.lineWidth=1),this.ctx.closePath()}lineTo(t){t=this.canvasToScreen(t),this.ctx.lineTo(t.x,t.y)}moveTo(t){t=this.canvasToScreen(t),this.ctx.moveTo(t.x,t.y)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n);const o=e.minus(t),i=n.minus(e);o.magnitudeSquared()<this.minSquareCurveApproxDist&&i.magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(n.x,n.y):this.ctx.bezierCurveTo(t.x,t.y,e.x,e.y,n.x,n.y)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e);t.minus(e).magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(e.x,e.y):this.ctx.quadraticCurveTo(t.x,t.y,e.x,e.y)}drawPath(t){this.ignoringObject||(this.currentObjectBBox?.containsRect(this.getViewport().visibleRect)&&(t=(0,a.visualEquivalent)(t,this.getViewport().visibleRect)),super.drawPath(t))}drawText(t,e,n){this.ctx.save(),e=this.getCanvasToScreenTransform().rightMul(e),this.transformBy(e),i.default.applyTextStyles(this.ctx,n),0!==n.renderingStyle.fill.a&&(this.ctx.fillStyle=n.renderingStyle.fill.toHexString(),this.ctx.fillText(t,0,0)),n.renderingStyle.stroke&&(this.ctx.strokeStyle=n.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=n.renderingStyle.stroke.width,this.ctx.strokeText(t,0,0)),this.ctx.restore()}drawImage(t){this.ctx.save();const e=this.getCanvasToScreenTransform().rightMul(t.transform);this.transformBy(e),this.ctx.drawImage(t.image,0,0),this.ctx.restore()}startObject(t,e){if(this.isTooSmallToRender(t)&&(this.ignoreObjectsAboveLevel=this.getNestingLevel(),this.ignoringObject=!0),super.startObject(t),this.currentObjectBBox=t,!this.ignoringObject&&e){if(!t.containsRect(this.getViewport().visibleRect)){this.clipLevels.push(this.objectLevel),this.ctx.save(),this.ctx.beginPath();for(const e of t.corners){const t=this.canvasToScreen(e);this.ctx.lineTo(t.x,t.y)}this.ctx.clip()}}}endObject(){const t=this.objectLevel;this.currentObjectBBox=null,super.endObject(),!this.ignoringObject&&this.clipLevels.length>0&&this.clipLevels[this.clipLevels.length-1]===t&&(this.ctx.restore(),this.clipLevels.pop()),null!==this.ignoreObjectsAboveLevel&&this.getNestingLevel()<=this.ignoreObjectsAboveLevel&&(this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1)}drawPoints(...t){for(let e=0;e<t.length;e++){const n=this.canvasToScreen(t[e]);this.ctx.beginPath(),this.ctx.arc(n.x,n.y,10,0,2*Math.PI),this.ctx.fillStyle=r.Color4.ofRGBA(.5+Math.sin(e)/2,1,.5+Math.cos(.2*e)/4,.5).toHexString(),this.ctx.lineWidth=2,this.ctx.fill(),this.ctx.stroke(),this.ctx.closePath(),this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillStyle="black",this.ctx.fillText(`${e}`,n.x,n.y,20)}}isTooSmallToRender(t){const e=this.getCanvasToScreenTransform().transformVec3(t.size),n=this.minRenderSizeBothDimens,o=Math.abs(e.x)<n&&Math.abs(e.y)<n,i=this.minRenderSizeAnyDimen,r=Math.abs(e.x)<i||Math.abs(e.y)<i;return o||r}}e.default=l},6377:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(7369));class s extends r.default{constructor(t){super(t),this.clearedCount=0,this.renderedPathCount=0,this.lastFillStyle=null,this.lastPoint=null,this.objectNestingLevel=0,this.lastText=null,this.lastImage=null,this.pointBuffer=[]}displaySize(){const t=this.getViewport().getScreenRectSize();return 0===t.x||0===t.y?i.Vec2.of(640,480):t}clear(){if(this.clearedCount++,this.renderedPathCount=0,this.pointBuffer=[],this.lastText=null,this.lastImage=null,this.objectNestingLevel>0)throw new Error(`Within an object while clearing! Nesting level: ${this.objectNestingLevel}`)}beginPath(t){this.lastPoint=t,this.pointBuffer.push(t)}endPath(t){this.renderedPathCount++,this.lastFillStyle=t}lineTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}moveTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n),this.lastPoint=n,this.pointBuffer.push(t,e,n)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(t,e)}drawPoints(...t){}drawText(t,e,n){this.lastText=t}drawImage(t){this.lastImage=t}startObject(t,e){super.startObject(t),this.objectNestingLevel+=1}endObject(){super.endObject(),this.objectNestingLevel-=1}isTooSmallToRender(t){return!1}canRenderFromWithoutDataLoss(t){return t instanceof s}renderFromOtherOfSameType(t,e){if(!(e instanceof s))throw new Error(`${e} cannot be rendered onto ${this}`);this.renderedPathCount+=e.renderedPathCount,this.lastFillStyle=e.lastFillStyle,this.lastPoint=e.lastPoint,this.pointBuffer.push(...e.pointBuffer.map((e=>t.transformVec2(e))))}}e.default=s},2001:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.renderedStylesheetId=void 0;const i=n(5097),r=n(1697),s=n(2500),a=o(n(7369)),l=n(7444),c=o(n(8315));e.renderedStylesheetId="js-draw-style-sheet";const d="http://www.w3.org/2000/svg",h={fontWeight:"400",fontStyle:"normal"};class u extends a.default{constructor(t,e,n=!1){super(e),this.elem=t,this.sanitize=n,this.lastPathStyle=null,this.lastPathString=[],this.lastContainerIDList=[],this.objectElems=null,this.overwrittenAttrs={},this.textContainer=null,this.textContainerTransform=null,this.textParentStyle=h,this.visibleRectOverride=null,this.clear(),this.addStyleSheet()}addStyleSheet(){if(!this.elem.querySelector(`#${e.renderedStylesheetId}`)){const t=document.createElementNS("http://www.w3.org/2000/svg","style");t.innerHTML="\n\t\t\t\tpath {\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t}\n\n\t\t\t\ttext {\n\t\t\t\t\twhite-space: pre;\n\t\t\t\t}\n\t\t\t".replace(/\s+/g,""),t.setAttribute("id",e.renderedStylesheetId),this.elem.appendChild(t)}}setRootSVGAttribute(t,e){this.sanitize||(t in this.overwrittenAttrs||(this.overwrittenAttrs[t]=this.elem.getAttribute(t)),null!==e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t))}displaySize(){return i.Vec2.of(this.elem.clientWidth,this.elem.clientHeight)}clear(){if(this.lastPathString=[],this.lastContainerIDList=[],!this.sanitize){for(const t in this.overwrittenAttrs){const e=this.overwrittenAttrs[t];e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t)}this.overwrittenAttrs={}}}addPathToSVG(){if(!this.lastPathStyle||0===this.lastPathString.length)return null;const t=document.createElementNS(d,"path");t.setAttribute("d",this.lastPathString.join(" "));const e=this.lastPathStyle;return e.fill.a>0?t.setAttribute("fill",e.fill.toHexString()):t.setAttribute("fill","none"),e.stroke&&(t.setAttribute("stroke",e.stroke.color.toHexString()),t.setAttribute("stroke-width",(0,i.toRoundedString)(e.stroke.width))),this.elem.appendChild(t),this.objectElems?.push(t),t}drawPath(t){const e=t.style,n=(0,l.pathFromRenderable)(t).transformedBy(this.getCanvasToScreenTransform());0!==this.lastPathString.length&&this.lastPathStyle&&(0,s.stylesEqual)(this.lastPathStyle,e)||(this.addPathToSVG(),this.lastPathStyle=e,this.lastPathString=[]),this.lastPathString.push(n.toString())}transformFrom(t,e,n=!1){const o=n?t:this.getCanvasToScreenTransform().rightMul(t);if(o.eq(i.Mat33.identity))e.style.transform="";else{const t=o.toCSSMatrix();e.style.transform=t,e.setAttribute("data-highp-transform",t)}}drawText(t,e,n){const o=(t,e)=>{e.fontFamily!==this.textParentStyle?.fontFamily&&(t.style.fontFamily=e.fontFamily),e.fontVariant!==this.textParentStyle?.fontVariant&&(t.style.fontVariant=e.fontVariant??""),e.fontWeight!==this.textParentStyle?.fontWeight&&(t.style.fontWeight=e.fontWeight??""),e.fontStyle!==this.textParentStyle?.fontStyle&&(t.style.fontStyle=e.fontStyle??""),e.size!==this.textParentStyle?.size&&(t.style.fontSize=e.size+"px");const n=e.renderingStyle.fill.toHexString();if(t.style.fill=n,e.renderingStyle.stroke){const n=e.renderingStyle.stroke;t.style.stroke=n.color.toHexString(),t.style.strokeWidth=n.width+"px"}};if(e=this.getCanvasToScreenTransform().rightMul(e),this.textContainer){const r=document.createElementNS(d,"tspan");r.appendChild(document.createTextNode(t)),this.textContainer.appendChild(r);const s=(e=this.textContainerTransform.inverse().rightMul(e)).transformVec2(i.Vec2.zero);r.setAttribute("x",`${(0,i.toRoundedString)(s.x)}`),r.setAttribute("y",`${(0,i.toRoundedString)(s.y)}`),o(r,n)}else{const i=document.createElementNS(d,"text");i.appendChild(document.createTextNode(t)),this.transformFrom(e,i,!0),o(i,n),this.elem.appendChild(i),this.objectElems?.push(i),this.objectLevel>0&&(this.textContainer=i,this.textContainerTransform=e,this.textParentStyle={...h,...n})}}drawImage(t){let e=t.label??t.image.getAttribute("aria-label")??"";""===e&&(e=t.image.getAttribute("alt")??"");const n=document.createElementNS(d,"image");n.setAttribute("href",t.base64Url),n.setAttribute("width",t.image.getAttribute("width")??""),n.setAttribute("height",t.image.getAttribute("height")??""),n.setAttribute("aria-label",e),this.transformFrom(t.transform,n),this.elem.appendChild(n),this.objectElems?.push(n)}startObject(t){super.startObject(t),this.lastPathString=[],this.lastPathStyle=null,this.textContainer=null,this.textParentStyle=h,this.objectElems=[]}endObject(t,e){if(super.endObject(t),this.addPathToSVG(),this.objectElems){if(t&&!this.sanitize){for(const e of this.objectElems){const n=t[r.svgAttributesDataKey],o=t[r.svgStyleAttributesDataKey];if(n)for(const[t,o]of n)e.setAttribute(t,o);if(o)for(const t of o)e.style.setProperty(t.key,t.value,t.priority)}const e=t[r.svgLoaderAttributeContainerID];let n=[];if(e&&e[0]&&e[0].length&&(n=e[0]),n.length>0&&(0,c.default)(this.lastContainerIDList,n)&&this.lastContainerIDList.length>=n.length-1){const t=n[n.length-1],e=this.elem.querySelectorAll(`g#${t}`);if(e.length>=1){const t=e[0];if(0===t.children.length||this.lastContainerIDList.length>=n.length)for(const e of this.objectElems)e.remove(),t.appendChild(e);else n=[]}}else n=[];this.lastContainerIDList=n}if(e&&this.objectElems)if(1===this.objectElems.length)this.objectElems[0].classList.add(...e);else{const t=document.createElementNS(d,"g");t.classList.add(...e);for(const e of this.objectElems)e.remove(),t.appendChild(e);this.elem.appendChild(t)}}}unimplementedMessage(){throw new Error("Not implemenented!")}beginPath(t){this.unimplementedMessage()}endPath(t){this.unimplementedMessage()}lineTo(t){this.unimplementedMessage()}moveTo(t){this.unimplementedMessage()}traceCubicBezierCurve(t,e,n){this.unimplementedMessage()}traceQuadraticBezierCurve(t,e){this.unimplementedMessage()}drawPoints(...t){t.map((t=>{const e=document.createElementNS(d,"circle");e.setAttribute("cx",`${t.x}`),e.setAttribute("cy",`${t.y}`),e.setAttribute("r","15"),this.elem.appendChild(e)}))}drawSVGElem(t){if(this.sanitize)return;if("style"===t.tagName.toLowerCase()&&t.getAttribute("id")===e.renderedStylesheetId)return;const n=t.cloneNode(!0);this.elem.appendChild(n),this.objectElems?.push(n)}isTooSmallToRender(t){return!1}overrideVisibleRect(t){this.visibleRectOverride=t}getVisibleRect(){return this.visibleRectOverride??super.getVisibleRect()}static fromViewport(t,e=!0){let n,o;"boolean"==typeof e?(n=e,o=!1):(n=e.sanitize??!0,o=e.useViewBoxForPositioning??!1);const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),a=t.getScreenRectSize(),l=t.visibleRect;let c;if(o){const e=t.visibleRect;c=[e.x,e.y,e.w,e.h],(t=t.getTemporaryClone()).resetTransform(i.Mat33.identity)}else c=[0,0,a.x,a.y];s.setAttribute("viewBox",c.map((t=>(0,i.toRoundedString)(t))).join(" ")),s.setAttribute("width",(0,i.toRoundedString)(a.x)),s.setAttribute("height",(0,i.toRoundedString)(a.y)),s.setAttribute("version","1.1"),s.setAttribute("baseProfile","full"),s.setAttribute("xmlns",r);const d=new u(s,t,n);return l.eq(t.visibleRect)||d.overrideVisibleRect(l),{element:s,renderer:d}}}e.default=u},1263:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(7369));class s extends r.default{constructor(t,e){super(t),this.localizationTable=e,this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}displaySize(){return i.Vec2.of(500,500)}clear(){this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}getDescription(){return[this.localizationTable.pathNodeCount(this.pathCount),...this.textNodeCount>0?[this.localizationTable.textNodeCount(this.textNodeCount)]:[],...this.imageNodeCount>0?[this.localizationTable.imageNodeCount(this.imageNodeCount)]:[],...this.descriptionBuilder].join("\n")}beginPath(t){}endPath(t){this.pathCount++}lineTo(t){}moveTo(t){}traceCubicBezierCurve(t,e,n){}traceQuadraticBezierCurve(t,e){}drawText(t,e,n){this.descriptionBuilder.push(this.localizationTable.textNode(t)),this.textNodeCount++}drawImage(t){const e=t.label?this.localizationTable.imageNode(t.label):this.localizationTable.unlabeledImageNode;this.descriptionBuilder.push(e),this.imageNodeCount++}isTooSmallToRender(t){return t.maxDimension<15/this.getSizeOfCanvasPixelOnScreen()}drawPoints(...t){}}e.default=s},7:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=t=>t.toUpperCase()===t&&t.toLowerCase()!==t&&1===t.length,o=t=>t.toLowerCase()===t&&t.toUpperCase()!==t&&1===t.length;class i{constructor(t){this.key=t.key,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.controlOrMeta=t.controlOrMeta}matchesEvent(t){const e=t.key?.toLowerCase(),i=n(t.key??""),r=o(t.key??""),s=(t.ctrlKey??!1)||"control"===e,a=(t.altKey??!1)||"alt"===e,l=(t.metaKey??!1)||"meta"===e,c=(t.shiftKey??i)||"shift"===e,d=t.controlOrMeta||t.ctrlKey||t.metaKey||!1;if(this.key!==t.code){if(this.key.toLowerCase()!==e)return!1;if((i||r)&&this.key!==t.key){if(!(!0===this.shiftKey&&this.key.toUpperCase()===t.key))return!1}}const h=this.controlOrMeta;return(s===this.ctrlKey&&l===this.metaKey&&!h||h&&d)&&a===this.altKey&&(c===this.shiftKey||void 0===this.shiftKey)}toString(){const t=[];return this.ctrlKey&&"control"!==this.key&&t.push("Ctrl"),this.controlOrMeta&&t.push("CtrlOrMeta"),this.altKey&&"alt"!==this.key&&t.push("Alt"),this.metaKey&&"meta"!==this.key&&t.push("Meta"),this.shiftKey&&"shift"!==this.key&&t.push("Shift"),t.push(this.key),t.join("+")}static fromString(t){const e=t=>{let e;n(t)?e=!0:(o(t)||t.length>1)&&(e=!1);const i=t.toLowerCase();return"shift"===i&&(e=!0),{shiftKey:e,ctrlKey:"control"===i||"ctrl"===i,altKey:"alt"===i,metaKey:"meta"===i,controlOrMeta:"control or meta"===i||"ctrlormeta"===i}};if(-1===t.search(/[-+]/)||1===t.length){const n=e(t);return new i({key:t,...n})}const r=/^(.*[-+])?(.+)$/g.exec(t);if(!r)throw new Error(`Invalid shortcut expression, ${t}!`);const s=r[2],a=e(s),l=(r[1]??"").split(/[-+]/);let c=a.shiftKey,d=a.ctrlKey,h=a.altKey,u=a.metaKey,p=a.controlOrMeta;for(const e of l)if(""!==e)switch(e.toLowerCase()){case"shift":c=!0;break;case"anyshift":c=void 0;break;case"ctrl":case"control":d=!0;break;case"meta":u=!0;break;case"ctrlormeta":case"ctrl or meta":case"controlormeta":p=!0;break;case"alt":h=!0;break;default:throw new Error(`Unknown modifier: "${e}" in shortcut ${t}.`)}return new i({key:s,shiftKey:c,ctrlKey:d,altKey:h,metaKey:u,controlOrMeta:p})}}e.default=i},5376:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(1906),r=o(n(7));class s{constructor(t){this.shortcutOverrides=Object.create(null);for(const e in t)this.overrideShortcut(e,t[e])}overrideShortcut(t,e){this.shortcutOverrides[t]=[...e]}matchesShortcut(t,e){let n=this.shortcutOverrides[t];if(!n){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);n=s.shortcuts[t]}for(const t of n)if(t.matchesEvent(e))return!0;return!1}static registerDefaultKeyboardShortcut(t,e,n){if(t in s.shortcuts)return!1;const o=e.map((t=>"string"==typeof t?r.default.fromString(t):t));return s.shortcuts[t]=[...o],s.shortcutDefaultDescriptions[t]=n,!0}static provideShortcutDescription(t,e,n){e in s.shortcutLocalizedDescriptions||(s.shortcutLocalizedDescriptions[e]=Object.create(null)),s.shortcutLocalizedDescriptions[e][t]=n}static getAllShortcutIds(){const t=[];for(const e in this.shortcuts)t.push(e);return t}static getShortcutDefaultKeybindings(t){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);return s.shortcuts[t]}static getShortcutDescription(t,e){return(0,i.matchingLocalizationTable)(e??[],this.shortcutLocalizedDescriptions,this.shortcutDefaultDescriptions)[t]??this.shortcutDefaultDescriptions[t]??null}}s.shortcuts=Object.create(null),s.shortcutDefaultDescriptions=Object.create(null),s.shortcutLocalizedDescriptions=Object.create(null),e.default=s},6843:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBinding=e.KeyboardShortcutManager=void 0;var i=n(5376);Object.defineProperty(e,"KeyboardShortcutManager",{enumerable:!0,get:function(){return o(i).default}});var r=n(7);Object.defineProperty(e,"KeyBinding",{enumerable:!0,get:function(){return o(r).default}})},3311:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{let e=0;const n=t.map((t=>t.id));n.sort();for(const t of n)e===t&&(e=t+1);return e}},1797:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.sendTouchEvent=e.sendPenEvent=void 0;var i=n(1380);Object.defineProperty(e,"sendPenEvent",{enumerable:!0,get:function(){return o(i).default}});var r=n(8783);Object.defineProperty(e,"sendTouchEvent",{enumerable:!0,get:function(){return o(r).default}})},1380:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(4318)),r=n(7520),s=o(n(3311));e.default=(t,e,n,o)=>{const a=(0,s.default)(o??[]),l=i.default.ofCanvasPoint(n,e!==r.InputEvtType.PointerUpEvt,t.viewport,a);return t.toolController.dispatchInputEvent({kind:e,allPointers:o??[l],current:l}),l}},8783:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=r(n(4318)),l=n(7520),c=s(n(3311));e.default=(t,e,n,o)=>{const i=t.viewport.screenToCanvas(n),r=(0,c.default)(o??[]),s=a.default.ofCanvasPoint(i,e!==l.InputEvtType.PointerUpEvt,t.viewport,r,a.PointerDevice.Touch);return t.toolController.dispatchInputEvent({kind:e,allPointers:[...o??[],s],current:s}),s}},2339:function(t,e,n){"use strict";var o,i,r,s,a=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},l=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const d=n(3173),h=n(5381),u=n(9746),p=c(n(7591)),f=c(n(4735)),m=c(n(4321)),g=c(n(6416)),b=c(n(2133)),y=c(n(7998)),v=c(n(9944)),w=c(n(5001)),x=c(n(5730)),S=c(n(7956)),T=n(3258),C=c(n(3534)),P=c(n(6318)),k=c(n(5771)),E=n(5097),z=n(5698),M=c(n(78));class _{constructor(t,e=u.defaultToolbarLocalization){this.editor=t,this.localizationTable=e,o.set(this,[]),i.set(this,{}),r.set(this,[]),s.set(this,null),this.closeColorPickerOverlay=null,_.colorisStarted||((0,h.init)(),_.colorisStarted=!0),this.setupColorPickers()}setupCloseColorPickerOverlay(){this.closeColorPickerOverlay||(this.closeColorPickerOverlay=document.createElement("div"),this.closeColorPickerOverlay.className=`${z.toolbarCSSPrefix}closeColorPickerOverlay`,this.editor.createHTMLOverlay(this.closeColorPickerOverlay),a(this,o,"f").push(this.editor.handlePointerEventsExceptClicksFrom(this.closeColorPickerOverlay,(t=>("pointerdown"===t&&(0,h.close)(),"pointerup"===t&&this.editor.focus(),!0)))))}setupColorPickers(){if(a(this,s,"f"))return void a(this,s,"f").call(this);this.setupCloseColorPickerOverlay();const t=[E.Color4.red.toHexString(),E.Color4.purple.toHexString(),E.Color4.blue.toHexString(),E.Color4.clay.toHexString(),E.Color4.black.toHexString(),E.Color4.white.toHexString()],e=t.length;let n=!1;const i=()=>{try{(0,h.coloris)({el:".coloris_input",format:"hex",selectInput:!1,focusInput:!1,themeMode:"auto",swatches:t})}catch(t){console.warn("Failed to initialize Coloris. Error: ",t),n||(n=!0,document.addEventListener("load",(()=>{i()}),{once:!0}))}};i(),l(this,s,i,"f");a(this,o,"f").push(this.editor.notifier.on(d.EditorEventType.ColorPickerToggled,(t=>{t.kind===d.EditorEventType.ColorPickerToggled&&this.closeColorPickerOverlay&&(this.closeColorPickerOverlay.style.display=t.open?"block":"none")}))),a(this,o,"f").push(this.editor.notifier.on(d.EditorEventType.ColorPickerColorSelected,(n=>{n.kind===d.EditorEventType.ColorPickerColorSelected&&(n=>{let o=!1;for(const e of t)e===n&&(o=!0);o||(t.push(n),t.length>12&&t.splice(e,1),i())})(n.color.toHexString())})))}closeColorPickers(){(0,h.close)?.()}getWidgetUniqueId(t){return t.getUniqueIdIn(a(this,i,"f"))}getWidgetFromId(t){return a(this,i,"f")[t]}getAllWidgets(){return a(this,r,"f")}addWidget(t){const e=t.getUniqueIdIn(a(this,i,"f"));a(this,i,"f")[e]=t,a(this,r,"f").push(t),this.addWidgetInternal(t),this.setupColorPickers()}removeWidget(t){const e=t.getUniqueIdIn(a(this,i,"f"));this.removeWidgetInternal(t),delete a(this,i,"f")[e],l(this,r,a(this,r,"f").filter((e=>e!==t)),"f")}serializeState(){const t={};for(const e in a(this,i,"f"))t[e]=a(this,i,"f")[e].serializeState();return t[_.rootToolbarId]=this.serializeInternal(),JSON.stringify(t)}deserializeState(t){const e=JSON.parse(t),n=_.rootToolbarId;this.deserializeInternal(e[n]);for(const t in e)t!==n&&(t in a(this,i,"f")?a(this,i,"f")[t].deserializeFrom(e[t]):console.warn(`Unable to deserialize widget ${t} — no such widget.`))}serializeInternal(){}deserializeInternal(t){}makeActionButton(t,e,n=!0){"boolean"==typeof n&&(n={mustBeToplevel:n});const o=n.mustBeToplevel??!0,i=n.autoDisableInReadOnlyEditors??!0,r="string"==typeof t?t:t.label;return new C.default(this.editor,"action-button",(()=>"string"==typeof t?null:t.icon),r,e,this.editor.localization,o,i)}addActionButton(t,e,n=!0){const o=this.makeActionButton(t,e,n);return this.addWidget(o),o}addTaggedActionButton(t,e,n,o=!0){const i=this.makeActionButton(e,n,o);return i.setTags(t),this.addWidget(i),i}addSaveButton(t){const e=new M.default(this.editor,this.localizationTable,t);return e.setTags([T.ToolbarWidgetTag.Save]),this.addWidget(e),e}addExitButton(t){return this.addTaggedActionButton([T.ToolbarWidgetTag.Exit],{label:this.editor.localization.exit,icon:this.editor.icons.makeCloseIcon()},(()=>{t()}),{autoDisableInReadOnlyEditors:!1})}addUndoRedoButtons(t=!0){const e=()=>this.addTaggedActionButton([T.ToolbarWidgetTag.Undo],{label:this.localizationTable.undo,icon:this.editor.icons.makeUndoIcon()},(()=>{this.editor.history.undo()})),n=()=>this.addTaggedActionButton([T.ToolbarWidgetTag.Redo],{label:this.localizationTable.redo,icon:this.editor.icons.makeRedoIcon()},(()=>{this.editor.history.redo()}));let o,i;t?(o=e(),i=n()):(i=n(),o=e()),o.setDisabled(!0),i.setDisabled(!0),this.editor.notifier.on(d.EditorEventType.UndoRedoStackUpdated,(t=>{if(t.kind!==d.EditorEventType.UndoRedoStackUpdated)throw new Error("Wrong event type!");o.setDisabled(0===t.undoStackSize),i.setDisabled(0===t.redoStackSize)}))}addDefaultToolWidgets(){const t=this.editor.toolController;for(const e of t.getMatchingTools(b.default)){const t=new y.default(this.editor,e,this.localizationTable);this.addWidget(t)}for(const e of t.getMatchingTools(g.default))this.addWidget(new v.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(p.default))this.addWidget(new w.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(m.default))this.addWidget(new x.default(this.editor,e,this.localizationTable));const e=t.getMatchingTools(f.default)[0];e&&this.addWidget(new S.default(this.editor,e,this.localizationTable)),this.addWidget(new k.default(this.editor,this.localizationTable)),this.addWidget(new P.default(this.editor,this.localizationTable))}addDefaultActionButtons(){this.addUndoRedoButtons()}remove(){this.closeColorPickerOverlay?.remove();for(const t of a(this,o,"f"))t.remove();l(this,o,[],"f"),this.onRemove()}manageListener(t){a(this,o,"f").push(t)}}o=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,_.colorisStarted=!1,_.rootToolbarId="root-toolbar--",e.default=_},9997:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeDropdownToolbar=void 0;const i=n(9746),r=o(n(3359)),s=o(n(2339)),a=n(5698);e.makeDropdownToolbar=t=>new l(t,t.getRootElement());class l extends s.default{constructor(t,e,n=i.defaultToolbarLocalization){super(t,n),this.widgetOrderCounter=0,this.overflowWidget=null,this.reLayoutQueued=!1,this.container=document.createElement("div"),this.container.classList.add(`${a.toolbarCSSPrefix}root`),this.container.classList.add(`${a.toolbarCSSPrefix}element`),this.container.classList.add(`${a.toolbarCSSPrefix}dropdown-toolbar`),this.container.setAttribute("role","toolbar"),e.appendChild(this.container),"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver((t=>{this.reLayout()})),this.resizeObserver.observe(this.container)):console.warn("ResizeObserver not supported. Toolbar will not resize.")}queueReLayout(){this.reLayoutQueued||(this.reLayoutQueued=!0,requestAnimationFrame((()=>this.reLayout())))}reLayout(){if(this.reLayoutQueued=!1,!this.overflowWidget)return;const t=t=>{let e=0;for(const n of t)n.isHidden()||(e+=n.getButtonWidth());return e},e=this.getAllWidgets();let n=t(this.overflowWidget.getChildWidgets()),o=t(e)-n,i=.87*this.container.clientWidth;window.innerHeight>1.75*i&&(i*=1.75);let r=!1;if((t=>{const e=this.overflowWidget?.getChildWidgets()??[];return 0!==e.length&&e[0].getButtonWidth()<=t})(i-o)){const t=this.overflowWidget.clearChildren();for(const e of t)e.addTo(this.container),e.setIsToplevel(!0),e.isHidden()||(o+=e.getButtonWidth());n=0,r=!0}if(o>=i){for(let t=e.length-1;t>=0&&o>=i;t--){const n=e[t];this.overflowWidget.hasAsChild(n)||n.canBeInOverflowMenu()&&(o-=n.getButtonWidth(),this.overflowWidget.addToOverflow(n))}r=!0}this.overflowWidget.setHidden(0===this.overflowWidget.getChildWidgets().length),r&&this.setupColorPickers()}addWidgetInternal(t){t.addTo(this.container).style.order=""+this.widgetOrderCounter++,this.queueReLayout()}removeWidgetInternal(t){t.remove(),this.queueReLayout()}addSpacer(t={}){const e=document.createElement("div");e.classList.add(`${a.toolbarCSSPrefix}spacer`),t.grow&&(e.style.flexGrow=`${t.grow}`),t.minSize&&(e.style.minWidth=t.minSize),t.maxSize&&(e.style.maxWidth=t.maxSize),e.style.order=""+this.widgetOrderCounter++,this.container.appendChild(e)}addOverflowWidget(){this.overflowWidget=new r.default(this.editor,this.localizationTable),this.addWidget(this.overflowWidget)}addDefaults(){this.addDefaultToolWidgets(),this.addOverflowWidget(),this.addDefaultActionButtons()}onRemove(){this.container.remove(),this.resizeObserver.disconnect()}}e.default=l},5221:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeEdgeToolbar=void 0;const i=n(3258),r=n(5698),s=o(n(5132)),a=n(1151),l=o(n(2339)),c=o(n(9441));e.makeEdgeToolbar=t=>new d(t,t.getRootElement(),t.localization);class d extends l.default{constructor(t,e,n){super(t,n),this.toolbarContainer=document.createElement("div"),this.toolbarContainer.classList.add(`${r.toolbarCSSPrefix}root`),this.toolbarContainer.classList.add(`${r.toolbarCSSPrefix}element`),this.toolbarContainer.classList.add(`${r.toolbarCSSPrefix}edge-toolbar`),this.toolbarContainer.setAttribute("role","toolbar"),this.toolbarActionRow=document.createElement("div"),this.toolbarActionRow.classList.add("toolbar-element","toolbar-action-row"),this.toolbarToolRow=document.createElement("div"),this.toolbarToolRow.classList.add("toolbar-element","toolbar-tool-row"),(0,c.default)(this.toolbarToolRow),"ResizeObserver"in window?(this.toolRowResizeObserver=new ResizeObserver((t=>{this.onToolbarRowResize()})),this.toolRowResizeObserver.observe(this.toolbarToolRow)):console.warn("ResizeObserver not supported. Toolbar will not resize."),this.toolbarContainer.replaceChildren(this.toolbarActionRow,this.toolbarToolRow),e.appendChild(this.toolbarContainer),this.sidebarVisible=a.ReactiveValue.fromInitialValue(!1),this.sidebarY=a.ReactiveValue.fromInitialValue(0),this.menuContainer=document.createElement("div"),this.menuContainer.classList.add(`${r.toolbarCSSPrefix}edgemenu-container`),this.sidebarContainer=document.createElement("div"),this.sidebarContainer.classList.add(`${r.toolbarCSSPrefix}edgemenu`,`${r.toolbarCSSPrefix}element`),this.sidebarContainer.classList.add(`${r.toolbarCSSPrefix}tool-properties`),this.sidebarContent=document.createElement("div"),this.sidebarY.onUpdateAndNow((t=>{const e="dropdown-below-edge";t>0?(this.sidebarContainer.style.transform=`translate(0, ${t}px)`,this.sidebarContainer.style.paddingBottom="",this.menuContainer.classList.add(e)):(this.sidebarContainer.style.transform="",this.sidebarContainer.style.paddingBottom=-t+"px",this.menuContainer.classList.remove(e))})),this.closeButton=document.createElement("button"),this.closeButton.classList.add("drag-elem"),this.editor.handleKeyEventsFrom(this.closeButton,(t=>"Space"!==t.code&&"Enter"!==t.code&&"Tab"!==t.code)),this.sidebarContainer.addEventListener("keyup",(t=>{t.defaultPrevented||"Escape"!==t.code||(this.sidebarVisible.set(!1),t.preventDefault())})),this.initDragListeners();this.sidebarTitle=a.MutableReactiveValue.fromInitialValue(""),this.layoutManager=new s.default(((...t)=>{this.sidebarContent.replaceChildren(...t),this.setupColorPickers()}),this.sidebarTitle,this.sidebarVisible,t.announceForAccessibility.bind(t),n),this.sidebarTitle.onUpdateAndNow((t=>{this.closeButton.setAttribute("aria-label",n.closeSidebar(t))})),this.listenForVisibilityChanges(),this.sidebarContainer.replaceChildren(this.closeButton,this.sidebarContent),this.menuContainer.replaceChildren(this.sidebarContainer),e.appendChild(this.menuContainer)}listenForVisibilityChanges(){let t=null;this.sidebarVisible.get()||(this.menuContainer.style.display="none",this.menuContainer.style.opacity="0"),this.sidebarVisible.onUpdate((e=>{const n="170ms ease";e?(this.sidebarY.set(this.snappedSidebarY()),t&&(clearTimeout(t),t=null),this.menuContainer.style.display="",this.sidebarContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-transition-in`,this.menuContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-container-transition-in`,this.menuContainer.style.opacity="1",this.closeButton.focus()):(this.closeColorPickers(),null===t&&(this.sidebarContainer.style.animation=` ${n} ${r.toolbarCSSPrefix}-edgemenu-transition-out`,this.menuContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-container-transition-out`,this.menuContainer.style.opacity="0",this.editor.announceForAccessibility(this.localizationTable.dropdownHidden(this.sidebarTitle.get())),t=setTimeout((()=>{this.menuContainer.style.display="none",this.menuContainer.style.overflowY="",t=null}),170)))}))}onToolbarRowResize(){const t=()=>{const t=this.toolbarToolRow.clientWidth;let e=0,n=0,o=0;for(const i of this.toolbarToolRow.children){const r=i.clientHeight;if(e+=r,o++,e>t){n=t-e+r/2,n<0&&(n+=r);break}}const i=Math.round(n/o*10)/10;this.toolbarToolRow.style.setProperty("--extra-left-right-padding",`${i}px`)},e=this.toolbarActionRow.getBoundingClientRect(),n=this.toolbarToolRow.getBoundingClientRect();e.y+e.height<=n.y?this.toolbarContainer.classList.remove("one-row"):this.toolbarContainer.classList.add("one-row"),this.toolbarToolRow.clientWidth<this.toolbarToolRow.scrollWidth?(this.toolbarToolRow.classList.add("has-scroll"),t()):this.toolbarToolRow.classList.remove("has-scroll","extra-padding")}addSpacer(t){}addUndoRedoButtons(){super.addUndoRedoButtons(!1)}addDefaults(){this.addDefaultActionButtons(),this.addDefaultToolWidgets()}updateWidgetCSSClasses(t){const e=t.getTags();t.removeCSSClassFromContainer("label-inline"),t.removeCSSClassFromContainer("label-left"),t.removeCSSClassFromContainer("label-right"),e.includes(i.ToolbarWidgetTag.Save)&&(t.addCSSClassToContainer("label-inline"),t.addCSSClassToContainer("label-right")),e.includes(i.ToolbarWidgetTag.Exit)&&(t.addCSSClassToContainer("label-inline"),t.addCSSClassToContainer("label-left"))}addWidgetInternal(t){this.updateWidgetCSSClasses(t),t.setLayoutManager(this.layoutManager),t.mustBeInToplevelMenu()?t.addTo(this.toolbarActionRow):t.addTo(this.toolbarToolRow)}removeWidgetInternal(t){t.remove()}onRemove(){this.toolbarContainer.remove(),this.menuContainer.remove(),this.toolRowResizeObserver.disconnect()}initDragListeners(){let t=0,e=0,n=0,o=0,i=!1,r=null;const s=[this.closeButton,this.sidebarContainer,this.sidebarContent];this.manageListener(this.editor.handlePointerEventsExceptClicksFrom(this.menuContainer,((t,e)=>e.target===this.menuContainer?("pointerdown"===t&&this.sidebarVisible.set(!1),"pointerup"===t&&this.editor.focus(),!0):!this.sidebarVisible.get()),((t,e)=>e.target===this.menuContainer)));const a=t=>{if(!t)return!1;if(s.includes(t))return!0;const e=["INPUT","SELECT","IMG"];let n=!1,o=t.parentElement;for(;o&&!e.includes(o.tagName);){if(o===this.sidebarContainer){n=!0;break}o=o.parentElement}return!e.includes(t.tagName)&&n},l=()=>Math.hypot(t-n,e-o)<5;let c=!1;this.sidebarContainer.addEventListener("pointerdown",(s=>{!s.defaultPrevented&&a(s.target)&&s.isPrimary&&(c=!1,t=s.clientX,e=s.clientY,n=s.clientX,o=s.clientY,r=null,i=!0)}),{passive:!0});let d=0;const h=t=>{i&&(d=performance.now(),null!==r&&(this.sidebarContainer.releasePointerCapture(r),r=null),this.finalizeDrag(),i=!1,c=!1)};this.sidebarContainer.onpointermove=n=>{if(!n.isPrimary||!i)return;if("mouse"===n.pointerType&&0===n.buttons)return void h();null!==r||l()||(this.sidebarContainer.setPointerCapture(n.pointerId),r=n.pointerId);const s=n.clientX,a=n.clientY,d=s-t,u=a-e;(Math.abs(a-o)>5||c)&&(this.handleDrag(d,u),t=s,e=a,c=!0)},this.sidebarContainer.onpointerleave=t=>{null===r&&i&&t.isPrimary&&(this.sidebarContainer.setPointerCapture(t.pointerId),r=t.pointerId)},this.closeButton.onclick=()=>{const t=performance.now()-d<100,e=l();(t&&e||!t)&&this.sidebarVisible.set(!1)},this.sidebarContainer.onpointerup=h,this.sidebarContainer.onpointercancel=h}handleDrag(t,e){this.sidebarContainer.style.transition="none",this.sidebarY.set(this.sidebarY.get()+e)}snappedSidebarY(t){const e=t??this.sidebarY.get(),n=[-100,0];this.sidebarContainer.clientHeight>window.innerHeight&&n.push(100);let o=n[0];for(const t of n)Math.abs(t-e)<Math.abs(o-e)&&(o=t);return o}finalizeDrag(){this.sidebarContainer.style.transition="",this.sidebarY.get()>this.sidebarContainer.clientHeight/2?this.sidebarVisible.set(!1):this.sidebarY.set(this.snappedSidebarY())}serializeInternal(){return{menuSizeY:this.snappedSidebarY()}}deserializeInternal(t){"object"==typeof t&&"number"==typeof t.menuSizeY&&this.sidebarY.set(this.snappedSidebarY(t.menuSizeY))}}e.default=d},8282:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=s(n(2001)),c=s(n(5566)),d=n(6951),h="http://www.w3.org/2000/svg",u="\n\tstyle='fill: var(--icon-color);'\n";let p=0;const f=()=>{const t="checkerboard-"+p++;return{patternDef:`\n\t\t<pattern\n\t\t\tid='${t}'\n\t\t\tviewBox='0,0,10,10'\n\t\t\twidth='20%'\n\t\t\theight='20%'\n\t\t\tpatternUnits='userSpaceOnUse'\n\t\t>\n\t\t\t<rect x='0' y='0' width='10' height='10' fill='white'/>\n\t\t\t<rect x='0' y='0' width='5' height='5' fill='gray'/>\n\t\t\t<rect x='5' y='5' width='5' height='5' fill='gray'/>\n\t\t</pattern>\n\t`,patternRef:`url(#${t})`}},m=t=>{const e=document.createElementNS(h,"svg");return e.innerHTML=`\n\t\t<style>\n\t\t\t.toolbar-svg-undo-redo-icon {\n\t\t\t\tstroke: var(--icon-color);\n\t\t\t\tstroke-width: 12;\n\t\t\t\tstroke-linejoin: round;\n\t\t\t\tstroke-linecap: round;\n\t\t\t\tfill: none;\n\n\t\t\t\ttransform-origin: center;\n\t\t\t}\n\t\t</style>\n\t\t<path\n\t\t\td='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'\n\t\t\tclass='toolbar-svg-undo-redo-icon'\n\t\t\tstyle='${t?"transform: scale(-1, 1);":""}'/>\n\t`,e.setAttribute("viewBox","0 0 100 100"),e};o=new WeakSet,i=function(){return this.makeIconFromPath("\n\t\t\tM 15,15 85,85\n\t\t\tM 15,85 85,15\n\t\t","none","var(--icon-color)","6px")},e.default=class{constructor(){o.add(this)}makeUndoIcon(){return m(!0)}makeRedoIcon(){return m(!1)}makeDropdownIcon(){const t=document.createElementNS(h,"svg");return t.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\td='M5,10 L50,90 L95,10 Z'\n\t\t\t\t${u}\n\t\t\t/>\n\t\t</g>\n\t\t`,t.setAttribute("viewBox","-10 -10 110 110"),t}makeEraserIcon(t){const e=document.createElementNS(h,"svg");t??=10;const n=t/4;return e.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\tstyle="fill:#ff70af"\n\t\t\t\tstroke="black"\n\t\t\t\ttransform="rotate(41.35)"\n\t\t\t\td="M 52.5 27\n\t\t\t\t\tC 50 28.9 48.9 31.7 48.9 34.8\n\t\t\t\t\tL 48.9 39.8\n\t\t\t\t\tC 48.9 45.3 53.4 49.8 58.9 49.8\n\t\t\t\t\tL 103.9 49.8\n\t\t\t\t\tC 105.8 49.8 107.6 49.2 109.1 48.3\n\t\t\t\t\tL 110.2 ${n+49.5} L 159.7 ${n+5}\n\t\t\t\t\tL 157.7 ${5.2-n} L 112.4 ${49.5-n}\n\t\t\t\t\tC 113.4 43.5 113.9 41.7 113.9 39.8\n\t\t\t\t\tL 113.9 34.8\n\t\t\t\t\tC 113.9 29.3 109.4 24.8 103.9 24.8\n\t\t\t\t\tL 58.9 24.8\n\t\t\t\t\tC 56.5 24.8 54.3 25.7 52.5 27\n\t\t\t\t\tz "\n\t\t\t\tid="path438" />\n\n\t\t\t<rect\n\t\t\t\tstroke="#cc8077"\n\t\t\t\t${u}\n\t\t\t\tid="rect218"\n\t\t\t\twidth="65"\n\t\t\t\theight="75"\n\t\t\t\tx="48.9"\n\t\t\t\ty="-38.7"\n\t\t\t\ttransform="rotate(41.35)" />\n\t\t</g>\n\t\t`,e.setAttribute("viewBox","0 0 120 120"),e}makeSelectionIcon(){const t=document.createElementNS(h,"svg");return t.innerHTML="\n\t\t<g>\n\t\t\t<rect x=10 y=10 width=70 height=70 fill='pink' stroke='black'/>\n\t\t\t<rect x=75 y=75 width=10 height=10 fill='white' stroke='black'/>\n\t\t</g>\n\t\t",t.setAttribute("viewBox","0 0 100 100"),t}makeRotateIcon(){const t=document.createElementNS(h,"svg");return t.innerHTML='\n\t\t\t<defs>\n\t\t\t\t<marker\n\t\t\t\t\tid="arrow-marker"\n\t\t\t\t\tviewBox="0 0 10 10"\n\t\t\t\t\trefX="3" refY="5"\n\t\t\t\t\tmarkerWidth="3" markerHeight="3"\n\t\t\t\t\torient="auto-start-reverse"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td="M0,0 L8,5 L0,10z"\n\t\t\t\t\t\tfill="var(--icon-color)"\n\t\t\t\t\t/>\n\t\t\t\t</marker>\n\t\t\t</defs>\n\n\t\t\t<path\n\t\t\t\tmarker-start="url(#arrow-marker)"\n\t\t\t\td="\n\t\t\t\t\tM20,20\n\t\t\t\t\tA30,30 0 1 1 80 80\n\t\t\t\t"\n\t\t\t\tfill="none"\n\t\t\t\tstroke="var(--icon-color)"\n\t\t\t\tstroke-width="12"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\td="\n\t\t\t\t\tM80,80\n\t\t\t\t\tA30,30 0 1 1 20 20\n\t\t\t\t"\n\t\t\t\tfill="none"\n\t\t\t\tstroke="var(--icon-color)"\n\t\t\t\tstroke-width="12"\n\t\t\t\tstroke-dasharray="30 10 20 10 20 10 10"\n\t\t\t\tstyle="stroke-linecap: butt;"\n\t\t\t/>\n\t\t',t.setAttribute("viewBox","-5 -5 110 110"),t}makeHandToolIcon(){return this.makeIconFromPath("\n\t\t\tm 10,60\n\t\t\t\t5,30\n\t\t\tH 90\n\t\t\tV 30\n\t\t\tC 90,20 75,20 75,30\n\t\t\tV 60\n\t\t\t\t20\n\t\t\tC 75,10 60,10 60,20\n\t\t\tV 60\n\t\t\t\t15\n\t\t\tC 60,5 45,5 45,15\n\t\t\tV 60\n\t\t\t\t25\n\t\t\tC 45,15 30,15 30,25\n\t\t\tV 60\n\t\t\t\t75\n\t\t\tL 25,60\n\t\t\tC 20,45 10,50 10,60\n\t\t\tZ\n\t\t","none","var(--icon-color)","3")}makeTouchPanningIcon(){return this.makeIconFromPath("\n\t\t\tM 5,5.5\n\t\t\tV 17.2\n\t\t\tL 16.25,5.46\n\t\t\tZ\n\t\n\t\t\tm 33.75,0\n\t\t\tL 50,17\n\t\t\tV 5.5\n\t\t\tZ\n\t\n\t\t\tM 5,40.7\n\t\t\tv 11.7\n\t\t\th 11.25\n\t\t\tz\n\t\n\t\t\tM 26,19\n\t\t\tC 19.8,19.4 17.65,30.4 21.9,34.8\n\t\t\tL 50,70\n\t\t\tH 27.5\n\t\t\tc -11.25,0 -11.25,17.6 0,17.6\n\t\t\tH 61.25\n\t\t\tC 94.9,87.8 95,87.6 95,40.7 78.125,23 67,29 55.6,46.5\n\t\t\tL 33.1,23\n\t\t\tC 30.3125,20.128192 27.9,19 25.830078,19.119756\n\t\t\tZ\n\t\t","none","var(--icon-color)","3")}makeAllDevicePanningIcon(){return this.makeIconFromPath("\n\t\t\tM 5 5\n\t\t\tL 5 17.5\n\t\t\t\t17.5 5\n\t\t\t\t5 5\n\t\t\tz\n\t\n\t\t\tM 42.5 5\n\t\t\tL 55 17.5\n\t\t\t\t55 5\n\t\t\t\t42.5 5\n\t\t\tz\n\t\n\t\t\tM 70 10\n\t\t\tL 70 21\n\t\t\t\t61 15\n\t\t\t\t55.5 23\n\t\t\t\t66 30\n\t\t\t\t56 37\n\t\t\t\t61 45\n\t\t\t\t70 39\n\t\t\t\t70 50\n\t\t\t\t80 50\n\t\t\t\t80 39\n\t\t\t\t89 45\n\t\t\t\t95 36\n\t\t\t\t84 30\n\t\t\t\t95 23\n\t\t\t\t89 15\n\t\t\t\t80 21\n\t\t\t\t80 10\n\t\t\t\t70 10\n\t\t\tz\n\t\n\t\t\tM 27.5 26.25\n\t\t\tL 27.5 91.25\n\t\t\tL 43.75 83.125\n\t\t\tL 52 99\n\t\t\tL 68 91\n\t\t\tL 60 75\n\t\t\tL 76.25 66.875\n\t\t\tL 27.5 26.25\n\t\t\tz\n\t\n\t\t\tM 5 42.5\n\t\t\tL 5 55\n\t\t\tL 17.5 55\n\t\t\tL 5 42.5\n\t\t\tz\n\t\t","none","var(--icon-color)","3")}makeZoomIcon(){const t=document.createElementNS(h,"svg");t.setAttribute("viewBox","0 0 100 100");const e=(e,n,o)=>{const i=document.createElementNS(h,"text");i.appendChild(document.createTextNode(e)),i.setAttribute("x",n.toString()),i.setAttribute("y",o.toString()),i.style.textAlign="center",i.style.textAnchor="middle",i.style.fontSize="55px",i.style.fill="var(--icon-color)",i.style.fontFamily="monospace",t.appendChild(i)};return e("+",40,45),e("-",70,75),t}makeRotationLockIcon(){const t=this.makeIconFromPath("\n\t\t\tM 40.1 25.1 \n\t\t\tC 32.5 25 27.9 34.1 27.9 34.1 \n\t\t\tL 25.7 30 \n\t\t\tL 28 44.7 \n\t\t\tL 36.6 40.3 \n\t\t\tL 32.3 38.3 \n\t\t\tC 33.6 28 38.1 25.2 45.1 31.8 \n\t\t\tL 49.4 29.6 \n\t\t\tC 45.9 26.3 42.8 25.1 40.1 25.1 \n\t\t\tz\n\n\t\t\tM 51.7 34.2 \n\t\t\tL 43.5 39.1 \n\t\t\tL 48 40.8 \n\t\t\tC 47.4 51.1 43.1 54.3 35.7 48.2 \n\t\t\tL 31.6 50.7 \n\t\t\tC 45.5 62.1 52.6 44.6 52.6 44.6 \n\t\t\tL 55.1 48.6 \n\t\t\tL 51.7 34.2 \n\t\t\tz\n\n\t\t\tM 56.9 49.9 \n\t\t\tC 49.8 49.9 49.2 57.3 49.3 60.9 \n\t\t\tL 47.6 60.9 \n\t\t\tL 47.6 73.7 \n\t\t\tL 66.1 73.7 \n\t\t\tL 66.1 60.9 \n\t\t\tL 64.4 60.9 \n\t\t\tC 64.5 57.3 63.9 49.9 56.9 49.9 \n\t\t\tz\n\n\t\t\tM 56.9 53.5 \n\t\t\tC 60.8 53.5 61 58.2 60.8 60.9 \n\t\t\tL 52.9 60.9 \n\t\t\tC 52.7 58.2 52.9 53.5 56.9 53.5 \n\t\t\tz\n\t\t");return t.setAttribute("viewBox","10 10 70 70"),t}makeInsertImageIcon(){return this.makeIconFromPath("\n\t\t\tM 5 10 L 5 90 L 95 90 L 95 10 L 5 10 z\n\t\t\tM 10 15 L 90 15 L 90 50 L 70 75 L 40 50 L 10 75 L 10 15 z\n\t\t\tM 22.5 25 A 7.5 7.5 0 0 0 15 32.5 A 7.5 7.5 0 0 0 22.5 40 A 7.5 7.5 0 0 0 30 32.5 A 7.5 7.5 0 0 0 22.5 25 z \n\t\t")}makeUploadFileIcon(){return this.makeIconFromPath("\n\t\t\tM 48,10 32,34 43,33 42,68\n\t\t\tH 54\n\t\t\tL 53,33 64,34 Z\n\t\n\t\t\tM 8,66 V 86 H 88 V 66 H 78 V 76 H 18 V 66 Z\n\t\t")}makeTextIcon(t){const e=document.createElementNS(h,"svg");e.setAttribute("viewBox","0 0 100 100");const n=document.createElementNS(h,"text");return n.appendChild(document.createTextNode("T")),n.style.fontFamily=t.fontFamily,n.style.fontWeight=t.fontWeight??"",n.style.fontVariant=t.fontVariant??"",n.style.fill=t.renderingStyle.fill.toHexString(),n.style.textAnchor="middle",n.setAttribute("x","50"),n.setAttribute("y","75"),n.style.fontSize="65px",n.style.filter="drop-shadow(0px 0px 10px var(--shadow-color))",e.appendChild(n),e}makePenIcon(t){const e=Math.round(4*Math.sqrt(t.thickness)),n=t.color,o=this.isRoundedTipPen(t),i=document.createElementNS(h,"svg");i.setAttribute("viewBox","0 0 100 100");const r=e/2,s=`\n\t\t\tM ${15-r},${80-r}\n\t\t\t ${15-r},${80+r}\n\t\t\t 30,83\n\t\t\t 15,65\n\t\t\tZ\n\t\t`,l=80+r,c=`\n\t\t\tm ${15-1.1*r},${l}\n\t\t\tc 35,10 55,15 60,30\n\t\t\tl ${35+1.2*r},${-10-r}\n\t\t\tC 80.47,98.32 50.5,${90+r} 20,${l} Z\n\t\t`,d="\n\t\t\tM 72.45,35.67\n\t\t\tA 10,15 41.8 0 1 55,40.2 10,15 41.8 0 1 57.55,22.3 10,15 41.8 0 1 75,17.8 10,15 41.8 0 1 72.5,35.67\n\t\t\tZ\n\t\t";let u="M 85,-25 25,35 h 10 v 10 h 10 v 10 h 10 v 10 h 10 l -5,10 60,-60 z",p="M 25,35 H 35 L 90,-15 85,-25 Z",m="M 60,75 65,65 H 55 l 55,-55 10,5 z";o&&(u="M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z",p="m 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z",m="M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z");const g=`M 25,35 ${10-r/4},${70-r/2} 20,75 25,85 60,75 70,55 45,25 Z`,b=a.Color4.fromHex("#f4d7d7").mix(n,r/40-.1).toHexString(),y=f(),v=`\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${n}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${n}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t`,w=`\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${b}"\n\t\t\t\tstroke="${n}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t`,x=`\n\t\t\t<path\n\t\t\t\t\n\tstyle='fill: var(--icon-color); stroke: var(--icon-color);'\n\n\t\t\t\td="${u}"\n\t\t\t/>\n\n\t\t\t\x3c!-- shadows --\x3e\n\t\t\t<path\n\t\t\t\tfill="rgba(150, 150, 150, 0.3)"\n\t\t\t\td="${p}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="rgba(100, 100, 100, 0.2)"\n\t\t\t\td="${m}"\n\t\t\t/>\n\n\t\t\t\x3c!-- color bubble --\x3e\n\t\t\t<path\n\t\t\t\tfill="${y.patternRef}"\n\t\t\t\td="${d}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${n}"\n\t\t\t\td="${d}"\n\t\t\t/>\n\t\t`;return i.innerHTML=`\n\t\t<defs>\n\t\t\t${y.patternDef}\n\t\t</defs>\n\t\t<g>\n\t\t\t${v}\n\t\t\t${w}\n\t\t\t${x}\n\t\t</g>\n\t\t`,i}makeIconFromFactory(t){const e=3*Math.sqrt(t.thickness),n=performance.now(),o={pos:a.Vec2.of(10,10),width:e,color:t.color,time:n-100},i={pos:a.Vec2.of(90,90),width:e,color:t.color,time:n},r=new c.default((()=>{})),s=t.factory(o,r);s.addPoint(i);const d=document.createElementNS(h,"svg");let u;d.setAttribute("viewBox","0 0 100 100"),r.updateScreenSize(a.Vec2.of(100,100));if(t.color.a<1){const t=f(),e=document.createElementNS(h,"defs");e.innerHTML=t.patternDef,d.appendChild(e);const n=document.createElementNS(h,"g");d.appendChild(n),u=new class extends l.default{constructor(){super(d,r)}addPathToSVG(){const e=super.addPathToSVG();if(e){const o=e.cloneNode(!0);o.style.zIndex="-1",o.hasAttribute("stroke")?o.setAttribute("stroke",t.patternRef):o.hasAttribute("fill")&&o.setAttribute("fill",t.patternRef),n.appendChild(o)}return e}}}else u=new l.default(d,r);s.preview(u);const p=s.getBBox();return d.setAttribute("viewBox",`${p.x} ${p.y} ${p.w} ${p.h}`),d}makePipetteIcon(t){const e=document.createElementNS(h,"svg"),n=document.createElementNS(h,"g");n.style.rotate="45deg",n.style.transformOrigin="center";const o=document.createElementNS(h,"g");if(o.innerHTML='\n\t\t<path\n\t\t\tstyle="fill: var(--icon-color); stroke-linecap:round; stroke-linejoin:round;"\n\t\t\td="\n\t\t\t\tm 32,12 v 68\n\t\t\t\tc 0,1 0.5,2 1.33,2.5 1.67,1.15 3.67,2.1 5.17,3.2 1.4,1.1 2.3,2.1 2.5,3.1 0.6,2.1 1,4.6 1,6.2 0,3.7 5.45,4.1 6,0.4 l 0.9,-6.8\n\t\t\t\tc 0.3,-0.9 1.1,-1.9 2.6,-2.9 1.5,-1.1 3.4,-2 5.1,-3.2\n\t\t\t\tC 57.5,82 58,81 58,80\n\t\t\t\tV 12 Z m 20,25 v 41.3\n\t\t\t\tc 0,1.7 -2.5,1.6 -4,2.7 -1,0.76 -2.1,1.5 -3,2.6\n\t\t\t\tC 44,82.5 43.02,81.75 42,81 40.51,79.92 38,80 38,78.34\n\t\t\t\tV 51 Z\n\t\t\t"\n\t\t/>\n\t\t<rect\n\t\t\tstyle="fill: var(--icon-color);"\n\t\t\twidth="32"\n\t\t\theight="9"\n\t\t\tx="29"\n\t\t\ty="2"\n\t\t\try="4.5"\n\t\t/>\n\t\t<path\n\t\t\tstyle="fill: var(--icon-color);"\n\t\t\td="m 45,-25 c -5.54,0 -11,4.26 -11,9 V 0 h 22 v -16 c 0,-4.74 -5.46,-9 -11,-9 z"\n\t\t/>\n\t\t',t){const o=f(),i=document.createElementNS(h,"defs");i.innerHTML=o.patternDef,e.appendChild(i);const r=document.createElementNS(h,"path"),s=document.createElementNS(h,"path"),a="\n\t\t\t\tM 35,36 H 55 V 78.678012 83 L 45,87 35,83 Z\n\t\t\t";s.setAttribute("d",a),r.setAttribute("d",a),s.style.fill=t.toHexString(),r.style.fill=o.patternRef,n.appendChild(r),n.appendChild(s)}return n.appendChild(o),e.appendChild(n),e.setAttribute("viewBox","5 -40 140 140"),e}makeFormatSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 5 10\n\t\t\tL 5 20 L 10 20 L 10 15 L 20 15 L 20 40 L 15 40 L 15 45 L 35 45 L 35 40 L 30 40 L 30 15 L 40 15 L 40 20 L 45 20 L 45 15 L 45 10 L 5 10 z\n\t\t\tM 90 10 C 90 10 86.5 13.8 86 14 C 86 14 76.2 24.8 76 25 L 60 25 L 60 65 C 75 70 85 70 90 65 L 90 25 L 80 25 L 76.7 25 L 90 10 z\n\t\t\tM 60 25 L 55 25 L 50 30 L 60 25 z\n\t\t\tM 10 55 L 10 90 L 41 90 L 41 86 L 45 86 L 45 55 L 10 55 z\n\t\t\tM 42 87 L 42 93 L 48 93 L 48 87 L 42 87 z \n\t\t")}makeResizeImageToSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 75 5 75 10 90 10 90 25 95 25 95 5 75 5 z\n\t\t\tM 15 15 15 30 20 30 20 20 30 20 30 15 15 15 z\n\t\t\tM 84 15 82 17 81 16 81 20 85 20 84 19 86 17 84 15 z\n\t\t\tM 26 24 24 26 26 28 25 29 29 29 29 25 28 26 26 24 z\n\t\t\tM 25 71 26 72 24 74 26 76 28 74 29 75 29 71 25 71 z\n\t\t\tM 15 75 15 85 25 85 25 80 20 80 20 75 15 75 z\n\t\t\tM 90 75 90 90 75 90 75 95 95 95 95 75 90 75 z\n\t\t\tM 81 81 81 85 82 84 84 86 86 84 84 82 85 81 81 81 z\n\t\t")}makeResizeViewportIcon(){return this.makeResizeImageToSelectionIcon()}makeDuplicateSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 45,10 45,55 90,55 90,10 45,10 z\n\t\t\tM 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z \n\t\t")}makePasteIcon(){const t=this.makeIconFromPath("\n\t\t\tM 50 0 L 50 5 L 35 5 L 40 24.75 L 20 25 L 20 100 L 85 100 L 100 90 L 100 24 L 75.1 24.3 L 80 5 L 65 5 L 65 0 L 50 0 z\n\t\t\tM 10 15 L 10 115 L 110 115 L 110 15 L 85 15 L 83 20 L 105 20 L 105 110 L 15 110 L 15 20 L 32 20 L 30 15 L 10 15 z\n\t\t\tM 25 35 L 90 35 L 90 40 L 25 40 L 25 35 z\n\t\t\tM 25 45 L 90 45 L 90 50 L 25 50 L 25 45 z\n\t\t\tM 25 55 L 85 55 L 85 60 L 25 60 L 25 55 z\n\t\t\tM 25 65 L 90 65 L 90 70 L 25 70 L 25 65 z \n\t\t");return t.setAttribute("viewBox","0 0 120 120"),t}makeDeleteSelectionIcon(){return r(this,o,"m",i).call(this)}makeCloseIcon(){return r(this,o,"m",i).call(this)}makeSaveIcon(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.innerHTML="\n\t\t\t<style>\n\t\t\t\t.toolbar-save-icon {\n\t\t\t\t\tstroke: var(--icon-color);\n\t\t\t\t\tstroke-width: 6;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tfill: none;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<path\n\t\t\t\td='\n\t\t\t\t\tM 15,55 30,70 85,20\n\t\t\t\t'\n\t\t\t\tclass='toolbar-save-icon'\n\t\t\t/>\n\t\t",t.setAttribute("viewBox","0 0 100 100"),t}makeConfigureDocumentIcon(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.innerHTML="\n\t\t\t<path\n\t\t\t\td='\n\t\t\t\t\tM 5,5 V 95 H 95 V 5 Z m 5,5 H 90 V 90 H 10 Z\n\t\t\t\t\tm 5,10 V 30 H 50 V 25 H 20 v -5 z\n\t\t\t\t\tm 40,0 V 50 H 85 V 20 Z\n\t\t\t\t\tm 2,2 H 83 V 39 L 77,28 70,42 64,35 57,45 Z\n\t\t\t\t\tm 8.5,5 C 64.67,27 64,27.67 64,28.5 64,29.33 64.67,30 65.5,30 66.33,30 67,29.33 67,28.5 67,27.67 66.33,27 65.5,27 Z\n\t\t\t\t\tM 15,40 v 5 h 35 v -5 z\n\t\t\t\t\tm 0,15 v 5 h 70 v -5 z\n\t\t\t\t\tm 0,15 v 5 h 70 v -5 z\n\t\t\t\t'\n\t\t\t\tstyle='fill: var(--icon-color);'\n\t\t\t/>\n\t\t",t.setAttribute("viewBox","0 0 100 100"),t}makeOverflowIcon(){return this.makeIconFromPath("\n\t\t\tM 15 40\n\t\t\tA 12.5 12.5 0 0 0 2.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 15 65\n\t\t\tA 12.5 12.5 0 0 0 27.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 15 40\n\t\t\tz\n\t\n\t\t\tM 50 40\n\t\t\tA 12.5 12.5 0 0 0 37.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 50 65\n\t\t\tA 12.5 12.5 0 0 0 62.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 50 40\n\t\t\tz\n\t\t\t\n\t\t\tM 85 40\n\t\t\tA 12.5 12.5 0 0 0 72.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 85 65\n\t\t\tA 12.5 12.5 0 0 0 97.5 52.5\n\t\t\tA 12.5 12.5 0 0 0 85 40\n\t\t\tz\n\t\t")}makeIconFromPath(t,e="var(--icon-color)",n="none",o="0px"){const i=document.createElementNS(h,"svg"),r=document.createElementNS(h,"path");return r.setAttribute("d",t),r.style.fill=e,r.style.stroke=n,r.style.strokeWidth=o,i.appendChild(r),i.setAttribute("viewBox","0 0 100 100"),i}makeCheckerboardPattern(){return f()}isRoundedTipPen(t){return t.factory===d.makeFreehandLineBuilder}licenseInfo(){return null}}},5698:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toolbarCSSPrefix=void 0,e.toolbarCSSPrefix="toolbar-"},2994:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeEdgeToolbar=e.makeDropdownToolbar=e.IconProvider=void 0,i(n(7321),e),i(n(425),e);var s=n(8282);Object.defineProperty(e,"IconProvider",{enumerable:!0,get:function(){return r(s).default}});var a=n(9997);Object.defineProperty(e,"makeDropdownToolbar",{enumerable:!0,get:function(){return a.makeDropdownToolbar}});var l=n(5221);Object.defineProperty(e,"makeEdgeToolbar",{enumerable:!0,get:function(){return l.makeEdgeToolbar}})},9746:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarLocalization=void 0,e.defaultToolbarLocalization={pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text",chooseFile:"Choose file",dragAndDropHereOrBrowse:"Drag and drop here\nor\n{{browse}}",submit:"Submit",cancel:"Cancel",resetView:"Reset view",thicknessLabel:"Thickness",colorLabel:"Color",fontLabel:"Font",textSize:"Size",resizeImageToSelection:"Resize image to selection",deleteSelection:"Delete selection",duplicateSelection:"Duplicate selection",exit:"Exit",save:"Save",undo:"Undo",redo:"Redo",selectPenTip:"Pen tip",selectShape:"Shape",pickColorFromScreen:"Pick color from screen",clickToPickColorAnnouncement:"Click on the screen to pick a color",colorSelectionCanceledAnnouncement:"Color selection canceled",selectionToolKeyboardShortcuts:"Selection tool: Use arrow keys to move selected items, lowercase/uppercase ‘i’ and ‘o’ to resize.",documentProperties:"Page",backgroundColor:"Background color",imageWidthOption:"Width",imageHeightOption:"Height",useGridOption:"Grid",enableAutoresizeOption:"Auto-resize",toggleOverflow:"More",about:"About",inputStabilization:"Input stabilization",touchPanning:"Touchscreen panning",roundedTipPen:"Round",flatTipPen:"Flat",arrowPen:"Arrow",linePen:"Line",outlinedRectanglePen:"Outlined rectangle",filledRectanglePen:"Filled rectangle",outlinedCirclePen:"Outlined circle",lockRotation:"Lock rotation",paste:"Paste",closeSidebar:t=>`Close sidebar for ${t}`,dropdownShown:t=>`Menu for ${t} shown`,dropdownHidden:t=>`Menu for ${t} hidden`,zoomLevel:t=>`Zoom: ${t}%`,colorChangedAnnouncement:t=>`Color changed to ${t}`,imageSize:(t,e)=>`Image size: ${t} ${e}`,errorImageHasZeroSize:"Error: Image has zero size",imageLoadError:t=>`Error loading image: ${t}`}},3534:function(t,e,n){"use strict";var o,i=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(3258));class l extends a.default{constructor(t,e,n,r,s,a,l=!1,c=!0){super(t,e,a),this.makeIcon=n,this.title=r,this.clickAction=s,this.mustBeToplevel=l,o.set(this,void 0),i(this,o,c,"f")}shouldAutoDisableInReadOnlyEditor(){return r(this,o,"f")}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}mustBeInToplevelMenu(){return this.mustBeToplevel}}o=new WeakMap,e.default=l},1421:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=o(n(3258)),s=n(5698);class a extends r.default{constructor(t,e,n,o){super(t,n,o),this.targetTool=e,t.notifier.on(i.EditorEventType.ToolEnabled,(t=>{if(t.kind!==i.EditorEventType.ToolEnabled)throw new Error("Incorrect event type! (Expected ToolEnabled)");t.tool===e&&(this.setSelected(!0),(()=>{const t=[...document.querySelectorAll("*:focus")];return t.length&&t.some((t=>t.classList.contains(`${s.toolbarCSSPrefix}button`)))})()&&this.focus())})),t.notifier.on(i.EditorEventType.ToolDisabled,(t=>{if(t.kind!==i.EditorEventType.ToolDisabled)throw new Error("Incorrect event type! (Expected ToolDisabled)");t.tool===e&&(this.setSelected(!1),this.setDropdownVisible(!1))}))}shouldAutoDisableInReadOnlyEditor(){return!this.targetTool.canReceiveInputInReadOnlyEditor()}handleClick(){this.hasDropdown?this.targetTool.isEnabled()?this.setDropdownVisible(!this.isDropdownVisible()):(this.targetTool.setEnabled(!0),this.activateDropdown()):this.targetTool.setEnabled(!this.targetTool.isEnabled())}onKeyPress(t){return!(!this.isSelected()||" "!==t.key||!this.hasDropdown)&&(this.handleClick(),!0)}addTo(t){const e=super.addTo(t);return this.setSelected(this.targetTool.isEnabled()),e}}e.default=a},3258:function(t,e,n){"use strict";var o,i,r,s,a=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},l=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ToolbarWidgetTag=void 0;const d=c(n(6390)),h=n(7520),u=n(5698),p=c(n(4477));var f;!function(t){t.Save="save",t.Exit="exit",t.Undo="undo",t.Redo="redo"}(f||(e.ToolbarWidgetTag=f={}));class m{constructor(t,e,n){this.editor=t,this.id=e,this.dropdown=null,o.set(this,void 0),this.disabled=!1,i.set(this,!1),r.set(this,[]),this.subWidgets={},this.toplevel=!0,s.set(this,null),this.localizationTable=n??t.localization;const l=new p.default((t=>this.editor.announceForAccessibility(t)),this.localizationTable);l.connectToEditorNotifier(t.notifier),this.layoutManager=l,this.icon=null,this.container=document.createElement("div"),this.container.classList.add(`${u.toolbarCSSPrefix}toolContainer`,`${u.toolbarCSSPrefix}toolButtonContainer`),this.dropdownContent=document.createElement("div"),a(this,o,!1,"f"),this.button=document.createElement("div"),this.button.classList.add(`${u.toolbarCSSPrefix}button`),this.label=document.createElement("label"),this.button.setAttribute("role","button"),this.button.tabIndex=0,this.button.oncontextmenu=t=>{t.preventDefault()};const c=this.editor.toolController.getMatchingTools(d.default);c.length>0&&this.onKeyPress!==m.prototype.onKeyPress&&c[0].registerListener((t=>this.onKeyPress(t)))}shouldAutoDisableInReadOnlyEditor(){return!0}getId(){return this.id}setTags(t){const e=t=>`toolwidget-tag--${t}`;for(const t of l(this,r,"f"))this.container.classList.remove(e(t));a(this,r,[...t],"f");for(const t of l(this,r,"f"))this.container.classList.add(e(t))}getTags(){return[...l(this,r,"f")]}getUniqueIdIn(t){let e=this.getId(),n=0;for(;e in t&&t[e]!==this;)e=this.getId()+"-"+n.toString(),n++;return e}fillDropdown(t){if(0===Object.keys(this.subWidgets).length)return!1;for(const e in this.subWidgets){const n=this.subWidgets[e];n.addTo(t),n.setIsToplevel(!1)}return!0}setupActionBtnClickListener(t){return this.setUpButtonEventListeners(t)}setUpButtonEventListeners(t){const e={Enter:!0," ":!0};t.onkeydown=t=>{let n=!1;if(t.key in e&&(this.disabled||(this.handleClick(),n=!0)),!n){const e=(0,h.keyPressEventFromHTMLEvent)(t);n=this.editor.toolController.dispatchInputEvent(e)}n&&t.preventDefault()},t.onkeyup=t=>{if(t.key in e)return;const n=(0,h.keyUpEventFromHTMLEvent)(t);this.editor.toolController.dispatchInputEvent(n)&&t.preventDefault()},t.onclick=()=>{this.disabled||this.handleClick()},t.ondblclick=t=>{t.preventDefault()}}onKeyPress(t){return!1}get hasDropdown(){return l(this,o,"f")}addSubWidget(t){const e=t.getUniqueIdIn(this.subWidgets);this.subWidgets[e]=t}setLayoutManager(t){t!==this.layoutManager&&(this.layoutManager=t,this.container.parentElement&&this.addTo(this.container.parentElement))}addTo(t){this.icon=null,this.updateIcon(),this.label.innerText=this.getTitle();const e="long-label";return this.label.innerText.length>7?this.label.classList.add(e):this.label.classList.remove(e),this.setUpButtonEventListeners(this.button),this.container.replaceChildren(),this.button.replaceChildren(this.icon,this.label),this.container.appendChild(this.button),this.dropdownContent.replaceChildren(),a(this,o,this.fillDropdown(this.dropdownContent),"f"),l(this,o,"f")&&(this.button.classList.add("has-dropdown"),this.dropdown?.destroy(),this.dropdownIcon=this.createDropdownIcon(),this.button.appendChild(this.dropdownIcon),this.dropdown=this.layoutManager.createToolMenu({target:this.button,getTitle:()=>this.getTitle(),isToplevel:()=>this.toplevel}),this.dropdown.visible.onUpdate((t=>{t?this.container.classList.add("dropdownVisible"):this.container.classList.remove("dropdownVisible"),t||this.focus()})),this.dropdown.appendChild(this.dropdownContent)),this.setDropdownVisible(!1),this.container.parentElement&&this.container.remove(),a(this,s,this.editor.isReadOnlyReactiveValue().onUpdateAndNow((t=>{t&&this.shouldAutoDisableInReadOnlyEditor()&&!this.disabled?(this.setDisabled(!0),a(this,i,!0,"f"),l(this,o,"f")&&this.dropdown?.requestHide()):!t&&l(this,i,"f")&&(a(this,i,!1,"f"),this.setDisabled(!1))})),"f"),t.appendChild(this.container),this.container}focus(){this.button.focus()}addCSSClassToContainer(t){this.container.classList.add(t)}removeCSSClassFromContainer(t){this.container.classList.remove(t)}remove(){this.container.remove(),l(this,s,"f")?.remove(),a(this,s,null,"f")}updateIcon(){let t=this.createIcon();t?this.container.classList.remove("no-icon"):(t=document.createElement("div"),this.container.classList.add("no-icon")),this.icon?.replaceWith(t),this.icon=t,this.icon.classList.add(`${u.toolbarCSSPrefix}icon`)}setDisabled(t){this.disabled=t,a(this,i,!1,"f"),this.disabled?(this.button.classList.add("disabled"),this.button.setAttribute("aria-disabled","true")):(this.button.classList.remove("disabled"),this.button.removeAttribute("aria-disabled"))}setSelected(t){this.isSelected()!==t&&(this.button.setAttribute("role","switch"),t?(this.container.classList.add("selected"),this.button.setAttribute("aria-checked","true")):(this.container.classList.remove("selected"),this.button.setAttribute("aria-checked","false")))}setDropdownVisible(t){t?this.dropdown?.requestShow():this.dropdown?.requestHide()}activateDropdown(){this.dropdown?.onActivated()}mustBeInToplevelMenu(){return!1}canBeInOverflowMenu(){return!this.mustBeInToplevelMenu()}getButtonWidth(){return this.button.clientWidth}isHidden(){return"none"===this.container.style.display}setHidden(t){this.container.style.display=t?"none":""}setIsToplevel(t){this.toplevel=t}isDropdownVisible(){return this.dropdown?.visible?.get()??!1}isSelected(){return this.container.classList.contains("selected")}createDropdownIcon(){const t=this.editor.icons.makeDropdownIcon();return t.classList.add(`${u.toolbarCSSPrefix}showHideDropdownIcon`),t}serializeState(){const t={};for(const e in this.subWidgets)t[e]=this.subWidgets[e].serializeState();return{subwidgetState:t}}deserializeFrom(t){if(t.subwidgetState)for(const e in t.subwidgetState)e in this.subWidgets&&this.subWidgets[e].deserializeFrom(t.subwidgetState[e])}}o=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,e.default=m},5771:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(9721)),l=s(n(1456)),c=r(n(1847)),d=n(505),h=n(5097),u=n(3173),p=n(5698),f=s(n(425)),m=s(n(3258));class g extends m.default{constructor(t,e){super(t,"document-properties-widget",e),this.updateDropdownContent=()=>{},this.dropdownUpdateQueued=!1,this.container.classList.add("dropdownShowable"),this.editor.notifier.on(u.EditorEventType.UndoRedoStackUpdated,(()=>{this.queueDropdownUpdate()})),this.editor.image.notifier.on(d.EditorImageEventType.ExportViewportChanged,(()=>{this.queueDropdownUpdate()}))}getTitle(){return this.localizationTable.documentProperties}createIcon(){return this.editor.icons.makeConfigureDocumentIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible()),this.queueDropdownUpdate()}queueDropdownUpdate(){this.dropdownUpdateQueued||(requestAnimationFrame((()=>this.updateDropdown())),this.dropdownUpdateQueued=!0)}updateDropdown(){this.dropdownUpdateQueued=!1,this.isDropdownVisible()&&this.updateDropdownContent()}setBackgroundColor(t){this.editor.dispatch(this.editor.setBackgroundColor(t))}getBackgroundColor(){return this.editor.estimateBackgroundColor()}removeBackgroundComponents(){const t=[];for(const e of this.editor.image.getBackgroundComponents())e instanceof c.default&&t.push(e);return new a.default(t)}setBackgroundType(t){const e=this.editor.estimateBackgroundColor(),n=new c.default(t,e),o=this.editor.image.addElement(n);return(0,l.default)([this.removeBackgroundComponents(),o])}getBackgroundType(){const t=this.editor.image.getBackgroundComponents();for(let e=t.length-1;e>=0;e--){const n=t[e];if(n instanceof c.default)return n.getBackgroundType()}return c.BackgroundType.None}updateImportExportRectSize(t){const e=t=>(void 0!==t&&(!isFinite(t)||t<=0)&&(t=100),t),n=e(t.width),o=e(t.height),i=this.editor.getImportExportRect(),r=new h.Rect2(i.x,i.y,n??i.w,o??i.h);this.editor.dispatch(this.editor.image.setImportExportRect(r)),this.editor.queueRerender()}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}spacedList`,`${p.toolbarCSSPrefix}nonbutton-controls-main-list`,`${p.toolbarCSSPrefix}document-properties-widget`);const{backgroundColorRow:n,setBgColorInputValue:o}=(()=>{const t=document.createElement("div"),e=document.createElement("label");e.innerText=this.localizationTable.backgroundColor;const{input:n,container:o,setValue:i}=(0,f.default)(this.editor,(t=>{t.eq(this.getBackgroundColor())||this.setBackgroundColor(t)}));return n.id=`${p.toolbarCSSPrefix}docPropertiesColorInput-${g.idCounter++}`,e.htmlFor=n.id,t.replaceChildren(e,o),{setBgColorInputValue:i,backgroundColorRow:t}})(),i=(t,e)=>{const n=document.createElement("div"),o=document.createElement("label"),i=document.createElement("input");return i.id=`${p.toolbarCSSPrefix}docPropertiesCheckbox-${g.idCounter++}`,o.htmlFor=i.id,i.type="checkbox",o.innerText=t,i.oninput=()=>{e(i.checked)},n.replaceChildren(o,i),{container:n,checkbox:i}},{container:r,checkbox:s}=i(this.localizationTable.useGridOption,(t=>{if(this.getBackgroundType()===c.BackgroundType.Grid===t)return;let e=c.BackgroundType.SolidColor;t&&(e=c.BackgroundType.Grid),this.editor.dispatch(this.setBackgroundType(e))})),a=(t,e)=>{const n=document.createElement("div"),o=document.createElement("label"),i=document.createElement("input");return o.innerText=t,i.type="number",i.min="0",i.id=`${p.toolbarCSSPrefix}docPropertiesDimensionRow-${g.idCounter++}`,o.htmlFor=i.id,i.style.flexGrow="2",i.style.width="25px",i.oninput=()=>{e(parseFloat(i.value))},n.classList.add("js-draw-size-input-row"),n.replaceChildren(o,i),{setValue:t=>{i.value=t.toString()},setIsAutomaticSize:t=>{i.disabled=t;const e="size-input-row--automatic-size";t?n.classList.add(e):n.classList.remove(e)},element:n}},l=a(this.localizationTable.imageWidthOption,(t=>{this.updateImportExportRectSize({width:t})})),d=a(this.localizationTable.imageHeightOption,(t=>{this.updateImportExportRectSize({height:t})})),{container:h,checkbox:u}=i(this.localizationTable.enableAutoresizeOption,(t=>{const e=this.editor.image;this.editor.dispatch(e.setAutoresizeEnabled(t))})),m=document.createElement("button");return m.classList.add("about-button"),m.innerText=this.localizationTable.about,m.onclick=()=>{this.editor.showAboutDialog()},this.updateDropdownContent=()=>{o(this.getBackgroundColor());const t=this.editor.image.getAutoresizeEnabled(),e=this.editor.getImportExportRect();l.setValue(e.width),d.setValue(e.height),u.checked=t,l.setIsAutomaticSize(t),d.setIsAutomaticSize(t),s.checked=this.getBackgroundType()===c.BackgroundType.Grid},this.updateDropdownContent(),e.replaceChildren(n,r,l.element,d.element,h,m),t.replaceChildren(e),!0}}g.idCounter=0,e.default=g},9944:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=n(5698),s=o(n(1421)),a=o(n(8392));class l extends s.default{constructor(t,e,n){super(t,e,"eraser-tool-widget",n),this.tool=e,this.updateInputs=()=>{},this.editor.notifier.on(i.EditorEventType.ToolUpdated,(t=>{t.kind===i.EditorEventType.ToolUpdated&&t.tool===this.tool&&(this.updateInputs(),this.updateIcon())}))}getTitle(){return this.localizationTable.eraser}createIcon(){return this.editor.icons.makeEraserIcon(this.tool.getThickness())}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${r.toolbarCSSPrefix}spacedList`,`${r.toolbarCSSPrefix}nonbutton-controls-main-list`);const n=(0,a.default)(this.editor,(t=>{this.tool.setThickness(t)}));n.setBounds(10,55),this.updateInputs=()=>{n.setValue(this.tool.getThickness())},this.updateInputs();const o=document.createElement("div");return o.style.height="5px",e.replaceChildren(n.container,o),t.replaceChildren(e),!0}serializeState(){return{...super.serializeState(),thickness:this.tool.getThickness()}}deserializeFrom(t){if(super.deserializeFrom(t),t.thickness){const e=parseFloat(t.thickness);if("number"!=typeof e||!isFinite(e))throw new Error(`Deserializing property ${e} is not a number or is not finite.`);this.tool.setThickness(e)}}}e.default=l},7956:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(5097),l=r(n(4735)),c=n(3173),d=s(n(5566)),h=n(5698),u=s(n(1421)),p=s(n(3258)),f=s(n(3595));class m extends p.default{constructor(t,e,n,o,i,r){super(t,`pan-mode-${n}`,r),this.tool=e,this.flag=n,this.makeIcon=o,this.title=i,t.notifier.on(c.EditorEventType.ToolUpdated,(t=>{if(t.kind===c.EditorEventType.ToolUpdated&&t.tool===e){const t=!!(e.getMode()&l.PanZoomMode.SinglePointerGestures);this.setSelected(!!(e.getMode()&n)||t),this.setDisabled(t&&n!==l.PanZoomMode.SinglePointerGestures)}})),this.setSelected(!1)}shouldAutoDisableInReadOnlyEditor(){return!1}setModeFlag(t){this.tool.setModeEnabled(this.flag,t)}handleClick(){this.setModeFlag(!this.isSelected())}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}}class g extends u.default{constructor(t,e,n){const o=g.getPrimaryHandTool(t.toolController);super(t,o??e,"hand-tool-widget",n),this.overridePanZoomTool=e,this.allowTogglingBaseTool=null!==o,this.allowTogglingBaseTool||this.container.classList.add("dropdownShowable");const i=new m(t,e,l.PanZoomMode.OneFingerTouchGestures,(()=>this.editor.icons.makeTouchPanningIcon()),n.touchPanning,n),r=new m(t,e,l.PanZoomMode.RotationLocked,(()=>this.editor.icons.makeRotationLockIcon()),n.lockRotation,n);this.addSubWidget(i),this.addSubWidget(r)}shouldAutoDisableInReadOnlyEditor(){return!1}static getPrimaryHandTool(t){return t.getPrimaryTools().filter((t=>t instanceof l.default))[0]}getTitle(){return this.localizationTable.handTool}createIcon(){return this.editor.icons.makeHandToolIcon()}handleClick(){this.allowTogglingBaseTool?super.handleClick():this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){super.fillDropdown(t);const e=document.createElement("div");return e.classList.add(`${h.toolbarCSSPrefix}nonbutton-controls-main-list`),(0,f.default)().addTo(e),e.appendChild(((t,e)=>{const n=document.createElement("div"),o=document.createElement("button"),i=document.createElement("button"),r=document.createElement("button"),s=document.createElement("span");let l;o.innerText="+",i.innerText="-",r.innerText=t.resetView,n.replaceChildren(s,o,i,r),n.classList.add(`${h.toolbarCSSPrefix}zoomLevelEditor`),s.classList.add("zoomDisplay");const u=()=>{let n=100*e.viewport.getScaleFactor();n=n>.1?Math.round(10*n)/10:Math.round(1e3*n)/1e3,n!==l&&(s.innerText=t.zoomLevel(n),l=n)};u(),e.notifier.on(c.EditorEventType.ViewportChanged,(t=>{t.kind===c.EditorEventType.ViewportChanged&&(u(),r.disabled=t.newTransform.eq(a.Mat33.identity))}));const p=t=>{const n=e.viewport.visibleRect.center,o=a.Mat33.scaling2D(t,n);e.dispatch(d.default.transformBy(o),!1)};return o.onclick=()=>{p(5/4)},i.onclick=()=>{p(.8)},r.onclick=()=>{e.dispatch(d.default.transformBy(e.viewport.canvasToScreenTransform.inverse()),!1)},n})(this.localizationTable,this.editor)),t.appendChild(e),!0}setSelected(t){this.allowTogglingBaseTool&&super.setSelected(t)}serializeState(){const t=this.overridePanZoomTool.getMode();return{...super.serializeState(),touchPanning:t&l.PanZoomMode.OneFingerTouchGestures,rotationLocked:t&l.PanZoomMode.RotationLocked}}deserializeFrom(t){void 0!==t.touchPanning&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.OneFingerTouchGestures,t.touchPanning),void 0!==t.rotationLocked&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.RotationLocked,t.rotationLocked),super.deserializeFrom(t)}}e.default=g},6318:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7077)),r=o(n(9721)),s=o(n(505)),a=o(n(1456)),l=o(n(7591)),c=n(5097),d=o(n(9070)),h=o(n(3258)),u=n(3173),p=n(5698),f=o(n(7993));class m extends h.default{constructor(t,e){e??=t.localization,super(t,"insert-image-widget",e),this.container.classList.add("dropdownShowable"),t.notifier.on(u.EditorEventType.SelectionUpdated,(t=>{t.kind===u.EditorEventType.SelectionUpdated&&this.isDropdownVisible()&&this.updateInputs()}))}getTitle(){return this.localizationTable.image}createIcon(){return this.editor.icons.makeInsertImageIcon()}setDropdownVisible(t){super.setDropdownVisible(t),this.isDropdownVisible()&&this.updateInputs()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){const e=document.createElement("div");e.classList.add("insert-image-widget-dropdown-content",`${p.toolbarCSSPrefix}spacedList`,`${p.toolbarCSSPrefix}nonbutton-controls-main-list`);const{container:n,selectedFiles:o}=(0,f.default)(this.localizationTable.chooseFile,this.editor,"image/*"),i=document.createElement("div");this.imagePreview=document.createElement("img"),this.statusView=document.createElement("div");const r=document.createElement("div");r.classList.add("action-button-row"),this.submitButton=document.createElement("button"),this.selectedFiles=o,this.imageAltTextInput=document.createElement("input");const s=document.createElement("label"),a="insert-image-alt-text-input-"+m.nextInputId++;return this.imageAltTextInput.setAttribute("id",a),s.htmlFor=a,s.innerText=this.localizationTable.inputAltText,this.imageAltTextInput.type="text",this.statusView.setAttribute("aria-live","polite"),this.submitButton.innerText=this.localizationTable.submit,this.selectedFiles.onUpdateAndNow((async t=>{if(0===t.length)return this.imagePreview.style.display="none",this.submitButton.disabled=!0,void(this.submitButton.style.display="none");this.imagePreview.style.display="block";const e=t[0];let n=null;try{n=await(0,d.default)(e)}catch(t){this.statusView.innerText=this.localizationTable.imageLoadError(t)}this.imageBase64URL=n,n?(this.imagePreview.src=n,this.submitButton.disabled=!1,this.submitButton.style.display="",this.updateImageSizeDisplay()):(this.submitButton.disabled=!0,this.submitButton.style.display="none",this.statusView.innerText="")})),i.replaceChildren(s,this.imageAltTextInput),r.replaceChildren(this.submitButton),e.replaceChildren(n,i,this.imagePreview,this.statusView,r),t.replaceChildren(e),!0}hideDialog(){this.setDropdownVisible(!1)}updateImageSizeDisplay(){const t=(this.imageBase64URL??"").length/1024,e=t/1024;let n="KiB",o=t;e>=1&&(o=e,n="MiB"),this.statusView.innerText=this.localizationTable.imageSize(Math.round(o),n)}updateInputs(){(()=>{this.selectedFiles?.set([]),this.imageAltTextInput.value="",this.imagePreview.style.display="none",this.submitButton.disabled=!0,this.statusView.innerText="",this.submitButton.style.display="",this.imageAltTextInput.oninput=null})();const t=this.editor.toolController.getMatchingTools(l.default),e=t.map((t=>t.getSelectedObjects())).flat();let n=null;1===e.length&&e[0]instanceof i.default?(n=e[0],this.imageAltTextInput.value=n.getAltText()??"",this.imagePreview.style.display="block",this.submitButton.disabled=!1,this.imageBase64URL=n.getURL(),this.imagePreview.src=this.imageBase64URL,this.updateImageSizeDisplay()):e.length>0&&t.forEach((t=>t.clearSelection())),this.submitButton.style.display="none",this.imageAltTextInput.oninput=()=>{this.imagePreview.src?.length>0&&(this.submitButton.style.display="")},this.submitButton.onclick=async()=>{if(!this.imageBase64URL)return;const e=new Image;e.src=this.imageBase64URL,e.setAttribute("alt",this.imageAltTextInput.value);const o=await i.default.fromImage(e,c.Mat33.identity);if(0!==o.getBBox().area)if(this.hideDialog(),n){const e=new r.default([n]);await this.editor.dispatch((0,a.default)([s.default.addElement(o),o.transformBy(n.getTransformation()),o.setZIndex(n.getZIndex()),e])),t[0]?.setSelection([o])}else await this.editor.addAndCenterComponents([o]);else this.statusView.innerText=this.localizationTable.errorImageHasZeroSize}}}m.nextInputId=0,e.default=m},3359:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3258));class r extends i.default{constructor(t,e){super(t,"overflow-widget",e),this.overflowChildren=[],this.container.classList.add("toolbar-overflow-widget"),this.container.classList.add("dropdownShowable"),this.overflowContainer??=document.createElement("div")}shouldAutoDisableInReadOnlyEditor(){return!1}getTitle(){return this.localizationTable.toggleOverflow}createIcon(){return this.editor.icons.makeOverflowIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){return this.overflowContainer??=document.createElement("div"),this.overflowContainer.parentElement&&this.overflowContainer.remove(),this.overflowContainer.classList.add("toolbar-overflow-widget-overflow-list"),t.appendChild(this.overflowContainer),!0}clearChildren(){this.overflowContainer.replaceChildren(),this.container.classList.remove("horizontal");const t=this.overflowChildren;return this.overflowChildren=[],t}getChildWidgets(){return[...this.overflowChildren]}hasAsChild(t){for(const e of this.overflowChildren)if(t===e)return!0;return!1}addToOverflow(t){this.overflowChildren.push(t),t.addTo(this.overflowContainer),t.setIsToplevel(!1),this.overflowChildren.length>2&&this.container.classList.add("horizontal")}canBeInOverflowMenu(){return!1}}e.default=r},7998:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(9274),r=n(6951),s=n(823),a=n(725),l=n(4666),c=n(7973),d=n(3173),h=o(n(425)),u=o(n(1421)),p=n(5097),f=n(3240),m=n(5698),g=o(n(8392)),b=o(n(8650));class y extends u.default{constructor(t,e,n){super(t,e,"pen",n),this.tool=e,this.updateInputs=()=>{},this.shapelikeIDs=["pressure-sensitive-pen","freehand-pen"],this.penTypes=[{name:this.localizationTable.flatTipPen,id:"pressure-sensitive-pen",factory:s.makePressureSensitiveFreehandLineBuilder},{name:this.localizationTable.roundedTipPen,id:"freehand-pen",factory:r.makeFreehandLineBuilder},{name:this.localizationTable.arrowPen,id:"arrow",isShapeBuilder:!0,factory:i.makeArrowBuilder},{name:this.localizationTable.linePen,id:"line",isShapeBuilder:!0,factory:a.makeLineBuilder},{name:this.localizationTable.filledRectanglePen,id:"filled-rectangle",isShapeBuilder:!0,factory:l.makeFilledRectangleBuilder},{name:this.localizationTable.outlinedRectanglePen,id:"outlined-rectangle",isShapeBuilder:!0,factory:l.makeOutlinedRectangleBuilder},{name:this.localizationTable.outlinedCirclePen,id:"outlined-circle",isShapeBuilder:!0,factory:c.makeOutlinedCircleBuilder}],this.editor.notifier.on(d.EditorEventType.ToolUpdated,(t=>{if(t.kind!==d.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");t.tool===this.tool&&(this.updateIcon(),this.updateInputs())}))}getTitle(){return this.targetTool.description}getCurrentPenTypeIdx(){const t=this.tool.getStrokeFactory();for(let e=0;e<this.penTypes.length;e++)if(this.penTypes[e].factory===t)return e;return-1}getCurrentPenType(){for(const t of this.penTypes)if(t.factory===this.tool.getStrokeFactory())return t;return null}createIconForRecord(t){const e={...this.tool.getStyleValue().get()};t?.factory&&(e.factory=t.factory);const n=t?.factory;return n&&n!==r.makeFreehandLineBuilder&&n!==s.makePressureSensitiveFreehandLineBuilder?this.editor.icons.makeIconFromFactory(e):this.editor.icons.makePenIcon(e)}createIcon(){return this.createIconForRecord(this.getCurrentPenType())}createPenTypeSelector(){const t=this.penTypes.map(((t,e)=>({id:e,makeIcon:()=>this.createIconForRecord(t),title:t.name,isShapeBuilder:t.isShapeBuilder??!1}))),e=(0,b.default)(this.localizationTable.selectPenTip,this.getCurrentPenTypeIdx(),t.filter((t=>!t.isShapeBuilder))),n=(0,b.default)(this.localizationTable.selectShape,this.getCurrentPenTypeIdx(),t.filter((t=>t.isShapeBuilder))),o=t=>{this.tool.setStrokeFactory(this.penTypes[t].factory)};return e.value.onUpdate(o),n.value.onUpdate(o),{setValue:t=>{e.value.set(t),n.value.set(t)},updateIcons:()=>{e.updateIcons(),n.updateIcons()},addTo:t=>{e.addTo(t),n.addTo(t)}}}setInputStabilizationEnabled(t){this.tool.setHasStabilization(t)}createStabilizationOption(){const t=document.createElement("div"),e=document.createElement("input"),n=document.createElement("label");return n.innerText=this.localizationTable.inputStabilization,e.type="checkbox",e.id=`${m.toolbarCSSPrefix}-penInputStabilizationCheckbox-${y.idCounter++}`,n.htmlFor=e.id,t.replaceChildren(n,e),e.oninput=()=>{this.setInputStabilizationEnabled(e.checked)},{update:()=>{e.checked=!!this.tool.getInputMapper()},addTo:e=>{e.appendChild(t)}}}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${m.toolbarCSSPrefix}spacedList`,`${m.toolbarCSSPrefix}nonbutton-controls-main-list`);const{container:n,setValue:o}=(0,g.default)(this.editor,(t=>{this.tool.setThickness(t)})),i=this.createPenTypeSelector(),r=document.createElement("div"),s=document.createElement("label"),{input:a,container:l,setValue:c}=(0,h.default)(this.editor,(t=>{this.tool.setColor(t)}));a.id=`${m.toolbarCSSPrefix}colorInput${y.idCounter++}`,s.innerText=this.localizationTable.colorLabel,s.setAttribute("for",a.id),r.appendChild(s),r.appendChild(l);const d=this.createStabilizationOption();return this.updateInputs=()=>{c(this.tool.getColor()),o(this.tool.getThickness()),i.updateIcons(),i.setValue(this.getCurrentPenTypeIdx()),d.update()},this.updateInputs(),e.replaceChildren(r,n),i.addTo(e),d.addTo(e),t.replaceChildren(e),!0}onKeyPress(t){if(!this.isSelected())return!1;for(let e=0;e<f.selectStrokeTypeKeyboardShortcutIds.length;e++){const n=f.selectStrokeTypeKeyboardShortcutIds[e];if(this.editor.shortcuts.matchesShortcut(n,t)){const t=e;if(t<this.penTypes.length)return this.tool.setStrokeFactory(this.penTypes[t].factory),!0}}return!!super.onKeyPress(t)}serializeState(){return{...super.serializeState(),color:this.tool.getColor().toHexString(),thickness:this.tool.getThickness(),strokeFactoryId:this.getCurrentPenType()?.id,inputStabilization:!!this.tool.getInputMapper()}}deserializeFrom(t){super.deserializeFrom(t);const e=(e,n)=>{const o=typeof t[e];if(o!==n)throw new Error(`Deserializing property ${e}: Invalid type. Expected ${n}, was ${o}.`)};if(t.color&&(e("color","string"),this.tool.setColor(p.Color4.fromHex(t.color))),t.thickness&&(e("thickness","number"),this.tool.setThickness(t.thickness)),t.strokeFactoryId){e("strokeFactoryId","string");const n=t.strokeFactoryId;for(const t of this.penTypes)if(n===t.id){this.tool.setStrokeFactory(t.factory);break}}void 0!==t.inputStabilization&&this.setInputStabilizationEnabled(!!t.inputStabilization)}}y.idCounter=0,e.default=y},78:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3534)),r=n(3258),s=n(3240);class a extends i.default{constructor(t,e,n){super(t,"save-button",t.icons.makeSaveIcon,e.save,n),this.setTags([r.ToolbarWidgetTag.Save])}shouldAutoDisableInReadOnlyEditor(){return!1}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(s.saveKeyboardShortcut,t)?(this.clickAction(),!0):super.onKeyPress(t)}mustBeInToplevelMenu(){return!0}}e.default=a},5001:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(739),s=o(n(1456)),a=n(3173),l=o(n(425)),c=o(n(3534)),d=o(n(1421)),h=n(3240),u=o(n(3595)),p=n(5698);class f extends d.default{constructor(t,e,n){super(t,e,"selection-tool-widget",n),this.tool=e,this.updateFormatMenu=()=>{};const o=new c.default(t,"resize-btn",(()=>t.icons.makeResizeImageToSelectionIcon()),this.localizationTable.resizeImageToSelection,(()=>{this.resizeImageToSelection()}),n),i=new c.default(t,"delete-btn",(()=>t.icons.makeDeleteSelectionIcon()),this.localizationTable.deleteSelection,(()=>{const t=this.tool.getSelection();this.editor.dispatch(t.deleteSelectedObjects()),this.tool.clearSelection()}),n),r=new c.default(t,"duplicate-btn",(()=>t.icons.makeDuplicateSelectionIcon()),this.localizationTable.duplicateSelection,(async()=>{const t=this.tool.getSelection();this.editor.dispatch(await t.duplicateSelectedObjects()),this.setDropdownVisible(!1)}),n);this.addSubWidget(o),this.addSubWidget(i),this.addSubWidget(r);const s=t=>{o.setDisabled(t),i.setDisabled(t),r.setDisabled(t)};s(!0),this.editor.notifier.on(a.EditorEventType.ToolUpdated,(t=>{if(t.kind!==a.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");if(t.tool===this.tool){const t=this.tool.getSelection(),e=t&&t.getSelectedItemCount()>0;s(!e),this.updateFormatMenu()}}))}resizeImageToSelection(){const t=this.tool.getSelection();t&&this.editor.dispatch(this.editor.setImportExportRect(t.region))}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(h.resizeImageToSelectionKeyboardShortcut,t)?(this.resizeImageToSelection(),!0):!!super.onKeyPress(t)}getTitle(){return this.localizationTable.select}createIcon(){return this.editor.icons.makeSelectionIcon()}fillDropdown(t){super.fillDropdown(t);const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}nonbutton-controls-main-list`),t.appendChild(e),(0,u.default)(this.localizationTable.reformatSelection).addTo(e);const n=((t,e,n)=>{const o=document.createElement("div");o.classList.add("selection-format-menu",`${p.toolbarCSSPrefix}spacedList`,`${p.toolbarCSSPrefix}indentedList`);const a=document.createElement("div"),c=document.createElement("label"),{input:d,container:h,setValue:u}=(0,l.default)(t,(n=>{const o=e.getSelection();if(o){const e=[];for(const t of o.getSelectedObjects())(0,r.isRestylableComponent)(t)&&e.push(t.updateStyle({color:n}));const i=(0,s.default)(e);t.dispatch(i)}}));return c.innerText=n.colorLabel,a.replaceChildren(c,h),o.replaceChildren(a),{addTo:t=>{t.appendChild(o)},update:()=>{const t=e.getSelection();if(t&&t.getSelectedItemCount()>0){d.disabled=!1,o.classList.remove("disabled");const e=[];for(const n of t.getSelectedObjects())if((0,r.isRestylableComponent)(n)){const t=n.getStyle().color;t&&e.push(t)}u(i.Color4.average(e))}else d.disabled=!0,o.classList.add("disabled"),u(i.Color4.transparent)}}})(this.editor,this.tool,this.localizationTable);return n.addTo(e),this.updateFormatMenu=()=>n.update(),n.update(),!0}}e.default=f},5730:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(3173),s=n(5698),a=o(n(425)),l=o(n(1421));class c extends l.default{constructor(t,e,n){super(t,e,"text-tool-widget",n),this.tool=e,this.updateDropdownInputs=null,t.notifier.on(r.EditorEventType.ToolUpdated,(t=>{t.kind===r.EditorEventType.ToolUpdated&&t.tool===e&&(this.updateIcon(),this.updateDropdownInputs?.())}))}getTitle(){return this.targetTool.description}createIcon(){const t=this.tool.getTextStyle();return this.editor.icons.makeTextIcon(t)}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${s.toolbarCSSPrefix}spacedList`,`${s.toolbarCSSPrefix}nonbutton-controls-main-list`);const n=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div"),r=document.createElement("select"),l=document.createElement("label"),d=document.createElement("input"),h=document.createElement("label"),{input:u,container:p,setValue:f}=(0,a.default)(this.editor,(t=>{this.tool.setColor(t)})),m=document.createElement("label"),g=new Set,b=t=>{const e=document.createElement("option");e.value=t,e.textContent=t,r.appendChild(e),g.add(t)};return d.setAttribute("type","number"),d.min="1",d.max="128",l.innerText=this.localizationTable.fontLabel,m.innerText=this.localizationTable.colorLabel,h.innerText=this.localizationTable.textSize,u.id=`${s.toolbarCSSPrefix}-text-color-input-${c.idCounter++}`,m.setAttribute("for",u.id),d.id=`${s.toolbarCSSPrefix}-text-size-input-${c.idCounter++}`,h.setAttribute("for",d.id),b("monospace"),b("serif"),b("sans-serif"),r.id=`${s.toolbarCSSPrefix}-text-font-input-${c.idCounter++}`,l.setAttribute("for",r.id),r.onchange=()=>{this.tool.setFontFamily(r.value)},d.onchange=()=>{const t=parseInt(d.value);!isNaN(t)&&t>0&&this.tool.setFontSize(t)},o.appendChild(m),o.appendChild(p),n.appendChild(l),n.appendChild(r),i.appendChild(h),i.appendChild(d),this.updateDropdownInputs=()=>{const t=this.tool.getTextStyle();f(t.renderingStyle.fill),g.has(t.fontFamily)||b(t.fontFamily),r.value=t.fontFamily,d.value=`${t.size}`},this.updateDropdownInputs(),e.replaceChildren(o,i,n),t.appendChild(e),!0}serializeState(){const t=this.tool.getTextStyle();return{...super.serializeState(),fontFamily:t.fontFamily,textSize:t.size,color:t.renderingStyle.fill.toHexString()}}deserializeFrom(t){t.fontFamily&&"string"==typeof t.fontFamily&&this.tool.setFontFamily(t.fontFamily),t.color&&"string"==typeof t.color&&this.tool.setColor(i.Color4.fromHex(t.color)),t.textSize&&"number"==typeof t.textSize&&this.tool.setFontSize(t.textSize),super.deserializeFrom(t)}}c.idCounter=0,e.default=c},425:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeColorInput=void 0;const i=n(5097),r=o(n(5248)),s=n(3173);e.makeColorInput=(t,e)=>{const n=document.createElement("span"),o=document.createElement("input");o.type="button",o.classList.add("coloris_input"),n.classList.add("color-input-container"),n.appendChild(o);const r=a(t,n,(t=>{o.value=t.toHexString(),d();const e=o.parentElement;e&&e.classList.contains("clr-field")&&(e.style.color=o.value)}));let l;const c=()=>{l=i.Color4.fromHex(o.value)},d=()=>{c(),l&&(t.announceForAccessibility(t.localization.colorChangedAnnouncement(l.toHexString())),e(l),t.notifier.dispatch(s.EditorEventType.ColorPickerColorSelected,{kind:s.EditorEventType.ColorPickerColorSelected,color:l}))};o.oninput=c;let h=!1;o.addEventListener("open",(()=>{h=!0,t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!0}),r.cancel(),n.classList.add("picker-open");const e=document.querySelector("#clr-picker #clr-hue-slider");e?.focus()}));o.addEventListener("close",(()=>{h=!1,t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!1}),d(),o.focus(),n.classList.remove("picker-open")}));return{input:o,container:n,setValue:t=>{"object"==typeof t&&(t=t.toHexString()),o.value=t,o.dispatchEvent(new Event("input",{bubbles:!0}))},closePicker:()=>{h&&d()}}};const a=(t,e,n)=>{const o=document.createElement("button");o.classList.add("pipetteButton"),o.title=t.localization.pickColorFromScreen,o.setAttribute("alt",o.title);const i=document.createElement("span");i.classList.add("pickColorInstructions"),i.innerText=t.localization.clickToPickColorAnnouncement;const s=e=>{o.replaceChildren(t.icons.makePipetteIcon(e),i)};s();const a=t.toolController.getMatchingTools(r.default)[0],l=()=>{a?.clearColorListener(),s(),o.classList.remove("active")},c=t=>{l(),t&&n(t)},d=t=>{t?s(t):s()};return o.onclick=()=>{if(o.classList.contains("active"))return l(),void t.announceForAccessibility(t.localization.colorSelectionCanceledAnnouncement);a?.setColorListener(d,c),a&&(o.classList.add("active"),t.announceForAccessibility(t.localization.clickToPickColorAnnouncement))},e.appendChild(o),{cancel:()=>{l()}}};e.default=e.makeColorInput},7993:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(1151));let r=0;e.default=(t,e,n="*")=>{const o=document.createElement("div"),s=document.createElement("label"),a=document.createElement("input"),l=document.createElement("div");l.classList.add("toolbar--file-input-description");const c=document.createElement("span");o.classList.add("toolbar--file-input-container"),s.appendChild(document.createTextNode(t)),a.accept=n,a.type="file";const d="js-draw-file-input-"+r++;a.setAttribute("id",d),s.htmlFor=d;const h=e.icons.makeUploadFileIcon();h.classList.add("icon"),l.replaceChildren(h,c),s.appendChild(l),o.replaceChildren(s,a);const u=i.default.fromInitialValue([]);return s.addEventListener("dragover",(t=>{t.preventDefault(),s.classList.add("drag-target")})),s.addEventListener("dragenter",(t=>{t.preventDefault(),s.classList.add("drag-target")})),s.addEventListener("dragleave",(t=>{t.preventDefault();const e=t.relatedTarget;e&&s.contains(e)||s.classList.remove("drag-target")})),s.addEventListener("drop",(t=>{t.preventDefault(),s.classList.remove("drag-target");const e=[];t.dataTransfer&&e.push(...t.dataTransfer.files),u.set(e)})),a.addEventListener("change",(()=>{const t=a.files??[];u.set([...t])})),u.onUpdate((t=>{0===t.length&&a.files&&a.files.length>0&&(a.value="")})),u.onUpdateAndNow((t=>{if(t.length>0)c.innerText=t.map((t=>t.name)).join("\n"),h.style.display="none";else{h.style.display="";const t=e.localization.dragAndDropHereOrBrowse.split(/[{]{2}(.*)[}]{2}/g);c.replaceChildren();for(let e=0;e<t.length;e++)if(e%2==1){const n=document.createElement("b");n.innerText=t[e],c.appendChild(n)}else c.appendChild(document.createTextNode(t[e]))}})),{container:o,input:a,selectedFiles:u,addTo:t=>{t.appendChild(o)}}}},8650:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(1151),r=o(n(9441)),s=n(5698);let a=0;e.default=(t,e,n)=>{const o=document.createElement("div");o.classList.add(`${s.toolbarCSSPrefix}grid-selector`);const l=i.MutableReactiveValue.fromInitialValue(e),c=document.createElement("div");c.setAttribute("role","menu"),c.id=`${s.toolbarCSSPrefix}-grid-select-id-${a++}`,(0,r.default)(c);const d=document.createElement("label");d.innerText=t,d.htmlFor=c.id,o.appendChild(d);let h=`${s.toolbarCSSPrefix}-grid-selector-${a++}`;const u=t=>{const e=document.createElement("div");e.classList.add("choice-button");const n=document.createElement("input");n.type="radio",n.id=`${s.toolbarCSSPrefix}-grid-select-button-${a++}`;const o=document.createElement("label"),i=()=>{o.setAttribute("title",t.title);const e=document.createElement("span");e.classList.add("button-label-text");const i=t.makeIcon();i.classList.add("icon"),e.innerText=t.title,o.htmlFor=n.id,o.replaceChildren(i,e)};i();const r=()=>{n.name=h};r();const d=()=>{n.checked?e.classList.add("checked"):e.classList.remove("checked")};n.oninput=()=>{n.checked&&l.set(t.id),d()},n.onfocus=()=>{e.querySelector(":focus-visible")&&e.classList.add("focus-visible")},n.onblur=()=>{e.classList.remove("focus-visible")},e.replaceChildren(n,o),c.appendChild(e);const u=t=>{n.checked=t,d()};u(!1);return{choiceRecord:t,setChecked:u,updateIcon:()=>{i()},updateButtonRadiogroupName:r}},p=[];for(const t of n)p.push(u(t));o.appendChild(c),l.onUpdateAndNow((t=>{for(let e=0;e<p.length;e++)p[e].setChecked(p[e].choiceRecord.id===t)}));const f={value:l,_radiogroupName:h,linkWith:t=>{f._radiogroupName=t._radiogroupName,h=t._radiogroupName;for(const t of p)t.updateButtonRadiogroupName()},updateIcons:()=>{p.forEach((t=>t.updateIcon()))},addTo:t=>{t.appendChild(o)}};return f}},3595:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t="")=>{const e=document.createElement("div");return e.classList.add("tool-dropdown-separator"),e.innerText=t,{addTo:t=>{t.appendChild(e)}}}},8392:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097),i=n(5698);let r=0;e.default=(t,e)=>{const n=document.createElement("div"),s=document.createElement("label"),a=document.createElement("input");n.classList.add(`${i.toolbarCSSPrefix}thicknessSliderContainer`),a.id=`${i.toolbarCSSPrefix}thicknessInput${r++}`,s.innerText=t.localization.thicknessLabel,s.setAttribute("for",a.id);const l=t=>Math.log10(t);a.type="range",a.oninput=()=>{e((t=>10**t)(parseFloat(a.value)))},n.appendChild(s),n.appendChild(a);const c=(t,e)=>{const n=(t,e)=>(e?Math.ceil:Math.floor)(100*t)/100,i=n(l(t),!1),r=n(l(e),!0);a.min=`${i}`,a.max=`${r}`,a.step=`${(0,o.toRoundedString)((r-i)/20)}`};return c(2,262),{container:n,addTo:t=>{t.appendChild(n)},setBounds:c,setValue:t=>{a.value=l(t).toString()}}}},3240:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.saveKeyboardShortcut=e.selectStrokeTypeKeyboardShortcutIds=e.resizeImageToSelectionKeyboardShortcut=void 0;const i=o(n(5376));e.resizeImageToSelectionKeyboardShortcut="jsdraw.toolbar.SelectionTool.resizeImageToSelection",i.default.registerDefaultKeyboardShortcut(e.resizeImageToSelectionKeyboardShortcut,["ctrlOrMeta+r"],"Resize image to selection"),e.selectStrokeTypeKeyboardShortcutIds=[1,2,3,4,5,6,7].map((t=>`jsdraw.toolbar.PenTool.select-pen-${t}`));for(let t=0;t<e.selectStrokeTypeKeyboardShortcutIds.length;t++){const n=e.selectStrokeTypeKeyboardShortcutIds[t];i.default.registerDefaultKeyboardShortcut(n,[`CtrlOrMeta+Digit${t+1}`],"Select pen style "+(t+1))}e.saveKeyboardShortcut="jsdraw.toolbar.SaveActionWidget.save",i.default.registerDefaultKeyboardShortcut(e.saveKeyboardShortcut,["ctrlOrMeta+KeyS"],"Save")},4477:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=o(n(1785)),s=n(5698),a=n(1151);var l;!function(t){t[t.DropdownShown=0]="DropdownShown",t[t.DropdownHidden=1]="DropdownHidden"}(l||(l={}));class c{constructor(t,e,n){this.parent=t,this.notifier=e,this.onDestroy=n,this.dropdownToggleListener=null,this.hideDropdownTimeout=null,this.visible=a.ReactiveValue.fromInitialValue(!1),this.dropdownContainer=document.createElement("div"),this.dropdownContainer.classList.add(`${s.toolbarCSSPrefix}dropdown`),this.dropdownContainer.classList.add("hidden"),t.target.insertAdjacentElement("afterend",this.dropdownContainer),this.dropdownToggleListener=this.notifier.on(l.DropdownShown,(t=>{t.dropdown!==this&&t.fromToplevelDropdown&&this.setVisible(!1)}))}onActivated(){}repositionDropdown(){const t=this.dropdownContainer.getBoundingClientRect(),e=document.scrollingElement?.clientWidth??document.body.clientHeight,n=document.scrollingElement?.clientHeight??document.body.clientHeight;let o,i;if(t.left>e/2){o=`calc(${this.parent.target.clientWidth+"px"} - 100%)`}if(t.bottom>n&&t.top-t.height>0){i=`calc(-${this.parent.target.clientHeight}px - 100%)`}this.dropdownContainer.style.translate=o||i?`${o??"0"} ${i??"0"}`:""}setVisible(t){if(this.visible.get()===t)return;this.hideDropdownTimeout&&(clearTimeout(this.hideDropdownTimeout),this.hideDropdownTimeout=null,this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown());if(this.visible.set(t),t)this.dropdownContainer.classList.remove("hidden"),this.notifier.dispatch(l.DropdownShown,{dropdown:this,fromToplevelDropdown:this.parent.isToplevel()}),this.repositionDropdown();else{this.notifier.dispatch(l.DropdownHidden,{dropdown:this,fromToplevelDropdown:this.parent.isToplevel()}),this.dropdownContainer.classList.add("hiding");const t=142.5;this.hideDropdownTimeout=setTimeout((()=>{this.dropdownContainer.classList.add("hidden"),this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown()}),t)}const e=`var(--dropdown-${t?"show":"hide"}-animation)`;this.dropdownContainer.style.animation=`150ms ease ${e}`}requestShow(){this.setVisible(!0)}requestHide(){this.setVisible(!1)}appendChild(t){this.dropdownContainer.appendChild(t)}clearChildren(){this.dropdownContainer.replaceChildren()}destroy(){this.setVisible(!1),this.dropdownContainer.remove(),this.dropdownToggleListener?.remove(),this.clearChildren(),this.onDestroy()}}e.default=class{constructor(t,e){this.localization=e,this.dropdowns=new Set,this.listeners=[],this.connectedNotifiers=[],this.notifier=new r.default,this.notifier.on(l.DropdownShown,(({dropdown:e,fromToplevelDropdown:n})=>{e&&(t(this.localization.dropdownShown(e.parent.getTitle())),this.connectedNotifiers.forEach((t=>{t.dispatch(i.EditorEventType.ToolbarDropdownShown,{kind:i.EditorEventType.ToolbarDropdownShown,fromToplevelDropdown:n,layoutManager:this})})))})),this.notifier.on(l.DropdownHidden,(({dropdown:e})=>{e&&t(this.localization.dropdownHidden(e.parent.getTitle()))}))}connectToEditorNotifier(t){this.connectedNotifiers.push(t),this.refreshListeners()}createToolMenu(t){const e=new c(t,this.notifier,(()=>{this.dropdowns.delete(e),this.refreshListeners()}));return this.dropdowns.add(e),this.refreshListeners(),e}refreshListeners(){const t=()=>{this.listeners.forEach((t=>t.remove())),this.listeners=[]};0===this.dropdowns.size?t():this.listeners.length!==this.connectedNotifiers.length&&(t(),this.listeners=this.connectedNotifiers.map((t=>t.on(i.EditorEventType.ToolbarDropdownShown,(t=>{t.kind===i.EditorEventType.ToolbarDropdownShown&&t.layoutManager!==this&&this.notifier.dispatch(l.DropdownShown,{fromToplevelDropdown:t.fromToplevelDropdown})})))))}}},5132:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(1151);e.default=class{constructor(t,e,n,i,r){this.setSidebarContent=t,this.sidebarTitle=e,this.sidebarVisibility=n,this.announceForAccessibility=i,this.localization=r,this.visibleWidgetContent=o.ReactiveValue.fromInitialValue(null)}createToolMenu(t){const e=document.createElement("div");let n=null;const i=o.ReactiveValue.fromCallback((()=>this.visibleWidgetContent.get()===n&&this.sidebarVisibility.get()),[this.visibleWidgetContent,this.sidebarVisibility]);return n={visible:i,requestShow:()=>{this.setSidebarContent(e),this.sidebarTitle.set(t.getTitle()),this.visibleWidgetContent.set(n),this.sidebarVisibility.set(!0),this.announceForAccessibility(this.localization.dropdownShown(t.getTitle()))},onActivated:()=>{},requestHide:()=>{i.get()&&this.sidebarVisibility.set(!1)},appendChild:t=>{e.appendChild(t)},clearChildren:()=>{e.replaceChildren()},destroy:()=>{n?.requestHide(),e.parentElement&&e.remove(),this.visibleWidgetContent.get()===n&&this.visibleWidgetContent.set(null)}},n}}},7321:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.DocumentPropertiesWidget=e.InsertImageWidget=e.EraserToolWidget=e.SelectionToolWidget=e.HandToolWidget=e.TextToolWidget=e.PenToolWidget=e.ToolbarWidgetTag=e.BaseWidget=e.BaseToolWidget=e.ActionButtonWidget=void 0;var i=n(3534);Object.defineProperty(e,"ActionButtonWidget",{enumerable:!0,get:function(){return o(i).default}});var r=n(1421);Object.defineProperty(e,"BaseToolWidget",{enumerable:!0,get:function(){return o(r).default}});var s=n(3258);Object.defineProperty(e,"BaseWidget",{enumerable:!0,get:function(){return o(s).default}}),Object.defineProperty(e,"ToolbarWidgetTag",{enumerable:!0,get:function(){return s.ToolbarWidgetTag}});var a=n(7998);Object.defineProperty(e,"PenToolWidget",{enumerable:!0,get:function(){return o(a).default}});var l=n(5730);Object.defineProperty(e,"TextToolWidget",{enumerable:!0,get:function(){return o(l).default}});var c=n(7956);Object.defineProperty(e,"HandToolWidget",{enumerable:!0,get:function(){return o(c).default}});var d=n(5001);Object.defineProperty(e,"SelectionToolWidget",{enumerable:!0,get:function(){return o(d).default}});var h=n(9944);Object.defineProperty(e,"EraserToolWidget",{enumerable:!0,get:function(){return o(h).default}});var u=n(6318);Object.defineProperty(e,"InsertImageWidget",{enumerable:!0,get:function(){return o(u).default}});var p=n(5771);Object.defineProperty(e,"DocumentPropertiesWidget",{enumerable:!0,get:function(){return o(p).default}})},7564:function(t,e,n){"use strict";var o,i,r,s,a=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},l=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const c=n(3173),d=n(7520),h=n(1151);o=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,e.default=class{constructor(t,e){this.notifier=t,this.description=e,o.set(this,void 0),i.set(this,null),r.set(this,null),s.set(this,null),a(this,o,h.ReactiveValue.fromInitialValue(!0),"f"),l(this,o,"f").onUpdate((t=>{t?(l(this,i,"f")?.notifyEnabled(this),this.notifier.dispatch(c.EditorEventType.ToolEnabled,{kind:c.EditorEventType.ToolEnabled,tool:this})):this.notifier.dispatch(c.EditorEventType.ToolDisabled,{kind:c.EditorEventType.ToolDisabled,tool:this})}))}canReceiveInputInReadOnlyEditor(){return!1}setInputMapper(t){a(this,r,t,"f"),t&&t.setEmitListener((t=>this.dispatchEventToCallback(t)))}getInputMapper(){return l(this,r,"f")}dispatchEventToCallback(t){let e;switch(t.kind){case d.InputEvtType.PointerDownEvt:return this.onPointerDown(t);case d.InputEvtType.PointerMoveEvt:this.onPointerMove(t);break;case d.InputEvtType.PointerUpEvt:return this.onPointerUp(t)??!1;case d.InputEvtType.GestureCancelEvt:this.onGestureCancel(t);break;case d.InputEvtType.WheelEvt:return this.onWheel(t);case d.InputEvtType.KeyPressEvent:return this.onKeyPress(t);case d.InputEvtType.KeyUpEvent:return this.onKeyUp(t);case d.InputEvtType.CopyEvent:return this.onCopy(t);case d.InputEvtType.PasteEvent:return this.onPaste(t);default:return e=t,e}return!0}onEvent(t){return l(this,r,"f")?l(this,r,"f").onEvent(t):this.dispatchEventToCallback(t)}onPointerDown(t){return!1}onPointerMove(t){}onPointerUp(t){}onGestureCancel(t){}onWheel(t){return!1}onCopy(t){return!1}onPaste(t){return!1}onKeyPress(t){return!1}onKeyUp(t){return!1}eventCanBeDeliveredToNonActiveTool(t){return!0}setEnabled(t){l(this,o,"f").set(t)}isEnabled(){return l(this,o,"f").get()}enabledValue(){return l(this,o,"f")}setToolGroup(t){this.isEnabled()&&t.notifyEnabled(this),a(this,i,t,"f")}getToolGroup(){return l(this,i,"f")?l(this,i,"f"):null}onDestroy(){l(this,s,"f")?.remove(),a(this,s,null,"f")}}},6416:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173),r=o(n(7564)),s=n(5097),a=o(n(9721)),l=n(4318),c=n(3348),d=n(1151);class h extends r.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastPoint=null,this.isFirstEraseEvt=!0,this.thickness=10,this.partialCommands=[],this.thicknessValue=d.ReactiveValue.fromInitialValue(this.thickness),this.thicknessValue.onUpdate((t=>{this.thickness=t,this.editor.notifier.dispatch(i.EditorEventType.ToolUpdated,{kind:i.EditorEventType.ToolUpdated,tool:this})}))}clearPreview(){this.editor.clearWetInk()}getSizeOnCanvas(){return this.thickness/this.editor.viewport.getScaleFactor()}drawPreviewAt(t){this.clearPreview();const e=this.getSizeOnCanvas(),n=this.editor.display.getWetInkRenderer(),o=this.getEraserRect(t),i={fill:s.Color4.gray};n.drawRect(o,e/4,i)}getEraserRect(t){const e=this.getSizeOnCanvas(),n=s.Vec2.of(e/2,e/2);return s.Rect2.fromCorners(t.minus(n),t.plus(n))}eraseTo(t){if(!this.isFirstEraseEvt&&0===t.minus(this.lastPoint).magnitude())return;this.isFirstEraseEvt=!1;const e=this.getEraserRect(t),n=new s.LineSegment2(this.lastPoint,t),o=s.Rect2.union(n.bbox,e),i=this.editor.image.getElementsIntersectingRegion(o).filter((t=>t.intersects(n)||t.intersectsRect(e))).filter((t=>t.isSelectable()));this.toRemove.push(...i);const r=i.map((t=>new a.default([t])));r.forEach((t=>t.apply(this.editor))),this.partialCommands.push(...r),this.drawPreviewAt(t),this.lastPoint=t}onPointerDown(t){return(1===t.allPointers.length||t.current.device===l.PointerDevice.Eraser)&&(this.lastPoint=t.current.canvasPos,this.toRemove=[],this.isFirstEraseEvt=!0,this.drawPreviewAt(t.current.canvasPos),!0)}onPointerMove(t){const e=t.current.canvasPos;this.eraseTo(e)}onPointerUp(t){if(this.eraseTo(t.current.canvasPos),this.toRemove.length>0){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[];const t=new a.default(this.toRemove);this.editor.dispatch(t)}this.clearPreview()}onGestureCancel(){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[],this.clearPreview()}onKeyPress(t){const e=this.editor.shortcuts;let n;return e.matchesShortcut(c.decreaseSizeKeyboardShortcutId,t)?n=2*this.getThickness()/3:e.matchesShortcut(c.increaseSizeKeyboardShortcutId,t)&&(n=3*this.getThickness()/2),void 0!==n&&(n=Math.min(Math.max(1,n),200),this.setThickness(n),!0)}getThickness(){return this.thickness}getThicknessValue(){return this.thicknessValue}setThickness(t){this.thicknessValue.set(t)}}e.default=h},5805:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=o(n(7564)),s=n(3348),a="find-tool";class l extends r.default{constructor(t){super(t.notifier,t.localization.findLabel),this.editor=t,this.currentMatchIdx=0,this.overlay=document.createElement("div"),this.fillOverlay(),t.createHTMLOverlay(this.overlay),this.overlay.style.display="none",this.overlay.classList.add(`${a}-overlay`)}canReceiveInputInReadOnlyEditor(){return!0}getMatches(t){t=t.toLocaleLowerCase();return this.editor.image.getAllElements().filter((t=>t instanceof i.default)).filter((e=>-1!==e.getText().toLocaleLowerCase().indexOf(t))).map((t=>t.getBBox()))}focusCurrentMatch(){const t=this.getMatches(this.searchInput.value);let e=this.currentMatchIdx%t.length;if(e<0&&(e=t.length+e),e<t.length){const n=!1;this.editor.dispatch(this.editor.viewport.zoomTo(t[e],!0,!0),n),this.editor.announceForAccessibility(this.editor.localization.focusedFoundText(e+1,t.length))}}toNextMatch(){this.currentMatchIdx++,this.focusCurrentMatch()}toPrevMatch(){this.currentMatchIdx--,this.focusCurrentMatch()}fillOverlay(){const t=document.createElement("label");this.searchInput=document.createElement("input");const e=document.createElement("button"),n=document.createElement("button");this.searchInput.setAttribute("id",`${a}-searchInput-${Math.random()}`),t.htmlFor=this.searchInput.getAttribute("id"),t.innerText=this.editor.localization.findLabel,e.innerText=this.editor.localization.toNextMatch,n.innerText=this.editor.localization.closeDialog,this.searchInput.onkeydown=t=>{"Enter"===t.key?t.shiftKey?this.toPrevMatch():this.toNextMatch():"Escape"===t.key?this.setVisible(!1):this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(t.preventDefault(),this.toggleVisible())},e.onclick=()=>{this.toNextMatch()},n.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(t,this.searchInput,e,n)}isVisible(){return"none"!==this.overlay.style.display}setVisible(t){t!==this.isVisible()&&(this.overlay.style.display=t?"block":"none",t?(this.searchInput.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogShown)):(this.editor.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogHidden)))}toggleVisible(){this.setVisible(!this.isVisible())}onKeyPress(t){return!!this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(this.toggleVisible(),!0)}setEnabled(t){super.setEnabled(t),this.isEnabled()&&this.setVisible(!1)}}e.default=l},7810:function(t,e){"use strict";var n,o=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},i=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});n=new WeakMap,e.default=class{constructor(){n.set(this,null)}setEmitListener(t){o(this,n,t&&"object"==typeof t?e=>t.onEvent(e)??!1:t,"f")}emit(t){return i(this,n,"f")?.call(this,t)??!1}}},3135:function(t,e,n){"use strict";var o,i,r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},s=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const l=a(n(7810));class c extends l.default{constructor(){super(...arguments),o.set(this,null),i.set(this,null)}onEvent(t){return null===r(this,o,"f")?this.emit(t):r(this,o,"f").onEvent(t)}addToTail(t){r(this,i,"f")?(r(this,i,"f").setEmitListener(t),s(this,i,t,"f")):(s(this,o,t,"f"),s(this,i,r(this,o,"f"),"f")),r(this,i,"f").setEmitListener((t=>this.emit(t)))}}o=new WeakMap,i=new WeakMap,e.default=c},2785:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(7520),r=o(n(7810)),s=n(5097),a=o(n(7395));var l;!function(t){t[t.IntertialStabilizer=0]="IntertialStabilizer"}(l||(l={}));const c={kind:l.IntertialStabilizer,mass:.4,springConstant:100,frictionCoefficient:.28,maxPointDist:10,inertiaFraction:.75,minSimilarityToFinalize:0,velocityDecayFactor:.1};class d{constructor(t,e,n){this.updatePointer=e,this.options=n,this.runLoop=!0,this.lastUpdateTime=0,this.velocity=s.Vec2.zero,this.strokePoint=t,this.targetPoint=t,this.targetInterval=10,this.loop()}async loop(){for(this.lastUpdateTime=performance.now();this.runLoop;)this.update(!1),await(0,a.default)()}setTarget(t){this.targetPoint=t}getNextVelocity(t){const e=this.targetPoint.minus(this.strokePoint),n=e.times(this.options.springConstant),o=10*this.options.mass,i=this.velocity.normalizedOrZero().times(-this.options.frictionCoefficient*o),r=n.plus(i).times(1/this.options.mass),s=this.options.velocityDecayFactor,a=this.velocity.times(1-s).plus(r.times(t/1e3));return e.normalizedOrZero().times(a.length()).lerp(a,this.options.inertiaFraction)}update(t){const e=performance.now(),n=e-this.lastUpdateTime,o=this.strokePoint.eq(this.targetPoint);if(n>this.targetInterval||t){if(!o){let t,o,i=1;do{t=this.getNextVelocity(n/i),o=t.times(n/1e3),i++}while(o.magnitude()>this.options.maxPointDist&&i<10);for(let t=0;t<i;t++)this.velocity=this.getNextVelocity(n/i),o=this.velocity.times(n/1e3),this.strokePoint=this.strokePoint.plus(o),t<i-1&&this.updatePointer(this.strokePoint,e)}if(this.lastUpdateTime=e,t||!o)return this.updatePointer(this.strokePoint,e)}return!1}finish(){this.runLoop=!1;const t=this.targetPoint.minus(this.strokePoint);this.velocity.dot(t)>this.options.minSimilarityToFinalize&&this.updatePointer(this.targetPoint,performance.now())}cancel(){this.runLoop=!1}}class h extends r.default{constructor(t,e=c){super(),this.viewport=t,this.options=e,this.stabilizer=null,this.lastPointerEvent=null}mapPointerEvent(t){return(0,i.isPointerEvt)(t)&&t.kind!==i.InputEvtType.PointerUpEvt&&(this.lastPointerEvent=t),t.kind===i.InputEvtType.GestureCancelEvt||t.allPointers.length>1||null===this.stabilizer?this.emit(t):(this.stabilizer.setTarget(t.current.screenPos),t.kind===i.InputEvtType.PointerMoveEvt?this.stabilizer.update(!0):t.kind===i.InputEvtType.PointerUpEvt?(this.stabilizer.finish(),this.emit(t)):this.emit(t))}emitPointerMove(t,e){if(!this.lastPointerEvent)return!1;const n=this.lastPointerEvent.current.withScreenPosition(t,this.viewport).withTimestamp(e),o={kind:i.InputEvtType.PointerMoveEvt,current:n,allPointers:[n]};return this.emit(o)}onEvent(t){if((0,i.isPointerEvt)(t)||t.kind===i.InputEvtType.GestureCancelEvt){t.kind===i.InputEvtType.PointerDownEvt&&(null===this.stabilizer?this.stabilizer=new d(t.current.screenPos,((t,e)=>this.emitPointerMove(t,e)),this.options):t.allPointers.length>1&&(this.stabilizer.cancel(),this.stabilizer=null));const e=this.mapPointerEvent(t);return t.kind!==i.InputEvtType.PointerUpEvt&&t.kind!==i.InputEvtType.GestureCancelEvt||(this.stabilizer?.cancel(),this.stabilizer=null),e}return this.emit(t)}static fromEditor(t){return new h(t.viewport)}}e.default=h},9542:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(7520),r=o(n(7810)),s=n(3348);class a extends r.default{constructor(t,e){super(),this.shortcuts=t,this.viewport=e,this.snapToGridEnabled=!1,this.angleLockEnabled=!1,this.startPointCanvas=null}xyAxesSnap(t){if(!this.startPointCanvas)return t;const e=this.viewport.canvasToScreen(this.startPointCanvas);return t.lockedToXYAxesScreen(e,this.viewport)}mapPointerEvent(t){const e=e=>t.allPointers.length>1?e:this.snapToGridEnabled?e.snappedToGrid(this.viewport):this.angleLockEnabled&&this.startPointCanvas?this.xyAxesSnap(e):e;return{kind:t.kind,current:e(t.current),allPointers:t.allPointers.map(e)}}onEvent(t){const e=this.shortcuts;t.kind!==i.InputEvtType.PointerDownEvt&&t.kind!==i.InputEvtType.PointerMoveEvt&&t.kind!==i.InputEvtType.PointerUpEvt||(t.kind===i.InputEvtType.PointerDownEvt&&(this.startPointCanvas=t.current.canvasPos),t=this.mapPointerEvent(t));let n=this.emit(t);if(t.kind===i.InputEvtType.KeyUpEvent||!n&&t.kind===i.InputEvtType.KeyPressEvent){const o=t.kind===i.InputEvtType.KeyPressEvent;e.matchesShortcut(s.snapToGridKeyboardShortcutId,t)&&(this.snapToGridEnabled=o,n=!0),e.matchesShortcut(s.lineLockKeyboardShortcutId,t)&&(this.angleLockEnabled=o,n=!0)}return n}static fromEditor(t){return new a(t.shortcuts,t.viewport)}}e.default=a},4735:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanZoomMode=void 0;const i=n(5097),r=n(4318),s=n(3173),a=o(n(7395)),l=n(5566),c=o(n(7564)),d=n(3348);var h;!function(t){t[t.OneFingerTouchGestures=1]="OneFingerTouchGestures",t[t.TwoFingerTouchGestures=2]="TwoFingerTouchGestures",t[t.RightClickDrags=4]="RightClickDrags",t[t.SinglePointerGestures=8]="SinglePointerGestures",t[t.Keyboard=16]="Keyboard",t[t.RotationLocked=32]="RotationLocked"}(h||(e.PanZoomMode=h={}));class u{constructor(t,e,n){this.initialVelocity=t,this.scrollBy=e,this.onComplete=n,this.running=!1,this.start()}async start(){if(this.running)return;this.currentVelocity=this.initialVelocity;let t=performance.now();this.running=!0;for(this.currentVelocity.magnitude()>5e3&&(this.currentVelocity=this.currentVelocity.normalized().times(5e3));this.running&&this.currentVelocity.magnitude()>200;){const e=performance.now(),n=(e-t)/1e3;this.currentVelocity=this.currentVelocity.times(Math.pow(1/8,n)),this.scrollBy(this.currentVelocity.times(n)),await(0,a.default)(),t=e}this.running&&this.stop()}getCurrentVelocity(){return this.running?this.currentVelocity:null}stop(){this.running&&(this.running=!1,this.onComplete())}}class p extends c.default{constructor(t,e,n){super(t.notifier,n),this.editor=t,this.mode=e,this.transform=null,this.lastPointerDownTimestamp=0,this.initialTouchAngle=0,this.initialViewportRotation=0,this.isScaling=!1,this.inertialScroller=null,this.velocity=null}canReceiveInputInReadOnlyEditor(){return!0}computePinchData(t,e){if(t.id<e.id){const n=t;t=e,e=n}const n=e.screenPos.minus(t.screenPos),o=n.angle(),i=n.magnitude();return{canvasCenter:e.canvasPos.plus(t.canvasPos).times(.5),screenCenter:e.screenPos.plus(t.screenPos).times(.5),angle:o,dist:i}}allPointersAreOfType(t,e){return t.every((t=>t.device===e))}onPointerDown({allPointers:t,current:e}){let n=!1;const o=this.inertialScroller?.getCurrentVelocity()??i.Vec2.zero;this.inertialScroller?.stop(),this.velocity=o,this.lastPointerDownTimestamp=e.timeStamp;const s=this.allPointersAreOfType(t,r.PointerDevice.Touch),a=this.allPointersAreOfType(t,r.PointerDevice.RightButtonMouse);if(s&&2===t.length&&this.mode&h.TwoFingerTouchGestures){const{screenCenter:e,angle:o,dist:i}=this.computePinchData(t[0],t[1]);this.lastDist=i,this.startDist=i,this.lastScreenCenter=e,this.initialTouchAngle=o,this.initialViewportRotation=this.editor.viewport.getRotationAngle(),this.isScaling=!1,n=!0}else 1===t.length&&(this.mode&h.OneFingerTouchGestures&&s||a&&this.mode&h.RightClickDrags||this.mode&h.SinglePointerGestures)&&(this.lastScreenCenter=t[0].screenPos,this.isScaling=!1,n=!0);return n&&(this.lastTimestamp=performance.now(),this.transform??=l.Viewport.transformBy(i.Mat33.identity),this.editor.display.setDraftMode(!0)),n}updateVelocity(t){const e=t.minus(this.lastScreenCenter);let n=(performance.now()-this.lastTimestamp)/1e3;if(0===e.magnitude()&&n<.1)return;if(0===n)return;n=Math.max(n,.01);const o=e.times(1/n);let i=o;this.velocity&&(i=this.velocity.lerp(o,.5)),this.velocity=i}getCenterDelta(t){return this.editor.viewport.screenToCanvasTransform.transformVec3(t.minus(this.lastScreenCenter))}toSnappedRotationDelta(t){let e=t-this.initialTouchAngle+this.initialViewportRotation;const n=Math.PI/2,o=Math.round(e/n)*n;return Math.abs(e-o)<.07&&(e=o,0!==e&&(e+=1e-4)),e-this.editor.viewport.getRotationAngle()}handleTwoFingerMove(t){const{screenCenter:e,canvasCenter:n,angle:o,dist:r}=this.computePinchData(t[0],t[1]),s=this.getCenterDelta(e);let a;a=this.isRotationLocked()?0:this.toSnappedRotationDelta(o),this.updateVelocity(e);let c=1;if(this.isScaling)c=r/this.lastDist;else{const t=r/this.startDist;(t>1.05||t<.95)&&(c=t,this.isScaling=!0)}const d=i.Mat33.translation(s).rightMul(i.Mat33.scaling2D(c,n)).rightMul(i.Mat33.zRotation(a,n));return this.lastScreenCenter=e,this.lastDist=r,this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(d)),d}handleOneFingerMove(t){const e=this.getCenterDelta(t.screenPos),n=i.Mat33.translation(e);return this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(n)),this.updateVelocity(t.screenPos),this.lastScreenCenter=t.screenPos,n}onPointerMove({allPointers:t}){this.transform??=l.Viewport.transformBy(i.Mat33.identity);let e=i.Mat33.identity;2===t.length?e=this.handleTwoFingerMove(t):1===t.length&&(e=this.handleOneFingerMove(t[0])),l.Viewport.transformBy(e).apply(this.editor),this.lastTimestamp=performance.now()}onPointerUp(t){const e=()=>{this.transform&&(this.transform.unapply(this.editor),this.editor.dispatch(this.transform,!1)),this.editor.display.setDraftMode(!1),this.transform=null,this.velocity=i.Vec2.zero};if(t.current.device===r.PointerDevice.Touch&&1===t.allPointers.length&&null!==this.velocity&&t.current.timeStamp-this.lastPointerDownTimestamp>30&&null!==this.velocity){const n=this.velocity;this.updateVelocity(t.current.screenPos),n.magnitude()<this.velocity.magnitude()&&(this.velocity=n),this.inertialScroller?.stop(),this.inertialScroller=new u(this.velocity,(t=>{if(!this.transform)return;const e=this.editor.viewport.screenToCanvasTransform.transformVec3(t);this.transform.unapply(this.editor),this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(i.Mat33.translation(e))),this.transform.apply(this.editor)}),e)}else e()}onGestureCancel(){this.inertialScroller?.stop(),this.velocity=i.Vec2.zero,this.transform?.unapply(this.editor),this.editor.display.setDraftMode(!1),this.transform=null}updateTransform(t,e=!1){let n=t;this.transform&&(n=this.transform.transform.rightMul(t)),this.transform?.unapply(this.editor),this.transform=l.Viewport.transformBy(n),this.transform.apply(this.editor),e&&this.editor.announceForAccessibility(this.transform.description(this.editor,this.editor.localization))}onWheel({delta:t,screenPos:e}){this.inertialScroller?.stop(),this.transform=l.Viewport.transformBy(i.Mat33.identity);const n=this.editor.viewport.screenToCanvas(e),o=this.editor.viewport.screenToCanvasTransform.transformVec3(i.Vec3.of(-t.x,-t.y,0));let r=t.z;r=2*Math.atan(r/2);const s=i.Mat33.scaling2D(Math.max(.4,Math.min(Math.pow(1.04,-r),4)),n).rightMul(i.Mat33.translation(o));return this.updateTransform(s,!0),!0}onKeyPress(t){if(this.inertialScroller?.stop(),!(this.mode&h.Keyboard))return!1;this.transform=l.Viewport.transformBy(i.Mat33.identity);let e=i.Vec2.zero,n=1,o=0;const r=this.editor.shortcuts;if(r.matchesShortcut(d.moveLeftKeyboardShortcutId,t))e=i.Vec2.of(-1,0);else if(r.matchesShortcut(d.moveRightKeyboardShortcutId,t))e=i.Vec2.of(1,0);else if(r.matchesShortcut(d.moveUpKeyboardShortcutId,t))e=i.Vec2.of(0,-1);else if(r.matchesShortcut(d.moveDownKeyboardShortcutId,t))e=i.Vec2.of(0,1);else if(r.matchesShortcut(d.zoomInKeyboardShortcutId,t))n=.5;else if(r.matchesShortcut(d.zoomOutKeyboardShortcutId,t))n=2;else if(r.matchesShortcut(d.rotateClockwiseKeyboardShortcutId,t))o=1;else{if(!r.matchesShortcut(d.rotateCounterClockwiseKeyboardShortcutId,t))return!1;o=-1}e=e.times(30),o*=Math.PI/8,e=e.times(-1),o*=-1,n=1/n,0!==o&&(o+=1e-4),this.isRotationLocked()&&(o=0);e=this.editor.viewport.screenToCanvasTransform.transformVec3(e);const s=this.editor.viewport.visibleRect.center,a=i.Mat33.scaling2D(n,s).rightMul(i.Mat33.zRotation(o,s)).rightMul(i.Mat33.translation(e));return this.updateTransform(a,!0),!0}isRotationLocked(){return!!(this.mode&h.RotationLocked)}setModeEnabled(t,e){let n=this.mode;e?n|=t:n&=~t,this.setMode(n)}setMode(t){t!==this.mode&&(this.mode=t,this.editor.notifier.dispatch(s.EditorEventType.ToolUpdated,{kind:s.EditorEventType.ToolUpdated,tool:this}))}getMode(){return this.mode}}e.default=p},2719:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=o(n(1697)),s=n(5097),a=o(n(7564)),l=o(n(4321)),c=o(n(7077));class d extends a.default{constructor(t){super(t.notifier,t.localization.pasteHandler),this.editor=t}onPaste(t){const e=t.mime.toLowerCase();return"image/svg+xml"===e?(this.doSVGPaste(t.data),!0):"text/plain"===e?(this.doTextPaste(t.data),!0):("image/png"===e||"image/jpeg"===e)&&(this.doImagePaste(t.data),!0)}async addComponentsFromPaste(t){await this.editor.addAndCenterComponents(t)}async doSVGPaste(t){const e=r.default.fromString(t,!0),n=[];await e.start((t=>{n.push(t)}),((t,e)=>null)),await this.addComponentsFromPaste(n)}async doTextPaste(t){const e=this.editor.toolController.getMatchingTools(l.default);e.sort(((t,e)=>!t.isEnabled()&&e.isEnabled()?-1:!e.isEnabled()&&t.isEnabled()?1:0));const n={size:12,fontFamily:"sans",renderingStyle:{fill:s.Color4.red}},o=e[0]?.getTextStyle()??n,r=t.split("\n");await this.addComponentsFromPaste([i.default.fromLines(r,s.Mat33.identity,o)])}async doImagePaste(t){const e=new Image;e.src=t;const n=await c.default.fromImage(e,s.Mat33.identity);await this.addComponentsFromPaste([n])}}e.default=d},2133:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(505)),s=n(4318),a=n(6951),l=n(3173),c=o(n(7564)),d=n(3348),h=n(3348),u=o(n(2785)),p=n(1151);class f extends c.default{constructor(t,e,n){super(t.notifier,e),this.editor=t,this.builder=null,this.lastPoint=null,this.startPoint=null,this.currentDeviceType=null,this.styleValue=p.ReactiveValue.fromInitialValue({factory:a.makeFreehandLineBuilder,color:i.Color4.blue,thickness:4,...n}),this.styleValue.onUpdateAndNow((t=>{this.style=t,this.noteUpdated()}))}getPressureMultiplier(){const t=this.style.thickness;return 1/this.editor.viewport.getScaleFactor()*t}toStrokePoint(t){let e=Math.max(t.pressure??1,.3);isFinite(e)||(console.warn("Non-finite pressure!",t),e=.3),console.assert(isFinite(t.canvasPos.length()),"Non-finite canvas position!"),console.assert(isFinite(t.screenPos.length()),"Non-finite screen position!"),console.assert(isFinite(t.timeStamp),"Non-finite timeStamp on pointer!");return{pos:t.canvasPos,width:e*this.getPressureMultiplier(),color:this.style.color,time:t.timeStamp}}previewStroke(){this.editor.clearWetInk(),this.builder?.preview(this.editor.display.getWetInkRenderer())}addPointToStroke(t){if(!this.builder)throw new Error("No stroke is currently being generated.");this.builder.addPoint(t),this.lastPoint=t,this.previewStroke()}onPointerDown(t){const{current:e,allPointers:n}=t,o=e.device===s.PointerDevice.Eraser;let i=!1;for(const t of n)if(t.device===s.PointerDevice.Pen){i=!0;break}return!(!this.builder||this.eventCanCancelStroke(t))||!((1!==n.length||o)&&!i)&&(this.startPoint=this.toStrokePoint(e),this.builder=this.style.factory(this.startPoint,this.editor.viewport),this.currentDeviceType=e.device,!0)}eventCanCancelStroke(t){const e=this.lastPoint?.time??0;if(t.current.timeStamp-e>1e3)return!0;const n=this.currentDeviceType===s.PointerDevice.Pen,o=t.current.device===s.PointerDevice.Touch;return!n||!o}eventCanBeDeliveredToNonActiveTool(t){return this.eventCanCancelStroke(t)}onPointerMove({current:t}){this.builder&&t.device===this.currentDeviceType&&this.addPointToStroke(this.toStrokePoint(t))}onPointerUp({current:t}){if(!this.builder)return!1;if(t.device!==this.currentDeviceType)return!0;const e=this.toStrokePoint(t),n={...e,width:this.lastPoint?.width??e.width};return this.addPointToStroke(n),t.isPrimary&&this.finalizeStroke(),!1}onGestureCancel(){this.builder=null,this.editor.clearWetInk()}finalizeStroke(){if(this.builder){const t=this.builder.build();if(this.previewStroke(),t.getBBox().area>0){const e=!0,n=r.default.addElement(t,e);this.editor.dispatch(n)}else console.warn("Pen: Not adding empty stroke",t,"to the canvas.")}this.builder=null,this.lastPoint=null,this.editor.clearWetInk()}noteUpdated(){this.editor.notifier.dispatch(l.EditorEventType.ToolUpdated,{kind:l.EditorEventType.ToolUpdated,tool:this})}setColor(t){t.toHexString()!==this.style.color.toHexString()&&this.styleValue.set({...this.style,color:t})}setThickness(t){t!==this.style.thickness&&this.styleValue.set({...this.style,thickness:t})}setStrokeFactory(t){t!==this.style.factory&&this.styleValue.set({...this.style,factory:t})}setHasStabilization(t){const e=!!this.getInputMapper();t!==e&&(e?this.setInputMapper(null):this.setInputMapper(new u.default(this.editor.viewport)),this.noteUpdated())}getThickness(){return this.style.thickness}getColor(){return this.style.color}getStrokeFactory(){return this.style.factory}getStyleValue(){return this.styleValue}onKeyPress(t){const e=this.editor.shortcuts,n=e.matchesShortcut(d.undoKeyboardShortcutId,t);if(this.builder&&n)return this.finalizeStroke(),!1;let o;return e.matchesShortcut(h.decreaseSizeKeyboardShortcutId,t)?o=2*this.getThickness()/3:e.matchesShortcut(h.increaseSizeKeyboardShortcutId,t)&&(o=3*this.getThickness()/2),void 0!==o&&(o=Math.min(Math.max(1,o),256),this.setThickness(o),!0)}}e.default=f},5248:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564));class r extends i.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.colorPreviewListener=null,this.colorSelectListener=null,this.enabledValue().onUpdateAndNow((()=>{this.updateSelectingStatus()}))}canReceiveInputInReadOnlyEditor(){return!0}updateSelectingStatus(){const t="pipette--color-selection-in-progress";this.isEnabled()&&this.colorSelectListener&&this.colorPreviewListener?this.editor.getRootElement().classList.add(t):this.editor.getRootElement().classList.remove(t)}setColorListener(t,e){this.colorPreviewListener=t,this.colorSelectListener=e,this.updateSelectingStatus()}clearColorListener(){this.colorPreviewListener=null,this.colorSelectListener=null,this.updateSelectingStatus()}onPointerDown({current:t,allPointers:e}){return!(!this.colorPreviewListener||1!==e.length)&&(this.colorPreviewListener(this.editor.display.getColorAt(t.screenPos)),!0)}onPointerMove({current:t}){this.colorPreviewListener?.(this.editor.display.getColorAt(t.screenPos))}onPointerUp({current:t}){this.colorSelectListener?.(this.editor.display.getColorAt(t.screenPos))}onGestureCancel(){this.colorSelectListener?.(null)}}e.default=r},8311:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=n(3173),s=o(n(7564));class a extends s.default{constructor(t){super(t.notifier,"scrollbar"),this.editor=t,this.fadeOutTimeout=null,this.scrollbarOverlay=document.createElement("div"),this.scrollbarOverlay.classList.add("ScrollbarTool-overlay"),this.verticalScrollbar=document.createElement("div"),this.verticalScrollbar.classList.add("vertical-scrollbar"),this.horizontalScrollbar=document.createElement("div"),this.horizontalScrollbar.classList.add("horizontal-scrollbar"),this.scrollbarOverlay.replaceChildren(this.verticalScrollbar,this.horizontalScrollbar);let e=null,n=null;this.enabledValue().onUpdateAndNow((o=>{e?.remove(),n?.remove(),n=null,e=null,o&&(n=t.notifier.on(r.EditorEventType.ViewportChanged,(t=>{this.updateScrollbars()})),this.updateScrollbars(),e=t.createHTMLOverlay(this.scrollbarOverlay))}))}updateScrollbars(){const t=this.editor.viewport,e=t.getScreenRectSize(),n=new i.Rect2(0,0,e.x,e.y),o=this.editor.getImportExportRect().transformedBoundingBox(t.canvasToScreenTransform).union(n),r=n.width/o.width*e.x,s=n.height/o.height*e.y,a=(n.x-o.x)/o.width*e.x,l=(n.y-o.y)/o.height*e.y;this.horizontalScrollbar.style.width=`${r}px`,this.verticalScrollbar.style.height=`${s}px`,this.horizontalScrollbar.style.marginLeft=`${a}px`,this.verticalScrollbar.style.marginTop=`${l}px`;const c=(t,e,n)=>{const o="represents-no-scroll";Math.abs(e-n)<1e-8?t.classList.add(o):t.classList.remove(o)};c(this.horizontalScrollbar,r,e.x),c(this.verticalScrollbar,s,e.y),null!==this.fadeOutTimeout&&clearTimeout(this.fadeOutTimeout);this.fadeOutTimeout=setTimeout((()=>{this.scrollbarOverlay.classList.remove("just-updated")}),3e3),this.scrollbarOverlay.classList.add("just-updated")}}e.default=a},8519:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564)),r=n(3348),s=o(n(7591));class a extends i.default{constructor(t){super(t.notifier,t.localization.selectAllTool),this.editor=t}canReceiveInputInReadOnlyEditor(){return!0}onKeyPress(t){if(this.editor.shortcuts.matchesShortcut(r.selectAllKeyboardShortcut,t)){const t=this.editor.toolController.getMatchingTools(s.default);if(t.length>0){const e=t[0];return e.setEnabled(!0),e.setSelection(this.editor.image.getAllElements()),!0}}return!1}}e.default=a},2129:function(t,e,n){"use strict";var o,i=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const l=a(n(6669)),c=n(5097),d=s(n(370)),h=n(7591),u=a(n(5566)),p=a(n(9721)),f=a(n(1365)),m=n(8862),g=n(3968),b=a(n(505));class y{constructor(t,e){this.editor=e,this.selectionTightBoundingBox=null,this.transform=c.Mat33.identity,this.selectedElems=[],this.hasParent=!0,this.removedFromImage={},this.targetHandle=null,this.backgroundDragging=!1,this.selectionDuplicatedAnimationTimeout=null,this.originalRegion=new c.Rect2(t.x,t.y,0,0),this.transformers={drag:new m.DragTransformer(e,this),resize:new m.ResizeTransformer(e,this),rotate:new m.RotateTransformer(e,this)},this.container=document.createElement("div"),this.backgroundElem=document.createElement("div"),this.backgroundElem.classList.add(`${h.cssPrefix}selection-background`),this.container.appendChild(this.backgroundElem);const n=new d.default({action:d.HandleAction.ResizeX,side:c.Vec2.of(1,.5)},this,this.editor.viewport,(t=>this.transformers.resize.onDragStart(t,g.ResizeMode.HorizontalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),o=new d.default({action:d.HandleAction.ResizeY,side:c.Vec2.of(.5,1)},this,this.editor.viewport,(t=>this.transformers.resize.onDragStart(t,g.ResizeMode.VerticalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),i=new d.default({action:d.HandleAction.ResizeXY,side:c.Vec2.of(1,1)},this,this.editor.viewport,(t=>this.transformers.resize.onDragStart(t,g.ResizeMode.Both)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),r=new d.default({action:d.HandleAction.Rotate,side:c.Vec2.of(.5,0),icon:this.editor.icons.makeRotateIcon()},this,this.editor.viewport,(t=>this.transformers.rotate.onDragStart(t)),(t=>this.transformers.rotate.onDragUpdate(t)),(()=>this.transformers.rotate.onDragEnd()));this.handles=[i,n,o,r];for(const t of this.handles)t.addTo(this.backgroundElem)}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){const t=c.Mat33.zRotation(this.regionRotation,this.originalRegion.center),e=this.transform.rightMul(t.inverse());return this.originalRegion.transformedBoundingBox(e)}computeTightBoundingBox(){return this.selectedElems.reduce(((t,e)=>(t??e.getBBox()).union(e.getBBox())),null)??c.Rect2.empty}get regionRotation(){return this.transform.transformVec3(c.Vec2.unitX).angle()}get preTransformedScreenRegion(){const t=t=>this.editor.viewport.canvasToScreen(t);return c.Rect2.fromCorners(t(this.preTransformRegion.topLeft),t(this.preTransformRegion.bottomRight))}get preTransformedScreenRegionRotation(){return this.editor.viewport.getRotationAngle()}get screenRegion(){const t=this.editor.viewport.canvasToScreenTransform,e=this.editor.viewport.getScaleFactor(),n=t.transformVec2(this.region.center);return new c.Rect2(n.x,n.y,e*this.region.width,e*this.region.height).translatedBy(this.region.size.times(-e/2))}get screenRegionRotation(){return this.regionRotation+this.editor.viewport.getRotationAngle()}setTransform(t,e=!0){this.transform=t,e&&this.hasParent&&(this.scrollTo(),this.previewTransformCmds())}async finalizeTransform(){const t=this.transform,e=this.selectedElems;this.originalRegion=this.originalRegion.transformedBoundingBox(this.transform),this.transform=c.Mat33.identity,await this.editor.dispatch(new y.ApplyTransformationCommand(this,e,t));this.editor.display.getWetInkRenderer().clear()}previewTransformCmds(){if(this.selectedElems.length>500)return void this.updateUI();const t=this.editor.display.getWetInkRenderer();t.clear(),t.pushTransform(this.transform);const e=this.editor.viewport.visibleRect.transformedBoundingBox(this.transform.inverse());for(const n of this.selectedElems)n.render(t,e);t.popTransform(),this.updateUI()}resolveToObjects(){let t=!1;if(this.transform=c.Mat33.identity,0===this.region.w||0===this.region.h){const e=this.editor.viewport.visibleRect.maxDimension/200;this.originalRegion=c.Rect2.bboxOf(this.region.corners,e),t=!0}return this.selectedElems=this.editor.image.getElementsIntersectingRegion(this.region).filter((t=>t.intersectsRect(this.region)&&t.isSelectable())),t&&this.selectedElems.length>0&&(this.selectedElems=[this.selectedElems[this.selectedElems.length-1]]),!!this.recomputeRegion()&&(this.updateUI(),!0)}recomputeRegion(){const t=this.computeTightBoundingBox();return this.selectionTightBoundingBox=t,t?(this.originalRegion=t,this.padRegion(),!0):(this.cancelSelection(),!1)}padRegion(){const t=this.selectionTightBoundingBox??this.originalRegion,e=this.getMinCanvasSize();if(t.w<e||t.h<e){const n=e/2;this.originalRegion=c.Rect2.bboxOf(t.corners,n),this.updateUI()}}getMinCanvasSize(){return 2*(d.handleSize/this.editor.viewport.getScaleFactor())}getSelectedItemCount(){return this.selectedElems.length}updateUI(){if(!this.hasParent)return;this.backgroundElem.style.marginLeft=`${this.screenRegion.topLeft.x}px`,this.backgroundElem.style.marginTop=`${this.screenRegion.topLeft.y}px`,this.backgroundElem.style.width=`${this.screenRegion.width}px`,this.backgroundElem.style.height=`${this.screenRegion.height}px`;const t=180*this.screenRegionRotation/Math.PI;this.backgroundElem.style.transform=`rotate(${t}deg)`,this.backgroundElem.style.transformOrigin="center";const e=`${h.cssPrefix}rotated-near-perpendicular`;Math.abs(Math.sin(this.screenRegionRotation))>.5?this.container.classList.add(e):this.container.classList.remove(e);for(const t of this.handles)t.updatePosition()}addRemoveSelectionFromImage(t){if(t||!(this.selectedElems.length>500)){for(const e of this.selectedElems){const n=this.editor.image.findParent(e);!t&&n?(this.removedFromImage[e.getId()]=!0,n.remove()):!n&&this.removedFromImage[e.getId()]&&(b.default.addElement(e).apply(this.editor),this.removedFromImage[e.getId()]=!1,delete this.removedFromImage[e.getId()])}this.editor.queueRerender().then((()=>{t||this.previewTransformCmds()}))}}removeDeletedElemsFromSelection(){this.selectedElems=this.selectedElems.filter((t=>{const e=!!this.editor.image.findParent(t),n=this.removedFromImage[t.getId()];return e||n}))}onDragStart(t){document.getSelection()?.removeAllRanges(),this.targetHandle=null;let e=!1;for(const n of this.handles)n.containsPoint(t.canvasPos)&&(this.targetHandle=n,e=!0);return this.backgroundDragging=!1,this.region.containsPoint(t.canvasPos)&&(this.backgroundDragging=!0,e=!0),e&&(this.removeDeletedElemsFromSelection(),this.addRemoveSelectionFromImage(!1)),this.targetHandle&&this.targetHandle.handleDragStart(t),this.backgroundDragging&&this.transformers.drag.onDragStart(t.canvasPos),e}onDragUpdate(t){this.backgroundDragging&&this.transformers.drag.onDragUpdate(t.canvasPos),this.targetHandle&&this.targetHandle.handleDragUpdate(t)}onDragEnd(){this.backgroundDragging?this.transformers.drag.onDragEnd():this.targetHandle&&this.targetHandle.handleDragEnd(),this.addRemoveSelectionFromImage(!0),this.backgroundDragging=!1,this.targetHandle=null,this.updateUI()}onDragCancel(){this.backgroundDragging=!1,this.targetHandle=null,this.setTransform(c.Mat33.identity),this.addRemoveSelectionFromImage(!0)}async scrollTo(){if(0===this.selectedElems.length)return;const t=new c.Rect2(0,0,this.editor.display.width,this.editor.display.height);if(!t.containsPoint(this.screenRegion.center)){const e=t.getClosestPointOnBoundaryTo(this.screenRegion.center),n=this.screenRegion.center.minus(e),o=this.editor.viewport.screenToCanvasTransform.transformVec3(n);await this.editor.dispatchNoAnnounce(u.default.transformBy(c.Mat33.translation(o.times(-1))),!1),await this.editor.queueRerender(),this.previewTransformCmds()}}deleteSelectedObjects(){return(this.backgroundDragging||this.targetHandle)&&this.onDragEnd(),new p.default(this.selectedElems)}runSelectionDuplicatedAnimation(){this.selectionDuplicatedAnimationTimeout&&clearTimeout(this.selectionDuplicatedAnimationTimeout);this.backgroundElem.style.animation="400ms ease selection-duplicated-animation",this.selectionDuplicatedAnimationTimeout=setTimeout((()=>{this.backgroundElem.style.animation="",this.selectionDuplicatedAnimationTimeout=null}),400)}async duplicateSelectedObjects(){const t=this.backgroundDragging||this.targetHandle;let e=null;if(t||this.runSelectionDuplicatedAnimation(),t){const t=null;e=new y.ApplyTransformationCommand(t,this.selectedElems,this.transform),await e.apply(this.editor),this.addRemoveSelectionFromImage(!0)}const n=new f.default(this.selectedElems);return t&&(await(e?.unapply(this.editor)),this.addRemoveSelectionFromImage(!1),this.previewTransformCmds(),this.updateUI()),n}addTo(t){this.container.parentElement&&this.container.remove(),t.appendChild(this.container),this.hasParent=!0}setToPoint(t){this.originalRegion=this.originalRegion.grownToPoint(t),this.selectionTightBoundingBox=null,this.updateUI()}cancelSelection(){this.container.parentElement&&this.container.remove(),this.originalRegion=c.Rect2.empty,this.selectionTightBoundingBox=null,this.hasParent=!1}setSelectedObjects(t,e){this.addRemoveSelectionFromImage(!0),this.originalRegion=e,this.selectionTightBoundingBox=e,this.selectedElems=t.filter((t=>t.isSelectable())),this.padRegion(),this.updateUI()}getSelectedObjects(){return[...this.selectedElems]}}o=y,l.default.register("selection-tool-transform",((t,e)=>{const n=new c.Mat33(...t.transform),i=t.elems??[];return new o.ApplyTransformationCommand(null,i,n)})),y.ApplyTransformationCommand=class extends l.default{constructor(t,e,n){super("selection-tool-transform"),this.selection=t,this.fullTransform=n;"string"==typeof e[0]?this.selectedElemIds=e:(this.selectedElemIds=e.map((t=>t.getId())),this.transformCommands=e.map((t=>t.transformBy(this.fullTransform))))}resolveToElems(t){this.transformCommands||(this.transformCommands=this.selectedElemIds.map((e=>{const n=t.image.lookupElement(e);if(!n)throw new Error(`Unable to find element with ID, ${e}.`);return n.transformBy(this.fullTransform)})))}async apply(t){this.resolveToElems(t),this.selection?.setTransform(this.fullTransform,!1),this.selection?.updateUI(),await t.asyncApplyCommands(this.transformCommands,100),this.selection?.setTransform(c.Mat33.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}async unapply(t){this.resolveToElems(t),this.selection?.setTransform(this.fullTransform.inverse(),!1),this.selection?.updateUI(),await t.asyncUnapplyCommands(this.transformCommands,100,!0),this.selection?.setTransform(c.Mat33.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray()}}description(t,e){return e.transformedElements(this.selectedElemIds.length)}},e.default=y},370:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.handleSize=e.HandleAction=void 0;const o=n(6585),i=n(5097),r=n(7591);var s,a;!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square"}(s||(s={})),function(t){t.ResizeXY="resize-xy",t.Rotate="rotate",t.ResizeX="resize-x",t.ResizeY="resize-y"}(a||(e.HandleAction=a={})),e.handleSize=30;e.default=class{constructor(t,e,n,i,l,c){this.presentation=t,this.parent=e,this.viewport=n,this.onDragStart=i,this.onDragUpdate=l,this.onDragEnd=c,this.dragLastPos=null,this.element=document.createElement("div"),this.element.classList.add(`${r.cssPrefix}handle`,`${r.cssPrefix}${t.action}`),this.parentSide=t.side;const d=t.icon;switch(d&&(this.element.appendChild(d),d.classList.add("icon")),t.action===a.Rotate?this.shape=s.Circle:this.shape=s.Square,this.shape){case s.Circle:this.element.classList.add(`${r.cssPrefix}circle`);break;case s.Square:this.element.classList.add(`${r.cssPrefix}square`);break;default:(0,o.assertUnreachable)(this.shape)}this.updatePosition()}addTo(t){t.appendChild(this.element)}getBBoxParentCoords(){const t=this.parent.screenRegion,n=i.Vec2.of(e.handleSize,e.handleSize),o=t.size.scale(this.parentSide).minus(n.times(.5));return new i.Rect2(o.x,o.y,n.x,n.y)}getBBoxCanvasCoords(){const t=this.parent.region,n=i.Vec2.of(e.handleSize,e.handleSize).times(1/this.viewport.getScaleFactor()),o=t.size.scale(this.parentSide).minus(n.times(.5));return new i.Rect2(o.x,o.y,n.x,n.y).translatedBy(t.topLeft)}updatePosition(){const t=this.getBBoxParentCoords();this.element.style.marginLeft=`${t.topLeft.x}px`,this.element.style.marginTop=`${t.topLeft.y}px`,this.element.style.width=`${t.w}px`,this.element.style.height=`${t.h}px`}containsPoint(t){const e=this.getBBoxCanvasCoords(),n=t.minus(e.center),o=e.size.x/2;let i;return i=this.shape===s.Circle?n.magnitude()<=o:Math.abs(n.x)<=o&&Math.abs(n.y)<=o,i}handleDragStart(t){this.onDragStart(t.canvasPos),this.dragLastPos=t.canvasPos}handleDragUpdate(t){this.dragLastPos&&this.onDragUpdate(t.canvasPos)}handleDragEnd(){this.dragLastPos&&this.onDragEnd()}setSnapToGrid(t){this.snapToGrid=t}isSnappingToGrid(){return this.snapToGrid}}},7591:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.cssPrefix=void 0;const i=n(5097),r=n(3173),s=o(n(5566)),a=o(n(7564)),l=o(n(2001)),c=o(n(2129)),d=o(n(3167)),h=n(3348);e.cssPrefix="selection-tool-";class u extends a.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.startPoint=null,this.expandingSelectionBox=!1,this.shiftKeyPressed=!1,this.snapToGrid=!1,this.selectionBoxHandlingEvt=!1,this.lastSelectedObjects=[],this.handleOverlay=document.createElement("div"),t.createHTMLOverlay(this.handleOverlay),this.handleOverlay.style.display="none",this.handleOverlay.classList.add("handleOverlay"),t.notifier.on(r.EditorEventType.ViewportChanged,(t=>{this.editor.clearWetInk(),this.expandingSelectionBox||this.selectionBox?.padRegion(),this.selectionBox?.updateUI()})),this.editor.handleKeyEventsFrom(this.handleOverlay),this.editor.handlePointerEventsFrom(this.handleOverlay)}makeSelectionBox(t){this.prevSelectionBox=this.selectionBox,this.selectionBox=new c.default(t,this.editor),this.expandingSelectionBox||this.prevSelectionBox?.cancelSelection(),this.selectionBox.addTo(this.handleOverlay)}snapSelectionToGrid(){if(!this.selectionBox)throw new Error("No selection to snap!");const t=this.selectionBox.computeTightBoundingBox().topLeft,e=this.editor.viewport.snapToGrid(t).minus(t),n=this.selectionBox.getTransform();this.selectionBox.setTransform(n.rightMul(i.Mat33.translation(e))),this.selectionBox.finalizeTransform()}onPointerDown({allPointers:t,current:e}){const n=this.snapToGrid;if(n&&(e=e.snappedToGrid(this.editor.viewport)),1===t.length&&e.isPrimary){this.startPoint=e.canvasPos;let t=!1;if(this.selectionBox){n&&this.snapSelectionToGrid();this.selectionBox.onDragStart(e)&&(t=!0,this.selectionBoxHandlingEvt=!0,this.expandingSelectionBox=!1)}return t||(this.expandingSelectionBox=this.shiftKeyPressed,this.makeSelectionBox(e.canvasPos)),!0}return!1}onPointerMove(t){if(!this.selectionBox)return;let e=t.current;if(!this.expandingSelectionBox&&this.shiftKeyPressed&&this.startPoint){const t=this.editor.viewport.canvasToScreen(this.startPoint);e=e.lockedToXYAxesScreen(t,this.editor.viewport)}this.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox.onDragUpdate(e):this.selectionBox.setToPoint(e.canvasPos)}onGestureEnd(){this.selectionBox&&(this.selectionBoxHandlingEvt?this.selectionBox.onDragEnd():(this.selectionBox.resolveToObjects(),this.onSelectionUpdated()),this.selectionBoxHandlingEvt=!1)}onPointerUp(t){if(!this.selectionBox)return;let e=t.current;this.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBox.setToPoint(e.canvasPos),this.expandingSelectionBox&&this.prevSelectionBox?(this.expandingSelectionBox=!1,this.selectionBox.resolveToObjects(),this.setSelection([...this.selectionBox.getSelectedObjects(),...this.prevSelectionBox.getSelectedObjects()])):this.onGestureEnd()}onGestureCancel(){this.selectionBoxHandlingEvt?this.selectionBox?.onDragCancel():(this.selectionBox?.cancelSelection(),this.selectionBox=this.prevSelectionBox,this.selectionBox?.addTo(this.handleOverlay),this.selectionBox?.recomputeRegion(),this.prevSelectionBox=null),this.expandingSelectionBox=!1}onSelectionUpdated(){const t=this.selectionBox?.getSelectedItemCount()??0,e=this.selectionBox?.getSelectedObjects()??[];(this.lastSelectedObjects.length!==t||e.some(((t,e)=>this.lastSelectedObjects[e]!==t)))&&(this.lastSelectedObjects=e,this.editor.notifier.dispatch(r.EditorEventType.ToolUpdated,{kind:r.EditorEventType.ToolUpdated,tool:this}),this.editor.notifier.dispatch(r.EditorEventType.SelectionUpdated,{kind:r.EditorEventType.SelectionUpdated,selectedComponents:e,tool:this}),t>0&&(this.editor.announceForAccessibility(this.editor.localization.selectedElements(t)),this.zoomToSelection())),0===t&&this.selectionBox&&(this.selectionBox.cancelSelection(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null)}zoomToSelection(){if(this.selectionBox){const t=this.selectionBox.region;this.editor.dispatchNoAnnounce(this.editor.viewport.zoomTo(t,!1),!1)}}onKeyPress(t){const e=this.editor.shortcuts;if(e.matchesShortcut(h.snapToGridKeyboardShortcutId,t))return this.snapToGrid=!0,!0;if(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t))return!0;if(e.matchesShortcut(h.selectAllKeyboardShortcut,t))return this.setSelection(this.editor.image.getAllElements()),!0;if(t.ctrlKey)return!1;if("Shift"===t.key)return this.shiftKeyPressed=!0,!0;let n=0,o=0,r=0,a=0,l=0;switch(t.key){case"a":case"h":case"ArrowLeft":o-=1;break;case"d":case"l":case"ArrowRight":o+=1;break;case"q":case"k":case"ArrowUp":r-=1;break;case"e":case"j":case"ArrowDown":r+=1;break;case"r":n+=1;break;case"R":n-=1;break;case"i":a-=1;break;case"I":a+=1;break;case"o":l-=1;break;case"O":l+=1}let c=0!==o||0!==r||0!==n||0!==a||0!==l;if(this.selectionBox){if(c){const t=10*this.editor.viewport.getSizeOfPixelOnCanvas(),e=Math.PI/8,c=5/4,d=this.selectionBox.region,h=i.Vec2.of(c**a,c**l),u=i.Mat33.zRotation(n*e).mapEntries((t=>s.default.roundScaleRatio(t))),p=this.editor.viewport.roundPoint(d.center),f=i.Mat33.scaling2D(h,this.editor.viewport.roundPoint(d.topLeft)).rightMul(i.Mat33.translation(p).rightMul(u).rightMul(i.Mat33.translation(p.times(-1)))).rightMul(i.Mat33.translation(this.editor.viewport.roundPoint(i.Vec2.of(o,r).times(t)))),m=this.selectionBox.getTransform();this.selectionBox.setTransform(m.rightMul(f))}}else c=!1;return!this.selectionBox||c||"Delete"!==t.key&&"Backspace"!==t.key||(this.editor.dispatch(this.selectionBox.deleteSelectedObjects()),this.clearSelection(),c=!0),c}onKeyUp(t){const e=this.editor.shortcuts;return e.matchesShortcut(h.snapToGridKeyboardShortcutId,t)?(this.snapToGrid=!1,!0):!!e.matchesShortcut(h.selectAllKeyboardShortcut,t)||(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t)?(this.selectionBox.duplicateSelectedObjects().then((t=>{this.editor.dispatch(t)})),!0):"Shift"===t.key?(this.shiftKeyPressed=!1,!0):!(!this.selectionBox||!u.handleableKeys.some((e=>e===t.key)))&&(this.selectionBox.finalizeTransform(),!0))}onCopy(t){if(!this.selectionBox)return!1;const e=this.selectionBox.getSelectedObjects(),n=this.selectionBox.region;if(0===e.length)return!1;const o=new s.default((()=>{}));o.updateScreenSize(i.Vec2.of(n.w,n.h)),o.resetTransform(i.Mat33.translation(n.topLeft.times(-1)));const{element:r,renderer:a}=l.default.fromViewport(o,!0),c=[];for(const t of e)t.render(a),t instanceof d.default&&c.push(t.getText());return t.setData("image/svg+xml",r.outerHTML),t.setData("text/html",r.outerHTML),c.length>0&&t.setData("text/plain",c.join("\n")),!0}setEnabled(t){super.setEnabled(t),this.selectionBox?.cancelSelection(),this.onSelectionUpdated(),this.handleOverlay.replaceChildren(),this.selectionBox=null,this.shiftKeyPressed=!1,this.snapToGrid=!1,this.handleOverlay.style.display=t?"block":"none",t?(this.handleOverlay.tabIndex=0,this.handleOverlay.setAttribute("aria-label",this.editor.localization.selectionToolKeyboardShortcuts)):this.handleOverlay.tabIndex=-1}getSelection(){return this.selectionBox}getSelectedObjects(){return this.selectionBox?.getSelectedObjects()??[]}setSelection(t){(t=t.filter((t=>t.isSelectable()))).sort(((t,e)=>t.getZIndex()-e.getZIndex())),t=t.filter(((e,n)=>!(n>0)||e!==t[n-1]));let e=null;for(const n of t)e=e?e.union(n.getBBox()):n.getBBox();e&&(this.clearSelection(),this.selectionBox||this.makeSelectionBox(e.topLeft),this.selectionBox.setSelectedObjects(t,e),this.onSelectionUpdated())}clearSelection(){this.handleOverlay.replaceChildren(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null,this.onSelectionUpdated()}}u.handleableKeys=["a","h","ArrowLeft","d","l","ArrowRight","q","k","ArrowUp","e","j","ArrowDown","r","R","i","I","o","O","Control","Meta"],e.default=u},8862:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RotateTransformer=e.ResizeTransformer=e.DragTransformer=void 0;const i=n(5097),r=o(n(5566)),s=n(3968);e.DragTransformer=class{constructor(t,e){this.editor=t,this.selection=e}onDragStart(t){this.selection.setTransform(i.Mat33.identity),this.dragStartPoint=t}onDragUpdate(t){const e=this.editor.viewport.roundPoint(t.minus(this.dragStartPoint));this.selection.setTransform(i.Mat33.translation(e))}onDragEnd(){this.selection.finalizeTransform()}};e.ResizeTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.mode=s.ResizeMode.Both}onDragStart(t,e){this.selection.setTransform(i.Mat33.identity),this.mode=e,this.dragStartPoint=t}onDragUpdate(t){const e=t.minus(this.dragStartPoint),n=this.selection.preTransformRegion.width,o=this.selection.preTransformRegion.height;let a=i.Vec2.of(1,1);if(this.mode===s.ResizeMode.HorizontalOnly){const t=n+e.x;a=i.Vec2.of(t/n,a.y)}if(this.mode===s.ResizeMode.VerticalOnly){const t=o+e.y;a=i.Vec2.of(a.x,t/o)}if(this.mode===s.ResizeMode.Both){const t=n+(Math.abs(e.x)>Math.abs(e.y)?e.x:e.y);a=i.Vec2.of(t/n,t/n)}if(a=a.map((t=>r.default.roundScaleRatio(t,2))),0!==a.x&&0!==a.y){const t=this.editor.viewport.roundPoint(this.selection.preTransformRegion.topLeft);this.selection.setTransform(i.Mat33.scaling2D(a,t))}}onDragEnd(){this.selection.finalizeTransform()}};e.RotateTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.startAngle=0}getAngle(t){const e=this.selection.preTransformRegion.center;return t.minus(e).angle()}roundAngle(t){const e=8/Math.PI;return Math.round(t*e)/e}onDragStart(t){this.selection.setTransform(i.Mat33.identity),this.startAngle=this.getAngle(t)}onDragUpdate(t){const e=this.roundAngle(this.getAngle(t)-this.startAngle),n=this.editor.viewport.roundPoint(this.selection.preTransformRegion.center),o=i.Mat33.zRotation(e).mapEntries((t=>r.default.roundScaleRatio(t))),s=i.Mat33.translation(n).rightMul(o).rightMul(i.Mat33.translation(n.times(-1)));this.selection.setTransform(s)}onDragEnd(){this.selection.finalizeTransform()}}},3968:(t,e)=>{"use strict";var n,o;Object.defineProperty(e,"__esModule",{value:!0}),e.TransformMode=e.ResizeMode=void 0,function(t){t[t.Both=0]="Both",t[t.HorizontalOnly=1]="HorizontalOnly",t[t.VerticalOnly=2]="VerticalOnly"}(n||(e.ResizeMode=n={})),function(t){t[t.Snap=0]="Snap",t[t.NoSnap=1]="NoSnap"}(o||(e.TransformMode=o={}))},7893:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(5097),r=o(n(7564));class s{constructor(){if(this.closed=!1,!window.AudioContext)return console.warn("Accessibility sound UI: Unable to open AudioContext."),void(this.closed=!0);this.ctx=new AudioContext,this.colorOscHue=this.ctx.createOscillator(),this.colorOscValue=this.ctx.createOscillator(),this.colorOscSaturation=this.ctx.createOscillator(),this.colorOscHue.type="triangle",this.colorOscSaturation.type="sine",this.colorOscValue.type="sawtooth",this.valueGain=this.ctx.createGain(),this.colorOscValue.connect(this.valueGain),this.valueGain.gain.setValueAtTime(.18,this.ctx.currentTime),this.colorGain=this.ctx.createGain(),this.colorOscHue.connect(this.colorGain),this.valueGain.connect(this.colorGain),this.colorOscSaturation.connect(this.colorGain),this.colorGain.connect(this.ctx.destination),this.boundaryGain=this.ctx.createGain(),this.boundaryOsc=this.ctx.createOscillator(),this.boundaryOsc.type="sawtooth",this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryOsc.connect(this.boundaryGain),this.boundaryGain.connect(this.ctx.destination),this.colorOscHue.start(),this.colorOscSaturation.start(),this.colorOscValue.start(),this.boundaryOsc.start(),this.pause()}pause(){this.closed||(this.colorGain.gain.setValueAtTime(0,this.ctx.currentTime),this.ctx.suspend())}play(){this.closed||this.ctx.resume()}setColor(t){const e=t.asHSV(),n=220*-Math.cos(e.x/2)+440,o=440*e.y+220,i=440*(e.z+.1),r=.25*Math.min(1,t.a)/(1+Math.exp(3*-(e.z-.5)));this.colorOscHue.frequency.setValueAtTime(n,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(o,this.ctx.currentTime),this.colorOscValue.frequency.setValueAtTime(i,this.ctx.currentTime),this.valueGain.gain.setValueAtTime(.4*(1-e.z),this.ctx.currentTime),this.colorGain.gain.setValueAtTime(r,this.ctx.currentTime)}announceBoundaryCross(t){this.boundaryGain.gain.cancelScheduledValues(this.ctx.currentTime),this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(.018,this.ctx.currentTime+.1),this.boundaryOsc.frequency.setValueAtTime(440+100*Math.atan(t/2),this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(0,this.ctx.currentTime+.25)}close(){this.ctx.close(),this.closed=!0}}class a extends r.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.soundFeedback=null,this.toggleButtonContainer=document.createElement("div"),this.toggleButtonContainer.classList.add("js-draw-sound-ui-toggle"),this.toggleButton=document.createElement("button"),this.toggleButton.onclick=()=>{this.setEnabled(!this.isEnabled())},this.toggleButtonContainer.appendChild(this.toggleButton),this.updateToggleButtonText(),t.createHTMLOverlay(this.toggleButtonContainer)}canReceiveInputInReadOnlyEditor(){return!0}updateToggleButtonText(){const t="sound-ui-tool-enabled";this.isEnabled()?(this.toggleButton.innerText=this.editor.localization.disableAccessibilityExploreTool,this.toggleButtonContainer.classList.add(t)):(this.toggleButton.innerText=this.editor.localization.enableAccessibilityExploreTool,this.toggleButtonContainer.classList.remove(t))}setEnabled(t){super.setEnabled(t),this.isEnabled()?this.editor.announceForAccessibility(this.editor.localization.soundExplorerUsageAnnouncement):(this.soundFeedback?.close(),this.soundFeedback=null),this.updateToggleButtonText()}onKeyPress(t){return"Escape"===t.code&&(this.setEnabled(!1),!0)}onPointerDown({current:t,allPointers:e}){return this.soundFeedback||(this.soundFeedback=new s),!(e.length>=2)&&(this.soundFeedback?.play(),this.soundFeedback?.setColor(this.editor.display.getColorAt(t.screenPos)??i.Color4.black),this.lastPointerPos=t.canvasPos,!0)}onPointerMove({current:t}){this.soundFeedback?.setColor(this.editor.display.getColorAt(t.screenPos)??i.Color4.black);const e=new i.LineSegment2(this.lastPointerPos,t.canvasPos),n=this.editor.image.getElementsIntersectingRegion(e.bbox).filter((t=>t.intersects(e)));this.lastPointerPos=t.canvasPos,n.length>0&&this.soundFeedback?.announceBoundaryCross(n.length)}onPointerUp(t){this.soundFeedback?.pause()}onGestureCancel(){this.soundFeedback?.pause()}}e.default=a},4321:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(3167)),r=o(n(505)),s=n(5097),a=n(4318),l=n(3173),c=o(n(7564)),d=o(n(9721)),h=o(n(1456)),u=n(1151),p="textEditorOverlay";class f extends c.default{constructor(t,e,n){super(t.notifier,e),this.editor=t,this.localizationTable=n,this.textInputElem=null,this.textTargetPosition=null,this.textMeasuringCtx=null,this.textScale=s.Vec2.of(1,1),this.removeExistingCommand=null,this.textStyleValue=u.ReactiveValue.fromInitialValue({size:32,fontFamily:"sans-serif",renderingStyle:{fill:s.Color4.purple}}),this.textStyleValue.onUpdateAndNow((()=>{this.textStyle=this.textStyleValue.get(),this.updateTextInput(),this.editor.notifier.dispatch(l.EditorEventType.ToolUpdated,{kind:l.EditorEventType.ToolUpdated,tool:this})})),this.textEditOverlay=document.createElement("div"),this.textEditOverlay.classList.add(p),this.editor.addStyleSheet(`\n\t\t\t.${p} {\n\t\t\t\theight: 0;\n\t\t\t\toverflow: visible;\n\t\t\t}\n\n\t\t\t.${p} textarea {\n\t\t\t\tbackground-color: rgba(0, 0, 0, 0);\n\n\t\t\t\twhite-space: pre;\n\t\t\t\toverflow: hidden;\n\n\t\t\t\tpadding: 0;\n\t\t\t\tmargin: 0;\n\t\t\t\tborder: none;\n\t\t\t\tpadding: 0;\n\n\t\t\t\tmin-width: 100px;\n\t\t\t\tmin-height: 1.1em;\n\t\t\t}\n\t\t`),this.editor.createHTMLOverlay(this.textEditOverlay),this.editor.notifier.on(l.EditorEventType.ViewportChanged,(()=>this.updateTextInput()))}initTextMeasuringCanvas(){this.textMeasuringCtx??=document.createElement("canvas").getContext("2d")}getTextAscent(t,e){if(this.initTextMeasuringCanvas(),this.textMeasuringCtx){this.textMeasuringCtx.textBaseline="alphabetic",i.default.applyTextStyles(this.textMeasuringCtx,e);const n=this.textMeasuringCtx.measureText(t);return n.fontBoundingBoxAscent??n.actualBoundingBoxAscent}return 2*e.size/3}flushInput(t=!0){if(this.textInputElem&&this.textTargetPosition){const e=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",t){const t=this.textInputElem;this.textInputElem=null,t.remove()}if(""===e)return;const n=s.Mat33.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(s.Mat33.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(s.Mat33.zRotation(this.textRotation)),o=i.default.fromLines(e.split("\n"),n,this.textStyle),a=r.default.addElement(o);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch((0,h.default)([this.removeExistingCommand,a])),this.removeExistingCommand=null):this.editor.dispatch(a)}}getTextScaleMatrix(){return s.Mat33.scaling2D(this.textScale.times(1/this.editor.viewport.getSizeOfPixelOnCanvas()))}updateTextInput(){if(!this.textInputElem||!this.textTargetPosition)return void this.textInputElem?.remove();const t=this.editor.viewport,e=t.canvasToScreen(this.textTargetPosition);this.textInputElem.placeholder=this.localizationTable.enterTextToInsert,this.textInputElem.style.fontFamily=this.textStyle.fontFamily,this.textInputElem.style.fontStyle=this.textStyle.fontStyle??"",this.textInputElem.style.fontVariant=this.textStyle.fontVariant??"",this.textInputElem.style.fontWeight=this.textStyle.fontWeight??"",this.textInputElem.style.fontSize=`${this.textStyle.size}px`,this.textInputElem.style.color=this.textStyle.renderingStyle.fill.toHexString(),this.textInputElem.style.position="relative",this.textInputElem.style.left=`${e.x}px`,this.textInputElem.style.top=`${e.y}px`,this.textInputElem.style.margin="0",this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`;const n=this.getTextAscent("Testing!",this.textStyle),o=this.textRotation+t.getRotationAngle(),i=this.getTextScaleMatrix();this.textInputElem.style.transform=`${i.toCSSMatrix()} rotate(${180*o/Math.PI}deg) translate(0, ${-n}px)`,this.textInputElem.style.transformOrigin="top left";const r=Math.floor(this.textStyle.size);this.textInputElem.style.lineHeight=`${r}px`}startTextInput(t,e){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=e,this.textInputElem.style.display="inline-block",this.textTargetPosition=this.editor.viewport.roundPoint(t),this.textRotation=-this.editor.viewport.getRotationAngle(),this.textScale=s.Vec2.of(1,1).times(this.editor.viewport.getSizeOfPixelOnCanvas()),this.updateTextInput(),setTimeout((()=>this.updateTextInput()),0),this.textInputElem.oninput=()=>{this.textInputElem&&(this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`)},this.textInputElem.onblur=()=>{const t=this.textInputElem;this.flushInput(!1),this.textInputElem=null,setTimeout((()=>{t?.remove()}),0)},this.textInputElem.onkeyup=t=>{"Enter"!==t.key||t.shiftKey?"Escape"===t.key&&(this.textInputElem?.remove(),this.textInputElem=null,this.editor.focus(),this.removeExistingCommand?.unapply(this.editor),this.removeExistingCommand=null):(this.flushInput(),this.editor.focus())},this.textEditOverlay.replaceChildren(this.textInputElem),setTimeout((()=>this.textInputElem?.focus()),0)}setEnabled(t){super.setEnabled(t),this.isEnabled()||this.flushInput(),this.textEditOverlay.style.display=t?"block":"none"}onPointerDown({current:t,allPointers:e}){if(t.device===a.PointerDevice.Eraser)return!1;if(1===e.length){const e=t.canvasPos,n=s.Vec2.of(2.5,2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas()),o=s.Rect2.fromCorners(e.minus(n),e.plus(n));let r=this.editor.image.getElementsIntersectingRegion(o).filter((t=>t instanceof i.default));const a=this.editor.viewport.visibleRect;if(r=r.filter((t=>!t.getBBox().containsRect(a))),this.flushInput(),r.length>0){const t=r[r.length-1];this.setTextStyle(t.getTextStyle()),this.removeExistingCommand=new d.default([t]),this.removeExistingCommand.apply(this.editor),this.startTextInput(t.getBaselinePos(),t.getText());const e=t.getTransform();this.textRotation=e.transformVec3(s.Vec2.unitX).angle();const n=e.transformVec3(s.Vec2.unitX).magnitude();this.textScale=s.Vec2.of(1,1).times(n),this.updateTextInput()}else this.removeExistingCommand=null,this.startTextInput(t.canvasPos,"");return!0}return!1}onGestureCancel(){this.flushInput(),this.editor.focus()}setFontFamily(t){t!==this.textStyle.fontFamily&&this.textStyleValue.set({...this.textStyle,fontFamily:t})}setColor(t){t.eq(this.textStyle.renderingStyle.fill)||this.textStyleValue.set({...this.textStyle,renderingStyle:{...this.textStyle.renderingStyle,fill:t}})}setFontSize(t){t!==this.textStyle.size&&this.textStyleValue.set({...this.textStyle,size:t})}getTextStyle(){return this.textStyle}getStyleValue(){return this.textStyleValue}setTextStyle(t){this.textStyleValue.set(t)}}e.default=f},8169:function(t,e,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(3173),l=n(5097),c=r(n(4735)),d=s(n(2133)),h=s(n(6122)),u=s(n(6416)),p=s(n(7591)),f=s(n(4074)),m=s(n(4321)),g=s(n(5248)),b=s(n(3448)),y=s(n(2719)),v=s(n(6390)),w=n(823),x=s(n(5805)),S=s(n(8519)),T=s(n(7893)),C=n(7520),P=s(n(3135)),k=s(n(2785)),E=s(n(8311));e.default=class{constructor(t,e){this.activeTool=null,this.isEditorReadOnly=t.isReadOnlyReactiveValue(),this.inputPipeline=new P.default,this.inputPipeline.setEmitListener((t=>this.onEventInternal(t)));const n=new h.default;this.primaryToolGroup=n;const o=new c.default(t,c.PanZoomMode.TwoFingerTouchGestures|c.PanZoomMode.RightClickDrags,e.touchPanTool),i=new c.default(t,c.PanZoomMode.Keyboard,e.keyboardPanZoom),r=new d.default(t,e.penTool(1),{color:l.Color4.purple,thickness:8}),s=new d.default(t,e.penTool(2),{color:l.Color4.clay,thickness:4});s.setInputMapper(new k.default(t.viewport));const C=[r,s,new d.default(t,e.penTool(3),{color:l.Color4.ofRGBA(1,1,0,.5),thickness:40,factory:w.makePressureSensitiveFreehandLineBuilder}),new u.default(t,e.eraserTool),new p.default(t,e.selectionTool),new m.default(t,e.textTool,e),new c.default(t,c.PanZoomMode.SinglePointerGestures,e.anyDevicePanning)],z=new T.default(t,e.soundExplorer);z.setEnabled(!1),this.tools=[new E.default(t),new g.default(t,e.pipetteTool),z,o,...C,i,new f.default(t),new v.default(t),new b.default(t),new x.default(t),new y.default(t),new S.default(t)],C.forEach((t=>t.setToolGroup(n))),o.setEnabled(!0),r.setEnabled(!0),t.notifier.on(a.EditorEventType.ToolEnabled,(n=>{n.kind===a.EditorEventType.ToolEnabled&&t.announceForAccessibility(e.toolEnabledAnnouncement(n.tool.description))})),t.notifier.on(a.EditorEventType.ToolDisabled,(n=>{n.kind===a.EditorEventType.ToolDisabled&&t.announceForAccessibility(e.toolDisabledAnnouncement(n.tool.description))})),this.activeTool=null}setTools(t,e){this.tools=t,this.primaryToolGroup=e??new h.default}addPrimaryTool(t){t.setToolGroup(this.primaryToolGroup),t.isEnabled()&&this.primaryToolGroup.notifyEnabled(t),this.addTool(t)}getPrimaryTools(){return this.tools.filter((t=>t.getToolGroup()===this.primaryToolGroup))}addTool(t){this.tools.push(t)}onEventInternal(t){const e=this.isEditorReadOnly.get(),n=t=>t.isEnabled()&&(!e||t.canReceiveInputInReadOnlyEditor());let o=!1;if(t.kind===C.InputEvtType.PointerDownEvt){let e=!1;this.activeTool&&!this.activeTool.eventCanBeDeliveredToNonActiveTool(t)&&(e=!0);for(const i of this.tools)if((!e||i===this.activeTool)&&n(i)&&i.onEvent(t)){this.activeTool!==i&&this.activeTool?.onEvent({kind:C.InputEvtType.GestureCancelEvt}),this.activeTool=i,o=!0;break}}else if(t.kind===C.InputEvtType.PointerUpEvt){const e=this.activeTool?.onEvent(t);e&&t.allPointers.length>1||(this.activeTool=null),o=!0}else if(t.kind===C.InputEvtType.PointerMoveEvt)null!==this.activeTool&&(this.activeTool.onEvent(t),o=!0);else if(t.kind===C.InputEvtType.GestureCancelEvt)null!==this.activeTool&&(this.activeTool.onEvent(t),this.activeTool=null);else for(const e of this.tools)if(n(e)&&(o=e.onEvent(t),o))break;return o}onEvent(t){return this.dispatchInputEvent(t)}dispatchInputEvent(t){return this.inputPipeline.onEvent(t)}addInputMapper(t){this.inputPipeline.addToTail(t)}getMatchingTools(t){return this.tools.filter((e=>e instanceof t))}onEditorDestroyed(){for(const t of this.tools)t.onDestroy()}}},6122:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){}notifyEnabled(t){t!==this.activeTool&&(this.activeTool?.setEnabled(!1),this.activeTool=t)}}},3448:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564));class r extends i.default{constructor(t){super(t.notifier,t.localization.changeTool),this.editor=t}canReceiveInputInReadOnlyEditor(){return!0}onKeyPress({key:t}){const e=this.editor.toolController.getPrimaryTools(),n=/^[0-9]$/.exec(t);let o;if(n){o=e[parseInt(n[0],10)-1]}return!!o&&(o.setEnabled(!0),!0)}}e.default=r},6390:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564));class r extends i.default{constructor(t){super(t.notifier,t.localization.changeTool),this.listeners=new Set([])}registerListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}onKeyPress(t){const e=Array.from(this.listeners.values());for(const n of e)if(n(t))return!0;return!1}}e.default=r},4074:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(7564)),r=n(3348);class s extends i.default{constructor(t){super(t.notifier,t.localization.undoRedoTool),this.editor=t}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(r.undoKeyboardShortcutId,t)?(this.editor.history.undo(),!0):!!this.editor.shortcuts.matchesShortcut(r.redoKeyboardShortcutId,t)&&(this.editor.history.redo(),!0)}}e.default=s},3348:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.duplicateSelectionShortcut=e.selectAllKeyboardShortcut=e.zoomOutKeyboardShortcutId=e.zoomInKeyboardShortcutId=e.rotateCounterClockwiseKeyboardShortcutId=e.rotateClockwiseKeyboardShortcutId=e.moveDownKeyboardShortcutId=e.moveUpKeyboardShortcutId=e.moveRightKeyboardShortcutId=e.moveLeftKeyboardShortcutId=e.toggleFindVisibleShortcutId=e.lineLockKeyboardShortcutId=e.snapToGridKeyboardShortcutId=e.decreaseSizeKeyboardShortcutId=e.increaseSizeKeyboardShortcutId=e.redoKeyboardShortcutId=e.undoKeyboardShortcutId=void 0;const i=o(n(5376));e.undoKeyboardShortcutId="jsdraw.tools.undo",e.redoKeyboardShortcutId="jsdaw.tools.redo",i.default.registerDefaultKeyboardShortcut(e.undoKeyboardShortcutId,["CtrlOrMeta+KeyZ"],"Undo"),i.default.registerDefaultKeyboardShortcut(e.redoKeyboardShortcutId,["CtrlOrMeta+Shift+KeyZ","CtrlOrMeta+KeyY"],"Redo"),e.increaseSizeKeyboardShortcutId="jsdraw.tools.increaseSize",i.default.registerDefaultKeyboardShortcut(e.increaseSizeKeyboardShortcutId,["Equal","Shift+Equal"],"Increase pen/eraser size"),e.decreaseSizeKeyboardShortcutId="jsdraw.tools.decreaseSize",i.default.registerDefaultKeyboardShortcut(e.decreaseSizeKeyboardShortcutId,["Minus","Shift+Minus"],"Decrease pen/eraser size"),e.snapToGridKeyboardShortcutId="jsdraw.tools.snapToGrid",i.default.registerDefaultKeyboardShortcut(e.snapToGridKeyboardShortcutId,["Control","Meta"],"Snap to grid (press and hold)"),e.lineLockKeyboardShortcutId="jsdraw.tools.lockToLine",i.default.registerDefaultKeyboardShortcut(e.lineLockKeyboardShortcutId,["Shift"],"Snap to XY axes (press and hold)"),e.toggleFindVisibleShortcutId="js-draw.tools.FindTool.toggleVisible",i.default.registerDefaultKeyboardShortcut(e.toggleFindVisibleShortcutId,["CtrlOrMeta+KeyF"],"Shows/hides the find tool"),e.moveLeftKeyboardShortcutId="jsdraw.tools.PanZoom.moveLeft",i.default.registerDefaultKeyboardShortcut(e.moveLeftKeyboardShortcutId,["ArrowLeft","KeyH","KeyA"],"Pan left"),e.moveRightKeyboardShortcutId="jsdraw.tools.PanZoom.moveRight",i.default.registerDefaultKeyboardShortcut(e.moveRightKeyboardShortcutId,["ArrowRight","KeyL","KeyD"],"Pan right"),e.moveUpKeyboardShortcutId="jsdraw.tools.PanZoom.moveUp",i.default.registerDefaultKeyboardShortcut(e.moveUpKeyboardShortcutId,["ArrowUp","KeyK","KeyQ"],"Pan up"),e.moveDownKeyboardShortcutId="jsdraw.tools.PanZoom.moveDown",i.default.registerDefaultKeyboardShortcut(e.moveDownKeyboardShortcutId,["ArrowDown","KeyJ","KeyE"],"Pan down"),e.rotateClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewClockwise",i.default.registerDefaultKeyboardShortcut(e.rotateClockwiseKeyboardShortcutId,["Shift+KeyR"],"Rotate viewport clockwise"),e.rotateCounterClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewCounterClockwise",i.default.registerDefaultKeyboardShortcut(e.rotateCounterClockwiseKeyboardShortcutId,["KeyR"],"Rotate viewport counter-clockwise"),e.zoomInKeyboardShortcutId="jsdraw.tools.PanZoom.zoomIn",i.default.registerDefaultKeyboardShortcut(e.zoomInKeyboardShortcutId,["KeyW"],"Zoom in"),e.zoomOutKeyboardShortcutId="jsdraw.tools.PanZoom.zoomOut",i.default.registerDefaultKeyboardShortcut(e.zoomOutKeyboardShortcutId,["KeyS"],"Zoom out"),e.selectAllKeyboardShortcut="jsdraw.tools.SelectionTool.selectAll",i.default.registerDefaultKeyboardShortcut(e.selectAllKeyboardShortcut,["CtrlOrMeta+KeyA"],"Select all"),e.duplicateSelectionShortcut="jsdraw.tools.SelectionTool.duplicateSelection",i.default.registerDefaultKeyboardShortcut(e.duplicateSelectionShortcut,["CtrlOrMeta+KeyD"],"Duplicate selection")},1709:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ToolbarShortcutHandler=e.SoundUITool=e.PasteHandler=e.EraserTool=e.SelectAllShortcutHandler=e.SelectionTool=e.TextTool=e.PenTool=e.PanZoomMode=e.PanZoomTool=e.ToolSwitcherShortcut=e.UndoRedoShortcut=e.ToolEnabledGroup=e.ToolController=e.BaseTool=void 0;var i=n(7564);Object.defineProperty(e,"BaseTool",{enumerable:!0,get:function(){return o(i).default}});var r=n(8169);Object.defineProperty(e,"ToolController",{enumerable:!0,get:function(){return o(r).default}});var s=n(6122);Object.defineProperty(e,"ToolEnabledGroup",{enumerable:!0,get:function(){return o(s).default}});var a=n(4074);Object.defineProperty(e,"UndoRedoShortcut",{enumerable:!0,get:function(){return o(a).default}});var l=n(3448);Object.defineProperty(e,"ToolSwitcherShortcut",{enumerable:!0,get:function(){return o(l).default}});var c=n(4735);Object.defineProperty(e,"PanZoomTool",{enumerable:!0,get:function(){return o(c).default}}),Object.defineProperty(e,"PanZoomMode",{enumerable:!0,get:function(){return c.PanZoomMode}});var d=n(2133);Object.defineProperty(e,"PenTool",{enumerable:!0,get:function(){return o(d).default}});var h=n(4321);Object.defineProperty(e,"TextTool",{enumerable:!0,get:function(){return o(h).default}});var u=n(7591);Object.defineProperty(e,"SelectionTool",{enumerable:!0,get:function(){return o(u).default}});var p=n(8519);Object.defineProperty(e,"SelectAllShortcutHandler",{enumerable:!0,get:function(){return o(p).default}});var f=n(6416);Object.defineProperty(e,"EraserTool",{enumerable:!0,get:function(){return o(f).default}});var m=n(2719);Object.defineProperty(e,"PasteHandler",{enumerable:!0,get:function(){return o(m).default}});var g=n(7893);Object.defineProperty(e,"SoundUITool",{enumerable:!0,get:function(){return o(g).default}});var b=n(6390);Object.defineProperty(e,"ToolbarShortcutHandler",{enumerable:!0,get:function(){return o(b).default}})},3376:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolLocalization=void 0,e.defaultToolLocalization={penTool:t=>`Pen ${t}`,selectionTool:"Selection",selectAllTool:"Select all shortcut",eraserTool:"Eraser",touchPanTool:"Touch panning",twoFingerPanZoomTool:"Panning and zooming",undoRedoTool:"Undo/Redo",rightClickDragPanTool:"Right-click drag",pipetteTool:"Pick color from screen",keyboardPanZoom:"Keyboard pan/zoom shortcuts",textTool:"Text",enterTextToInsert:"Text to insert",changeTool:"Change tool",pasteHandler:"Copy paste handler",soundExplorer:"Sound-based image exploration",disableAccessibilityExploreTool:"Disable sound-based exploration",enableAccessibilityExploreTool:"Enable sound-based exploration",soundExplorerUsageAnnouncement:"Sound-based image exploration enabled: Click/drag the screen to play a sound representation of different parts of the image.",findLabel:"Find",toNextMatch:"Next",closeDialog:"Close",findDialogShown:"Find dialog shown",findDialogHidden:"Find dialog hidden",focusedFoundText:(t,e)=>`Viewing match ${t} of ${e}`,anyDevicePanning:"Any device panning",copied:(t,e)=>`Copied ${t} ${e}`,pasted:(t,e)=>`Pasted ${t} ${e}`,toolEnabledAnnouncement:t=>`${t} enabled`,toolDisabledAnnouncement:t=>`${t} disabled`}},3173:(t,e)=>{"use strict";var n,o;Object.defineProperty(e,"__esModule",{value:!0}),e.UndoEventType=e.EditorEventType=void 0,function(t){t[t.ToolEnabled=0]="ToolEnabled",t[t.ToolDisabled=1]="ToolDisabled",t[t.ToolUpdated=2]="ToolUpdated",t[t.UndoRedoStackUpdated=3]="UndoRedoStackUpdated",t[t.CommandDone=4]="CommandDone",t[t.CommandUndone=5]="CommandUndone",t[t.ObjectAdded=6]="ObjectAdded",t[t.ViewportChanged=7]="ViewportChanged",t[t.DisplayResized=8]="DisplayResized",t[t.SelectionUpdated=9]="SelectionUpdated",t[t.ReadOnlyModeToggled=10]="ReadOnlyModeToggled",t[t.ColorPickerToggled=11]="ColorPickerToggled",t[t.ColorPickerColorSelected=12]="ColorPickerColorSelected",t[t.ToolbarDropdownShown=13]="ToolbarDropdownShown"}(n||(e.EditorEventType=n={})),function(t){t[t.CommandDone=0]="CommandDone",t[t.CommandUndone=1]="CommandUndone",t[t.CommandRedone=2]="CommandRedone"}(o||(e.UndoEventType=o={}))},1151:function(t,e){"use strict";var n,o,i=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},r=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0}),e.MutableReactiveValue=e.ReactiveValue=void 0;const s={remove(){}},a=()=>s;class l{static fromInitialValue(t){return new d(t)}static fromImmutable(t){return{get:()=>t,onUpdate:a,onUpdateAndNow:e=>(e(t),s)}}static fromCallback(t,e){const n=new d(t()),o=window.WeakRef?new window.WeakRef(n):{deref:()=>n};for(const n of e){const e=n.onUpdate((()=>{const n=o.deref();n?n.set(t()):e.remove()}))}return n}static map(t,e,n){const o=l.fromInitialValue(e(t.get()));let i=o.get();return t.onUpdate((t=>{i=e(t),o.set(i)})),n&&o.onUpdate((e=>{e!==i&&t.set(n(e))})),o}}e.ReactiveValue=l;class c extends l{static fromProperty(t,e){const n=l.fromInitialValue(t.get()[e]),o=window.WeakRef?new window.WeakRef(n):{deref:()=>n},i=t.onUpdate((t=>{const n=o.deref();n?n.set(t[e]):i.remove()}));return n.onUpdate((n=>{t.set({...t.get(),[e]:n})})),n}}e.MutableReactiveValue=c;class d extends c{constructor(t){super(),n.set(this,void 0),o.set(this,void 0),i(this,n,t,"f"),i(this,o,[],"f")}set(t){if(r(this,n,"f")!==t){i(this,n,t,"f");for(const e of r(this,o,"f"))e(t)}}get(){return r(this,n,"f")}onUpdate(t){return r(this,o,"f").push(t),{remove:()=>{i(this,o,r(this,o,"f").filter((e=>e!==t)),"f")}}}onUpdateAndNow(t){return t(this.get()),this.onUpdate(t)}}n=new WeakMap,o=new WeakMap,e.default=l},438:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=n(5097);e.default=(t,e)=>{const n=t.getRootElement(),i=[["--background-color-1","--foreground-color-1",!0,!0],["--background-color-2","--foreground-color-2",!0,!0],["--background-color-3","--foreground-color-3",!0,!0],["--background-color-2","--primary-action-foreground-color",!1,!0],["--selection-background-color","--selection-foreground-color",!1,!0]];if(!e?.dontClearOverrides)for(const[t,e]of i)n.style.setProperty(t,null),n.style.setProperty(e,null);const r=getComputedStyle(n),s=Object.create(null),a=(t,e,i,a,l)=>{let c=s[t]?s[t]:o.Color4.fromString(r.getPropertyValue(t)),d=s[e]?s[e]:o.Color4.fromString(r.getPropertyValue(e));if(c.relativeLuminance()<d.relativeLuminance()){const n=c;c=d,d=n;const o=e;e=t,t=o;const i=a;a=l,l=i}let h=!1,u=o.Color4.contrastRatio(c,d),p=0;for(;u<i&&p<8;){const t=o.Vec3.of(.1,.1,.1);a&&(d.eq(o.Color4.white)&&!l&&(d=o.Color4.black),c=o.Color4.fromRGBVector(c.rgb.plus(t))),l&&(d.eq(o.Color4.black)&&!a&&(d=o.Color4.white),d=o.Color4.fromRGBVector(d.rgb.minus(t))),u=o.Color4.contrastRatio(c,d),h=!0,p++}h&&(n.style.setProperty(t,c.toHexString()),n.style.setProperty(e,d.toHexString()),s[t]=c,s[e]=d)};a("--selection-background-color","--background-color-2",1.29,!0,!1);for(const[t,e,n,o]of i){a(t,e,4.5,n,o)}}},6585:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertIsBoolean=e.assertIsNumberArray=e.assertIsNumber=e.assertUnreachable=void 0;e.assertUnreachable=t=>{throw new Error(`Should be unreachable. Key: ${t}.`)};e.assertIsNumber=(t,e=!1)=>{if("number"!=typeof t||!e&&isNaN(t))throw new Error("Given value is not a number");return!0};e.assertIsNumberArray=(t,n=!1)=>{if("object"!=typeof t)throw new Error("Asserting isNumberArray: Given entity is not an array");if(!(0,e.assertIsNumber)(t.length))return!1;for(const o of t)if(!(0,e.assertIsNumber)(o,n))return!1;return!0};e.assertIsBoolean=t=>{if("boolean"!=typeof t)throw new Error("Given value is not a boolean");return!0}},9070:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=new FileReader;return new Promise(((o,i)=>{n.onload=()=>o(n.result),n.onerror=i,n.onabort=i,n.onprogress=t=>{e?.(t)},n.readAsDataURL(t)}))}},1993:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n={Control:"ControlLeft","=":"Equal","-":"Minus",";":"Semicolon"," ":"Space"};e.default=t=>{const e=t.toUpperCase();return"A"<=e&&e<="Z"?`Key${e}`:"0"<=t&&t<="9"?`Digit${t}`:t in n?n[t]:t}},3662:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.adjustEditorThemeForContrast=void 0;var i=n(438);Object.defineProperty(e,"adjustEditorThemeForContrast",{enumerable:!0,get:function(){return o(i).default}})},8315:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=t.length<e.length?t:e,o=n===t?e:t;for(let t=0;t<n.length;t++)if(n[t]!==o[t])return!1;return!0}},9441:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{t.onwheel=e=>{const n=t.clientWidth!==t.scrollWidth&&0!==e.deltaX,o=t.scrollLeft+e.deltaX<=0,i=t.scrollLeft+t.clientWidth+e.deltaX>t.scrollWidth;!n||o||i||e.stopPropagation()}}},7395:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=()=>new Promise((t=>{requestAnimationFrame((()=>t()))}))},7129:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{if(t.some((t=>t&&t.then)))return Promise.all(t).then((()=>{}))}},2674:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={number:"1.4.1"}},9143:(t,e,n)=>{"use strict";n.r(e);var o=n(6062),i=n.n(o),r=n(4036),s=n.n(r),a=n(6793),l=n.n(a),c=n(7892),d=n.n(c),h=n(1173),u=n.n(h),p=n(2464),f=n.n(p),m=n(4245),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u();i()(m.Z,g);m.Z&&m.Z.locals&&m.Z.locals;var b=n(489),y={};y.styleTagTransform=f(),y.setAttributes=d(),y.insert=l().bind(null,"head"),y.domAPI=s(),y.insertStyleElement=u();i()(b.Z,y);b.Z&&b.Z.locals&&b.Z.locals},8463:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Color4=void 0;const i=o(n(3505));class r{constructor(t,e,n,o){this.r=t,this.g=e,this.b=n,this.a=o,this.hexString=null}static ofRGB(t,e,n){return r.ofRGBA(t,e,n,1)}static ofRGBA(t,e,n,o){return t=Math.max(0,Math.min(t,1)),e=Math.max(0,Math.min(e,1)),n=Math.max(0,Math.min(n,1)),o=Math.max(0,Math.min(o,1)),new r(t,e,n,o)}static fromHex(t){if(!(t=(t=(t.match(/^[#]?(.*)$/)??[])[1]).toUpperCase()).match(/^[0-9A-F]+$/))throw new Error(`${t} is not in a valid format.`);if(3===t.length||4===t.length){const e=t.split("");t=e.map((t=>`${t}0`)).join("")}6===t.length&&(t+="FF");const e=[];for(let n=2;n<=t.length;n+=2){const o=t.substring(n-2,n);e.push(parseInt(o,16)/255)}if(4!==e.length)throw new Error(`Unable to parse ${t}: Wrong number of components.`);return r.ofRGBA(e[0],e[1],e[2],e[3])}static fromString(t){if(t.startsWith("#"))return r.fromHex(t);if("none"===t||"transparent"===t)return r.transparent;if(""===t)return r.black;const e=t.replace(/\s*/g,"").match(/^rgba?\(([,0-9.]+)\)$/i);if(e){const n=e[1],o=JSON.parse(`[ ${n} ]`);if(3===o.length)return r.ofRGB(o[0]/255,o[1]/255,o[2]/255);if(4===o.length)return r.ofRGBA(o[0]/255,o[1]/255,o[2]/255,o[3]);throw new Error(`RGB string, ${t}, has wrong number of components: ${o.length}`)}const n=document.createElement("canvas");n.width=1,n.height=1;const o=n.getContext("2d");if(!o)return r.black;o.fillStyle=t,o.fillRect(0,0,1,1);const i=o.getImageData(0,0,1,1),s=i.data[0]/255,a=i.data[1]/255,l=i.data[2]/255,c=i.data[3]/255;return r.ofRGBA(s,a,l,c)}eq(t){return null!=t&&(0===this.a&&0===t.a||this.toHexString()===t.toHexString())}mix(t,e){const n=1-(e=Math.min(Math.max(e,0),1));return new r(this.r*n+t.r*e,this.g*n+t.g*e,this.b*n+t.b*e,this.a*n+t.a*e)}get rgb(){return i.default.of(this.r,this.g,this.b)}relativeLuminance(){const t=[this.r,this.g,this.b].map((t=>t<.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)));return.2126*t[0]+.7152*t[1]+.0722*t[2]}static contrastRatio(t,e){const n=t.relativeLuminance(),o=e.relativeLuminance();return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}static average(t){let e=0,n=0,o=0,i=0;for(const r of t)e+=r.a,n+=r.r,o+=r.g,i+=r.b;return t.length>0&&(e/=t.length,n/=t.length,o/=t.length,i/=t.length),new r(n,o,i,e)}asHSV(){const t=Math.min(this.r,this.g,this.b),e=Math.max(this.r,this.g,this.b),n=e-t;let o;o=0===n?0:this.r>=this.g&&this.r>=this.b?(this.g-this.b)/n%6:this.g>=this.r&&this.g>=this.b?(this.b-this.r)/n+2:(this.r-this.g)/n+4,o*=60,o*=Math.PI/180,o<0&&(o+=2*Math.PI);const r=e,s=r>0?n/r:0;return i.default.of(o,s,r)}static fromHSV(t,e,n){t<0&&(t+=2*Math.PI),t%=2*Math.PI;const o=(n=Math.max(0,Math.min(1,n)))*(e=Math.max(0,Math.min(1,e))),i=t/(Math.PI/3),s=o*(1-Math.abs(i%2-1));let a;a=i<1?[o,s,0]:i<2?[s,o,0]:i<3?[0,o,s]:i<4?[0,s,o]:i<5?[s,0,o]:[o,0,s];const l=n-o;return r.ofRGB(a[0]+l,a[1]+l,a[2]+l)}static fromRGBVector(t,e){return r.ofRGBA(t.x,t.y,t.z,e??1)}toHexString(){if(this.hexString)return this.hexString;const t=t=>{const e=Math.round(255*t).toString(16);return 1===e.length?`0${e}`:e},e=t(this.a),n=t(this.r),o=t(this.g),i=t(this.b);return"ff"===e?`#${n}${o}${i}`:(this.hexString=`#${n}${o}${i}${e}`,this.hexString)}toString(){return this.toHexString()}}e.Color4=r,r.transparent=r.ofRGBA(0,0,0,0),r.red=r.ofRGB(1,0,0),r.orange=r.ofRGB(1,.65,0),r.green=r.ofRGB(0,1,0),r.blue=r.ofRGB(0,0,1),r.purple=r.ofRGB(.5,.2,.5),r.yellow=r.ofRGB(1,1,.1),r.clay=r.ofRGB(.8,.4,.2),r.black=r.ofRGB(0,0,0),r.gray=r.ofRGB(.5,.5,.5),r.white=r.ofRGB(1,1,1),e.default=r},3380:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Mat33=void 0;const i=n(1728),r=o(n(3505));class s{constructor(t,e,n,o,i,s,a,l,c){this.a1=t,this.a2=e,this.a3=n,this.b1=o,this.b2=i,this.b3=s,this.c1=a,this.c2=l,this.c3=c,this.cachedInverse=void 0,this.rows=[r.default.of(t,e,n),r.default.of(o,i,s),r.default.of(a,l,c)]}static ofRows(t,e,n){return new s(t.x,t.y,t.z,e.x,e.y,e.z,n.x,n.y,n.z)}inverse(){return this.computeInverse()??s.identity}invertable(){return null!==this.computeInverse()}computeInverse(){if(void 0!==this.cachedInverse)return this.cachedInverse;const t=[this.rows[0],this.rows[1],this.rows[2]],e=[r.default.unitX,r.default.unitY,r.default.unitZ];for(let n=0;n<3;n++){let o=t[n].at(n);const i=1e-10;if(Math.abs(o)<i){let r=-1;for(let e=1;e<=2;e++){const o=(n+e)%3;if(Math.abs(t[o].at(n))>=i){r=o;break}}if(-1===r)return this.cachedInverse=null,null;const s=t[n],a=e[n];t[n]=t[r],e[n]=e[r],t[r]=s,e[r]=a,o=t[n].at(n)}let r=1/o;t[n]=t[n].times(r),e[n]=e[n].times(r);const s=t[n],a=e[n];for(let o=1;o<=2;o++){const i=(n+o)%3;r=-t[i].at(n),t[i]=t[i].plus(s.times(r)),e[i]=e[i].plus(a.times(r))}}const n=s.ofRows(e[0],e[1],e[2]);return this.cachedInverse=n,n}transposed(){return new s(this.a1,this.b1,this.c1,this.a2,this.b2,this.c2,this.a3,this.b3,this.c3)}rightMul(t){t=t.transposed();const e=(e,n)=>this.rows[e].dot(t.rows[n]);return new s(e(0,0),e(0,1),e(0,2),e(1,0),e(1,1),e(1,2),e(2,0),e(2,1),e(2,2))}transformVec2(t){let e=r.default.of(t.x,t.y,1);return e=this.transformVec3(e),i.Vec2.of(e.x,e.y)}transformVec3(t){return r.default.of(this.rows[0].dot(t),this.rows[1].dot(t),this.rows[2].dot(t))}isIdentity(){return this===s.identity||this.eq(s.identity)}eq(t,e=0){for(let n=0;n<3;n++)if(!this.rows[n].eq(t.rows[n],e))return!1;return!0}toString(){let t="";const e=[0,0,0];for(const t of this.rows)for(let n=0;n<3;n++)e[n]=Math.max(e[0],`${t.at(n)}`.length);for(let n=0;n<3;n++){t+=0===n?"⎡ ":1===n?"⎢ ":"⎣ ";for(let o=0;o<3;o++){const i=this.rows[n].at(o).toString();let r="";for(let t=i.length;t<e[o];t++)r+=" ";t+=i+", "+r}t+=0===n?" ⎤":1===n?" ⎥":" ⎦",t+="\n"}return t.trimEnd()}toArray(){return[this.a1,this.a2,this.a3,this.b1,this.b2,this.b3,this.c1,this.c2,this.c3]}mapEntries(t){return new s(t(this.a1,[0,0]),t(this.a2,[0,1]),t(this.a3,[0,2]),t(this.b1,[1,0]),t(this.b2,[1,1]),t(this.b3,[1,2]),t(this.c1,[2,0]),t(this.c2,[2,1]),t(this.c3,[2,2]))}getScaleFactor(){return Math.hypot(this.a1,this.a2)}getColumn(t){return r.default.of(this.rows[0].at(t),this.rows[1].at(t),this.rows[2].at(t))}maximumEntryMagnitude(){let t=Math.abs(this.a1);for(const e of this.toArray())t=Math.max(t,Math.abs(e));return t}static translation(t){return new s(1,0,t.x,0,1,t.y,0,0,1)}static zRotation(t,e=i.Vec2.zero){if(0===t)return s.identity;const n=Math.cos(t),o=Math.sin(t);let r=s.translation(e);return r=r.rightMul(new s(n,-o,0,o,n,0,0,0,1)),r.rightMul(s.translation(e.times(-1)))}static scaling2D(t,e=i.Vec2.zero){let n,o,r=s.translation(e);return"number"==typeof t?(n=t,o=t):(n=t.x,o=t.y),r=r.rightMul(new s(n,0,0,0,o,0,0,0,1)),r.rightMul(s.translation(e.times(-1)))}toCSSMatrix(){return`matrix(${this.a1},${this.b1},${this.a2},${this.b2},${this.a3},${this.b3})`}static fromCSSMatrix(t){if(""===t||"none"===t)return s.identity;const e=t=>t.split(/[, \t\n]+/g).map((e=>{let n=!1;e.endsWith("%")&&(n=!0,e=e.substring(0,e.length-1)),e=e.replace(/px$/gi,"");if(!/^[-]?\d*(?:\.\d*)?(?:[eE][-+]?\d+)?$/i.exec(e))throw new Error(`All arguments to transform functions must be numeric (state: ${JSON.stringify({currentArgument:e,allArguments:t})})`);let o=parseFloat(e);return n&&(o/=100),o})),n={matrix:t=>{if(6!==t.length)throw new Error(`Invalid matrix argument: ${t}. Must have length 6`);const e=t[0],n=t[1],o=t[2],i=t[3],r=t[4],a=t[5];return new s(e,o,r,n,i,a,0,0,1)},scale:t=>{let e,n;if(1===t.length)e=t[0],n=t[0];else{if(2!==t.length)throw new Error(`The scale() function only supports two arguments. Given: ${t}`);e=t[0],n=t[1]}return s.scaling2D(i.Vec2.of(e,n))},translate:t=>{let e=0,n=0;if(1===t.length)e=t[0];else{if(2!==t.length)throw new Error(`The translate() function requires either 1 or 2 arguments. Given ${t}`);e=t[0],n=t[1]}return s.translation(i.Vec2.of(e,n))}},o=/\s*(\w+)\s*\(([^)]*)\)/gi;let r,a=null;for(;null!==(r=o.exec(t));){const t=r[1].toLowerCase();if(!(t in n))throw new Error(`Unsupported CSS transform action: ${t}`);const o=e(r[2]),i=n[t](o);a=a?a.rightMul(i):i}return a??s.identity}}e.Mat33=s,s.identity=new s(1,0,0,0,1,0,0,0,1),e.default=s},1728:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Vec2=void 0;const i=o(n(3505));var r;!function(t){t.of=(t,e)=>i.default.of(t,e,0),t.ofXY=({x:t,y:e})=>i.default.of(t,e,0),t.unitX=t.of(1,0),t.unitY=t.of(0,1),t.zero=t.of(0,0)}(r||(e.Vec2=r={}))},3505:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Vec3=void 0;class n{constructor(t,e,n){this.x=t,this.y=e,this.z=n}get xy(){return{x:this.x,y:this.y}}static of(t,e,o){return new n(t,e,o)}at(t){if(0===t)return this.x;if(1===t)return this.y;if(2===t)return this.z;throw new Error(`${t} out of bounds!`)}length(){return this.magnitude()}magnitude(){return Math.sqrt(this.dot(this))}magnitudeSquared(){return this.dot(this)}maximumEntryMagnitude(){return Math.max(Math.abs(this.x),Math.max(Math.abs(this.y),Math.abs(this.z)))}angle(){return Math.atan2(this.y,this.x)}normalized(){const t=this.magnitude();return n.of(this.x/t,this.y/t,this.z/t)}normalizedOrZero(){return this.eq(n.zero)?n.zero:this.normalized()}times(t){return n.of(this.x*t,this.y*t,this.z*t)}plus(t){return n.of(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){return n.of(this.x-t.x,this.y-t.y,this.z-t.z)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){return n.of(this.y*t.z-t.y*this.z,t.x*this.z-this.x*t.z,this.x*t.y-t.x*this.y)}scale(t){return"number"==typeof t?this.times(t):n.of(this.x*t.x,this.y*t.y,this.z*t.z)}orthog(){return 0===this.dot(n.unitX)&&0===this.dot(n.unitY)?0===this.dot(n.unitX)?n.unitX:this.cross(n.unitX).normalized():this.cross(n.unitZ.times(-1)).normalized()}extend(t,e){return this.plus(e.normalized().times(t))}lerp(t,e){return this.times(1-e).plus(t.times(e))}zip(t,e){return n.of(e(t.x,this.x),e(t.y,this.y),e(t.z,this.z))}map(t){return n.of(t(this.x,0),t(this.y,1),t(this.z,2))}asArray(){return[this.x,this.y,this.z]}eq(t,e=1e-10){for(let n=0;n<3;n++)if(Math.abs(t.at(n)-this.at(n))>e)return!1;return!0}toString(){return`Vec(${this.x}, ${this.y}, ${this.z})`}}e.Vec3=n,n.unitX=n.of(1,0,0),n.unitY=n.of(0,1,0),n.unitZ=n.of(0,0,1),n.zero=n.of(0,0,0),e.default=n},5097:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toRoundedString=e.Color4=e.Vec3=e.Vec2=e.Mat33=e.QuadraticBezier=e.Rect2=e.PathCommandType=e.Path=e.LineSegment2=void 0;var o=n(4610);Object.defineProperty(e,"LineSegment2",{enumerable:!0,get:function(){return o.LineSegment2}});var i=n(3305);Object.defineProperty(e,"Path",{enumerable:!0,get:function(){return i.Path}}),Object.defineProperty(e,"PathCommandType",{enumerable:!0,get:function(){return i.PathCommandType}});var r=n(4221);Object.defineProperty(e,"Rect2",{enumerable:!0,get:function(){return r.Rect2}});var s=n(1798);Object.defineProperty(e,"QuadraticBezier",{enumerable:!0,get:function(){return s.QuadraticBezier}});var a=n(3380);Object.defineProperty(e,"Mat33",{enumerable:!0,get:function(){return a.Mat33}});var l=n(1728);Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return l.Vec2}});var c=n(3505);Object.defineProperty(e,"Vec3",{enumerable:!0,get:function(){return c.Vec3}});var d=n(8463);Object.defineProperty(e,"Color4",{enumerable:!0,get:function(){return d.Color4}});var h=n(8207);Object.defineProperty(e,"toRoundedString",{enumerable:!0,get:function(){return h.toRoundedString}})},8432:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e,n)=>{if(0===t){let t;return t=0===e?0===n?0:NaN:-n/e,[t,t]}const o=e*e-4*t*n;if(o<0)return[NaN,NaN];const i=Math.sqrt(o),r=(-e+i)/(2*t),s=(-e-i)/(2*t);return r>s?[r,s]:[s,r]}},8207:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toStringOfSamePrecision=e.getLenAfterDecimal=e.toRoundedString=e.cleanUpNumber=void 0;e.cleanUpNumber=t=>{if(t.indexOf("e")>0&&t.match(/[eE][-]\d{2,}$/))return"0";const e=t.charAt(t.length-1);"0"!==e&&"."!==e||(t=(t=(t=t.replace(/([.]\d*[^0]+)0+$/,"$1")).replace(/[.]0+$/,".")).replace(/[.]$/,""));const n=t.charAt(0);return"0"!==n&&"-"!==n||(t=(t=(t=t.replace(/^(0+)[.]/,".")).replace(/^-(0+)[.]/,"-.")).replace(/^(-?)0+$/,"$10")),"-0"===t?"0":t};e.toRoundedString=t=>{let n=t.toString(10);if(-1===n.indexOf("."))return n;const o=/^([-]?)(\d*)\.(\d{3,}9{4,})\d{1,4}$/.exec(n);if(o){const t=o[1],e=o[3],i=parseInt(e.charAt(e.length-1),10),r=parseInt(e,10),s=parseInt(o[2],10),a=o[3];let l=(r+10-i).toString(),c=0;for(l.length>r.toString().length&&(l=l.substring(1),c=1);l.length<a.length;)l=c.toString(10)+l,c=0;n=`${t+(s+c).toString()}.${l}`}return n=n.replace(/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,"$1"),(0,e.cleanUpNumber)(n)};const n=/^([-]?)(\d*)[.](\d+)$/;e.getLenAfterDecimal=t=>{const e=n.exec(t);if(!e)return-1!==t.search(/[eE]/)||/^[a-zA-Z]+$/.exec(t)?-1:0;return e[3].length};e.toStringOfSamePrecision=(t,...o)=>{const i=t.toString(10),r=n.exec(i);if(!r)return i;let s=-1;for(const t of o)s=Math.max((0,e.getLenAfterDecimal)(t),s);if(-1===s)return(0,e.toRoundedString)(t);let a=r[3].substring(0,s),l=r[2];const c=r[3].charAt(s);if(""!==c){if(parseInt(c,10)>=5){if(a.length>0){const t=/^(0+)(\d*)$/.exec(a);let e="",n=a;t&&(e=t[1],n=t[2]),a=(parseInt(a)+1).toString(),a.length>n.length&&e.length>0&&(e=e.substring(1)),a=e+a}(0===a.length||a.length>s)&&(l=(parseInt(l)+1).toString(),a=a.substring(1))}}const d=r[1];return(0,e.cleanUpNumber)(`${d}${l}.${a}`)}},1631:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{distance(t){return Math.abs(this.signedDistance(t))}containsPoint(t,e=n.smallValue){return this.signedDistance(t)<e}getLooseBoundingBox(){return this.getTightBoundingBox()}}n.smallValue=1e-12,e.default=n},4657:function(t,e,n){"use strict";var o,i=this&&this.__classPrivateFieldGet||function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)},r=this&&this.__classPrivateFieldSet||function(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(4232),l=n(1728),c=s(n(1631)),d=s(n(4221));class h extends c.default{constructor(){super(...arguments),o.set(this,null)}getBezier(){return i(this,o,"f")||r(this,o,new a.Bezier(this.getPoints().map((t=>t.xy))),"f"),i(this,o,"f")}signedDistance(t){return this.getBezier().project(t.xy).d}distance(t){return this.signedDistance(t)}at(t){return l.Vec2.ofXY(this.getBezier().get(t))}derivativeAt(t){return l.Vec2.ofXY(this.getBezier().derivative(t))}normal(t){return l.Vec2.ofXY(this.getBezier().normal(t))}getTightBoundingBox(){const t=this.getBezier().bbox(),e=t.x.max-t.x.min,n=t.y.max-t.y.min;return new d.default(t.x.min,t.y.min,e,n)}intersectsLineSegment(t){const e=this.getBezier();return e.intersects(t).map((n=>{"string"==typeof n&&(n=parseFloat(n));const o=l.Vec2.ofXY(e.get(n));return o.minus(t.p1).magnitude()>t.length||o.minus(t.p2).magnitude()>t.length?null:o})).filter((t=>null!==t))}}o=new WeakMap,e.default=h},9383:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(4657)),r=o(n(4221));class s extends i.default{constructor(t,e,n,o){super(),this.p0=t,this.p1=e,this.p2=n,this.p3=o}getPoints(){return[this.p0,this.p1,this.p2,this.p3]}getLooseBoundingBox(){return r.default.bboxOf([this.p0,this.p1,this.p2,this.p3])}}e.default=s},4610:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.LineSegment2=void 0;const i=o(n(4221)),r=n(1728),s=o(n(1631));class a extends s.default{constructor(t,e){super(),this.point1=t,this.point2=e,this.bbox=i.default.bboxOf([t,e]),this.direction=e.minus(t),this.length=this.direction.magnitude(),this.length>0&&(this.direction=this.direction.times(1/this.length))}get p1(){return this.point1}get p2(){return this.point2}get(t){return this.point1.plus(this.direction.times(t))}at(t){return this.get(t*this.length)}intersection(t){let e,n;if(0===this.direction.x){if(0===t.direction.x||0===this.direction.y)return null;const o=this.point1.x,i=(this.point1.x-t.point1.x)*t.direction.y/t.direction.x+t.point1.y;e=r.Vec2.of(o,i),n=(i-this.point1.y)/this.direction.y}else{const o=(this.point1.y-t.point1.y)*this.direction.x*t.direction.x+this.direction.x*t.direction.y*t.point1.x-this.direction.y*t.direction.x*this.point1.x,i=t.direction.y*this.direction.x-this.direction.y*t.direction.x;if(0===i)return null;const s=o/i,a=(s-this.point1.x)/this.direction.x,l=this.point1.y+this.direction.y*a;e=r.Vec2.of(s,l),n=(s-this.point1.x)/this.direction.x}const o=e.minus(this.point1).magnitude(),i=e.minus(this.point2).magnitude(),s=e.minus(t.point1).magnitude(),a=e.minus(t.point2).magnitude();return o>this.length||i>this.length||s>t.length||a>t.length?null:{point:e,t:n}}intersects(t){return null!==this.intersection(t)}intersectsLineSegment(t){const e=this.intersection(t);return e?[e.point]:[]}closestPointTo(t){const e=t.minus(this.p1).dot(this.direction),n=this.length-e,o=this.p1.plus(this.direction.times(e));return e>0&&e<this.length?o:Math.abs(n)<Math.abs(e)?this.p2:this.p1}signedDistance(t){return this.closestPointTo(t).minus(t).magnitude()}transformedBy(t){return new a(t.transformVec2(this.p1),t.transformVec2(this.p2))}getTightBoundingBox(){return this.bbox}toString(){return`LineSegment(${this.p1.toString()}, ${this.p2.toString()})`}}e.LineSegment2=a,e.default=a},3305:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Path=e.PathCommandType=void 0;const i=n(8207),r=o(n(4610)),s=o(n(4221)),a=n(1728),l=o(n(9383)),c=o(n(1798)),d=o(n(4495));var h;!function(t){t[t.LineTo=0]="LineTo",t[t.MoveTo=1]="MoveTo",t[t.CubicBezierTo=2]="CubicBezierTo",t[t.QuadraticBezierTo=3]="QuadraticBezierTo"}(h||(e.PathCommandType=h={}));class u{constructor(t,e){this.startPoint=t,this.parts=e,this.cachedGeometry=null,this.cachedPolylineApproximation=null,this.cachedStringVersion=null,this.bbox=s.default.bboxOf([t]);for(const n of e)this.bbox=this.bbox.union(u.computeBBoxForSegment(t,n))}getExactBBox(){const t=[];for(const e of this.geometry)t.push(e.getTightBoundingBox());return s.default.union(...t)}get geometry(){if(this.cachedGeometry)return this.cachedGeometry;let t=this.startPoint;const e=[];for(const n of this.parts){let o;switch(n.kind){case h.CubicBezierTo:e.push(new l.default(t,n.controlPoint1,n.controlPoint2,n.endPoint)),t=n.endPoint;break;case h.QuadraticBezierTo:e.push(new c.default(t,n.controlPoint,n.endPoint)),t=n.endPoint;break;case h.LineTo:e.push(new r.default(t,n.point)),t=n.point;break;case h.MoveTo:e.push(new d.default(n.point)),t=n.point;break;default:return o=n,o}}return this.cachedGeometry=e,this.cachedGeometry}*startEndPoints(){yield this.startPoint;for(const t of this.parts){let e;switch(t.kind){case h.CubicBezierTo:case h.QuadraticBezierTo:yield t.endPoint;break;case h.LineTo:case h.MoveTo:yield t.point;break;default:return e=t,e}}}polylineApproximation(){if(this.cachedPolylineApproximation)return this.cachedPolylineApproximation;const t=[];for(const e of this.parts)switch(e.kind){case h.CubicBezierTo:t.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:t.push(e.controlPoint,e.endPoint);break;case h.MoveTo:case h.LineTo:t.push(e.point)}const e=[];let n=this.startPoint;for(const o of t)e.push(new r.default(n,o)),n=o;return e}static computeBBoxForSegment(t,e){const n=[t];let o;switch(e.kind){case h.MoveTo:case h.LineTo:n.push(e.point);break;case h.CubicBezierTo:n.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:n.push(e.controlPoint,e.endPoint);break;default:return o=e,o}return s.default.bboxOf(n)}raymarchIntersectionWith(t,e,n=[]){if(!t.bbox.intersects(this.bbox.grownBy(e)))return[];const o=t.length,i=[];for(const n of this.geometry){const r=n.getTightBoundingBox().grownBy(e);if(!r.intersects(t.bbox))continue;const s=t=>n.signedDistance(t),a=t=>s(t)-e;a(t.p1)>o&&a(t.p2)>o||i.push({part:n,distFn:s,bbox:r})}if(0===i.length)return[];const r=t=>{let n=1/0,o=null;const r=[];for(const e of i){const{part:i,distFn:s,bbox:a}=e;if(!a.containsPoint(t)){r.push(e);continue}const l=s(t);l<=n&&(n=l,o=i)}for(const{part:e,distFn:i,bbox:s}of r){if(!s.grownBy(n).containsPoint(t))continue;const r=i(t);r<=n&&(n=r,o=e)}return[o,n-e]},s=[t.p1,...n,t.p2],a=e=>e.minus(t.p1).dot(t.direction);s.sort(((t,e)=>a(t)-a(e)));const l=[],c=e/1e3,d=(e,n,i)=>{let s=e,[d,h]=r(s),u=a(s);if(h>o)return u;const p=t.direction.times(n);for(let t=0;t<7;t++){const t=h;if(s=s.plus(p.times(t)),u=a(s),u<=i)return u;const[e,n]=r(s);if(Math.abs(n)>Math.abs(h))return null;if(h=n,d=e,Math.abs(h)<c)break}return d&&(u>=0&&u<=o)&&Math.abs(h)<c&&l.push({point:s,parameterValue:NaN,curve:d}),u};let h=0;for(let t=0;t<s.length;t++){const e=s[t];h=Math.max(h,d(e,1,h)??h),h=Math.max(h,d(e,-1,h)??h)}return l}intersection(t,e){let n=[];if(!t.bbox.intersects(this.bbox.grownBy(e??0)))return[];for(const e of this.geometry){const o=e.intersectsLineSegment(t);o.length>0&&n.push({curve:e,point:o[0]})}if(e&&e>1e-8){const o=n.map((t=>t.point));n=this.raymarchIntersectionWith(t,e,o)}return n}static mapPathCommand(t,e){switch(t.kind){case h.MoveTo:case h.LineTo:return{kind:t.kind,point:e(t.point)};case h.CubicBezierTo:return{kind:t.kind,controlPoint1:e(t.controlPoint1),controlPoint2:e(t.controlPoint2),endPoint:e(t.endPoint)};case h.QuadraticBezierTo:return{kind:t.kind,controlPoint:e(t.controlPoint),endPoint:e(t.endPoint)}}return t}mapPoints(t){const e=t(this.startPoint),n=[];for(const e of this.parts)n.push(u.mapPathCommand(e,t));return new u(e,n)}transformedBy(t){return t.isIdentity()?this:this.mapPoints((e=>t.transformVec2(e)))}union(t){return t?new u(this.startPoint,[...this.parts,{kind:h.MoveTo,point:t.startPoint},...t.parts]):this}getEndPoint(){if(0===this.parts.length)return this.startPoint;const t=this.parts[this.parts.length-1];return t.kind===h.QuadraticBezierTo||t.kind===h.CubicBezierTo?t.endPoint:t.point}roughlyIntersects(t,e=0){if(0===this.parts.length)return t.containsPoint(this.startPoint);if(this.startPoint.eq(this.getEndPoint())&&0===e)return this.closedRoughlyIntersects(t);if(t.containsRect(this.bbox))return!0;let n=this.startPoint;for(const o of this.parts){const i=u.computeBBoxForSegment(n,o).grownBy(e);if(n=o.kind===h.LineTo||o.kind===h.MoveTo?o.point:o.endPoint,t.intersects(i))return!0}return!1}closedRoughlyIntersects(t){if(t.containsRect(this.bbox))return!0;const e=this.bbox.topLeft.minus(a.Vec2.of(1,1)),n=t.corners,o=this.polylineApproximation();for(const t of n){const n=new r.default(t,e);let i=0;for(const t of o)t.intersects(n)&&i++;if(i%2==1)return!0}const i=t.grownBy(Math.min(t.size.x,t.size.y)),s=[];for(const t of i.divideIntoGrid(4,4))s.push(...t.getEdges());for(const t of s)for(const e of o)if(t.intersects(e))return!0;return!1}static fromRect(t,e=null){const n=[];let o,i;if(null!==e){const n=a.Vec2.of(e,e).times(.5),r=s.default.fromCorners(t.topLeft.plus(n),t.bottomRight.minus(n)),l=s.default.fromCorners(t.topLeft.minus(n),t.bottomRight.plus(n));o=[r.corners[3],...r.corners,...l.corners.reverse()],i=l.corners[3]}else o=t.corners.slice(1),i=t.corners[0];for(const t of o)n.push({kind:h.LineTo,point:t});return n.push({kind:h.LineTo,point:i}),new u(i,n)}toString(t){if(this.cachedStringVersion)return this.cachedStringVersion;void 0===t&&(t=Math.abs(this.bbox.topLeft.x)>10&&Math.abs(this.bbox.topLeft.y)>10);const e=u.toString(this.startPoint,this.parts,!t);return this.cachedStringVersion=e,e}serialize(){return this.toString()}static toString(t,e,n){const o=[];let r;const s=(t,...e)=>{const s=[],a=[],l=!r||n,c=r?(0,i.toRoundedString)(r.x):"",d=r?(0,i.toRoundedString)(r.y):"";for(const t of e){const e=(0,i.toRoundedString)(t.x),n=(0,i.toRoundedString)(t.y);if(l)s.push(`${e},${n}`);else{const o=(0,i.toStringOfSamePrecision)(t.x-r.x,e,c,d),s=(0,i.toStringOfSamePrecision)(t.y-r.y,n,c,d);"-"===s.charAt(0)?a.push(`${o}${s}`):a.push(`${o},${s}`)}}let h;h=l?`${t}${s.join(" ")}`:`${t.toLowerCase()}${a.join(" ")}`,"l0,0"!==h&&"m0,0"!==h&&(o.push(h),e.length>0&&(r=e[e.length-1]))};let a;e[0]?.kind!==h.MoveTo&&s("M",t);for(let t=0;t<e.length;t++){const n=e[t];switch(n.kind){case h.MoveTo:s("M",n.point);break;case h.LineTo:s("L",n.point);break;case h.CubicBezierTo:s("C",n.controlPoint1,n.controlPoint2,n.endPoint);break;case h.QuadraticBezierTo:s("Q",n.controlPoint,n.endPoint);break;default:return a=n,a}}return o.join("")}static fromString(t){t=t.split("\n").join(" ");let e=a.Vec2.zero,n=null,o=null,i=!0;const r=[],s=t=>{i?i=!1:r.push({kind:h.LineTo,point:t})},l={m:1,l:1,c:3,q:2,z:0,h:1,v:1},c=/([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/gi;let d;for(;null!==(d=c.exec(t));){const t=d[2].trim().split(/[^0-9Ee.-]/).filter((t=>t.length>0)).reduce(((t,e)=>{const n=(e=e.replace(/([^eE])[-]/g,"$1 -")).split(" -");return""!==n[0]&&t.push(n[0]),t.push(...n.slice(1).map((t=>`-${t}`))),t}),[]);let c=t.map((t=>parseFloat(t))),u=d[1].toLowerCase(),v=d[1]!==u;if("v"===u||"h"===u)c=c.reduce(((t,n)=>"v"===u?t.concat(v?e.x:0,n):t.concat(n,v?e.y:0)),[]),u="l";else if("z"===u){if(!n)continue;c=[n.x,n.y],n=e,v=!0,u="l"}const w=l[u]??0,x=c.reduce(((t,e,n,o)=>{if(n%2!=0){const i=e,r=o[n-1];return t.concat(a.Vec2.of(r,i))}return t}),[]).map(((t,n)=>{let o;return o=v?t:e.plus(t),(n+1)%w==0&&(e=o),o}));if(x.length%w!=0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(x)} with a length of ${x.length} ≠ ${w}k, k ∈ ℤ.`,`The number of arguments to ${u} must be a multiple of ${w}!`,`Command: ${d[0]}`].join("\n"));for(let t=0;t<x.length;t+=w){const e=x.slice(t,t+w);switch(u.toLowerCase()){case"m":0===t?(y=e[0],i?i=!1:r.push({kind:h.MoveTo,point:y})):s(e[0]);break;case"l":s(e[0]);break;case"c":m=e[0],g=e[1],b=e[2],r.push({kind:h.CubicBezierTo,controlPoint1:m,controlPoint2:g,endPoint:b});break;case"q":p=e[0],f=e[1],r.push({kind:h.QuadraticBezierTo,controlPoint:p,endPoint:f});break;default:throw new Error(`Unknown path command ${u}`)}i=!1}x.length>0&&(n??=x[0],o??=n,e=x[x.length-1])}var p,f,m,g,b,y;const v=new u(o??a.Vec2.zero,r);return v.cachedStringVersion=t,v}}e.Path=u,u.empty=new u(a.Vec2.zero,[]),e.default=u},4495:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(n(1631)),r=o(n(4221));class s extends i.default{constructor(t){super(),this.p=t}signedDistance(t){return this.p.minus(t).magnitude()}intersectsLineSegment(t,e){return t.containsPoint(this.p,e)?[this.p]:[]}getTightBoundingBox(){return new r.default(this.p.x,this.p.y,0,0)}}e.default=s},1798:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.QuadraticBezier=void 0;const i=n(1728),r=o(n(8432)),s=o(n(4657)),a=o(n(4221));class l extends s.default{constructor(t,e,n){super(),this.p0=t,this.p1=e,this.p2=n}static componentAt(t,e,n,o){return e+t*(-2*e+2*n)+t*t*(e-2*n+o)}static derivativeComponentAt(t,e,n,o){return-2*e+2*n+2*t*(e-2*n+o)}at(t){const e=this.p0,n=this.p1,o=this.p2;return i.Vec2.of(l.componentAt(t,e.x,n.x,o.x),l.componentAt(t,e.y,n.y,o.y))}derivativeAt(t){const e=this.p0,n=this.p1,o=this.p2;return i.Vec2.of(l.derivativeComponentAt(t,e.x,n.x,o.x),l.derivativeComponentAt(t,e.y,n.y,o.y))}normal(t){return this.derivativeAt(t).orthog().normalized()}getLooseBoundingBox(){return a.default.bboxOf([this.p0,this.p1,this.p2])}approximateDistance(t){const e=this.p0.x-t.x,n=-2*this.p0.x+2*this.p1.x,o=this.p0.x-2*this.p1.x+this.p2.x,i=this.p0.y-t.y,s=-2*this.p0.y+2*this.p1.y,a=this.p0.y-2*this.p1.y+this.p2.y,l=2*e*n+2*i*s-t.x*n-t.y*s,c=2*n*n+2*s*s+2*o*e+2*a*i-t.x*o-t.y*a,d=2*(2*s*a+2*n*o+2*o*n+2*a*s);let[h,u]=(0,r.default)(d/2,c,l);isNaN(h)&&(h=.25),isNaN(u)&&(u=.75);const p=this.at(h),f=this.at(u),m=p.minus(t).magnitudeSquared(),g=f.minus(t).magnitudeSquared(),b=this.at(0).minus(t).magnitudeSquared(),y=this.at(1).minus(t).magnitudeSquared();return Math.sqrt(Math.min(m,g,b,y))}getPoints(){return[this.p0,this.p1,this.p2]}}e.QuadraticBezier=l,e.default=l},4221:function(t,e,n){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Rect2=void 0;const i=o(n(4610)),r=n(1728),s=o(n(1631));class a extends s.default{constructor(t,e,n,o){super(),this.x=t,this.y=e,this.w=n,this.h=o,n<0&&(this.x+=n,this.w=Math.abs(n)),o<0&&(this.y+=o,this.h=Math.abs(o)),this.topLeft=r.Vec2.of(this.x,this.y),this.size=r.Vec2.of(this.w,this.h),this.area=this.w*this.h}translatedBy(t){return new a(t.x+this.x,t.y+this.y,this.w,this.h)}resizedTo(t){return new a(this.x,this.y,t.x,t.y)}containsPoint(t){return this.x<=t.x&&this.y<=t.y&&this.x+this.w>=t.x&&this.y+this.h>=t.y}containsRect(t){return this.x<=t.x&&this.y<=t.y&&this.x+this.w>=t.x+t.w&&this.y+this.h>=t.y+t.h}intersects(t){const e=this.x,n=e+this.w,o=t.x,i=t.x+t.w;if(n<o||e>i)return!1;const r=this.y,s=r+this.h,a=t.y,l=t.y+t.h;return!(s<a||r>l)}intersection(t){if(!this.intersects(t))return null;const e=this.topLeft.zip(t.topLeft,Math.max),n=this.bottomRight.zip(t.bottomRight,Math.min);return a.fromCorners(e,n)}union(t){return a.union(this,t)}divideIntoGrid(t,e){const n=[];if(t<=0||e<=0)return n;const o=this.w/t,i=this.h/e;0===o&&(t=1),0===i&&(e=1);for(let r=0;r<e;r++)for(let e=0;e<t;e++){const t=o*e+this.x,s=i*r+this.y;n.push(new a(t,s,o,i))}return n}grownToPoint(t,e=0){const n=new a(t.x-e,t.y-e,2*e,2*e);return this.union(n)}grownBy(t){if(0===t)return this;if(t<0){const e=-Math.min(-t,this.w/2),n=-Math.min(-t,this.h/2);return new a(this.x-e,this.y-n,this.w+2*e,this.h+2*n)}return new a(this.x-t,this.y-t,this.w+2*t,this.h+2*t)}getClosestPointOnBoundaryTo(t){const e=this.getEdges().map((e=>e.closestPointTo(t)));let n=null,o=null;for(const i of e){const e=i.minus(t).length();(null===o||e<o)&&(n=i,o=e)}return n}get corners(){return[this.bottomRight,this.topRight,this.topLeft,this.bottomLeft]}get maxDimension(){return Math.max(this.w,this.h)}get bottomRight(){return this.topLeft.plus(this.size)}get topRight(){return this.bottomRight.plus(r.Vec2.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(r.Vec2.of(0,this.h))}get width(){return this.w}get height(){return this.h}get center(){return this.topLeft.plus(this.size.times(.5))}getEdges(){const t=this.corners;return[new i.default(t[0],t[1]),new i.default(t[1],t[2]),new i.default(t[2],t[3]),new i.default(t[3],t[0])]}intersectsLineSegment(t){const e=[];for(const n of this.getEdges()){n.intersectsLineSegment(t).forEach((t=>e.push(t)))}return e}signedDistance(t){const e=this.getClosestPointOnBoundaryTo(t),n=t.minus(e).magnitude();return this.containsPoint(t)?-n:n}getTightBoundingBox(){return this}transformedBoundingBox(t){return a.bboxOf(this.corners.map((e=>t.transformVec2(e))))}eq(t,e=0){return this.topLeft.eq(t.topLeft,e)&&this.size.eq(t.size,e)}toString(){return`Rect(point(${this.x}, ${this.y}), size(${this.w}, ${this.h}))`}static fromCorners(t,e){return new a(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.abs(t.x-e.x),Math.abs(t.y-e.y))}static bboxOf(t,e=0){let n=0,o=0,i=0,s=0,l=!0;for(const e of t)l&&(n=e.x,o=e.y,i=e.x,s=e.y,l=!1),n=Math.min(n,e.x),o=Math.min(o,e.y),i=Math.max(i,e.x),s=Math.max(s,e.y);return a.fromCorners(r.Vec2.of(n-e,o-e),r.Vec2.of(i+e,s+e))}static union(...t){if(0===t.length)return a.empty;const e=t[0];let n=e.x,o=e.y,i=e.x+e.w,r=e.y+e.h;for(let e=1;e<t.length;e++){const s=t[e];n=Math.min(n,s.x),o=Math.min(o,s.y),i=Math.max(i,s.x+s.w),r=Math.max(r,s.y+s.h)}return new a(n,o,i-n,r-o)}static of(t){const e=t.width??t.w??0,n=t.height??t.h??0;return new a(t.x,t.y,e,n)}}e.Rect2=a,a.empty=new a(0,0,0,0),a.unitSquare=new a(0,0,1,1),e.default=a},5381:(t,e)=>{var n,o,i;"undefined"!=typeof self&&self,o=[],void 0===(i="function"==typeof(n=function(){
|
2
2
|
/*!
|
3
3
|
* Copyright (c) 2021-2023 Momo Bassit.
|
4
4
|
* Licensed under the MIT License (MIT)
|
@@ -6,4 +6,4 @@
|
|
6
6
|
* Version: 0.21.0
|
7
7
|
* NPM: https://github.com/melloware/coloris-npm
|
8
8
|
*/
|
9
|
-
return function(t,e,n,o){var i,r,s,a,l,c,d,h,u,p,f,m,g,b,y,v,w,x=e.createElement("canvas").getContext("2d"),S={r:0,g:0,b:0,h:0,s:0,v:0,a:1},T={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:function(){return o},a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},C={},P="",k={},E=!1;function z(n){if("object"==typeof n){var a=function(){switch(l){case"el":L(n.el),!1!==n.wrap&&O(n.el);break;case"parent":(i=e.querySelector(n.parent))&&(i.appendChild(r),T.parent=n.parent,i===e.body&&(i=o));break;case"themeMode":T.themeMode=n.themeMode,"auto"===n.themeMode&&t.matchMedia&&t.matchMedia("(prefers-color-scheme: dark)").matches&&(T.themeMode="dark");case"theme":n.theme&&(T.theme=n.theme),r.className="clr-picker clr-"+T.theme+" clr-"+T.themeMode,T.inline&&R();break;case"rtl":T.rtl=!!n.rtl,e.querySelectorAll(".clr-field").forEach((function(t){return t.classList.toggle("clr-rtl",T.rtl)}));break;case"margin":n.margin*=1,T.margin=isNaN(n.margin)?T.margin:n.margin;break;case"wrap":n.el&&n.wrap&&O(n.el);break;case"formatToggle":T.formatToggle=!!n.formatToggle,it("clr-format").style.display=T.formatToggle?"block":"none",T.formatToggle&&(T.format="auto");break;case"swatches":if(Array.isArray(n.swatches)){var a=[];n.swatches.forEach((function(t,e){a.push('<button type="button" id="clr-swatch-'+e+'" aria-labelledby="clr-swatch-label clr-swatch-'+e+'" style="color: '+t+';">'+t+"</button>")})),it("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":"",T.swatches=n.swatches.slice()}break;case"swatchesOnly":T.swatchesOnly=!!n.swatchesOnly,r.setAttribute("data-minimal",T.swatchesOnly);break;case"alpha":T.alpha=!!n.alpha,r.setAttribute("data-alpha",T.alpha);break;case"inline":if(T.inline=!!n.inline,r.setAttribute("data-inline",T.inline),T.inline){var f=n.defaultColor||T.defaultColor;y=j(f),R(),A(f)}break;case"clearButton":"object"==typeof n.clearButton&&(n.clearButton.label&&(T.clearLabel=n.clearButton.label,h.innerHTML=T.clearLabel),n.clearButton=n.clearButton.show),T.clearButton=!!n.clearButton,h.style.display=T.clearButton?"block":"none";break;case"clearLabel":T.clearLabel=n.clearLabel,h.innerHTML=T.clearLabel;break;case"closeButton":T.closeButton=!!n.closeButton,T.closeButton?r.insertBefore(u,c):c.appendChild(u);break;case"closeLabel":T.closeLabel=n.closeLabel,u.innerHTML=T.closeLabel;break;case"a11y":var g=n.a11y,b=!1;if("object"==typeof g)for(var v in g)g[v]&&T.a11y[v]&&(T.a11y[v]=g[v],b=!0);if(b){var w=it("clr-open-label"),x=it("clr-swatch-label");w.innerHTML=T.a11y.open,x.innerHTML=T.a11y.swatch,u.setAttribute("aria-label",T.a11y.close),h.setAttribute("aria-label",T.a11y.clear),p.setAttribute("aria-label",T.a11y.hueSlider),m.setAttribute("aria-label",T.a11y.alphaSlider),d.setAttribute("aria-label",T.a11y.input),s.setAttribute("aria-label",T.a11y.instruction)}break;default:T[l]=n[l]}};for(var l in n)a()}}function M(t,e){"string"==typeof t&&"object"==typeof e&&(C[t]=e,E=!0)}function _(t){delete C[t],0===Object.keys(C).length&&(E=!1,t===P&&B())}function I(t){if(E){var e=["el","wrap","rtl","inline","defaultColor","a11y"],n=function(){var n=C[o];if(t.matches(o)){for(var i in P=o,k={},e.forEach((function(t){return delete n[t]})),n)k[i]=Array.isArray(T[i])?T[i].slice():T[i];return z(n),"break"}};for(var o in C)if("break"===n())break}}function B(){Object.keys(k).length>0&&(z(k),P="",k={})}function L(t){rt(e,"click",t,(function(t){T.inline||(I(t.target),b=t.target,v=b.value,y=j(v),r.classList.add("clr-open"),R(),A(v),(T.focusInput||T.selectInput)&&(d.focus({preventScroll:!0}),d.setSelectionRange(b.selectionStart,b.selectionEnd)),T.selectInput&&d.select(),(w||T.swatchesOnly)&&ot().shift().focus(),b.dispatchEvent(new Event("open",{bubbles:!0})))})),rt(e,"input",t,(function(t){var e=t.target.parentNode;e.classList.contains("clr-field")&&(e.style.color=t.target.value)}))}function R(){if(r&&(b||T.inline)){var n,o,l,c=i,d=t.scrollY,h=r.offsetWidth,u=r.offsetHeight,p={left:!1,top:!1},f={x:0,y:0};if(c&&(n=t.getComputedStyle(c),o=parseFloat(n.marginTop),l=parseFloat(n.borderTopWidth),(f=c.getBoundingClientRect()).y+=l+d),!T.inline){var m=b.getBoundingClientRect(),g=m.x,y=d+m.y+m.height+T.margin;c?(g-=f.x,y-=f.y,g+h>c.clientWidth&&(g+=m.width-h,p.left=!0),y+u>c.clientHeight-o&&u+T.margin<=m.top-(f.y-d)&&(y-=m.height+u+2*T.margin,p.top=!0),y+=c.scrollTop):(g+h>e.documentElement.clientWidth&&(g+=m.width-h,p.left=!0),y+u-d>e.documentElement.clientHeight&&u+T.margin<=m.top&&(y=d+m.y-u-T.margin,p.top=!0)),r.classList.toggle("clr-left",p.left),r.classList.toggle("clr-top",p.top),r.style.left=g+"px",r.style.top=y+"px",f.x+=r.offsetLeft,f.y+=r.offsetTop}a={width:s.offsetWidth,height:s.offsetHeight,x:s.offsetLeft+f.x,y:s.offsetTop+f.y}}}function O(t){e.querySelectorAll(t).forEach((function(t){var n=t.parentNode;if(!n.classList.contains("clr-field")){var o=e.createElement("div"),i="clr-field";(T.rtl||t.classList.contains("clr-rtl"))&&(i+=" clr-rtl"),o.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',n.insertBefore(o,t),o.setAttribute("class",i),o.style.color=t.value,o.appendChild(t)}}))}function D(t){if(b&&!T.inline){var e=b;t&&(b=o,v!==e.value&&(e.value=v,e.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout((function(){v!==e.value&&e.dispatchEvent(new Event("change",{bubbles:!0}))})),r.classList.remove("clr-open"),E&&B(),e.dispatchEvent(new Event("close",{bubbles:!0})),T.focusInput&&e.focus({preventScroll:!0}),b=o}}function A(t){var e=J(t),n=X(e);$(n.s,n.v),H(e,n),p.value=n.h,r.style.color="hsl("+n.h+", 100%, 50%)",f.style.left=n.h/360*100+"%",l.style.left=a.width*n.s/100+"px",l.style.top=a.height-a.height*n.v/100+"px",m.value=100*n.a,g.style.left=100*n.a+"%"}function j(t){var e=t.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function V(n){n=n!==o?n:d.value,b&&(b.value=n,b.dispatchEvent(new Event("input",{bubbles:!0}))),T.onChange&&T.onChange.call(t,n,b),e.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:n,currentEl:b}}))}function F(t,e){var n={h:1*p.value,s:t/a.width*100,v:100-e/a.height*100,a:m.value/100},o=Z(n);$(n.s,n.v),H(o,n),V()}function $(t,e){var n=T.a11y.marker;t=1*t.toFixed(1),e=1*e.toFixed(1),n=(n=n.replace("{s}",t)).replace("{v}",e),l.setAttribute("aria-label",n)}function N(t){return{pageX:t.changedTouches?t.changedTouches[0].pageX:t.pageX,pageY:t.changedTouches?t.changedTouches[0].pageY:t.pageY}}function U(t){var e=N(t),n=e.pageX-a.x,o=e.pageY-a.y;i&&(o+=i.scrollTop),K(n,o),t.preventDefault(),t.stopPropagation()}function W(t,e){K(1*l.style.left.replace("px","")+t,1*l.style.top.replace("px","")+e)}function K(t,e){t=t<0?0:t>a.width?a.width:t,e=e<0?0:e>a.height?a.height:e,l.style.left=t+"px",l.style.top=e+"px",F(t,e),l.focus()}function H(t,n){void 0===t&&(t={}),void 0===n&&(n={});var o=T.format;for(var i in t)S[i]=t[i];for(var r in n)S[r]=n[r];var a=Q(S),h=a.substring(0,7);switch(l.style.color=h,g.parentNode.style.color=h,g.style.color=a,c.style.color=a,s.style.display="none",s.offsetHeight,s.style.display="",g.nextElementSibling.style.display="none",g.nextElementSibling.offsetHeight,g.nextElementSibling.style.display="","mixed"===o?o=1===S.a?"hex":"rgb":"auto"===o&&(o=y),o){case"hex":d.value=a;break;case"rgb":d.value=tt(S);break;case"hsl":d.value=et(Y(S))}e.querySelector('.clr-format [value="'+o+'"]').checked=!0}function G(){var t=1*p.value,e=1*l.style.left.replace("px",""),n=1*l.style.top.replace("px","");r.style.color="hsl("+t+", 100%, 50%)",f.style.left=t/360*100+"%",F(e,n)}function q(){var t=m.value/100;g.style.left=100*t+"%",H({a:t}),V()}function Z(t){var e=t.s/100,o=t.v/100,i=e*o,r=t.h/60,s=i*(1-n.abs(r%2-1)),a=o-i;i+=a,s+=a;var l=n.floor(r)%6,c=[i,s,a,a,s,i][l],d=[s,i,i,s,a,a][l],h=[a,a,s,i,i,s][l];return{r:n.round(255*c),g:n.round(255*d),b:n.round(255*h),a:t.a}}function Y(t){var e,o=t.v/100,i=o*(1-t.s/100/2);return i>0&&i<1&&(e=n.round((o-i)/n.min(i,1-i)*100)),{h:t.h,s:e||0,l:n.round(100*i),a:t.a}}function X(t){var e=t.r/255,o=t.g/255,i=t.b/255,r=n.max(e,o,i),s=r-n.min(e,o,i),a=r,l=0,c=0;return s&&(r===e&&(l=(o-i)/s),r===o&&(l=2+(i-e)/s),r===i&&(l=4+(e-o)/s),r&&(c=s/r)),{h:(l=n.floor(60*l))<0?l+360:l,s:n.round(100*c),v:n.round(100*a),a:t.a}}function J(t){var e,n,o=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;return x.fillStyle="#000",x.fillStyle=t,(e=o.exec(x.fillStyle))?(n={r:1*e[3],g:1*e[4],b:1*e[5],a:1*e[6]}).a=+n.a.toFixed(2):n={r:(e=x.fillStyle.replace("#","").match(/.{2}/g).map((function(t){return parseInt(t,16)})))[0],g:e[1],b:e[2],a:1},n}function Q(t){var e=t.r.toString(16),n=t.g.toString(16),o=t.b.toString(16),i="";if(t.r<16&&(e="0"+e),t.g<16&&(n="0"+n),t.b<16&&(o="0"+o),T.alpha&&(t.a<1||T.forceAlpha)){var r=255*t.a|0;i=r.toString(16),r<16&&(i="0"+i)}return"#"+e+n+o+i}function tt(t){return!T.alpha||1===t.a&&!T.forceAlpha?"rgb("+t.r+", "+t.g+", "+t.b+")":"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"}function et(t){return!T.alpha||1===t.a&&!T.forceAlpha?"hsl("+t.h+", "+t.s+"%, "+t.l+"%)":"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"}function nt(){e.getElementById("clr-picker")||(i=o,(r=e.createElement("div")).setAttribute("id","clr-picker"),r.className="clr-picker",r.innerHTML='<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+T.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+T.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+T.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+T.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+T.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button type="button" id="clr-clear" class="clr-clear" aria-label="'+T.a11y.clear+'">'+T.clearLabel+'</button><div id="clr-color-preview" class="clr-preview"><button type="button" id="clr-close" class="clr-close" aria-label="'+T.a11y.close+'">'+T.closeLabel+'</button></div><span id="clr-open-label" hidden>'+T.a11y.open+'</span><span id="clr-swatch-label" hidden>'+T.a11y.swatch+"</span>",e.body.appendChild(r),s=it("clr-color-area"),l=it("clr-color-marker"),h=it("clr-clear"),u=it("clr-close"),c=it("clr-color-preview"),d=it("clr-color-value"),p=it("clr-hue-slider"),f=it("clr-hue-marker"),m=it("clr-alpha-slider"),g=it("clr-alpha-marker"),L(T.el),O(T.el),rt(r,"mousedown",(function(t){r.classList.remove("clr-keyboard-nav"),t.stopPropagation()})),rt(s,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(s,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(l,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(l,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(d,"change",(function(t){var e=d.value;(b||T.inline)&&V(""===e?e:A(e))})),rt(h,"click",(function(t){V(""),D()})),rt(u,"click",(function(t){V(),D()})),rt(it("clr-format"),"click",".clr-format input",(function(t){y=t.target.value,H(),V()})),rt(r,"click",".clr-swatches button",(function(t){A(t.target.textContent),V(),T.swatchesOnly&&D()})),rt(e,"mouseup",(function(t){e.removeEventListener("mousemove",U)})),rt(e,"touchend",(function(t){e.removeEventListener("touchmove",U)})),rt(e,"mousedown",(function(t){w=!1,r.classList.remove("clr-keyboard-nav"),D()})),rt(e,"keydown",(function(t){var e=t.key,n=t.target,o=t.shiftKey,i=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];if("Escape"===e?D(!0):i.includes(e)&&(w=!0,r.classList.add("clr-keyboard-nav")),"Tab"===e&&n.matches(".clr-picker *")){var s=ot(),a=s.shift(),l=s.pop();o&&n===a?(l.focus(),t.preventDefault()):o||n!==l||(a.focus(),t.preventDefault())}})),rt(e,"click",".clr-field button",(function(t){E&&B(),t.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))})),rt(l,"keydown",(function(t){var e={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(e).includes(t.key)&&(W.apply(void 0,e[t.key]),t.preventDefault())})),rt(s,"click",U),rt(p,"input",G),rt(m,"input",q))}function ot(){return Array.from(r.querySelectorAll("input, button")).filter((function(t){return!!t.offsetWidth}))}function it(t){return e.getElementById(t)}function rt(t,e,n,o){var i=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof n?t.addEventListener(e,(function(t){i.call(t.target,n)&&o.call(t.target,t)})):(o=n,t.addEventListener(e,o))}function st(t,n){n=n!==o?n:[],"loading"!==e.readyState?t.apply(void 0,n):e.addEventListener("DOMContentLoaded",(function(){t.apply(void 0,n)}))}function at(t,e){v=(b=e).value,I(e),y=j(t),R(),A(t),V(),v!==t&&b.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==o&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var lt=function(){var e={init:nt,set:z,wrap:O,close:D,setInstance:M,setColor:at,removeInstance:_,updatePosition:R};function n(t){st((function(){t&&("string"==typeof t?L(t):z(t))}))}var o=function(t){n[t]=function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];st(e[t],o)}};for(var i in e)o(i);return st((function(){t.addEventListener("resize",(function(t){n.updatePosition()})),t.addEventListener("scroll",(function(t){n.updatePosition()}))})),n}();return lt.coloris=lt,lt}(window,document,Math)})?n.apply(e,o):n)||(t.exports=i)},4232:e=>{var n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=(t=>(e,s)=>t&&t.get(e)||(s=((t,e,s,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let l of i(e))r.call(t,l)||!s&&"default"===l||n(t,l,{get:()=>e[l],enumerable:!(a=o(e,l))||a.enumerable});return t})(n({},"__esModule",{value:!0}),e,1),t&&t.set(e,s),s))("undefined"!=typeof WeakMap?new WeakMap:0),a={};((t,e)=>{for(var o in e)n(t,o,{get:e[o],enumerable:!0})})(a,{Bezier:()=>B});var{abs:l,cos:c,sin:d,acos:h,atan2:u,sqrt:p,pow:f}=Math;function m(t){return t<0?-f(-t,1/3):f(t,1/3)}var g=Math.PI,b=2*g,y=g/2,v=Number.MAX_SAFE_INTEGER||9007199254740991,w=Number.MIN_SAFE_INTEGER||-9007199254740991,x={x:0,y:0,z:0},S={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const n=e(t);let o=n.x*n.x+n.y*n.y;return void 0!==n.z&&(o+=n.z*n.z),p(o)},compute:function(t,e,n){if(0===t)return e[0].t=0,e[0];const o=e.length-1;if(1===t)return e[o].t=1,e[o];const i=1-t;let r=e;if(0===o)return e[0].t=t,e[0];if(1===o){const e={x:i*r[0].x+t*r[1].x,y:i*r[0].y+t*r[1].y,t};return n&&(e.z=i*r[0].z+t*r[1].z),e}if(o<4){let e,s,a,l=i*i,c=t*t,d=0;2===o?(r=[r[0],r[1],r[2],x],e=l,s=i*t*2,a=c):3===o&&(e=l*i,s=l*t*3,a=i*c*3,d=t*c);const h={x:e*r[0].x+s*r[1].x+a*r[2].x+d*r[3].x,y:e*r[0].y+s*r[1].y+a*r[2].y+d*r[3].y,t};return n&&(h.z=e*r[0].z+s*r[1].z+a*r[2].z+d*r[3].z),h}const s=JSON.parse(JSON.stringify(e));for(;s.length>1;){for(let e=0;e<s.length-1;e++)s[e]={x:s[e].x+(s[e+1].x-s[e].x)*t,y:s[e].y+(s[e+1].y-s[e].y)*t},void 0!==s[e].z&&(s[e]=s[e].z+(s[e+1].z-s[e].z)*t);s.splice(s.length-1,1)}return s[0].t=t,s[0]},computeWithRatios:function(t,e,n,o){const i=1-t,r=n,s=e;let a,l=r[0],c=r[1],d=r[2],h=r[3];return l*=i,c*=t,2===s.length?(a=l+c,{x:(l*s[0].x+c*s[1].x)/a,y:(l*s[0].y+c*s[1].y)/a,z:!!o&&(l*s[0].z+c*s[1].z)/a,t}):(l*=i,c*=2*i,d*=t*t,3===s.length?(a=l+c+d,{x:(l*s[0].x+c*s[1].x+d*s[2].x)/a,y:(l*s[0].y+c*s[1].y+d*s[2].y)/a,z:!!o&&(l*s[0].z+c*s[1].z+d*s[2].z)/a,t}):(l*=i,c*=1.5*i,d*=3*i,h*=t*t*t,4===s.length?(a=l+c+d+h,{x:(l*s[0].x+c*s[1].x+d*s[2].x+h*s[3].x)/a,y:(l*s[0].y+c*s[1].y+d*s[2].y+h*s[3].y)/a,z:!!o&&(l*s[0].z+c*s[1].z+d*s[2].z+h*s[3].z)/a,t}):void 0))},derive:function(t,e){const n=[];for(let o=t,i=o.length,r=i-1;i>1;i--,r--){const t=[];for(let n,i=0;i<r;i++)n={x:r*(o[i+1].x-o[i].x),y:r*(o[i+1].y-o[i].y)},e&&(n.z=r*(o[i+1].z-o[i].z)),t.push(n);n.push(t),o=t}return n},between:function(t,e,n){return e<=t&&t<=n||S.approximately(t,e)||S.approximately(t,n)},approximately:function(t,e,n){return l(t-e)<=(n||1e-6)},length:function(t){const e=S.Tvalues.length;let n=0;for(let o,i=0;i<e;i++)o=.5*S.Tvalues[i]+.5,n+=S.Cvalues[i]*S.arcfn(o,t);return.5*n},map:function(t,e,n,o,i){return o+(i-o)*((t-e)/(n-e))},lerp:function(t,e,n){const o={x:e.x+t*(n.x-e.x),y:e.y+t*(n.y-e.y)};return void 0!==e.z&&void 0!==n.z&&(o.z=e.z+t*(n.z-e.z)),o},pointToString:function(t){let e=t.x+"/"+t.y;return void 0!==t.z&&(e+="/"+t.z),e},pointsToString:function(t){return"["+t.map(S.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,n){const o=e.x-t.x,i=e.y-t.y,r=n.x-t.x,s=n.y-t.y;return u(o*s-i*r,o*r+i*s)},round:function(t,e){const n=""+t,o=n.indexOf(".");return parseFloat(n.substring(0,o+1+e))},dist:function(t,e){const n=t.x-e.x,o=t.y-e.y;return p(n*n+o*o)},closest:function(t,e){let n,o,i=f(2,63);return t.forEach((function(t,r){o=S.dist(e,t),o<i&&(i=o,n=r)})),{mdist:i,mpos:n}},abcratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(t,e)+f(1-t,e);return l((n-1)/n)},projectionratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(1-t,e);return n/(f(t,e)+n)},lli8:function(t,e,n,o,i,r,s,a){const l=(t-n)*(r-a)-(e-o)*(i-s);return 0!=l&&{x:((t*o-e*n)*(i-s)-(t-n)*(i*a-r*s))/l,y:((t*o-e*n)*(r-a)-(e-o)*(i*a-r*s))/l}},lli4:function(t,e,n,o){const i=t.x,r=t.y,s=e.x,a=e.y,l=n.x,c=n.y,d=o.x,h=o.y;return S.lli8(i,r,s,a,l,c,d,h)},lli:function(t,e){return S.lli4(t,t.c,e,e.c)},makeline:function(t,e){return new B(t.x,t.y,(t.x+e.x)/2,(t.y+e.y)/2,e.x,e.y)},findbbox:function(t){let e=v,n=v,o=w,i=w;return t.forEach((function(t){const r=t.bbox();e>r.x.min&&(e=r.x.min),n>r.y.min&&(n=r.y.min),o<r.x.max&&(o=r.x.max),i<r.y.max&&(i=r.y.max)})),{x:{min:e,mid:(e+o)/2,max:o,size:o-e},y:{min:n,mid:(n+i)/2,max:i,size:i-n}}},shapeintersections:function(t,e,n,o,i){if(!S.bboxoverlap(e,o))return[];const r=[],s=[t.startcap,t.forward,t.back,t.endcap],a=[n.startcap,n.forward,n.back,n.endcap];return s.forEach((function(e){e.virtual||a.forEach((function(o){if(o.virtual)return;const s=e.intersects(o,i);s.length>0&&(s.c1=e,s.c2=o,s.s1=t,s.s2=n,r.push(s))}))})),r},makeshape:function(t,e,n){const o=e.points.length,i=t.points.length,r=S.makeline(e.points[o-1],t.points[0]),s=S.makeline(t.points[i-1],e.points[0]),a={startcap:r,forward:t,back:e,endcap:s,bbox:S.findbbox([r,t,e,s]),intersections:function(t){return S.shapeintersections(a,a.bbox,t,t.bbox,n)}};return a},getminmax:function(t,e,n){if(!n)return{min:0,max:0};let o,i,r=v,s=w;-1===n.indexOf(0)&&(n=[0].concat(n)),-1===n.indexOf(1)&&n.push(1);for(let a=0,l=n.length;a<l;a++)o=n[a],i=t.get(o),i[e]<r&&(r=i[e]),i[e]>s&&(s=i[e]);return{min:r,mid:(r+s)/2,max:s,size:s-r}},align:function(t,e){const n=e.p1.x,o=e.p1.y,i=-u(e.p2.y-o,e.p2.x-n);return t.map((function(t){return{x:(t.x-n)*c(i)-(t.y-o)*d(i),y:(t.x-n)*d(i)+(t.y-o)*c(i)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=t.length-1,o=S.align(t,e),i=function(t){return 0<=t&&t<=1};if(2===n){const t=o[0].y,e=o[1].y,n=o[2].y,r=t-2*e+n;if(0!==r){const o=-p(e*e-t*n),s=-t+e;return[-(o+s)/r,-(-o+s)/r].filter(i)}return e!==n&&0===r?[(2*e-n)/(2*e-2*n)].filter(i):[]}const r=o[0].y,s=o[1].y,a=o[2].y;let l=3*s-r-3*a+o[3].y,d=3*r-6*s+3*a,u=-3*r+3*s,f=r;if(S.approximately(l,0)){if(S.approximately(d,0))return S.approximately(u,0)?[]:[-f/u].filter(i);const t=p(u*u-4*d*f),e=2*d;return[(t-u)/e,(-u-t)/e].filter(i)}d/=l,u/=l,f/=l;const g=(3*u-d*d)/3,y=g/3,v=(2*d*d*d-9*d*u+27*f)/27,w=v/2,x=w*w+y*y*y;let T,C,P,k,E;if(x<0){const t=-g/3,e=p(t*t*t),n=-v/(2*e),o=h(n<-1?-1:n>1?1:n),r=2*m(e);return P=r*c(o/3)-d/3,k=r*c((o+b)/3)-d/3,E=r*c((o+2*b)/3)-d/3,[P,k,E].filter(i)}if(0===x)return T=w<0?m(-w):-m(w),P=2*T-d/3,k=-T-d/3,[P,k].filter(i);{const t=p(x);return T=m(-w+t),C=m(w+t),[T-C-d/3].filter(i)}},droots:function(t){if(3===t.length){const e=t[0],n=t[1],o=t[2],i=e-2*n+o;if(0!==i){const t=-p(n*n-e*o),r=-e+n;return[-(t+r)/i,-(-t+r)/i]}return n!==o&&0===i?[(2*n-o)/(2*(n-o))]:[]}if(2===t.length){const e=t[0],n=t[1];return e!==n?[e/(e-n)]:[]}return[]},curvature:function(t,e,n,o,i){let r,s,a,c,d=0,h=0;const u=S.compute(t,e),m=S.compute(t,n),g=u.x*u.x+u.y*u.y;if(o?(r=p(f(u.y*m.z-m.y*u.z,2)+f(u.z*m.x-m.z*u.x,2)+f(u.x*m.y-m.x*u.y,2)),s=f(g+u.z*u.z,1.5)):(r=u.x*m.y-u.y*m.x,s=f(g,1.5)),0===r||0===s)return{k:0,r:0};if(d=r/s,h=s/r,!i){const i=S.curvature(t-.001,e,n,o,!0).k,r=S.curvature(t+.001,e,n,o,!0).k;c=(r-d+(d-i))/2,a=(l(r-d)+l(d-i))/2}return{k:d,r:h,dk:c,adk:a}},inflections:function(t){if(t.length<4)return[];const e=S.align(t,{p1:t[0],p2:t.slice(-1)[0]}),n=e[2].x*e[1].y,o=e[3].x*e[1].y,i=e[1].x*e[2].y,r=18*(-3*n+2*o+3*i-e[3].x*e[2].y),s=18*(3*n-o-3*i),a=18*(i-n);if(S.approximately(r,0)){if(!S.approximately(s,0)){let t=-a/s;if(0<=t&&t<=1)return[t]}return[]}const l=2*r;if(S.approximately(l,0))return[];const c=s*s-4*r*a;if(c<0)return[];const d=Math.sqrt(c);return[(d-s)/l,-(s+d)/l].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const n=["x","y"],o=n.length;for(let i,r,s,a,c=0;c<o;c++)if(i=n[c],r=t[i].mid,s=e[i].mid,a=(t[i].size+e[i].size)/2,l(r-s)>=a)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,n){const o=t.bbox(),i=e.bbox(),r=1e5,s=n||.5;if(o.x.size+o.y.size<s&&i.x.size+i.y.size<s)return[(r*(t._t1+t._t2)/2|0)/r+"/"+(r*(e._t1+e._t2)/2|0)/r];let a=t.split(.5),l=e.split(.5),c=[{left:a.left,right:l.left},{left:a.left,right:l.right},{left:a.right,right:l.right},{left:a.right,right:l.left}];c=c.filter((function(t){return S.bboxoverlap(t.left.bbox(),t.right.bbox())}));let d=[];return 0===c.length||(c.forEach((function(t){d=d.concat(S.pairiteration(t.left,t.right,s))})),d=d.filter((function(t,e){return d.indexOf(t)===e}))),d},getccenter:function(t,e,n){const o=e.x-t.x,i=e.y-t.y,r=n.x-e.x,s=n.y-e.y,a=o*c(y)-i*d(y),l=o*d(y)+i*c(y),h=r*c(y)-s*d(y),p=r*d(y)+s*c(y),f=(t.x+e.x)/2,m=(t.y+e.y)/2,g=(e.x+n.x)/2,v=(e.y+n.y)/2,w=f+a,x=m+l,T=g+h,C=v+p,P=S.lli8(f,m,w,x,g,v,T,C),k=S.dist(P,t);let E,z=u(t.y-P.y,t.x-P.x),M=u(e.y-P.y,e.x-P.x),_=u(n.y-P.y,n.x-P.x);return z<_?((z>M||M>_)&&(z+=b),z>_&&(E=_,_=z,z=E)):_<M&&M<z?(E=_,_=z,z=E):_+=b,P.s=z,P.e=_,P.r=k,P},numberSort:function(t,e){return t-e}},T=class{constructor(t){this.curves=[],this._3d=!1,t&&(this.curves=t,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map((function(t){return S.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),n=1;n<t.length;n++)S.expandbox(e,t[n].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(n){e.push(...n.offset(t))})),new T(e)}},{abs:C,min:P,max:k,cos:E,sin:z,acos:M,sqrt:_}=Math,I=Math.PI,B=class{constructor(t){let e=t&&t.forEach?t:Array.from(arguments).slice(),n=!1;if("object"==typeof e[0]){n=e.length;const t=[];e.forEach((function(e){["x","y","z"].forEach((function(n){void 0!==e[n]&&t.push(e[n])}))})),e=t}let o=!1;const i=e.length;if(n){if(n>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");o=!0}}else if(6!==i&&8!==i&&9!==i&&12!==i&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const r=this._3d=!o&&(9===i||12===i)||t&&t[0]&&void 0!==t[0].z,s=this.points=[];for(let t=0,n=r?3:2;t<i;t+=n){var a={x:e[t],y:e[t+1]};r&&(a.z=e[t+2]),s.push(a)}const l=this.order=s.length-1,c=this.dims=["x","y"];r&&c.push("z"),this.dimlen=c.length;const d=S.align(s,{p1:s[0],p2:s[l]}),h=S.dist(s[0],s[l]);this._linear=d.reduce(((t,e)=>t+C(e.y)),0)<h/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(t,e,n,o){if(void 0===o&&(o=.5),0===o)return new B(e,e,n);if(1===o)return new B(t,e,e);const i=B.getABC(2,t,e,n,o);return new B(t,i.A,n)}static cubicFromPoints(t,e,n,o,i){void 0===o&&(o=.5);const r=B.getABC(3,t,e,n,o);void 0===i&&(i=S.dist(e,r.C));const s=i*(1-o)/o,a=S.dist(t,n),l=(n.x-t.x)/a,c=(n.y-t.y)/a,d=i*l,h=i*c,u=s*l,p=s*c,f=e.x-d,m=e.y-h,g=e.x+u,b=e.y+p,y=r.A,v=y.x+(f-y.x)/(1-o),w=y.y+(m-y.y)/(1-o),x=y.x+(g-y.x)/o,T=y.y+(b-y.y)/o,C={x:t.x+(v-t.x)/o,y:t.y+(w-t.y)/o},P={x:n.x+(x-n.x)/(1-o),y:n.y+(T-n.y)/(1-o)};return new B(t,C,P,n)}static getUtils(){return S}getUtils(){return B.getUtils()}static get PolyBezier(){return T}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let n=1,o=t.length;n<o;n++)e.push(t[n].x),e.push(t[n].y);return e.join(" ")}setRatios(t){if(t.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=t,this._lut=[]}verify(){const t=this.coordDigest();t!==this._print&&(this._print=t,this.update())}coordDigest(){return this.points.map((function(t,e){return""+e+t.x+t.y+(t.z?t.z:0)})).join("")}update(){this._lut=[],this.dpoints=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=S.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return S.length(this.derivative.bind(this))}static getABC(t=2,e,n,o,i=.5){const r=S.projectionratio(i,t),s=1-r,a={x:r*e.x+s*o.x,y:r*e.y+s*o.y},l=S.abcratio(i,t);return{A:{x:n.x+(n.x-a.x)/l,y:n.y+(n.y-a.y)/l},B:n,C:a,S:e,E:o}}getABC(t,e){e=e||this.get(t);let n=this.points[0],o=this.points[this.order];return B.getABC(this.order,n,e,o,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t+1)return this._lut;this._lut=[],t++,this._lut=[];for(let e,n,o=0;o<t;o++)n=o/(t-1),e=this.compute(n),e.t=n,this._lut.push(e);return this._lut}on(e,n){n=n||5;const o=this.getLUT(),i=[];for(let t,r=0,s=0;r<o.length;r++)t=o[r],S.dist(t,e)<n&&(i.push(t),s+=r/o.length);return!!i.length&&(t/=i.length)}project(t){const e=this.getLUT(),n=e.length-1,o=S.closest(e,t),i=o.mpos,r=(i-1)/n,s=(i+1)/n,a=.1/n;let l,c=o.mdist,d=r,h=d;c+=1;for(let e;d<s+a;d+=a)l=this.compute(d),e=S.dist(t,l),e<c&&(c=e,h=d);return h=h<0?0:h>1?1:h,l=this.compute(h),l.t=h,l.d=c,l}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?S.computeWithRatios(t,this.points,this.ratios,this._3d):S.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],n=t.length;for(let o,i,r=1;r<n;r++)o=t[r],i=t[r-1],e[r]={x:(n-r)/n*o.x+r/n*i.x,y:(n-r)/n*o.y+r/n*i.y};return e[n]=t[n-1],new B(e)}derivative(t){return S.compute(t,this.dpoints[0],this._3d)}dderivative(t){return S.compute(t,this.dpoints[1],this._3d)}align(){let t=this.points;return new B(S.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return S.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),n=_(e.x*e.x+e.y*e.y);return{t,x:-e.y/n,y:e.x/n}}__normal3(t){const e=this.derivative(t),n=this.derivative(t+.01),o=_(e.x*e.x+e.y*e.y+e.z*e.z),i=_(n.x*n.x+n.y*n.y+n.z*n.z);e.x/=o,e.y/=o,e.z/=o,n.x/=i,n.y/=i,n.z/=i;const r={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},s=_(r.x*r.x+r.y*r.y+r.z*r.z);r.x/=s,r.y/=s,r.z/=s;const a=[r.x*r.x,r.x*r.y-r.z,r.x*r.z+r.y,r.x*r.y+r.z,r.y*r.y,r.y*r.z-r.x,r.x*r.z-r.y,r.y*r.z+r.x,r.z*r.z];return{t,x:a[0]*e.x+a[1]*e.y+a[2]*e.z,y:a[3]*e.x+a[4]*e.y+a[5]*e.z,z:a[6]*e.x+a[7]*e.y+a[8]*e.z}}hull(t){let e=this.points,n=[],o=[],i=0;for(o[i++]=e[0],o[i++]=e[1],o[i++]=e[2],3===this.order&&(o[i++]=e[3]);e.length>1;){n=[];for(let r,s=0,a=e.length-1;s<a;s++)r=S.lerp(t,e[s],e[s+1]),o[i++]=r,n.push(r);e=n}return o}split(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;const n=this.hull(t),o={left:2===this.order?new B([n[0],n[3],n[5]]):new B([n[0],n[4],n[7],n[9]]),right:2===this.order?new B([n[5],n[4],n[2]]):new B([n[9],n[8],n[6],n[3]]),span:n};return o.left._t1=S.map(0,0,1,this._t1,this._t2),o.left._t2=S.map(t,0,1,this._t1,this._t2),o.right._t1=S.map(t,0,1,this._t1,this._t2),o.right._t2=S.map(1,0,1,this._t1,this._t2),e?(e=S.map(e,t,1,0,1),o.right.split(e).left):o}extrema(){const t={};let e=[];return this.dims.forEach(function(n){let o=function(t){return t[n]},i=this.dpoints[0].map(o);t[n]=S.droots(i),3===this.order&&(i=this.dpoints[1].map(o),t[n]=t[n].concat(S.droots(i))),t[n]=t[n].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[n].sort(S.numberSort))}.bind(this)),t.values=e.sort(S.numberSort).filter((function(t,n){return e.indexOf(t)===n})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(n){e[n]=S.getminmax(this,n,t[n])}.bind(this)),e}overlaps(t){const e=this.bbox(),n=t.bbox();return S.bboxoverlap(e,n)}offset(t,e){if(void 0!==e){const n=this.get(t),o=this.normal(t),i={c:n,n:o,x:n.x+o.x*e,y:n.y+o.y*e};return this._3d&&(i.z=n.z+o.z*e),i}if(this._linear){const e=this.normal(0),n=this.points.map((function(n){const o={x:n.x+t*e.x,y:n.y+t*e.y};return n.z&&e.z&&(o.z=n.z+t*e.z),o}));return[new B(n)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=S.angle(this.points[0],this.points[3],this.points[1]),e=S.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let n=t.x*e.x+t.y*e.y;return this._3d&&(n+=t.z*e.z),C(M(n))<I/3}reduce(){let t,e,n=0,o=0,i=.01,r=[],s=[],a=this.extrema().values;for(-1===a.indexOf(0)&&(a=[0].concat(a)),-1===a.indexOf(1)&&a.push(1),n=a[0],t=1;t<a.length;t++)o=a[t],e=this.split(n,o),e._t1=n,e._t2=o,r.push(e),n=o;return r.forEach((function(t){for(n=0,o=0;o<=1;)for(o=n+i;o<=1.01;o+=i)if(e=t.split(n,o),!e.simple()){if(o-=i,C(n-o)<i)return[];e=t.split(n,o),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=S.map(o,0,1,t._t1,t._t2),s.push(e),n=o;break}n<1&&(e=t.split(n,1),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=t._t2,s.push(e))})),s}translate(t,e,n){n="number"==typeof n?n:e;const o=this.order;let i=this.points.map(((t,i)=>(1-i/o)*e+i/o*n));return new B(this.points.map(((e,n)=>({x:e.x+t.x*i[n],y:e.y+t.y*i[n]}))))}scale(t){const e=this.order;let n=!1;if("function"==typeof t&&(n=t),n&&2===e)return this.raise().scale(n);const o=this.clockwise,i=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):t,n?n(1):t);const r=n?n(0):t,s=n?n(1):t,a=[this.offset(0,10),this.offset(1,10)],l=[],c=S.lli4(a[0],a[0].c,a[1],a[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const n=l[t*e]=S.copy(i[t*e]);n.x+=(t?s:r)*a[t].n.x,n.y+=(t?s:r)*a[t].n.y})),n?([0,1].forEach((function(r){if(2!==e||!r){var s=i[r+1],a={x:s.x-c.x,y:s.y-c.y},d=n?n((r+1)/e):t;n&&!o&&(d=-d);var h=_(a.x*a.x+a.y*a.y);a.x/=h,a.y/=h,l[r+1]={x:s.x+d*a.x,y:s.y+d*a.y}}})),new B(l)):([0,1].forEach((t=>{if(2===e&&t)return;const n=l[t*e],o=this.derivative(t),r={x:n.x+o.x,y:n.y+o.y};l[t+1]=S.lli4(n,r,c,i[t+1])})),new B(l))}outline(t,e,n,o){if(e=void 0===e?t:e,this._linear){const i=this.normal(0),r=this.points[0],s=this.points[this.points.length-1];let a,l,c;void 0===n&&(n=t,o=e),a={x:r.x+i.x*t,y:r.y+i.y*t},c={x:s.x+i.x*n,y:s.y+i.y*n},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const d=[a,l,c];a={x:r.x-i.x*e,y:r.y-i.y*e},c={x:s.x-i.x*o,y:s.y-i.y*o},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const h=[c,l,a],u=S.makeline(h[2],d[0]),p=S.makeline(d[2],h[0]),f=[u,new B(d),p,new B(h)];return new T(f)}const i=this.reduce(),r=i.length,s=[];let a,l=[],c=0,d=this.length();const h=void 0!==n&&void 0!==o;function u(t,e,n,o,i){return function(r){const s=o/n,a=(o+i)/n,l=e-t;return S.map(r,0,1,t+s*l,t+a*l)}}i.forEach((function(i){const r=i.length();h?(s.push(i.scale(u(t,n,d,c,r))),l.push(i.scale(u(-e,-o,d,c,r)))):(s.push(i.scale(t)),l.push(i.scale(-e))),c+=r})),l=l.map((function(t){return a=t.points,a[3]?t.points=[a[3],a[2],a[1],a[0]]:t.points=[a[2],a[1],a[0]],t})).reverse();const p=s[0].points[0],f=s[r-1].points[s[r-1].points.length-1],m=l[r-1].points[l[r-1].points.length-1],g=l[0].points[0],b=S.makeline(m,p),y=S.makeline(f,g),v=[b].concat(s).concat([y]).concat(l);return new T(v)}outlineshapes(t,e,n){e=e||t;const o=this.outline(t,e).curves,i=[];for(let t=1,e=o.length;t<e/2;t++){const r=S.makeshape(o[t],o[e-t],n);r.startcap.virtual=t>1,r.endcap.virtual=t<e/2-1,i.push(r)}return i}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof B&&(t=t.reduce()),this.curveintersects(this.reduce(),t,e)):this.selfintersects(e)}lineIntersects(t){const e=P(t.p1.x,t.p2.x),n=P(t.p1.y,t.p2.y),o=k(t.p1.x,t.p2.x),i=k(t.p1.y,t.p2.y);return S.roots(this.points,t).filter((t=>{var r=this.get(t);return S.between(r.x,e,o)&&S.between(r.y,n,i)}))}selfintersects(t){const e=this.reduce(),n=e.length-2,o=[];for(let i,r,s,a=0;a<n;a++)r=e.slice(a,a+1),s=e.slice(a+2),i=this.curveintersects(r,s,t),o.push(...i);return o}curveintersects(t,e,n){const o=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&o.push({left:t,right:e})}))}));let i=[];return o.forEach((function(t){const e=S.pairiteration(t.left,t.right,n);e.length>0&&(i=i.concat(e))})),i}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,n,o){const i=(o-n)/4,r=this.get(n+i),s=this.get(o-i),a=S.dist(t,e),l=S.dist(t,r),c=S.dist(t,s);return C(l-a)+C(c-a)}_iterate(t,e){let n,o=0,i=1;do{n=0,i=1;let r,s,a,l,c,d=this.get(o),h=!1,u=!1,p=i,f=1,m=0;do{if(u=h,l=a,p=(o+i)/2,m++,r=this.get(p),s=this.get(i),a=S.getccenter(d,r,s),a.interval={start:o,end:i},h=this._error(a,d,o,i)<=t,c=u&&!h,c||(f=i),h){if(i>=1){if(a.interval.end=f=1,l=a,i>1){let t={x:a.x+a.r*E(a.e),y:a.y+a.r*z(a.e)};a.e+=S.angle({x:a.x,y:a.y},t,this.get(1))}break}i+=(i-o)/2}else i=p}while(!c&&n++<100);if(n>=100)break;l=l||a,e.push(l),o=f}while(i<1);return e}};e.exports=s(a)}},n={};function o(t){var i=n[t];if(void 0!==i)return i.exports;var r=n[t]={id:t,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nc=void 0;var i=o(7783);window.jsdraw=i})();
|
9
|
+
return function(t,e,n,o){var i,r,s,a,l,c,d,h,u,p,f,m,g,b,y,v,w,x=e.createElement("canvas").getContext("2d"),S={r:0,g:0,b:0,h:0,s:0,v:0,a:1},T={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:function(){return o},a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},C={},P="",k={},E=!1;function z(n){if("object"==typeof n){var a=function(){switch(l){case"el":B(n.el),!1!==n.wrap&&O(n.el);break;case"parent":(i=e.querySelector(n.parent))&&(i.appendChild(r),T.parent=n.parent,i===e.body&&(i=o));break;case"themeMode":T.themeMode=n.themeMode,"auto"===n.themeMode&&t.matchMedia&&t.matchMedia("(prefers-color-scheme: dark)").matches&&(T.themeMode="dark");case"theme":n.theme&&(T.theme=n.theme),r.className="clr-picker clr-"+T.theme+" clr-"+T.themeMode,T.inline&&L();break;case"rtl":T.rtl=!!n.rtl,e.querySelectorAll(".clr-field").forEach((function(t){return t.classList.toggle("clr-rtl",T.rtl)}));break;case"margin":n.margin*=1,T.margin=isNaN(n.margin)?T.margin:n.margin;break;case"wrap":n.el&&n.wrap&&O(n.el);break;case"formatToggle":T.formatToggle=!!n.formatToggle,it("clr-format").style.display=T.formatToggle?"block":"none",T.formatToggle&&(T.format="auto");break;case"swatches":if(Array.isArray(n.swatches)){var a=[];n.swatches.forEach((function(t,e){a.push('<button type="button" id="clr-swatch-'+e+'" aria-labelledby="clr-swatch-label clr-swatch-'+e+'" style="color: '+t+';">'+t+"</button>")})),it("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":"",T.swatches=n.swatches.slice()}break;case"swatchesOnly":T.swatchesOnly=!!n.swatchesOnly,r.setAttribute("data-minimal",T.swatchesOnly);break;case"alpha":T.alpha=!!n.alpha,r.setAttribute("data-alpha",T.alpha);break;case"inline":if(T.inline=!!n.inline,r.setAttribute("data-inline",T.inline),T.inline){var f=n.defaultColor||T.defaultColor;y=j(f),L(),A(f)}break;case"clearButton":"object"==typeof n.clearButton&&(n.clearButton.label&&(T.clearLabel=n.clearButton.label,h.innerHTML=T.clearLabel),n.clearButton=n.clearButton.show),T.clearButton=!!n.clearButton,h.style.display=T.clearButton?"block":"none";break;case"clearLabel":T.clearLabel=n.clearLabel,h.innerHTML=T.clearLabel;break;case"closeButton":T.closeButton=!!n.closeButton,T.closeButton?r.insertBefore(u,c):c.appendChild(u);break;case"closeLabel":T.closeLabel=n.closeLabel,u.innerHTML=T.closeLabel;break;case"a11y":var g=n.a11y,b=!1;if("object"==typeof g)for(var v in g)g[v]&&T.a11y[v]&&(T.a11y[v]=g[v],b=!0);if(b){var w=it("clr-open-label"),x=it("clr-swatch-label");w.innerHTML=T.a11y.open,x.innerHTML=T.a11y.swatch,u.setAttribute("aria-label",T.a11y.close),h.setAttribute("aria-label",T.a11y.clear),p.setAttribute("aria-label",T.a11y.hueSlider),m.setAttribute("aria-label",T.a11y.alphaSlider),d.setAttribute("aria-label",T.a11y.input),s.setAttribute("aria-label",T.a11y.instruction)}break;default:T[l]=n[l]}};for(var l in n)a()}}function M(t,e){"string"==typeof t&&"object"==typeof e&&(C[t]=e,E=!0)}function _(t){delete C[t],0===Object.keys(C).length&&(E=!1,t===P&&R())}function I(t){if(E){var e=["el","wrap","rtl","inline","defaultColor","a11y"],n=function(){var n=C[o];if(t.matches(o)){for(var i in P=o,k={},e.forEach((function(t){return delete n[t]})),n)k[i]=Array.isArray(T[i])?T[i].slice():T[i];return z(n),"break"}};for(var o in C)if("break"===n())break}}function R(){Object.keys(k).length>0&&(z(k),P="",k={})}function B(t){rt(e,"click",t,(function(t){T.inline||(I(t.target),b=t.target,v=b.value,y=j(v),r.classList.add("clr-open"),L(),A(v),(T.focusInput||T.selectInput)&&(d.focus({preventScroll:!0}),d.setSelectionRange(b.selectionStart,b.selectionEnd)),T.selectInput&&d.select(),(w||T.swatchesOnly)&&ot().shift().focus(),b.dispatchEvent(new Event("open",{bubbles:!0})))})),rt(e,"input",t,(function(t){var e=t.target.parentNode;e.classList.contains("clr-field")&&(e.style.color=t.target.value)}))}function L(){if(r&&(b||T.inline)){var n,o,l,c=i,d=t.scrollY,h=r.offsetWidth,u=r.offsetHeight,p={left:!1,top:!1},f={x:0,y:0};if(c&&(n=t.getComputedStyle(c),o=parseFloat(n.marginTop),l=parseFloat(n.borderTopWidth),(f=c.getBoundingClientRect()).y+=l+d),!T.inline){var m=b.getBoundingClientRect(),g=m.x,y=d+m.y+m.height+T.margin;c?(g-=f.x,y-=f.y,g+h>c.clientWidth&&(g+=m.width-h,p.left=!0),y+u>c.clientHeight-o&&u+T.margin<=m.top-(f.y-d)&&(y-=m.height+u+2*T.margin,p.top=!0),y+=c.scrollTop):(g+h>e.documentElement.clientWidth&&(g+=m.width-h,p.left=!0),y+u-d>e.documentElement.clientHeight&&u+T.margin<=m.top&&(y=d+m.y-u-T.margin,p.top=!0)),r.classList.toggle("clr-left",p.left),r.classList.toggle("clr-top",p.top),r.style.left=g+"px",r.style.top=y+"px",f.x+=r.offsetLeft,f.y+=r.offsetTop}a={width:s.offsetWidth,height:s.offsetHeight,x:s.offsetLeft+f.x,y:s.offsetTop+f.y}}}function O(t){e.querySelectorAll(t).forEach((function(t){var n=t.parentNode;if(!n.classList.contains("clr-field")){var o=e.createElement("div"),i="clr-field";(T.rtl||t.classList.contains("clr-rtl"))&&(i+=" clr-rtl"),o.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',n.insertBefore(o,t),o.setAttribute("class",i),o.style.color=t.value,o.appendChild(t)}}))}function D(t){if(b&&!T.inline){var e=b;t&&(b=o,v!==e.value&&(e.value=v,e.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout((function(){v!==e.value&&e.dispatchEvent(new Event("change",{bubbles:!0}))})),r.classList.remove("clr-open"),E&&R(),e.dispatchEvent(new Event("close",{bubbles:!0})),T.focusInput&&e.focus({preventScroll:!0}),b=o}}function A(t){var e=J(t),n=X(e);$(n.s,n.v),G(e,n),p.value=n.h,r.style.color="hsl("+n.h+", 100%, 50%)",f.style.left=n.h/360*100+"%",l.style.left=a.width*n.s/100+"px",l.style.top=a.height-a.height*n.v/100+"px",m.value=100*n.a,g.style.left=100*n.a+"%"}function j(t){var e=t.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function V(n){n=n!==o?n:d.value,b&&(b.value=n,b.dispatchEvent(new Event("input",{bubbles:!0}))),T.onChange&&T.onChange.call(t,n,b),e.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:n,currentEl:b}}))}function F(t,e){var n={h:1*p.value,s:t/a.width*100,v:100-e/a.height*100,a:m.value/100},o=Z(n);$(n.s,n.v),G(o,n),V()}function $(t,e){var n=T.a11y.marker;t=1*t.toFixed(1),e=1*e.toFixed(1),n=(n=n.replace("{s}",t)).replace("{v}",e),l.setAttribute("aria-label",n)}function N(t){return{pageX:t.changedTouches?t.changedTouches[0].pageX:t.pageX,pageY:t.changedTouches?t.changedTouches[0].pageY:t.pageY}}function U(t){var e=N(t),n=e.pageX-a.x,o=e.pageY-a.y;i&&(o+=i.scrollTop),K(n,o),t.preventDefault(),t.stopPropagation()}function W(t,e){K(1*l.style.left.replace("px","")+t,1*l.style.top.replace("px","")+e)}function K(t,e){t=t<0?0:t>a.width?a.width:t,e=e<0?0:e>a.height?a.height:e,l.style.left=t+"px",l.style.top=e+"px",F(t,e),l.focus()}function G(t,n){void 0===t&&(t={}),void 0===n&&(n={});var o=T.format;for(var i in t)S[i]=t[i];for(var r in n)S[r]=n[r];var a=Q(S),h=a.substring(0,7);switch(l.style.color=h,g.parentNode.style.color=h,g.style.color=a,c.style.color=a,s.style.display="none",s.offsetHeight,s.style.display="",g.nextElementSibling.style.display="none",g.nextElementSibling.offsetHeight,g.nextElementSibling.style.display="","mixed"===o?o=1===S.a?"hex":"rgb":"auto"===o&&(o=y),o){case"hex":d.value=a;break;case"rgb":d.value=tt(S);break;case"hsl":d.value=et(Y(S))}e.querySelector('.clr-format [value="'+o+'"]').checked=!0}function H(){var t=1*p.value,e=1*l.style.left.replace("px",""),n=1*l.style.top.replace("px","");r.style.color="hsl("+t+", 100%, 50%)",f.style.left=t/360*100+"%",F(e,n)}function q(){var t=m.value/100;g.style.left=100*t+"%",G({a:t}),V()}function Z(t){var e=t.s/100,o=t.v/100,i=e*o,r=t.h/60,s=i*(1-n.abs(r%2-1)),a=o-i;i+=a,s+=a;var l=n.floor(r)%6,c=[i,s,a,a,s,i][l],d=[s,i,i,s,a,a][l],h=[a,a,s,i,i,s][l];return{r:n.round(255*c),g:n.round(255*d),b:n.round(255*h),a:t.a}}function Y(t){var e,o=t.v/100,i=o*(1-t.s/100/2);return i>0&&i<1&&(e=n.round((o-i)/n.min(i,1-i)*100)),{h:t.h,s:e||0,l:n.round(100*i),a:t.a}}function X(t){var e=t.r/255,o=t.g/255,i=t.b/255,r=n.max(e,o,i),s=r-n.min(e,o,i),a=r,l=0,c=0;return s&&(r===e&&(l=(o-i)/s),r===o&&(l=2+(i-e)/s),r===i&&(l=4+(e-o)/s),r&&(c=s/r)),{h:(l=n.floor(60*l))<0?l+360:l,s:n.round(100*c),v:n.round(100*a),a:t.a}}function J(t){var e,n,o=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;return x.fillStyle="#000",x.fillStyle=t,(e=o.exec(x.fillStyle))?(n={r:1*e[3],g:1*e[4],b:1*e[5],a:1*e[6]}).a=+n.a.toFixed(2):n={r:(e=x.fillStyle.replace("#","").match(/.{2}/g).map((function(t){return parseInt(t,16)})))[0],g:e[1],b:e[2],a:1},n}function Q(t){var e=t.r.toString(16),n=t.g.toString(16),o=t.b.toString(16),i="";if(t.r<16&&(e="0"+e),t.g<16&&(n="0"+n),t.b<16&&(o="0"+o),T.alpha&&(t.a<1||T.forceAlpha)){var r=255*t.a|0;i=r.toString(16),r<16&&(i="0"+i)}return"#"+e+n+o+i}function tt(t){return!T.alpha||1===t.a&&!T.forceAlpha?"rgb("+t.r+", "+t.g+", "+t.b+")":"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"}function et(t){return!T.alpha||1===t.a&&!T.forceAlpha?"hsl("+t.h+", "+t.s+"%, "+t.l+"%)":"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"}function nt(){e.getElementById("clr-picker")||(i=o,(r=e.createElement("div")).setAttribute("id","clr-picker"),r.className="clr-picker",r.innerHTML='<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+T.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+T.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+T.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+T.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+T.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button type="button" id="clr-clear" class="clr-clear" aria-label="'+T.a11y.clear+'">'+T.clearLabel+'</button><div id="clr-color-preview" class="clr-preview"><button type="button" id="clr-close" class="clr-close" aria-label="'+T.a11y.close+'">'+T.closeLabel+'</button></div><span id="clr-open-label" hidden>'+T.a11y.open+'</span><span id="clr-swatch-label" hidden>'+T.a11y.swatch+"</span>",e.body.appendChild(r),s=it("clr-color-area"),l=it("clr-color-marker"),h=it("clr-clear"),u=it("clr-close"),c=it("clr-color-preview"),d=it("clr-color-value"),p=it("clr-hue-slider"),f=it("clr-hue-marker"),m=it("clr-alpha-slider"),g=it("clr-alpha-marker"),B(T.el),O(T.el),rt(r,"mousedown",(function(t){r.classList.remove("clr-keyboard-nav"),t.stopPropagation()})),rt(s,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(s,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(l,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(l,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(d,"change",(function(t){var e=d.value;(b||T.inline)&&V(""===e?e:A(e))})),rt(h,"click",(function(t){V(""),D()})),rt(u,"click",(function(t){V(),D()})),rt(it("clr-format"),"click",".clr-format input",(function(t){y=t.target.value,G(),V()})),rt(r,"click",".clr-swatches button",(function(t){A(t.target.textContent),V(),T.swatchesOnly&&D()})),rt(e,"mouseup",(function(t){e.removeEventListener("mousemove",U)})),rt(e,"touchend",(function(t){e.removeEventListener("touchmove",U)})),rt(e,"mousedown",(function(t){w=!1,r.classList.remove("clr-keyboard-nav"),D()})),rt(e,"keydown",(function(t){var e=t.key,n=t.target,o=t.shiftKey,i=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];if("Escape"===e?D(!0):i.includes(e)&&(w=!0,r.classList.add("clr-keyboard-nav")),"Tab"===e&&n.matches(".clr-picker *")){var s=ot(),a=s.shift(),l=s.pop();o&&n===a?(l.focus(),t.preventDefault()):o||n!==l||(a.focus(),t.preventDefault())}})),rt(e,"click",".clr-field button",(function(t){E&&R(),t.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))})),rt(l,"keydown",(function(t){var e={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(e).includes(t.key)&&(W.apply(void 0,e[t.key]),t.preventDefault())})),rt(s,"click",U),rt(p,"input",H),rt(m,"input",q))}function ot(){return Array.from(r.querySelectorAll("input, button")).filter((function(t){return!!t.offsetWidth}))}function it(t){return e.getElementById(t)}function rt(t,e,n,o){var i=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof n?t.addEventListener(e,(function(t){i.call(t.target,n)&&o.call(t.target,t)})):(o=n,t.addEventListener(e,o))}function st(t,n){n=n!==o?n:[],"loading"!==e.readyState?t.apply(void 0,n):e.addEventListener("DOMContentLoaded",(function(){t.apply(void 0,n)}))}function at(t,e){v=(b=e).value,I(e),y=j(t),L(),A(t),V(),v!==t&&b.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==o&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var lt=function(){var e={init:nt,set:z,wrap:O,close:D,setInstance:M,setColor:at,removeInstance:_,updatePosition:L};function n(t){st((function(){t&&("string"==typeof t?B(t):z(t))}))}var o=function(t){n[t]=function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];st(e[t],o)}};for(var i in e)o(i);return st((function(){t.addEventListener("resize",(function(t){n.updatePosition()})),t.addEventListener("scroll",(function(t){n.updatePosition()}))})),n}();return lt.coloris=lt,lt}(window,document,Math)})?n.apply(e,o):n)||(t.exports=i)},4232:e=>{var n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=(t=>(e,s)=>t&&t.get(e)||(s=((t,e,s,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let l of i(e))r.call(t,l)||!s&&"default"===l||n(t,l,{get:()=>e[l],enumerable:!(a=o(e,l))||a.enumerable});return t})(n({},"__esModule",{value:!0}),e,1),t&&t.set(e,s),s))("undefined"!=typeof WeakMap?new WeakMap:0),a={};((t,e)=>{for(var o in e)n(t,o,{get:e[o],enumerable:!0})})(a,{Bezier:()=>R});var{abs:l,cos:c,sin:d,acos:h,atan2:u,sqrt:p,pow:f}=Math;function m(t){return t<0?-f(-t,1/3):f(t,1/3)}var g=Math.PI,b=2*g,y=g/2,v=Number.MAX_SAFE_INTEGER||9007199254740991,w=Number.MIN_SAFE_INTEGER||-9007199254740991,x={x:0,y:0,z:0},S={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const n=e(t);let o=n.x*n.x+n.y*n.y;return void 0!==n.z&&(o+=n.z*n.z),p(o)},compute:function(t,e,n){if(0===t)return e[0].t=0,e[0];const o=e.length-1;if(1===t)return e[o].t=1,e[o];const i=1-t;let r=e;if(0===o)return e[0].t=t,e[0];if(1===o){const e={x:i*r[0].x+t*r[1].x,y:i*r[0].y+t*r[1].y,t};return n&&(e.z=i*r[0].z+t*r[1].z),e}if(o<4){let e,s,a,l=i*i,c=t*t,d=0;2===o?(r=[r[0],r[1],r[2],x],e=l,s=i*t*2,a=c):3===o&&(e=l*i,s=l*t*3,a=i*c*3,d=t*c);const h={x:e*r[0].x+s*r[1].x+a*r[2].x+d*r[3].x,y:e*r[0].y+s*r[1].y+a*r[2].y+d*r[3].y,t};return n&&(h.z=e*r[0].z+s*r[1].z+a*r[2].z+d*r[3].z),h}const s=JSON.parse(JSON.stringify(e));for(;s.length>1;){for(let e=0;e<s.length-1;e++)s[e]={x:s[e].x+(s[e+1].x-s[e].x)*t,y:s[e].y+(s[e+1].y-s[e].y)*t},void 0!==s[e].z&&(s[e]=s[e].z+(s[e+1].z-s[e].z)*t);s.splice(s.length-1,1)}return s[0].t=t,s[0]},computeWithRatios:function(t,e,n,o){const i=1-t,r=n,s=e;let a,l=r[0],c=r[1],d=r[2],h=r[3];return l*=i,c*=t,2===s.length?(a=l+c,{x:(l*s[0].x+c*s[1].x)/a,y:(l*s[0].y+c*s[1].y)/a,z:!!o&&(l*s[0].z+c*s[1].z)/a,t}):(l*=i,c*=2*i,d*=t*t,3===s.length?(a=l+c+d,{x:(l*s[0].x+c*s[1].x+d*s[2].x)/a,y:(l*s[0].y+c*s[1].y+d*s[2].y)/a,z:!!o&&(l*s[0].z+c*s[1].z+d*s[2].z)/a,t}):(l*=i,c*=1.5*i,d*=3*i,h*=t*t*t,4===s.length?(a=l+c+d+h,{x:(l*s[0].x+c*s[1].x+d*s[2].x+h*s[3].x)/a,y:(l*s[0].y+c*s[1].y+d*s[2].y+h*s[3].y)/a,z:!!o&&(l*s[0].z+c*s[1].z+d*s[2].z+h*s[3].z)/a,t}):void 0))},derive:function(t,e){const n=[];for(let o=t,i=o.length,r=i-1;i>1;i--,r--){const t=[];for(let n,i=0;i<r;i++)n={x:r*(o[i+1].x-o[i].x),y:r*(o[i+1].y-o[i].y)},e&&(n.z=r*(o[i+1].z-o[i].z)),t.push(n);n.push(t),o=t}return n},between:function(t,e,n){return e<=t&&t<=n||S.approximately(t,e)||S.approximately(t,n)},approximately:function(t,e,n){return l(t-e)<=(n||1e-6)},length:function(t){const e=S.Tvalues.length;let n=0;for(let o,i=0;i<e;i++)o=.5*S.Tvalues[i]+.5,n+=S.Cvalues[i]*S.arcfn(o,t);return.5*n},map:function(t,e,n,o,i){return o+(i-o)*((t-e)/(n-e))},lerp:function(t,e,n){const o={x:e.x+t*(n.x-e.x),y:e.y+t*(n.y-e.y)};return void 0!==e.z&&void 0!==n.z&&(o.z=e.z+t*(n.z-e.z)),o},pointToString:function(t){let e=t.x+"/"+t.y;return void 0!==t.z&&(e+="/"+t.z),e},pointsToString:function(t){return"["+t.map(S.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,n){const o=e.x-t.x,i=e.y-t.y,r=n.x-t.x,s=n.y-t.y;return u(o*s-i*r,o*r+i*s)},round:function(t,e){const n=""+t,o=n.indexOf(".");return parseFloat(n.substring(0,o+1+e))},dist:function(t,e){const n=t.x-e.x,o=t.y-e.y;return p(n*n+o*o)},closest:function(t,e){let n,o,i=f(2,63);return t.forEach((function(t,r){o=S.dist(e,t),o<i&&(i=o,n=r)})),{mdist:i,mpos:n}},abcratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(t,e)+f(1-t,e);return l((n-1)/n)},projectionratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(1-t,e);return n/(f(t,e)+n)},lli8:function(t,e,n,o,i,r,s,a){const l=(t-n)*(r-a)-(e-o)*(i-s);return 0!=l&&{x:((t*o-e*n)*(i-s)-(t-n)*(i*a-r*s))/l,y:((t*o-e*n)*(r-a)-(e-o)*(i*a-r*s))/l}},lli4:function(t,e,n,o){const i=t.x,r=t.y,s=e.x,a=e.y,l=n.x,c=n.y,d=o.x,h=o.y;return S.lli8(i,r,s,a,l,c,d,h)},lli:function(t,e){return S.lli4(t,t.c,e,e.c)},makeline:function(t,e){return new R(t.x,t.y,(t.x+e.x)/2,(t.y+e.y)/2,e.x,e.y)},findbbox:function(t){let e=v,n=v,o=w,i=w;return t.forEach((function(t){const r=t.bbox();e>r.x.min&&(e=r.x.min),n>r.y.min&&(n=r.y.min),o<r.x.max&&(o=r.x.max),i<r.y.max&&(i=r.y.max)})),{x:{min:e,mid:(e+o)/2,max:o,size:o-e},y:{min:n,mid:(n+i)/2,max:i,size:i-n}}},shapeintersections:function(t,e,n,o,i){if(!S.bboxoverlap(e,o))return[];const r=[],s=[t.startcap,t.forward,t.back,t.endcap],a=[n.startcap,n.forward,n.back,n.endcap];return s.forEach((function(e){e.virtual||a.forEach((function(o){if(o.virtual)return;const s=e.intersects(o,i);s.length>0&&(s.c1=e,s.c2=o,s.s1=t,s.s2=n,r.push(s))}))})),r},makeshape:function(t,e,n){const o=e.points.length,i=t.points.length,r=S.makeline(e.points[o-1],t.points[0]),s=S.makeline(t.points[i-1],e.points[0]),a={startcap:r,forward:t,back:e,endcap:s,bbox:S.findbbox([r,t,e,s]),intersections:function(t){return S.shapeintersections(a,a.bbox,t,t.bbox,n)}};return a},getminmax:function(t,e,n){if(!n)return{min:0,max:0};let o,i,r=v,s=w;-1===n.indexOf(0)&&(n=[0].concat(n)),-1===n.indexOf(1)&&n.push(1);for(let a=0,l=n.length;a<l;a++)o=n[a],i=t.get(o),i[e]<r&&(r=i[e]),i[e]>s&&(s=i[e]);return{min:r,mid:(r+s)/2,max:s,size:s-r}},align:function(t,e){const n=e.p1.x,o=e.p1.y,i=-u(e.p2.y-o,e.p2.x-n);return t.map((function(t){return{x:(t.x-n)*c(i)-(t.y-o)*d(i),y:(t.x-n)*d(i)+(t.y-o)*c(i)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=t.length-1,o=S.align(t,e),i=function(t){return 0<=t&&t<=1};if(2===n){const t=o[0].y,e=o[1].y,n=o[2].y,r=t-2*e+n;if(0!==r){const o=-p(e*e-t*n),s=-t+e;return[-(o+s)/r,-(-o+s)/r].filter(i)}return e!==n&&0===r?[(2*e-n)/(2*e-2*n)].filter(i):[]}const r=o[0].y,s=o[1].y,a=o[2].y;let l=3*s-r-3*a+o[3].y,d=3*r-6*s+3*a,u=-3*r+3*s,f=r;if(S.approximately(l,0)){if(S.approximately(d,0))return S.approximately(u,0)?[]:[-f/u].filter(i);const t=p(u*u-4*d*f),e=2*d;return[(t-u)/e,(-u-t)/e].filter(i)}d/=l,u/=l,f/=l;const g=(3*u-d*d)/3,y=g/3,v=(2*d*d*d-9*d*u+27*f)/27,w=v/2,x=w*w+y*y*y;let T,C,P,k,E;if(x<0){const t=-g/3,e=p(t*t*t),n=-v/(2*e),o=h(n<-1?-1:n>1?1:n),r=2*m(e);return P=r*c(o/3)-d/3,k=r*c((o+b)/3)-d/3,E=r*c((o+2*b)/3)-d/3,[P,k,E].filter(i)}if(0===x)return T=w<0?m(-w):-m(w),P=2*T-d/3,k=-T-d/3,[P,k].filter(i);{const t=p(x);return T=m(-w+t),C=m(w+t),[T-C-d/3].filter(i)}},droots:function(t){if(3===t.length){const e=t[0],n=t[1],o=t[2],i=e-2*n+o;if(0!==i){const t=-p(n*n-e*o),r=-e+n;return[-(t+r)/i,-(-t+r)/i]}return n!==o&&0===i?[(2*n-o)/(2*(n-o))]:[]}if(2===t.length){const e=t[0],n=t[1];return e!==n?[e/(e-n)]:[]}return[]},curvature:function(t,e,n,o,i){let r,s,a,c,d=0,h=0;const u=S.compute(t,e),m=S.compute(t,n),g=u.x*u.x+u.y*u.y;if(o?(r=p(f(u.y*m.z-m.y*u.z,2)+f(u.z*m.x-m.z*u.x,2)+f(u.x*m.y-m.x*u.y,2)),s=f(g+u.z*u.z,1.5)):(r=u.x*m.y-u.y*m.x,s=f(g,1.5)),0===r||0===s)return{k:0,r:0};if(d=r/s,h=s/r,!i){const i=S.curvature(t-.001,e,n,o,!0).k,r=S.curvature(t+.001,e,n,o,!0).k;c=(r-d+(d-i))/2,a=(l(r-d)+l(d-i))/2}return{k:d,r:h,dk:c,adk:a}},inflections:function(t){if(t.length<4)return[];const e=S.align(t,{p1:t[0],p2:t.slice(-1)[0]}),n=e[2].x*e[1].y,o=e[3].x*e[1].y,i=e[1].x*e[2].y,r=18*(-3*n+2*o+3*i-e[3].x*e[2].y),s=18*(3*n-o-3*i),a=18*(i-n);if(S.approximately(r,0)){if(!S.approximately(s,0)){let t=-a/s;if(0<=t&&t<=1)return[t]}return[]}const l=2*r;if(S.approximately(l,0))return[];const c=s*s-4*r*a;if(c<0)return[];const d=Math.sqrt(c);return[(d-s)/l,-(s+d)/l].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const n=["x","y"],o=n.length;for(let i,r,s,a,c=0;c<o;c++)if(i=n[c],r=t[i].mid,s=e[i].mid,a=(t[i].size+e[i].size)/2,l(r-s)>=a)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,n){const o=t.bbox(),i=e.bbox(),r=1e5,s=n||.5;if(o.x.size+o.y.size<s&&i.x.size+i.y.size<s)return[(r*(t._t1+t._t2)/2|0)/r+"/"+(r*(e._t1+e._t2)/2|0)/r];let a=t.split(.5),l=e.split(.5),c=[{left:a.left,right:l.left},{left:a.left,right:l.right},{left:a.right,right:l.right},{left:a.right,right:l.left}];c=c.filter((function(t){return S.bboxoverlap(t.left.bbox(),t.right.bbox())}));let d=[];return 0===c.length||(c.forEach((function(t){d=d.concat(S.pairiteration(t.left,t.right,s))})),d=d.filter((function(t,e){return d.indexOf(t)===e}))),d},getccenter:function(t,e,n){const o=e.x-t.x,i=e.y-t.y,r=n.x-e.x,s=n.y-e.y,a=o*c(y)-i*d(y),l=o*d(y)+i*c(y),h=r*c(y)-s*d(y),p=r*d(y)+s*c(y),f=(t.x+e.x)/2,m=(t.y+e.y)/2,g=(e.x+n.x)/2,v=(e.y+n.y)/2,w=f+a,x=m+l,T=g+h,C=v+p,P=S.lli8(f,m,w,x,g,v,T,C),k=S.dist(P,t);let E,z=u(t.y-P.y,t.x-P.x),M=u(e.y-P.y,e.x-P.x),_=u(n.y-P.y,n.x-P.x);return z<_?((z>M||M>_)&&(z+=b),z>_&&(E=_,_=z,z=E)):_<M&&M<z?(E=_,_=z,z=E):_+=b,P.s=z,P.e=_,P.r=k,P},numberSort:function(t,e){return t-e}},T=class{constructor(t){this.curves=[],this._3d=!1,t&&(this.curves=t,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map((function(t){return S.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),n=1;n<t.length;n++)S.expandbox(e,t[n].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(n){e.push(...n.offset(t))})),new T(e)}},{abs:C,min:P,max:k,cos:E,sin:z,acos:M,sqrt:_}=Math,I=Math.PI,R=class{constructor(t){let e=t&&t.forEach?t:Array.from(arguments).slice(),n=!1;if("object"==typeof e[0]){n=e.length;const t=[];e.forEach((function(e){["x","y","z"].forEach((function(n){void 0!==e[n]&&t.push(e[n])}))})),e=t}let o=!1;const i=e.length;if(n){if(n>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");o=!0}}else if(6!==i&&8!==i&&9!==i&&12!==i&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const r=this._3d=!o&&(9===i||12===i)||t&&t[0]&&void 0!==t[0].z,s=this.points=[];for(let t=0,n=r?3:2;t<i;t+=n){var a={x:e[t],y:e[t+1]};r&&(a.z=e[t+2]),s.push(a)}const l=this.order=s.length-1,c=this.dims=["x","y"];r&&c.push("z"),this.dimlen=c.length;const d=S.align(s,{p1:s[0],p2:s[l]}),h=S.dist(s[0],s[l]);this._linear=d.reduce(((t,e)=>t+C(e.y)),0)<h/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(t,e,n,o){if(void 0===o&&(o=.5),0===o)return new R(e,e,n);if(1===o)return new R(t,e,e);const i=R.getABC(2,t,e,n,o);return new R(t,i.A,n)}static cubicFromPoints(t,e,n,o,i){void 0===o&&(o=.5);const r=R.getABC(3,t,e,n,o);void 0===i&&(i=S.dist(e,r.C));const s=i*(1-o)/o,a=S.dist(t,n),l=(n.x-t.x)/a,c=(n.y-t.y)/a,d=i*l,h=i*c,u=s*l,p=s*c,f=e.x-d,m=e.y-h,g=e.x+u,b=e.y+p,y=r.A,v=y.x+(f-y.x)/(1-o),w=y.y+(m-y.y)/(1-o),x=y.x+(g-y.x)/o,T=y.y+(b-y.y)/o,C={x:t.x+(v-t.x)/o,y:t.y+(w-t.y)/o},P={x:n.x+(x-n.x)/(1-o),y:n.y+(T-n.y)/(1-o)};return new R(t,C,P,n)}static getUtils(){return S}getUtils(){return R.getUtils()}static get PolyBezier(){return T}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let n=1,o=t.length;n<o;n++)e.push(t[n].x),e.push(t[n].y);return e.join(" ")}setRatios(t){if(t.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=t,this._lut=[]}verify(){const t=this.coordDigest();t!==this._print&&(this._print=t,this.update())}coordDigest(){return this.points.map((function(t,e){return""+e+t.x+t.y+(t.z?t.z:0)})).join("")}update(){this._lut=[],this.dpoints=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=S.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return S.length(this.derivative.bind(this))}static getABC(t=2,e,n,o,i=.5){const r=S.projectionratio(i,t),s=1-r,a={x:r*e.x+s*o.x,y:r*e.y+s*o.y},l=S.abcratio(i,t);return{A:{x:n.x+(n.x-a.x)/l,y:n.y+(n.y-a.y)/l},B:n,C:a,S:e,E:o}}getABC(t,e){e=e||this.get(t);let n=this.points[0],o=this.points[this.order];return R.getABC(this.order,n,e,o,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t+1)return this._lut;this._lut=[],t++,this._lut=[];for(let e,n,o=0;o<t;o++)n=o/(t-1),e=this.compute(n),e.t=n,this._lut.push(e);return this._lut}on(e,n){n=n||5;const o=this.getLUT(),i=[];for(let t,r=0,s=0;r<o.length;r++)t=o[r],S.dist(t,e)<n&&(i.push(t),s+=r/o.length);return!!i.length&&(t/=i.length)}project(t){const e=this.getLUT(),n=e.length-1,o=S.closest(e,t),i=o.mpos,r=(i-1)/n,s=(i+1)/n,a=.1/n;let l,c=o.mdist,d=r,h=d;c+=1;for(let e;d<s+a;d+=a)l=this.compute(d),e=S.dist(t,l),e<c&&(c=e,h=d);return h=h<0?0:h>1?1:h,l=this.compute(h),l.t=h,l.d=c,l}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?S.computeWithRatios(t,this.points,this.ratios,this._3d):S.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],n=t.length;for(let o,i,r=1;r<n;r++)o=t[r],i=t[r-1],e[r]={x:(n-r)/n*o.x+r/n*i.x,y:(n-r)/n*o.y+r/n*i.y};return e[n]=t[n-1],new R(e)}derivative(t){return S.compute(t,this.dpoints[0],this._3d)}dderivative(t){return S.compute(t,this.dpoints[1],this._3d)}align(){let t=this.points;return new R(S.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return S.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),n=_(e.x*e.x+e.y*e.y);return{t,x:-e.y/n,y:e.x/n}}__normal3(t){const e=this.derivative(t),n=this.derivative(t+.01),o=_(e.x*e.x+e.y*e.y+e.z*e.z),i=_(n.x*n.x+n.y*n.y+n.z*n.z);e.x/=o,e.y/=o,e.z/=o,n.x/=i,n.y/=i,n.z/=i;const r={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},s=_(r.x*r.x+r.y*r.y+r.z*r.z);r.x/=s,r.y/=s,r.z/=s;const a=[r.x*r.x,r.x*r.y-r.z,r.x*r.z+r.y,r.x*r.y+r.z,r.y*r.y,r.y*r.z-r.x,r.x*r.z-r.y,r.y*r.z+r.x,r.z*r.z];return{t,x:a[0]*e.x+a[1]*e.y+a[2]*e.z,y:a[3]*e.x+a[4]*e.y+a[5]*e.z,z:a[6]*e.x+a[7]*e.y+a[8]*e.z}}hull(t){let e=this.points,n=[],o=[],i=0;for(o[i++]=e[0],o[i++]=e[1],o[i++]=e[2],3===this.order&&(o[i++]=e[3]);e.length>1;){n=[];for(let r,s=0,a=e.length-1;s<a;s++)r=S.lerp(t,e[s],e[s+1]),o[i++]=r,n.push(r);e=n}return o}split(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;const n=this.hull(t),o={left:2===this.order?new R([n[0],n[3],n[5]]):new R([n[0],n[4],n[7],n[9]]),right:2===this.order?new R([n[5],n[4],n[2]]):new R([n[9],n[8],n[6],n[3]]),span:n};return o.left._t1=S.map(0,0,1,this._t1,this._t2),o.left._t2=S.map(t,0,1,this._t1,this._t2),o.right._t1=S.map(t,0,1,this._t1,this._t2),o.right._t2=S.map(1,0,1,this._t1,this._t2),e?(e=S.map(e,t,1,0,1),o.right.split(e).left):o}extrema(){const t={};let e=[];return this.dims.forEach(function(n){let o=function(t){return t[n]},i=this.dpoints[0].map(o);t[n]=S.droots(i),3===this.order&&(i=this.dpoints[1].map(o),t[n]=t[n].concat(S.droots(i))),t[n]=t[n].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[n].sort(S.numberSort))}.bind(this)),t.values=e.sort(S.numberSort).filter((function(t,n){return e.indexOf(t)===n})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(n){e[n]=S.getminmax(this,n,t[n])}.bind(this)),e}overlaps(t){const e=this.bbox(),n=t.bbox();return S.bboxoverlap(e,n)}offset(t,e){if(void 0!==e){const n=this.get(t),o=this.normal(t),i={c:n,n:o,x:n.x+o.x*e,y:n.y+o.y*e};return this._3d&&(i.z=n.z+o.z*e),i}if(this._linear){const e=this.normal(0),n=this.points.map((function(n){const o={x:n.x+t*e.x,y:n.y+t*e.y};return n.z&&e.z&&(o.z=n.z+t*e.z),o}));return[new R(n)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=S.angle(this.points[0],this.points[3],this.points[1]),e=S.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let n=t.x*e.x+t.y*e.y;return this._3d&&(n+=t.z*e.z),C(M(n))<I/3}reduce(){let t,e,n=0,o=0,i=.01,r=[],s=[],a=this.extrema().values;for(-1===a.indexOf(0)&&(a=[0].concat(a)),-1===a.indexOf(1)&&a.push(1),n=a[0],t=1;t<a.length;t++)o=a[t],e=this.split(n,o),e._t1=n,e._t2=o,r.push(e),n=o;return r.forEach((function(t){for(n=0,o=0;o<=1;)for(o=n+i;o<=1.01;o+=i)if(e=t.split(n,o),!e.simple()){if(o-=i,C(n-o)<i)return[];e=t.split(n,o),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=S.map(o,0,1,t._t1,t._t2),s.push(e),n=o;break}n<1&&(e=t.split(n,1),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=t._t2,s.push(e))})),s}translate(t,e,n){n="number"==typeof n?n:e;const o=this.order;let i=this.points.map(((t,i)=>(1-i/o)*e+i/o*n));return new R(this.points.map(((e,n)=>({x:e.x+t.x*i[n],y:e.y+t.y*i[n]}))))}scale(t){const e=this.order;let n=!1;if("function"==typeof t&&(n=t),n&&2===e)return this.raise().scale(n);const o=this.clockwise,i=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):t,n?n(1):t);const r=n?n(0):t,s=n?n(1):t,a=[this.offset(0,10),this.offset(1,10)],l=[],c=S.lli4(a[0],a[0].c,a[1],a[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const n=l[t*e]=S.copy(i[t*e]);n.x+=(t?s:r)*a[t].n.x,n.y+=(t?s:r)*a[t].n.y})),n?([0,1].forEach((function(r){if(2!==e||!r){var s=i[r+1],a={x:s.x-c.x,y:s.y-c.y},d=n?n((r+1)/e):t;n&&!o&&(d=-d);var h=_(a.x*a.x+a.y*a.y);a.x/=h,a.y/=h,l[r+1]={x:s.x+d*a.x,y:s.y+d*a.y}}})),new R(l)):([0,1].forEach((t=>{if(2===e&&t)return;const n=l[t*e],o=this.derivative(t),r={x:n.x+o.x,y:n.y+o.y};l[t+1]=S.lli4(n,r,c,i[t+1])})),new R(l))}outline(t,e,n,o){if(e=void 0===e?t:e,this._linear){const i=this.normal(0),r=this.points[0],s=this.points[this.points.length-1];let a,l,c;void 0===n&&(n=t,o=e),a={x:r.x+i.x*t,y:r.y+i.y*t},c={x:s.x+i.x*n,y:s.y+i.y*n},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const d=[a,l,c];a={x:r.x-i.x*e,y:r.y-i.y*e},c={x:s.x-i.x*o,y:s.y-i.y*o},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const h=[c,l,a],u=S.makeline(h[2],d[0]),p=S.makeline(d[2],h[0]),f=[u,new R(d),p,new R(h)];return new T(f)}const i=this.reduce(),r=i.length,s=[];let a,l=[],c=0,d=this.length();const h=void 0!==n&&void 0!==o;function u(t,e,n,o,i){return function(r){const s=o/n,a=(o+i)/n,l=e-t;return S.map(r,0,1,t+s*l,t+a*l)}}i.forEach((function(i){const r=i.length();h?(s.push(i.scale(u(t,n,d,c,r))),l.push(i.scale(u(-e,-o,d,c,r)))):(s.push(i.scale(t)),l.push(i.scale(-e))),c+=r})),l=l.map((function(t){return a=t.points,a[3]?t.points=[a[3],a[2],a[1],a[0]]:t.points=[a[2],a[1],a[0]],t})).reverse();const p=s[0].points[0],f=s[r-1].points[s[r-1].points.length-1],m=l[r-1].points[l[r-1].points.length-1],g=l[0].points[0],b=S.makeline(m,p),y=S.makeline(f,g),v=[b].concat(s).concat([y]).concat(l);return new T(v)}outlineshapes(t,e,n){e=e||t;const o=this.outline(t,e).curves,i=[];for(let t=1,e=o.length;t<e/2;t++){const r=S.makeshape(o[t],o[e-t],n);r.startcap.virtual=t>1,r.endcap.virtual=t<e/2-1,i.push(r)}return i}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof R&&(t=t.reduce()),this.curveintersects(this.reduce(),t,e)):this.selfintersects(e)}lineIntersects(t){const e=P(t.p1.x,t.p2.x),n=P(t.p1.y,t.p2.y),o=k(t.p1.x,t.p2.x),i=k(t.p1.y,t.p2.y);return S.roots(this.points,t).filter((t=>{var r=this.get(t);return S.between(r.x,e,o)&&S.between(r.y,n,i)}))}selfintersects(t){const e=this.reduce(),n=e.length-2,o=[];for(let i,r,s,a=0;a<n;a++)r=e.slice(a,a+1),s=e.slice(a+2),i=this.curveintersects(r,s,t),o.push(...i);return o}curveintersects(t,e,n){const o=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&o.push({left:t,right:e})}))}));let i=[];return o.forEach((function(t){const e=S.pairiteration(t.left,t.right,n);e.length>0&&(i=i.concat(e))})),i}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,n,o){const i=(o-n)/4,r=this.get(n+i),s=this.get(o-i),a=S.dist(t,e),l=S.dist(t,r),c=S.dist(t,s);return C(l-a)+C(c-a)}_iterate(t,e){let n,o=0,i=1;do{n=0,i=1;let r,s,a,l,c,d=this.get(o),h=!1,u=!1,p=i,f=1,m=0;do{if(u=h,l=a,p=(o+i)/2,m++,r=this.get(p),s=this.get(i),a=S.getccenter(d,r,s),a.interval={start:o,end:i},h=this._error(a,d,o,i)<=t,c=u&&!h,c||(f=i),h){if(i>=1){if(a.interval.end=f=1,l=a,i>1){let t={x:a.x+a.r*E(a.e),y:a.y+a.r*z(a.e)};a.e+=S.angle({x:a.x,y:a.y},t,this.get(1))}break}i+=(i-o)/2}else i=p}while(!c&&n++<100);if(n>=100)break;l=l||a,e.push(l),o=f}while(i<1);return e}};e.exports=s(a)}},n={};function o(t){var i=n[t];if(void 0!==i)return i.exports;var r=n[t]={id:t,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nc=void 0;var i=o(7783);window.jsdraw=i})();
|