js-draw 1.25.0 → 1.27.1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/dist/Editor.css +1 -1935
- package/dist/bundle.js +478 -4
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/Editor.d.ts +0 -2
- package/dist/cjs/Editor.js +1 -1
- package/dist/cjs/bundle/bundled.js +2 -1
- package/dist/cjs/components/AbstractComponent.d.ts +15 -0
- package/dist/cjs/components/AbstractComponent.js +16 -0
- package/dist/cjs/components/Stroke.d.ts +1 -0
- package/dist/cjs/components/Stroke.js +7 -0
- package/dist/cjs/image/EditorImage.d.ts +2 -1
- package/dist/cjs/image/EditorImage.js +21 -6
- package/dist/cjs/toolbar/AbstractToolbar.js +9 -2
- package/dist/cjs/toolbar/IconProvider.d.ts +2 -1
- package/dist/cjs/toolbar/IconProvider.js +18 -8
- package/dist/cjs/toolbar/localization.d.ts +2 -0
- package/dist/cjs/toolbar/localization.js +2 -0
- package/dist/cjs/toolbar/widgets/BaseWidget.js +6 -1
- package/dist/cjs/toolbar/widgets/HandToolWidget.js +3 -3
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.d.ts +7 -0
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +109 -28
- package/dist/cjs/toolbar/widgets/components/makeButtonGrid.d.ts +17 -0
- package/dist/cjs/toolbar/widgets/components/makeButtonGrid.js +40 -0
- package/dist/cjs/tools/SelectionTool/Selection.d.ts +2 -3
- package/dist/cjs/tools/SelectionTool/Selection.js +30 -46
- package/dist/cjs/tools/SelectionTool/SelectionBuilders/LassoSelectionBuilder.d.ts +17 -0
- package/dist/cjs/tools/SelectionTool/SelectionBuilders/LassoSelectionBuilder.js +67 -0
- package/dist/cjs/tools/SelectionTool/SelectionBuilders/RectSelectionBuilder.d.ts +13 -0
- package/dist/cjs/tools/SelectionTool/SelectionBuilders/RectSelectionBuilder.js +33 -0
- package/dist/cjs/tools/SelectionTool/SelectionBuilders/SelectionBuilder.d.ts +15 -0
- package/dist/cjs/tools/SelectionTool/SelectionBuilders/SelectionBuilder.js +39 -0
- package/dist/cjs/tools/SelectionTool/SelectionMenuShortcut.d.ts +3 -1
- package/dist/cjs/tools/SelectionTool/SelectionMenuShortcut.js +13 -4
- package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +10 -2
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +68 -55
- package/dist/cjs/tools/SelectionTool/types.d.ts +4 -0
- package/dist/cjs/tools/SelectionTool/types.js +6 -1
- package/dist/cjs/tools/TextTool.js +5 -2
- package/dist/cjs/tools/lib.d.ts +1 -1
- package/dist/cjs/tools/lib.js +2 -1
- package/dist/cjs/util/ReactiveValue.js +2 -6
- package/dist/cjs/util/assertions.d.ts +7 -6
- package/dist/cjs/util/assertions.js +35 -29
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/Editor.d.ts +0 -2
- package/dist/mjs/Editor.mjs +1 -1
- package/dist/mjs/bundle/bundled.mjs +2 -1
- package/dist/mjs/components/AbstractComponent.d.ts +15 -0
- package/dist/mjs/components/AbstractComponent.mjs +16 -0
- package/dist/mjs/components/Stroke.d.ts +1 -0
- package/dist/mjs/components/Stroke.mjs +7 -0
- package/dist/mjs/image/EditorImage.d.ts +2 -1
- package/dist/mjs/image/EditorImage.mjs +21 -6
- package/dist/mjs/toolbar/AbstractToolbar.mjs +9 -2
- package/dist/mjs/toolbar/IconProvider.d.ts +2 -1
- package/dist/mjs/toolbar/IconProvider.mjs +18 -8
- package/dist/mjs/toolbar/localization.d.ts +2 -0
- package/dist/mjs/toolbar/localization.mjs +2 -0
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +6 -1
- package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +3 -3
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.d.ts +7 -0
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +109 -28
- package/dist/mjs/toolbar/widgets/components/makeButtonGrid.d.ts +17 -0
- package/dist/mjs/toolbar/widgets/components/makeButtonGrid.mjs +35 -0
- package/dist/mjs/tools/SelectionTool/Selection.d.ts +2 -3
- package/dist/mjs/tools/SelectionTool/Selection.mjs +30 -46
- package/dist/mjs/tools/SelectionTool/SelectionBuilders/LassoSelectionBuilder.d.ts +17 -0
- package/dist/mjs/tools/SelectionTool/SelectionBuilders/LassoSelectionBuilder.mjs +61 -0
- package/dist/mjs/tools/SelectionTool/SelectionBuilders/RectSelectionBuilder.d.ts +13 -0
- package/dist/mjs/tools/SelectionTool/SelectionBuilders/RectSelectionBuilder.mjs +27 -0
- package/dist/mjs/tools/SelectionTool/SelectionBuilders/SelectionBuilder.d.ts +15 -0
- package/dist/mjs/tools/SelectionTool/SelectionBuilders/SelectionBuilder.mjs +36 -0
- package/dist/mjs/tools/SelectionTool/SelectionMenuShortcut.d.ts +3 -1
- package/dist/mjs/tools/SelectionTool/SelectionMenuShortcut.mjs +13 -4
- package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +10 -2
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +68 -55
- package/dist/mjs/tools/SelectionTool/types.d.ts +4 -0
- package/dist/mjs/tools/SelectionTool/types.mjs +5 -0
- package/dist/mjs/tools/TextTool.mjs +5 -2
- package/dist/mjs/tools/lib.d.ts +1 -1
- package/dist/mjs/tools/lib.mjs +1 -1
- package/dist/mjs/util/ReactiveValue.mjs +2 -6
- package/dist/mjs/util/assertions.d.ts +7 -6
- package/dist/mjs/util/assertions.mjs +28 -24
- package/dist/mjs/version.mjs +1 -1
- package/package.json +4 -4
- package/src/toolbar/EdgeToolbar.scss +6 -1
- package/src/toolbar/widgets/components/components.scss +1 -0
- package/src/toolbar/widgets/components/makeButtonGrid.scss +25 -0
- package/src/tools/SelectionTool/SelectionTool.scss +12 -1
- package/src/tools/util/createMenuOverlay.scss +5 -3
package/dist/bundle.js
CHANGED
@@ -1,9 +1,483 @@
|
|
1
|
-
(()=>{var e={9724:(t,e,o)=>{"use strict";o.d(e,{A:()=>a});var n=o(6758),i=o.n(n),r=o(935),s=o.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},5731:(t,e,o)=>{"use strict";o.d(e,{A:()=>a});var n=o(6758),i=o.n(n),r=o(935),s=o.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:100%;max-height:100%;display:block;margin-left:auto;margin-right:auto}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content .insert-image-image-status-view{display:flex;justify-content:space-between;padding-bottom:0}: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}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons{display:flex;justify-content:stretch;padding-top:0;padding-bottom:5px;direction:ltr}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>*{flex-grow:1;text-align:start;margin-inline-end:5px}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>* .icon{margin:0;margin-inline-start:4px;margin-inline-end:10px}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>:nth-child(1){direction:ltr}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>:last-child{direction:rtl}.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 .coloris_input{height:calc(100% - 6px)}.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>.color-input-wrapper{display:flex;justify-content:stretch}.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.-loading{opacity:.8}.toolbar-element .toolbar--file-input-container>input.file-input{opacity:0;width:0;min-width:0 !important;max-width:0;height:0;overflow:hidden;padding:0;margin: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 .cancel-button{padding-left:3px;padding-right:3px}.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;cursor:pointer;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)}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list{height:min(200px,50vh);position:relative;display:flex;align-items:center}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.scroller{display:flex;flex-direction:column;overflow-y:auto;scroll-snap-type:y mandatory;height:100%;width:100%;flex-grow:1}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.scroller>.item{height:100%;width:100%;flex-shrink:0;display:flex;justify-content:center;align-items:center;scroll-snap-align:start;scroll-snap-stop:always;box-sizing:border-box}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.-empty{display:none}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers{overflow:hidden;display:flex;flex-direction:column;align-items:center;max-height:100%;min-height:0}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers.-one-element{visibility:hidden}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers>.marker{padding:2px;opacity:.1;cursor:pointer;left:0;transition:left .2s ease}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers>.marker>.content{background-color:var(--foreground-color-1);border-radius:2px;padding:2px}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers>.marker.-active{position:relative;left:2px;opacity:.2}.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:sepia(0.2);opacity:.45;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;opacity:.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-element .toolbar--toggle-button{color:var(--foreground-color-1);font-weight:normal}.toolbar-element .toolbar--toggle-button[aria-checked=true]{background:var(--selection-background-color);color:var(--selection-foreground-color)}.toolbar-element .toolbar--toggle-button>.icon{width:25px;height:25px;margin:0 5px}.toolbar-element .toolbar--toggle-button>*{vertical-align:middle}.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 rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label-delayed{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes show-label-now{0%{opacity:0}5%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}@keyframes toolbar--edgemenu-transition-in{from{transform:translate(0, 100%)}to{transform:translate(0, 0)}}@keyframes toolbar--edgemenu-transition-in-reduce-motion{from{opacity:0}to{opacity:1}}@keyframes toolbar--edgemenu-transition-out{to{transform:translate(0, 100%)}}@keyframes toolbar--edgemenu-transition-out-reduce-motion{from{opacity:1}to{opacity:0}}@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}}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):hover:not(:focus-visible)>label,.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):active>label{opacity:.8;animation:1s ease show-label-delayed}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button.has-long-press-or-hover>label{opacity:.8}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:focus-visible>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);z-index:1;pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.3s 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:7px;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:7px;margin-left:0;width:22px}.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)}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):hover:not(:focus-visible)>label,.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):active>label{opacity:.8;animation:1s ease show-label-delayed}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button.has-long-press-or-hover>label{opacity:.8}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:focus-visible>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);z-index:1;pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.3s 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 .toolbar-toolContainer:not(.no-icon):not(.label-inline).dropdownVisible>.toolbar-button>label{opacity:.8;animation:1.5s ease rehide-label .3s,1s ease keep-label-hidden 1.8s infinite}.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:.15s ease-in-out background-color,.2s ease-in-out opacity}}.toolbar-edgemenu-container.dropdown-below-edge{overflow-y:hidden}.toolbar-edgemenu-container button{font-size:1.2em;box-shadow:none;border:none;padding:10px;transition:.2s ease box-shadow;font-weight:bold;color:var(--primary-action-foreground-color)}.toolbar-edgemenu-container button:not(:disabled):hover{box-shadow:0 1px 2px var(--shadow-color)}.toolbar-edgemenu-container button:disabled{opacity:.5;font-weight:unset;cursor:unset;color:var(--foreground-color-1)}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button{--button-label-hover-offset-y: var(--button-size)}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):hover:not(:focus-visible)>label>.button-label-text,.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):active>label>.button-label-text{opacity:.8;animation:1s ease show-label-delayed}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button.has-long-press-or-hover>label>.button-label-text{opacity:.8}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:focus-visible>label>.button-label-text,.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);z-index:1;pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.3s 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-help-overlay-button{align-items:last baseline}.toolbar-edgemenu-container .toolbar-edgemenu{--toolbar-button-height: 48px;touch-action:none;user-select:none;-webkit-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;-webkit-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:first-child{margin-top:0}.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}.toolbar-help-overlay{width:100%;height:100%;max-width:none;max-height:none;border:none;margin:0;padding:0;z-index:5;touch-action:none;overflow:hidden;color:#fff;--icon-color: white;background-color:rgba(0,0,0,0);display:flex;flex-direction:column;transition:.3s ease transform}.toolbar-help-overlay::backdrop{background-color:rgba(0,0,0,.8);backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px)}.toolbar-help-overlay,.toolbar-help-overlay::backdrop{animation:.25s ease transition-in}@keyframes transition-in{0%{opacity:0}100%{opacity:1}}@keyframes transition-out{0%{opacity:1}100%{opacity:0}}.toolbar-help-overlay.-hiding,.toolbar-help-overlay.-hiding::backdrop{animation:.25s ease transition-out;opacity:0}.toolbar-help-overlay.-dragging{transition:none}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay{transition:none}}@media screen and (min-width: 800px){.toolbar-help-overlay>.navigation-buttons{order:1;margin-top:auto}}.toolbar-help-overlay .with-text-shadow,.toolbar-help-overlay .help-page-container>.label,.toolbar-help-overlay button{text-shadow:0 0 3px rgba(20,20,20,.9);filter:drop-shadow(0px 0px 2px rgba(0, 0, 0, 0.5))}.toolbar-help-overlay button:not(:disabled){cursor:pointer}.toolbar-help-overlay button{background:rgba(0,0,0,0);border:none;color:var(--help-overlay-foreground);border-radius:15px}.toolbar-help-overlay .close-button{align-self:flex-start;width:48px;height:48px;z-index:1}.toolbar-help-overlay .close-button>svg{width:100%}.toolbar-help-overlay .navigation-content{flex-grow:1;display:flex}.toolbar-help-overlay .help-page-container{display:flex;align-items:center;flex-grow:1;touch-action:none}.toolbar-help-overlay .help-page-container>.label{flex-grow:1;text-align:center;font-size:18.5pt;margin-left:15px;margin-right:15px;margin-top:0px;z-index:1;transition:.5s ease margin-top}.toolbar-help-overlay .help-page-container>.label.-large-space-below{margin-top:0;margin-bottom:auto}.toolbar-help-overlay .help-page-container>.label.-small-space-above{margin-top:40px;margin-bottom:auto}.toolbar-help-overlay .help-page-container>.label.-large-space-above{margin-top:auto;margin-bottom:10px}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay .help-page-container>.label{transition:none}}.toolbar-help-overlay .help-page-container>.cloned-element-container{position:absolute;z-index:0;user-select:none;-webkit-user-select:none;border-radius:10px;opacity:.01;background-color:rgba(100,100,100,.01);box-shadow:none;transition:.5s ease opacity,.5s ease background-color}.toolbar-help-overlay .help-page-container>.cloned-element-container *{pointer-events:none !important}.toolbar-help-overlay .help-page-container>.cloned-element-container>*{margin:0;opacity:.01 !important;transition:.3s ease opacity !important}.toolbar-help-overlay .help-page-container>.cloned-element-container:not(.-clickable) *{cursor:unset !important}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable,.toolbar-help-overlay .help-page-container>.cloned-element-container.-background{z-index:1;touch-action:none}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable{cursor:pointer;z-index:2}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable.has-long-press-or-hover{opacity:.5 !important}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable.has-long-press-or-hover,.toolbar-help-overlay .help-page-container>.cloned-element-container.-active{background-color:var(--background-color-1)}.toolbar-help-overlay .help-page-container>.cloned-element-container.-active{opacity:1;background-color:var(--background-color-1);box-shadow:0 0 3px rgba(100,100,100,.5)}.toolbar-help-overlay .help-page-container>.cloned-element-container.-active>*{opacity:1 !important}.toolbar-help-overlay .navigation-buttons{display:flex;flex-direction:row;justify-content:space-between;direction:ltr}.toolbar-help-overlay .navigation-buttons>button:disabled{opacity:.5}.toolbar-help-overlay .navigation-buttons>.next,.toolbar-help-overlay .navigation-buttons>.previous{font-size:1em;padding:10px;transition:.2s ease font-size;z-index:3}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay .navigation-buttons>.next,.toolbar-help-overlay .navigation-buttons>.previous{transition:none}}.toolbar-help-overlay .navigation-buttons:not(.-has-previous)>.next:not(:disabled){animation:.5s ease highlight-button .5s}@keyframes highlight-button{0%{transform:scale(1)}50%{transform:scale(1.2)}55%{transform:scale(1.2) rotate(2deg)}65%{transform:scale(1.2) rotate(-2deg)}100%{transform:scale(1)}}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay .navigation-buttons:not(.-has-previous)>.next:not(:disabled){animation:none}}.toolbar-help-overlay .navigation-buttons>.next::after{content:"❯";margin-left:3px}.toolbar-help-overlay .navigation-buttons>.previous::before{content:"❮";margin-right:3px}.toolbar-help-overlay .navigation-buttons.-has-next>.next{font-size:1.4em}.toolbar-help-overlay .navigation-buttons.-has-previous>.previous{font-size:1.4em}.toolbar-help-overlay .navigation-buttons.-highlight-next>.next,.toolbar-help-overlay .navigation-buttons.-highlight-previous>.previous{font-weight:bold;background-color:rgba(200,200,200,.1);font-size:1.4em}.toolbar-help-overlay .navigation-help{margin-top:1em;font-size:.7em}.toolbar-element .toolbar-help-overlay-button{height:0;position:relative;display:flex;justify-content:end}.toolbar-element .toolbar-help-overlay-button>.button{margin:0;padding:5px;padding-top:0;padding-bottom:0;box-shadow:none;text-align:center;opacity:.5}.toolbar-element .toolbar-help-overlay-button>.button>.icon{width:1.18em;height:1.18em;transition:.2s ease filter}.toolbar-element .toolbar-help-overlay-button>.button:focus-visible>.icon,.toolbar-element .toolbar-help-overlay-button>.button:hover>.icon{filter:drop-shadow(0px 0px 1px var(--shadow-color))}.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))}.clipboard-error-dialog details>summary{cursor:pointer}.clipboard-error-dialog details[open]{margin-bottom:12px}.clipboard-error-dialog textarea{width:100%;box-sizing:border-box}.selection-tool-selection-background{background-color:var(--selection-background-color);opacity:.5;overflow:visible}.selection-tool-handle{position:absolute;box-sizing:border-box;display:flex;align-items:center;justify-content:center;--max-size: 17px}.selection-tool-handle .selection-tool-content{border:1px solid var(--foreground-color-1);background:var(--background-color-1);box-sizing:border-box;max-width:var(--max-size);max-height:var(--max-size);width:100%;height:100%;display:flex;justify-content:center;align-items:center;padding:3px}.selection-tool-handle .selection-tool-content .icon{width:100%;height:100%}.selection-tool-handle.selection-tool-circle .selection-tool-content{border-radius:100%}.selection-tool-handle.selection-tool-rotate{--max-size: 28px;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:nwse-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:nesw-resize}.selection-tool-selection-menu>button{max-height:var(--vertical-offset);background-color:var(--background-color-1);font-size:14px;color:var(--foreground-color-1);border:.5px solid var(--foreground-color-1);border-radius:3px;padding:3px;opacity:.8;transition:.2s ease opacity}.selection-tool-selection-menu>button:hover,.selection-tool-selection-menu>button:focus-visible{background-color:var(--background-color-2);color:var(--foreground-color-2);cursor:pointer;opacity:1}.overlay.handleOverlay{touch-action:none;direction:ltr}.overlay.handleOverlay,.overlay.handleOverlay .selection-tool-selection-outer-container{height:0;overflow:visible}.overlay.handleOverlay .selection-tool-selection-inner-container{width:var(--editor-current-display-width-px);height:var(--editor-current-display-height-px);overflow:hidden;pointer-events:none}.overlay.handleOverlay .selection-tool-selection-inner-container>*{pointer-events:all}.overlay.handleOverlay .selection-tool-selection-inner-container.-empty{opacity:0}.overlay.handleOverlay .selection-tool-selection-inner-container.-hide-handles .selection-tool-handle{display:none}@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;user-select:none;-webkit-user-select:none}.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}@keyframes show-popup-menu-animation{from{opacity:0}to{opacity:1}}.editor-popup-menu{width:100%;height:100%;background-color:rgba(0,0,0,0);border:none;animation:var(--hide-menu-animation-timeout) ease show-popup-menu-animation;opacity:1;transition:var(--hide-menu-animation-timeout) ease opacity;overflow:hidden}.editor-popup-menu.-hide{opacity:0}.editor-popup-menu>.content{position:absolute;left:var(--anchor-x);top:var(--anchor-y);display:flex;flex-direction:column;overflow:clip;border-radius:6px;box-shadow:0px 1px 2px var(--shadow-color)}.editor-popup-menu::backdrop{background:rgba(0,0,0,0)}.editor-popup-menu-option{display:flex;justify-content:start;cursor:pointer;padding:5px;padding-top:6px;padding-bottom:6px;background-color:var(--background-color-1);color:var(--foreground-color-1);--icon-color: currentColor;border:none;font-size:1em}.editor-popup-menu-option:hover,.editor-popup-menu-option:focus-visible{background-color:var(--background-color-2);color:var(--foreground-color-2)}.editor-popup-menu-option>:first-child{width:1em;height:1em;flex-shrink:0;margin-inline-start:0em;margin-inline-end:.25em}.about-dialog-content>.scroll{white-space:pre-wrap;font-family:monospace}.about-dialog-content>.scroll>details>summary{cursor:pointer}.about-dialog-content>.scroll>h2,.about-dialog-content>.scroll>details>summary{margin-top:15px;font-size:1.2em;font-weight:bold}.about-dialog-content>.scroll>h2 a,.about-dialog-content>.scroll>details>summary a{color:var(--foreground-color-1);text-decoration:underline}@keyframes fade-in{from{opacity:0}to{opacity:1}}.message-dialog-container dialog{display:flex}.message-dialog-container dialog.-closing{opacity:0}.message-dialog-container dialog.-closing::backdrop{opacity:0}.message-dialog-container dialog,.message-dialog-container dialog::backdrop{transition:opacity .2s ease;animation:fade-in .2s ease}.message-dialog-content{display:flex;flex-direction:column;flex-grow:1}.message-dialog-content>.close{display:block;margin-left:auto;margin-right:auto}.message-dialog-content>.scroll{flex-grow:1;flex-shrink:1;overflow-y:auto;margin-left:20px;margin-right:20px;padding-bottom:20px}.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}.dialog-container>dialog::backdrop{backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px);background-color:var(--background-color-transparent)}#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;writing-mode:horizontal-tb;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;user-select:none;-webkit-user-select:none;-webkit-user-drag:none}.imageEditorContainer .loadingMessage{position:fixed;text-align:center;font-size:2em;text-shadow:0px 0px 1px var(--background-color-1);bottom:0;left:0;right:0}.imageEditorContainer .accessibilityAnnouncement{opacity:0;width:0;height:0;overflow:hidden;pointer-events:none;user-select:none;-webkit-user-select:none}.imageEditorContainer .textRendererOutputContainer{width:.001px;height:.001px;overflow:hidden;-webkit-user-select:none;user-select:none}.imageEditorContainer .textRendererOutputContainer:focus-within{overflow:visible;z-index:5}.imageEditorContainer .anchored-element-overlay{overflow:visible;height:0}.imageEditorContainer .anchored-element-overlay>.content-wrapper{width:var(--editor-current-display-width-px);height:var(--editor-current-display-height-px);overflow:hidden;position:relative;pointer-events:none}.imageEditorContainer .anchored-element-overlay>.content-wrapper>.content{position:absolute;left:var(--position-x);top:var(--position-y);transform:scale(var(--scale)) rotate(var(--rotation));transform-origin:left top;margin:0;pointer-events:all}@media print{.imageEditorContainer .loadingMessage{display:none}.imageEditorContainer .imageEditorRenderArea canvas{width:100%;height:initial}}',""]);const a=s},935:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var o="",n=void 0!==e[5];return e[4]&&(o+="@supports (".concat(e[4],") {")),e[2]&&(o+="@media ".concat(e[2]," {")),n&&(o+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),o+=t(e),n&&(o+="}"),e[2]&&(o+="}"),e[4]&&(o+="}"),o})).join("")},e.i=function(t,o,n,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(n)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]);n&&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),o&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=o):d[2]=o),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),e.push(d))}},e}},6758:t=>{"use strict";t.exports=function(t){return t[1]}},2591:t=>{"use strict";var e=[];function o(t){for(var o=-1,n=0;n<e.length;n++)if(e[n].identifier===t){o=n;break}return o}function n(t,n){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=n.base?l[0]+n.base:l[0],d=r[c]||0,h="".concat(c," ").concat(d);r[c]=d+1;var u=o(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,n);n.byIndex=a,e.splice(a,0,{identifier:h,updater:f,references:1})}s.push(h)}return s}function i(t,e){var o=e.domAPI(e);o.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;o.update(t=e)}else o.remove()}}t.exports=function(t,i){var r=n(t=t||[],i=i||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=o(r[s]);e[a].references--}for(var l=n(t,i),c=0;c<r.length;c++){var d=o(r[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}r=l}}},8128:t=>{"use strict";var e={};t.exports=function(t,o){var n=function(t){if(void 0===e[t]){var o=document.querySelector(t);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(t){o=null}e[t]=o}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(o)}},3051:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},855:(t,e,o)=>{"use strict";t.exports=function(t){var e=o.nc;e&&t.setAttribute("nonce",e)}},1740:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(o){!function(t,e,o){var n="";o.supports&&(n+="@supports (".concat(o.supports,") {")),o.media&&(n+="@media ".concat(o.media," {"));var i=void 0!==o.layer;i&&(n+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),n+=o.css,i&&(n+="}"),o.media&&(n+="}"),o.supports&&(n+="}");var r=o.sourceMap;r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,o)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},3656: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))}}},3954:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);return r(e,t),e}),a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Editor=void 0;const l=a(o(7)),c=a(o(4641)),d=o(2018),h=o(7394),u=a(o(1721)),p=a(o(4093)),f=a(o(9118)),m=o(5379),g=s(o(1606)),b=a(o(3604)),y=a(o(578)),v=a(o(2543)),x=a(o(6975)),w=a(o(8748)),S=a(o(6398)),T=a(o(2717)),C=a(o(1172)),P=a(o(6188)),k=s(o(2115)),E=a(o(4433)),z=a(o(5577)),M=a(o(1083)),_=a(o(4212)),I=a(o(2832)),R=a(o(4690)),B=a(o(5711)),O=o(9261),L=s(o(7988)),D=a(o(410)),A=a(o(3718)),j=a(o(9988)),V=a(o(272));class F{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??g.RenderingMode.CanvasRenderer,localization:this.localization,minZoom:e.minZoom??2e-10,maxZoom:e.maxZoom??1e12,keyboardShortcutOverrides:e.keyboardShortcutOverrides??{},iconProvider:e.iconProvider??new x.default,notices:e.notices??[],appInfo:e.appInfo?{...e.appInfo}:null,pens:{additionalPenTypes:e.pens?.additionalPenTypes??[],filterPenTypes:e.pens?.filterPenTypes??(()=>!0)},text:{fonts:e.text?.fonts??["sans-serif","serif","monospace"]},image:{showImagePicker:e.image?.showImagePicker??void 0},clipboardApi:e.clipboardApi??null},this.settings.minZoom>this.settings.maxZoom)throw new Error("Minimum zoom must be lesser than maximum zoom!");this.readOnly=L.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 f.default,this.viewport=new p.default(((t,e)=>{this.notifier.dispatch(d.EditorEventType.ViewportChanged,{kind:d.EditorEventType.ViewportChanged,newTransform:e,oldTransform:t})})),this.display=new g.default(this,this.settings.renderingMode,this.renderingRegion),this.image=new l.default,this.history=new u.default(this,this.announceRedoCallback,this.announceUndoCallback),this.toolController=new c.default(this,this.localization),this.toolController.addInputMapper(_.default.fromEditor(this)),this.toolController.addInputMapper(new V.default),t.appendChild(this.container),this.viewport.updateScreenSize(m.Vec2.of(this.display.width,this.display.height)),this.registerListeners(),this.queueRerender(),this.hideLoadingWarning(),this.notifier.on(d.EditorEventType.ViewportChanged,(t=>{if(t.kind!==d.EditorEventType.ViewportChanged)return;const e=t=>t.transformVec3(m.Vec2.unitX).length(),o=e(t.newTransform);if(o>this.settings.maxZoom||o<this.settings.minZoom){const o=e(t.oldTransform);let n=m.Mat33.identity;n=o<=this.settings.maxZoom&&o>=this.settings.minZoom?t.oldTransform:m.Mat33.scaling2D((this.settings.minZoom+this.settings.maxZoom)/2),this.viewport.resetTransform(n)}else isFinite(o)||(console.warn(`Non-finite zoom (${o}) detected. Resetting the viewport. This was likely caused by division by zero.`),isFinite(e(t.oldTransform))?this.viewport.resetTransform(t.oldTransform):this.viewport.resetTransform())}))}getCurrentSettings(){return{...this.settings}}getRootElement(){return this.container}getOutputBBoxInDOM(){return m.Rect2.of(this.renderingRegion.getBoundingClientRect())}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);const t=[this.renderingRegion,this.accessibilityAnnounceArea,this.accessibilityControlArea,this.loadingWarning];for(const e of t)e.addEventListener("drag",(t=>(t.preventDefault(),!1))),e.addEventListener("dragstart",(t=>(t.preventDefault(),!1)));this.container.addEventListener("wheel",(t=>{this.handleHTMLWheelEvent(t)}));const e=()=>{this.viewport.updateScreenSize(m.Vec2.of(this.display.width,this.display.height)),this.rerender(),this.updateEditorSizeVariables()};if("ResizeObserver"in window){const t=new ResizeObserver(e);t.observe(this.renderingRegion),t.observe(this.container)}else addEventListener("resize",e);this.accessibilityControlArea.addEventListener("input",(()=>{this.accessibilityControlArea.value=""}));const o=new j.default(this);document.addEventListener("copy",(async t=>{this.isEventSink(document.querySelector(":focus"))&&o.copy(t)})),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`)}handleHTMLWheelEvent(t){let e=m.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=m.Vec3.of(0,0,t.deltaY));const o=this.getOutputBBoxInDOM(),n=m.Vec2.of(t.clientX,t.clientY).minus(o.topLeft);return!!this.toolController.dispatchInputEvent({kind:h.InputEvtType.WheelEvt,delta:e,screenPos:n})&&(t.preventDefault(),!0)}getPointerList(){const t=performance.now(),e=[];for(const o in this.pointers){const n=2e3;this.pointers[o]&&t-this.pointers[o].timeStamp<n&&e.push(this.pointers[o])}return e}setPointerCapture(t,e){try{t.setPointerCapture(e)}catch(t){console.warn("Failed to setPointerCapture",t)}}releasePointerCapture(t,e){try{t.releasePointerCapture(e)}catch(t){console.warn("Failed to releasePointerCapture",t)}}handleHTMLPointerEvent(t,e){const o=this.renderingRegion,n=e.target??this.renderingRegion;if("pointerdown"===t){const t=y.default.ofEvent(e,!0,this.viewport,o);this.pointers[t.id]=t,this.setPointerCapture(n,t.id);const i={kind:h.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,o);if(t.down){const o=this.pointers[t.id];if(o){if(t.screenPos.distanceTo(o.screenPos)<2)return!1}this.pointers[t.id]=t,this.toolController.dispatchInputEvent({kind:h.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,o);return!!this.pointers[t.id]&&(this.pointers[t.id]=t,this.releasePointerCapture(n,t.id),this.toolController.dispatchInputEvent({kind:h.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 handleDrop(t){t.preventDefault(),await this.handlePaste(t)}async handlePaste(t){const e=document.querySelector(":focus")??t.target;if(this.isEventSink(e))return await new j.default(this).paste(t)}handlePointerEventsFrom(t,e,o){const n={touchstart:t=>{o&&!o("touchstart",t)||t.preventDefault()},contextmenu:t=>{o&&!o("contextmenu",t)||t.preventDefault()}},i=["pointerdown","pointermove","pointerup","pointercancel"];for(const t of i)n[t]=o=>{const n=o;if(!e||e(t,n))return this.handleHTMLPointerEvent(t,n)};for(const e in n)t.addEventListener(e,n[e]);return{remove:()=>{for(const e in n)t.removeEventListener(e,n[e])}}}handlePointerEventsExceptClicksFrom(t,e,o){const n=Object.create(null);return this.handlePointerEventsFrom(t,((o,i)=>{if(e&&!e(o,i))return!1;const r=m.Vec2.of(i.pageX??i.clientX,i.pageY??i.clientY),s=i.pointerId??0;let a=!0;if("pointerdown"===o)n[s]={eventBuffer:[[o,i]],startPoint:r,hasMovedSignificantly:!1},this.setPointerCapture(t,i.pointerId),a=!1;else if("pointermove"===o&&n[s]){const t=n[s].startPoint,e=n[s].eventBuffer,l=10;if(t&&r.distanceTo(t)<l&&!n[s].hasMovedSignificantly)e.push([o,i]),a=!1;else{for(const[t,o]of e)this.handleHTMLPointerEvent(t,o);n[s].eventBuffer=[],n[s].hasMovedSignificantly=!0,a=!0}}else"pointermove"===o?a=!0:("pointerup"===o||"pointercancel"===o)&&n[s]&&n[s].eventBuffer.length>0&&(this.releasePointerCapture(t,i.pointerId),a=!1,delete n[s]);return a}),o)}handleHTMLKeyDownEvent(t){console.assert("keydown"===t.type,`handling a keydown event with type ${t.type}`);const e=(0,h.keyPressEventFromHTMLEvent)(t);return this.toolController.dispatchInputEvent(e)?(t.preventDefault(),!0):"t"===e.key||"T"===e.key?(t.preventDefault(),this.display.rerenderAsText(),!0):"Escape"===e.key&&(this.renderingRegion.blur(),!0)}handleHTMLKeyUpEvent(t){console.assert("keyup"===t.type,`Handling a keyup event with type ${t.type}`);const e=(0,h.keyUpEventFromHTMLEvent)(t);return!!this.toolController.dispatchInputEvent(e)&&(t.preventDefault(),!0)}handleKeyEventsFrom(t,e=(()=>!0)){(0,D.default)(t,{filter:e,handleKeyDown:t=>{this.handleHTMLKeyDownEvent(t)},handleKeyUp:t=>{this.handleHTMLKeyUpEvent(t)},getHandlesKeyEventsFrom:t=>this.eventListenerTargets.includes(t)}),t.ondragover=t=>{t.preventDefault()},t.ondrop=t=>{this.handleDrop(t)},this.eventListenerTargets.push(t)}setReadOnly(t){t!==this.readOnly.get()&&(this.readOnly.set(t),this.notifier.dispatch(d.EditorEventType.ReadOnlyModeToggled,{kind:d.EditorEventType.ReadOnlyModeToggled,editorIsReadOnly:t}))}isReadOnlyReactiveValue(){return this.readOnly}isReadOnly(){return this.readOnly}dispatch(t,e=!0){const o=this.dispatchNoAnnounce(t,e),n=t.description(this,this.localization);return this.announceForAccessibility(n),o}dispatchNoAnnounce(t,e=!1){const o=t.apply(this);if(e){const e=!1;this.history.push(t,e)}return o}async asyncApplyOrUnapplyCommands(t,e,o){console.assert(o>0),this.display.setDraftMode(!0);for(let n=0;n<t.length;n+=o){this.showLoadingWarning(n/t.length);for(let i=n;i<t.length&&i<n+o;i++){const o=t[i];e?o.apply(this):o.unapply(this)}n+o<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,o=!1){return o&&(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:m.Color4.fromHex("#44444455")},o=5*this.viewport.getSizeOfPixelOnCanvas();e.drawRect(this.getImportExportRect(),o,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()}}anchorElementToCanvas(t,e){e instanceof m.Mat33&&(e=L.default.fromImmutable(e));const o=document.createElement("div");o.classList.add("anchored-element-overlay");const n=document.createElement("div");n.classList.add("content-wrapper"),t.classList.add("content");const i=()=>{const t=e.get().transformVec3(m.Vec2.unitX).angle()+this.viewport.getRotationAngle(),n=this.viewport.canvasToScreenTransform.rightMul(e.get());o.style.setProperty("--full-transform",n.toCSSMatrix());const i=n.transformVec2(m.Vec2.zero);o.style.setProperty("--position-x",`${i.x}px`),o.style.setProperty("--position-y",`${i.y}px`),o.style.setProperty("--rotation",180*t/Math.PI+"deg"),o.style.setProperty("--scale",`${n.getScaleFactor()}`)};i();const r=e.onUpdate(i),s=this.notifier.on(d.EditorEventType.ViewportChanged,i);return n.appendChild(t),o.appendChild(n),o.classList.add("overlay","js-draw-editor-overlay"),this.renderingRegion.insertAdjacentElement("afterend",o),{remove:()=>{o.remove(),r.remove(),s.remove()}}}addStyleSheet(t){const e=document.createElement("style");return e.innerText=t,this.container.appendChild(e),e}sendKeyboardEvent(t,e,o=!1,n=!1,i=void 0){i??=e.toUpperCase()===e&&e.toLowerCase()!==e,this.toolController.dispatchInputEvent({kind:t,key:e,code:(0,I.default)(e),ctrlKey:o,altKey:n,shiftKey:i})}sendPenEvent(t,e,o){(0,E.default)(this,t,e,o)}async addAndCenterComponents(t,e=!0,o){let n=null;for(const e of t)n=n?n.union(e.getBBox()):e.getBBox();if(!n)return;const i=this.viewport.visibleRect,r=i.width/n.width,s=i.height/n.height;let a=r;(n.width*a>i.width||n.height*a>i.height)&&(a=s),a*=2/3,a=p.default.roundScaleRatio(a);const c=m.Mat33.translation(i.center.minus(n.center)).rightMul(m.Mat33.scaling2D(a,n.center)),d=[];for(const e of t)d.push(l.default.addElement(e)),d.push(e.transformBy(c));if(await this.dispatch((0,T.default)(d,{applyChunkSize:100,description:o}),!0),e)for(const e of this.toolController.getMatchingTools(C.default))e.setEnabled(!0),e.setSelection(t)}toDataURL(t="image/png",e){const{element:o,renderer:n}=w.default.fromViewport(this.image.getImportExportViewport(),{canvasSize:e});this.image.renderAll(n);return o.toDataURL(t)}toSVG(t){return(0,O.editorImageToSVGSync)(this.image,t??{})}async toSVGAsync(t={}){const e=t.pauseAfterCount??100;return await(0,O.editorImageToSVGAsync)(this.image,(async(o,n,i)=>{if(t.onProgress){if(!1===await t.onProgress(n,i))return!1}return n%e==0&&await(0,S.default)(),!0}),{minDimension:t.minDimension})}async loadFrom(t){this.showLoadingWarning(0),this.display.setDraftMode(!0);const e=this.image.getBackgroundComponents(),o=new P.default(e);await t.start((async t=>{await this.dispatchNoAnnounce(l.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&&this.dispatchNoAnnounce(this.image.setAutoresizeEnabled(e.autoresize),!1)})),this.image.getBackgroundComponents().length!==e.length&&await this.dispatchNoAnnounce(o),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}setBackgroundStyle(t){const e=this.getTopmostBackgroundComponent(),o=[];e&&o.push(new P.default([e]));const n=e?.getBackgroundType?.()??k.BackgroundType.None,i=e?.getStyle?.().color??m.Color4.transparent,r=this.image.getAutoresizeEnabled(),s=t.color&&n===k.BackgroundType.None?k.BackgroundType.SolidColor:n,a=t.type??s,c=t.color??i,d=t.autoresize??r;if(a!==k.BackgroundType.None){const t=new k.default(a,c);o.push(l.default.addElement(t))}return d!==r&&(o.push(this.image.setAutoresizeEnabled(d)),d||0!==this.image.getImportExportRect().maxDimension||o.push(this.image.setImportExportRect(this.image.getImportExportRect().resizedTo(m.Vec2.of(500,500))))),(0,T.default)(o)}setBackgroundColor(t){let e=this.getTopmostBackgroundComponent();if(e)return e.updateStyle({color:t});{const o=t.eq(m.Color4.transparent)?k.BackgroundType.None:k.BackgroundType.SolidColor;return e=new k.default(o,t),this.image.addElement(e)}}estimateBackgroundColor(){const t=[];for(const e of this.image.getBackgroundComponents())e instanceof k.default&&t.push(e.getStyle().color??m.Color4.transparent);return m.Color4.average(t)}getImportExportRect(){return this.image.getImportExportViewport().visibleRect}setImportExportRect(t){return this.image.setImportExportRect(t)}async loadFromSVG(t,e=!1){const o=b.default.fromString(t,e);await this.loadFrom(o)}showAboutDialog(){const t=this.icons.licenseInfo(),e=[];if(this.settings.appInfo){const t=[];this.settings.appInfo.version&&t.push(`v${this.settings.appInfo.version}`,""),this.settings.appInfo.description?t.push(this.settings.appInfo.description+"\n"):t.push(`js-draw v${B.default.number}`),e.push({heading:`${this.settings.appInfo.name}`,text:t.join("\n")})}else e.push({heading:"js-draw",text:`v${B.default.number}`});const o=this.viewport.getScreenRectSize();e.push({heading:this.localization.developerInformation,text:["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`," auto-resize: "+(this.image.getAutoresizeEnabled()?"enabled":"disabled"),` image size: ${this.getImportExportRect().w}x${this.getImportExportRect().h}`,` screen size: ${o.x}x${o.y}`,` device pixel ratio: ${this.display.getDevicePixelRatio()}`," cache:",` ${this.display.getCache().getDebugInfo().replace(/([\n])/g,"\n ")}`].join("\n"),minimized:!0}),e.push({heading:this.localization.softwareLibraries,text:[`This image editor is powered by js-draw v${B.default.number}.`,"","At runtime, js-draw uses"," - The Coloris color picker: https://github.com/mdbassit/Coloris"," - The bezier.js Bézier curve library: https://github.com/Pomax/bezierjs","","Both are licensed under the MIT license:","","","== Coloris ==",(0,A.default)("2021 Mohammed Bassit"),"","","== Bezier.js ==",(0,A.default)('2023 Mike "Pomax" Kamermans'),"","","== js-draw ==",(0,A.default)("2023-2024 Henry Heino"),""].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=F,e.default=F},9118:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.listeners={}}dispatch(t,e){const o=this.listeners[t];if(o)for(let t=0;t<o.length;t++)o[t](e)}on(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),{remove:()=>{const o=this.listeners[t];return this.off(t,e),o.length!==this.listeners[t].length}}}off(t,e){const o=this.listeners[t];o&&(this.listeners[t]=o.filter((t=>t!==e)))}}},578:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointerDevice=void 0;const n=o(5379);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,o,n,i,r,s,a){this.screenPos=t,this.canvasPos=e,this.pressure=o,this.isPrimary=n,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 o=this.screenPos.minus(t),i=n.Vec2.unitX.times(o.x),r=n.Vec2.unitY.times(o.y);let s;return s=o.dot(i)>o.dot(r)?i:r,s=s.plus(t),this.withScreenPosition(s,e)}withScreenPosition(t,e){const o=e.screenToCanvas(t);return this.withCanvasPosition(o,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 o=e.canvasToScreen(t);return new r(o,t,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(t,e,o,s){let a=n.Vec2.of(t.clientX,t.clientY);if(s){const t=s.getBoundingClientRect();a=a.minus(n.Vec2.of(t.left,t.top))}let l={mouse:i.PrimaryButtonMouse,pen:i.Pen,touch:i.Touch}[t.pointerType]??i.Other;l===i.Pen&&32&t.buttons&&(l=i.Eraser);const c=t.timeStamp,d=o.roundPoint(o.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,o,n=0,s=i.Pen,a=!0,l=null,c=null){const d=o.canvasToScreen(t);return c??=performance.now(),new r(d,t,l,a,e,s,n,c)}static ofScreenPoint(t,e,o,n=0,s=i.Pen,a=!0,l=null,c=null){const d=o.screenToCanvas(t);return c??=performance.now(),new r(t,d,l,a,e,s,n,c)}}e.default=r},3604:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);return r(e,t),e}),a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SVGLoaderLoadMethod=e.svgLoaderAutoresizeClassName=e.svgLoaderAttributeContainerID=e.svgStyleAttributesDataKey=e.svgAttributesDataKey=e.defaultSVGViewRect=void 0;const l=o(5379),c=s(o(2115)),d=a(o(4686)),h=a(o(2066)),u=a(o(67)),p=s(o(2170)),f=a(o(3405)),m=o(8258),g=o(1598),b=a(o(4482));var y;e.defaultSVGViewRect=new l.Rect2(0,0,500,500),e.svgAttributesDataKey="svgAttrs",e.svgStyleAttributesDataKey="svgStyleAttrs",e.svgLoaderAttributeContainerID="svgContainerID",e.svgLoaderAutoresizeClassName="js-draw--autoresize",function(t){t.IFrame="iframe",t.DOMParser="domparser"}(y||(e.SVGLoaderLoadMethod=y={}));const v=["stroke","fill","stroke-width"];class x{constructor(t,e,o){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=!o.sanitize,this.disableUnknownObjectWarnings=!!o.disableUnknownObjectWarnings}getStyle(t,e){let o,n=l.Color4.transparent;const i=t.getAttribute("fill")??(e?.fill||t.style?.fill);if(i)try{n=l.Color4.fromString(i)}catch{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=l.Color4.fromString(r);e.a>0&&(o={width:t,color:e})}catch(t){console.error("Error parsing stroke data:",t)}return{fill:n,stroke:o}}strokeDataFromElem(t){const e=[],o=t.getAttribute("d")??"",n=this.getStyle(t),i=o.split("M");let r=!0;for(const t of i){const o=/^[0-9., \t\n]+$/.exec(t);if(""!==t&&!o){const o=r?t:`M${t}`,i=l.Path.fromString(o),s=(0,m.pathToRenderable)(i,n);e.push(s)}r=!1}return e}attachUnrecognisedAttrs(t,o,n,i){if(this.storeUnknown){for(const r of o.getAttributeNames())n.has(r)||"style"===r&&i||t.attachLoadSaveData(e.svgAttributesDataKey,[r,o.getAttribute(r)]);if(i&&o.style)for(let n=0;n<o.style.length;n++){const r=o.style[n];""!==r&&r&&(i.has(r)||t.attachLoadSaveData(e.svgStyleAttributesDataKey,{key:r,value:o.style.getPropertyValue(r),priority:o.style.getPropertyPriority(r)}))}}}async addPath(t){let e;try{const o=this.strokeDataFromElem(t);e=new h.default(o),this.attachUnrecognisedAttrs(e,t,new Set([...v,"d"]),new Set(v))}catch(o){if(console.error("Invalid path in node",t,"\nError:",o,"\nAdding as an unknown object."),!this.storeUnknown)return;e=new f.default(t)}await this.addComponent(e)}async addBackground(t){if(t.classList.contains(c.backgroundTypeToClassNameMap[c.BackgroundType.Grid])){let e,o,n,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];o=i.getAttribute("fill"),e=r.getAttribute("stroke"),n=r.getAttribute("stroke-width")}else o=t.getAttribute("fill"),e=t.getAttribute("stroke"),n=t.getAttribute("stroke-width");if(o??=l.Color4.transparent.toHexString(),!e)return void await this.addUnknownNode(t);for(const e of t.classList)if(e.startsWith(c.imageBackgroundGridSizeCSSPrefix)){const t=e.substring(c.imageBackgroundGridSizeCSSPrefix.length);i=parseFloat(t.replace(/p/g,"."))}n&&(r=parseFloat(n));const s=l.Color4.fromString(o);let a=l.Color4.fromString(e);t.classList.contains(c.imageBackgroundNonAutomaticSecondaryColorCSSClassName)||(a=void 0);const d=c.default.ofGrid(s,i,a,r);await this.addComponent(d)}else if("path"===t.tagName.toLowerCase()){const e=l.Color4.fromString(t.getAttribute("fill")??t.style.fill??"black"),o=new c.default(c.BackgroundType.SolidColor,e);await this.addComponent(o)}else await this.addUnknownNode(t)}getComputedStyle(t){try{return window.getComputedStyle(t)}catch(t){return void console.warn("Error computing style",t)}}getTransform(t,e,o){const n="data-highp-transform",i=t.getAttribute(n);let r;if(i)try{r=l.Mat33.fromCSSMatrix(i),e?.push(n)}catch(t){console.warn(`Unable to parse raw transform data, ${i}. Falling back to CSS data. Error:`,t)}if(!r){o??=this.getComputedStyle(t);let n=o?.transform;n&&"none"!==n||(n=t.style?.transform||"none");try{r=l.Mat33.fromCSSMatrix(t.style.transform)}catch(t){console.warn("matrix parse error",t),r=l.Mat33.fromCSSMatrix(n)}const i=t.getAttribute("x"),s=t.getAttribute("y");if(i||s){const t=parseFloat(i??"0"),o=parseFloat(s??"0");isNaN(t)||isNaN(o)||(e?.push("x","y"),r=r.rightMul(l.Mat33.translation(l.Vec2.of(t,o))))}}return r}makeText(t){const e=[];for(const o of t.childNodes)if(o.nodeType===Node.TEXT_NODE)e.push(o.nodeValue??"");else{if(o.nodeType!==Node.ELEMENT_NODE)throw new Error(`Unrecognized text child node: ${o}.`);{const t=o;if("tspan"!==t.tagName.toLowerCase())throw new Error(`Unrecognized text child element: ${t}`);e.push(this.makeText(t))}}0===e.length&&e.push("");const o=this.getComputedStyle(t),n=new Set(["fontFamily","transform",...v]),i={size:(0,b.default)(t,o,n),fontFamily:o?.fontFamily||t.style?.fontFamily||"sans-serif",fontWeight:o?.fontWeight||t.style?.fontWeight||void 0,fontStyle:o?.fontStyle||t.style?.fontStyle||void 0,renderingStyle:this.getStyle(t,o)},r=[];let s=this.getTransform(t,r,o),a=p.TextTransformMode.ABSOLUTE_XY;const c=t.getAttribute("dx");c&&(a=p.TextTransformMode.RELATIVE_X_ABSOLUTE_Y,s=s.rightMul(l.Mat33.translation(l.Vec2.of(parseFloat(c),0))),r.push("dx"));const d=t.getAttribute("dy");d&&(a=a===p.TextTransformMode.RELATIVE_X_ABSOLUTE_Y?p.TextTransformMode.RELATIVE_XY:p.TextTransformMode.RELATIVE_Y_ABSOLUTE_X,s=s.rightMul(l.Mat33.translation(l.Vec2.of(0,parseFloat(d)))),r.push("dy"));const h=new p.default(e,s,i,a);return this.attachUnrecognisedAttrs(h,t,new Set(r),new Set(n)),h}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 o=[],n=this.getTransform(t,o),i=await d.default.fromImage(e,n);this.attachUnrecognisedAttrs(i,t,new Set(o),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 f.default(t);await this.addComponent(e)}}async startGroup(t){let e=(t=t.cloneNode(!1)).id||`id-${this.encounteredIDs.length}`,o=0,n="";for(;this.encounteredIDs.includes(e+n);)o++,n="--"+o;e+=n,t.replaceChildren(),t.id=e;const i=new f.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 o=t.getAttribute("viewBox");if(this.rootViewBox||!o)return;const n=o.split(/[ \t\n,]+/),i=parseFloat(n[0]),r=parseFloat(n[1]),s=parseFloat(n[2]),a=parseFloat(n[3]);if(isNaN(i)||isNaN(r)||isNaN(s)||isNaN(a))return void console.warn(`node ${t} has an unparsable viewbox. Viewbox: ${o}. Match: ${n}.`);const c=t.classList.contains(e.svgLoaderAutoresizeClassName);this.rootViewBox=new l.Rect2(i,r,s,a),this.onDetermineExportRect?.(this.rootViewBox,{autoresize:c})}async updateSVGAttrs(t){this.storeUnknown&&await(this.onAddComponent?.(new u.default(this.getSourceAttrs(t))))}async visit(t){this.totalToProcess+=t.childElementCount;let e=!0;switch(t.tagName.toLowerCase()){case"g":t.classList.contains(c.imageBackgroundCSSClassName)?(await this.addBackground(t),e=!1):await this.startGroup(t);break;case"path":t.classList.contains(c.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":t.getAttribute("id")!==g.renderedStylesheetId&&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,o,n=null){this.onAddComponent=t,this.onProgress=o,this.onDetermineExportRect=n,this.totalToProcess=this.source.childElementCount,this.processedCount=0,this.rootViewBox=null,await this.visit(this.source);this.rootViewBox||this.onDetermineExportRect?.(e.defaultSVGViewRect),this.onFinish?.(),this.onFinish=null}static fromString(t,e=!1){const o="boolean"!=typeof e&&e?.loadMethod===y.DOMParser,{svgElem:n,cleanUp:i}=(()=>{if(!o)try{const e=document.createElement("iframe");if(e.src="about:blank",e.setAttribute("sandbox","allow-same-origin"),e.setAttribute("csp","default-src 'about:blank'"),e.style.display="none",document.body.appendChild(e),!e.hasAttribute("sandbox"))throw e.remove(),new Error("SVG loading iframe is not sandboxed.");const o=e.contentWindow?.document??e.contentDocument;if(null==o)throw new Error("Unable to open a sandboxed iframe!");o.open(),o.write("\n\t\t\t\t\t\t<!DOCTYPE html>\n\t\t\t\t\t\t<html>\n\t\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t\t<title>SVG Loading Sandbox</title>\n\t\t\t\t\t\t\t\t<meta name='viewport' conent='width=device-width,initial-scale=1.0'/>\n\t\t\t\t\t\t\t\t<meta charset='utf-8'/>\n\t\t\t\t\t\t\t</head>\n\t\t\t\t\t\t\t<body style='font-size: 12px;'>\n\t\t\t\t\t\t\t\t<script>\n\t\t\t\t\t\t\t\t\tconsole.error('JavaScript should not be able to run here!');\n\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\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\t\t\t);\n\t\t\t\t\t\t\t\t<\/script>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</html>\n\t\t\t\t\t"),o.close();const n=o.createElementNS("http://www.w3.org/2000/svg","svg");n.innerHTML=t,o.body.appendChild(n);const i=()=>{n.remove(),e.remove(),e.src=""};return{svgElem:n,cleanUp:i}}catch(t){console.warn("Failed loading SVG via a sandboxed iframe. Some styles may not be loaded correctly. Error: ",t)}const e=(new DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,"text/html"),n=e.querySelector("svg"),i=e.querySelector("parsererror");if(i)throw new Error("Parse error: "+i.textContent);return{svgElem:n,cleanUp:()=>{}}})();let r,s;return"boolean"==typeof e?(r=e,s=!1):(r=e.sanitize??!1,s=e.disableUnknownObjectWarnings??!1),new x(n,i,{sanitize:r,disableUnknownObjectWarnings:s})}}e.default=x},4482:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e,o)=>{const n=/^([-0-9.e]+)px/i;let i=n.exec(t.style?.fontSize??"");!i&&"tspan"===t.tagName.toLowerCase()&&t.parentElement&&(i=n.exec(t.parentElement.style?.fontSize??"")),!i&&e&&(i=n.exec(e.fontSize));let r=12;return i&&(o.add("fontSize"),r=parseFloat(i[1])),r}},1721:function(t,e,o){"use strict";var n,i,r=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},s=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const a=o(2018);n=new WeakMap,i=new WeakMap,e.default=class{constructor(t,e,o){this.editor=t,this.announceRedoCallback=e,this.announceUndoCallback=o,n.set(this,void 0),i.set(this,void 0),this.maxUndoRedoStackSize=700,r(this,n,[],"f"),r(this,i,[],"f")}fireUpdateEvent(t,e){this.editor.notifier.dispatch(a.EditorEventType.UndoRedoStackUpdated,{kind:a.EditorEventType.UndoRedoStackUpdated,undoStackSize:s(this,n,"f").length,redoStackSize:s(this,i,"f").length,command:e,stackUpdateType:t})}push(t,e=!0){e&&t.apply(this.editor),s(this,n,"f").push(t);for(const t of s(this,i,"f"))t.onDrop(this.editor);if(r(this,i,[],"f"),s(this,n,"f").length>this.maxUndoRedoStackSize){const t=Math.ceil(this.maxUndoRedoStackSize/100);s(this,n,"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,n,"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,n,"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,n,"f").length}get redoStackSize(){return s(this,i,"f").length}}},4093:function(t,e,o){"use strict";var n,i,r=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},s=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.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(o(1403)),c=o(5379);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),o=t=>{const o=1/h.getGridSize(e);return Math.round(t*o)/o};return c.Vec2.of(o(t.x),o(t.y))}getSizeOfPixelOnCanvas(){return 1/this.getScaleFactor()}getRotationAngle(){return this.transform.transformVec3(c.Vec3.unitX).angle()}static roundPoint(t,e){const o=10**Math.floor(Math.log10(e)),n=t=>Math.round(t/o)*o;return"number"==typeof t?n(t):t.map(n)}roundPoint(t){return h.roundPoint(t,1/this.getScaleFactor())}static roundScaleRatio(t,e=1){if(Math.abs(t)<=1e-12)return 0;const o=10**Math.floor(Math.log10(Math.abs(t))),n=2**e;return t=Math.round(t/o*n)/n*o}computeZoomToTransform(t,e=!0,o=!0){let n=c.Mat33.identity;if(0===t.w||0===t.h){let n=Math.max(t.w,t.h);0===n&&(n=50,e=!1,o=!1),t=new c.Rect2(t.x,t.y,n,n)}if(isNaN(t.size.magnitude()))throw new Error(`${t.toString()} rectangle has NaN size! Cannot zoom to!`);const i=()=>{const t=this.visibleRect.transformedBoundingBox(n.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&&o||a&&e){const e=Math.max(t.w/r.w,t.h/r.h),o=c.Mat33.scaling2D(e,r.topLeft).inverse();n=n.rightMul(o)}if(r=i(),!r.containsRect(t)){const e=t.center.minus(r.center),o=c.Mat33.translation(e).inverse();n=n.rightMul(o)}return n.invertable()||(console.warn("Unable to zoom to ",t,"! Computed transform",n,"is singular."),n=c.Mat33.identity),n}zoomTo(t,e=!0,o=!0){const n=this.computeZoomToTransform(t,e,o);return new h.ViewportTransform(n)}}e.Viewport=h,h.ViewportTransform=(i=class extends d{constructor(t){super(),this.transform=t,n.set(this,void 0),r(this,n,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,n,"f"))),t.queueRerender()}description(t,e){const o=[],n=t.viewport.visibleRect.center,i=this.transform.transformVec3(c.Vec2.unitX),r=this.transform.transformVec2(n),s=i.magnitude(),a=180/Math.PI*i.angle(),l=r.minus(n);s>1.2?o.push(e.zoomedIn):s<.8&&o.push(e.zoomedOut),Math.floor(Math.abs(a))>0&&o.push(e.rotatedBy(Math.round(a)));const d=1e-4;return l.x>d?o.push(e.movedLeft):l.x<-1e-4&&o.push(e.movedRight),l.y<-1e-4?o.push(e.movedDown):l.y>d&&o.push(e.movedUp),o.join("; ")}},n=new WeakMap,i),e.default=h},2728:function(t,e,o){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),i=this&&this.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),o(9435);const s=r(o(3954));i(o(6592),e),e.default=s.default},1403:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Command=void 0;class o{onDrop(t){}static union(t,e){return new class extends o{apply(o){t.apply(o),e.apply(o)}unapply(o){e.unapply(o),t.unapply(o)}description(o,n){const i=t.description(o,n),r=e.description(o,n);return i===r?i:`${i}, ${r}`}}}}e.Command=o,o.empty=new class extends o{description(t,e){return""}apply(t){}unapply(t){}},e.default=o},1247:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(3925)),r=n(o(6188)),s=n(o(1434));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 o=t.map((t=>e.image.lookupElement(t)));return new a(o)})),e.default=a},6188:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(3029)),r=n(o(3925)),s=n(o(7)),a=n(o(1434));class l extends a.default{constructor(t){super("erase"),this.toRemove=t.map((t=>t)),this.applied=!1}apply(t){for(const e of this.toRemove){const o=t.image.findParent(e);o&&(o.remove(),t.image.onDestroyElement(e))}this.applied=!0,t.queueRerender()}unapply(t){for(const e of this.toRemove)t.image.findParent(e)||s.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 o=(0,r.default)(e,this.toRemove)??e.elements;return e.eraseAction(o,this.toRemove.length)}serializeToJSON(){return this.toRemove.map((t=>t.serialize()))}}a.default.register("erase",((t,e)=>{if(!Array.isArray(t))throw new Error("seralized erase data must be an array");const o=t.map((t=>{const o="string"==typeof t?t:`${t.id}`;return e.image.lookupElement(o)??i.default.deserialize(t)}));return new l(o)})),e.default=l},1434:function(t,e,o){"use strict";var n,i=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},r=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.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(o(1403));class l extends a.default{constructor(t){if(super(),n.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,n,t,"f")}serialize(){return{data:this.serializeToJSON(),commandType:r(this,n,"f")}}static deserialize(t,e){const o="string"==typeof t?JSON.parse(t):t,n=o.commandType;if(!(n in l.deserializationCallbacks))throw new Error(`Unrecognised command type ${n}!`);return l.deserializationCallbacks[n](o.data,e)}static register(t,e){l.deserializationCallbacks[t]=e}}n=new WeakMap,l.deserializationCallbacks={},e.default=l},5922:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(1434));class r extends i.default{constructor(t,e,o){super(t),this.component=o??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},8567:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(1403)),r=n(o(1434)),s=t=>{if(t instanceof r.default)return new class extends r.default{constructor(){super(...arguments),this._command=t}serializeToJSON(){return t.serialize()}apply(e){t.unapply(e)}unapply(e){t.apply(e)}onDrop(e){t.onDrop(e)}description(e,o){return o.inverseOf(t.description(e,o))}}("inverse");return new class extends i.default{apply(e){t.unapply(e)}unapply(e){t.apply(e)}onDrop(e){t.onDrop(e)}description(e,o){return o.inverseOf(t.description(e,o))}}};r.default.register("inverse",((t,e)=>s(r.default.deserialize(t,e)))),e.default=s},525:function(t,e,o){"use strict";var n=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=n(o(1403));e.Command=i.default;const r=n(o(1247));e.Duplicate=r.default;const s=n(o(6188));e.Erase=s.default;const a=n(o(8567));e.invertCommand=a.default;const l=n(o(1434));e.SerializableCommand=l.default;const c=n(o(2717));e.uniteCommands=c.default},9985:(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",andNMoreCommands:t=>`And ${t} more commands.`,selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`}},2717:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(9713)),r=n(o(1403)),s=n(o(1434));class a extends r.default{constructor(t,e,o){super(),this.commands=t,this.applyChunkSize=e,this.descriptionOverride=o}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 o=e.map((e=>e.unapply(t)));return(0,i.default)(o)}return t.asyncUnapplyCommands(e,this.applyChunkSize,!1)}onDrop(t){this.commands.forEach((e=>e.onDrop(t)))}description(t,e){if(this.descriptionOverride)return this.descriptionOverride;const o=[];let n=null,i=0,r=0;for(const s of this.commands){const a=s.description(t,e);a!==n&&null!==n&&(o.push(e.unionOf(n,i)),n=null,i=0),i++,r++,n??=a;const l=12;if(o.length>l)break}return i>1?o.push(e.unionOf(n,i)):1===i&&o.push(n),r<this.commands.length&&o.push(e.andNMoreCommands(this.commands.length-r)),o.join(", ")}}class l extends s.default{constructor(t,e,o){super("union"),this.commands=t,this.applyChunkSize=e,this.descriptionOverride=o,this.nonserializableCommand=new a(t,e,o)}serializeToJSON(){return this.serializedData?this.serializedData:{applyChunkSize:this.applyChunkSize,data:this.commands.map((t=>t.serialize())),description:this.descriptionOverride}}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 o,n,i=!0;for(const e of t)if(!(e instanceof s.default)){i=!1;break}if("number"==typeof e?o=e:(o=e?.applyChunkSize,n=e?.description),i){return new l(t,o,n)}return new a(t,o,n)};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 o=t.applyChunkSize;if("number"!=typeof o&&void 0!==o)throw new Error("serialized applyChunkSize is neither undefined nor a number.");const n="string"==typeof t.description?t.description:void 0,i=[];for(const o of t.data)i.push(s.default.deserialize(o,e));return c(i,{applyChunkSize:o,description:n})})),e.default=c},3029:function(t,e,o){"use strict";var n,i=this&&this.__setFunctionName||function(t,e,o){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:o?"".concat(o," ",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(o(1434)),a=r(o(7)),l=o(5379),c=r(o(5922));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}occludesEverythingBelowWhenRenderedInRect(t){return!1}onAddToImage(t){}onRemoveFromImage(){}intersectsRect(t){if(t.containsRect(this.getExactBBox()))return!0;return t.getEdges().some((t=>this.intersects(t)))}isSelectable(){return!0}isBackground(){return!1}getProportionalRenderingTime(){return 1}transformBy(t){return new h.TransformElementCommand(t,this.getId(),this)}setZIndex(t){return new h.TransformElementCommand(l.Mat33.identity,this.getId(),this,t)}setZIndexAndTransformBy(t,e,o){return new h.TransformElementCommand(t,this.getId(),this,e,o)}clone(){const t=this.createClone();for(const e in this.loadSaveData)for(const o of this.loadSaveData[e])t.attachLoadSaveData(e,o);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.id=t.id,isFinite(t.zIndex)&&(e.zIndex=t.zIndex,h.zIndexCounter=Math.max(h.zIndexCounter,e.zIndex+1)),e}}h.zIndexCounter=0,h.deserializationCallbacks={},h.transformElementCommandId="transform-element",h.TransformElementCommand=(i(n=class extends c.default{constructor(t,e,o,n,i){super(h.transformElementCommandId,e,o),this.affineTransfm=t,this.origZIndex=i,this.targetZIndex=n??h.zIndexCounter++,this.targetZIndex>=h.zIndexCounter&&(h.zIndexCounter=this.targetZIndex+1),o&&void 0===i&&(this.origZIndex=o.getZIndex())}resolveComponent(t){this.component||(super.resolveComponent(t),this.origZIndex??=this.component.getZIndex())}updateTransform(t,e,o){if(!this.component)throw new Error("this.component is undefined or null!");const n=t.image.findParent(this.component);let i=!1;n&&(n.remove(),i=!0),this.component.applyTransformation(e),this.component.zIndex=o,this.component.lastChangedTime=(new Date).getTime(),o>=h.zIndexCounter&&(h.zIndexCounter=o+1),i&&a.default.addElement(this.component).apply(t)}apply(t){this.resolveComponent(t.image),this.updateTransform(t,this.affineTransfm,this.targetZIndex),t.queueRerender()}unapply(t){this.resolveComponent(t.image),this.updateTransform(t,this.affineTransfm.inverse(),this.origZIndex),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 o=e.image.lookupElement(t.id)??void 0,n=new l.Mat33(...t.transfm),i=t.targetZIndex,r=t.origZIndex??void 0;return new h.TransformElementCommand(n,t.id,o,i,r)})),n),e.default=h},2115:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);return r(e,t),e}),a=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 l=o(7),c=o(5379),d=s(o(3029)),h=o(486),u=a(o(4093)),p=o(8258);var f;!function(t){t[t.SolidColor=0]="SolidColor",t[t.Grid=1]="Grid",t[t.None=2]="None"}(f||(e.BackgroundType=f={})),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={[f.Grid]:"js-draw-image-background-grid",[f.SolidColor]:e.imageBackgroundCSSClassName,[f.None]:""};class m extends d.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=u.default.getGridSize(2),this.gridStrokeWidth=.7,this.secondaryColor=null,this.isRestylableComponent=!0,this.contentBBox=c.Rect2.empty}static ofGrid(t,e,o,n){const i=new m(f.Grid,t);return void 0!==e&&(i.gridSize=e),void 0!==o&&(i.secondaryColor=o),void 0!==n&&(i.gridStrokeWidth=n),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===f.None&&(t=void 0),{color:t}}updateStyle(t){return(0,h.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){const o=t.color;o&&(this.mainColor=o,o.eq(c.Color4.transparent)&&this.backgroundType===f.SolidColor?this.backgroundType=f.None:this.backgroundType===f.None&&(this.backgroundType=f.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(l.EditorImageEventType.ExportViewportChanged,(()=>{this.recomputeBBox(t)})),this.autoresizeChangedListener=t.notifier.on(l.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 o=!1;this.contentBBox.eq(e)||(this.contentBBox=e,o||=!this.fillsScreen);const n=t.getAutoresizeEnabled();n!==this.fillsScreen&&(this.fillsScreen=n,o=!0),o&&t.queueRerenderOf(this)}generateGridPath(t){const e=this.getFullBoundingBox(t),o=(t?.intersection(e)??e).grownBy(this.gridStrokeWidth/2),n=t=>Math.floor(t/this.gridSize)*this.gridSize,i=t=>Math.ceil(t/this.gridSize)*this.gridSize,r=i(o.y),s=n(o.y+o.h),a=i(o.x),l=n(o.x+o.w),d=[],h=(s-r)/this.gridSize,u=(l-a)/this.gridSize;if(h>1e3||u>1e3)return c.Path.empty;const p=c.Vec2.of(o.x,r);for(let t=r;t<=s;t+=this.gridSize)d.push({kind:c.PathCommandType.MoveTo,point:c.Vec2.of(o.x,t)}),d.push({kind:c.PathCommandType.LineTo,point:c.Vec2.of(o.x+o.w,t)});for(let t=a;t<=l;t+=this.gridSize)d.push({kind:c.PathCommandType.MoveTo,point:c.Vec2.of(t,o.y)}),d.push({kind:c.PathCommandType.LineTo,point:c.Vec2.of(t,o.y+o.h)});return new c.Path(p,d)}getFullBoundingBox(t){return(this.fillsScreen?t:this.contentBBox)??this.contentBBox}render(t,o){if(this.backgroundType===f.None)return;const n=!o;this.fillsScreen&&(o??=t.getVisibleRect());const i=this.backgroundType===f.Grid,r=this.getFullBoundingBox(o);if(t.startObject(r,i),this.backgroundType===f.SolidColor||this.backgroundType===f.Grid){const e=o?.intersection(r);e?t.fillRect(e,this.mainColor):n&&t.fillRect(r,this.mainColor)}if(this.backgroundType===f.Grid){let e=this.secondaryColor;e??=c.Color4.ofRGBA(1-this.mainColor.r,1-this.mainColor.g,1-this.mainColor.b,.2),0===this.mainColor.a&&(e=c.Color4.ofRGBA(.5,.5,.5,.2));const n={fill:c.Color4.transparent,stroke:{width:this.gridStrokeWidth,color:e}};t.drawPath((0,p.pathToRenderable)(this.generateGridPath(o),n))}const s=e.backgroundTypeToClassNameMap[this.backgroundType],a=[e.imageBackgroundCSSClassName];if(s!==e.imageBackgroundCSSClassName){a.push(s);const t=(0,c.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?d.ComponentSizingMode.FillScreen:d.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===f.SolidColor)return t.filledBackgroundWithColor(this.mainColor.toString());if(this.backgroundType===f.None)return t.emptyBackground;if(this.backgroundType===f.Grid)return t.gridBackground;return this.backgroundType}createClone(){return new m(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 o=t.backgroundType;if(o!==f.None&&o!==f.Grid&&o!==f.SolidColor){return o}e=o;const n=c.Color4.fromHex(t.mainColor),i=t.secondaryColor?c.Color4.fromHex(t.secondaryColor):null,r=t.gridSize??void 0,s=t.gridStrokeWidth??void 0,a=new m(e,n);return a.secondaryColor=i,r&&(a.gridSize=r),s&&(a.gridStrokeWidth=s),a}}e.default=m,d.default.registerComponent("image-background",m.deserializeFromJSON)},4686:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=o(7571),s=n(o(3029)),a=n(o(8614));class l 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 o,n,i;await(0,a.default)(t),"number"==typeof t.width&&"number"==typeof t.height&&0!==t.width&&0!==t.height?(o=t.width,n=t.height):(o=t.clientWidth,n=t.clientHeight);let r=t.src??"";if(r.startsWith("data:image/"))i=new Image,i.src=r,i.width=o,i.height=n;else{const e=document.createElement("canvas");e.width=o,e.height=n;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 l({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 o of e)if(o.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 l({...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 o=new i.Mat33(...t.transform);return new l({image:e,base64Url:t.src,label:t.label,transform:o})}}e.default=l,s.default.registerComponent("image-component",l.deserializeFromJSON)},486:function(t,e,o){"use strict";var n=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=o(5379),r=n(o(1434)),s=n(o(5922)),a=o(196),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,o)=>new h(t,e,o.getId(),o);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,o,n){super(d,o,n),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 o=c(t.originalStyle),n=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(o,n,i)}))},67:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=o(5379),c=a(o(1598)),d=s(o(3029)),h="svg-global-attributes";class u extends d.default{constructor(t){super(h),this.contentBBox=l.Rect2.empty;const e=["viewBox","width","height"];this.attrs=t.filter((([t,o])=>!e.includes(t)))}render(t,e){if(t instanceof c.default)for(const[e,o]of this.attrs)t.setRootSVGAttribute(e,o)}intersects(t){return!1}applyTransformation(t){}isSelectable(){return!1}getSizingMode(){return d.ComponentSizingMode.Anywhere}createClone(){return new u(this.attrs)}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify(this.attrs)}static deserializeFromString(t){return new u([])}}e.default=u,d.default.registerComponent(h,u.deserializeFromString)},2066:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=o(8247),s=n(o(3029)),a=o(486),l=o(8258);class c extends s.default{constructor(t,e){super("stroke",e),this.isRestylableComponent=!0,this.simplifiedPath=null,this.approximateRenderingTime=0,this.parts=[];for(const e of t){const t=(0,l.pathFromRenderable)(e),o=this.bboxForPart(t.bbox,e.style);this.contentBBox?this.contentBBox=this.contentBBox.union(o):this.contentBBox=o,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 o={...e.style,stroke:e.style.stroke?{...e.style.stroke}:void 0};return o.stroke&&o.stroke.width>0?o.stroke.color=t.color:o.fill=t.color,{path:e.path,startPoint:e.startPoint,commands:e.commands,style:o}})),e&&(e.image.queueRerenderOf(this),e.queueRerender()))}withRegionErased(t,e){const o=t.polylineApproximation(),n=[];let r=!1;for(const s of this.parts){const a=s.path,d=t=>{if(s.style.fill.a>0){if(t.parts.length<1||1===t.parts.length&&t.parts[0].kind===i.PathCommandType.LineTo)return null;t=t.asClosed()}return isNaN(t.getExactBBox().area)?(console.warn("Prevented creating a stroke with NaN area"),r=!0,null):new c([(0,l.pathToRenderable)(t,s.style)],this.getZIndex())},h=[];for(const t of o)h.push(...a.intersection(t));let u=!1;if(0===h.length&&s.style.stroke&&s.style.stroke.width>.3*t.bbox.minDimension&&s.style.stroke.width<30*t.bbox.maxDimension){for(const t of o)h.push(...a.intersection(t,s.style.stroke.width/2));u=!0}h.sort(i.comparePathIndices);let p=(()=>{if(0===h.length)return!1;if(u)return 0===h[0].curveIndex&&h[0].parameterValue<=0;const e=(0,i.stepPathIndexBy)(h[0],-1e-10);return o=a.at(e),t.closedContainsPoint(o);var o})()?1:0;const f=(e,o)=>{const i=d(e);let s=p%2==1;p++,void 0!==o&&(s=o),void 0===o&&!s&&t.closedContainsPoint(e.getExactBBox().center)&&(s=!s),i&&(r||=s&&e.getExactBBox().maxDimension>2*t.getExactBBox().maxDimension,s||n.push(i))};if(0===s.style.fill.a){if(!(t.getExactBBox().maxDimension/10>a.getExactBBox().maxDimension)){const t=a.splitAt(h,{mapNewPoint:t=>e.roundPoint(t)});for(const e of t)f(e)}}else if(h.length>=2&&h.length%2==0){const t=a.splitAt(h,{mapNewPoint:t=>e.roundPoint(t)});for(let e=0;e<Math.floor(t.length/2);e++)f(t[e].union(t[t.length-e-1]).asClosed());t.length%2!=0&&f(t[Math.floor(t.length/2)].asClosed())}else f(a,!1)}return r?[this]:n}intersects(t){for(const e of this.parts){const o=e.style.stroke?.width,n=o?o/2:void 0;if(e.path.intersection(t,n).length>0)return!0}return!1}intersectsRect(t){if(!t.intersects(this.getBBox()))return!1;for(const e of this.parts){const o=t.grownBy(-(e.style.stroke?.width??0));if(0!==o.area)for(const t of e.path.startEndPoints())if(o.containsPoint(t))return!0}return super.intersectsRect(t)}computeSimplifiedPathFor(t){const e=[];let o=!1,n=!1;for(const i of this.parts){if(n||!i.style.stroke||i.style.stroke.color.a<.99){e.push(i);continue}const r=(0,l.simplifyPathToFullScreenOrEmpty)(i,t);r?(e.push(r.path),r.fullScreen&&(o=!0,n=!0)):e.push(i)}return{forVisibleRect:t,parts:e,occludes:o}}occludesEverythingBelowWhenRenderedInRect(t){return!!this.getBBox().containsRect(t)&&(this.simplifiedPath&&this.simplifiedPath.forVisibleRect.eq(t)||(this.simplifiedPath=this.computeSimplifiedPathFor(t)),this.simplifiedPath.occludes)}render(t,e){t.startObject(this.getBBox());let o=this.parts;e&&this.simplifiedPath?.forVisibleRect?.containsRect(e)?o=this.simplifiedPath.parts:this.simplifiedPath=null;for(const n of o){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:o}of this.parts){const n=this.bboxForPart(e.getExactBBox(),o);t??=n,t=t.union(n)}return t??i.Rect2.empty}applyTransformation(t){this.contentBBox=i.Rect2.empty;let e=!0;this.parts=this.parts.map((o=>{const n=o.path.transformedBy(t),i={...o.style,stroke:o.style.stroke?{...o.style.stroke}:void 0};if(i.stroke){const e=t.getScaleFactor();i.stroke.width*=e}const r=this.bboxForPart(n.bbox,i);return e?(this.contentBBox=r,e=!1):this.contentBBox=this.contentBBox.union(r),{path:n,startPoint:n.startPoint,commands:n.parts,style:i}}))}getParts(){return[...this.parts]}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)},2170:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.TextTransformMode=void 0;const i=o(5379),r=o(196),s=n(o(3029)),a=o(486),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={}));const d={fontFamily:"sans",size:12,renderingStyle:{fill:i.Color4.purple}};class h extends s.default{constructor(t,e,o=d,n=c.ABSOLUTE_XY){super(l),this.textObjects=t,this.transform=e,this.style=o,this.transformMode=n,this.isRestylableComponent=!0,this.recomputeBBox();!t.some((t=>"string"==typeof t))&&t.length>0&&(this.style=t[0].getTextStyle())}static applyTextStyles(t,e){const o=e.fontFamily.match(/\s/),n=e.fontFamily.match(/^".*"$/),i=o&&!n?`"${e.fontFamily.replace(/["]/g,'\\"')}"`:e.fontFamily;t.font=[e.fontStyle??"",e.fontWeight??"",(e.size??12)+"px",`${i}`].join(" "),t.textAlign="left"}static estimateTextDimens(t,e){const o=t.length*e.size,n=e.size;return new i.Rect2(0,2*-n/3,o,n)}static getTextMetrics(t,e){if(h.textMeasuringCtx??=document.createElement("canvas").getContext("2d")??null,!h.textMeasuringCtx)return null;const o=h.textMeasuringCtx;return h.applyTextStyles(o,e),o.measureText(t)}static getTextDimens(t,e){const o=this.getTextMetrics(t,e);if(!o)return this.estimateTextDimens(t,e);const n=-o.actualBoundingBoxAscent,r=o.actualBoundingBoxAscent+o.actualBoundingBoxDescent;return new i.Rect2(0,n,o.width,r)}static getFontHeight(t){return t.size}computeUntransformedBBoxOfPart(t){return"string"==typeof t?h.getTextDimens(t,this.style):t.contentBBox}recomputeBBox(){let t=null;const e=new h.TextCursor(this.transform,this.style);for(const o of this.textObjects){const n=e.update(o).transform,i=this.computeUntransformedBBoxOfPart(o).transformedBoundingBox(n);t??=i,t=t.union(i)}this.contentBBox=t??i.Rect2.empty}renderInternal(t,e,o=i.Mat33.identity){const n=new h.TextCursor(this.transform,this.style);for(const i of this.textObjects){const{transform:r,bbox:s}=n.update(i);e&&!e.intersects(s.transformedBoundingBox(o))||("string"==typeof i?t.drawText(i,r,this.style):(t.pushTransform(r),i.renderInternal(t,e,o.rightMul(r)),t.popTransform()))}}render(t,e){t.startObject(this.contentBBox),this.renderInternal(t,e),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(t){const e=new h.TextCursor(this.transform,this.style);for(const o of this.textObjects){const n=e.update(o).transform.inverse(),i=t.transformedBy(n);if("string"==typeof o){if(h.getTextDimens(o,this.style).getEdges().some((t=>null!==i.intersection(t))))return!0}else if(o.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 o of this.textObjects)o instanceof h&&o.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 h(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),o=t.textObjects.map((t=>null!==(t.text??null)?t.text:h.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 n=t.transform,s=new i.Mat33(...n);return new h(o,s,e)}static fromLines(t,e,o){let n=null;const r=[],s=Math.round(this.getFontHeight(o));let a=i.Vec2.zero;for(const e of t){n&&(a=a.plus(i.Vec2.unitY.times(s)));const t=new h([e],i.Mat33.translation(a),o);r.push(t),n=t}return new h(r,e,o)}}h.textMeasuringCtx=null,h.TextCursor=class{constructor(t=i.Mat33.identity,e){this.parentTransform=t,this.parentStyle=e,this.transform=i.Mat33.identity}update(t){let e,o=i.Mat33.identity,n=i.Mat33.identity;"string"==typeof t?e=h.getTextDimens(t,this.parentStyle):(n=t.transform,e=t.getBBox());const r="string"==typeof t?c.RELATIVE_XY:t.transformMode;if(r===c.RELATIVE_XY)o=this.transform.rightMul(o);else if(r===c.RELATIVE_X_ABSOLUTE_Y||r===c.RELATIVE_Y_ABSOLUTE_X){o=this.transform.mapEntries(((t,[e,o])=>{if(r===c.RELATIVE_X_ABSOLUTE_Y)return 1===e&&2===o?0:t;if(r===c.RELATIVE_Y_ABSOLUTE_X)return 0===e&&2===o?0:t;throw new Error("Unreachable")})).rightMul(o)}const s=i.Mat33.translation(i.Vec2.of(e.width,0));this.transform=o.rightMul(n).rightMul(s);const a=this.parentTransform.rightMul(o);return{transform:a,bbox:e.transformedBoundingBox(a)}}},e.default=h,s.default.registerComponent(l,(t=>h.deserializeFromString(t)))},3405:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=o(5379),c=a(o(1598)),d=s(o(3029)),h="unknown-svg-object";class u extends d.default{constructor(t){super(h),this.svgObject=t,this.contentBBox=l.Rect2.of(t.getBoundingClientRect())}render(t,e){t instanceof c.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 d.ComponentSizingMode.Anywhere}createClone(){return new u(this.svgObject.cloneNode(!0))}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify({html:this.svgObject.outerHTML})}}e.default=u,d.default.registerComponent(h,null)},8145:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeArrowBuilder=void 0;const i=o(5379),r=n(o(2066)),s=n(o(8091));e.makeArrowBuilder=(0,s.default)(((t,e)=>new a(t,e)));class a{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,o=e.minus(t).normalized(),n=e.distanceTo(t),s=Math.min(this.getLineWidth(),n/2),a=this.startPoint.width/2,l=this.endPoint.width/2,c=e.minus(o.times(s)),d=o.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(o.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=a},22:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedCircleBuilder=void 0;const i=o(5379),r=o(8258),s=n(o(4093)),a=n(o(2066)),l=n(o(8091));e.makeOutlinedCircleBuilder=(0,l.default)(((t,e)=>new c(t,e)));class c{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,o=s.default.roundPoint(this.endPoint.width,5/this.viewport.getScaleFactor()),n=this.startPoint.pos.lerp(this.endPoint.pos,.5),l=this.endPoint.pos.minus(n).length()-o/2,c=n.plus(i.Vec2.of(l,0));for(let o=e;o<=2*Math.PI;o+=e){const r=i.Vec2.of(l*Math.cos(o),-l*Math.sin(o)).plus(n),s=1.141,a=i.Vec2.of(Math.cos(o-e/2),-Math.sin(o-e/2)).times(l*s).plus(n);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:o,color:this.endPoint.color}})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}},9177:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeFreehandLineBuilder=void 0;const i=o(5379),r=n(o(2066)),s=n(o(4093)),a=o(780),l=n(o(3172));e.makeFreehandLineBuilder=(0,l.default)(((t,e)=>{const o=3*e.getSizeOfPixelOnCanvas(),n=e.getSizeOfPixelOnCanvas();return new c(t,n,o,e)}));class c{constructor(t,e,o,n){this.startPoint=t,this.minFitAllowed=e,this.viewport=n,this.isFirstSegment=!0,this.parts=[],this.widthAverageNumSamples=1,this.curveFitter=new a.StrokeSmoother(t,e,o,(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 o=this.viewport.visibleRect;t.startObject(o);for(const o of e)t.drawPath(o);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=c},9616:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeLineBuilder=void 0;const i=o(5379),r=o(8258),s=n(o(2066)),a=n(o(8091));e.makeLineBuilder=(0,a.default)(((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=this.startPoint.pos,e=this.endPoint.pos,o=e.minus(t).normalized(),n=this.startPoint.width/2,a=this.endPoint.width/2,l=o.orthog(),c=l.times(n),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=l},1342:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makePolylineBuilder=void 0;const i=o(5379),r=n(o(2066)),s=n(o(4093)),a=n(o(3172));e.makePolylineBuilder=(0,a.default)(((t,e)=>{const o=.75*e.getSizeOfPixelOnCanvas();return new l(t,o,e)}));class l{constructor(t,e,o){this.minFitAllowed=e,this.viewport=o,this.parts=[],this.widthAverageNumSamples=1,this.lastLineSegment=null,this.averageWidth=t.width,this.startPoint={...t,pos:this.roundPoint(t.pos)},this.lastPoint=this.startPoint.pos,this.bbox=new i.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0),this.parts=[{kind:i.PathCommandType.MoveTo,point:this.startPoint.pos}]}getBBox(){return this.bbox.grownBy(this.averageWidth)}getRenderingStyle(){return{fill:i.Color4.transparent,stroke:{color:this.startPoint.color,width:this.roundDistance(this.averageWidth)}}}previewCurrentPath(){const t=this.startPoint.pos,e=[...this.parts];return e.length<=1&&e.push({kind:i.PathCommandType.LineTo,point:t.plus(i.Vec2.of(this.averageWidth/4,0))}),{startPoint:t,commands:e,style:this.getRenderingStyle()}}previewFullPath(){return[this.previewCurrentPath()]}preview(t){const e=this.previewFullPath();if(e){const o=this.viewport.visibleRect;t.startObject(o);for(const o of e)t.drawPath(o);t.endObject()}}build(){return new r.default(this.previewFullPath())}getMinFit(){let t=Math.min(this.minFitAllowed,this.averageWidth/4);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)}addPoint(t){this.widthAverageNumSamples++,this.averageWidth=this.averageWidth*(this.widthAverageNumSamples-1)/this.widthAverageNumSamples+t.width/this.widthAverageNumSamples;const e=this.roundPoint(t.pos);e.eq(this.lastPoint)||(this.lastLineSegment&&this.lastLineSegment.direction.dot(e.minus(this.lastPoint).normalized())>.997&&(this.parts.pop(),this.lastPoint=this.lastLineSegment.p1),this.parts.push({kind:i.PathCommandType.LineTo,point:this.roundPoint(t.pos)}),this.bbox=this.bbox.grownToPoint(e),this.lastLineSegment=new i.LineSegment2(this.lastPoint,e),this.lastPoint=e)}}e.default=l},14:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makePressureSensitiveFreehandLineBuilder=void 0;const i=o(5379),r=n(o(2066)),s=n(o(4093)),a=o(780),l=n(o(3172));e.makePressureSensitiveFreehandLineBuilder=(0,l.default)(((t,e)=>{const o=3*e.getSizeOfPixelOnCanvas(),n=e.getSizeOfPixelOnCanvas();return new c(t,n,o,e)}));class c{constructor(t,e,o,n){this.startPoint=t,this.minFitAllowed=e,this.viewport=n,this.isFirstSegment=!0,this.pathStartConnector=null,this.mostRecentConnector=null,this.nextCurveStartConnector=null,this.lastUpperBezier=null,this.lastLowerBezier=null,this.parts=[],this.upperSegments=[],this.lowerSegments=[],this.curveFitter=new a.StrokeSmoother(t,e,o,(t=>this.addCurve(t))),this.curveStartWidth=t.width,this.bbox=new i.Rect2(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:this.startPoint.color??null}}previewCurrentPath(t=!0){const e=this.upperSegments.slice(),o=this.lowerSegments.slice();let n,r;const s=this.curveFitter.preview();if(s&&t){const{upperCurveCommand:t,lowerToUpperConnector:i,upperToLowerConnector:a,lowerCurveCommand:l}=this.segmentToPath(s);e.push(t),o.push(l),n=i,r=this.pathStartConnector??[a]}else{if(null===this.mostRecentConnector||null===this.pathStartConnector)return null;n=this.mostRecentConnector,r=this.pathStartConnector}let a;const l=o[o.length-1];return a=l.kind===i.PathCommandType.LineTo||l.kind===i.PathCommandType.MoveTo?l.point:l.endPoint,{startPoint:a,commands:[n,...e.reverse(),...r,...o],style:this.getRenderingStyle()}}previewFullPath(){const t=this.previewCurrentPath();return t?[...this.parts,t]:null}preview(t){const e=this.previewFullPath();if(e){const o=this.viewport.visibleRect;t.startObject(o);for(const o of e)t.drawPath(o);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.isFirstSegment&&this.addCurve(null),new r.default(this.previewFullPath())}roundPoint(t){let e=Math.min(this.minFitAllowed,this.curveStartWidth/3);return e<1e-10&&(e=this.minFitAllowed),s.default.roundPoint(t,e)}shouldStartNewSegment(t,e){if(!this.lastLowerBezier||!this.lastUpperBezier)return!1;const o=(t,e)=>{const o=t.intersectsBezier(e);return o.length?o[0].point:null},n=t=>t.p2.minus(t.p1).normalized(),i=t=>t.p1.minus(t.p0).normalized();if(i(e).dot(n(this.lastUpperBezier))<.35||i(t).dot(n(this.lastLowerBezier))<.35||i(e).dot(n(e))<0||i(t).dot(n(t))<0)return!0;const r=o(t,this.lastUpperBezier),s=o(e,this.lastLowerBezier);return!(!r&&!s)}addCurve(t){if(!t){if(!this.isFirstSegment)return;const t=s.default.roundPoint(this.startPoint.width/2.2,Math.min(this.minFitAllowed,this.startPoint.width/4)),e=this.roundPoint(this.startPoint.pos),o=this.startPoint.pos.plus(i.Vec2.of(t,0));this.lowerSegments.push({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 n={kind:i.PathCommandType.LineTo,point:o};return this.pathStartConnector=[n],void(this.mostRecentConnector=n)}const{upperCurveCommand:e,lowerToUpperConnector:o,upperToLowerConnector:n,lowerCurveCommand:r,lowerCurve:a,upperCurve:l,nextCurveStartConnector:c}=this.segmentToPath(t);let d=this.shouldStartNewSegment(a,l);if(d){const t=this.previewCurrentPath(!1);t?(this.parts.push(t),this.upperSegments=[],this.lowerSegments=[]):d=!1}(this.isFirstSegment||d)&&(this.pathStartConnector=this.nextCurveStartConnector??[n],this.isFirstSegment=!1),this.mostRecentConnector=o,this.nextCurveStartConnector=c,this.lowerSegments.push(r),this.upperSegments.push(e),this.lastLowerBezier=a,this.lastUpperBezier=l,this.curveStartWidth=t.startWidth}segmentToPath(t){const e=new i.QuadraticBezier(t.startPoint,t.controlPoint,t.endPoint);let o=e.normal(0),n=e.normal(1);o=o.times(t.startWidth/2),n=n.times(t.endWidth/2),isFinite(o.magnitude())||(console.error("Warning: startVec is NaN or ∞",o,n,t),o=n);const r=t.startPoint,s=t.endPoint,a=t.controlPoint,l=e.nearestPointTo(a).parameterValue,c=e.normal(l).times(t.startWidth/2*l+t.endWidth/2*(1-l)),d=this.roundPoint(r.plus(o)),h=this.roundPoint(a.plus(c)),u=this.roundPoint(s.plus(n)),p=this.roundPoint(a.minus(c)),f=this.roundPoint(s.minus(n)),m=this.roundPoint(r.minus(o)),g={kind:i.PathCommandType.QuadraticBezierTo,controlPoint:h,endPoint:u},b={kind:i.PathCommandType.LineTo,point:d},y={kind:i.PathCommandType.LineTo,point:f},v=[{kind:i.PathCommandType.LineTo,point:f},{kind:i.PathCommandType.LineTo,point:u}];return{upperCurveCommand:{kind:i.PathCommandType.QuadraticBezierTo,controlPoint:p,endPoint:m},upperToLowerConnector:b,lowerToUpperConnector:y,lowerCurveCommand:g,upperCurve:new i.QuadraticBezier(f,p,m),lowerCurve:new i.QuadraticBezier(d,h,u),nextCurveStartConnector:v}}addPoint(t){this.curveFitter.addPoint(t)}}e.default=c},117:function(t,e,o){"use strict";var n=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=o(5379),r=o(8258),s=n(o(2066)),a=n(o(8091));e.makeFilledRectangleBuilder=(0,a.default)(((t,e)=>new l(t,!0,e))),e.makeOutlinedRectangleBuilder=(0,a.default)(((t,e)=>new l(t,!1,e)));class l{constructor(t,e,o){this.startPoint=t,this.filled=e,this.viewport=o,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.viewport.getRotationAngle(),e=i.Mat33.zRotation(-t),o=e.inverse().transformVec2(this.startPoint.pos),n=e.inverse().transformVec2(this.endPoint.pos),a=i.Rect2.fromCorners(o,n),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=l},3172:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379);e.default=t=>(e,o)=>new s(t,e,o);const i=(t,e,o)=>({points:[t,e[e.length-1]]}),r=(t,e,o)=>({points:[...o.corners,o.corners[0]]});class s{constructor(t,e,o){this.sourceFactory=t,this.startPoint=e,this.viewport=o,this.builder=t(e,o),this.points=[e]}getBBox(){return this.builder.getBBox()}build(){return this.builder.build()}preview(t){this.builder.preview(t)}addPoint(t){this.points.push(t),this.builder.addPoint(t)}async autocorrectShape(){const t=this.viewport.canvasToScreen(this.startPoint.pos),e=this.points.map((t=>this.viewport.canvasToScreen(t.pos))),o=n.Rect2.bboxOf(e),s=this.viewport.canvasToScreen(this.viewport.snapToGrid(this.startPoint.pos)),a=this.points.map((t=>this.viewport.canvasToScreen(this.viewport.snapToGrid(t.pos)))),l=n.Rect2.bboxOf(a);if(o.maxDimension<32)return null;const c=Math.min(30,o.maxDimension/4),d=[{...i(s,a),toleranceMultiplier:.5},i(t,e),{...r(0,0,l),toleranceMultiplier:.6},r(0,0,o)],h=(o=>{for(const i of d){const r=i.points,s=o*o*(i.toleranceMultiplier??1),a=t=>{for(;t<0;)t+=r.length;return t%=r.length,r[t]};let l=null,c=1/0,d=0;for(let e=0;e<r.length;e++){const o=r[e],n=o.squareDistanceTo(t);(!l||n<c)&&(c=n,l=o,d=e)}let h=0,u=d;for(const t of e){let e=1/0,o=u;const i=6;for(let r=-i;r<=i;r++){const i=u+r,s=a(i-1),l=a(i),c=a(i+1),d=new n.LineSegment2(s,l),h=new n.LineSegment2(l,c),p=d.distance(t),f=h.distance(t),m=Math.min(p,f),g=m*m;g<e&&(e=g,o=i)}if(u=o,h=Math.max(e,h),h>s)break}if(h<s)return r}return null})(c);if(!h)return null;const u=this.points[this.points.length-1],p=this.startPoint.width,f=u.width,m=this.startPoint.color,g=u.color,b=this.startPoint.time,y=u.time,v=t=>{const e=h[Math.max(0,Math.floor(t))],o=h[Math.min(Math.ceil(t),h.length-1)],n=e.lerp(o,t-Math.floor(t)),i=t/h.length;return{pos:this.viewport.screenToCanvas(n),width:p*(1-i)+f*i,color:m.mix(g,i),time:b*(1-i)+y*i}},x=this.sourceFactory(v(0),this.viewport),w=h.length<10;for(let t=0;t<h.length;t++)w&&x.addPoint(v(t-.001)),x.addPoint(v(t)),w&&x.addPoint(v(t+.001));return x.build()}}},8091:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>(e,n)=>new o(t,e,n);class o{constructor(t,e,o){this.sourceFactory=t,this.startPoint=e,this.viewport=o,this.builder=t(e,o),this.points=[e]}getBBox(){return this.builder.getBBox()}build(){return this.builder.build()}preview(t){this.builder.preview(t)}addPoint(t){this.points.push(t),this.builder.addPoint(t)}async autocorrectShape(){const t=t=>({...t,pos:this.viewport.snapToGrid(t.pos)}),e=t(this.startPoint),o=this.sourceFactory(e,this.viewport),n=this.points.map((e=>t(e)));for(const t of n)o.addPoint(t);return o.build()}}},6938:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedRectangleBuilder=e.makeFilledRectangleBuilder=e.makeLineBuilder=e.makeArrowBuilder=e.makeOutlinedCircleBuilder=e.makePressureSensitiveFreehandLineBuilder=e.makePolylineBuilder=e.makeFreehandLineBuilder=void 0;var n=o(9177);Object.defineProperty(e,"makeFreehandLineBuilder",{enumerable:!0,get:function(){return n.makeFreehandLineBuilder}});var i=o(1342);Object.defineProperty(e,"makePolylineBuilder",{enumerable:!0,get:function(){return i.makePolylineBuilder}});var r=o(14);Object.defineProperty(e,"makePressureSensitiveFreehandLineBuilder",{enumerable:!0,get:function(){return r.makePressureSensitiveFreehandLineBuilder}});var s=o(22);Object.defineProperty(e,"makeOutlinedCircleBuilder",{enumerable:!0,get:function(){return s.makeOutlinedCircleBuilder}});var a=o(8145);Object.defineProperty(e,"makeArrowBuilder",{enumerable:!0,get:function(){return a.makeArrowBuilder}});var l=o(9616);Object.defineProperty(e,"makeLineBuilder",{enumerable:!0,get:function(){return l.makeLineBuilder}});var c=o(117);Object.defineProperty(e,"makeFilledRectangleBuilder",{enumerable:!0,get:function(){return c.makeFilledRectangleBuilder}}),Object.defineProperty(e,"makeOutlinedRectangleBuilder",{enumerable:!0,get:function(){return c.makeOutlinedRectangleBuilder}})},1508:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3331:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||i(e,t,o)},a=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);return r(e,t),e}),l=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=void 0,s(o(1508),e),s(o(6938),e);var c=o(780);Object.defineProperty(e,"StrokeSmoother",{enumerable:!0,get:function(){return l(c).default}}),s(o(3029),e);var d=o(3029);Object.defineProperty(e,"AbstractComponent",{enumerable:!0,get:function(){return l(d).default}});const h=l(o(2066));e.Stroke=h.default,e.StrokeComponent=h.default;const u=l(o(2170));e.TextComponent=u.default,e.Text=u.default;const p=l(o(4686));e.ImageComponent=p.default;const f=o(486);Object.defineProperty(e,"createRestyleComponentCommand",{enumerable:!0,get:function(){return f.createRestyleComponentCommand}}),Object.defineProperty(e,"isRestylableComponent",{enumerable:!0,get:function(){return f.isRestylableComponent}});const m=a(o(2115));e.BackgroundComponent=m.default,Object.defineProperty(e,"BackgroundComponentBackgroundType",{enumerable:!0,get:function(){return m.BackgroundType}})},3539:(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}`}},780:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StrokeSmoother=void 0;const n=o(5379);class i{constructor(t,e,o,i){this.startPoint=t,this.minFitAllowed=e,this.maxFitAllowed=o,this.onCurveAdded=i,this.isFirstSegment=!0,this.lastExitingVec=null,this.currentCurve=null,this.lastPoint=this.startPoint,this.buffer=[this.startPoint.pos],this.momentum=n.Vec2.zero,this.currentCurve=null,this.curveStartWidth=t.width,this.bbox=new n.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,o=this.currentCurve.p2;return t.distanceTo(e)+o.distanceTo(e)}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),o=this.currentCurve.at(1);return{startPoint:e,controlPoint:this.currentCurve.p1,endPoint:o,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,o=t.time-this.lastPoint.time;if(t.pos.eq(this.lastPoint.pos,e)||0===o)return;if(isNaN(t.pos.magnitude()))return void console.warn("Discarding NaN point.",t);const n=Math.min(this.lastPoint.width,t.width)/3;if(this.startPoint.pos.distanceTo(t.pos)<n&&this.isFirstSegment)return;const i=o/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 o=t.width,i=this.curveEndWidth;if(this.curveEndWidth=o,this.bbox=this.bbox.grownToPoint(t.pos,o),null===this.currentCurve){const r=e.pos,s=e.pos.plus(this.lastExitingVec??n.Vec2.unitX),a=t.pos;this.currentCurve=new n.QuadraticBezier(r,s,a),console.assert(!isNaN(r.magnitude())&&!isNaN(s.magnitude())&&!isNaN(a.magnitude()),"Expected !NaN"),this.isFirstSegment?this.curveStartWidth=(this.curveStartWidth+o)/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.distanceTo(a),d=1.7*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 n.LineSegment2(a,a.plus(r.times(d))),u=new n.LineSegment2(l.minus(s.times(d)),l).intersection(h);let p=null;u&&(p=u.point),p||(p=a.lerp(l,.5).lerp(a.plus(r.times(c)),.1)),(a.eq(p)||l.eq(p))&&(p=a.plus(r.times(c/5))),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 n.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),o=e;let n=0;for(const i of this.buffer){let r=t.approximateDistance(i);if(r>e&&(r=t.distance(i),n+=Math.max(0,r-e),n>o))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},3925:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{if(0===e.length)return null;const o=e[0].description(t);for(const n of e)if(n.description(t)!==o)return null;return o}},4690:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8816));e.default=(t,e)=>{const o=(0,i.default)(t,{title:t.localization.about,contentClassNames:["about-dialog-content"]});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 o=document.createElement("div");o.innerText=t.text,e.appendChild(o)}o.appendChild(e)}return{close:()=>o.close()}}},8816:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(6453));e.default=(t,e)=>{const o=document.createElement("div"),{remove:n}=t.createHTMLOverlay(o);o.classList.add("dialog-container","message-dialog-container",...e.classNames??[]);const r=document.createElement("dialog"),s=document.createElement("div");s.classList.add("message-dialog-content",...e.contentClassNames??[]);const a=document.createElement("h1");a.textContent=e.title,a.setAttribute("autofocus","true");const l=document.createElement("button");l.innerText=t.localization.closeDialog,l.classList.add("close");const c=document.createElement("div");c.classList.add("scroll"),c.onwheel=t=>t.stopPropagation(),s.replaceChildren(a,c,l),r.replaceChildren(s),o.replaceChildren(r);r.style.setProperty("--close-delay","300ms");const d=async()=>{r.classList.add("-closing"),await(0,i.default)(300),r.close()};return r.addEventListener("pointerdown",(t=>{t.target===r&&d()})),r.onclose=()=>{n()},l.onclick=()=>d(),r.showModal(),{close:()=>d(),appendChild:t=>{c.appendChild(t)}}}},7:function(t,e,o){"use strict";var n,i,r,s,a=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),l=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),c=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),i=0;i<o.length;i++)"default"!==o[i]&&a(e,t,o[i]);return l(e,t),e}),d=this&&this.__setFunctionName||function(t,e,o){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:o?"".concat(o," ",e):e})},h=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RootImageNode=e.ImageNode=e.computeFirstIndexToRender=e.EditorImageEventType=e.sortLeavesByZIndex=void 0;const u=h(o(4093)),p=c(o(3029)),f=o(5379),m=h(o(1434)),g=h(o(9118)),b=o(7571),y=h(o(1403));var v;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"}(v||(e.EditorImageEventType=v={}));let x=!1;class w{constructor(){this.componentCount=0,this.settingExportRect=!1,this.root=new T,this.background=new T,this.componentsById=Object.create(null),this.notifier=new g.default,this.importExportViewport=new u.default((()=>{this.onExportViewportChanged()})),this.importExportViewport.updateScreenSize(f.Vec2.of(500,500)),this.shouldAutoresizeExportViewport=!1}getBackgroundComponents(){const t=[],o=this.background.getLeaves();(0,e.sortLeavesByZIndex)(o);for(const e of o){const o=e.getContent();o&&t.push(o)}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,o){this.background.render(t,o.visibleRect),x?this.root.render(t,o.visibleRect):e.render(t,this.root,o)}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,o=!1){let n=this.root.getLeavesIntersectingRegion(t);return o&&(n=n.concat(this.background.getLeavesIntersectingRegion(t))),(0,e.sortLeavesByZIndex)(n),n.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 i.AddElementCommand(t,e)}addElement(t,e){return i.addElement(t,e)}getImportExportViewport(){return this.importExportViewport}getImportExportRect(){return this.getImportExportViewport().visibleRect}setImportExportRect(t){return i.SetImportExportRectCommand.of(this,t,!1)}getAutoresizeEnabled(){return this.shouldAutoresizeExportViewport}setAutoresizeEnabled(t){if(t===this.shouldAutoresizeExportViewport)return y.default.empty;const e=this.root.getBBox();return i.SetImportExportRectCommand.of(this,e,t)}setAutoresizeEnabledDirectly(t){t!==this.shouldAutoresizeExportViewport&&(this.shouldAutoresizeExportViewport=t,this.notifier.dispatch(v.AutoresizeModeChanged,{image:this}))}autoresizeExportViewport(){this.shouldAutoresizeExportViewport&&this.setExportRectDirectly(this.root.getBBox())}setExportRectDirectly(t){const e=this.getImportExportViewport(),o=e.getScreenRectSize(),n=e.canvasToScreenTransform,i=f.Mat33.translation(t.topLeft.times(-1));return(!o.eq(t.size)||!n.eq(i))&&(this.settingExportRect=!0,e.updateScreenSize(t.size),e.resetTransform(i),this.settingExportRect=!1,this.onExportViewportChanged(),!0)}onExportViewportChanged(){this.settingExportRect||this.notifier.dispatch(v.ExportViewportChanged,{image:this})}static setDebugMode(t){x=t}}i=w,w.AddElementCommand=(d(r=class extends m.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"),m.default.register("add-element",((t,e)=>{const o=t.elemData.id,n=e.image.lookupElement(o)??p.default.deserialize(t.elemData),r=new i.AddElementCommand(n);return r.serializedElem=t.elemData,r})),r),w.SetImportExportRectCommand=(d(s=class extends m.default{constructor(t,e,o,n,r){super(i.SetImportExportRectCommand.commandId),this.originalSize=t,this.originalTransform=e,this.originalAutoresize=o,this.newExportRect=n,this.newAutoresize=r}static of(t,e,o){const n=t.getImportExportViewport(),r=n.visibleRect.size,s=n.canvasToScreenTransform,a=t.getAutoresizeEnabled();return new i.SetImportExportRectCommand(r,s,a,e,o)}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"),s.commandId="set-import-export-rect",(()=>{const t=s.commandId;m.default.register(t,((t,e)=>{(0,b.assertIsNumber)(t.originalSize.x),(0,b.assertIsNumber)(t.originalSize.y),(0,b.assertIsNumberArray)(t.originalTransform),(0,b.assertIsNumberArray)([t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h]),(0,b.assertIsBoolean)(t.autoresize??!1),(0,b.assertIsBoolean)(t.originalAutoresize??!1);const o=f.Vec2.ofXY(t.originalSize),n=new f.Mat33(...t.originalTransform),r=new f.Rect2(t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h),s=t.autoresize??!1,a=t.originalAutoresize??!1;return new i.SetImportExportRectCommand(o,n,a,r,s)}))})(),s),e.default=w;e.computeFirstIndexToRender=(t,e)=>{let o=0;if(e)for(let n=t.length-1;n>=1;n--)if(t[n].getBBox().containsRect(e)&&t[n].getContent()?.occludesEverythingBelowWhenRenderedInRect(e)){o=n;break}return o};class S{constructor(t=null){this.parent=t,this.targetChildCount=30,this.children=[],this.bbox=f.Rect2.empty,this.content=null,this.id=S.idCounter++}getId(){return this.id}onContentChange(){this.id=S.idCounter++}getContent(){return this.content}getParent(){return this.parent}getChildrenIntersectingRegion(t,e){return this.children.filter((o=>{const n=o.getBBox();return!e?.(n)&&n.intersects(t)}))}getChildrenOrSelfIntersectingRegion(t){return this.content?[this]:this.getChildrenIntersectingRegion(t)}getLeavesIntersectingRegion(t,e){const o=[],n=[];for(n.push(this);n.length>0;){const i=n.pop();null!==i.content&&o.push(i),n.push(...i.getChildrenIntersectingRegion(t,e))}return o}getChildWithContent(t){const e=this.getLeavesIntersectingRegion(t.getBBox());for(const o of e)if(o.getContent()===t)return o;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 S(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 S(this);if(this.children.length<this.targetChildCount)this.children.push(e);else{const t=new S(this);t.children=this.children,this.children=[e,t],t.updateParents(),t.recomputeBBox(!0)}return e.addLeaf(t)}const o=this.children.filter((t=>t.getBBox().containsRect(e)));if(o.length>0&&this.children.length>=this.targetChildCount){o.sort(((t,e)=>t.getBBox().area-e.getBBox().area));const e=o[0].addLeaf(t);return e.rebalance(),e}const n=S.createLeafNode(this,t);return this.children.push(n),n.recomputeBBox(!0),this.children.length>=this.targetChildCount&&this.rebalance(),n}static createLeafNode(t,e){const o=new S(t);return o.content=e,o}getBBox(){return this.bbox}recomputeBBox(t){const e=this.bbox;null!==this.content?this.bbox=this.content.getBBox():this.bbox=f.Rect2.union(...this.children.map((t=>t.getBBox()))),t&&!e.eq(this.bbox)&&(this.bbox.containsRect(e)?this.parent?.unionBBoxWith(this.bbox):this.parent?.recomputeBBox(!0)),this.checkRep()}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;if(null!==t.parent){const e=t.parent;e.children=e.children.filter((e=>e!==t)),t.parent=null,t.children=[],this.parent=e,e.children.push(this),this.parent.recomputeBBox(!1)}else null===this.content&&(this.parent.children=this.children,this.parent.updateParents(),this.parent=null)}if(this.children.length>10*this.targetChildCount){const t=this.getBBox().divideIntoGrid(4,4),e=[];for(;e.length<t.length;)e.push(0);for(const o of this.children)for(let n=0;n<t.length;n++)t[n].containsRect(o.getBBox())&&e[n]++;let o=0,n=e[0];for(let t=1;t<e.length;t++)e[t]>n&&(o=t,n=e[t]);const i=t[o];if(n>4){const t=[],e=[];for(const o of this.children)i.containsRect(o.getBBox())?e.push(o):t.push(o);if(e.length<this.children.length){this.children=t;const o=new S(this);this.children.push(o),o.children=e,o.updateParents(!1),o.recomputeBBox(!1),o.rebalance()}}}this.parent&&0===this.children.length&&null===this.content&&this.remove()}removeChild(t){this.checkRep();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),this.rebalance(),this.checkRep()}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=[],this.checkRep()}async renderAllAsync(t,o){const n=this.getLeaves();(0,e.sortLeavesByZIndex)(n);const i=n.length;for(let e=0;e<i;e++){const r=n[e].getContent();if(!r)continue;if(!await o(r,e,i))return!1;r.render(t,void 0)}return!0}render(t,o){let n;n=o?this.getLeavesIntersectingRegion(o,(e=>t.isTooSmallToRender(e))):this.getLeaves(),(0,e.sortLeavesByZIndex)(n);const i=(0,e.computeFirstIndexToRender)(n);for(let e=i;e<n.length;e++){n[e].getContent().render(t,o)}x&&o&&(0!==i&&console.log("EditorImage: skipped ",i,"nodes due to occlusion"),this.renderDebugBoundingBoxes(t,o))}renderDebugBoundingBoxes(t,e,o=0){const n=this.getBBox(),i=1/(t.getSizeOfCanvasPixelOnScreen()||1);if(n.maxDimension<3*i||!n.intersects(e))return;t.startObject(n);const r=!!this.content,s=r?f.Color4.ofRGBA(1,0,1,.4):f.Color4.ofRGBA(0,1,Math.sin(o),.6),a=r?1*i:2*i;if(t.drawRect(n.intersection(e),a,{fill:s}),t.endObject(),n.maxDimension>e.maxDimension/3){const e={fontFamily:"monospace",size:n.minDimension/20,renderingStyle:{fill:f.Color4.red}};t.drawText(`Depth: ${o}`,f.Mat33.translation(n.bottomLeft),e)}for(const n of this.children)n.renderDebugBoundingBoxes(t,e,o+1)}checkRep(t=0){if(x){if(this.parent&&!this.parent.children.includes(this))throw new Error(`Parent does not have this node as a child. (depth: ${t})`);let e=null;const o=new Set;for(const t of this.children){if(e??=t.getBBox(),e=e.union(t.getBBox()),t.parent!==this)throw new Error(`Child with bbox ${t.getBBox()} and ${t.children.length} has wrong parent (was ${t.parent}).`);if(o.has(t))throw new Error(`Child ${t} is present twice or more in its parent's child list`);o.add(t)}const n=this.bbox.minDimension/100;if(e&&!this.bbox.eq(e,n))throw new Error(`Wrong bounding box ${e} \\neq ${this.bbox} (depth: ${t})`)}}}e.ImageNode=S,S.idCounter=0;class T extends S{constructor(){super(...arguments),this.fullscreenChildren=[],this.dataComponents=[]}getChildrenIntersectingRegion(t,e){const o=super.getChildrenIntersectingRegion(t);for(const t of this.fullscreenChildren)o.push(t);return o}getLeaves(){const t=super.getLeaves();return this.dataComponents.concat(this.fullscreenChildren,t)}removeChild(t){let e=!1;const o=o=>{const n=o===t;return e||=n,!n};this.dataComponents=this.dataComponents.filter(o),this.fullscreenChildren=this.fullscreenChildren.filter(o),e||super.removeChild(t)}getChildWithContent(t){const e=()=>{const e=this.fullscreenChildren.concat(this.dataComponents);for(const o of e)if(o.getContent()===t)return o;return null};return t.getSizingMode(),p.ComponentSizingMode.BoundingBox,super.getChildWithContent(t)??e()}addLeaf(t){const e=t.getSizingMode();if(e===p.ComponentSizingMode.BoundingBox)return super.addLeaf(t);if(e===p.ComponentSizingMode.FillScreen){this.onContentChange();const e=S.createLeafNode(this,t);return this.fullscreenChildren.push(e),e}if(e===p.ComponentSizingMode.Anywhere){this.onContentChange();const e=S.createLeafNode(this,t);return this.dataComponents.push(e),e}throw new Error(`Invalid sizing mode, ${e}`)}}e.RootImageNode=T},495:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379);e.default=(t,e,o)=>{let i=e.w,r=e.h;if(o?.minDimension&&i<o.minDimension){const t=o.minDimension;r*=t/(i||1),i=t}if(o?.minDimension&&r<o.minDimension){const t=o.minDimension;i*=t/(r||1),r=t}t.setAttribute("width",(0,n.toRoundedString)(i)),t.setAttribute("height",(0,n.toRoundedString)(r))}},9261:function(t,e,o){"use strict";var n=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=o(5379),r=n(o(1598)),s=o(3604),a=n(o(495)),l=(t,e,o)=>{const n=t.getImportExportViewport().getTemporaryClone();if(o?.minDimension){const t=n.visibleRect;let e=t;e.w<=0&&(e=new i.Rect2(e.x,e.y,o.minDimension,e.h)),e.h<=0&&(e=new i.Rect2(e.x,e.y,e.w,o.minDimension)),e.eq(t)||n.updateScreenSize(e.size)}const{element:l,renderer:c}=r.default.fromViewport(n,{sanitize:o.sanitize??!1,useViewBoxForPositioning:!0});return e(c,(()=>{t.getAutoresizeEnabled()?l.classList.add(s.svgLoaderAutoresizeClassName):l.classList.remove(s.svgLoaderAutoresizeClassName);const e=n.visibleRect;return(0,a.default)(l,e,o),l})),l};e.editorImageToSVGSync=(t,e)=>l(t,((e,o)=>{t.renderAll(e),o()}),e);e.editorImageToSVGAsync=(t,e,o)=>new Promise((n=>{l(t,(async(o,i)=>{await t.renderAllAsync(o,e);const r=i();n(r)}),o)}))},278:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.EditorImage=void 0;var i=o(7);Object.defineProperty(e,"EditorImage",{enumerable:!0,get:function(){return n(i).default}})},7394:(t,e)=>{"use strict";var o;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",t[t.ContextMenu=9]="ContextMenu"}(o||(e.InputEvtType=o={}));const n=(t,e)=>({kind:t,key:e.key,code:e.code,ctrlKey:e.ctrlKey||e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey});e.keyUpEventFromHTMLEvent=t=>n(o.KeyUpEvent,t);e.keyPressEventFromHTMLEvent=t=>n(o.KeyPressEvent,t);e.isPointerEvt=t=>t.kind===o.PointerDownEvt||t.kind===o.PointerMoveEvt||t.kind===o.PointerUpEvt},6592:function(t,e,o){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),i=this&&this.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)},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(o(3954));e.Editor=s.default,i(o(278),e),i(o(2018),e),i(o(7394),e);var a=o(2543);Object.defineProperty(e,"getLocalizationTable",{enumerable:!0,get:function(){return r(a).default}}),Object.defineProperty(e,"matchingLocalizationTable",{enumerable:!0,get:function(){return a.matchingLocalizationTable}}),i(o(5246),e);var l=o(3604);Object.defineProperty(e,"SVGLoader",{enumerable:!0,get:function(){return r(l).default}});var c=o(4093);Object.defineProperty(e,"Viewport",{enumerable:!0,get:function(){return r(c).default}}),i(o(5379),e),i(o(3331),e),i(o(525),e),i(o(6532),e),i(o(3280),e),i(o(1063),e),i(o(9611),e),i(o(4772),e);var d=o(9118);Object.defineProperty(e,"EventDispatcher",{enumerable:!0,get:function(){return r(d).default}});var h=o(578);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=o(1721);Object.defineProperty(e,"UndoRedoHistory",{enumerable:!0,get:function(){return r(u).default}}),i(o(9395),e);var p=o(5711);Object.defineProperty(e,"__js_draw__version",{enumerable:!0,get:function(){return r(p).default}});const f=r(o(2101));e.AbstractToolbar=f.default,e.HTMLToolbar=f.default,e.default=s.default},5246:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultEditorLocalization=void 0;const n=o(9985),i=o(3539),r=o(4215),s=o(7806),a=o(8658);e.defaultEditorLocalization={...s.defaultToolbarLocalization,...a.defaultToolLocalization,...n.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}`,softwareLibraries:"Libraries",developerInformation:"Developer information"}},8351:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n={...o(5246).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",selectPenType:"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",unionOf:(t,e)=>`Vereinigung: ${e} ${t}`,emptyBackground:"Leerer Hintergrund",filledBackgroundWithColor:t=>`Gefüllter Hintergrund (${t})`,restyledElement:t=>`${t} umgestaltet`};e.default=n},5831:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n={...o(5246).defaultEditorLocalization};e.default=n},4988:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n={...o(5246).defaultEditorLocalization,pen:"Lapiz",eraser:"Borrador",select:"Selecciona",handTool:"Mover",image:"Imagen",inputAltText:"Texto alternativo",resetImage:"Reiniciar",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",selectPenType:"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",enableAutoresizeOption:"Redimensionar automático",toggleOverflow:"Más",about:"Acerca de",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",selectionMenu__paste:"Pegar",selectionMenu__delete:"Eliminar",selectionMenu__duplicate:"Duplicar",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",undoRedoTool:"Deshace/rehace",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",anyDevicePanning:"Mover la pantalla con todo dispotivo",copied:t=>`${t} cosas fueron copiados`,pasted:t=>1===t?"Pegado":`${t} cosas fueron pegados`,toolEnabledAnnouncement:t=>`${t} fue activado`,toolDisabledAnnouncement:t=>`${t} fue desactivado`,resizeOutputCommand:t=>`Tamaño de imagen fue cambiado a ${t.w}x${t.h}`,eraseAction:(t,e)=>`Borrado: ${e} ${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=n},2543:function(t,e,o){"use strict";var n=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=o(5246),r=n(o(8351)),s=n(o(5831)),a=n(o(4988));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,o)=>{let n;for(const o of t){const t=l(o);if(n&&t!==n&&n in e)return e[n];if(o in e)return e[o];n=t}return n&&n in e?e[n]:o};e.default=t=>(t??=navigator.languages,(0,e.matchingLocalizationTable)(t,e.allLocales,i.defaultEditorLocalization))},1606:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RenderingMode=void 0;const i=n(o(8748)),r=o(2018),s=n(o(7376)),a=o(5379),l=n(o(1258)),c=n(o(1733));var d;!function(t){t[t.DummyRenderer=0]="DummyRenderer",t[t.CanvasRenderer=1]="CanvasRenderer"}(d||(e.RenderingMode=d={}));e.default=class{constructor(t,e,o){if(this.editor=t,this.parent=o,this.textRerenderOutput=null,this.devicePixelRatio=window.devicePixelRatio??1,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 n=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 o=document.createElement("canvas");o.width=n.x+1,o.height=n.y+1;const r=o.getContext("2d");return new i.default(r,t.viewport)},isOfCorrectType:t=>this.dryInkRenderer.canRenderFromWithoutDataLoss(t),blockResolution:n,cacheSize:1296e5,maxScale:Math.max(1,1.3/window.devicePixelRatio),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"),o=t.getContext("2d"),n=e.getContext("2d");this.dryInkRenderer=new i.default(o,this.editor.viewport),this.wetInkRenderer=new i.default(n,this.editor.viewport),t.className="dryInkCanvas",e.className="wetInkCanvas",this.parent&&(this.parent.appendChild(t),this.parent.appendChild(e)),this.resizeSurfacesCallback=()=>{const i=t=>Math.ceil(t.clientWidth*this.devicePixelRatio)||t.width,s=t=>Math.ceil(t.clientHeight*this.devicePixelRatio)||t.height,l=t=>s(t)!==t.height||i(t)!==t.width;(l(t)||l(e))&&(t.width=i(t),t.height=s(t),e.width=i(e),e.height=s(e),n.resetTransform(),o.resetTransform(),o.scale(this.devicePixelRatio,this.devicePixelRatio),n.scale(this.devicePixelRatio,this.devicePixelRatio),this.editor.notifier.dispatch(r.EditorEventType.DisplayResized,{kind:r.EditorEventType.DisplayResized,newSize:a.Vec2.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{o.save(),o.resetTransform(),o.drawImage(e,0,0),o.restore()},this.getColorAt=t=>{const e=t.times(this.devicePixelRatio),n=o.getImageData(e.x,e.y,1,1),i=n?.data;if(i){return a.Color4.ofRGBA(i[0]/255,i[1]/255,i[2]/255,i[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)}setDevicePixelRatio(t){if(isFinite(t)&&t>=.001&&t<=10&&t!==this.devicePixelRatio)return this.devicePixelRatio=t,this.resizeSurfacesCallback?.(),this.editor.queueRerender()}getDevicePixelRatio(){return this.devicePixelRatio}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?.()}}},8258:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.visualEquivalent=e.simplifyPathToFullScreenOrEmpty=e.pathToRenderable=e.pathFromRenderable=void 0;const n=o(5379);e.pathFromRenderable=t=>t.path?t.path:new n.Path(t.startPoint,t.commands);e.pathToRenderable=(t,e)=>({startPoint:t.startPoint,style:e,commands:t.parts,path:t});e.simplifyPathToFullScreenOrEmpty=(t,o,i={fastCheck:!0,expensiveCheck:!0})=>{const r=(0,e.pathFromRenderable)(t),s=t.style.stroke?.width??0,a=s>0&&0===t.style.fill.a,l=r.bbox.grownBy(s),c=a&&s>o.maxDimension&&l.containsRect(o);if(i.fastCheck&&c&&t.style.stroke){const i=s/2;for(const s of r.startEndPoints())if(o.isWithinRadiusOf(i,s))return{rectangle:o,path:(0,e.pathToRenderable)(n.Path.fromRect(o),{fill:t.style.stroke.color}),fullScreen:!0}}if(i.expensiveCheck&&c&&t.style.stroke&&s>3*o.maxDimension){const i=r.signedDistance(o.center,s/2),a=s/6;if(i<-o.maxDimension/2-a)return{path:(0,e.pathToRenderable)(n.Path.fromRect(o),{fill:t.style.stroke.color}),rectangle:o,fullScreen:!0};if(i>o.maxDimension/2+a)return{path:(0,e.pathToRenderable)(n.Path.empty,{fill:n.Color4.transparent}),rectangle:n.Rect2.empty,fullScreen:!1}}return null};e.visualEquivalent=(t,o)=>{const i=(0,e.pathFromRenderable)(t),r=t.style.stroke?.width??0,s=r>0&&0===t.style.fill.a,a=i.bbox.grownBy(r);let l=(0,e.simplifyPathToFullScreenOrEmpty)(t,o,{fastCheck:!0,expensiveCheck:!1});if(l)return l.path;if(o.grownBy(r).transformedBoundingBox(n.Mat33.scaling2D(4,o.center)).containsRect(a))return((t,e)=>t.path?t:{...t,path:e})(t,i);const c=[];let d=i.startPoint;for(const t of i.parts){const e=n.Path.computeBBoxForSegment(d,t).grownBy(r);let i;i=t.kind===n.PathCommandType.LineTo||t.kind===n.PathCommandType.MoveTo?t.point:t.endPoint;e.intersects(o)?c.push(t):s||t.kind===n.PathCommandType.MoveTo?c.push({kind:n.PathCommandType.MoveTo,point:i}):c.push({kind:n.PathCommandType.LineTo,point:i}),d=i}const h=new n.Path(i.startPoint,c),u=t.style;return l=(0,e.simplifyPathToFullScreenOrEmpty)(t,o,{fastCheck:!1,expensiveCheck:!0}),l?l.path:(0,e.pathToRenderable)(h,u)}},8247:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.styleFromJSON=e.styleToJSON=e.stylesEqual=e.cloneStyle=void 0;const n=o(5379);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:n.Color4.fromHex(t.stroke.color),width:t.stroke.width}:void 0;return{fill:n.Color4.fromHex(t.fill),stroke:e}}},196:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.textStyleToJSON=e.textStyleFromJSON=e.cloneTextStyle=void 0;const n=o(8247);e.cloneTextStyle=t=>({...t,renderingStyle:(0,n.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,n.styleFromJSON)(t.renderingStyle),size:t.size,fontWeight:t.fontWeight,fontVariant:t.fontVariant,fontFamily:t.fontFamily}};e.textStyleToJSON=t=>({...t,renderingStyle:(0,n.styleToJSON)(t.renderingStyle)})},6601:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379);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 n.Mat33.scaling2D(this.cacheState.props.blockResolution.x/t.size.x).rightMul(n.Mat33.translation(t.topLeft.times(-1)))}setRenderingRegion(t){const e=this.getTransform(t);this.renderer.setTransform(e),this.renderer.overrideVisibleRect(t.grownBy(1/e.getScaleFactor()))}}},2062:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CacheRecordManager=void 0;const i=n(o(6601));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 o=new i.default(e,this.cacheState);return o.setRenderingRegion(t),this.cacheRecords.push(o),this.cacheState.debugMode&&console.log("[Cache] Cache spaces used: ",this.cacheRecords.length," of ",this.maxCanvases),o}{const o=this.getLeastRecentlyUsedRecord();return this.cacheState.debugMode&&console.log("[Cache] Re-alloc. Times allocated: ",o.allocCount,"\nLast used cycle: ",o.getLastUsedCycle(),"\nCurrent cycle: ",this.cacheState.currentRenderingCycle),o.realloc(e),o.setRenderingRegion(t),this.cacheState.debugMode&&(console.log("[Cache] Now re-alloc'd. Last used cycle: ",o.getLastUsedCycle()),console.assert(o.cacheState===this.cacheState,"[Cache] Unequal cache states! cacheState should be a shared object!")),o}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort(((t,e)=>t.getLastUsedCycle()-e.getLastUsedCycle())),this.cacheRecords[0]}getDebugInfo(){let t=0,e=0;for(const o of this.cacheRecords)e+=o.allocCount,o.isAllocd()&&t++;e/=Math.max(this.cacheRecords.length,1);return[`${this.cacheRecords.length} cache records (max ${this.maxCanvases})`,`${t} assigned to screen regions`,"Average number of times reassigned: "+Math.round(100*e)/100].join("\n")}}},1258:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=n(o(9418)),s=o(2062);e.default=class{constructor(t){this.recordManager=new s.CacheRecordManager(t),this.sharedState={props:t,currentRenderingCycle:0,recordManager:this.recordManager,debugMode:!1},this.recordManager.setSharedState(this.sharedState)}render(t,e,o){const n=o.visibleRect;if(this.sharedState.currentRenderingCycle++,!this.sharedState.props.isOfCorrectType(t))return void e.render(t,n);if(!this.rootNode){const t=this.sharedState.props.blockResolution,e=n.topLeft;this.rootNode=new r.default(new i.Rect2(e.x,e.y,t.x,t.y),this.sharedState)}for(;!this.rootNode.region.containsRect(n);)this.rootNode=this.rootNode.generateParent();this.rootNode=this.rootNode.smallestChildContaining(n)??this.rootNode;const s=e.getLeavesIntersectingRegion(o.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],o):e.render(t,n)}getDebugInfo(){return this.recordManager.getDebugInfo()}setIsDebugMode(t){this.sharedState.debugMode=t}}},9418:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(7),i=o(5379);class r{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 r(t,this.cacheState);e.generateChildren();const o=this.region.maxDimension/100,n=(e.instantiatedChildren.length-1)/2;if(!e.instantiatedChildren[n].region.eq(this.region,o))throw console.error(e.instantiatedChildren[n].region,"≠",this.region),new Error("Logic error: [this] is not contained within its parent's center child");return e.instantiatedChildren[n]=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 r(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 o of this.instantiatedChildren)if(o.region.intersects(t.visibleRect)&&!o.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 o of t)o.getBBox().intersects(this.region)&&e.push(o.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,o){if(!o.visibleRect.intersects(this.region)||0===e.length)return;if(e=(t=>{const e=[];for(const o of t){const t=o.getBBox();t.intersects(this.region)&&(t.maxDimension>=this.region.maxDimension?e.push(...o.getChildrenOrSelfIntersectingRegion(this.region)):e.push(o))}return e})(e),!this.cacheState.props.isOfCorrectType(t)){for(const n of e)n.render(t,o.visibleRect);return}this.cacheState.debugMode&&t.drawRect(this.region,o.getSizeOfPixelOnCanvas(),{fill:i.Color4.yellow});if(this.renderingWouldBeHighEnoughResolution(o)){const r=t=>t.w/this.region.w<1/this.cacheState.props.blockResolution.x,s=[];for(const t of e)s.push(...t.getLeavesIntersectingRegion(this.region,r));(0,n.sortLeavesByZIndex)(s);const a=this.computeSortedByLeafIds(s);if(0===a.length)return;const l=a.map((t=>t.getId()));let c;if(this.renderingIsUpToDate(l))c=this.cachedRenderer.startRender();else{if(this.allChildrenCanRender(o,a)){for(const n of this.getChildren())n.renderItems(t,e,o);return}let d=0;for(const t of a)r(t.getBBox())||(d+=t.getContent().getProportionalRenderingTime());if(d>this.cacheState.props.minProportionalRenderTimePerCache){let e=!0;if(this.cachedRenderer)if(a.length>this.renderedIds.length&&this.allRenderedIdsIn(l)&&null!==this.renderedMaxZIndex){const n=[];let r=null;for(let t=0;t<a.length;t++){const e=a[t],o=e.getContent().getZIndex();(t>=this.renderedIds.length||e.getId()!==this.renderedIds[t])&&(n.push(e),(null===r||o<r)&&(r=o))}if(null!==r&&r>this.renderedMaxZIndex){e=!1,c=this.cachedRenderer.startRender();for(let t=0;t<s.length;t++){const e=s[t],o=e.getContent().getZIndex();o>this.renderedMaxZIndex&&(e.render(c,this.region),this.renderedMaxZIndex=o)}this.cacheState.debugMode&&t.drawRect(this.region,2*o.getSizeOfPixelOnCanvas(),{fill:i.Color4.clay})}}else this.cacheState.debugMode&&console.log("Decided on a full re-render. Reason: At least one of the following is false:","\n leafIds.length > this.renderedIds.length: ",l.length>this.renderedIds.length,"\n this.allRenderedIdsIn(leafIds): ",this.allRenderedIdsIn(l),"\n this.renderedMaxZIndex !== null: ",null!==this.renderedMaxZIndex,"\n\nthis.rerenderedIds: ",this.renderedIds,", leafIds: ",l);else this.cachedRenderer=this.cacheState.recordManager.allocCanvas(this.region,(()=>this.onRegionDealloc()));if(e){c=this.cachedRenderer.startRender(),c.clear(),this.renderedMaxZIndex=null;for(let t=(0,n.computeFirstIndexToRender)(s,this.region);t<s.length;t++){const e=s[t],o=e.getContent();this.renderedMaxZIndex??=o.getZIndex(),this.renderedMaxZIndex=Math.max(this.renderedMaxZIndex,o.getZIndex()),e.render(c,this.region)}this.cacheState.debugMode&&t.drawRect(this.region,3*o.getSizeOfPixelOnCanvas(),{fill:i.Color4.red})}this.renderedIds=l}else{this.cachedRenderer?.dealloc();const e=o.getSizeOfPixelOnCanvas(),n=new i.Rect2(this.region.x,this.region.y,this.region.w+e,this.region.h+e),r=!0;t.startObject(n,r);for(const e of s)e.render(t,this.region.intersection(o.visibleRect));t.endObject(),this.cacheState.debugMode&&t.drawRect(this.region,2*o.getSizeOfPixelOnCanvas(),{fill:i.Color4.green})}}if(c){const e=this.cachedRenderer.getTransform(this.region).inverse();t.renderFromOtherOfSameType(e,c)}this.instantiatedChildren.every((t=>t.isEmpty()))&&(this.instantiatedChildren=[])}else for(const n of this.getChildren())n.renderItems(t,e.filter((t=>t.getBBox().intersects(n.region))),o);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=r},1063:function(t,e,o){"use strict";var n=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=o(3982);Object.defineProperty(e,"AbstractRenderer",{enumerable:!0,get:function(){return n(i).default}});var r=o(7376);Object.defineProperty(e,"DummyRenderer",{enumerable:!0,get:function(){return n(r).default}});var s=o(1598);Object.defineProperty(e,"SVGRenderer",{enumerable:!0,get:function(){return n(s).default}});var a=o(8748);Object.defineProperty(e,"CanvasRenderer",{enumerable:!0,get:function(){return n(a).default}});var l=o(1606);Object.defineProperty(e,"Display",{enumerable:!0,get:function(){return n(l).default}}),Object.defineProperty(e,"RenderingMode",{enumerable:!0,get:function(){return l.RenderingMode}});var c=o(8258);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}})},4215:(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"}},3982:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379),i=o(8247),r=o(8258);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:o,commands:r,style:s}=e;t&&(0,i.stylesEqual)(t,s)?this.moveTo(o):(t&&this.endPath(t),this.beginPath(o),t=s);for(const t of r)t.kind===n.PathCommandType.LineTo?this.lineTo(t.point):t.kind===n.PathCommandType.MoveTo?this.moveTo(t.point):t.kind===n.PathCommandType.CubicBezierTo?this.traceCubicBezierCurve(t.controlPoint1,t.controlPoint2,t.endPoint):t.kind===n.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,o){const i=n.Path.fromRect(t,e);this.drawPath((0,r.pathToRenderable)(i,o))}fillRect(t,e){const o=n.Path.fromRect(t);this.drawPath((0,r.pathToRenderable)(o,{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(n.Vec2.unitX).length()}overrideVisibleRect(t){this.visibleRectOverride=t}getVisibleRect(){return this.visibleRectOverride??this.viewport.visibleRect}}},8748:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(2170)),r=o(5379),s=n(o(3982)),a=o(8258);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=1,this.minRenderSizeAnyDimen=.1):(this.minSquareCurveApproxDist=.5,this.minRenderSizeBothDimens=.1,this.minRenderSizeAnyDimen=1e-6)}displaySize(){return r.Vec2.of(this.ctx.canvas.clientWidth,this.ctx.canvas.clientHeight)}clear(){this.ctx.save(),this.ctx.resetTransform(),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}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,o){t=this.canvasToScreen(t),e=this.canvasToScreen(e),o=this.canvasToScreen(o);const n=e.minus(t),i=o.minus(e);n.magnitudeSquared()<this.minSquareCurveApproxDist&&i.magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(o.x,o.y):this.ctx.bezierCurveTo(t.x,t.y,e.x,e.y,o.x,o.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){if(this.ignoringObject)return;const e=this.getVisibleRect();this.currentObjectBBox?.containsRect(e)&&(t=(0,a.visualEquivalent)(t,e)),super.drawPath(t)}drawText(t,e,o){this.ctx.save(),e=this.getCanvasToScreenTransform().rightMul(e),this.transformBy(e),i.default.applyTextStyles(this.ctx,o),0!==o.renderingStyle.fill.a&&(this.ctx.fillStyle=o.renderingStyle.fill.toHexString(),this.ctx.fillText(t,0,0)),o.renderingStyle.stroke&&(this.ctx.strokeStyle=o.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=o.renderingStyle.stroke.width,this.ctx.strokeText(t,0,0)),this.ctx.restore()}drawImage(t){if(0===t.image.width||0===t.image.height)return;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.getVisibleRect())){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 o=this.canvasToScreen(t[e]);this.ctx.beginPath(),this.ctx.arc(o.x,o.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}`,o.x,o.y,20)}}isTooSmallToRender(t){const e=t.size.times(this.getSizeOfCanvasPixelOnScreen()),o=this.minRenderSizeBothDimens,n=Math.abs(e.x)<o&&Math.abs(e.y)<o,i=this.minRenderSizeAnyDimen,r=Math.abs(e.x)<i||Math.abs(e.y)<i;return n||r}static fromViewport(t,e={}){const o=document.createElement("canvas"),n=t.getScreenRectSize();let i=e.canvasSize??n;e.maxCanvasDimen&&i.maximumEntryMagnitude()>e.maxCanvasDimen&&(i=i.times(e.maxCanvasDimen/i.maximumEntryMagnitude())),o.width=i.x,o.height=i.y;const r=o.getContext("2d"),s=Math.min(i.x/n.x,i.y/n.y);return r.scale(s,s),{renderer:new l(r,t),element:o}}}e.default=l},7376:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=n(o(3982));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,o){t=this.canvasToScreen(t),e=this.canvasToScreen(e),o=this.canvasToScreen(o),this.lastPoint=o,this.pointBuffer.push(t,e,o)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(t,e)}drawPoints(...t){}drawText(t,e,o){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))))}toString(){return"[DummyRenderer]"}}e.default=s},1598:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.renderedStylesheetId=void 0;const i=o(5379),r=o(3604),s=o(8247),a=n(o(3982)),l=o(8258),c=n(o(6953));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,o=!1){super(e),this.elem=t,this.sanitize=o,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.appendChild(document.createTextNode("\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.getSizeOfCanvasPixelOnScreen()))),this.elem.appendChild(t),this.objectElems?.push(t),t}drawPath(t){const e=t.style,o=(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(o.toString())}transformFrom(t,e,o=!1){const n=o?t:this.getCanvasToScreenTransform().rightMul(t);if(n.eq(i.Mat33.identity))e.style.transform="";else{const t=n.toCSSMatrix();e.style.transform=t,e.setAttribute("data-highp-transform",t)}}drawText(t,e,o){const n=(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 o=e.renderingStyle.fill.toHexString();if(t.style.fill=o,e.renderingStyle.stroke){const o=e.renderingStyle.stroke;t.style.stroke=o.color.toHexString(),t.style.strokeWidth=o.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)}`),n(r,o)}else{const i=document.createElementNS(d,"text");i.appendChild(document.createTextNode(t)),this.transformFrom(e,i,!0),n(i,o),this.elem.appendChild(i),this.objectElems?.push(i),this.objectLevel>0&&(this.textContainer=i,this.textContainerTransform=e,this.textParentStyle={...h,...o})}}drawImage(t){let e=t.label??t.image.getAttribute("aria-label")??"";""===e&&(e=t.image.getAttribute("alt")??"");const o=document.createElementNS(d,"image");o.setAttribute("href",t.base64Url),o.setAttribute("width",t.image.getAttribute("width")??""),o.setAttribute("height",t.image.getAttribute("height")??""),o.setAttribute("aria-label",e),this.transformFrom(t.transform,o),this.elem.appendChild(o),this.objectElems?.push(o)}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 o=t[r.svgAttributesDataKey],n=t[r.svgStyleAttributesDataKey];if(o)for(const[t,n]of o)e.setAttribute(t,n);if(n)for(const t of n)e.style.setProperty(t.key,t.value,t.priority)}const e=t[r.svgLoaderAttributeContainerID];let o=[];if(e&&e[0]&&e[0].length&&(o=e[0]),o.length>0&&(0,c.default)(this.lastContainerIDList,o)&&this.lastContainerIDList.length>=o.length-1){const t=o[o.length-1],e=this.elem.querySelectorAll(`g#${t}`);if(e.length>=1){const t=e[0];if(0===t.children.length||this.lastContainerIDList.length>=o.length)for(const e of this.objectElems)e.remove(),t.appendChild(e);else o=[]}}else o=[];this.lastContainerIDList=o}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,o){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 o=t.cloneNode(!0);this.elem.appendChild(o),this.objectElems?.push(o)}isTooSmallToRender(t){return!1}static fromViewport(t,e=!0){let o,n;"boolean"==typeof e?(o=e,n=!1):(o=e.sanitize??!0,n=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(n){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,o);return l.eq(t.visibleRect)||d.overrideVisibleRect(l),{element:s,renderer:d}}}e.default=u},1733:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=n(o(3982));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,o){}traceQuadraticBezierCurve(t,e){}drawText(t,e,o){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},7067:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=t=>t.toUpperCase()===t&&t.toLowerCase()!==t&&1===t.length,n=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=o(t.key??""),r=n(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;o(t)?e=!0:(n(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 o=e(t);return new i({key:t,...o})}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},5577:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(2543),r=n(o(7067));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 o=this.shortcutOverrides[t];if(!o){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);o=s.shortcuts[t]}for(const t of o)if(t.matchesEvent(e))return!0;return!1}static registerDefaultKeyboardShortcut(t,e,o){if(t in s.shortcuts)return!1;const n=e.map((t=>"string"==typeof t?r.default.fromString(t):t));return s.shortcuts[t]=[...n],s.shortcutDefaultDescriptions[t]=o,!0}static provideShortcutDescription(t,e,o){e in s.shortcutLocalizedDescriptions||(s.shortcutLocalizedDescriptions[e]=Object.create(null)),s.shortcutLocalizedDescriptions[e][t]=o}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},4772:function(t,e,o){"use strict";var n=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=o(5577);Object.defineProperty(e,"KeyboardShortcutManager",{enumerable:!0,get:function(){return n(i).default}});var r=o(7067);Object.defineProperty(e,"KeyBinding",{enumerable:!0,get:function(){return n(r).default}})},9979:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{let e=0;const o=t.map((t=>t.id));o.sort();for(const t of o)e===t&&(e=t+1);return e}},9611:function(t,e,o){"use strict";var n=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=o(4433);Object.defineProperty(e,"sendPenEvent",{enumerable:!0,get:function(){return n(i).default}});var r=o(8441);Object.defineProperty(e,"sendTouchEvent",{enumerable:!0,get:function(){return n(r).default}})},4433:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=s(o(578)),c=o(7394),d=a(o(9979));e.default=(t,e,o,n,i=l.PointerDevice.Pen)=>{const r=(0,d.default)(n??[]),s=l.default.ofCanvasPoint(o,e!==c.InputEvtType.PointerUpEvt,t.viewport,r,i);return t.toolController.dispatchInputEvent({kind:e,allPointers:n??[s],current:s}),s}},8441:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=s(o(578)),c=o(7394),d=a(o(9979));e.default=(t,e,o,n)=>{const i=t.viewport.screenToCanvas(o),r=(0,d.default)(n??[]),s=l.default.ofCanvasPoint(i,e!==c.InputEvtType.PointerUpEvt,t.viewport,r,l.PointerDevice.Touch);return t.toolController.dispatchInputEvent({kind:e,allPointers:[...n??[],s],current:s}),s}},2101:function(t,e,o){"use strict";var n,i,r,s,a=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)},l=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const d=o(2018),h=o(1666),u=o(7806),p=c(o(1172)),f=c(o(7955)),m=c(o(7686)),g=c(o(1011)),b=c(o(9392)),y=c(o(9108)),v=c(o(1295)),x=c(o(869)),w=c(o(5360)),S=c(o(1210)),T=o(5068),C=c(o(9751)),P=c(o(1294)),k=c(o(7021)),E=o(5379),z=o(2034),M=c(o(8230)),_=c(o(7855));class I{constructor(t,e=u.defaultToolbarLocalization){this.editor=t,this.localizationTable=e,n.set(this,[]),i.set(this,{}),r.set(this,[]),s.set(this,null),this.closeColorPickerOverlay=null,I.colorisStarted||((0,h.init)(),I.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,n,"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 o=!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),o||(o=!0,document.addEventListener("load",(()=>{i()}),{once:!0}))}};i(),l(this,s,i,"f");a(this,n,"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,n,"f").push(this.editor.notifier.on(d.EditorEventType.ColorPickerColorSelected,(o=>{o.kind===d.EditorEventType.ColorPickerColorSelected&&(o=>{let n=!1;for(const e of t)e===o&&(n=!0);n||(t.push(o),t.length>12&&t.splice(e,1),i())})(o.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[I.rootToolbarId]=this.serializeInternal(),JSON.stringify(t)}deserializeState(t){const e=JSON.parse(t),o=I.rootToolbarId;this.deserializeInternal(e[o]);for(const t in e)t!==o&&(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,o=!0){"boolean"==typeof o&&(o={mustBeToplevel:o});const n=o.mustBeToplevel??!0,i=o.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,n,i)}addActionButton(t,e,o=!0){const n=this.makeActionButton(t,e,o);return this.addWidget(n),n}addTaggedActionButton(t,e,o,n=!0){const i=this.makeActionButton(e,o,n);return i.setTags(t),this.addWidget(i),i}addSaveButton(t,e={}){const o=new M.default(this.editor,this.localizationTable,t,e);return this.addWidget(o),o}addExitButton(t,e={}){const o=new _.default(this.editor,this.localizationTable,t,e);return this.addWidget(o),o}addUndoRedoButtons(t=!0){const e=()=>this.addTaggedActionButton([T.ToolbarWidgetTag.Undo],{label:this.localizationTable.undo,icon:this.editor.icons.makeUndoIcon()},(()=>{this.editor.history.undo()})),o=()=>this.addTaggedActionButton([T.ToolbarWidgetTag.Redo],{label:this.localizationTable.redo,icon:this.editor.icons.makeRedoIcon()},(()=>{this.editor.history.redo()}));let n,i;t?(n=e(),i=o()):(i=o(),n=e()),n.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!");n.setDisabled(0===t.undoStackSize),i.setDisabled(0===t.redoStackSize)}))}addWidgetsForPrimaryTools(t){for(const e of this.editor.toolController.getPrimaryTools())if(!t||t?.(e))if(e instanceof b.default){const t=new y.default(this.editor,e,this.localizationTable);this.addWidget(t)}else e instanceof g.default?this.addWidget(new v.default(this.editor,e,this.localizationTable)):e instanceof p.default?this.addWidget(new x.default(this.editor,e,this.localizationTable)):e instanceof m.default?this.addWidget(new w.default(this.editor,e,this.localizationTable)):e instanceof f.default&&this.addWidget(new S.default(this.editor,e,this.localizationTable))}addDefaultToolWidgets(){this.addWidgetsForPrimaryTools(),this.addDefaultEditorControlWidgets()}addDefaultEditorControlWidgets(){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,n,"f"))t.remove();l(this,n,[],"f"),this.onRemove();for(const t of a(this,r,"f"))t.remove()}manageListener(t){a(this,n,"f").push(t)}}n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,I.colorisStarted=!1,I.rootToolbarId="root-toolbar--",e.default=I},4659:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeDropdownToolbar=void 0;const i=o(7806),r=n(o(816)),s=n(o(2101)),a=o(2034);e.makeDropdownToolbar=t=>new l(t,t.getRootElement());class l extends s.default{constructor(t,e,o=i.defaultToolbarLocalization){super(t,o),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 o of t)o.isHidden()||(e+=o.getButtonWidth());return e},e=this.getAllWidgets();let o=t(this.overflowWidget.getChildWidgets()),n=t(e)-o,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-n)){const t=this.overflowWidget.clearChildren();for(const e of t)e.addTo(this.container),e.setIsToplevel(!0),e.isHidden()||(n+=e.getButtonWidth());o=0,r=!0}if(n>=i){for(let t=e.length-1;t>=0&&n>=i;t--){const o=e[t];this.overflowWidget.hasAsChild(o)||o.canBeInOverflowMenu()&&(n-=o.getButtonWidth(),this.overflowWidget.addToOverflow(o))}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},1083:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeEdgeToolbar=void 0;const i=o(5068),r=o(2034),s=n(o(4175)),a=o(7988),l=n(o(2101)),c=n(o(9292)),d=n(o(1576));e.makeEdgeToolbar=t=>new h(t,t.getRootElement(),t.localization);class h extends l.default{constructor(t,e,o){super(t,o),this.clearDragListeners=null,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),o),this.sidebarTitle.onUpdateAndNow((t=>{this.closeButton.setAttribute("aria-label",o.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");const e=window.matchMedia?.("(prefers-reduced-motion: reduce)")??"";this.sidebarVisible.onUpdate((o=>{const n="170ms ease",i=e.matches?"-reduce-motion":"";o?(this.sidebarY.set(this.snappedSidebarY()),t&&(clearTimeout(t),t=null),this.menuContainer.style.display="",this.sidebarContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-transition-in${i}`,this.menuContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-container-transition-in${i}`,this.menuContainer.style.opacity="1",this.closeButton.focus({preventScroll:!0})):(this.closeColorPickers(),null===t&&(this.sidebarContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-transition-out${i}`,this.menuContainer.style.animation=`${n} ${r.toolbarCSSPrefix}-edgemenu-container-transition-out${i}`,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,o=0,n=0;for(const i of this.toolbarToolRow.children){const r=i.clientHeight;if(e+=r,n++,e>t){o=t-e+r/2,o<0&&(o+=r);break}}const i=Math.round(o/n*10)/10;this.toolbarToolRow.style.setProperty("--extra-left-right-padding",`${i}px`)},e=this.toolbarActionRow.getBoundingClientRect(),o=this.toolbarToolRow.getBoundingClientRect();e.y+e.height<=o.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-left")),e.includes(i.ToolbarWidgetTag.Exit)&&(t.addCSSClassToContainer("label-inline"),t.addCSSClassToContainer("label-right"))}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(),this.clearDragListeners?.()}initDragListeners(){const t=[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),setTimeout((()=>this.editor.focus()),0)),!0):!this.sidebarVisible.get()),((t,e)=>e.target===this.menuContainer)));let e=!0,o=0;const n=(0,d.default)(this.sidebarContainer,{draggableChildElements:t,onDrag:(t,e)=>this.handleDrag(t,e),onDragEnd:t=>{o=t.endTimestamp,e=t.roughlyClick,this.finalizeDrag()}});this.clearDragListeners=()=>n.removeListeners(),this.closeButton.onclick=()=>{const t=performance.now()-o<100;(t&&e||!t)&&this.sidebarVisible.set(!1)}}handleDrag(t,e){this.sidebarContainer.style.transition="none",this.sidebarY.set(this.sidebarY.get()+e)}snappedSidebarY(t){const e=t??this.sidebarY.get(),o=[-100,0];this.sidebarContainer.clientHeight>window.innerHeight&&o.push(100);let n=o[0];for(const t of o)Math.abs(t-e)<Math.abs(n-e)&&(n=t);return n}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=h},6975:function(t,e,o){"use strict";var n,i,r=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.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=o(5379),l=s(o(1598)),c=s(o(4093)),d=o(9177),h=o(1342),u=o(1011),p=o(7964),f="http://www.w3.org/2000/svg";let m=0;const g=()=>{const t="checkerboard-"+m++,e=(0,p.createSvgElement)("pattern",{id:t,viewBox:"0,0,10,10",width:"20%",height:"20%",patternUnits:"userSpaceOnUse",children:(0,p.createSvgElements)("rect",[{x:0,y:0,width:10,height:10,fill:"white"},{x:0,y:0,width:5,height:5,fill:"gray"},{x:5,y:5,width:5,height:5,fill:"gray"}])}),o=`url(#${t})`;return{patternDefElement:e,get patternDef(){return e.innerHTML},patternRef:o}},b=t=>{const e=document.createElementNS(f,"svg");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";const o=document.createElementNS(f,"path");return o.setAttribute("d","M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80"),o.classList.add("toolbar-svg-undo-redo-icon"),t&&(o.style.transform="scale(-1, 1)"),e.appendChild(o),e.setAttribute("viewBox","0 0 100 100"),e};n=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(){n.add(this)}makeUndoIcon(){return b(!0)}makeRedoIcon(){return b(!1)}makeDropdownIcon(){const t=this.makeIconFromPath("M5,10 L50,90 L95,10 Z");return t.setAttribute("viewBox","-10 -10 110 110"),t}makeEraserIcon(t,e){t??=10;const o=t/4,n="#ff70af";return(0,p.createSvgElement)("svg",{viewBox:"0 0 120 120",children:[(0,p.createSvgElement)("defs",{children:[(0,p.createSvgElement)("linearGradient",{id:"dash-pattern",children:(0,p.createSvgElements)("stop",[{offset:"80%","stop-color":n},{offset:"85%","stop-color":"white"},{offset:"90%","stop-color":n}])})]}),(0,p.createSvgElement)("path",{fill:e===u.EraserMode.PartialStroke?"url(#dash-pattern)":n,stroke:"black",transform:"rotate(41.35)",d:`\n\t\t\t\t\t\tM 52.5 27\n\t\t\t\t\t\tC 50 28.9 48.9 31.7 48.9 34.8\n\t\t\t\t\t\tL 48.9 39.8\n\t\t\t\t\t\tC 48.9 45.3 53.4 49.8 58.9 49.8\n\t\t\t\t\t\tL 103.9 49.8\n\t\t\t\t\t\tC 105.8 49.8 107.6 49.2 109.1 48.3\n\t\t\t\t\t\tL 110.2 ${o+49.5} L 159.7 ${o+5}\n\t\t\t\t\t\tL 157.7 ${5.2-o} L 112.4 ${49.5-o}\n\t\t\t\t\t\tC 113.4 43.5 113.9 41.7 113.9 39.8\n\t\t\t\t\t\tL 113.9 34.8\n\t\t\t\t\t\tC 113.9 29.3 109.4 24.8 103.9 24.8\n\t\t\t\t\t\tL 58.9 24.8\n\t\t\t\t\t\tC 56.5 24.8 54.3 25.7 52.5 27\n\t\t\t\t\t\tz\n\t\t\t\t\t`}),(0,p.createSvgElement)("rect",{stroke:"#cc8077",fill:"var(--icon-color)",width:65,height:75,x:48.9,y:-38.7,transform:"rotate(41.35)"})]})}makeSelectionIcon(){const t=document.createElementNS(f,"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(f,"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(f,"svg");t.setAttribute("viewBox","0 0 100 100");const e=(e,o,n)=>{const i=document.createElementNS(f,"text");i.appendChild(document.createTextNode(e)),i.setAttribute("x",o.toString()),i.setAttribute("y",n.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(f,"svg");e.setAttribute("viewBox","0 0 100 100");const o=document.createElementNS(f,"text");return o.appendChild(document.createTextNode("T")),o.style.fontFamily=t.fontFamily,o.style.fontWeight=t.fontWeight??"",o.style.fontVariant=t.fontVariant??"",o.style.fill=t.renderingStyle.fill.toHexString(),o.style.textAnchor="middle",o.setAttribute("x","50"),o.setAttribute("y","75"),o.style.fontSize="65px",o.style.filter="drop-shadow(0px 0px 10px var(--shadow-color))",e.appendChild(o),e}makePenIcon(t){const e=Math.round(4*Math.sqrt(t.thickness)),o=t.color,n=e/2,i=`\n\t\t\tM ${15-n},${80-n}\n\t\t\t ${15-n},${80+n}\n\t\t\t 30,83\n\t\t\t 15,65\n\t\t\tZ\n\t\t`,r=80+n,s=`\n\t\t\tm ${15-1.1*n},${r}\n\t\t\tc 35,10 55,15 60,30\n\t\t\tl ${35+1.2*n},${-10-n}\n\t\t\tC 80.47,98.32 50.5,${90+n} 20,${r} Z\n\t\t`,l="\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 c="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",d="M 25,35 H 35 L 90,-15 85,-25 Z",h="M 60,75 65,65 H 55 l 55,-55 10,5 z";this.isRoundedTipPen(t)&&(c="M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z",d="m 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z",h="M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z");const u=`M 25,35 ${10-n/4},${70-n/2} 20,75 25,85 60,75 70,55 45,25 Z`,m=a.Color4.fromHex("#f4d7d7").mix(o,n/40-.1).toHexString(),b=g(),y=o.toHexString(),v=(0,p.createSvgPaths)({fill:b.patternRef,d:i},{fill:b.patternRef,d:s},{fill:y,d:i},{fill:y,d:s}),x=(0,p.createSvgPaths)({fill:b.patternRef,d:u},{fill:m,stroke:y,d:u}),w=(0,p.createSvgPaths)({fill:"var(--icon-color)",stroke:"var(--icon-color)",d:c},{fill:"rgba(150, 150, 150, 0.3)",d},{fill:"rgba(100, 100, 100, 0.2)",d:h},{fill:b.patternRef,d:l},{fill:y,d:l}),S=document.createElementNS(f,"svg");S.setAttribute("viewBox","0 0 100 100");const T=(0,p.createSvgElement)("g",{children:[v,x,w].flat()}),C=(0,p.createSvgElement)("defs",{children:[b.patternDefElement]});return S.replaceChildren(C,T),S}makeIconFromFactory(t){const e=3*Math.sqrt(t.thickness),o=performance.now(),n={pos:a.Vec2.of(10,10),width:e,color:t.color,time:o-100},i={pos:a.Vec2.of(90,90),width:e,color:t.color,time:o},r=new c.default((()=>{})),s=t.factory(n,r);s.addPoint(i);const d=document.createElementNS(f,"svg");let h;d.setAttribute("viewBox","0 0 100 100"),r.updateScreenSize(a.Vec2.of(100,100));if(t.color.a<1){const t=g(),e=document.createElementNS(f,"defs");e.appendChild(t.patternDefElement),d.appendChild(e);const o=document.createElementNS(f,"g");d.appendChild(o),h=new class extends l.default{constructor(){super(d,r)}addPathToSVG(){const e=super.addPathToSVG();if(e){const n=e.cloneNode(!0);n.style.zIndex="-1",n.hasAttribute("stroke")?n.setAttribute("stroke",t.patternRef):n.hasAttribute("fill")&&n.setAttribute("fill",t.patternRef),o.appendChild(n)}return e}}}else h=new l.default(d,r);s.preview(h);const u=s.getBBox();return d.setAttribute("viewBox",`${u.x} ${u.y} ${u.w} ${u.h}`),d}makePipetteIcon(t){const e=document.createElementNS(f,"svg"),o=document.createElementNS(f,"g");o.style.rotate="45deg",o.style.transformOrigin="center";const n=document.createElementNS(f,"g");if(n.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 n=g(),i=document.createElementNS(f,"defs");i.appendChild(n.patternDefElement),e.appendChild(i);const r=document.createElementNS(f,"path"),s=document.createElementNS(f,"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=n.patternRef,o.appendChild(r),o.appendChild(s)}return o.appendChild(n),e.appendChild(o),e.setAttribute("viewBox","5 -40 140 140"),e}makeShapeAutocorrectIcon(){return this.makeIconFromPath("\n\t\t\tm 79.129476,33.847107 9.967823,-0.03218 v 55 h -55 l 0.03218,-9.96782\n\t\t\tM 71.1,40.8 a 30,30 0 0 1 -30,30 30,30 0 0 1 -30,-30 30,30 0 0 1 30,-30 30,30 0 0 1 30,30 L 71.1,40.8\n\t\t\tM 34.1,58.8 v -25 h 25 v 0\n\t\t","none","var(--icon-color)","7px")}makeStrokeSmoothingIcon(){return this.makeIconFromPath("\n\t\t\tm 31,83.2 c -50,0 30,-65 -20,-65\n\t\t\tM 75,17.3 40,59.7 38.2,77.6 55.5,72.4 90.5,30 Z\n\t\t","none","var(--icon-color)","7px")}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")}makeCopyIcon(){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,n,"m",i).call(this)}makeCloseIcon(){return r(this,n,"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")}makeHelpIcon(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.innerHTML='\n\t\t\t<circle\n\t\t\t\tstyle="stroke-width:1.587; stroke: var(--icon-color);"\n\t\t\t\tfill="none"\n\t\t\t\tcx="13.23"\n\t\t\t\tcy="13.23"\n\t\t\t\tr="11.9"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tstyle="stroke-width: 3; stroke-linecap: butt; stroke: var(--icon-color);"\n\t\t\t\tfill="none"\n\t\t\t\td="M 9.26,6.61 C 18.7,3.25 19.95,10.4 14.3,13.4 c -1.15,0.61 -1.32,1.32 -1.32,2.65 v 2.12"\n\t\t\t/>\n\t\t\t<circle\n\t\t\t\tstyle="fill: var(--icon-color);"\n\t\t\t\tcx="13"\n\t\t\t\tcy="21.32"\n\t\t\t\tr="1.9"\n\t\t\t/>\n\t\t',t.setAttribute("viewBox","0 0 26.46 26.46"),t.setAttribute("width","100"),t.setAttribute("height","100"),t}makeIconFromPath(t,e="var(--icon-color)",o="none",n="0px"){const i=document.createElementNS(f,"svg"),r=document.createElementNS(f,"path");return r.setAttribute("d",t),r.style.fill=e,r.style.stroke=o,r.style.strokeWidth=n,i.appendChild(r),i.setAttribute("viewBox","0 0 100 100"),i}makeCheckerboardPattern(){return g()}isRoundedTipPen(t){return t.factory===d.makeFreehandLineBuilder||t.factory===h.makePolylineBuilder}isPolylinePen(t){return t.factory===h.makePolylineBuilder}licenseInfo(){return null}}},2034:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toolbarCSSPrefix=void 0,e.toolbarCSSPrefix="toolbar-"},3280:function(t,e,o){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),i=this&&this.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)},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(o(6006),e),i(o(9943),e);var s=o(6975);Object.defineProperty(e,"IconProvider",{enumerable:!0,get:function(){return r(s).default}});var a=o(4659);Object.defineProperty(e,"makeDropdownToolbar",{enumerable:!0,get:function(){return a.makeDropdownToolbar}});var l=o(1083);Object.defineProperty(e,"makeEdgeToolbar",{enumerable:!0,get:function(){return l.makeEdgeToolbar}})},7806:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarLocalization=void 0;const n=o(4816);e.defaultToolbarLocalization={...n.defaultToolbarUtilsLocalization,pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text",decreaseImageSize:"Decrease size",resetImage:"Reset",chooseFile:"Choose file",dragAndDropHereOrBrowse:"Drag and drop here\nor\n{{browse}}",submit:"Submit",addAll:"Add all",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",fullStrokeEraser:"Full stroke eraser",selectPenType:"Pen type",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:"Stabilization",strokeAutocorrect:"Autocorrect",touchPanning:"Scroll with touch",roundedTipPen:"Round",roundedTipPen2:"Polyline",flatTipPen:"Flat",arrowPen:"Arrow",linePen:"Line",outlinedRectanglePen:"Outlined rectangle",filledRectanglePen:"Filled rectangle",outlinedCirclePen:"Outlined circle",lockRotation:"Lock rotation",paste:"Paste",errorImageHasZeroSize:"Error: Image has zero size",describeTheImage:"Image description",fileInput__loading:"Loading...",fileInput__andNMoreFiles:t=>`(...${t} more)`,penDropdown__baseHelpText:"This tool draws shapes or freehand lines.",penDropdown__colorHelpText:"Changes the pen's color",penDropdown__thicknessHelpText:"Changes the thickness of strokes drawn by the pen.",penDropdown__penTypeHelpText:"Changes the pen style.\n\nEither a “pen” style or “shape” can be chosen. Choosing a “pen” style draws freehand lines. Choosing a “shape” draws shapes.",penDropdown__autocorrectHelpText:"Converts approximate freehand lines and rectangles to perfect ones.\n\nThe pen must be held stationary at the end of a stroke to trigger a correction.",penDropdown__stabilizationHelpText:"Draws smoother strokes.\n\nThis also adds a short delay between the mouse/stylus and the stroke.",handDropdown__baseHelpText:"This tool is responsible for scrolling, rotating, and zooming the editor.",handDropdown__zoomInHelpText:"Zooms in.",handDropdown__zoomOutHelpText:"Zooms out.",handDropdown__resetViewHelpText:"Resets the zoom level to 100% and resets scroll.",handDropdown__zoomDisplayHelpText:"Shows the current zoom level. 100% shows the image at its actual size.",handDropdown__touchPanningHelpText:"When enabled, touchscreen gestures move the image rather than select or draw.",handDropdown__lockRotationHelpText:"When enabled, prevents touch gestures from rotating the screen.",eraserDropdown__baseHelpText:"This tool removes strokes, images, and text under the cursor.",eraserDropdown__thicknessHelpText:"Changes the size of the eraser.",eraserDropdown__fullStrokeEraserHelpText:"When in full-stroke mode, entire shapes are erased.\n\nWhen not in full-stroke mode, shapes can be partially erased.",selectionDropdown__baseHelpText:"Selects content and manipulates the selection",selectionDropdown__resizeToHelpText:"Crops the drawing to the size of what's currently selected.\n\nIf auto-resize is enabled, it will be disabled.",selectionDropdown__deleteHelpText:"Erases selected items.",selectionDropdown__duplicateHelpText:"Makes a copy of selected items.",selectionDropdown__changeColorHelpText:"Changes the color of selected items.",pageDropdown__baseHelpText:"Controls the drawing canvas' background color, pattern, and size.",pageDropdown__backgroundColorHelpText:"Changes the background color of the drawing canvas.",pageDropdown__gridCheckboxHelpText:"Enables/disables a background grid pattern.",pageDropdown__autoresizeCheckboxHelpText:"When checked, the page grows to fit the drawing.\n\nWhen unchecked, the page is visible and its size can be set manually.",pageDropdown__aboutButtonHelpText:"Shows version, debug, and other information.",colorPickerPipetteHelpText:"Picks a color from the screen.",colorPickerToggleHelpText:"Opens/closes the color picker.",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}`,imageLoadError:t=>`Error loading image: ${t}`}},2722:function(t,e,o){"use strict";var n,i=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=o(5379),a=r(o(1576)),l=o(7988),c=r(o(4339)),d=r(o(3676));n=new WeakMap,e.default=class{constructor(t,e){this.createOverlay=t,this.context=e,n.set(this,[])}showHelpOverlay(){const t=document.createElement("dialog");t.setAttribute("autofocus","true"),t.classList.add("toolbar-help-overlay");const e=()=>{t.classList.add("-hiding"),setTimeout((()=>t.close()),250)};let o=0;const r=()=>{performance.now()-o<100||e()},h=(()=>{const t=l.MutableReactiveValue.fromInitialValue(0),e=document.createElement("div");e.classList.add("navigation-content");const o=((t,e,o,n)=>{const i=document.createElement("div");i.classList.add("help-page-container");const r=document.createElement("div");r.classList.add("label","-space-above"),r.setAttribute("aria-live","polite");let a=0,l=t[0]??null,h=[];i.addEventListener("click",(t=>{t.target===i&&o()}));const u=()=>{if(!l)return s.Rect2.empty;const t=l.targetElements.map((t=>s.Rect2.of(t.getBoundingClientRect())));return s.Rect2.union(...t)},p=()=>{const t=u();for(let o=0;o<h.length;o++)for(const{container:n,bbox:i}of h[o])if(o===a)n.classList.add("-active"),n.classList.remove("-clickable","-background"),n.onclick=()=>{};else{i.containsRect(t)?(n.classList.add("-background"),n.classList.remove("-active","-clickable")):(n.classList.add("-clickable"),n.classList.remove("-active","-background"));const r=o;n.onclick=()=>{e(r)}}},f=()=>{const t=s.Rect2.of(r.getBoundingClientRect()),e=u();if(t.intersects(e)){const o=s.Rect2.of(i.getBoundingClientRect()),n=e.topLeft.y,a=o.bottomLeft.y-e.bottomLeft.y;n>a&&n>t.height/3&&(r.classList.remove("-small-space-above","-large-space-above"),r.classList.add("-large-space-below")),n<a&&a>t.height&&(r.classList.add("-large-space-above"),r.classList.remove("-large-space-below"))}},m=()=>{i.replaceChildren(),r.classList.remove("-large-space-above"),r.classList.add("-small-space-above","-large-space-below"),i.appendChild(r);const e=new s.Rect2(0,0,window.innerWidth,window.innerHeight);h=[];for(let o=0;o<t.length;o++){const n=t[o],r=[];for(const t of n.targetElements){let o=s.Rect2.of(t.getBoundingClientRect());if(!e.intersects(o)){const t=e.bottomLeft.lerp(e.bottomRight,.5),n=o.bottomLeft.lerp(o.bottomRight,.5),i=t.minus(n);o=o.translatedBy(i)}const n=(0,c.default)(t);for(const t of n.querySelectorAll("input"))t.disabled=!0;n.style.margin="0";const a=document.createElement("div");a.classList.add("cloned-element-container"),a.style.position="absolute",a.style.left=`${o.topLeft.x}px`,a.style.top=`${o.topLeft.y}px`,a.replaceChildren(n),(0,d.default)(a,{timeout:0}),r.push({container:a,bbox:o}),i.appendChild(a)}h.push(r)}p()},g=()=>{const t=document.createElement("div");t.innerText=l?.helpText??"",t.classList.add("current-item-help");const e=document.createElement("div");e.innerText=n.localization.helpScreenNavigationHelp,e.classList.add("navigation-help"),r.replaceChildren(t,...0===a?[e]:[]),p()};return g(),{addToParent:t=>{m(),t.appendChild(i),f()},refresh:()=>{m(),f()},setPageIndex:e=>{a=e,l=t[e],g()}}})(i(this,n,"f"),(e=>t.set(e)),r,this.context);o.addToParent(e);t.onUpdateAndNow((t=>{t>=i(this,n,"f").length||t<0?(console.warn("Help screen: Navigated to out-of-bounds page",t),e.style.display="none"):(e.style.display="",o.setPageIndex(t))}));const a={content:e,currentPage:t,toNext:()=>{a.hasNext()&&t.set(t.get()+1)},toPrevious:()=>{a.hasPrevious()&&t.set(t.get()-1)},hasNext:()=>t.get()+1<i(this,n,"f").length,hasPrevious:()=>t.get()>0,refreshCurrent:()=>{o.refresh()}};return a})(),u=(t=>{const e=document.createElement("div");e.classList.add("navigation-buttons");const o=document.createElement("button"),n=document.createElement("button");o.innerText=this.context.localization.next,n.innerText=this.context.localization.previous,o.classList.add("next"),n.classList.add("previous");return t.currentPage.onUpdateAndNow((()=>{e.classList.remove("-has-next","-has-previous"),t.hasNext()?(e.classList.add("-has-next"),o.disabled=!1):(e.classList.remove("-has-next"),o.disabled=!0),t.hasPrevious()?(e.classList.add("-has-previous"),n.disabled=!1):(e.classList.remove("-has-previous"),n.disabled=!0)})),o.onclick=()=>{t.toNext()},n.onclick=()=>{t.toPrevious()},e.replaceChildren(n,o),e})(h);t.replaceChildren((()=>{const t=document.createElement("button");t.classList.add("close-button"),t.appendChild(this.context.icons.makeCloseIcon());const o=this.context.localization.close;return t.setAttribute("aria-label",o),t.setAttribute("title",o),t.onclick=()=>{e()},t})(),u,h.content),this.createOverlay(t),t.showModal();const p=30,f=e=>{e>0&&!h.hasPrevious()&&(e=0),e<0&&!h.hasNext()&&(e=0),(e>p||e<-30)&&(e=p*Math.sign(e)),t.style.transform=`translate(${e}px, 0px)`,e>=p?u.classList.add("-highlight-previous"):u.classList.remove("-highlight-previous"),e<=-30?u.classList.add("-highlight-next"):u.classList.remove("-highlight-next")},m=(0,a.default)(t,{draggableChildElements:[h.content],onDrag:(e,o,n)=>{t.classList.add("-dragging"),f(n.x)},onDragEnd:e=>{if(t.classList.remove("-dragging"),f(0),!e.roughlyClick){const t=e.displacement.x;t>p?h.toPrevious():t<-30&&h.toNext(),o=e.endTimestamp}}});let g;window.ResizeObserver&&(g=new ResizeObserver((()=>{h.refreshCurrent()})),g.observe(t));const b=()=>{requestAnimationFrame((()=>h.refreshCurrent()))},y=window.matchMedia?.("(prefers-color-scheme: dark)");y?.addEventListener("change",b);const v=[h.content,u,t];t.onclick=t=>{v.includes(t.target)&&r()},t.onkeyup=t=>{"Escape"===t.code?(e(),t.preventDefault()):"ArrowRight"===t.code?(h.toNext(),t.preventDefault()):"ArrowLeft"===t.code&&(h.toPrevious(),t.preventDefault())},t.addEventListener("close",(()=>{this.context.announceForAccessibility(this.context.localization.helpHidden),y?.removeEventListener("change",b),m.removeListeners(),g?.disconnect(),t.remove()}))}registerTextHelpForElement(t,e){this.registerTextHelpForElements([t],e)}registerTextHelpForElements(t,e){i(this,n,"f").push({targetElements:[...t],helpText:e})}hasHelpText(){return i(this,n,"f").length>0}createToggleButton(){const t=document.createElement("div");t.classList.add("toolbar-help-overlay-button");const e=document.createElement("button");e.classList.add("button");const o=this.context.icons.makeHelpIcon();return o.classList.add("icon"),e.appendChild(o),e.setAttribute("aria-label",this.context.localization.help),e.onclick=()=>{this.showHelpOverlay()},t.appendChild(e),t}}},4816:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarUtilsLocalization=void 0,e.defaultToolbarUtilsLocalization={help:"Help",helpHidden:"Help hidden",next:"Next",previous:"Previous",close:"Close",helpScreenNavigationHelp:"Click on a control for more information."}},1576:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379);e.default=(t,e)=>{const o=[...e.draggableChildElements,t];let i=0,r=0,s=0,a=0,l=!1,c=null;const d=[],h=(e,o,n)=>{t.addEventListener(e,o,n),d.push((()=>{t.removeEventListener(e,o)}))},u=()=>Math.hypot(i-s,r-a)<5;let p=!1;h("pointerdown",(t=>{!t.defaultPrevented&&(t=>{if(!t)return!1;if(o.includes(t))return!0;const e=["INPUT","SELECT","IMG"];let n=!1,i=t.parentElement;for(;i&&!e.includes(i.tagName);){if(o.includes(i)){n=!0;break}i=i.parentElement}return!e.includes(t.tagName)&&n})(t.target)&&t.isPrimary&&(p=!1,i=t.clientX,r=t.clientY,s=t.clientX,a=t.clientY,c=null,l=!0)}),{passive:!0});const f=o=>{l&&(null!==c&&(t.releasePointerCapture(c),c=null),e.onDragEnd({roughlyClick:u(),endTimestamp:performance.now(),displacement:n.Vec2.of(i-s,r-a)}),l=!1,p=!1)};return h("pointermove",(o=>{if(!o.isPrimary||!l)return;if("mouse"===o.pointerType&&0===o.buttons)return void f();null!==c||u()||(t.setPointerCapture(o.pointerId),c=o.pointerId);const d=o.clientX,h=o.clientY,m=d-i,g=h-r;Math.abs(d-s)<=5&&Math.abs(h-a)<=5&&!p||(e.onDrag(m,g,n.Vec2.of(d-s,h-a)),i=d,r=h,p=!0)})),h("pointerleave",(e=>{null===c&&l&&e.isPrimary&&(t.setPointerCapture(e.pointerId),c=e.pointerId)})),h("pointerup",f),h("pointercancel",f),{removeListeners:()=>{for(const t of d)t()}}}},9751:function(t,e,o){"use strict";var n,i,r=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},s=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const l=a(o(5068));class c extends l.default{constructor(t,e,o,s,a,l,c=!1,d=!0){super(t,e,l),this.makeIcon=o,this.title=s,this.clickAction=a,this.mustBeToplevel=c,n.set(this,void 0),i.set(this,void 0),r(this,n,d,"f")}setHelpText(t){r(this,i,t,"f")}getHelpText(){return s(this,i,"f")}shouldAutoDisableInReadOnlyEditor(){return s(this,n,"f")}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}mustBeInToplevelMenu(){return this.mustBeToplevel}}n=new WeakMap,i=new WeakMap,e.default=c},550:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(5068)),r=o(2034);class s extends i.default{constructor(t,e,o,n){super(t,o,n),this.targetTool=e,this.targetTool.enabledValue().onUpdateAndNow((t=>{t?(this.setSelected(!0),(()=>{const t=[...document.querySelectorAll("*:focus")];return t.length&&t.some((t=>t.classList.contains(`${r.toolbarCSSPrefix}button`)))})()&&this.focus()):(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()||"Space"!==t.code||!this.hasDropdown)&&(this.handleClick(),!0)}addTo(t){const e=super.addTo(t);return this.setSelected(this.targetTool.isEnabled()),e}}e.default=s},5068:function(t,e,o){"use strict";var n,i,r,s,a,l,c,d=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},h=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ToolbarWidgetTag=void 0;const p=u(o(5716)),f=o(7394),m=o(2034),g=u(o(418)),b=u(o(3676)),y=u(o(2722));var v;!function(t){t.Save="save",t.Exit="exit",t.Undo="undo",t.Redo="redo"}(v||(e.ToolbarWidgetTag=v={}));class x{constructor(t,e,o){n.add(this),this.editor=t,this.id=e,this.dropdown=null,r.set(this,void 0),this.disabled=!1,s.set(this,!1),a.set(this,[]),this.subWidgets={},this.toplevel=!0,l.set(this,null),this.localizationTable=o??t.localization;const i=new g.default((t=>this.editor.announceForAccessibility(t)),this.localizationTable);i.connectToEditorNotifier(t.notifier),this.layoutManager=i,this.icon=null,this.container=document.createElement("div"),this.container.classList.add(`${m.toolbarCSSPrefix}toolContainer`,`${m.toolbarCSSPrefix}toolButtonContainer`,`${m.toolbarCSSPrefix}internalWidgetId--${e.replace(/[^a-zA-Z0-9_]/g,"-")}`),this.dropdownContent=document.createElement("div"),d(this,r,!1,"f"),this.button=document.createElement("div"),this.button.classList.add(`${m.toolbarCSSPrefix}button`),this.label=document.createElement("label"),this.button.setAttribute("role","button"),this.button.tabIndex=0,this.button.oncontextmenu=t=>{t.preventDefault()},(0,b.default)(this.button)}shouldAutoDisableInReadOnlyEditor(){return!0}getId(){return this.id}setTags(t){const e=t=>`toolwidget-tag--${t}`;for(const t of h(this,a,"f"))this.container.classList.remove(e(t));d(this,a,[...t],"f");for(const t of h(this,a,"f"))this.container.classList.add(e(t))}getTags(){return[...h(this,a,"f")]}getUniqueIdIn(t){let e=this.getId(),o=0;for(;e in t&&t[e]!==this;)e=this.getId()+"-"+o.toString(),o++;return e}fillDropdown(t,e){if(0===Object.keys(this.subWidgets).length)return!1;for(const o in this.subWidgets){const n=this.subWidgets[o],i=n.addTo(t);n.setIsToplevel(!1);const r=n.getHelpText();r&&e?.registerTextHelpForElement(i,r)}return!0}getHelpText(){}setupActionBtnClickListener(t){return this.setUpButtonEventListeners(t)}setUpButtonEventListeners(t){const e={Enter:!0," ":!0};t.onkeydown=t=>{let o=!1;if(t.key in e&&(this.disabled||(this.handleClick(),o=!0)),!o){const e=(0,f.keyPressEventFromHTMLEvent)(t);o=this.editor.toolController.dispatchInputEvent(e)}o&&t.preventDefault()},t.onkeyup=t=>{if(t.key in e)return;const o=(0,f.keyUpEventFromHTMLEvent)(t);this.editor.toolController.dispatchInputEvent(o)&&t.preventDefault()},t.onclick=()=>{this.disabled||this.handleClick()},t.ondblclick=t=>{t.preventDefault()}}onKeyPress(t){return!1}get hasDropdown(){return h(this,r,"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";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);const o=new y.default((t=>this.editor.createHTMLOverlay(t)),this.editor),i=this.getHelpText();return i&&o.registerTextHelpForElement(this.dropdownContent,[this.getTitle(),i].join("\n\n")),this.dropdownContent.replaceChildren(),d(this,r,this.fillDropdown(this.dropdownContent,o),"f"),h(this,r,"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()})),o.hasHelpText()&&this.dropdown.appendChild(o.createToggleButton()),this.dropdown.appendChild(this.dropdownContent)),this.setDropdownVisible(!1),this.container.parentElement&&this.container.remove(),h(this,n,"m",c).call(this),t.appendChild(this.container),this.container}remove(){this.container.remove(),h(this,l,"f")?.call(this)}focus(){this.button.focus()}addCSSClassToContainer(t){this.container.classList.add(t)}removeCSSClassFromContainer(t){this.container.classList.remove(t)}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(`${m.toolbarCSSPrefix}icon`)}setDisabled(t){this.disabled=t,d(this,s,!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(`${m.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])}}i=x,r=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,n=new WeakSet,c=function(){h(this,l,"f")?.call(this);const t=this.editor.toolController.getMatchingTools(p.default);let e=null;if(t.length>0&&this.onKeyPress!==i.prototype.onKeyPress){const o=t=>this.onKeyPress(t),n=t[0];n.registerListener(o),e=()=>{n.removeListener(o)}}const o=this.editor.isReadOnlyReactiveValue().onUpdateAndNow((t=>{t&&this.shouldAutoDisableInReadOnlyEditor()&&!this.disabled?(this.setDisabled(!0),d(this,s,!0,"f"),h(this,r,"f")&&this.dropdown?.requestHide()):!t&&h(this,s,"f")&&(d(this,s,!1,"f"),this.setDisabled(!1))}));d(this,l,(()=>{o.remove(),e?.(),d(this,l,null,"f")}),"f")},e.default=x},7021:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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(o(6188)),c=a(o(2717)),d=s(o(2115)),h=o(7),u=o(5379),p=o(2018),f=o(2034),m=a(o(9943)),g=a(o(5068));class b extends g.default{constructor(t,e){super(t,"document-properties-widget",e),this.updateDropdownContent=()=>{},this.dropdownUpdateQueued=!1,this.container.classList.add("dropdownShowable"),this.editor.notifier.on(p.EditorEventType.UndoRedoStackUpdated,(()=>{this.queueDropdownUpdate()})),this.editor.image.notifier.on(h.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 d.default&&t.push(e);return new l.default(t)}setBackgroundType(t){const e=this.editor.estimateBackgroundColor(),o=new d.default(t,e),n=this.editor.image.addElement(o);return(0,c.default)([this.removeBackgroundComponents(),n])}getBackgroundType(){const t=this.editor.image.getBackgroundComponents();for(let e=t.length-1;e>=0;e--){const o=t[e];if(o instanceof d.default)return o.getBackgroundType()}return d.BackgroundType.None}updateImportExportRectSize(t){const e=t=>(void 0!==t&&(!isFinite(t)||t<=0)&&(t=100),t),o=e(t.width),n=e(t.height),i=this.editor.getImportExportRect(),r=new u.Rect2(i.x,i.y,o??i.w,n??i.h);this.editor.dispatch(this.editor.image.setImportExportRect(r)),this.editor.queueRerender()}getHelpText(){return this.localizationTable.pageDropdown__baseHelpText}fillDropdown(t,e){const o=document.createElement("div");o.classList.add(`${f.toolbarCSSPrefix}spacedList`,`${f.toolbarCSSPrefix}nonbutton-controls-main-list`,`${f.toolbarCSSPrefix}document-properties-widget`);const{backgroundColorRow:n,setBgColorInputValue:i,registerWithHelp:r}=(()=>{const t=document.createElement("div"),e=document.createElement("label");e.innerText=this.localizationTable.backgroundColor;const{input:o,container:n,setValue:i,registerWithHelpTextDisplay:r}=(0,m.default)(this.editor,(t=>{t.eq(this.getBackgroundColor())||this.setBackgroundColor(t)}));o.id=`${f.toolbarCSSPrefix}docPropertiesColorInput-${b.idCounter++}`,e.htmlFor=o.id,t.replaceChildren(e,n);return{setBgColorInputValue:i,backgroundColorRow:t,registerWithHelp:e=>{e&&(e?.registerTextHelpForElement(t,this.localizationTable.pageDropdown__backgroundColorHelpText),r(e))}}})(),s=(t,e)=>{const o=document.createElement("div"),n=document.createElement("label"),i=document.createElement("input");return i.id=`${f.toolbarCSSPrefix}docPropertiesCheckbox-${b.idCounter++}`,n.htmlFor=i.id,i.type="checkbox",n.innerText=t,i.oninput=()=>{e(i.checked)},o.replaceChildren(n,i),{container:o,checkbox:i}},{container:a,checkbox:l}=s(this.localizationTable.useGridOption,(t=>{if(this.getBackgroundType()===d.BackgroundType.Grid===t)return;let e=d.BackgroundType.SolidColor;t&&(e=d.BackgroundType.Grid),this.editor.dispatch(this.setBackgroundType(e))})),c=(t,e)=>{const o=document.createElement("div"),n=document.createElement("label"),i=document.createElement("input");return n.innerText=t,i.type="number",i.min="0",i.id=`${f.toolbarCSSPrefix}docPropertiesDimensionRow-${b.idCounter++}`,n.htmlFor=i.id,i.style.flexGrow="2",i.style.width="25px",i.oninput=()=>{e(parseFloat(i.value))},o.classList.add("js-draw-size-input-row"),o.replaceChildren(n,i),{setValue:t=>{if(document.activeElement===i&&i.value.match(/^0*$/)){const e=i.value;i.type="text",i.value=t.toString();const o=Math.max(1,i.value.length-e.length);i.setSelectionRange(0,o),i.type="number"}else i.value=t.toString()},setIsAutomaticSize:t=>{i.disabled=t;const e="size-input-row--automatic-size";t?o.classList.add(e):o.classList.remove(e)},element:o}},h=c(this.localizationTable.imageWidthOption,(t=>{this.updateImportExportRectSize({width:t})})),u=c(this.localizationTable.imageHeightOption,(t=>{this.updateImportExportRectSize({height:t})})),{container:p,checkbox:g}=s(this.localizationTable.enableAutoresizeOption,(t=>{const e=this.editor.image;this.editor.dispatch(e.setAutoresizeEnabled(t))})),y=document.createElement("button");return y.classList.add("about-button"),y.innerText=this.localizationTable.about,y.onclick=()=>{this.editor.showAboutDialog()},r(e),e?.registerTextHelpForElement(a,this.localizationTable.pageDropdown__gridCheckboxHelpText),e?.registerTextHelpForElement(p,this.localizationTable.pageDropdown__autoresizeCheckboxHelpText),e?.registerTextHelpForElement(y,this.localizationTable.pageDropdown__aboutButtonHelpText),this.updateDropdownContent=()=>{i(this.getBackgroundColor());const t=this.editor.image.getAutoresizeEnabled(),e=this.editor.getImportExportRect();h.setValue(e.width),u.setValue(e.height),g.checked=t,h.setIsAutomaticSize(t),u.setIsAutomaticSize(t),l.checked=this.getBackgroundType()===d.BackgroundType.Grid},this.updateDropdownContent(),o.replaceChildren(n,a,h.element,u.element,p,y),t.replaceChildren(o),!0}}b.idCounter=0,e.default=b},1295:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(1011),r=o(2018),s=o(2034),a=n(o(550)),l=n(o(2059));class c extends a.default{constructor(t,e,o){super(t,e,"eraser-tool-widget",o),this.tool=e,this.updateInputs=()=>{},this.editor.notifier.on(r.EditorEventType.ToolUpdated,(t=>{t.kind===r.EditorEventType.ToolUpdated&&t.tool===this.tool&&(this.updateInputs(),this.updateIcon())}))}getHelpText(){return this.localizationTable.eraserDropdown__baseHelpText}getTitle(){return this.localizationTable.eraser}makeIconForType(t){return this.editor.icons.makeEraserIcon(this.tool.getThickness(),t)}createIcon(){return this.makeIconForType(this.tool.getModeValue().get())}makeEraserTypeSelector(t){const e=document.createElement("div"),o=document.createElement("label"),n=document.createElement("input");n.id=`${s.toolbarCSSPrefix}eraserToolWidget-${c.idCounter++}`,o.htmlFor=n.id,o.innerText=this.localizationTable.fullStrokeEraser,n.type="checkbox",n.oninput=()=>{this.tool.getModeValue().set(n.checked?i.EraserMode.FullStroke:i.EraserMode.PartialStroke)};return e.replaceChildren(o,n),t?.registerTextHelpForElement(e,this.localizationTable.eraserDropdown__fullStrokeEraserHelpText),{addTo:t=>{t.appendChild(e)},updateValue:()=>{n.checked=this.tool.getModeValue().get()===i.EraserMode.FullStroke}}}fillDropdown(t,e){const o=document.createElement("div");o.classList.add(`${s.toolbarCSSPrefix}spacedList`,`${s.toolbarCSSPrefix}nonbutton-controls-main-list`);const n=(0,l.default)(this.editor,(t=>{this.tool.setThickness(t)}));n.setBounds(10,55),e?.registerTextHelpForElement(n.container,this.localizationTable.eraserDropdown__thicknessHelpText);const i=this.makeEraserTypeSelector(e);return this.updateInputs=()=>{n.setValue(this.tool.getThickness()),i.updateValue()},this.updateInputs(),o.replaceChildren(n.container),i.addTo(o),t.replaceChildren(o),!0}serializeState(){return{...super.serializeState(),thickness:this.tool.getThickness(),mode:this.tool.getModeValue().get()}}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)}if(t.mode){const e=t.mode;Object.values(i.EraserMode).includes(e)&&this.tool.getModeValue().set(e)}}}c.idCounter=0,e.default=c},7855:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(9751)),r=o(5068),s=o(9376);class a extends i.default{constructor(t,e,o,n={}){super(t,"exit-button",(()=>n.icon??t.icons.makeCloseIcon()),n.label??e.exit,o),this.setTags([r.ToolbarWidgetTag.Exit])}shouldAutoDisableInReadOnlyEditor(){return!1}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(s.exitKeyboardShortcut,t)?(this.clickAction(),!0):super.onKeyPress(t)}mustBeInToplevelMenu(){return!0}}e.default=a},1210:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=o(5379),c=s(o(7955)),d=o(2018),h=a(o(4093)),u=o(2034),p=a(o(550)),f=a(o(5068)),m=a(o(5007));class g extends f.default{constructor(t,e,o,n,i,r,s){super(t,`pan-mode-${o}`,s),this.tool=e,this.flag=o,this.makeIcon=n,this.title=i,this.helpText=r,t.notifier.on(d.EditorEventType.ToolUpdated,(t=>{if(t.kind===d.EditorEventType.ToolUpdated&&t.tool===e){const t=!!(e.getMode()&c.PanZoomMode.SinglePointerGestures);this.setSelected(!!(e.getMode()&o)||t),this.setDisabled(t&&o!==c.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}getHelpText(){return this.helpText}}class b extends p.default{constructor(t,e,o){const n=t.toolController.getPrimaryTools().includes(e),i=(n?e:b.getPrimaryHandTool(t.toolController))??e;super(t,i,"hand-tool-widget",o),this.overridePanZoomTool=(n?b.getOverrideHandTool(t.toolController):e)??e,this.allowTogglingBaseTool=null!==i,this.allowTogglingBaseTool||this.container.classList.add("dropdownShowable");const r=new g(t,this.overridePanZoomTool,c.PanZoomMode.OneFingerTouchGestures,(()=>this.editor.icons.makeTouchPanningIcon()),o.touchPanning,o.handDropdown__touchPanningHelpText,o),s=new g(t,this.overridePanZoomTool,c.PanZoomMode.RotationLocked,(()=>this.editor.icons.makeRotationLockIcon()),o.lockRotation,o.handDropdown__lockRotationHelpText,o);this.addSubWidget(r),this.addSubWidget(s)}static getPrimaryHandTool(t){return t.getPrimaryTools().filter((t=>t instanceof c.default))[0]}static getOverrideHandTool(t){return t.getMatchingTools(c.default)[0]}shouldAutoDisableInReadOnlyEditor(){return!1}getTitle(){return this.localizationTable.handTool}createIcon(){return this.editor.icons.makeHandToolIcon()}handleClick(){this.allowTogglingBaseTool?super.handleClick():this.setDropdownVisible(!this.isDropdownVisible())}getHelpText(){return this.localizationTable.handDropdown__baseHelpText}fillDropdown(t,e){super.fillDropdown(t,e);const o=document.createElement("div");o.classList.add(`${u.toolbarCSSPrefix}nonbutton-controls-main-list`),(0,m.default)().addTo(o);const n=((t,e,o)=>{const n=document.createElement("div"),i=document.createElement("button"),r=document.createElement("button"),s=document.createElement("button"),a=document.createElement("span");let c;i.innerText="+",r.innerText="-",s.innerText=t.resetView,n.replaceChildren(a,i,r,s),n.classList.add(`${u.toolbarCSSPrefix}zoomLevelEditor`),a.classList.add("zoomDisplay");const p=()=>{let o=100*e.viewport.getScaleFactor();o=o>.1?Math.round(10*o)/10:Math.round(1e3*o)/1e3,o!==c&&(a.innerText=t.zoomLevel(o),c=o)};p(),e.notifier.on(d.EditorEventType.ViewportChanged,(t=>{t.kind===d.EditorEventType.ViewportChanged&&(p(),s.disabled=t.newTransform.eq(l.Mat33.identity))}));const f=t=>{const o=e.viewport.visibleRect.center,n=l.Mat33.scaling2D(t,o);e.dispatch(h.default.transformBy(n),!1)};return i.onclick=()=>{f(5/4)},r.onclick=()=>{f(.8)},s.onclick=()=>{e.dispatch(h.default.transformBy(e.viewport.canvasToScreenTransform.inverse()),!1)},o?.registerTextHelpForElement(i,t.handDropdown__zoomInHelpText),o?.registerTextHelpForElement(r,t.handDropdown__zoomOutHelpText),o?.registerTextHelpForElement(s,t.handDropdown__resetViewHelpText),o?.registerTextHelpForElement(a,t.handDropdown__zoomDisplayHelpText),n})(this.localizationTable,this.editor,e);return o.appendChild(n),t.appendChild(o),!0}setSelected(t){this.allowTogglingBaseTool&&super.setSelected(t)}serializeState(){const t=this.overridePanZoomTool.getMode();return{...super.serializeState(),touchPanning:t&c.PanZoomMode.OneFingerTouchGestures,rotationLocked:t&c.PanZoomMode.RotationLocked}}deserializeFrom(t){void 0!==t.touchPanning&&this.overridePanZoomTool.setModeEnabled(c.PanZoomMode.OneFingerTouchGestures,t.touchPanning),void 0!==t.rotationLocked&&this.overridePanZoomTool.setModeEnabled(c.PanZoomMode.RotationLocked,t.rotationLocked),super.deserializeFrom(t)}}e.default=b},2242:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ImageWrapper=void 0;class o{constructor(t,e,o){this.imageBase64Url=t,this.preview=e,this.onUrlUpdate=o,this.originalSrc=t,e.src=t}updateImageData(t){this.preview.src=t,this.imageBase64Url=t,this.onUrlUpdate()}decreaseSize(t=3/4){const e=document.createElement("canvas");e.width=this.preview.naturalWidth*t,e.height=this.preview.naturalHeight*t;const o=e.getContext("2d");o?.drawImage(this.preview,0,0,e.width,e.height);const n=this.originalSrc?.startsWith("data:image/jpeg;")?"image/jpeg":"image/png";this.updateImageData(e.toDataURL(n))}reset(){this.updateImageData(this.originalSrc)}isChanged(){return this.imageBase64Url!==this.originalSrc}isLarge(){return this.getBase64Url().length>125829.12}getBase64Url(){return this.imageBase64Url}getAltText(){return this.altText}setAltText(t){this.altText=t,this.preview.alt=t}static fromSrcAndPreview(t,e,n){return new o(t,e,n)}static fromRenderable(t,e){const n=new Image;n.src=t.base64Url;const i=new o(t.base64Url,n,e),r=t.label??t.image.getAttribute("alt");return r&&i.setAltText(r),{wrapper:i,preview:n}}}e.ImageWrapper=o},1294:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(4686)),r=n(o(6188)),s=n(o(7)),a=n(o(2717)),l=n(o(1172)),c=o(5379),d=n(o(5068)),h=o(2018),u=o(2034),p=n(o(3634)),f=o(7988),m=n(o(42)),g=o(2242),b=n(o(1265)),y=n(o(7951));class v extends d.default{constructor(t,e){e??=t.localization,super(t,"insert-image-widget",e),this.container.classList.add("dropdownShowable"),t.notifier.on(h.EditorEventType.SelectionUpdated,(t=>{t.kind===h.EditorEventType.SelectionUpdated&&this.isDropdownVisible()&&this.updateInputs()})),this.images=f.MutableReactiveValue.fromInitialValue([]),this.images.onUpdateAndNow((()=>{this.onImageDataUpdate()}))}getTitle(){return this.localizationTable.image}createIcon(){return this.editor.icons.makeInsertImageIcon()}setDropdownVisible(t){super.setDropdownVisible(t),this.isDropdownVisible()?this.updateInputs():this.selectedFiles?.set([])}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){const e=document.createElement("div");e.classList.add("insert-image-widget-dropdown-content",`${u.toolbarCSSPrefix}spacedList`,`${u.toolbarCSSPrefix}nonbutton-controls-main-list`);const{container:o,selectedFiles:n}=(0,p.default)(this.localizationTable.chooseFile,this.editor,{accepts:"image/*",allowMultiSelect:!0,customPickerAction:this.editor.getCurrentSettings().image?.showImagePicker}),i=document.createElement("div");this.imagesPreview=(0,b.default)(this.images),this.statusView=document.createElement("div");const r=document.createElement("div");r.classList.add("action-button-row"),this.statusView.classList.add("insert-image-image-status-view"),this.submitButton=document.createElement("button"),this.selectedFiles=n,this.imageAltTextInput=document.createElement("input");const s=document.createElement("label"),a="insert-image-alt-text-input-"+v.nextInputId++;return this.imageAltTextInput.setAttribute("id",a),s.htmlFor=a,s.innerText=this.localizationTable.inputAltText,this.imageAltTextInput.type="text",this.imageAltTextInput.placeholder=this.localizationTable.describeTheImage,this.statusView.setAttribute("aria-live","polite"),this.submitButton.innerText=this.localizationTable.submit,this.imagesPreview.visibleItem.onUpdateAndNow((()=>this.onImageDataUpdate())),this.imageAltTextInput.oninput=()=>{const t=this.imagesPreview.visibleItem.get();t&&(t.setAltText(this.imageAltTextInput.value),this.submitButton.style.display="")},this.selectedFiles.onUpdateAndNow((async t=>{if(0===t.length)return void this.images.set([]);const e=(await Promise.all(t.map((async t=>{let e;try{e=await(0,y.default)(t)}catch(t){console.error("Image load error",t);const e=this.localizationTable.imageLoadError(t);return this.statusView.innerText=e,[]}return e.map((t=>{const{wrapper:e,preview:o}=g.ImageWrapper.fromRenderable(t,(()=>this.onImageDataUpdate()));return{data:e,element:o}}))})))).flat();this.images.set(e)})),i.replaceChildren(s,this.imageAltTextInput),r.replaceChildren(this.submitButton),e.replaceChildren(o,i,this.imagesPreview.container,this.statusView,r),t.replaceChildren(e),!0}onImageDataUpdate(){if(!this.imagesPreview)return;const t=this.imagesPreview.visibleItem.get(),e=t?.getBase64Url();this.imageAltTextInput.value=t?.getAltText()??"",e?(this.submitButton.disabled=!1,this.submitButton.style.display="",this.updateImageSizeDisplay()):(this.submitButton.disabled=!0,this.submitButton.style.display="none",this.statusView.innerText="",this.submitButton.disabled=!0),this.images.get().length<=1?this.submitButton.innerText=this.localizationTable.submit:this.submitButton.innerText=this.localizationTable.addAll}hideDialog(){this.setDropdownVisible(!1)}updateImageSizeDisplay(){const t=this.imagesPreview.visibleItem.get(),e=t?.getBase64Url()??"",{size:o,units:n}=(0,m.default)(e.length),i=document.createElement("span");i.innerText=this.localizationTable.imageSize(Math.round(o),n);const r=document.createElement("button");r.innerText=this.localizationTable.decreaseImageSize,r.onclick=()=>{t?.decreaseSize()};const s=document.createElement("button");if(s.innerText=this.localizationTable.resetImage,s.onclick=()=>{t?.reset()},this.statusView.replaceChildren(i),t?.isLarge())this.statusView.appendChild(r);else if(t?.isChanged())this.statusView.appendChild(s);else{this.images.get().some((t=>t.data?.isChanged()||t.data?.isLarge()))&&(r.disabled=!0,this.statusView.appendChild(r))}}updateInputs(){(()=>{this.selectedFiles?.set([]),this.imageAltTextInput.value="",this.submitButton.disabled=!0,this.statusView.innerText="",this.submitButton.style.display=""})();const t=this.editor.toolController.getMatchingTools(l.default),e=t.map((t=>t.getSelectedObjects())).flat();let o=null;if(1===e.length&&e[0]instanceof i.default){o=e[0];const t=new Image,n=g.ImageWrapper.fromSrcAndPreview(o.getURL(),t,(()=>this.onImageDataUpdate()));n.setAltText(o.getAltText()??""),this.images.set([{data:n,element:t}])}else e.length>0&&t.forEach((t=>t.clearSelection()));this.submitButton.style.display="none",this.submitButton.onclick=async()=>{const e=[];let n=c.Mat33.identity,l=null;for(const{data:t}of this.images.get()){if(!t)continue;const o=new Image;o.src=t.getBase64Url();const r=t.getAltText();let s;r&&o.setAttribute("alt",r);try{s=await i.default.fromImage(o,n)}catch(t){return console.error("Error loading image",t),void(this.statusView.innerText=this.localizationTable.imageLoadError(t))}const a=s.getBBox();if(0===a.area)return void(this.statusView.innerText=this.localizationTable.errorImageHasZeroSize);e.push(s),l??=a,l.union(a);const d=c.Vec2.of(0,a.height);n=n.rightMul(c.Mat33.translation(d))}if(e.length){if(!l)throw new Error("Logic error: Full bounding box must be calculated when components are to be added.");if(this.hideDialog(),o){const n=new r.default([o]),i=o.getTransformation(),d=o.getBBox().width||1,h=l.transformedBoundingBox(i).width||1,u=c.Mat33.scaling2D(d/h),p=[];for(const t of e)p.push(s.default.addElement(t),t.transformBy(i.rightMul(u)),t.setZIndex(o.getZIndex()));this.editor.dispatch((0,a.default)([...p,n])),t[0]?.setSelection(e)}else await this.editor.addAndCenterComponents(e)}}}}v.nextInputId=0,e.default=v},7951:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8733)),r=o(5379);e.default=async t=>{const e=[],o=new Image,n=await(0,i.default)(t);return n&&e.push({image:o,base64Url:n,transform:r.Mat33.identity}),e}},816:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(5068));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},9108:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(8145),r=o(9177),s=o(14),a=o(9616),l=o(117),c=o(22),d=o(2018),h=n(o(9943)),u=n(o(550)),p=o(5379),f=o(9376),m=o(2034),g=n(o(2059)),b=n(o(3759)),y=o(1342);class v extends u.default{constructor(t,e,o){super(t,e,"pen",o),this.tool=e,this.updateInputs=()=>{},this.shapelikeIDs=["pressure-sensitive-pen","freehand-pen"];const n=t.getCurrentSettings().pens?.additionalPenTypes??[],h=t.getCurrentSettings().pens?.filterPenTypes??(()=>!0);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.roundedTipPen2,id:"polyline-pen",factory:y.makePolylineBuilder},...n.filter((t=>!t.isShapeBuilder)),{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},...n.filter((t=>t.isShapeBuilder))].filter(h),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 o=t?.factory;return o&&o!==r.makeFreehandLineBuilder&&o!==s.makePressureSensitiveFreehandLineBuilder&&o!==y.makePolylineBuilder?this.editor.icons.makeIconFromFactory(e):this.editor.icons.makePenIcon(e)}createIcon(){return this.createIconForRecord(this.getCurrentPenType())}createPenTypeSelector(t){const e=this.penTypes.map(((t,e)=>({id:e,makeIcon:()=>this.createIconForRecord(t),title:t.name,isShapeBuilder:t.isShapeBuilder??!1}))),o=e.filter((t=>!t.isShapeBuilder)),n=(0,b.default)(this.localizationTable.selectPenType,this.getCurrentPenTypeIdx(),o),i=e.filter((t=>t.isShapeBuilder)),r=(0,b.default)(this.localizationTable.selectShape,this.getCurrentPenTypeIdx(),i),s=t=>{this.tool.setStrokeFactory(this.penTypes[t].factory)};return n.value.onUpdate(s),r.value.onUpdate(s),t?.registerTextHelpForElements([n.getRootElement(),r.getRootElement()],this.localizationTable.penDropdown__penTypeHelpText),{setValue:t=>{n.value.set(t),r.value.set(t)},updateIcons:()=>{n.updateIcons(),r.updateIcons()},addTo:t=>{o.length&&n.addTo(t),i.length&&r.addTo(t)}}}createStrokeCorrectionOptions(t){const e=document.createElement("div");e.classList.add("action-button-row",`${m.toolbarCSSPrefix}-pen-tool-toggle-buttons`);const o=(o,n)=>{const i=document.createElement("button");i.classList.add(`${m.toolbarCSSPrefix}-toggle-button`);const r=n.cloneNode(!0);r.classList.add("icon");const s=document.createElement("span");s.innerText=o,i.replaceChildren(r,s),i.setAttribute("role","switch"),e.appendChild(i);let a=!1,l=t=>{};const c={setChecked(t){a=t,i.setAttribute("aria-checked",`${a}`),l(a)},setOnInputListener(t){l=t},addHelpText(e){t?.registerTextHelpForElement(i,e)}};return i.onclick=()=>{c.setChecked(!a)},c},n=o(this.localizationTable.inputStabilization,this.editor.icons.makeStrokeSmoothingIcon());n.setOnInputListener((t=>{this.tool.setHasStabilization(t)}));const i=o(this.localizationTable.strokeAutocorrect,this.editor.icons.makeShapeAutocorrectIcon());return i.setOnInputListener((t=>{this.tool.setStrokeAutocorrectEnabled(t)})),i.addHelpText(this.localizationTable.penDropdown__autocorrectHelpText),n.addHelpText(this.localizationTable.penDropdown__stabilizationHelpText),{update:()=>{n.setChecked(!!this.tool.getInputMapper()),i.setChecked(this.tool.getStrokeAutocorrectionEnabled())},addTo:t=>{t.appendChild(e)}}}getHelpText(){return this.localizationTable.penDropdown__baseHelpText}fillDropdown(t,e){const o=document.createElement("div");o.classList.add(`${m.toolbarCSSPrefix}spacedList`,`${m.toolbarCSSPrefix}nonbutton-controls-main-list`);const{container:n,setValue:i}=(0,g.default)(this.editor,(t=>{this.tool.setThickness(t)})),r=document.createElement("div"),s=document.createElement("label"),a=(0,h.default)(this.editor,(t=>{this.tool.setColor(t)})),{input:l,container:c}=a;l.id=`${m.toolbarCSSPrefix}colorInput${v.idCounter++}`,s.innerText=this.localizationTable.colorLabel,s.setAttribute("for",l.id),r.appendChild(s),r.appendChild(c);const d=this.createStrokeCorrectionOptions(e),u=this.createPenTypeSelector(e);return e?.registerTextHelpForElement(r,this.localizationTable.penDropdown__colorHelpText),e&&a.registerWithHelpTextDisplay(e),e?.registerTextHelpForElement(n,this.localizationTable.penDropdown__thicknessHelpText),this.updateInputs=()=>{a.setValue(this.tool.getColor()),i(this.tool.getThickness()),u.updateIcons(),u.setValue(this.getCurrentPenTypeIdx()),d.update()},this.updateInputs(),o.replaceChildren(r,n),u.addTo(o),t.replaceChildren(o),d.addTo(t),!0}onKeyPress(t){if(!this.isSelected())return!1;for(let e=0;e<f.selectStrokeTypeKeyboardShortcutIds.length;e++){const o=f.selectStrokeTypeKeyboardShortcutIds[e];if(this.editor.shortcuts.matchesShortcut(o,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(),strokeAutocorrect:this.tool.getStrokeAutocorrectionEnabled()}}deserializeFrom(t){super.deserializeFrom(t);const e=(e,o)=>{const n=typeof t[e];if(n!==o)throw new Error(`Deserializing property ${e}: Invalid type. Expected ${o}, was ${n}.`)};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 o=t.strokeFactoryId;for(const t of this.penTypes)if(o===t.id){this.tool.setStrokeFactory(t.factory);break}}void 0!==t.inputStabilization&&this.tool.setHasStabilization(!!t.inputStabilization),void 0!==t.strokeAutocorrect&&this.tool.setStrokeAutocorrectEnabled(!!t.strokeAutocorrect)}}v.idCounter=0,e.default=v},8230:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(9751)),r=o(5068),s=o(9376);class a extends i.default{constructor(t,e,o,n={}){super(t,"save-button",(()=>n.icon??t.icons.makeSaveIcon()),n.label??e.save,o),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},869:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=o(486),s=n(o(2717)),a=o(2018),l=n(o(9943)),c=n(o(9751)),d=n(o(550)),h=o(9376),u=n(o(5007)),p=o(2034);class f extends d.default{constructor(t,e,o){super(t,e,"selection-tool-widget",o),this.tool=e,this.updateFormatMenu=()=>{};const n=new c.default(t,"resize-btn",(()=>t.icons.makeResizeImageToSelectionIcon()),this.localizationTable.resizeImageToSelection,(()=>{this.resizeImageToSelection()}),o);n.setHelpText(this.localizationTable.selectionDropdown__resizeToHelpText);const 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()}),o);i.setHelpText(this.localizationTable.selectionDropdown__deleteHelpText);const 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)}),o);r.setHelpText(this.localizationTable.selectionDropdown__duplicateHelpText),this.addSubWidget(n),this.addSubWidget(i),this.addSubWidget(r);const s=t=>{n.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()}getHelpText(){return this.localizationTable.selectionDropdown__baseHelpText}fillDropdown(t,e){super.fillDropdown(t,e);const o=document.createElement("div");o.classList.add(`${p.toolbarCSSPrefix}nonbutton-controls-main-list`),t.appendChild(o),(0,u.default)(this.localizationTable.reformatSelection).addTo(o);const n=((t,e,o)=>{const n=document.createElement("div");n.classList.add("selection-format-menu",`${p.toolbarCSSPrefix}spacedList`,`${p.toolbarCSSPrefix}indentedList`);const a=document.createElement("div"),c=document.createElement("label"),d=(0,l.default)(t,(o=>{const n=e.getSelection();if(n){const e=[];for(const t of n.getSelectedObjects())(0,r.isRestylableComponent)(t)&&e.push(t.updateStyle({color:o}));const i=(0,s.default)(e);t.dispatch(i)}})),{input:h,container:u}=d;return c.innerText=o.colorLabel,a.replaceChildren(c,u),n.replaceChildren(a),{addTo:t=>{t.appendChild(n)},update:()=>{const t=e.getSelection();if(t&&t.getSelectedItemCount()>0){h.disabled=!1,n.classList.remove("disabled");const e=[];for(const o of t.getSelectedObjects())if((0,r.isRestylableComponent)(o)){const t=o.getStyle().color;t&&e.push(t)}d.setValue(i.Color4.average(e))}else h.disabled=!0,n.classList.add("disabled"),d.setValue(i.Color4.transparent)},registerHelpText:t=>{t.registerTextHelpForElement(a,o.selectionDropdown__changeColorHelpText),d.registerWithHelpTextDisplay(t)}}})(this.editor,this.tool,this.localizationTable);return n.addTo(o),this.updateFormatMenu=()=>n.update(),e&&n.registerHelpText(e),n.update(),!0}}e.default=f},5360:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=o(2018),s=o(2034),a=n(o(9943)),l=n(o(550));class c extends l.default{constructor(t,e,o){super(t,e,"text-tool-widget",o),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 o=document.createElement("div"),n=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)};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);const y=this.editor.getCurrentSettings().text?.fonts??[];for(const t of y)b(t);return r.classList.add("font-selector"),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)},n.appendChild(m),n.appendChild(p),o.appendChild(l),o.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(n,i,o),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},9943:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeColorInput=void 0;const i=o(5379),r=n(o(2870)),s=o(2018);e.makeColorInput=(t,e)=>{const o=document.createElement("span"),n=document.createElement("span"),r=document.createElement("input");r.type="button",r.classList.add("coloris_input"),o.classList.add("color-input-container"),n.classList.add("color-input-wrapper"),n.appendChild(r),o.appendChild(n);const l=a(t,o,(t=>{r.value=t.toHexString(),h();const e=r.parentElement;e&&e.classList.contains("clr-field")&&(e.style.color=r.value)}));let c;const d=()=>{c=i.Color4.fromHex(r.value)},h=()=>{d(),c&&(t.announceForAccessibility(t.localization.colorChangedAnnouncement(c.toHexString())),e(c),t.notifier.dispatch(s.EditorEventType.ColorPickerColorSelected,{kind:s.EditorEventType.ColorPickerColorSelected,color:c}))};r.oninput=d;let u=!1;r.addEventListener("open",(()=>{u=!0,t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!0}),l.cancel(),o.classList.add("picker-open");const e=document.querySelector("#clr-picker #clr-hue-slider");e?.focus()}));r.addEventListener("close",(()=>{u=!1,t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!1}),h(),r.focus(),o.classList.remove("picker-open")}));return{input:r,container:o,setValue:t=>{"object"==typeof t&&(t=t.toHexString()),r.value=t,r.dispatchEvent(new Event("input",{bubbles:!0}))},closePicker:()=>{u&&h()},registerWithHelpTextDisplay:e=>{e.registerTextHelpForElement(n,t.localization.colorPickerToggleHelpText),l.registerWithHelpTextDisplay(e)}}};const a=(t,e,o)=>{const n=document.createElement("button");n.classList.add("pipetteButton"),n.title=t.localization.pickColorFromScreen,n.setAttribute("alt",n.title);const i=document.createElement("span");i.classList.add("pickColorInstructions"),i.innerText=t.localization.clickToPickColorAnnouncement;const s=e=>{n.replaceChildren(t.icons.makePipetteIcon(e),i)};s();const a=t.toolController.getMatchingTools(r.default)[0],l=()=>{a?.clearColorListener(),s(),n.classList.remove("active")},c=t=>{l(),t&&o(t)},d=t=>{t?s(t):s()};return n.onclick=()=>{if(n.classList.contains("active"))return l(),void t.announceForAccessibility(t.localization.colorSelectionCanceledAnnouncement);a?.setColorListener(d,c),a&&(n.classList.add("active"),t.announceForAccessibility(t.localization.clickToPickColorAnnouncement))},e.appendChild(n),{cancel:()=>{l()},registerWithHelpTextDisplay:e=>{e.registerTextHelpForElement(n,t.localization.colorPickerPipetteHelpText)}}};e.default=e.makeColorInput},3634:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(7988));let r=0;e.default=(t,e,{accepts:o="*",allowMultiSelect:n=!1,customPickerAction:s}={})=>{const a=document.createElement("div"),l=document.createElement("label"),c=document.createElement("input"),d=document.createElement("div");d.classList.add("toolbar--file-input-description");const h=document.createElement("span");a.classList.add("toolbar--file-input-container"),l.appendChild(document.createTextNode(t)),c.accept=o,c.type=s?"button":"file",c.classList.add("file-input"),c.multiple=n;const u="js-draw-file-input-"+r++;c.setAttribute("id",u),l.htmlFor=u;const p=e.icons.makeUploadFileIcon();p.classList.add("icon"),d.replaceChildren(p,h),l.appendChild(d),a.replaceChildren(l,c);const f=i.default.fromInitialValue([]);let m=!1,g=null;const b=()=>{const t=f.get();if(m){if(h.textContent=e.localization.fileInput__loading,g){const t=document.createElement("b");t.textContent=e.localization.cancel,t.classList.add("cancel-button"),h.appendChild(t)}p.style.display="none"}else if(t.length>0){const o=t.map((t=>t.name)),n=5;if(o.length<=n)h.textContent=o.join("\n");else{const t=o.slice(0,n-1);h.textContent=[...t,e.localization.fileInput__andNMoreFiles(o.length-t.length)].join("\n")}p.style.display="none"}else{p.style.display="";const t=e.localization.dragAndDropHereOrBrowse.split(/[{]{2}(.*)[}]{2}/g);h.replaceChildren();for(let e=0;e<t.length;e++)if(e%2==1){const o=document.createElement("b");o.textContent=t[e],h.appendChild(o)}else h.appendChild(document.createTextNode(t[e]))}};if(l.addEventListener("dragover",(t=>{t.preventDefault(),l.classList.add("drag-target")})),l.addEventListener("dragenter",(t=>{t.preventDefault(),l.classList.add("drag-target")})),l.addEventListener("dragleave",(t=>{t.preventDefault();const e=t.relatedTarget;e&&l.contains(e)||l.classList.remove("drag-target")})),l.addEventListener("drop",(t=>{t.preventDefault(),l.classList.remove("drag-target");const e=[];t.dataTransfer&&e.push(...t.dataTransfer.files),f.set(e)})),c.addEventListener("change",(()=>{const t=c.files??[];f.set([...t])})),s){const t=async()=>{if(m)g?.();else{a.classList.add("-loading"),m=!0,b();try{const t=await s({setOnCancelCallback:t=>{if(!m)throw new Error("Task already completed. Can't register cancel handler.");g=()=>{g=null,b(),t()},b()}});t&&f.set(t)}finally{a.classList.remove("-loading"),m=!1,b()}}};c.onclick=t}return f.onUpdate((t=>{0===t.length&&c.files&&c.files.length>0&&(c.value=""),g?.()})),f.onUpdateAndNow(b),{container:a,input:c,selectedFiles:f,addTo:t=>{t.appendChild(a)}}}},3759:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(7988),r=n(o(9292)),s=n(o(3676)),a=o(2034);let l=0;e.default=(t,e,o)=>{const n=document.createElement("div");n.classList.add(`${a.toolbarCSSPrefix}grid-selector`);const c=i.MutableReactiveValue.fromInitialValue(e),d=document.createElement("div");d.setAttribute("role","menu"),d.id=`${a.toolbarCSSPrefix}-grid-select-id-${l++}`,(0,r.default)(d);const h=document.createElement("label");h.textContent=t,h.htmlFor=d.id,n.appendChild(h);let u=`${a.toolbarCSSPrefix}-grid-selector-${l++}`;const p=t=>{const e=document.createElement("div");e.classList.add("choice-button");const o=document.createElement("input");o.type="radio",o.id=`${a.toolbarCSSPrefix}-grid-select-button-${l++}`,(0,s.default)(e);const n=document.createElement("label"),i=()=>{n.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,n.htmlFor=o.id,n.replaceChildren(i,e)};i();const r=()=>{o.name=u};r();const h=()=>{o.checked?e.classList.add("checked"):e.classList.remove("checked")};o.oninput=()=>{o.checked&&c.set(t.id),h()},o.onfocus=()=>{e.querySelector(":focus-visible")&&e.classList.add("focus-visible")},o.onblur=()=>{e.classList.remove("focus-visible")},e.oncontextmenu=t=>{t.preventDefault()},e.replaceChildren(o,n),d.appendChild(e);const p=t=>{o.checked=t,h()};p(!1);return{choiceRecord:t,setChecked:p,updateIcon:()=>{i()},updateButtonRadiogroupName:r}},f=[];for(const t of o)f.push(p(t));n.appendChild(d),c.onUpdateAndNow((t=>{for(let e=0;e<f.length;e++)f[e].setChecked(f[e].choiceRecord.id===t)}));const m={value:c,_radiogroupName:u,linkWith:t=>{m._radiogroupName=t._radiogroupName,u=t._radiogroupName;for(const t of f)t.updateButtonRadiogroupName()},updateIcons:()=>{f.forEach((t=>t.updateIcon()))},getRootElement:()=>n,addTo:t=>{t.appendChild(n)}};return m}},5007:(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)}}}},1265:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(9292)),r=o(7988);e.default=t=>{const e=document.createElement("div");e.classList.add("toolbar-snapped-scroll-list");const o=document.createElement("div");o.classList.add("scroller");const n=r.MutableReactiveValue.fromInitialValue(0);let s=null;const a=r.ReactiveValue.map(t,(t=>t.map(((t,e)=>{const o=document.createElement("div");return t.element.parentElement&&t.element.remove(),o.appendChild(t.element),o.classList.add("item"),o.setAttribute("data-item-index",`${e}`),{element:o,data:t.data}})))),l=[];a.onUpdateAndNow((t=>{n.set(-1);for(const t of l)s?.unobserve(t.element);o.replaceChildren(),t.length>1?s=new IntersectionObserver((t=>{for(const e of t)if(e.isIntersecting&&e.intersectionRatio>.7){const t=e.target.getAttribute("data-item-index");if(null===t)throw new Error("Could not find attribute data-item-index");const o=Number(t);n.set(o);break}}),{root:o,threshold:.9}):s&&(s.disconnect(),n.set(0),s=null),0===t.length?e.classList.add("-empty"):e.classList.remove("-empty");for(const e of t)o.appendChild(e.element);if(n.set(0),s)for(const e of t)s.observe(e.element)}));const c=r.ReactiveValue.map(n,(e=>{const o=t.get();return 0<=e&&e<o.length?o[e].data:null}));return(0,i.default)(o),e.replaceChildren((()=>{const o=document.createElement("div");o.classList.add("page-markers"),o.setAttribute("tabindex","-1");const i=[];return r.ReactiveValue.union([n,t]).onUpdateAndNow((([t,n])=>{let r,s=!1;for(;n.length<i.length;)i.pop(),s=!0;for(let e=0;e<n.length;e++){let o;if(e>=i.length){o=document.createElement("div");const t=document.createElement("div");t.classList.add("content"),o.replaceChildren(t),i.push(o),s=!0}else o=i[e];o.classList.add("marker"),e===t?(o.classList.add("-active"),r=o):o.classList.remove("-active");const n=e;o.onclick=()=>{a.get()[n]?.element?.scrollIntoView({block:"nearest",behavior:"smooth"})}}s&&o.replaceChildren(...i),r&&o.scrollHeight>e.clientHeight&&r.scrollIntoView({block:"nearest"}),1===i.length?o.classList.add("-one-element"):o.classList.remove("-one-element")})),o})(),o),{container:e,visibleItem:c}}},2059:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379),i=o(2034);let r=0;e.default=(t,e)=>{const o=document.createElement("div"),s=document.createElement("label"),a=document.createElement("input");o.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)))},o.appendChild(s),o.appendChild(a);const c=(t,e)=>{const o=(t,e)=>(e?Math.ceil:Math.floor)(100*t)/100,i=o(l(t),!1),r=o(l(e),!0);a.min=`${i}`,a.max=`${r}`,a.step=`${(0,n.toRoundedString)((r-i)/20)}`};return c(2,262),{container:o,addTo:t=>{t.appendChild(o)},setBounds:c,setValue:t=>{a.value=l(t).toString()}}}},9376:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.exitKeyboardShortcut=e.saveKeyboardShortcut=e.selectStrokeTypeKeyboardShortcutIds=e.resizeImageToSelectionKeyboardShortcut=void 0;const i=n(o(5577));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,8,9].map((t=>`jsdraw.toolbar.PenTool.select-pen-${t}`));for(let t=0;t<e.selectStrokeTypeKeyboardShortcutIds.length;t++){const o=e.selectStrokeTypeKeyboardShortcutIds[t];i.default.registerDefaultKeyboardShortcut(o,[`CtrlOrMeta+Digit${t+1}`],"Select pen style "+(t+1))}e.saveKeyboardShortcut="jsdraw.toolbar.SaveActionWidget.save",i.default.registerDefaultKeyboardShortcut(e.saveKeyboardShortcut,["ctrlOrMeta+KeyS"],"Save"),e.exitKeyboardShortcut="jsdraw.toolbar.ExitActionWidget.exit",i.default.registerDefaultKeyboardShortcut(e.exitKeyboardShortcut,["Alt+KeyQ"],"Exit")},418:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(2018),r=n(o(9118)),s=o(2034),a=o(7988);var l;!function(t){t[t.DropdownShown=0]="DropdownShown",t[t.DropdownHidden=1]="DropdownHidden"}(l||(l={}));class c{constructor(t,e,o){this.parent=t,this.notifier=e,this.onDestroy=o,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,o=document.scrollingElement?.clientHeight??document.body.clientHeight;let n,i;if(t.left>e/2){n=`calc(${this.parent.target.clientWidth+"px"} - 100%)`}if(t.bottom>o&&t.top-t.height>0){i=`calc(-${this.parent.target.clientHeight}px - 100%)`}this.dropdownContainer.style.translate=n||i?`${n??"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:o})=>{e&&(t(this.localization.dropdownShown(e.parent.getTitle())),this.connectedNotifiers.forEach((t=>{t.dispatch(i.EditorEventType.ToolbarDropdownShown,{kind:i.EditorEventType.ToolbarDropdownShown,fromToplevelDropdown:o,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})})))))}}},4175:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(7988);e.default=class{constructor(t,e,o,i,r){this.setSidebarContent=t,this.sidebarTitle=e,this.sidebarVisibility=o,this.announceForAccessibility=i,this.localization=r,this.visibleWidgetContent=n.ReactiveValue.fromInitialValue(null)}createToolMenu(t){const e=document.createElement("div");let o=null;const i=n.ReactiveValue.fromCallback((()=>this.visibleWidgetContent.get()===o&&this.sidebarVisibility.get()),[this.visibleWidgetContent,this.sidebarVisibility]);return o={visible:i,requestShow:()=>{this.setSidebarContent(e),this.sidebarTitle.set(t.getTitle()),this.visibleWidgetContent.set(o),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:()=>{o?.requestHide(),e.parentElement&&e.remove(),this.visibleWidgetContent.get()===o&&this.visibleWidgetContent.set(null)}},o}}},6006:function(t,e,o){"use strict";var n=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=o(9751);Object.defineProperty(e,"ActionButtonWidget",{enumerable:!0,get:function(){return n(i).default}});var r=o(550);Object.defineProperty(e,"BaseToolWidget",{enumerable:!0,get:function(){return n(r).default}});var s=o(5068);Object.defineProperty(e,"BaseWidget",{enumerable:!0,get:function(){return n(s).default}}),Object.defineProperty(e,"ToolbarWidgetTag",{enumerable:!0,get:function(){return s.ToolbarWidgetTag}});var a=o(9108);Object.defineProperty(e,"PenToolWidget",{enumerable:!0,get:function(){return n(a).default}});var l=o(5360);Object.defineProperty(e,"TextToolWidget",{enumerable:!0,get:function(){return n(l).default}});var c=o(1210);Object.defineProperty(e,"HandToolWidget",{enumerable:!0,get:function(){return n(c).default}});var d=o(869);Object.defineProperty(e,"SelectionToolWidget",{enumerable:!0,get:function(){return n(d).default}});var h=o(1295);Object.defineProperty(e,"EraserToolWidget",{enumerable:!0,get:function(){return n(h).default}});var u=o(1294);Object.defineProperty(e,"InsertImageWidget",{enumerable:!0,get:function(){return n(u).default}});var p=o(7021);Object.defineProperty(e,"DocumentPropertiesWidget",{enumerable:!0,get:function(){return n(p).default}})},8836:function(t,e,o){"use strict";var n,i,r,s,a=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},l=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const c=o(2018),d=o(7394),h=o(7988);n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakMap,e.default=class{constructor(t,e){this.notifier=t,this.description=e,n.set(this,void 0),i.set(this,null),r.set(this,null),s.set(this,null),a(this,n,h.ReactiveValue.fromInitialValue(!0),"f"),l(this,n,"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);case d.InputEvtType.ContextMenu:return this.onContextMenu(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}onContextMenu(t){return!1}eventCanBeDeliveredToNonActiveTool(t){return!0}setEnabled(t){l(this,n,"f").set(t)}isEnabled(){return l(this,n,"f").get()}enabledValue(){return l(this,n,"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"),a(this,i,null,"f")}}},1011:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.EraserMode=void 0;const i=o(2018),r=n(o(8836)),s=o(5379),a=n(o(6188)),l=o(578),c=o(6362),d=o(7988),h=n(o(7)),u=n(o(2717)),p=o(8258);var f;!function(t){t.PartialStroke="partial-stroke",t.FullStroke="full-stroke"}(f||(e.EraserMode=f={}));class m extends r.default{constructor(t,e){super(t.notifier,t.localization.changeTool),this.editor=t,this.eraser=e}onPointerDown(t){if(1===t.allPointers.length&&t.current.device===l.PointerDevice.Eraser){const e=this.editor.toolController.getPrimaryTools().filter((t=>t.isEnabled()));if(e.length?this.previousEnabledTool=e[0]:this.previousEnabledTool=null,this.previousEraserEnabledState=this.eraser.isEnabled(),this.eraser.setEnabled(!0),this.eraser.onPointerDown(t))return!0;this.restoreOriginalTool()}return!1}onPointerMove(t){this.eraser.onPointerMove(t)}restoreOriginalTool(){this.eraser.setEnabled(this.previousEraserEnabledState),this.previousEnabledTool&&this.previousEnabledTool.setEnabled(!0)}onPointerUp(t){this.eraser.onPointerUp(t),this.restoreOriginalTool()}onGestureCancel(t){this.eraser.onGestureCancel(t),this.restoreOriginalTool()}}class g extends r.default{constructor(t,e,o){super(t.notifier,e),this.editor=t,this.lastPoint=null,this.isFirstEraseEvt=!0,this.toAdd=new Set,this.eraseCommands=[],this.addCommands=[],this.thickness=o?.thickness??10,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})})),this.modeValue=d.ReactiveValue.fromInitialValue(o?.mode??f.FullStroke),this.modeValue.onUpdate((t=>{this.editor.notifier.dispatch(i.EditorEventType.ToolUpdated,{kind:i.EditorEventType.ToolUpdated,tool:this})}))}makeEraserSwitcherTool(){return new m(this.editor,this)}clearPreview(){this.editor.clearWetInk()}getSizeOnCanvas(){return this.thickness/this.editor.viewport.getScaleFactor()}drawPreviewAt(t){this.clearPreview();const e=this.getSizeOnCanvas(),o=this.editor.display.getWetInkRenderer(),n=this.getEraserRect(t),i=this.getEraserRect(this.lastPoint??t),r={fill:s.Color4.transparent,stroke:{width:e/10,color:s.Color4.gray}};o.drawPath((0,p.pathToRenderable)(s.Path.fromConvexHullOf([...n.corners,...i.corners]),r))}getEraserRect(t){const e=this.getSizeOnCanvas(),o=s.Vec2.of(e/2,e/2);return s.Rect2.fromCorners(t.minus(o),t.plus(o))}eraseTo(t){if(!this.isFirstEraseEvt&&0===t.distanceTo(this.lastPoint))return;this.isFirstEraseEvt=!1;const e=this.getEraserRect(t),o=new s.LineSegment2(this.lastPoint,t),n=s.Rect2.union(o.bbox,e),i=this.editor.image.getElementsIntersectingRegion(n).filter((t=>t.intersects(o)||t.intersectsRect(e))).filter((t=>t.isSelectable()));if(this.modeValue.get()===f.FullStroke){this.toRemove.push(...i);const t=i.map((t=>new a.default([t])));t.forEach((t=>t.apply(this.editor))),this.eraseCommands.push(...t)}else{const o=[],n=[];for(const r of i){if(o.push(r),!r.withRegionErased)continue;if(e.grownBy(e.maxDimension/3).containsRect(r.getExactBBox()))continue;const i=s.Path.fromConvexHullOf([...e.corners,...this.getEraserRect(this.lastPoint??t).corners].map((t=>this.editor.viewport.roundPoint(t))));n.push(...r.withRegionErased(i,this.editor.viewport))}const r=new a.default(o),l=n.map((t=>h.default.addElement(t)));r.apply(this.editor),l.forEach((t=>t.apply(this.editor)));const c=[];for(const t of o)this.toAdd.has(t)?this.toAdd.delete(t):c.push(t);this.toRemove.push(...c);for(const t of n)this.toAdd.add(t);this.eraseCommands.push(new a.default(c)),this.addCommands.push(...l)}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.toAdd.clear(),this.isFirstEraseEvt=!0,this.drawPreviewAt(t.current.canvasPos),!0)}onPointerMove(t){const e=t.current.canvasPos;this.eraseTo(e)}onPointerUp(t){this.eraseTo(t.current.canvasPos);const e=[];if(this.addCommands.length>0){this.addCommands.forEach((t=>t.unapply(this.editor)));for(const t of this.toAdd)this.toRemove.includes(t)&&(this.toAdd.delete(t),this.toRemove=this.toRemove.filter((e=>e!==t)));for(const t of this.toRemove)this.toAdd.has(t)&&(this.toAdd.delete(t),this.toRemove=this.toRemove.filter((e=>e!==t)));e.push(...[...this.toAdd].map((t=>h.default.addElement(t)))),this.addCommands=[]}if(this.eraseCommands.length>0){this.eraseCommands.forEach((t=>t.unapply(this.editor))),this.eraseCommands=[];const t=new a.default(this.toRemove);e.push(t)}1===e.length?this.editor.dispatch(e[0]):this.editor.dispatch((0,u.default)(e)),this.clearPreview()}onGestureCancel(t){this.addCommands.forEach((t=>t.unapply(this.editor))),this.eraseCommands.forEach((t=>t.unapply(this.editor))),this.eraseCommands=[],this.addCommands=[],this.clearPreview()}onKeyPress(t){const e=this.editor.shortcuts;let o;return e.matchesShortcut(c.decreaseSizeKeyboardShortcutId,t)?o=2*this.getThickness()/3:e.matchesShortcut(c.increaseSizeKeyboardShortcutId,t)&&(o=3*this.getThickness()/2),void 0!==o&&(o=Math.min(Math.max(1,o),200),this.setThickness(o),!0)}getThickness(){return this.thickness}setThickness(t){this.thicknessValue.set(t)}getThicknessValue(){return this.thicknessValue}getModeValue(){return this.modeValue}}e.default=g},8402:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(2170)),r=n(o(4686)),s=n(o(8836)),a=o(6362),l="find-tool";class c extends s.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(`${l}-overlay`)}canReceiveInputInReadOnlyEditor(){return!0}getMatches(t){const e=t.toLocaleLowerCase();return this.editor.image.getAllElements().filter((o=>{let n="";if(o instanceof i.default)n=o.getText();else{if(!(o instanceof r.default))return!1;n=o.getAltText()??""}const s=-1!==n.toLocaleLowerCase().indexOf(e),a=-1!==n.indexOf(t);return s||a})).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 o=!1;this.editor.dispatch(this.editor.viewport.zoomTo(t[e],!0,!0),o),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"),o=document.createElement("button");this.searchInput.setAttribute("id",`${l}-searchInput-${Math.random()}`),t.htmlFor=this.searchInput.getAttribute("id"),t.innerText=this.editor.localization.findLabel,e.innerText=this.editor.localization.toNextMatch,o.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(a.toggleFindVisibleShortcutId,t)&&(t.preventDefault(),this.toggleVisible())},e.onclick=()=>{this.toNextMatch()},o.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(t,this.searchInput,e,o)}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(a.toggleFindVisibleShortcutId,t)&&(this.toggleVisible(),!0)}setEnabled(t){super.setEnabled(t),this.isEnabled()&&this.setVisible(!1)}}e.default=c},272:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=o(7394),c=a(o(2388)),d=s(o(5043)),h=o(578);class u extends c.default{constructor(){super(),this.canShowContextMenu=!1,this.stationaryDetector=null,this.clickTolerance=12}canMakeLongPressMenuEvent(t){const e=[h.PointerDevice.Touch];return 1===t.allPointers.length&&e.includes(t.current.device)}onEvent(t){const e=()=>{if(!(0,l.isPointerEvt)(t))return!1;if(this.canShowContextMenu){if(this.emit({kind:l.InputEvtType.ContextMenu,screenPos:t.current.screenPos,canvasPos:t.current.canvasPos}))return this.emit({kind:l.InputEvtType.GestureCancelEvt}),!0}return!1};if(t.kind===l.InputEvtType.PointerDownEvt)1===t.allPointers.length?(this.canShowContextMenu=!0,this.contextMenuTriggerPointer=t.current,this.contextMenuStartPoint=t.current.screenPos,this.canMakeLongPressMenuEvent(t)&&(this.stationaryDetector=new d.default(t.current,d.defaultStationaryDetectionConfig,e))):this.canShowContextMenu=!1;else if(t.kind===l.InputEvtType.PointerMoveEvt){if(this.canShowContextMenu){this.stationaryDetector?.onPointerMove(t.current);const e=t.current.screenPos.minus(this.contextMenuStartPoint),o=this.clickTolerance;e.length()>o&&(this.canShowContextMenu=!1)}}else if(t.kind===l.InputEvtType.PointerUpEvt&&(this.stationaryDetector?.destroy(),this.contextMenuTriggerPointer?.id===t.current.id&&this.contextMenuTriggerPointer.device===h.PointerDevice.RightButtonMouse&&e()))return!0;return this.emit(t)}}e.default=u},2388:function(t,e){"use strict";var o,n=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},i=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});o=new WeakMap,e.default=class{constructor(){o.set(this,null)}setEmitListener(t){n(this,o,t&&"object"==typeof t?e=>t.onEvent(e)??!1:t,"f")}emit(t){return i(this,o,"f")?.call(this,t)??!1}}},960:function(t,e,o){"use strict";var n,i,r=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)},s=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const l=a(o(2388));class c extends l.default{constructor(){super(...arguments),n.set(this,null),i.set(this,null)}onEvent(t){return null===r(this,n,"f")?this.emit(t):r(this,n,"f").onEvent(t)}addToTail(t){r(this,i,"f")?(r(this,i,"f").setEmitListener(t),s(this,i,t,"f")):(s(this,n,t,"f"),s(this,i,r(this,n,"f"),"f")),r(this,i,"f").setEmitListener((t=>this.emit(t)))}}n=new WeakMap,i=new WeakMap,e.default=c},3343:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(7394),r=n(o(2388)),s=o(5379),a=n(o(6398));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,o){this.updatePointer=e,this.options=o,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),o=e.times(this.options.springConstant),n=10*this.options.mass,i=this.velocity.normalizedOrZero().times(-this.options.frictionCoefficient*n),r=o.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(),o=e-this.lastUpdateTime,n=this.strokePoint.eq(this.targetPoint);if(o>this.targetInterval||t){if(!n){let t,n,i=1;do{t=this.getNextVelocity(o/i),n=t.times(o/1e3),i++}while(n.magnitude()>this.options.maxPointDist&&i<10);for(let t=0;t<i;t++)this.velocity=this.getNextVelocity(o/i),n=this.velocity.times(o/1e3),this.strokePoint=this.strokePoint.plus(n),t<i-1&&this.updatePointer(this.strokePoint,e)}if(this.lastUpdateTime=e,t||!n)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 o=this.lastPointerEvent.current.withScreenPosition(t,this.viewport).withTimestamp(e),n={kind:i.InputEvtType.PointerMoveEvt,current:o,allPointers:[o]};return this.emit(n)}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},4212:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(7394),r=n(o(2388)),s=o(6362);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 o=this.emit(t);if(t.kind===i.InputEvtType.KeyUpEvent||!o&&t.kind===i.InputEvtType.KeyPressEvent){const n=t.kind===i.InputEvtType.KeyPressEvent;e.matchesShortcut(s.snapToGridKeyboardShortcutId,t)&&(this.snapToGridEnabled=n,o=!0),e.matchesShortcut(s.lineLockKeyboardShortcutId,t)&&(this.angleLockEnabled=n,o=!0)}return o}static fromEditor(t){return new a(t.shortcuts,t.viewport)}}e.default=a},7955:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanZoomMode=void 0;const i=o(5379),r=o(578),s=o(2018),a=n(o(6398)),l=o(4093),c=n(o(8836)),d=o(6362);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,o){this.initialVelocity=t,this.scrollBy=e,this.onComplete=o,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(),o=(e-t)/1e3;this.currentVelocity=this.currentVelocity.times(Math.pow(1/8,o)),this.scrollBy(this.currentVelocity.times(o)),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,o){super(t.notifier,o),this.editor=t,this.mode=e,this.transform=null,this.initialRotationSnapAngle=.22,this.afterRotationStartSnapAngle=.07,this.pinchZoomStartThreshold=1.08,this.lastPointerDownTimestamp=0,this.initialTouchAngle=0,this.initialViewportRotation=0,this.initialViewportScale=0,this.isScaling=!1,this.isRotating=!1,this.inertialScroller=null,this.velocity=null}canReceiveInputInReadOnlyEditor(){return!0}computePinchData(t,e){if(t.id<e.id){const o=t;t=e,e=o}const o=e.screenPos.minus(t.screenPos),n=o.angle(),i=o.magnitude();return{canvasCenter:e.canvasPos.plus(t.canvasPos).times(.5),screenCenter:e.screenPos.plus(t.screenPos).times(.5),angle:n,dist:i}}allPointersAreOfType(t,e){return t.every((t=>t.device===e))}onPointerDown({allPointers:t,current:e}){let o=!1;const n=this.inertialScroller?.getCurrentVelocity()??i.Vec2.zero;this.inertialScroller?.stop(),this.velocity=n,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:n,dist:i}=this.computePinchData(t[0],t[1]);this.lastTouchDist=i,this.startTouchDist=i,this.lastScreenCenter=e,this.initialTouchAngle=n,this.initialViewportRotation=this.editor.viewport.getRotationAngle(),this.initialViewportScale=this.editor.viewport.getScaleFactor(),this.isScaling=!1,this.isRotating=Math.abs(Math.sin(2*this.initialViewportRotation))>.001,o=!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,o=!0);return o&&(this.lastTimestamp=performance.now(),this.transform??=l.Viewport.transformBy(i.Mat33.identity),this.editor.display.setDraftMode(!0)),o}updateVelocity(t){const e=t.minus(this.lastScreenCenter);let o=(performance.now()-this.lastTimestamp)/1e3;if(0===e.magnitude()&&o<.1)return;if(0===o)return;o=Math.max(o,.01);const n=e.times(1/o);let i=n;this.velocity&&(i=this.velocity.lerp(n,.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 o=Math.PI/2,n=Math.round(e/o)*o,i=this.isRotating?this.afterRotationStartSnapAngle:this.initialRotationSnapAngle;return Math.abs(e-n)<i&&(e=n,0!==e&&(e+=1e-4)),e-this.editor.viewport.getRotationAngle()}toSnappedScaleFactor(t){const e=this.initialViewportScale*t/this.startTouchDist,o=this.editor.viewport.getScaleFactor(),n=Math.log(e)/Math.log(10),i=Math.round(n);return Math.abs(i-n)<.04?Math.pow(10,i)/o:t/this.lastTouchDist}handleTwoFingerMove(t){const{screenCenter:e,canvasCenter:o,angle:n,dist:r}=this.computePinchData(t[0],t[1]),s=this.getCenterDelta(e);let a;if(a=this.isRotationLocked()?0:this.toSnappedRotationDelta(n),Math.abs(a)>1e-8&&(this.isRotating=!0),this.updateVelocity(e),!this.isScaling){const t=r/this.startTouchDist,e=this.pinchZoomStartThreshold,o=1/this.pinchZoomStartThreshold;(t>e||t<o)&&(this.isScaling=!0)}let c=1;this.isScaling&&(c=this.toSnappedScaleFactor(r),this.lastTouchDist=r);const d=i.Mat33.translation(s).rightMul(i.Mat33.scaling2D(c,o)).rightMul(i.Mat33.zRotation(a,o));return this.lastScreenCenter=e,this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(d)),d}handleOneFingerMove(t){const e=this.getCenterDelta(t.screenPos),o=i.Mat33.translation(e);return this.transform=l.Viewport.transformBy(this.transform.transform.rightMul(o)),this.updateVelocity(t.screenPos),this.lastScreenCenter=t.screenPos,o}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 o=this.velocity;this.updateVelocity(t.current.screenPos),o.magnitude()<this.velocity.magnitude()&&(this.velocity=o),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 o=t;this.transform&&(o=this.transform.transform.rightMul(t)),this.transform?.unapply(this.editor),this.transform=l.Viewport.transformBy(o),this.transform.apply(this.editor),e&&this.editor.announceForAccessibility(this.transform.description(this.editor,this.editor.localization))}applyAndFinalizeTransform(t){this.updateTransform(t,!0),this.transform=null}onWheel({delta:t,screenPos:e}){this.inertialScroller?.stop(),this.transform=l.Viewport.transformBy(i.Mat33.identity);const o=this.editor.viewport.screenToCanvas(e),n=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)),o).rightMul(i.Mat33.translation(n));return this.applyAndFinalizeTransform(s),!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,o=1,n=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))o=.5;else if(r.matchesShortcut(d.zoomOutKeyboardShortcutId,t))o=2;else if(r.matchesShortcut(d.rotateClockwiseKeyboardShortcutId,t))n=1;else{if(!r.matchesShortcut(d.rotateCounterClockwiseKeyboardShortcutId,t))return!1;n=-1}e=e.times(30),n*=Math.PI/8,e=e.times(-1),n*=-1,o=1/o,0!==n&&(n+=1e-4),this.isRotationLocked()&&(n=0);e=this.editor.viewport.screenToCanvasTransform.transformVec3(e);const s=this.editor.viewport.visibleRect.center,a=i.Mat33.scaling2D(o,s).rightMul(i.Mat33.zRotation(n,s)).rightMul(i.Mat33.translation(e));return this.applyAndFinalizeTransform(a),!0}isRotationLocked(){return!!(this.mode&h.RotationLocked)}setModeEnabled(t,e){let o=this.mode;e?o|=t:o&=~t,this.setMode(o)}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},166:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(2170)),r=n(o(3604)),s=o(5379),a=n(o(8836)),l=n(o(7686)),c=n(o(4686));class d extends a.default{constructor(t){super(t.notifier,t.localization.pasteHandler),this.editor=t}onPaste(t,e){const o=t.mime.toLowerCase(),n=(()=>{if("image/svg+xml"===o)return t.data;if("text/plain"===o){const e=t.data.trim();if(e.startsWith("<svg")&&e.endsWith("</svg>"))return e}if("text/html"!==o)return!1;if(!t.data.match(/^[^]{0,200}<svg.*/i))return!1;let e=t.data.toLowerCase().lastIndexOf("</svg>");return-1===e&&(e=t.data.length),t.data.substring(t.data.search(/<svg/i),e)})();return n?(this.doSVGPaste(n).then(e),!0):"text/plain"===o?(this.doTextPaste(t.data).then(e),!0):("image/png"===o||"image/jpeg"===o)&&(this.doImagePaste(t.data).then(e),!0)}async addComponentsFromPaste(t){await this.editor.addAndCenterComponents(t,!0,this.editor.localization.pasted(t.length))}async doSVGPaste(t){this.editor.showLoadingWarning(0);try{const e=r.default.fromString(t,!0),o=[];await e.start((t=>{o.push(t)}),((t,e)=>null)),await this.addComponentsFromPaste(o)}finally{this.editor.hideLoadingWarning()}}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 o={size:12,fontFamily:"sans",renderingStyle:{fill:s.Color4.red}},n=e[0]?.getTextStyle()??o;if(""===t.trim())return;const r=t.split("\n");await this.addComponentsFromPaste([i.default.fromLines(r,s.Mat33.identity,n)])}async doImagePaste(t){const e=new Image;e.src=t;const o=await c.default.fromImage(e,s.Mat33.identity);await this.addComponentsFromPaste([o])}}e.default=d},9392:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=o(5379),c=a(o(7)),d=o(578),h=o(9177),u=o(2018),p=a(o(8836)),f=o(6362),m=o(6362),g=a(o(3343)),b=o(7988),y=s(o(5043));class v extends p.default{constructor(t,e,o){super(t.notifier,e),this.editor=t,this.builder=null,this.lastPoint=null,this.startPoint=null,this.currentDeviceType=null,this.currentPointerId=null,this.shapeAutocompletionEnabled=!1,this.autocorrectedShape=null,this.lastAutocorrectedShape=null,this.removedAutocorrectedShapeTime=0,this.stationaryDetector=null,this.styleValue=b.ReactiveValue.fromInitialValue({factory:h.makeFreehandLineBuilder,color:l.Color4.blue,thickness:4,...o}),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();const t=this.editor.display.getWetInkRenderer();if(this.autocorrectedShape){const e=this.editor.viewport.visibleRect;this.autocorrectedShape.render(t,e)}else this.builder?.preview(t)}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){if(this.builder&&!this.eventCanCancelStroke(t))return!0;const{current:e,allPointers:o}=t,n=e.device===d.PointerDevice.Eraser,i=e.device===d.PointerDevice.Pen;return!((1!==o.length||n)&&!i)&&(this.startPoint=this.toStrokePoint(e),this.builder=this.style.factory(this.startPoint,this.editor.viewport),this.currentDeviceType=e.device,this.currentPointerId=e.id,this.shapeAutocompletionEnabled?this.stationaryDetector=new y.default(e,y.defaultStationaryDetectionConfig,(t=>this.autocorrectShape(t))):this.stationaryDetector=null,this.lastAutocorrectedShape=null,this.removedAutocorrectedShapeTime=0,!0)}eventCanCancelStroke(t){const e=this.lastPoint?.time??0;if(t.current.timeStamp-e>1e3)return!0;const o=this.currentDeviceType===d.PointerDevice.Pen,n=t.current.device===d.PointerDevice.Touch;return!o||!n}eventCanBeDeliveredToNonActiveTool(t){return this.eventCanCancelStroke(t)}onPointerMove({current:t}){if(!this.builder)return;if(t.device!==this.currentDeviceType)return;if(t.id!==this.currentPointerId)return;const e=this.stationaryDetector?.onPointerMove(t);e||(this.addPointToStroke(this.toStrokePoint(t)),this.autocorrectedShape&&(this.removedAutocorrectedShapeTime=performance.now(),this.autocorrectedShape=null,this.editor.announceForAccessibility(this.editor.localization.autocorrectionCanceled)))}onPointerUp({current:t}){if(!this.builder)return!1;if(t.id!==this.currentPointerId)return!0;this.stationaryDetector?.onPointerUp(t);const e=this.toStrokePoint(t),o={...e,width:this.lastPoint?.width??e.width};return this.addPointToStroke(o),this.finalizeStroke(),!1}onGestureCancel(){this.builder=null,this.editor.clearWetInk(),this.stationaryDetector?.destroy(),this.stationaryDetector=null}removedAutocorrectedShapeRecently(){return this.removedAutocorrectedShapeTime>performance.now()-320}async autocorrectShape(t){if(!this.builder||!this.builder.autocorrectShape)return;if(!this.shapeAutocompletionEnabled)return;if(this.autocorrectedShape)return;const e=await this.builder.autocorrectShape();if(!this.builder||!e)return;const o=e.getBBox().area;if(0===o||!isFinite(o))return;const n=e.description(this.editor.localization);this.editor.announceForAccessibility(this.editor.localization.autocorrectedTo(n)),this.autocorrectedShape=e,this.lastAutocorrectedShape=e,this.previewStroke()}finalizeStroke(){if(this.builder){this.lastAutocorrectedShape&&this.removedAutocorrectedShapeRecently()&&(this.autocorrectedShape=this.lastAutocorrectedShape);const t=this.autocorrectedShape??this.builder.build();if(this.previewStroke(),t.getBBox().area>0){t===this.autocorrectedShape&&this.editor.announceForAccessibility(this.editor.localization.autocorrectedTo(t.description(this.editor.localization)));const e=!0,o=c.default.addElement(t,e);this.editor.dispatch(o)}else console.warn("Pen: Not adding empty stroke",t,"to the canvas.")}this.builder=null,this.lastPoint=null,this.autocorrectedShape=null,this.lastAutocorrectedShape=null,this.editor.clearWetInk(),this.stationaryDetector?.destroy(),this.stationaryDetector=null}noteUpdated(){this.editor.notifier.dispatch(u.EditorEventType.ToolUpdated,{kind:u.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 g.default(this.editor.viewport)),this.noteUpdated())}setStrokeAutocorrectEnabled(t){t!==this.shapeAutocompletionEnabled&&(this.shapeAutocompletionEnabled=t,this.noteUpdated())}getStrokeAutocorrectionEnabled(){return this.shapeAutocompletionEnabled}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,o=e.matchesShortcut(f.undoKeyboardShortcutId,t);if(this.builder&&o)return this.finalizeStroke(),!1;let n;return e.matchesShortcut(m.decreaseSizeKeyboardShortcutId,t)?n=2*this.getThickness()/3:e.matchesShortcut(m.increaseSizeKeyboardShortcutId,t)&&(n=3*this.getThickness()/2),void 0!==n&&(n=Math.min(Math.max(1,n),256),this.setThickness(n),!0)}}e.default=v},2870:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8836));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},915:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=o(2018),s=n(o(8836));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,o=null;this.enabledValue().onUpdateAndNow((n=>{e?.remove(),o?.remove(),o=null,e=null,n&&(o=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(),o=new i.Rect2(0,0,e.x,e.y),n=this.editor.getImportExportRect().transformedBoundingBox(t.canvasToScreenTransform).union(o),r=o.width/n.width*e.x,s=o.height/n.height*e.y,a=(o.x-n.x)/n.width*e.x,l=(o.y-n.y)/n.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,o)=>{const n="represents-no-scroll";Math.abs(e-o)<1e-8?t.classList.add(n):t.classList.remove(n)};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},4209:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8836)),r=o(6362),s=n(o(1172));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},5834:function(t,e,o){"use strict";var n,i,r=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),i=0;i<o.length;i++)"default"!==o[i]&&r(e,t,o[i]);return s(e,t),e}),l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const c=l(o(1434)),d=o(5379),h=a(o(5900)),u=o(1172),p=l(o(4093)),f=l(o(6188)),m=l(o(1247)),g=o(3615),b=o(6757),y=l(o(7)),v=l(o(2717)),x=l(o(8047));class w{constructor(t,e,o){this.editor=e,this.selectionTightBoundingBox=null,this.transform=d.Mat33.identity,this.selectedElems=[],this.hasParent=!0,this.removedFromImage={},this.activeHandle=null,this.backgroundDragging=!1,this.selectionDuplicatedAnimationTimeout=null,this.originalRegion=new d.Rect2(t.x,t.y,0,0),this.transformers={drag:new g.DragTransformer(e,this),resize:new g.ResizeTransformer(e,this),rotate:new g.RotateTransformer(e,this)},this.outerContainer=document.createElement("div"),this.outerContainer.classList.add(`${u.cssPrefix}selection-outer-container`),this.innerContainer=document.createElement("div"),this.innerContainer.classList.add(`${u.cssPrefix}selection-inner-container`),this.backgroundElem=document.createElement("div"),this.backgroundElem.classList.add(`${u.cssPrefix}selection-background`),this.innerContainer.appendChild(this.backgroundElem),this.outerContainer.appendChild(this.innerContainer);const n=(t,e)=>{const o={[b.ResizeMode.Both]:h.HandleAction.ResizeXY,[b.ResizeMode.HorizontalOnly]:h.HandleAction.ResizeX,[b.ResizeMode.VerticalOnly]:h.HandleAction.ResizeY};return new h.default({action:o[t],side:e},this,this.editor.viewport,(e=>this.transformers.resize.onDragStart(e,t)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd()))},i=[n(b.ResizeMode.HorizontalOnly,d.Vec2.of(0,.5)),n(b.ResizeMode.HorizontalOnly,d.Vec2.of(1,.5))],r=n(b.ResizeMode.VerticalOnly,d.Vec2.of(.5,1)),s=n(b.ResizeMode.Both,d.Vec2.of(1,1)),a=new h.default({action:h.HandleAction.Rotate,side:d.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())),l=new x.default(this,this.editor.viewport,o,this.editor.localization);this.childwidgets=[s,...i,r,a,l];for(const t of this.childwidgets)t.addTo(this.backgroundElem);this.updateUI()}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){const t=d.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)??d.Rect2.empty}get regionRotation(){return this.transform.transformVec3(d.Vec2.unitX).angle()}get preTransformedScreenRegion(){const t=t=>this.editor.viewport.canvasToScreen(t);return d.Rect2.fromCorners(t(this.preTransformRegion.topLeft),t(this.preTransformRegion.bottomRight))}get preTransformedScreenRegionRotation(){return this.editor.viewport.getRotationAngle()}getScreenRegion(){const t=this.editor.viewport.canvasToScreenTransform,e=this.editor.viewport.getScaleFactor(),o=t.transformVec2(this.region.center);return new d.Rect2(o.x,o.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.previewTransformCmds()}getDeltaZIndexToMoveSelectionToTop(){if(0===this.selectedElems.length)return 0;const t=this.selectedElems[0].getZIndex(),e=this.editor.image.getElementsIntersectingRegion(this.region);return(e[e.length-1]?.getZIndex()??t)+1-t}finalizeTransform(){const t=this.transform,e=this.selectedElems;let o;if(this.originalRegion=this.originalRegion.transformedBoundingBox(this.transform),this.transform=d.Mat33.identity,this.scrollTo(),this.selectedElems.length>0){const n=this.getDeltaZIndexToMoveSelectionToTop();o=this.editor.dispatch(new i.ApplyTransformationCommand(this,e,t,n))}return o}sendToBack(){const t=this.editor.image.getElementsIntersectingRegion(this.editor.viewport.visibleRect),e=(t[0]?.getZIndex()??0)-1-(this.selectedElems[this.selectedElems.length-1]?.getZIndex()??0);if(0!==e){const t=this.selectedElems.map((t=>t.setZIndex(t.getZIndex()+e)));return(0,v.default)(t,100)}return null}previewTransformCmds(){if(0===this.selectedElems.length)return;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.union(this.region).transformedBoundingBox(this.transform.inverse());for(const o of this.selectedElems)o.render(t,e);t.popTransform(),this.updateUI()}resolveToObjects(){let t=!1;if(this.transform=d.Mat33.identity,0===this.region.w||0===this.region.h){const e=this.editor.viewport.visibleRect.maxDimension/200;this.originalRegion=d.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 o=e/2;this.originalRegion=d.Rect2.bboxOf(t.corners,o),this.updateUI()}}getMinCanvasSize(){return 2*(h.handleSize/this.editor.viewport.getScaleFactor())}getSelectedItemCount(){return this.selectedElems.length}updateUI(){if(!this.hasParent)return;const t=this.getScreenRegion();this.backgroundElem.style.marginLeft=`${t.topLeft.x}px`,this.backgroundElem.style.marginTop=`${t.topLeft.y}px`,this.backgroundElem.style.width=`${t.width}px`,this.backgroundElem.style.height=`${t.height}px`;const e=180*this.screenRegionRotation/Math.PI;this.backgroundElem.style.transform=`rotate(${e}deg)`,this.backgroundElem.style.transformOrigin="center";const o=`${u.cssPrefix}rotated-near-perpendicular`;Math.abs(Math.sin(this.screenRegionRotation))>.5?this.innerContainer.classList.add(o):this.innerContainer.classList.remove(o),0===t.width&&0===t.height?this.innerContainer.classList.add("-empty"):this.innerContainer.classList.remove("-empty");for(const t of this.childwidgets)t.updatePosition(this.getScreenRegion())}addRemoveSelectionFromImage(t){if(t||!(this.selectedElems.length>500)){for(const e of this.selectedElems){const o=this.editor.image.findParent(e);!t&&o?(this.removedFromImage[e.getId()]=!0,o.remove()):!o&&this.removedFromImage[e.getId()]&&(y.default.addElement(e).apply(this.editor),this.removedFromImage[e.getId()]=!1,delete this.removedFromImage[e.getId()])}this.editor.queueRerender().then((()=>{if(t){this.editor.display.getWetInkRenderer().clear()}else this.previewTransformCmds()}))}}removeDeletedElemsFromSelection(){this.selectedElems=this.selectedElems.filter((t=>{const e=!!this.editor.image.findParent(t),o=this.removedFromImage[t.getId()];return e||o}))}onDragStart(t){document.getSelection()?.removeAllRanges(),this.activeHandle=null;let e=!1;this.backgroundDragging=!1,this.region.containsPoint(t.canvasPos)&&(this.backgroundDragging=!0,e=!0);for(const o of this.childwidgets)o.containsPoint(t.canvasPos)&&(this.activeHandle=o,this.backgroundDragging=!1,e=!0);return e&&(this.removeDeletedElemsFromSelection(),this.addRemoveSelectionFromImage(!1)),this.activeHandle&&this.activeHandle.handleDragStart(t),this.backgroundDragging&&this.transformers.drag.onDragStart(t.canvasPos),e}onDragUpdate(t){this.backgroundDragging&&this.transformers.drag.onDragUpdate(t.canvasPos),this.activeHandle&&this.activeHandle.handleDragUpdate(t)}onDragEnd(){this.backgroundDragging?this.transformers.drag.onDragEnd():this.activeHandle&&this.activeHandle.handleDragEnd(),this.addRemoveSelectionFromImage(!0),this.backgroundDragging=!1,this.activeHandle=null,this.updateUI()}onDragCancel(){this.backgroundDragging=!1,this.activeHandle=null,this.setTransform(d.Mat33.identity),this.addRemoveSelectionFromImage(!0),this.updateUI()}scrollTo(){if(0===this.selectedElems.length)return!1;const t=this.editor.viewport.getScreenRectSize(),e=new d.Rect2(0,0,t.x,t.y),o=this.getScreenRegion();if(!e.containsPoint(o.center)){const t=o.center,n=e.getClosestPointOnBoundaryTo(t),i=this.editor.viewport.screenToCanvas(n),r=this.region.center,s=i.minus(r);return this.editor.dispatchNoAnnounce(p.default.transformBy(d.Mat33.translation(s.times(.5))),!1),this.editor.queueRerender().then((()=>{this.previewTransformCmds()})),!0}return!1}deleteSelectedObjects(){return(this.backgroundDragging||this.activeHandle)&&this.onDragEnd(),new f.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.activeHandle;let e=null;if(t||this.runSelectionDuplicatedAnimation(),t){const t=null,o=this.getDeltaZIndexToMoveSelectionToTop();e=new i.ApplyTransformationCommand(t,this.selectedElems,this.transform,o),await e.apply(this.editor),this.addRemoveSelectionFromImage(!0)}const o=new m.default(this.selectedElems);return t&&(await(e?.unapply(this.editor)),this.addRemoveSelectionFromImage(!1),this.previewTransformCmds(),this.updateUI()),o}setHandlesVisible(t){t?this.innerContainer.classList.remove("-hide-handles"):this.innerContainer.classList.add("-hide-handles")}addTo(t){this.outerContainer.parentElement&&this.outerContainer.remove(),t.appendChild(this.outerContainer),this.hasParent=!0}setToPoint(t){this.originalRegion=this.originalRegion.grownToPoint(t),this.selectionTightBoundingBox=null,this.updateUI()}cancelSelection(){this.outerContainer.parentElement&&this.outerContainer.remove(),this.originalRegion=d.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.selectedElems.sort(((t,e)=>t.getZIndex()-e.getZIndex())),this.padRegion(),this.updateUI()}getSelectedObjects(){return[...this.selectedElems]}}i=w,c.default.register("selection-tool-transform",((t,e)=>{const o=new d.Mat33(...t.transform),n=t.elems??[],r=parseInt(t.deltaZIndex??0);return new i.ApplyTransformationCommand(null,n,o,r)})),w.ApplyTransformationCommand=class extends c.default{constructor(t,e,o,n){super("selection-tool-transform"),this.selection=t,this.fullTransform=o,this.deltaZIndex=n;"string"==typeof e[0]?this.selectedElemIds=e:(this.selectedElemIds=e.map((t=>t.getId())),this.transformCommands=e.map((t=>t.setZIndexAndTransformBy(this.fullTransform,t.getZIndex()+n))))}resolveToElems(t,e){this.transformCommands||(this.transformCommands=this.selectedElemIds.map((o=>{const n=t.image.lookupElement(o);if(!n)return console.warn(`Unable to find element with ID, ${o}.`),null;let i=n.getZIndex(),r=n.getZIndex()+this.deltaZIndex;return e&&(r=n.getZIndex(),i=n.getZIndex()-this.deltaZIndex),n.setZIndexAndTransformBy(this.fullTransform,r,i)})).filter((t=>null!==t)))}async apply(t){this.resolveToElems(t,!1),this.selection?.setTransform(this.fullTransform,!1),this.selection?.updateUI(),await t.asyncApplyCommands(this.transformCommands,100),this.selection?.setTransform(d.Mat33.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}async unapply(t){this.resolveToElems(t,!0),this.selection?.setTransform(this.fullTransform.inverse(),!1),this.selection?.updateUI(),await t.asyncUnapplyCommands(this.transformCommands,100,!0),this.selection?.setTransform(d.Mat33.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray(),deltaZIndex:this.deltaZIndex}}description(t,e){return e.transformedElements(this.selectedElemIds.length)}},e.default=w},5900:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.handleSize=e.HandleAction=void 0;const n=o(7571),i=o(5379),r=o(1172);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,o,i,l,c){this.presentation=t,this.parent=e,this.viewport=o,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}`);const d=document.createElement("div");d.classList.add(`${r.cssPrefix}content`),this.element.appendChild(d),this.parentSide=t.side;const h=t.icon;switch(h&&(d.appendChild(h),h.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,n.assertUnreachable)(this.shape)}this.updatePosition()}addTo(t){t.appendChild(this.element)}remove(){this.element.remove()}getBBoxParentCoords(){const t=this.parent.getScreenRegion(),o=i.Vec2.of(e.handleSize,e.handleSize),n=t.size.scale(this.parentSide).minus(o.times(.5));return new i.Rect2(n.x,n.y,o.x,o.y)}getBBoxCanvasCoords(){const t=this.parent.region,o=i.Vec2.of(e.handleSize,e.handleSize).times(1/this.viewport.getScaleFactor()),n=t.size.scale(this.parentSide).minus(o.times(.5));return new i.Rect2(n.x,n.y,o.x,o.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(),o=t.minus(e.center),n=e.size.x/2;let i;return i=this.shape===s.Circle?o.magnitude()<=n:Math.abs(o.x)<=n&&Math.abs(o.y)<=n,i}handleDragStart(t){return this.onDragStart(t.canvasPos),this.dragLastPos=t.canvasPos,!0}handleDragUpdate(t){this.dragLastPos&&this.onDragUpdate(t.canvasPos)}handleDragEnd(){if(this.dragLastPos)return this.onDragEnd()}setSnapToGrid(t){this.snapToGrid=t}isSnappingToGrid(){return this.snapToGrid}}},8047:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379),i=o(1172);e.default=class{constructor(t,e,o,n){this.parent=t,this.viewport=e,this.localization=n,this.lastDragPointer=null,this.element=document.createElement("div"),this.element.classList.add(`${i.cssPrefix}handle`,`${i.cssPrefix}selection-menu`),this.element.style.setProperty("--vertical-offset","40px"),this.onClick=()=>{const t=this.getBBoxCanvasCoords().center;o(t)},this.initUI(),this.updatePosition()}initUI(){const t=document.createElement("button");t.textContent="...",t.ariaLabel=this.localization.selectionMenu__show,t.title=t.ariaLabel,t.onkeydown=t=>{"Enter"===t.key&&this.onClick()},this.element.appendChild(t),requestAnimationFrame((()=>{this.updatePosition()}))}addTo(t){t.appendChild(this.element)}remove(){this.element.remove()}getElementScreenSize(){return n.Vec2.of(this.element.clientWidth,this.element.clientHeight)}getBBoxParentCoords(){const t=n.Vec2.of(0,-40),e=this.getElementScreenSize();return new n.Rect2(t.x,t.y,e.x,e.y)}getBBoxCanvasCoords(){const t=this.parent.region,e=this.viewport.getSizeOfPixelOnCanvas(),o=this.getElementScreenSize().times(e),i=40/this.viewport.getScaleFactor(),r=n.Vec2.of(t.x,t.y-i);return new n.Rect2(r.x,r.y,o.x,o.y)}updatePosition(){const t=this.getBBoxParentCoords();this.element.style.marginLeft=`${t.topLeft.x}px`,this.element.style.marginTop=`${t.topLeft.y}px`}containsPoint(t){return this.getBBoxCanvasCoords().containsPoint(t)}handleDragStart(t){return this.lastDragPointer=t,!0}handleDragUpdate(t){this.lastDragPointer=t}handleDragEnd(){this.lastDragPointer&&this.containsPoint(this.lastDragPointer.canvasPos)&&this.onClick(),this.lastDragPointer=null}}},1172:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.cssPrefix=void 0;const i=o(5379),r=o(2018),s=n(o(4093)),a=n(o(8836)),l=n(o(8748)),c=n(o(1598)),d=n(o(5834)),h=n(o(2170)),u=o(6362),p=n(o(7275)),f=n(o(5426));e.cssPrefix="selection-tool-";class m extends a.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.rebuildSelectionScheduled=!1,this.startPoint=null,this.expandingSelectionBox=!1,this.shiftKeyPressed=!1,this.snapToGrid=!1,this.lastPointer=null,this.showContextMenu=async(t,e=!0)=>{await(0,f.default)(this.selectionBox,this.editor,t,e,(()=>this.clearSelection()))},this.selectionBoxHandlingEvt=!1,this.lastSelectedObjects=[],this.hasUnfinalizedTransformFromKeyPress=!1,this.autoscroller=new p.default(t.viewport,(e=>{if(t.dispatch(s.default.transformBy(i.Mat33.translation(e)),!1),this.lastPointer){const e=this.lastPointer.withScreenPosition(this.lastPointer.screenPos,t.viewport);this.onMainPointerUpdated(e)}})),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 d.default(t,this.editor,this.showContextMenu),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),o=this.selectionBox.getTransform();this.selectionBox.setTransform(o.rightMul(i.Mat33.translation(e))),this.selectionBox.finalizeTransform()}onContextMenu(t){const e=this.selectionBox?.getScreenRegion()?.containsPoint(t.screenPos);return this.showContextMenu(t.canvasPos,e),!0}onPointerDown({allPointers:t,current:e}){const o=this.snapToGrid;if(o&&(e=e.snappedToGrid(this.editor.viewport)),1===t.length){this.startPoint=e.canvasPos;let t=!1;if(this.selectionBox){o&&this.snapSelectionToGrid();this.selectionBox.onDragStart(e)&&(t=!0,this.selectionBoxHandlingEvt=!0,this.expandingSelectionBox=!1)}return t?this.autoscroller.start():(this.expandingSelectionBox=this.shiftKeyPressed,this.rebuildSelectionScheduled=!0),!0}return!1}onPointerMove(t){this.onMainPointerUpdated(t.current)}onMainPointerUpdated(t){if(this.lastPointer=t,this.rebuildSelectionScheduled&&(this.rebuildSelectionScheduled=!1,this.makeSelectionBox(this.startPoint??t.canvasPos),this.selectionBox?.setHandlesVisible(!1)),this.selectionBox){if(this.autoscroller.onPointerMove(t.screenPos),!this.expandingSelectionBox&&this.shiftKeyPressed&&this.startPoint){const e=this.editor.viewport.canvasToScreen(this.startPoint);t=t.lockedToXYAxesScreen(e,this.editor.viewport)}this.snapToGrid&&(t=t.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox.onDragUpdate(t):this.selectionBox.setToPoint(t.canvasPos)}}onPointerUp(t){this.onMainPointerUpdated(t.current),this.autoscroller.stop(),this.selectionBox&&(this.selectionBox.setHandlesVisible(!0),this.expandingSelectionBox&&this.prevSelectionBox?(this.expandingSelectionBox=!1,this.selectionBox.resolveToObjects(),this.setSelection([...this.selectionBox.getSelectedObjects(),...this.prevSelectionBox.getSelectedObjects()])):(this.selectionBoxHandlingEvt?this.selectionBox.onDragEnd():(this.selectionBox.resolveToObjects(),this.onSelectionUpdated()),this.selectionBoxHandlingEvt=!1,this.lastPointer=null))}onGestureCancel(){this.autoscroller.stop(),this.selectionBoxHandlingEvt?this.selectionBox?.onDragCancel():this.rebuildSelectionScheduled||(this.selectionBox?.cancelSelection(),this.selectionBox=this.prevSelectionBox,this.selectionBox?.addTo(this.handleOverlay),this.selectionBox?.recomputeRegion(),this.prevSelectionBox=null),this.rebuildSelectionScheduled=!1,this.expandingSelectionBox=!1,this.lastPointer=null,this.selectionBoxHandlingEvt=!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(u.snapToGridKeyboardShortcutId,t))return this.snapToGrid=!0,!0;if(this.selectionBox&&(e.matchesShortcut(u.duplicateSelectionShortcut,t)||e.matchesShortcut(u.sendToBackSelectionShortcut,t)))return!0;if(e.matchesShortcut(u.selectAllKeyboardShortcut,t))return this.setSelection(this.editor.image.getAllElements()),!0;if(t.ctrlKey)return!1;if((t.shiftKey||"Shift"===t.key)&&(this.shiftKeyPressed=!0,"Shift"===t.key))return!0;let o=0,n=0,r=0,a=0,l=0;e.matchesShortcut(u.translateLeftSelectionShortcutId,t)?n-=1:e.matchesShortcut(u.translateRightSelectionShortcutId,t)?n+=1:e.matchesShortcut(u.translateUpSelectionShortcutId,t)?r-=1:e.matchesShortcut(u.translateDownSelectionShortcutId,t)?r+=1:e.matchesShortcut(u.rotateClockwiseSelectionShortcutId,t)?o+=1:e.matchesShortcut(u.rotateCounterClockwiseSelectionShortcutId,t)?o-=1:e.matchesShortcut(u.shrinkXSelectionShortcutId,t)?a-=1:e.matchesShortcut(u.stretchXSelectionShortcutId,t)?a+=1:e.matchesShortcut(u.shrinkYSelectionShortcutId,t)?l-=1:e.matchesShortcut(u.stretchYSelectionShortcutId,t)?l+=1:e.matchesShortcut(u.shrinkXYSelectionShortcutId,t)?(a-=1,l-=1):e.matchesShortcut(u.stretchXYSelectionShortcutId,t)&&(a+=1,l+=1);let c=0!==n||0!==r||0!==o||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(o*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(n,r).times(t)))),m=this.selectionBox.getTransform();this.selectionBox.setTransform(m.rightMul(f)),this.selectionBox.scrollTo(),this.hasUnfinalizedTransformFromKeyPress=!0}}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;if(e.matchesShortcut(u.snapToGridKeyboardShortcutId,t))return this.snapToGrid=!1,!0;if(e.matchesShortcut(u.selectAllKeyboardShortcut,t))return!0;if(this.selectionBox&&e.matchesShortcut(u.duplicateSelectionShortcut,t))return this.selectionBox.duplicateSelectedObjects().then((t=>{this.editor.dispatch(t)})),!0;if(this.selectionBox&&e.matchesShortcut(u.sendToBackSelectionShortcut,t)){const t=this.selectionBox.sendToBack();return t&&this.editor.dispatch(t),!0}return!1===t.shiftKey&&(this.shiftKeyPressed=!1),"Shift"===t.key?(this.shiftKeyPressed=!1,!0):!this.hasUnfinalizedTransformFromKeyPress||!!this.selectionBox&&(this.selectionBox.finalizeTransform(),this.hasUnfinalizedTransformFromKeyPress=!1,!0)}onCopy(t){if(!this.selectionBox)return!1;const e=this.selectionBox.getSelectedObjects(),o=this.selectionBox.region;if(0===e.length)return!1;const n=new s.default((()=>{}));let r=this.selectionBox.getScreenRegion().size.times(this.editor.display.getDevicePixelRatio()).maximumEntryMagnitude()/(o.size.maximumEntryMagnitude()||1);r=Math.pow(2,Math.ceil(Math.log2(r))),n.updateScreenSize(o.size.times(r)),n.resetTransform(i.Mat33.scaling2D(r).rightMul(i.Mat33.translation(o.topLeft.times(-1))));const{element:a,renderer:d}=c.default.fromViewport(n,{sanitize:!0,useViewBoxForPositioning:!0}),{element:u,renderer:p}=l.default.fromViewport(n,{maxCanvasDimen:4096}),f=[];for(const t of e)t.render(d),t.render(p),t instanceof h.default&&f.push(t.getText());return t.setData("image/svg+xml",a.outerHTML),t.setData("text/html",a.outerHTML),t.setData("image/png",new Promise(((t,e)=>{u.toBlob((o=>{o?t(o):e(new Error("Failed to convert canvas to blob."))}),"image/png")}))),f.length>0&&t.setData("text/plain",f.join("\n")),!0}setEnabled(t){const e=this.isEnabled();super.setEnabled(t),e!==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,o)=>!(o>0)||e!==t[o-1]));let e=null;for(const o of t)e=e?e.union(o.getBBox()):o.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()}}e.default=m},7275:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=n(o(6398));e.default=class{constructor(t,e){this.viewport=t,this.scrollByCanvasDelta=e,this.started=!1,this.updateLoopId=0,this.updateLoopRunning=!1,this.targetPoint=null,this.scrollRate=1e3}getScrollForPoint(t){const e=this.viewport.getScreenRectSize(),o=new i.Rect2(0,0,e.x,e.y).grownBy(-44);if(o.containsPoint(t))return i.Vec2.zero;const n=o.getClosestPointOnBoundaryTo(t),r=n.distanceTo(t),s=n.minus(t),a=Math.min(r/44,1.25);return s.normalizedOrZero().times(a)}start(){this.started=!0}onPointerMove(t){this.started&&(this.getScrollForPoint(t)===i.Vec2.zero?this.stopUpdateLoop():(this.targetPoint=t,this.startUpdateLoop()))}stop(){this.targetPoint=null,this.started=!1,this.stopUpdateLoop()}startUpdateLoop(){this.updateLoopRunning||(async()=>{this.updateLoopId++;const t=this.updateLoopId;let e=performance.now();for(;this.updateLoopId===t&&this.targetPoint;){this.updateLoopRunning=!0;const t=performance.now(),o=t-e,n=this.getScrollForPoint(this.targetPoint).times(this.scrollRate*o/1e3);this.scrollByCanvasDelta(this.viewport.screenToCanvasTransform.transformVec3(n)),e=t,await(0,r.default)()}this.updateLoopRunning=!1})()}stopUpdateLoop(){this.updateLoopId++}}},3615:function(t,e,o){"use strict";var n=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=o(5379),r=n(o(4093)),s=o(6757);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(){return 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,this.computeOriginAndScaleRate()}computeOriginAndScaleRate(){const t=this.selection.preTransformRegion,e=t.corners;let o=0;for(let t=0;t<e.length;t++){const n=e[t],i=this.dragStartPoint.minus(n).magnitudeSquared();i>o&&(o=i,this.transformOrigin=n)}let n=1,r=1;this.transformOrigin.x>t.center.x&&(n=-1),this.transformOrigin.y>t.center.y&&(r=-1),this.scaleRate=i.Vec2.of(n,r)}onDragUpdate(t){const e=t.minus(this.dragStartPoint),o=this.selection.preTransformRegion.width,n=this.selection.preTransformRegion.height;let a=i.Vec2.of(1,1);if(this.mode===s.ResizeMode.HorizontalOnly){const t=o+e.x*this.scaleRate.x;a=i.Vec2.of(t/o,a.y)}if(this.mode===s.ResizeMode.VerticalOnly){const t=n+e.y*this.scaleRate.y;a=i.Vec2.of(a.x,t/n)}if(this.mode===s.ResizeMode.Both){const t=o+(Math.abs(e.x)>Math.abs(e.y)?e.x:e.y);a=i.Vec2.of(t/o,t/o)}if(a=a.map((t=>r.default.roundScaleRatio(t,2))),0!==a.x&&0!==a.y){const t=this.editor.viewport.roundPoint(this.transformOrigin);this.selection.setTransform(i.Mat33.scaling2D(a,t))}}onDragEnd(){return this.selection.finalizeTransform()}};e.RotateTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.startAngle=0,this.targetRotation=0,this.maximumDistFromStart=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.startPoint=t,this.selection.setTransform(i.Mat33.identity),this.startAngle=this.getAngle(t),this.targetRotation=0,this.maximumDistFromStart=0,this.startTime=performance.now()}setRotationTo(t){const e=this.editor.viewport.roundPoint(this.selection.preTransformRegion.center),o=i.Mat33.zRotation(t).mapEntries((t=>r.default.roundScaleRatio(t))),n=i.Mat33.translation(e).rightMul(o).rightMul(i.Mat33.translation(e.times(-1)));this.selection.setTransform(n)}onDragUpdate(t){this.targetRotation=this.roundAngle(this.getAngle(t)-this.startAngle),this.setRotationTo(this.targetRotation);const e=t.minus(this.startPoint).magnitude();e>this.maximumDistFromStart&&(this.maximumDistFromStart=e)}onDragEnd(){return(performance.now()-this.startTime)/1e3<.4&&this.maximumDistFromStart<10&&0===this.targetRotation&&this.setRotationTo(-Math.PI/2),this.selection.finalizeTransform()}}},8561:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.stretchXYSelectionShortcutId=e.shrinkXYSelectionShortcutId=e.stretchYSelectionShortcutId=e.shrinkYSelectionShortcutId=e.stretchXSelectionShortcutId=e.shrinkXSelectionShortcutId=e.rotateClockwiseSelectionShortcutId=e.rotateCounterClockwiseSelectionShortcutId=e.translateDownSelectionShortcutId=e.translateUpSelectionShortcutId=e.translateRightSelectionShortcutId=e.translateLeftSelectionShortcutId=e.sendToBackSelectionShortcut=e.duplicateSelectionShortcut=e.selectAllKeyboardShortcut=void 0;const i=n(o(5577));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"),e.sendToBackSelectionShortcut="jsdraw.tools.SelectionTool.sendToBack",i.default.registerDefaultKeyboardShortcut(e.sendToBackSelectionShortcut,["End"],"Send to back"),e.translateLeftSelectionShortcutId="jsdraw.tools.SelectionTool.translateLeft",i.default.registerDefaultKeyboardShortcut(e.translateLeftSelectionShortcutId,["KeyA","KeyH","ArrowLeft"],"Move selection left"),e.translateRightSelectionShortcutId="jsdraw.tools.SelectionTool.translateRight",i.default.registerDefaultKeyboardShortcut(e.translateRightSelectionShortcutId,["KeyD","KeyL","ArrowRight"],"Move selection right"),e.translateUpSelectionShortcutId="jsdraw.tools.SelectionTool.translateUp",i.default.registerDefaultKeyboardShortcut(e.translateUpSelectionShortcutId,["KeyQ","KeyK","ArrowUp"],"Move selection up"),e.translateDownSelectionShortcutId="jsdraw.tools.SelectionTool.translateDown",i.default.registerDefaultKeyboardShortcut(e.translateDownSelectionShortcutId,["KeyE","KeyJ","ArrowDown"],"Move selection down"),e.rotateCounterClockwiseSelectionShortcutId="jsdraw.tools.SelectionTool.rotateCCW",i.default.registerDefaultKeyboardShortcut(e.rotateCounterClockwiseSelectionShortcutId,["Shift+KeyR"],"Rotate selection counter clockwise"),e.rotateClockwiseSelectionShortcutId="jsdraw.tools.SelectionTool.rotateCW",i.default.registerDefaultKeyboardShortcut(e.rotateClockwiseSelectionShortcutId,["KeyR"],"Rotate selection clockwise"),e.shrinkXSelectionShortcutId="jsdraw.tools.SelectionTool.shrink.x",i.default.registerDefaultKeyboardShortcut(e.shrinkXSelectionShortcutId,["KeyI"],"Decrease width"),e.stretchXSelectionShortcutId="jsdraw.tools.SelectionTool.stretch.x",i.default.registerDefaultKeyboardShortcut(e.stretchXSelectionShortcutId,["Shift+KeyI"],"Increase width"),e.shrinkYSelectionShortcutId="jsdraw.tools.SelectionTool.shrink.y",i.default.registerDefaultKeyboardShortcut(e.shrinkYSelectionShortcutId,["KeyO"],"Decrease height"),e.stretchYSelectionShortcutId="jsdraw.tools.SelectionTool.stretch.y",i.default.registerDefaultKeyboardShortcut(e.stretchYSelectionShortcutId,["Shift+KeyO"],"Increase height"),e.shrinkXYSelectionShortcutId="jsdraw.tools.SelectionTool.shrink.xy",i.default.registerDefaultKeyboardShortcut(e.shrinkXYSelectionShortcutId,["Comma"],"Decrease selection size"),e.stretchXYSelectionShortcutId="jsdraw.tools.SelectionTool.stretch.xy",i.default.registerDefaultKeyboardShortcut(e.stretchXYSelectionShortcutId,["Period"],"Increase selection size")},6757:(t,e)=>{"use strict";var o,n;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"}(o||(e.ResizeMode=o={})),function(t){t[t.Snap=0]="Snap",t[t.NoSnap=1]="NoSnap"}(n||(e.TransformMode=n={}))},9854:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8816)),r=n(o(9988));e.default=t=>{const e=e=>{const o=(0,i.default)(t,{title:t.localization.copyPasteError__heading,classNames:["clipboard-error-dialog"]});o.appendChild(document.createTextNode(t.localization.copyPasteError__description));const n=document.createElement("details"),r=document.createElement("summary");return r.textContent=t.localization.copyPasteError__errorDetails,n.appendChild(r),n.appendChild(document.createTextNode(`Error: ${e}`)),o.appendChild(n),o};return{onCopyError(o){const n=e(o),i=document.createElement("label");i.textContent=t.localization.copyPasteError__copyRetry;const s=document.createElement("textarea");i.appendChild(s);const a=new r.default(t),l=t=>(t.preventDefault(),a.copy(t).then((()=>{n.close()})));s.oncopy=l,s.ondragstart=l,s.value=t.localization.copyPasteError__copyMe,n.appendChild(i),s.select(),document.execCommand("copy")},onPasteError(o){const n=e(o),i=document.createElement("label");i.textContent=t.localization.copyPasteError__pasteRetry;const s=document.createElement("textarea");i.appendChild(s);const a=new r.default(t),l=t=>(t.preventDefault(),a.paste(t).then((t=>{t&&n.close()})));s.onpaste=l,s.ondrop=l,n.appendChild(i),s.focus(),document.execCommand("paste")}}}},5426:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(6665)),r=n(o(9988)),s=n(o(9854));e.default=async(t,e,o,n,a)=>{const l=e.localization,c=t?.getSelectedItemCount()&&n,d=[{text:l.selectionMenu__paste,icon:()=>e.icons.makePasteIcon(),key:()=>{new r.default(e,(0,s.default)(e)).paste()}}],h=await(0,i.default)(e,o,c?[{text:l.selectionMenu__duplicate,icon:()=>e.icons.makeDuplicateSelectionIcon(),key:async()=>{await e.dispatch(await t.duplicateSelectedObjects())}},{text:l.selectionMenu__delete,icon:()=>e.icons.makeDeleteSelectionIcon(),key:async()=>{await e.dispatch(t.deleteSelectedObjects()),a()}},{text:l.selectionMenu__copyToClipboard,icon:()=>e.icons.makeCopyIcon(),key:()=>{new r.default(e,(0,s.default)(e)).copy()}},...d]:d);h?.()}},340:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(5379),r=n(o(8836));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(),o=220*-Math.cos(e.x/2)+440,n=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(o,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(n,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),o=this.editor.image.getElementsIntersectingRegion(e.bbox).filter((t=>t.intersects(e)));this.lastPointerPos=t.canvasPos,o.length>0&&this.soundFeedback?.announceBoundaryCross(o.length)}onPointerUp(t){this.soundFeedback?.pause()}onGestureCancel(){this.soundFeedback?.pause()}}e.default=a},7686:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(2170)),r=n(o(7)),s=o(5379),a=o(578),l=o(2018),c=n(o(8836)),d=n(o(6188)),h=n(o(2717)),u=o(7988),p="textEditorOverlay";class f extends c.default{constructor(t,e,o){super(t.notifier,e),this.editor=t,this.localizationTable=o,this.textInputElem=null,this.textMeasuringCtx=null,this.removeExistingCommand=null;const n=t.getCurrentSettings().text?.fonts??[];this.textStyleValue=u.ReactiveValue.fromInitialValue({size:32,fontFamily:n.length>0?n[0]:"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.contentTransform=u.ReactiveValue.fromInitialValue(s.Mat33.identity),this.textEditOverlay=document.createElement("div"),this.textEditOverlay.classList.add(p),this.editor.addStyleSheet(`\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.anchorControl=this.editor.anchorElementToCanvas(this.textEditOverlay,this.contentTransform)}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 o=this.textMeasuringCtx.measureText(t);return o.fontBoundingBoxAscent??o.actualBoundingBoxAscent}return 2*e.size/3}flushInput(t=!0){if(!this.textInputElem)return;const e=this.textEditOverlay.parentElement,o=s.Vec2.of(e?.scrollLeft??0,e?.scrollTop??0),n=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",t){const t=this.textInputElem;this.textInputElem=null,t.remove()}if(""!==n){const t=o.times(-1),e=this.editor.viewport.screenToCanvasTransform.transformVec3(t),a=s.Mat33.translation(e),l=i.default.fromLines(n.split("\n"),a.rightMul(this.contentTransform.get()),this.textStyle),c=r.default.addElement(l);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch((0,h.default)([this.removeExistingCommand,c])),this.removeExistingCommand=null):this.editor.dispatch(c)}}updateTextInput(){if(!this.textInputElem)return;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.margin="0",this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`;const t=this.getTextAscent("Testing!",this.textStyle);this.textInputElem.style.transform=`translate(0, ${-t}px)`,this.textInputElem.style.transformOrigin="top left";const e=Math.floor(this.textStyle.size);this.textInputElem.style.lineHeight=`${e}px`}startTextInput(t,e){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=e,this.textInputElem.style.display="inline-block";const o=this.editor.viewport.roundPoint(t),n=-this.editor.viewport.getRotationAngle(),i=s.Vec2.of(1,1).times(this.editor.viewport.getSizeOfPixelOnCanvas());this.contentTransform.set(s.Mat33.translation(o).rightMul(s.Mat33.zRotation(n)).rightMul(s.Mat33.scaling2D(i))),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=>{t.isComposing||("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,o=s.Vec2.of(2.5,2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas()),n=s.Rect2.fromCorners(e.minus(o),e.plus(o));let r=this.editor.image.getElementsIntersectingRegion(n).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()),this.contentTransform.set(t.getTransform()),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)}onDestroy(){super.onDestroy(),this.anchorControl.remove()}}e.default=f},4641:function(t,e,o){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),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||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[e.length]=o);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o=n(t),s=0;s<o.length;s++)"default"!==o[s]&&i(e,t,o[s]);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=o(2018),c=o(5379),d=s(o(7955)),h=a(o(9392)),u=a(o(9873)),p=a(o(1011)),f=a(o(1172)),m=a(o(903)),g=a(o(7686)),b=a(o(2870)),y=a(o(5192)),v=a(o(166)),x=a(o(5716)),w=o(14),S=a(o(8402)),T=a(o(4209)),C=a(o(340)),P=o(7394),k=a(o(960)),E=a(o(3343)),z=a(o(915));e.default=class{constructor(t,e){this.activeTool=null,this.isEditorReadOnly=t.isReadOnlyReactiveValue(),this.inputPipeline=new k.default,this.inputPipeline.setEmitListener((t=>this.onEventInternal(t)));const o=new u.default;this.primaryToolGroup=o;const n=new d.default(t,d.PanZoomMode.TwoFingerTouchGestures|d.PanZoomMode.RightClickDrags,e.touchPanTool),i=new d.default(t,d.PanZoomMode.Keyboard,e.keyboardPanZoom),r=new h.default(t,e.penTool(1),{color:c.Color4.purple,thickness:8}),s=new h.default(t,e.penTool(2),{color:c.Color4.clay,thickness:4});s.setInputMapper(new E.default(t.viewport));const a=new p.default(t,e.eraserTool),P=[r,s,new h.default(t,e.penTool(3),{color:c.Color4.ofRGBA(1,1,0,.5),thickness:40,factory:w.makePressureSensitiveFreehandLineBuilder}),a,new f.default(t,e.selectionTool),new g.default(t,e.textTool,e),new d.default(t,d.PanZoomMode.SinglePointerGestures,e.anyDevicePanning)],M=new C.default(t,e.soundExplorer);M.setEnabled(!1),this.tools=[new z.default(t),new b.default(t,e.pipetteTool),M,n,...P,i,new m.default(t),new x.default(t),new y.default(t),a.makeEraserSwitcherTool(),new S.default(t),new v.default(t),new T.default(t)],P.forEach((t=>t.setToolGroup(o))),n.setEnabled(!0),r.setEnabled(!0),t.notifier.on(l.EditorEventType.ToolEnabled,(o=>{o.kind===l.EditorEventType.ToolEnabled&&t.announceForAccessibility(e.toolEnabledAnnouncement(o.tool.description))})),t.notifier.on(l.EditorEventType.ToolDisabled,(o=>{o.kind===l.EditorEventType.ToolDisabled&&t.announceForAccessibility(e.toolDisabledAnnouncement(o.tool.description))})),this.activeTool=null}setTools(t,e){this.tools=t,this.primaryToolGroup=e??new u.default}addPrimaryTool(t){t.setToolGroup(this.primaryToolGroup),t.isEnabled()&&this.primaryToolGroup.notifyEnabled(t),this.tools.includes(t)||this.addTool(t)}getPrimaryTools(){return this.tools.filter((t=>t.getToolGroup()===this.primaryToolGroup))}addTool(t,e){this.tools.includes(t)||(e?.addToFront?this.tools.splice(0,0,t):this.tools.push(t))}removeAndDestroyTools(t){const e=[];for(const o of this.tools)t.includes(o)?(this.activeTool===o&&(this.activeTool=null),o.onDestroy()):e.push(o);this.tools=e}insertTools(t,e,o){this.tools=this.tools.filter((t=>!e.includes(t)));const n=[];for(const i of this.tools)"after"===o&&n.push(i),i===t&&n.push(...e),"before"===o&&n.push(i);this.tools=n}insertToolsAfter(t,e){this.insertTools(t,e,"after")}insertToolsBefore(t,e){this.insertTools(t,e,"before")}onEventInternal(t){const e=this.isEditorReadOnly.get(),o=t=>t.isEnabled()&&(!e||t.canReceiveInputInReadOnlyEditor());let n=!1;if(t.kind===P.InputEvtType.PointerDownEvt){let e=!1;this.activeTool&&!this.activeTool.eventCanBeDeliveredToNonActiveTool(t)&&(e=!0);for(const i of this.tools)if((!e||i===this.activeTool)&&o(i)&&i.onEvent(t)){this.activeTool!==i&&this.activeTool?.onEvent({kind:P.InputEvtType.GestureCancelEvt}),this.activeTool=i,n=!0;break}}else if(t.kind===P.InputEvtType.PointerUpEvt){const e=this.activeTool?.onEvent(t);e&&t.allPointers.length>1||(this.activeTool=null),n=!0}else if(t.kind===P.InputEvtType.PointerMoveEvt)null!==this.activeTool&&(this.activeTool.onEvent(t),n=!0);else if(t.kind===P.InputEvtType.GestureCancelEvt)null!==this.activeTool&&(this.activeTool.onEvent(t),this.activeTool=null);else for(const e of this.tools)if(o(e)&&(n=e.onEvent(t),n))break;return n}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()}}},9873:(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)}}},5192:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8836));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(),o=/^[0-9]$/.exec(t);let n;if(o){n=e[parseInt(o[0],10)-1]}return!!n&&(n.setEnabled(!0),!0)}}e.default=r},5716:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8836));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 o of e)if(o(t))return!0;return!1}}e.default=r},903:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(8836)),r=o(6362);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},6362:function(t,e,o){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),i=this&&this.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),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 s=r(o(5577));e.undoKeyboardShortcutId="jsdraw.tools.undo",e.redoKeyboardShortcutId="jsdaw.tools.redo",s.default.registerDefaultKeyboardShortcut(e.undoKeyboardShortcutId,["CtrlOrMeta+KeyZ"],"Undo"),s.default.registerDefaultKeyboardShortcut(e.redoKeyboardShortcutId,["CtrlOrMeta+Shift+KeyZ","CtrlOrMeta+KeyY"],"Redo"),e.increaseSizeKeyboardShortcutId="jsdraw.tools.increaseSize",s.default.registerDefaultKeyboardShortcut(e.increaseSizeKeyboardShortcutId,["Equal","Shift+Equal"],"Increase pen/eraser size"),e.decreaseSizeKeyboardShortcutId="jsdraw.tools.decreaseSize",s.default.registerDefaultKeyboardShortcut(e.decreaseSizeKeyboardShortcutId,["Minus","Shift+Minus"],"Decrease pen/eraser size"),e.snapToGridKeyboardShortcutId="jsdraw.tools.snapToGrid",s.default.registerDefaultKeyboardShortcut(e.snapToGridKeyboardShortcutId,["Control","Meta"],"Snap to grid (press and hold)"),e.lineLockKeyboardShortcutId="jsdraw.tools.lockToLine",s.default.registerDefaultKeyboardShortcut(e.lineLockKeyboardShortcutId,["Shift"],"Snap to XY axes (press and hold)"),e.toggleFindVisibleShortcutId="js-draw.tools.FindTool.toggleVisible",s.default.registerDefaultKeyboardShortcut(e.toggleFindVisibleShortcutId,["CtrlOrMeta+KeyF"],"Shows/hides the find tool"),e.moveLeftKeyboardShortcutId="jsdraw.tools.PanZoom.moveLeft",s.default.registerDefaultKeyboardShortcut(e.moveLeftKeyboardShortcutId,["ArrowLeft","KeyH","KeyA"],"Pan left"),e.moveRightKeyboardShortcutId="jsdraw.tools.PanZoom.moveRight",s.default.registerDefaultKeyboardShortcut(e.moveRightKeyboardShortcutId,["ArrowRight","KeyL","KeyD"],"Pan right"),e.moveUpKeyboardShortcutId="jsdraw.tools.PanZoom.moveUp",s.default.registerDefaultKeyboardShortcut(e.moveUpKeyboardShortcutId,["ArrowUp","KeyK","KeyQ"],"Pan up"),e.moveDownKeyboardShortcutId="jsdraw.tools.PanZoom.moveDown",s.default.registerDefaultKeyboardShortcut(e.moveDownKeyboardShortcutId,["ArrowDown","KeyJ","KeyE"],"Pan down"),e.rotateClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewClockwise",s.default.registerDefaultKeyboardShortcut(e.rotateClockwiseKeyboardShortcutId,["Shift+KeyR"],"Rotate viewport clockwise"),e.rotateCounterClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewCounterClockwise",s.default.registerDefaultKeyboardShortcut(e.rotateCounterClockwiseKeyboardShortcutId,["KeyR"],"Rotate viewport counter-clockwise"),e.zoomInKeyboardShortcutId="jsdraw.tools.PanZoom.zoomIn",s.default.registerDefaultKeyboardShortcut(e.zoomInKeyboardShortcutId,["KeyW"],"Zoom in"),e.zoomOutKeyboardShortcutId="jsdraw.tools.PanZoom.zoomOut",s.default.registerDefaultKeyboardShortcut(e.zoomOutKeyboardShortcutId,["KeyS"],"Zoom out"),i(o(8561),e)},6532:function(t,e,o){"use strict";var n=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.EraserMode=e.EraserTool=e.SelectAllShortcutHandler=e.SelectionTool=e.TextTool=e.PenTool=e.PanZoomMode=e.PanZoomTool=e.ToolSwitcherShortcut=e.UndoRedoShortcut=e.ToolEnabledGroup=e.ToolController=e.BaseTool=e.InputMapper=void 0;var i=o(2388);Object.defineProperty(e,"InputMapper",{enumerable:!0,get:function(){return n(i).default}});var r=o(8836);Object.defineProperty(e,"BaseTool",{enumerable:!0,get:function(){return n(r).default}});var s=o(4641);Object.defineProperty(e,"ToolController",{enumerable:!0,get:function(){return n(s).default}});var a=o(9873);Object.defineProperty(e,"ToolEnabledGroup",{enumerable:!0,get:function(){return n(a).default}});var l=o(903);Object.defineProperty(e,"UndoRedoShortcut",{enumerable:!0,get:function(){return n(l).default}});var c=o(5192);Object.defineProperty(e,"ToolSwitcherShortcut",{enumerable:!0,get:function(){return n(c).default}});var d=o(7955);Object.defineProperty(e,"PanZoomTool",{enumerable:!0,get:function(){return n(d).default}}),Object.defineProperty(e,"PanZoomMode",{enumerable:!0,get:function(){return d.PanZoomMode}});var h=o(9392);Object.defineProperty(e,"PenTool",{enumerable:!0,get:function(){return n(h).default}});var u=o(7686);Object.defineProperty(e,"TextTool",{enumerable:!0,get:function(){return n(u).default}});var p=o(1172);Object.defineProperty(e,"SelectionTool",{enumerable:!0,get:function(){return n(p).default}});var f=o(4209);Object.defineProperty(e,"SelectAllShortcutHandler",{enumerable:!0,get:function(){return n(f).default}});var m=o(1011);Object.defineProperty(e,"EraserTool",{enumerable:!0,get:function(){return n(m).default}}),Object.defineProperty(e,"EraserMode",{enumerable:!0,get:function(){return m.EraserMode}});var g=o(166);Object.defineProperty(e,"PasteHandler",{enumerable:!0,get:function(){return n(g).default}});var b=o(340);Object.defineProperty(e,"SoundUITool",{enumerable:!0,get:function(){return n(b).default}});var y=o(5716);Object.defineProperty(e,"ToolbarShortcutHandler",{enumerable:!0,get:function(){return n(y).default}})},8658:(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",selectionMenu__show:"Show selection menu",selectionMenu__copyToClipboard:"Copy to clipboard",selectionMenu__duplicate:"Duplicate",selectionMenu__delete:"Delete",selectionMenu__paste:"Paste",copyPasteError__heading:"Copy/paste",copyPasteError__description:"Something went wrong — this tool may not have clipboard access.",copyPasteError__errorDetails:"Show error",copyPasteError__pasteRetry:"To retry, please paste into the input box below:",copyPasteError__copyRetry:"To retry, please copy the text in the input box below:",copyPasteError__copyMe:"Copy me!",autocorrectedTo:t=>`Autocorrected to ${t}`,autocorrectionCanceled:"Autocorrect cancelled",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=>`Copied ${t} item(s)`,pasted:t=>`Pasted ${t} item(s)`,toolEnabledAnnouncement:t=>`${t} enabled`,toolDisabledAnnouncement:t=>`${t} disabled`}},5043:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultStationaryDetectionConfig=void 0;const n=o(5379);e.defaultStationaryDetectionConfig={maxSpeed:8.5,maxRadius:11,minTimeSeconds:.5};e.default=class{constructor(t,e,o){this.config=e,this.onStationary=o,this.timeout=null,this.stationaryStartPointer=t,this.lastPointer=t,this.averageVelocity=n.Vec2.zero,this.setStationaryTimeout(1e3*this.config.minTimeSeconds)}onPointerMove(t){if(!this.stationaryStartPointer)return;if(t.id!==this.stationaryStartPointer.id)return!1;const e=t.screenPos.minus(this.lastPointer.screenPos),o=t.screenPos.minus(this.stationaryStartPointer.screenPos);let n=(t.timeStamp-this.lastPointer.timeStamp)/1e3;0===n&&(n=1);const i=e.times(1/n);this.averageVelocity=this.averageVelocity.lerp(i,.5);const r=t.timeStamp-this.stationaryStartPointer.timeStamp,s=o.length()>this.config.maxRadius;if(this.hasMovedOutOfRadius||=s,s||this.averageVelocity.length()>this.config.maxSpeed||r<this.config.minTimeSeconds)return this.stationaryStartPointer=t,this.lastPointer=t,this.setStationaryTimeout(1e3*this.config.minTimeSeconds),!1;const a=1e3*this.config.minTimeSeconds-r;return this.lastPointer=t,a<=0}onPointerUp(t){t.id!==this.stationaryStartPointer?.id&&this.cancelStationaryTimeout()}destroy(){this.cancelStationaryTimeout(),this.stationaryStartPointer=null}getHasMovedOutOfRadius(){return this.hasMovedOutOfRadius}cancelStationaryTimeout(){null!==this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}setStationaryTimeout(t){null===this.timeout&&(t<=0?this.onStationary(this.lastPointer):this.timeout=setTimeout((()=>{if(this.timeout=null,!this.stationaryStartPointer)return;const t=performance.now()-this.stationaryStartPointer.timeStamp,e=1e3*this.config.minTimeSeconds-t;e<=0?this.onStationary(this.lastPointer):this.setStationaryTimeout(e)}),t))}}},6665:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(6453)),r=o(2018);let s=0;e.default=async(t,e,o)=>{const n=document.createElement("div"),{remove:a}=t.createHTMLOverlay(n),l=document.createElement("dialog");l.classList.add("editor-popup-menu");l.style.setProperty("--hide-menu-animation-timeout","240ms");const c=()=>{const o=t.getOutputBBoxInDOM(),n=t.viewport.canvasToScreen(e).plus(o.topLeft);l.style.setProperty("--anchor-x",`${n.x}px`),l.style.setProperty("--anchor-y",`${n.y}px`)};c();const d=t.notifier.on(r.EditorEventType.ViewportChanged,c);n.appendChild(l);let h=!1;const u=async()=>{h||(h=!0,d.remove(),l.classList.add("-hide"),await(0,i.default)(240),l.close())};return new Promise((e=>{let n=!1,i=null;const r=()=>{n||(e(i),n=!0)};l.onclose=()=>{a(),r()};t.handlePointerEventsExceptClicksFrom(l,((t,e)=>e.target===l&&"pointerdown"===t?(u(),!0):!!h),((t,e)=>e.target===l));const c=document.createElement("div");c.classList.add("content"),c.role="menu";const d=[];c.addEventListener("keydown",(t=>{const e=d.findIndex((t=>t===document.activeElement));if(-1===e)return;let o=e;"ArrowDown"===t.key?o++:"ArrowUp"===t.key?o--:"End"===t.key?o=d.length-1:"Home"===t.key&&(o=0),o<0&&(o+=d.length),o%=d.length,o!==e&&(t.preventDefault(),d[o].focus())}));for(const t of o){const e=document.createElement("button");e.id="menu-overlay-option-"+s++,e.role="menuitem",e.classList.add("option","editor-popup-menu-option"),e.replaceChildren(t.icon(),document.createTextNode(t.text)),e.onclick=e=>{var o;e.defaultPrevented||(o=t.key,i=o,u(),r())},c.appendChild(e),0===d.length&&(e.autofocus=!0),d.push(e)}l.appendChild(c),l.showModal(),c.scrollIntoView({block:"nearest"})}))}},2018:(t,e)=>{"use strict";var o,n;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"}(o||(e.EditorEventType=o={})),function(t){t[t.CommandDone=0]="CommandDone",t[t.CommandUndone=1]="CommandUndone",t[t.CommandRedone=2]="CommandRedone"}(n||(e.UndoEventType=n={}))},9988:function(t,e,o){"use strict";var n,i=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)},r=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=o(7394),l=s(o(8733)),c=t=>t.endsWith("+xml")||t.startsWith("text/");n=new WeakMap,e.default=class{constructor(t,e){this.editor=t,this.callbacks=e,n.set(this,!1)}paste(t){const e=t=>{if(this.callbacks?.onPasteError)return this.callbacks.onPasteError(t),Promise.resolve(!1);throw t};try{return this.pasteInternal(t).catch(e)}catch(t){return e(t)}}async pasteInternal(t){const e=this.editor,o=t?.dataTransfer??t?.clipboardData??null,n=!!o,i=(t,o)=>o&&e.toolController.dispatchInputEvent({kind:a.InputEvtType.PasteEvent,mime:t,data:o}),r=["image/svg+xml","text/html","image/png","image/jpeg","text/plain"];let s=[];const d=new Map,h=e.getCurrentSettings();if(n){s=[...o.files];for(const t of r){const e=o.getData(t);e&&d.set(t,e)}}else if(h.clipboardApi){const t=await h.clipboardApi.read();for(const[e,o]of t.entries())if("string"==typeof o)d.set(e,o);else{let t=o;t.type!==e&&(t=new Blob([t],{type:e})),s.push(t)}}else{const t=await navigator.clipboard.read();for(const e of t)for(const t of e.types)r.includes(t)&&s.push(await e.getType(t))}const u=async o=>{const n=c(o);if(n){const e=d.get(o);if(i(o,e))return t?.preventDefault(),!0}for(const r of s){const s=r?.type?.toLowerCase();if(s===o)if(n){const e=await r.text();if(i(o,e))return t?.preventDefault(),!0}else{e.showLoadingWarning(0);const n=t=>{e.showLoadingWarning(t.loaded/t.total)};try{const s=await(0,l.default)(r,{onprogress:n});if(i(o,s))return t?.preventDefault(),e.hideLoadingWarning(),!0}catch(t){console.error("Error reading image:",t)}e.hideLoadingWarning()}}return!1};for(const t of r)if(await u(t))return!0;return!1}copy(t){const e=t=>{if(this.callbacks?.onCopyError)return this.callbacks.onCopyError(t),Promise.resolve();throw t};try{return this.copyInternal(t).catch(e)}catch(t){return e(t)}}copyInternal(t){const e=new Map;this.editor.toolController.dispatchInputEvent({kind:a.InputEvtType.CopyEvent,setData:(t,o)=>{e.set(t,o)}})&&t?.preventDefault();const o=[...e.keys()].some((t=>!c(t))),s=o=>{if(!t)throw new Error("Unable to copy -- no event provided"+(o?`. Original error: ${o}`:""));for(const[o,n]of e.entries())"string"==typeof n&&("clipboardData"in t?t.clipboardData?.setData(o,n):t.dataTransfer?.setData(o,n))},l="undefined"!=typeof ClipboardItem&&void 0!==navigator?.clipboard?.write,d=!i(this,n,"f")&&l&&(o||!t),h=this.editor.getCurrentSettings();if(d&&h.clipboardApi){return h.clipboardApi.write(e)??Promise.resolve()}if(d){let t=null;const o=t=>{console.warn("Unable to copy to the clipboard API. Future calls to .copy will use ClipboardEvents if possible.",t),r(this,n,!0,"f"),s(t)};try{t=(()=>{const t=(t=>{const e=Object.create(null);for(const[o,n]of Object.entries(t))"supports"in ClipboardItem&&"function"==typeof ClipboardItem.supports&&!ClipboardItem.supports(o)||(e[o]=n);return e})((t=>{const e=Object.create(null);for(const[o,n]of t.entries()){if("string"==typeof n){const t=new Blob([(new TextEncoder).encode(n)],{type:o});e[o]=t}else e[o]=n;"image/svg+xml"===o&&(e["text/html"]??=e[o])}return e})(e));return navigator.clipboard.write([new ClipboardItem(t)])})()}catch(t){o(t)}if(t)return t.catch(o)}else s();return Promise.resolve()}}},7988:function(t,e){"use strict";var o,n,i=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},r=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0}),e.MutableReactiveValue=e.ReactiveValue=void 0;const s={remove(){}},a=()=>s;class l{waitForNextUpdate(){return new Promise((t=>{const e=this.onUpdate((o=>{e.remove(),t(o)}))}))}static fromInitialValue(t){return new d(t)}static fromImmutable(t){return{get:()=>t,onUpdate:a,onUpdateAndNow:e=>(e(t),s),waitForNextUpdate:()=>new Promise((()=>{}))}}static fromCallback(t,e){const o=new d(t()),n=window.WeakRef?new window.WeakRef(o):{deref:()=>o};for(const o of e){const e=o.onUpdate((()=>{const o=n.deref();o?o.set(t()):e.remove()}))}return o}static map(t,e,o){const n=l.fromInitialValue(e(t.get()));let i=n.get();return t.onUpdate((t=>{i=e(t),n.set(i)})),o&&n.onUpdate((e=>{e!==i&&t.set(o(e))})),n}static union(t){return l.fromCallback((()=>t.map((t=>t.get()))),t)}}e.ReactiveValue=l;class c extends l{static fromProperty(t,e){const o=l.fromInitialValue(t.get()[e]),n=window.WeakRef?new window.WeakRef(o):{deref:()=>o},i=t.onUpdate((t=>{const o=n.deref();o?o.set(t[e]):i.remove()}));return o.onUpdate((o=>{t.set({...t.get(),[e]:o})})),o}}e.MutableReactiveValue=c;class d extends c{constructor(t){super(),o.set(this,void 0),n.set(this,void 0),i(this,o,t,"f"),i(this,n,[],"f")}set(t){if(r(this,o,"f")!==t){i(this,o,t,"f");for(const e of r(this,n,"f"))e(t)}}get(){return r(this,o,"f")}onUpdate(t){return r(this,n,"f").push(t),{remove:()=>{i(this,n,r(this,n,"f").filter((e=>e!==t)),"f")}}}onUpdateAndNow(t){return t(this.get()),this.onUpdate(t)}}o=new WeakMap,n=new WeakMap,e.default=l},3676:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(7184));e.default=(t,e)=>{const o="has-long-press-or-hover",n="no-long-press-or-hover";t.classList.add("no-long-press-or-hover");const{removeListeners:r}=(0,i.default)(t,{onStart(){t.classList.remove(n),t.classList.add(o)},onEnd(){t.classList.add(n),t.classList.remove(o)},longPressTimeout:e?.timeout});return{removeEventListeners:()=>{t.classList.remove(n),r()}}}},6710:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(5379);e.default=(t,e)=>{const o=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)o.style.setProperty(t,null),o.style.setProperty(e,null);const r=getComputedStyle(o),s=Object.create(null),a=(t,e,i,a,l)=>{let c=s[t]?s[t]:n.Color4.fromString(r.getPropertyValue(t)),d=s[e]?s[e]:n.Color4.fromString(r.getPropertyValue(e));if(c.relativeLuminance()<d.relativeLuminance()){const o=c;c=d,d=o;const n=e;e=t,t=n;const i=a;a=l,l=i}let h=!1,u=n.Color4.contrastRatio(c,d),p=0;for(;u<i&&p<8;){const t=n.Vec3.of(.1,.1,.1);a&&(d.eq(n.Color4.white)&&!l&&(d=n.Color4.black),c=n.Color4.fromRGBVector(c.rgb.plus(t))),l&&(d.eq(n.Color4.black)&&!a&&(d=n.Color4.white),d=n.Color4.fromRGBVector(d.rgb.minus(t))),u=n.Color4.contrastRatio(c,d),h=!0,p++}h&&(o.style.setProperty(t,c.toHexString()),o.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,o,n]of i){a(t,e,4.5,o,n)}}},7571:(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,o=!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 n of t)if(!(0,e.assertIsNumber)(n,o))return!1;return!0};e.assertIsBoolean=t=>{if("boolean"!=typeof t)throw new Error("Given value is not a boolean");return!0}},42:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{const e=t/1024,o=e/1024,n=o/1024;let i="B",r=t;return n>=1?(r=n,i="GiB"):o>=1?(r=o,i="MiB"):e>=1&&(r=e,i="KiB"),{size:r,units:i}}},4339:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{const e=(t,o)=>{const n=getComputedStyle(t);for(let t=0;t<n.length;t++){const e=n.item(t),i=n.getPropertyValue(e);o.style?.setProperty(e,i)}for(let n=0;n<t.children.length;n++){const i=t.children.item(n),r=o.children.item(n);i&&r?e(i,r):console.warn("CloneElement: Missing child")}},o=t.cloneNode(!0);return e(t,o),o}},7964:(t,e)=>{"use strict";var o;Object.defineProperty(e,"__esModule",{value:!0}),e.createSvgPaths=e.createSvgElements=e.createSvgElement=e.ElementNamespace=void 0,function(t){t.Html="html",t.Svg="svg"}(o||(e.ElementNamespace=o={}));const n=(t,e,n=o.Html)=>{let i;if(n===o.Html)i=document.createElement(t);else{if(n!==o.Svg)throw new Error(`Unknown element type ${n}`);i=document.createElementNS("http://www.w3.org/2000/svg",t)}for(const[t,o]of Object.entries(e))if("children"!==t){if("string"!=typeof o&&"number"!=typeof o)throw new Error("Unsupported value type "+typeof o);i.setAttribute(t,o.toString())}if(e.children)for(const t of e.children)i.appendChild(t);return i};e.createSvgElement=(t,e)=>n(t,e,o.Svg);e.createSvgElements=(t,o)=>o.map((o=>(0,e.createSvgElement)(t,o)));e.createSvgPaths=(...t)=>(0,e.createSvgElements)("path",t),e.default=n},8733:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=async(t,e={})=>{try{const o=new FileReader;return await new Promise(((n,i)=>{o.onload=()=>n(o.result),o.onerror=i,o.onabort=i,o.onprogress=t=>{e.onprogress?.(t)},o.readAsDataURL(t)}))}catch(o){(e.onWarning??console.warn)("Unable to convert file to base64 with a FileReader: ",o);const n=await t.arrayBuffer(),i=new Uint8Array(n),r=30,s=[];for(let t=0;t<i.length;t+=r){const e=String.fromCharCode(...i.slice(t,t+r));s.push(btoa(e))}return`data:${t.type??"image/*"};base64,${s.join("")}`}}},2832:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={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 o?o[t]:t}},9395:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MutableReactiveValue=e.ReactiveValue=e.adjustEditorThemeForContrast=void 0;var i=o(6710);Object.defineProperty(e,"adjustEditorThemeForContrast",{enumerable:!0,get:function(){return n(i).default}});var r=o(7988);Object.defineProperty(e,"ReactiveValue",{enumerable:!0,get:function(){return r.ReactiveValue}}),Object.defineProperty(e,"MutableReactiveValue",{enumerable:!0,get:function(){return r.MutableReactiveValue}})},6953:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const o=t.length<e.length?t:e,n=o===t?e:t;for(let t=0;t<o.length;t++)if(o[t]!==n[t])return!1;return!0}},410:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{let o=[];const n=(t,e)=>t.key===e.key&&t.code===e.code,i=t=>{if("keydown"===t.type){if(r=t,o.some((t=>n(t,r)))||o.push({code:(i=t).code,key:i.key,ctrlKey:i.ctrlKey,altKey:i.altKey,shiftKey:i.shiftKey,metaKey:i.metaKey}),!e.filter(t))return;e.handleKeyDown(t)}else{if(console.assert("keyup"===t.type),o=o.filter((e=>!n(e,t))),!e.filter(t))return;e.handleKeyUp(t)}var i,r};t.addEventListener("keydown",(t=>{i(t)})),t.addEventListener("keyup",(t=>{i(t)})),t.addEventListener("focusout",(n=>{let i=!1;if(n.relatedTarget){const o=n.relatedTarget;i=t.contains(o)||e.getHandlesKeyEventsFrom(o)}if(!i){for(const t of o)e.handleKeyUp(new KeyboardEvent("keyup",{...t}));o=[]}}));const r=t=>{let e=!1,n=!1,r=!1,s=!1;for(const t of o){const o=t.code;e||=!!o.match(/^Shift(Left|Right)$/),n||=!!o.match(/^Control(Left|Right)$/),r||=!!o.match(/^Alt(Left|Right)$/),s||=!!o.match(/^Meta(Left|Right)$/)}const a=t=>t?"keydown":"keyup",l={shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,ctrlKey:t.ctrlKey};t.shiftKey!==e&&i(new KeyboardEvent(a(t.shiftKey),{...l,key:"Shift",code:"ShiftLeft"})),t.altKey!==r&&i(new KeyboardEvent(a(t.altKey),{...l,key:"Alt",code:"AltLeft"})),t.ctrlKey!==n&&i(new KeyboardEvent(a(t.ctrlKey),{...l,key:"Control",code:"ControlLeft"})),t.metaKey!==s&&i(new KeyboardEvent(a(t.metaKey),{...l,key:"Meta",code:"MetaLeft"}))};t.addEventListener("mousedown",(t=>{r(t)})),t.addEventListener("mousemove",(t=>{r(t)}))}},7184:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const o=new Map;let n=null,i=!1;const r=()=>{if(0===o.size)i?(i=!1,e.onEnd()):null!==n&&(clearTimeout(n),n=null);else{const t=Date.now();let s=0;for(const e of o.values()){const o=t-e.timeEnter;s=Math.max(o,s)}const a=e.longPressTimeout??700;null!==n&&(clearTimeout(n),n=null);const l=a-s;l<=0?(e.onStart(),i=!0):n=setTimeout((()=>{n=null,r()}),l)}},s=t=>{const e={timeEnter:Date.now()};"pointerenter"===t.type?o.set(t.pointerId,e):"pointerleave"!==t.type&&"pointercancel"!==t.type||o.clear(),r()};return t.addEventListener("pointerenter",s),t.addEventListener("pointerleave",s),t.addEventListener("pointercancel",s),{removeListeners:()=>{t.removeEventListener("pointerenter",s),t.removeEventListener("pointerleave",s),t.removeEventListener("pointercancel",s)}}}},3718:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>`\nMIT License\n\nCopyright (c) ${t}\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.`.replace(/([^\n])[\n]([^\n])/g,"$1 $2")},9292:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{const e=(t,e,o,n)=>e!==n&&0!==t&&!(o+t<=0)&&!(o+e+t>n);t.onwheel=o=>{const n=e(o.deltaX,t.clientWidth,t.scrollLeft,t.scrollWidth),i=e(o.deltaY,t.clientHeight,t.scrollTop,t.scrollHeight);(n||i)&&o.stopPropagation()}}},6398:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=()=>new Promise((t=>{requestAnimationFrame((()=>t()))}))},9713:(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((()=>{}))}},8614:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=async t=>{t.complete||await new Promise(((e,o)=>{t.onload=t=>e(t),t.onerror=t=>o(t),t.onabort=t=>o(t)}))}},6453:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>new Promise((e=>{setTimeout((()=>e()),t)}))},5711:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={number:"1.25.0"}},9435:(t,e,o)=>{"use strict";var n=o(2591),i=o.n(n),r=o(1740),s=o.n(r),a=o(8128),l=o.n(a),c=o(855),d=o.n(c),h=o(3051),u=o.n(h),p=o(3656),f=o.n(p),m=o(5731),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u();i()(m.A,g);m.A&&m.A.locals&&m.A.locals;var b=o(9724),y={};y.styleTagTransform=f(),y.setAttributes=d(),y.insert=l().bind(null,"head"),y.domAPI=s(),y.insertStyleElement=u();i()(b.A,y);b.A&&b.A.locals&&b.A.locals},5035:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Color4=void 0;const i=n(o(4981));class r{constructor(t,e,o,n){this.r=t,this.g=e,this.b=o,this.a=n,this.hexString=null}static ofRGB(t,e,o){return r.ofRGBA(t,e,o,1)}static ofRGBA(t,e,o,n){return t=Math.max(0,Math.min(t,1)),e=Math.max(0,Math.min(e,1)),o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1)),new r(t,e,o,n)}static fromRGBArray(t,e=255){const o=t[0],n=t[1]??o,i=t[2]??o;let s=255;return 3<t.length&&(s=t[3]),r.ofRGBA(o/e,n/e,i/e,s/e)}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 o=2;o<=t.length;o+=2){const n=t.substring(o-2,o);e.push(parseInt(n,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 o=e[1],n=JSON.parse(`[ ${o} ]`);if(3===n.length)return r.ofRGB(n[0]/255,n[1]/255,n[2]/255);if(4===n.length)return r.ofRGBA(n[0]/255,n[1]/255,n[2]/255,n[3]);throw new Error(`RGB string, ${t}, has wrong number of components: ${n.length}`)}const o=document.createElement("canvas");o.width=1,o.height=1;const n=o.getContext("2d");if(!n)return r.black;n.fillStyle=t,n.fillRect(0,0,1,1);const i=n.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 o=1-(e=Math.min(Math.max(e,0),1));return new r(this.r*o+t.r*e,this.g*o+t.g*e,this.b*o+t.b*e,this.a*o+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 o=t.relativeLuminance(),n=e.relativeLuminance();return(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}static average(t){let e=0,o=0,n=0,i=0;for(const r of t)e+=r.a,o+=r.r,n+=r.g,i+=r.b;return t.length>0&&(e/=t.length,o/=t.length,n/=t.length,i/=t.length),new r(o,n,i,e)}asHSV(){const t=Math.min(this.r,this.g,this.b),e=Math.max(this.r,this.g,this.b),o=e-t;let n;n=0===o?0:this.r>=this.g&&this.r>=this.b?(this.g-this.b)/o%6:this.g>=this.r&&this.g>=this.b?(this.b-this.r)/o+2:(this.r-this.g)/o+4,n*=60,n*=Math.PI/180,n<0&&(n+=2*Math.PI);const r=e,s=r>0?o/r:0;return i.default.of(n,s,r)}static fromHSV(t,e,o){t<0&&(t+=2*Math.PI),t%=2*Math.PI;const n=(o=Math.max(0,Math.min(1,o)))*(e=Math.max(0,Math.min(1,e))),i=t/(Math.PI/3),s=n*(1-Math.abs(i%2-1));let a;a=i<1?[n,s,0]:i<2?[s,n,0]:i<3?[0,n,s]:i<4?[0,s,n]:i<5?[s,0,n]:[n,0,s];const l=o-n;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),o=t(this.r),n=t(this.g),i=t(this.b);return"ff"===e?`#${o}${n}${i}`:(this.hexString=`#${o}${n}${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},3128:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Mat33=void 0;const i=o(6742),r=n(o(4981));class s{constructor(t,e,o,n,i,s,a,l,c){this.a1=t,this.a2=e,this.a3=o,this.b1=n,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,o),r.default.of(n,i,s),r.default.of(a,l,c)]}static ofRows(t,e,o){return new s(t.x,t.y,t.z,e.x,e.y,e.z,o.x,o.y,o.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 o=0;o<3;o++){let n=t[o].at(o);const i=1e-10;if(Math.abs(n)<i){let r=-1;for(let e=1;e<=2;e++){const n=(o+e)%3;if(Math.abs(t[n].at(o))>=i){r=n;break}}if(-1===r)return this.cachedInverse=null,null;const s=t[o],a=e[o];t[o]=t[r],e[o]=e[r],t[r]=s,e[r]=a,n=t[o].at(o)}let r=1/n;t[o]=t[o].times(r),e[o]=e[o].times(r);const s=t[o],a=e[o];for(let n=1;n<=2;n++){const i=(o+n)%3;r=-t[i].at(o),t[i]=t[i].plus(s.times(r)),e[i]=e[i].plus(a.times(r))}}const o=s.ofRows(e[0],e[1],e[2]);return this.cachedInverse=o,o}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,o)=>this.rows[e].dot(t.rows[o]);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 o=0;o<3;o++)if(!this.rows[o].eq(t.rows[o],e))return!1;return!0}toString(){let t="";const e=[0,0,0];for(const t of this.rows)for(let o=0;o<3;o++)e[o]=Math.max(e[0],`${t.at(o)}`.length);for(let o=0;o<3;o++){t+=0===o?"⎡ ":1===o?"⎢ ":"⎣ ";for(let n=0;n<3;n++){const i=this.rows[o].at(n).toString();let r="";for(let t=i.length;t<e[n];t++)r+=" ";t+=i+", "+r}t+=0===o?" ⎤":1===o?" ⎥":" ⎦",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 o=Math.cos(t),n=Math.sin(t);let r=s.translation(e);return r=r.rightMul(new s(o,-n,0,n,o,0,0,0,1)),r.rightMul(s.translation(e.times(-1)))}static scaling2D(t,e=i.Vec2.zero){let o,n,r=s.translation(e);return"number"==typeof t?(o=t,n=t):(o=t.x,n=t.y),r=r.rightMul(new s(o,0,0,0,n,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;t=t.trim().replace(/\s+/g," ");const e=t=>t.split(/[, \t\n]+/g).map((e=>{if(""===e.trim())return null;let o=!1;e.endsWith("%")&&(o=!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 n=parseFloat(e);return o&&(n/=100),n})).filter((t=>null!==t)),o={matrix:t=>{if(6!==t.length)throw new Error(`Invalid matrix argument: ${t}. Must have length 6`);const e=t[0],o=t[1],n=t[2],i=t[3],r=t[4],a=t[5];return new s(e,n,r,o,i,a,0,0,1)},scale:t=>{let e,o;if(1===t.length)e=t[0],o=t[0];else{if(2!==t.length)throw new Error(`The scale() function only supports two arguments. Given: ${t}`);e=t[0],o=t[1]}return s.scaling2D(i.Vec2.of(e,o))},translate:t=>{let e=0,o=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],o=t[1]}return s.translation(i.Vec2.of(e,o))}},n=/(?:^|\W)(\w+)\s?\(([^)]*)\)/gi;let r,a=null;for(;null!==(r=n.exec(t));){const t=r[1].toLowerCase();if(!(t in o))throw new Error(`Unsupported CSS transform action: ${t}`);const n=e(r[2]),i=o[t](n);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},6742:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Vec2=e.Vec3=void 0;const n=o(4981);Object.defineProperty(e,"Vec3",{enumerable:!0,get:function(){return n.Vec3}}),Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return n.Vec2}}),e.default=n.Vec2},4981:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Vec3=e.Vec2=void 0;class o{constructor(t,e,o){this.x=t,this.y=e,this.z=o}get xy(){return{x:this.x,y:this.y}}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.magnitudeSquared())}magnitudeSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}squareDistanceTo(t){const e=this.x-t.x,o=this.y-t.y,n=this.z-t.z;return e*e+o*o+n*n}distanceTo(t){return Math.sqrt(this.squareDistanceTo(t))}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 r.of(this.x/t,this.y/t,this.z/t)}normalizedOrZero(){return this.eq(r.zero)?r.zero:this.normalized()}times(t){return r.of(this.x*t,this.y*t,this.z*t)}plus(t){return r.of(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){return r.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 r.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):r.of(this.x*t.x,this.y*t.y,this.z*t.z)}orthog(){return 0===this.dot(r.unitX)&&0===this.dot(r.unitY)?0===this.dot(r.unitX)?r.unitX:this.cross(r.unitX).normalized():this.cross(r.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 r.of(e(t.x,this.x),e(t.y,this.y),e(t.z,this.z))}map(t){return r.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){return Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e&&Math.abs(t.z-this.z)<=e}toString(){return`Vec(${this.x}, ${this.y}, ${this.z})`}}class n{constructor(t,e){this.x=t,this.y=e}get z(){return 0}get xy(){return{x:this.x,y:this.y}}at(t){if(0===t)return this.x;if(1===t)return this.y;if(2===t)return 0;throw new Error(`${t} out of bounds!`)}length(){return this.magnitude()}magnitude(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitudeSquared(){return this.x*this.x+this.y*this.y}squareDistanceTo(t){const e=this.x-t.x,o=this.y-t.y;return e*e+o*o+t.z*t.z}distanceTo(t){return Math.sqrt(this.squareDistanceTo(t))}maximumEntryMagnitude(){return Math.max(Math.abs(this.x),Math.abs(this.y))}angle(){return Math.atan2(this.y,this.x)}normalized(){const t=this.magnitude();return i.of(this.x/t,this.y/t)}normalizedOrZero(){return this.eq(r.zero)?r.zero:this.normalized()}times(t){return i.of(this.x*t,this.y*t)}plus(t){return r.of(this.x+t.x,this.y+t.y,t.z)}minus(t){return r.of(this.x-t.x,this.y-t.y,-t.z)}dot(t){return this.x*t.x+this.y*t.y}cross(t){return r.of(this.y*t.z,-this.x*t.z,this.x*t.y-t.x*this.y)}scale(t){return"number"==typeof t?this.times(t):i.of(this.x*t.x,this.y*t.y)}orthog(){return 0===this.dot(r.unitX)&&0===this.dot(r.unitY)?0===this.dot(r.unitX)?r.unitX:this.cross(r.unitX).normalized():this.cross(r.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 r.of(e(t.x,this.x),e(t.y,this.y),e(t.z,0))}map(t){return r.of(t(this.x,0),t(this.y,1),t(0,2))}asArray(){return[this.x,this.y,0]}eq(t,e=1e-10){return Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e&&Math.abs(t.z)<=e}toString(){return`Vec(${this.x}, ${this.y})`}}var i,r;!function(t){t.of=(t,e)=>new n(t,e),t.ofXY=({x:e,y:o})=>t.of(e,o),t.unitX=t.of(1,0),t.unitY=t.of(0,1),t.zero=t.of(0,0)}(i||(e.Vec2=i={})),function(t){t.of=(t,e,n)=>0===n?i.of(t,e):new o(t,e,n),t.unitX=i.unitX,t.unitY=i.unitY,t.zero=i.zero,t.unitZ=t.of(0,0,1)}(r||(e.Vec3=r={})),e.default=r},5379:function(t,e,o){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,o,n){void 0===n&&(n=o);var i=Object.getOwnPropertyDescriptor(e,o);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,n,i)}:function(t,e,o,n){void 0===n&&(n=o),t[n]=e[o]}),i=this&&this.__exportStar||function(t,e){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(e,o)||n(e,t,o)};Object.defineProperty(e,"__esModule",{value:!0}),e.Color4=e.Vec3=e.Vec2=e.Mat33=e.Abstract2DShape=e.QuadraticBezier=e.Parameterized2DShape=e.Rect2=e.PathCommandType=e.comparePathIndices=e.stepPathIndexBy=e.Path=e.LineSegment2=void 0;var r=o(3328);Object.defineProperty(e,"LineSegment2",{enumerable:!0,get:function(){return r.LineSegment2}});var s=o(5780);Object.defineProperty(e,"Path",{enumerable:!0,get:function(){return s.Path}}),Object.defineProperty(e,"stepPathIndexBy",{enumerable:!0,get:function(){return s.stepCurveIndexBy}}),Object.defineProperty(e,"comparePathIndices",{enumerable:!0,get:function(){return s.compareCurveIndices}}),Object.defineProperty(e,"PathCommandType",{enumerable:!0,get:function(){return s.PathCommandType}});var a=o(683);Object.defineProperty(e,"Rect2",{enumerable:!0,get:function(){return a.Rect2}});var l=o(6831);Object.defineProperty(e,"Parameterized2DShape",{enumerable:!0,get:function(){return l.Parameterized2DShape}});var c=o(9682);Object.defineProperty(e,"QuadraticBezier",{enumerable:!0,get:function(){return c.QuadraticBezier}});var d=o(5150);Object.defineProperty(e,"Abstract2DShape",{enumerable:!0,get:function(){return d.Abstract2DShape}});var h=o(3128);Object.defineProperty(e,"Mat33",{enumerable:!0,get:function(){return h.Mat33}});var u=o(6742);Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return u.Vec2}});var p=o(4981);Object.defineProperty(e,"Vec3",{enumerable:!0,get:function(){return p.Vec3}});var f=o(5035);Object.defineProperty(e,"Color4",{enumerable:!0,get:function(){return f.Color4}}),i(o(3606),e)},2364:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e,o)=>{if(0===t){let t;return t=0===e?0===o?0:NaN:-o/e,[t,t]}const n=e*e-4*t*o;if(n<0)return[NaN,NaN];const i=Math.sqrt(n),r=(-e+i)/(2*t),s=(-e-i)/(2*t);return r>s?[r,s]:[s,r]}},3760:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),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 o=t.charAt(0);return"0"!==o&&"-"!==o||(t=(t=(t=t.replace(/^(0+)[.]/,".")).replace(/^-(0+)[.]/,"-.")).replace(/^(-?)0+$/,"$10")),"-0"===t?"0":t},e.default=e.cleanUpNumber},1780:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.numberRegex=void 0,e.numberRegex=/^([-]?)(\d*)[.](\d+)$/},8435:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getLenAfterDecimal=void 0;const n=o(1780);e.getLenAfterDecimal=t=>{const e=n.numberRegex.exec(t);if(!e)return-1!==t.search(/[eE]/)||/^[a-zA-Z]+$/.exec(t)?-1:0;return e[3].length},e.default=e.getLenAfterDecimal},3606:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toRoundedString=void 0;var n=o(858);Object.defineProperty(e,"toRoundedString",{enumerable:!0,get:function(){return n.toRoundedString}})},858:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.toRoundedString=void 0;const i=n(o(3760));e.toRoundedString=t=>{let e=t.toString(10);if(-1===e.indexOf("."))return e;const o=/^([-]?)(\d*)\.(\d{3,}9{4,})\d{1,4}$/.exec(e);if(o){const t=o[1],n=o[3],i=parseInt(n.charAt(n.length-1),10),r=parseInt(n,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;e=`${t+(s+c).toString()}.${l}`}return e=e.replace(/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,"$1"),(0,i.default)(e)},e.default=e.toRoundedString},2568:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.toStringOfSamePrecision=void 0;const i=n(o(3760)),r=o(1780),s=n(o(8435)),a=n(o(858));e.toStringOfSamePrecision=(t,...e)=>{const o=t.toString(10),n=r.numberRegex.exec(o);if(!n)return o;let l=-1;for(const t of e)l=Math.max((0,s.default)(t),l);if(-1===l)return(0,a.default)(t);let c=n[3].substring(0,l),d=n[2];const h=n[3].charAt(l);if(""!==h){if(parseInt(h,10)>=5){if(c.length>0){const t=/^(0+)(\d*)$/.exec(c);let e="",o=c;t&&(e=t[1],o=t[2]),c=(parseInt(c)+1).toString(),c.length>o.length&&e.length>0&&(e=e.substring(1)),c=e+c}(0===c.length||c.length>l)&&(d=(parseInt(d)+1).toString(),c=c.substring(1))}}const u=n[1];return(0,i.default)(`${u}${d}.${c}`)},e.default=e.toStringOfSamePrecision},5150:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Abstract2DShape=void 0;class o{distance(t){return Math.abs(this.signedDistance(t))}containsPoint(t,e=o.smallValue){return this.signedDistance(t)<e}getLooseBoundingBox(){return this.getTightBoundingBox()}}e.Abstract2DShape=o,o.smallValue=1e-12,e.default=o},3212:function(t,e,o){"use strict";var n,i=this&&this.__classPrivateFieldSet||function(t,e,o,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(t,o):i?i.value=o:e.set(t,o),o},r=this&&this.__classPrivateFieldGet||function(t,e,o,n){if("a"===o&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?n:"a"===o?n.call(t):n?n.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.BezierJSWrapper=void 0;const a=o(5893),l=o(6742),c=s(o(3328)),d=s(o(683)),h=s(o(6831));class u extends h.default{constructor(t){super(),n.set(this,null),t&&i(this,n,t,"f")}getBezier(){return r(this,n,"f")||i(this,n,new a.Bezier(this.getPoints().map((t=>t.xy))),"f"),r(this,n,"f")}signedDistance(t){return this.nearestPointTo(t).point.distanceTo(t)}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))}secondDerivativeAt(t){return l.Vec2.ofXY(this.getBezier().dderivative(t))}normal(t){return l.Vec2.ofXY(this.getBezier().normal(t))}normalAt(t){return this.normal(t)}tangentAt(t){return this.derivativeAt(t).normalized()}getTightBoundingBox(){const t=this.getBezier().bbox(),e=t.x.max-t.x.min,o=t.y.max-t.y.min;return new d.default(t.x.min,t.y.min,e,o)}argIntersectsLineSegment(t){const e=c.default.ofSmallestContainingPoints(this.getPoints());if(e){return e.intersectsLineSegment(t).map((t=>this.nearestPointTo(t).parameterValue))}return this.getBezier().intersects(t).map((e=>{"string"==typeof e&&(e=parseFloat(e));const o=l.Vec2.ofXY(this.at(e));return o.distanceTo(t.p1)>t.length||o.distanceTo(t.p2)>t.length?null:e})).filter((t=>null!==t))}splitAt(t){if(t<=0||t>=1)return[this];const e=this.getBezier().split(t);return[new p(e.left.points.map((t=>l.Vec2.ofXY(t))),e.left),new p(e.right.points.map((t=>l.Vec2.ofXY(t))),e.right)]}nearestPointTo(t){const e=e=>t.squareDistanceTo(this.at(e)),o=e(0);let n=0,i=o;for(let t=0;t<4;t++){const o=t/3,r=e(o);r<i&&(n=o,i=r)}const r=e=>{const o=this.at(e),n=this.derivativeAt(e),i=this.secondDerivativeAt(e);return 2*n.x*n.x+2*o.x*i.x-2*t.x*i.x+2*n.y*n.y+2*o.y*i.y-2*t.y*i.y},s=e=>{const o=this.at(e),n=this.derivativeAt(e);return 2*o.x*n.x-2*t.x*n.x+2*o.y*n.y-2*t.y*n.y},a=()=>{const t=r(n);if(0===t)return;const e=(0-s(n))/t+n;n=e,n>1?n=1:n<0&&(n=0)};for(let t=0;t<12;t++)a();return{parameterValue:n,point:this.at(n)}}intersectsBezier(t){const e=this.getBezier().intersects(t.getBezier());if(!e||0===e.length)return[];const o=[];for(const t of e){const n=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(t);if(!n)throw new Error(`Incorrect format returned by .intersects: ${e} should be array of "number/number"!`);const i=parseFloat(n[1]);o.push({parameterValue:i,point:this.at(i)})}return o}toString(){return`Bézier(${this.getPoints().map((t=>t.toString())).join(", ")})`}}e.BezierJSWrapper=u,n=new WeakMap;class p extends u{constructor(t,e){super(e),this.controlPoints=t}getPoints(){return this.controlPoints}}e.default=u},1834:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(o(3212)),r=n(o(683));class s extends i.default{constructor(t,e,o,n){super(),this.p0=t,this.p1=e,this.p2=o,this.p3=n}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},3328:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.LineSegment2=void 0;const i=n(o(683)),r=o(6742),s=n(o(6831));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))}static ofSmallestContainingPoints(t){if(t.length<=1)return null;const e=[...t].sort(((t,e)=>t.x!==e.x?t.x-e.x:t.y-e.y)),o=new a(e[0],e[e.length-1]);for(const t of e)if(!o.containsPoint(t))return null;return o}get p1(){return this.point1}get p2(){return this.point2}get center(){return this.point1.lerp(this.point2,.5)}get(t){return this.point1.plus(this.direction.times(t))}at(t){return this.get(t*this.length)}normalAt(t){return this.direction.orthog()}tangentAt(t){return this.direction}splitAt(t){return t<=0||t>=1?[this]:[new a(this.point1,this.at(t)),new a(this.at(t),this.point2)]}intersection(t){let e,o;if(Math.abs(this.direction.x)<4e-13){if(0===t.direction.x||0===this.direction.y)return null;const n=this.point1.x,i=(this.point1.x-t.point1.x)*t.direction.y/t.direction.x+t.point1.y;e=r.Vec2.of(n,i),o=(i-this.point1.y)/this.direction.y}else{const n=(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=n/i,a=(s-this.point1.x)/this.direction.x,l=this.point1.y+this.direction.y*a;e=r.Vec2.of(s,l),o=(s-this.point1.x)/this.direction.x}const n=e.distanceTo(this.point1),i=e.distanceTo(this.point2),s=e.distanceTo(t.point1),a=e.distanceTo(t.point2);return n>this.length||i>this.length||s>t.length||a>t.length?null:{point:e,t:o}}intersects(t){return null!==this.intersection(t)}argIntersectsLineSegment(t){const e=this.intersection(t);return e?[e.t/this.length]:[]}intersectsLineSegment(t){const e=this.intersection(t);return e?[e.point]:[]}closestPointTo(t){return this.nearestPointTo(t).point}nearestPointTo(t){const e=t.minus(this.p1).dot(this.direction),o=this.length-e,n=this.p1.plus(this.direction.times(e));return e>0&&e<this.length?{point:n,parameterValue:e/this.length}:Math.abs(o)<Math.abs(e)?{point:this.p2,parameterValue:1}:{point:this.p1,parameterValue:0}}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()})`}eq(t,e){if(!(t instanceof a))return!1;const o=e?.tolerance,n=e?.ignoreDirection??!0;return t.p1.eq(this.p1,o)&&t.p2.eq(this.p2,o)||n&&t.p1.eq(this.p2,o)&&t.p2.eq(this.p1,o)}}e.LineSegment2=a,e.default=a},6831:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Parameterized2DShape=void 0;const i=n(o(5150));class r extends i.default{intersectsLineSegment(t){return this.argIntersectsLineSegment(t).map((t=>this.at(t)))}}e.Parameterized2DShape=r,e.default=r},5780:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Path=e.stepCurveIndexBy=e.compareCurveIndices=e.PathCommandType=void 0;const i=n(o(3328)),r=n(o(683)),s=o(6742),a=n(o(1834)),l=n(o(9682)),c=n(o(4502)),d=n(o(858)),h=n(o(2568)),u=n(o(1477));var p;!function(t){t[t.LineTo=0]="LineTo",t[t.MoveTo=1]="MoveTo",t[t.CubicBezierTo=2]="CubicBezierTo",t[t.QuadraticBezierTo=3]="QuadraticBezierTo"}(p||(e.PathCommandType=p={}));e.compareCurveIndices=(t,e)=>{const o=t.curveIndex-e.curveIndex;return 0===o?t.parameterValue-e.parameterValue:o};e.stepCurveIndexBy=(t,e)=>t.parameterValue+e>1?{curveIndex:t.curveIndex+1,parameterValue:t.parameterValue+e-1}:t.parameterValue+e<0?0===t.curveIndex?{curveIndex:0,parameterValue:0}:{curveIndex:t.curveIndex-1,parameterValue:t.parameterValue+e+1}:{curveIndex:t.curveIndex,parameterValue:t.parameterValue+e};class f{constructor(t,e){this.startPoint=t,this.cachedGeometry=null,this.cachedPolylineApproximation=null,this.cachedStringVersion=null,this.parts=e,this.bbox=r.default.bboxOf([t]);for(const e of this.parts)this.bbox=this.bbox.union(f.computeBBoxForSegment(t,e))}getExactBBox(){const t=[];for(const e of this.geometry)t.push(e.getTightBoundingBox());return r.default.union(...t)}get geometry(){if(this.cachedGeometry)return this.cachedGeometry;let t=this.startPoint;const e=[];for(const o of this.parts){let n;switch(o.kind){case p.CubicBezierTo:e.push(new a.default(t,o.controlPoint1,o.controlPoint2,o.endPoint)),t=o.endPoint;break;case p.QuadraticBezierTo:e.push(new l.default(t,o.controlPoint,o.endPoint)),t=o.endPoint;break;case p.LineTo:e.push(new i.default(t,o.point)),t=o.point;break;case p.MoveTo:e.push(new c.default(o.point)),t=o.point;break;default:return n=o,n}}return this.cachedGeometry=e,this.cachedGeometry}*startEndPoints(){yield this.startPoint;for(const t of this.parts){let e;switch(t.kind){case p.CubicBezierTo:case p.QuadraticBezierTo:yield t.endPoint;break;case p.LineTo:case p.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 p.CubicBezierTo:t.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case p.QuadraticBezierTo:t.push(e.controlPoint,e.endPoint);break;case p.MoveTo:case p.LineTo:t.push(e.point)}const e=[];let o=this.startPoint;for(const n of t)e.push(new i.default(o,n)),o=n;return e}static computeBBoxForSegment(t,e){const o=[t];let n;switch(e.kind){case p.MoveTo:case p.LineTo:o.push(e.point);break;case p.CubicBezierTo:o.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case p.QuadraticBezierTo:o.push(e.controlPoint,e.endPoint);break;default:return n=e,n}return r.default.bboxOf(o)}signedDistance(t,e){let o=1/0;for(const n of this.geometry){const i=n.signedDistance(t)-e;i<o&&(o=i)}return o}raymarchIntersectionWith(t,e,o=[]){if(!t.bbox.intersects(this.bbox.grownBy(e)))return[];const n=t.length,i=[];for(const o of this.geometry){const r=o.getTightBoundingBox().grownBy(e);if(!r.intersects(t.bbox))continue;const s=t=>o.signedDistance(t),a=t=>s(t)-e;a(t.p1)>n&&a(t.p2)>n||i.push({part:o,distFn:s,bbox:r})}if(0===i.length)return[];const r=t=>{let o=1/0,n=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<=o&&(o=l,n=i)}for(const{part:e,distFn:i,bbox:s}of r){if(isFinite(o)&&!s.grownBy(o).containsPoint(t))continue;const r=i(t);r<=o&&(o=r,n=e)}return[n,o-e]},s=[t.p1,...o,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=(o,i,s)=>{let d=o,[h,u]=r(d),p=a(d);if(u>n)return p;const f=t.direction.times(i);for(let t=0;t<8;t++){const t=u;if(d=d.plus(f.times(t)),p=a(d),p<=s)return p;const[e,o]=r(d);if(Math.abs(o)>Math.abs(u))return null;if(u=o,h=e,Math.abs(u)<c)break}if(h&&(p>=0&&p<=n)&&Math.abs(u)<c){l.push({point:d,parameterValue:h.nearestPointTo(d).parameterValue,curve:h,curveIndex:this.geometry.indexOf(h)});const o=e/20/t.length;p+=isFinite(o)?o:0}return p};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 o=[];if(!t.bbox.intersects(this.bbox.grownBy(e??0)))return[];if(0===this.parts.length)return new f(this.startPoint,[{kind:p.MoveTo,point:this.startPoint}]).intersection(t,e);let n=0;for(const e of this.geometry){const i=e.argIntersectsLineSegment(t);for(const t of i)o.push({curve:e,curveIndex:n,point:e.at(t),parameterValue:t});n++}if(e&&e>1e-8){const n=o.map((t=>t.point));o=this.raymarchIntersectionWith(t,e,n)}return o}nearestPointTo(t){let e=1/0,o=0,n=0,i=this.startPoint;for(let r=0;r<this.geometry.length;r++){const s=this.geometry[r].nearestPointTo(t),a=s.point.squareDistanceTo(t);(0===r||a<e)&&(o=r,e=a,n=s.parameterValue,i=s.point)}return{curve:this.geometry[o],curveIndex:o,parameterValue:n,point:i}}at(t){return 0===t.curveIndex&&0===t.parameterValue?this.startPoint:this.geometry[t.curveIndex].at(t.parameterValue)}tangentAt(t){return this.geometry[t.curveIndex].tangentAt(t.parameterValue)}splitNear(t,e){const o=this.nearestPointTo(t);return this.splitAt(o,e)}spliced(t,e,o,n){if(r=e,(i=t).curveIndex<r.curveIndex||i.curveIndex===r.curveIndex&&i.parameterValue<=r.parameterValue){const i=this.splitAt(t,n),r=this.splitAt(e,n),s=i[0],a=r[r.length-1];return o?s.union(o).union(a):s.union(a)}{const i=this.splitAt([t],n)[0].splitNear(this.at(e),n),r=i[i.length-1];return o?r.union(o):r}var i,r}splitAt(t,o){for(Array.isArray(t)||(t=[t]),(t=[...t]).sort(e.compareCurveIndices);t.length>0&&t[t.length-1].curveIndex>=this.parts.length-1&&t[t.length-1].parameterValue>=1;)t.pop();for(t.reverse();t.length>0&&t[t.length-1].curveIndex<=0&&t[t.length-1].parameterValue<=0;)t.pop();if(0===t.length||0===this.parts.length)return[this];const n=t.length+1,i=o?.mapNewPoint??(t=>t),r=[];let s=this.startPoint,a=[],{curveIndex:l,parameterValue:c}=t.pop();for(let e=0;e<this.parts.length;e++)if(e!==l)a.push(this.parts[e]);else{let o=this.parts[e],n=this.geometry[e];for(;e===l;){let d;const h=[];switch(o.kind){case p.MoveTo:a.push({kind:o.kind,point:o.point}),d=o.point;break;case p.LineTo:{const t=n.splitAt(c);a.push({kind:o.kind,point:i(t[0].p2)}),d=t[0].p2,t.length>1&&(console.assert(2===t.length),h.push({kind:o.kind,point:t[1].p2}),n=t[1])}break;case p.QuadraticBezierTo:case p.CubicBezierTo:{const t=n.splitAt(c);let e=2===t.length;for(const r of t){n=r;const t=e?a:h,s=r.getPoints();o.kind===p.CubicBezierTo?t.push({kind:o.kind,controlPoint1:i(s[1]),controlPoint2:i(s[2]),endPoint:i(s[3])}):t.push({kind:o.kind,controlPoint:i(s[1]),endPoint:i(s[2])}),e||(d=s[0]),e=!1}}break;default:return o}r.push(new f(s,[...a])),s=i(d),console.assert(!!s,"should have a start point"),a=h,o=h[h.length-1]??o;const u=t.pop();if(!u)break;if(l=u.curveIndex,e===l){const t=this.at(u);c=n.nearestPointTo(t).parameterValue,a=[]}else c=u.parameterValue}}return r.push(new f(s,a)),console.assert(r.length===n,`should split into splitAt.length + 1 splits (was ${r.length}, expected ${n})`),r}asClosed(){const t=[];let e=!1;for(const o of this.parts)o.kind===p.MoveTo?(t.push({kind:p.LineTo,point:o.point}),e=!0):t.push(o);if(this.getEndPoint().eq(this.startPoint)||(t.push({kind:p.LineTo,point:this.startPoint}),e=!0),!e)return this;const o=new f(this.startPoint,t);return console.assert(o.getEndPoint().eq(o.startPoint)),o}static mapPathCommand(t,e){switch(t.kind){case p.MoveTo:case p.LineTo:return{kind:t.kind,point:e(t.point)};case p.CubicBezierTo:return{kind:t.kind,controlPoint1:e(t.controlPoint1),controlPoint2:e(t.controlPoint2),endPoint:e(t.endPoint)};case p.QuadraticBezierTo:return{kind:t.kind,controlPoint:e(t.controlPoint),endPoint:e(t.endPoint)}}return t}mapPoints(t){const e=t(this.startPoint),o=[];for(const e of this.parts)o.push(f.mapPathCommand(e,t));return new f(e,o)}transformedBy(t){return t.isIdentity()?this:this.mapPoints((e=>t.transformVec2(e)))}closedContainsPoint(t){const e=this.getExactBBox();if(!e.containsPoint(t))return!1;const o=t.plus(s.Vec2.of(e.width,0)),n=this.asClosed(),r=new i.default(t,o);return n.intersection(r).length%2==1}union(t,e={allowReverse:!0}){if(!t)return this;if(Array.isArray(t))return new f(this.startPoint,[...this.parts,...t]);let o=[];if(this.getEndPoint().eq(t.startPoint))o=this.parts.concat(t.parts);else{if(e.allowReverse&&this.startPoint.eq(t.getEndPoint()))return t.union(this,{allowReverse:!1});if(e.allowReverse&&this.startPoint.eq(t.startPoint))return this.union(t.reversed(),{allowReverse:!1});o=[...this.parts,{kind:p.MoveTo,point:t.startPoint},...t.parts]}return new f(this.startPoint,o)}reversed(){const t=this.getEndPoint(),e=[];let o=this.startPoint;for(const t of this.parts)switch(t.kind){case p.LineTo:case p.MoveTo:e.push({kind:t.kind,point:o}),o=t.point;break;case p.CubicBezierTo:e.push({kind:t.kind,controlPoint1:t.controlPoint2,controlPoint2:t.controlPoint1,endPoint:o}),o=t.endPoint;break;case p.QuadraticBezierTo:e.push({kind:t.kind,controlPoint:t.controlPoint,endPoint:o}),o=t.endPoint;break;default:return t}return e.reverse(),new f(t,e)}getEndPoint(){if(0===this.parts.length)return this.startPoint;const t=this.parts[this.parts.length-1];return t.kind===p.QuadraticBezierTo||t.kind===p.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 o=this.startPoint;for(const n of this.parts){const i=f.computeBBoxForSegment(o,n).grownBy(e);if(o=n.kind===p.LineTo||n.kind===p.MoveTo?n.point:n.endPoint,t.intersects(i))return!0}return!1}closedRoughlyIntersects(t){if(t.containsRect(this.bbox))return!0;const e=this.bbox.topLeft.minus(s.Vec2.of(1,1)),o=t.corners,n=this.polylineApproximation();for(const t of o){const o=new i.default(t,e);let r=0;for(const t of n)t.intersects(o)&&r++;if(r%2==1)return!0}const r=t.grownBy(Math.min(t.size.x,t.size.y)),a=[];for(const t of r.divideIntoGrid(4,4))a.push(...t.getEdges());for(const t of a)for(const e of n)if(t.intersects(e))return!0;return!1}eq(t,e){if(t.parts.length!==this.parts.length)return!1;for(let o=0;o<this.parts.length;o++){const n=this.parts[o],i=t.parts[o];switch(n.kind){case p.LineTo:case p.MoveTo:if(n.kind!==i.kind)return!1;if(!n.point.eq(i.point,e))return!1;break;case p.CubicBezierTo:if(n.kind!==i.kind)return!1;if(!n.controlPoint1.eq(i.controlPoint1,e)||!n.controlPoint2.eq(i.controlPoint2,e)||!n.endPoint.eq(i.endPoint,e))return!1;break;case p.QuadraticBezierTo:if(n.kind!==i.kind)return!1;if(!n.controlPoint.eq(i.controlPoint,e)||!n.endPoint.eq(i.endPoint,e))return!1;break;default:return n}}return!0}static fromRect(t,e=null){const o=[];let n,i;if(null!==e){const o=s.Vec2.of(e,e).times(.5),a=r.default.fromCorners(t.topLeft.plus(o),t.bottomRight.minus(o)),l=r.default.fromCorners(t.topLeft.minus(o),t.bottomRight.plus(o));n=[a.corners[3],...a.corners,...l.corners.reverse()],i=l.corners[3]}else n=t.corners.slice(1),i=t.corners[0];for(const t of n)o.push({kind:p.LineTo,point:t});return o.push({kind:p.LineTo,point:i}),new f(i,o)}toString(t,e=!1){if(this.cachedStringVersion&&!e)return this.cachedStringVersion;void 0===t&&(t=Math.abs(this.bbox.topLeft.x)>10&&Math.abs(this.bbox.topLeft.y)>10);const o=f.toString(this.startPoint,this.parts,!t);return this.cachedStringVersion=o,o}serialize(){return this.toString()}static toString(t,e,o){const n=[];let i;const r=(t,...e)=>{const r=[],s=[],a=!i||o,l=i?(0,d.default)(i.x):"",c=i?(0,d.default)(i.y):"";for(const t of e){const e=(0,d.default)(t.x),o=(0,d.default)(t.y);if(a)r.push(`${e},${o}`);else{const n=(0,h.default)(t.x-i.x,e,l,c),r=(0,h.default)(t.y-i.y,o,l,c);"-"===r.charAt(0)?s.push(`${n}${r}`):s.push(`${n},${r}`)}}let u;u=a?`${t}${r.join(" ")}`:`${t.toLowerCase()}${s.join(" ")}`,"l0,0"!==u&&"m0,0"!==u&&(n.push(u),e.length>0&&(i=e[e.length-1]))};let s;e[0]?.kind!==p.MoveTo&&r("M",t);for(let t=0;t<e.length;t++){const o=e[t];switch(o.kind){case p.MoveTo:r("M",o.point);break;case p.LineTo:r("L",o.point);break;case p.CubicBezierTo:r("C",o.controlPoint1,o.controlPoint2,o.endPoint);break;case p.QuadraticBezierTo:r("Q",o.controlPoint,o.endPoint);break;default:return s=o,s}}return n.join("")}static fromString(t){t=t.split("\n").join(" ");let e=s.Vec2.zero,o=null,n=null,i=!0;const r=[],a=t=>{i?i=!1:r.push({kind:p.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 o=(e=e.replace(/([^eE])[-]/g,"$1 -")).split(" -");return""!==o[0]&&t.push(o[0]),t.push(...o.slice(1).map((t=>`-${t}`))),t}),[]);let c=t.map((t=>parseFloat(t))),f=d[1].toLowerCase(),v=d[1]!==f;if("v"===f||"h"===f)c=c.reduce(((t,o)=>"v"===f?t.concat(v?e.x:0,o):t.concat(o,v?e.y:0)),[]),f="l";else if("z"===f){if(!o)continue;c=[o.x,o.y],o=e,v=!0,f="l"}const x=l[f]??0,w=c.reduce(((t,e,o,n)=>{if(o%2!=0){const i=e,r=n[o-1];return t.concat(s.Vec2.of(r,i))}return t}),[]).map(((t,o)=>{let n;return n=v?t:e.plus(t),(o+1)%x==0&&(e=n),n}));if(w.length%x!=0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(w)} with a length of ${w.length} ≠ ${x}k, k ∈ ℤ.`,`The number of arguments to ${f} must be a multiple of ${x}!`,`Command: ${d[0]}`].join("\n"));for(let t=0;t<w.length;t+=x){const e=w.slice(t,t+x);switch(f.toLowerCase()){case"m":0===t?(y=e[0],i?i=!1:r.push({kind:p.MoveTo,point:y})):a(e[0]);break;case"l":a(e[0]);break;case"c":m=e[0],g=e[1],b=e[2],r.push({kind:p.CubicBezierTo,controlPoint1:m,controlPoint2:g,endPoint:b});break;case"q":h=e[0],u=e[1],r.push({kind:p.QuadraticBezierTo,controlPoint:h,endPoint:u});break;default:throw new Error(`Unknown path command ${f}`)}i=!1}w.length>0&&(o??=w[0],n??=o,e=w[w.length-1])}var h,u,m,g,b,y;const v=new f(n??s.Vec2.zero,r);return v.cachedStringVersion=t,v}static fromConvexHullOf(t){if(0===t.length)return f.empty;const e=(0,u.default)(t),o=e.slice(1).map((t=>({kind:p.LineTo,point:t})));return o.push({kind:p.LineTo,point:e[0]}),new f(e[0],o)}}e.Path=f,f.empty=new f(s.Vec2.zero,[]),e.default=f},4502:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(6742),r=n(o(6831)),s=n(o(683));class a extends r.default{constructor(t){super(),this.p=t}signedDistance(t){return this.p.distanceTo(t)}argIntersectsLineSegment(t,e){return t.containsPoint(this.p,e)?[0]:[]}getTightBoundingBox(){return new s.default(this.p.x,this.p.y,0,0)}at(t){return this.p}normalAt(t){return i.Vec2.unitY}tangentAt(t){return i.Vec2.unitX}splitAt(t){return[this]}nearestPointTo(t){return{point:this.p,parameterValue:0}}}e.default=a},9682:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.QuadraticBezier=void 0;const i=o(6742),r=n(o(2364)),s=n(o(3212)),a=n(o(683));class l extends s.default{constructor(t,e,o){super(),this.p0=t,this.p1=e,this.p2=o}static componentAt(t,e,o,n){return e+t*(-2*e+2*o)+t*t*(e-2*o+n)}static derivativeComponentAt(t,e,o,n){return-2*e+2*o+2*t*(e-2*o+n)}static secondDerivativeComponentAt(t,e,o,n){return 2*(e-2*o+n)}at(t){if(0===t)return this.p0;if(1===t)return this.p2;const e=this.p0,o=this.p1,n=this.p2;return i.Vec2.of(l.componentAt(t,e.x,o.x,n.x),l.componentAt(t,e.y,o.y,n.y))}derivativeAt(t){const e=this.p0,o=this.p1,n=this.p2;return i.Vec2.of(l.derivativeComponentAt(t,e.x,o.x,n.x),l.derivativeComponentAt(t,e.y,o.y,n.y))}secondDerivativeAt(t){const e=this.p0,o=this.p1,n=this.p2;return i.Vec2.of(l.secondDerivativeComponentAt(t,e.x,o.x,n.x),l.secondDerivativeComponentAt(t,e.y,o.y,n.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,o=-2*this.p0.x+2*this.p1.x,n=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*o+2*i*s-t.x*o-t.y*s,c=2*o*o+2*s*s+2*n*e+2*a*i-t.x*n-t.y*a,d=2*(2*s*a+2*o*n+2*n*o+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.squareDistanceTo(t),g=f.squareDistanceTo(t),b=this.at(0).squareDistanceTo(t),y=this.at(1).squareDistanceTo(t);return Math.sqrt(Math.min(m,g,b,y))}getPoints(){return[this.p0,this.p1,this.p2]}}e.QuadraticBezier=l,e.default=l},683:function(t,e,o){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Rect2=void 0;const i=n(o(3328)),r=n(o(3128)),s=o(6742),a=n(o(5150));class l extends a.default{constructor(t,e,o,n){super(),this.x=t,this.y=e,this.w=o,this.h=n,o<0&&(this.x+=o,this.w=Math.abs(o)),n<0&&(this.y+=n,this.h=Math.abs(n)),this.topLeft=s.Vec2.of(this.x,this.y),this.size=s.Vec2.of(this.w,this.h),this.area=this.w*this.h}translatedBy(t){return new l(t.x+this.x,t.y+this.y,this.w,this.h)}resizedTo(t){return new l(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,o=e+this.w,n=t.x,i=t.x+t.w;if(o<n||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),o=this.bottomRight.zip(t.bottomRight,Math.min);return l.fromCorners(e,o)}union(t){return l.union(this,t)}divideIntoGrid(t,e){const o=[];if(t<=0||e<=0)return o;const n=this.w/t,i=this.h/e;0===n&&(t=1),0===i&&(e=1);for(let r=0;r<e;r++)for(let e=0;e<t;e++){const t=n*e+this.x,s=i*r+this.y;o.push(new l(t,s,n,i))}return o}grownToPoint(t,e=0){const o=new l(t.x-e,t.y-e,2*e,2*e);return this.union(o)}grownBy(t){if(0===t)return this;if(t<0){const e=-Math.min(-t,this.w/2),o=-Math.min(-t,this.h/2);return new l(this.x-e,this.y-o,this.w+2*e,this.h+2*o)}return new l(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 o=null,n=null;for(const i of e){const e=i.distanceTo(t);(null===n||e<n)&&(o=i,n=e)}return o}isWithinRadiusOf(t,e){if(this.maxDimension>t)return!1;const o=t*t;return this.corners.every((t=>t.minus(e).magnitudeSquared()<o))}get corners(){return[this.bottomRight,this.topRight,this.topLeft,this.bottomLeft]}get maxDimension(){return Math.max(this.w,this.h)}get minDimension(){return Math.min(this.w,this.h)}get bottomRight(){return this.topLeft.plus(this.size)}get topRight(){return this.bottomRight.plus(s.Vec2.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(s.Vec2.of(0,this.h))}get width(){return this.w}get height(){return this.h}get center(){return s.Vec2.of(this.x+this.w/2,this.y+this.h/2)}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 o of this.getEdges()){o.intersectsLineSegment(t).forEach((t=>e.push(t)))}return e}signedDistance(t){const e=this.getClosestPointOnBoundaryTo(t),o=t.minus(e).magnitude();return this.containsPoint(t)?-o:o}getTightBoundingBox(){return this}transformedBoundingBox(t){return t===r.default.identity?this:l.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 l(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 o=0,n=0,i=0,r=0,a=!0;for(const e of t)a&&(o=e.x,n=e.y,i=e.x,r=e.y,a=!1),o=Math.min(o,e.x),n=Math.min(n,e.y),i=Math.max(i,e.x),r=Math.max(r,e.y);return l.fromCorners(s.Vec2.of(o-e,n-e),s.Vec2.of(i+e,r+e))}static union(...t){if(0===t.length)return l.empty;const e=t[0];let o=e.x,n=e.y,i=e.x+e.w,r=e.y+e.h;for(let e=1;e<t.length;e++){const s=t[e];o=Math.min(o,s.x),n=Math.min(n,s.y),i=Math.max(i,s.x+s.w),r=Math.max(r,s.y+s.h)}return new l(o,n,i-o,r-n)}static of(t){const e=t.width??t.w??0,o=t.height??t.h??0;return new l(t.x,t.y,e,o)}}e.Rect2=l,l.empty=new l(0,0,0,0),l.unitSquare=new l(0,0,1,1),e.default=l},1477:(t,e,o)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=o(6742);e.default=t=>{if(0===t.length)return[];const e=t.reduce(((t,e)=>e.y<t.y?e:t),t[0]),o=[e];let i=[...t.filter((t=>!t.eq(e)))],r=n.Vec2.of(-1,0);for(;i.length>0;){const t=o[o.length-1];let n=r.dot(e.minus(t).normalizedOrZero()),s=e;for(const e of i){const o=r.dot(e.minus(t).normalizedOrZero());o<=n&&(s=e,n=o)}i=i.filter((t=>!t.eq(s)));const a=s.minus(t).normalized();if(1===Math.abs(a.dot(r))&&o.length>1&&o.pop(),s.eq(e))break;o.push(s),r=t.minus(s).normalized()}return o}},1666:(t,e)=>{var o,n,i;"undefined"!=typeof self&&self,n=[],void 0===(i="function"==typeof(o=function(){
|
2
|
-
/*!
|
1
|
+
"use strict";var jsdraw=(()=>{var yn=Object.defineProperty;var la=Object.getOwnPropertyDescriptor;var ca=Object.getOwnPropertyNames;var da=Object.prototype.hasOwnProperty;var ua=(s,o)=>{for(var e in o)yn(s,e,{get:o[e],enumerable:!0})},pa=(s,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of ca(o))!da.call(s,n)&&n!==e&&yn(s,n,{get:()=>o[n],enumerable:!(r=la(o,n))||r.enumerable});return s};var ha=s=>pa(yn({},"__esModule",{value:!0}),s);var Bl={};ua(Bl,{Abstract2DShape:()=>yo,AbstractComponent:()=>_,AbstractRenderer:()=>ze,AbstractToolbar:()=>it,ActionButtonWidget:()=>Ue,BackgroundComponent:()=>ce,BackgroundComponentBackgroundType:()=>co,BaseTool:()=>K,BaseToolWidget:()=>ye,BaseWidget:()=>ae,CanvasRenderer:()=>Le,Color4:()=>L,Command:()=>Ie,ComponentSizingMode:()=>to,Display:()=>Nt,DocumentPropertiesWidget:()=>Zt,DummyRenderer:()=>ot,Duplicate:()=>zt,Editor:()=>fn,EditorEventType:()=>Y,EditorImage:()=>q,Erase:()=>J,EraserMode:()=>ao,EraserTool:()=>Je,EraserToolWidget:()=>Kt,EventDispatcher:()=>Fe,HTMLToolbar:()=>it,HandToolWidget:()=>_t,IconProvider:()=>$t,ImageComponent:()=>be,InputEvtType:()=>He,InputMapper:()=>Re,InsertImageWidget:()=>qt,KeyBinding:()=>St,KeyboardShortcutManager:()=>H,LineSegment2:()=>ue,Mat33:()=>k,MutableReactiveValue:()=>te,PanZoomMode:()=>Ao,PanZoomTool:()=>Ce,Parameterized2DShape:()=>xo,PasteHandler:()=>At,Path:()=>$,PathCommandType:()=>we,PenTool:()=>Ne,PenToolWidget:()=>Wt,Pointer:()=>ke,PointerDevice:()=>Ge,QuadraticBezier:()=>De,ReactiveValue:()=>j,Rect2:()=>I,RenderingMode:()=>Yr,SVGLoader:()=>et,SVGRenderer:()=>me,SelectAllShortcutHandler:()=>Ot,SelectionMode:()=>Lt,SelectionTool:()=>ve,SelectionToolWidget:()=>Gt,SerializableCommand:()=>W,SoundUITool:()=>Ft,Stroke:()=>ee,StrokeComponent:()=>ee,StrokeSmoother:()=>ls,Text:()=>ne,TextComponent:()=>ne,TextTool:()=>$e,TextToolWidget:()=>jt,ToolController:()=>Ht,ToolEnabledGroup:()=>mt,ToolSwitcherShortcut:()=>Dt,ToolbarShortcutHandler:()=>tt,ToolbarWidgetTag:()=>Ut,UndoEventType:()=>In,UndoRedoHistory:()=>qr,UndoRedoShortcut:()=>Bt,Vec2:()=>w,Vec3:()=>F,Viewport:()=>U,__js_draw__version:()=>bo,adjustEditorThemeForContrast:()=>Ys,comparePathIndices:()=>Eo,createRestyleComponentCommand:()=>pt,default:()=>Il,defaultEditorLocalization:()=>Xe,getLocalizationTable:()=>Sr,invertCommand:()=>_s,isPointerEvt:()=>oo,isRestylableComponent:()=>Vo,keyPressEventFromHTMLEvent:()=>Lo,keyUpEventFromHTMLEvent:()=>zo,makeArrowBuilder:()=>sn,makeColorInput:()=>zs,makeDropdownToolbar:()=>qs,makeEdgeToolbar:()=>Os,makeFilledRectangleBuilder:()=>cn,makeFreehandLineBuilder:()=>Qe,makeLineBuilder:()=>ln,makeOutlinedCircleBuilder:()=>un,makeOutlinedRectangleBuilder:()=>dn,makePolylineBuilder:()=>ft,makePressureSensitiveFreehandLineBuilder:()=>Vt,matchingLocalizationTable:()=>Io,pathFromRenderable:()=>ht,pathToRenderable:()=>Z,pathVisualEquivalent:()=>Dr,sendPenEvent:()=>on,sendTouchEvent:()=>Zs,stepPathIndexBy:()=>vr,toRoundedString:()=>pe,uniteCommands:()=>le});(()=>{if(typeof document<"u"&&typeof document.createElement=="function"){let s=document.createElement("style");s.textContent='\uFEFF: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:100%;max-height:100%;display:block;margin-left:auto;margin-right:auto}:root .insert-image-widget-dropdown-content.insert-image-widget-dropdown-content.insert-image-widget-dropdown-content .insert-image-image-status-view{display:flex;justify-content:space-between;padding-bottom:0}: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}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons{display:flex;justify-content:stretch;padding-top:0;padding-bottom:5px;direction:ltr}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>*{flex-grow:1;text-align:start;margin-inline-end:5px}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>* .icon{margin:0;margin-inline-start:4px;margin-inline-end:10px}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>:nth-child(1){direction:ltr}:root .toolbar--pen-tool-toggle-buttons.toolbar--pen-tool-toggle-buttons>:last-child{direction:rtl}.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 .coloris_input{height:calc(100% - 6px)}.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>.color-input-wrapper{display:flex;justify-content:stretch}.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.-loading{opacity:.8}.toolbar-element .toolbar--file-input-container>input.file-input{opacity:0;width:0;min-width:0 !important;max-width:0;height:0;overflow:hidden;padding:0;margin: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 .cancel-button{padding-left:3px;padding-right:3px}.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;cursor:pointer;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)}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list{height:min(200px,50vh);position:relative;display:flex;align-items:center}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.scroller{display:flex;flex-direction:column;overflow-y:auto;scroll-snap-type:y mandatory;height:100%;width:100%;flex-grow:1}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.scroller>.item{height:100%;width:100%;flex-shrink:0;display:flex;justify-content:center;align-items:center;scroll-snap-align:start;scroll-snap-stop:always;box-sizing:border-box}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.-empty{display:none}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers{overflow:hidden;display:flex;flex-direction:column;align-items:center;max-height:100%;min-height:0}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers.-one-element{visibility:hidden}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers>.marker{padding:2px;opacity:.1;cursor:pointer;left:0;transition:left .2s ease}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers>.marker>.content{background-color:var(--foreground-color-1);border-radius:2px;padding:2px}:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list>.page-markers>.marker.-active{position:relative;left:2px;opacity:.2}.toolbar-button-grid{display:grid;grid-template-columns:repeat(var(--column-count), 1fr);justify-items:center;--button-size: 30px}.toolbar-button-grid>.button{font-size:1em;width:min-content}.toolbar-button-grid>.button>.icon{max-width:var(--button-size);max-height:var(--button-size);width:48px;height:48px}.toolbar-button-grid>.button>label{display:block;font-weight:normal}.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:sepia(0.2);opacity:.45;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;opacity:.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-element .toolbar--toggle-button{color:var(--foreground-color-1);font-weight:normal}.toolbar-element .toolbar--toggle-button[aria-checked=true]{background:var(--selection-background-color);color:var(--selection-foreground-color)}.toolbar-element .toolbar--toggle-button>.icon{width:25px;height:25px;margin:0 5px}.toolbar-element .toolbar--toggle-button>*{vertical-align:middle}.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 rehide-label{0%{opacity:.8}80%{opacity:.8}100%{opacity:.1}}@keyframes show-label-delayed{0%{opacity:0}80%{opacity:0}100%{opacity:.8}}@keyframes show-label-now{0%{opacity:0}5%{opacity:0}100%{opacity:.8}}@keyframes keep-label-hidden{0%{opacity:0}100%{opacity:0}}@keyframes toolbar--edgemenu-transition-in{from{transform:translate(0, 100%)}to{transform:translate(0, 0)}}@keyframes toolbar--edgemenu-transition-in-reduce-motion{from{opacity:0}to{opacity:1}}@keyframes toolbar--edgemenu-transition-out{to{transform:translate(0, 100%)}}@keyframes toolbar--edgemenu-transition-out-reduce-motion{from{opacity:1}to{opacity:0}}@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}}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):hover:not(:focus-visible)>label,.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):active>label{opacity:.8;animation:1s ease show-label-delayed}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button.has-long-press-or-hover>label{opacity:.8}.toolbar-edge-toolbar.one-row>*>.toolbar-toolContainer.label-inline>.toolbar-button:focus-visible>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);z-index:1;pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.3s 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:7px;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:7px;margin-left:0;width:22px}.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)}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):hover:not(:focus-visible)>label,.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):active>label{opacity:.8;animation:1s ease show-label-delayed}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button.has-long-press-or-hover>label{opacity:.8}.toolbar-edge-toolbar .toolbar-toolContainer:not(.no-icon):not(.label-inline) .toolbar-button:focus-visible>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);z-index:1;pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.3s 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 .toolbar-toolContainer:not(.no-icon):not(.label-inline).dropdownVisible>.toolbar-button>label{opacity:.8;animation:1.5s ease rehide-label .3s,1s ease keep-label-hidden 1.8s infinite}.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:.15s ease-in-out background-color,.2s ease-in-out opacity}}.toolbar-edgemenu-container.dropdown-below-edge{overflow-y:hidden}.toolbar-edgemenu-container button{font-size:1.2em;box-shadow:none;border:none;padding:10px;transition:.2s ease box-shadow;font-weight:bold;color:var(--primary-action-foreground-color)}.toolbar-edgemenu-container button:not(:disabled):hover{box-shadow:0 0px 2px var(--shadow-color)}.toolbar-edgemenu-container button:disabled{opacity:.5;font-weight:unset;cursor:unset;color:var(--foreground-color-1)}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button{--button-label-hover-offset-y: var(--button-size)}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):hover:not(:focus-visible)>label>.button-label-text,.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):active>label>.button-label-text{opacity:.8;animation:1s ease show-label-delayed}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button.has-long-press-or-hover>label>.button-label-text{opacity:.8}.toolbar-edgemenu-container .toolbar-grid-selector .choice-button:focus-visible>label>.button-label-text,.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);z-index:1;pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.3s 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-button-grid button{--button-label-hover-offset-y: 0}.toolbar-edgemenu-container .toolbar-button-grid button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):hover:not(:focus-visible)>label,.toolbar-edgemenu-container .toolbar-button-grid button:not(.no-long-press-or-hover):not(.has-long-press-or-hover):active>label{opacity:.8;animation:1s ease show-label-delayed}.toolbar-edgemenu-container .toolbar-button-grid button.has-long-press-or-hover>label{opacity:.8}.toolbar-edgemenu-container .toolbar-button-grid button:focus-visible>label,.toolbar-edgemenu-container .toolbar-button-grid button.focus-visible>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edgemenu-container .toolbar-button-grid button:has(:focus-visible)>label{animation:1.5s ease rehide-label;opacity:0}.toolbar-edgemenu-container .toolbar-button-grid button>label{opacity:0;position:absolute;margin-top:var(--button-label-hover-offset-y);margin-left:var(--button-label-hover-offset-x);z-index:1;pointer-events:none;background-color:var(--background-color-1);color:var(--foreground-color-1);border-radius:25px;padding:10px;transition:.3s ease opacity,.2s ease margin-top}@media(prefers-reduced-motion: reduce){.toolbar-edgemenu-container .toolbar-button-grid button>label{transition:none}}.toolbar-edgemenu-container .toolbar-help-overlay-button{align-items:last baseline}.toolbar-edgemenu-container .toolbar-edgemenu{--toolbar-button-height: 48px;touch-action:none;user-select:none;-webkit-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;-webkit-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:first-child{margin-top:0}.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}.toolbar-help-overlay{width:100%;height:100%;max-width:none;max-height:none;border:none;margin:0;padding:0;z-index:5;touch-action:none;overflow:hidden;color:#fff;--icon-color: white;background-color:rgba(0,0,0,0);display:flex;flex-direction:column;transition:.3s ease transform}.toolbar-help-overlay::backdrop{background-color:rgba(0,0,0,.8);backdrop-filter:blur(1px);-webkit-backdrop-filter:blur(1px)}.toolbar-help-overlay,.toolbar-help-overlay::backdrop{animation:.25s ease transition-in}@keyframes transition-in{0%{opacity:0}100%{opacity:1}}@keyframes transition-out{0%{opacity:1}100%{opacity:0}}.toolbar-help-overlay.-hiding,.toolbar-help-overlay.-hiding::backdrop{animation:.25s ease transition-out;opacity:0}.toolbar-help-overlay.-dragging{transition:none}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay{transition:none}}@media screen and (min-width: 800px){.toolbar-help-overlay>.navigation-buttons{order:1;margin-top:auto}}.toolbar-help-overlay .with-text-shadow,.toolbar-help-overlay .help-page-container>.label,.toolbar-help-overlay button{text-shadow:0 0 3px rgba(20,20,20,.9);filter:drop-shadow(0px 0px 2px rgba(0, 0, 0, 0.5))}.toolbar-help-overlay button:not(:disabled){cursor:pointer}.toolbar-help-overlay button{background:rgba(0,0,0,0);border:none;color:var(--help-overlay-foreground);border-radius:15px}.toolbar-help-overlay .close-button{align-self:flex-start;width:48px;height:48px;z-index:1}.toolbar-help-overlay .close-button>svg{width:100%}.toolbar-help-overlay .navigation-content{flex-grow:1;display:flex}.toolbar-help-overlay .help-page-container{display:flex;align-items:center;flex-grow:1;touch-action:none}.toolbar-help-overlay .help-page-container>.label{flex-grow:1;text-align:center;font-size:18.5pt;margin-left:15px;margin-right:15px;margin-top:0px;z-index:1;transition:.5s ease margin-top}.toolbar-help-overlay .help-page-container>.label.-large-space-below{margin-top:0;margin-bottom:auto}.toolbar-help-overlay .help-page-container>.label.-small-space-above{margin-top:40px;margin-bottom:auto}.toolbar-help-overlay .help-page-container>.label.-large-space-above{margin-top:auto;margin-bottom:10px}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay .help-page-container>.label{transition:none}}.toolbar-help-overlay .help-page-container>.cloned-element-container{position:absolute;z-index:0;user-select:none;-webkit-user-select:none;border-radius:10px;opacity:.01;background-color:rgba(100,100,100,.01);box-shadow:none;transition:.5s ease opacity,.5s ease background-color}.toolbar-help-overlay .help-page-container>.cloned-element-container *{pointer-events:none !important}.toolbar-help-overlay .help-page-container>.cloned-element-container>*{margin:0;opacity:.01 !important;transition:.3s ease opacity !important}.toolbar-help-overlay .help-page-container>.cloned-element-container:not(.-clickable) *{cursor:unset !important}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable,.toolbar-help-overlay .help-page-container>.cloned-element-container.-background{z-index:1;touch-action:none}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable{cursor:pointer;z-index:2}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable.has-long-press-or-hover{opacity:.5 !important}.toolbar-help-overlay .help-page-container>.cloned-element-container.-clickable.has-long-press-or-hover,.toolbar-help-overlay .help-page-container>.cloned-element-container.-active{background-color:var(--background-color-1)}.toolbar-help-overlay .help-page-container>.cloned-element-container.-active{opacity:1;background-color:var(--background-color-1);box-shadow:0 0 3px rgba(100,100,100,.5)}.toolbar-help-overlay .help-page-container>.cloned-element-container.-active>*{opacity:1 !important}.toolbar-help-overlay .navigation-buttons{display:flex;flex-direction:row;justify-content:space-between;direction:ltr}.toolbar-help-overlay .navigation-buttons>button:disabled{opacity:.5}.toolbar-help-overlay .navigation-buttons>.next,.toolbar-help-overlay .navigation-buttons>.previous{font-size:1em;padding:10px;transition:.2s ease font-size;z-index:3}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay .navigation-buttons>.next,.toolbar-help-overlay .navigation-buttons>.previous{transition:none}}.toolbar-help-overlay .navigation-buttons:not(.-has-previous)>.next:not(:disabled){animation:.5s ease highlight-button .5s}@keyframes highlight-button{0%{transform:scale(1)}50%{transform:scale(1.2)}55%{transform:scale(1.2) rotate(2deg)}65%{transform:scale(1.2) rotate(-2deg)}100%{transform:scale(1)}}@media(prefers-reduced-motion: reduce){.toolbar-help-overlay .navigation-buttons:not(.-has-previous)>.next:not(:disabled){animation:none}}.toolbar-help-overlay .navigation-buttons>.next::after{content:"\u276F";margin-left:3px}.toolbar-help-overlay .navigation-buttons>.previous::before{content:"\u276E";margin-right:3px}.toolbar-help-overlay .navigation-buttons.-has-next>.next{font-size:1.4em}.toolbar-help-overlay .navigation-buttons.-has-previous>.previous{font-size:1.4em}.toolbar-help-overlay .navigation-buttons.-highlight-next>.next,.toolbar-help-overlay .navigation-buttons.-highlight-previous>.previous{font-weight:bold;background-color:rgba(200,200,200,.1);font-size:1.4em}.toolbar-help-overlay .navigation-help{margin-top:1em;font-size:.7em}.toolbar-element .toolbar-help-overlay-button{height:0;position:relative;display:flex;justify-content:end}.toolbar-element .toolbar-help-overlay-button>.button{margin:0;padding:5px;padding-top:0;padding-bottom:0;box-shadow:none;text-align:center;opacity:.5}.toolbar-element .toolbar-help-overlay-button>.button>.icon{width:1.18em;height:1.18em;transition:.2s ease filter}.toolbar-element .toolbar-help-overlay-button>.button:focus-visible>.icon,.toolbar-element .toolbar-help-overlay-button>.button:hover>.icon{filter:drop-shadow(0px 0px 1px var(--shadow-color))}.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))}.clipboard-error-dialog details>summary{cursor:pointer}.clipboard-error-dialog details[open]{margin-bottom:12px}.clipboard-error-dialog textarea{width:100%;box-sizing:border-box}.selection-tool-selection-background{background-color:var(--selection-background-color);opacity:.5;overflow:visible}.selection-tool-handle{position:absolute;box-sizing:border-box;display:flex;align-items:center;justify-content:center;--max-size: 17px}.selection-tool-handle .selection-tool-content{border:1px solid var(--foreground-color-1);background:var(--background-color-1);box-sizing:border-box;max-width:var(--max-size);max-height:var(--max-size);width:100%;height:100%;display:flex;justify-content:center;align-items:center;padding:3px}.selection-tool-handle .selection-tool-content .icon{width:100%;height:100%}.selection-tool-handle.selection-tool-circle .selection-tool-content{border-radius:100%}.selection-tool-handle.selection-tool-rotate{--max-size: 28px;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:nwse-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:nesw-resize}.selection-tool-selection-menu>button{max-height:var(--vertical-offset);background-color:var(--background-color-1);width:24px;height:24px;padding:6px;font-size:14px;user-select:none;-webkit-user-select:none;color:var(--foreground-color-1);border:.5px solid var(--foreground-color-1);border-radius:3px;opacity:.8;transition:.2s ease opacity}.selection-tool-selection-menu>button:hover,.selection-tool-selection-menu>button:focus-visible{background-color:var(--background-color-2);color:var(--foreground-color-2);cursor:pointer;opacity:1}.selection-tool-selection-menu>button>.icon{width:100%;height:100%}.overlay.handleOverlay{touch-action:none;direction:ltr}.overlay.handleOverlay,.overlay.handleOverlay .selection-tool-selection-outer-container{height:0;overflow:visible}.overlay.handleOverlay .selection-tool-selection-inner-container{width:var(--editor-current-display-width-px);height:var(--editor-current-display-height-px);overflow:hidden;pointer-events:none}.overlay.handleOverlay .selection-tool-selection-inner-container>*{pointer-events:all}.overlay.handleOverlay .selection-tool-selection-inner-container.-empty{opacity:0;display:none}.overlay.handleOverlay .selection-tool-selection-inner-container.-hide-handles .selection-tool-handle{display:none}@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;user-select:none;-webkit-user-select:none}.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}@keyframes show-popup-menu-animation{from{opacity:0}to{opacity:1}}.editor-popup-menu{width:100%;height:100%;background-color:rgba(0,0,0,0);border:none;animation:var(--hide-menu-animation-timeout) ease show-popup-menu-animation;opacity:1;transition:var(--hide-menu-animation-timeout) ease opacity;overflow:hidden}.editor-popup-menu.-hide{opacity:0}.editor-popup-menu>.content{position:absolute;left:var(--anchor-x);top:var(--anchor-y);display:flex;flex-direction:column;overflow:clip;border-radius:6px;box-shadow:0px 0px 2px var(--shadow-color);background-color:var(--background-color-1)}.editor-popup-menu::backdrop{background:rgba(0,0,0,0)}.editor-popup-menu-option{display:flex;justify-content:start;cursor:pointer;padding:5px;padding-top:6px;padding-bottom:6px;background-color:rgba(0,0,0,0);color:var(--foreground-color-1);--icon-color: currentColor;border:none;font-size:1em}.editor-popup-menu-option:hover,.editor-popup-menu-option:focus-visible{background-color:var(--background-color-2);color:var(--foreground-color-2)}.editor-popup-menu-option>:first-child{width:1em;height:1em;flex-shrink:0;align-self:center;margin-inline-start:0em;margin-inline-end:.32em}.about-dialog-content>.scroll{white-space:pre-wrap;font-family:monospace}.about-dialog-content>.scroll>details>summary{cursor:pointer}.about-dialog-content>.scroll>h2,.about-dialog-content>.scroll>details>summary{margin-top:15px;font-size:1.2em;font-weight:bold}.about-dialog-content>.scroll>h2 a,.about-dialog-content>.scroll>details>summary a{color:var(--foreground-color-1);text-decoration:underline}@keyframes fade-in{from{opacity:0}to{opacity:1}}.message-dialog-container dialog{display:flex}.message-dialog-container dialog.-closing{opacity:0}.message-dialog-container dialog.-closing::backdrop{opacity:0}.message-dialog-container dialog,.message-dialog-container dialog::backdrop{transition:opacity .2s ease;animation:fade-in .2s ease}.message-dialog-content{display:flex;flex-direction:column;flex-grow:1}.message-dialog-content>.close{display:block;margin-left:auto;margin-right:auto}.message-dialog-content>.scroll{flex-grow:1;flex-shrink:1;overflow-y:auto;margin-left:20px;margin-right:20px;padding-bottom:20px}.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}.dialog-container>dialog::backdrop{backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px);background-color:var(--background-color-transparent)}#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;writing-mode:horizontal-tb;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;user-select:none;-webkit-user-select:none;-webkit-user-drag:none}.imageEditorContainer .loadingMessage{position:fixed;text-align:center;font-size:2em;text-shadow:0px 0px 1px var(--background-color-1);bottom:0;left:0;right:0}.imageEditorContainer .accessibilityAnnouncement{opacity:0;width:0;height:0;overflow:hidden;pointer-events:none;user-select:none;-webkit-user-select:none}.imageEditorContainer .textRendererOutputContainer{width:.001px;height:.001px;overflow:hidden;-webkit-user-select:none;user-select:none}.imageEditorContainer .textRendererOutputContainer:focus-within{overflow:visible;z-index:5}.imageEditorContainer .anchored-element-overlay{overflow:visible;height:0}.imageEditorContainer .anchored-element-overlay>.content-wrapper{width:var(--editor-current-display-width-px);height:var(--editor-current-display-height-px);overflow:hidden;position:relative;pointer-events:none}.imageEditorContainer .anchored-element-overlay>.content-wrapper>.content{position:absolute;left:var(--position-x);top:var(--position-y);transform:scale(var(--scale)) rotate(var(--rotation));transform-origin:left top;margin:0;pointer-events:all}@media print{.imageEditorContainer .loadingMessage{display:none}.imageEditorContainer .imageEditorRenderArea canvas{width:100%;height:initial}}',document.head.appendChild(s)}})();(()=>{if(typeof document<"u"&&typeof document.createElement=="function"){let s=document.createElement("style");s.textContent='.clr-picker{display:none;flex-wrap:wrap;position:absolute;width:200px;z-index:1000;border-radius:10px;background-color:#fff;justify-content:flex-end;direction:ltr;box-shadow:0 0 5px rgba(0, 0, 0, 0.05),0 5px 20px rgba(0, 0, 0, 0.1);-moz-user-select:none;-webkit-user-select:none;user-select:none}.clr-picker.clr-open,.clr-picker[data-inline=true]{display:flex}.clr-picker[data-inline=true]{position:relative}.clr-gradient{position:relative;width:100%;height:100px;margin-bottom:15px;border-radius:3px 3px 0 0;background-image:linear-gradient(rgba(0, 0, 0, 0), #000),linear-gradient(90deg, #fff, currentColor);cursor:pointer}.clr-marker{position:absolute;width:12px;height:12px;margin:-6px 0 0 -6px;border:1px solid #fff;border-radius:50%;background-color:currentColor;cursor:pointer}.clr-picker input[type=range]::-webkit-slider-runnable-track{width:100%;height:16px}.clr-picker input[type=range]::-webkit-slider-thumb{width:16px;height:16px;-webkit-appearance:none}.clr-picker input[type=range]::-moz-range-track{width:100%;height:16px;border:0}.clr-picker input[type=range]::-moz-range-thumb{width:16px;height:16px;border:0}.clr-hue{background-image:linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%)}.clr-hue,.clr-alpha{position:relative;width:calc(100% - 40px);height:8px;margin:5px 20px;border-radius:4px}.clr-alpha span{display:block;height:100%;width:100%;border-radius:inherit;background-image:linear-gradient(90deg, rgba(0, 0, 0, 0), currentColor)}.clr-hue input,.clr-alpha input{position:absolute;width:calc(100% + 32px);height:16px;left:-16px;top:-4px;margin:0;background-color:transparent;opacity:0;cursor:pointer;appearance:none;-webkit-appearance:none}.clr-hue div,.clr-alpha div{position:absolute;width:16px;height:16px;left:0;top:50%;margin-left:-8px;transform:translateY(-50%);border:2px solid #fff;border-radius:50%;background-color:currentColor;box-shadow:0 0 1px #888;pointer-events:none}.clr-alpha div:before{content:"";position:absolute;height:100%;width:100%;left:0;top:0;border-radius:50%;background-color:currentColor}.clr-format{display:none;order:1;width:calc(100% - 40px);margin:0 20px 20px}.clr-segmented{display:flex;position:relative;width:100%;margin:0;padding:0;border:1px solid #ddd;border-radius:15px;box-sizing:border-box;color:#999;font-size:12px}.clr-segmented input,.clr-segmented legend{position:absolute;width:100%;height:100%;margin:0;padding:0;border:0;left:0;top:0;opacity:0;pointer-events:none}.clr-segmented label{flex-grow:1;margin:0;padding:4px 0;font-size:inherit;font-weight:normal;line-height:initial;text-align:center;cursor:pointer}.clr-segmented label:first-of-type{border-radius:10px 0 0 10px}.clr-segmented label:last-of-type{border-radius:0 10px 10px 0}.clr-segmented input:checked+label{color:#fff;background-color:#666}.clr-swatches{order:2;width:calc(100% - 32px);margin:0 16px}.clr-swatches div{display:flex;flex-wrap:wrap;padding-bottom:12px;justify-content:center}.clr-swatches button{position:relative;width:20px;height:20px;margin:0 4px 6px 4px;padding:0;border:0;border-radius:50%;color:inherit;text-indent:-1000px;white-space:nowrap;overflow:hidden;cursor:pointer}.clr-swatches button:after{content:"";display:block;position:absolute;width:100%;height:100%;left:0;top:0;border-radius:inherit;background-color:currentColor;box-shadow:inset 0 0 0 1px rgba(0, 0, 0, 0.1)}input.clr-color{order:1;width:calc(100% - 80px);height:32px;margin:15px 20px 20px auto;padding:0 10px;border:1px solid #ddd;border-radius:16px;color:#444;background-color:#fff;font-family:sans-serif;font-size:14px;text-align:center;box-shadow:none}input.clr-color:focus{outline:none;border:1px solid #1e90ff}.clr-close,.clr-clear{display:none;order:2;height:24px;margin:0 20px 20px;padding:0 20px;border:0;border-radius:12px;color:#fff;background-color:#666;font-family:inherit;font-size:12px;font-weight:400;cursor:pointer}.clr-close{display:block;margin:0 20px 20px auto}.clr-preview{position:relative;width:32px;height:32px;margin:15px 0 20px 20px;border-radius:50%;overflow:hidden}.clr-preview:before,.clr-preview:after{content:"";position:absolute;height:100%;width:100%;left:0;top:0;border:1px solid #fff;border-radius:50%}.clr-preview:after{border:0;background-color:currentColor;box-shadow:inset 0 0 0 1px rgba(0, 0, 0, 0.1)}.clr-preview button{position:absolute;width:100%;height:100%;z-index:1;margin:0;padding:0;border:0;border-radius:50%;outline-offset:-2px;background-color:transparent;text-indent:-9999px;cursor:pointer;overflow:hidden}.clr-marker,.clr-hue div,.clr-alpha div,.clr-color{box-sizing:border-box}.clr-field{display:inline-block;position:relative;color:transparent}.clr-field input{margin:0;direction:ltr}.clr-field.clr-rtl input{text-align:right}.clr-field button{position:absolute;width:30px;height:100%;right:0;top:50%;transform:translateY(-50%);margin:0;padding:0;border:0;color:inherit;text-indent:-1000px;white-space:nowrap;overflow:hidden;pointer-events:none}.clr-field.clr-rtl button{right:auto;left:0}.clr-field button:after{content:"";display:block;position:absolute;width:100%;height:100%;left:0;top:0;border-radius:inherit;background-color:currentColor;box-shadow:inset 0 0 1px rgba(0, 0, 0, 0.5)}.clr-alpha,.clr-alpha div,.clr-swatches button,.clr-preview:before,.clr-field button{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);background-position:0 0,4px 4px;background-size:8px 8px}.clr-marker:focus{outline:none}.clr-keyboard-nav .clr-marker:focus,.clr-keyboard-nav .clr-hue input:focus+div,.clr-keyboard-nav .clr-alpha input:focus+div,.clr-keyboard-nav .clr-segmented input:focus+label{outline:none;box-shadow:0 0 0 2px #1e90ff,0 0 2px 2px #fff}.clr-picker[data-alpha=false] .clr-alpha{display:none}.clr-picker[data-minimal=true]{padding-top:16px}.clr-picker[data-minimal=true] .clr-gradient,.clr-picker[data-minimal=true] .clr-hue,.clr-picker[data-minimal=true] .clr-alpha,.clr-picker[data-minimal=true] .clr-color,.clr-picker[data-minimal=true] .clr-preview{display:none}.clr-dark{background-color:#444}.clr-dark .clr-segmented{border-color:#777}.clr-dark .clr-swatches button:after{box-shadow:inset 0 0 0 1px rgba(255, 255, 255, 0.3)}.clr-dark input.clr-color{color:#fff;border-color:#777;background-color:#555}.clr-dark input.clr-color:focus{border-color:#1e90ff}.clr-dark .clr-preview:after{box-shadow:inset 0 0 0 1px rgba(255, 255, 255, 0.5)}.clr-dark .clr-alpha,.clr-dark .clr-alpha div,.clr-dark .clr-swatches button,.clr-dark .clr-preview:before{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)}.clr-picker.clr-polaroid{border-radius:6px;box-shadow:0 0 5px rgba(0, 0, 0, 0.1),0 5px 30px rgba(0, 0, 0, 0.2)}.clr-picker.clr-polaroid:before{content:"";display:block;position:absolute;width:16px;height:10px;left:20px;top:-10px;border:solid transparent;border-width:0 8px 10px 8px;border-bottom-color:currentColor;box-sizing:border-box;color:#fff;filter:drop-shadow(0 -4px 3px rgba(0, 0, 0, 0.1));pointer-events:none}.clr-picker.clr-polaroid.clr-dark:before{color:#444}.clr-picker.clr-polaroid.clr-left:before{left:auto;right:20px}.clr-picker.clr-polaroid.clr-top:before{top:auto;bottom:-10px;transform:rotateZ(180deg)}.clr-polaroid .clr-gradient{width:calc(100% - 20px);height:120px;margin:10px;border-radius:3px}.clr-polaroid .clr-hue,.clr-polaroid .clr-alpha{width:calc(100% - 30px);height:10px;margin:6px 15px;border-radius:5px}.clr-polaroid .clr-hue div,.clr-polaroid .clr-alpha div{box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.clr-polaroid .clr-format{width:calc(100% - 20px);margin:0 10px 15px}.clr-polaroid .clr-swatches{width:calc(100% - 12px);margin:0 6px}.clr-polaroid .clr-swatches div{padding-bottom:10px}.clr-polaroid .clr-swatches button{width:22px;height:22px}.clr-polaroid input.clr-color{width:calc(100% - 60px);margin:10px 10px 15px auto}.clr-polaroid .clr-clear{margin:0 10px 15px 10px}.clr-polaroid .clr-close{margin:0 10px 15px auto}.clr-polaroid .clr-preview{margin:10px 0 15px 10px}.clr-picker.clr-large{width:275px}.clr-large .clr-gradient{height:150px}.clr-large .clr-swatches button{width:22px;height:22px}.clr-picker.clr-pill{width:380px;padding-left:180px;box-sizing:border-box}.clr-pill .clr-gradient{position:absolute;width:180px;height:100%;left:0;top:0;margin-bottom:0;border-radius:3px 0 0 3px}.clr-pill .clr-hue{margin-top:20px}',document.head.appendChild(s)}})();var xn=class s{onDrop(o){}static union(o,e){return new class extends s{apply(r){o.apply(r),e.apply(r)}unapply(r){e.unapply(r),o.unapply(r)}description(r,n){let i=o.description(r,n),a=e.description(r,n);return i===a?i:`${i}, ${a}`}}}static{this.empty=new class extends s{description(o,e){return""}apply(o){}unapply(o){}}}},Ie=xn;var wn=class{constructor(o,e,r){this.x=o;this.y=e;this.z=r}get xy(){return{x:this.x,y:this.y}}at(o){if(o===0)return this.x;if(o===1)return this.y;if(o===2)return this.z;throw new Error(`${o} out of bounds!`)}length(){return this.magnitude()}magnitude(){return Math.sqrt(this.magnitudeSquared())}magnitudeSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}squareDistanceTo(o){let e=this.x-o.x,r=this.y-o.y,n=this.z-o.z;return e*e+r*r+n*n}distanceTo(o){return Math.sqrt(this.squareDistanceTo(o))}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(){let o=this.magnitude();return F.of(this.x/o,this.y/o,this.z/o)}normalizedOrZero(){return this.eq(F.zero)?F.zero:this.normalized()}times(o){return F.of(this.x*o,this.y*o,this.z*o)}plus(o){return F.of(this.x+o.x,this.y+o.y,this.z+o.z)}minus(o){return F.of(this.x-o.x,this.y-o.y,this.z-o.z)}dot(o){return this.x*o.x+this.y*o.y+this.z*o.z}cross(o){return F.of(this.y*o.z-o.y*this.z,o.x*this.z-this.x*o.z,this.x*o.y-o.x*this.y)}scale(o){return typeof o=="number"?this.times(o):F.of(this.x*o.x,this.y*o.y,this.z*o.z)}orthog(){return this.dot(F.unitX)===0&&this.dot(F.unitY)===0?this.dot(F.unitX)===0?F.unitX:this.cross(F.unitX).normalized():this.cross(F.unitZ.times(-1)).normalized()}extend(o,e){return this.plus(e.normalized().times(o))}lerp(o,e){return this.times(1-e).plus(o.times(e))}zip(o,e){return F.of(e(o.x,this.x),e(o.y,this.y),e(o.z,this.z))}map(o){return F.of(o(this.x,0),o(this.y,1),o(this.z,2))}asArray(){return[this.x,this.y,this.z]}eq(o,e=1e-10){return Math.abs(o.x-this.x)<=e&&Math.abs(o.y-this.y)<=e&&Math.abs(o.z-this.z)<=e}toString(){return`Vec(${this.x}, ${this.y}, ${this.z})`}},Cn=class{constructor(o,e){this.x=o;this.y=e}get z(){return 0}get xy(){return{x:this.x,y:this.y}}at(o){if(o===0)return this.x;if(o===1)return this.y;if(o===2)return 0;throw new Error(`${o} out of bounds!`)}length(){return this.magnitude()}magnitude(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitudeSquared(){return this.x*this.x+this.y*this.y}squareDistanceTo(o){let e=this.x-o.x,r=this.y-o.y;return e*e+r*r+o.z*o.z}distanceTo(o){return Math.sqrt(this.squareDistanceTo(o))}maximumEntryMagnitude(){return Math.max(Math.abs(this.x),Math.abs(this.y))}angle(){return Math.atan2(this.y,this.x)}normalized(){let o=this.magnitude();return w.of(this.x/o,this.y/o)}normalizedOrZero(){return this.eq(F.zero)?F.zero:this.normalized()}times(o){return w.of(this.x*o,this.y*o)}plus(o){return F.of(this.x+o.x,this.y+o.y,o.z)}minus(o){return F.of(this.x-o.x,this.y-o.y,-o.z)}dot(o){return this.x*o.x+this.y*o.y}cross(o){return F.of(this.y*o.z,-this.x*o.z,this.x*o.y-o.x*this.y)}scale(o){return typeof o=="number"?this.times(o):w.of(this.x*o.x,this.y*o.y)}orthog(){return this.dot(F.unitX)===0&&this.dot(F.unitY)===0?this.dot(F.unitX)===0?F.unitX:this.cross(F.unitX).normalized():this.cross(F.unitZ.times(-1)).normalized()}extend(o,e){return this.plus(e.normalized().times(o))}lerp(o,e){return this.times(1-e).plus(o.times(e))}zip(o,e){return F.of(e(o.x,this.x),e(o.y,this.y),e(o.z,0))}map(o){return F.of(o(this.x,0),o(this.y,1),o(0,2))}asArray(){return[this.x,this.y,0]}eq(o,e=1e-10){return Math.abs(o.x-this.x)<=e&&Math.abs(o.y-this.y)<=e&&Math.abs(o.z)<=e}toString(){return`Vec(${this.x}, ${this.y})`}},w;(i=>(i.of=(a,l)=>new Cn(a,l),i.ofXY=({x:a,y:l})=>i.of(a,l),i.unitX=i.of(1,0),i.unitY=i.of(0,1),i.zero=i.of(0,0)))(w||={});var F;(i=>(i.of=(a,l,c)=>c===0?w.of(a,l):new wn(a,l,c),i.unitX=w.unitX,i.unitY=w.unitY,i.zero=w.zero,i.unitZ=i.of(0,0,1)))(F||={});var Pe=F;var k=class s{constructor(o,e,r,n,i,a,l,c,d){this.a1=o;this.a2=e;this.a3=r;this.b1=n;this.b2=i;this.b3=a;this.c1=l;this.c2=c;this.c3=d;this.cachedInverse=void 0;this.rows=[Pe.of(o,e,r),Pe.of(n,i,a),Pe.of(l,c,d)]}static ofRows(o,e,r){return new s(o.x,o.y,o.z,e.x,e.y,e.z,r.x,r.y,r.z)}static{this.identity=new s(1,0,0,0,1,0,0,0,1)}inverse(){return this.computeInverse()??s.identity}invertable(){return this.computeInverse()!==null}computeInverse(){if(this.cachedInverse!==void 0)return this.cachedInverse;let o=[this.rows[0],this.rows[1],this.rows[2]],e=[Pe.unitX,Pe.unitY,Pe.unitZ];for(let n=0;n<3;n++){let i=o[n].at(n),a=1e-10;if(Math.abs(i)<a){let u=-1;for(let m=1;m<=2;m++){let g=(n+m)%3;if(Math.abs(o[g].at(n))>=a){u=g;break}}if(u===-1)return this.cachedInverse=null,null;let p=o[n],h=e[n];o[n]=o[u],e[n]=e[u],o[u]=p,e[u]=h,i=o[n].at(n)}let l=1/i;o[n]=o[n].times(l),e[n]=e[n].times(l);let c=o[n],d=e[n];for(let u=1;u<=2;u++){let p=(n+u)%3;l=-o[p].at(n),o[p]=o[p].plus(c.times(l)),e[p]=e[p].plus(d.times(l))}}let r=s.ofRows(e[0],e[1],e[2]);return this.cachedInverse=r,r}transposed(){return new s(this.a1,this.b1,this.c1,this.a2,this.b2,this.c2,this.a3,this.b3,this.c3)}rightMul(o){o=o.transposed();let e=(r,n)=>this.rows[r].dot(o.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(o){let e=Pe.of(o.x,o.y,1);return e=this.transformVec3(e),w.of(e.x,e.y)}transformVec3(o){return Pe.of(this.rows[0].dot(o),this.rows[1].dot(o),this.rows[2].dot(o))}isIdentity(){return this===s.identity?!0:this.eq(s.identity)}eq(o,e=0){for(let r=0;r<3;r++)if(!this.rows[r].eq(o.rows[r],e))return!1;return!0}toString(){let o="",e=[0,0,0];for(let r of this.rows)for(let n=0;n<3;n++)e[n]=Math.max(e[0],`${r.at(n)}`.length);for(let r=0;r<3;r++){r===0?o+="\u23A1 ":r===1?o+="\u23A2 ":o+="\u23A3 ";for(let n=0;n<3;n++){let i=this.rows[r].at(n).toString(),a="";for(let l=i.length;l<e[n];l++)a+=" ";o+=i+", "+a}r===0?o+=" \u23A4":r===1?o+=" \u23A5":o+=" \u23A6",o+=`
|
2
|
+
`}return o.trimEnd()}toArray(){return[this.a1,this.a2,this.a3,this.b1,this.b2,this.b3,this.c1,this.c2,this.c3]}mapEntries(o){return new s(o(this.a1,[0,0]),o(this.a2,[0,1]),o(this.a3,[0,2]),o(this.b1,[1,0]),o(this.b2,[1,1]),o(this.b3,[1,2]),o(this.c1,[2,0]),o(this.c2,[2,1]),o(this.c3,[2,2]))}getScaleFactor(){return Math.hypot(this.a1,this.a2)}getColumn(o){return Pe.of(this.rows[0].at(o),this.rows[1].at(o),this.rows[2].at(o))}maximumEntryMagnitude(){let o=Math.abs(this.a1);for(let e of this.toArray())o=Math.max(o,Math.abs(e));return o}static translation(o){return new s(1,0,o.x,0,1,o.y,0,0,1)}static zRotation(o,e=w.zero){if(o===0)return s.identity;let r=Math.cos(o),n=Math.sin(o),i=s.translation(e);return i=i.rightMul(new s(r,-n,0,n,r,0,0,0,1)),i.rightMul(s.translation(e.times(-1)))}static scaling2D(o,e=w.zero){let r=s.translation(e),n,i;return typeof o=="number"?(n=o,i=o):(n=o.x,i=o.y),r=r.rightMul(new s(n,0,0,0,i,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(o){if(o===""||o==="none")return s.identity;o=o.trim().replace(/\s+/g," ");let e=l=>l.split(/[, \t\n]+/g).map(d=>{if(d.trim()==="")return null;let u=!1;if(d.endsWith("%")&&(u=!0,d=d.substring(0,d.length-1)),d=d.replace(/px$/gi,""),!/^[-]?\d*(?:\.\d*)?(?:[eE][-+]?\d+)?$/i.exec(d))throw new Error(`All arguments to transform functions must be numeric (state: ${JSON.stringify({currentArgument:d,allArguments:l})})`);let h=parseFloat(d);return u&&(h/=100),h}).filter(d=>d!==null),r={matrix:l=>{if(l.length!==6)throw new Error(`Invalid matrix argument: ${l}. Must have length 6`);let c=l[0],d=l[1],u=l[2],p=l[3],h=l[4],m=l[5];return new s(c,u,h,d,p,m,0,0,1)},scale:l=>{let c,d;if(l.length===1)c=l[0],d=l[0];else if(l.length===2)c=l[0],d=l[1];else throw new Error(`The scale() function only supports two arguments. Given: ${l}`);return s.scaling2D(w.of(c,d))},translate:l=>{let c=0,d=0;if(l.length===1)c=l[0];else if(l.length===2)c=l[0],d=l[1];else throw new Error(`The translate() function requires either 1 or 2 arguments. Given ${l}`);return s.translation(w.of(c,d))}},n=/(?:^|\W)(\w+)\s?\(([^)]*)\)/gi,i,a=null;for(;(i=n.exec(o))!==null;){let l=i[1].toLowerCase();if(!(l in r))throw new Error(`Unsupported CSS transform action: ${l}`);let c=e(i[2]),d=r[l](c);a?a=a.rightMul(d):a=d}return a??s.identity}},Di=k;var yo=class s{static{this.smallValue=1e-12}distance(o){return Math.abs(this.signedDistance(o))}containsPoint(o,e=s.smallValue){return this.signedDistance(o)<e}getLooseBoundingBox(){return this.getTightBoundingBox()}},ur=yo;var I=class s extends ur{constructor(e,r,n,i){super();this.x=e;this.y=r;this.w=n;this.h=i;n<0&&(this.x+=n,this.w=Math.abs(n)),i<0&&(this.y+=i,this.h=Math.abs(i)),this.topLeft=w.of(this.x,this.y),this.size=w.of(this.w,this.h),this.area=this.w*this.h}translatedBy(e){return new s(e.x+this.x,e.y+this.y,this.w,this.h)}resizedTo(e){return new s(this.x,this.y,e.x,e.y)}containsPoint(e){return this.x<=e.x&&this.y<=e.y&&this.x+this.w>=e.x&&this.y+this.h>=e.y}containsRect(e){return this.x<=e.x&&this.y<=e.y&&this.x+this.w>=e.x+e.w&&this.y+this.h>=e.y+e.h}intersects(e){let r=this.x,n=r+this.w,i=e.x,a=e.x+e.w;if(n<i||r>a)return!1;let l=this.y,c=l+this.h,d=e.y,u=e.y+e.h;return!(c<d||l>u)}intersection(e){if(!this.intersects(e))return null;let r=this.topLeft.zip(e.topLeft,Math.max),n=this.bottomRight.zip(e.bottomRight,Math.min);return s.fromCorners(r,n)}union(e){return s.union(this,e)}divideIntoGrid(e,r){let n=[];if(e<=0||r<=0)return n;let i=this.w/e,a=this.h/r;i===0&&(e=1),a===0&&(r=1);for(let l=0;l<r;l++)for(let c=0;c<e;c++){let d=i*c+this.x,u=a*l+this.y;n.push(new s(d,u,i,a))}return n}grownToPoint(e,r=0){let n=new s(e.x-r,e.y-r,r*2,r*2);return this.union(n)}grownBy(e){if(e===0)return this;if(e<0){let r=-Math.min(-e,this.w/2),n=-Math.min(-e,this.h/2);return new s(this.x-r,this.y-n,this.w+r*2,this.h+n*2)}return new s(this.x-e,this.y-e,this.w+e*2,this.h+e*2)}grownToSize(e){if(this.width>=e.x&&this.height>=e.y)return this;let r=Math.max(0,e.x-this.width),n=Math.max(0,e.y-this.height);return new s(this.x-r/2,this.y-n/2,this.width+r,this.height+n)}getClosestPointOnBoundaryTo(e){let r=this.getEdges().map(a=>a.closestPointTo(e)),n=null,i=null;for(let a of r){let l=a.distanceTo(e);(i===null||l<i)&&(n=a,i=l)}return n}isWithinRadiusOf(e,r){if(this.maxDimension>e)return!1;let n=e*e;return this.corners.every(i=>i.minus(r).magnitudeSquared()<n)}get corners(){return[this.bottomRight,this.topRight,this.topLeft,this.bottomLeft]}get maxDimension(){return Math.max(this.w,this.h)}get minDimension(){return Math.min(this.w,this.h)}get bottomRight(){return this.topLeft.plus(this.size)}get topRight(){return this.bottomRight.plus(w.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(w.of(0,this.h))}get width(){return this.w}get height(){return this.h}get center(){return w.of(this.x+this.w/2,this.y+this.h/2)}getEdges(){let e=this.corners;return[new Be(e[0],e[1]),new Be(e[1],e[2]),new Be(e[2],e[3]),new Be(e[3],e[0])]}intersectsLineSegment(e){let r=[];for(let n of this.getEdges())n.intersectsLineSegment(e).forEach(a=>r.push(a));return r}signedDistance(e){let r=this.getClosestPointOnBoundaryTo(e),n=e.minus(r).magnitude();return this.containsPoint(e)?-n:n}getTightBoundingBox(){return this}transformedBoundingBox(e){return e===Di.identity?this:s.bboxOf(this.corners.map(r=>e.transformVec2(r)))}eq(e,r=0){return this.topLeft.eq(e.topLeft,r)&&this.size.eq(e.size,r)}toString(){return`Rect(point(${this.x}, ${this.y}), size(${this.w}, ${this.h}))`}static fromCorners(e,r){return new s(Math.min(e.x,r.x),Math.min(e.y,r.y),Math.abs(e.x-r.x),Math.abs(e.y-r.y))}static bboxOf(e,r=0){let n=0,i=0,a=0,l=0,c=!0;for(let d of e)c&&(n=d.x,i=d.y,a=d.x,l=d.y,c=!1),n=Math.min(n,d.x),i=Math.min(i,d.y),a=Math.max(a,d.x),l=Math.max(l,d.y);return s.fromCorners(w.of(n-r,i-r),w.of(a+r,l+r))}static union(...e){if(e.length===0)return s.empty;let r=e[0],n=r.x,i=r.y,a=r.x+r.w,l=r.y+r.h;for(let c=1;c<e.length;c++){let d=e[c];n=Math.min(n,d.x),i=Math.min(i,d.y),a=Math.max(a,d.x+d.w),l=Math.max(l,d.y+d.h)}return new s(n,i,a-n,l-i)}static of(e){let r=e.width??e.w??0,n=e.height??e.h??0;return new s(e.x,e.y,r,n)}static{this.empty=new s(0,0,0,0)}static{this.unitSquare=new s(0,0,1,1)}},he=I;var xo=class extends ur{intersectsLineSegment(o){return this.argIntersectsLineSegment(o).map(e=>this.at(e))}},Xt=xo;var ue=class s extends Xt{constructor(e,r){super();this.point1=e;this.point2=r;this.bbox=he.bboxOf([e,r]),this.direction=r.minus(e),this.length=this.direction.magnitude(),this.length>0&&(this.direction=this.direction.times(1/this.length))}static ofSmallestContainingPoints(e){if(e.length<=1)return null;let r=[...e].sort((i,a)=>i.x!==a.x?i.x-a.x:i.y-a.y),n=new s(r[0],r[r.length-1]);for(let i of r)if(!n.containsPoint(i))return null;return n}get p1(){return this.point1}get p2(){return this.point2}get center(){return this.point1.lerp(this.point2,.5)}get(e){return this.point1.plus(this.direction.times(e))}at(e){return this.get(e*this.length)}normalAt(e){return this.direction.orthog()}tangentAt(e){return this.direction}splitAt(e){return e<=0||e>=1?[this]:[new s(this.point1,this.at(e)),new s(this.at(e),this.point2)]}intersection(e){let r,n;if(Math.abs(this.direction.x)<4e-13){if(e.direction.x===0||this.direction.y===0)return null;let u=this.point1.x,p=(this.point1.x-e.point1.x)*e.direction.y/e.direction.x+e.point1.y;r=w.of(u,p),n=(p-this.point1.y)/this.direction.y}else{let u=(this.point1.y-e.point1.y)*this.direction.x*e.direction.x+this.direction.x*e.direction.y*e.point1.x-this.direction.y*e.direction.x*this.point1.x,p=e.direction.y*this.direction.x-this.direction.y*e.direction.x;if(p===0)return null;let h=u/p,m=(h-this.point1.x)/this.direction.x,g=this.point1.y+this.direction.y*m;r=w.of(h,g),n=(h-this.point1.x)/this.direction.x}let a=r.distanceTo(this.point1),l=r.distanceTo(this.point2),c=r.distanceTo(e.point1),d=r.distanceTo(e.point2);return a>this.length||l>this.length||c>e.length||d>e.length?null:{point:r,t:n}}intersects(e){return this.intersection(e)!==null}argIntersectsLineSegment(e){let r=this.intersection(e);return r?[r.t/this.length]:[]}intersectsLineSegment(e){let r=this.intersection(e);return r?[r.point]:[]}closestPointTo(e){return this.nearestPointTo(e).point}nearestPointTo(e){let r=e.minus(this.p1).dot(this.direction),n=this.length-r,i=this.p1.plus(this.direction.times(r));return r>0&&r<this.length?{point:i,parameterValue:r/this.length}:Math.abs(n)<Math.abs(r)?{point:this.p2,parameterValue:1}:{point:this.p1,parameterValue:0}}signedDistance(e){return this.closestPointTo(e).minus(e).magnitude()}transformedBy(e){return new s(e.transformVec2(this.p1),e.transformVec2(this.p2))}getTightBoundingBox(){return this.bbox}toString(){return`LineSegment(${this.p1.toString()}, ${this.p2.toString()})`}eq(e,r){if(!(e instanceof s))return!1;let n=r?.tolerance,i=r?.ignoreDirection??!0;return e.p1.eq(this.p1,n)&&e.p2.eq(this.p2,n)||i&&e.p1.eq(this.p2,n)&&e.p2.eq(this.p1,n)}},Be=ue;var{abs:wo,cos:Ze,sin:Qt,acos:ma,atan2:Co,sqrt:ct,pow:Me}=Math;function To(s){return s<0?-Me(-s,1/3):Me(s,1/3)}var Ai=Math.PI,pr=2*Ai,dt=Ai/2,fa=1e-6,Tn=Number.MAX_SAFE_INTEGER||9007199254740991,Sn=Number.MIN_SAFE_INTEGER||-9007199254740991,ga={x:0,y:0,z:0},B={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(s,o){let e=o(s),r=e.x*e.x+e.y*e.y;return typeof e.z<"u"&&(r+=e.z*e.z),ct(r)},compute:function(s,o,e){if(s===0)return o[0].t=0,o[0];let r=o.length-1;if(s===1)return o[r].t=1,o[r];let n=1-s,i=o;if(r===0)return o[0].t=s,o[0];if(r===1){let l={x:n*i[0].x+s*i[1].x,y:n*i[0].y+s*i[1].y,t:s};return e&&(l.z=n*i[0].z+s*i[1].z),l}if(r<4){let l=n*n,c=s*s,d,u,p,h=0;r===2?(i=[i[0],i[1],i[2],ga],d=l,u=n*s*2,p=c):r===3&&(d=l*n,u=l*s*3,p=n*c*3,h=s*c);let m={x:d*i[0].x+u*i[1].x+p*i[2].x+h*i[3].x,y:d*i[0].y+u*i[1].y+p*i[2].y+h*i[3].y,t:s};return e&&(m.z=d*i[0].z+u*i[1].z+p*i[2].z+h*i[3].z),m}let a=JSON.parse(JSON.stringify(o));for(;a.length>1;){for(let l=0;l<a.length-1;l++)a[l]={x:a[l].x+(a[l+1].x-a[l].x)*s,y:a[l].y+(a[l+1].y-a[l].y)*s},typeof a[l].z<"u"&&(a[l]=a[l].z+(a[l+1].z-a[l].z)*s);a.splice(a.length-1,1)}return a[0].t=s,a[0]},computeWithRatios:function(s,o,e,r){let n=1-s,i=e,a=o,l=i[0],c=i[1],d=i[2],u=i[3],p;if(l*=n,c*=s,a.length===2)return p=l+c,{x:(l*a[0].x+c*a[1].x)/p,y:(l*a[0].y+c*a[1].y)/p,z:r?(l*a[0].z+c*a[1].z)/p:!1,t:s};if(l*=n,c*=2*n,d*=s*s,a.length===3)return p=l+c+d,{x:(l*a[0].x+c*a[1].x+d*a[2].x)/p,y:(l*a[0].y+c*a[1].y+d*a[2].y)/p,z:r?(l*a[0].z+c*a[1].z+d*a[2].z)/p:!1,t:s};if(l*=n,c*=1.5*n,d*=3*n,u*=s*s*s,a.length===4)return p=l+c+d+u,{x:(l*a[0].x+c*a[1].x+d*a[2].x+u*a[3].x)/p,y:(l*a[0].y+c*a[1].y+d*a[2].y+u*a[3].y)/p,z:r?(l*a[0].z+c*a[1].z+d*a[2].z+u*a[3].z)/p:!1,t:s}},derive:function(s,o){let e=[];for(let r=s,n=r.length,i=n-1;n>1;n--,i--){let a=[];for(let l=0,c;l<i;l++)c={x:i*(r[l+1].x-r[l].x),y:i*(r[l+1].y-r[l].y)},o&&(c.z=i*(r[l+1].z-r[l].z)),a.push(c);e.push(a),r=a}return e},between:function(s,o,e){return o<=s&&s<=e||B.approximately(s,o)||B.approximately(s,e)},approximately:function(s,o,e){return wo(s-o)<=(e||fa)},length:function(s){let e=B.Tvalues.length,r=0;for(let n=0,i;n<e;n++)i=.5*B.Tvalues[n]+.5,r+=B.Cvalues[n]*B.arcfn(i,s);return .5*r},map:function(s,o,e,r,n){let i=e-o,a=n-r,l=s-o,c=l/i;return r+a*c},lerp:function(s,o,e){let r={x:o.x+s*(e.x-o.x),y:o.y+s*(e.y-o.y)};return o.z!==void 0&&e.z!==void 0&&(r.z=o.z+s*(e.z-o.z)),r},pointToString:function(s){let o=s.x+"/"+s.y;return typeof s.z<"u"&&(o+="/"+s.z),o},pointsToString:function(s){return"["+s.map(B.pointToString).join(", ")+"]"},copy:function(s){return JSON.parse(JSON.stringify(s))},angle:function(s,o,e){let r=o.x-s.x,n=o.y-s.y,i=e.x-s.x,a=e.y-s.y,l=r*a-n*i,c=r*i+n*a;return Co(l,c)},round:function(s,o){let e=""+s,r=e.indexOf(".");return parseFloat(e.substring(0,r+1+o))},dist:function(s,o){let e=s.x-o.x,r=s.y-o.y;return ct(e*e+r*r)},closest:function(s,o){let e=Me(2,63),r,n;return s.forEach(function(i,a){n=B.dist(o,i),n<e&&(e=n,r=a)}),{mdist:e,mpos:r}},abcratio:function(s,o){if(o!==2&&o!==3)return!1;if(typeof s>"u")s=.5;else if(s===0||s===1)return s;let e=Me(s,o)+Me(1-s,o),r=e-1;return wo(r/e)},projectionratio:function(s,o){if(o!==2&&o!==3)return!1;if(typeof s>"u")s=.5;else if(s===0||s===1)return s;let e=Me(1-s,o),r=Me(s,o)+e;return e/r},lli8:function(s,o,e,r,n,i,a,l){let c=(s*r-o*e)*(n-a)-(s-e)*(n*l-i*a),d=(s*r-o*e)*(i-l)-(o-r)*(n*l-i*a),u=(s-e)*(i-l)-(o-r)*(n-a);return u==0?!1:{x:c/u,y:d/u}},lli4:function(s,o,e,r){let n=s.x,i=s.y,a=o.x,l=o.y,c=e.x,d=e.y,u=r.x,p=r.y;return B.lli8(n,i,a,l,c,d,u,p)},lli:function(s,o){return B.lli4(s,s.c,o,o.c)},makeline:function(s,o){return new Jt(s.x,s.y,(s.x+o.x)/2,(s.y+o.y)/2,o.x,o.y)},findbbox:function(s){let o=Tn,e=Tn,r=Sn,n=Sn;return s.forEach(function(i){let a=i.bbox();o>a.x.min&&(o=a.x.min),e>a.y.min&&(e=a.y.min),r<a.x.max&&(r=a.x.max),n<a.y.max&&(n=a.y.max)}),{x:{min:o,mid:(o+r)/2,max:r,size:r-o},y:{min:e,mid:(e+n)/2,max:n,size:n-e}}},shapeintersections:function(s,o,e,r,n){if(!B.bboxoverlap(o,r))return[];let i=[],a=[s.startcap,s.forward,s.back,s.endcap],l=[e.startcap,e.forward,e.back,e.endcap];return a.forEach(function(c){c.virtual||l.forEach(function(d){if(d.virtual)return;let u=c.intersects(d,n);u.length>0&&(u.c1=c,u.c2=d,u.s1=s,u.s2=e,i.push(u))})}),i},makeshape:function(s,o,e){let r=o.points.length,n=s.points.length,i=B.makeline(o.points[r-1],s.points[0]),a=B.makeline(s.points[n-1],o.points[0]),l={startcap:i,forward:s,back:o,endcap:a,bbox:B.findbbox([i,s,o,a])};return l.intersections=function(c){return B.shapeintersections(l,l.bbox,c,c.bbox,e)},l},getminmax:function(s,o,e){if(!e)return{min:0,max:0};let r=Tn,n=Sn,i,a;e.indexOf(0)===-1&&(e=[0].concat(e)),e.indexOf(1)===-1&&e.push(1);for(let l=0,c=e.length;l<c;l++)i=e[l],a=s.get(i),a[o]<r&&(r=a[o]),a[o]>n&&(n=a[o]);return{min:r,mid:(r+n)/2,max:n,size:n-r}},align:function(s,o){let e=o.p1.x,r=o.p1.y,n=-Co(o.p2.y-r,o.p2.x-e),i=function(a){return{x:(a.x-e)*Ze(n)-(a.y-r)*Qt(n),y:(a.x-e)*Qt(n)+(a.y-r)*Ze(n)}};return s.map(i)},roots:function(s,o){o=o||{p1:{x:0,y:0},p2:{x:1,y:0}};let e=s.length-1,r=B.align(s,o),n=function(C){return 0<=C&&C<=1};if(e===2){let C=r[0].y,V=r[1].y,O=r[2].y,G=C-2*V+O;if(G!==0){let se=-ct(V*V-C*O),oe=-C+V,fe=-(se+oe)/G,Se=-(-se+oe)/G;return[fe,Se].filter(n)}else if(V!==O&&G===0)return[(2*V-O)/(2*V-2*O)].filter(n);return[]}let i=r[0].y,a=r[1].y,l=r[2].y,c=r[3].y,d=-i+3*a-3*l+c,u=3*i-6*a+3*l,p=-3*i+3*a,h=i;if(B.approximately(d,0)){if(B.approximately(u,0))return B.approximately(p,0)?[]:[-h/p].filter(n);let C=ct(p*p-4*u*h),V=2*u;return[(C-p)/V,(-p-C)/V].filter(n)}u/=d,p/=d,h/=d;let m=(3*p-u*u)/3,g=m/3,v=(2*u*u*u-9*u*p+27*h)/27,b=v/2,y=b*b+g*g*g,f,T,P,S,E;if(y<0){let C=-m/3,V=C*C*C,O=ct(V),G=-v/(2*O),se=G<-1?-1:G>1?1:G,oe=ma(se),fe=To(O),Se=2*fe;return P=Se*Ze(oe/3)-u/3,S=Se*Ze((oe+pr)/3)-u/3,E=Se*Ze((oe+2*pr)/3)-u/3,[P,S,E].filter(n)}else{if(y===0)return f=b<0?To(-b):-To(b),P=2*f-u/3,S=-f-u/3,[P,S].filter(n);{let C=ct(y);return f=To(-b+C),T=To(b+C),[f-T-u/3].filter(n)}}},droots:function(s){if(s.length===3){let o=s[0],e=s[1],r=s[2],n=o-2*e+r;if(n!==0){let i=-ct(e*e-o*r),a=-o+e,l=-(i+a)/n,c=-(-i+a)/n;return[l,c]}else if(e!==r&&n===0)return[(2*e-r)/(2*(e-r))];return[]}if(s.length===2){let o=s[0],e=s[1];return o!==e?[o/(o-e)]:[]}return[]},curvature:function(s,o,e,r,n){let i,a,l,c,d=0,u=0,p=B.compute(s,o),h=B.compute(s,e),m=p.x*p.x+p.y*p.y;if(r?(i=ct(Me(p.y*h.z-h.y*p.z,2)+Me(p.z*h.x-h.z*p.x,2)+Me(p.x*h.y-h.x*p.y,2)),a=Me(m+p.z*p.z,3/2)):(i=p.x*h.y-p.y*h.x,a=Me(m,3/2)),i===0||a===0)return{k:0,r:0};if(d=i/a,u=a/i,!n){let g=B.curvature(s-.001,o,e,r,!0).k,v=B.curvature(s+.001,o,e,r,!0).k;c=(v-d+(d-g))/2,l=(wo(v-d)+wo(d-g))/2}return{k:d,r:u,dk:c,adk:l}},inflections:function(s){if(s.length<4)return[];let o=B.align(s,{p1:s[0],p2:s.slice(-1)[0]}),e=o[2].x*o[1].y,r=o[3].x*o[1].y,n=o[1].x*o[2].y,i=o[3].x*o[2].y,a=18*(-3*e+2*r+3*n-i),l=18*(3*e-r-3*n),c=18*(n-e);if(B.approximately(a,0)){if(!B.approximately(l,0)){let h=-c/l;if(0<=h&&h<=1)return[h]}return[]}let d=2*a;if(B.approximately(d,0))return[];let u=l*l-4*a*c;if(u<0)return[];let p=Math.sqrt(u);return[(p-l)/d,-(l+p)/d].filter(function(h){return 0<=h&&h<=1})},bboxoverlap:function(s,o){let e=["x","y"],r=e.length;for(let n=0,i,a,l,c;n<r;n++)if(i=e[n],a=s[i].mid,l=o[i].mid,c=(s[i].size+o[i].size)/2,wo(a-l)>=c)return!1;return!0},expandbox:function(s,o){o.x.min<s.x.min&&(s.x.min=o.x.min),o.y.min<s.y.min&&(s.y.min=o.y.min),o.z&&o.z.min<s.z.min&&(s.z.min=o.z.min),o.x.max>s.x.max&&(s.x.max=o.x.max),o.y.max>s.y.max&&(s.y.max=o.y.max),o.z&&o.z.max>s.z.max&&(s.z.max=o.z.max),s.x.mid=(s.x.min+s.x.max)/2,s.y.mid=(s.y.min+s.y.max)/2,s.z&&(s.z.mid=(s.z.min+s.z.max)/2),s.x.size=s.x.max-s.x.min,s.y.size=s.y.max-s.y.min,s.z&&(s.z.size=s.z.max-s.z.min)},pairiteration:function(s,o,e){let r=s.bbox(),n=o.bbox(),i=1e5,a=e||.5;if(r.x.size+r.y.size<a&&n.x.size+n.y.size<a)return[(i*(s._t1+s._t2)/2|0)/i+"/"+(i*(o._t1+o._t2)/2|0)/i];let l=s.split(.5),c=o.split(.5),d=[{left:l.left,right:c.left},{left:l.left,right:c.right},{left:l.right,right:c.right},{left:l.right,right:c.left}];d=d.filter(function(p){return B.bboxoverlap(p.left.bbox(),p.right.bbox())});let u=[];return d.length===0||(d.forEach(function(p){u=u.concat(B.pairiteration(p.left,p.right,a))}),u=u.filter(function(p,h){return u.indexOf(p)===h})),u},getccenter:function(s,o,e){let r=o.x-s.x,n=o.y-s.y,i=e.x-o.x,a=e.y-o.y,l=r*Ze(dt)-n*Qt(dt),c=r*Qt(dt)+n*Ze(dt),d=i*Ze(dt)-a*Qt(dt),u=i*Qt(dt)+a*Ze(dt),p=(s.x+o.x)/2,h=(s.y+o.y)/2,m=(o.x+e.x)/2,g=(o.y+e.y)/2,v=p+l,b=h+c,y=m+d,f=g+u,T=B.lli8(p,h,v,b,m,g,y,f),P=B.dist(T,s),S=Co(s.y-T.y,s.x-T.x),E=Co(o.y-T.y,o.x-T.x),C=Co(e.y-T.y,e.x-T.x),V;return S<C?((S>E||E>C)&&(S+=pr),S>C&&(V=C,C=S,S=V)):C<E&&E<S?(V=C,C=S,S=V):C+=pr,T.s=S,T.e=C,T.r=P,T},numberSort:function(s,o){return s-o}};var eo=class s{constructor(o){this.curves=[],this._3d=!1,o&&(this.curves=o,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(o){return B.pointsToString(o.points)}).join(", ")+"]"}addCurve(o){this.curves.push(o),this._3d=this._3d||o._3d}length(){return this.curves.map(function(o){return o.length()}).reduce(function(o,e){return o+e})}curve(o){return this.curves[o]}bbox(){let o=this.curves;for(var e=o[0].bbox(),r=1;r<o.length;r++)B.expandbox(e,o[r].bbox());return e}offset(o){let e=[];return this.curves.forEach(function(r){e.push(...r.offset(o))}),new s(e)}};var{abs:So,min:Vi,max:Oi,cos:ba,sin:va,acos:ya,sqrt:Po}=Math,xa=Math.PI;var Jt=class s{constructor(o){let e=o&&o.forEach?o:Array.from(arguments).slice(),r=!1;if(typeof e[0]=="object"){r=e.length;let m=[];e.forEach(function(g){["x","y","z"].forEach(function(v){typeof g[v]<"u"&&m.push(g[v])})}),e=m}let n=!1,i=e.length;if(r){if(r>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");n=!0}}else if(i!==6&&i!==8&&i!==9&&i!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");let a=this._3d=!n&&(i===9||i===12)||o&&o[0]&&typeof o[0].z<"u",l=this.points=[];for(let m=0,g=a?3:2;m<i;m+=g){var c={x:e[m],y:e[m+1]};a&&(c.z=e[m+2]),l.push(c)}let d=this.order=l.length-1,u=this.dims=["x","y"];a&&u.push("z"),this.dimlen=u.length;let p=B.align(l,{p1:l[0],p2:l[d]}),h=B.dist(l[0],l[d]);this._linear=p.reduce((m,g)=>m+So(g.y),0)<h/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(o,e,r,n){if(typeof n>"u"&&(n=.5),n===0)return new s(e,e,r);if(n===1)return new s(o,e,e);let i=s.getABC(2,o,e,r,n);return new s(o,i.A,r)}static cubicFromPoints(o,e,r,n,i){typeof n>"u"&&(n=.5);let a=s.getABC(3,o,e,r,n);typeof i>"u"&&(i=B.dist(e,a.C));let l=i*(1-n)/n,c=B.dist(o,r),d=(r.x-o.x)/c,u=(r.y-o.y)/c,p=i*d,h=i*u,m=l*d,g=l*u,v={x:e.x-p,y:e.y-h},b={x:e.x+m,y:e.y+g},y=a.A,f={x:y.x+(v.x-y.x)/(1-n),y:y.y+(v.y-y.y)/(1-n)},T={x:y.x+(b.x-y.x)/n,y:y.y+(b.y-y.y)/n},P={x:o.x+(f.x-o.x)/n,y:o.y+(f.y-o.y)/n},S={x:r.x+(T.x-r.x)/(1-n),y:r.y+(T.y-r.y)/(1-n)};return new s(o,P,S,r)}static getUtils(){return B}getUtils(){return s.getUtils()}static get PolyBezier(){return eo}valueOf(){return this.toString()}toString(){return B.pointsToString(this.points)}toSVG(){if(this._3d)return!1;let o=this.points,e=o[0].x,r=o[0].y,n=["M",e,r,this.order===2?"Q":"C"];for(let i=1,a=o.length;i<a;i++)n.push(o[i].x),n.push(o[i].y);return n.join(" ")}setRatios(o){if(o.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=o,this._lut=[]}verify(){let o=this.coordDigest();o!==this._print&&(this._print=o,this.update())}coordDigest(){return this.points.map(function(o,e){return""+e+o.x+o.y+(o.z?o.z:0)}).join("")}update(){this._lut=[],this.dpoints=B.derive(this.points,this._3d),this.computedirection()}computedirection(){let o=this.points,e=B.angle(o[0],o[this.order],o[1]);this.clockwise=e>0}length(){return B.length(this.derivative.bind(this))}static getABC(o=2,e,r,n,i=.5){let a=B.projectionratio(i,o),l=1-a,c={x:a*e.x+l*n.x,y:a*e.y+l*n.y},d=B.abcratio(i,o);return{A:{x:r.x+(r.x-c.x)/d,y:r.y+(r.y-c.y)/d},B:r,C:c,S:e,E:n}}getABC(o,e){e=e||this.get(o);let r=this.points[0],n=this.points[this.order];return s.getABC(this.order,r,e,n,o)}getLUT(o){if(this.verify(),o=o||100,this._lut.length===o+1)return this._lut;this._lut=[],o++,this._lut=[];for(let e=0,r,n;e<o;e++)n=e/(o-1),r=this.compute(n),r.t=n,this._lut.push(r);return this._lut}on(o,e){e=e||5;let r=this.getLUT(),n=[];for(let i=0,a,l=0;i<r.length;i++)a=r[i],B.dist(a,o)<e&&(n.push(a),l+=i/r.length);return n.length?t/=n.length:!1}project(o){let e=this.getLUT(),r=e.length-1,n=B.closest(e,o),i=n.mpos,a=(i-1)/r,l=(i+1)/r,c=.1/r,d=n.mdist,u=a,p=u,h;d+=1;for(let m;u<l+c;u+=c)h=this.compute(u),m=B.dist(o,h),m<d&&(d=m,p=u);return p=p<0?0:p>1?1:p,h=this.compute(p),h.t=p,h.d=d,h}get(o){return this.compute(o)}point(o){return this.points[o]}compute(o){return this.ratios?B.computeWithRatios(o,this.points,this.ratios,this._3d):B.compute(o,this.points,this._3d,this.ratios)}raise(){let o=this.points,e=[o[0]],r=o.length;for(let n=1,i,a;n<r;n++)i=o[n],a=o[n-1],e[n]={x:(r-n)/r*i.x+n/r*a.x,y:(r-n)/r*i.y+n/r*a.y};return e[r]=o[r-1],new s(e)}derivative(o){return B.compute(o,this.dpoints[0],this._3d)}dderivative(o){return B.compute(o,this.dpoints[1],this._3d)}align(){let o=this.points;return new s(B.align(o,{p1:o[0],p2:o[o.length-1]}))}curvature(o){return B.curvature(o,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return B.inflections(this.points)}normal(o){return this._3d?this.__normal3(o):this.__normal2(o)}__normal2(o){let e=this.derivative(o),r=Po(e.x*e.x+e.y*e.y);return{t:o,x:-e.y/r,y:e.x/r}}__normal3(o){let e=this.derivative(o),r=this.derivative(o+.01),n=Po(e.x*e.x+e.y*e.y+e.z*e.z),i=Po(r.x*r.x+r.y*r.y+r.z*r.z);e.x/=n,e.y/=n,e.z/=n,r.x/=i,r.y/=i,r.z/=i;let a={x:r.y*e.z-r.z*e.y,y:r.z*e.x-r.x*e.z,z:r.x*e.y-r.y*e.x},l=Po(a.x*a.x+a.y*a.y+a.z*a.z);a.x/=l,a.y/=l,a.z/=l;let c=[a.x*a.x,a.x*a.y-a.z,a.x*a.z+a.y,a.x*a.y+a.z,a.y*a.y,a.y*a.z-a.x,a.x*a.z-a.y,a.y*a.z+a.x,a.z*a.z];return{t:o,x:c[0]*e.x+c[1]*e.y+c[2]*e.z,y:c[3]*e.x+c[4]*e.y+c[5]*e.z,z:c[6]*e.x+c[7]*e.y+c[8]*e.z}}hull(o){let e=this.points,r=[],n=[],i=0;for(n[i++]=e[0],n[i++]=e[1],n[i++]=e[2],this.order===3&&(n[i++]=e[3]);e.length>1;){r=[];for(let a=0,l,c=e.length-1;a<c;a++)l=B.lerp(o,e[a],e[a+1]),n[i++]=l,r.push(l);e=r}return n}split(o,e){if(o===0&&e)return this.split(e).left;if(e===1)return this.split(o).right;let r=this.hull(o),n={left:this.order===2?new s([r[0],r[3],r[5]]):new s([r[0],r[4],r[7],r[9]]),right:this.order===2?new s([r[5],r[4],r[2]]):new s([r[9],r[8],r[6],r[3]]),span:r};return n.left._t1=B.map(0,0,1,this._t1,this._t2),n.left._t2=B.map(o,0,1,this._t1,this._t2),n.right._t1=B.map(o,0,1,this._t1,this._t2),n.right._t2=B.map(1,0,1,this._t1,this._t2),e?(e=B.map(e,o,1,0,1),n.right.split(e).left):n}extrema(){let o={},e=[];return this.dims.forEach(function(r){let n=function(a){return a[r]},i=this.dpoints[0].map(n);o[r]=B.droots(i),this.order===3&&(i=this.dpoints[1].map(n),o[r]=o[r].concat(B.droots(i))),o[r]=o[r].filter(function(a){return a>=0&&a<=1}),e=e.concat(o[r].sort(B.numberSort))}.bind(this)),o.values=e.sort(B.numberSort).filter(function(r,n){return e.indexOf(r)===n}),o}bbox(){let o=this.extrema(),e={};return this.dims.forEach(function(r){e[r]=B.getminmax(this,r,o[r])}.bind(this)),e}overlaps(o){let e=this.bbox(),r=o.bbox();return B.bboxoverlap(e,r)}offset(o,e){if(typeof e<"u"){let r=this.get(o),n=this.normal(o),i={c:r,n,x:r.x+n.x*e,y:r.y+n.y*e};return this._3d&&(i.z=r.z+n.z*e),i}if(this._linear){let r=this.normal(0),n=this.points.map(function(i){let a={x:i.x+o*r.x,y:i.y+o*r.y};return i.z&&r.z&&(a.z=i.z+o*r.z),a});return[new s(n)]}return this.reduce().map(function(r){return r._linear?r.offset(o)[0]:r.scale(o)})}simple(){if(this.order===3){let n=B.angle(this.points[0],this.points[3],this.points[1]),i=B.angle(this.points[0],this.points[3],this.points[2]);if(n>0&&i<0||n<0&&i>0)return!1}let o=this.normal(0),e=this.normal(1),r=o.x*e.x+o.y*e.y;return this._3d&&(r+=o.z*e.z),So(ya(r))<xa/3}reduce(){let o,e=0,r=0,n=.01,i,a=[],l=[],c=this.extrema().values;for(c.indexOf(0)===-1&&(c=[0].concat(c)),c.indexOf(1)===-1&&c.push(1),e=c[0],o=1;o<c.length;o++)r=c[o],i=this.split(e,r),i._t1=e,i._t2=r,a.push(i),e=r;return a.forEach(function(d){for(e=0,r=0;r<=1;)for(r=e+n;r<=1+n;r+=n)if(i=d.split(e,r),!i.simple()){if(r-=n,So(e-r)<n)return[];i=d.split(e,r),i._t1=B.map(e,0,1,d._t1,d._t2),i._t2=B.map(r,0,1,d._t1,d._t2),l.push(i),e=r;break}e<1&&(i=d.split(e,1),i._t1=B.map(e,0,1,d._t1,d._t2),i._t2=d._t2,l.push(i))}),l}translate(o,e,r){r=typeof r=="number"?r:e;let n=this.order,i=this.points.map((a,l)=>(1-l/n)*e+l/n*r);return new s(this.points.map((a,l)=>({x:a.x+o.x*i[l],y:a.y+o.y*i[l]})))}scale(o){let e=this.order,r=!1;if(typeof o=="function"&&(r=o),r&&e===2)return this.raise().scale(r);let n=this.clockwise,i=this.points;if(this._linear)return this.translate(this.normal(0),r?r(0):o,r?r(1):o);let a=r?r(0):o,l=r?r(1):o,c=[this.offset(0,10),this.offset(1,10)],d=[],u=B.lli4(c[0],c[0].c,c[1],c[1].c);if(!u)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(p){let h=d[p*e]=B.copy(i[p*e]);h.x+=(p?l:a)*c[p].n.x,h.y+=(p?l:a)*c[p].n.y}),r?([0,1].forEach(function(p){if(!(e===2&&p)){var h=i[p+1],m={x:h.x-u.x,y:h.y-u.y},g=r?r((p+1)/e):o;r&&!n&&(g=-g);var v=Po(m.x*m.x+m.y*m.y);m.x/=v,m.y/=v,d[p+1]={x:h.x+g*m.x,y:h.y+g*m.y}}}),new s(d)):([0,1].forEach(p=>{if(e===2&&p)return;let h=d[p*e],m=this.derivative(p),g={x:h.x+m.x,y:h.y+m.y};d[p+1]=B.lli4(h,g,u,i[p+1])}),new s(d))}outline(o,e,r,n){if(e=e===void 0?o:e,this._linear){let S=this.normal(0),E=this.points[0],C=this.points[this.points.length-1],V,O,G;r===void 0&&(r=o,n=e),V={x:E.x+S.x*o,y:E.y+S.y*o},G={x:C.x+S.x*r,y:C.y+S.y*r},O={x:(V.x+G.x)/2,y:(V.y+G.y)/2};let se=[V,O,G];V={x:E.x-S.x*e,y:E.y-S.y*e},G={x:C.x-S.x*n,y:C.y-S.y*n},O={x:(V.x+G.x)/2,y:(V.y+G.y)/2};let oe=[G,O,V],fe=B.makeline(oe[2],se[0]),Se=B.makeline(se[2],oe[0]),de=[fe,new s(se),Se,new s(oe)];return new eo(de)}let i=this.reduce(),a=i.length,l=[],c=[],d,u=0,p=this.length(),h=typeof r<"u"&&typeof n<"u";function m(S,E,C,V,O){return function(G){let se=V/C,oe=(V+O)/C,fe=E-S;return B.map(G,0,1,S+se*fe,S+oe*fe)}}i.forEach(function(S){let E=S.length();h?(l.push(S.scale(m(o,r,p,u,E))),c.push(S.scale(m(-e,-n,p,u,E)))):(l.push(S.scale(o)),c.push(S.scale(-e))),u+=E}),c=c.map(function(S){return d=S.points,d[3]?S.points=[d[3],d[2],d[1],d[0]]:S.points=[d[2],d[1],d[0]],S}).reverse();let g=l[0].points[0],v=l[a-1].points[l[a-1].points.length-1],b=c[a-1].points[c[a-1].points.length-1],y=c[0].points[0],f=B.makeline(b,g),T=B.makeline(v,y),P=[f].concat(l).concat([T]).concat(c);return new eo(P)}outlineshapes(o,e,r){e=e||o;let n=this.outline(o,e).curves,i=[];for(let a=1,l=n.length;a<l/2;a++){let c=B.makeshape(n[a],n[l-a],r);c.startcap.virtual=a>1,c.endcap.virtual=a<l/2-1,i.push(c)}return i}intersects(o,e){return o?o.p1&&o.p2?this.lineIntersects(o):(o instanceof s&&(o=o.reduce()),this.curveintersects(this.reduce(),o,e)):this.selfintersects(e)}lineIntersects(o){let e=Vi(o.p1.x,o.p2.x),r=Vi(o.p1.y,o.p2.y),n=Oi(o.p1.x,o.p2.x),i=Oi(o.p1.y,o.p2.y);return B.roots(this.points,o).filter(a=>{var l=this.get(a);return B.between(l.x,e,n)&&B.between(l.y,r,i)})}selfintersects(o){let e=this.reduce(),r=e.length-2,n=[];for(let i=0,a,l,c;i<r;i++)l=e.slice(i,i+1),c=e.slice(i+2),a=this.curveintersects(l,c,o),n.push(...a);return n}curveintersects(o,e,r){let n=[];o.forEach(function(a){e.forEach(function(l){a.overlaps(l)&&n.push({left:a,right:l})})});let i=[];return n.forEach(function(a){let l=B.pairiteration(a.left,a.right,r);l.length>0&&(i=i.concat(l))}),i}arcs(o){return o=o||.5,this._iterate(o,[])}_error(o,e,r,n){let i=(n-r)/4,a=this.get(r+i),l=this.get(n-i),c=B.dist(o,e),d=B.dist(o,a),u=B.dist(o,l);return So(d-c)+So(u-c)}_iterate(o,e){let r=0,n=1,i;do{i=0,n=1;let a=this.get(r),l,c,d,u,p=!1,h=!1,m,g=n,v=1,b=0;do if(h=p,u=d,g=(r+n)/2,b++,l=this.get(g),c=this.get(n),d=B.getccenter(a,l,c),d.interval={start:r,end:n},p=this._error(d,a,r,n)<=o,m=h&&!p,m||(v=n),p){if(n>=1){if(d.interval.end=v=1,u=d,n>1){let f={x:d.x+d.r*ba(d.e),y:d.y+d.r*va(d.e)};d.e+=B.angle({x:d.x,y:d.y},f,this.get(1))}break}n=n+(n-r)/2}else n=g;while(!m&&i++<100);if(i>=100)break;u=u||d,e.push(u),r=v}while(n<1);return e}};var hr=class extends Xt{#e=null;constructor(o){super(),o&&(this.#e=o)}getBezier(){return this.#e||(this.#e=new Jt(this.getPoints().map(o=>o.xy))),this.#e}signedDistance(o){return this.nearestPointTo(o).point.distanceTo(o)}distance(o){return this.signedDistance(o)}at(o){return w.ofXY(this.getBezier().get(o))}derivativeAt(o){return w.ofXY(this.getBezier().derivative(o))}secondDerivativeAt(o){return w.ofXY(this.getBezier().dderivative(o))}normal(o){return w.ofXY(this.getBezier().normal(o))}normalAt(o){return this.normal(o)}tangentAt(o){return this.derivativeAt(o).normalized()}getTightBoundingBox(){let o=this.getBezier().bbox(),e=o.x.max-o.x.min,r=o.y.max-o.y.min;return new he(o.x.min,o.y.min,e,r)}argIntersectsLineSegment(o){let e=Be.ofSmallestContainingPoints(this.getPoints());return e?e.intersectsLineSegment(o).map(i=>this.nearestPointTo(i).parameterValue):this.getBezier().intersects(o).map(n=>{typeof n=="string"&&(n=parseFloat(n));let i=w.ofXY(this.at(n));return i.distanceTo(o.p1)>o.length||i.distanceTo(o.p2)>o.length?null:n}).filter(n=>n!==null)}splitAt(o){if(o<=0||o>=1)return[this];let r=this.getBezier().split(o);return[new mr(r.left.points.map(n=>w.ofXY(n)),r.left),new mr(r.right.points.map(n=>w.ofXY(n)),r.right)]}nearestPointTo(o){let e=u=>o.squareDistanceTo(this.at(u)),r=e(0),n=0,i=r,a=4;for(let u=0;u<a;u++){let p=u/(a-1),h=e(p);h<i&&(n=p,i=h)}let l=u=>{let p=this.at(u),h=this.derivativeAt(u),m=this.secondDerivativeAt(u);return 2*h.x*h.x+2*p.x*m.x-2*o.x*m.x+2*h.y*h.y+2*p.y*m.y-2*o.y*m.y},c=u=>{let p=this.at(u),h=this.derivativeAt(u);return 2*p.x*h.x-2*o.x*h.x+2*p.y*h.y-2*o.y*h.y},d=()=>{let u=l(n);if(u===0)return;n=(0-c(n))/u+n,n>1?n=1:n<0&&(n=0)};for(let u=0;u<12;u++)d();return{parameterValue:n,point:this.at(n)}}intersectsBezier(o){let e=this.getBezier().intersects(o.getBezier());if(!e||e.length===0)return[];let r=[];for(let n of e){let i=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(n);if(!i)throw new Error(`Incorrect format returned by .intersects: ${e} should be array of "number/number"!`);let a=parseFloat(i[1]);r.push({parameterValue:a,point:this.at(a)})}return r}toString(){return`B\xE9zier(${this.getPoints().map(o=>o.toString()).join(", ")})`}},mr=class extends hr{constructor(e,r){super(r);this.controlPoints=e}getPoints(){return this.controlPoints}},fr=hr;var Pn=class extends fr{constructor(e,r,n,i){super();this.p0=e;this.p1=r;this.p2=n;this.p3=i}getPoints(){return[this.p0,this.p1,this.p2,this.p3]}getLooseBoundingBox(){return he.bboxOf([this.p0,this.p1,this.p2,this.p3])}},Fi=Pn;var wa=(s,o,e)=>{if(s===0){let l;return o===0?l=e===0?0:NaN:l=-e/o,[l,l]}let r=o*o-4*s*e;if(r<0)return[NaN,NaN];let n=Math.sqrt(r),i=(-o+n)/(2*s),a=(-o-n)/(2*s);return i>a?[i,a]:[a,i]},Hi=wa;var De=class s extends fr{constructor(e,r,n){super();this.p0=e;this.p1=r;this.p2=n}static componentAt(e,r,n,i){return r+e*(-2*r+2*n)+e*e*(r-2*n+i)}static derivativeComponentAt(e,r,n,i){return-2*r+2*n+2*e*(r-2*n+i)}static secondDerivativeComponentAt(e,r,n,i){return 2*(r-2*n+i)}at(e){if(e===0)return this.p0;if(e===1)return this.p2;let r=this.p0,n=this.p1,i=this.p2;return w.of(s.componentAt(e,r.x,n.x,i.x),s.componentAt(e,r.y,n.y,i.y))}derivativeAt(e){let r=this.p0,n=this.p1,i=this.p2;return w.of(s.derivativeComponentAt(e,r.x,n.x,i.x),s.derivativeComponentAt(e,r.y,n.y,i.y))}secondDerivativeAt(e){let r=this.p0,n=this.p1,i=this.p2;return w.of(s.secondDerivativeComponentAt(e,r.x,n.x,i.x),s.secondDerivativeComponentAt(e,r.y,n.y,i.y))}normal(e){return this.derivativeAt(e).orthog().normalized()}getLooseBoundingBox(){return he.bboxOf([this.p0,this.p1,this.p2])}approximateDistance(e){let r=this.p0.x-e.x,n=-2*this.p0.x+2*this.p1.x,i=this.p0.x-2*this.p1.x+this.p2.x,a=this.p0.y-e.y,l=-2*this.p0.y+2*this.p1.y,c=this.p0.y-2*this.p1.y+this.p2.y,d=2*r*n+2*a*l-e.x*n-e.y*l,u=2*n*n+2*l*l+2*i*r+2*c*a-e.x*i-e.y*c,p=2*l*c+2*n*i+2*i*n+2*c*l,h=d,m=u,g=2*p,[v,b]=Hi(g/2,m,h);isNaN(v)&&(v=.25),isNaN(b)&&(b=.75);let y=this.at(v),f=this.at(b),T=y.squareDistanceTo(e),P=f.squareDistanceTo(e),S=this.at(0).squareDistanceTo(e),E=this.at(1).squareDistanceTo(e);return Math.sqrt(Math.min(T,P,S,E))}getPoints(){return[this.p0,this.p1,this.p2]}},Ni=De;var En=class extends Xt{constructor(e){super();this.p=e}signedDistance(e){return this.p.distanceTo(e)}argIntersectsLineSegment(e,r){return e.containsPoint(this.p,r)?[0]:[]}getTightBoundingBox(){return new he(this.p.x,this.p.y,0,0)}at(e){return this.p}normalAt(e){return w.unitY}tangentAt(e){return w.unitX}splitAt(e){return[this]}nearestPointTo(e){return{point:this.p,parameterValue:0}}},$i=En;var Ca=s=>{if(s.indexOf("e")>0&&s.match(/[eE][-]\d{2,}$/))return"0";let o=s.charAt(s.length-1);(o==="0"||o===".")&&(s=s.replace(/([.]\d*[^0])0+$/,"$1"),s=s.replace(/[.]0+$/,"."),s=s.replace(/[.]$/,""));let e=s.charAt(0);return(e==="0"||e==="-")&&(s=s.replace(/^(0+)[.]/,"."),s=s.replace(/^-(0+)[.]/,"-."),s=s.replace(/^(-?)0+$/,"$10")),s==="-0"?"0":s},gr=Ca;var pe=s=>{let o=/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,e=/^([-]?)(\d*)\.(\d{3,}9{4,})\d{1,4}$/,r=s.toString(10);if(r.indexOf(".")===-1)return r;let n=e.exec(r);if(n){let i=n[1],a=n[3],l=parseInt(a.charAt(a.length-1),10),c=parseInt(a,10),d=parseInt(n[2],10),u=n[3],p=(c+10-l).toString(),h=0;for(p.length>c.toString().length&&(p=p.substring(1),h=1);p.length<u.length;)p=h.toString(10)+p,h=0;r=`${i+(d+h).toString()}.${p}`}return r=r.replace(o,"$1"),gr(r)},wt=pe;var br=/^([-]?)(\d*)[.](\d+)$/;var Ta=s=>{let o=br.exec(s);return o?o[3].length:s.search(/[eE]/)!==-1||/^[a-zA-Z]+$/.exec(s)?-1:0},Ui=Ta;var Sa=(s,...o)=>{let e=s.toString(10),r=br.exec(e);if(!r)return e;let n=-1;for(let d of o)n=Math.max(Ui(d),n);if(n===-1)return wt(s);let i=r[3].substring(0,n),a=r[2],l=r[3].charAt(n);if(l!==""&&parseInt(l,10)>=5){if(i.length>0){let u=/^(0+)(\d*)$/.exec(i),p="",h=i;u&&(p=u[1],h=u[2]),i=(parseInt(i)+1).toString(),i.length>h.length&&p.length>0&&(p=p.substring(1)),i=p+i}(i.length===0||i.length>n)&&(a=(parseInt(a)+1).toString(),i=i.substring(1))}let c=r[1];return gr(`${c}${a}.${i}`)},kn=Sa;var Pa=s=>{if(s.length===0)return[];let o=s.reduce((i,a)=>a.y<i.y?a:i,s[0]),e=[o],r=[...s.filter(i=>!i.eq(o))],n=w.of(-1,0);for(;r.length>0;){let i=e[e.length-1],a=n.dot(o.minus(i).normalizedOrZero()),l=o;for(let d of r){let u=n.dot(d.minus(i).normalizedOrZero());u<=a&&(l=d,a=u)}r=r.filter(d=>!d.eq(l));let c=l.minus(i).normalized();if(Math.abs(c.dot(n))===1&&e.length>1&&e.pop(),l.eq(o))break;e.push(l),n=i.minus(l).normalized()}return e},Wi=Pa;var we=(n=>(n[n.LineTo=0]="LineTo",n[n.MoveTo=1]="MoveTo",n[n.CubicBezierTo=2]="CubicBezierTo",n[n.QuadraticBezierTo=3]="QuadraticBezierTo",n))(we||{}),Eo=(s,o)=>{let e=s.curveIndex-o.curveIndex;return e===0?s.parameterValue-o.parameterValue:e},vr=(s,o)=>s.parameterValue+o>1?{curveIndex:s.curveIndex+1,parameterValue:s.parameterValue+o-1}:s.parameterValue+o<0?s.curveIndex===0?{curveIndex:0,parameterValue:0}:{curveIndex:s.curveIndex-1,parameterValue:s.parameterValue+o+1}:{curveIndex:s.curveIndex,parameterValue:s.parameterValue+o},$=class s{constructor(o,e){this.startPoint=o;this.cachedGeometry=null;this.cachedPolylineApproximation=null;this.cachedStringVersion=null;this.parts=e,this.bbox=he.bboxOf([o]);for(let r of this.parts)this.bbox=this.bbox.union(s.computeBBoxForSegment(o,r))}getExactBBox(){let o=[];for(let e of this.geometry)o.push(e.getTightBoundingBox());return he.union(...o)}get geometry(){if(this.cachedGeometry)return this.cachedGeometry;let o=this.startPoint,e=[];for(let r of this.parts){let n;switch(r.kind){case 2:e.push(new Fi(o,r.controlPoint1,r.controlPoint2,r.endPoint)),o=r.endPoint;break;case 3:e.push(new Ni(o,r.controlPoint,r.endPoint)),o=r.endPoint;break;case 0:e.push(new Be(o,r.point)),o=r.point;break;case 1:e.push(new $i(r.point)),o=r.point;break;default:return n=r,n}}return this.cachedGeometry=e,this.cachedGeometry}*startEndPoints(){yield this.startPoint;for(let o of this.parts){let e;switch(o.kind){case 2:yield o.endPoint;break;case 3:yield o.endPoint;break;case 0:yield o.point;break;case 1:yield o.point;break;default:return e=o,e}}}polylineApproximation(){if(this.cachedPolylineApproximation)return this.cachedPolylineApproximation;let o=[];for(let n of this.parts)switch(n.kind){case 2:o.push(n.controlPoint1,n.controlPoint2,n.endPoint);break;case 3:o.push(n.controlPoint,n.endPoint);break;case 1:case 0:o.push(n.point);break}let e=[],r=this.startPoint;for(let n of o)e.push(new Be(r,n)),r=n;return e}static computeBBoxForSegment(o,e){let r=[o],n;switch(e.kind){case 1:case 0:r.push(e.point);break;case 2:r.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case 3:r.push(e.controlPoint,e.endPoint);break;default:return n=e,n}return he.bboxOf(r)}signedDistance(o,e){let r=1/0;for(let n of this.geometry){let i=n.signedDistance(o)-e;i<r&&(r=i)}return r}raymarchIntersectionWith(o,e,r=[]){if(!o.bbox.intersects(this.bbox.grownBy(e)))return[];let n=o.length,i=[];for(let g of this.geometry){let v=g.getTightBoundingBox().grownBy(e);if(!v.intersects(o.bbox))continue;let b=f=>g.signedDistance(f),y=f=>b(f)-e;y(o.p1)>n&&y(o.p2)>n||i.push({part:g,distFn:b,bbox:v})}if(i.length===0)return[];let a=g=>{let v=1/0,b=null,y=[];for(let f of i){let{part:T,distFn:P,bbox:S}=f;if(!S.containsPoint(g)){y.push(f);continue}let E=P(g);E<=v&&(v=E,b=T)}for(let{part:f,distFn:T,bbox:P}of y){if(isFinite(v)&&!P.grownBy(v).containsPoint(g))continue;let S=T(g);S<=v&&(v=S,b=f)}return[b,v-e]},l=8,c=[o.p1,...r,o.p2],d=g=>g.minus(o.p1).dot(o.direction);c.sort((g,v)=>{let b=d(g),y=d(v);return b-y});let u=[],p=e/1e3,h=(g,v,b)=>{let y=g,[f,T]=a(y),P=d(y);if(T>n)return P;let S=o.direction.times(v);for(let C=0;C<l;C++){let V=T;if(y=y.plus(S.times(V)),P=d(y),P<=b)return P;let[O,G]=a(y);if(Math.abs(G)>Math.abs(T))return null;if(T=G,f=O,Math.abs(T)<p)break}let E=P>=0&&P<=n;if(f&&E&&Math.abs(T)<p){u.push({point:y,parameterValue:f.nearestPointTo(y).parameterValue,curve:f,curveIndex:this.geometry.indexOf(f)});let C=e/20/o.length;P+=isFinite(C)?C:0}return P},m=0;for(let g=0;g<c.length;g++){let v=c[g];m=Math.max(m,h(v,1,m)??m),m=Math.max(m,h(v,-1,m)??m)}return u}intersection(o,e){let r=[];if(!o.bbox.intersects(this.bbox.grownBy(e??0)))return[];if(this.parts.length===0)return new s(this.startPoint,[{kind:1,point:this.startPoint}]).intersection(o,e);let n=0;for(let a of this.geometry){let l=a.argIntersectsLineSegment(o);for(let c of l)r.push({curve:a,curveIndex:n,point:a.at(c),parameterValue:c});n++}if(e&&e>1e-8){let a=r.map(l=>l.point);r=this.raymarchIntersectionWith(o,e,a)}return r}nearestPointTo(o){let e=1/0,r=0,n=0,i=this.startPoint;for(let a=0;a<this.geometry.length;a++){let c=this.geometry[a].nearestPointTo(o),d=c.point.squareDistanceTo(o);(a===0||d<e)&&(r=a,e=d,n=c.parameterValue,i=c.point)}return{curve:this.geometry[r],curveIndex:r,parameterValue:n,point:i}}at(o){return o.curveIndex===0&&o.parameterValue===0?this.startPoint:this.geometry[o.curveIndex].at(o.parameterValue)}tangentAt(o){return this.geometry[o.curveIndex].tangentAt(o.parameterValue)}splitNear(o,e){let r=this.nearestPointTo(o);return this.splitAt(r,e)}spliced(o,e,r,n){if(((a,l)=>a.curveIndex<l.curveIndex||a.curveIndex===l.curveIndex&&a.parameterValue<=l.parameterValue)(o,e)){let a=this.splitAt(o,n),l=this.splitAt(e,n),c=a[0],d=l[l.length-1];return r?c.union(r).union(d):c.union(d)}else{let c=this.splitAt([o],n)[0].splitNear(this.at(e),n),d=c[c.length-1];return r?d.union(r):d}}splitAt(o,e){for(Array.isArray(o)||(o=[o]),o=[...o],o.sort(Eo);o.length>0&&o[o.length-1].curveIndex>=this.parts.length-1&&o[o.length-1].parameterValue>=1;)o.pop();for(o.reverse();o.length>0&&o[o.length-1].curveIndex<=0&&o[o.length-1].parameterValue<=0;)o.pop();if(o.length===0||this.parts.length===0)return[this];let r=o.length+1,n=e?.mapNewPoint??(u=>u),i=[],a=this.startPoint,l=[],{curveIndex:c,parameterValue:d}=o.pop();for(let u=0;u<this.parts.length;u++)if(u!==c)l.push(this.parts[u]);else{let p=this.parts[u],h=this.geometry[u];for(;u===c;){let m,g=[];switch(p.kind){case 1:l.push({kind:p.kind,point:p.point}),m=p.point;break;case 0:{let b=h.splitAt(d);l.push({kind:p.kind,point:n(b[0].p2)}),m=b[0].p2,b.length>1&&(console.assert(b.length===2),g.push({kind:p.kind,point:b[1].p2}),h=b[1])}break;case 3:case 2:{let b=h.splitAt(d),y=b.length===2;for(let f of b){h=f;let T=y?l:g,P=f.getPoints();p.kind===2?T.push({kind:p.kind,controlPoint1:n(P[1]),controlPoint2:n(P[2]),endPoint:n(P[3])}):T.push({kind:p.kind,controlPoint:n(P[1]),endPoint:n(P[2])}),y||(m=P[0]),y=!1}}break;default:return p}i.push(new s(a,[...l])),a=n(m),console.assert(!!a,"should have a start point"),l=g,p=g[g.length-1]??p;let v=o.pop();if(v)if(c=v.curveIndex,u===c){let b=this.at(v);d=h.nearestPointTo(b).parameterValue,l=[]}else d=v.parameterValue;else break}}return i.push(new s(a,l)),console.assert(i.length===r,`should split into splitAt.length + 1 splits (was ${i.length}, expected ${r})`),i}asClosed(){let o=[],e=!1;for(let n of this.parts)n.kind===1?(o.push({kind:0,point:n.point}),e=!0):o.push(n);if(this.getEndPoint().eq(this.startPoint)||(o.push({kind:0,point:this.startPoint}),e=!0),!e)return this;let r=new s(this.startPoint,o);return console.assert(r.getEndPoint().eq(r.startPoint)),r}static mapPathCommand(o,e){switch(o.kind){case 1:case 0:return{kind:o.kind,point:e(o.point)};case 2:return{kind:o.kind,controlPoint1:e(o.controlPoint1),controlPoint2:e(o.controlPoint2),endPoint:e(o.endPoint)};case 3:return{kind:o.kind,controlPoint:e(o.controlPoint),endPoint:e(o.endPoint)}}return o}mapPoints(o){let e=o(this.startPoint),r=[];for(let n of this.parts)r.push(s.mapPathCommand(n,o));return new s(e,r)}transformedBy(o){return o.isIdentity()?this:this.mapPoints(e=>o.transformVec2(e))}closedContainsPoint(o){let e=this.getExactBBox();if(!e.containsPoint(o))return!1;let r=o.plus(w.of(e.width,0)),n=this.asClosed(),i=new Be(o,r),a=n.intersection(i);return a.filter((c,d)=>d===0?!0:!(a[d-1].parameterValue>=1&&c.parameterValue<=0)).length%2===1}closedContainsRect(o){if(!this.bbox.containsRect(o)||!o.corners.every(e=>this.closedContainsPoint(e)))return!1;for(let e of o.getEdges())if(this.intersection(e).length)return!1;return!0}union(o,e={allowReverse:!0}){if(!o)return this;if(Array.isArray(o))return new s(this.startPoint,[...this.parts,...o]);let r=this.getEndPoint(),n=[];if(r.eq(o.startPoint))n=this.parts.concat(o.parts);else{if(e.allowReverse&&this.startPoint.eq(o.getEndPoint()))return o.union(this,{allowReverse:!1});if(e.allowReverse&&this.startPoint.eq(o.startPoint))return this.union(o.reversed(),{allowReverse:!1});n=[...this.parts,{kind:1,point:o.startPoint},...o.parts]}return new s(this.startPoint,n)}reversed(){let o=this.getEndPoint(),e=[],r=this.startPoint;for(let n of this.parts)switch(n.kind){case 0:case 1:e.push({kind:n.kind,point:r}),r=n.point;break;case 2:e.push({kind:n.kind,controlPoint1:n.controlPoint2,controlPoint2:n.controlPoint1,endPoint:r}),r=n.endPoint;break;case 3:e.push({kind:n.kind,controlPoint:n.controlPoint,endPoint:r}),r=n.endPoint;break;default:return n}return e.reverse(),new s(o,e)}getEndPoint(){if(this.parts.length===0)return this.startPoint;let o=this.parts[this.parts.length-1];return o.kind===3||o.kind===2?o.endPoint:o.point}roughlyIntersects(o,e=0){if(this.parts.length===0)return o.containsPoint(this.startPoint);if(this.startPoint.eq(this.getEndPoint())&&e===0)return this.closedRoughlyIntersects(o);if(o.containsRect(this.bbox))return!0;let n=this.startPoint;for(let i of this.parts){let a=s.computeBBoxForSegment(n,i).grownBy(e);if(i.kind===0||i.kind===1?n=i.point:n=i.endPoint,o.intersects(a))return!0}return!1}closedRoughlyIntersects(o){if(o.containsRect(this.bbox))return!0;let e=this.bbox.topLeft.minus(w.of(1,1)),r=o.corners,n=this.polylineApproximation();for(let l of r){let c=new Be(l,e),d=0;for(let u of n)u.intersects(c)&&d++;if(d%2===1)return!0}let i=o.grownBy(Math.min(o.size.x,o.size.y)),a=[];for(let l of i.divideIntoGrid(4,4))a.push(...l.getEdges());for(let l of a)for(let c of n)if(l.intersects(c))return!0;return!1}eq(o,e){if(o.parts.length!==this.parts.length)return!1;for(let r=0;r<this.parts.length;r++){let n=this.parts[r],i=o.parts[r];switch(n.kind){case 0:case 1:if(n.kind!==i.kind)return!1;if(!n.point.eq(i.point,e))return!1;break;case 2:if(n.kind!==i.kind)return!1;if(!n.controlPoint1.eq(i.controlPoint1,e)||!n.controlPoint2.eq(i.controlPoint2,e)||!n.endPoint.eq(i.endPoint,e))return!1;break;case 3:if(n.kind!==i.kind)return!1;if(!n.controlPoint.eq(i.controlPoint,e)||!n.endPoint.eq(i.endPoint,e))return!1;break;default:return n}}return!0}static fromRect(o,e=null){let r=[],n,i;if(e!==null){let a=w.of(e,e).times(.5),l=he.fromCorners(o.topLeft.plus(a),o.bottomRight.minus(a)),c=he.fromCorners(o.topLeft.minus(a),o.bottomRight.plus(a));n=[l.corners[3],...l.corners,...c.corners.reverse()],i=c.corners[3]}else n=o.corners.slice(1),i=o.corners[0];for(let a of n)r.push({kind:0,point:a});return r.push({kind:0,point:i}),new s(i,r)}toString(o,e=!1){if(this.cachedStringVersion&&!e)return this.cachedStringVersion;o===void 0&&(o=Math.abs(this.bbox.topLeft.x)>10&&Math.abs(this.bbox.topLeft.y)>10);let r=s.toString(this.startPoint,this.parts,!o);return this.cachedStringVersion=r,r}serialize(){return this.toString()}static toString(o,e,r){let n=[],i,a=(c,...d)=>{let u=[],p=[],h=!i||r,m=i?wt(i.x):"",g=i?wt(i.y):"";for(let b of d){let y=wt(b.x),f=wt(b.y);if(h)u.push(`${y},${f}`);else{let T=kn(b.x-i.x,y,m,g),P=kn(b.y-i.y,f,m,g);P.charAt(0)==="-"?p.push(`${T}${P}`):p.push(`${T},${P}`)}}let v;h?v=`${c}${u.join(" ")}`:v=`${c.toLowerCase()}${p.join(" ")}`,!(v==="l0,0"||v==="m0,0")&&(n.push(v),d.length>0&&(i=d[d.length-1]))};e[0]?.kind!==1&&a("M",o);let l;for(let c=0;c<e.length;c++){let d=e[c];switch(d.kind){case 1:a("M",d.point);break;case 0:a("L",d.point);break;case 2:a("C",d.controlPoint1,d.controlPoint2,d.endPoint);break;case 3:a("Q",d.controlPoint,d.endPoint);break;default:return l=d,l}}return n.join("")}static fromString(o){o=o.split(`
|
3
|
+
`).join(" ");let e=w.zero,r=null,n=null,i=!0,a=[],l=v=>{if(i){i=!1;return}a.push({kind:1,point:v})},c=v=>{if(i){i=!1;return}a.push({kind:0,point:v})},d=(v,b,y)=>{a.push({kind:2,controlPoint1:v,controlPoint2:b,endPoint:y})},u=(v,b)=>{a.push({kind:3,controlPoint:v,endPoint:b})},p={m:1,l:1,c:3,q:2,z:0,h:1,v:1},h=/([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/gi,m;for(;(m=h.exec(o))!==null;){let b=m[2].trim().split(/[^0-9Ee.-]/).filter(S=>S.length>0).reduce((S,E)=>{E=E.replace(/([^eE])[-]/g,"$1 -");let C=E.split(" -");return C[0]!==""&&S.push(C[0]),S.push(...C.slice(1).map(V=>`-${V}`)),S},[]).map(S=>parseFloat(S)),y=m[1].toLowerCase(),f=m[1]!==y;if(y==="v"||y==="h")b=b.reduce((S,E)=>y==="v"?S.concat(f?e.x:0,E):S.concat(E,f?e.y:0),[]),y="l";else if(y==="z"){if(r)b=[r.x,r.y],r=e;else continue;f=!0,y="l"}let T=p[y]??0,P=b.reduce((S,E,C,V)=>{if(C%2!==0){let O=E,G=V[C-1];return S.concat(w.of(G,O))}else return S},[]).map((S,E)=>{let C;return f?C=S:C=e.plus(S),(E+1)%T===0&&(e=C),C});if(P.length%T!==0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(P)} with a length of ${P.length} \u2260 ${T}k, k \u2208 \u2124.`,`The number of arguments to ${y} must be a multiple of ${T}!`,`Command: ${m[0]}`].join(`
|
4
|
+
`));for(let S=0;S<P.length;S+=T){let E=P.slice(S,S+T);switch(y.toLowerCase()){case"m":S===0?l(E[0]):c(E[0]);break;case"l":c(E[0]);break;case"c":d(E[0],E[1],E[2]);break;case"q":u(E[0],E[1]);break;default:throw new Error(`Unknown path command ${y}`)}i=!1}P.length>0&&(r??=P[0],n??=r,e=P[P.length-1])}let g=new s(n??w.zero,a);return g.cachedStringVersion=o,g}static fromConvexHullOf(o){if(o.length===0)return s.empty;let e=Wi(o),r=e.slice(1).map(n=>({kind:0,point:n}));return r.push({kind:0,point:e[0]}),new s(e[0],r)}static{this.empty=new s(w.zero,[])}};var L=class s{constructor(o,e,r,n){this.r=o;this.g=e;this.b=r;this.a=n;this.hexString=null}static ofRGB(o,e,r){return s.ofRGBA(o,e,r,1)}static ofRGBA(o,e,r,n){return o=Math.max(0,Math.min(o,1)),e=Math.max(0,Math.min(e,1)),r=Math.max(0,Math.min(r,1)),n=Math.max(0,Math.min(n,1)),new s(o,e,r,n)}static fromRGBArray(o,e=255){let r=o[0],n=o[1]??r,i=o[2]??r,a=255;return 3<o.length&&(a=o[3]),s.ofRGBA(r/e,n/e,i/e,a/e)}static fromHex(o){if(o=(o.match(/^[#]?(.*)$/)??[])[1],o=o.toUpperCase(),!o.match(/^[0-9A-F]+$/))throw new Error(`${o} is not in a valid format.`);(o.length===3||o.length===4)&&(o=o.split("").map(n=>`${n}0`).join("")),o.length===6&&(o+="FF");let e=[];for(let r=2;r<=o.length;r+=2){let n=o.substring(r-2,r);e.push(parseInt(n,16)/255)}if(e.length!==4)throw new Error(`Unable to parse ${o}: Wrong number of components.`);return s.ofRGBA(e[0],e[1],e[2],e[3])}static fromString(o){if(o.startsWith("#"))return s.fromHex(o);if(o==="none"||o==="transparent")return s.transparent;if(o==="")return s.black;let e=/^rgba?\(([,0-9.]+)\)$/i,r=o.replace(/\s*/g,"").match(e);if(r){let p=r[1],h=JSON.parse(`[ ${p} ]`);if(h.length===3)return s.ofRGB(h[0]/255,h[1]/255,h[2]/255);if(h.length===4)return s.ofRGBA(h[0]/255,h[1]/255,h[2]/255,h[3]);throw new Error(`RGB string, ${o}, has wrong number of components: ${h.length}`)}let n=document.createElement("canvas");n.width=1,n.height=1;let i=n.getContext("2d");if(!i)return s.black;i.fillStyle=o,i.fillRect(0,0,1,1);let a=i.getImageData(0,0,1,1),l=a.data[0]/255,c=a.data[1]/255,d=a.data[2]/255,u=a.data[3]/255;return s.ofRGBA(l,c,d,u)}eq(o){return o==null?!1:this.a===0&&o.a===0?!0:this.toHexString()===o.toHexString()}mix(o,e){e=Math.min(Math.max(e,0),1);let r=1-e;return new s(this.r*r+o.r*e,this.g*r+o.g*e,this.b*r+o.b*e,this.a*r+o.a*e)}withAlpha(o){return new s(this.r,this.g,this.b,o)}get rgb(){return Pe.of(this.r,this.g,this.b)}relativeLuminance(){let o=[this.r,this.g,this.b].map(e=>e<.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return .2126*o[0]+.7152*o[1]+.0722*o[2]}static contrastRatio(o,e){let r=o.relativeLuminance(),n=e.relativeLuminance();return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}static average(o){let e=0,r=0,n=0,i=0;for(let a of o)e+=a.a,r+=a.r,n+=a.g,i+=a.b;return o.length>0&&(e/=o.length,r/=o.length,n/=o.length,i/=o.length),new s(r,n,i,e)}asHSV(){let o=Math.min(this.r,this.g,this.b),e=Math.max(this.r,this.g,this.b),r=e-o,n;r===0?n=0:this.r>=this.g&&this.r>=this.b?n=(this.g-this.b)/r%6:this.g>=this.r&&this.g>=this.b?n=(this.b-this.r)/r+2:n=(this.r-this.g)/r+4,n*=60,n*=Math.PI/180,n<0&&(n+=Math.PI*2);let i=e,a=i>0?r/i:0;return Pe.of(n,a,i)}static fromHSV(o,e,r){o<0&&(o+=Math.PI*2),o%=Math.PI*2,r=Math.max(0,Math.min(1,r)),e=Math.max(0,Math.min(1,e));let n=r*e,i=o/(Math.PI/3),a=n*(1-Math.abs(i%2-1)),l;i<1?l=[n,a,0]:i<2?l=[a,n,0]:i<3?l=[0,n,a]:i<4?l=[0,a,n]:i<5?l=[a,0,n]:l=[n,0,a];let c=r-n;return s.ofRGB(l[0]+c,l[1]+c,l[2]+c)}static fromRGBVector(o,e){return s.ofRGBA(o.x,o.y,o.z,e??1)}toHexString(){if(this.hexString)return this.hexString;let o=a=>{let l=Math.round(255*a).toString(16);return l.length===1?`0${l}`:l},e=o(this.a),r=o(this.r),n=o(this.g),i=o(this.b);return e==="ff"?`#${r}${n}${i}`:(this.hexString=`#${r}${n}${i}${e}`,this.hexString)}toString(){return this.toHexString()}static{this.transparent=s.ofRGBA(0,0,0,0)}static{this.red=s.ofRGB(1,0,0)}static{this.orange=s.ofRGB(1,.65,0)}static{this.green=s.ofRGB(0,1,0)}static{this.blue=s.ofRGB(0,0,1)}static{this.purple=s.ofRGB(.5,.2,.5)}static{this.yellow=s.ofRGB(1,1,.1)}static{this.clay=s.ofRGB(.8,.4,.2)}static{this.black=s.ofRGB(0,0,0)}static{this.gray=s.ofRGB(.5,.5,.5)}static{this.white=s.ofRGB(1,1,1)}};var Rn=class extends Ie{},Ee=class s{constructor(o){this.onTransformChangeCallback=o;this.resetTransform(k.identity),this.screenRect=I.empty}static{this.ViewportTransform=class extends Rn{constructor(e){super();this.transform=e;this.#e=e.inverse()}#e;apply(e){let r=e.viewport;r.resetTransform(r.transform.rightMul(this.transform)),e.queueRerender()}unapply(e){let r=e.viewport;r.resetTransform(r.transform.rightMul(this.#e)),e.queueRerender()}description(e,r){let n=[],i=e.viewport.visibleRect.center,a=this.transform.transformVec3(w.unitX),l=this.transform.transformVec2(i),c=a.magnitude(),d=180/Math.PI*a.angle(),u=l.minus(i);c>1.2?n.push(r.zoomedIn):c<.8&&n.push(r.zoomedOut),Math.floor(Math.abs(d))>0&&n.push(r.rotatedBy(Math.round(d)));let p=1e-4;return u.x>p?n.push(r.movedLeft):u.x<-p&&n.push(r.movedRight),u.y<-p?n.push(r.movedDown):u.y>p&&n.push(r.movedUp),n.join("; ")}}}getTemporaryClone(){let o=new s(()=>{});return o.transform=this.transform,o.inverseTransform=this.inverseTransform,o.screenRect=this.screenRect,o}updateScreenSize(o){this.screenRect=this.screenRect.resizedTo(o)}get visibleRect(){return this.screenRect.transformedBoundingBox(this.inverseTransform)}screenToCanvas(o){return this.inverseTransform.transformVec2(o)}canvasToScreen(o){return this.transform.transformVec2(o)}static transformBy(o){return new s.ViewportTransform(o)}resetTransform(o=k.identity){let e=this.transform;this.transform=o,this.inverseTransform=o.inverse(),this.onTransformChangeCallback?.(e,o)}get screenToCanvasTransform(){return this.inverseTransform}get canvasToScreenTransform(){return this.transform}getScreenRectSize(){return this.screenRect.size}getResolution(){return this.getScreenRectSize()}getScaleFactor(){return this.transform.transformVec3(F.unitX).magnitude()}getScaleFactorToNearestPowerOfTen(){return this.getScaleFactorToNearestPowerOf(10)}getScaleFactorToNearestPowerOf(o){let e=this.getScaleFactor();return Math.pow(o,Math.round(Math.log(e)/Math.log(o)))}static getGridSize(o){return 50/o}snapToGrid(o){let e=this.getScaleFactorToNearestPowerOf(2),r=i=>{let a=1/s.getGridSize(e);return Math.round(i*a)/a};return w.of(r(o.x),r(o.y))}getSizeOfPixelOnCanvas(){return 1/this.getScaleFactor()}getRotationAngle(){return this.transform.transformVec3(F.unitX).angle()}static roundPoint(o,e){let r=10**Math.floor(Math.log10(e)),n=i=>Math.round(i/r)*r;return typeof o=="number"?n(o):o.map(n)}roundPoint(o){return s.roundPoint(o,1/this.getScaleFactor())}static roundScaleRatio(o,e=1){if(Math.abs(o)<=1e-12)return 0;let r=10**Math.floor(Math.log10(Math.abs(o))),n=2**e;return o=Math.round(o/r*n)/n*r,o}computeZoomToTransform(o,e=!0,r=!0){let n=k.identity;if(o.w===0||o.h===0){let d=Math.max(o.w,o.h);d===0&&(d=50,e=!1,r=!1),o=new I(o.x,o.y,d,d)}if(isNaN(o.size.magnitude()))throw new Error(`${o.toString()} rectangle has NaN size! Cannot zoom to!`);let i=()=>{let d=this.visibleRect.transformedBoundingBox(n.inverse());return d.transformedBoundingBox(k.scaling2D(4/5,d.center))},a=i(),l=a.w<o.w||a.h<o.h,c=o.maxDimension/a.maxDimension<1/3;if(l&&r||c&&e){let d=Math.max(o.w/a.w,o.h/a.h),p=k.scaling2D(d,a.topLeft).inverse();n=n.rightMul(p)}if(a=i(),!a.containsRect(o)){let d=o.center.minus(a.center),p=k.translation(d).inverse();n=n.rightMul(p)}return n.invertable()||(console.warn("Unable to zoom to ",o,"! Computed transform",n,"is singular."),n=k.identity),n}zoomTo(o,e=!0,r=!0){let n=this.computeZoomToTransform(o,e,r);return new s.ViewportTransform(n)}},U=Ee;var W=class s extends Ie{#e;constructor(o){if(super(),!(o in s.deserializationCallbacks))throw new Error(`Command ${o} must have a registered deserialization callback. To do this, call SerializableCommand.register.`);this.#e=o}static{this.deserializationCallbacks={}}serialize(){return{data:this.serializeToJSON(),commandType:this.#e}}static deserialize(o,e){let r=typeof o=="string"?JSON.parse(o):o,n=r.commandType;if(!(n in s.deserializationCallbacks))throw new Error(`Unrecognised command type ${n}!`);return s.deserializationCallbacks[n](r.data,e)}static register(o,e){s.deserializationCallbacks[o]=e}};var Ct=class extends W{constructor(o,e,r){super(o),this.component=r??null,this.componentID=e}resolveComponent(o){if(this.component)return;let e=o.lookupElement(this.componentID);if(!e)throw new Error(`Unable to resolve component with ID ${this.componentID}`);this.component=e}};var to=(r=>(r[r.BoundingBox=0]="BoundingBox",r[r.FillScreen=1]="FillScreen",r[r.Anywhere=2]="Anywhere",r))(to||{}),_=class s{constructor(o,e){this.componentKind=o;this.loadSaveData={};if(this.lastChangedTime=new Date().getTime(),e!==void 0?this.zIndex=e:this.zIndex=s.zIndexCounter++,this.id=`${new Date().getTime()}-${Math.random()}`,s.deserializationCallbacks[o]===void 0)throw new Error(`Component ${o} has not been registered using AbstractComponent.registerComponent`)}static{this.zIndexCounter=0}getId(){return this.id}static{this.deserializationCallbacks={}}static registerComponent(o,e){this.deserializationCallbacks[o]=e??null}attachLoadSaveData(o,e){this.loadSaveData[o]||(this.loadSaveData[o]=[]),this.loadSaveData[o].push(e)}getLoadSaveData(){return this.loadSaveData}getZIndex(){return this.zIndex}getBBox(){return this.contentBBox}getExactBBox(){return this.getBBox()}getSizingMode(){return 0}occludesEverythingBelowWhenRenderedInRect(o){return!1}onAddToImage(o){}onRemoveFromImage(){}intersectsRect(o){return o.containsRect(this.getExactBBox())?!0:o.getEdges().some(r=>this.intersects(r))}keyPoints(){return[this.getBBox().center]}isSelectable(){return!0}isBackground(){return!1}getProportionalRenderingTime(){return 1}transformBy(o){return new s.TransformElementCommand(o,this.getId(),this)}setZIndex(o){return new s.TransformElementCommand(k.identity,this.getId(),this,o)}setZIndexAndTransformBy(o,e,r){return new s.TransformElementCommand(o,this.getId(),this,e,r)}static{this.transformElementCommandId="transform-element"}static{this.TransformElementCommand=class extends Ct{constructor(e,r,n,i,a){super(s.transformElementCommandId,r,n);this.affineTransfm=e;this.origZIndex=a;this.targetZIndex=i??s.zIndexCounter++,this.targetZIndex>=s.zIndexCounter&&(s.zIndexCounter=this.targetZIndex+1),n&&a===void 0&&(this.origZIndex=n.getZIndex())}resolveComponent(e){this.component||(super.resolveComponent(e),this.origZIndex??=this.component.getZIndex())}updateTransform(e,r,n){if(!this.component)throw new Error("this.component is undefined or null!");let i=e.image.findParent(this.component),a=!1;i&&(i.remove(),a=!0),this.component.applyTransformation(r),this.component.zIndex=n,this.component.lastChangedTime=new Date().getTime(),n>=s.zIndexCounter&&(s.zIndexCounter=n+1),a&&q.addElement(this.component).apply(e)}apply(e){this.resolveComponent(e.image),this.updateTransform(e,this.affineTransfm,this.targetZIndex),e.queueRerender()}unapply(e){this.resolveComponent(e.image),this.updateTransform(e,this.affineTransfm.inverse(),this.origZIndex),e.queueRerender()}description(e,r){return r.transformedElements(1)}static{W.register(s.transformElementCommandId,(e,r)=>{let n=r.image.lookupElement(e.id)??void 0,i=new k(...e.transfm),a=e.targetZIndex,l=e.origZIndex??void 0;return new s.TransformElementCommand(i,e.id,n,a,l)})}serializeToJSON(){return{id:this.componentID,transfm:this.affineTransfm.toArray(),targetZIndex:this.targetZIndex,origZIndex:this.origZIndex}}}}clone(){let o=this.createClone();for(let e in this.loadSaveData)for(let r of this.loadSaveData[e])o.attachLoadSaveData(e,r);return o}serialize(){let o=this.serializeToJSON();if(o===null)throw new Error(`${this} cannot be serialized.`);return{name:this.componentKind,zIndex:this.zIndex,id:this.id,loadSaveData:this.loadSaveData,data:o}}static isNotDeserializable(o){return typeof o=="string"&&(o=JSON.parse(o)),typeof o!="object"||!this.deserializationCallbacks[o?.name]||!o.data}static deserialize(o){if(typeof o=="string"&&(o=JSON.parse(o)),s.isNotDeserializable(o))throw new Error(`Element with data ${o} cannot be deserialized.`);let e=this.deserializationCallbacks[o.name](o.data);return e.id=o.id,isFinite(o.zIndex)&&(e.zIndex=o.zIndex,s.zIndexCounter=Math.max(s.zIndexCounter,e.zIndex+1)),e}};var Fe=class{constructor(){this.listeners={}}dispatch(o,e){let r=this.listeners[o];if(r)for(let n=0;n<r.length;n++)r[n](e)}on(o,e){return this.listeners[o]||(this.listeners[o]=[]),this.listeners[o].push(e),{remove:()=>{let r=this.listeners[o];return this.off(o,e),r.length!==this.listeners[o].length}}}off(o,e){let r=this.listeners[o];r&&(this.listeners[o]=r.filter(n=>n!==e))}};function Ki(s){throw new Error(`Should be unreachable. Key: ${s}.`)}function ut(s,o=!1){if(typeof s!="number"||!o&&isNaN(s))throw new Error("Given value is not a number")}function Ea(s){if(!Array.isArray(s))throw new Error("Asserting isArray: Given entity is not an array")}function ko(s,o=!1){Ea(s),ut(s.length);for(let e of s)ut(e,o)}function zn(s){if(typeof s!="boolean")throw new Error("Given value is not a boolean")}function Gi(s){if(!s)throw new Error(`${JSON.stringify(s)} is not truthy`)}function yr(s){if(typeof s!="object")throw new Error(`AssertIsObject: Given entity is not an object (type = ${typeof s})`)}var Tt=s=>{s.sort((o,e)=>o.getContent().getZIndex()-e.getContent().getZIndex())};var xr=!1,q=class s{constructor(){this.componentCount=0;this.settingExportRect=!1;this.root=new wr,this.background=new wr,this.componentsById=Object.create(null),this.notifier=new Fe,this.importExportViewport=new U(()=>{this.onExportViewportChanged()}),this.importExportViewport.updateScreenSize(w.of(500,500)),this.shouldAutoresizeExportViewport=!1}getBackgroundComponents(){let o=[],e=this.background.getLeaves();Tt(e);for(let r of e){let n=r.getContent();n&&o.push(n)}return o}findParent(o){return this.background.getChildWithContent(o)??this.root.getChildWithContent(o)}queueRerenderOf(o){let e=this.findParent(o);e&&(e.remove(),this.addElementDirectly(o))}renderWithCache(o,e,r){this.background.render(o,r.visibleRect),xr?this.root.render(o,r.visibleRect):e.render(o,this.root,r)}render(o,e){this.background.render(o,e?.visibleRect),this.root.render(o,e?.visibleRect)}async renderAllAsync(o,e){return await this.background.renderAllAsync(o,e)?await this.root.renderAllAsync(o,e):!1}renderAll(o){this.render(o,null)}getAllElements(){let o=this.root.getLeaves();return Tt(o),o.map(e=>e.getContent())}estimateNumElements(){return this.componentCount}getElementsIntersectingRegion(o,e=!1){let r=this.root.getLeavesIntersectingRegion(o);return e&&(r=r.concat(this.background.getLeavesIntersectingRegion(o))),Tt(r),r.map(n=>n.getContent())}onDestroyElement(o){this.componentCount--,delete this.componentsById[o.getId()],this.autoresizeExportViewport()}onElementAdded(o){this.componentCount++,this.componentsById[o.getId()]=o,this.autoresizeExportViewport()}lookupElement(o){return this.componentsById[o]??null}addElementDirectly(o){o.onAddToImage(this);let r=(o.isBackground()?this.background:this.root).addLeaf(o);return this.onElementAdded(o),r}removeElementDirectly(o){let e=this.findParent(o);return e?.remove(),e?(this.onDestroyElement(o),!0):!1}static addElement(o,e=!1){return new s.AddElementCommand(o,e)}addElement(o,e){return s.addElement(o,e)}static{this.AddElementCommand=class extends W{constructor(e,r=!1){super("add-element");this.element=e;this.applyByFlattening=r;this.serializedElem=null;if(this.serializedElem=null,isNaN(e.getBBox().area))throw new Error("Elements in the image cannot have NaN bounding boxes")}apply(e){e.image.addElementDirectly(this.element),this.applyByFlattening?(this.applyByFlattening=!1,e.display.flatten()):e.queueRerender()}unapply(e){e.image.removeElementDirectly(this.element),e.queueRerender()}description(e,r){return r.addElementAction(this.element.description(r))}serializeToJSON(){return{elemData:this.serializedElem??this.element.serialize()}}static{W.register("add-element",(e,r)=>{let n=e.elemData.id,a=r.image.lookupElement(n)??_.deserialize(e.elemData),l=new s.AddElementCommand(a);return l.serializedElem=e.elemData,l})}}}getImportExportViewport(){return this.importExportViewport}getImportExportRect(){return this.getImportExportViewport().visibleRect}setImportExportRect(o){return s.SetImportExportRectCommand.of(this,o,!1)}getAutoresizeEnabled(){return this.shouldAutoresizeExportViewport}setAutoresizeEnabled(o){if(o===this.shouldAutoresizeExportViewport)return Ie.empty;let e=this.root.getBBox();return s.SetImportExportRectCommand.of(this,e,o)}setAutoresizeEnabledDirectly(o){o!==this.shouldAutoresizeExportViewport&&(this.shouldAutoresizeExportViewport=o,this.notifier.dispatch(1,{image:this}))}autoresizeExportViewport(){this.shouldAutoresizeExportViewport&&this.setExportRectDirectly(this.root.getBBox())}setExportRectDirectly(o){let e=this.getImportExportViewport(),r=e.getScreenRectSize(),n=e.canvasToScreenTransform,i=k.translation(o.topLeft.times(-1));return!r.eq(o.size)||!n.eq(i)?(this.settingExportRect=!0,e.updateScreenSize(o.size),e.resetTransform(i),this.settingExportRect=!1,this.onExportViewportChanged(),!0):!1}onExportViewportChanged(){this.settingExportRect||this.notifier.dispatch(0,{image:this})}static setDebugMode(o){xr=o}static{this.SetImportExportRectCommand=class extends W{constructor(e,r,n,i,a){super(s.SetImportExportRectCommand.commandId);this.originalSize=e;this.originalTransform=r;this.originalAutoresize=n;this.newExportRect=i;this.newAutoresize=a}static{this.commandId="set-import-export-rect"}static of(e,r,n){let i=e.getImportExportViewport(),a=i.visibleRect.size,l=i.canvasToScreenTransform,c=e.getAutoresizeEnabled();return new s.SetImportExportRectCommand(a,l,c,r,n)}apply(e){e.image.setAutoresizeEnabledDirectly(this.newAutoresize),e.image.setExportRectDirectly(this.newExportRect),e.queueRerender()}unapply(e){let r=e.image.getImportExportViewport();e.image.setAutoresizeEnabledDirectly(this.originalAutoresize),r.updateScreenSize(this.originalSize),r.resetTransform(this.originalTransform),e.queueRerender()}description(e,r){return this.newAutoresize!==this.originalAutoresize?this.newAutoresize?r.enabledAutoresizeOutputCommand:r.disabledAutoresizeOutputCommand:r.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}}static{let e=this.commandId;W.register(e,(r,n)=>{ut(r.originalSize.x),ut(r.originalSize.y),ko(r.originalTransform),ko([r.newRegion.x,r.newRegion.y,r.newRegion.w,r.newRegion.h]),zn(r.autoresize??!1),zn(r.originalAutoresize??!1);let i=w.ofXY(r.originalSize),a=new k(...r.originalTransform),l=new I(r.newRegion.x,r.newRegion.y,r.newRegion.w,r.newRegion.h),c=r.autoresize??!1,d=r.originalAutoresize??!1;return new s.SetImportExportRectCommand(i,a,d,l,c)})}}}},Ln=(s,o)=>{let e=0;if(o){for(let r=s.length-1;r>=1;r--)if(s[r].getBBox().containsRect(o)&&s[r].getContent()?.occludesEverythingBelowWhenRenderedInRect(o)){e=r;break}}return e},Ro=class s{constructor(o=null){this.parent=o;this.targetChildCount=30;this.children=[],this.bbox=I.empty,this.content=null,this.id=s.idCounter++}static{this.idCounter=0}getId(){return this.id}onContentChange(){this.id=s.idCounter++}getContent(){return this.content}getParent(){return this.parent}getChildrenIntersectingRegion(o,e){return this.children.filter(r=>{let n=r.getBBox();return!e?.(n)&&n.intersects(o)})}getChildrenOrSelfIntersectingRegion(o,e){return this.content&&this.bbox.intersects(o)&&!e?.(this.bbox)?[this]:this.getChildrenIntersectingRegion(o,e)}getLeavesIntersectingRegion(o,e){let r=[],n=[];for(n.push(this);n.length>0;){let a=n.pop().getChildrenOrSelfIntersectingRegion(o,e);for(let l of a)l.content?r.push(l):n.push(l)}return r}getChildWithContent(o){let e=this.getLeavesIntersectingRegion(o.getBBox());for(let r of e)if(r.getContent()===o)return r;return null}getLeaves(){if(this.content)return[this];let o=[];for(let e of this.children)o.push(...e.getLeaves());return o}addLeaf(o){if(this.onContentChange(),this.content===null&&this.children.length===0)return this.content=o,this.recomputeBBox(!0),this;if(this.content!==null){console.assert(this.children.length===0);let i=new s(this);i.content=this.content,this.content=null,this.children.push(i),i.recomputeBBox(!1)}let e=o.getBBox();if(e.containsRect(this.getBBox())){let i=new s(this);if(this.children.length<this.targetChildCount)this.children.push(i);else{let a=new s(this);a.children=this.children,this.children=[i,a],a.updateParents(),a.recomputeBBox(!0)}return i.addLeaf(o)}let r=this.children.filter(i=>i.getBBox().containsRect(e));if(r.length>0&&this.children.length>=this.targetChildCount){r.sort((a,l)=>a.getBBox().area-l.getBBox().area);let i=r[0].addLeaf(o);return i.rebalance(),i}let n=s.createLeafNode(this,o);return this.children.push(n),n.recomputeBBox(!0),this.children.length>=this.targetChildCount&&this.rebalance(),n}static createLeafNode(o,e){let r=new s(o);return r.content=e,r}getBBox(){return this.bbox}recomputeBBox(o){let e=this.bbox;this.content!==null?this.bbox=this.content.getBBox():this.bbox=I.union(...this.children.map(r=>r.getBBox())),o&&!e.eq(this.bbox)&&(this.bbox.containsRect(e)?this.parent?.unionBBoxWith(this.bbox):this.parent?.recomputeBBox(!0)),this.checkRep()}unionBBoxWith(o){this.bbox=this.bbox.union(o),this.parent?.unionBBoxWith(o)}updateParents(o=!1){for(let e of this.children)e.parent=this,o&&e.updateParents(o)}rebalance(){if(this.parent&&this.parent.children.length===1){console.assert(this.parent.content===null),console.assert(this.parent.children[0]===this);let o=this.parent;if(o.parent!==null){let e=o.parent;e.children=e.children.filter(r=>r!==o),o.parent=null,o.children=[],this.parent=e,e.children.push(this),this.parent.recomputeBBox(!1)}else this.content===null&&(this.parent.children=this.children,this.parent.updateParents(),this.parent=null)}if(this.children.length>this.targetChildCount*10){let o=this.getBBox().divideIntoGrid(4,4),e=[];for(;e.length<o.length;)e.push(0);for(let a of this.children)for(let l=0;l<o.length;l++)o[l].containsRect(a.getBBox())&&e[l]++;let r=0,n=e[0];for(let a=1;a<e.length;a++)e[a]>n&&(r=a,n=e[a]);let i=o[r];if(n>4){let a=[],l=[];for(let c of this.children)i.containsRect(c.getBBox())?l.push(c):a.push(c);if(l.length<this.children.length){this.children=a;let c=new s(this);this.children.push(c),c.children=l,c.updateParents(!1),c.recomputeBBox(!1),c.rebalance()}}}this.parent&&this.children.length===0&&this.content===null&&this.remove()}removeChild(o){this.checkRep();let e=this.children.length;this.children=this.children.filter(r=>r!==o),console.assert(this.children.length===e-1,`${e-1} \u2260 ${this.children.length} after removing all nodes equal to ${o}. Nodes should only be removed once.`),this.children.forEach(r=>{r.rebalance()}),this.recomputeBBox(!0),this.rebalance(),this.checkRep()}remove(){if(this.content?.onRemoveFromImage(),!this.parent){this.content=null,this.children=[];return}this.parent.removeChild(this),this.parent=null,this.content=null,this.children=[],this.checkRep()}async renderAllAsync(o,e){let r=this.getLeaves();Tt(r);let n=r.length;for(let i=0;i<n;i++){let l=r[i].getContent();if(!l)continue;if(!await e(l,i,n))return!1;l.render(o,void 0)}return!0}render(o,e){let r;e?r=this.getLeavesIntersectingRegion(e,i=>o.isTooSmallToRender(i)):r=this.getLeaves(),Tt(r);let n=Ln(r);for(let i=n;i<r.length;i++)r[i].getContent().render(o,e);xr&&e&&(n!==0&&console.log("EditorImage: skipped ",n,"nodes due to occlusion"),this.renderDebugBoundingBoxes(o,e))}renderDebugBoundingBoxes(o,e,r=0){let n=this.getBBox(),i=1/(o.getSizeOfCanvasPixelOnScreen()||1);if(n.maxDimension<3*i||!n.intersects(e))return;o.startObject(n);let a=!!this.content,l=a?L.ofRGBA(1,0,1,.4):L.ofRGBA(0,1,Math.sin(r),.6),c=a?1*i:2*i;if(o.drawRect(n.intersection(e),c,{fill:l}),o.endObject(),n.maxDimension>e.maxDimension/3){let d={fontFamily:"monospace",size:n.minDimension/20,renderingStyle:{fill:L.red}};o.drawText(`Depth: ${r}`,k.translation(n.bottomLeft),d)}for(let d of this.children)d.renderDebugBoundingBoxes(o,e,r+1)}checkRep(o=0){if(xr){if(this.parent&&!this.parent.children.includes(this))throw new Error(`Parent does not have this node as a child. (depth: ${o})`);let e=null,r=new Set;for(let i of this.children){if(e??=i.getBBox(),e=e.union(i.getBBox()),i.parent!==this)throw new Error(`Child with bbox ${i.getBBox()} and ${i.children.length} has wrong parent (was ${i.parent}).`);if(r.has(i))throw new Error(`Child ${i} is present twice or more in its parent's child list`);r.add(i)}let n=this.bbox.minDimension/100;if(e&&!this.bbox.eq(e,n))throw new Error(`Wrong bounding box ${e} \\neq ${this.bbox} (depth: ${o})`)}}},wr=class extends Ro{constructor(){super(...arguments);this.fullscreenChildren=[];this.dataComponents=[]}getChildrenIntersectingRegion(e,r){let n=super.getChildrenIntersectingRegion(e);for(let i of this.fullscreenChildren)n.push(i);return n}getChildrenOrSelfIntersectingRegion(e,r){let n=this.getContent();return n&&n.getSizingMode()===1?[this]:super.getChildrenOrSelfIntersectingRegion(e,r)}getLeaves(){let e=super.getLeaves();return this.dataComponents.concat(this.fullscreenChildren,e)}removeChild(e){let r=!1,n=i=>{let a=i===e;return r||=a,!a};this.dataComponents=this.dataComponents.filter(n),this.fullscreenChildren=this.fullscreenChildren.filter(n),r||super.removeChild(e)}getChildWithContent(e){let r=()=>{let n=this.fullscreenChildren.concat(this.dataComponents);for(let i of n)if(i.getContent()===e)return i;return null};return e.getSizingMode()===0?super.getChildWithContent(e)??r():super.getChildWithContent(e)??r()}addLeaf(e){let r=e.getSizingMode();if(r===0)return super.addLeaf(e);if(r===1){this.onContentChange();let n=Ro.createLeafNode(this,e);return this.fullscreenChildren.push(n),n}else if(r===2){this.onContentChange();let n=Ro.createLeafNode(this,e);return this.dataComponents.push(n),n}else{let n=r;throw new Error(`Invalid sizing mode, ${r}`)}}};var Y=(g=>(g[g.ToolEnabled=0]="ToolEnabled",g[g.ToolDisabled=1]="ToolDisabled",g[g.ToolUpdated=2]="ToolUpdated",g[g.UndoRedoStackUpdated=3]="UndoRedoStackUpdated",g[g.CommandDone=4]="CommandDone",g[g.CommandUndone=5]="CommandUndone",g[g.ObjectAdded=6]="ObjectAdded",g[g.ViewportChanged=7]="ViewportChanged",g[g.DisplayResized=8]="DisplayResized",g[g.SelectionUpdated=9]="SelectionUpdated",g[g.ReadOnlyModeToggled=10]="ReadOnlyModeToggled",g[g.ColorPickerToggled=11]="ColorPickerToggled",g[g.ColorPickerColorSelected=12]="ColorPickerColorSelected",g[g.ToolbarDropdownShown=13]="ToolbarDropdownShown",g))(Y||{}),In=(r=>(r[r.CommandDone=0]="CommandDone",r[r.CommandUndone=1]="CommandUndone",r[r.CommandRedone=2]="CommandRedone",r))(In||{});var Ge=(a=>(a[a.Pen=0]="Pen",a[a.Eraser=1]="Eraser",a[a.Touch=2]="Touch",a[a.PrimaryButtonMouse=3]="PrimaryButtonMouse",a[a.RightButtonMouse=4]="RightButtonMouse",a[a.Other=5]="Other",a))(Ge||{}),ke=class s{constructor(o,e,r,n,i,a,l,c){this.screenPos=o;this.canvasPos=e;this.pressure=r;this.isPrimary=n;this.down=i;this.device=a;this.id=l;this.timeStamp=c}snappedToGrid(o){let e=o.snapToGrid(this.canvasPos);return this.withCanvasPosition(e,o)}lockedToXYAxesScreen(o,e){let n=this.screenPos.minus(o),i=w.unitX.times(n.x),a=w.unitY.times(n.y),l;return n.dot(i)>n.dot(a)?l=i:l=a,l=l.plus(o),this.withScreenPosition(l,e)}withScreenPosition(o,e){let r=e.screenToCanvas(o);return this.withCanvasPosition(r,e)}withTimestamp(o){return new s(this.screenPos,this.canvasPos,this.pressure,this.isPrimary,this.down,this.device,this.id,o)}withCanvasPosition(o,e){let r=e.canvasToScreen(o);return new s(r,o,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(o,e,r,n){let i=w.of(o.clientX,o.clientY);if(n){let p=n.getBoundingClientRect();i=i.minus(w.of(p.left,p.top))}let l={mouse:3,pen:0,touch:2}[o.pointerType]??5;l===0&&o.buttons&32&&(l=1);let d=o.timeStamp,u=r.roundPoint(r.screenToCanvas(i));return l===3&&o.buttons&2&&(l=4),new s(i,u,o.pressure??null,o.isPrimary,e,l,o.pointerId,d)}static ofCanvasPoint(o,e,r,n=0,i=0,a=!0,l=null,c=null){let d=r.canvasToScreen(o);return c??=performance.now(),new s(d,o,l,a,e,i,n,c)}static ofScreenPoint(o,e,r,n=0,i=0,a=!0,l=null,c=null){let d=r.screenToCanvas(o);return c??=performance.now(),new s(o,d,l,a,e,i,n,c)}};var ka=()=>new Promise(s=>{requestAnimationFrame(()=>s())}),Ye=ka;var He=(u=>(u[u.PointerDownEvt=0]="PointerDownEvt",u[u.PointerMoveEvt=1]="PointerMoveEvt",u[u.PointerUpEvt=2]="PointerUpEvt",u[u.GestureCancelEvt=3]="GestureCancelEvt",u[u.WheelEvt=4]="WheelEvt",u[u.KeyPressEvent=5]="KeyPressEvent",u[u.KeyUpEvent=6]="KeyUpEvent",u[u.CopyEvent=7]="CopyEvent",u[u.PasteEvent=8]="PasteEvent",u[u.ContextMenu=9]="ContextMenu",u))(He||{}),ji=(s,o)=>({kind:s,key:o.key,code:o.code,ctrlKey:o.ctrlKey||o.metaKey,altKey:o.altKey,shiftKey:o.shiftKey}),zo=s=>ji(6,s),Lo=s=>ji(5,s),oo=s=>s.kind===0||s.kind===1||s.kind===2;var _i={remove(){}},Ra=()=>_i,j=class s{waitForNextUpdate(){return new Promise(o=>{let e=this.onUpdate(r=>{e.remove(),o(r)})})}static fromInitialValue(o){return new Cr(o)}static fromImmutable(o){return{get:()=>o,onUpdate:Ra,onUpdateAndNow:e=>(e(o),_i),waitForNextUpdate:()=>new Promise(()=>{})}}static fromCallback(o,e){let r=new Cr(o()),n=typeof WeakRef<"u"?new WeakRef(r):{deref:()=>r};for(let i of e){let a=i.onUpdate(()=>{let l=n.deref();l?l.set(o()):a.remove()})}return r}static map(o,e,r){let n=s.fromInitialValue(e(o.get())),i=n.get();return o.onUpdate(a=>{i=e(a),n.set(i)}),r&&n.onUpdate(a=>{a!==i&&o.set(r(a))}),n}static union(o){return s.fromCallback(()=>o.map(e=>e.get()),o)}},te=class extends j{static fromProperty(o,e){let r=j.fromInitialValue(o.get()[e]),n=typeof WeakRef<"u"?new WeakRef(r):{deref:()=>r},i=o.onUpdate(a=>{let l=n.deref();l?l.set(a[e]):i.remove()});return r.onUpdate(a=>{o.set({...o.get(),[e]:a})}),r}},Cr=class extends te{#e;#t;constructor(o){super(),this.#e=o,this.#t=[]}set(o){if(this.#e!==o){this.#e=o;for(let e of this.#t)e(o)}}get(){return this.#e}onUpdate(o){return this.#t.push(o),{remove:()=>{this.#t=this.#t.filter(e=>e!==o)}}}onUpdateAndNow(o){return o(this.get()),this.onUpdate(o)}},Tr=j;var K=class{constructor(o,e){this.notifier=o;this.description=e;this.#e=j.fromInitialValue(!0),this.#e.onUpdate(r=>{r?(this.#t?.notifyEnabled(this),this.notifier.dispatch(0,{kind:0,tool:this})):this.notifier.dispatch(1,{kind:1,tool:this})})}#e;#t=null;#o=null;#r=null;canReceiveInputInReadOnlyEditor(){return!1}setInputMapper(o){this.#o=o,o&&o.setEmitListener(e=>this.dispatchEventToCallback(e))}getInputMapper(){return this.#o}dispatchEventToCallback(o){let e;switch(o.kind){case 0:return this.onPointerDown(o);case 1:this.onPointerMove(o);break;case 2:return this.onPointerUp(o)??!1;case 3:this.onGestureCancel(o);break;case 4:return this.onWheel(o);case 5:return this.onKeyPress(o);case 6:return this.onKeyUp(o);case 7:return this.onCopy(o);case 8:return this.onPaste(o);case 9:return this.onContextMenu(o);default:return e=o,e}return!0}onEvent(o){return this.#o?this.#o.onEvent(o):this.dispatchEventToCallback(o)}onPointerDown(o){return!1}onPointerMove(o){}onPointerUp(o){}onGestureCancel(o){}onWheel(o){return!1}onCopy(o){return!1}onPaste(o){return!1}onKeyPress(o){return!1}onKeyUp(o){return!1}onContextMenu(o){return!1}eventCanBeDeliveredToNonActiveTool(o){return!0}setEnabled(o){this.#e.set(o)}isEnabled(){return this.#e.get()}enabledValue(){return this.#e}setToolGroup(o){this.isEnabled()&&o.notifyEnabled(this),this.#t=o}getToolGroup(){return this.#t?this.#t:null}onDestroy(){this.#r?.remove(),this.#r=null,this.#t=null}};var qi={updatedViewport:"Transformed Viewport",transformedElements:s=>`Transformed ${s} element${s===1?"":"s"}`,resizeOutputCommand:s=>`Resized image to ${s.w}x${s.h}`,enabledAutoresizeOutputCommand:"Enabled output autoresize",disabledAutoresizeOutputCommand:"Disabled output autoresize",addElementAction:s=>`Added ${s}`,eraseAction:(s,o)=>`Erased ${o} ${s}`,duplicateAction:(s,o)=>`Duplicated ${o} ${s}`,unionOf:(s,o)=>`Union: ${o} ${s}`,inverseOf:s=>`Inverse of ${s}`,elements:"Elements",erasedNoElements:"Erased nothing",duplicatedNoElements:"Duplicated nothing",rotatedBy:s=>`Rotated by ${Math.abs(s)} degrees ${s<0?"clockwise":"counter-clockwise"}`,movedLeft:"Moved left",movedUp:"Moved up",movedDown:"Moved down",movedRight:"Moved right",zoomedOut:"Zoomed out",zoomedIn:"Zoomed in",andNMoreCommands:s=>`And ${s} more commands.`,selectedElements:s=>`Selected ${s} element${s===1?"":"s"}`};var Zi={unlabeledImageNode:"Unlabeled image node",stroke:"Stroke",svgObject:"SVG Object",emptyBackground:"Empty background",gridBackground:"Grid background",filledBackgroundWithColor:s=>`Filled background (${s})`,text:s=>`Text object: ${s}`,imageNode:s=>`Image: ${s}`,restyledElement:s=>`Restyled ${s}`};var Yi={pathNodeCount:s=>`There are ${s} visible path objects.`,textNodeCount:s=>`There are ${s} visible text nodes.`,imageNodeCount:s=>`There are ${s} visible image nodes.`,textNode:s=>`Text: ${s}`,imageNode:s=>`Image: ${s}`,unlabeledImageNode:"Unlabeled image",rerenderAsText:"Re-render as text"};var Xi={help:"Help",helpHidden:"Help hidden",next:"Next",previous:"Previous",close:"Close",helpScreenNavigationHelp:"Click on a control for more information."};var ro={...Xi,pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text",decreaseImageSize:"Decrease size",resetImage:"Reset",chooseFile:"Choose file",dragAndDropHereOrBrowse:`Drag and drop here
|
5
|
+
or
|
6
|
+
{{browse}}`,submit:"Submit",addAll:"Add all",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",fullStrokeEraser:"Full stroke eraser",selectPenType:"Pen type",selectShape:"Shape",pickColorFromScreen:"Pick color from screen",clickToPickColorAnnouncement:"Click on the screen to pick a color",colorSelectionCanceledAnnouncement:"Color selection canceled",selectionTool__lassoSelect:"Freeform selection",selectionTool__lassoSelect__help:"When enabled, dragging creates a freeform (lasso) selection.",selectionToolKeyboardShortcuts:"Selection tool: Use arrow keys to move selected items, lowercase/uppercase \u2018i\u2019 and \u2018o\u2019 to resize.",documentProperties:"Page",backgroundColor:"Background color",imageWidthOption:"Width",imageHeightOption:"Height",useGridOption:"Grid",enableAutoresizeOption:"Auto-resize",toggleOverflow:"More",about:"About",inputStabilization:"Stabilization",strokeAutocorrect:"Autocorrect",touchPanning:"Scroll with touch",roundedTipPen:"Round",roundedTipPen2:"Polyline",flatTipPen:"Flat",arrowPen:"Arrow",linePen:"Line",outlinedRectanglePen:"Outlined rectangle",filledRectanglePen:"Filled rectangle",outlinedCirclePen:"Outlined circle",lockRotation:"Lock rotation",paste:"Paste",errorImageHasZeroSize:"Error: Image has zero size",describeTheImage:"Image description",fileInput__loading:"Loading...",fileInput__andNMoreFiles:s=>`(...${s} more)`,penDropdown__baseHelpText:"This tool draws shapes or freehand lines.",penDropdown__colorHelpText:"Changes the pen's color",penDropdown__thicknessHelpText:"Changes the thickness of strokes drawn by the pen.",penDropdown__penTypeHelpText:`Changes the pen style.
|
7
|
+
|
8
|
+
Either a \u201Cpen\u201D style or \u201Cshape\u201D can be chosen. Choosing a \u201Cpen\u201D style draws freehand lines. Choosing a \u201Cshape\u201D draws shapes.`,penDropdown__autocorrectHelpText:`Converts approximate freehand lines and rectangles to perfect ones.
|
9
|
+
|
10
|
+
The pen must be held stationary at the end of a stroke to trigger a correction.`,penDropdown__stabilizationHelpText:`Draws smoother strokes.
|
11
|
+
|
12
|
+
This also adds a short delay between the mouse/stylus and the stroke.`,handDropdown__baseHelpText:"This tool is responsible for scrolling, rotating, and zooming the editor.",handDropdown__zoomInHelpText:"Zooms in.",handDropdown__zoomOutHelpText:"Zooms out.",handDropdown__resetViewHelpText:"Resets the zoom level to 100% and resets scroll.",handDropdown__zoomDisplayHelpText:"Shows the current zoom level. 100% shows the image at its actual size.",handDropdown__touchPanningHelpText:"When enabled, touchscreen gestures move the image rather than select or draw.",handDropdown__lockRotationHelpText:"When enabled, prevents touch gestures from rotating the screen.",eraserDropdown__baseHelpText:"This tool removes strokes, images, and text under the cursor.",eraserDropdown__thicknessHelpText:"Changes the size of the eraser.",eraserDropdown__fullStrokeEraserHelpText:`When in full-stroke mode, entire shapes are erased.
|
13
|
+
|
14
|
+
When not in full-stroke mode, shapes can be partially erased.`,selectionDropdown__baseHelpText:"Selects content and manipulates the selection",selectionDropdown__resizeToHelpText:`Crops the drawing to the size of what's currently selected.
|
15
|
+
|
16
|
+
If auto-resize is enabled, it will be disabled.`,selectionDropdown__deleteHelpText:"Erases selected items.",selectionDropdown__duplicateHelpText:"Makes a copy of selected items.",selectionDropdown__changeColorHelpText:"Changes the color of selected items.",pageDropdown__baseHelpText:"Controls the drawing canvas' background color, pattern, and size.",pageDropdown__backgroundColorHelpText:"Changes the background color of the drawing canvas.",pageDropdown__gridCheckboxHelpText:"Enables/disables a background grid pattern.",pageDropdown__autoresizeCheckboxHelpText:`When checked, the page grows to fit the drawing.
|
17
|
+
|
18
|
+
When unchecked, the page is visible and its size can be set manually.`,pageDropdown__aboutButtonHelpText:"Shows version, debug, and other information.",colorPickerPipetteHelpText:"Picks a color from the screen.",colorPickerToggleHelpText:"Opens/closes the color picker.",closeSidebar:s=>`Close sidebar for ${s}`,dropdownShown:s=>`Menu for ${s} shown`,dropdownHidden:s=>`Menu for ${s} hidden`,zoomLevel:s=>`Zoom: ${s}%`,colorChangedAnnouncement:s=>`Color changed to ${s}`,imageSize:(s,o)=>`Image size: ${s} ${o}`,imageLoadError:s=>`Error loading image: ${s}`};var Qi={penTool:s=>`Pen ${s}`,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",selectionMenu__show:"Show selection menu",selectionMenu__copyToClipboard:"Copy to clipboard",selectionMenu__duplicate:"Duplicate",selectionMenu__delete:"Delete",selectionMenu__paste:"Paste",copyPasteError__heading:"Copy/paste",copyPasteError__description:"Something went wrong \u2014 this tool may not have clipboard access.",copyPasteError__errorDetails:"Show error",copyPasteError__pasteRetry:"To retry, please paste into the input box below:",copyPasteError__copyRetry:"To retry, please copy the text in the input box below:",copyPasteError__copyMe:"Copy me!",autocorrectedTo:s=>`Autocorrected to ${s}`,autocorrectionCanceled:"Autocorrect cancelled",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:(s,o)=>`Viewing match ${s} of ${o}`,anyDevicePanning:"Any device panning",copied:s=>`Copied ${s} item(s)`,pasted:s=>`Pasted ${s} item(s)`,toolEnabledAnnouncement:s=>`${s} enabled`,toolDisabledAnnouncement:s=>`${s} disabled`};var Xe={...ro,...Qi,...qi,...Zi,...Yi,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:s=>`Loading ${s}%...`,imageEditor:"Image Editor",doneLoading:"Done loading",undoAnnouncement:s=>`Undid ${s}`,redoAnnouncement:s=>`Redid ${s}`,softwareLibraries:"Libraries",developerInformation:"Developer information"};var za={...Xe,pen:"Stift",eraser:"Radierer",select:"Auswahl",handTool:"Verschieben",zoom:"Vergr\xF6\xDFerung",image:"Bild",inputAltText:"Alt-Text: ",chooseFile:"W\xE4hle Datei: ",submit:"Absenden",cancel:"Abbrechen",resetView:"Ansicht zur\xFCcksetzen",thicknessLabel:"Dicke: ",colorLabel:"Farbe: ",fontLabel:"Schriftart: ",textSize:"Gr\xF6\xDFe: ",resizeImageToSelection:"Bildgr\xF6\xDFe an Auswahl anpassen",deleteSelection:"Auswahl l\xF6schen",duplicateSelection:"Auswahl duplizieren",undo:"R\xFCckg\xE4ngig",redo:"Wiederholen",pickColorFromScreen:"Farbe von Bildschirm ausw\xE4hlen",clickToPickColorAnnouncement:"Klicke auf den Bildschirm, um eine Farbe auszuw\xE4hlen",selectionToolKeyboardShortcuts:"Auswahl-Werkzeug: Verwende die Pfeiltasten, um ausgew\xE4hlte Elemente zu verschieben und \u201Ai\u2018 und \u201Ao\u2018, um ihre Gr\xF6\xDFe zu \xE4ndern.",touchPanning:"Ansicht mit Touchscreen verschieben",anyDevicePanning:"Ansicht mit jedem Eingabeger\xE4t verschieben",selectPenType:"Objekt-Typ: ",roundedTipPen:"Freihand",flatTipPen:"Stift (druckempfindlich)",arrowPen:"Pfeil",linePen:"Linie",outlinedRectanglePen:"Umrissenes Rechteck",filledRectanglePen:"Ausgef\xFClltes Rechteck",lockRotation:"Sperre Rotation",paste:"Einf\xFCgen",dropdownShown:s=>`Dropdown-Men\xFC f\xFCr ${s} angezeigt`,dropdownHidden:s=>`Dropdown-Men\xFC f\xFCr ${s} versteckt`,zoomLevel:s=>`Verg\xF6\xDFerung: ${s}%`,colorChangedAnnouncement:s=>`Farbe zu ${s} ge\xE4ndert`,imageSize:(s,o)=>`Bild-Gr\xF6\xDFe: ${s} ${o}`,imageLoadError:s=>`Fehler beim Laden des Bildes: ${s}`,errorImageHasZeroSize:"Fehler: Bild hat Gr\xF6\xDFe Null",penTool:s=>`Stift ${s}`,selectionTool:"Auswahl",eraserTool:"Radiergummi",touchPanTool:"Ansicht mit Touchscreen verschieben",twoFingerPanZoomTool:"Ansicht verschieben und vergr\xF6\xDFern",undoRedoTool:"R\xFCckg\xE4ngig/Wiederholen",rightClickDragPanTool:"Rechtsklick-Ziehen",pipetteTool:"Farbe von Bildschirm ausw\xE4hlen",keyboardPanZoom:"Tastaturk\xFCrzel zum Verschieben/Vergr\xF6\xDFern der Ansicht",textTool:"Text",enterTextToInsert:"Einzuf\xFCgender Text",changeTool:"Wechsle Werkzeug",pasteHandler:"Copy-Paste-Handler",findLabel:"Finde",toNextMatch:"N\xE4chstes",closeDialog:"Schlie\xDFen",findDialogShown:"Finde-Dialog angezeigt",findDialogHidden:"Finde-Dialog versteckt",focusedFoundText:(s,o)=>`Sieh Treffer ${s} von ${o} an`,toolEnabledAnnouncement:s=>`${s} aktiviert`,toolDisabledAnnouncement:s=>`${s} deaktiviert`,updatedViewport:"Transformierte Ansicht",transformedElements:s=>`${s} Element${s===1?"":"e"} transformiert`,resizeOutputCommand:s=>`Bildgr\xF6\xDFe auf ${s.w}x${s.h} ge\xE4ndert`,addElementAction:s=>`${s} hinzugef\xFCgt`,eraseAction:(s,o)=>`${o} ${s} gel\xF6scht`,duplicateAction:(s,o)=>`${o} ${s} dupliziert`,inverseOf:s=>`${s} umgekehrt`,elements:"Elemente",erasedNoElements:"Nichts entfernt",duplicatedNoElements:"Nichts dupliziert",rotatedBy:s=>`${Math.abs(s)} Grad ${s<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\xF6\xDFert",selectedElements:s=>`${s} Element${s===1?"":"e"} ausgew\xE4hlt`,stroke:"Strich",svgObject:"SVG-Objekt",text:s=>`Text-Objekt: ${s}`,pathNodeCount:s=>`Es gibt ${s} sichtbare Pfad-Objekte.`,textNodeCount:s=>`Es gibt ${s} sichtbare Text-Knotenpunkte.`,textNode:s=>`Text: ${s}`,imageNodeCount:s=>`Es gibt ${s} sichtbare Bild-Knoten.`,imageNode:s=>`Bild: ${s}`,unlabeledImageNode:"Bild ohne Label",rerenderAsText:"Als Text darstellen",accessibilityInputInstructions:"Dr\xFCcke \u201At\u2018, 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\xFCcke \u201Aw\u2018 zum Vergr\xF6\xDFern und \u201As\u2018 zum Verkleinern der Ansicht.",loading:s=>`Laden ${s}%...`,doneLoading:"Laden fertig",imageEditor:"Bild-Editor",undoAnnouncement:s=>`${s} r\xFCckg\xE4ngig gemacht`,redoAnnouncement:s=>`${s} wiederholt`,reformatSelection:"Formatiere Auswahl",documentProperties:"Seite",backgroundColor:"Hintergrundfarbe: ",imageWidthOption:"Breite: ",imageHeightOption:"H\xF6he: ",useGridOption:"Gitter: ",toggleOverflow:"Mehr",selectAllTool:"Alle ausw\xE4hlen",soundExplorer:"Klangbasierte Bilderkundung",disableAccessibilityExploreTool:"Deaktiviere klangbasierte Erkundung",enableAccessibilityExploreTool:"Aktiviere klangbasierte Erkundung",unionOf:(s,o)=>`Vereinigung: ${o} ${s}`,emptyBackground:"Leerer Hintergrund",filledBackgroundWithColor:s=>`Gef\xFCllter Hintergrund (${s})`,restyledElement:s=>`${s} umgestaltet`},Ji=za;var La={...Xe},es=La;var Ia={...Xe,pen:"Lapiz",eraser:"Borrador",select:"Selecciona",handTool:"Mover",image:"Imagen",inputAltText:"Texto alternativo",resetImage:"Reiniciar",chooseFile:"Seleccionar archivo",cancel:"Cancelar",resetView:"Reiniciar vista",thicknessLabel:"Tama\xF1o",fontLabel:"Fuente:",textSize:"Tama\xF1o",resizeImageToSelection:"Redimensionar la imagen a lo que est\xE1 seleccionado",deleteSelection:"Borra la selecci\xF3n",duplicateSelection:"Duplica la selecci\xF3n",exit:"Salir",save:"Guardar",undo:"Deshace",redo:"Rehace",selectPenType:"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",enableAutoresizeOption:"Redimensionar autom\xE1tico",toggleOverflow:"M\xE1s",about:"Acerca de",touchPanning:"Mover la pantalla con un dedo",roundedTipPen:"Lapiz Redondeado",arrowPen:"Flecha",linePen:"L\xEDnea",outlinedRectanglePen:"Rect\xE1ngulo delineado",filledRectanglePen:"Rect\xE1ngulo sin borde",lockRotation:"Bloquea rotaci\xF3n",paste:"Pegar",selectionMenu__paste:"Pegar",selectionMenu__delete:"Eliminar",selectionMenu__duplicate:"Duplicar",closeSidebar:s=>`Close sidebar for ${s}`,dropdownShown:s=>`Men\xFA por ${s} es visible`,dropdownHidden:s=>`Men\xFA por ${s} fue ocultado`,zoomLevel:s=>`Zoom: ${s}%`,colorChangedAnnouncement:s=>`Color fue cambiado a ${s}`,imageSize:(s,o)=>`Tama\xF1o del imagen: ${s} ${o}`,imageLoadError:s=>`Error cargando imagen: ${s}`,penTool:s=>`Lapiz ${s}`,selectionTool:"Selecciona",eraserTool:"Borrador",touchPanTool:"Instrumento de mover la pantalla con un dedo",undoRedoTool:"Deshace/rehace",pipetteTool:"Seleccione un color de la pantalla",keyboardPanZoom:"Mover la pantalla con el teclado",textTool:"Texto",enterTextToInsert:"Entra texto",findLabel:"Buscar",toNextMatch:"Pr\xF3xima",closeDialog:"Cerrar",anyDevicePanning:"Mover la pantalla con todo dispotivo",copied:s=>`${s} cosas fueron copiados`,pasted:s=>s===1?"Pegado":`${s} cosas fueron pegados`,toolEnabledAnnouncement:s=>`${s} fue activado`,toolDisabledAnnouncement:s=>`${s} fue desactivado`,resizeOutputCommand:s=>`Tama\xF1o de imagen fue cambiado a ${s.w}x${s.h}`,eraseAction:(s,o)=>`Borrado: ${o} ${s}`,rerenderAsText:"Redibuja la pantalla al texto",loading:s=>`Cargando: ${s}%...`,imageEditor:"Editor de dibujos",doneLoading:"El cargado termin\xF3",undoAnnouncement:s=>`${s} fue deshecho`,redoAnnouncement:s=>`${s} fue rehecho`},ts=Ia;var Ba={de:Ji,en:es,es:ts},Ma=s=>{let o=/^(\w+)[_-](\w+)$/.exec(s);return o?o[1]:s},Io=(s,o,e)=>{let r;for(let n of s){let i=Ma(n);if(r&&i!==r&&r in o)return o[r];if(n in o)return o[n];r=i}return r&&r in o?o[r]:e},Da=s=>(s??=navigator.languages,Io(s,Ba,Xe)),Sr=Da;var os=s=>s.toUpperCase()===s&&s.toLowerCase()!==s&&s.length===1,rs=s=>s.toLowerCase()===s&&s.toUpperCase()!==s&&s.length===1,St=class s{constructor(o){this.key=o.key,this.shiftKey=o.shiftKey,this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.metaKey=o.metaKey,this.controlOrMeta=o.controlOrMeta}matchesEvent(o){let e=o.key?.toLowerCase(),r=os(o.key??""),n=rs(o.key??""),i=(o.ctrlKey??!1)||e==="control",a=(o.altKey??!1)||e==="alt",l=(o.metaKey??!1)||e==="meta",c=(o.shiftKey??r)||e==="shift",d=o.controlOrMeta||o.ctrlKey||o.metaKey||!1;if(this.key!==o.code&&(this.key.toLowerCase()!==e||(r||n)&&this.key!==o.key&&!(this.shiftKey===!0&&this.key.toUpperCase()===o.key)))return!1;let u=this.controlOrMeta;return(i===this.ctrlKey&&l===this.metaKey&&!u||u&&d)&&a===this.altKey&&(c===this.shiftKey||this.shiftKey===void 0)}toString(){let o=[];return this.ctrlKey&&this.key!=="control"&&o.push("Ctrl"),this.controlOrMeta&&o.push("CtrlOrMeta"),this.altKey&&this.key!=="alt"&&o.push("Alt"),this.metaKey&&this.key!=="meta"&&o.push("Meta"),this.shiftKey&&this.key!=="shift"&&o.push("Shift"),o.push(this.key),o.join("+")}static fromString(o){let e=v=>{let b;os(v)?b=!0:(rs(v)||v.length>1)&&(b=!1);let y=v.toLowerCase();return y==="shift"&&(b=!0),{shiftKey:b,ctrlKey:y==="control"||y==="ctrl",altKey:y==="alt",metaKey:y==="meta",controlOrMeta:y==="control or meta"||y==="ctrlormeta"}};if(o.search(/[-+]/)===-1||o.length===1){let v=e(o);return new s({key:o,...v})}let i=/^(.*[-+])?(.+)$/g.exec(o);if(!i)throw new Error(`Invalid shortcut expression, ${o}!`);let a=i[2],l=e(a),c=(i[1]??"").split(/[-+]/),d=l.shiftKey,u=l.ctrlKey,p=l.altKey,h=l.metaKey,m=l.controlOrMeta;for(let v of c)if(v!=="")switch(v.toLowerCase()){case"shift":d=!0;break;case"anyshift":d=void 0;break;case"ctrl":case"control":u=!0;break;case"meta":h=!0;break;case"ctrlormeta":case"ctrl or meta":case"controlormeta":m=!0;break;case"alt":p=!0;break;default:throw new Error(`Unknown modifier: "${v}" in shortcut ${o}.`)}return new s({key:a,shiftKey:d,ctrlKey:u,altKey:p,metaKey:h,controlOrMeta:m})}};var H=class s{constructor(o){this.shortcutOverrides=Object.create(null);for(let e in o)this.overrideShortcut(e,o[e])}static{this.shortcuts=Object.create(null)}static{this.shortcutDefaultDescriptions=Object.create(null)}static{this.shortcutLocalizedDescriptions=Object.create(null)}overrideShortcut(o,e){this.shortcutOverrides[o]=[...e]}matchesShortcut(o,e){let r=this.shortcutOverrides[o];if(!r)if(o in s.shortcuts)r=s.shortcuts[o];else throw new Error(`No shortcut with ID ${o} exists!`);for(let n of r)if(n.matchesEvent(e))return!0;return!1}static registerDefaultKeyboardShortcut(o,e,r){if(o in s.shortcuts)return!1;let n=e.map(i=>typeof i=="string"?St.fromString(i):i);return s.shortcuts[o]=[...n],s.shortcutDefaultDescriptions[o]=r,!0}static provideShortcutDescription(o,e,r){e in s.shortcutLocalizedDescriptions||(s.shortcutLocalizedDescriptions[e]=Object.create(null)),s.shortcutLocalizedDescriptions[e][o]=r}static getAllShortcutIds(){let o=[];for(let e in this.shortcuts)o.push(e);return o}static getShortcutDefaultKeybindings(o){if(!(o in s.shortcuts))throw new Error(`No shortcut with ID ${o} exists!`);return s.shortcuts[o]}static getShortcutDescription(o,e){return Io(e??[],this.shortcutLocalizedDescriptions,this.shortcutDefaultDescriptions)[o]??this.shortcutDefaultDescriptions[o]??null}};var no="jsdraw.tools.SelectionTool.selectAll";H.registerDefaultKeyboardShortcut(no,["CtrlOrMeta+KeyA"],"Select all");var Pr="jsdraw.tools.SelectionTool.duplicateSelection";H.registerDefaultKeyboardShortcut(Pr,["CtrlOrMeta+KeyD"],"Duplicate selection");var Er="jsdraw.tools.SelectionTool.sendToBack";H.registerDefaultKeyboardShortcut(Er,["End"],"Send to back");var Bn="jsdraw.tools.SelectionTool.translateLeft";H.registerDefaultKeyboardShortcut(Bn,["KeyA","KeyH","ArrowLeft"],"Move selection left");var Mn="jsdraw.tools.SelectionTool.translateRight";H.registerDefaultKeyboardShortcut(Mn,["KeyD","KeyL","ArrowRight"],"Move selection right");var Dn="jsdraw.tools.SelectionTool.translateUp";H.registerDefaultKeyboardShortcut(Dn,["KeyQ","KeyK","ArrowUp"],"Move selection up");var An="jsdraw.tools.SelectionTool.translateDown";H.registerDefaultKeyboardShortcut(An,["KeyE","KeyJ","ArrowDown"],"Move selection down");var Vn="jsdraw.tools.SelectionTool.rotateCCW";H.registerDefaultKeyboardShortcut(Vn,["Shift+KeyR"],"Rotate selection counter clockwise");var On="jsdraw.tools.SelectionTool.rotateCW";H.registerDefaultKeyboardShortcut(On,["KeyR"],"Rotate selection clockwise");var Fn="jsdraw.tools.SelectionTool.shrink.x";H.registerDefaultKeyboardShortcut(Fn,["KeyI"],"Decrease width");var Hn="jsdraw.tools.SelectionTool.stretch.x";H.registerDefaultKeyboardShortcut(Hn,["Shift+KeyI"],"Increase width");var Nn="jsdraw.tools.SelectionTool.shrink.y";H.registerDefaultKeyboardShortcut(Nn,["KeyO"],"Decrease height");var $n="jsdraw.tools.SelectionTool.stretch.y";H.registerDefaultKeyboardShortcut($n,["Shift+KeyO"],"Increase height");var Un="jsdraw.tools.SelectionTool.shrink.xy";H.registerDefaultKeyboardShortcut(Un,["Comma"],"Decrease selection size");var Wn="jsdraw.tools.SelectionTool.stretch.xy";H.registerDefaultKeyboardShortcut(Wn,["Period"],"Increase selection size");var Bo="jsdraw.tools.undo",Kn="jsdaw.tools.redo";H.registerDefaultKeyboardShortcut(Bo,["CtrlOrMeta+KeyZ"],"Undo");H.registerDefaultKeyboardShortcut(Kn,["CtrlOrMeta+Shift+KeyZ","CtrlOrMeta+KeyY"],"Redo");var Mo="jsdraw.tools.increaseSize";H.registerDefaultKeyboardShortcut(Mo,["Equal","Shift+Equal"],"Increase pen/eraser size");var Do="jsdraw.tools.decreaseSize";H.registerDefaultKeyboardShortcut(Do,["Minus","Shift+Minus"],"Decrease pen/eraser size");var io="jsdraw.tools.snapToGrid";H.registerDefaultKeyboardShortcut(io,["Control","Meta"],"Snap to grid (press and hold)");var Gn="jsdraw.tools.lockToLine";H.registerDefaultKeyboardShortcut(Gn,["Shift"],"Snap to XY axes (press and hold)");var kr="js-draw.tools.FindTool.toggleVisible";H.registerDefaultKeyboardShortcut(kr,["CtrlOrMeta+KeyF"],"Shows/hides the find tool");var jn="jsdraw.tools.PanZoom.moveLeft";H.registerDefaultKeyboardShortcut(jn,["ArrowLeft","KeyH","KeyA"],"Pan left");var _n="jsdraw.tools.PanZoom.moveRight";H.registerDefaultKeyboardShortcut(_n,["ArrowRight","KeyL","KeyD"],"Pan right");var qn="jsdraw.tools.PanZoom.moveUp";H.registerDefaultKeyboardShortcut(qn,["ArrowUp","KeyK","KeyQ"],"Pan up");var Zn="jsdraw.tools.PanZoom.moveDown";H.registerDefaultKeyboardShortcut(Zn,["ArrowDown","KeyJ","KeyE"],"Pan down");var Yn="jsdraw.tools.PanZoom.rotateViewClockwise";H.registerDefaultKeyboardShortcut(Yn,["Shift+KeyR"],"Rotate viewport clockwise");var Xn="jsdraw.tools.PanZoom.rotateViewCounterClockwise";H.registerDefaultKeyboardShortcut(Xn,["KeyR"],"Rotate viewport counter-clockwise");var Qn="jsdraw.tools.PanZoom.zoomIn";H.registerDefaultKeyboardShortcut(Qn,["KeyW"],"Zoom in");var Jn="jsdraw.tools.PanZoom.zoomOut";H.registerDefaultKeyboardShortcut(Jn,["KeyS"],"Zoom out");var Ao=(a=>(a[a.OneFingerTouchGestures=1]="OneFingerTouchGestures",a[a.TwoFingerTouchGestures=2]="TwoFingerTouchGestures",a[a.RightClickDrags=4]="RightClickDrags",a[a.SinglePointerGestures=8]="SinglePointerGestures",a[a.Keyboard=16]="Keyboard",a[a.RotationLocked=32]="RotationLocked",a))(Ao||{}),ei=class{constructor(o,e,r){this.initialVelocity=o;this.scrollBy=e;this.onComplete=r;this.running=!1;this.start()}async start(){if(this.running)return;this.currentVelocity=this.initialVelocity;let o=performance.now();this.running=!0;let e=5e3,r=200;for(this.currentVelocity.magnitude()>e&&(this.currentVelocity=this.currentVelocity.normalized().times(e));this.running&&this.currentVelocity.magnitude()>r;){let n=performance.now(),i=(n-o)/1e3;this.currentVelocity=this.currentVelocity.times(Math.pow(1/8,i)),this.scrollBy(this.currentVelocity.times(i)),await Ye(),o=n}this.running&&this.stop()}getCurrentVelocity(){return this.running?this.currentVelocity:null}stop(){this.running&&(this.running=!1,this.onComplete())}},Ce=class extends K{constructor(e,r,n){super(e.notifier,n);this.editor=e;this.mode=r;this.transform=null;this.initialRotationSnapAngle=.22;this.afterRotationStartSnapAngle=.07;this.pinchZoomStartThreshold=1.08;this.lastPointerDownTimestamp=0;this.initialTouchAngle=0;this.initialViewportRotation=0;this.initialViewportScale=0;this.isScaling=!1;this.isRotating=!1;this.inertialScroller=null;this.velocity=null}canReceiveInputInReadOnlyEditor(){return!0}computePinchData(e,r){if(e.id<r.id){let d=e;e=r,r=d}let n=r.screenPos.minus(e.screenPos),i=n.angle(),a=n.magnitude(),l=r.canvasPos.plus(e.canvasPos).times(.5),c=r.screenPos.plus(e.screenPos).times(.5);return{canvasCenter:l,screenCenter:c,angle:i,dist:a}}allPointersAreOfType(e,r){return e.every(n=>n.device===r)}onPointerDown({allPointers:e,current:r}){let n=!1,i=this.inertialScroller?.getCurrentVelocity()??w.zero;this.inertialScroller?.stop(),this.velocity=i,this.lastPointerDownTimestamp=r.timeStamp;let a=this.allPointersAreOfType(e,2),l=this.allPointersAreOfType(e,4);if(a&&e.length===2&&this.mode&2){let{screenCenter:c,angle:d,dist:u}=this.computePinchData(e[0],e[1]);this.lastTouchDist=u,this.startTouchDist=u,this.lastScreenCenter=c,this.initialTouchAngle=d,this.initialViewportRotation=this.editor.viewport.getRotationAngle(),this.initialViewportScale=this.editor.viewport.getScaleFactor(),this.isScaling=!1,this.isRotating=Math.abs(Math.sin(this.initialViewportRotation*2))>.001,n=!0}else e.length===1&&(this.mode&1&&a||l&&this.mode&4||this.mode&8)&&(this.lastScreenCenter=e[0].screenPos,this.isScaling=!1,n=!0);return n&&(this.lastTimestamp=performance.now(),this.transform??=Ee.transformBy(k.identity),this.editor.display.setDraftMode(!0)),n}updateVelocity(e){let r=e.minus(this.lastScreenCenter),n=(performance.now()-this.lastTimestamp)/1e3;if(r.magnitude()===0&&n<.1||n===0)return;n=Math.max(n,.01);let i=r.times(1/n),a=i;this.velocity&&(a=this.velocity.lerp(i,.5)),this.velocity=a}getCenterDelta(e){return this.editor.viewport.screenToCanvasTransform.transformVec3(e.minus(this.lastScreenCenter))}toSnappedRotationDelta(e){let n=e-this.initialTouchAngle+this.initialViewportRotation,i=Math.PI/2,a=Math.round(n/i)*i,l=this.isRotating?this.afterRotationStartSnapAngle:this.initialRotationSnapAngle;return Math.abs(n-a)<l&&(n=a,n!==0&&(n+=1e-4)),n-this.editor.viewport.getRotationAngle()}toSnappedScaleFactor(e){let r=this.initialViewportScale*e/this.startTouchDist,n=this.editor.viewport.getScaleFactor(),i=Math.log(r)/Math.log(10),a=Math.round(i);return Math.abs(a-i)<.04?Math.pow(10,a)/n:e/this.lastTouchDist}handleTwoFingerMove(e){let{screenCenter:r,canvasCenter:n,angle:i,dist:a}=this.computePinchData(e[0],e[1]),l=this.getCenterDelta(r),c;if(this.isRotationLocked()?c=0:c=this.toSnappedRotationDelta(i),Math.abs(c)>1e-8&&(this.isRotating=!0),this.updateVelocity(r),!this.isScaling){let p=a/this.startTouchDist,h=this.pinchZoomStartThreshold,m=1/this.pinchZoomStartThreshold;(p>h||p<m)&&(this.isScaling=!0)}let d=1;this.isScaling&&(d=this.toSnappedScaleFactor(a),this.lastTouchDist=a);let u=k.translation(l).rightMul(k.scaling2D(d,n)).rightMul(k.zRotation(c,n));return this.lastScreenCenter=r,this.transform=Ee.transformBy(this.transform.transform.rightMul(u)),u}handleOneFingerMove(e){let r=this.getCenterDelta(e.screenPos),n=k.translation(r);return this.transform=Ee.transformBy(this.transform.transform.rightMul(n)),this.updateVelocity(e.screenPos),this.lastScreenCenter=e.screenPos,n}onPointerMove({allPointers:e}){this.transform??=Ee.transformBy(k.identity);let r=k.identity;e.length===2?r=this.handleTwoFingerMove(e):e.length===1&&(r=this.handleOneFingerMove(e[0])),Ee.transformBy(r).apply(this.editor),this.lastTimestamp=performance.now()}onPointerUp(e){let r=()=>{this.transform&&(this.transform.unapply(this.editor),this.editor.dispatch(this.transform,!1)),this.editor.display.setDraftMode(!1),this.transform=null,this.velocity=w.zero};if(e.current.device===2&&e.allPointers.length===1&&this.velocity!==null&&e.current.timeStamp-this.lastPointerDownTimestamp>30&&this.velocity!==null){let a=this.velocity;this.updateVelocity(e.current.screenPos),a.magnitude()<this.velocity.magnitude()&&(this.velocity=a),this.inertialScroller?.stop(),this.inertialScroller=new ei(this.velocity,l=>{if(!this.transform)return;let c=this.editor.viewport.screenToCanvasTransform.transformVec3(l);this.transform.unapply(this.editor),this.transform=Ee.transformBy(this.transform.transform.rightMul(k.translation(c))),this.transform.apply(this.editor)},r)}else r()}onGestureCancel(){this.inertialScroller?.stop(),this.velocity=w.zero,this.transform?.unapply(this.editor),this.editor.display.setDraftMode(!1),this.transform=null}updateTransform(e,r=!1){let n=e;this.transform&&(n=this.transform.transform.rightMul(e)),this.transform?.unapply(this.editor),this.transform=Ee.transformBy(n),this.transform.apply(this.editor),r&&this.editor.announceForAccessibility(this.transform.description(this.editor,this.editor.localization))}applyAndFinalizeTransform(e){this.updateTransform(e,!0),this.transform=null}onWheel({delta:e,screenPos:r}){this.inertialScroller?.stop(),this.transform=Ee.transformBy(k.identity);let n=this.editor.viewport.screenToCanvas(r),a=this.editor.viewport.screenToCanvasTransform.transformVec3(F.of(-e.x,-e.y,0)),l=e.z;l=Math.atan(l/2)*2;let d=k.scaling2D(Math.max(.4,Math.min(Math.pow(1.04,-l),4)),n).rightMul(k.translation(a));return this.applyAndFinalizeTransform(d),!0}onKeyPress(e){if(this.inertialScroller?.stop(),!(this.mode&16))return!1;this.transform=Ee.transformBy(k.identity);let r=w.zero,n=1,i=0,a=this.editor.shortcuts;if(a.matchesShortcut(jn,e))r=w.of(-1,0);else if(a.matchesShortcut(_n,e))r=w.of(1,0);else if(a.matchesShortcut(qn,e))r=w.of(0,-1);else if(a.matchesShortcut(Zn,e))r=w.of(0,1);else if(a.matchesShortcut(Qn,e))n=1/2;else if(a.matchesShortcut(Jn,e))n=2;else if(a.matchesShortcut(Yn,e))i=1;else if(a.matchesShortcut(Xn,e))i=-1;else return!1;r=r.times(30),i*=Math.PI/8,r=r.times(-1),i=i*-1,n=1/n,i!==0&&(i+=1e-4),this.isRotationLocked()&&(i=0),r=this.editor.viewport.screenToCanvasTransform.transformVec3(r);let c=this.editor.viewport.visibleRect.center,d=k.scaling2D(n,c).rightMul(k.zRotation(i,c)).rightMul(k.translation(r));return this.applyAndFinalizeTransform(d),!0}isRotationLocked(){return!!(this.mode&32)}setModeEnabled(e,r){let n=this.mode;r?n|=e:n&=~e,this.setMode(n)}setMode(e){e!==this.mode&&(this.mode=e,this.editor.notifier.dispatch(2,{kind:2,tool:this}))}getMode(){return this.mode}};var ns=s=>({fill:s.fill,stroke:s.stroke?{...s.stroke}:void 0}),Rr=(s,o)=>(s===o||s.fill.eq(o.fill)&&s.stroke==null==(o.stroke==null)&&(s.stroke?.color?.eq(o.stroke?.color)??!0)&&s.stroke?.width===o.stroke?.width)??!1,zr=s=>{let o=s.stroke?{color:s.stroke.color.toHexString(),width:s.stroke.width}:void 0;return{fill:s.fill.toHexString(),stroke:o}},Lr=s=>{let o=s.stroke?{color:L.fromHex(s.stroke.color),width:s.stroke.width}:void 0;return{fill:L.fromHex(s.fill),stroke:o}};var ti=s=>({...s,renderingStyle:ns(s.renderingStyle)}),Ir=s=>{if(typeof s=="string"&&(s=JSON.parse(s)),typeof s.fontFamily!="string")throw new Error("Serialized textStyle missing string fontFamily attribute!");return{renderingStyle:Lr(s.renderingStyle),size:s.size,fontWeight:s.fontWeight,fontVariant:s.fontVariant,fontFamily:s.fontFamily}},Br=s=>({...s,renderingStyle:zr(s.renderingStyle)});var is=s=>{let o={};return s.color&&(o.color=s.color.toHexString()),s.textStyle&&(o.textStyle=Br(s.textStyle)),o},ss=s=>{let o=s.color?L.fromHex(s.color):void 0,e=s.textStyle?Ir(s.textStyle):void 0;return{color:o,textStyle:e}},pt=(s,o,e)=>new oi(s,o,e.getId(),e),Vo=s=>!(!("getStyle"in s&&"updateStyle"in s&&"forceStyle"in s)||!("isRestylableComponent"in s)||!s.isRestylableComponent),as="default-restyle-element",oi=class s extends Ct{constructor(e,r,n,i){super(as,n,i);this.originalStyle=e;this.newStyle=r}getComponent(e){this.resolveComponent(e.image);let r=this.component;if(!r||!r.forceStyle||!r.updateStyle)throw new Error("this.component is missing forceStyle and/or updateStyle methods!");return r}apply(e){this.getComponent(e).forceStyle(this.newStyle,e)}unapply(e){this.getComponent(e).forceStyle(this.originalStyle,e)}description(e,r){return r.restyledElement(this.getComponent(e).description(r))}serializeToJSON(){return{id:this.componentID,originalStyle:is(this.originalStyle),newStyle:is(this.newStyle)}}static{W.register(as,(e,r)=>{let n=ss(e.originalStyle),i=ss(e.newStyle),a=e.id;if(typeof e.id!="string")throw new Error(`json.id is of type ${typeof e.id}, not string.`);return new s(n,i,a)})}};var ht=s=>s.path?s.path:new $(s.startPoint,s.commands),Z=(s,o)=>({startPoint:s.startPoint,style:o,commands:s.parts,path:s}),Aa=(s,o)=>s.path?s:{...s,path:o},Mr=(s,o,e={fastCheck:!0,expensiveCheck:!0})=>{let r=ht(s),n=s.style.stroke?.width??0,i=n>0&&s.style.fill.a===0,a=r.bbox.grownBy(n),l=i&&n>o.maxDimension&&a.containsRect(o);if(e.fastCheck&&l&&s.style.stroke){let c=n/2;for(let d of r.startEndPoints())if(o.isWithinRadiusOf(c,d))return{rectangle:o,path:Z($.fromRect(o),{fill:s.style.stroke.color}),fullScreen:!0}}if(e.expensiveCheck&&l&&s.style.stroke&&n>o.maxDimension*3){let c=r.signedDistance(o.center,n/2),d=n/6;if(c<-o.maxDimension/2-d)return{path:Z($.fromRect(o),{fill:s.style.stroke.color}),rectangle:o,fullScreen:!0};if(c>o.maxDimension/2+d)return{path:Z($.empty,{fill:L.transparent}),rectangle:I.empty,fullScreen:!1}}return null},Dr=(s,o)=>{let e=ht(s),r=s.style.stroke?.width??0,n=r>0&&s.style.fill.a===0,i=e.bbox.grownBy(r),a=Mr(s,o,{fastCheck:!0,expensiveCheck:!1});if(a)return a.path;if(o.grownBy(r).transformedBoundingBox(k.scaling2D(4,o.center)).containsRect(i))return Aa(s,e);let c=[],d=e.startPoint;for(let h of e.parts){let m=$.computeBBoxForSegment(d,h).grownBy(r),g;h.kind===0||h.kind===1?g=h.point:g=h.endPoint,m.intersects(o)?c.push(h):n||h.kind===1?c.push({kind:1,point:g}):c.push({kind:0,point:g}),d=g}let u=new $(e.startPoint,c),p=s.style;return a=Mr(s,o,{fastCheck:!1,expensiveCheck:!0}),a?a.path:Z(u,p)};var ee=class s extends _{constructor(e,r){super("stroke",r);this.isRestylableComponent=!0;this.simplifiedPath=null;this.approximateRenderingTime=0,this.parts=[];for(let n of e){let i=ht(n),a=this.bboxForPart(i.bbox,n.style);this.contentBBox?this.contentBBox=this.contentBBox.union(a):this.contentBBox=a,this.parts.push({path:i,startPoint:i.startPoint,style:n.style,commands:i.parts}),this.approximateRenderingTime+=i.parts.length}this.contentBBox??=I.empty}getStyle(){if(this.parts.length===0)return{};let e=this.parts[0];return e.style.stroke===void 0||e.style.stroke.width===0?{color:e.style.fill}:{color:e.style.stroke.color}}updateStyle(e){return pt(this.getStyle(),e,this)}forceStyle(e,r){e.color&&(this.parts=this.parts.map(n=>{let i={...n.style,stroke:n.style.stroke?{...n.style.stroke}:void 0};return i.stroke&&i.stroke.width>0?i.stroke.color=e.color:i.fill=e.color,{path:n.path,startPoint:n.startPoint,commands:n.commands,style:i}}),r&&(r.image.queueRerenderOf(this),r.queueRerender()))}withRegionErased(e,r){let n=e.polylineApproximation(),i=c=>e.closedContainsPoint(c),a=[],l=!1;for(let c of this.parts){let d=c.path,u=b=>{if(c.style.fill.a>0){if(b.parts.length<1||b.parts.length===1&&b.parts[0].kind===0)return null;b=b.asClosed()}return isNaN(b.getExactBBox().area)?(console.warn("Prevented creating a stroke with NaN area"),l=!0,null):new s([Z(b,c.style)],this.getZIndex())},p=[];for(let b of n)p.push(...d.intersection(b));let h=!1;if(p.length===0&&c.style.stroke&&c.style.stroke.width>e.bbox.minDimension*.3&&c.style.stroke.width<e.bbox.maxDimension*30){for(let b of n)p.push(...d.intersection(b,c.style.stroke.width/2));h=!0}p.sort(Eo);let g=(()=>{if(p.length===0)return!1;if(h)return p[0].curveIndex===0&&p[0].parameterValue<=0;let b=vr(p[0],-1e-10);return i(d.at(b))})()?1:0,v=(b,y)=>{let f=u(b),T=g%2===1;g++,y!==void 0&&(T=y),y===void 0&&!T&&e.closedContainsPoint(b.getExactBBox().center)&&(T=!T),f&&(l||=T&&b.getExactBBox().maxDimension>e.getExactBBox().maxDimension*2,T||a.push(f))};if(c.style.fill.a===0){if(!(e.getExactBBox().maxDimension/10>d.getExactBBox().maxDimension)){let y=d.splitAt(p,{mapNewPoint:f=>r.roundPoint(f)});for(let f of y)v(f)}}else if(p.length>=2&&p.length%2===0){let b=d.splitAt(p,{mapNewPoint:y=>r.roundPoint(y)});for(let y=0;y<Math.floor(b.length/2);y++)v(b[y].union(b[b.length-y-1]).asClosed());b.length%2!==0&&v(b[Math.floor(b.length/2)].asClosed())}else v(d,!1)}return l?[this]:a}intersects(e){for(let r of this.parts){let n=r.style.stroke?.width,i=n?n/2:void 0;if(r.path.intersection(e,i).length>0)return!0}return!1}keyPoints(){return this.parts.map(e=>e.startPoint).flat()}intersectsRect(e){if(!e.intersects(this.getBBox()))return!1;for(let r of this.parts){let n=e.grownBy(-(r.style.stroke?.width??0));if(n.area!==0){for(let i of r.path.startEndPoints())if(n.containsPoint(i))return!0}}return super.intersectsRect(e)}computeSimplifiedPathFor(e){let r=[],n=!1,i=!1;for(let a of this.parts){if(i||!a.style.stroke||a.style.stroke.color.a<.99){r.push(a);continue}let l=Mr(a,e);l?(r.push(l.path),l.fullScreen&&(n=!0,i=!0)):r.push(a)}return{forVisibleRect:e,parts:r,occludes:n}}occludesEverythingBelowWhenRenderedInRect(e){return this.getBBox().containsRect(e)?((!this.simplifiedPath||!this.simplifiedPath.forVisibleRect.eq(e))&&(this.simplifiedPath=this.computeSimplifiedPathFor(e)),this.simplifiedPath.occludes):!1}render(e,r){e.startObject(this.getBBox());let n=this.parts;r&&this.simplifiedPath?.forVisibleRect?.containsRect(r)?n=this.simplifiedPath.parts:this.simplifiedPath=null;for(let i of n){let a=this.bboxForPart(i.path.bbox,i.style);r&&(!a.intersects(r)||(a.size.x>r.size.x*3||a.size.y>r.size.y*3)&&!i.path.roughlyIntersects(r,i.style.stroke?.width??0))||e.drawPath(i)}e.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.approximateRenderingTime}bboxForPart(e,r){return r.stroke?e.grownBy(r.stroke.width/2):e}getExactBBox(){let e=null;for(let{path:r,style:n}of this.parts){let i=this.bboxForPart(r.getExactBBox(),n);e??=i,e=e.union(i)}return e??I.empty}applyTransformation(e){this.contentBBox=I.empty;let r=!0;this.parts=this.parts.map(n=>{let i=n.path.transformedBy(e),a={...n.style,stroke:n.style.stroke?{...n.style.stroke}:void 0};if(a.stroke){let c=e.getScaleFactor();a.stroke.width*=c}let l=this.bboxForPart(i.bbox,a);return r?(this.contentBBox=l,r=!1):this.contentBBox=this.contentBBox.union(l),{path:i,startPoint:i.startPoint,commands:i.parts,style:a}})}getParts(){return[...this.parts]}getPath(){let e=null;for(let r of this.parts)e?e=e.union(r.path):e??=r.path;return e??$.empty}description(e){return e.stroke}createClone(){return new s(this.parts)}serializeToJSON(){return this.parts.map(e=>({style:zr(e.style),path:e.path.serialize()}))}static deserializeFromJSON(e){if(typeof e=="string"&&(e=JSON.parse(e)),typeof e!="object"||typeof e.length!="number")throw new Error(`${e} is missing required field, parts, or parts is of the wrong type.`);let r=e.map(n=>{let i=Lr(n.style);return Z($.fromString(n.path),i)});return new s(r)}};_.registerComponent("stroke",ee.deserializeFromJSON);var Pt=class{constructor(o,e,r,n){this.startPoint=o;this.minFitAllowed=e;this.maxFitAllowed=r;this.onCurveAdded=n;this.isFirstSegment=!0;this.lastExitingVec=null;this.currentCurve=null;this.lastPoint=this.startPoint,this.buffer=[this.startPoint.pos],this.momentum=w.zero,this.currentCurve=null,this.curveStartWidth=o.width,this.bbox=new I(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;let o=this.currentCurve.p0,e=this.currentCurve.p1,r=this.currentCurve.p2,n=o.distanceTo(e),i=r.distanceTo(e);return n+i}finalizeCurrentCurve(){if(!this.currentCurve)return;this.onCurveAdded(this.currentSegmentToPath());let o=this.buffer[this.buffer.length-1];this.lastExitingVec=this.currentCurve.p2.minus(this.currentCurve.p1),console.assert(this.lastExitingVec.magnitude()!==0,"lastExitingVec has zero length!"),this.buffer=[this.buffer[this.buffer.length-2],o],this.currentCurve=null,this.isFirstSegment=!1}currentSegmentToPath(){if(this.currentCurve==null)throw new Error("Invalid State: currentCurve is null!");let o=this.currentCurve.normal(0).normalized();if(!isFinite(o.magnitude()))throw new Error(`startVec(${o}) is NaN or \u221E`);let e=this.currentCurve.at(0),r=this.currentCurve.at(1),n=this.currentCurve.p1;return{startPoint:e,controlPoint:n,endPoint:r,startWidth:this.curveStartWidth,endWidth:this.curveEndWidth}}computeExitingVec(){return this.momentum.normalized().times(this.lastPoint.width/2)}addPoint(o){if(this.lastPoint){let T=o.time-this.lastPoint.time;if(o.pos.eq(this.lastPoint.pos,1e-10)||T===0)return;if(isNaN(o.pos.magnitude())){console.warn("Discarding NaN point.",o);return}let P=Math.min(this.lastPoint.width,o.width)/3;if(this.startPoint.pos.distanceTo(o.pos)<P&&this.isFirstSegment)return;let E=T/1e3,C=o.pos.minus(this.lastPoint.pos).times(1/E);this.momentum=C}let e=this.lastPoint??o;this.lastPoint=o,this.buffer.push(o.pos);let r=o.width,n=this.curveEndWidth;if(this.curveEndWidth=r,this.bbox=this.bbox.grownToPoint(o.pos,r),this.currentCurve===null){let f=e.pos,T=e.pos.plus(this.lastExitingVec??w.unitX),P=o.pos;this.currentCurve=new De(f,T,P),console.assert(!isNaN(f.magnitude())&&!isNaN(T.magnitude())&&!isNaN(P.magnitude()),"Expected !NaN"),this.isFirstSegment?this.curveStartWidth=(this.curveStartWidth+r)/2:this.curveStartWidth=n}let i=this.lastExitingVec;if(!i){let f=Math.ceil(this.buffer.length/2);(f===0||f>=this.buffer.length)&&(f=this.buffer.length-1),i=this.buffer[f].minus(this.buffer[0])}let a=this.computeExitingVec(),l=1.7,c=this.buffer[0],d=o.pos,u=d.distanceTo(c),p=l*u;if(p===0||a.magnitude()===0||!isFinite(a.magnitude()))return;console.assert(isFinite(i.magnitude()),"Pre-normalized enteringVec has NaN or \u221E magnitude!"),i=i.normalized(),a=a.normalized(),console.assert(isFinite(i.magnitude()),"Normalized enteringVec has NaN or \u221E magnitude!");let h=new ue(c,c.plus(i.times(p))),g=new ue(d.minus(a.times(p)),d).intersection(h),v=null;g&&(v=g.point),v||(v=c.lerp(d,.5).lerp(c.plus(i.times(u)),.1)),(c.eq(v)||d.eq(v))&&(v=c.plus(i.times(u/5))),console.assert(!c.eq(v,1e-11),"Start and control points are equal!"),console.assert(!v.eq(d,1e-11),"Control and end points are equal!");let b=this.currentCurve;this.currentCurve=new De(c,v,d),isNaN(this.currentCurve.normal(0).magnitude())&&(console.error("NaN normal at 0. Curve:",this.currentCurve),this.currentCurve=b);let y=f=>{let T=Math.min(Math.max(Math.min(this.curveStartWidth,this.curveEndWidth)/4,this.minFitAllowed),this.maxFitAllowed),P=T,S=0;for(let E of this.buffer){let C=f.approximateDistance(E);if(C>T&&(C=f.distance(E),S+=Math.max(0,C-T),S>P))return!1}return!0};if(this.buffer.length>3&&this.approxCurrentCurveLength()>this.curveStartWidth/2&&!y(this.currentCurve)){this.currentCurve=b,this.curveEndWidth=n,this.lastPoint=e,this.finalizeCurrentCurve();return}}},ls=Pt;var Va=s=>(o,e)=>new ri(s,o,e),so=Va,cs=(s,o,e)=>({points:[s,o[o.length-1]]}),ds=(s,o,e)=>({points:[...e.corners,e.corners[0]]}),ri=class{constructor(o,e,r){this.sourceFactory=o;this.startPoint=e;this.viewport=r;this.builder=o(e,r),this.points=[e]}getBBox(){return this.builder.getBBox()}build(){return this.builder.build()}preview(o){this.builder.preview(o)}addPoint(o){this.points.push(o),this.builder.addPoint(o)}async autocorrectShape(){let o=this.viewport.canvasToScreen(this.startPoint.pos),e=this.points.map(S=>this.viewport.canvasToScreen(S.pos)),r=I.bboxOf(e),n=this.viewport.canvasToScreen(this.viewport.snapToGrid(this.startPoint.pos)),i=this.points.map(S=>this.viewport.canvasToScreen(this.viewport.snapToGrid(S.pos))),a=I.bboxOf(i);if(r.maxDimension<32)return null;let l=Math.min(30,r.maxDimension/4),c=[{...cs(n,i,a),toleranceMultiplier:.5},cs(o,e,r),{...ds(n,i,a),toleranceMultiplier:.6},ds(o,e,r)],u=(S=>{for(let E of c){let C=E.points,V=S*S*(E.toleranceMultiplier??1),O=de=>{for(;de<0;)de+=C.length;return de%=C.length,C[de]},G=null,se=1/0,oe=0;for(let de=0;de<C.length;de++){let We=C[de],_e=We.squareDistanceTo(o);(!G||_e<se)&&(se=_e,G=We,oe=de)}let fe=0,Se=oe;for(let de of e){let We=1/0,_e=Se,st=6;for(let at=-st;at<=st;at++){let Ve=Se+at,yt=O(Ve-1),Yt=O(Ve),Ke=O(Ve+1),sr=new ue(yt,Yt),ar=new ue(Yt,Ke),bn=sr.distance(de),qe=ar.distance(de),lr=Math.min(bn,qe),vo=lr*lr;vo<We&&(We=vo,_e=Ve)}if(Se=_e,fe=Math.max(We,fe),fe>V)break}if(fe<V)return C}return null})(l);if(!u)return null;let p=this.points[this.points.length-1],h=this.startPoint.width,m=p.width,g=this.startPoint.color,v=p.color,b=this.startPoint.time,y=p.time,f=S=>{let E=u[Math.max(0,Math.floor(S))],C=u[Math.min(Math.ceil(S),u.length-1)],V=E.lerp(C,S-Math.floor(S)),O=S/u.length;return{pos:this.viewport.screenToCanvas(V),width:h*(1-O)+m*O,color:g.mix(v,O),time:b*(1-O)+y*O}},T=this.sourceFactory(f(0),this.viewport),P=u.length<10;for(let S=0;S<u.length;S++)P&&T.addPoint(f(S-.001)),T.addPoint(f(S)),P&&T.addPoint(f(S+.001));return T.build()}};var Qe=so((s,o)=>{let e=o.getSizeOfPixelOnCanvas()*3,r=o.getSizeOfPixelOnCanvas();return new Ar(s,r,e,o)}),Ar=class{constructor(o,e,r,n){this.startPoint=o;this.minFitAllowed=e;this.viewport=n;this.isFirstSegment=!0;this.parts=[];this.widthAverageNumSamples=1;this.curveFitter=new Pt(o,e,r,i=>this.addCurve(i)),this.averageWidth=o.width,this.bbox=new I(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:L.transparent,stroke:{color:this.startPoint.color,width:this.roundDistance(this.averageWidth)}}}previewCurrentPath(){let e=[...this.parts.slice(),...this.curveToPathCommands(this.curveFitter.preview())];return{startPoint:this.startPoint.pos,commands:e,style:this.getRenderingStyle()}}previewFullPath(){let o=this.previewCurrentPath();return o?[o]:null}previewStroke(){let o=this.previewFullPath();return o?new ee(o):null}preview(o){let e=this.previewFullPath();if(e){let r=this.viewport.visibleRect;o.startObject(r);for(let n of e)o.drawPath(n);o.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.previewStroke()}getMinFit(){let o=Math.min(this.minFitAllowed,this.averageWidth/3);return o<1e-10&&(o=this.minFitAllowed),o}roundPoint(o){let e=this.getMinFit();return U.roundPoint(o,e)}roundDistance(o){let e=this.getMinFit();return U.roundPoint(o,e)}curveToPathCommands(o){if(!o){if(!this.isFirstSegment)return[];let r=U.roundPoint(this.averageWidth/10,Math.min(this.minFitAllowed,this.averageWidth/10)),n=this.roundPoint(this.startPoint.pos);return[{kind:3,controlPoint:n.plus(w.of(r,r)),endPoint:n.plus(w.of(0,r))},{kind:3,controlPoint:n.plus(w.of(-r,r)),endPoint:n.plus(w.of(-r,0))},{kind:3,controlPoint:n.plus(w.of(-r,-r)),endPoint:n.plus(w.of(0,-r))},{kind:3,controlPoint:n.plus(w.of(r,-r)),endPoint:n.plus(w.of(r,0))}]}let e=[];return this.isFirstSegment&&e.push({kind:1,point:this.roundPoint(o.startPoint)}),e.push({kind:3,controlPoint:this.roundPoint(o.controlPoint),endPoint:this.roundPoint(o.endPoint)}),e}addCurve(o){let e=this.curveToPathCommands(o);this.parts.push(...e),this.isFirstSegment&&(this.isFirstSegment=!1)}addPoint(o){this.curveFitter.addPoint(o),this.widthAverageNumSamples++,this.averageWidth=this.averageWidth*(this.widthAverageNumSamples-1)/this.widthAverageNumSamples+o.width/this.widthAverageNumSamples}};var Re=class{#e=null;constructor(){}setEmitListener(o){o&&typeof o=="object"?this.#e=e=>o.onEvent(e)??!1:this.#e=o}emit(o){return this.#e?.(o)??!1}};var Oa={kind:0,mass:.4,springConstant:100,frictionCoefficient:.28,maxPointDist:10,inertiaFraction:.75,minSimilarityToFinalize:0,velocityDecayFactor:.1},ni=class{constructor(o,e,r){this.updatePointer=e;this.options=r;this.runLoop=!0;this.lastUpdateTime=0;this.velocity=w.zero;this.strokePoint=o,this.targetPoint=o,this.targetInterval=10,this.loop()}async loop(){for(this.lastUpdateTime=performance.now();this.runLoop;)this.update(!1),await Ye()}setTarget(o){this.targetPoint=o}getNextVelocity(o){let e=this.targetPoint.minus(this.strokePoint),r=e.times(this.options.springConstant),i=this.options.mass*10,a=this.velocity.normalizedOrZero().times(-this.options.frictionCoefficient*i),l=r.plus(a).times(1/this.options.mass),c=this.options.velocityDecayFactor,d=this.velocity.times(1-c).plus(l.times(o/1e3));return e.normalizedOrZero().times(d.length()).lerp(d,this.options.inertiaFraction)}update(o){let e=performance.now(),r=e-this.lastUpdateTime,n=this.strokePoint.eq(this.targetPoint);if(r>this.targetInterval||o){if(!n){let i,a,l=1;do i=this.getNextVelocity(r/l),a=i.times(r/1e3),l++;while(a.magnitude()>this.options.maxPointDist&&l<10);for(let c=0;c<l;c++)this.velocity=this.getNextVelocity(r/l),a=this.velocity.times(r/1e3),this.strokePoint=this.strokePoint.plus(a),c<l-1&&this.updatePointer(this.strokePoint,e)}if(this.lastUpdateTime=e,o||!n)return this.updatePointer(this.strokePoint,e)}return!1}finish(){this.runLoop=!1;let o=this.targetPoint.minus(this.strokePoint);this.velocity.dot(o)>this.options.minSimilarityToFinalize&&this.updatePointer(this.targetPoint,performance.now())}cancel(){this.runLoop=!1}},Et=class s extends Re{constructor(e,r=Oa){super();this.viewport=e;this.options=r;this.stabilizer=null;this.lastPointerEvent=null}mapPointerEvent(e){return oo(e)&&e.kind!==2&&(this.lastPointerEvent=e),e.kind===3||e.allPointers.length>1||this.stabilizer===null?this.emit(e):(this.stabilizer.setTarget(e.current.screenPos),e.kind===1?this.stabilizer.update(!0):e.kind===2?(this.stabilizer.finish(),this.emit(e)):this.emit(e))}emitPointerMove(e,r){if(!this.lastPointerEvent)return!1;let n=this.lastPointerEvent.current.withScreenPosition(e,this.viewport).withTimestamp(r),i={kind:1,current:n,allPointers:[n]};return this.emit(i)}onEvent(e){if(oo(e)||e.kind===3){e.kind===0&&(this.stabilizer===null?this.stabilizer=new ni(e.current.screenPos,(n,i)=>this.emitPointerMove(n,i),this.options):e.allPointers.length>1&&(this.stabilizer.cancel(),this.stabilizer=null));let r=this.mapPointerEvent(e);return(e.kind===2||e.kind===3)&&(this.stabilizer?.cancel(),this.stabilizer=null),r}return this.emit(e)}static fromEditor(e){return new s(e.viewport)}};var Vr={maxSpeed:8.5,maxRadius:11,minTimeSeconds:.5},kt=class{constructor(o,e,r){this.config=e;this.onStationary=r;this.timeout=null;this.stationaryStartPointer=o,this.lastPointer=o,this.averageVelocity=w.zero,this.setStationaryTimeout(this.config.minTimeSeconds*1e3)}onPointerMove(o){if(!this.stationaryStartPointer)return;if(o.id!==this.stationaryStartPointer.id)return!1;let e=o.screenPos.minus(this.lastPointer.screenPos),r=o.screenPos.minus(this.stationaryStartPointer.screenPos),n=(o.timeStamp-this.lastPointer.timeStamp)/1e3;n===0&&(n=1);let i=e.times(1/n);this.averageVelocity=this.averageVelocity.lerp(i,.5);let a=o.timeStamp-this.stationaryStartPointer.timeStamp,l=r.length()>this.config.maxRadius;if(this.hasMovedOutOfRadius||=l,l||this.averageVelocity.length()>this.config.maxSpeed||a<this.config.minTimeSeconds)return this.stationaryStartPointer=o,this.lastPointer=o,this.setStationaryTimeout(this.config.minTimeSeconds*1e3),!1;let c=this.config.minTimeSeconds*1e3-a;return this.lastPointer=o,c<=0}onPointerUp(o){o.id!==this.stationaryStartPointer?.id&&this.cancelStationaryTimeout()}destroy(){this.cancelStationaryTimeout(),this.stationaryStartPointer=null}getHasMovedOutOfRadius(){return this.hasMovedOutOfRadius}cancelStationaryTimeout(){this.timeout!==null&&(clearTimeout(this.timeout),this.timeout=null)}setStationaryTimeout(o){this.timeout===null&&(o<=0?this.onStationary(this.lastPointer):this.timeout=setTimeout(()=>{if(this.timeout=null,!this.stationaryStartPointer)return;let e=performance.now()-this.stationaryStartPointer.timeStamp,r=this.config.minTimeSeconds*1e3-e;r<=0?this.onStationary(this.lastPointer):this.setStationaryTimeout(r)},o))}};var Ne=class extends K{constructor(e,r,n){super(e.notifier,r);this.editor=e;this.builder=null;this.lastPoint=null;this.startPoint=null;this.currentDeviceType=null;this.currentPointerId=null;this.shapeAutocompletionEnabled=!1;this.autocorrectedShape=null;this.lastAutocorrectedShape=null;this.removedAutocorrectedShapeTime=0;this.stationaryDetector=null;this.styleValue=j.fromInitialValue({factory:Qe,color:L.blue,thickness:4,...n}),this.styleValue.onUpdateAndNow(i=>{this.style=i,this.noteUpdated()})}getPressureMultiplier(){let e=this.style.thickness;return 1/this.editor.viewport.getScaleFactor()*e}toStrokePoint(e){let n=Math.max(e.pressure??1,.3);return isFinite(n)||(console.warn("Non-finite pressure!",e),n=.3),console.assert(isFinite(e.canvasPos.length()),"Non-finite canvas position!"),console.assert(isFinite(e.screenPos.length()),"Non-finite screen position!"),console.assert(isFinite(e.timeStamp),"Non-finite timeStamp on pointer!"),{pos:e.canvasPos,width:n*this.getPressureMultiplier(),color:this.style.color,time:e.timeStamp}}previewStroke(){this.editor.clearWetInk();let e=this.editor.display.getWetInkRenderer();if(this.autocorrectedShape){let r=this.editor.viewport.visibleRect;this.autocorrectedShape.render(e,r)}else this.builder?.preview(e)}addPointToStroke(e){if(!this.builder)throw new Error("No stroke is currently being generated.");this.builder.addPoint(e),this.lastPoint=e,this.previewStroke()}onPointerDown(e){if(this.builder&&!this.eventCanCancelStroke(e))return!0;let{current:r,allPointers:n}=e,i=r.device===1,a=r.device===0;return n.length===1&&!i||a?(this.startPoint=this.toStrokePoint(r),this.builder=this.style.factory(this.startPoint,this.editor.viewport),this.currentDeviceType=r.device,this.currentPointerId=r.id,this.shapeAutocompletionEnabled?this.stationaryDetector=new kt(r,Vr,l=>this.autocorrectShape(l)):this.stationaryDetector=null,this.lastAutocorrectedShape=null,this.removedAutocorrectedShapeTime=0,!0):!1}eventCanCancelStroke(e){let r=this.lastPoint?.time??0;if(e.current.timeStamp-r>1e3)return!0;let n=this.currentDeviceType===0,i=e.current.device===2;return!(n&&i)}eventCanBeDeliveredToNonActiveTool(e){return this.eventCanCancelStroke(e)}onPointerMove({current:e}){if(!this.builder||e.device!==this.currentDeviceType||e.id!==this.currentPointerId)return;this.stationaryDetector?.onPointerMove(e)||(this.addPointToStroke(this.toStrokePoint(e)),this.autocorrectedShape&&(this.removedAutocorrectedShapeTime=performance.now(),this.autocorrectedShape=null,this.editor.announceForAccessibility(this.editor.localization.autocorrectionCanceled)))}onPointerUp({current:e}){if(!this.builder)return!1;if(e.id!==this.currentPointerId)return!0;this.stationaryDetector?.onPointerUp(e);let r=this.toStrokePoint(e),n={...r,width:this.lastPoint?.width??r.width};return this.addPointToStroke(n),this.finalizeStroke(),!1}onGestureCancel(){this.builder=null,this.editor.clearWetInk(),this.stationaryDetector?.destroy(),this.stationaryDetector=null}removedAutocorrectedShapeRecently(){return this.removedAutocorrectedShapeTime>performance.now()-320}async autocorrectShape(e){if(!this.builder||!this.builder.autocorrectShape||!this.shapeAutocompletionEnabled||this.autocorrectedShape)return;let r=await this.builder.autocorrectShape();if(!this.builder||!r)return;let n=r.getBBox().area;if(n===0||!isFinite(n))return;let i=r.description(this.editor.localization);this.editor.announceForAccessibility(this.editor.localization.autocorrectedTo(i)),this.autocorrectedShape=r,this.lastAutocorrectedShape=r,this.previewStroke()}finalizeStroke(){if(this.builder){this.lastAutocorrectedShape&&this.removedAutocorrectedShapeRecently()&&(this.autocorrectedShape=this.lastAutocorrectedShape);let e=this.autocorrectedShape??this.builder.build();if(this.previewStroke(),e.getBBox().area>0){e===this.autocorrectedShape&&this.editor.announceForAccessibility(this.editor.localization.autocorrectedTo(e.description(this.editor.localization)));let n=q.addElement(e,!0);this.editor.dispatch(n)}else console.warn("Pen: Not adding empty stroke",e,"to the canvas.")}this.builder=null,this.lastPoint=null,this.autocorrectedShape=null,this.lastAutocorrectedShape=null,this.editor.clearWetInk(),this.stationaryDetector?.destroy(),this.stationaryDetector=null}noteUpdated(){this.editor.notifier.dispatch(2,{kind:2,tool:this})}setColor(e){e.toHexString()!==this.style.color.toHexString()&&this.styleValue.set({...this.style,color:e})}setThickness(e){e!==this.style.thickness&&this.styleValue.set({...this.style,thickness:e})}setStrokeFactory(e){e!==this.style.factory&&this.styleValue.set({...this.style,factory:e})}setHasStabilization(e){let r=!!this.getInputMapper();e!==r&&(r?this.setInputMapper(null):this.setInputMapper(new Et(this.editor.viewport)),this.noteUpdated())}setStrokeAutocorrectEnabled(e){e!==this.shapeAutocompletionEnabled&&(this.shapeAutocompletionEnabled=e,this.noteUpdated())}getStrokeAutocorrectionEnabled(){return this.shapeAutocompletionEnabled}getThickness(){return this.style.thickness}getColor(){return this.style.color}getStrokeFactory(){return this.style.factory}getStyleValue(){return this.styleValue}onKeyPress(e){let r=this.editor.shortcuts,n=r.matchesShortcut(Bo,e);if(this.builder&&n)return this.finalizeStroke(),!1;let i;return r.matchesShortcut(Do,e)?i=this.getThickness()*2/3:r.matchesShortcut(Mo,e)&&(i=this.getThickness()*3/2),i!==void 0?(i=Math.min(Math.max(1,i),256),this.setThickness(i),!0):!1}};var mt=class{constructor(){}notifyEnabled(o){o!==this.activeTool&&(this.activeTool?.setEnabled(!1),this.activeTool=o)}};var Or=(s,o)=>{if(o.length===0)return null;let e=o[0].description(s);for(let r of o)if(r.description(s)!==e)return null;return e};var J=class s extends W{constructor(o){super("erase"),this.toRemove=o.map(e=>e),this.applied=!1}apply(o){for(let e of this.toRemove){let r=o.image.findParent(e);r&&(r.remove(),o.image.onDestroyElement(e))}this.applied=!0,o.queueRerender()}unapply(o){for(let e of this.toRemove)o.image.findParent(e)||q.addElement(e).apply(o);this.applied=!1,o.queueRerender()}onDrop(o){if(this.applied)for(let e of this.toRemove)o.image.onDestroyElement(e)}description(o,e){if(this.toRemove.length===0)return e.erasedNoElements;let r=Or(e,this.toRemove)??e.elements;return e.eraseAction(r,this.toRemove.length)}serializeToJSON(){return this.toRemove.map(e=>e.serialize())}static{W.register("erase",(o,e)=>{if(!Array.isArray(o))throw new Error("seralized erase data must be an array");let r=o.map(n=>{let i=typeof n=="string"?n:`${n.id}`;return e.image.lookupElement(i)??_.deserialize(n)});return new s(r)})}};var Fa=s=>{if(s.some(o=>o&&o.then))return Promise.all(s).then(()=>{})},ii=Fa;var Fr=class extends Ie{constructor(e,r,n){super();this.commands=e;this.applyChunkSize=r;this.descriptionOverride=n}apply(e){if(this.applyChunkSize===void 0){let r=this.commands.map(n=>n.apply(e));return ii(r)}else return e.asyncApplyCommands(this.commands,this.applyChunkSize)}unapply(e){let r=[...this.commands];if(r.reverse(),this.applyChunkSize===void 0){let n=r.map(i=>i.unapply(e));return ii(n)}else return e.asyncUnapplyCommands(r,this.applyChunkSize,!1)}onDrop(e){this.commands.forEach(r=>r.onDrop(e))}description(e,r){if(this.descriptionOverride)return this.descriptionOverride;let n=[],i=null,a=0,l=0;for(let c of this.commands){let d=c.description(e,r);if(d!==i&&i!==null&&(n.push(r.unionOf(i,a)),i=null,a=0),a++,l++,i??=d,n.length>12)break}return a>1?n.push(r.unionOf(i,a)):a===1&&n.push(i),l<this.commands.length&&n.push(r.andNMoreCommands(this.commands.length-l)),n.join(", ")}},si=class extends W{constructor(e,r,n){super("union");this.commands=e;this.applyChunkSize=r;this.descriptionOverride=n;this.nonserializableCommand=new Fr(e,r,n)}serializeToJSON(){return this.serializedData?this.serializedData:{applyChunkSize:this.applyChunkSize,data:this.commands.map(e=>e.serialize()),description:this.descriptionOverride}}apply(e){return this.serializedData=this.serializeToJSON(),this.nonserializableCommand.apply(e)}unapply(e){return this.nonserializableCommand.unapply(e)}onDrop(e){this.nonserializableCommand.onDrop(e)}description(e,r){return this.nonserializableCommand.description(e,r)}},us=(s,o)=>{let e=!0;for(let i of s)if(!(i instanceof W)){e=!1;break}let r,n;if(typeof o=="number"?r=o:(r=o?.applyChunkSize,n=o?.description),e){let i=s;return new si(i,r,n)}else return new Fr(s,r,n)};W.register("union",(s,o)=>{if(typeof s.data.length!="number")throw new Error("Unions of commands must serialize to lists of serialization data.");let e=s.applyChunkSize;if(typeof e!="number"&&e!==void 0)throw new Error("serialized applyChunkSize is neither undefined nor a number.");let r=typeof s.description=="string"?s.description:void 0,n=[];for(let i of s.data)n.push(W.deserialize(i,o));return us(n,{applyChunkSize:e,description:r})});var le=us;var ao=(e=>(e.PartialStroke="partial-stroke",e.FullStroke="full-stroke",e))(ao||{}),ai=class extends K{constructor(e,r){super(e.notifier,e.localization.changeTool);this.editor=e;this.eraser=r}onPointerDown(e){if(e.allPointers.length===1&&e.current.device===1){let n=this.editor.toolController.getPrimaryTools().filter(i=>i.isEnabled());if(n.length?this.previousEnabledTool=n[0]:this.previousEnabledTool=null,this.previousEraserEnabledState=this.eraser.isEnabled(),this.eraser.setEnabled(!0),this.eraser.onPointerDown(e))return!0;this.restoreOriginalTool()}return!1}onPointerMove(e){this.eraser.onPointerMove(e)}restoreOriginalTool(){this.eraser.setEnabled(this.previousEraserEnabledState),this.previousEnabledTool&&this.previousEnabledTool.setEnabled(!0)}onPointerUp(e){this.eraser.onPointerUp(e),this.restoreOriginalTool()}onGestureCancel(e){this.eraser.onGestureCancel(e),this.restoreOriginalTool()}},Je=class extends K{constructor(e,r,n){super(e.notifier,r);this.editor=e;this.lastPoint=null;this.isFirstEraseEvt=!0;this.toAdd=new Set;this.eraseCommands=[];this.addCommands=[];this.thickness=n?.thickness??10,this.thicknessValue=j.fromInitialValue(this.thickness),this.thicknessValue.onUpdate(i=>{this.thickness=i,this.editor.notifier.dispatch(2,{kind:2,tool:this})}),this.modeValue=j.fromInitialValue(n?.mode??"full-stroke"),this.modeValue.onUpdate(i=>{this.editor.notifier.dispatch(2,{kind:2,tool:this})})}makeEraserSwitcherTool(){return new ai(this.editor,this)}clearPreview(){this.editor.clearWetInk()}getSizeOnCanvas(){return this.thickness/this.editor.viewport.getScaleFactor()}drawPreviewAt(e){this.clearPreview();let r=this.getSizeOnCanvas(),n=this.editor.display.getWetInkRenderer(),i=this.getEraserRect(e),a=this.getEraserRect(this.lastPoint??e),l={fill:L.transparent,stroke:{width:r/10,color:L.gray}};n.drawPath(Z($.fromConvexHullOf([...i.corners,...a.corners]),l))}getEraserRect(e){let r=this.getSizeOnCanvas(),n=w.of(r/2,r/2);return I.fromCorners(e.minus(n),e.plus(n))}eraseTo(e){if(!this.isFirstEraseEvt&&e.distanceTo(this.lastPoint)===0)return;this.isFirstEraseEvt=!1;let r=this.getEraserRect(e),n=new ue(this.lastPoint,e),i=I.union(n.bbox,r),l=this.editor.image.getElementsIntersectingRegion(i).filter(c=>c.intersects(n)||c.intersectsRect(r)).filter(c=>c.isSelectable());if(this.modeValue.get()==="full-stroke"){this.toRemove.push(...l);let c=l.map(d=>new J([d]));c.forEach(d=>d.apply(this.editor)),this.eraseCommands.push(...c)}else{let c=[],d=[];for(let m of l){if(c.push(m),!m.withRegionErased||r.grownBy(r.maxDimension/3).containsRect(m.getExactBBox()))continue;let v=$.fromConvexHullOf([...r.corners,...this.getEraserRect(this.lastPoint??e).corners].map(b=>this.editor.viewport.roundPoint(b)));d.push(...m.withRegionErased(v,this.editor.viewport))}let u=new J(c),p=d.map(m=>q.addElement(m));u.apply(this.editor),p.forEach(m=>m.apply(this.editor));let h=[];for(let m of c)this.toAdd.has(m)?this.toAdd.delete(m):h.push(m);this.toRemove.push(...h);for(let m of d)this.toAdd.add(m);this.eraseCommands.push(new J(h)),this.addCommands.push(...p)}this.drawPreviewAt(e),this.lastPoint=e}onPointerDown(e){return e.allPointers.length===1||e.current.device===1?(this.lastPoint=e.current.canvasPos,this.toRemove=[],this.toAdd.clear(),this.isFirstEraseEvt=!0,this.drawPreviewAt(e.current.canvasPos),!0):!1}onPointerMove(e){let r=e.current.canvasPos;this.eraseTo(r)}onPointerUp(e){this.eraseTo(e.current.canvasPos);let r=[];if(this.addCommands.length>0){this.addCommands.forEach(n=>n.unapply(this.editor));for(let n of this.toAdd)this.toRemove.includes(n)&&(this.toAdd.delete(n),this.toRemove=this.toRemove.filter(i=>i!==n));for(let n of this.toRemove)this.toAdd.has(n)&&(this.toAdd.delete(n),this.toRemove=this.toRemove.filter(i=>i!==n));r.push(...[...this.toAdd].map(n=>q.addElement(n))),this.addCommands=[]}if(this.eraseCommands.length>0){this.eraseCommands.forEach(i=>i.unapply(this.editor)),this.eraseCommands=[];let n=new J(this.toRemove);r.push(n)}r.length===1?this.editor.dispatch(r[0]):this.editor.dispatch(le(r)),this.clearPreview()}onGestureCancel(e){this.addCommands.forEach(r=>r.unapply(this.editor)),this.eraseCommands.forEach(r=>r.unapply(this.editor)),this.eraseCommands=[],this.addCommands=[],this.clearPreview()}onKeyPress(e){let r=this.editor.shortcuts,n;return r.matchesShortcut(Do,e)?n=this.getThickness()*2/3:r.matchesShortcut(Mo,e)&&(n=this.getThickness()*3/2),n!==void 0?(n=Math.min(Math.max(1,n),200),this.setThickness(n),!0):!1}getThickness(){return this.thickness}setThickness(e){this.thicknessValue.set(e)}getThicknessValue(){return this.thicknessValue}getModeValue(){return this.modeValue}};var ps="text";var Ha={fontFamily:"sans",size:12,renderingStyle:{fill:L.purple}},ne=class s extends _{constructor(e,r,n=Ha,i=0){super(ps);this.textObjects=e;this.transform=r;this.style=n;this.transformMode=i;this.isRestylableComponent=!0;this.recomputeBBox(),!e.some(l=>typeof l=="string")&&e.length>0&&(this.style=e[0].getTextStyle())}static applyTextStyles(e,r){let n=r.fontFamily.match(/\s/),i=r.fontFamily.match(/^".*"$/),a=n&&!i?`"${r.fontFamily.replace(/["]/g,'\\"')}"`:r.fontFamily;e.font=[r.fontStyle??"",r.fontWeight??"",(r.size??12)+"px",`${a}`].join(" "),e.textAlign="left"}static{this.textMeasuringCtx=null}static estimateTextDimens(e,r){let n=e.length*r.size,i=r.size;return new I(0,-i*2/3,n,i)}static getTextMetrics(e,r){if(s.textMeasuringCtx??=document.createElement("canvas").getContext("2d")??null,!s.textMeasuringCtx)return null;let n=s.textMeasuringCtx;return s.applyTextStyles(n,r),n.measureText(e)}static getTextDimens(e,r){let n=this.getTextMetrics(e,r);if(!n)return this.estimateTextDimens(e,r);let i=-n.actualBoundingBoxAscent,a=n.actualBoundingBoxAscent+n.actualBoundingBoxDescent;return new I(0,i,n.width,a)}static getFontHeight(e){return e.size}computeUntransformedBBoxOfPart(e){return typeof e=="string"?s.getTextDimens(e,this.style):e.contentBBox}recomputeBBox(){let e=null,r=new s.TextCursor(this.transform,this.style);for(let n of this.textObjects){let i=r.update(n).transform,a=this.computeUntransformedBBoxOfPart(n).transformedBoundingBox(i);e??=a,e=e.union(a)}this.contentBBox=e??I.empty}renderInternal(e,r,n=k.identity){let i=new s.TextCursor(this.transform,this.style);for(let a of this.textObjects){let{transform:l,bbox:c}=i.update(a);r&&!r.intersects(c.transformedBoundingBox(n))||(typeof a=="string"?e.drawText(a,l,this.style):(e.pushTransform(l),a.renderInternal(e,r,n.rightMul(l)),e.popTransform()))}}render(e,r){e.startObject(this.contentBBox),this.renderInternal(e,r),e.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(e){let r=new s.TextCursor(this.transform,this.style);for(let n of this.textObjects){let i=r.update(n).transform.inverse(),a=e.transformedBy(i);if(typeof n=="string"){if(s.getTextDimens(n,this.style).getEdges().some(c=>a.intersection(c)!==null))return!0}else if(n.intersects(a))return!0}return!1}getStyle(){return{color:this.style.renderingStyle.fill,textStyle:{...this.style,renderingStyle:{...this.style.renderingStyle}}}}updateStyle(e){return pt(this.getStyle(),e,this)}forceStyle(e,r){if(e.textStyle)this.style=ti(e.textStyle);else if(e.color)this.style={...this.style,renderingStyle:{...this.style.renderingStyle,fill:e.color}};else return;for(let n of this.textObjects)n instanceof s&&n.forceStyle(e,r);r&&(r.image.queueRerenderOf(this),r.queueRerender())}getTextStyle(){return ti(this.style)}getBaselinePos(){return this.transform.transformVec2(w.zero)}getTransform(){return this.transform}applyTransformation(e){this.transform=e.rightMul(this.transform),this.recomputeBBox()}createClone(){let e=this.textObjects.map(r=>typeof r=="string"?r:r.createClone());return new s(e,this.transform,this.style)}getText(){let e=[];for(let r of this.textObjects)typeof r=="string"?e.push(r):e.push(r.getText());return e.join(`
|
19
|
+
`)}description(e){return e.text(this.getText())}serializeToJSON(){let e=Br(this.style);return{textObjects:this.textObjects.map(n=>typeof n=="string"?{text:n}:{json:n.serializeToJSON()}),transform:this.transform.toArray(),style:e}}static deserializeFromString(e){typeof e=="string"&&(e=JSON.parse(e));let r=Ir(e.style),n=e.textObjects.map(l=>(l.text??null)!==null?l.text:s.deserializeFromString(l.json));if(e.transform=e.transform.filter(l=>typeof l=="number"),e.transform.length!==9)throw new Error(`Unable to deserialize transform, ${e.transform}.`);let i=e.transform,a=new k(...i);return new s(n,a,r)}static fromLines(e,r,n){let i=null,a=[],l=Math.round(this.getFontHeight(n)),c=w.zero;for(let d of e){i&&(c=c.plus(w.unitY.times(l)));let u=new s([d],k.translation(c),n);a.push(u),i=u}return new s(a,r,n)}static{this.TextCursor=class{constructor(e=k.identity,r){this.parentTransform=e;this.parentStyle=r;this.transform=k.identity}update(e){let r=k.identity,n=k.identity,i;typeof e=="string"?i=s.getTextDimens(e,this.parentStyle):(n=e.transform,i=e.getBBox());let a=typeof e=="string"?1:e.transformMode;a===1?r=this.transform.rightMul(r):(a===2||a===3)&&(r=this.transform.mapEntries((u,[p,h])=>{if(a===2)return p===1&&h===2?0:u;if(a===3)return p===0&&h===2?0:u;throw new Error("Unreachable")}).rightMul(r));let l=k.translation(w.of(i.width,0));this.transform=r.rightMul(n).rightMul(l);let c=this.parentTransform.rightMul(r);return{transform:c,bbox:i.transformedBoundingBox(c)}}}}};_.registerComponent(ps,s=>ne.deserializeFromString(s));var ze=class{constructor(o){this.viewport=o;this.selfTransform=null;this.transformStack=[];this.objectLevel=0;this.currentPaths=null}getViewport(){return this.viewport}setDraftMode(o){}flushPath(){if(!this.currentPaths)return;let o=null;for(let e of this.currentPaths){let{startPoint:r,commands:n,style:i}=e;!o||!Rr(o,i)?(o&&this.endPath(o),this.beginPath(r),o=i):this.moveTo(r);for(let a of n)a.kind===0?this.lineTo(a.point):a.kind===1?this.moveTo(a.point):a.kind===2?this.traceCubicBezierCurve(a.controlPoint1,a.controlPoint2,a.endPoint):a.kind===3&&this.traceQuadraticBezierCurve(a.controlPoint,a.endPoint)}o&&this.endPath(o),this.currentPaths=[]}drawPath(o){this.objectLevel===0||this.currentPaths===null?(this.currentPaths=[o],this.flushPath(),this.currentPaths=null):this.currentPaths.push(o)}drawRect(o,e,r){let n=$.fromRect(o,e);this.drawPath(Z(n,r))}fillRect(o,e){let r=$.fromRect(o);this.drawPath(Z(r,{fill:e}))}startObject(o,e){this.objectLevel>0&&this.flushPath(),this.currentPaths=[],this.objectLevel++}endObject(o,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(o){return!1}renderFromOtherOfSameType(o,e){throw new Error(`Unable to render from ${e}: Not implemented`)}setTransform(o){this.selfTransform=o}pushTransform(o){this.transformStack.push(this.selfTransform),this.setTransform(this.getCanvasToScreenTransform().rightMul(o))}popTransform(){if(this.transformStack.length===0)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(o){return this.getCanvasToScreenTransform().transformVec2(o)}getSizeOfCanvasPixelOnScreen(){return this.getCanvasToScreenTransform().transformVec3(w.unitX).length()}overrideVisibleRect(o){this.visibleRectOverride=o}getVisibleRect(){return this.visibleRectOverride??this.viewport.visibleRect}};var Le=class s extends ze{constructor(e,r){super(r);this.ctx=e;this.ignoreObjectsAboveLevel=null;this.ignoringObject=!1;this.currentObjectBBox=null;this.clipLevels=[];this.setDraftMode(!1)}transformBy(e){this.ctx.transform(e.a1,e.b1,e.a2,e.b2,e.a3,e.b3)}canRenderFromWithoutDataLoss(e){return e instanceof s}renderFromOtherOfSameType(e,r){if(!(r instanceof s))throw new Error(`${r} cannot be rendered onto ${this}`);e=this.getCanvasToScreenTransform().rightMul(e),this.ctx.save(),this.transformBy(e),this.ctx.drawImage(r.ctx.canvas,0,0),this.ctx.restore()}setDraftMode(e){e?(this.minSquareCurveApproxDist=9,this.minRenderSizeBothDimens=1,this.minRenderSizeAnyDimen=.1):(this.minSquareCurveApproxDist=.5,this.minRenderSizeBothDimens=.1,this.minRenderSizeAnyDimen=1e-6)}displaySize(){return w.of(this.ctx.canvas.clientWidth,this.ctx.canvas.clientHeight)}clear(){this.ctx.save(),this.ctx.resetTransform(),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}beginPath(e){e=this.canvasToScreen(e),this.ctx.beginPath(),this.ctx.moveTo(e.x,e.y)}endPath(e){e.fill.a>0&&(this.ctx.fillStyle=e.fill.toHexString(),this.ctx.fill()),e.stroke&&(this.ctx.strokeStyle=e.stroke.color.toHexString(),this.ctx.lineWidth=this.getSizeOfCanvasPixelOnScreen()*e.stroke.width,this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.stroke(),this.ctx.lineWidth=1),this.ctx.closePath()}lineTo(e){e=this.canvasToScreen(e),this.ctx.lineTo(e.x,e.y)}moveTo(e){e=this.canvasToScreen(e),this.ctx.moveTo(e.x,e.y)}traceCubicBezierCurve(e,r,n){e=this.canvasToScreen(e),r=this.canvasToScreen(r),n=this.canvasToScreen(n);let i=r.minus(e),a=n.minus(r);i.magnitudeSquared()<this.minSquareCurveApproxDist&&a.magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(n.x,n.y):this.ctx.bezierCurveTo(e.x,e.y,r.x,r.y,n.x,n.y)}traceQuadraticBezierCurve(e,r){e=this.canvasToScreen(e),r=this.canvasToScreen(r),e.minus(r).magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(r.x,r.y):this.ctx.quadraticCurveTo(e.x,e.y,r.x,r.y)}drawPath(e){if(this.ignoringObject)return;let r=this.getVisibleRect();this.currentObjectBBox?.containsRect(r)&&(e=Dr(e,r)),super.drawPath(e)}drawText(e,r,n){this.ctx.save(),r=this.getCanvasToScreenTransform().rightMul(r),this.transformBy(r),ne.applyTextStyles(this.ctx,n),n.renderingStyle.fill.a!==0&&(this.ctx.fillStyle=n.renderingStyle.fill.toHexString(),this.ctx.fillText(e,0,0)),n.renderingStyle.stroke&&(this.ctx.strokeStyle=n.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=n.renderingStyle.stroke.width,this.ctx.strokeText(e,0,0)),this.ctx.restore()}drawImage(e){if(e.image.width===0||e.image.height===0)return;this.ctx.save();let r=this.getCanvasToScreenTransform().rightMul(e.transform);this.transformBy(r),this.ctx.drawImage(e.image,0,0),this.ctx.restore()}startObject(e,r){if(this.isTooSmallToRender(e)&&(this.ignoreObjectsAboveLevel=this.getNestingLevel(),this.ignoringObject=!0),super.startObject(e),this.currentObjectBBox=e,!this.ignoringObject&&r&&!e.containsRect(this.getVisibleRect())){this.clipLevels.push(this.objectLevel),this.ctx.save(),this.ctx.beginPath();for(let i of e.corners){let a=this.canvasToScreen(i);this.ctx.lineTo(a.x,a.y)}this.ctx.clip()}}endObject(){let e=this.objectLevel;this.currentObjectBBox=null,super.endObject(),!this.ignoringObject&&this.clipLevels.length>0&&this.clipLevels[this.clipLevels.length-1]===e&&(this.ctx.restore(),this.clipLevels.pop()),this.ignoreObjectsAboveLevel!==null&&this.getNestingLevel()<=this.ignoreObjectsAboveLevel&&(this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1)}drawPoints(...e){for(let n=0;n<e.length;n++){let i=this.canvasToScreen(e[n]);this.ctx.beginPath(),this.ctx.arc(i.x,i.y,10,0,Math.PI*2),this.ctx.fillStyle=L.ofRGBA(.5+Math.sin(n)/2,1,.5+Math.cos(n*.2)/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(`${n}`,i.x,i.y,10*2)}}isTooSmallToRender(e){let r=e.size.times(this.getSizeOfCanvasPixelOnScreen()),n=this.minRenderSizeBothDimens,i=Math.abs(r.x)<n&&Math.abs(r.y)<n,a=this.minRenderSizeAnyDimen,l=Math.abs(r.x)<a||Math.abs(r.y)<a;return i||l}static fromViewport(e,r={}){let n=document.createElement("canvas"),i=e.getScreenRectSize(),a=r.canvasSize??i;r.maxCanvasDimen&&a.maximumEntryMagnitude()>r.maxCanvasDimen&&(a=a.times(r.maxCanvasDimen/a.maximumEntryMagnitude())),n.width=a.x,n.height=a.y;let l=n.getContext("2d"),c=Math.min(a.x/i.x,a.y/i.y);return l.scale(c,c),{renderer:new s(l,e),element:n}}};var co=(r=>(r[r.SolidColor=0]="SolidColor",r[r.Grid=1]="Grid",r[r.None=2]="None",r))(co||{}),lo="js-draw-image-background",Hr="js-draw-image-background-grid-",li="js-draw-image-background-non-automatic-secondary-color",ci={1:"js-draw-image-background-grid",0:lo,2:""},ce=class s extends _{constructor(e,r){super("image-background",0);this.backgroundType=e;this.mainColor=r;this.viewportSizeChangeListener=null;this.autoresizeChangedListener=null;this.fillsScreen=!1;this.gridSize=U.getGridSize(2);this.gridStrokeWidth=.7;this.secondaryColor=null;this.isRestylableComponent=!0;this.contentBBox=I.empty}static ofGrid(e,r,n,i){let a=new s(1,e);return r!==void 0&&(a.gridSize=r),n!==void 0&&(a.secondaryColor=n),i!==void 0&&(a.gridStrokeWidth=i),a}getBackgroundType(){return this.backgroundType}getMainColor(){return this.mainColor}getSecondaryColor(){return this.secondaryColor}getGridSize(){return this.gridSize}getStyle(){let e=this.mainColor;return this.backgroundType===2&&(e=void 0),{color:e}}updateStyle(e){return pt(this.getStyle(),e,this)}forceStyle(e,r){let n=e.color;n&&(this.mainColor=n,n.eq(L.transparent)&&this.backgroundType===0?this.backgroundType=2:this.backgroundType===2&&(this.backgroundType=0),r&&(r.image.queueRerenderOf(this),r.queueRerender()))}onAddToImage(e){this.viewportSizeChangeListener&&(console.warn("onAddToImage called when background is already in an image"),this.onRemoveFromImage()),this.viewportSizeChangeListener=e.notifier.on(0,()=>{this.recomputeBBox(e)}),this.autoresizeChangedListener=e.notifier.on(1,()=>{this.recomputeBBox(e)}),this.recomputeBBox(e)}onRemoveFromImage(){this.viewportSizeChangeListener?.remove(),this.autoresizeChangedListener?.remove(),this.viewportSizeChangeListener=null,this.autoresizeChangedListener=null}recomputeBBox(e){let r=e.getImportExportViewport().visibleRect,n=!1;this.contentBBox.eq(r)||(this.contentBBox=r,n||=!this.fillsScreen);let i=e.getAutoresizeEnabled();i!==this.fillsScreen&&(this.fillsScreen=i,n=!0),n&&e.queueRerenderOf(this)}generateGridPath(e){let r=this.getFullBoundingBox(e),n=(e?.intersection(r)??r).grownBy(this.gridStrokeWidth/2),i=y=>Math.floor(y/this.gridSize)*this.gridSize,a=y=>Math.ceil(y/this.gridSize)*this.gridSize,l=a(n.y),c=i(n.y+n.h),d=a(n.x),u=i(n.x+n.w),p=[],h=(c-l)/this.gridSize,m=(u-d)/this.gridSize;if(h>1e3||m>1e3)return $.empty;let b=w.of(n.x,l);for(let y=l;y<=c;y+=this.gridSize)p.push({kind:1,point:w.of(n.x,y)}),p.push({kind:0,point:w.of(n.x+n.w,y)});for(let y=d;y<=u;y+=this.gridSize)p.push({kind:1,point:w.of(y,n.y)}),p.push({kind:0,point:w.of(y,n.y+n.h)});return new $(b,p)}getFullBoundingBox(e){return(this.fillsScreen?e:this.contentBBox)??this.contentBBox}render(e,r){if(this.backgroundType===2)return;let n=!r;this.fillsScreen&&(r??=e.getVisibleRect());let i=this.backgroundType===1,a=this.getFullBoundingBox(r);if(e.startObject(a,i),this.backgroundType===0||this.backgroundType===1){let d=r?.intersection(a);d?e.fillRect(d,this.mainColor):n&&e.fillRect(a,this.mainColor)}if(this.backgroundType===1){let d=this.secondaryColor;d??=L.ofRGBA(1-this.mainColor.r,1-this.mainColor.g,1-this.mainColor.b,.2),this.mainColor.a===0&&(d=L.ofRGBA(.5,.5,.5,.2));let u={fill:L.transparent,stroke:{width:this.gridStrokeWidth,color:d}};e.drawPath(Z(this.generateGridPath(r),u))}let l=ci[this.backgroundType],c=[lo];if(l!==lo){c.push(l);let d=pe(this.gridSize).replace(/[.]/g,"p");c.push(Hr+d)}this.secondaryColor!==null&&c.push(li),e.endObject(this.getLoadSaveData(),c)}intersects(e){return this.contentBBox.getEdges().some(r=>r.intersects(e))}isSelectable(){return!1}isBackground(){return!0}getSizingMode(){return this.fillsScreen?1:0}serializeToJSON(){return{mainColor:this.mainColor.toHexString(),secondaryColor:this.secondaryColor?.toHexString(),backgroundType:this.backgroundType,gridSize:this.gridSize,gridStrokeWidth:this.gridStrokeWidth}}applyTransformation(e){}description(e){return this.backgroundType===0?e.filledBackgroundWithColor(this.mainColor.toString()):this.backgroundType===2?e.emptyBackground:this.backgroundType===1?e.gridBackground:this.backgroundType}createClone(){return new s(this.backgroundType,this.mainColor)}static deserializeFromJSON(e){if(typeof e=="string"&&(e=JSON.parse(e)),typeof e.mainColor!="string")throw new Error("Error deserializing \u2014 mainColor must be of type string.");let r,n=e.backgroundType;if(n===2||n===1||n===0)r=n;else return n;let i=L.fromHex(e.mainColor),a=e.secondaryColor?L.fromHex(e.secondaryColor):null,l=e.gridSize??void 0,c=e.gridStrokeWidth??void 0,d=new s(r,i);return d.secondaryColor=a,l&&(d.gridSize=l),c&&(d.gridStrokeWidth=c),d}};_.registerComponent("image-background",ce.deserializeFromJSON);var $a=async s=>{s.complete||await new Promise((o,e)=>{s.onload=r=>o(r),s.onerror=r=>e(r),s.onabort=r=>e(r)})},hs=$a;var be=class s extends _{constructor(o){super("image-component"),this.image={...o,label:o.label??o.image.getAttribute("alt")??o.image.getAttribute("aria-label")??void 0},(r=>r.getAttribute("src")!==void 0)(o.image)&&!o.image.complete&&(o.image.onload=()=>this.recomputeBBox()),this.recomputeBBox()}getImageRect(){return new I(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(o,e){await hs(o);let r,n;typeof o.width=="number"&&typeof o.height=="number"&&o.width!==0&&o.height!==0?(r=o.width,n=o.height):(r=o.clientWidth,n=o.clientHeight);let i,a=o.src??"";if(a.startsWith("data:image/"))i=new Image,i.src=a,i.width=r,i.height=n;else{let l=document.createElement("canvas");l.width=r,l.height=n,l.getContext("2d").drawImage(o,0,0,l.width,l.height),a=l.toDataURL(),i=l}return i.setAttribute("alt",o.getAttribute("alt")??""),i.setAttribute("aria-label",o.getAttribute("aria-label")??""),new s({image:i,base64Url:a,transform:e})}render(o,e){o.startObject(this.contentBBox),o.drawImage(this.image),o.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return 10}intersects(o){let r=this.getImageRect().getEdges().map(n=>n.transformedBy(this.image.transform));for(let n of r)if(n.intersects(o))return!0;return!1}applyTransformation(o){this.image.transform=o.rightMul(this.image.transform),this.recomputeBBox()}description(o){return this.image.label?o.imageNode(this.image.label):o.unlabeledImageNode}getAltText(){return this.image.label}getURL(){return this.image.base64Url}getTransformation(){return this.image.transform}createClone(){return new s({...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(o){if(typeof o.src!="string")throw new Error(`${o} has invalid format! Expected src property.`);ko(o.transform),ut(o.width),ut(o.height);let e=new Image;e.src=o.src,e.width=o.width,e.height=o.height;let r=new k(...o.transform);return new s({image:e,base64Url:o.src,label:o.label,transform:r})}};_.registerComponent("image-component",be.deserializeFromJSON);var ms="svg-global-attributes",uo=class s extends _{constructor(o){super(ms),this.contentBBox=I.empty;let e=["viewBox","width","height"];this.attrs=o.filter(([r,n])=>!e.includes(r))}render(o,e){if(o instanceof me)for(let[r,n]of this.attrs)o.setRootSVGAttribute(r,n)}intersects(o){return!1}applyTransformation(o){}isSelectable(){return!1}getSizingMode(){return 2}createClone(){return new s(this.attrs)}description(o){return o.svgObject}serializeToJSON(){return JSON.stringify(this.attrs)}static deserializeFromString(o){return new s([])}};_.registerComponent(ms,uo.deserializeFromString);var fs="unknown-svg-object",Rt=class s extends _{constructor(e){super(fs);this.svgObject=e;this.contentBBox=I.of(e.getBoundingClientRect())}render(e,r){e instanceof me&&(e.startObject(this.contentBBox),e.drawSVGElem(this.svgObject),e.endObject(this.getLoadSaveData()))}intersects(e){return this.contentBBox.getEdges().some(r=>r.intersection(e)!==null)}applyTransformation(e){}isSelectable(){return!1}getSizingMode(){return 2}createClone(){return new s(this.svgObject.cloneNode(!0))}description(e){return e.svgObject}serializeToJSON(){return JSON.stringify({html:this.svgObject.outerHTML})}};_.registerComponent(fs,null);var Ua=(s,o,e)=>{let r=/^([-0-9.e]+)px/i,n=r.exec(s.style?.fontSize??"");!n&&s.tagName.toLowerCase()==="tspan"&&s.parentElement&&(n=r.exec(s.parentElement.style?.fontSize??"")),!n&&o&&(n=r.exec(o.fontSize));let i=12;return n&&(e.add("fontSize"),i=parseFloat(n[1])),i},gs=Ua;var Wa=new I(0,0,500,500),ui="svgAttrs",pi="svgStyleAttrs",hi="svgContainerID",Nr="js-draw--autoresize";var di=["stroke","fill","stroke-width"],et=class s{constructor(o,e,r){this.source=o;this.onFinish=e;this.onAddComponent=null;this.onProgress=null;this.onDetermineExportRect=null;this.processedCount=0;this.totalToProcess=0;this.containerGroupIDs=[];this.encounteredIDs=[];this.storeUnknown=!(r.sanitize??!1),this.disableUnknownObjectWarnings=!!r.disableUnknownObjectWarnings}getStyle(o,e){let r=L.transparent,n,i=o.getAttribute("fill")??(e?.fill||o.style?.fill);if(i)try{r=L.fromString(i)}catch{console.error("Unknown fill color,",i)}let a=o.getAttribute("stroke")??e?.stroke??o.style?.stroke??"",l=o.getAttribute("stroke-width")??e?.strokeWidth??o.style?.strokeWidth??"";if(a&&l)try{let d=parseFloat(l??"1");isFinite(d)||(d=0);let u=L.fromString(a);u.a>0&&(n={width:d,color:u})}catch(d){console.error("Error parsing stroke data:",d)}return{fill:r,stroke:n}}strokeDataFromElem(o){let e=[],r=o.getAttribute("d")??"",n=this.getStyle(o),i=r.split("M"),a=!0;for(let l of i){let c=/^[0-9., \t\n]+$/.exec(l);if(l!==""&&!c){let d=a?l:`M${l}`,u=$.fromString(d),p=Z(u,n);e.push(p)}a=!1}return e}attachUnrecognisedAttrs(o,e,r,n){if(this.storeUnknown){for(let i of e.getAttributeNames())r.has(i)||i==="style"&&n||o.attachLoadSaveData(ui,[i,e.getAttribute(i)]);if(n&&e.style)for(let i=0;i<e.style.length;i++){let a=e.style[i];a===""||!a||n.has(a)||o.attachLoadSaveData(pi,{key:a,value:e.style.getPropertyValue(a),priority:e.style.getPropertyPriority(a)})}}}async addPath(o){let e;try{let r=this.strokeDataFromElem(o);e=new ee(r),this.attachUnrecognisedAttrs(e,o,new Set([...di,"d"]),new Set(di))}catch(r){if(console.error("Invalid path in node",o,`
|
20
|
+
Error:`,r,`
|
21
|
+
Adding as an unknown object.`),this.storeUnknown)e=new Rt(o);else return}await this.addComponent(e)}async addBackground(o){if(o.classList.contains(ci[1])){let e,r,n;if(o.tagName.toLowerCase()==="g"){if(o.children.length!==2){await this.addUnknownNode(o);return}let u=o.children[0],p=o.children[1];r=u.getAttribute("fill"),e=p.getAttribute("stroke"),n=p.getAttribute("stroke-width")}else r=o.getAttribute("fill"),e=o.getAttribute("stroke"),n=o.getAttribute("stroke-width");if(r??=L.transparent.toHexString(),!e){await this.addUnknownNode(o);return}let i;for(let u of o.classList)if(u.startsWith(Hr)){let p=u.substring(Hr.length);i=parseFloat(p.replace(/p/g,"."))}let a;n&&(a=parseFloat(n));let l=L.fromString(r),c=L.fromString(e);o.classList.contains(li)||(c=void 0);let d=ce.ofGrid(l,i,c,a);await this.addComponent(d)}else if(o.tagName.toLowerCase()==="path"){let e=L.fromString(o.getAttribute("fill")??o.style.fill??"black"),r=new ce(0,e);await this.addComponent(r)}else await this.addUnknownNode(o)}getComputedStyle(o){try{return window.getComputedStyle(o)}catch(e){console.warn("Error computing style",e);return}}getTransform(o,e,r){let n="data-highp-transform",i=o.getAttribute(n),a;if(i)try{a=k.fromCSSMatrix(i),e?.push(n)}catch(l){console.warn(`Unable to parse raw transform data, ${i}. Falling back to CSS data. Error:`,l)}if(!a){r??=this.getComputedStyle(o);let l=r?.transform;(!l||l==="none")&&(l=o.style?.transform||"none");try{a=k.fromCSSMatrix(o.style.transform)}catch(u){console.warn("matrix parse error",u),a=k.fromCSSMatrix(l)}let c=o.getAttribute("x"),d=o.getAttribute("y");if(c||d){let u=parseFloat(c??"0"),p=parseFloat(d??"0");!isNaN(u)&&!isNaN(p)&&(e?.push("x","y"),a=a.rightMul(k.translation(w.of(u,p))))}}return a}makeText(o){let e=[];for(let h of o.childNodes)if(h.nodeType===Node.TEXT_NODE)e.push(h.nodeValue??"");else if(h.nodeType===Node.ELEMENT_NODE){let m=h;if(m.tagName.toLowerCase()==="tspan")e.push(this.makeText(m));else throw new Error(`Unrecognized text child element: ${m}`)}else throw new Error(`Unrecognized text child node: ${h}.`);e.length===0&&e.push("");let r=this.getComputedStyle(o),n=new Set(["fontFamily","transform",...di]),i={size:gs(o,r,n),fontFamily:r?.fontFamily||o.style?.fontFamily||"sans-serif",fontWeight:r?.fontWeight||o.style?.fontWeight||void 0,fontStyle:r?.fontStyle||o.style?.fontStyle||void 0,renderingStyle:this.getStyle(o,r)},a=[],l=this.getTransform(o,a,r),c=0,d=o.getAttribute("dx");d&&(c=2,l=l.rightMul(k.translation(w.of(parseFloat(d),0))),a.push("dx"));let u=o.getAttribute("dy");u&&(c===2?c=1:c=3,l=l.rightMul(k.translation(w.of(0,parseFloat(u)))),a.push("dy"));let p=new ne(e,l,i,c);return this.attachUnrecognisedAttrs(p,o,new Set(a),new Set(n)),p}async addText(o){try{let e=this.makeText(o);await this.addComponent(e)}catch(e){console.error("Invalid text object in node",o,". Continuing.... Error:",e),this.addUnknownNode(o)}}async addImage(o){let e=new Image;e.src=o.getAttribute("xlink:href")??o.href.baseVal,e.setAttribute("alt",o.getAttribute("aria-label")??"");try{let r=[],n=this.getTransform(o,r),i=await be.fromImage(e,n);this.attachUnrecognisedAttrs(i,o,new Set(r),new Set(["transform"])),await this.addComponent(i)}catch(r){console.error("Error loading image:",r,". Element: ",o,". Continuing..."),await this.addUnknownNode(o)}}async addUnknownNode(o){if(this.storeUnknown){let e=new Rt(o);await this.addComponent(e)}}async startGroup(o){o=o.cloneNode(!1);let e=o.id||`id-${this.encounteredIDs.length}`,r=0,n="";for(;this.encounteredIDs.includes(e+n);)r++,n="--"+r;e+=n,o.replaceChildren(),o.id=e;let i=new Rt(o);this.addComponent(i),this.containerGroupIDs.push(o.id),this.encounteredIDs.push(o.id)}async endGroup(){this.containerGroupIDs.pop()}async addComponent(o){this.containerGroupIDs.length>0&&o.attachLoadSaveData(hi,[...this.containerGroupIDs]),await this.onAddComponent?.(o)}updateViewBox(o){let e=o.getAttribute("viewBox");if(this.rootViewBox||!e)return;let r=e.split(/[ \t\n,]+/),n=parseFloat(r[0]),i=parseFloat(r[1]),a=parseFloat(r[2]),l=parseFloat(r[3]);if(isNaN(n)||isNaN(i)||isNaN(a)||isNaN(l)){console.warn(`node ${o} has an unparsable viewbox. Viewbox: ${e}. Match: ${r}.`);return}let c=o.classList.contains(Nr);this.rootViewBox=new I(n,i,a,l),this.onDetermineExportRect?.(this.rootViewBox,{autoresize:c})}async updateSVGAttrs(o){this.storeUnknown&&await this.onAddComponent?.(new uo(this.getSourceAttrs(o)))}async visit(o){this.totalToProcess+=o.childElementCount;let e=!0;switch(o.tagName.toLowerCase()){case"g":o.classList.contains(lo)?(await this.addBackground(o),e=!1):await this.startGroup(o);break;case"path":o.classList.contains(lo)?await this.addBackground(o):await this.addPath(o);break;case"text":await this.addText(o),e=!1;break;case"image":await this.addImage(o),e=!1;break;case"svg":this.updateViewBox(o),this.updateSVGAttrs(o);break;case"style":o.getAttribute("id")!==Oo&&await this.addUnknownNode(o);break;default:this.disableUnknownObjectWarnings||(console.warn("Unknown SVG element,",o,o.tagName),o instanceof SVGElement||console.warn("Element",o,"is not an SVGElement!",this.storeUnknown?"Continuing anyway.":"Skipping.")),await this.addUnknownNode(o);return}if(e){for(let r of o.children)await this.visit(r);o.tagName.toLowerCase()==="g"&&await this.endGroup()}this.processedCount++,await this.onProgress?.(this.processedCount,this.totalToProcess)}getSourceAttrs(o){return o.getAttributeNames().map(e=>[e,o.getAttribute(e)])}async start(o,e,r=null){this.onAddComponent=o,this.onProgress=e,this.onDetermineExportRect=r,this.totalToProcess=this.source.childElementCount,this.processedCount=0,this.rootViewBox=null,await this.visit(this.source),this.rootViewBox||this.onDetermineExportRect?.(Wa),this.onFinish?.(),this.onFinish=null}static fromString(o,e=!1){let r=typeof e!="boolean"&&e?.loadMethod==="domparser",{svgElem:n,cleanUp:i}=(()=>{if(!r)try{let m=document.createElement("iframe");if(m.src="about:blank",m.setAttribute("sandbox","allow-same-origin"),m.setAttribute("csp","default-src 'about:blank'"),m.style.display="none",document.body.appendChild(m),!m.hasAttribute("sandbox"))throw m.remove(),new Error("SVG loading iframe is not sandboxed.");let g=m.contentWindow?.document??m.contentDocument;if(g==null)throw new Error("Unable to open a sandboxed iframe!");g.open(),g.write(`
|
22
|
+
<!DOCTYPE html>
|
23
|
+
<html>
|
24
|
+
<head>
|
25
|
+
<title>SVG Loading Sandbox</title>
|
26
|
+
<meta name='viewport' conent='width=device-width,initial-scale=1.0'/>
|
27
|
+
<meta charset='utf-8'/>
|
28
|
+
</head>
|
29
|
+
<body style='font-size: 12px;'>
|
30
|
+
<script>
|
31
|
+
console.error('JavaScript should not be able to run here!');
|
32
|
+
throw new Error(
|
33
|
+
'The SVG sandbox is broken! Please double-check the sandboxing setting.'
|
34
|
+
);
|
35
|
+
<\/script>
|
36
|
+
</body>
|
37
|
+
</html>
|
38
|
+
`),g.close();let v=g.createElementNS("http://www.w3.org/2000/svg","svg");return v.innerHTML=o,g.body.appendChild(v),{svgElem:v,cleanUp:()=>{v.remove(),m.remove(),m.src=""}}}catch(m){console.warn("Failed loading SVG via a sandboxed iframe. Some styles may not be loaded correctly. Error: ",m)}let d=new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${o}</svg>`,"text/html"),u=d.querySelector("svg"),p=d.querySelector("parsererror");if(p)throw new Error("Parse error: "+p.textContent);return{svgElem:u,cleanUp:()=>{}}})(),a,l;return typeof e=="boolean"?(a=e,l=!1):(a=e.sanitize??!1,l=e.disableUnknownObjectWarnings??!1),new s(n,i,{sanitize:a,disableUnknownObjectWarnings:l})}};var Ka=(s,o)=>{let e=s.length<o.length?s:o,r=e===s?o:s;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0},bs=Ka;var Oo="js-draw-style-sheet",po="http://www.w3.org/2000/svg",mi={fontWeight:"400",fontStyle:"normal"},me=class s extends ze{constructor(e,r,n=!1){super(r);this.elem=e;this.sanitize=n;this.lastPathStyle=null;this.lastPathString=[];this.lastContainerIDList=[];this.objectElems=null;this.overwrittenAttrs={};this.textContainer=null;this.textContainerTransform=null;this.textParentStyle=mi;this.clear(),this.addStyleSheet()}addStyleSheet(){if(!this.elem.querySelector(`#${Oo}`)){let e=document.createElementNS("http://www.w3.org/2000/svg","style");e.appendChild(document.createTextNode(`
|
39
|
+
path {
|
40
|
+
stroke-linecap: round;
|
41
|
+
stroke-linejoin: round;
|
42
|
+
}
|
43
|
+
|
44
|
+
text {
|
45
|
+
white-space: pre;
|
46
|
+
}
|
47
|
+
`.replace(/\s+/g,""))),e.setAttribute("id",Oo),this.elem.appendChild(e)}}setRootSVGAttribute(e,r){this.sanitize||(e in this.overwrittenAttrs||(this.overwrittenAttrs[e]=this.elem.getAttribute(e)),r!==null?this.elem.setAttribute(e,r):this.elem.removeAttribute(e))}displaySize(){return w.of(this.elem.clientWidth,this.elem.clientHeight)}clear(){if(this.lastPathString=[],this.lastContainerIDList=[],!this.sanitize){for(let e in this.overwrittenAttrs){let r=this.overwrittenAttrs[e];r?this.elem.setAttribute(e,r):this.elem.removeAttribute(e)}this.overwrittenAttrs={}}}addPathToSVG(){if(!this.lastPathStyle||this.lastPathString.length===0)return null;let e=document.createElementNS(po,"path");e.setAttribute("d",this.lastPathString.join(" "));let r=this.lastPathStyle;return r.fill.a>0?e.setAttribute("fill",r.fill.toHexString()):e.setAttribute("fill","none"),r.stroke&&(e.setAttribute("stroke",r.stroke.color.toHexString()),e.setAttribute("stroke-width",pe(r.stroke.width*this.getSizeOfCanvasPixelOnScreen()))),this.elem.appendChild(e),this.objectElems?.push(e),e}drawPath(e){let r=e.style,n=ht(e).transformedBy(this.getCanvasToScreenTransform());(this.lastPathString.length===0||!this.lastPathStyle||!Rr(this.lastPathStyle,r))&&(this.addPathToSVG(),this.lastPathStyle=r,this.lastPathString=[]),this.lastPathString.push(n.toString())}transformFrom(e,r,n=!1){let i=n?e:this.getCanvasToScreenTransform().rightMul(e);if(i.eq(k.identity))r.style.transform="";else{let a=i.toCSSMatrix();r.style.transform=a,r.setAttribute("data-highp-transform",a)}}drawText(e,r,n){let i=(a,l)=>{l.fontFamily!==this.textParentStyle?.fontFamily&&(a.style.fontFamily=l.fontFamily),l.fontVariant!==this.textParentStyle?.fontVariant&&(a.style.fontVariant=l.fontVariant??""),l.fontWeight!==this.textParentStyle?.fontWeight&&(a.style.fontWeight=l.fontWeight??""),l.fontStyle!==this.textParentStyle?.fontStyle&&(a.style.fontStyle=l.fontStyle??""),l.size!==this.textParentStyle?.size&&(a.style.fontSize=l.size+"px");let c=l.renderingStyle.fill.toHexString();if(a.style.fill=c,l.renderingStyle.stroke){let d=l.renderingStyle.stroke;a.style.stroke=d.color.toHexString(),a.style.strokeWidth=d.width+"px"}};if(r=this.getCanvasToScreenTransform().rightMul(r),this.textContainer){let a=document.createElementNS(po,"tspan");a.appendChild(document.createTextNode(e)),this.textContainer.appendChild(a),r=this.textContainerTransform.inverse().rightMul(r);let l=r.transformVec2(w.zero);a.setAttribute("x",`${pe(l.x)}`),a.setAttribute("y",`${pe(l.y)}`),i(a,n)}else{let a=document.createElementNS(po,"text");a.appendChild(document.createTextNode(e)),this.transformFrom(r,a,!0),i(a,n),this.elem.appendChild(a),this.objectElems?.push(a),this.objectLevel>0&&(this.textContainer=a,this.textContainerTransform=r,this.textParentStyle={...mi,...n})}}drawImage(e){let r=e.label??e.image.getAttribute("aria-label")??"";r===""&&(r=e.image.getAttribute("alt")??"");let n=document.createElementNS(po,"image");n.setAttribute("href",e.base64Url),n.setAttribute("width",e.image.getAttribute("width")??""),n.setAttribute("height",e.image.getAttribute("height")??""),n.setAttribute("aria-label",r),this.transformFrom(e.transform,n),this.elem.appendChild(n),this.objectElems?.push(n)}startObject(e){super.startObject(e),this.lastPathString=[],this.lastPathStyle=null,this.textContainer=null,this.textParentStyle=mi,this.objectElems=[]}endObject(e,r){if(super.endObject(e),this.addPathToSVG(),!!this.objectElems){if(e&&!this.sanitize){for(let a of this.objectElems){let l=e[ui],c=e[pi];if(l)for(let[d,u]of l)a.setAttribute(d,u);if(c)for(let d of c)a.style.setProperty(d.key,d.value,d.priority)}let n=e[hi],i=[];if(n&&n[0]&&n[0].length&&(i=n[0]),i.length>0&&bs(this.lastContainerIDList,i)&&this.lastContainerIDList.length>=i.length-1){let a=i[i.length-1],l=this.elem.querySelectorAll(`g#${a}`);if(l.length>=1){let c=l[0];if(c.children.length===0||this.lastContainerIDList.length>=i.length)for(let d of this.objectElems)d.remove(),c.appendChild(d);else i=[]}}else i=[];this.lastContainerIDList=i}if(r&&this.objectElems)if(this.objectElems.length===1)this.objectElems[0].classList.add(...r);else{let n=document.createElementNS(po,"g");n.classList.add(...r);for(let i of this.objectElems)i.remove(),n.appendChild(i);this.elem.appendChild(n)}}}unimplementedMessage(){throw new Error("Not implemenented!")}beginPath(e){this.unimplementedMessage()}endPath(e){this.unimplementedMessage()}lineTo(e){this.unimplementedMessage()}moveTo(e){this.unimplementedMessage()}traceCubicBezierCurve(e,r,n){this.unimplementedMessage()}traceQuadraticBezierCurve(e,r){this.unimplementedMessage()}drawPoints(...e){e.map(r=>{let n=document.createElementNS(po,"circle");n.setAttribute("cx",`${r.x}`),n.setAttribute("cy",`${r.y}`),n.setAttribute("r","15"),this.elem.appendChild(n)})}drawSVGElem(e){if(this.sanitize||e.tagName.toLowerCase()==="style"&&e.getAttribute("id")===Oo)return;let r=e.cloneNode(!0);this.elem.appendChild(r),this.objectElems?.push(r)}isTooSmallToRender(e){return!1}static fromViewport(e,r=!0){let n,i;typeof r=="boolean"?(n=r,i=!1):(n=r.sanitize??!0,i=r.useViewBoxForPositioning??!1);let a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),c=e.getScreenRectSize(),d=e.visibleRect,u;if(i){let h=e.visibleRect;u=[h.x,h.y,h.w,h.h],e=e.getTemporaryClone(),e.resetTransform(k.identity)}else u=[0,0,c.x,c.y];l.setAttribute("viewBox",u.map(h=>pe(h)).join(" ")),l.setAttribute("width",pe(c.x)),l.setAttribute("height",pe(c.y)),l.setAttribute("version","1.1"),l.setAttribute("baseProfile","full"),l.setAttribute("xmlns",a);let p=new s(l,e,n);return d.eq(e.visibleRect)||p.overrideVisibleRect(d),{element:l,renderer:p}}};var ho=30,mo=class{constructor(o,e,r,n,i,a){this.presentation=o;this.parent=e;this.viewport=r;this.onDragStart=n;this.onDragUpdate=i;this.onDragEnd=a;this.dragLastPos=null;this.element=document.createElement("div"),this.element.classList.add(`${Te}handle`,`${Te}${o.action}`);let l=document.createElement("div");l.classList.add(`${Te}content`),this.element.appendChild(l),this.parentSide=o.side;let c=o.icon;switch(c&&(l.appendChild(c),c.classList.add("icon")),o.action==="rotate"?this.shape=0:this.shape=1,this.shape){case 0:this.element.classList.add(`${Te}circle`);break;case 1:this.element.classList.add(`${Te}square`);break;default:Ki(this.shape)}this.updatePosition()}addTo(o){o.appendChild(this.element)}remove(){this.element.remove()}getBBoxParentCoords(){let o=this.parent.getScreenRegion(),e=w.of(ho,ho),r=o.size.scale(this.parentSide).minus(e.times(1/2));return new I(r.x,r.y,e.x,e.y)}getBBoxCanvasCoords(){let o=this.parent.region,e=w.of(ho,ho).times(1/this.viewport.getScaleFactor()),r=o.size.scale(this.parentSide).minus(e.times(.5));return new I(r.x,r.y,e.x,e.y).translatedBy(o.topLeft)}updatePosition(){let o=this.getBBoxParentCoords();this.element.style.marginLeft=`${o.topLeft.x}px`,this.element.style.marginTop=`${o.topLeft.y}px`,this.element.style.width=`${o.w}px`,this.element.style.height=`${o.h}px`}containsPoint(o){let e=this.getBBoxCanvasCoords(),r=o.minus(e.center),n=e.size.x/2,i;return this.shape===0?i=r.magnitude()<=n:i=Math.abs(r.x)<=n&&Math.abs(r.y)<=n,i}handleDragStart(o){return this.onDragStart(o.canvasPos),this.dragLastPos=o.canvasPos,!0}handleDragUpdate(o){this.dragLastPos&&this.onDragUpdate(o.canvasPos)}handleDragEnd(){if(this.dragLastPos)return this.onDragEnd()}setSnapToGrid(o){this.snapToGrid=o}isSnappingToGrid(){return this.snapToGrid}};var zt=class s extends W{constructor(e){super("duplicate");this.toDuplicate=e;this.duplicates=e.map(r=>r.clone()),this.reverse=new J(this.duplicates)}apply(e){this.reverse.unapply(e)}unapply(e){this.reverse.apply(e)}onDrop(e){this.reverse.onDrop(e)}description(e,r){return this.duplicates.length===0?r.duplicatedNoElements:r.duplicateAction(Or(r,this.duplicates)??r.elements,this.duplicates.length)}serializeToJSON(){return this.toDuplicate.map(e=>e.getId())}static{W.register("duplicate",(e,r)=>{let n=e.map(i=>r.image.lookupElement(i));return new s(n)})}};var Lt=(e=>(e.Lasso="lasso",e.Rectangle="rect",e))(Lt||{});var $r=class{constructor(o,e){this.editor=o;this.selection=e}onDragStart(o){this.selection.setTransform(k.identity),this.dragStartPoint=o}onDragUpdate(o){let e=this.editor.viewport.roundPoint(o.minus(this.dragStartPoint));this.selection.setTransform(k.translation(e))}onDragEnd(){return this.selection.finalizeTransform()}},Ur=class{constructor(o,e){this.editor=o;this.selection=e;this.mode=0}onDragStart(o,e){this.selection.setTransform(k.identity),this.mode=e,this.dragStartPoint=o,this.computeOriginAndScaleRate()}computeOriginAndScaleRate(){let o=this.selection.preTransformRegion,e=o.corners,r=0;for(let a=0;a<e.length;a++){let l=e[a],c=this.dragStartPoint.minus(l).magnitudeSquared();c>r&&(r=c,this.transformOrigin=l)}let n=1,i=1;this.transformOrigin.x>o.center.x&&(n=-1),this.transformOrigin.y>o.center.y&&(i=-1),this.scaleRate=w.of(n,i)}onDragUpdate(o){let e=o.minus(this.dragStartPoint),r=this.selection.preTransformRegion.width,n=this.selection.preTransformRegion.height,i=w.of(1,1);if(this.mode===1){let a=r+e.x*this.scaleRate.x;i=w.of(a/r,i.y)}if(this.mode===2){let a=n+e.y*this.scaleRate.y;i=w.of(i.x,a/n)}if(this.mode===0){let a=Math.abs(e.x)>Math.abs(e.y)?e.x:e.y,l=r+a;i=w.of(l/r,l/r)}if(i=i.map(a=>U.roundScaleRatio(a,2)),i.x!==0&&i.y!==0){let a=this.editor.viewport.roundPoint(this.transformOrigin);this.selection.setTransform(k.scaling2D(i,a))}}onDragEnd(){return this.selection.finalizeTransform()}},Wr=class{constructor(o,e){this.editor=o;this.selection=e;this.startAngle=0;this.targetRotation=0;this.maximumDistFromStart=0}getAngle(o){let e=this.selection.preTransformRegion.center;return o.minus(e).angle()}roundAngle(o){let e=8/Math.PI;return Math.round(o*e)/e}onDragStart(o){this.startPoint=o,this.selection.setTransform(k.identity),this.startAngle=this.getAngle(o),this.targetRotation=0,this.maximumDistFromStart=0,this.startTime=performance.now()}setRotationTo(o){let e=this.editor.viewport.roundPoint(this.selection.preTransformRegion.center),n=k.zRotation(o).mapEntries(a=>U.roundScaleRatio(a)),i=k.translation(e).rightMul(n).rightMul(k.translation(e.times(-1)));this.selection.setTransform(i)}onDragUpdate(o){this.targetRotation=this.roundAngle(this.getAngle(o)-this.startAngle),this.setRotationTo(this.targetRotation);let e=o.minus(this.startPoint).magnitude();e>this.maximumDistFromStart&&(this.maximumDistFromStart=e)}onDragEnd(){return(performance.now()-this.startTime)/1e3<.4&&this.maximumDistFromStart<10&&this.targetRotation===0&&this.setRotationTo(-Math.PI/2),this.selection.finalizeTransform()}};var fi=40,Fo=class{constructor(o,e,r,n,i){this.parent=o;this.viewport=e;this.icon=r;this.localization=i;this.lastDragPointer=null;this.element=document.createElement("div"),this.element.classList.add(`${Te}handle`,`${Te}selection-menu`),this.element.style.setProperty("--vertical-offset",`${fi}px`),this.onClick=()=>{this.button?.focus({preventScroll:!0});let a=this.getBBoxCanvasCoords().center;n(a)},this.initUI(),this.updatePosition()}initUI(){let o=document.createElement("button");this.icon.classList.add("icon"),o.replaceChildren(this.icon),o.ariaLabel=this.localization.selectionMenu__show,o.title=o.ariaLabel,this.button=o,o.onkeydown=e=>{e.key==="Enter"&&(e.preventDefault(),this.onClick())},this.element.appendChild(o),requestAnimationFrame(()=>{this.updatePosition()})}addTo(o){o.appendChild(this.element)}remove(){this.element.remove()}getElementScreenSize(){return w.of(this.element.clientWidth,this.element.clientHeight)}getBBoxParentCoords(){let o=w.of(0,-fi),e=this.getElementScreenSize();return new I(o.x,o.y,e.x,e.y)}getBBoxCanvasCoords(){let o=this.parent.region,e=this.viewport.getSizeOfPixelOnCanvas(),r=this.getElementScreenSize().times(e),n=fi/this.viewport.getScaleFactor(),i=w.of(o.x,o.y-n),a=w.of(48,48).times(e);return new I(i.x,i.y,r.x,r.y).grownToSize(a)}updatePosition(){let o=this.getBBoxParentCoords();this.element.style.marginLeft=`${o.topLeft.x}px`,this.element.style.marginTop=`${o.topLeft.y}px`}containsPoint(o){return this.getBBoxCanvasCoords().containsPoint(o)}handleDragStart(o){return this.lastDragPointer=o,!0}handleDragUpdate(o){this.lastDragPointer=o}handleDragEnd(){this.lastDragPointer&&this.containsPoint(this.lastDragPointer.canvasPos)&&this.onClick(),this.lastDragPointer=null}};var gi=100,vs=500,Ho=class s{constructor(o,e,r){this.editor=e;this.selectionTightBoundingBox=null;this.transform=k.identity;this.selectedElems=[];this.hasParent=!0;this.removedFromImage={};this.activeHandle=null;this.backgroundDragging=!1;this.selectionDuplicatedAnimationTimeout=null;o=[...o],this.selectedElems=o,this.originalRegion=I.empty,this.transformers={drag:new $r(e,this),resize:new Ur(e,this),rotate:new Wr(e,this)},this.outerContainer=document.createElement("div"),this.outerContainer.classList.add(`${Te}selection-outer-container`),this.innerContainer=document.createElement("div"),this.innerContainer.classList.add(`${Te}selection-inner-container`),this.backgroundElem=document.createElement("div"),this.backgroundElem.classList.add(`${Te}selection-background`),this.innerContainer.appendChild(this.backgroundElem),this.outerContainer.appendChild(this.innerContainer);let n=(u,p)=>{let h={0:"resize-xy",1:"resize-x",2:"resize-y"};return new mo({action:h[u],side:p},this,this.editor.viewport,m=>this.transformers.resize.onDragStart(m,u),m=>this.transformers.resize.onDragUpdate(m),()=>this.transformers.resize.onDragEnd())},i=[n(1,w.of(0,.5)),n(1,w.of(1,.5))],a=n(2,w.of(.5,1)),l=n(0,w.of(1,1)),c=new mo({action:"rotate",side:w.of(.5,0),icon:this.editor.icons.makeRotateIcon()},this,this.editor.viewport,u=>this.transformers.rotate.onDragStart(u),u=>this.transformers.rotate.onDragUpdate(u),()=>this.transformers.rotate.onDragEnd()),d=new Fo(this,this.editor.viewport,this.editor.icons.makeOverflowIcon(),r,this.editor.localization);this.childwidgets=[d,l,...i,a,c];for(let u of this.childwidgets)u.addTo(this.backgroundElem);this.recomputeRegion(),this.updateUI()}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){let o=k.zRotation(this.regionRotation,this.originalRegion.center),e=this.transform.rightMul(o.inverse());return this.originalRegion.transformedBoundingBox(e)}computeTightBoundingBox(){return this.selectedElems.reduce((e,r)=>(e??r.getBBox()).union(r.getBBox()),null)??I.empty}get regionRotation(){return this.transform.transformVec3(w.unitX).angle()}get preTransformedScreenRegion(){let o=e=>this.editor.viewport.canvasToScreen(e);return I.fromCorners(o(this.preTransformRegion.topLeft),o(this.preTransformRegion.bottomRight))}get preTransformedScreenRegionRotation(){return this.editor.viewport.getRotationAngle()}getScreenRegion(){let o=this.editor.viewport.canvasToScreenTransform,e=this.editor.viewport.getScaleFactor(),r=o.transformVec2(this.region.center);return new I(r.x,r.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(o,e=!0){this.transform=o,e&&this.hasParent&&this.previewTransformCmds()}getDeltaZIndexToMoveSelectionToTop(){if(this.selectedElems.length===0)return 0;let o=this.selectedElems[0].getZIndex(),e=this.editor.image.getElementsIntersectingRegion(this.region);return(e[e.length-1]?.getZIndex()??o)+1-o}finalizeTransform(){let o=this.transform,e=this.selectedElems;this.originalRegion=this.originalRegion.transformedBoundingBox(this.transform),this.transform=k.identity,this.scrollTo();let r;if(this.selectedElems.length>0){let n=this.getDeltaZIndexToMoveSelectionToTop();r=this.editor.dispatch(new s.ApplyTransformationCommand(this,e,o,n))}return r}sendToBack(){let e=this.editor.image.getElementsIntersectingRegion(this.editor.viewport.visibleRect)[0]?.getZIndex()??0,r=this.selectedElems[this.selectedElems.length-1]?.getZIndex()??0,i=e-1-r;if(i!==0){let a=this.selectedElems.map(l=>l.setZIndex(l.getZIndex()+i));return le(a,gi)}return null}static{W.register("selection-tool-transform",(o,e)=>{let r=new k(...o.transform),n=o.elems??[],i=parseInt(o.deltaZIndex??0);return new this.ApplyTransformationCommand(null,n,r,i)})}static{this.ApplyTransformationCommand=class extends W{constructor(e,r,n,i){super("selection-tool-transform");this.selection=e;this.fullTransform=n;this.deltaZIndex=i;(l=>typeof l[0]=="string")(r)?this.selectedElemIds=r:(this.selectedElemIds=r.map(l=>l.getId()),this.transformCommands=r.map(l=>l.setZIndexAndTransformBy(this.fullTransform,l.getZIndex()+i)))}resolveToElems(e,r){this.transformCommands||(this.transformCommands=this.selectedElemIds.map(n=>{let i=e.image.lookupElement(n);if(!i)return console.warn(`Unable to find element with ID, ${n}.`),null;let a=i.getZIndex(),l=i.getZIndex()+this.deltaZIndex;return r&&(l=i.getZIndex(),a=i.getZIndex()-this.deltaZIndex),i.setZIndexAndTransformBy(this.fullTransform,l,a)}).filter(n=>n!==null))}async apply(e){this.resolveToElems(e,!1),this.selection?.setTransform(this.fullTransform,!1),this.selection?.updateUI(),await e.asyncApplyCommands(this.transformCommands,gi),this.selection?.setTransform(k.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}async unapply(e){this.resolveToElems(e,!0),this.selection?.setTransform(this.fullTransform.inverse(),!1),this.selection?.updateUI(),await e.asyncUnapplyCommands(this.transformCommands,gi,!0),this.selection?.setTransform(k.identity,!1),this.selection?.recomputeRegion(),this.selection?.updateUI()}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray(),deltaZIndex:this.deltaZIndex}}description(e,r){return r.transformedElements(this.selectedElemIds.length)}}}previewTransformCmds(){if(this.selectedElems.length===0)return;if(this.selectedElems.length>vs){this.updateUI();return}let o=this.editor.display.getWetInkRenderer();o.clear(),o.pushTransform(this.transform);let r=this.editor.viewport.visibleRect.union(this.region).transformedBoundingBox(this.transform.inverse());for(let n of this.selectedElems)n.render(o,r);o.popTransform(),this.updateUI()}recomputeRegion(){let o=this.computeTightBoundingBox();return this.selectionTightBoundingBox=o,o?(this.originalRegion=o,this.padRegion(),!0):(this.cancelSelection(),!1)}padRegion(){let o=this.selectionTightBoundingBox??this.originalRegion,e=this.getMinCanvasSize();if(o.w<e||o.h<e){let r=e/2;this.originalRegion=I.bboxOf(o.corners,r),this.updateUI()}}getMinCanvasSize(){return ho/this.editor.viewport.getScaleFactor()*2}getSelectedItemCount(){return this.selectedElems.length}updateUI(){if(!this.hasParent)return;let o=this.getScreenRegion();this.backgroundElem.style.marginLeft=`${o.topLeft.x}px`,this.backgroundElem.style.marginTop=`${o.topLeft.y}px`,this.backgroundElem.style.width=`${o.width}px`,this.backgroundElem.style.height=`${o.height}px`;let e=this.screenRegionRotation*180/Math.PI;this.backgroundElem.style.transform=`rotate(${e}deg)`,this.backgroundElem.style.transformOrigin="center";let r=`${Te}rotated-near-perpendicular`;Math.abs(Math.sin(this.screenRegionRotation))>.5?this.innerContainer.classList.add(r):this.innerContainer.classList.remove(r),o.width===0&&o.height===0?this.innerContainer.classList.add("-empty"):this.innerContainer.classList.remove("-empty");for(let n of this.childwidgets)n.updatePosition(this.getScreenRegion())}addRemoveSelectionFromImage(o){if(!(!o&&this.selectedElems.length>vs)){for(let e of this.selectedElems){let r=this.editor.image.findParent(e);!o&&r?(this.removedFromImage[e.getId()]=!0,r.remove()):!r&&this.removedFromImage[e.getId()]&&(q.addElement(e).apply(this.editor),this.removedFromImage[e.getId()]=!1,delete this.removedFromImage[e.getId()])}this.editor.queueRerender().then(()=>{o?this.editor.display.getWetInkRenderer().clear():this.previewTransformCmds()})}}removeDeletedElemsFromSelection(){this.selectedElems=this.selectedElems.filter(o=>{let e=!!this.editor.image.findParent(o),r=this.removedFromImage[o.getId()];return e||r})}onDragStart(o){if(this.selectedElems.length===0)return!1;document.getSelection()?.removeAllRanges(),this.activeHandle=null;let e=!1;this.backgroundDragging=!1,this.region.containsPoint(o.canvasPos)&&(this.backgroundDragging=!0,e=!0);for(let r of this.childwidgets)r.containsPoint(o.canvasPos)&&(this.activeHandle=r,this.backgroundDragging=!1,e=!0);return e&&(this.removeDeletedElemsFromSelection(),this.addRemoveSelectionFromImage(!1)),this.activeHandle&&this.activeHandle.handleDragStart(o),this.backgroundDragging&&this.transformers.drag.onDragStart(o.canvasPos),e}onDragUpdate(o){this.backgroundDragging&&this.transformers.drag.onDragUpdate(o.canvasPos),this.activeHandle&&this.activeHandle.handleDragUpdate(o)}onDragEnd(){this.backgroundDragging?this.transformers.drag.onDragEnd():this.activeHandle&&this.activeHandle.handleDragEnd(),this.addRemoveSelectionFromImage(!0),this.backgroundDragging=!1,this.activeHandle=null,this.updateUI()}onDragCancel(){this.backgroundDragging=!1,this.activeHandle=null,this.setTransform(k.identity),this.addRemoveSelectionFromImage(!0),this.updateUI()}scrollTo(){if(this.selectedElems.length===0)return!1;let o=this.editor.viewport.getScreenRectSize(),e=new I(0,0,o.x,o.y),r=this.getScreenRegion();if(!e.containsPoint(r.center)){let n=r.center,i=e.getClosestPointOnBoundaryTo(n),a=this.editor.viewport.screenToCanvas(i),l=this.region.center,c=a.minus(l);return this.editor.dispatchNoAnnounce(U.transformBy(k.translation(c.times(.5))),!1),this.editor.queueRerender().then(()=>{this.previewTransformCmds()}),!0}return!1}deleteSelectedObjects(){return(this.backgroundDragging||this.activeHandle)&&this.onDragEnd(),new J(this.selectedElems)}runSelectionDuplicatedAnimation(){this.selectionDuplicatedAnimationTimeout&&clearTimeout(this.selectionDuplicatedAnimationTimeout);let o=400;this.backgroundElem.style.animation=`${o}ms ease selection-duplicated-animation`,this.selectionDuplicatedAnimationTimeout=setTimeout(()=>{this.backgroundElem.style.animation="",this.selectionDuplicatedAnimationTimeout=null},o)}async duplicateSelectedObjects(){let o=this.backgroundDragging||this.activeHandle,e=null;o||this.runSelectionDuplicatedAnimation();let r;if(o){let i=this.getDeltaZIndexToMoveSelectionToTop();e=new s.ApplyTransformationCommand(null,this.selectedElems,this.transform,i),await e.apply(this.editor),this.addRemoveSelectionFromImage(!0),r=le(this.selectedElems.map(a=>q.addElement(a.clone()))),await e?.unapply(this.editor),this.addRemoveSelectionFromImage(!1),this.previewTransformCmds(),this.updateUI()}else r=new zt(this.selectedElems);return r}snapSelectedObjectsToGrid(){let o=this.editor.viewport,e=this.computeTightBoundingBox().topLeft,n=o.snapToGrid(e).minus(e),i=this.getTransform();this.setTransform(i.rightMul(k.translation(n))),this.finalizeTransform()}setHandlesVisible(o){o?this.innerContainer.classList.remove("-hide-handles"):this.innerContainer.classList.add("-hide-handles")}addTo(o){this.outerContainer.parentElement&&this.outerContainer.remove(),o.appendChild(this.outerContainer),this.hasParent=!0}setToPoint(o){this.originalRegion=this.originalRegion.grownToPoint(o),this.selectionTightBoundingBox=null,this.updateUI()}cancelSelection(){this.outerContainer.parentElement&&this.outerContainer.remove(),this.originalRegion=I.empty,this.selectionTightBoundingBox=null,this.hasParent=!1}getSelectedObjects(){return[...this.selectedElems]}};var No=class{constructor(o,e){this.viewport=o;this.scrollByCanvasDelta=e;this.started=!1;this.updateLoopId=0;this.updateLoopRunning=!1;this.targetPoint=null;this.scrollRate=1e3}getScrollForPoint(o){let e=this.viewport.getScreenRectSize(),r=new I(0,0,e.x,e.y),n=44,i=r.grownBy(-n);if(i.containsPoint(o))return w.zero;let a=i.getClosestPointOnBoundaryTo(o),l=a.distanceTo(o),c=a.minus(o),u=Math.min(l/n,1.25);return c.normalizedOrZero().times(u)}start(){this.started=!0}onPointerMove(o){this.started&&(this.getScrollForPoint(o)===w.zero?this.stopUpdateLoop():(this.targetPoint=o,this.startUpdateLoop()))}stop(){this.targetPoint=null,this.started=!1,this.stopUpdateLoop()}startUpdateLoop(){this.updateLoopRunning||(async()=>{this.updateLoopId++;let o=this.updateLoopId,e=performance.now();for(;this.updateLoopId===o&&this.targetPoint;){this.updateLoopRunning=!0;let r=performance.now(),n=r-e,a=this.getScrollForPoint(this.targetPoint).times(this.scrollRate*n/1e3);this.scrollByCanvasDelta(this.viewport.screenToCanvasTransform.transformVec3(a)),e=r,await Ye()}this.updateLoopRunning=!1})()}stopUpdateLoop(){this.updateLoopId++}};var ja=s=>new Promise(o=>{setTimeout(()=>o(),s)}),Kr=ja;var _a=0,qa=async(s,o,e)=>{let r=document.createElement("div"),{remove:n}=s.createHTMLOverlay(r),i=document.createElement("dialog");i.classList.add("editor-popup-menu");let a=240;i.style.setProperty("--hide-menu-animation-timeout",`${a}ms`);let l=()=>{let p=s.getOutputBBoxInDOM(),h=s.viewport.canvasToScreen(o).plus(p.topLeft);i.style.setProperty("--anchor-x",`${h.x}px`),i.style.setProperty("--anchor-y",`${h.y}px`)};l();let c=s.notifier.on(7,l);r.appendChild(i);let d=!1,u=async()=>{d||(d=!0,c.remove(),i.classList.add("-hide"),await Kr(a),i.close())};return new Promise(p=>{let h=!1,m=null,g=()=>{h||(p(m),h=!0)};i.onclose=()=>{n(),g()};let v=f=>{m=f,u(),g()};s.handlePointerEventsExceptClicksFrom(i,(f,T)=>T.target===i&&f==="pointerdown"?(u(),!0):!!d,(f,T)=>T.target===i);let b=document.createElement("div");b.classList.add("content"),b.role="menu";let y=[];b.addEventListener("keydown",f=>{let T=y.findIndex(S=>S===document.activeElement);if(T===-1)return;let P=T;f.key==="ArrowDown"?P++:f.key==="ArrowUp"?P--:f.key==="End"?P=y.length-1:f.key==="Home"&&(P=0),P<0&&(P+=y.length),P%=y.length,P!==T&&(f.preventDefault(),y[P].focus())});for(let f of e){let T=document.createElement("button");T.id=`menu-overlay-option-${_a++}`,T.role="menuitem",T.classList.add("option","editor-popup-menu-option"),T.replaceChildren(f.icon(),document.createTextNode(f.text)),T.onclick=P=>{P.defaultPrevented||v(f.key)},b.appendChild(T),y.length===0&&(T.autofocus=!0),y.push(T)}i.appendChild(b),i.showModal(),b.scrollIntoView({block:"nearest"})})},ys=qa;var Za=async(s,o={})=>{try{let e=new FileReader;return await new Promise((r,n)=>{e.onload=()=>r(e.result),e.onerror=n,e.onabort=n,e.onprogress=i=>{o.onprogress?.(i)},e.readAsDataURL(s)})}catch(e){(o.onWarning??console.warn)("Unable to convert file to base64 with a FileReader: ",e);let r=await s.arrayBuffer(),n=new Uint8Array(r),i=30,a=[];for(let l=0;l<n.length;l+=i){let c=String.fromCharCode(...n.slice(l,l+i));a.push(btoa(c))}return`data:${s.type??"image/*"};base64,${a.join("")}`}},Gr=Za;var xs=s=>s.endsWith("+xml")||s.startsWith("text/"),Ae=class{constructor(o,e){this.editor=o;this.callbacks=e}#e=!1;paste(o){let e=r=>{if(this.callbacks?.onPasteError)return this.callbacks.onPasteError(r),Promise.resolve(!1);throw r};try{return this.pasteInternal(o).catch(e)}catch(r){return e(r)}}async pasteInternal(o){let e=this.editor,r=o?.dataTransfer??o?.clipboardData??null,n=!!r,i=(p,h)=>h&&e.toolController.dispatchInputEvent({kind:8,mime:p,data:h}),a=["image/svg+xml","text/html","image/png","image/jpeg","text/plain"],l=[],c=new Map,d=e.getCurrentSettings();if(n){l=[...r.files];for(let p of a){let h=r.getData(p);h&&c.set(p,h)}}else if(d.clipboardApi){let p=await d.clipboardApi.read();for(let[h,m]of p.entries())if(typeof m=="string")c.set(h,m);else{let g=m;g.type!==h&&(g=new Blob([g],{type:h})),l.push(g)}}else{let p=await navigator.clipboard.read();for(let h of p)for(let m of h.types)a.includes(m)&&l.push(await h.getType(m))}let u=async p=>{let h=xs(p);if(h){let m=c.get(p);if(i(p,m))return o?.preventDefault(),!0}for(let m of l)if(m?.type?.toLowerCase()===p)if(h){let v=await m.text();if(i(p,v))return o?.preventDefault(),!0}else{e.showLoadingWarning(0);let v=b=>{e.showLoadingWarning(b.loaded/b.total)};try{let b=await Gr(m,{onprogress:v});if(i(p,b))return o?.preventDefault(),e.hideLoadingWarning(),!0}catch(b){console.error("Error reading image:",b)}e.hideLoadingWarning()}return!1};for(let p of a)if(await u(p))return!0;return!1}copy(o){let e=r=>{if(this.callbacks?.onCopyError)return this.callbacks.onCopyError(r),Promise.resolve();throw r};try{return this.copyInternal(o).catch(e)}catch(r){return e(r)}}copyInternal(o){let e=new Map;this.editor.toolController.dispatchInputEvent({kind:7,setData:(u,p)=>{e.set(u,p)}})&&o?.preventDefault();let n=[...e.keys()].some(u=>!xs(u)),i=u=>{if(!o)throw new Error(`Unable to copy -- no event provided${u?`. Original error: ${u}`:""}`);for(let[p,h]of e.entries())typeof h=="string"&&("clipboardData"in o?o.clipboardData?.setData(p,h):o.dataTransfer?.setData(p,h))},a=()=>{let h=(m=>{let g=Object.create(null);for(let[v,b]of Object.entries(m))"supports"in ClipboardItem&&typeof ClipboardItem.supports=="function"&&!ClipboardItem.supports(v)||(g[v]=b);return g})((m=>{let g=Object.create(null);for(let[v,b]of m.entries()){if(typeof b=="string"){let y=new Blob([new TextEncoder().encode(b)],{type:v});g[v]=y}else g[v]=b;v==="image/svg+xml"&&(g["text/html"]??=g[v])}return g})(e));return navigator.clipboard.write([new ClipboardItem(h)])},l=typeof ClipboardItem<"u"&&typeof navigator?.clipboard?.write<"u",c=!this.#e&&l&&(n||!o),d=this.editor.getCurrentSettings();if(c&&d.clipboardApi)return d.clipboardApi.write(e)??Promise.resolve();if(c){let u=null,p=h=>{console.warn("Unable to copy to the clipboard API. Future calls to .copy will use ClipboardEvents if possible.",h),this.#e=!0,i(h)};try{u=a()}catch(h){p(h)}if(u)return u.catch(p)}else i();return Promise.resolve()}};var Ya=(s,o)=>{let e=document.createElement("div"),{remove:r}=s.createHTMLOverlay(e);e.classList.add("dialog-container","message-dialog-container",...o.classNames??[]);let n=document.createElement("dialog"),i=document.createElement("div");i.classList.add("message-dialog-content",...o.contentClassNames??[]);let a=document.createElement("h1");a.textContent=o.title,a.setAttribute("autofocus","true");let l=document.createElement("button");l.innerText=s.localization.closeDialog,l.classList.add("close");let c=document.createElement("div");c.classList.add("scroll"),c.onwheel=h=>h.stopPropagation(),i.replaceChildren(a,c,l),n.replaceChildren(i),e.replaceChildren(n);let d=300;n.style.setProperty("--close-delay",`${d}ms`);let u=async()=>{n.classList.add("-closing"),await Kr(d),n.close()};return(()=>{n.addEventListener("pointerdown",h=>{h.target===n&&u()}),n.onclose=()=>{r()},l.onclick=()=>u()})(),n.showModal(),{close:()=>u(),appendChild:h=>{c.appendChild(h)}}},jr=Ya;var Xa=s=>{let o=e=>{let r=jr(s,{title:s.localization.copyPasteError__heading,classNames:["clipboard-error-dialog"]});r.appendChild(document.createTextNode(s.localization.copyPasteError__description));let n=document.createElement("details"),i=document.createElement("summary");return i.textContent=s.localization.copyPasteError__errorDetails,n.appendChild(i),n.appendChild(document.createTextNode(`Error: ${e}`)),r.appendChild(n),r};return{onCopyError(e){let r=o(e),n=document.createElement("label");n.textContent=s.localization.copyPasteError__copyRetry;let i=document.createElement("textarea");n.appendChild(i);let a=new Ae(s),l=c=>(c.preventDefault(),a.copy(c).then(()=>{r.close()}));i.oncopy=l,i.ondragstart=l,i.value=s.localization.copyPasteError__copyMe,r.appendChild(n),i.select(),document.execCommand("copy")},onPasteError(e){let r=o(e),n=document.createElement("label");n.textContent=s.localization.copyPasteError__pasteRetry;let i=document.createElement("textarea");n.appendChild(i);let a=new Ae(s),l=c=>(c.preventDefault(),a.paste(c).then(d=>{d&&r.close()}));i.onpaste=l,i.ondrop=l,r.appendChild(n),i.focus(),document.execCommand("paste")}}},bi=Xa;var Qa=async(s,o,e,r,n)=>{let i=o.localization,a=s?.getSelectedItemCount()&&r,l=[{text:i.selectionMenu__paste,icon:()=>o.icons.makePasteIcon(),key:()=>{new Ae(o,bi(o)).paste()}}];(await ys(o,e,a?[{text:i.selectionMenu__duplicate,icon:()=>o.icons.makeDuplicateSelectionIcon(),key:async()=>{await o.dispatch(await s.duplicateSelectedObjects())}},{text:i.selectionMenu__delete,icon:()=>o.icons.makeDeleteSelectionIcon(),key:async()=>{await o.dispatch(s.deleteSelectedObjects()),n()}},{text:i.selectionMenu__copyToClipboard,icon:()=>o.icons.makeCopyIcon(),key:()=>{new Ae(o,bi(o)).copy()}},...l]:l))?.()},ws=Qa;var It=class{render(o,e){o.drawPath(Z(this.previewPath(),{fill:e}))}resolve(o,e){let r=this.previewPath(),n=c=>c.filter(d=>d.isSelectable()),i,a=e.getSizeOfPixelOnCanvas()*3;if(r.bbox.maxDimension<=a){let c=e.visibleRect.maxDimension/200,d=r.bbox.grownBy(c);i=o.getElementsIntersectingRegion(d).filter(u=>d.containsRect(u.getBBox())||u.intersectsRect(d)),i=n(i),i.length>1&&(i=[i[0]])}else i=n(this.resolveInternal(o));return i}};var $o=class extends It{constructor(e,r){super();this.viewport=r;this.boundaryPoints=[];this.boundaryPoints.push(e),this.lastPoint=e}onPointerMove(e){let r=this.boundaryPoints[this.boundaryPoints.length-1],n=this.viewport.getSizeOfPixelOnCanvas()*8;r.distanceTo(e)>=n&&this.boundaryPoints.push(e),this.lastPoint=e}previewPath(){let e=this.boundaryPoints.map(r=>({kind:0,point:r}));return e.push({kind:0,point:this.lastPoint}),new $(this.boundaryPoints[0],e).asClosed()}resolveInternal(e){let r=this.previewPath(),n=r.polylineApproximation(),i=e.getElementsIntersectingRegion(r.bbox),a=l=>{if(r.closedContainsRect(l.getExactBBox()))return!0;let c=!1;for(let d of l.keyPoints())if(r.closedContainsPoint(d)){c=!0;break}if(!c)return!1;for(let d of n)if(l.intersects(d))return!1;return!0};return i.filter(a)}};var Uo=class extends It{constructor(o){super(),this.rect=I.fromCorners(o,o)}onPointerMove(o){this.rect=this.rect.grownToPoint(o)}previewPath(){return $.fromRect(this.rect)}resolveInternal(o){return o.getElementsIntersectingRegion(this.rect).filter(e=>e.intersectsRect(this.rect))}};var Te="selection-tool-";var ve=class extends K{constructor(e,r){super(e.notifier,r);this.editor=e;this.removeSelectionScheduled=!1;this.startPoint=null;this.expandingSelectionBox=!1;this.shiftKeyPressed=!1;this.snapToGrid=!1;this.lastPointer=null;this.showContextMenu=async(e,r=!0)=>{await ws(this.selectionBox,this.editor,e,r,()=>this.clearSelection())};this.selectionBoxHandlingEvt=!1;this.lastSelectedObjects=[];this.hasUnfinalizedTransformFromKeyPress=!1;this.modeValue=te.fromInitialValue("rect"),this.modeValue.onUpdate(()=>{this.editor.notifier.dispatch(2,{kind:2,tool:this})}),this.autoscroller=new No(e.viewport,n=>{if(e.dispatch(U.transformBy(k.translation(n)),!1),this.lastPointer){let i=this.lastPointer.withScreenPosition(this.lastPointer.screenPos,e.viewport);this.onMainPointerUpdated(i)}}),this.handleOverlay=document.createElement("div"),e.createHTMLOverlay(this.handleOverlay),this.handleOverlay.style.display="none",this.handleOverlay.classList.add("handleOverlay"),e.notifier.on(7,n=>{this.editor.clearWetInk(),this.expandingSelectionBox||this.selectionBox?.padRegion(),this.selectionBox?.updateUI()}),this.editor.handleKeyEventsFrom(this.handleOverlay),this.editor.handlePointerEventsFrom(this.handleOverlay)}getSelectionColor(){let e=getComputedStyle(this.handleOverlay).getPropertyValue("--selection-background-color");return L.fromString(e).withAlpha(.5)}makeSelectionBox(e){this.prevSelectionBox=this.selectionBox,this.selectionBox=new Ho(e,this.editor,this.showContextMenu),this.expandingSelectionBox||this.prevSelectionBox?.cancelSelection(),this.selectionBox.addTo(this.handleOverlay)}onContextMenu(e){let r=this.selectionBox?.getScreenRegion()?.containsPoint(e.screenPos);return this.showContextMenu(e.canvasPos,r),!0}onPointerDown({allPointers:e,current:r}){let n=this.snapToGrid;if(n&&(r=r.snappedToGrid(this.editor.viewport)),e.length===1){this.startPoint=r.canvasPos;let i=!1;return this.selectionBox&&(n&&this.selectionBox.snapSelectedObjectsToGrid(),this.selectionBox.onDragStart(r)&&(i=!0,this.selectionBoxHandlingEvt=!0,this.expandingSelectionBox=!1)),i?this.autoscroller.start():(this.expandingSelectionBox=this.shiftKeyPressed,this.removeSelectionScheduled=!this.expandingSelectionBox,this.modeValue.get()==="lasso"?this.selectionBuilder=new $o(r.canvasPos,this.editor.viewport):this.selectionBuilder=new Uo(r.canvasPos)),!0}return!1}onPointerMove(e){this.onMainPointerUpdated(e.current)}onMainPointerUpdated(e){if(this.lastPointer=e,this.removeSelectionScheduled&&(this.removeSelectionScheduled=!1,this.handleOverlay.replaceChildren(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null),this.autoscroller.onPointerMove(e.screenPos),!this.expandingSelectionBox&&this.shiftKeyPressed&&this.startPoint){let r=this.editor.viewport.canvasToScreen(this.startPoint);e=e.lockedToXYAxesScreen(r,this.editor.viewport)}this.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox?.onDragUpdate(e):(this.selectionBuilder?.onPointerMove(e.canvasPos),this.editor.clearWetInk(),this.selectionBuilder?.render(this.editor.display.getWetInkRenderer(),this.getSelectionColor()))}onPointerUp(e){if(this.onMainPointerUpdated(e.current),this.autoscroller.stop(),this.selectionBoxHandlingEvt)this.selectionBox?.onDragEnd();else if(this.selectionBuilder){let r=this.selectionBuilder.resolve(this.editor.image,this.editor.viewport);this.selectionBuilder=null,this.editor.clearWetInk(),this.expandingSelectionBox&&this.selectionBox?this.setSelection([...this.selectionBox.getSelectedObjects(),...r]):this.setSelection(r)}this.expandingSelectionBox=!1,this.removeSelectionScheduled=!1,this.selectionBoxHandlingEvt=!1,this.lastPointer=null}onGestureCancel(){this.selectionBuilder&&(this.selectionBuilder=null,this.editor.clearWetInk()),this.autoscroller.stop(),this.selectionBoxHandlingEvt?this.selectionBox?.onDragCancel():this.removeSelectionScheduled||(this.selectionBox?.cancelSelection(),this.selectionBox=this.prevSelectionBox,this.selectionBox?.addTo(this.handleOverlay),this.selectionBox?.recomputeRegion(),this.prevSelectionBox=null),this.removeSelectionScheduled=!1,this.expandingSelectionBox=!1,this.lastPointer=null,this.selectionBoxHandlingEvt=!1}onSelectionUpdated(){let e=this.selectionBox?.getSelectedItemCount()??0,r=this.selectionBox?.getSelectedObjects()??[];(this.lastSelectedObjects.length!==e||r.some((i,a)=>this.lastSelectedObjects[a]!==i))&&(this.lastSelectedObjects=r,this.editor.notifier.dispatch(2,{kind:2,tool:this}),this.editor.notifier.dispatch(9,{kind:9,selectedComponents:r,tool:this}),e>0&&(this.editor.announceForAccessibility(this.editor.localization.selectedElements(e)),this.zoomToSelection())),e===0&&this.selectionBox&&(this.selectionBox.cancelSelection(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null)}zoomToSelection(){if(this.selectionBox){let e=this.selectionBox.region;this.editor.dispatchNoAnnounce(this.editor.viewport.zoomTo(e,!1),!1)}}onKeyPress(e){let r=this.editor.shortcuts;if(r.matchesShortcut(io,e))return this.snapToGrid=!0,!0;if(this.selectionBox&&(r.matchesShortcut(Pr,e)||r.matchesShortcut(Er,e)))return!0;if(r.matchesShortcut(no,e))return this.setSelection(this.editor.image.getAllElements()),!0;if(e.ctrlKey)return!1;if((e.shiftKey||e.key==="Shift")&&(this.shiftKeyPressed=!0,e.key==="Shift"))return!0;let n=0,i=0,a=0,l=0,c=0;r.matchesShortcut(Bn,e)?i-=1:r.matchesShortcut(Mn,e)?i+=1:r.matchesShortcut(Dn,e)?a-=1:r.matchesShortcut(An,e)?a+=1:r.matchesShortcut(On,e)?n+=1:r.matchesShortcut(Vn,e)?n-=1:r.matchesShortcut(Fn,e)?l-=1:r.matchesShortcut(Hn,e)?l+=1:r.matchesShortcut(Nn,e)?c-=1:r.matchesShortcut($n,e)?c+=1:r.matchesShortcut(Un,e)?(l-=1,c-=1):r.matchesShortcut(Wn,e)&&(l+=1,c+=1);let d=i!==0||a!==0||n!==0||l!==0||c!==0;if(!this.selectionBox)d=!1;else if(d){let u=10*this.editor.viewport.getSizeOfPixelOnCanvas(),p=Math.PI/8,h=5/4,m=this.selectionBox.region,g=w.of(h**l,h**c),b=k.zRotation(n*p).mapEntries(P=>U.roundScaleRatio(P)),y=this.editor.viewport.roundPoint(m.center),f=k.scaling2D(g,this.editor.viewport.roundPoint(m.topLeft)).rightMul(k.translation(y).rightMul(b).rightMul(k.translation(y.times(-1)))).rightMul(k.translation(this.editor.viewport.roundPoint(w.of(i,a).times(u)))),T=this.selectionBox.getTransform();this.selectionBox.setTransform(T.rightMul(f)),this.selectionBox.scrollTo(),this.hasUnfinalizedTransformFromKeyPress=!0}return this.selectionBox&&!d&&(e.key==="Delete"||e.key==="Backspace")&&(this.editor.dispatch(this.selectionBox.deleteSelectedObjects()),this.clearSelection(),d=!0),d}onKeyUp(e){let r=this.editor.shortcuts;if(r.matchesShortcut(io,e))return this.snapToGrid=!1,!0;if(r.matchesShortcut(no,e))return!0;if(this.selectionBox&&r.matchesShortcut(Pr,e))return this.selectionBox.duplicateSelectedObjects().then(n=>{this.editor.dispatch(n)}),!0;if(this.selectionBox&&r.matchesShortcut(Er,e)){let n=this.selectionBox.sendToBack();return n&&this.editor.dispatch(n),!0}return e.shiftKey===!1&&(this.shiftKeyPressed=!1),e.key==="Shift"?(this.shiftKeyPressed=!1,!0):this.hasUnfinalizedTransformFromKeyPress?this.selectionBox?(this.selectionBox.finalizeTransform(),this.hasUnfinalizedTransformFromKeyPress=!1,!0):!1:!0}onCopy(e){if(!this.selectionBox)return!1;let r=this.selectionBox.getSelectedObjects(),n=this.selectionBox.region;if(r.length===0)return!1;let i=new U(()=>{}),l=this.selectionBox.getScreenRegion().size.times(this.editor.display.getDevicePixelRatio()).maximumEntryMagnitude()/(n.size.maximumEntryMagnitude()||1);l=Math.pow(2,Math.ceil(Math.log2(l))),i.updateScreenSize(n.size.times(l)),i.resetTransform(k.scaling2D(l).rightMul(k.translation(n.topLeft.times(-1))));let{element:c,renderer:d}=me.fromViewport(i,{sanitize:!0,useViewBoxForPositioning:!0}),{element:u,renderer:p}=Le.fromViewport(i,{maxCanvasDimen:4096}),h=[];for(let m of r)m.render(d),m.render(p),m instanceof ne&&h.push(m.getText());return e.setData("image/svg+xml",c.outerHTML),e.setData("text/html",c.outerHTML),e.setData("image/png",new Promise((m,g)=>{u.toBlob(v=>{v?m(v):g(new Error("Failed to convert canvas to blob."))},"image/png")})),h.length>0&&e.setData("text/plain",h.join(`
|
48
|
+
`)),!0}setEnabled(e){let r=this.isEnabled();super.setEnabled(e),r!==e&&(this.selectionBox?.cancelSelection(),this.onSelectionUpdated(),this.handleOverlay.replaceChildren(),this.selectionBox=null,this.shiftKeyPressed=!1,this.snapToGrid=!1,this.handleOverlay.style.display=e?"block":"none",e?(this.handleOverlay.tabIndex=0,this.handleOverlay.setAttribute("aria-label",this.editor.localization.selectionToolKeyboardShortcuts)):this.handleOverlay.tabIndex=-1)}getSelection(){return this.selectionBox}isSelecting(){return!!this.selectionBuilder}getSelectedObjects(){return this.selectionBox?.getSelectedObjects()??[]}setSelection(e){e=e.filter(n=>n.isSelectable()),e.sort((n,i)=>n.getZIndex()-i.getZIndex()),e=e.filter((n,i)=>i>0?n!==e[i-1]:!0);let r=null;for(let n of e)r?r=r.union(n.getBBox()):r=n.getBBox();this.clearSelectionNoUpdateEvent(),r&&this.makeSelectionBox(e),this.onSelectionUpdated()}clearSelectionNoUpdateEvent(){this.handleOverlay.replaceChildren(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null}clearSelection(){this.clearSelectionNoUpdateEvent(),this.onSelectionUpdated()}};var Bt=class extends K{constructor(e){super(e.notifier,e.localization.undoRedoTool);this.editor=e}onKeyPress(e){return this.editor.shortcuts.matchesShortcut(Bo,e)?(this.editor.history.undo(),!0):this.editor.shortcuts.matchesShortcut(Kn,e)?(this.editor.history.redo(),!0):!1}};var Cs="textEditorOverlay",$e=class extends K{constructor(e,r,n){super(e.notifier,r);this.editor=e;this.localizationTable=n;this.textInputElem=null;this.textMeasuringCtx=null;this.removeExistingCommand=null;let i=e.getCurrentSettings().text?.fonts??[];this.textStyleValue=j.fromInitialValue({size:32,fontFamily:i.length>0?i[0]:"sans-serif",renderingStyle:{fill:L.purple}}),this.textStyleValue.onUpdateAndNow(()=>{this.textStyle=this.textStyleValue.get(),this.updateTextInput(),this.editor.notifier.dispatch(2,{kind:2,tool:this})}),this.contentTransform=j.fromInitialValue(k.identity),this.textEditOverlay=document.createElement("div"),this.textEditOverlay.classList.add(Cs),this.editor.addStyleSheet(`
|
49
|
+
.${Cs} textarea {
|
50
|
+
background-color: rgba(0, 0, 0, 0);
|
51
|
+
|
52
|
+
white-space: pre;
|
53
|
+
overflow: hidden;
|
54
|
+
|
55
|
+
padding: 0;
|
56
|
+
margin: 0;
|
57
|
+
border: none;
|
58
|
+
padding: 0;
|
59
|
+
|
60
|
+
min-width: 100px;
|
61
|
+
min-height: 1.1em;
|
62
|
+
}
|
63
|
+
`),this.anchorControl=this.editor.anchorElementToCanvas(this.textEditOverlay,this.contentTransform)}initTextMeasuringCanvas(){this.textMeasuringCtx??=document.createElement("canvas").getContext("2d")}getTextAscent(e,r){if(this.initTextMeasuringCanvas(),this.textMeasuringCtx){this.textMeasuringCtx.textBaseline="alphabetic",ne.applyTextStyles(this.textMeasuringCtx,r);let n=this.textMeasuringCtx.measureText(e);return n.fontBoundingBoxAscent??n.actualBoundingBoxAscent}return r.size*2/3}flushInput(e=!0){if(!this.textInputElem)return;let r=this.textEditOverlay.parentElement,n=w.of(r?.scrollLeft??0,r?.scrollTop??0),i=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",e){let a=this.textInputElem;this.textInputElem=null,a.remove()}if(i!==""){let a=n.times(-1),l=this.editor.viewport.screenToCanvasTransform.transformVec3(a),c=k.translation(l),d=ne.fromLines(i.split(`
|
64
|
+
`),c.rightMul(this.contentTransform.get()),this.textStyle),u=q.addElement(d);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch(le([this.removeExistingCommand,u])),this.removeExistingCommand=null):this.editor.dispatch(u)}}updateTextInput(){if(!this.textInputElem)return;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.margin="0",this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`;let n=this.getTextAscent("Testing!",this.textStyle);this.textInputElem.style.transform=`translate(0, ${-n}px)`,this.textInputElem.style.transformOrigin="top left";let i=Math.floor(this.textStyle.size);this.textInputElem.style.lineHeight=`${i}px`}startTextInput(e,r){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=r,this.textInputElem.style.display="inline-block";let n=this.editor.viewport.roundPoint(e),i=-this.editor.viewport.getRotationAngle(),a=w.of(1,1).times(this.editor.viewport.getSizeOfPixelOnCanvas());this.contentTransform.set(k.translation(n).rightMul(k.zRotation(i)).rightMul(k.scaling2D(a))),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=()=>{let l=this.textInputElem;this.flushInput(!1),this.textInputElem=null,l&&l.classList.add("-hiding"),setTimeout(()=>{l?.remove()},0)},this.textInputElem.onkeyup=l=>{l.isComposing||(l.key==="Enter"&&!l.shiftKey?(this.flushInput(),this.editor.focus()):l.key==="Escape"&&(this.textInputElem?.remove(),this.textInputElem=null,this.editor.focus(),this.removeExistingCommand?.unapply(this.editor),this.removeExistingCommand=null))},this.textEditOverlay.replaceChildren(this.textInputElem),setTimeout(()=>this.textInputElem?.focus(),0)}setEnabled(e){super.setEnabled(e),this.isEnabled()||this.flushInput(),this.textEditOverlay.style.display=e?"block":"none"}onPointerDown({current:e,allPointers:r}){if(e.device===1)return!1;if(r.length===1){let n=e.canvasPos,i=w.of(4,4).times(this.editor.viewport.getSizeOfPixelOnCanvas()),a=I.fromCorners(n.minus(i),n.plus(i)),c=this.editor.image.getElementsIntersectingRegion(a).filter(u=>u instanceof ne),d=this.editor.viewport.visibleRect;if(c=c.filter(u=>!u.getBBox().containsRect(d)),this.flushInput(),c.length>0){let u=c[c.length-1];this.setTextStyle(u.getTextStyle()),this.removeExistingCommand=new J([u]),this.removeExistingCommand.apply(this.editor),this.startTextInput(u.getBaselinePos(),u.getText()),this.contentTransform.set(u.getTransform()),this.updateTextInput()}else this.removeExistingCommand=null,this.startTextInput(e.canvasPos,"");return!0}return!1}onGestureCancel(){this.flushInput(),this.editor.focus()}setFontFamily(e){e!==this.textStyle.fontFamily&&this.textStyleValue.set({...this.textStyle,fontFamily:e})}setColor(e){e.eq(this.textStyle.renderingStyle.fill)||this.textStyleValue.set({...this.textStyle,renderingStyle:{...this.textStyle.renderingStyle,fill:e}})}setFontSize(e){e!==this.textStyle.size&&this.textStyleValue.set({...this.textStyle,size:e})}getTextStyle(){return this.textStyle}getStyleValue(){return this.textStyleValue}setTextStyle(e){this.textStyleValue.set(e)}onDestroy(){super.onDestroy(),this.anchorControl.remove()}};var Mt=class extends K{constructor(e,r){super(e.notifier,r);this.editor=e;this.colorPreviewListener=null;this.colorSelectListener=null;this.enabledValue().onUpdateAndNow(()=>{this.updateSelectingStatus()})}canReceiveInputInReadOnlyEditor(){return!0}updateSelectingStatus(){let e="pipette--color-selection-in-progress";this.isEnabled()&&this.colorSelectListener&&this.colorPreviewListener?this.editor.getRootElement().classList.add(e):this.editor.getRootElement().classList.remove(e)}setColorListener(e,r){this.colorPreviewListener=e,this.colorSelectListener=r,this.updateSelectingStatus()}clearColorListener(){this.colorPreviewListener=null,this.colorSelectListener=null,this.updateSelectingStatus()}onPointerDown({current:e,allPointers:r}){return this.colorPreviewListener&&r.length===1?(this.colorPreviewListener(this.editor.display.getColorAt(e.screenPos)),!0):!1}onPointerMove({current:e}){this.colorPreviewListener?.(this.editor.display.getColorAt(e.screenPos))}onPointerUp({current:e}){this.colorSelectListener?.(this.editor.display.getColorAt(e.screenPos))}onGestureCancel(){this.colorSelectListener?.(null)}};var Dt=class extends K{constructor(e){super(e.notifier,e.localization.changeTool);this.editor=e}canReceiveInputInReadOnlyEditor(){return!0}onKeyPress({key:e}){let n=this.editor.toolController.getPrimaryTools(),i=/^[0-9]$/.exec(e),a;if(i){let l=parseInt(i[0],10)-1;a=n[l]}return a?(a.setEnabled(!0),!0):!1}};var At=class extends K{constructor(e){super(e.notifier,e.localization.pasteHandler);this.editor=e}onPaste(e,r){let n=e.mime.toLowerCase(),i=(()=>{if(n==="image/svg+xml")return e.data;if(n==="text/plain"){let c=e.data.trim();if(c.startsWith("<svg")&&c.endsWith("</svg>"))return c}if(n!=="text/html"||!e.data.match(/^[^]{0,200}<svg.*/i))return!1;let l=e.data.toLowerCase().lastIndexOf("</svg>");return l===-1&&(l=e.data.length),e.data.substring(e.data.search(/<svg/i),l)})();return i?(this.doSVGPaste(i).then(r),!0):n==="text/plain"?(this.doTextPaste(e.data).then(r),!0):n==="image/png"||n==="image/jpeg"?(this.doImagePaste(e.data).then(r),!0):!1}async addComponentsFromPaste(e){await this.editor.addAndCenterComponents(e,!0,this.editor.localization.pasted(e.length))}async doSVGPaste(e){this.editor.showLoadingWarning(0);try{let r=et.fromString(e,!0),n=[];await r.start(i=>{n.push(i)},(i,a)=>null),await this.addComponentsFromPaste(n)}finally{this.editor.hideLoadingWarning()}}async doTextPaste(e){let r=this.editor.toolController.getMatchingTools($e);r.sort((l,c)=>!l.isEnabled()&&c.isEnabled()?-1:!c.isEnabled()&&l.isEnabled()?1:0);let n={size:12,fontFamily:"sans",renderingStyle:{fill:L.red}},i=r[0]?.getTextStyle()??n;if(e.trim()==="")return;let a=e.split(`
|
65
|
+
`);await this.addComponentsFromPaste([ne.fromLines(a,k.identity,i)])}async doImagePaste(e){let r=new Image;r.src=e;let n=await be.fromImage(r,k.identity);await this.addComponentsFromPaste([n])}};var tt=class extends K{constructor(e){super(e.notifier,e.localization.changeTool);this.listeners=new Set([])}registerListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}onKeyPress(e){let r=Array.from(this.listeners.values());for(let n of r)if(n(e))return!0;return!1}};var Vt=so((s,o)=>{let e=o.getSizeOfPixelOnCanvas()*3,r=o.getSizeOfPixelOnCanvas();return new _r(s,r,e,o)}),_r=class{constructor(o,e,r,n){this.startPoint=o;this.minFitAllowed=e;this.viewport=n;this.isFirstSegment=!0;this.pathStartConnector=null;this.mostRecentConnector=null;this.nextCurveStartConnector=null;this.lastUpperBezier=null;this.lastLowerBezier=null;this.parts=[];this.upperSegments=[],this.lowerSegments=[],this.curveFitter=new Pt(o,e,r,i=>this.addCurve(i)),this.curveStartWidth=o.width,this.bbox=new I(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:this.startPoint.color??null}}previewCurrentPath(o=!0){let e=this.upperSegments.slice(),r=this.lowerSegments.slice(),n,i,a=this.curveFitter.preview();if(a&&o){let{upperCurveCommand:d,lowerToUpperConnector:u,upperToLowerConnector:p,lowerCurveCommand:h}=this.segmentToPath(a);e.push(d),r.push(h),n=u,i=this.pathStartConnector??[p]}else{if(this.mostRecentConnector===null||this.pathStartConnector===null)return null;n=this.mostRecentConnector,i=this.pathStartConnector}let l,c=r[r.length-1];return c.kind===0||c.kind===1?l=c.point:l=c.endPoint,{startPoint:l,commands:[n,...e.reverse(),...i,...r],style:this.getRenderingStyle()}}previewFullPath(){let o=this.previewCurrentPath();return o?[...this.parts,o]:null}preview(o){let e=this.previewFullPath();if(e){let r=this.viewport.visibleRect;o.startObject(r);for(let n of e)o.drawPath(n);o.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.isFirstSegment&&this.addCurve(null),new ee(this.previewFullPath())}roundPoint(o){let e=Math.min(this.minFitAllowed,this.curveStartWidth/3);return e<1e-10&&(e=this.minFitAllowed),U.roundPoint(o,e)}shouldStartNewSegment(o,e){if(!this.lastLowerBezier||!this.lastUpperBezier)return!1;let r=(c,d)=>{let u=c.intersectsBezier(d);return u.length?u[0].point:null},n=c=>c.p2.minus(c.p1).normalized(),i=c=>c.p1.minus(c.p0).normalized();if(i(e).dot(n(this.lastUpperBezier))<.35||i(o).dot(n(this.lastLowerBezier))<.35||i(e).dot(n(e))<0||i(o).dot(n(o))<0)return!0;let a=r(o,this.lastUpperBezier),l=r(e,this.lastLowerBezier);return!!(a||l)}addCurve(o){if(!o){if(!this.isFirstSegment)return;let u=U.roundPoint(this.startPoint.width/2.2,Math.min(this.minFitAllowed,this.startPoint.width/4)),p=this.roundPoint(this.startPoint.pos),h=this.startPoint.pos.plus(w.of(u,0));this.lowerSegments.push({kind:3,controlPoint:p.plus(w.of(u,u)),endPoint:p.plus(w.of(0,u))},{kind:3,controlPoint:p.plus(w.of(-u,u)),endPoint:p.plus(w.of(-u,0))},{kind:3,controlPoint:p.plus(w.of(-u,-u)),endPoint:p.plus(w.of(0,-u))},{kind:3,controlPoint:p.plus(w.of(u,-u)),endPoint:p.plus(w.of(u,0))});let m={kind:0,point:h};this.pathStartConnector=[m],this.mostRecentConnector=m;return}let{upperCurveCommand:e,lowerToUpperConnector:r,upperToLowerConnector:n,lowerCurveCommand:i,lowerCurve:a,upperCurve:l,nextCurveStartConnector:c}=this.segmentToPath(o),d=this.shouldStartNewSegment(a,l);if(d){let u=this.previewCurrentPath(!1);u?(this.parts.push(u),this.upperSegments=[],this.lowerSegments=[]):d=!1}(this.isFirstSegment||d)&&(this.pathStartConnector=this.nextCurveStartConnector??[n],this.isFirstSegment=!1),this.mostRecentConnector=r,this.nextCurveStartConnector=c,this.lowerSegments.push(i),this.upperSegments.push(e),this.lastLowerBezier=a,this.lastUpperBezier=l,this.curveStartWidth=o.startWidth}segmentToPath(o){let e=new De(o.startPoint,o.controlPoint,o.endPoint),r=e.normal(0),n=e.normal(1);r=r.times(o.startWidth/2),n=n.times(o.endWidth/2),isFinite(r.magnitude())||(console.error("Warning: startVec is NaN or \u221E",r,n,o),r=n);let i=o.startPoint,a=o.endPoint,l=o.controlPoint,d=e.nearestPointTo(l).parameterValue,u=e.normal(d).times(o.startWidth/2*d+o.endWidth/2*(1-d)),p=this.roundPoint(i.plus(r)),h=this.roundPoint(l.plus(u)),m=this.roundPoint(a.plus(n)),g=this.roundPoint(l.minus(u)),v=this.roundPoint(a.minus(n)),b=this.roundPoint(i.minus(r)),y={kind:3,controlPoint:h,endPoint:m},f={kind:0,point:p},T={kind:0,point:v},P=[{kind:0,point:v},{kind:0,point:m}],S={kind:3,controlPoint:g,endPoint:b},E=new De(v,g,b),C=new De(p,h,m);return{upperCurveCommand:S,upperToLowerConnector:f,lowerToUpperConnector:T,lowerCurveCommand:y,upperCurve:E,lowerCurve:C,nextCurveStartConnector:P}}addPoint(o){this.curveFitter.addPoint(o)}};var Ts="find-tool",Wo=class extends K{constructor(e){super(e.notifier,e.localization.findLabel);this.editor=e;this.currentMatchIdx=0;this.overlay=document.createElement("div"),this.fillOverlay(),e.createHTMLOverlay(this.overlay),this.overlay.style.display="none",this.overlay.classList.add(`${Ts}-overlay`)}canReceiveInputInReadOnlyEditor(){return!0}getMatches(e){let r=e.toLocaleLowerCase();return this.editor.image.getAllElements().filter(i=>{let a="";if(i instanceof ne)a=i.getText();else if(i instanceof be)a=i.getAltText()??"";else return!1;let l=a.toLocaleLowerCase().indexOf(r)!==-1,c=a.indexOf(e)!==-1;return l||c}).map(i=>i.getBBox())}focusCurrentMatch(){let e=this.getMatches(this.searchInput.value),r=this.currentMatchIdx%e.length;r<0&&(r=e.length+r),r<e.length&&(this.editor.dispatch(this.editor.viewport.zoomTo(e[r],!0,!0),!1),this.editor.announceForAccessibility(this.editor.localization.focusedFoundText(r+1,e.length)))}toNextMatch(){this.currentMatchIdx++,this.focusCurrentMatch()}toPrevMatch(){this.currentMatchIdx--,this.focusCurrentMatch()}fillOverlay(){let e=document.createElement("label");this.searchInput=document.createElement("input");let r=document.createElement("button"),n=document.createElement("button");this.searchInput.setAttribute("id",`${Ts}-searchInput-${Math.random()}`),e.htmlFor=this.searchInput.getAttribute("id"),e.innerText=this.editor.localization.findLabel,r.innerText=this.editor.localization.toNextMatch,n.innerText=this.editor.localization.closeDialog,this.searchInput.onkeydown=i=>{i.key==="Enter"?i.shiftKey?this.toPrevMatch():this.toNextMatch():i.key==="Escape"?this.setVisible(!1):this.editor.shortcuts.matchesShortcut(kr,i)&&(i.preventDefault(),this.toggleVisible())},r.onclick=()=>{this.toNextMatch()},n.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(e,this.searchInput,r,n)}isVisible(){return this.overlay.style.display!=="none"}setVisible(e){e!==this.isVisible()&&(this.overlay.style.display=e?"block":"none",e?(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(e){return this.editor.shortcuts.matchesShortcut(kr,e)?(this.toggleVisible(),!0):!1}setEnabled(e){super.setEnabled(e),this.isEnabled()&&this.setVisible(!1)}};var Ot=class extends K{constructor(e){super(e.notifier,e.localization.selectAllTool);this.editor=e}canReceiveInputInReadOnlyEditor(){return!0}onKeyPress(e){if(this.editor.shortcuts.matchesShortcut(no,e)){let r=this.editor.toolController.getMatchingTools(ve);if(r.length>0){let n=r[0];return n.setEnabled(!0),n.setSelection(this.editor.image.getAllElements()),!0}}return!1}};var vi=class{constructor(){this.closed=!1;if(!window.AudioContext){console.warn("Accessibility sound UI: Unable to open AudioContext."),this.closed=!0;return}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(o){let e=o.asHSV(),r=-Math.cos(e.x/2)*220+440,n=e.y*440+220,i=(e.z+.1)*440,a=.25*Math.min(1,o.a)/(1+Math.exp(-(e.z-.5)*3));this.colorOscHue.frequency.setValueAtTime(r,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(n,this.ctx.currentTime),this.colorOscValue.frequency.setValueAtTime(i,this.ctx.currentTime),this.valueGain.gain.setValueAtTime((1-e.z)*.4,this.ctx.currentTime),this.colorGain.gain.setValueAtTime(a,this.ctx.currentTime)}announceBoundaryCross(o){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+Math.atan(o/2)*100,this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(0,this.ctx.currentTime+.25)}close(){this.ctx.close(),this.closed=!0}},Ft=class extends K{constructor(e,r){super(e.notifier,r);this.editor=e;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(),e.createHTMLOverlay(this.toggleButtonContainer)}canReceiveInputInReadOnlyEditor(){return!0}updateToggleButtonText(){let e="sound-ui-tool-enabled";this.isEnabled()?(this.toggleButton.innerText=this.editor.localization.disableAccessibilityExploreTool,this.toggleButtonContainer.classList.add(e)):(this.toggleButton.innerText=this.editor.localization.enableAccessibilityExploreTool,this.toggleButtonContainer.classList.remove(e))}setEnabled(e){super.setEnabled(e),this.isEnabled()?this.editor.announceForAccessibility(this.editor.localization.soundExplorerUsageAnnouncement):(this.soundFeedback?.close(),this.soundFeedback=null),this.updateToggleButtonText()}onKeyPress(e){return e.code==="Escape"?(this.setEnabled(!1),!0):!1}onPointerDown({current:e,allPointers:r}){return this.soundFeedback||(this.soundFeedback=new vi),r.length>=2?!1:(this.soundFeedback?.play(),this.soundFeedback?.setColor(this.editor.display.getColorAt(e.screenPos)??L.black),this.lastPointerPos=e.canvasPos,!0)}onPointerMove({current:e}){this.soundFeedback?.setColor(this.editor.display.getColorAt(e.screenPos)??L.black);let r=new ue(this.lastPointerPos,e.canvasPos),n=this.editor.image.getElementsIntersectingRegion(r.bbox).filter(i=>i.intersects(r));this.lastPointerPos=e.canvasPos,n.length>0&&this.soundFeedback?.announceBoundaryCross(n.length)}onPointerUp(e){this.soundFeedback?.pause()}onGestureCancel(){this.soundFeedback?.pause()}};var Ko=class extends Re{#e=null;#t=null;onEvent(o){return this.#e===null?this.emit(o):this.#e.onEvent(o)}addToTail(o){this.#t?(this.#t.setEmitListener(o),this.#t=o):(this.#e=o,this.#t=this.#e),this.#t.setEmitListener(e=>this.emit(e))}};var Go=class extends K{constructor(e){super(e.notifier,"scrollbar");this.editor=e;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 r=null,n=null;this.enabledValue().onUpdateAndNow(i=>{r?.remove(),n?.remove(),n=null,r=null,i&&(n=e.notifier.on(7,a=>{this.updateScrollbars()}),this.updateScrollbars(),r=e.createHTMLOverlay(this.scrollbarOverlay))})}updateScrollbars(){let e=this.editor.viewport,r=e.getScreenRectSize(),n=new I(0,0,r.x,r.y),i=this.editor.getImportExportRect().transformedBoundingBox(e.canvasToScreenTransform).union(n),a=n.width/i.width*r.x,l=n.height/i.height*r.y,c=(n.x-i.x)/i.width*r.x,d=(n.y-i.y)/i.height*r.y;this.horizontalScrollbar.style.width=`${a}px`,this.verticalScrollbar.style.height=`${l}px`,this.horizontalScrollbar.style.marginLeft=`${c}px`,this.verticalScrollbar.style.marginTop=`${d}px`;let u=(h,m,g)=>{let v="represents-no-scroll";Math.abs(m-g)<1e-8?h.classList.add(v):h.classList.remove(v)};u(this.horizontalScrollbar,a,r.x),u(this.verticalScrollbar,l,r.y),this.fadeOutTimeout!==null&&clearTimeout(this.fadeOutTimeout);let p=3e3;this.fadeOutTimeout=setTimeout(()=>{this.scrollbarOverlay.classList.remove("just-updated")},p),this.scrollbarOverlay.classList.add("just-updated")}};var Ht=class{constructor(o,e){this.activeTool=null;this.isEditorReadOnly=o.isReadOnlyReactiveValue(),this.inputPipeline=new Ko,this.inputPipeline.setEmitListener(p=>this.onEventInternal(p));let r=new mt;this.primaryToolGroup=r;let n=new Ce(o,6,e.touchPanTool),i=new Ce(o,16,e.keyboardPanZoom),a=new Ne(o,e.penTool(1),{color:L.purple,thickness:8}),l=new Ne(o,e.penTool(2),{color:L.clay,thickness:4});l.setInputMapper(new Et(o.viewport));let c=new Je(o,e.eraserTool),d=[a,l,new Ne(o,e.penTool(3),{color:L.ofRGBA(1,1,0,.5),thickness:40,factory:Vt}),c,new ve(o,e.selectionTool),new $e(o,e.textTool,e),new Ce(o,8,e.anyDevicePanning)],u=new Ft(o,e.soundExplorer);u.setEnabled(!1),this.tools=[new Go(o),new Mt(o,e.pipetteTool),u,n,...d,i,new Bt(o),new tt(o),new Dt(o),c.makeEraserSwitcherTool(),new Wo(o),new At(o),new Ot(o)],d.forEach(p=>p.setToolGroup(r)),n.setEnabled(!0),a.setEnabled(!0),o.notifier.on(0,p=>{p.kind===0&&o.announceForAccessibility(e.toolEnabledAnnouncement(p.tool.description))}),o.notifier.on(1,p=>{p.kind===1&&o.announceForAccessibility(e.toolDisabledAnnouncement(p.tool.description))}),this.activeTool=null}setTools(o,e){this.tools=o,this.primaryToolGroup=e??new mt}addPrimaryTool(o){o.setToolGroup(this.primaryToolGroup),o.isEnabled()&&this.primaryToolGroup.notifyEnabled(o),this.tools.includes(o)||this.addTool(o)}getPrimaryTools(){return this.tools.filter(o=>o.getToolGroup()===this.primaryToolGroup)}addTool(o,e){this.tools.includes(o)||(e?.addToFront?this.tools.splice(0,0,o):this.tools.push(o))}removeAndDestroyTools(o){let e=[];for(let r of this.tools)o.includes(r)?(this.activeTool===r&&(this.activeTool=null),r.onDestroy()):e.push(r);this.tools=e}insertTools(o,e,r){this.tools=this.tools.filter(i=>!e.includes(i));let n=[];for(let i of this.tools)r==="after"&&n.push(i),i===o&&n.push(...e),r==="before"&&n.push(i);this.tools=n}insertToolsAfter(o,e){this.insertTools(o,e,"after")}insertToolsBefore(o,e){this.insertTools(o,e,"before")}onEventInternal(o){let e=this.isEditorReadOnly.get(),r=i=>i.isEnabled()&&(!e||i.canReceiveInputInReadOnlyEditor()),n=!1;if(o.kind===0){let i=!1;this.activeTool&&!this.activeTool.eventCanBeDeliveredToNonActiveTool(o)&&(i=!0);for(let a of this.tools)if(!(i&&a!==this.activeTool)&&r(a)&&a.onEvent(o)){this.activeTool!==a&&this.activeTool?.onEvent({kind:3}),this.activeTool=a,n=!0;break}}else if(o.kind===2)this.activeTool?.onEvent(o)&&o.allPointers.length>1||(this.activeTool=null),n=!0;else if(o.kind===1)this.activeTool!==null&&(this.activeTool.onEvent(o),n=!0);else if(o.kind===3)this.activeTool!==null&&(this.activeTool.onEvent(o),this.activeTool=null);else for(let i of this.tools)if(r(i)&&(n=i.onEvent(o),n))break;return n}onEvent(o){return this.dispatchInputEvent(o)}dispatchInputEvent(o){return this.inputPipeline.onEvent(o)}addInputMapper(o){this.inputPipeline.addToTail(o)}getMatchingTools(o){return this.tools.filter(e=>e instanceof o)}onEditorDestroyed(){for(let o of this.tools)o.onDestroy()}};var yi=class{constructor(o,e,r){this.editor=o;this.announceRedoCallback=e;this.announceUndoCallback=r;this.maxUndoRedoStackSize=700;this.#e=[],this.#t=[]}#e;#t;fireUpdateEvent(o,e){this.editor.notifier.dispatch(3,{kind:3,undoStackSize:this.#e.length,redoStackSize:this.#t.length,command:e,stackUpdateType:o})}push(o,e=!0){e&&o.apply(this.editor),this.#e.push(o);for(let r of this.#t)r.onDrop(this.editor);if(this.#t=[],this.#e.length>this.maxUndoRedoStackSize){let r=Math.ceil(this.maxUndoRedoStackSize/100);this.#e.splice(0,r).forEach(i=>i.onDrop(this.editor))}this.fireUpdateEvent(0,o),this.editor.notifier.dispatch(4,{kind:4,command:o})}undo(){let o=this.#e.pop();if(o){this.#t.push(o);let e=o.unapply(this.editor);return this.announceUndoCallback(o),this.fireUpdateEvent(1,o),this.editor.notifier.dispatch(5,{kind:5,command:o}),e}}redo(){let o=this.#t.pop();if(o){this.#e.push(o);let e=o.apply(this.editor);return this.announceRedoCallback(o),this.fireUpdateEvent(2,o),this.editor.notifier.dispatch(4,{kind:4,command:o}),e}}get undoStackSize(){return this.#e.length}get redoStackSize(){return this.#t.length}},qr=yi;var ot=class s extends ze{constructor(e){super(e);this.clearedCount=0;this.renderedPathCount=0;this.lastFillStyle=null;this.lastPoint=null;this.objectNestingLevel=0;this.lastText=null;this.lastImage=null;this.pointBuffer=[]}displaySize(){let e=this.getViewport().getScreenRectSize();return e.x===0||e.y===0?w.of(640,480):e}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(e){this.lastPoint=e,this.pointBuffer.push(e)}endPath(e){this.renderedPathCount++,this.lastFillStyle=e}lineTo(e){e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(e)}moveTo(e){e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(e)}traceCubicBezierCurve(e,r,n){e=this.canvasToScreen(e),r=this.canvasToScreen(r),n=this.canvasToScreen(n),this.lastPoint=n,this.pointBuffer.push(e,r,n)}traceQuadraticBezierCurve(e,r){e=this.canvasToScreen(e),r=this.canvasToScreen(r),this.lastPoint=r,this.pointBuffer.push(e,r)}drawPoints(...e){}drawText(e,r,n){this.lastText=e}drawImage(e){this.lastImage=e}startObject(e,r){super.startObject(e),this.objectNestingLevel+=1}endObject(){super.endObject(),this.objectNestingLevel-=1}isTooSmallToRender(e){return!1}canRenderFromWithoutDataLoss(e){return e instanceof s}renderFromOtherOfSameType(e,r){if(!(r instanceof s))throw new Error(`${r} cannot be rendered onto ${this}`);this.renderedPathCount+=r.renderedPathCount,this.lastFillStyle=r.lastFillStyle,this.lastPoint=r.lastPoint,this.pointBuffer.push(...r.pointBuffer.map(n=>e.transformVec2(n)))}toString(){return"[DummyRenderer]"}};var rt=3,jo=class s{constructor(o,e){this.region=o;this.cacheState=e;this.instantiatedChildren=[];this.parent=null;this.cachedRenderer=null;this.renderedIds=[];this.renderedMaxZIndex=null}generateParent(){if(this.parent)return this.parent;let o=I.fromCorners(this.region.topLeft.minus(this.region.size),this.region.bottomRight.plus(this.region.size)),e=new s(o,this.cacheState);e.generateChildren();let r=this.region.maxDimension/100,n=(e.instantiatedChildren.length-1)/2;if(!e.instantiatedChildren[n].region.eq(this.region,r))throw console.error(e.instantiatedChildren[n].region,"\u2260",this.region),new Error("Logic error: [this] is not contained within its parent's center child");return e.instantiatedChildren[n]=this,this.parent=e,e}generateChildren(){if(this.instantiatedChildren.length===0){if(this.region.size.x/rt===0||this.region.size.y/rt===0){console.warn("Cache element has zero size! Not generating children.");return}let o=this.region.divideIntoGrid(rt,rt);console.assert(o.length===rt*rt,"Warning: divideIntoGrid created the wrong number of subrectangles!");for(let e of o){let r=new s(e,this.cacheState);r.parent=this,this.instantiatedChildren.push(r)}}this.checkRep()}getChildren(){return this.checkRep(),this.generateChildren(),this.instantiatedChildren}smallestChildContaining(o){let e=o.maxDimension>this.region.maxDimension/rt;if(!this.region.containsRect(o)||e)return null;for(let r of this.getChildren())if(r.region.containsRect(o))return r.smallestChildContaining(o)??r;return null}renderingWouldBeHighEnoughResolution(o){let e=this.region.w/this.cacheState.props.blockResolution.x;return!(o.getScaleFactor()*e>this.cacheState.props.maxScale)}allChildrenCanRender(o,e){if(this.instantiatedChildren.length===0)return!1;for(let r of this.instantiatedChildren)if(r.region.intersects(o.visibleRect)&&!r.renderingIsUpToDate(this.idsOfIntersecting(e)))return!1;return!0}computeSortedByLeafIds(o){let e=o.slice();return e.sort((r,n)=>r.getId()-n.getId()),e}idsOfIntersecting(o){let e=[];for(let r of o)r.getBBox().intersects(this.region)&&e.push(r.getId());return e}allRenderedIdsIn(o){if(this.renderedIds.length>o.length)return!1;for(let e=0;e<this.renderedIds.length;e++)if(o[e]!==this.renderedIds[e])return!1;return!0}renderingIsUpToDate(o){return this.cachedRenderer===null||o.length!==this.renderedIds.length?!1:this.allRenderedIdsIn(o)}renderItems(o,e,r){if(!r.visibleRect.intersects(this.region)||e.length===0)return;if(e=(a=>{let l=[];for(let c of a){let d=c.getBBox();d.intersects(this.region)&&(d.maxDimension>=this.region.maxDimension?l.push(...c.getChildrenOrSelfIntersectingRegion(this.region)):l.push(c))}return l})(e),!this.cacheState.props.isOfCorrectType(o)){for(let a of e)a.render(o,r.visibleRect);return}if(this.cacheState.debugMode&&o.drawRect(this.region,r.getSizeOfPixelOnCanvas(),{fill:L.yellow}),this.renderingWouldBeHighEnoughResolution(r)){let a=p=>p.w/this.region.w<1/this.cacheState.props.blockResolution.x,l=[];for(let p of e)l.push(...p.getLeavesIntersectingRegion(this.region,a));Tt(l);let c=this.computeSortedByLeafIds(l);if(c.length===0)return;let d=c.map(p=>p.getId()),u;if(this.renderingIsUpToDate(d))u=this.cachedRenderer.startRender();else{if(this.allChildrenCanRender(r,c)){for(let h of this.getChildren())h.renderItems(o,e,r);return}let p=0;for(let h of c)a(h.getBBox())||(p+=h.getContent().getProportionalRenderingTime());if(p>this.cacheState.props.minProportionalRenderTimePerCache){let h=!0;if(!this.cachedRenderer)this.cachedRenderer=this.cacheState.recordManager.allocCanvas(this.region,()=>this.onRegionDealloc());else if(c.length>this.renderedIds.length&&this.allRenderedIdsIn(d)&&this.renderedMaxZIndex!==null){let m=[],g=null;for(let v=0;v<c.length;v++){let b=c[v],f=b.getContent().getZIndex();(v>=this.renderedIds.length||b.getId()!==this.renderedIds[v])&&(m.push(b),(g===null||f<g)&&(g=f))}if(g!==null&&g>this.renderedMaxZIndex){h=!1,u=this.cachedRenderer.startRender();for(let v=0;v<l.length;v++){let b=l[v],y=b.getContent().getZIndex();y>this.renderedMaxZIndex&&(b.render(u,this.region),this.renderedMaxZIndex=y)}this.cacheState.debugMode&&o.drawRect(this.region,2*r.getSizeOfPixelOnCanvas(),{fill:L.clay})}}else this.cacheState.debugMode&&console.log("Decided on a full re-render. Reason: At least one of the following is false:",`
|
66
|
+
leafIds.length > this.renderedIds.length: `,d.length>this.renderedIds.length,`
|
67
|
+
this.allRenderedIdsIn(leafIds): `,this.allRenderedIdsIn(d),`
|
68
|
+
this.renderedMaxZIndex !== null: `,this.renderedMaxZIndex!==null,`
|
69
|
+
|
70
|
+
this.rerenderedIds: `,this.renderedIds,", leafIds: ",d);if(h){u=this.cachedRenderer.startRender(),u.clear(),this.renderedMaxZIndex=null;let m=Ln(l,this.region);for(let g=m;g<l.length;g++){let v=l[g],b=v.getContent();this.renderedMaxZIndex??=b.getZIndex(),this.renderedMaxZIndex=Math.max(this.renderedMaxZIndex,b.getZIndex()),v.render(u,this.region)}this.cacheState.debugMode&&o.drawRect(this.region,3*r.getSizeOfPixelOnCanvas(),{fill:L.red})}this.renderedIds=d}else{this.cachedRenderer?.dealloc();let h=r.getSizeOfPixelOnCanvas(),m=new I(this.region.x,this.region.y,this.region.w+h,this.region.h+h);o.startObject(m,!0);for(let v of l)v.render(o,this.region.intersection(r.visibleRect));o.endObject(),this.cacheState.debugMode&&o.drawRect(this.region,2*r.getSizeOfPixelOnCanvas(),{fill:L.green})}}if(u){let p=this.cachedRenderer.getTransform(this.region).inverse();o.renderFromOtherOfSameType(p,u)}this.instantiatedChildren.every(p=>p.isEmpty())&&(this.instantiatedChildren=[])}else for(let a of this.getChildren())a.renderItems(o,e.filter(l=>l.getBBox().intersects(a.region)),r);this.checkRep()}isEmpty(){return this.cachedRenderer!==null?!1:this.instantiatedChildren.every(o=>o.isEmpty())}onRegionDealloc(){this.cachedRenderer=null,this.isEmpty()&&(this.instantiatedChildren=[])}checkRep(){if(this.instantiatedChildren.length!==rt*rt&&this.instantiatedChildren.length!==0)throw new Error(`Repcheck: Wrong number of children. Got ${this.instantiatedChildren.length}`);if(this.renderedIds[1]!==void 0&&this.renderedIds[0]>=this.renderedIds[1])throw console.error(this.renderedIds),new Error("Repcheck: First two ids are not in ascending order!");for(let o of this.instantiatedChildren)if(o.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")}};var _o=class{constructor(o,e){this.onBeforeDeallocCallback=o;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(o){this.allocd&&this.dealloc(),this.allocd=!0,this.onBeforeDeallocCallback=o,this.lastUsedCycle=this.cacheState.currentRenderingCycle,this.allocCount++}getLastUsedCycle(){return this.lastUsedCycle}getTransform(o){return k.scaling2D(this.cacheState.props.blockResolution.x/o.size.x).rightMul(k.translation(o.topLeft.times(-1)))}setRenderingRegion(o){let e=this.getTransform(o);this.renderer.setTransform(e),this.renderer.overrideVisibleRect(o.grownBy(1/e.getScaleFactor()))}};var Zr=class{constructor(o){this.cacheRecords=[];this.maxCanvases=Math.ceil(o.cacheSize/4/o.blockResolution.x/o.blockResolution.y)}setSharedState(o){this.cacheState=o}allocCanvas(o,e){if(this.cacheRecords.length<this.maxCanvases){let r=new _o(e,this.cacheState);return r.setRenderingRegion(o),this.cacheRecords.push(r),this.cacheState.debugMode&&console.log("[Cache] Cache spaces used: ",this.cacheRecords.length," of ",this.maxCanvases),r}else{let r=this.getLeastRecentlyUsedRecord();return this.cacheState.debugMode&&console.log("[Cache] Re-alloc. Times allocated: ",r.allocCount,`
|
71
|
+
Last used cycle: `,r.getLastUsedCycle(),`
|
72
|
+
Current cycle: `,this.cacheState.currentRenderingCycle),r.realloc(e),r.setRenderingRegion(o),this.cacheState.debugMode&&(console.log("[Cache] Now re-alloc'd. Last used cycle: ",r.getLastUsedCycle()),console.assert(r.cacheState===this.cacheState,"[Cache] Unequal cache states! cacheState should be a shared object!")),r}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort((o,e)=>o.getLastUsedCycle()-e.getLastUsedCycle()),this.cacheRecords[0]}getDebugInfo(){let o=0,e=0;for(let n of this.cacheRecords)e+=n.allocCount,n.isAllocd()&&o++;return e/=Math.max(this.cacheRecords.length,1),[`${this.cacheRecords.length} cache records (max ${this.maxCanvases})`,`${o} assigned to screen regions`,`Average number of times reassigned: ${Math.round(e*100)/100}`].join(`
|
73
|
+
`)}};var qo=class{constructor(o){this.recordManager=new Zr(o),this.sharedState={props:o,currentRenderingCycle:0,recordManager:this.recordManager,debugMode:!1},this.recordManager.setSharedState(this.sharedState)}render(o,e,r){let n=r.visibleRect;if(this.sharedState.currentRenderingCycle++,!this.sharedState.props.isOfCorrectType(o)){e.render(o,n);return}if(!this.rootNode){let l=this.sharedState.props.blockResolution,c=n.topLeft;this.rootNode=new jo(new I(c.x,c.y,l.x,l.y),this.sharedState)}for(;!this.rootNode.region.containsRect(n);)this.rootNode=this.rootNode.generateParent();this.rootNode=this.rootNode.smallestChildContaining(n)??this.rootNode;let i=e.getLeavesIntersectingRegion(r.visibleRect,l=>o.isTooSmallToRender(l)),a=0;for(let l of i)a+=l.getContent().getProportionalRenderingTime();a>this.sharedState.props.minProportionalRenderTimeToUseCache?this.rootNode.renderItems(o,[e],r):e.render(o,n)}getDebugInfo(){return this.recordManager.getDebugInfo()}setIsDebugMode(o){this.sharedState.debugMode=o}};var Zo=class extends ze{constructor(e,r){super(e);this.localizationTable=r;this.descriptionBuilder=[];this.pathCount=0;this.textNodeCount=0;this.imageNodeCount=0}displaySize(){return w.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(`
|
74
|
+
`)}beginPath(e){}endPath(e){this.pathCount++}lineTo(e){}moveTo(e){}traceCubicBezierCurve(e,r,n){}traceQuadraticBezierCurve(e,r){}drawText(e,r,n){this.descriptionBuilder.push(this.localizationTable.textNode(e)),this.textNodeCount++}drawImage(e){let r=e.label?this.localizationTable.imageNode(e.label):this.localizationTable.unlabeledImageNode;this.descriptionBuilder.push(r),this.imageNodeCount++}isTooSmallToRender(e){return e.maxDimension<15/this.getSizeOfCanvasPixelOnScreen()}drawPoints(...e){}};var Yr=(e=>(e[e.DummyRenderer=0]="DummyRenderer",e[e.CanvasRenderer=1]="CanvasRenderer",e))(Yr||{}),Nt=class{constructor(o,e,r){this.editor=o;this.parent=r;this.textRerenderOutput=null;this.devicePixelRatio=window.devicePixelRatio??1;this.getColorAt=o=>null;if(e===1)this.initializeCanvasRendering();else if(e===0)this.dryInkRenderer=new ot(o.viewport),this.wetInkRenderer=new ot(o.viewport);else throw new Error(`Unknown rendering mode, ${e}!`);this.textRenderer=new Zo(o.viewport,o.localization),this.initializeTextRendering();let n=w.of(600,600);this.cache=new qo({createRenderer:()=>{if(e===0)return new ot(o.viewport);if(e!==1)throw new Error("Unspported rendering mode");let i=document.createElement("canvas");i.width=n.x+1,i.height=n.y+1;let a=i.getContext("2d");return new Le(a,o.viewport)},isOfCorrectType:i=>this.dryInkRenderer.canRenderFromWithoutDataLoss(i),blockResolution:n,cacheSize:600*600*4*90,maxScale:Math.max(1,1.3/window.devicePixelRatio),minProportionalRenderTimePerCache:20*4,minProportionalRenderTimeToUseCache:105*4}),this.editor.notifier.on(8,i=>{if(i.kind!==8)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(){let o=document.createElement("canvas"),e=document.createElement("canvas"),r=o.getContext("2d"),n=e.getContext("2d");this.dryInkRenderer=new Le(r,this.editor.viewport),this.wetInkRenderer=new Le(n,this.editor.viewport),o.className="dryInkCanvas",e.className="wetInkCanvas",this.parent&&(this.parent.appendChild(o),this.parent.appendChild(e)),this.resizeSurfacesCallback=()=>{let i=c=>Math.ceil(c.clientWidth*this.devicePixelRatio)||c.width,a=c=>Math.ceil(c.clientHeight*this.devicePixelRatio)||c.height,l=c=>a(c)!==c.height||i(c)!==c.width;(l(o)||l(e))&&(o.width=i(o),o.height=a(o),e.width=i(e),e.height=a(e),n.resetTransform(),r.resetTransform(),r.scale(this.devicePixelRatio,this.devicePixelRatio),n.scale(this.devicePixelRatio,this.devicePixelRatio),this.editor.notifier.dispatch(8,{kind:8,newSize:w.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{r.save(),r.resetTransform(),r.drawImage(e,0,0),r.restore()},this.getColorAt=i=>{let a=i.times(this.devicePixelRatio),c=r.getImageData(a.x,a.y,1,1)?.data;return c?L.ofRGBA(c[0]/255,c[1]/255,c[2]/255,c[3]/255):null}}initializeTextRendering(){let o=document.createElement("div");o.classList.add("textRendererOutputContainer");let 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()},o.replaceChildren(e,this.textRerenderOutput),this.editor.createHTMLOverlay(o)}setDevicePixelRatio(o){if(isFinite(o)&&o>=.001&&o<=10&&o!==this.devicePixelRatio)return this.devicePixelRatio=o,this.resizeSurfacesCallback?.(),this.editor.queueRerender()}getDevicePixelRatio(){return this.devicePixelRatio}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(o){this.dryInkRenderer.setDraftMode(o)}getDryInkRenderer(){return this.dryInkRenderer}getWetInkRenderer(){return this.wetInkRenderer}flatten(){this.flattenCallback?.()}};var ft=so((s,o)=>{let e=o.getSizeOfPixelOnCanvas()*.75;return new Xr(s,e,o)}),Xr=class{constructor(o,e,r){this.minFitAllowed=e;this.viewport=r;this.parts=[];this.widthAverageNumSamples=1;this.lastLineSegment=null;this.averageWidth=o.width,this.startPoint={...o,pos:this.roundPoint(o.pos)},this.lastPoint=this.startPoint.pos,this.bbox=new I(this.startPoint.pos.x,this.startPoint.pos.y,0,0),this.parts=[{kind:1,point:this.startPoint.pos}]}getBBox(){return this.bbox.grownBy(this.averageWidth)}getRenderingStyle(){return{fill:L.transparent,stroke:{color:this.startPoint.color,width:this.roundDistance(this.averageWidth)}}}previewCurrentPath(){let o=this.startPoint.pos,e=[...this.parts];return e.length<=1&&e.push({kind:0,point:o.plus(w.of(this.averageWidth/4,0))}),{startPoint:o,commands:e,style:this.getRenderingStyle()}}previewFullPath(){return[this.previewCurrentPath()]}preview(o){let e=this.previewFullPath();if(e){let r=this.viewport.visibleRect;o.startObject(r);for(let n of e)o.drawPath(n);o.endObject()}}build(){return new ee(this.previewFullPath())}getMinFit(){let o=Math.min(this.minFitAllowed,this.averageWidth/4);return o<1e-10&&(o=this.minFitAllowed),o}roundPoint(o){let e=this.getMinFit();return U.roundPoint(o,e)}roundDistance(o){let e=this.getMinFit();return U.roundPoint(o,e)}addPoint(o){this.widthAverageNumSamples++,this.averageWidth=this.averageWidth*(this.widthAverageNumSamples-1)/this.widthAverageNumSamples+o.width/this.widthAverageNumSamples;let e=this.roundPoint(o.pos);e.eq(this.lastPoint)||(this.lastLineSegment&&this.lastLineSegment.direction.dot(e.minus(this.lastPoint).normalized())>.997&&(this.parts.pop(),this.lastPoint=this.lastLineSegment.p1),this.parts.push({kind:0,point:this.roundPoint(o.pos)}),this.bbox=this.bbox.grownToPoint(e),this.lastLineSegment=new ue(this.lastPoint,e),this.lastPoint=e)}};var Ja=(s,o,e="html")=>{let r;if(e==="html")r=document.createElement(s);else if(e==="svg")r=document.createElementNS("http://www.w3.org/2000/svg",s);else throw new Error(`Unknown element type ${e}`);for(let[n,i]of Object.entries(o))if(n!=="children"){if(typeof i!="string"&&typeof i!="number")throw new Error(`Unsupported value type ${typeof i}`);r.setAttribute(n,i.toString())}if(o.children)for(let n of o.children)r.appendChild(n);return r},je=(s,o)=>Ja(s,o,"svg"),Qr=(s,o)=>o.map(e=>je(s,e)),Jr=(...s)=>Qr("path",s);var ie="http://www.w3.org/2000/svg",el=0,en=()=>{let s=`checkerboard-${el++}`,o=je("pattern",{id:s,viewBox:"0,0,10,10",width:"20%",height:"20%",patternUnits:"userSpaceOnUse",children:Qr("rect",[{x:0,y:0,width:10,height:10,fill:"white"},{x:0,y:0,width:5,height:5,fill:"gray"},{x:5,y:5,width:5,height:5,fill:"gray"}])}),e=`url(#${s})`;return{patternDefElement:o,get patternDef(){return o.innerHTML},patternRef:e}},Ss=s=>{let o=document.createElementNS(ie,"svg");o.innerHTML=`
|
75
|
+
<style>
|
76
|
+
.toolbar-svg-undo-redo-icon {
|
77
|
+
stroke: var(--icon-color);
|
78
|
+
stroke-width: 12;
|
79
|
+
stroke-linejoin: round;
|
80
|
+
stroke-linecap: round;
|
81
|
+
fill: none;
|
82
|
+
|
83
|
+
transform-origin: center;
|
84
|
+
}
|
85
|
+
</style>
|
86
|
+
`;let e=document.createElementNS(ie,"path");return e.setAttribute("d","M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80"),e.classList.add("toolbar-svg-undo-redo-icon"),s&&(e.style.transform="scale(-1, 1)"),o.appendChild(e),o.setAttribute("viewBox","0 0 100 100"),o},$t=class{makeUndoIcon(){return Ss(!0)}makeRedoIcon(){return Ss(!1)}makeDropdownIcon(){let o=this.makeIconFromPath("M5,10 L50,90 L95,10 Z");return o.setAttribute("viewBox","-10 -10 110 110"),o}makeEraserIcon(o,e){o??=10;let r=o/4,n="#ff70af";return je("svg",{viewBox:"0 0 120 120",children:[je("defs",{children:[je("linearGradient",{id:"dash-pattern",children:Qr("stop",[{offset:"80%","stop-color":n},{offset:"85%","stop-color":"white"},{offset:"90%","stop-color":n}])})]}),je("path",{fill:e==="partial-stroke"?"url(#dash-pattern)":n,stroke:"black",transform:"rotate(41.35)",d:`
|
87
|
+
M 52.5 27
|
88
|
+
C 50 28.9 48.9 31.7 48.9 34.8
|
89
|
+
L 48.9 39.8
|
90
|
+
C 48.9 45.3 53.4 49.8 58.9 49.8
|
91
|
+
L 103.9 49.8
|
92
|
+
C 105.8 49.8 107.6 49.2 109.1 48.3
|
93
|
+
L 110.2 ${r+49.5} L 159.7 ${r+5}
|
94
|
+
L 157.7 ${-r+5.2} L 112.4 ${49.5-r}
|
95
|
+
C 113.4 43.5 113.9 41.7 113.9 39.8
|
96
|
+
L 113.9 34.8
|
97
|
+
C 113.9 29.3 109.4 24.8 103.9 24.8
|
98
|
+
L 58.9 24.8
|
99
|
+
C 56.5 24.8 54.3 25.7 52.5 27
|
100
|
+
z
|
101
|
+
`}),je("rect",{stroke:"#cc8077",fill:"var(--icon-color)",width:65,height:75,x:48.9,y:-38.7,transform:"rotate(41.35)"})]})}makeSelectionIcon(o="rect"){let e=document.createElementNS(ie,"svg");return o==="rect"?e.innerHTML=`
|
102
|
+
<g>
|
103
|
+
<rect x="10" y="10" width="70" height="70" fill="pink" stroke="black" stroke-dasharray="32 9"/>
|
104
|
+
<rect x="75" y="75" width="10" height="10" fill="white" stroke="black"/>
|
105
|
+
</g>
|
106
|
+
`:e.innerHTML=`
|
107
|
+
<g>
|
108
|
+
<rect x="10" y="10" width="76" height="76" rx="50" stroke-dasharray="32 9" fill="pink" stroke="black"/>
|
109
|
+
<rect x="71" y="71" width="10" height="10" fill="white" stroke="black"/>
|
110
|
+
</g>
|
111
|
+
`,e.setAttribute("viewBox","0 0 100 100"),e}makeRotateIcon(){let o=document.createElementNS(ie,"svg");return o.innerHTML=`
|
112
|
+
<defs>
|
113
|
+
<marker
|
114
|
+
id="arrow-marker"
|
115
|
+
viewBox="0 0 10 10"
|
116
|
+
refX="3" refY="5"
|
117
|
+
markerWidth="3" markerHeight="3"
|
118
|
+
orient="auto-start-reverse"
|
119
|
+
>
|
120
|
+
<path
|
121
|
+
d="M0,0 L8,5 L0,10z"
|
122
|
+
fill="var(--icon-color)"
|
123
|
+
/>
|
124
|
+
</marker>
|
125
|
+
</defs>
|
126
|
+
|
127
|
+
<path
|
128
|
+
marker-start="url(#arrow-marker)"
|
129
|
+
d="
|
130
|
+
M20,20
|
131
|
+
A30,30 0 1 1 80 80
|
132
|
+
"
|
133
|
+
fill="none"
|
134
|
+
stroke="var(--icon-color)"
|
135
|
+
stroke-width="12"
|
136
|
+
/>
|
137
|
+
<path
|
138
|
+
d="
|
139
|
+
M80,80
|
140
|
+
A30,30 0 1 1 20 20
|
141
|
+
"
|
142
|
+
fill="none"
|
143
|
+
stroke="var(--icon-color)"
|
144
|
+
stroke-width="12"
|
145
|
+
stroke-dasharray="30 10 20 10 20 10 10"
|
146
|
+
style="stroke-linecap: butt;"
|
147
|
+
/>
|
148
|
+
`,o.setAttribute("viewBox","-5 -5 110 110"),o}makeHandToolIcon(){return this.makeIconFromPath(`
|
149
|
+
m 10,60
|
150
|
+
5,30
|
151
|
+
H 90
|
152
|
+
V 30
|
153
|
+
C 90,20 75,20 75,30
|
154
|
+
V 60
|
155
|
+
20
|
156
|
+
C 75,10 60,10 60,20
|
157
|
+
V 60
|
158
|
+
15
|
159
|
+
C 60,5 45,5 45,15
|
160
|
+
V 60
|
161
|
+
25
|
162
|
+
C 45,15 30,15 30,25
|
163
|
+
V 60
|
164
|
+
75
|
165
|
+
L 25,60
|
166
|
+
C 20,45 10,50 10,60
|
167
|
+
Z
|
168
|
+
`,"none","var(--icon-color)","3")}makeTouchPanningIcon(){return this.makeIconFromPath(`
|
169
|
+
M 5,5.5
|
170
|
+
V 17.2
|
171
|
+
L 16.25,5.46
|
172
|
+
Z
|
173
|
+
|
174
|
+
m 33.75,0
|
175
|
+
L 50,17
|
176
|
+
V 5.5
|
177
|
+
Z
|
178
|
+
|
179
|
+
M 5,40.7
|
180
|
+
v 11.7
|
181
|
+
h 11.25
|
182
|
+
z
|
183
|
+
|
184
|
+
M 26,19
|
185
|
+
C 19.8,19.4 17.65,30.4 21.9,34.8
|
186
|
+
L 50,70
|
187
|
+
H 27.5
|
188
|
+
c -11.25,0 -11.25,17.6 0,17.6
|
189
|
+
H 61.25
|
190
|
+
C 94.9,87.8 95,87.6 95,40.7 78.125,23 67,29 55.6,46.5
|
191
|
+
L 33.1,23
|
192
|
+
C 30.3125,20.128192 27.9,19 25.830078,19.119756
|
193
|
+
Z
|
194
|
+
`,"none","var(--icon-color)","3")}makeAllDevicePanningIcon(){return this.makeIconFromPath(`
|
195
|
+
M 5 5
|
196
|
+
L 5 17.5
|
197
|
+
17.5 5
|
198
|
+
5 5
|
199
|
+
z
|
200
|
+
|
201
|
+
M 42.5 5
|
202
|
+
L 55 17.5
|
203
|
+
55 5
|
204
|
+
42.5 5
|
205
|
+
z
|
206
|
+
|
207
|
+
M 70 10
|
208
|
+
L 70 21
|
209
|
+
61 15
|
210
|
+
55.5 23
|
211
|
+
66 30
|
212
|
+
56 37
|
213
|
+
61 45
|
214
|
+
70 39
|
215
|
+
70 50
|
216
|
+
80 50
|
217
|
+
80 39
|
218
|
+
89 45
|
219
|
+
95 36
|
220
|
+
84 30
|
221
|
+
95 23
|
222
|
+
89 15
|
223
|
+
80 21
|
224
|
+
80 10
|
225
|
+
70 10
|
226
|
+
z
|
227
|
+
|
228
|
+
M 27.5 26.25
|
229
|
+
L 27.5 91.25
|
230
|
+
L 43.75 83.125
|
231
|
+
L 52 99
|
232
|
+
L 68 91
|
233
|
+
L 60 75
|
234
|
+
L 76.25 66.875
|
235
|
+
L 27.5 26.25
|
236
|
+
z
|
237
|
+
|
238
|
+
M 5 42.5
|
239
|
+
L 5 55
|
240
|
+
L 17.5 55
|
241
|
+
L 5 42.5
|
242
|
+
z
|
243
|
+
`,"none","var(--icon-color)","3")}makeZoomIcon(){let o=document.createElementNS(ie,"svg");o.setAttribute("viewBox","0 0 100 100");let e=(r,n,i)=>{let a=document.createElementNS(ie,"text");a.appendChild(document.createTextNode(r)),a.setAttribute("x",n.toString()),a.setAttribute("y",i.toString()),a.style.textAlign="center",a.style.textAnchor="middle",a.style.fontSize="55px",a.style.fill="var(--icon-color)",a.style.fontFamily="monospace",o.appendChild(a)};return e("+",40,45),e("-",70,75),o}makeRotationLockIcon(){let o=this.makeIconFromPath(`
|
244
|
+
M 40.1 25.1
|
245
|
+
C 32.5 25 27.9 34.1 27.9 34.1
|
246
|
+
L 25.7 30
|
247
|
+
L 28 44.7
|
248
|
+
L 36.6 40.3
|
249
|
+
L 32.3 38.3
|
250
|
+
C 33.6 28 38.1 25.2 45.1 31.8
|
251
|
+
L 49.4 29.6
|
252
|
+
C 45.9 26.3 42.8 25.1 40.1 25.1
|
253
|
+
z
|
254
|
+
|
255
|
+
M 51.7 34.2
|
256
|
+
L 43.5 39.1
|
257
|
+
L 48 40.8
|
258
|
+
C 47.4 51.1 43.1 54.3 35.7 48.2
|
259
|
+
L 31.6 50.7
|
260
|
+
C 45.5 62.1 52.6 44.6 52.6 44.6
|
261
|
+
L 55.1 48.6
|
262
|
+
L 51.7 34.2
|
263
|
+
z
|
264
|
+
|
265
|
+
M 56.9 49.9
|
266
|
+
C 49.8 49.9 49.2 57.3 49.3 60.9
|
267
|
+
L 47.6 60.9
|
268
|
+
L 47.6 73.7
|
269
|
+
L 66.1 73.7
|
270
|
+
L 66.1 60.9
|
271
|
+
L 64.4 60.9
|
272
|
+
C 64.5 57.3 63.9 49.9 56.9 49.9
|
273
|
+
z
|
274
|
+
|
275
|
+
M 56.9 53.5
|
276
|
+
C 60.8 53.5 61 58.2 60.8 60.9
|
277
|
+
L 52.9 60.9
|
278
|
+
C 52.7 58.2 52.9 53.5 56.9 53.5
|
279
|
+
z
|
280
|
+
`);return o.setAttribute("viewBox","10 10 70 70"),o}makeInsertImageIcon(){return this.makeIconFromPath(`
|
281
|
+
M 5 10 L 5 90 L 95 90 L 95 10 L 5 10 z
|
282
|
+
M 10 15 L 90 15 L 90 50 L 70 75 L 40 50 L 10 75 L 10 15 z
|
283
|
+
M 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
|
284
|
+
`)}makeUploadFileIcon(){return this.makeIconFromPath(`
|
285
|
+
M 48,10 32,34 43,33 42,68
|
286
|
+
H 54
|
287
|
+
L 53,33 64,34 Z
|
288
|
+
|
289
|
+
M 8,66 V 86 H 88 V 66 H 78 V 76 H 18 V 66 Z
|
290
|
+
`)}makeTextIcon(o){let e=document.createElementNS(ie,"svg");e.setAttribute("viewBox","0 0 100 100");let r=document.createElementNS(ie,"text");return r.appendChild(document.createTextNode("T")),r.style.fontFamily=o.fontFamily,r.style.fontWeight=o.fontWeight??"",r.style.fontVariant=o.fontVariant??"",r.style.fill=o.renderingStyle.fill.toHexString(),r.style.textAnchor="middle",r.setAttribute("x","50"),r.setAttribute("y","75"),r.style.fontSize="65px",r.style.filter="drop-shadow(0px 0px 10px var(--shadow-color))",e.appendChild(r),e}makePenIcon(o){let e=Math.round(Math.sqrt(o.thickness)*4),r=o.color,n=this.isRoundedTipPen(o),i=e/2,a=`
|
291
|
+
M ${15-i},${80-i}
|
292
|
+
${15-i},${80+i}
|
293
|
+
30,83
|
294
|
+
15,65
|
295
|
+
Z
|
296
|
+
`,l=80+i,c=`
|
297
|
+
m ${15-i*1.1},${l}
|
298
|
+
c 35,10 55,15 60,30
|
299
|
+
l ${35+i*1.2},${-10-i}
|
300
|
+
C 80.47,98.32 50.5,${90+i} 20,${l} Z
|
301
|
+
`,d=`
|
302
|
+
M 72.45,35.67
|
303
|
+
A 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
|
304
|
+
Z
|
305
|
+
`,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",h="M 60,75 65,65 H 55 l 55,-55 10,5 z";n&&(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",h="M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z");let m=`M 25,35 ${10-i/4},${70-i/2} 20,75 25,85 60,75 70,55 45,25 Z`,v=L.fromHex("#f4d7d7").mix(r,i/40-.1).toHexString(),b=en(),y=r.toHexString(),f=Jr({fill:b.patternRef,d:a},{fill:b.patternRef,d:c},{fill:y,d:a},{fill:y,d:c}),T=Jr({fill:b.patternRef,d:m},{fill:v,stroke:y,d:m}),P=Jr({fill:"var(--icon-color)",stroke:"var(--icon-color)",d:u},{fill:"rgba(150, 150, 150, 0.3)",d:p},{fill:"rgba(100, 100, 100, 0.2)",d:h},{fill:b.patternRef,d},{fill:y,d}),S=document.createElementNS(ie,"svg");S.setAttribute("viewBox","0 0 100 100");let E=je("g",{children:[f,T,P].flat()}),C=je("defs",{children:[b.patternDefElement]});return S.replaceChildren(C,E),S}makeIconFromFactory(o){let e=Math.sqrt(o.thickness)*3,r=performance.now(),n={pos:w.of(10,10),width:e,color:o.color,time:r-100},i={pos:w.of(90,90),width:e,color:o.color,time:r},a=new U(()=>{}),l=o.factory(n,a);l.addPoint(i);let c=document.createElementNS(ie,"svg");c.setAttribute("viewBox","0 0 100 100"),a.updateScreenSize(w.of(100,100));let d;if(o.color.a<1){let h=en(),m=document.createElementNS(ie,"defs");m.appendChild(h.patternDefElement),c.appendChild(m);let g=document.createElementNS(ie,"g");c.appendChild(g),d=new class extends me{constructor(){super(c,a)}addPathToSVG(){let v=super.addPathToSVG();if(v){let b=v.cloneNode(!0);b.style.zIndex="-1",b.hasAttribute("stroke")?b.setAttribute("stroke",h.patternRef):b.hasAttribute("fill")&&b.setAttribute("fill",h.patternRef),g.appendChild(b)}return v}}}else d=new me(c,a);l.preview(d);let p=l.getBBox();return c.setAttribute("viewBox",`${p.x} ${p.y} ${p.w} ${p.h}`),c}makePipetteIcon(o){let e=document.createElementNS(ie,"svg"),r=document.createElementNS(ie,"g");r.style.rotate="45deg",r.style.transformOrigin="center";let n=document.createElementNS(ie,"g");if(n.innerHTML=`
|
306
|
+
<path
|
307
|
+
style="fill: var(--icon-color); stroke-linecap:round; stroke-linejoin:round;"
|
308
|
+
d="
|
309
|
+
m 32,12 v 68
|
310
|
+
c 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
|
311
|
+
c 0.3,-0.9 1.1,-1.9 2.6,-2.9 1.5,-1.1 3.4,-2 5.1,-3.2
|
312
|
+
C 57.5,82 58,81 58,80
|
313
|
+
V 12 Z m 20,25 v 41.3
|
314
|
+
c 0,1.7 -2.5,1.6 -4,2.7 -1,0.76 -2.1,1.5 -3,2.6
|
315
|
+
C 44,82.5 43.02,81.75 42,81 40.51,79.92 38,80 38,78.34
|
316
|
+
V 51 Z
|
317
|
+
"
|
318
|
+
/>
|
319
|
+
<rect
|
320
|
+
style="fill: var(--icon-color);"
|
321
|
+
width="32"
|
322
|
+
height="9"
|
323
|
+
x="29"
|
324
|
+
y="2"
|
325
|
+
ry="4.5"
|
326
|
+
/>
|
327
|
+
<path
|
328
|
+
style="fill: var(--icon-color);"
|
329
|
+
d="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"
|
330
|
+
/>
|
331
|
+
`,o){let i=en(),a=document.createElementNS(ie,"defs");a.appendChild(i.patternDefElement),e.appendChild(a);let l=document.createElementNS(ie,"path"),c=document.createElementNS(ie,"path"),d=`
|
332
|
+
M 35,36 H 55 V 78.678012 83 L 45,87 35,83 Z
|
333
|
+
`;c.setAttribute("d",d),l.setAttribute("d",d),c.style.fill=o.toHexString(),l.style.fill=i.patternRef,r.appendChild(l),r.appendChild(c)}return r.appendChild(n),e.appendChild(r),e.setAttribute("viewBox","5 -40 140 140"),e}makeShapeAutocorrectIcon(){return this.makeIconFromPath(`
|
334
|
+
m 79.129476,33.847107 9.967823,-0.03218 v 55 h -55 l 0.03218,-9.96782
|
335
|
+
M 71.1,40.8 a 30,30 0 0 1 -30,30 30,30 0 0 1 -30,-30 30,30 0 0 1 30,-30 30,30 0 0 1 30,30 L 71.1,40.8
|
336
|
+
M 34.1,58.8 v -25 h 25 v 0
|
337
|
+
`,"none","var(--icon-color)","7px")}makeStrokeSmoothingIcon(){return this.makeIconFromPath(`
|
338
|
+
m 31,83.2 c -50,0 30,-65 -20,-65
|
339
|
+
M 75,17.3 40,59.7 38.2,77.6 55.5,72.4 90.5,30 Z
|
340
|
+
`,"none","var(--icon-color)","7px")}makeFormatSelectionIcon(){return this.makeIconFromPath(`
|
341
|
+
M 5 10
|
342
|
+
L 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
|
343
|
+
M 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
|
344
|
+
M 60 25 L 55 25 L 50 30 L 60 25 z
|
345
|
+
M 10 55 L 10 90 L 41 90 L 41 86 L 45 86 L 45 55 L 10 55 z
|
346
|
+
M 42 87 L 42 93 L 48 93 L 48 87 L 42 87 z
|
347
|
+
`)}makeResizeImageToSelectionIcon(){return this.makeIconFromPath(`
|
348
|
+
M 75 5 75 10 90 10 90 25 95 25 95 5 75 5 z
|
349
|
+
M 15 15 15 30 20 30 20 20 30 20 30 15 15 15 z
|
350
|
+
M 84 15 82 17 81 16 81 20 85 20 84 19 86 17 84 15 z
|
351
|
+
M 26 24 24 26 26 28 25 29 29 29 29 25 28 26 26 24 z
|
352
|
+
M 25 71 26 72 24 74 26 76 28 74 29 75 29 71 25 71 z
|
353
|
+
M 15 75 15 85 25 85 25 80 20 80 20 75 15 75 z
|
354
|
+
M 90 75 90 90 75 90 75 95 95 95 95 75 90 75 z
|
355
|
+
M 81 81 81 85 82 84 84 86 86 84 84 82 85 81 81 81 z
|
356
|
+
`)}makeResizeViewportIcon(){return this.makeResizeImageToSelectionIcon()}makeDuplicateSelectionIcon(){return this.makeIconFromPath(`
|
357
|
+
M 45,10 45,55 90,55 90,10 45,10 z
|
358
|
+
M 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z
|
359
|
+
`)}makeCopyIcon(){return this.makeIconFromPath(`
|
360
|
+
M 45,10 45,55 90,55 90,10 45,10 z
|
361
|
+
M 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z
|
362
|
+
`)}makePasteIcon(){let o=this.makeIconFromPath(`
|
363
|
+
M 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
|
364
|
+
M 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
|
365
|
+
M 25 35 L 90 35 L 90 40 L 25 40 L 25 35 z
|
366
|
+
M 25 45 L 90 45 L 90 50 L 25 50 L 25 45 z
|
367
|
+
M 25 55 L 85 55 L 85 60 L 25 60 L 25 55 z
|
368
|
+
M 25 65 L 90 65 L 90 70 L 25 70 L 25 65 z
|
369
|
+
`);return o.setAttribute("viewBox","0 0 120 120"),o}#e(){return this.makeIconFromPath(`
|
370
|
+
M 15,15 85,85
|
371
|
+
M 15,85 85,15
|
372
|
+
`,"none","var(--icon-color)","6px")}makeDeleteSelectionIcon(){return this.#e()}makeCloseIcon(){return this.#e()}makeSaveIcon(){let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.innerHTML=`
|
373
|
+
<style>
|
374
|
+
.toolbar-save-icon {
|
375
|
+
stroke: var(--icon-color);
|
376
|
+
stroke-width: 6;
|
377
|
+
stroke-linejoin: round;
|
378
|
+
stroke-linecap: round;
|
379
|
+
fill: none;
|
380
|
+
}
|
381
|
+
</style>
|
382
|
+
<path
|
383
|
+
d='
|
384
|
+
M 15,55 30,70 85,20
|
385
|
+
'
|
386
|
+
class='toolbar-save-icon'
|
387
|
+
/>
|
388
|
+
`,o.setAttribute("viewBox","0 0 100 100"),o}makeConfigureDocumentIcon(){let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.innerHTML=`
|
389
|
+
<path
|
390
|
+
d='
|
391
|
+
M 5,5 V 95 H 95 V 5 Z m 5,5 H 90 V 90 H 10 Z
|
392
|
+
m 5,10 V 30 H 50 V 25 H 20 v -5 z
|
393
|
+
m 40,0 V 50 H 85 V 20 Z
|
394
|
+
m 2,2 H 83 V 39 L 77,28 70,42 64,35 57,45 Z
|
395
|
+
m 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
|
396
|
+
M 15,40 v 5 h 35 v -5 z
|
397
|
+
m 0,15 v 5 h 70 v -5 z
|
398
|
+
m 0,15 v 5 h 70 v -5 z
|
399
|
+
'
|
400
|
+
style='fill: var(--icon-color);'
|
401
|
+
/>
|
402
|
+
`,o.setAttribute("viewBox","0 0 100 100"),o}makeOverflowIcon(){return this.makeIconFromPath(`
|
403
|
+
M 15 40
|
404
|
+
A 12.5 12.5 0 0 0 2.5 52.5
|
405
|
+
A 12.5 12.5 0 0 0 15 65
|
406
|
+
A 12.5 12.5 0 0 0 27.5 52.5
|
407
|
+
A 12.5 12.5 0 0 0 15 40
|
408
|
+
z
|
409
|
+
|
410
|
+
M 50 40
|
411
|
+
A 12.5 12.5 0 0 0 37.5 52.5
|
412
|
+
A 12.5 12.5 0 0 0 50 65
|
413
|
+
A 12.5 12.5 0 0 0 62.5 52.5
|
414
|
+
A 12.5 12.5 0 0 0 50 40
|
415
|
+
z
|
416
|
+
|
417
|
+
M 85 40
|
418
|
+
A 12.5 12.5 0 0 0 72.5 52.5
|
419
|
+
A 12.5 12.5 0 0 0 85 65
|
420
|
+
A 12.5 12.5 0 0 0 97.5 52.5
|
421
|
+
A 12.5 12.5 0 0 0 85 40
|
422
|
+
z
|
423
|
+
`)}makeHelpIcon(){let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.innerHTML=`
|
424
|
+
<circle
|
425
|
+
style="stroke-width:1.587; stroke: var(--icon-color);"
|
426
|
+
fill="none"
|
427
|
+
cx="13.23"
|
428
|
+
cy="13.23"
|
429
|
+
r="11.9"
|
430
|
+
/>
|
431
|
+
<path
|
432
|
+
style="stroke-width: 3; stroke-linecap: butt; stroke: var(--icon-color);"
|
433
|
+
fill="none"
|
434
|
+
d="M 9.26,6.61 C 18.7,3.25 19.95,10.4 14.3,13.4 c -1.15,0.61 -1.32,1.32 -1.32,2.65 v 2.12"
|
435
|
+
/>
|
436
|
+
<circle
|
437
|
+
style="fill: var(--icon-color);"
|
438
|
+
cx="13"
|
439
|
+
cy="21.32"
|
440
|
+
r="1.9"
|
441
|
+
/>
|
442
|
+
`,o.setAttribute("viewBox","0 0 26.46 26.46"),o.setAttribute("width","100"),o.setAttribute("height","100"),o}makeIconFromPath(o,e="var(--icon-color)",r="none",n="0px"){let i=document.createElementNS(ie,"svg"),a=document.createElementNS(ie,"path");return a.setAttribute("d",o),a.style.fill=e,a.style.stroke=r,a.style.strokeWidth=n,i.appendChild(a),i.setAttribute("viewBox","0 0 100 100"),i}makeCheckerboardPattern(){return en()}isRoundedTipPen(o){return o.factory===Qe||o.factory===ft}isPolylinePen(o){return o.factory===ft}licenseInfo(){return null}};var tl=s=>{let o=0,e=s.map(r=>r.id);e.sort();for(let r of e)o===r&&(o=r+1);return o},tn=tl;var ol=(s,o,e,r,n=0)=>{let i=tn(r??[]),a=ke.ofCanvasPoint(e,o!==2,s.viewport,i,n);return s.toolController.dispatchInputEvent({kind:o,allPointers:r??[a],current:a}),a},on=ol;var D="toolbar-";var xi=class{constructor(o,e,r){this.parent=o;this.notifier=e;this.onDestroy=r;this.dropdownToggleListener=null;this.hideDropdownTimeout=null;this.visible=j.fromInitialValue(!1),this.dropdownContainer=document.createElement("div"),this.dropdownContainer.classList.add(`${D}dropdown`),this.dropdownContainer.classList.add("hidden"),o.target.insertAdjacentElement("afterend",this.dropdownContainer),this.dropdownToggleListener=this.notifier.on(0,n=>{n.dropdown!==this&&n.fromToplevelDropdown&&this.setVisible(!1)})}onActivated(){}repositionDropdown(){let o=this.dropdownContainer.getBoundingClientRect(),e=document.scrollingElement?.clientWidth??document.body.clientHeight,r=document.scrollingElement?.clientHeight??document.body.clientHeight,n,i;o.left>e/2&&(n=`calc(${this.parent.target.clientWidth+"px"} - 100%)`),o.bottom>r&&o.top-o.height>0&&(i=`calc(-${this.parent.target.clientHeight}px - 100%)`),n||i?this.dropdownContainer.style.translate=`${n??"0"} ${i??"0"}`:this.dropdownContainer.style.translate=""}setVisible(o){if(this.visible.get()===o)return;this.hideDropdownTimeout&&(clearTimeout(this.hideDropdownTimeout),this.hideDropdownTimeout=null,this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown());let r=150;if(this.visible.set(o),o)this.dropdownContainer.classList.remove("hidden"),this.notifier.dispatch(0,{dropdown:this,fromToplevelDropdown:this.parent.isToplevel()}),this.repositionDropdown();else{this.notifier.dispatch(1,{dropdown:this,fromToplevelDropdown:this.parent.isToplevel()}),this.dropdownContainer.classList.add("hiding");let i=r*.95;this.hideDropdownTimeout=setTimeout(()=>{this.dropdownContainer.classList.add("hidden"),this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown()},i)}let n=`var(--dropdown-${o?"show":"hide"}-animation)`;this.dropdownContainer.style.animation=`${r}ms ease ${n}`}requestShow(){this.setVisible(!0)}requestHide(){this.setVisible(!1)}appendChild(o){this.dropdownContainer.appendChild(o)}clearChildren(){this.dropdownContainer.replaceChildren()}destroy(){this.setVisible(!1),this.dropdownContainer.remove(),this.dropdownToggleListener?.remove(),this.clearChildren(),this.onDestroy()}},Yo=class{constructor(o,e){this.localization=e;this.dropdowns=new Set;this.listeners=[];this.connectedNotifiers=[];this.notifier=new Fe,this.notifier.on(0,({dropdown:r,fromToplevelDropdown:n})=>{r&&(o(this.localization.dropdownShown(r.parent.getTitle())),this.connectedNotifiers.forEach(i=>{i.dispatch(13,{kind:13,fromToplevelDropdown:n,layoutManager:this})}))}),this.notifier.on(1,({dropdown:r})=>{r&&o(this.localization.dropdownHidden(r.parent.getTitle()))})}connectToEditorNotifier(o){this.connectedNotifiers.push(o),this.refreshListeners()}createToolMenu(o){let e=new xi(o,this.notifier,()=>{this.dropdowns.delete(e),this.refreshListeners()});return this.dropdowns.add(e),this.refreshListeners(),e}refreshListeners(){let o=()=>{this.listeners.forEach(e=>e.remove()),this.listeners=[]};this.dropdowns.size===0?o():this.listeners.length!==this.connectedNotifiers.length&&(o(),this.listeners=this.connectedNotifiers.map(e=>e.on(13,r=>{r.kind!==13||r.layoutManager===this||this.notifier.dispatch(0,{fromToplevelDropdown:r.fromToplevelDropdown})})))}};var rl=(s,o)=>{let e=new Map,r=null,n=!1,i=()=>{if(e.size===0)n?(n=!1,o.onEnd()):r!==null&&(clearTimeout(r),r=null);else{let l=Date.now(),c=0;for(let p of e.values()){let h=l-p.timeEnter;c=Math.max(h,c)}let d=o.longPressTimeout??700;r!==null&&(clearTimeout(r),r=null);let u=d-c;u<=0?(o.onStart(),n=!0):r=setTimeout(()=>{r=null,i()},u)}},a=l=>{let c={timeEnter:Date.now()};l.type==="pointerenter"?e.set(l.pointerId,c):(l.type==="pointerleave"||l.type==="pointercancel")&&e.clear(),i()};return s.addEventListener("pointerenter",a),s.addEventListener("pointerleave",a),s.addEventListener("pointercancel",a),{removeListeners:()=>{s.removeEventListener("pointerenter",a),s.removeEventListener("pointerleave",a),s.removeEventListener("pointercancel",a)}}},Ps=rl;var nl=(s,o)=>{let e="has-long-press-or-hover",r="no-long-press-or-hover";s.classList.add("no-long-press-or-hover");let{removeListeners:n}=Ps(s,{onStart(){s.classList.remove(r),s.classList.add(e)},onEnd(){s.classList.add(r),s.classList.remove(e)},longPressTimeout:o?.timeout});return{removeEventListeners:()=>{s.classList.remove(r),n()}}},gt=nl;var il=(s,o)=>{let e=[...o.draggableChildElements,s],r=0,n=0,i=0,a=0,l=!1,c=null,d=b=>{if(!b)return!1;if(e.includes(b))return!0;let y=["INPUT","SELECT","IMG"],f=!1,T=b.parentElement;for(;T&&!y.includes(T.tagName);){if(e.includes(T)){f=!0;break}T=T.parentElement}return!y.includes(b.tagName)&&f},u=[],p=(b,y,f)=>{s.addEventListener(b,y,f),u.push(()=>{s.removeEventListener(b,y)})},h=5,m=()=>Math.hypot(r-i,n-a)<h,g=!1;p("pointerdown",b=>{b.defaultPrevented||!d(b.target)||b.isPrimary&&(g=!1,r=b.clientX,n=b.clientY,i=b.clientX,a=b.clientY,c=null,l=!0)},{passive:!0});let v=b=>{l&&(c!==null&&(s.releasePointerCapture(c),c=null),o.onDragEnd({roughlyClick:m(),endTimestamp:performance.now(),displacement:w.of(r-i,n-a)}),l=!1,g=!1)};return p("pointermove",b=>{if(!b.isPrimary||!l)return;if(b.pointerType==="mouse"&&b.buttons===0){v(b);return}c===null&&!m()&&(s.setPointerCapture(b.pointerId),c=b.pointerId);let y=b.clientX,f=b.clientY,T=y-r,P=f-n;(!(Math.abs(y-i)<=h&&Math.abs(f-a)<=h)||g)&&(o.onDrag(T,P,w.of(y-i,f-a)),r=y,n=f,g=!0)}),p("pointerleave",b=>{c===null&&l&&b.isPrimary&&(s.setPointerCapture(b.pointerId),c=b.pointerId)}),p("pointerup",v),p("pointercancel",v),{removeListeners:()=>{for(let b of u)b()}}},rn=il;var sl=s=>{let o=(r,n)=>{let i=getComputedStyle(r);for(let a=0;a<i.length;a++){let l=i.item(a),c=i.getPropertyValue(l);n.style?.setProperty(l,c)}for(let a=0;a<r.children.length;a++){let l=r.children.item(a),c=n.children.item(a);l&&c?o(l,c):console.warn("CloneElement: Missing child")}},e=s.cloneNode(!0);return o(s,e),e},Es=sl;var al=(s,o,e,r)=>{let n=document.createElement("div");n.classList.add("help-page-container");let i=document.createElement("div");i.classList.add("label","-space-above"),i.setAttribute("aria-live","polite");let a=0,l=s[0]??null,c=[];n.addEventListener("click",v=>{v.target===n&&e()});let d=()=>{if(!l)return I.empty;let v=l.targetElements.map(b=>I.of(b.getBoundingClientRect()));return I.union(...v)},u=()=>{let v=d();for(let b=0;b<c.length;b++)for(let{container:y,bbox:f}of c[b])if(b===a)y.classList.add("-active"),y.classList.remove("-clickable","-background"),y.onclick=()=>{};else{f.containsRect(v)?(y.classList.add("-background"),y.classList.remove("-active","-clickable")):(y.classList.add("-clickable"),y.classList.remove("-active","-background"));let T=b;y.onclick=()=>{o(T)}}},p=()=>{let v=I.of(i.getBoundingClientRect()),b=d();if(v.intersects(b)){let y=I.of(n.getBoundingClientRect()),f=b.topLeft.y,T=y.bottomLeft.y-b.bottomLeft.y;f>T&&f>v.height/3&&(i.classList.remove("-small-space-above","-large-space-above"),i.classList.add("-large-space-below")),f<T&&T>v.height&&(i.classList.add("-large-space-above"),i.classList.remove("-large-space-below"))}},h=()=>{n.replaceChildren(),i.classList.remove("-large-space-above"),i.classList.add("-small-space-above","-large-space-below"),n.appendChild(i);let v=new I(0,0,window.innerWidth,window.innerHeight);c=[];for(let b=0;b<s.length;b++){let y=s[b],f=[];for(let T of y.targetElements){let P=I.of(T.getBoundingClientRect());if(!v.intersects(P)){let C=v.bottomLeft.lerp(v.bottomRight,.5),V=P.bottomLeft.lerp(P.bottomRight,.5),O=C.minus(V);P=P.translatedBy(O)}let S=Es(T);for(let C of S.querySelectorAll("input"))C.disabled=!0;S.style.margin="0";let E=document.createElement("div");E.classList.add("cloned-element-container"),E.style.position="absolute",E.style.left=`${P.topLeft.x}px`,E.style.top=`${P.topLeft.y}px`,E.replaceChildren(S),gt(E,{timeout:0}),f.push({container:E,bbox:P}),n.appendChild(E)}c.push(f)}u()},m=()=>{h(),p()},g=()=>{let v=document.createElement("div");v.innerText=l?.helpText??"",v.classList.add("current-item-help");let b=document.createElement("div");b.innerText=r.localization.helpScreenNavigationHelp,b.classList.add("navigation-help"),i.replaceChildren(v,...a===0?[b]:[]),u()};return g(),{addToParent:v=>{h(),v.appendChild(n),p()},refresh:m,setPageIndex:v=>{a=v,l=s[v],g()}}},Xo=class{constructor(o,e){this.createOverlay=o;this.context=e}#e=[];showHelpOverlay(){let o=document.createElement("dialog");o.setAttribute("autofocus","true"),o.classList.add("toolbar-help-overlay");let e=!1,r=()=>{if(e)return;let f=250;o.classList.add("-hiding"),setTimeout(()=>o.close(),f)},n=0,i=()=>{performance.now()-n<100||r()},a=()=>{let f=document.createElement("button");f.classList.add("close-button"),f.appendChild(this.context.icons.makeCloseIcon());let T=this.context.localization.close;return f.setAttribute("aria-label",T),f.setAttribute("title",T),f.onclick=()=>{r()},f},l=()=>{let f=te.fromInitialValue(0),T=document.createElement("div");T.classList.add("navigation-content");let P=al(this.#e,C=>f.set(C),i,this.context);P.addToParent(T);let S=C=>{C>=this.#e.length||C<0?(console.warn("Help screen: Navigated to out-of-bounds page",C),T.style.display="none"):(T.style.display="",P.setPageIndex(C))};f.onUpdateAndNow(S);let E={content:T,currentPage:f,toNext:()=>{E.hasNext()&&f.set(f.get()+1)},toPrevious:()=>{E.hasPrevious()&&f.set(f.get()-1)},hasNext:()=>f.get()+1<this.#e.length,hasPrevious:()=>f.get()>0,refreshCurrent:()=>{P.refresh()}};return E},c=f=>{let T=document.createElement("div");T.classList.add("navigation-buttons");let P=document.createElement("button"),S=document.createElement("button");P.innerText=this.context.localization.next,S.innerText=this.context.localization.previous,P.classList.add("next"),S.classList.add("previous");let E=()=>{T.classList.remove("-has-next","-has-previous"),f.hasNext()?(T.classList.add("-has-next"),P.disabled=!1):(T.classList.remove("-has-next"),P.disabled=!0),f.hasPrevious()?(T.classList.add("-has-previous"),S.disabled=!1):(T.classList.remove("-has-previous"),S.disabled=!0)};return f.currentPage.onUpdateAndNow(E),P.onclick=()=>{f.toNext()},S.onclick=()=>{f.toPrevious()},T.replaceChildren(S,P),T},d=l(),u=c(d);o.replaceChildren(a(),u,d.content),this.createOverlay(o),o.showModal();let p=30,h=f=>{f>0&&!d.hasPrevious()&&(f=0),f<0&&!d.hasNext()&&(f=0),(f>p||f<-p)&&(f=p*Math.sign(f)),o.style.transform=`translate(${f}px, 0px)`,f>=p?u.classList.add("-highlight-previous"):u.classList.remove("-highlight-previous"),f<=-p?u.classList.add("-highlight-next"):u.classList.remove("-highlight-next")},m=rn(o,{draggableChildElements:[d.content],onDrag:(f,T,P)=>{o.classList.add("-dragging"),h(P.x)},onDragEnd:f=>{if(o.classList.remove("-dragging"),h(0),!f.roughlyClick){let T=f.displacement.x;T>p?d.toPrevious():T<-p&&d.toNext(),n=f.endTimestamp}}}),g;window.ResizeObserver&&(g=new ResizeObserver(()=>{d.refreshCurrent()}),g.observe(o));let v=()=>{requestAnimationFrame(()=>d.refreshCurrent())},b=window.matchMedia?.("(prefers-color-scheme: dark)");b?.addEventListener("change",v);let y=[d.content,u,o];o.onclick=f=>{y.includes(f.target)&&i()},o.onkeyup=f=>{f.code==="Escape"?(r(),f.preventDefault()):f.code==="ArrowRight"?(d.toNext(),f.preventDefault()):f.code==="ArrowLeft"&&(d.toPrevious(),f.preventDefault())},o.addEventListener("close",()=>{this.context.announceForAccessibility(this.context.localization.helpHidden),b?.removeEventListener("change",v),m.removeListeners(),g?.disconnect(),o.remove()})}registerTextHelpForElement(o,e){this.registerTextHelpForElements([o],e)}registerTextHelpForElements(o,e){this.#e.push({targetElements:[...o],helpText:e})}hasHelpText(){return this.#e.length>0}createToggleButton(){let o=document.createElement("div");o.classList.add("toolbar-help-overlay-button");let e=document.createElement("button");e.classList.add("button");let r=this.context.icons.makeHelpIcon();return r.classList.add("icon"),e.appendChild(r),e.setAttribute("aria-label",this.context.localization.help),e.onclick=()=>{this.showHelpOverlay()},o.appendChild(e),o}};var Ut=(n=>(n.Save="save",n.Exit="exit",n.Undo="undo",n.Redo="redo",n))(Ut||{}),ae=class s{constructor(o,e,r){this.editor=o;this.id=e;this.dropdown=null;this.disabled=!1;this.#t=!1;this.#o=[];this.subWidgets={};this.toplevel=!0;this.#r=null;this.localizationTable=r??o.localization;let n=new Yo(i=>this.editor.announceForAccessibility(i),this.localizationTable);n.connectToEditorNotifier(o.notifier),this.layoutManager=n,this.icon=null,this.container=document.createElement("div"),this.container.classList.add(`${D}toolContainer`,`${D}toolButtonContainer`,`${D}internalWidgetId--${e.replace(/[^a-zA-Z0-9_]/g,"-")}`),this.dropdownContent=document.createElement("div"),this.#e=!1,this.button=document.createElement("div"),this.button.classList.add(`${D}button`),this.label=document.createElement("label"),this.button.setAttribute("role","button"),this.button.tabIndex=0,this.button.oncontextmenu=i=>{i.preventDefault()},gt(this.button)}#e;#t;#o;#r;#n(){this.#r?.();let o=this.editor.toolController.getMatchingTools(tt),e=null;if(o.length>0&&this.onKeyPress!==s.prototype.onKeyPress){let n=a=>this.onKeyPress(a),i=o[0];i.registerListener(n),e=()=>{i.removeListener(n)}}let r=this.editor.isReadOnlyReactiveValue().onUpdateAndNow(n=>{n&&this.shouldAutoDisableInReadOnlyEditor()&&!this.disabled?(this.setDisabled(!0),this.#t=!0,this.#e&&this.dropdown?.requestHide()):!n&&this.#t&&(this.#t=!1,this.setDisabled(!1))});this.#r=()=>{r.remove(),e?.(),this.#r=null}}shouldAutoDisableInReadOnlyEditor(){return!0}getId(){return this.id}setTags(o){let e=r=>`toolwidget-tag--${r}`;for(let r of this.#o)this.container.classList.remove(e(r));this.#o=[...o];for(let r of this.#o)this.container.classList.add(e(r))}getTags(){return[...this.#o]}getUniqueIdIn(o){let e=this.getId(),r=0;for(;e in o&&o[e]!==this;)e=this.getId()+"-"+r.toString(),r++;return e}fillDropdown(o,e){if(Object.keys(this.subWidgets).length===0)return!1;for(let r in this.subWidgets){let n=this.subWidgets[r],i=n.addTo(o);n.setIsToplevel(!1);let a=n.getHelpText();a&&e?.registerTextHelpForElement(i,a)}return!0}getHelpText(){}setupActionBtnClickListener(o){return this.setUpButtonEventListeners(o)}setUpButtonEventListeners(o){let e={Enter:!0," ":!0};o.onkeydown=r=>{let n=!1;if(r.key in e&&(this.disabled||(this.handleClick(),n=!0)),!n){let i=Lo(r);n=this.editor.toolController.dispatchInputEvent(i)}n&&r.preventDefault()},o.onkeyup=r=>{if(r.key in e)return;let n=zo(r);this.editor.toolController.dispatchInputEvent(n)&&r.preventDefault()},o.onclick=()=>{this.disabled||this.handleClick()},o.ondblclick=r=>{r.preventDefault()}}onKeyPress(o){return!1}get hasDropdown(){return this.#e}addSubWidget(o){let e=o.getUniqueIdIn(this.subWidgets);this.subWidgets[e]=o}setLayoutManager(o){o!==this.layoutManager&&(this.layoutManager=o,this.container.parentElement&&this.addTo(this.container.parentElement))}addTo(o){this.icon=null,this.updateIcon(),this.label.innerText=this.getTitle();let e="long-label";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);let r=new Xo(i=>this.editor.createHTMLOverlay(i),this.editor),n=this.getHelpText();return n&&r.registerTextHelpForElement(this.dropdownContent,[this.getTitle(),n].join(`
|
443
|
+
|
444
|
+
`)),this.dropdownContent.replaceChildren(),this.#e=this.fillDropdown(this.dropdownContent,r),this.#e&&(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(i=>{i?this.container.classList.add("dropdownVisible"):this.container.classList.remove("dropdownVisible"),i||this.focus()}),r.hasHelpText()&&this.dropdown.appendChild(r.createToggleButton()),this.dropdown.appendChild(this.dropdownContent)),this.setDropdownVisible(!1),this.container.parentElement&&this.container.remove(),this.#n(),o.appendChild(this.container),this.container}remove(){this.container.remove(),this.#r?.()}focus(){this.button.focus()}addCSSClassToContainer(o){this.container.classList.add(o)}removeCSSClassFromContainer(o){this.container.classList.remove(o)}updateIcon(){let o=this.createIcon();o?this.container.classList.remove("no-icon"):(o=document.createElement("div"),this.container.classList.add("no-icon")),this.icon?.replaceWith(o),this.icon=o,this.icon.classList.add(`${D}icon`)}setDisabled(o){this.disabled=o,this.#t=!1,this.disabled?(this.button.classList.add("disabled"),this.button.setAttribute("aria-disabled","true")):(this.button.classList.remove("disabled"),this.button.removeAttribute("aria-disabled"))}setSelected(o){this.isSelected()!==o&&(this.button.setAttribute("role","switch"),o?(this.container.classList.add("selected"),this.button.setAttribute("aria-checked","true")):(this.container.classList.remove("selected"),this.button.setAttribute("aria-checked","false")))}setDropdownVisible(o){o?this.dropdown?.requestShow():this.dropdown?.requestHide()}activateDropdown(){this.dropdown?.onActivated()}mustBeInToplevelMenu(){return!1}canBeInOverflowMenu(){return!this.mustBeInToplevelMenu()}getButtonWidth(){return this.button.clientWidth}isHidden(){return this.container.style.display==="none"}setHidden(o){this.container.style.display=o?"none":""}setIsToplevel(o){this.toplevel=o}isDropdownVisible(){return this.dropdown?.visible?.get()??!1}isSelected(){return this.container.classList.contains("selected")}createDropdownIcon(){let o=this.editor.icons.makeDropdownIcon();return o.classList.add(`${D}showHideDropdownIcon`),o}serializeState(){let o={};for(let e in this.subWidgets)o[e]=this.subWidgets[e].serializeState();return{subwidgetState:o}}deserializeFrom(o){if(o.subwidgetState){yr(o.subwidgetState);for(let e in o.subwidgetState)if(e in this.subWidgets){let r=o.subwidgetState[e];r&&this.subWidgets[e].deserializeFrom(r)}}}};var Qo=class{constructor(o,e,r,n,i){this.setSidebarContent=o;this.sidebarTitle=e;this.sidebarVisibility=r;this.announceForAccessibility=n;this.localization=i;this.visibleWidgetContent=j.fromInitialValue(null)}createToolMenu(o){let e=document.createElement("div"),r=null,n=j.fromCallback(()=>this.visibleWidgetContent.get()===r&&this.sidebarVisibility.get(),[this.visibleWidgetContent,this.sidebarVisibility]);return r={visible:n,requestShow:()=>{this.setSidebarContent(e),this.sidebarTitle.set(o.getTitle()),this.visibleWidgetContent.set(r),this.sidebarVisibility.set(!0),this.announceForAccessibility(this.localization.dropdownShown(o.getTitle()))},onActivated:()=>{},requestHide:()=>{n.get()&&this.sidebarVisibility.set(!1)},appendChild:i=>{e.appendChild(i)},clearChildren:()=>{e.replaceChildren()},destroy:()=>{r?.requestHide(),e.parentElement&&e.remove(),this.visibleWidgetContent.get()===r&&this.visibleWidgetContent.set(null)}},r}};var bt=(()=>{return((s,o,e,r)=>{let n=o.createElement("canvas").getContext("2d"),i={r:0,g:0,b:0,h:0,s:0,v:0,a:1},a,l,c,d,u,p,h,m,g,v,b,y,f,T,P,S,E={},C={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:()=>r,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."}},V={},O="",G={},se=!1;function oe(x){if(typeof x=="object")for(let R in x)switch(R){case"el":_e(x.el),x.wrap!==!1&&at(x.el);break;case"parent":a=o.querySelector(x.parent),a&&(a.appendChild(l),C.parent=x.parent,a===o.body&&(a=r));break;case"themeMode":C.themeMode=x.themeMode,x.themeMode==="auto"&&s.matchMedia&&s.matchMedia("(prefers-color-scheme: dark)").matches&&(C.themeMode="dark");case"theme":x.theme&&(C.theme=x.theme),l.className=`clr-picker clr-${C.theme} clr-${C.themeMode}`,C.inline&&st();break;case"rtl":C.rtl=!!x.rtl,o.querySelectorAll(".clr-field").forEach(A=>A.classList.toggle("clr-rtl",C.rtl));break;case"margin":x.margin*=1,C.margin=isNaN(x.margin)?C.margin:x.margin;break;case"wrap":x.el&&x.wrap&&at(x.el);break;case"formatToggle":C.formatToggle=!!x.formatToggle,ge("clr-format").style.display=C.formatToggle?"block":"none",C.formatToggle&&(C.format="auto");break;case"swatches":if(Array.isArray(x.swatches)){let A=[];x.swatches.forEach((N,Q)=>{A.push(`<button type="button" id="clr-swatch-${Q}" aria-labelledby="clr-swatch-label clr-swatch-${Q}" style="color: ${N};">${N}</button>`)}),ge("clr-swatches").innerHTML=A.length?`<div>${A.join("")}</div>`:"",C.swatches=x.swatches.slice()}break;case"swatchesOnly":C.swatchesOnly=!!x.swatchesOnly,l.setAttribute("data-minimal",C.swatchesOnly);break;case"alpha":C.alpha=!!x.alpha,l.setAttribute("data-alpha",C.alpha);break;case"inline":if(C.inline=!!x.inline,l.setAttribute("data-inline",C.inline),C.inline){let A=x.defaultColor||C.defaultColor;T=Yt(A),st(),yt(A)}break;case"clearButton":typeof x.clearButton=="object"&&(x.clearButton.label&&(C.clearLabel=x.clearButton.label,h.innerHTML=C.clearLabel),x.clearButton=x.clearButton.show),C.clearButton=!!x.clearButton,h.style.display=C.clearButton?"block":"none";break;case"clearLabel":C.clearLabel=x.clearLabel,h.innerHTML=C.clearLabel;break;case"closeButton":C.closeButton=!!x.closeButton,C.closeButton?l.insertBefore(m,u):u.appendChild(m);break;case"closeLabel":C.closeLabel=x.closeLabel,m.innerHTML=C.closeLabel;break;case"a11y":let z=x.a11y,M=!1;if(typeof z=="object")for(let A in z)z[A]&&C.a11y[A]&&(C.a11y[A]=z[A],M=!0);if(M){let A=ge("clr-open-label"),N=ge("clr-swatch-label");A.innerHTML=C.a11y.open,N.innerHTML=C.a11y.swatch,m.setAttribute("aria-label",C.a11y.close),h.setAttribute("aria-label",C.a11y.clear),g.setAttribute("aria-label",C.a11y.hueSlider),b.setAttribute("aria-label",C.a11y.alphaSlider),p.setAttribute("aria-label",C.a11y.input),c.setAttribute("aria-label",C.a11y.instruction)}break;default:C[R]=x[R]}}function fe(x,R){typeof x=="string"&&typeof R=="object"&&(V[x]=R,se=!0)}function Se(x){delete V[x],Object.keys(V).length===0&&(se=!1,x===O&&We())}function de(x){if(se){let R=["el","wrap","rtl","inline","defaultColor","a11y"];for(let z in V){let M=V[z];if(x.matches(z)){O=z,G={},R.forEach(A=>delete M[A]);for(let A in M)G[A]=Array.isArray(C[A])?C[A].slice():C[A];oe(M);break}}}}function We(){Object.keys(G).length>0&&(oe(G),O="",G={})}function _e(x){X(o,"click",x,R=>{C.inline||(de(R.target),f=R.target,P=f.value,T=Yt(P),l.classList.add("clr-open"),st(),yt(P),(C.focusInput||C.selectInput)&&(p.focus({preventScroll:!0}),p.setSelectionRange(f.selectionStart,f.selectionEnd)),C.selectInput&&p.select(),(S||C.swatchesOnly)&&Mi().shift().focus(),f.dispatchEvent(new Event("open",{bubbles:!0})))}),X(o,"input",x,R=>{let z=R.target.parentNode;z.classList.contains("clr-field")&&(z.style.color=R.target.value)})}function st(){if(!l||!f&&!C.inline)return;let x=a,R=s.scrollY,z=l.offsetWidth,M=l.offsetHeight,A={left:!1,top:!1},N,Q,Oe,re={x:0,y:0};if(x&&(N=s.getComputedStyle(x),Q=parseFloat(N.marginTop),Oe=parseFloat(N.borderTopWidth),re=x.getBoundingClientRect(),re.y+=Oe+R),!C.inline){let xe=f.getBoundingClientRect(),lt=xe.x,xt=R+xe.y+xe.height+C.margin;x?(lt-=re.x,xt-=re.y,lt+z>x.clientWidth&&(lt+=xe.width-z,A.left=!0),xt+M>x.clientHeight-Q&&M+C.margin<=xe.top-(re.y-R)&&(xt-=xe.height+M+C.margin*2,A.top=!0),xt+=x.scrollTop):(lt+z>o.documentElement.clientWidth&&(lt+=xe.width-z,A.left=!0),xt+M-R>o.documentElement.clientHeight&&M+C.margin<=xe.top&&(xt=R+xe.y-M-C.margin,A.top=!0)),l.classList.toggle("clr-left",A.left),l.classList.toggle("clr-top",A.top),l.style.left=`${lt}px`,l.style.top=`${xt}px`,re.x+=l.offsetLeft,re.y+=l.offsetTop}E={width:c.offsetWidth,height:c.offsetHeight,x:c.offsetLeft+re.x,y:c.offsetTop+re.y}}function at(x){o.querySelectorAll(x).forEach(R=>{let z=R.parentNode;if(!z.classList.contains("clr-field")){let M=o.createElement("div"),A="clr-field";(C.rtl||R.classList.contains("clr-rtl"))&&(A+=" clr-rtl"),M.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',z.insertBefore(M,R),M.setAttribute("class",A),M.style.color=R.value,M.appendChild(R)}})}function Ve(x){if(f&&!C.inline){let R=f;x&&(f=r,P!==R.value&&(R.value=P,R.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout(()=>{P!==R.value&&R.dispatchEvent(new Event("change",{bubbles:!0}))}),l.classList.remove("clr-open"),se&&We(),R.dispatchEvent(new Event("close",{bubbles:!0})),C.focusInput&&R.focus({preventScroll:!0}),f=r}}function yt(x){let R=oa(x),z=ta(R);ar(z.s,z.v),cr(R,z),g.value=z.h,l.style.color=`hsl(${z.h}, 100%, 50%)`,v.style.left=`${z.h/360*100}%`,d.style.left=`${E.width*z.s/100}px`,d.style.top=`${E.height-E.height*z.v/100}px`,b.value=z.a*100,y.style.left=`${z.a*100}%`}function Yt(x){let R=x.substring(0,3).toLowerCase();return R==="rgb"||R==="hsl"?R:"hex"}function Ke(x){x=x!==r?x:p.value,f&&(f.value=x,f.dispatchEvent(new Event("input",{bubbles:!0}))),C.onChange&&C.onChange.call(s,x,f),o.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:x,currentEl:f}}))}function sr(x,R){let z={h:g.value*1,s:x/E.width*100,v:100-R/E.height*100,a:b.value/100},M=Js(z);ar(z.s,z.v),cr(M,z),Ke()}function ar(x,R){let z=C.a11y.marker;x=x.toFixed(1)*1,R=R.toFixed(1)*1,z=z.replace("{s}",x),z=z.replace("{v}",R),d.setAttribute("aria-label",z)}function bn(x){return{pageX:x.changedTouches?x.changedTouches[0].pageX:x.pageX,pageY:x.changedTouches?x.changedTouches[0].pageY:x.pageY}}function qe(x){let R=bn(x),z=R.pageX-E.x,M=R.pageY-E.y;a&&(M+=a.scrollTop),vo(z,M),x.preventDefault(),x.stopPropagation()}function lr(x,R){let z=d.style.left.replace("px","")*1+x,M=d.style.top.replace("px","")*1+R;vo(z,M)}function vo(x,R){x=x<0?0:x>E.width?E.width:x,R=R<0?0:R>E.height?E.height:R,d.style.left=`${x}px`,d.style.top=`${R}px`,sr(x,R),d.focus()}function cr(x,R){x===void 0&&(x={}),R===void 0&&(R={});let z=C.format;for(let N in x)i[N]=x[N];for(let N in R)i[N]=R[N];let M=ra(i),A=M.substring(0,7);switch(d.style.color=A,y.parentNode.style.color=A,y.style.color=M,u.style.color=M,c.style.display="none",c.offsetHeight,c.style.display="",y.nextElementSibling.style.display="none",y.nextElementSibling.offsetHeight,y.nextElementSibling.style.display="",z==="mixed"?z=i.a===1?"hex":"rgb":z==="auto"&&(z=T),z){case"hex":p.value=M;break;case"rgb":p.value=na(i);break;case"hsl":p.value=ia(ea(i));break}o.querySelector(`.clr-format [value="${z}"]`).checked=!0}function Xs(){let x=g.value*1,R=d.style.left.replace("px","")*1,z=d.style.top.replace("px","")*1;l.style.color=`hsl(${x}, 100%, 50%)`,v.style.left=`${x/360*100}%`,sr(R,z)}function Qs(){let x=b.value/100;y.style.left=`${x*100}%`,cr({a:x}),Ke()}function Js(x){let R=x.s/100,z=x.v/100,M=R*z,A=x.h/60,N=M*(1-e.abs(A%2-1)),Q=z-M;M=M+Q,N=N+Q;let Oe=e.floor(A)%6,re=[M,N,Q,Q,N,M][Oe],xe=[N,M,M,N,Q,Q][Oe],lt=[Q,Q,N,M,M,N][Oe];return{r:e.round(re*255),g:e.round(xe*255),b:e.round(lt*255),a:x.a}}function ea(x){let R=x.v/100,z=R*(1-x.s/100/2),M;return z>0&&z<1&&(M=e.round((R-z)/e.min(z,1-z)*100)),{h:x.h,s:M||0,l:e.round(z*100),a:x.a}}function ta(x){let R=x.r/255,z=x.g/255,M=x.b/255,A=e.max(R,z,M),N=e.min(R,z,M),Q=A-N,Oe=A,re=0,xe=0;return Q&&(A===R&&(re=(z-M)/Q),A===z&&(re=2+(M-R)/Q),A===M&&(re=4+(R-z)/Q),A&&(xe=Q/A)),re=e.floor(re*60),{h:re<0?re+360:re,s:e.round(xe*100),v:e.round(Oe*100),a:x.a}}function oa(x){let R=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,z,M;return n.fillStyle="#000",n.fillStyle=x,z=R.exec(n.fillStyle),z?(M={r:z[3]*1,g:z[4]*1,b:z[5]*1,a:z[6]*1},M.a=+M.a.toFixed(2)):(z=n.fillStyle.replace("#","").match(/.{2}/g).map(A=>parseInt(A,16)),M={r:z[0],g:z[1],b:z[2],a:1}),M}function ra(x){let R=x.r.toString(16),z=x.g.toString(16),M=x.b.toString(16),A="";if(x.r<16&&(R="0"+R),x.g<16&&(z="0"+z),x.b<16&&(M="0"+M),C.alpha&&(x.a<1||C.forceAlpha)){let N=x.a*255|0;A=N.toString(16),N<16&&(A="0"+A)}return"#"+R+z+M+A}function na(x){return!C.alpha||x.a===1&&!C.forceAlpha?`rgb(${x.r}, ${x.g}, ${x.b})`:`rgba(${x.r}, ${x.g}, ${x.b}, ${x.a})`}function ia(x){return!C.alpha||x.a===1&&!C.forceAlpha?`hsl(${x.h}, ${x.s}%, ${x.l}%)`:`hsla(${x.h}, ${x.s}%, ${x.l}%, ${x.a})`}function sa(){o.getElementById("clr-picker")||(a=r,l=o.createElement("div"),l.setAttribute("id","clr-picker"),l.className="clr-picker",l.innerHTML=`<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="${C.a11y.input}"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="${C.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="${C.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="${C.a11y.alphaSlider}"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>${C.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="${C.a11y.clear}">${C.clearLabel}</button><div id="clr-color-preview" class="clr-preview"><button type="button" id="clr-close" class="clr-close" aria-label="${C.a11y.close}">${C.closeLabel}</button></div><span id="clr-open-label" hidden>${C.a11y.open}</span><span id="clr-swatch-label" hidden>${C.a11y.swatch}</span>`,o.body.appendChild(l),c=ge("clr-color-area"),d=ge("clr-color-marker"),h=ge("clr-clear"),m=ge("clr-close"),u=ge("clr-color-preview"),p=ge("clr-color-value"),g=ge("clr-hue-slider"),v=ge("clr-hue-marker"),b=ge("clr-alpha-slider"),y=ge("clr-alpha-marker"),_e(C.el),at(C.el),X(l,"mousedown",x=>{l.classList.remove("clr-keyboard-nav"),x.stopPropagation()}),X(c,"mousedown",x=>{X(o,"mousemove",qe)}),X(c,"touchstart",x=>{o.addEventListener("touchmove",qe,{passive:!1})}),X(d,"mousedown",x=>{X(o,"mousemove",qe)}),X(d,"touchstart",x=>{o.addEventListener("touchmove",qe,{passive:!1})}),X(p,"change",x=>{let R=p.value;if(f||C.inline){let z=R===""?R:yt(R);Ke(z)}}),X(h,"click",x=>{Ke(""),Ve()}),X(m,"click",x=>{Ke(),Ve()}),X(ge("clr-format"),"click",".clr-format input",x=>{T=x.target.value,cr(),Ke()}),X(l,"click",".clr-swatches button",x=>{yt(x.target.textContent),Ke(),C.swatchesOnly&&Ve()}),X(o,"mouseup",x=>{o.removeEventListener("mousemove",qe)}),X(o,"touchend",x=>{o.removeEventListener("touchmove",qe)}),X(o,"mousedown",x=>{S=!1,l.classList.remove("clr-keyboard-nav"),Ve()}),X(o,"keydown",x=>{let R=x.key,z=x.target,M=x.shiftKey;if(R==="Escape"?Ve(!0):["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(R)&&(S=!0,l.classList.add("clr-keyboard-nav")),R==="Tab"&&z.matches(".clr-picker *")){let N=Mi(),Q=N.shift(),Oe=N.pop();M&&z===Q?(Oe.focus(),x.preventDefault()):!M&&z===Oe&&(Q.focus(),x.preventDefault())}}),X(o,"click",".clr-field button",x=>{se&&We(),x.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),X(d,"keydown",x=>{let R={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(R).includes(x.key)&&(lr(...R[x.key]),x.preventDefault())}),X(c,"click",qe),X(g,"input",Xs),X(b,"input",Qs))}function Mi(){return Array.from(l.querySelectorAll("input, button")).filter(z=>!!z.offsetWidth)}function ge(x){return o.getElementById(x)}function X(x,R,z,M){let A=Element.prototype.matches||Element.prototype.msMatchesSelector;typeof z=="string"?x.addEventListener(R,N=>{A.call(N.target,z)&&M.call(N.target,N)}):(M=z,x.addEventListener(R,M))}function dr(x,R){R=R!==r?R:[],o.readyState!=="loading"?x(...R):o.addEventListener("DOMContentLoaded",()=>{x(...R)})}NodeList!==r&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);function aa(x,R){f=R,P=f.value,de(R),T=Yt(x),st(),yt(x),Ke(),P!==x&&f.dispatchEvent(new Event("change",{bubbles:!0}))}let vn=(()=>{let x={init:sa,set:oe,wrap:at,close:Ve,setInstance:fe,setColor:aa,removeInstance:Se,updatePosition:st,ready:dr};function R(z){dr(()=>{z&&(typeof z=="string"?_e(z):oe(z))})}for(let z in x)R[z]=function(){for(var M=arguments.length,A=new Array(M),N=0;N<M;N++)A[N]=arguments[N];dr(x[z],A)};return dr(()=>{s.addEventListener("resize",z=>{R.updatePosition()}),s.addEventListener("scroll",z=>{R.updatePosition()})}),R})();return vn.coloris=vn,vn})(window,document,Math)})(),ks=bt.coloris,Rs=bt.init,sw=bt.set,aw=bt.wrap,wi=bt.close,lw=bt.setInstance,cw=bt.removeInstance,dw=bt.updatePosition;var ll=s=>(o,e)=>new Ci(s,o,e),nt=ll,Ci=class{constructor(o,e,r){this.sourceFactory=o;this.startPoint=e;this.viewport=r;this.builder=o(e,r),this.points=[e]}getBBox(){return this.builder.getBBox()}build(){return this.builder.build()}preview(o){this.builder.preview(o)}addPoint(o){this.points.push(o),this.builder.addPoint(o)}async autocorrectShape(){let o=i=>({...i,pos:this.viewport.snapToGrid(i.pos)}),e=o(this.startPoint),r=this.sourceFactory(e,this.viewport),n=this.points.map(i=>o(i));for(let i of n)r.addPoint(i);return r.build()}};var sn=nt((s,o)=>new nn(s,o)),nn=class{constructor(o,e){this.startPoint=o;this.viewport=e;this.endPoint=o}getLineWidth(){return Math.max(this.endPoint.width,this.startPoint.width)}getBBox(){return this.buildPreview().getBBox()}buildPreview(){let o=this.startPoint.pos,e=this.endPoint.pos,r=e.minus(o).normalized(),n=e.distanceTo(o),i=Math.min(this.getLineWidth(),n/2),a=this.startPoint.width/2,l=this.endPoint.width/2,c=e.minus(r.times(i)),d=r.orthog(),u=d.times(a),p=d.times(l),h=new $(c.minus(p),[{kind:0,point:o.minus(u)},{kind:0,point:o.plus(u)},{kind:0,point:c.plus(p)},{kind:0,point:c.plus(d.times(i).plus(p))},{kind:0,point:e.plus(r.times(l))},{kind:0,point:c.plus(d.times(-i).minus(p))},{kind:0,point:c.minus(p)}]).mapPoints(g=>this.viewport.roundPoint(g));return new ee([{startPoint:h.startPoint,commands:h.parts,style:{fill:this.startPoint.color}}])}build(){return this.buildPreview()}preview(o){this.buildPreview().render(o)}addPoint(o){this.endPoint=o}};var ln=nt((s,o)=>new an(s,o)),an=class{constructor(o,e){this.startPoint=o;this.viewport=e;this.endPoint=o}getBBox(){return this.buildPreview().getBBox()}buildPreview(){let o=this.startPoint.pos,e=this.endPoint.pos,r=e.minus(o).normalized(),n=this.startPoint.width/2,i=this.endPoint.width/2,a=r.orthog(),l=a.times(n),c=a.times(i),d=o.minus(l),u=new $(d,[{kind:0,point:o.plus(l)},{kind:0,point:e.plus(c)},{kind:0,point:e.minus(c)},{kind:0,point:o.minus(l)}]).mapPoints(h=>this.viewport.roundPoint(h));return new ee([Z(u,{fill:this.startPoint.color})])}build(){return this.buildPreview()}preview(o){this.buildPreview().render(o)}addPoint(o){this.endPoint=o}};var cn=nt((s,o)=>new Jo(s,!0,o)),dn=nt((s,o)=>new Jo(s,!1,o)),Jo=class{constructor(o,e,r){this.startPoint=o;this.filled=e;this.viewport=r;this.endPoint=o}getBBox(){return this.buildPreview().getBBox()}buildPreview(){let o=this.viewport.getRotationAngle(),e=k.zRotation(-o),r=e.inverse().transformVec2(this.startPoint.pos),n=e.inverse().transformVec2(this.endPoint.pos),i=I.fromCorners(r,n),a=$.fromRect(i,this.filled?null:this.endPoint.width).transformedBy(e).mapPoints(c=>this.viewport.roundPoint(c));return new ee([Z(a,{fill:this.endPoint.color})])}build(){return this.buildPreview()}preview(o){this.buildPreview().render(o)}addPoint(o){this.endPoint=o}};var un=nt((s,o)=>new Ti(s,o)),Ti=class{constructor(o,e){this.startPoint=o;this.viewport=e;this.endPoint=o}getBBox(){return this.buildPreview().getBBox()}buildPreview(){let o=[],r=Math.PI*2/6,n=U.roundPoint(this.endPoint.width,5/this.viewport.getScaleFactor()),i=this.startPoint.pos.lerp(this.endPoint.pos,.5),l=this.endPoint.pos.minus(i).length()-n/2,c=i.plus(w.of(l,0));for(let p=r;p<=Math.PI*2;p+=r){let h=w.of(l*Math.cos(p),-l*Math.sin(p)).plus(i),g=w.of(Math.cos(p-r/2),-Math.sin(p-r/2)).times(l*1.141).plus(i);o.push({kind:3,controlPoint:g,endPoint:h})}o.push({kind:0,point:c});let d=new $(c,o).mapPoints(p=>this.viewport.roundPoint(p));return new ee([Z(d,{fill:L.transparent,stroke:{width:n,color:this.endPoint.color}})])}build(){return this.buildPreview()}preview(o){this.buildPreview().render(o)}addPoint(o){this.endPoint=o}};var zs=(s,o)=>{let e=document.createElement("span"),r=document.createElement("span"),n=document.createElement("input");n.type="button",n.classList.add("coloris_input"),e.classList.add("color-input-container"),r.classList.add("color-input-wrapper"),r.appendChild(n),e.appendChild(r);let i=cl(s,e,h=>{n.value=h.toHexString(),c();let m=n.parentElement;m&&m.classList.contains("clr-field")&&(m.style.color=n.value)}),a,l=()=>{a=L.fromHex(n.value)},c=()=>{l(),a&&(s.announceForAccessibility(s.localization.colorChangedAnnouncement(a.toHexString())),o(a),s.notifier.dispatch(12,{kind:12,color:a}))};n.oninput=l;let d=!1;n.addEventListener("open",()=>{d=!0,s.notifier.dispatch(11,{kind:11,open:!0}),i.cancel(),e.classList.add("picker-open"),document.querySelector("#clr-picker #clr-hue-slider")?.focus()});let u=()=>{d=!1,s.notifier.dispatch(11,{kind:11,open:!1}),c(),n.focus(),e.classList.remove("picker-open")};return n.addEventListener("close",()=>{u()}),{input:n,container:e,setValue:h=>{typeof h=="object"&&(h=h.toHexString()),n.value=h,n.dispatchEvent(new Event("input",{bubbles:!0}))},closePicker:()=>{d&&c()},registerWithHelpTextDisplay:h=>{h.registerTextHelpForElement(r,s.localization.colorPickerToggleHelpText),i.registerWithHelpTextDisplay(h)}}},cl=(s,o,e)=>{let r=document.createElement("button");r.classList.add("pipetteButton"),r.title=s.localization.pickColorFromScreen,r.setAttribute("alt",r.title);let n=document.createElement("span");n.classList.add("pickColorInstructions"),n.innerText=s.localization.clickToPickColorAnnouncement;let i=u=>{r.replaceChildren(s.icons.makePipetteIcon(u),n)};i();let a=s.toolController.getMatchingTools(Mt)[0],l=()=>{a?.clearColorListener(),i(),r.classList.remove("active")},c=u=>{l(),u&&e(u)},d=u=>{u?i(u):i()};return r.onclick=()=>{if(r.classList.contains("active")){l(),s.announceForAccessibility(s.localization.colorSelectionCanceledAnnouncement);return}a?.setColorListener(d,c),a&&(r.classList.add("active"),s.announceForAccessibility(s.localization.clickToPickColorAnnouncement))},o.appendChild(r),{cancel:()=>{l()},registerWithHelpTextDisplay:u=>{u.registerTextHelpForElement(r,s.localization.colorPickerPipetteHelpText)}}},vt=zs;var dl=()=>{let s=[...document.querySelectorAll("*:focus")];return s.length&&s.some(o=>o.classList.contains(`${D}button`))},ye=class extends ae{constructor(e,r,n,i){super(e,n,i);this.targetTool=r;this.targetTool.enabledValue().onUpdateAndNow(a=>{a?(this.setSelected(!0),dl()&&this.focus()):(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(e){return this.isSelected()&&e.code==="Space"&&this.hasDropdown?(this.handleClick(),!0):!1}addTo(e){let r=super.addTo(e);return this.setSelected(this.targetTool.isEnabled()),r}};var Si="jsdraw.toolbar.SelectionTool.resizeImageToSelection";H.registerDefaultKeyboardShortcut(Si,["ctrlOrMeta+r"],"Resize image to selection");var er=[1,2,3,4,5,6,7,8,9].map(s=>`jsdraw.toolbar.PenTool.select-pen-${s}`);for(let s=0;s<er.length;s++){let o=er[s];H.registerDefaultKeyboardShortcut(o,[`CtrlOrMeta+Digit${s+1}`],"Select pen style "+(s+1))}var Pi="jsdraw.toolbar.SaveActionWidget.save";H.registerDefaultKeyboardShortcut(Pi,["ctrlOrMeta+KeyS"],"Save");var Ei="jsdraw.toolbar.ExitActionWidget.exit";H.registerDefaultKeyboardShortcut(Ei,["Alt+KeyQ"],"Exit");var ul=0,pl=(s,o)=>{let e=document.createElement("div"),r=document.createElement("label"),n=document.createElement("input");e.classList.add(`${D}thicknessSliderContainer`),n.id=`${D}thicknessInput${ul++}`,r.innerText=s.localization.thicknessLabel,r.setAttribute("for",n.id);let i=c=>Math.log10(c),a=c=>10**c;n.type="range",n.oninput=()=>{o(a(parseFloat(n.value)))},e.appendChild(r),e.appendChild(n);let l=(c,d)=>{let u=(m,g)=>(g?Math.ceil:Math.floor)(m*100)/100,p=u(i(c),!1),h=u(i(d),!0);n.min=`${p}`,n.max=`${h}`,n.step=`${pe((h-p)/20)}`};return l(2,262),{container:e,addTo:c=>{c.appendChild(e)},setBounds:l,setValue:c=>{n.value=i(c).toString()}}},pn=pl;var hl=s=>{let o=(e,r,n,i)=>{let a=r!==i&&e!==0,l=n+e<=0,d=n+r+e>i;return a&&!l&&!d};s.onwheel=e=>{let r=o(e.deltaX,s.clientWidth,s.scrollLeft,s.scrollWidth),n=o(e.deltaY,s.clientHeight,s.scrollTop,s.scrollHeight);(r||n)&&e.stopPropagation()}},fo=hl;var ki=0,ml=(s,o,e)=>{let r=document.createElement("div");r.classList.add(`${D}grid-selector`);let n=te.fromInitialValue(o),i=document.createElement("div");i.setAttribute("role","menu"),i.id=`${D}-grid-select-id-${ki++}`,fo(i);let a=document.createElement("label");a.textContent=s,a.htmlFor=i.id,r.appendChild(a);let l=`${D}-grid-selector-${ki++}`,c=p=>{let h=document.createElement("div");h.classList.add("choice-button");let m=document.createElement("input");m.type="radio",m.id=`${D}-grid-select-button-${ki++}`,gt(h);let g=document.createElement("label"),v=()=>{g.setAttribute("title",p.title);let P=document.createElement("span");P.classList.add("button-label-text");let S=p.makeIcon();S.classList.add("icon"),P.innerText=p.title,g.htmlFor=m.id,g.replaceChildren(S,P)};v();let b=()=>{m.name=l};b();let y=()=>{m.checked?h.classList.add("checked"):h.classList.remove("checked")};m.oninput=()=>{m.checked&&n.set(p.id),y()},m.onfocus=()=>{h.querySelector(":focus-visible")&&h.classList.add("focus-visible")},m.onblur=()=>{h.classList.remove("focus-visible")},h.oncontextmenu=P=>{P.preventDefault()},h.replaceChildren(m,g),i.appendChild(h);let f=P=>{m.checked=P,y()};return f(!1),{choiceRecord:p,setChecked:f,updateIcon:()=>{v()},updateButtonRadiogroupName:b}},d=[];for(let p of e)d.push(c(p));r.appendChild(i),n.onUpdateAndNow(p=>{for(let h=0;h<d.length;h++)d[h].setChecked(d[h].choiceRecord.id===p)});let u={value:n,_radiogroupName:l,linkWith:p=>{u._radiogroupName=p._radiogroupName,l=p._radiogroupName;for(let h of d)h.updateButtonRadiogroupName()},updateIcons:()=>{d.forEach(p=>p.updateIcon())},getRootElement(){return r},addTo:p=>{p.appendChild(r)}};return u},Ri=ml;var Wt=class s extends ye{constructor(e,r,n){super(e,r,"pen",n);this.tool=r;this.updateInputs=()=>{};this.shapelikeIDs=["pressure-sensitive-pen","freehand-pen"];let i=e.getCurrentSettings().pens?.additionalPenTypes??[],a=e.getCurrentSettings().pens?.filterPenTypes??(()=>!0);this.penTypes=[{name:this.localizationTable.flatTipPen,id:"pressure-sensitive-pen",factory:Vt},{name:this.localizationTable.roundedTipPen,id:"freehand-pen",factory:Qe},{name:this.localizationTable.roundedTipPen2,id:"polyline-pen",factory:ft},...i.filter(l=>!l.isShapeBuilder),{name:this.localizationTable.arrowPen,id:"arrow",isShapeBuilder:!0,factory:sn},{name:this.localizationTable.linePen,id:"line",isShapeBuilder:!0,factory:ln},{name:this.localizationTable.filledRectanglePen,id:"filled-rectangle",isShapeBuilder:!0,factory:cn},{name:this.localizationTable.outlinedRectanglePen,id:"outlined-rectangle",isShapeBuilder:!0,factory:dn},{name:this.localizationTable.outlinedCirclePen,id:"outlined-circle",isShapeBuilder:!0,factory:un},...i.filter(l=>l.isShapeBuilder)].filter(a),this.editor.notifier.on(2,l=>{if(l.kind!==2)throw new Error("Invalid event type!");l.tool===this.tool&&(this.updateIcon(),this.updateInputs())})}static{this.idCounter=0}getTitle(){return this.targetTool.description}getCurrentPenTypeIdx(){let e=this.tool.getStrokeFactory();for(let r=0;r<this.penTypes.length;r++)if(this.penTypes[r].factory===e)return r;return-1}getCurrentPenType(){for(let e of this.penTypes)if(e.factory===this.tool.getStrokeFactory())return e;return null}createIconForRecord(e){let r={...this.tool.getStyleValue().get()};e?.factory&&(r.factory=e.factory);let n=e?.factory;return!n||n===Qe||n===Vt||n===ft?this.editor.icons.makePenIcon(r):this.editor.icons.makeIconFromFactory(r)}createIcon(){return this.createIconForRecord(this.getCurrentPenType())}createPenTypeSelector(e){let r=this.penTypes.map((d,u)=>({id:u,makeIcon:()=>this.createIconForRecord(d),title:d.name,isShapeBuilder:d.isShapeBuilder??!1})),n=r.filter(d=>!d.isShapeBuilder),i=Ri(this.localizationTable.selectPenType,this.getCurrentPenTypeIdx(),n),a=r.filter(d=>d.isShapeBuilder),l=Ri(this.localizationTable.selectShape,this.getCurrentPenTypeIdx(),a),c=d=>{this.tool.setStrokeFactory(this.penTypes[d].factory)};return i.value.onUpdate(c),l.value.onUpdate(c),e?.registerTextHelpForElements([i.getRootElement(),l.getRootElement()],this.localizationTable.penDropdown__penTypeHelpText),{setValue:d=>{i.value.set(d),l.value.set(d)},updateIcons:()=>{i.updateIcons(),l.updateIcons()},addTo:d=>{n.length&&i.addTo(d),a.length&&l.addTo(d)}}}createStrokeCorrectionOptions(e){let r=document.createElement("div");r.classList.add("action-button-row",`${D}-pen-tool-toggle-buttons`);let n=(l,c)=>{let d=document.createElement("button");d.classList.add(`${D}-toggle-button`);let u=c.cloneNode(!0);u.classList.add("icon");let p=document.createElement("span");p.innerText=l,d.replaceChildren(u,p),d.setAttribute("role","switch"),r.appendChild(d);let h=!1,m=v=>{},g={setChecked(v){h=v,d.setAttribute("aria-checked",`${h}`),m(h)},setOnInputListener(v){m=v},addHelpText(v){e?.registerTextHelpForElement(d,v)}};return d.onclick=()=>{g.setChecked(!h)},g},i=n(this.localizationTable.inputStabilization,this.editor.icons.makeStrokeSmoothingIcon());i.setOnInputListener(l=>{this.tool.setHasStabilization(l)});let a=n(this.localizationTable.strokeAutocorrect,this.editor.icons.makeShapeAutocorrectIcon());return a.setOnInputListener(l=>{this.tool.setStrokeAutocorrectEnabled(l)}),a.addHelpText(this.localizationTable.penDropdown__autocorrectHelpText),i.addHelpText(this.localizationTable.penDropdown__stabilizationHelpText),{update:()=>{i.setChecked(!!this.tool.getInputMapper()),a.setChecked(this.tool.getStrokeAutocorrectionEnabled())},addTo:l=>{l.appendChild(r)}}}getHelpText(){return this.localizationTable.penDropdown__baseHelpText}fillDropdown(e,r){let n=document.createElement("div");n.classList.add(`${D}spacedList`,`${D}nonbutton-controls-main-list`);let{container:i,setValue:a}=pn(this.editor,g=>{this.tool.setThickness(g)}),l=document.createElement("div"),c=document.createElement("label"),d=vt(this.editor,g=>{this.tool.setColor(g)}),{input:u,container:p}=d;u.id=`${D}colorInput${s.idCounter++}`,c.innerText=this.localizationTable.colorLabel,c.setAttribute("for",u.id),l.appendChild(c),l.appendChild(p);let h=this.createStrokeCorrectionOptions(r),m=this.createPenTypeSelector(r);return r?.registerTextHelpForElement(l,this.localizationTable.penDropdown__colorHelpText),r&&d.registerWithHelpTextDisplay(r),r?.registerTextHelpForElement(i,this.localizationTable.penDropdown__thicknessHelpText),this.updateInputs=()=>{d.setValue(this.tool.getColor()),a(this.tool.getThickness()),m.updateIcons(),m.setValue(this.getCurrentPenTypeIdx()),h.update()},this.updateInputs(),n.replaceChildren(l,i),m.addTo(n),e.replaceChildren(n),h.addTo(e),!0}onKeyPress(e){if(!this.isSelected())return!1;for(let r=0;r<er.length;r++){let n=er[r];if(this.editor.shortcuts.matchesShortcut(n,e)){let i=r;if(i<this.penTypes.length)return this.tool.setStrokeFactory(this.penTypes[i].factory),!0}}return!!super.onKeyPress(e)}serializeState(){return{...super.serializeState(),color:this.tool.getColor().toHexString(),thickness:this.tool.getThickness(),strokeFactoryId:this.getCurrentPenType()?.id,inputStabilization:!!this.tool.getInputMapper(),strokeAutocorrect:this.tool.getStrokeAutocorrectionEnabled()}}deserializeFrom(e){super.deserializeFrom(e);let r=(n,i)=>{let a=typeof e[n];if(a!==i)throw new Error(`Deserializing property ${n}: Invalid type. Expected ${i}, was ${a}.`)};if(e.color&&(r("color","string"),this.tool.setColor(L.fromHex(e.color))),e.thickness&&(r("thickness","number"),this.tool.setThickness(e.thickness)),e.strokeFactoryId){r("strokeFactoryId","string");let n=e.strokeFactoryId;for(let i of this.penTypes)if(n===i.id){this.tool.setStrokeFactory(i.factory);break}}e.inputStabilization!==void 0&&this.tool.setHasStabilization(!!e.inputStabilization),e.strokeAutocorrect!==void 0&&this.tool.setStrokeAutocorrectEnabled(!!e.strokeAutocorrect)}};var Kt=class s extends ye{constructor(e,r,n){super(e,r,"eraser-tool-widget",n);this.tool=r;this.updateInputs=()=>{};this.editor.notifier.on(2,i=>{i.kind===2&&i.tool===this.tool&&(this.updateInputs(),this.updateIcon())})}getHelpText(){return this.localizationTable.eraserDropdown__baseHelpText}getTitle(){return this.localizationTable.eraser}makeIconForType(e){return this.editor.icons.makeEraserIcon(this.tool.getThickness(),e)}createIcon(){return this.makeIconForType(this.tool.getModeValue().get())}static{this.idCounter=0}makeEraserTypeSelector(e){let r=document.createElement("div"),n=document.createElement("label"),i=document.createElement("input");i.id=`${D}eraserToolWidget-${s.idCounter++}`,n.htmlFor=i.id,n.innerText=this.localizationTable.fullStrokeEraser,i.type="checkbox",i.oninput=()=>{this.tool.getModeValue().set(i.checked?"full-stroke":"partial-stroke")};let a=()=>{i.checked=this.tool.getModeValue().get()==="full-stroke"};return r.replaceChildren(n,i),e?.registerTextHelpForElement(r,this.localizationTable.eraserDropdown__fullStrokeEraserHelpText),{addTo:l=>{l.appendChild(r)},updateValue:a}}fillDropdown(e,r){let n=document.createElement("div");n.classList.add(`${D}spacedList`,`${D}nonbutton-controls-main-list`);let i=pn(this.editor,l=>{this.tool.setThickness(l)});i.setBounds(10,55),r?.registerTextHelpForElement(i.container,this.localizationTable.eraserDropdown__thicknessHelpText);let a=this.makeEraserTypeSelector(r);return this.updateInputs=()=>{i.setValue(this.tool.getThickness()),a.updateValue()},this.updateInputs(),n.replaceChildren(i.container),a.addTo(n),e.replaceChildren(n),!0}serializeState(){return{...super.serializeState(),thickness:this.tool.getThickness(),mode:this.tool.getModeValue().get()}}deserializeFrom(e){if(super.deserializeFrom(e),e.thickness){let r=parseFloat(e.thickness);if(typeof r!="number"||!isFinite(r))throw new Error(`Deserializing property ${r} is not a number or is not finite.`);this.tool.setThickness(r)}if(e.mode){let r=e.mode;Object.values(ao).includes(r)&&this.tool.getModeValue().set(r)}}};var fl=(s="")=>{let o=document.createElement("div");return o.classList.add("tool-dropdown-separator"),o.innerText=s,{addTo:e=>{e.appendChild(o)}}},tr=fl;var gl=(s,o)=>{let e=document.createElement("div");e.classList.add("toolbar-button-grid"),e.style.setProperty("--column-count",`${o}`);let r=n=>{let i=document.createElement("button");i.classList.add("button");let a=n.icon();a.classList.add("icon");let l=document.createElement("label");return l.textContent=n.label,l.classList.add("button-label-text"),i.onclick=n.onClick,n.enabled&&n.enabled.onUpdateAndNow(c=>{i.disabled=!c}),i.replaceChildren(a,l),e.appendChild(i),gt(i),n.onCreated?.(i),i};return s.map(r),{container:e}},Ls=gl;var bl=(s,o,e)=>{let r=document.createElement("div");r.classList.add("selection-format-menu",`${D}spacedList`,`${D}indentedList`);let n=document.createElement("div"),i=document.createElement("label"),a=vt(s,u=>{let p=o.getSelection();if(p){let h=[];for(let g of p.getSelectedObjects())Vo(g)&&h.push(g.updateStyle({color:u}));let m=le(h);s.dispatch(m)}}),{input:l,container:c}=a;i.innerText=e.colorLabel;let d=()=>{let u=o.getSelection();if(u&&u.getSelectedItemCount()>0){l.disabled=!1,r.classList.remove("disabled");let p=[];for(let h of u.getSelectedObjects())if(Vo(h)){let m=h.getStyle().color;m&&p.push(m)}a.setValue(L.average(p))}else l.disabled=!0,r.classList.add("disabled"),a.setValue(L.transparent)};return n.replaceChildren(i,c),r.replaceChildren(n),{addTo:u=>{u.appendChild(r)},update:d,registerHelpText:u=>{u.registerTextHelpForElement(n,e.selectionDropdown__changeColorHelpText),a.registerWithHelpTextDisplay(u)}}},zi=class extends ae{constructor(e,r,n){super(e,"selection-mode-toggle",n);this.tool=r;e.notifier.on(2,i=>{i.kind===2&&i.tool===r&&this.setSelected(r.modeValue.get()==="lasso")}),this.setSelected(!1)}shouldAutoDisableInReadOnlyEditor(){return!1}setModeFlag(e){this.tool.modeValue.set(e?"lasso":"rect")}handleClick(){this.setModeFlag(!this.isSelected())}getTitle(){return this.localizationTable.selectionTool__lassoSelect}createIcon(){return this.editor.icons.makeSelectionIcon("lasso")}fillDropdown(e){return!1}getHelpText(){return this.localizationTable.selectionTool__lassoSelect__help}},Gt=class extends ye{constructor(e,r,n){super(e,r,"selection-tool-widget",n);this.tool=r;this.updateFormatMenu=()=>{};this.addSubWidget(new zi(e,r,this.localizationTable));let i=()=>{let a=this.tool.getSelection();return!!a&&a.getSelectedItemCount()>0};this.hasSelectionValue=te.fromInitialValue(i()),this.editor.notifier.on(2,a=>{if(a.kind!==2)throw new Error("Invalid event type!");a.tool===this.tool&&(this.hasSelectionValue.set(i()),this.updateFormatMenu())}),r.modeValue.onUpdate(()=>{this.updateIcon()})}resizeImageToSelection(){let e=this.tool.getSelection();e&&this.editor.dispatch(this.editor.setImportExportRect(e.region))}onKeyPress(e){return this.editor.shortcuts.matchesShortcut(Si,e)?(this.resizeImageToSelection(),!0):!!super.onKeyPress(e)}getTitle(){return this.localizationTable.select}createIcon(){return this.editor.icons.makeSelectionIcon(this.tool.modeValue.get())}getHelpText(){return this.localizationTable.selectionDropdown__baseHelpText}createSelectionActions(e){let r=this.editor.icons;return{container:Ls([{icon:()=>r.makeDeleteSelectionIcon(),label:this.localizationTable.deleteSelection,onCreated:i=>{e?.registerTextHelpForElement(i,this.localizationTable.selectionDropdown__deleteHelpText)},onClick:()=>{let i=this.tool.getSelection();this.editor.dispatch(i.deleteSelectedObjects()),this.tool.clearSelection()},enabled:this.hasSelectionValue},{icon:()=>r.makeDuplicateSelectionIcon(),label:this.localizationTable.duplicateSelection,onCreated:i=>{e?.registerTextHelpForElement(i,this.localizationTable.selectionDropdown__duplicateHelpText)},onClick:async()=>{let a=await this.tool.getSelection()?.duplicateSelectedObjects();a&&this.editor.dispatch(a)},enabled:this.hasSelectionValue},{icon:()=>r.makeResizeImageToSelectionIcon(),label:this.localizationTable.resizeImageToSelection,onCreated:i=>{e?.registerTextHelpForElement(i,this.localizationTable.selectionDropdown__resizeToHelpText)},onClick:()=>{this.resizeImageToSelection()},enabled:this.hasSelectionValue}],3).container}}fillDropdown(e,r){super.fillDropdown(e,r);let n=document.createElement("div");n.classList.add(`${D}nonbutton-controls-main-list`),e.appendChild(n),tr().addTo(n);let i=this.createSelectionActions(r);n.appendChild(i.container),tr(this.localizationTable.reformatSelection).addTo(n);let a=bl(this.editor,this.tool,this.localizationTable);return a.addTo(n),this.updateFormatMenu=()=>a.update(),r&&a.registerHelpText(r),a.update(),!0}serializeState(){return{...super.serializeState(),selectionMode:this.tool.modeValue.get()}}deserializeFrom(e){super.deserializeFrom(e),Object.values(Lt).includes(e.selectionMode)&&this.tool.modeValue.set(e.selectionMode)}};var jt=class s extends ye{constructor(e,r,n){super(e,r,"text-tool-widget",n);this.tool=r;this.updateDropdownInputs=null;e.notifier.on(2,i=>{i.kind===2&&i.tool===r&&(this.updateIcon(),this.updateDropdownInputs?.())})}getTitle(){return this.targetTool.description}createIcon(){let e=this.tool.getTextStyle();return this.editor.icons.makeTextIcon(e)}static{this.idCounter=0}fillDropdown(e){let r=document.createElement("div");r.classList.add(`${D}spacedList`,`${D}nonbutton-controls-main-list`);let n=document.createElement("div"),i=document.createElement("div"),a=document.createElement("div"),l=document.createElement("select"),c=document.createElement("label"),d=document.createElement("input"),u=document.createElement("label"),{input:p,container:h,setValue:m}=vt(this.editor,f=>{this.tool.setColor(f)}),g=document.createElement("label"),v=new Set,b=f=>{let T=document.createElement("option");T.value=f,T.textContent=f,l.appendChild(T),v.add(f)};d.setAttribute("type","number"),d.min="1",d.max="128",c.innerText=this.localizationTable.fontLabel,g.innerText=this.localizationTable.colorLabel,u.innerText=this.localizationTable.textSize,p.id=`${D}-text-color-input-${s.idCounter++}`,g.setAttribute("for",p.id),d.id=`${D}-text-size-input-${s.idCounter++}`,u.setAttribute("for",d.id);let y=this.editor.getCurrentSettings().text?.fonts??[];for(let f of y)b(f);return l.classList.add("font-selector"),l.id=`${D}-text-font-input-${s.idCounter++}`,c.setAttribute("for",l.id),l.onchange=()=>{this.tool.setFontFamily(l.value)},d.onchange=()=>{let f=parseInt(d.value);!isNaN(f)&&f>0&&this.tool.setFontSize(f)},i.appendChild(g),i.appendChild(h),n.appendChild(c),n.appendChild(l),a.appendChild(u),a.appendChild(d),this.updateDropdownInputs=()=>{let f=this.tool.getTextStyle();m(f.renderingStyle.fill),v.has(f.fontFamily)||b(f.fontFamily),l.value=f.fontFamily,d.value=`${f.size}`},this.updateDropdownInputs(),r.replaceChildren(i,a,n),e.appendChild(r),!0}serializeState(){let e=this.tool.getTextStyle();return{...super.serializeState(),fontFamily:e.fontFamily,textSize:e.size,color:e.renderingStyle.fill.toHexString()}}deserializeFrom(e){e.fontFamily&&typeof e.fontFamily=="string"&&this.tool.setFontFamily(e.fontFamily),e.color&&typeof e.color=="string"&&this.tool.setColor(L.fromHex(e.color)),e.textSize&&typeof e.textSize=="number"&&this.tool.setFontSize(e.textSize),super.deserializeFrom(e)}};var vl=(s,o,e)=>{let r=document.createElement("div"),n=document.createElement("button"),i=document.createElement("button"),a=document.createElement("button"),l=document.createElement("span");n.innerText="+",i.innerText="-",a.innerText=s.resetView,r.replaceChildren(l,n,i,a),r.classList.add(`${D}zoomLevelEditor`),l.classList.add("zoomDisplay");let c,d=()=>{let p=o.viewport.getScaleFactor()*100;p>.1?p=Math.round(p*10)/10:p=Math.round(p*1e3)/1e3,p!==c&&(l.textContent=s.zoomLevel(p),c=p)};d(),o.notifier.on(7,p=>{p.kind===7&&(d(),a.disabled=p.newTransform.eq(k.identity))});let u=p=>{let h=o.viewport.visibleRect.center,m=k.scaling2D(p,h);o.dispatch(U.transformBy(m),!1)};return n.onclick=()=>{u(5/4)},i.onclick=()=>{u(4/5)},a.onclick=()=>{o.dispatch(U.transformBy(o.viewport.canvasToScreenTransform.inverse()),!1)},e?.registerTextHelpForElement(n,s.handDropdown__zoomInHelpText),e?.registerTextHelpForElement(i,s.handDropdown__zoomOutHelpText),e?.registerTextHelpForElement(a,s.handDropdown__resetViewHelpText),e?.registerTextHelpForElement(l,s.handDropdown__zoomDisplayHelpText),r},hn=class extends ae{constructor(e,r,n,i,a,l,c){super(e,`pan-mode-${n}`,c);this.tool=r;this.flag=n;this.makeIcon=i;this.title=a;this.helpText=l;e.notifier.on(2,d=>{if(d.kind===2&&d.tool===r){let u=!!(r.getMode()&8);this.setSelected(!!(r.getMode()&n)||u),this.setDisabled(u&&n!==8)}}),this.setSelected(!1)}shouldAutoDisableInReadOnlyEditor(){return!1}setModeFlag(e){this.tool.setModeEnabled(this.flag,e)}handleClick(){this.setModeFlag(!this.isSelected())}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(e){return!1}getHelpText(){return this.helpText}},_t=class s extends ye{constructor(o,e,r){let n=o.toolController.getPrimaryTools().includes(e),i=(n?e:s.getPrimaryHandTool(o.toolController))??e;super(o,i,"hand-tool-widget",r),this.overridePanZoomTool=(n?s.getOverrideHandTool(o.toolController):e)??e,this.allowTogglingBaseTool=i!==null,this.allowTogglingBaseTool||this.container.classList.add("dropdownShowable");let a=new hn(o,this.overridePanZoomTool,1,()=>this.editor.icons.makeTouchPanningIcon(),r.touchPanning,r.handDropdown__touchPanningHelpText,r),l=new hn(o,this.overridePanZoomTool,32,()=>this.editor.icons.makeRotationLockIcon(),r.lockRotation,r.handDropdown__lockRotationHelpText,r);this.addSubWidget(a),this.addSubWidget(l)}static getPrimaryHandTool(o){return o.getPrimaryTools().filter(n=>n instanceof Ce)[0]}static getOverrideHandTool(o){return o.getMatchingTools(Ce)[0]}shouldAutoDisableInReadOnlyEditor(){return!1}getTitle(){return this.localizationTable.handTool}createIcon(){return this.editor.icons.makeHandToolIcon()}handleClick(){this.allowTogglingBaseTool?super.handleClick():this.setDropdownVisible(!this.isDropdownVisible())}getHelpText(){return this.localizationTable.handDropdown__baseHelpText}fillDropdown(o,e){super.fillDropdown(o,e);let r=document.createElement("div");r.classList.add(`${D}nonbutton-controls-main-list`),tr().addTo(r);let n=vl(this.localizationTable,this.editor,e);return r.appendChild(n),o.appendChild(r),!0}setSelected(o){this.allowTogglingBaseTool&&super.setSelected(o)}serializeState(){let o=this.overridePanZoomTool.getMode();return{...super.serializeState(),touchPanning:o&1,rotationLocked:o&32}}deserializeFrom(o){o.touchPanning!==void 0&&this.overridePanZoomTool.setModeEnabled(1,!!o.touchPanning),o.rotationLocked!==void 0&&this.overridePanZoomTool.setModeEnabled(32,!!o.rotationLocked),super.deserializeFrom(o)}};var Ue=class extends ae{constructor(e,r,n,i,a,l,c=!1,d=!0){super(e,r,l);this.makeIcon=n;this.title=i;this.clickAction=a;this.mustBeToplevel=c;this.#e=d}#e;#t=void 0;setHelpText(e){this.#t=e}getHelpText(){return this.#t}shouldAutoDisableInReadOnlyEditor(){return this.#e}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(e){return!1}mustBeInToplevelMenu(){return this.mustBeToplevel}};var yl=0,xl=(s,o,{accepts:e="*",allowMultiSelect:r=!1,customPickerAction:n}={})=>{let i=document.createElement("div"),a=document.createElement("label"),l=document.createElement("input"),c=document.createElement("div");c.classList.add("toolbar--file-input-description");let d=document.createElement("span");i.classList.add("toolbar--file-input-container"),a.appendChild(document.createTextNode(s)),l.accept=e,l.type=n?"button":"file",l.classList.add("file-input"),l.multiple=r;let u=`js-draw-file-input-${yl++}`;l.setAttribute("id",u),a.htmlFor=u;let p=o.icons.makeUploadFileIcon();p.classList.add("icon"),c.replaceChildren(p,d),a.appendChild(c),i.replaceChildren(a,l);let h=Tr.fromInitialValue([]),m=!1,g=null,v=()=>{let y=h.get();if(m){if(d.textContent=o.localization.fileInput__loading,g){let f=document.createElement("b");f.textContent=o.localization.cancel,f.classList.add("cancel-button"),d.appendChild(f)}p.style.display="none"}else if(y.length>0){let f=y.map(P=>P.name),T=5;if(f.length<=T)d.textContent=f.join(`
|
445
|
+
`);else{let P=f.slice(0,T-1);d.textContent=[...P,o.localization.fileInput__andNMoreFiles(f.length-P.length)].join(`
|
446
|
+
`)}p.style.display="none"}else{p.style.display="";let T=o.localization.dragAndDropHereOrBrowse.split(/[{]{2}(.*)[}]{2}/g);d.replaceChildren();for(let P=0;P<T.length;P++)if(P%2===1){let S=document.createElement("b");S.textContent=T[P],d.appendChild(S)}else d.appendChild(document.createTextNode(T[P]))}};if((()=>{a.addEventListener("dragover",y=>{y.preventDefault(),a.classList.add("drag-target")}),a.addEventListener("dragenter",y=>{y.preventDefault(),a.classList.add("drag-target")}),a.addEventListener("dragleave",y=>{y.preventDefault();let f=y.relatedTarget;(!f||!a.contains(f))&&a.classList.remove("drag-target")}),a.addEventListener("drop",y=>{y.preventDefault(),a.classList.remove("drag-target");let f=[];y.dataTransfer&&f.push(...y.dataTransfer.files),h.set(f)}),l.addEventListener("change",()=>{let y=l.files??[];h.set([...y])})})(),n){let y=async()=>{if(m){g?.();return}i.classList.add("-loading"),m=!0,v();try{let f=await n({setOnCancelCallback:T=>{if(!m)throw new Error("Task already completed. Can't register cancel handler.");g=()=>{g=null,v(),T()},v()}});f&&h.set(f)}finally{i.classList.remove("-loading"),m=!1,v()}};l.onclick=y}return h.onUpdate(y=>{y.length===0&&l.files&&l.files.length>0&&(l.value=""),g?.()}),h.onUpdateAndNow(v),{container:i,input:l,selectedFiles:h,addTo:y=>{y.appendChild(i)}}},Is=xl;var wl=s=>{let o=s/1024,e=o/1024,r=e/1024,n="B",i=s;return r>=1?(i=r,n="GiB"):e>=1?(i=e,n="MiB"):o>=1&&(i=o,n="KiB"),{size:i,units:n}},Bs=wl;var or=class s{constructor(o,e,r){this.imageBase64Url=o;this.preview=e;this.onUrlUpdate=r;this.originalSrc=o,e.src=o}updateImageData(o){this.preview.src=o,this.imageBase64Url=o,this.onUrlUpdate()}decreaseSize(o=3/4){let e=document.createElement("canvas");e.width=this.preview.naturalWidth*o,e.height=this.preview.naturalHeight*o,e.getContext("2d")?.drawImage(this.preview,0,0,e.width,e.height);let n=this.originalSrc?.startsWith("data:image/jpeg;")?"image/jpeg":"image/png";this.updateImageData(e.toDataURL(n))}reset(){this.updateImageData(this.originalSrc)}isChanged(){return this.imageBase64Url!==this.originalSrc}isLarge(){return this.getBase64Url().length>125829.12}getBase64Url(){return this.imageBase64Url}getAltText(){return this.altText}setAltText(o){this.altText=o,this.preview.alt=o}static fromSrcAndPreview(o,e,r){return new s(o,e,r)}static fromRenderable(o,e){let r=new Image;r.src=o.base64Url;let n=new s(o.base64Url,r,e),i=o.label??o.image.getAttribute("alt");return i&&n.setAltText(i),{wrapper:n,preview:r}}};var Cl=s=>{let o=document.createElement("div");o.classList.add("toolbar-snapped-scroll-list");let e=document.createElement("div");e.classList.add("scroller");let r=te.fromInitialValue(0),n=null,i=()=>{let p=document.createElement("div");p.classList.add("page-markers"),p.setAttribute("tabindex","-1");let h=[];return j.union([r,s]).onUpdateAndNow(([g,v])=>{let b=!1;for(;v.length<h.length;)h.pop(),b=!0;let y;for(let f=0;f<v.length;f++){let T;if(f>=h.length){T=document.createElement("div");let S=document.createElement("div");S.classList.add("content"),T.replaceChildren(S),h.push(T),b=!0}else T=h[f];T.classList.add("marker"),f===g?(T.classList.add("-active"),y=T):T.classList.remove("-active");let P=f;T.onclick=()=>{c.get()[P]?.element?.scrollIntoView({block:"nearest",behavior:"smooth"})}}b&&p.replaceChildren(...h),y&&p.scrollHeight>o.clientHeight&&y.scrollIntoView({block:"nearest"}),h.length===1?p.classList.add("-one-element"):p.classList.remove("-one-element")}),p},a=()=>{n=new IntersectionObserver(p=>{for(let h of p)if(h.isIntersecting&&h.intersectionRatio>.7){let m=h.target.getAttribute("data-item-index");if(m===null)throw new Error("Could not find attribute data-item-index");let g=Number(m);r.set(g);break}},{root:e,threshold:.9})},l=()=>{n&&(n.disconnect(),r.set(0),n=null)},c=j.map(s,p=>p.map((h,m)=>{let g=document.createElement("div");return h.element.parentElement&&h.element.remove(),g.appendChild(h.element),g.classList.add("item"),g.setAttribute("data-item-index",`${m}`),{element:g,data:h.data}})),d=[];c.onUpdateAndNow(p=>{r.set(-1);for(let h of d)n?.unobserve(h.element);e.replaceChildren(),p.length>1?a():l(),p.length===0?o.classList.add("-empty"):o.classList.remove("-empty");for(let h of p)e.appendChild(h.element);if(r.set(0),n)for(let h of p)n.observe(h.element)});let u=j.map(r,p=>{let h=s.get();return 0<=p&&p<h.length?h[p].data:null});return fo(e),o.replaceChildren(i(),e),{container:o,visibleItem:u}},Ms=Cl;var Tl=async s=>{let o=[],e=new Image,r=await Gr(s);return r&&o.push({image:e,base64Url:r,transform:k.identity}),o},Ds=Tl;var qt=class s extends ae{constructor(o,e){e??=o.localization,super(o,"insert-image-widget",e),this.container.classList.add("dropdownShowable"),o.notifier.on(9,r=>{r.kind===9&&this.isDropdownVisible()&&this.updateInputs()}),this.images=te.fromInitialValue([]),this.images.onUpdateAndNow(()=>{this.onImageDataUpdate()})}getTitle(){return this.localizationTable.image}createIcon(){return this.editor.icons.makeInsertImageIcon()}setDropdownVisible(o){super.setDropdownVisible(o),this.isDropdownVisible()?this.updateInputs():this.selectedFiles?.set([])}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}static{this.nextInputId=0}fillDropdown(o){let e=document.createElement("div");e.classList.add("insert-image-widget-dropdown-content",`${D}spacedList`,`${D}nonbutton-controls-main-list`);let{container:r,selectedFiles:n}=Is(this.localizationTable.chooseFile,this.editor,{accepts:"image/*",allowMultiSelect:!0,customPickerAction:this.editor.getCurrentSettings().image?.showImagePicker}),i=document.createElement("div");this.imagesPreview=Ms(this.images),this.statusView=document.createElement("div");let a=document.createElement("div");a.classList.add("action-button-row"),this.statusView.classList.add("insert-image-image-status-view"),this.submitButton=document.createElement("button"),this.selectedFiles=n,this.imageAltTextInput=document.createElement("input");let l=document.createElement("label"),c=`insert-image-alt-text-input-${s.nextInputId++}`;return this.imageAltTextInput.setAttribute("id",c),l.htmlFor=c,l.innerText=this.localizationTable.inputAltText,this.imageAltTextInput.type="text",this.imageAltTextInput.placeholder=this.localizationTable.describeTheImage,this.statusView.setAttribute("aria-live","polite"),this.submitButton.innerText=this.localizationTable.submit,this.imagesPreview.visibleItem.onUpdateAndNow(()=>this.onImageDataUpdate()),this.imageAltTextInput.oninput=()=>{let d=this.imagesPreview.visibleItem.get();d&&(d.setAltText(this.imageAltTextInput.value),this.submitButton.style.display="")},this.selectedFiles.onUpdateAndNow(async d=>{if(d.length===0){this.images.set([]);return}let u=(await Promise.all(d.map(async p=>{let h;try{h=await Ds(p)}catch(m){console.error("Image load error",m);let g=this.localizationTable.imageLoadError(m);return this.statusView.innerText=g,[]}return h.map(m=>{let{wrapper:g,preview:v}=or.fromRenderable(m,()=>this.onImageDataUpdate());return{data:g,element:v}})}))).flat();this.images.set(u)}),i.replaceChildren(l,this.imageAltTextInput),a.replaceChildren(this.submitButton),e.replaceChildren(r,i,this.imagesPreview.container,this.statusView,a),o.replaceChildren(e),!0}onImageDataUpdate(){if(!this.imagesPreview)return;let o=this.imagesPreview.visibleItem.get(),e=o?.getBase64Url();this.imageAltTextInput.value=o?.getAltText()??"",e?(this.submitButton.disabled=!1,this.submitButton.style.display="",this.updateImageSizeDisplay()):(this.submitButton.disabled=!0,this.submitButton.style.display="none",this.statusView.innerText="",this.submitButton.disabled=!0),this.images.get().length<=1?this.submitButton.innerText=this.localizationTable.submit:this.submitButton.innerText=this.localizationTable.addAll}hideDialog(){this.setDropdownVisible(!1)}updateImageSizeDisplay(){let o=this.imagesPreview.visibleItem.get(),e=o?.getBase64Url()??"",{size:r,units:n}=Bs(e.length),i=document.createElement("span");i.innerText=this.localizationTable.imageSize(Math.round(r),n);let a=document.createElement("button");a.innerText=this.localizationTable.decreaseImageSize,a.onclick=()=>{o?.decreaseSize()};let l=document.createElement("button");l.innerText=this.localizationTable.resetImage,l.onclick=()=>{o?.reset()},this.statusView.replaceChildren(i),o?.isLarge()?this.statusView.appendChild(a):o?.isChanged()?this.statusView.appendChild(l):this.images.get().some(d=>d.data?.isChanged()||d.data?.isLarge())&&(a.disabled=!0,this.statusView.appendChild(a))}updateInputs(){(()=>{this.selectedFiles?.set([]),this.imageAltTextInput.value="",this.submitButton.disabled=!0,this.statusView.innerText="",this.submitButton.style.display=""})();let e=this.editor.toolController.getMatchingTools(ve),r=e.map(i=>i.getSelectedObjects()).flat(),n=null;if(r.length===1&&r[0]instanceof be){n=r[0];let i=new Image,a=or.fromSrcAndPreview(n.getURL(),i,()=>this.onImageDataUpdate());a.setAltText(n.getAltText()??""),this.images.set([{data:a,element:i}])}else r.length>0&&e.forEach(i=>i.clearSelection());this.submitButton.style.display="none",this.submitButton.onclick=async()=>{let i=[],a=k.identity,l=null;for(let{data:c}of this.images.get()){if(!c)continue;let d=new Image;d.src=c.getBase64Url();let u=c.getAltText();u&&d.setAttribute("alt",u);let p;try{p=await be.fromImage(d,a)}catch(g){console.error("Error loading image",g),this.statusView.innerText=this.localizationTable.imageLoadError(g);return}let h=p.getBBox();if(h.area===0){this.statusView.innerText=this.localizationTable.errorImageHasZeroSize;return}i.push(p),l??=h,l.union(h);let m=w.of(0,h.height);a=a.rightMul(k.translation(m))}if(i.length){if(!l)throw new Error("Logic error: Full bounding box must be calculated when components are to be added.");if(this.hideDialog(),n){let c=new J([n]),d=n.getTransformation(),u=n.getBBox().width||1,p=l.transformedBoundingBox(d).width||1,h=k.scaling2D(u/p),m=[];for(let g of i)m.push(q.addElement(g),g.transformBy(d.rightMul(h)),g.setZIndex(n.getZIndex()));this.editor.dispatch(le([...m,c])),e[0]?.setSelection(i)}else await this.editor.addAndCenterComponents(i)}}}};var Zt=class s extends ae{constructor(e,r){super(e,"document-properties-widget",r);this.updateDropdownContent=()=>{};this.dropdownUpdateQueued=!1;this.container.classList.add("dropdownShowable"),this.editor.notifier.on(3,()=>{this.queueDropdownUpdate()}),this.editor.image.notifier.on(0,()=>{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(e){this.editor.dispatch(this.editor.setBackgroundColor(e))}getBackgroundColor(){return this.editor.estimateBackgroundColor()}removeBackgroundComponents(){let e=[];for(let r of this.editor.image.getBackgroundComponents())r instanceof ce&&e.push(r);return new J(e)}setBackgroundType(e){let r=this.editor.estimateBackgroundColor(),n=new ce(e,r),i=this.editor.image.addElement(n);return le([this.removeBackgroundComponents(),i])}getBackgroundType(){let e=this.editor.image.getBackgroundComponents();for(let r=e.length-1;r>=0;r--){let n=e[r];if(n instanceof ce)return n.getBackgroundType()}return 2}updateImportExportRectSize(e){let r=c=>(c!==void 0&&(!isFinite(c)||c<=0)&&(c=100),c),n=r(e.width),i=r(e.height),a=this.editor.getImportExportRect(),l=new I(a.x,a.y,n??a.w,i??a.h);this.editor.dispatch(this.editor.image.setImportExportRect(l)),this.editor.queueRerender()}getHelpText(){return this.localizationTable.pageDropdown__baseHelpText}static{this.idCounter=0}fillDropdown(e,r){let n=document.createElement("div");n.classList.add(`${D}spacedList`,`${D}nonbutton-controls-main-list`,`${D}document-properties-widget`);let i=()=>{let f=document.createElement("div"),T=document.createElement("label");T.innerText=this.localizationTable.backgroundColor;let{input:P,container:S,setValue:E,registerWithHelpTextDisplay:C}=vt(this.editor,O=>{O.eq(this.getBackgroundColor())||this.setBackgroundColor(O)});return P.id=`${D}docPropertiesColorInput-${s.idCounter++}`,T.htmlFor=P.id,f.replaceChildren(T,S),{setBgColorInputValue:E,backgroundColorRow:f,registerWithHelp:O=>{O&&(O?.registerTextHelpForElement(f,this.localizationTable.pageDropdown__backgroundColorHelpText),C(O))}}},{backgroundColorRow:a,setBgColorInputValue:l,registerWithHelp:c}=i(),d=(f,T)=>{let P=document.createElement("div"),S=document.createElement("label"),E=document.createElement("input");return E.id=`${D}docPropertiesCheckbox-${s.idCounter++}`,S.htmlFor=E.id,E.type="checkbox",S.innerText=f,E.oninput=()=>{T(E.checked)},P.replaceChildren(S,E),{container:P,checkbox:E}},{container:u,checkbox:p}=d(this.localizationTable.useGridOption,f=>{if(this.getBackgroundType()===1===f)return;let S=0;f&&(S=1),this.editor.dispatch(this.setBackgroundType(S))}),h=(f,T)=>{let P=document.createElement("div"),S=document.createElement("label"),E=document.createElement("input");return S.innerText=f,E.type="number",E.min="0",E.id=`${D}docPropertiesDimensionRow-${s.idCounter++}`,S.htmlFor=E.id,E.style.flexGrow="2",E.style.width="25px",E.oninput=()=>{T(parseFloat(E.value))},P.classList.add("js-draw-size-input-row"),P.replaceChildren(S,E),{setValue:C=>{if(document.activeElement===E&&E.value.match(/^0*$/)){let V=E.value;E.type="text",E.value=C.toString();let O=Math.max(1,E.value.length-V.length);E.setSelectionRange(0,O),E.type="number"}else E.value=C.toString()},setIsAutomaticSize:C=>{E.disabled=C;let V="size-input-row--automatic-size";C?P.classList.add(V):P.classList.remove(V)},element:P}},m=h(this.localizationTable.imageWidthOption,f=>{this.updateImportExportRectSize({width:f})}),g=h(this.localizationTable.imageHeightOption,f=>{this.updateImportExportRectSize({height:f})}),{container:v,checkbox:b}=d(this.localizationTable.enableAutoresizeOption,f=>{let T=this.editor.image;this.editor.dispatch(T.setAutoresizeEnabled(f))}),y=document.createElement("button");return y.classList.add("about-button"),y.innerText=this.localizationTable.about,y.onclick=()=>{this.editor.showAboutDialog()},c(r),r?.registerTextHelpForElement(u,this.localizationTable.pageDropdown__gridCheckboxHelpText),r?.registerTextHelpForElement(v,this.localizationTable.pageDropdown__autoresizeCheckboxHelpText),r?.registerTextHelpForElement(y,this.localizationTable.pageDropdown__aboutButtonHelpText),this.updateDropdownContent=()=>{l(this.getBackgroundColor());let f=this.editor.image.getAutoresizeEnabled(),T=this.editor.getImportExportRect();m.setValue(T.width),g.setValue(T.height),b.checked=f,m.setIsAutomaticSize(f),g.setIsAutomaticSize(f),p.checked=this.getBackgroundType()===1},this.updateDropdownContent(),n.replaceChildren(a,u,m.element,g.element,v,y),e.replaceChildren(n),!0}};var Li=class extends Ue{constructor(o,e,r,n={}){super(o,"save-button",()=>n.icon??o.icons.makeSaveIcon(),n.label??e.save,r),this.setTags(["save"])}shouldAutoDisableInReadOnlyEditor(){return!1}onKeyPress(o){return this.editor.shortcuts.matchesShortcut(Pi,o)?(this.clickAction(),!0):super.onKeyPress(o)}mustBeInToplevelMenu(){return!0}},As=Li;var Ii=class extends Ue{constructor(o,e,r,n={}){super(o,"exit-button",()=>n.icon??o.icons.makeCloseIcon(),n.label??e.exit,r),this.setTags(["exit"])}shouldAutoDisableInReadOnlyEditor(){return!1}onKeyPress(o){return this.editor.shortcuts.matchesShortcut(Ei,o)?(this.clickAction(),!0):super.onKeyPress(o)}mustBeInToplevelMenu(){return!0}},Vs=Ii;var it=class s{constructor(o,e=ro){this.editor=o;this.localizationTable=e;this.#e=[];this.#t={};this.#o=[];this.#r=null;this.closeColorPickerOverlay=null;s.colorisStarted||(Rs(),s.colorisStarted=!0),this.setupColorPickers()}#e;#t;#o;static{this.colorisStarted=!1}#r;setupCloseColorPickerOverlay(){this.closeColorPickerOverlay||(this.closeColorPickerOverlay=document.createElement("div"),this.closeColorPickerOverlay.className=`${D}closeColorPickerOverlay`,this.editor.createHTMLOverlay(this.closeColorPickerOverlay),this.#e.push(this.editor.handlePointerEventsExceptClicksFrom(this.closeColorPickerOverlay,o=>(o==="pointerdown"&&wi(),o==="pointerup"&&this.editor.focus(),!0))))}setupColorPickers(){if(this.#r){this.#r();return}this.setupCloseColorPickerOverlay();let o=12,e=[L.red.toHexString(),L.purple.toHexString(),L.blue.toHexString(),L.clay.toHexString(),L.black.toHexString(),L.white.toHexString()],r=e.length,n=!1,i=()=>{try{ks({el:".coloris_input",format:"hex",selectInput:!1,focusInput:!1,themeMode:"auto",swatches:e})}catch(l){console.warn("Failed to initialize Coloris. Error: ",l),n||(n=!0,document.addEventListener("load",()=>{i()},{once:!0}))}};i(),this.#r=i;let a=l=>{let c=!1;for(let d of e)d===l&&(c=!0);c||(e.push(l),e.length>o&&e.splice(r,1),i())};this.#e.push(this.editor.notifier.on(11,l=>{l.kind===11&&this.closeColorPickerOverlay&&(this.closeColorPickerOverlay.style.display=l.open?"block":"none")})),this.#e.push(this.editor.notifier.on(12,l=>{l.kind===12&&a(l.color.toHexString())}))}closeColorPickers(){wi?.()}getWidgetUniqueId(o){return o.getUniqueIdIn(this.#t)}getWidgetFromId(o){return this.#t[o]}getAllWidgets(){return this.#o}addWidget(o){let e=o.getUniqueIdIn(this.#t);this.#t[e]=o,this.#o.push(o),this.addWidgetInternal(o),this.setupColorPickers()}removeWidget(o){let e=o.getUniqueIdIn(this.#t);this.removeWidgetInternal(o),delete this.#t[e],this.#o=this.#o.filter(r=>r!==o)}static{this.rootToolbarId="root-toolbar--"}serializeState(){let o={};for(let e in this.#t)o[e]=this.#t[e].serializeState();return o[s.rootToolbarId]=this.serializeInternal(),JSON.stringify(o)}deserializeState(o){let e=JSON.parse(o);yr(e),Gi(e);let r=s.rootToolbarId;r in e&&typeof e[r]<"u"&&this.deserializeInternal(e[r]);for(let n in e)if(n!==r){if(!(n in this.#t)){console.warn(`Unable to deserialize widget ${n} \xAD\u2014 no such widget.`);continue}typeof e[n]=="object"&&e[n]&&this.#t[n].deserializeFrom(e[n])}}serializeInternal(){}deserializeInternal(o){}makeActionButton(o,e,r=!0){typeof r=="boolean"&&(r={mustBeToplevel:r});let n=r.mustBeToplevel??!0,i=r.autoDisableInReadOnlyEditors??!0,a=typeof o=="string"?o:o.label,l="action-button",c=()=>typeof o=="string"?null:o.icon;return new Ue(this.editor,l,c,a,e,this.editor.localization,n,i)}addActionButton(o,e,r=!0){let n=this.makeActionButton(o,e,r);return this.addWidget(n),n}addTaggedActionButton(o,e,r,n=!0){let i=this.makeActionButton(e,r,n);return i.setTags(o),this.addWidget(i),i}addSaveButton(o,e={}){let r=new As(this.editor,this.localizationTable,o,e);return this.addWidget(r),r}addExitButton(o,e={}){let r=new Vs(this.editor,this.localizationTable,o,e);return this.addWidget(r),r}addUndoRedoButtons(o=!0){let e=()=>this.addTaggedActionButton(["undo"],{label:this.localizationTable.undo,icon:this.editor.icons.makeUndoIcon()},()=>{this.editor.history.undo()}),r=()=>this.addTaggedActionButton(["redo"],{label:this.localizationTable.redo,icon:this.editor.icons.makeRedoIcon()},()=>{this.editor.history.redo()}),n,i;o?(n=e(),i=r()):(i=r(),n=e()),n.setDisabled(!0),i.setDisabled(!0),this.editor.notifier.on(3,a=>{if(a.kind!==3)throw new Error("Wrong event type!");n.setDisabled(a.undoStackSize===0),i.setDisabled(a.redoStackSize===0)})}addWidgetsForPrimaryTools(o){for(let e of this.editor.toolController.getPrimaryTools())if(!(o&&!o?.(e)))if(e instanceof Ne){let r=new Wt(this.editor,e,this.localizationTable);this.addWidget(r)}else e instanceof Je?this.addWidget(new Kt(this.editor,e,this.localizationTable)):e instanceof ve?this.addWidget(new Gt(this.editor,e,this.localizationTable)):e instanceof $e?this.addWidget(new jt(this.editor,e,this.localizationTable)):e instanceof Ce&&this.addWidget(new _t(this.editor,e,this.localizationTable))}addDefaultToolWidgets(){this.addWidgetsForPrimaryTools(),this.addDefaultEditorControlWidgets()}addDefaultEditorControlWidgets(){this.addWidget(new Zt(this.editor,this.localizationTable)),this.addWidget(new qt(this.editor,this.localizationTable))}addDefaultActionButtons(){this.addUndoRedoButtons()}remove(){this.closeColorPickerOverlay?.remove();for(let o of this.#e)o.remove();this.#e=[],this.onRemove();for(let o of this.#o)o.remove()}manageListener(o){this.#e.push(o)}};var Os=s=>new go(s,s.getRootElement(),s.localization),go=class extends it{constructor(e,r,n){super(e,n);this.clearDragListeners=null;this.toolbarContainer=document.createElement("div"),this.toolbarContainer.classList.add(`${D}root`),this.toolbarContainer.classList.add(`${D}element`),this.toolbarContainer.classList.add(`${D}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"),fo(this.toolbarToolRow),"ResizeObserver"in window?(this.toolRowResizeObserver=new ResizeObserver(a=>{this.onToolbarRowResize()}),this.toolRowResizeObserver.observe(this.toolbarToolRow)):console.warn("ResizeObserver not supported. Toolbar will not resize."),this.toolbarContainer.replaceChildren(this.toolbarActionRow,this.toolbarToolRow),r.appendChild(this.toolbarContainer),this.sidebarVisible=j.fromInitialValue(!1),this.sidebarY=j.fromInitialValue(0),this.menuContainer=document.createElement("div"),this.menuContainer.classList.add(`${D}edgemenu-container`),this.sidebarContainer=document.createElement("div"),this.sidebarContainer.classList.add(`${D}edgemenu`,`${D}element`),this.sidebarContainer.classList.add(`${D}tool-properties`),this.sidebarContent=document.createElement("div"),this.sidebarY.onUpdateAndNow(a=>{let l="dropdown-below-edge";a>0?(this.sidebarContainer.style.transform=`translate(0, ${a}px)`,this.sidebarContainer.style.paddingBottom="",this.menuContainer.classList.add(l)):(this.sidebarContainer.style.transform="",this.sidebarContainer.style.paddingBottom=`${-a}px`,this.menuContainer.classList.remove(l))}),this.closeButton=document.createElement("button"),this.closeButton.classList.add("drag-elem"),this.editor.handleKeyEventsFrom(this.closeButton,a=>a.code!=="Space"&&a.code!=="Enter"&&a.code!=="Tab"),this.sidebarContainer.addEventListener("keyup",a=>{!a.defaultPrevented&&a.code==="Escape"&&(this.sidebarVisible.set(!1),a.preventDefault())}),this.initDragListeners();let i=(...a)=>{this.sidebarContent.replaceChildren(...a),this.setupColorPickers()};this.sidebarTitle=te.fromInitialValue(""),this.layoutManager=new Qo(i,this.sidebarTitle,this.sidebarVisible,e.announceForAccessibility.bind(e),n),this.sidebarTitle.onUpdateAndNow(a=>{this.closeButton.setAttribute("aria-label",n.closeSidebar(a))}),this.listenForVisibilityChanges(),this.sidebarContainer.replaceChildren(this.closeButton,this.sidebarContent),this.menuContainer.replaceChildren(this.sidebarContainer),r.appendChild(this.menuContainer)}listenForVisibilityChanges(){let e=null,r=170;this.sidebarVisible.get()||(this.menuContainer.style.display="none",this.menuContainer.style.opacity="0");let n=window.matchMedia?.("(prefers-reduced-motion: reduce)")??"";this.sidebarVisible.onUpdate(i=>{let a=`${r}ms ease`,l=n.matches?"-reduce-motion":"";i?(this.sidebarY.set(this.snappedSidebarY()),e&&(clearTimeout(e),e=null),this.menuContainer.style.display="",this.sidebarContainer.style.animation=`${a} ${D}-edgemenu-transition-in${l}`,this.menuContainer.style.animation=`${a} ${D}-edgemenu-container-transition-in${l}`,this.menuContainer.style.opacity="1",this.closeButton.focus({preventScroll:!0})):(this.closeColorPickers(),e===null&&(this.sidebarContainer.style.animation=`${a} ${D}-edgemenu-transition-out${l}`,this.menuContainer.style.animation=`${a} ${D}-edgemenu-container-transition-out${l}`,this.menuContainer.style.opacity="0",this.editor.announceForAccessibility(this.localizationTable.dropdownHidden(this.sidebarTitle.get())),e=setTimeout(()=>{this.menuContainer.style.display="none",this.menuContainer.style.overflowY="",e=null},r)))})}onToolbarRowResize(){let e=()=>{let a=this.toolbarToolRow.clientWidth,l=0,c=0,d=0;for(let p of this.toolbarToolRow.children){let h=p.clientHeight;if(l+=h,d++,l>a){c=a-l+h/2,c<0&&(c+=h);break}}let u=Math.round(c/d*10)/10;this.toolbarToolRow.style.setProperty("--extra-left-right-padding",`${u}px`)},r=this.toolbarActionRow.getBoundingClientRect(),n=this.toolbarToolRow.getBoundingClientRect();r.y+r.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"),e()):this.toolbarToolRow.classList.remove("has-scroll","extra-padding")}addSpacer(e){}addUndoRedoButtons(){super.addUndoRedoButtons(!1)}addDefaults(){this.addDefaultActionButtons(),this.addDefaultToolWidgets()}updateWidgetCSSClasses(e){let r=e.getTags();e.removeCSSClassFromContainer("label-inline"),e.removeCSSClassFromContainer("label-left"),e.removeCSSClassFromContainer("label-right"),r.includes("save")&&(e.addCSSClassToContainer("label-inline"),e.addCSSClassToContainer("label-left")),r.includes("exit")&&(e.addCSSClassToContainer("label-inline"),e.addCSSClassToContainer("label-right"))}addWidgetInternal(e){this.updateWidgetCSSClasses(e),e.setLayoutManager(this.layoutManager),e.mustBeInToplevelMenu()?e.addTo(this.toolbarActionRow):e.addTo(this.toolbarToolRow)}removeWidgetInternal(e){e.remove()}onRemove(){this.toolbarContainer.remove(),this.menuContainer.remove(),this.toolRowResizeObserver.disconnect(),this.clearDragListeners?.()}initDragListeners(){let e=[this.closeButton,this.sidebarContainer,this.sidebarContent];this.manageListener(this.editor.handlePointerEventsExceptClicksFrom(this.menuContainer,(a,l)=>l.target===this.menuContainer?(a==="pointerdown"&&(this.sidebarVisible.set(!1),setTimeout(()=>this.editor.focus(),0)),!0):!this.sidebarVisible.get(),(a,l)=>l.target===this.menuContainer));let r=!0,n=0,i=rn(this.sidebarContainer,{draggableChildElements:e,onDrag:(a,l)=>this.handleDrag(a,l),onDragEnd:a=>{n=a.endTimestamp,r=a.roughlyClick,this.finalizeDrag()}});this.clearDragListeners=()=>i.removeListeners(),this.closeButton.onclick=()=>{let a=performance.now()-n<100;(a&&r||!a)&&this.sidebarVisible.set(!1)}}handleDrag(e,r){this.sidebarContainer.style.transition="none",this.sidebarY.set(this.sidebarY.get()+r)}snappedSidebarY(e){let r=e??this.sidebarY.get(),n=[-100,0];this.sidebarContainer.clientHeight>window.innerHeight&&n.push(100);let i=n[0];for(let a of n)Math.abs(a-r)<Math.abs(i-r)&&(i=a);return i}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(e){typeof e=="object"&&typeof e.menuSizeY=="number"&&this.sidebarY.set(this.snappedSidebarY(e.menuSizeY))}};var rr=class s extends Re{constructor(e,r){super();this.shortcuts=e;this.viewport=r;this.snapToGridEnabled=!1;this.angleLockEnabled=!1;this.startPointCanvas=null}xyAxesSnap(e){if(!this.startPointCanvas)return e;let r=this.viewport.canvasToScreen(this.startPointCanvas);return e.lockedToXYAxesScreen(r,this.viewport)}mapPointerEvent(e){let r=n=>e.allPointers.length>1?n:this.snapToGridEnabled?n.snappedToGrid(this.viewport):this.angleLockEnabled&&this.startPointCanvas?this.xyAxesSnap(n):n;return{kind:e.kind,current:r(e.current),allPointers:e.allPointers.map(r)}}onEvent(e){let r=this.shortcuts;(e.kind===0||e.kind===1||e.kind===2)&&(e.kind===0&&(this.startPointCanvas=e.current.canvasPos),e=this.mapPointerEvent(e));let n=this.emit(e);if(e.kind===6||!n&&e.kind===5){let i=e.kind===5;r.matchesShortcut(io,e)&&(this.snapToGridEnabled=i,n=!0),r.matchesShortcut(Gn,e)&&(this.angleLockEnabled=i,n=!0)}return n}static fromEditor(e){return new s(e.shortcuts,e.viewport)}};var Fs={Control:"ControlLeft","=":"Equal","-":"Minus",";":"Semicolon"," ":"Space"},Sl=s=>{let o=s.toUpperCase();return"A"<=o&&o<="Z"?`Key${o}`:"0"<=s&&s<="9"?`Digit${s}`:s in Fs?Fs[s]:s},Hs=Sl;var Pl=(s,o)=>{let e=jr(s,{title:s.localization.about,contentClassNames:["about-dialog-content"]});for(let r of o){let n=document.createElement(r.minimized?"details":"div");n.classList.add("about-entry");let i=document.createElement(r.minimized?"summary":"h2");if(typeof r.heading=="string")i.innerText=r.heading;else{let a=document.createElement("a");a.href=r.heading.href.replace(/^javascript:/i,""),a.text=r.heading.text,i.appendChild(a)}if(n.appendChild(i),r.text){let a=document.createElement("div");a.innerText=r.text,n.appendChild(a)}e.appendChild(n)}return{close:()=>e.close()}},Ns=Pl;var bo={number:"1.27.1"};var El=(s,o,e)=>{let r=o.w,n=o.h;if(e?.minDimension&&r<e.minDimension){let i=e.minDimension;n*=i/(r||1),r=i}if(e?.minDimension&&n<e.minDimension){let i=e.minDimension;r*=i/(n||1),n=i}s.setAttribute("width",pe(r)),s.setAttribute("height",pe(n))},$s=El;var Us=(s,o,e)=>{let r=s.getImportExportViewport().getTemporaryClone();if(e?.minDimension){let a=r.visibleRect,l=a;l.w<=0&&(l=new I(l.x,l.y,e.minDimension,l.h)),l.h<=0&&(l=new I(l.x,l.y,l.w,e.minDimension)),l.eq(a)||r.updateScreenSize(l.size)}let{element:n,renderer:i}=me.fromViewport(r,{sanitize:e.sanitize??!1,useViewBoxForPositioning:!0});return o(i,()=>{s.getAutoresizeEnabled()?n.classList.add(Nr):n.classList.remove(Nr);let a=r.visibleRect;return $s(n,a,e),n}),n},Ws=(s,o)=>Us(s,(e,r)=>{s.renderAll(e),r()},o),Ks=(s,o,e)=>new Promise(r=>{Us(s,async(n,i)=>{await s.renderAllAsync(n,o);let a=i();r(a)},e)});var kl=(s,o)=>{let e=[],r=(c,d)=>c.key===d.key&&c.code===d.code,n=c=>e.some(d=>r(d,c)),i=c=>({code:c.code,key:c.key,ctrlKey:c.ctrlKey,altKey:c.altKey,shiftKey:c.shiftKey,metaKey:c.metaKey}),a=c=>{if(c.type==="keydown"){if(n(c)||e.push(i(c)),!o.filter(c))return;o.handleKeyDown(c)}else{if(console.assert(c.type==="keyup"),e=e.filter(d=>!r(d,c)),!o.filter(c))return;o.handleKeyUp(c)}};s.addEventListener("keydown",c=>{a(c)}),s.addEventListener("keyup",c=>{a(c)}),s.addEventListener("focusout",c=>{let d=!1;if(c.relatedTarget){let u=c.relatedTarget;d=s.contains(u)||o.getHandlesKeyEventsFrom(u)}if(!d){for(let u of e)o.handleKeyUp(new KeyboardEvent("keyup",{...u}));e=[]}});let l=c=>{let d=!1,u=!1,p=!1,h=!1;for(let v of e){let b=v.code;d||=!!b.match(/^Shift(Left|Right)$/),u||=!!b.match(/^Control(Left|Right)$/),p||=!!b.match(/^Alt(Left|Right)$/),h||=!!b.match(/^Meta(Left|Right)$/)}let m=v=>v?"keydown":"keyup",g={shiftKey:c.shiftKey,altKey:c.altKey,metaKey:c.metaKey,ctrlKey:c.ctrlKey};c.shiftKey!==d&&a(new KeyboardEvent(m(c.shiftKey),{...g,key:"Shift",code:"ShiftLeft"})),c.altKey!==p&&a(new KeyboardEvent(m(c.altKey),{...g,key:"Alt",code:"AltLeft"})),c.ctrlKey!==u&&a(new KeyboardEvent(m(c.ctrlKey),{...g,key:"Control",code:"ControlLeft"})),c.metaKey!==h&&a(new KeyboardEvent(m(c.metaKey),{...g,key:"Meta",code:"MetaLeft"}))};s.addEventListener("mousedown",c=>{l(c)}),s.addEventListener("mousemove",c=>{l(c)})},Gs=kl;var Rl=s=>(e=>e.replace(/([^\n])[\n]([^\n])/g,"$1 $2"))(`
|
447
|
+
MIT License
|
448
|
+
|
449
|
+
Copyright (c) ${s}
|
450
|
+
|
451
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
452
|
+
of this software and associated documentation files (the "Software"), to deal
|
453
|
+
in the Software without restriction, including without limitation the rights
|
454
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
455
|
+
copies of the Software, and to permit persons to whom the Software is
|
456
|
+
furnished to do so, subject to the following conditions:
|
457
|
+
|
458
|
+
The above copyright notice and this permission notice shall be included in all
|
459
|
+
copies or substantial portions of the Software.
|
460
|
+
|
461
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
462
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
463
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
464
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
465
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
466
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
467
|
+
SOFTWARE.`),mn=Rl;var nr=class extends Re{constructor(){super();this.canShowContextMenu=!1;this.stationaryDetector=null;this.clickTolerance=12}canMakeLongPressMenuEvent(e){let r=[2];return e.allPointers.length===1&&r.includes(e.current.device)}onEvent(e){let r=()=>oo(e)&&this.canShowContextMenu&&this.emit({kind:9,screenPos:e.current.screenPos,canvasPos:e.current.canvasPos})?(this.emit({kind:3}),!0):!1;if(e.kind===0)e.allPointers.length===1?(this.canShowContextMenu=!0,this.contextMenuTriggerPointer=e.current,this.contextMenuStartPoint=e.current.screenPos,this.canMakeLongPressMenuEvent(e)&&(this.stationaryDetector=new kt(e.current,Vr,r))):this.canShowContextMenu=!1;else if(e.kind===1){if(this.canShowContextMenu){this.stationaryDetector?.onPointerMove(e.current);let n=e.current.screenPos.minus(this.contextMenuStartPoint),i=this.clickTolerance;n.length()>i&&(this.canShowContextMenu=!1)}}else if(e.kind===2&&(this.stationaryDetector?.destroy(),this.contextMenuTriggerPointer?.id===e.current.id&&this.contextMenuTriggerPointer.device===4&&r()))return!0;return this.emit(e)}};var Bi=class{constructor(o,e={}){this.eventListenerTargets=[];this.previousAccessibilityAnnouncement="";this.pointers={};this.announceUndoCallback=o=>{this.announceForAccessibility(this.localization.undoAnnouncement(o.description(this,this.localization)))};this.announceRedoCallback=o=>{this.announceForAccessibility(this.localization.redoAnnouncement(o.description(this,this.localization)))};this.nextRerenderListeners=[];this.rerenderQueued=!1;this.closeAboutDialog=null;if(this.localization={...Sr(),...e.localization},this.settings={wheelEventsEnabled:e.wheelEventsEnabled??!0,renderingMode:e.renderingMode??1,localization:this.localization,minZoom:e.minZoom??2e-10,maxZoom:e.maxZoom??1e12,keyboardShortcutOverrides:e.keyboardShortcutOverrides??{},iconProvider:e.iconProvider??new $t,notices:e.notices??[],appInfo:e.appInfo?{...e.appInfo}:null,pens:{additionalPenTypes:e.pens?.additionalPenTypes??[],filterPenTypes:e.pens?.filterPenTypes??(()=>!0)},text:{fonts:e.text?.fonts??["sans-serif","serif","monospace"]},image:{showImagePicker:e.image?.showImagePicker??void 0},clipboardApi:e.clipboardApi??null},this.settings.minZoom>this.settings.maxZoom)throw new Error("Minimum zoom must be lesser than maximum zoom!");this.readOnly=te.fromInitialValue(!1),this.icons=this.settings.iconProvider,this.shortcuts=new H(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 Fe,this.viewport=new U((r,n)=>{this.notifier.dispatch(7,{kind:7,newTransform:n,oldTransform:r})}),this.display=new Nt(this,this.settings.renderingMode,this.renderingRegion),this.image=new q,this.history=new qr(this,this.announceRedoCallback,this.announceUndoCallback),this.toolController=new Ht(this,this.localization),this.toolController.addInputMapper(rr.fromEditor(this)),this.toolController.addInputMapper(new nr),o.appendChild(this.container),this.viewport.updateScreenSize(w.of(this.display.width,this.display.height)),this.registerListeners(),this.queueRerender(),this.hideLoadingWarning(),this.notifier.on(7,r=>{if(r.kind!==7)return;let n=a=>a.transformVec3(w.unitX).length(),i=n(r.newTransform);if(i>this.settings.maxZoom||i<this.settings.minZoom){let a=n(r.oldTransform),l=k.identity;a<=this.settings.maxZoom&&a>=this.settings.minZoom?l=r.oldTransform:l=k.scaling2D((this.settings.minZoom+this.settings.maxZoom)/2),this.viewport.resetTransform(l)}else isFinite(i)||(console.warn(`Non-finite zoom (${i}) detected. Resetting the viewport. This was likely caused by division by zero.`),isFinite(n(r.oldTransform))?this.viewport.resetTransform(r.oldTransform):this.viewport.resetTransform())})}getCurrentSettings(){return{...this.settings}}getRootElement(){return this.container}getOutputBBoxInDOM(){return I.of(this.renderingRegion.getBoundingClientRect())}showLoadingWarning(o){let e=Math.round(o*100);this.loadingWarning.innerText=this.localization.loading(e),this.loadingWarning.style.display="block"}hideLoadingWarning(){this.loadingWarning.style.display="none",this.announceForAccessibility(this.localization.doneLoading)}announceForAccessibility(o){o===this.previousAccessibilityAnnouncement&&(o=o+". "),this.accessibilityAnnounceArea.innerText=o,this.previousAccessibilityAnnouncement=o}addToolbar(o=!0){let e=new go(this,this.container,this.localization);return o&&e.addDefaults(),e}registerListeners(){this.handlePointerEventsFrom(this.renderingRegion),this.handleKeyEventsFrom(this.renderingRegion),this.handlePointerEventsFrom(this.accessibilityAnnounceArea);let o=[this.renderingRegion,this.accessibilityAnnounceArea,this.accessibilityControlArea,this.loadingWarning];for(let n of o)n.addEventListener("drag",i=>(i.preventDefault(),!1)),n.addEventListener("dragstart",i=>(i.preventDefault(),!1));this.container.addEventListener("wheel",n=>{this.handleHTMLWheelEvent(n)});let e=()=>{this.viewport.updateScreenSize(w.of(this.display.width,this.display.height)),this.rerender(),this.updateEditorSizeVariables()};if("ResizeObserver"in window){let n=new ResizeObserver(e);n.observe(this.renderingRegion),n.observe(this.container)}else addEventListener("resize",e);this.accessibilityControlArea.addEventListener("input",()=>{this.accessibilityControlArea.value=""});let r=new Ae(this);document.addEventListener("copy",async n=>{this.isEventSink(document.querySelector(":focus"))&&r.copy(n)}),document.addEventListener("paste",n=>{this.handlePaste(n)})}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`)}handleHTMLWheelEvent(o){let e=F.of(o.deltaX,o.deltaY,o.deltaZ);if(!o.ctrlKey&&!o.metaKey)if(this.settings.wheelEventsEnabled){if(this.settings.wheelEventsEnabled==="only-if-focused"&&!this.container.querySelector(":focus"))return}else return;o.deltaMode===WheelEvent.DOM_DELTA_LINE?e=e.times(15):o.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e=e.times(100)),(o.ctrlKey||o.metaKey)&&(e=F.of(0,0,o.deltaY));let r=this.getOutputBBoxInDOM(),n=w.of(o.clientX,o.clientY).minus(r.topLeft);return this.toolController.dispatchInputEvent({kind:4,delta:e,screenPos:n})?(o.preventDefault(),!0):!1}getPointerList(){let o=performance.now(),e=[];for(let r in this.pointers)this.pointers[r]&&o-this.pointers[r].timeStamp<2e3&&e.push(this.pointers[r]);return e}setPointerCapture(o,e){try{o.setPointerCapture(e)}catch(r){console.warn("Failed to setPointerCapture",r)}}releasePointerCapture(o,e){try{o.releasePointerCapture(e)}catch(r){console.warn("Failed to releasePointerCapture",r)}}handleHTMLPointerEvent(o,e){let r=this.renderingRegion,n=e.target??this.renderingRegion;if(o==="pointerdown"){let i=ke.ofEvent(e,!0,this.viewport,r);this.pointers[i.id]=i,this.setPointerCapture(n,i.id);let a={kind:0,current:i,allPointers:this.getPointerList()};return this.toolController.dispatchInputEvent(a),!0}else if(o==="pointermove"){let i=ke.ofEvent(e,this.pointers[e.pointerId]?.down??!1,this.viewport,r);if(i.down){let a=this.pointers[i.id];if(a&&i.screenPos.distanceTo(a.screenPos)<2)return!1;this.pointers[i.id]=i,this.toolController.dispatchInputEvent({kind:1,current:i,allPointers:this.getPointerList()})&&e.preventDefault()}return!0}else if(o==="pointercancel"||o==="pointerup"){let i=ke.ofEvent(e,!1,this.viewport,r);return this.pointers[i.id]?(this.pointers[i.id]=i,this.releasePointerCapture(n,i.id),this.toolController.dispatchInputEvent({kind:2,current:i,allPointers:this.getPointerList()})&&e.preventDefault(),delete this.pointers[i.id],!0):!1}return o}isEventSink(o){let e=o;for(;e!==null;){for(let r of this.eventListenerTargets)if(r===e)return!0;e=e.parentElement}return!1}async handleDrop(o){o.preventDefault(),await this.handlePaste(o)}async handlePaste(o){let e=document.querySelector(":focus")??o.target;if(this.isEventSink(e))return await new Ae(this).paste(o)}handlePointerEventsFrom(o,e,r){let a={touchstart:c=>{r&&!r("touchstart",c)||c.preventDefault()},contextmenu:c=>{r&&!r("contextmenu",c)||c.preventDefault()}},l=["pointerdown","pointermove","pointerup","pointercancel"];for(let c of l)a[c]=d=>{let u=d;if(!(e&&!e(c,u)))return this.handleHTMLPointerEvent(c,u)};for(let c in a)o.addEventListener(c,a[c]);return{remove:()=>{for(let c in a)o.removeEventListener(c,a[c])}}}handlePointerEventsExceptClicksFrom(o,e,r){let n=Object.create(null);return this.handlePointerEventsFrom(o,(i,a)=>{if(e&&!e(i,a))return!1;let l=w.of(a.pageX??a.clientX,a.pageY??a.clientY),c=a.pointerId??0,d=!0;if(i==="pointerdown")n[c]={eventBuffer:[[i,a]],startPoint:l,hasMovedSignificantly:!1},this.setPointerCapture(o,a.pointerId),d=!1;else if(i==="pointermove"&&n[c]){let u=n[c].startPoint,p=n[c].eventBuffer;if(u&&l.distanceTo(u)<10&&!n[c].hasMovedSignificantly)p.push([i,a]),d=!1;else{for(let[g,v]of p)this.handleHTMLPointerEvent(g,v);n[c].eventBuffer=[],n[c].hasMovedSignificantly=!0,d=!0}}else i==="pointermove"?d=!0:(i==="pointerup"||i==="pointercancel")&&n[c]&&n[c].eventBuffer.length>0&&(this.releasePointerCapture(o,a.pointerId),d=!1,delete n[c]);return d},r)}handleHTMLKeyDownEvent(o){console.assert(o.type==="keydown",`handling a keydown event with type ${o.type}`);let e=Lo(o);return this.toolController.dispatchInputEvent(e)?(o.preventDefault(),!0):e.key==="t"||e.key==="T"?(o.preventDefault(),this.display.rerenderAsText(),!0):e.key==="Escape"?(this.renderingRegion.blur(),!0):!1}handleHTMLKeyUpEvent(o){console.assert(o.type==="keyup",`Handling a keyup event with type ${o.type}`);let e=zo(o);return this.toolController.dispatchInputEvent(e)?(o.preventDefault(),!0):!1}handleKeyEventsFrom(o,e=()=>!0){Gs(o,{filter:e,handleKeyDown:r=>{this.handleHTMLKeyDownEvent(r)},handleKeyUp:r=>{this.handleHTMLKeyUpEvent(r)},getHandlesKeyEventsFrom:r=>this.eventListenerTargets.includes(r)}),o.ondragover=r=>{r.preventDefault()},o.ondrop=r=>{this.handleDrop(r)},this.eventListenerTargets.push(o)}setReadOnly(o){o!==this.readOnly.get()&&(this.readOnly.set(o),this.notifier.dispatch(10,{kind:10,editorIsReadOnly:o}))}isReadOnlyReactiveValue(){return this.readOnly}isReadOnly(){return this.readOnly}dispatch(o,e=!0){let r=this.dispatchNoAnnounce(o,e),n=o.description(this,this.localization);return this.announceForAccessibility(n),r}dispatchNoAnnounce(o,e=!1){let r=o.apply(this);return e&&this.history.push(o,!1),r}async asyncApplyOrUnapplyCommands(o,e,r){console.assert(r>0),this.display.setDraftMode(!0);for(let n=0;n<o.length;n+=r){this.showLoadingWarning(n/o.length);for(let i=n;i<o.length&&i<n+r;i++){let a=o[i];e?a.apply(this):a.unapply(this)}n+r<o.length&&await new Promise(i=>{this.rerender(),requestAnimationFrame(i)})}this.display.setDraftMode(!1),this.hideLoadingWarning()}asyncApplyCommands(o,e){return this.asyncApplyOrUnapplyCommands(o,!0,e)}asyncUnapplyCommands(o,e,r=!1){return r&&(o=[...o],o.reverse()),this.asyncApplyOrUnapplyCommands(o,!1,e)}queueRerender(){return this.rerenderQueued||(this.rerenderQueued=!0,requestAnimationFrame(()=>{this.rerenderQueued&&(this.rerender(),this.rerenderQueued=!1)})),new Promise(o=>{this.nextRerenderListeners.push(()=>o())})}isRerenderQueued(){return this.rerenderQueued}rerender(o=!0){if(this.display.startRerender(),this.display.width===0||this.display.height===0)return;let e=this.display.getDryInkRenderer();if(this.image.renderWithCache(e,this.display.getCache(),this.viewport),o&&!this.image.getAutoresizeEnabled()){let r={fill:L.fromHex("#44444455")},n=5*this.viewport.getSizeOfPixelOnCanvas();e.drawRect(this.getImportExportRect(),n,r)}this.rerenderQueued=!1,this.nextRerenderListeners.forEach(r=>r()),this.nextRerenderListeners=[]}drawWetInk(...o){for(let e of o)this.display.getWetInkRenderer().drawPath(e)}clearWetInk(){this.display.getWetInkRenderer().clear()}focus(){this.renderingRegion.focus()}createHTMLOverlay(o){return o.classList.add("overlay","js-draw-editor-overlay"),this.container.appendChild(o),{remove:()=>o.remove()}}anchorElementToCanvas(o,e){e instanceof k&&(e=Tr.fromImmutable(e));let r=document.createElement("div");r.classList.add("anchored-element-overlay");let n=document.createElement("div");n.classList.add("content-wrapper"),o.classList.add("content");let i=()=>{let u=e.get().transformVec3(w.unitX).angle()+this.viewport.getRotationAngle(),p=this.viewport.canvasToScreenTransform.rightMul(e.get());r.style.setProperty("--full-transform",p.toCSSMatrix());let h=p.transformVec2(w.zero);r.style.setProperty("--position-x",`${h.x}px`),r.style.setProperty("--position-y",`${h.y}px`),r.style.setProperty("--rotation",`${u*180/Math.PI}deg`),r.style.setProperty("--scale",`${p.getScaleFactor()}`)};i();let a=e.onUpdate(i),l=this.notifier.on(7,i);return n.appendChild(o),r.appendChild(n),r.classList.add("overlay","js-draw-editor-overlay"),this.renderingRegion.insertAdjacentElement("afterend",r),{remove:()=>{r.remove(),a.remove(),l.remove()}}}addStyleSheet(o){let e=document.createElement("style");return e.innerText=o,this.container.appendChild(e),e}sendKeyboardEvent(o,e,r=!1,n=!1,i=void 0){i??=e.toUpperCase()===e&&e.toLowerCase()!==e,this.toolController.dispatchInputEvent({kind:o,key:e,code:Hs(e),ctrlKey:r,altKey:n,shiftKey:i})}sendPenEvent(o,e,r){on(this,o,e,r)}async addAndCenterComponents(o,e=!0,r){let n=null;for(let h of o)n?n=n.union(h.getBBox()):n=h.getBBox();if(!n)return;let i=this.viewport.visibleRect,a=i.width/n.width,l=i.height/n.height,c=a;(n.width*c>i.width||n.height*c>i.height)&&(c=l),c*=2/3,c=U.roundScaleRatio(c);let d=k.translation(i.center.minus(n.center)).rightMul(k.scaling2D(c,n.center)),u=[];for(let h of o)u.push(q.addElement(h)),u.push(h.transformBy(d));if(await this.dispatch(le(u,{applyChunkSize:100,description:r}),!0),e)for(let h of this.toolController.getMatchingTools(ve))h.setEnabled(!0),h.setSelection(o)}toDataURL(o="image/png",e){let{element:r,renderer:n}=Le.fromViewport(this.image.getImportExportViewport(),{canvasSize:e});return this.image.renderAll(n),r.toDataURL(o)}toSVG(o){return Ws(this.image,o??{})}async toSVGAsync(o={}){let e=o.pauseAfterCount??100;return await Ks(this.image,async(r,n,i)=>o.onProgress&&await o.onProgress(n,i)===!1?!1:(n%e===0&&await Ye(),!0),{minDimension:o.minDimension})}async loadFrom(o){this.showLoadingWarning(0),this.display.setDraftMode(!0);let e=this.image.getBackgroundComponents(),r=new J(e);await o.start(async n=>{await this.dispatchNoAnnounce(q.addElement(n))},(n,i)=>n%500===0?(this.showLoadingWarning(n/i),this.rerender(),Ye()):null,(n,i)=>{this.dispatchNoAnnounce(this.setImportExportRect(n),!1),this.dispatchNoAnnounce(this.viewport.zoomTo(n),!1),i&&this.dispatchNoAnnounce(this.image.setAutoresizeEnabled(i.autoresize),!1)}),this.image.getBackgroundComponents().length!==e.length&&await this.dispatchNoAnnounce(r),this.hideLoadingWarning(),this.display.setDraftMode(!1),this.queueRerender()}getTopmostBackgroundComponent(){let o=null;for(let e of this.image.getBackgroundComponents())e instanceof ce&&(o=e);return o}setBackgroundStyle(o){let e=this.getTopmostBackgroundComponent(),r=[];e&&r.push(new J([e]));let n=e?.getBackgroundType?.()??2,i=e?.getStyle?.().color??L.transparent,a=this.image.getAutoresizeEnabled(),l=o.color&&n===2?0:n,c=o.type??l,d=o.color??i,u=o.autoresize??a;if(c!==2){let p=new ce(c,d);r.push(q.addElement(p))}return u!==a&&(r.push(this.image.setAutoresizeEnabled(u)),!u&&this.image.getImportExportRect().maxDimension===0&&r.push(this.image.setImportExportRect(this.image.getImportExportRect().resizedTo(w.of(500,500))))),le(r)}setBackgroundColor(o){let e=this.getTopmostBackgroundComponent();if(e)return e.updateStyle({color:o});{let r=o.eq(L.transparent)?2:0;return e=new ce(r,o),this.image.addElement(e)}}estimateBackgroundColor(){let o=[];for(let e of this.image.getBackgroundComponents())e instanceof ce&&o.push(e.getStyle().color??L.transparent);return L.average(o)}getImportExportRect(){return this.image.getImportExportViewport().visibleRect}setImportExportRect(o){return this.image.setImportExportRect(o)}async loadFromSVG(o,e=!1){let r=et.fromString(o,e);await this.loadFrom(r)}showAboutDialog(){let o=this.icons.licenseInfo(),e=[];if(this.settings.appInfo){let n=[];this.settings.appInfo.version&&n.push(`v${this.settings.appInfo.version}`,""),this.settings.appInfo.description?n.push(this.settings.appInfo.description+`
|
468
|
+
`):n.push(`js-draw v${bo.number}`),e.push({heading:`${this.settings.appInfo.name}`,text:n.join(`
|
469
|
+
`)})}else e.push({heading:"js-draw",text:`v${bo.number}`});let r=this.viewport.getScreenRectSize();e.push({heading:this.localization.developerInformation,text:["Image debug information (from when this dialog was opened):",` ${this.viewport.getScaleFactor()}x zoom, ${180/Math.PI*this.viewport.getRotationAngle()}\xB0 rotation`,` ${this.image.estimateNumElements()} components`,` auto-resize: ${this.image.getAutoresizeEnabled()?"enabled":"disabled"}`,` image size: ${this.getImportExportRect().w}x${this.getImportExportRect().h}`,` screen size: ${r.x}x${r.y}`,` device pixel ratio: ${this.display.getDevicePixelRatio()}`," cache:",` ${this.display.getCache().getDebugInfo().replace(/([\n])/g,`
|
470
|
+
`)}`].join(`
|
471
|
+
`),minimized:!0}),e.push({heading:this.localization.softwareLibraries,text:[`This image editor is powered by js-draw v${bo.number}.`,"","At runtime, js-draw uses"," - The Coloris color picker: https://github.com/mdbassit/Coloris"," - The bezier.js B\xE9zier curve library: https://github.com/Pomax/bezierjs","","Both are licensed under the MIT license:","","","== Coloris ==",mn("2021 Mohammed Bassit"),"","","== Bezier.js ==",mn('2023 Mike "Pomax" Kamermans'),"","","== js-draw ==",mn("2023-2025 Henry Heino"),""].join(`
|
472
|
+
`),minimized:!0}),o&&e.push({heading:"Icon Pack",text:o,minimized:!0}),e.push(...this.settings.notices),this.closeAboutDialog?.(),this.closeAboutDialog=Ns(this,e).close}remove(){this.container.remove(),this.toolController.onEditorDestroyed()}},fn=Bi;var js=s=>s instanceof W?new class extends W{constructor(){super(...arguments);this._command=s}serializeToJSON(){return s.serialize()}apply(e){s.unapply(e)}unapply(e){s.apply(e)}onDrop(e){s.onDrop(e)}description(e,r){return r.inverseOf(s.description(e,r))}}("inverse"):new class extends Ie{apply(e){s.unapply(e)}unapply(e){s.apply(e)}onDrop(e){s.onDrop(e)}description(e,r){return r.inverseOf(s.description(e,r))}};W.register("inverse",(s,o)=>js(W.deserialize(s,o)));var _s=js;var ir=class extends ae{constructor(e,r){super(e,"overflow-widget",r);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(e){return this.overflowContainer??=document.createElement("div"),this.overflowContainer.parentElement&&this.overflowContainer.remove(),this.overflowContainer.classList.add("toolbar-overflow-widget-overflow-list"),e.appendChild(this.overflowContainer),!0}clearChildren(){this.overflowContainer.replaceChildren(),this.container.classList.remove("horizontal");let e=this.overflowChildren;return this.overflowChildren=[],e}getChildWidgets(){return[...this.overflowChildren]}hasAsChild(e){for(let r of this.overflowChildren)if(e===r)return!0;return!1}addToOverflow(e){this.overflowChildren.push(e),e.addTo(this.overflowContainer),e.setIsToplevel(!1),this.overflowChildren.length>2&&this.container.classList.add("horizontal")}canBeInOverflowMenu(){return!1}};var qs=s=>new gn(s,s.getRootElement()),gn=class extends it{constructor(e,r,n=ro){super(e,n);this.widgetOrderCounter=0;this.overflowWidget=null;this.reLayoutQueued=!1;this.container=document.createElement("div"),this.container.classList.add(`${D}root`),this.container.classList.add(`${D}element`),this.container.classList.add(`${D}dropdown-toolbar`),this.container.setAttribute("role","toolbar"),r.appendChild(this.container),"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver(i=>{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;let e=d=>{let u=0;for(let p of d)p.isHidden()||(u+=p.getButtonWidth());return u},r=d=>{let u=this.overflowWidget?.getChildWidgets()??[];return u.length===0?!1:u[0].getButtonWidth()<=d},n=this.getAllWidgets(),i=e(this.overflowWidget.getChildWidgets()),a=e(n)-i,l=this.container.clientWidth*.87;window.innerHeight>l*1.75&&(l*=1.75);let c=!1;if(r(l-a)){let d=this.overflowWidget.clearChildren();for(let u of d)u.addTo(this.container),u.setIsToplevel(!0),u.isHidden()||(a+=u.getButtonWidth());i=0,c=!0}if(a>=l){for(let d=n.length-1;d>=0&&a>=l;d--){let u=n[d];this.overflowWidget.hasAsChild(u)||u.canBeInOverflowMenu()&&(a-=u.getButtonWidth(),this.overflowWidget.addToOverflow(u))}c=!0}this.overflowWidget.setHidden(this.overflowWidget.getChildWidgets().length===0),c&&this.setupColorPickers()}addWidgetInternal(e){let r=e.addTo(this.container);r.style.order=`${this.widgetOrderCounter++}`,this.queueReLayout()}removeWidgetInternal(e){e.remove(),this.queueReLayout()}addSpacer(e={}){let r=document.createElement("div");r.classList.add(`${D}spacer`),e.grow&&(r.style.flexGrow=`${e.grow}`),e.minSize&&(r.style.minWidth=e.minSize),e.maxSize&&(r.style.maxWidth=e.maxSize),r.style.order=`${this.widgetOrderCounter++}`,this.container.appendChild(r)}addOverflowWidget(){this.overflowWidget=new ir(this.editor,this.localizationTable),this.addWidget(this.overflowWidget)}addDefaults(){this.addDefaultToolWidgets(),this.addOverflowWidget(),this.addDefaultActionButtons()}onRemove(){this.container.remove(),this.resizeObserver.disconnect()}};var zl=(s,o,e,r)=>{let n=s.viewport.screenToCanvas(e),i=tn(r??[]),a=ke.ofCanvasPoint(n,o!==2,s.viewport,i,2);return s.toolController.dispatchInputEvent({kind:o,allPointers:[...r??[],a],current:a}),a},Zs=zl;var Ll=(s,o)=>{let e=s.getRootElement(),r=[["--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(!o?.dontClearOverrides)for(let[l,c]of r)e.style.setProperty(l,null),e.style.setProperty(c,null);let n=getComputedStyle(e),i=Object.create(null),a=(l,c,d,u,p)=>{let h=i[l]?i[l]:L.fromString(n.getPropertyValue(l)),m=i[c]?i[c]:L.fromString(n.getPropertyValue(c));if(h.relativeLuminance()<m.relativeLuminance()){let y=h;h=m,m=y;let f=c;c=l,l=f;let T=u;u=p,p=T}let g=!1,v=L.contrastRatio(h,m),b=0;for(;v<d&&b<8;){let y=F.of(.1,.1,.1);u&&(m.eq(L.white)&&!p&&(m=L.black),h=L.fromRGBVector(h.rgb.plus(y))),p&&(m.eq(L.black)&&!u&&(m=L.white),m=L.fromRGBVector(m.rgb.minus(y))),v=L.contrastRatio(h,m),g=!0,b++}g&&(e.style.setProperty(l,h.toHexString()),e.style.setProperty(c,m.toHexString()),i[l]=h,i[c]=m)};a("--selection-background-color","--background-color-2",1.29,!0,!1);for(let[l,c,d,u]of r)a(l,c,4.5,d,u)},Ys=Ll;var Il=fn;return ha(Bl);})();
|
473
|
+
/*! Bundled license information:
|
474
|
+
|
475
|
+
@melloware/coloris/dist/esm/coloris.js:
|
476
|
+
(*!
|
3
477
|
* Copyright (c) 2021-2023 Momo Bassit.
|
4
478
|
* Licensed under the MIT License (MIT)
|
5
479
|
* https://github.com/mdbassit/Coloris
|
6
480
|
* Version: 0.21.1
|
7
481
|
* NPM: https://github.com/melloware/coloris-npm
|
8
|
-
|
9
|
-
return((t,e,o,n)=>{const i=e.createElement("canvas").getContext("2d"),r={r:0,g:0,b:0,h:0,s:0,v:0,a:1};let s,a,l,c,d,h,u,p,f,m,g,b,y,v,x,w,S={};const 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:()=>n,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={};let P="",k={},E=!1;function z(o){if("object"==typeof o)for(const i in o)switch(i){case"el":B(o.el),!1!==o.wrap&&L(o.el);break;case"parent":s=e.querySelector(o.parent),s&&(s.appendChild(a),T.parent=o.parent,s===e.body&&(s=n));break;case"themeMode":T.themeMode=o.themeMode,"auto"===o.themeMode&&t.matchMedia&&t.matchMedia("(prefers-color-scheme: dark)").matches&&(T.themeMode="dark");case"theme":o.theme&&(T.theme=o.theme),a.className=`clr-picker clr-${T.theme} clr-${T.themeMode}`,T.inline&&O();break;case"rtl":T.rtl=!!o.rtl,e.querySelectorAll(".clr-field").forEach((t=>t.classList.toggle("clr-rtl",T.rtl)));break;case"margin":o.margin*=1,T.margin=isNaN(o.margin)?T.margin:o.margin;break;case"wrap":o.el&&o.wrap&&L(o.el);break;case"formatToggle":T.formatToggle=!!o.formatToggle,it("clr-format").style.display=T.formatToggle?"block":"none",T.formatToggle&&(T.format="auto");break;case"swatches":if(Array.isArray(o.swatches)){const t=[];o.swatches.forEach(((e,o)=>{t.push(`<button type="button" id="clr-swatch-${o}" aria-labelledby="clr-swatch-label clr-swatch-${o}" style="color: ${e};">${e}</button>`)})),it("clr-swatches").innerHTML=t.length?`<div>${t.join("")}</div>`:"",T.swatches=o.swatches.slice()}break;case"swatchesOnly":T.swatchesOnly=!!o.swatchesOnly,a.setAttribute("data-minimal",T.swatchesOnly);break;case"alpha":T.alpha=!!o.alpha,a.setAttribute("data-alpha",T.alpha);break;case"inline":if(T.inline=!!o.inline,a.setAttribute("data-inline",T.inline),T.inline){const t=o.defaultColor||T.defaultColor;v=j(t),O(),A(t)}break;case"clearButton":"object"==typeof o.clearButton&&(o.clearButton.label&&(T.clearLabel=o.clearButton.label,u.innerHTML=T.clearLabel),o.clearButton=o.clearButton.show),T.clearButton=!!o.clearButton,u.style.display=T.clearButton?"block":"none";break;case"clearLabel":T.clearLabel=o.clearLabel,u.innerHTML=T.clearLabel;break;case"closeButton":T.closeButton=!!o.closeButton,T.closeButton?a.insertBefore(p,d):d.appendChild(p);break;case"closeLabel":T.closeLabel=o.closeLabel,p.innerHTML=T.closeLabel;break;case"a11y":const r=o.a11y;let c=!1;if("object"==typeof r)for(const t in r)r[t]&&T.a11y[t]&&(T.a11y[t]=r[t],c=!0);if(c){const t=it("clr-open-label"),e=it("clr-swatch-label");t.innerHTML=T.a11y.open,e.innerHTML=T.a11y.swatch,p.setAttribute("aria-label",T.a11y.close),u.setAttribute("aria-label",T.a11y.clear),f.setAttribute("aria-label",T.a11y.hueSlider),g.setAttribute("aria-label",T.a11y.alphaSlider),h.setAttribute("aria-label",T.a11y.input),l.setAttribute("aria-label",T.a11y.instruction)}break;default:T[i]=o[i]}}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){const e=["el","wrap","rtl","inline","defaultColor","a11y"];for(let o in C){const n=C[o];if(t.matches(o)){P=o,k={},e.forEach((t=>delete n[t]));for(let t in n)k[t]=Array.isArray(T[t])?T[t].slice():T[t];z(n);break}}}}function R(){Object.keys(k).length>0&&(z(k),P="",k={})}function B(t){rt(e,"click",t,(t=>{T.inline||(I(t.target),y=t.target,x=y.value,v=j(x),a.classList.add("clr-open"),O(),A(x),(T.focusInput||T.selectInput)&&(h.focus({preventScroll:!0}),h.setSelectionRange(y.selectionStart,y.selectionEnd)),T.selectInput&&h.select(),(w||T.swatchesOnly)&&nt().shift().focus(),y.dispatchEvent(new Event("open",{bubbles:!0})))})),rt(e,"input",t,(t=>{const e=t.target.parentNode;e.classList.contains("clr-field")&&(e.style.color=t.target.value)}))}function O(){if(!a||!y&&!T.inline)return;const o=s,n=t.scrollY,i=a.offsetWidth,r=a.offsetHeight,c={left:!1,top:!1};let d,h,u,p={x:0,y:0};if(o&&(d=t.getComputedStyle(o),h=parseFloat(d.marginTop),u=parseFloat(d.borderTopWidth),p=o.getBoundingClientRect(),p.y+=u+n),!T.inline){const t=y.getBoundingClientRect();let s=t.x,l=n+t.y+t.height+T.margin;o?(s-=p.x,l-=p.y,s+i>o.clientWidth&&(s+=t.width-i,c.left=!0),l+r>o.clientHeight-h&&r+T.margin<=t.top-(p.y-n)&&(l-=t.height+r+2*T.margin,c.top=!0),l+=o.scrollTop):(s+i>e.documentElement.clientWidth&&(s+=t.width-i,c.left=!0),l+r-n>e.documentElement.clientHeight&&r+T.margin<=t.top&&(l=n+t.y-r-T.margin,c.top=!0)),a.classList.toggle("clr-left",c.left),a.classList.toggle("clr-top",c.top),a.style.left=`${s}px`,a.style.top=`${l}px`,p.x+=a.offsetLeft,p.y+=a.offsetTop}S={width:l.offsetWidth,height:l.offsetHeight,x:l.offsetLeft+p.x,y:l.offsetTop+p.y}}function L(t){e.querySelectorAll(t).forEach((t=>{const o=t.parentNode;if(!o.classList.contains("clr-field")){const n=e.createElement("div");let i="clr-field";(T.rtl||t.classList.contains("clr-rtl"))&&(i+=" clr-rtl"),n.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',o.insertBefore(n,t),n.setAttribute("class",i),n.style.color=t.value,n.appendChild(t)}}))}function D(t){if(y&&!T.inline){const e=y;t&&(y=n,x!==e.value&&(e.value=x,e.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout((()=>{x!==e.value&&e.dispatchEvent(new Event("change",{bubbles:!0}))})),a.classList.remove("clr-open"),E&&R(),e.dispatchEvent(new Event("close",{bubbles:!0})),T.focusInput&&e.focus({preventScroll:!0}),y=n}}function A(t){const e=J(t),o=X(e);N(o.s,o.v),K(e,o),f.value=o.h,a.style.color=`hsl(${o.h}, 100%, 50%)`,m.style.left=o.h/360*100+"%",c.style.left=S.width*o.s/100+"px",c.style.top=S.height-S.height*o.v/100+"px",g.value=100*o.a,b.style.left=100*o.a+"%"}function j(t){const e=t.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function V(o){o=o!==n?o:h.value,y&&(y.value=o,y.dispatchEvent(new Event("input",{bubbles:!0}))),T.onChange&&T.onChange.call(t,o,y),e.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:o,currentEl:y}}))}function F(t,e){const o={h:1*f.value,s:t/S.width*100,v:100-e/S.height*100,a:g.value/100},n=Z(o);N(o.s,o.v),K(n,o),V()}function N(t,e){let o=T.a11y.marker;t=1*t.toFixed(1),e=1*e.toFixed(1),o=o.replace("{s}",t),o=o.replace("{v}",e),c.setAttribute("aria-label",o)}function $(t){return{pageX:t.changedTouches?t.changedTouches[0].pageX:t.pageX,pageY:t.changedTouches?t.changedTouches[0].pageY:t.pageY}}function U(t){const e=$(t);let o=e.pageX-S.x,n=e.pageY-S.y;s&&(n+=s.scrollTop),W(o,n),t.preventDefault(),t.stopPropagation()}function H(t,e){W(1*c.style.left.replace("px","")+t,1*c.style.top.replace("px","")+e)}function W(t,e){t=t<0?0:t>S.width?S.width:t,e=e<0?0:e>S.height?S.height:e,c.style.left=`${t}px`,c.style.top=`${e}px`,F(t,e),c.focus()}function K(t,o){void 0===t&&(t={}),void 0===o&&(o={});let n=T.format;for(const e in t)r[e]=t[e];for(const t in o)r[t]=o[t];const i=Q(r),s=i.substring(0,7);switch(c.style.color=s,b.parentNode.style.color=s,b.style.color=i,d.style.color=i,l.style.display="none",l.offsetHeight,l.style.display="",b.nextElementSibling.style.display="none",b.nextElementSibling.offsetHeight,b.nextElementSibling.style.display="","mixed"===n?n=1===r.a?"hex":"rgb":"auto"===n&&(n=v),n){case"hex":h.value=i;break;case"rgb":h.value=tt(r);break;case"hsl":h.value=et(Y(r))}e.querySelector(`.clr-format [value="${n}"]`).checked=!0}function G(){const t=1*f.value,e=1*c.style.left.replace("px",""),o=1*c.style.top.replace("px","");a.style.color=`hsl(${t}, 100%, 50%)`,m.style.left=t/360*100+"%",F(e,o)}function q(){const t=g.value/100;b.style.left=100*t+"%",K({a:t}),V()}function Z(t){const e=t.s/100,n=t.v/100;let i=e*n,r=t.h/60,s=i*(1-o.abs(r%2-1)),a=n-i;i+=a,s+=a;const l=o.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:o.round(255*c),g:o.round(255*d),b:o.round(255*h),a:t.a}}function Y(t){const e=t.v/100,n=e*(1-t.s/100/2);let i;return n>0&&n<1&&(i=o.round((e-n)/o.min(n,1-n)*100)),{h:t.h,s:i||0,l:o.round(100*n),a:t.a}}function X(t){const e=t.r/255,n=t.g/255,i=t.b/255,r=o.max(e,n,i),s=r-o.min(e,n,i),a=r;let l=0,c=0;return s&&(r===e&&(l=(n-i)/s),r===n&&(l=2+(i-e)/s),r===i&&(l=4+(e-n)/s),r&&(c=s/r)),l=o.floor(60*l),{h:l<0?l+360:l,s:o.round(100*c),v:o.round(100*a),a:t.a}}function J(t){const e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;let o,n;return i.fillStyle="#000",i.fillStyle=t,o=e.exec(i.fillStyle),o?(n={r:1*o[3],g:1*o[4],b:1*o[5],a:1*o[6]},n.a=+n.a.toFixed(2)):(o=i.fillStyle.replace("#","").match(/.{2}/g).map((t=>parseInt(t,16))),n={r:o[0],g:o[1],b:o[2],a:1}),n}function Q(t){let e=t.r.toString(16),o=t.g.toString(16),n=t.b.toString(16),i="";if(t.r<16&&(e="0"+e),t.g<16&&(o="0"+o),t.b<16&&(n="0"+n),T.alpha&&(t.a<1||T.forceAlpha)){const e=255*t.a|0;i=e.toString(16),e<16&&(i="0"+i)}return"#"+e+o+n+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 ot(){e.getElementById("clr-picker")||(s=n,a=e.createElement("div"),a.setAttribute("id","clr-picker"),a.className="clr-picker",a.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(a),l=it("clr-color-area"),c=it("clr-color-marker"),u=it("clr-clear"),p=it("clr-close"),d=it("clr-color-preview"),h=it("clr-color-value"),f=it("clr-hue-slider"),m=it("clr-hue-marker"),g=it("clr-alpha-slider"),b=it("clr-alpha-marker"),B(T.el),L(T.el),rt(a,"mousedown",(t=>{a.classList.remove("clr-keyboard-nav"),t.stopPropagation()})),rt(l,"mousedown",(t=>{rt(e,"mousemove",U)})),rt(l,"touchstart",(t=>{e.addEventListener("touchmove",U,{passive:!1})})),rt(c,"mousedown",(t=>{rt(e,"mousemove",U)})),rt(c,"touchstart",(t=>{e.addEventListener("touchmove",U,{passive:!1})})),rt(h,"change",(t=>{const e=h.value;(y||T.inline)&&V(""===e?e:A(e))})),rt(u,"click",(t=>{V(""),D()})),rt(p,"click",(t=>{V(),D()})),rt(it("clr-format"),"click",".clr-format input",(t=>{v=t.target.value,K(),V()})),rt(a,"click",".clr-swatches button",(t=>{A(t.target.textContent),V(),T.swatchesOnly&&D()})),rt(e,"mouseup",(t=>{e.removeEventListener("mousemove",U)})),rt(e,"touchend",(t=>{e.removeEventListener("touchmove",U)})),rt(e,"mousedown",(t=>{w=!1,a.classList.remove("clr-keyboard-nav"),D()})),rt(e,"keydown",(t=>{const e=t.key,o=t.target,n=t.shiftKey,i=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];if("Escape"===e?D(!0):i.includes(e)&&(w=!0,a.classList.add("clr-keyboard-nav")),"Tab"===e&&o.matches(".clr-picker *")){const e=nt(),i=e.shift(),r=e.pop();n&&o===i?(r.focus(),t.preventDefault()):n||o!==r||(i.focus(),t.preventDefault())}})),rt(e,"click",".clr-field button",(t=>{E&&R(),t.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))})),rt(c,"keydown",(t=>{const e={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(e).includes(t.key)&&(H(...e[t.key]),t.preventDefault())})),rt(l,"click",U),rt(f,"input",G),rt(g,"input",q))}function nt(){return Array.from(a.querySelectorAll("input, button")).filter((t=>!!t.offsetWidth))}function it(t){return e.getElementById(t)}function rt(t,e,o,n){const i=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof o?t.addEventListener(e,(t=>{i.call(t.target,o)&&n.call(t.target,t)})):(n=o,t.addEventListener(e,n))}function st(t,o){o=o!==n?o:[],"loading"!==e.readyState?t(...o):e.addEventListener("DOMContentLoaded",(()=>{t(...o)}))}function at(t,e){y=e,x=y.value,I(e),v=j(t),O(),A(t),V(),x!==t&&y.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==n&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);const lt=(()=>{const e={init:ot,set:z,wrap:L,close:D,setInstance:M,setColor:at,removeInstance:_,updatePosition:O,ready:st};function o(t){st((()=>{t&&("string"==typeof t?B(t):z(t))}))}for(const t in e)o[t]=function(){for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];st(e[t],n)};return st((()=>{t.addEventListener("resize",(t=>{o.updatePosition()})),t.addEventListener("scroll",(t=>{o.updatePosition()}))})),o})();return lt.coloris=lt,lt})(window,document,Math)})?o.apply(e,n):o)||(t.exports=i)},5893:e=>{var o=Object.defineProperty,n=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||o(t,l,{get:()=>e[l],enumerable:!(a=n(e,l))||a.enumerable});return t})(o({},"__esModule",{value:!0}),e,1),t&&t.set(e,s),s))("undefined"!=typeof WeakMap?new WeakMap:0),a={};((t,e)=>{for(var n in e)o(t,n,{get:e[n],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,x=Number.MIN_SAFE_INTEGER||-9007199254740991,w={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 o=e(t);let n=o.x*o.x+o.y*o.y;return void 0!==o.z&&(n+=o.z*o.z),p(n)},compute:function(t,e,o){if(0===t)return e[0].t=0,e[0];const n=e.length-1;if(1===t)return e[n].t=1,e[n];const i=1-t;let r=e;if(0===n)return e[0].t=t,e[0];if(1===n){const e={x:i*r[0].x+t*r[1].x,y:i*r[0].y+t*r[1].y,t};return o&&(e.z=i*r[0].z+t*r[1].z),e}if(n<4){let e,s,a,l=i*i,c=t*t,d=0;2===n?(r=[r[0],r[1],r[2],w],e=l,s=i*t*2,a=c):3===n&&(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 o&&(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,o,n){const i=1-t,r=o,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:!!n&&(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:!!n&&(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:!!n&&(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 o=[];for(let n=t,i=n.length,r=i-1;i>1;i--,r--){const t=[];for(let o,i=0;i<r;i++)o={x:r*(n[i+1].x-n[i].x),y:r*(n[i+1].y-n[i].y)},e&&(o.z=r*(n[i+1].z-n[i].z)),t.push(o);o.push(t),n=t}return o},between:function(t,e,o){return e<=t&&t<=o||S.approximately(t,e)||S.approximately(t,o)},approximately:function(t,e,o){return l(t-e)<=(o||1e-6)},length:function(t){const e=S.Tvalues.length;let o=0;for(let n,i=0;i<e;i++)n=.5*S.Tvalues[i]+.5,o+=S.Cvalues[i]*S.arcfn(n,t);return.5*o},map:function(t,e,o,n,i){return n+(i-n)*((t-e)/(o-e))},lerp:function(t,e,o){const n={x:e.x+t*(o.x-e.x),y:e.y+t*(o.y-e.y)};return void 0!==e.z&&void 0!==o.z&&(n.z=e.z+t*(o.z-e.z)),n},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,o){const n=e.x-t.x,i=e.y-t.y,r=o.x-t.x,s=o.y-t.y;return u(n*s-i*r,n*r+i*s)},round:function(t,e){const o=""+t,n=o.indexOf(".");return parseFloat(o.substring(0,n+1+e))},dist:function(t,e){const o=t.x-e.x,n=t.y-e.y;return p(o*o+n*n)},closest:function(t,e){let o,n,i=f(2,63);return t.forEach((function(t,r){n=S.dist(e,t),n<i&&(i=n,o=r)})),{mdist:i,mpos:o}},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 o=f(t,e)+f(1-t,e);return l((o-1)/o)},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 o=f(1-t,e);return o/(f(t,e)+o)},lli8:function(t,e,o,n,i,r,s,a){const l=(t-o)*(r-a)-(e-n)*(i-s);return 0!=l&&{x:((t*n-e*o)*(i-s)-(t-o)*(i*a-r*s))/l,y:((t*n-e*o)*(r-a)-(e-n)*(i*a-r*s))/l}},lli4:function(t,e,o,n){const i=t.x,r=t.y,s=e.x,a=e.y,l=o.x,c=o.y,d=n.x,h=n.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,o=v,n=x,i=x;return t.forEach((function(t){const r=t.bbox();e>r.x.min&&(e=r.x.min),o>r.y.min&&(o=r.y.min),n<r.x.max&&(n=r.x.max),i<r.y.max&&(i=r.y.max)})),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:o,mid:(o+i)/2,max:i,size:i-o}}},shapeintersections:function(t,e,o,n,i){if(!S.bboxoverlap(e,n))return[];const r=[],s=[t.startcap,t.forward,t.back,t.endcap],a=[o.startcap,o.forward,o.back,o.endcap];return s.forEach((function(e){e.virtual||a.forEach((function(n){if(n.virtual)return;const s=e.intersects(n,i);s.length>0&&(s.c1=e,s.c2=n,s.s1=t,s.s2=o,r.push(s))}))})),r},makeshape:function(t,e,o){const n=e.points.length,i=t.points.length,r=S.makeline(e.points[n-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,o)}};return a},getminmax:function(t,e,o){if(!o)return{min:0,max:0};let n,i,r=v,s=x;-1===o.indexOf(0)&&(o=[0].concat(o)),-1===o.indexOf(1)&&o.push(1);for(let a=0,l=o.length;a<l;a++)n=o[a],i=t.get(n),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 o=e.p1.x,n=e.p1.y,i=-u(e.p2.y-n,e.p2.x-o);return t.map((function(t){return{x:(t.x-o)*c(i)-(t.y-n)*d(i),y:(t.x-o)*d(i)+(t.y-n)*c(i)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const o=t.length-1,n=S.align(t,e),i=function(t){return 0<=t&&t<=1};if(2===o){const t=n[0].y,e=n[1].y,o=n[2].y,r=t-2*e+o;if(0!==r){const n=-p(e*e-t*o),s=-t+e;return[-(n+s)/r,-(-n+s)/r].filter(i)}return e!==o&&0===r?[(2*e-o)/(2*e-2*o)].filter(i):[]}const r=n[0].y,s=n[1].y,a=n[2].y;let l=3*s-r-3*a+n[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,x=v/2,w=x*x+y*y*y;let T,C,P,k,E;if(w<0){const t=-g/3,e=p(t*t*t),o=-v/(2*e),n=h(o<-1?-1:o>1?1:o),r=2*m(e);return P=r*c(n/3)-d/3,k=r*c((n+b)/3)-d/3,E=r*c((n+2*b)/3)-d/3,[P,k,E].filter(i)}if(0===w)return T=x<0?m(-x):-m(x),P=2*T-d/3,k=-T-d/3,[P,k].filter(i);{const t=p(w);return T=m(-x+t),C=m(x+t),[T-C-d/3].filter(i)}},droots:function(t){if(3===t.length){const e=t[0],o=t[1],n=t[2],i=e-2*o+n;if(0!==i){const t=-p(o*o-e*n),r=-e+o;return[-(t+r)/i,-(-t+r)/i]}return o!==n&&0===i?[(2*o-n)/(2*(o-n))]:[]}if(2===t.length){const e=t[0],o=t[1];return e!==o?[e/(e-o)]:[]}return[]},curvature:function(t,e,o,n,i){let r,s,a,c,d=0,h=0;const u=S.compute(t,e),m=S.compute(t,o),g=u.x*u.x+u.y*u.y;if(n?(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,o,n,!0).k,r=S.curvature(t+.001,e,o,n,!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]}),o=e[2].x*e[1].y,n=e[3].x*e[1].y,i=e[1].x*e[2].y,r=18*(-3*o+2*n+3*i-e[3].x*e[2].y),s=18*(3*o-n-3*i),a=18*(i-o);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 o=["x","y"],n=o.length;for(let i,r,s,a,c=0;c<n;c++)if(i=o[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,o){const n=t.bbox(),i=e.bbox(),r=1e5,s=o||.5;if(n.x.size+n.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,o){const n=e.x-t.x,i=e.y-t.y,r=o.x-e.x,s=o.y-e.y,a=n*c(y)-i*d(y),l=n*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+o.x)/2,v=(e.y+o.y)/2,x=f+a,w=m+l,T=g+h,C=v+p,P=S.lli8(f,m,x,w,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(o.y-P.y,o.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(),o=1;o<t.length;o++)S.expandbox(e,t[o].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(o){e.push(...o.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(),o=!1;if("object"==typeof e[0]){o=e.length;const t=[];e.forEach((function(e){["x","y","z"].forEach((function(o){void 0!==e[o]&&t.push(e[o])}))})),e=t}let n=!1;const i=e.length;if(o){if(o>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");n=!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=!n&&(9===i||12===i)||t&&t[0]&&void 0!==t[0].z,s=this.points=[];for(let t=0,o=r?3:2;t<i;t+=o){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,o,n){if(void 0===n&&(n=.5),0===n)return new R(e,e,o);if(1===n)return new R(t,e,e);const i=R.getABC(2,t,e,o,n);return new R(t,i.A,o)}static cubicFromPoints(t,e,o,n,i){void 0===n&&(n=.5);const r=R.getABC(3,t,e,o,n);void 0===i&&(i=S.dist(e,r.C));const s=i*(1-n)/n,a=S.dist(t,o),l=(o.x-t.x)/a,c=(o.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-n),x=y.y+(m-y.y)/(1-n),w=y.x+(g-y.x)/n,T=y.y+(b-y.y)/n,C={x:t.x+(v-t.x)/n,y:t.y+(x-t.y)/n},P={x:o.x+(w-o.x)/(1-n),y:o.y+(T-o.y)/(1-n)};return new R(t,C,P,o)}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 o=1,n=t.length;o<n;o++)e.push(t[o].x),e.push(t[o].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,o,n,i=.5){const r=S.projectionratio(i,t),s=1-r,a={x:r*e.x+s*n.x,y:r*e.y+s*n.y},l=S.abcratio(i,t);return{A:{x:o.x+(o.x-a.x)/l,y:o.y+(o.y-a.y)/l},B:o,C:a,S:e,E:n}}getABC(t,e){e=e||this.get(t);let o=this.points[0],n=this.points[this.order];return R.getABC(this.order,o,e,n,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,o,n=0;n<t;n++)o=n/(t-1),e=this.compute(o),e.t=o,this._lut.push(e);return this._lut}on(e,o){o=o||5;const n=this.getLUT(),i=[];for(let t,r=0,s=0;r<n.length;r++)t=n[r],S.dist(t,e)<o&&(i.push(t),s+=r/n.length);return!!i.length&&(t/=i.length)}project(t){const e=this.getLUT(),o=e.length-1,n=S.closest(e,t),i=n.mpos,r=(i-1)/o,s=(i+1)/o,a=.1/o;let l,c=n.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]],o=t.length;for(let n,i,r=1;r<o;r++)n=t[r],i=t[r-1],e[r]={x:(o-r)/o*n.x+r/o*i.x,y:(o-r)/o*n.y+r/o*i.y};return e[o]=t[o-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),o=_(e.x*e.x+e.y*e.y);return{t,x:-e.y/o,y:e.x/o}}__normal3(t){const e=this.derivative(t),o=this.derivative(t+.01),n=_(e.x*e.x+e.y*e.y+e.z*e.z),i=_(o.x*o.x+o.y*o.y+o.z*o.z);e.x/=n,e.y/=n,e.z/=n,o.x/=i,o.y/=i,o.z/=i;const r={x:o.y*e.z-o.z*e.y,y:o.z*e.x-o.x*e.z,z:o.x*e.y-o.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,o=[],n=[],i=0;for(n[i++]=e[0],n[i++]=e[1],n[i++]=e[2],3===this.order&&(n[i++]=e[3]);e.length>1;){o=[];for(let r,s=0,a=e.length-1;s<a;s++)r=S.lerp(t,e[s],e[s+1]),n[i++]=r,o.push(r);e=o}return n}split(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;const o=this.hull(t),n={left:2===this.order?new R([o[0],o[3],o[5]]):new R([o[0],o[4],o[7],o[9]]),right:2===this.order?new R([o[5],o[4],o[2]]):new R([o[9],o[8],o[6],o[3]]),span:o};return n.left._t1=S.map(0,0,1,this._t1,this._t2),n.left._t2=S.map(t,0,1,this._t1,this._t2),n.right._t1=S.map(t,0,1,this._t1,this._t2),n.right._t2=S.map(1,0,1,this._t1,this._t2),e?(e=S.map(e,t,1,0,1),n.right.split(e).left):n}extrema(){const t={};let e=[];return this.dims.forEach(function(o){let n=function(t){return t[o]},i=this.dpoints[0].map(n);t[o]=S.droots(i),3===this.order&&(i=this.dpoints[1].map(n),t[o]=t[o].concat(S.droots(i))),t[o]=t[o].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[o].sort(S.numberSort))}.bind(this)),t.values=e.sort(S.numberSort).filter((function(t,o){return e.indexOf(t)===o})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(o){e[o]=S.getminmax(this,o,t[o])}.bind(this)),e}overlaps(t){const e=this.bbox(),o=t.bbox();return S.bboxoverlap(e,o)}offset(t,e){if(void 0!==e){const o=this.get(t),n=this.normal(t),i={c:o,n,x:o.x+n.x*e,y:o.y+n.y*e};return this._3d&&(i.z=o.z+n.z*e),i}if(this._linear){const e=this.normal(0),o=this.points.map((function(o){const n={x:o.x+t*e.x,y:o.y+t*e.y};return o.z&&e.z&&(n.z=o.z+t*e.z),n}));return[new R(o)]}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 o=t.x*e.x+t.y*e.y;return this._3d&&(o+=t.z*e.z),C(M(o))<I/3}reduce(){let t,e,o=0,n=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),o=a[0],t=1;t<a.length;t++)n=a[t],e=this.split(o,n),e._t1=o,e._t2=n,r.push(e),o=n;return r.forEach((function(t){for(o=0,n=0;n<=1;)for(n=o+i;n<=1.01;n+=i)if(e=t.split(o,n),!e.simple()){if(n-=i,C(o-n)<i)return[];e=t.split(o,n),e._t1=S.map(o,0,1,t._t1,t._t2),e._t2=S.map(n,0,1,t._t1,t._t2),s.push(e),o=n;break}o<1&&(e=t.split(o,1),e._t1=S.map(o,0,1,t._t1,t._t2),e._t2=t._t2,s.push(e))})),s}translate(t,e,o){o="number"==typeof o?o:e;const n=this.order;let i=this.points.map(((t,i)=>(1-i/n)*e+i/n*o));return new R(this.points.map(((e,o)=>({x:e.x+t.x*i[o],y:e.y+t.y*i[o]}))))}scale(t){const e=this.order;let o=!1;if("function"==typeof t&&(o=t),o&&2===e)return this.raise().scale(o);const n=this.clockwise,i=this.points;if(this._linear)return this.translate(this.normal(0),o?o(0):t,o?o(1):t);const r=o?o(0):t,s=o?o(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 o=l[t*e]=S.copy(i[t*e]);o.x+=(t?s:r)*a[t].n.x,o.y+=(t?s:r)*a[t].n.y})),o?([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=o?o((r+1)/e):t;o&&!n&&(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 o=l[t*e],n=this.derivative(t),r={x:o.x+n.x,y:o.y+n.y};l[t+1]=S.lli4(o,r,c,i[t+1])})),new R(l))}outline(t,e,o,n){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===o&&(o=t,n=e),a={x:r.x+i.x*t,y:r.y+i.y*t},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 d=[a,l,c];a={x:r.x-i.x*e,y:r.y-i.y*e},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 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!==o&&void 0!==n;function u(t,e,o,n,i){return function(r){const s=n/o,a=(n+i)/o,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,o,d,c,r))),l.push(i.scale(u(-e,-n,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,o){e=e||t;const n=this.outline(t,e).curves,i=[];for(let t=1,e=n.length;t<e/2;t++){const r=S.makeshape(n[t],n[e-t],o);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),o=P(t.p1.y,t.p2.y),n=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,n)&&S.between(r.y,o,i)}))}selfintersects(t){const e=this.reduce(),o=e.length-2,n=[];for(let i,r,s,a=0;a<o;a++)r=e.slice(a,a+1),s=e.slice(a+2),i=this.curveintersects(r,s,t),n.push(...i);return n}curveintersects(t,e,o){const n=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&n.push({left:t,right:e})}))}));let i=[];return n.forEach((function(t){const e=S.pairiteration(t.left,t.right,o);e.length>0&&(i=i.concat(e))})),i}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,o,n){const i=(n-o)/4,r=this.get(o+i),s=this.get(n-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 o,n=0,i=1;do{o=0,i=1;let r,s,a,l,c,d=this.get(n),h=!1,u=!1,p=i,f=1,m=0;do{if(u=h,l=a,p=(n+i)/2,m++,r=this.get(p),s=this.get(i),a=S.getccenter(d,r,s),a.interval={start:n,end:i},h=this._error(a,d,n,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-n)/2}else i=p}while(!c&&o++<100);if(o>=100)break;l=l||a,e.push(l),n=f}while(i<1);return e}};e.exports=s(a)}},o={};function n(t){var i=o[t];if(void 0!==i)return i.exports;var r=o[t]={id:t,exports:{}};return e[t].call(r.exports,r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.nc=void 0;var i=n(2728);window.jsdraw=i})();
|
482
|
+
*)
|
483
|
+
*/
|