js-draw 0.21.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/bundle.js +3 -3
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/src/Color4.js +2 -2
- package/dist/cjs/src/Editor.d.ts +1 -3
- package/dist/cjs/src/EditorImage.js +8 -2
- package/dist/cjs/src/Viewport.js +1 -1
- package/dist/cjs/src/commands/Command.js +1 -1
- package/dist/cjs/src/commands/SerializableCommand.js +1 -1
- package/dist/cjs/src/commands/uniteCommands.js +5 -0
- package/dist/cjs/src/components/AbstractComponent.js +6 -1
- package/dist/cjs/src/components/ImageComponent.d.ts +6 -6
- package/dist/cjs/src/components/ImageComponent.js +17 -12
- package/dist/cjs/src/components/TextComponent.js +1 -1
- package/dist/cjs/src/localizations/de.js +1 -1
- package/dist/cjs/src/math/Mat33.js +1 -1
- package/dist/cjs/src/math/Path.js +1 -1
- package/dist/cjs/src/math/Rect2.js +1 -1
- package/dist/cjs/src/math/Vec3.js +1 -1
- package/dist/cjs/src/rendering/Display.d.ts +1 -1
- package/dist/cjs/src/rendering/Display.js +1 -2
- package/dist/cjs/src/toolbar/HTMLToolbar.d.ts +2 -0
- package/dist/cjs/src/toolbar/HTMLToolbar.js +71 -12
- package/dist/cjs/src/toolbar/localization.d.ts +1 -0
- package/dist/cjs/src/toolbar/localization.js +1 -0
- package/dist/cjs/src/toolbar/makeColorInput.js +8 -0
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.d.ts +0 -1
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.js +0 -1
- package/dist/cjs/src/toolbar/widgets/BaseWidget.d.ts +5 -0
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +24 -7
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.js +1 -1
- package/dist/cjs/src/tools/SelectionTool/Selection.js +5 -2
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.js +1 -1
- package/dist/cjs/src/types.d.ts +2 -0
- package/dist/mjs/src/Color4.mjs +2 -1
- package/dist/mjs/src/Editor.d.ts +1 -3
- package/dist/mjs/src/EditorImage.mjs +10 -2
- package/dist/mjs/src/Viewport.mjs +2 -1
- package/dist/mjs/src/commands/Command.mjs +2 -1
- package/dist/mjs/src/commands/SerializableCommand.mjs +2 -1
- package/dist/mjs/src/commands/uniteCommands.mjs +5 -0
- package/dist/mjs/src/components/AbstractComponent.mjs +7 -1
- package/dist/mjs/src/components/ImageComponent.d.ts +6 -6
- package/dist/mjs/src/components/ImageComponent.mjs +17 -12
- package/dist/mjs/src/components/TextComponent.mjs +2 -1
- package/dist/mjs/src/localizations/de.mjs +1 -1
- package/dist/mjs/src/math/Mat33.mjs +2 -1
- package/dist/mjs/src/math/Path.mjs +2 -1
- package/dist/mjs/src/math/Rect2.mjs +2 -1
- package/dist/mjs/src/math/Vec3.mjs +2 -1
- package/dist/mjs/src/rendering/Display.d.ts +1 -1
- package/dist/mjs/src/rendering/Display.mjs +1 -2
- package/dist/mjs/src/toolbar/HTMLToolbar.d.ts +2 -0
- package/dist/mjs/src/toolbar/HTMLToolbar.mjs +72 -12
- package/dist/mjs/src/toolbar/localization.d.ts +1 -0
- package/dist/mjs/src/toolbar/localization.mjs +1 -0
- package/dist/mjs/src/toolbar/makeColorInput.mjs +8 -0
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.d.ts +0 -1
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.mjs +0 -1
- package/dist/mjs/src/toolbar/widgets/BaseWidget.d.ts +5 -0
- package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +24 -7
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.mjs +2 -1
- package/dist/mjs/src/tools/SelectionTool/Selection.mjs +6 -2
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.mjs +2 -1
- package/dist/mjs/src/types.d.ts +2 -0
- package/package.json +13 -13
- package/src/toolbar/toolbar.css +7 -0
- package/tsconfig-typedoc.json +7 -0
- package/tsconfig.json +2 -0
- package/typedoc.json +1 -0
package/dist/bundle.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
(()=>{var e={7786:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,'.clr-picker {\r\n display: none;\r\n flex-wrap: wrap;\r\n position: absolute;\r\n width: 200px;\r\n z-index: 1000;\r\n border-radius: 10px;\r\n background-color: #fff;\r\n justify-content: flex-end;\r\n direction: ltr;\r\n box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1);\r\n -moz-user-select: none;\r\n -webkit-user-select: none;\r\n user-select: none;\r\n}\r\n\r\n.clr-picker.clr-open,\r\n.clr-picker[data-inline="true"] {\r\n display: flex;\r\n}\r\n\r\n.clr-picker[data-inline="true"] {\r\n position: relative;\r\n}\r\n\r\n.clr-gradient {\r\n position: relative;\r\n width: 100%;\r\n height: 100px;\r\n margin-bottom: 15px;\r\n border-radius: 3px 3px 0 0;\r\n background-image: linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor);\r\n cursor: pointer;\r\n}\r\n\r\n.clr-marker {\r\n position: absolute;\r\n width: 12px;\r\n height: 12px;\r\n margin: -6px 0 0 -6px;\r\n border: 1px solid #fff;\r\n border-radius: 50%;\r\n background-color: currentColor;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-picker input[type="range"]::-webkit-slider-runnable-track {\r\n width: 100%;\r\n height: 8px;\r\n}\r\n\r\n.clr-picker input[type="range"]::-webkit-slider-thumb {\r\n width: 8px;\r\n height: 8px;\r\n -webkit-appearance: none;\r\n}\r\n\r\n.clr-picker input[type="range"]::-moz-range-track {\r\n width: 100%;\r\n height: 8px;\r\n border: 0;\r\n}\r\n\r\n.clr-picker input[type="range"]::-moz-range-thumb {\r\n width: 8px;\r\n height: 8px;\r\n border: 0;\r\n}\r\n\r\n.clr-hue {\r\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%);\r\n}\r\n\r\n.clr-hue,\r\n.clr-alpha {\r\n position: relative;\r\n width: calc(100% - 40px);\r\n height: 8px;\r\n margin: 5px 20px;\r\n border-radius: 4px;\r\n}\r\n\r\n.clr-alpha span {\r\n display: block;\r\n height: 100%;\r\n width: 100%;\r\n border-radius: inherit;\r\n background-image: linear-gradient(90deg, rgba(0,0,0,0), currentColor);\r\n}\r\n\r\n.clr-hue input,\r\n.clr-alpha input {\r\n position: absolute;\r\n width: calc(100% + 16px);\r\n height: 16px;\r\n left: -8px;\r\n top: -4px;\r\n margin: 0;\r\n background-color: transparent;\r\n opacity: 0;\r\n cursor: pointer;\r\n appearance: none;\r\n -webkit-appearance: none;\r\n}\r\n\r\n.clr-hue div,\r\n.clr-alpha div {\r\n position: absolute;\r\n width: 16px;\r\n height: 16px;\r\n left: 0;\r\n top: 50%;\r\n margin-left: -8px;\r\n transform: translateY(-50%);\r\n border: 2px solid #fff;\r\n border-radius: 50%;\r\n background-color: currentColor;\r\n box-shadow: 0 0 1px #888;\r\n pointer-events: none;\r\n}\r\n\r\n.clr-alpha div:before {\r\n content: \'\';\r\n position: absolute;\r\n height: 100%;\r\n width: 100%;\r\n left: 0;\r\n top: 0;\r\n border-radius: 50%;\r\n background-color: currentColor;\r\n}\r\n\r\n.clr-format {\r\n display: none;\r\n order: 1;\r\n width: calc(100% - 40px);\r\n margin: 0 20px 20px;\r\n}\r\n\r\n.clr-segmented {\r\n display: flex;\r\n position: relative;\r\n width: 100%;\r\n margin: 0;\r\n padding: 0;\r\n border: 1px solid #ddd;\r\n border-radius: 15px;\r\n box-sizing: border-box;\r\n color: #999;\r\n font-size: 12px;\r\n}\r\n\r\n.clr-segmented input,\r\n.clr-segmented legend {\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n left: 0;\r\n top: 0;\r\n opacity: 0;\r\n pointer-events: none;\r\n}\r\n\r\n.clr-segmented label {\r\n flex-grow: 1;\r\n margin: 0;\r\n padding: 4px 0;\r\n font-size: inherit;\r\n font-weight: normal;\r\n line-height: initial;\r\n text-align: center;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-segmented label:first-of-type {\r\n border-radius: 10px 0 0 10px;\r\n}\r\n\r\n.clr-segmented label:last-of-type {\r\n border-radius: 0 10px 10px 0;\r\n}\r\n\r\n.clr-segmented input:checked + label {\r\n color: #fff;\r\n background-color: #666;\r\n}\r\n\r\n.clr-swatches {\r\n order: 2;\r\n width: calc(100% - 32px);\r\n margin: 0 16px;\r\n}\r\n\r\n.clr-swatches div {\r\n display: flex;\r\n flex-wrap: wrap;\r\n padding-bottom: 12px;\r\n justify-content: center;\r\n}\r\n\r\n.clr-swatches button {\r\n position: relative;\r\n width: 20px;\r\n height: 20px;\r\n margin: 0 4px 6px 4px;\r\n padding: 0;\r\n border: 0;\r\n border-radius: 50%;\r\n color: inherit;\r\n text-indent: -1000px;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-swatches button:after {\r\n content: \'\';\r\n display: block;\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n left: 0;\r\n top: 0;\r\n border-radius: inherit;\r\n background-color: currentColor;\r\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\r\n}\r\n\r\ninput.clr-color {\r\n order: 1;\r\n width: calc(100% - 80px);\r\n height: 32px;\r\n margin: 15px 20px 20px auto;\r\n padding: 0 10px;\r\n border: 1px solid #ddd;\r\n border-radius: 16px;\r\n color: #444;\r\n background-color: #fff;\r\n font-family: sans-serif;\r\n font-size: 14px;\r\n text-align: center;\r\n box-shadow: none;\r\n}\r\n\r\ninput.clr-color:focus {\r\n outline: none;\r\n border: 1px solid #1e90ff;\r\n}\r\n\r\n.clr-close,\r\n.clr-clear {\r\n display: none;\r\n order: 2;\r\n height: 24px;\r\n margin: 0 20px 20px;\r\n padding: 0 20px;\r\n border: 0;\r\n border-radius: 12px;\r\n color: #fff;\r\n background-color: #666;\r\n font-family: inherit;\r\n font-size: 12px;\r\n font-weight: 400;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-close {\r\n display: block;\r\n margin: 0 20px 20px auto;\r\n}\r\n\r\n.clr-preview {\r\n position: relative;\r\n width: 32px;\r\n height: 32px;\r\n margin: 15px 0 20px 20px;\r\n border-radius: 50%;\r\n overflow: hidden;\r\n}\r\n\r\n.clr-preview:before,\r\n.clr-preview:after {\r\n content: \'\';\r\n position: absolute;\r\n height: 100%;\r\n width: 100%;\r\n left: 0;\r\n top: 0;\r\n border: 1px solid #fff;\r\n border-radius: 50%;\r\n}\r\n\r\n.clr-preview:after {\r\n border: 0;\r\n background-color: currentColor;\r\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\r\n}\r\n\r\n.clr-preview button {\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n z-index: 1;\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n background-color: transparent;\r\n text-indent: -9999px;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-marker,\r\n.clr-hue div,\r\n.clr-alpha div,\r\n.clr-color {\r\n box-sizing: border-box;\r\n}\r\n\r\n.clr-field {\r\n display: inline-block;\r\n position: relative;\r\n color: transparent;\r\n}\r\n\r\n.clr-field input {\r\n margin: 0;\r\n direction: ltr;\r\n}\r\n\r\n.clr-field.clr-rtl input {\r\n text-align: right;\r\n}\r\n\r\n.clr-field button {\r\n position: absolute;\r\n width: 30px;\r\n height: 100%;\r\n right: 0;\r\n top: 50%;\r\n transform: translateY(-50%);\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n color: inherit;\r\n text-indent: -1000px;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n pointer-events: none;\r\n}\r\n\r\n.clr-field.clr-rtl button {\r\n right: auto;\r\n left: 0;\r\n}\r\n\r\n.clr-field button:after {\r\n content: \'\';\r\n display: block;\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n left: 0;\r\n top: 0;\r\n border-radius: inherit;\r\n background-color: currentColor;\r\n box-shadow: inset 0 0 1px rgba(0,0,0,.5);\r\n}\r\n\r\n.clr-alpha,\r\n.clr-alpha div,\r\n.clr-swatches button,\r\n.clr-preview:before,\r\n.clr-field button {\r\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);\r\n background-position: 0 0, 4px 4px;\r\n background-size: 8px 8px;\r\n}\r\n\r\n.clr-marker:focus {\r\n outline: none;\r\n}\r\n\r\n.clr-keyboard-nav .clr-marker:focus,\r\n.clr-keyboard-nav .clr-hue input:focus + div,\r\n.clr-keyboard-nav .clr-alpha input:focus + div,\r\n.clr-keyboard-nav .clr-segmented input:focus + label {\r\n outline: none;\r\n box-shadow: 0 0 0 2px #1e90ff, 0 0 2px 2px #fff;\r\n}\r\n\r\n.clr-picker[data-alpha="false"] .clr-alpha {\r\n display: none;\r\n}\r\n\r\n.clr-picker[data-minimal="true"] {\r\n padding-top: 16px;\r\n}\r\n\r\n.clr-picker[data-minimal="true"] .clr-gradient,\r\n.clr-picker[data-minimal="true"] .clr-hue,\r\n.clr-picker[data-minimal="true"] .clr-alpha,\r\n.clr-picker[data-minimal="true"] .clr-color,\r\n.clr-picker[data-minimal="true"] .clr-preview {\r\n display: none;\r\n}\r\n\r\n/** Dark theme **/\r\n\r\n.clr-dark {\r\n background-color: #444;\r\n}\r\n\r\n.clr-dark .clr-segmented {\r\n border-color: #777;\r\n}\r\n\r\n.clr-dark .clr-swatches button:after {\r\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);\r\n}\r\n\r\n.clr-dark input.clr-color {\r\n color: #fff;\r\n border-color: #777;\r\n background-color: #555;\r\n}\r\n\r\n.clr-dark input.clr-color:focus {\r\n border-color: #1e90ff;\r\n}\r\n\r\n.clr-dark .clr-preview:after {\r\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);\r\n}\r\n\r\n.clr-dark .clr-alpha,\r\n.clr-dark .clr-alpha div,\r\n.clr-dark .clr-swatches button,\r\n.clr-dark .clr-preview:before {\r\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);\r\n}\r\n\r\n/** Polaroid theme **/\r\n\r\n.clr-picker.clr-polaroid {\r\n border-radius: 6px;\r\n box-shadow: 0 0 5px rgba(0,0,0,.1), 0 5px 30px rgba(0,0,0,.2);\r\n}\r\n\r\n.clr-picker.clr-polaroid:before {\r\n content: \'\';\r\n display: block;\r\n position: absolute;\r\n width: 16px;\r\n height: 10px;\r\n left: 20px;\r\n top: -10px;\r\n border: solid transparent;\r\n border-width: 0 8px 10px 8px;\r\n border-bottom-color: currentColor;\r\n box-sizing: border-box;\r\n color: #fff;\r\n filter: drop-shadow(0 -4px 3px rgba(0,0,0,.1));\r\n pointer-events: none;\r\n}\r\n\r\n.clr-picker.clr-polaroid.clr-dark:before {\r\n color: #444;\r\n}\r\n\r\n.clr-picker.clr-polaroid.clr-left:before {\r\n left: auto;\r\n right: 20px;\r\n}\r\n\r\n.clr-picker.clr-polaroid.clr-top:before {\r\n top: auto;\r\n bottom: -10px;\r\n transform: rotateZ(180deg);\r\n}\r\n\r\n.clr-polaroid .clr-gradient {\r\n width: calc(100% - 20px);\r\n height: 120px;\r\n margin: 10px;\r\n border-radius: 3px;\r\n}\r\n\r\n.clr-polaroid .clr-hue,\r\n.clr-polaroid .clr-alpha {\r\n width: calc(100% - 30px);\r\n height: 10px;\r\n margin: 6px 15px;\r\n border-radius: 5px;\r\n}\r\n\r\n.clr-polaroid .clr-hue div,\r\n.clr-polaroid .clr-alpha div {\r\n box-shadow: 0 0 5px rgba(0,0,0,.2);\r\n}\r\n\r\n.clr-polaroid .clr-format {\r\n width: calc(100% - 20px);\r\n margin: 0 10px 15px;\r\n}\r\n\r\n.clr-polaroid .clr-swatches {\r\n width: calc(100% - 12px);\r\n margin: 0 6px;\r\n}\r\n.clr-polaroid .clr-swatches div {\r\n padding-bottom: 10px;\r\n}\r\n\r\n.clr-polaroid .clr-swatches button {\r\n width: 22px;\r\n height: 22px;\r\n}\r\n\r\n.clr-polaroid input.clr-color {\r\n width: calc(100% - 60px);\r\n margin: 10px 10px 15px auto;\r\n}\r\n\r\n.clr-polaroid .clr-clear {\r\n margin: 0 10px 15px 10px;\r\n}\r\n\r\n.clr-polaroid .clr-close {\r\n margin: 0 10px 15px auto;\r\n}\r\n\r\n.clr-polaroid .clr-preview {\r\n margin: 10px 0 15px 10px;\r\n}\r\n\r\n/** Large theme **/\r\n\r\n.clr-picker.clr-large {\r\n width: 275px;\r\n}\r\n\r\n.clr-large .clr-gradient {\r\n height: 150px;\r\n}\r\n\r\n.clr-large .clr-swatches button {\r\n width: 22px;\r\n height: 22px;\r\n}\r\n\r\n/** Pill (horizontal) theme **/\r\n\r\n.clr-picker.clr-pill {\r\n width: 380px;\r\n padding-left: 180px;\r\n box-sizing: border-box;\r\n}\r\n\r\n.clr-pill .clr-gradient {\r\n position: absolute;\r\n width: 180px;\r\n height: 100%;\r\n left: 0;\r\n top: 0;\r\n margin-bottom: 0;\r\n border-radius: 3px 0 0 3px;\r\n}\r\n\r\n.clr-pill .clr-hue {\r\n margin-top: 20px;\r\n}',""]);const a=s},3521:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,'\n/* Imports Coloris\' CSS and makes additional changes to the color picker */\n\n#clr-picker {\n --clr-slider-size: 30px;\n}\n\n/* Coloris: Try to avoid scrolling instead of updating the color input. */\n#clr-picker #clr-color-area, #clr-picker .clr_hue {\n\ttouch-action: none;\n}\n\n/* Increase space between inputs */\n#clr-picker .clr-alpha {\n\tmargin-top: 15px;\n\tmargin-bottom: 15px;\n}\n\n/* Increase size of input thumb to make it easier to select colors. */\n#clr-picker.clr-picker input[type="range"]::-moz-range-thumb {\n\twidth: var(--clr-slider-size);\n\theight: var(--clr-slider-size);\n}\n\n/* Also apply to Chrome/iOS */\n#clr-picker.clr-picker input[type="range"]::-webkit-slider-thumb {\n /*\n Note: This doesn\'t seem to take effect in iOS if it\'s combined with the\n ::-moz-range-thumb rule above\n */\n\twidth: var(--clr-slider-size);\n\theight: var(--clr-slider-size);\n}\n\n#clr-picker.clr-picker input[type="range"]::-webkit-slider-runnable-track {\n\theight: var(--clr-slider-size);\n}\n\n#clr-picker.clr-picker input[type="range"]::-moz-range-track {\n\theight: var(--clr-slider-size);\n}\n\n/*\nDebugging: Uncommenting this rule makes Coloris\' sliders more\nvisible.\n\n#clr-picker.clr-picker input[type="range"] {\n opacity: 0.5;\n -webkit-appearance: auto;\n appearance: auto;\n}\n*/\n',""]);const a=s},4059:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o),a=n(7771),l=n(1443),c=n(3521),d=s()(r());d.i(a.Z),d.i(l.Z),d.i(c.Z),d.push([t.id,"\n.imageEditorContainer {\n\t/* Deafult colors for the editor */\n --primary-background-color: white;\n --primary-background-color-transparent: rgba(255, 255, 255, 0.5);\n --secondary-background-color: #faf;\n --primary-foreground-color: black;\n --secondary-foreground-color: black;\n\t--primary-shadow-color: rgba(0, 0, 0, 0.5);\n}\n\n@media (prefers-color-scheme: dark) {\n\t.imageEditorContainer {\n\t\t--primary-background-color: #151515;\n\t\t--primary-background-color-transparent: rgba(50, 50, 50, 0.5);\n\t\t--secondary-background-color: #607;\n\t\t--primary-foreground-color: white;\n\t\t--secondary-foreground-color: white;\n\t\t--primary-shadow-color: rgba(250, 250, 250, 0.5);\n\t}\n}\n\n.imageEditorContainer {\n\tcolor: var(--primary-foreground-color);\n\tfont-family: system-ui, -apple-system, sans-serif;\n\tbackground-color: var(--primary-background-color);\n\n\tdisplay: flex;\n\tflex-direction: column-reverse;\n}\n\n.imageEditorContainer .imageEditorRenderArea {\n\tdisplay: grid;\n\tgrid-template-columns: 1fr;\n\tflex-grow: 2;\n\tflex-shrink: 1;\n\tmin-height: 100px;\n}\n\n.imageEditorContainer .imageEditorRenderArea canvas {\n\t/* Stack all canvases on top of each other */\n\tgrid-row: 1 / 1;\n\tgrid-column: 1 / 1;\n\ttouch-action: none;\n\n\t/* Fill the container */\n\tbox-sizing: border-box;\n\twidth: 100%;\n\theight: 100%;\n\n\t/* Allow the canvas to shrink (needed in Chrome) */\n\tmin-height: 0px;\n\tmax-height: inherit;\n}\n\n.imageEditorContainer .loadingMessage {\n\tposition: fixed;\n\ttext-align: center;\n\tfont-size: 2em;\n\n\tbottom: 0;\n\tleft: 0;\n\tright: 0;\n}\n\n.imageEditorContainer .accessibilityAnnouncement {\n\topacity: 0;\n\twidth: 0;\n\theight: 0;\n\toverflow: hidden;\n\tpointer-events: none;\n}\n\n.imageEditorContainer .textRendererOutputContainer {\n\twidth: 1px;\n\theight: 1px;\n\toverflow: hidden;\n}\n\n.imageEditorContainer .textRendererOutputContainer:focus-within {\n\toverflow: visible;\n\tz-index: 5;\n}\n\n@media print {\n\t.imageEditorContainer .loadingMessage {\n\t\tdisplay: none;\n\t}\n\n\t.imageEditorContainer .imageEditorRenderArea canvas {\n\t\twidth: 100%;\n\t\theight: initial;\n\t}\n}",""]);const u=d},7771:(t,e,n)=>{"use strict";n.d(e,{Z:()=>d});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o),a=n(6350),l=n(519),c=s()(r());c.i(a.Z),c.i(l.Z),c.push([t.id,".toolbar-root {\n\tbackground-color: var(--primary-background-color);\n\t--icon-color: var(--primary-foreground-color);\n\n\n\tborder: 1px solid var(--secondary-background-color);\n\tborder-radius: 2px;\n\tflex-wrap: wrap;\n\n\tbox-sizing: border-box;\n\twidth: 100%;\n\n\tdisplay: flex;\n\tflex-direction: row;\n\tjustify-content: center;\n\n\t--toolbar-button-height: min(20vh, 60px);\n\n\t/* Display above selection dialogs, etc. */\n\tz-index: 2;\n\n\tfont-family: system-ui, -apple-system, sans-serif;\n}\n\n.toolbar-root > .toolbar-toolContainer > .toolbar-button,\n.toolbar-root > .toolbar-toolContainer > * > button,\n.toolbar-root > .toolbar-buttonGroup > button,\n.toolbar-root > .toolbar-button {\n\twidth: min-content;\n\twhite-space: pre;\n\theight: var(--toolbar-button-height);\n}\n\n.toolbar-dropdown .toolbar-button > .toolbar-icon {\n\tmax-width: 50px;\n\twidth: 100%;\n}\n\n.toolbar-button.disabled {\n\tfilter: opacity(0.5) sepia(0.2);\n\tcursor: unset;\n}\n\n.toolbar-button, .toolbar-root button {\n\tcursor: pointer;\n\ttext-align: center;\n\tborder-radius: 6px;\n\n\t--icon-color: var(--primary-foreground-color);\n\tbackground-color: var(--primary-background-color);\n\tcolor: var(--primary-foreground-color);\n\tborder: none;\n\tbox-shadow: 0px 0px 2px var(--primary-shadow-color);\n\n\ttransition: background-color 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease;\n}\n\n.toolbar-button,\n.toolbar-buttonGroup > button,\n.toolbar-toolContainer > * > button,\n.toolbar-root > button {\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\n\tpadding-left: 3px;\n\tpadding-right: 3px;\n\tmargin-left: 3px;\n\tmargin-right: 3px;\n\n\tmin-width: 40px;\n\twidth: min-content;\n\tfont-size: 1em;\n}\n\n.toolbar-button > label {\n\tcursor: inherit;\n}\n\n.toolbar-dropdown > .toolbar-toolContainer > button,\n.toolbar-dropdown > .toolbar-toolContainer > .toolbar-button {\n\twidth: 6em;\n}\n\n.toolbar-button:not(.disabled):hover, .toolbar-root button:not(:disabled):hover {\n\tbox-shadow: 0px 2px 4px var(--primary-shadow-color);\n}\n\n.toolbar-root button:disabled {\n\tcursor: inherit;\n\tfilter: opacity(0.5);\n}\n\n.toolbar-root .toolbar-icon {\n\tflex-shrink: 1;\n\n\twidth: 100%;\n\tmin-width: 30px;\n\tmin-height: 30px;\n}\n\n.toolbar-toolContainer.selected > .toolbar-button {\n\tbackground-color: var(--secondary-background-color);\n\tcolor: var(--secondary-foreground-color);\n\t--icon-color: var(--secondary-foreground-color);\n}\n\n.toolbar-toolContainer:not(.selected):not(.dropdownShowable) > .toolbar-button > .toolbar-showHideDropdownIcon {\n\tdisplay: none;\n}\n\n.toolbar-toolContainer > .toolbar-button > .toolbar-showHideDropdownIcon {\n\theight: 10px;\n\ttransition: transform 0.5s ease;\n}\n\n.toolbar-toolContainer.dropdownVisible > .toolbar-button > .toolbar-showHideDropdownIcon {\n\ttransform: rotate(180deg);\n}\n\n.toolbar-dropdown.hidden,\n.toolbar-toolContainer:not(.selected):not(.dropdownShowable) > .toolbar-dropdown {\n\tdisplay: none;\n}\n\n.toolbar-dropdown {\n\tposition: absolute;\n\tpadding: 15px;\n\tpadding-top: 5px;\n\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tflex-direction: column;\n\tmax-height: 80vh;\n\n\tmax-width: fit-content;\n\n\t/* Prevent overlap/being displayed under the undo/redo buttons */\n\tz-index: 2;\n\tbackground-color: var(--primary-background-color);\n\tbox-shadow: 0px 3px 3px var(--primary-shadow-color);\n}\n\n.toolbar-buttonGroup {\n\tdisplay: flex;\n\tflex-direction: row;\n\tjustify-content: center;\n}\n\n.toolbar-closeColorPickerOverlay {\n\tdisplay: none;\n\tposition: fixed;\n\ttop: 0;\n\tleft: 0;\n\tbottom: 0;\n\tright: 0;\n\n\ttouch-action: none;\n\n\tbackground-color: var(--primary-background-color);\n\topacity: 0.3;\n}\n\n/* Make color selection buttons fill their containing label */\n.toolbar-dropdown .clr-field button {\n\twidth: 100%;\n\theight: 100%;\n\tborder-radius: 2px;\n\tmargin-left: 0;\n\tmargin-right: 0;\n}\n\n.toolbar-root .toolbar-zoomLevelEditor {\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.toolbar-root .toolbar-zoomLevelEditor .zoomDisplay {\n\tflex-grow: 1;\n}\n\n.toolbar-root .toolbar-zoomLevelEditor button {\n\tmin-width: 48px;\n}\n\n.color-input-container {\n\tdisplay: inline-flex;\n\tflex-direction: row;\n}\n\n.color-input-container .pipetteButton {\n\twidth: 30px;\n\theight: 30px;\n\tpadding: 0;\n\tdisplay: inline-flex;\n}\n\n.color-input-container .pipetteButton > svg {\n\twidth: 100%;\n}\n\n.color-input-container .pipetteButton.active {\n\tbackground-color: var(--secondary-background-color);\n\t--icon-color: var(--secondary-foreground-color);\n}\n\n.toolbar-spacedList > * {\n\tpadding-bottom: 5px;\n\tpadding-top: 5px;\n}\n\n@media print {\n\t/* Hide the toolbar on print. */\n\t.toolbar-root {\n\t\tdisplay: none;\n\t}\n}",""]);const d=c},6350:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.toolbar-image-selection-overlay {\n\tposition: absolute;\n\n\twidth: 100%;\n\theight: 100%;\n\tz-index: 10;\n\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.toolbar-image-selection-overlay > div {\n\tbackground: var(--primary-background-color);\n\tbox-shadow: 1px 1px 3px var(--primary-shadow-color);\n\n\tpadding: 18px;\n\tborder-radius: 3px;\n}\n\n.toolbar-image-selection-overlay > div > div {\n\tpadding: 5px;\n}\n\n.toolbar-image-selection-overlay img {\n\tmax-width: min(50vw, 75%);\n\tmax-height: 50vh;\n\n\t/* Center */\n\tdisplay: block;\n\tmargin-left: auto;\n\tmargin-right: auto;\n}\n\n.toolbar-image-selection-overlay .action-button-row {\n\tmargin-top: 4px;\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.toolbar-image-selection-overlay .action-button-row > button {\n\tflex-grow: 1;\n}",""]);const a=s},519:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.toolbar-overflow-widget-overflow-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\tflex-wrap: wrap;\n\tjustify-content: center;\n}\n\n.toolbar-overflow-widget-overflow-list > .toolbar-toolContainer > .toolbar-button {\n\theight: var(--toolbar-button-height);\n}\n\n.toolbar-overflow-widget.horizontal .toolbar-overflow-widget-overflow-list {\n\tflex-direction: row;\n}\n\n.toolbar-overflow-widget.horizontal > .toolbar-dropdown {\n\tmax-width: 100%;\n\tleft: 15px;\n\tright: 15px;\n\n\t/* Override the default transform and margin-left */\n\tmargin-left: 0 !important;\n\ttransform: none !important;\n\n\tpadding: 4px;\n}",""]);const a=s},3324:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.find-tool-overlay {\n /* Show at the bottom of the screen. */\n order: -1;\n\n position: absolute;\n}",""]);const a=s},6611:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.selection-tool-selection-background {\n background-color: var(--secondary-background-color);\n opacity: 0.5;\n overflow: visible;\n position: absolute;\n}\n\n.selection-tool-handle {\n border: 1px solid var(--primary-foreground-color);\n background: var(--primary-background-color);\n position: absolute;\n cursor: grab;\n}\n\n.selection-tool-handle.selection-tool-circle {\n border-radius: 100%;\n}\n\n.overlay.handleOverlay {\n height: 0;\n overflow: visible;\n}",""]);const a=s},7034:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.js-draw-sound-ui-toggle {\n\twidth: 0px;\n\theight: 0px;\n\toverflow: hidden; \n}\n\n.js-draw-sound-ui-toggle:focus-within, .js-draw-sound-ui-toggle.sound-ui-tool-enabled {\n\toverflow: visible;\n\tz-index: 5;\n}\n\n.js-draw-sound-ui-toggle:not(:focus-within):not(:hover).sound-ui-tool-enabled {\n\topacity: 0.5;\n}\n",""]);const a=s},1443:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o),a=n(6611),l=n(3324),c=n(7034),d=s()(r());d.i(a.Z),d.i(l.Z),d.i(c.Z),d.push([t.id,"",""]);const u=d},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,r,o){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)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]);i&&s[d[0]]||(void 0!==o&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=o),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),r&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=r):d[4]="".concat(r)),e.push(d))}},e}},8081:t=>{"use strict";t.exports=function(t){return t[1]}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var o={},s=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],d=o[c]||0,u="".concat(c," ").concat(d);o[c]=d+1;var h=n(u),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var f=r(p,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:f,references:1})}s.push(u)}return s}function r(t,e){var n=e.domAPI(e);n.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,r){var o=i(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<o.length;s++){var a=n(o[s]);e[a].references--}for(var l=i(t,r),c=0;c<o.length;c++){var d=n(o[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,r&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589: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))}}},8233:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Color4=void 0;const r=i(n(3785));class o{constructor(t,e,n,i){this.r=t,this.g=e,this.b=n,this.a=i,this.hexString=null}static ofRGB(t,e,n){return o.ofRGBA(t,e,n,1)}static ofRGBA(t,e,n,i){return t=Math.max(0,Math.min(t,1)),e=Math.max(0,Math.min(e,1)),n=Math.max(0,Math.min(n,1)),i=Math.max(0,Math.min(i,1)),new o(t,e,n,i)}static fromHex(t){var e;if(!(t=(t=(null!==(e=t.match(/^[#]?(.*)$/))&&void 0!==e?e:[])[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 n=[];for(let e=2;e<=t.length;e+=2){const i=t.substring(e-2,e);n.push(parseInt(i,16)/255)}if(4!==n.length)throw new Error(`Unable to parse ${t}: Wrong number of components.`);return o.ofRGBA(n[0],n[1],n[2],n[3])}static fromString(t){if(t.startsWith("#"))return o.fromHex(t);if("none"===t||"transparent"===t)return o.transparent;const e=t.replace(/\s*/g,"").match(/^rgba?\(([,0-9.]+)\)$/i);if(e){const n=e[1],i=JSON.parse(`[ ${n} ]`);if(3===i.length)return o.ofRGB(i[0]/255,i[1]/255,i[2]/255);if(4===i.length)return o.ofRGBA(i[0]/255,i[1]/255,i[2]/255,i[3]);throw new Error(`RGB string, ${t}, has wrong number of components: ${i.length}`)}const n=document.createElement("canvas");n.width=1,n.height=1;const i=n.getContext("2d");i.fillStyle=t,i.fillRect(0,0,1,1);const r=i.getImageData(0,0,1,1),s=r.data[0]/255,a=r.data[1]/255,l=r.data[2]/255,c=r.data[3]/255;return o.ofRGBA(s,a,l,c)}eq(t){return null!=t&&(0===this.a&&0===t.a||this.toHexString()===t.toHexString())}mix(t,e){const n=1-(e=Math.min(Math.max(e,0),1));return new o(this.r*n+t.r*e,this.g*n+t.g*e,this.b*n+t.b*e,this.a*n+t.a*e)}static average(t){let e=0,n=0,i=0,r=0;for(const o of t)e+=o.a,n+=o.r,i+=o.g,r+=o.b;return t.length>0&&(e/=t.length,n/=t.length,i/=t.length,r/=t.length),new o(n,i,r,e)}asHSV(){const t=Math.min(this.r,this.g,this.b),e=Math.max(this.r,this.g,this.b),n=e-t;let i;i=0===n?0:this.r>=this.g&&this.r>=this.b?(this.g-this.b)/n%6:this.g>=this.r&&this.g>=this.b?(this.b-this.r)/n+2:(this.r-this.g)/n+4,i*=60,i*=Math.PI/180,i<0&&(i+=2*Math.PI);const o=e,s=o>0?n/o:0;return r.default.of(i,s,o)}toHexString(){if(this.hexString)return this.hexString;const t=t=>{const e=Math.round(255*t).toString(16);return 1===e.length?`0${e}`:e},e=t(this.a),n=t(this.r),i=t(this.g),r=t(this.b);return"ff"===e?`#${n}${i}${r}`:(this.hexString=`#${n}${i}${r}${e}`,this.hexString)}toString(){return this.toHexString()}}e.default=o,e.Color4=o,o.transparent=o.ofRGBA(0,0,0,0),o.red=o.ofRGB(1,0,0),o.green=o.ofRGB(0,1,0),o.blue=o.ofRGB(0,0,1),o.purple=o.ofRGB(.5,.2,.5),o.yellow=o.ofRGB(1,1,.1),o.clay=o.ofRGB(.8,.4,.2),o.black=o.ofRGB(0,0,0),o.gray=o.ofRGB(.5,.5,.5),o.white=o.ofRGB(1,1,1)},169:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},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(n(4721)),c=a(n(1769)),d=n(9699),u=a(n(5467)),h=a(n(8831)),p=a(n(5559)),f=n(6750),m=a(n(3785)),g=a(n(7389)),v=o(n(5860)),y=a(n(9563)),b=a(n(8233)),x=a(n(8684)),w=a(n(306)),T=a(n(2054)),S=a(n(7282)),C=a(n(5818)),P=n(1520),k=a(n(972)),E=a(n(2822)),z=a(n(9161)),_=a(n(3966)),M=a(n(1626)),B=a(n(529)),O=o(n(7520)),I=a(n(6485));class R{constructor(t,e={}){var n,i,r,o,s;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.localization=Object.assign(Object.assign({},(0,S.default)()),e.localization),this.settings={wheelEventsEnabled:null===(n=e.wheelEventsEnabled)||void 0===n||n,renderingMode:null!==(i=e.renderingMode)&&void 0!==i?i:v.RenderingMode.CanvasRenderer,localization:this.localization,minZoom:null!==(r=e.minZoom)&&void 0!==r?r:2e-10,maxZoom:null!==(o=e.maxZoom)&&void 0!==o?o:1e12,iconProvider:null!==(s=e.iconProvider)&&void 0!==s?s:new C.default},this.icons=this.settings.iconProvider,this.container=document.createElement("div"),this.renderingRegion=document.createElement("div"),this.container.appendChild(this.renderingRegion),this.container.className="imageEditorContainer",this.loadingWarning=document.createElement("div"),this.loadingWarning.classList.add("loadingMessage"),this.loadingWarning.ariaLive="polite",this.container.appendChild(this.loadingWarning),this.accessibilityControlArea=document.createElement("textarea"),this.accessibilityControlArea.setAttribute("placeholder",this.localization.accessibilityInputInstructions),this.accessibilityControlArea.style.opacity="0",this.accessibilityControlArea.style.width="0",this.accessibilityControlArea.style.height="0",this.accessibilityControlArea.style.position="absolute",this.accessibilityAnnounceArea=document.createElement("div"),this.accessibilityAnnounceArea.setAttribute("aria-live","assertive"),this.accessibilityAnnounceArea.className="accessibilityAnnouncement",this.container.appendChild(this.accessibilityAnnounceArea),this.renderingRegion.style.touchAction="none",this.renderingRegion.className="imageEditorRenderArea",this.renderingRegion.appendChild(this.accessibilityControlArea),this.renderingRegion.setAttribute("tabIndex","0"),this.renderingRegion.setAttribute("alt",""),this.notifier=new p.default,this.viewport=new h.default(((t,e)=>{this.notifier.dispatch(d.EditorEventType.ViewportChanged,{kind:d.EditorEventType.ViewportChanged,newTransform:e,oldTransform:t})})),this.display=new v.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),t.appendChild(this.container),this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.registerListeners(),this.queueRerender(),this.hideLoadingWarning(),this.notifier.on(d.EditorEventType.ViewportChanged,(t=>{if(t.kind===d.EditorEventType.ViewportChanged){const e=t.newTransform.transformVec3(f.Vec2.unitX).length();if(e>this.settings.maxZoom||e<this.settings.minZoom){const e=t.oldTransform.transformVec3(f.Vec2.unitX).length();let n=T.default.identity;e<=this.settings.maxZoom&&e>=this.settings.minZoom&&(n=t.oldTransform),this.viewport.resetTransform(n)}}}))}getRootElement(){return this.container}showLoadingWarning(t){const e=Math.round(100*t);this.loadingWarning.innerText=this.localization.loading(e),this.loadingWarning.style.display="block"}hideLoadingWarning(){this.loadingWarning.style.display="none",this.announceForAccessibility(this.localization.doneLoading)}announceForAccessibility(t){t===this.previousAccessibilityAnnouncement&&(t+=". "),this.accessibilityAnnounceArea.innerText=t,this.previousAccessibilityAnnouncement=t}addToolbar(t=!0){const e=new g.default(this,this.container,this.localization);return t&&e.addDefaults(),e}registerListeners(){this.handlePointerEventsFrom(this.renderingRegion),this.handleKeyEventsFrom(this.renderingRegion),this.container.addEventListener("wheel",(t=>{let e=m.default.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.default.of(0,0,t.deltaY));const n=this.renderingRegion.getBoundingClientRect(),i=f.Vec2.of(t.clientX,t.clientY).minus(f.Vec2.of(n.left,n.top));return!!this.toolController.dispatchInputEvent({kind:d.InputEvtType.WheelEvt,delta:e,screenPos:i})&&(t.preventDefault(),!0)})),this.notifier.on(d.EditorEventType.DisplayResized,(t=>{this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.queueRerender()}));const t=()=>{this.notifier.dispatch(d.EditorEventType.DisplayResized,{kind:d.EditorEventType.DisplayResized,newSize:f.Vec2.of(this.display.width,this.display.height)})};if("ResizeObserver"in window){new ResizeObserver(t).observe(this.container)}else addEventListener("resize",t);this.accessibilityControlArea.addEventListener("input",(()=>{this.accessibilityControlArea.value=""})),document.addEventListener("copy",(t=>{if(!this.isEventSink(document.querySelector(":focus")))return;const e=t.clipboardData;this.toolController.dispatchInputEvent({kind:d.InputEvtType.CopyEvent,setData:(t,n)=>{null==e||e.setData(t,n)}})&&t.preventDefault()})),document.addEventListener("paste",(t=>{this.handlePaste(t)}))}getPointerList(){const t=(new Date).getTime(),e=[];for(const n in this.pointers){const i=2e3;this.pointers[n]&&t-this.pointers[n].timeStamp<i&&e.push(this.pointers[n])}return e}handleHTMLPointerEvent(t,e){var n,i,r;const o=this.renderingRegion,s=null!==(n=e.target)&&void 0!==n?n:this.renderingRegion;if("pointerdown"===t){const t=w.default.ofEvent(e,!0,this.viewport,o);this.pointers[t.id]=t,s.setPointerCapture(t.id);const n={kind:d.InputEvtType.PointerDownEvt,current:t,allPointers:this.getPointerList()};return this.toolController.dispatchInputEvent(n),!0}if("pointermove"===t){const t=w.default.ofEvent(e,null!==(r=null===(i=this.pointers[e.pointerId])||void 0===i?void 0:i.down)&&void 0!==r&&r,this.viewport,o);if(t.down){const n=this.pointers[t.id];if(n){if(t.screenPos.minus(n.screenPos).magnitude()<2)return!1}this.pointers[t.id]=t,this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerMoveEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault()}return!0}if("pointercancel"===t||"pointerup"===t){const t=w.default.ofEvent(e,!1,this.viewport,o);return!!this.pointers[t.id]&&(this.pointers[t.id]=t,s.releasePointerCapture(t.id),this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerUpEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault(),delete this.pointers[t.id],!0)}return t}isEventSink(t){let e=t;for(;null!==e;){for(const t of this.eventListenerTargets)if(t===e)return!0;e=e.parentElement}return!1}handlePaste(t){var e,n;return s(this,void 0,void 0,(function*(){const i=null!==(e=document.querySelector(":focus"))&&void 0!==e?e:t.target;if(!this.isEventSink(i))return;const r=null!==(n=t.dataTransfer)&&void 0!==n?n:t.clipboardData;if(!r)return;for(const e of r.files)if("image/svg+xml"===e.type.toLowerCase()){const n=yield e.text();if(this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e.type,data:n}))return void t.preventDefault()}for(const e of r.files){const n=e.type.toLowerCase();if("image/png"===n||"image/jpg"===n){this.showLoadingWarning(0);const i=t=>{this.showLoadingWarning(t.loaded/t.total)};try{const r=yield(0,z.default)(e,i);if(r&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:n,data:r}))return t.preventDefault(),void this.hideLoadingWarning()}catch(t){console.error("Error reading image:",t)}this.hideLoadingWarning()}}const o=["image/svg+xml","text/plain"];for(const e of o){const n=r.getData(e);if(n&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e,data:n}))return void t.preventDefault()}}))}handlePointerEventsFrom(t,e){const n={touchstart:t=>t.preventDefault(),contextmenu:t=>{t.preventDefault()}},i=["pointerdown","pointermove","pointerup","pointercancel"];for(const t of i)n[t]=n=>{const i=n;return!(!e||e(t,i))||this.handleHTMLPointerEvent(t,i)};for(const e in n)t.addEventListener(e,n[e]);return{remove:()=>{for(const e in n)t.removeEventListener(e,n[e])}}}handleKeyEventsFrom(t){t.addEventListener("keydown",(t=>{"t"===t.key||"T"===t.key?(t.preventDefault(),this.display.rerenderAsText()):this.toolController.dispatchInputEvent({kind:d.InputEvtType.KeyPressEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})?t.preventDefault():"Escape"===t.key&&this.renderingRegion.blur()})),t.addEventListener("keyup",(t=>{this.toolController.dispatchInputEvent({kind:d.InputEvtType.KeyUpEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})&&t.preventDefault()})),t.ondragover=t=>{t.preventDefault()},t.ondrop=t=>{t.preventDefault(),this.handlePaste(t)},this.eventListenerTargets.push(t)}dispatch(t,e=!0){const n=this.dispatchNoAnnounce(t,e);return this.announceForAccessibility(t.description(this,this.localization)),n}dispatchNoAnnounce(t,e=!1){const n=t.apply(this);if(e){const e=!1;this.history.push(t,e)}return n}asyncApplyOrUnapplyCommands(t,e,n){return s(this,void 0,void 0,(function*(){console.assert(n>0),this.display.setDraftMode(!0);for(let i=0;i<t.length;i+=n){this.showLoadingWarning(i/t.length);for(let r=i;r<t.length&&r<i+n;r++){const n=t[r];e?n.apply(this):n.unapply(this)}i+n<t.length&&(yield new Promise((t=>{this.rerender(),requestAnimationFrame(t)})))}this.display.setDraftMode(!1),this.hideLoadingWarning()}))}asyncApplyCommands(t,e){return this.asyncApplyOrUnapplyCommands(t,!0,e)}asyncUnapplyCommands(t,e,n=!1){return n&&(t=[...t]).reverse(),this.asyncApplyOrUnapplyCommands(t,!1,e)}queueRerender(){return this.rerenderQueued||(this.rerenderQueued=!0,requestAnimationFrame((()=>{this.rerenderQueued&&(this.rerender(),this.rerenderQueued=!1)}))),new Promise((t=>{this.nextRerenderListeners.push((()=>t()))}))}isRerenderQueued(){return this.rerenderQueued}rerender(t=!0){if(this.display.startRerender(),0===this.display.width||0===this.display.height)return;const e=this.display.getDryInkRenderer();if(this.image.renderWithCache(e,this.display.getCache(),this.viewport),t){const t={fill:b.default.fromHex("#44444455")},n=5*this.viewport.getSizeOfPixelOnCanvas();e.drawRect(this.getImportExportRect(),n,t)}this.rerenderQueued=!1,this.nextRerenderListeners.forEach((t=>t())),this.nextRerenderListeners=[]}drawWetInk(...t){for(const e of t)this.display.getWetInkRenderer().drawPath(e)}clearWetInk(){this.display.getWetInkRenderer().clear()}focus(){this.renderingRegion.focus()}createHTMLOverlay(t){return t.classList.add("overlay"),this.container.appendChild(t),{remove:()=>t.remove()}}addStyleSheet(t){const e=document.createElement("style");return e.innerText=t,this.container.appendChild(e),e}sendKeyboardEvent(t,e,n=!1,i=!1){this.toolController.dispatchInputEvent({kind:t,key:e,ctrlKey:n,altKey:i})}sendPenEvent(t,e,n){(0,I.default)(this,t,e,n)}addAndCenterComponents(t,e=!0){return s(this,void 0,void 0,(function*(){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,o=i.height/n.height;let s=r;(n.width*s>i.width||n.height*s>i.height)&&(s=o),s*=2/3,s=h.default.roundScaleRatio(s);const a=T.default.translation(i.center.minus(n.center)).rightMul(T.default.scaling2D(s,n.center)),c=[];for(const e of t)c.push(l.default.addElement(e)),c.push(e.transformBy(a));if(yield this.dispatch((0,_.default)(c,100),!0),e)for(const e of this.toolController.getMatchingTools(M.default))e.setEnabled(!0),e.setSelection(t)}))}toDataURL(t="image/png"){const e=document.createElement("canvas"),n=this.image.getImportExportViewport(),i=n.getScreenRectSize();e.width=i.x,e.height=i.y;const r=e.getContext("2d"),o=new k.default(r,n);this.image.renderAll(o);return e.toDataURL(t)}toSVG(){const t=this.image.getImportExportViewport().getTemporaryClone(),{element:e,renderer:n}=y.default.fromViewport(t,!1),i=t.canvasToScreenTransform;t.resetTransform(T.default.identity),this.image.renderAll(n),t.resetTransform(i);const r=t.visibleRect;return e.setAttribute("viewBox",[r.x,r.y,r.w,r.h].map((t=>(0,P.toRoundedString)(t))).join(" ")),e.setAttribute("width",(0,P.toRoundedString)(r.w)),e.setAttribute("height",(0,P.toRoundedString)(r.h)),e}loadFrom(t){return s(this,void 0,void 0,(function*(){this.showLoadingWarning(0),this.display.setDraftMode(!0);const e=this.image.getBackgroundComponents(),n=new B.default(e);yield t.start((t=>s(this,void 0,void 0,(function*(){yield this.dispatchNoAnnounce(l.default.addElement(t))}))),((t,e)=>t%500==0?(this.showLoadingWarning(t/e),this.rerender(),(0,E.default)()):null),(t=>{this.dispatchNoAnnounce(this.setImportExportRect(t),!1),this.dispatchNoAnnounce(this.viewport.zoomTo(t),!1)})),this.image.getBackgroundComponents().length!==e.length&&(yield this.dispatchNoAnnounce(n)),this.hideLoadingWarning(),this.display.setDraftMode(!1),this.queueRerender()}))}getTopmostBackgroundComponent(){let t=null;for(const e of this.image.getBackgroundComponents())e instanceof O.default&&(t=e);return t}setBackgroundColor(t){let e=this.getTopmostBackgroundComponent();if(e)return e.updateStyle({color:t});{const n=t.eq(b.default.transparent)?O.BackgroundType.None:O.BackgroundType.SolidColor;return e=new O.default(n,t),this.image.addElement(e)}}estimateBackgroundColor(){var t;const e=[];for(const n of this.image.getBackgroundComponents())n instanceof O.default&&e.push(null!==(t=n.getStyle().color)&&void 0!==t?t:b.default.transparent);return b.default.average(e)}getImportExportRect(){return this.image.getImportExportViewport().visibleRect}setImportExportRect(t){return this.image.setImportExportRect(t)}loadFromSVG(t,e=!1){return s(this,void 0,void 0,(function*(){const n=x.default.fromString(t,e);yield this.loadFrom(n)}))}}e.Editor=R,e.default=R},4721:function(t,e,n){"use strict";var i,r,o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ImageNode=e.EditorImageEventType=e.sortLeavesByZIndex=void 0;const s=o(n(8831)),a=o(n(7747)),l=o(n(5085)),c=o(n(1386)),d=o(n(5559)),u=n(6750),h=o(n(2054)),p=n(246);var f;e.sortLeavesByZIndex=t=>{t.sort(((t,e)=>t.getContent().getZIndex()-e.getContent().getZIndex()))},function(t){t[t.ExportViewportChanged=0]="ExportViewportChanged"}(f=e.EditorImageEventType||(e.EditorImageEventType={}));class m{constructor(){this.root=new g,this.background=new g,this.componentsById={},this.notifier=new d.default,this.importExportViewport=new s.default((()=>{this.notifier.dispatch(f.ExportViewportChanged,{image:this})})),this.importExportViewport.updateScreenSize(u.Vec2.of(500,500))}getBackgroundComponents(){const t=[],n=this.background.getLeaves();(0,e.sortLeavesByZIndex)(n);for(const e of n){const n=e.getContent();n&&t.push(n)}return t}findParent(t){var e;return null!==(e=this.background.getChildWithContent(t))&&void 0!==e?e:this.root.getChildWithContent(t)}queueRerenderOf(t){const e=this.findParent(t);e&&(e.remove(),this.addElementDirectly(t))}renderWithCache(t,e,n){this.background.render(t,n.visibleRect),e.render(t,this.root,n)}render(t,e){this.background.render(t,null==e?void 0:e.visibleRect),this.root.render(t,null==e?void 0:e.visibleRect)}renderAll(t){this.render(t,null)}getAllElements(){const t=this.root.getLeaves();return(0,e.sortLeavesByZIndex)(t),t.map((t=>t.getContent()))}getElementsIntersectingRegion(t){const n=this.root.getLeavesIntersectingRegion(t);return(0,e.sortLeavesByZIndex)(n),n.map((t=>t.getContent()))}onDestroyElement(t){delete this.componentsById[t.getId()]}lookupElement(t){var e;return null!==(e=this.componentsById[t])&&void 0!==e?e:null}addElementDirectly(t){t.onAddToImage(this),this.componentsById[t.getId()]=t;return(t.isBackground()?this.background:this.root).addLeaf(t)}removeElementDirectly(t){const e=this.findParent(t);return null==e||e.remove(),!!e&&(this.onDestroyElement(t),!0)}static addElement(t,e=!1){return new m.AddElementCommand(t,e)}addElement(t,e){return m.addElement(t,e)}getImportExportViewport(){return this.importExportViewport}setImportExportRect(t){const e=this.getImportExportViewport(),n=e.visibleRect.size,i=e.canvasToScreenTransform;return new m.SetImportExportRectCommand(n,i,t)}}e.default=m,m.AddElementCommand=(i=class extends c.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(){var t;return{elemData:null!==(t=this.serializedElem)&&void 0!==t?t:this.element.serialize()}}},c.default.register("add-element",((t,e)=>{const n=t.elemData.id,i=e.image.lookupElement(n),r=null!=i?i:a.default.deserialize(t.elemData),o=new m.AddElementCommand(r);return o.serializedElem=t.elemData,o})),i),m.SetImportExportRectCommand=((r=class extends c.default{constructor(t,e,n){super(m.SetImportExportRectCommand.commandId),this.originalSize=t,this.originalTransform=e,this.finalRect=n}apply(t){const e=t.image.getImportExportViewport();e.updateScreenSize(this.finalRect.size),e.resetTransform(h.default.translation(this.finalRect.topLeft.times(-1))),t.queueRerender()}unapply(t){const e=t.image.getImportExportViewport();e.updateScreenSize(this.originalSize),e.resetTransform(this.originalTransform),t.queueRerender()}description(t,e){return e.resizeOutputCommand(this.finalRect)}serializeToJSON(){return{originalSize:this.originalSize.xy,originalTransform:this.originalTransform.toArray(),newRegion:{x:this.finalRect.x,y:this.finalRect.y,w:this.finalRect.w,h:this.finalRect.h}}}}).commandId="set-import-export-rect",(()=>{const t=r.commandId;c.default.register(t,((t,e)=>{(0,p.assertIsNumber)(t.originalSize.x),(0,p.assertIsNumber)(t.originalSize.y),(0,p.assertIsNumberArray)(t.originalTransform),(0,p.assertIsNumberArray)([t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h]);const n=u.Vec2.ofXY(t.originalSize),i=new h.default(...t.originalTransform),r=new l.default(t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h);return new m.SetImportExportRectCommand(n,i,r)}))})(),r);class g{constructor(t=null){this.parent=t,this.targetChildCount=30,this.children=[],this.bbox=l.default.empty,this.content=null,this.id=g.idCounter++}getId(){return this.id}onContentChange(){this.id=g.idCounter++}getContent(){return this.content}getParent(){return this.parent}getChildrenIntersectingRegion(t){return this.children.filter((e=>e.getBBox().intersects(t)))}getChildrenOrSelfIntersectingRegion(t){return this.content?[this]:this.getChildrenIntersectingRegion(t)}getLeavesIntersectingRegion(t,e){const n=[];let i;const r=[];r.push(this);const o=()=>{i=void 0;const o=r.pop();o&&!(null==e?void 0:e(o.bbox))&&(i=o,null!==i.content&&i.getBBox().intersection(t)&&n.push(i),r.push(...i.getChildrenIntersectingRegion(t)))};for(;r.length>0;)o();return n}getChildWithContent(t){const e=this.getLeavesIntersectingRegion(t.getBBox());for(const n of e)if(n.getContent()===t)return n;return null}getLeaves(){if(this.content)return[this];const t=[];for(const e of this.children)t.push(...e.getLeaves());return t}addLeaf(t){if(this.onContentChange(),null===this.content&&0===this.children.length)return this.content=t,this.recomputeBBox(!0),this;if(null!==this.content){console.assert(0===this.children.length);const t=new g(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 g(this);if(this.children.length<this.targetChildCount)this.children.push(e);else{const t=new g(this);t.children=this.children,this.children=[e,t],t.recomputeBBox(!0),t.updateParents()}return e.addLeaf(t)}const n=this.children.filter((t=>t.getBBox().containsRect(e)));if(n.length>0&&this.children.length>=this.targetChildCount){n.sort(((t,e)=>t.getBBox().area-e.getBBox().area));const e=n[0].addLeaf(t);return e.rebalance(),e}const i=new g(this);return this.children.push(i),i.content=t,i.recomputeBBox(!0),i}getBBox(){return this.bbox}recomputeBBox(t){var e;const n=this.bbox;null!==this.content?this.bbox=this.content.getBBox():this.bbox=l.default.union(...this.children.map((t=>t.getBBox()))),t&&!n.eq(this.bbox)&&(null===(e=this.parent)||void 0===e||e.recomputeBBox(!0))}updateParents(t=!1){for(const e of this.children)e.parent=this,t&&e.updateParents(t)}rebalance(){if(this.parent&&1===this.parent.children.length){console.assert(null===this.parent.content),console.assert(this.parent.children[0]===this);const t=this.parent;null!==t.parent?(t.children=[],this.parent=t.parent,this.parent.children.push(this),t.parent=null,this.parent.recomputeBBox(!1)):null===this.content&&(this.parent.children=this.children,this.parent.updateParents(),this.parent=null)}}remove(){var t;if(null===(t=this.content)||void 0===t||t.onRemoveFromImage(),!this.parent)return this.content=null,void(this.children=[]);const e=this.parent.children.length;this.parent.children=this.parent.children.filter((t=>t!==this)),console.assert(this.parent.children.length===e-1,`${e-1} ≠ ${this.parent.children.length} after removing all nodes equal to ${this}. Nodes should only be removed once.`),this.parent.children.forEach((t=>{t.rebalance()})),this.parent.recomputeBBox(!0),this.content=null,this.parent=null,this.children=[]}render(t,n){let i;i=n?this.getLeavesIntersectingRegion(n,(e=>t.isTooSmallToRender(e))):this.getLeaves(),(0,e.sortLeavesByZIndex)(i);for(const e of i)e.getContent().render(t,n)}}e.ImageNode=g,g.idCounter=0},5559:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.listeners={}}dispatch(t,e){const n=this.listeners[t];if(n)for(let t=0;t<n.length;t++)n[t](e)}on(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),{remove:()=>{const n=this.listeners[t];return this.off(t,e),n.length!==this.listeners[t].length}}}off(t,e){const n=this.listeners[t];n&&(this.listeners[t]=n.filter((t=>t!==e)))}}},306:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointerDevice=void 0;const i=n(6750);var r;!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"}(r=e.PointerDevice||(e.PointerDevice={}));class o{constructor(t,e,n,i,r,o,s,a){this.screenPos=t,this.canvasPos=e,this.pressure=n,this.isPrimary=i,this.down=r,this.device=o,this.id=s,this.timeStamp=a}snappedToGrid(t){const e=t.snapToGrid(this.canvasPos),n=t.canvasToScreen(e);return new o(n,e,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(t,e,n,s){var a,l;let c=i.Vec2.of(t.clientX,t.clientY);if(s){const t=s.getBoundingClientRect();c=c.minus(i.Vec2.of(t.left,t.top))}let d=null!==(a={mouse:r.PrimaryButtonMouse,pen:r.Pen,touch:r.Touch}[t.pointerType])&&void 0!==a?a:r.Other;d===r.Pen&&0!=(32&t.buttons)&&(d=r.Eraser);const u=(new Date).getTime(),h=n.roundPoint(n.screenToCanvas(c));return d===r.PrimaryButtonMouse&&(2&t.buttons?d=r.RightButtonMouse:1&t.buttons||(d=r.Other)),new o(c,h,null!==(l=t.pressure)&&void 0!==l?l:null,t.isPrimary,e,d,t.pointerId,u)}static ofCanvasPoint(t,e,n,i=0,s=r.Pen,a=!0,l=null){const c=n.canvasToScreen(t),d=(new Date).getTime();return new o(c,t,l,a,e,s,i,d)}}e.default=o},8684:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.svgStyleAttributesDataKey=e.svgAttributesDataKey=e.defaultSVGViewRect=void 0;const l=a(n(8233)),c=o(n(7520)),d=a(n(5249)),u=a(n(9984)),h=a(n(9276)),p=a(n(6205)),f=a(n(5807)),m=a(n(2054)),g=a(n(9765)),v=a(n(5085)),y=n(6750);e.defaultSVGViewRect=new v.default(0,0,500,500),e.svgAttributesDataKey="svgAttrs",e.svgStyleAttributesDataKey="svgStyleAttrs";const b=["stroke","fill","stroke-width"];class x{constructor(t,e,n=!0){this.source=t,this.onFinish=e,this.storeUnknown=n,this.onAddComponent=null,this.onProgress=null,this.onDetermineExportRect=null,this.processedCount=0,this.totalToProcess=0}getStyle(t,e){var n,i,r,o,s,a;let c,d=l.default.transparent;const u=null!==(i=null!==(n=t.getAttribute("fill"))&&void 0!==n?n:null==e?void 0:e.fill)&&void 0!==i?i:t.style.fill;if(u)try{d=l.default.fromString(u)}catch(t){console.error("Unknown fill color,",u)}const h=null!==(o=null!==(r=t.getAttribute("stroke"))&&void 0!==r?r:null==e?void 0:e.stroke)&&void 0!==o?o:t.style.stroke,p=null!==(a=null!==(s=t.getAttribute("stroke-width"))&&void 0!==s?s:null==e?void 0:e.strokeWidth)&&void 0!==a?a:t.style.strokeWidth;if(h&&p)try{let t=parseFloat(null!=p?p:"1");isFinite(t)||(t=0);const e=l.default.fromString(h);e.a>0&&(c={width:t,color:e})}catch(t){console.error("Error parsing stroke data:",t)}return{fill:d,stroke:c}}strokeDataFromElem(t){var e;const n=[],i=null!==(e=t.getAttribute("d"))&&void 0!==e?e:"",r=this.getStyle(t),o=i.split("M");let s=!0;for(const t of o){const e=/^[0-9., \t\n]+$/.exec(t);if(""!==t&&!e){const e=s?t:`M${t}`,i=g.default.fromString(e).toRenderable(r);n.push(i)}s=!1}return n}attachUnrecognisedAttrs(t,n,i,r){if(this.storeUnknown){for(const o of n.getAttributeNames())i.has(o)||"style"===o&&r||t.attachLoadSaveData(e.svgAttributesDataKey,[o,n.getAttribute(o)]);if(r&&n.style)for(const i of n.style)""!==i&&i&&(r.has(i)||t.attachLoadSaveData(e.svgStyleAttributesDataKey,{key:i,value:n.style.getPropertyValue(i),priority:n.style.getPropertyPriority(i)}))}}addPath(t){var e;return s(this,void 0,void 0,(function*(){let n;try{const e=this.strokeDataFromElem(t);n=new u.default(e),this.attachUnrecognisedAttrs(n,t,new Set([...b,"d"]),new Set(b))}catch(e){if(console.error("Invalid path in node",t,"\nError:",e,"\nAdding as an unknown object."),!this.storeUnknown)return;n=new f.default(t)}yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,n)}))}addBackground(t){var e,n,i,r;return s(this,void 0,void 0,(function*(){if(t.classList.contains(c.backgroundTypeToClassNameMap[c.BackgroundType.Grid])){let n,i,r,o,s;if("g"===t.tagName.toLowerCase()){if(2!==t.children.length)return void(yield this.addUnknownNode(t));const e=t.children[0],o=t.children[1];i=e.getAttribute("fill"),n=o.getAttribute("stroke"),r=o.getAttribute("stroke-width")}else i=t.getAttribute("fill"),n=t.getAttribute("stroke"),r=t.getAttribute("stroke-width");if(null!=i||(i=l.default.transparent.toHexString()),!n)return void(yield this.addUnknownNode(t));for(const e of t.classList)if(e.startsWith(c.imageBackgroundGridSizeCSSPrefix)){const t=e.substring(c.imageBackgroundGridSizeCSSPrefix.length);o=parseFloat(t.replace(/p/g,"."))}r&&(s=parseFloat(r));const a=l.default.fromString(i);let d=l.default.fromString(n);t.classList.contains(c.imageBackgroundNonAutomaticSecondaryColorCSSClassName)||(d=void 0);const u=c.default.ofGrid(a,o,d,s);yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,u)}else if("path"===t.tagName.toLowerCase()){const e=l.default.fromString(null!==(i=null!==(n=t.getAttribute("fill"))&&void 0!==n?n:t.style.fill)&&void 0!==i?i:"black"),o=new c.default(c.BackgroundType.SolidColor,e);yield null===(r=this.onAddComponent)||void 0===r?void 0:r.call(this,o)}else yield this.addUnknownNode(t)}))}getTransform(t,e,n){null!=n||(n=window.getComputedStyle(t));let i,r=n.transform;""!==r&&"none"!==r||(r=t.style.transform||"none");try{i=m.default.fromCSSMatrix(t.style.transform)}catch(t){i=m.default.fromCSSMatrix(r)}const o=t.getAttribute("x"),s=t.getAttribute("y");if(o||s){const t=parseFloat(null!=o?o:"0"),n=parseFloat(null!=s?s:"0");isNaN(t)||isNaN(n)||(null==e||e.push("x","y"),i=i.rightMul(m.default.translation(y.Vec2.of(t,n))))}return i}makeText(t){var e;const n=[];for(const i of t.childNodes)if(i.nodeType===Node.TEXT_NODE)n.push(null!==(e=i.nodeValue)&&void 0!==e?e:"");else{if(i.nodeType!==Node.ELEMENT_NODE)throw new Error(`Unrecognized text child node: ${i}.`);{const t=i;if("tspan"!==t.tagName.toLowerCase())throw new Error(`Unrecognized text child element: ${t}`);n.push(this.makeText(t))}}0===n.length&&n.push("");const i=window.getComputedStyle(t),r=/^([-0-9.e]+)px/i;let o=r.exec(t.style.fontSize);!o&&"tspan"===t.tagName.toLowerCase()&&t.parentElement&&(o=r.exec(t.parentElement.style.fontSize)),o||(o=r.exec(i.fontSize));const s=["fontFamily","transform",...b];let a=12;o&&(s.push("fontSize"),a=parseFloat(o[1]));const l={size:a,fontFamily:i.fontFamily||t.style.fontFamily||"sans-serif",renderingStyle:this.getStyle(t,i)},c=[],d=this.getTransform(t,c,i),u=new p.default(n,d,l);return this.attachUnrecognisedAttrs(u,t,new Set(c),new Set(s)),u}addText(t){var e;return s(this,void 0,void 0,(function*(){try{const n=this.makeText(t);yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,n)}catch(e){console.error("Invalid text object in node",t,". Continuing.... Error:",e),this.addUnknownNode(t)}}))}addImage(t){var e,n,i;return s(this,void 0,void 0,(function*(){const r=new Image;r.src=null!==(e=t.getAttribute("xlink:href"))&&void 0!==e?e:t.href.baseVal,r.setAttribute("alt",null!==(n=t.getAttribute("aria-label"))&&void 0!==n?n:"");try{const e=[],n=this.getTransform(t,e),o=yield d.default.fromImage(r,n);this.attachUnrecognisedAttrs(o,t,new Set(e),new Set(["transform"])),yield null===(i=this.onAddComponent)||void 0===i?void 0:i.call(this,o)}catch(e){console.error("Error loading image:",e,". Element: ",t,". Continuing..."),yield this.addUnknownNode(t)}}))}addUnknownNode(t){var e;return s(this,void 0,void 0,(function*(){if(this.storeUnknown){const n=new f.default(t);yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,n)}}))}updateViewBox(t){var e;const n=t.getAttribute("viewBox");if(this.rootViewBox||!n)return;const i=n.split(/[ \t\n,]+/),r=parseFloat(i[0]),o=parseFloat(i[1]),s=parseFloat(i[2]),a=parseFloat(i[3]);isNaN(r)||isNaN(o)||isNaN(s)||isNaN(a)?console.warn(`node ${t} has an unparsable viewbox. Viewbox: ${n}. Match: ${i}.`):(this.rootViewBox=new v.default(r,o,s,a),null===(e=this.onDetermineExportRect)||void 0===e||e.call(this,this.rootViewBox))}updateSVGAttrs(t){var e;return s(this,void 0,void 0,(function*(){this.storeUnknown&&(yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,new h.default(this.getSourceAttrs(t))))}))}visit(t){var e;return s(this,void 0,void 0,(function*(){this.totalToProcess+=t.childElementCount;let n=!0;switch(t.tagName.toLowerCase()){case"g":t.classList.contains(c.imageBackgroundCSSClassName)&&(yield this.addBackground(t),n=!1);break;case"path":t.classList.contains(c.imageBackgroundCSSClassName)?yield this.addBackground(t):yield this.addPath(t);break;case"text":yield this.addText(t),n=!1;break;case"image":yield this.addImage(t),n=!1;break;case"svg":this.updateViewBox(t),this.updateSVGAttrs(t);break;case"style":yield this.addUnknownNode(t);break;default:return console.warn("Unknown SVG element,",t),t instanceof SVGElement||console.warn("Element",t,"is not an SVGElement!",this.storeUnknown?"Continuing anyway.":"Skipping."),void(yield this.addUnknownNode(t))}if(n)for(const e of t.children)yield this.visit(e);this.processedCount++,yield null===(e=this.onProgress)||void 0===e?void 0:e.call(this,this.processedCount,this.totalToProcess)}))}getSourceAttrs(t){return t.getAttributeNames().map((e=>[e,t.getAttribute(e)]))}start(t,n,i=null){var r,o;return s(this,void 0,void 0,(function*(){this.onAddComponent=t,this.onProgress=n,this.onDetermineExportRect=i,this.totalToProcess=this.source.childElementCount,this.processedCount=0,this.rootViewBox=null,yield this.visit(this.source);this.rootViewBox||null===(r=this.onDetermineExportRect)||void 0===r||r.call(this,e.defaultSVGViewRect),null===(o=this.onFinish)||void 0===o||o.call(this)}))}static fromString(t,e=!1){var n,i;const r=document.createElement("iframe");if(r.src="about:blank",r.setAttribute("sandbox","allow-same-origin"),r.setAttribute("csp","default-src 'about:blank'"),r.style.display="none",document.body.appendChild(r),!r.hasAttribute("sandbox"))throw r.remove(),new Error("SVG loading iframe is not sandboxed.");const o=null!==(i=null===(n=r.contentWindow)||void 0===n?void 0:n.document)&&void 0!==i?i:r.contentDocument;if(null==o)throw new Error("Unable to open a sandboxed iframe!");o.open(),o.write("\n\t\t\t<!DOCTYPE html>\n\t\t\t<html>\n\t\t\t\t<head>\n\t\t\t\t\t<title>SVG Loading Sandbox</title>\n\t\t\t\t\t<meta name='viewport' conent='width=device-width,initial-scale=1.0'/>\n\t\t\t\t\t<meta charset='utf-8'/>\n\t\t\t\t</head>\n\t\t\t\t<body style='font-size: 12px;'>\n\t\t\t\t\t<script>\n\t\t\t\t\t\tconsole.error('JavaScript should not be able to run here!');\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The SVG sandbox is broken! Please double-check the sandboxing setting.'\n\t\t\t\t\t\t);\n\t\t\t\t\t<\/script>\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t"),o.close();const s=o.createElementNS("http://www.w3.org/2000/svg","svg");return s.innerHTML=t,o.body.appendChild(s),new x(s,(()=>{s.remove(),r.remove()}),!e)}}e.default=x},5467:function(t,e,n){"use strict";var i,r,o=this&&this.__classPrivateFieldSet||function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const a=n(9699);i=new WeakMap,r=new WeakMap,e.default=class{constructor(t,e,n){this.editor=t,this.announceRedoCallback=e,this.announceUndoCallback=n,i.set(this,void 0),r.set(this,void 0),this.maxUndoRedoStackSize=700,o(this,i,[],"f"),o(this,r,[],"f")}fireUpdateEvent(t,e){this.editor.notifier.dispatch(a.EditorEventType.UndoRedoStackUpdated,{kind:a.EditorEventType.UndoRedoStackUpdated,undoStackSize:s(this,i,"f").length,redoStackSize:s(this,r,"f").length,command:e,stackUpdateType:t})}push(t,e=!0){e&&t.apply(this.editor),s(this,i,"f").push(t);for(const t of s(this,r,"f"))t.onDrop(this.editor);if(o(this,r,[],"f"),s(this,i,"f").length>this.maxUndoRedoStackSize){const t=Math.ceil(this.maxUndoRedoStackSize/100);s(this,i,"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,i,"f").pop();t&&(s(this,r,"f").push(t),t.unapply(this.editor),this.announceUndoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandUndone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandUndone,{kind:a.EditorEventType.CommandUndone,command:t}))}redo(){const t=s(this,r,"f").pop();t&&(s(this,i,"f").push(t),t.apply(this.editor),this.announceRedoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandRedone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandDone,{kind:a.EditorEventType.CommandDone,command:t}))}get undoStackSize(){return s(this,i,"f").length}get redoStackSize(){return s(this,r,"f").length}}},8831:function(t,e,n){"use strict";var i,r,o=this&&this.__classPrivateFieldSet||function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Viewport=e.ViewportTransform=void 0;const l=a(n(9205)),c=a(n(2054)),d=a(n(5085)),u=n(6750),h=a(n(3785));class p extends l.default{}e.ViewportTransform=p;class f{constructor(t){this.onTransformChangeCallback=t,this.resetTransform(c.default.identity),this.screenRect=d.default.empty}getTemporaryClone(){const t=new f((()=>{}));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 f.ViewportTransform(t)}resetTransform(t=c.default.identity){var e;const n=this.transform;this.transform=t,this.inverseTransform=t.inverse(),null===(e=this.onTransformChangeCallback)||void 0===e||e.call(this,n,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(h.default.unitX).magnitude()}getScaleFactorToNearestPowerOfTen(){return this.getScaleFactorToNearestPowerOf(10)}getScaleFactorToNearestPowerOf(t){const e=this.getScaleFactor();return Math.pow(t,Math.round(Math.log(e)/Math.log(t)))}static getGridSize(t){return 50/t}snapToGrid(t){const e=this.getScaleFactorToNearestPowerOf(2),n=t=>{const n=1/f.getGridSize(e);return Math.round(t*n)/n};return u.Vec2.of(n(t.x),n(t.y))}getSizeOfPixelOnCanvas(){return 1/this.getScaleFactor()}getRotationAngle(){return this.transform.transformVec3(h.default.unitX).angle()}static roundPoint(t,e){const n=Math.pow(10,Math.floor(Math.log10(e))),i=t=>Math.round(t/n)*n;return"number"==typeof t?i(t):t.map(i)}roundPoint(t){return f.roundPoint(t,1/this.getScaleFactor())}static roundScaleRatio(t,e=1){if(Math.abs(t)<=1e-12)return 0;const n=Math.pow(10,Math.floor(Math.log10(Math.abs(t)))),i=Math.pow(2,e);return t=Math.round(t/n*i)/i*n}computeZoomToTransform(t,e=!0,n=!0){let i=c.default.identity;if(0===t.w||0===t.h)throw new Error(`${t.toString()} rectangle is empty! Cannot zoom to!`);if(isNaN(t.size.magnitude()))throw new Error(`${t.toString()} rectangle has NaN size! Cannot zoom to!`);const r=()=>{const t=this.visibleRect.transformedBoundingBox(i.inverse());return t.transformedBoundingBox(c.default.scaling2D(.8,t.center))};let o=r();const s=o.w<t.w||o.h<t.h,a=t.maxDimension/o.maxDimension<1/3;if(s&&n||a&&e){const e=Math.max(t.w/o.w,t.h/o.h),n=c.default.scaling2D(e,o.topLeft).inverse();i=i.rightMul(n)}if(o=r(),!o.containsRect(t)){const e=t.center.minus(o.center),n=c.default.translation(e).inverse();i=i.rightMul(n)}return i.invertable()||(console.warn("Unable to zoom to ",t,"! Computed transform",i,"is singular."),i=c.default.identity),i}zoomTo(t,e=!0,n=!0){const i=this.computeZoomToTransform(t,e,n);return new f.ViewportTransform(i)}}e.Viewport=f,f.ViewportTransform=(r=class extends p{constructor(t){super(),this.transform=t,i.set(this,void 0),o(this,i,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,i,"f"))),t.queueRerender()}description(t,e){const n=[],i=t.viewport.visibleRect.center,r=this.transform.transformVec3(u.Vec2.unitX),o=this.transform.transformVec2(i),s=r.magnitude(),a=180/Math.PI*r.angle(),l=o.minus(i);s>1.2?n.push(e.zoomedIn):s<.8&&n.push(e.zoomedOut),Math.floor(Math.abs(a))>0&&n.push(e.rotatedBy(Math.round(a)));const c=1e-4;return l.x>c?n.push(e.movedLeft):l.x<-1e-4&&n.push(e.movedRight),l.y<-1e-4?n.push(e.movedDown):l.y>c&&n.push(e.movedUp),n.join("; ")}},i=new WeakMap,r),e.default=f},8088:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),n(3732);const s=o(n(169));r(n(5563),e),e.default=s.default},9205:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Command=void 0;class n{onDrop(t){}static union(t,e){return new class extends n{apply(n){t.apply(n),e.apply(n)}unapply(n){e.unapply(n),t.unapply(n)}description(n,i){const r=t.description(n,i),o=e.description(n,i);return r===o?r:`${r}, ${o}`}}}}e.Command=n,n.empty=new class extends n{description(t,e){return""}apply(t){}unapply(t){}},e.default=n},9098:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(6792)),o=i(n(529)),s=i(n(1386));class a extends s.default{constructor(t){super("duplicate"),this.toDuplicate=t,this.duplicates=t.map((t=>t.clone())),this.reverse=new o.default(this.duplicates)}apply(t){this.reverse.unapply(t)}unapply(t){this.reverse.apply(t)}description(t,e){var n;return 0===this.duplicates.length?e.duplicatedNoElements:e.duplicateAction(null!==(n=(0,r.default)(e,this.duplicates))&&void 0!==n?n:e.elements,this.duplicates.length)}serializeToJSON(){return this.toDuplicate.map((t=>t.getId()))}}e.default=a,s.default.register("duplicate",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t)));return new a(n)}))},529:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(6792)),o=i(n(4721)),s=i(n(1386));class a extends s.default{constructor(t){super("erase"),this.toRemove=t.map((t=>t)),this.applied=!1}apply(t){for(const e of this.toRemove){const n=t.image.findParent(e);n&&n.remove()}this.applied=!0,t.queueRerender()}unapply(t){for(const e of this.toRemove)t.image.findParent(e)||o.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){var n;if(0===this.toRemove.length)return e.erasedNoElements;const i=null!==(n=(0,r.default)(e,this.toRemove))&&void 0!==n?n:e.elements;return e.eraseAction(i,this.toRemove.length)}serializeToJSON(){return this.toRemove.map((t=>t.getId()))}}e.default=a,s.default.register("erase",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t))).filter((t=>null!==t));return new a(n)}))},1386:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9205));class o extends r.default{constructor(t){if(super(),this.commandTypeId=t,!(t in o.deserializationCallbacks))throw new Error(`Command ${t} must have a registered deserialization callback. To do this, call SerializableCommand.register.`)}serialize(){return{data:this.serializeToJSON(),commandType:this.commandTypeId}}static deserialize(t,e){const n="string"==typeof t?JSON.parse(t):t,i=n.commandType;if(!(i in o.deserializationCallbacks))throw new Error(`Unrecognised command type ${i}!`);return o.deserializationCallbacks[i](n.data,e)}static register(t,e){o.deserializationCallbacks[t]=e}}e.default=o,o.deserializationCallbacks={}},6498:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(1386));class o extends r.default{constructor(t,e,n){super(t),this.component=null!=n?n:null,this.componentID=e}resolveComponent(t){if(this.component)return;const e=t.lookupElement(this.componentID);if(!e)throw new Error(`Unable to resolve component with ID ${this.componentID}`);this.component=e}}e.default=o},1408:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9205)),o=i(n(1386)),s=t=>{if(t instanceof o.default)return new class extends o.default{serializeToJSON(){return t.serialize()}apply(e){t.unapply(e)}unapply(e){t.unapply(e)}description(e,n){return n.inverseOf(t.description(e,n))}}("inverse");return new class extends r.default{apply(e){t.unapply(e)}unapply(e){t.apply(e)}description(e,n){return n.inverseOf(t.description(e,n))}}};o.default.register("inverse",((t,e)=>s(o.default.deserialize(t,e)))),e.default=s},3707:function(t,e,n){"use strict";var i=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 r=i(n(9205));e.Command=r.default;const o=i(n(9098));e.Duplicate=o.default;const s=i(n(529));e.Erase=s.default;const a=i(n(1408));e.invertCommand=a.default;const l=i(n(1386));e.SerializableCommand=l.default;const c=i(n(3966));e.uniteCommands=c.default},3814:(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}`,addElementAction:t=>`Added ${t}`,eraseAction:(t,e)=>`Erased ${e} ${t}`,duplicateAction:(t,e)=>`Duplicated ${e} ${t}`,unionOf:(t,e)=>`Union: ${e} ${t}`,inverseOf:t=>`Inverse of ${t}`,elements:"Elements",erasedNoElements:"Erased nothing",duplicatedNoElements:"Duplicated nothing",rotatedBy:t=>`Rotated by ${Math.abs(t)} degrees ${t<0?"clockwise":"counter-clockwise"}`,movedLeft:"Moved left",movedUp:"Moved up",movedDown:"Moved down",movedRight:"Moved right",zoomedOut:"Zoomed out",zoomedIn:"Zoomed in",selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`}},3966:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9205)),o=i(n(1386));class s extends r.default{constructor(t,e){super(),this.commands=t,this.applyChunkSize=e}static waitForAll(t){if(t.some((t=>t&&t.then)))return console.log("waiting..."),Promise.all(t).then((()=>{}))}apply(t){if(void 0===this.applyChunkSize){const e=this.commands.map((e=>e.apply(t)));return s.waitForAll(e)}return t.asyncApplyCommands(this.commands,this.applyChunkSize)}unapply(t){const e=[...this.commands];if(e.reverse(),void 0===this.applyChunkSize){const n=e.map((e=>e.unapply(t)));return s.waitForAll(n)}return t.asyncUnapplyCommands(e,this.applyChunkSize,!1)}description(t,e){const n=[];let i=null,r=0;for(const o of this.commands){const s=o.description(t,e);s!==i&&null!==i&&(n.push(e.unionOf(i,r)),i=null,r=0),r++,null!=i||(i=s)}return r>1?n.push(e.unionOf(i,r)):1===r&&n.push(i),n.join(", ")}}class a extends o.default{constructor(t,e){super("union"),this.commands=t,this.applyChunkSize=e,this.nonserializableCommand=new s(t,e)}serializeToJSON(){return{applyChunkSize:this.applyChunkSize,data:this.commands.map((t=>t.serialize()))}}apply(t){return this.nonserializableCommand.apply(t)}unapply(t){return this.nonserializableCommand.unapply(t)}description(t,e){return this.nonserializableCommand.description(t,e)}}const l=(t,e)=>{let n=!0;for(const e of t)if(!(e instanceof o.default)){n=!1;break}if(n){return new a(t,e)}return new s(t,e)};o.default.register("union",((t,e)=>{if("number"!=typeof t.data.length)throw new Error("Unions of commands must serialize to lists of serialization data.");const n=t.applyChunkSize;if("number"!=typeof n&&void 0!==n)throw new Error("serialized applyChunkSize is neither undefined nor a number.");const i=[];for(const n of t.data)i.push(o.default.deserialize(n,e));return l(i,n)})),e.default=l},7747:function(t,e,n){"use strict";var i,r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(1386)),s=r(n(4721)),a=r(n(2054)),l=r(n(6498));class c{constructor(t,e){if(this.componentKind=t,this.loadSaveData={},this.lastChangedTime=(new Date).getTime(),this.zIndex=void 0!==e?e:c.zIndexCounter++,this.id=`${(new Date).getTime()}-${Math.random()}`,void 0===c.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]=null!=e?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()}onAddToImage(t){}onRemoveFromImage(){}intersectsRect(t){if(t.containsRect(this.getExactBBox()))return!0;return t.getEdges().some((t=>this.intersects(t)))}transformBy(t){return new c.TransformElementCommand(t,this.getId(),this)}setZIndex(t){return new c.TransformElementCommand(a.default.identity,this.getId(),this,t,this.getZIndex())}isSelectable(){return!0}isBackground(){return!1}getProportionalRenderingTime(){return 1}clone(){const t=this.createClone();for(const e in this.loadSaveData)for(const n of this.loadSaveData[e])t.attachLoadSaveData(e,n);return t}serialize(){const t=this.serializeToJSON();if(null===t)throw new Error(`${this} cannot be serialized.`);return{name:this.componentKind,zIndex:this.zIndex,id:this.id,loadSaveData:this.loadSaveData,data:t}}static isNotDeserializable(t){return"string"==typeof t&&(t=JSON.parse(t)),"object"!=typeof t||(!this.deserializationCallbacks[null==t?void 0:t.name]||!t.data)}static deserialize(t){if("string"==typeof t&&(t=JSON.parse(t)),c.isNotDeserializable(t))throw new Error(`Element with data ${t} cannot be deserialized.`);const e=this.deserializationCallbacks[t.name](t.data);return e.zIndex=t.zIndex,e.id=t.id,e}}e.default=c,c.zIndexCounter=0,c.deserializationCallbacks={},c.transformElementCommandId="transform-element",c.TransformElementCommand=(i=class extends l.default{constructor(t,e,n,i,r){super(c.transformElementCommandId,e,n),this.affineTransfm=t,this.origZIndex=r,this.targetZIndex=null!=i?i:c.zIndexCounter++,this.targetZIndex>=c.zIndexCounter&&(c.zIndexCounter=this.targetZIndex+1),n&&void 0===r&&(this.origZIndex=n.getZIndex())}resolveComponent(t){var e;this.component||(super.resolveComponent(t),null!==(e=this.origZIndex)&&void 0!==e||(this.origZIndex=this.component.getZIndex()))}updateTransform(t,e){if(!this.component)throw new Error("this.component is undefined or null!");const n=t.image.findParent(this.component);let i=!1;n&&(n.remove(),i=!0),this.component.applyTransformation(e),this.component.lastChangedTime=(new Date).getTime(),i&&s.default.addElement(this.component).apply(t)}apply(t){this.resolveComponent(t.image),this.component.zIndex=this.targetZIndex,this.updateTransform(t,this.affineTransfm),t.queueRerender()}unapply(t){this.resolveComponent(t.image),this.component.zIndex=this.origZIndex,this.updateTransform(t,this.affineTransfm.inverse()),t.queueRerender()}description(t,e){return e.transformedElements(1)}serializeToJSON(){return{id:this.componentID,transfm:this.affineTransfm.toArray(),targetZIndex:this.targetZIndex,origZIndex:this.origZIndex}}},o.default.register(c.transformElementCommandId,((t,e)=>{var n,i;const r=null!==(n=e.image.lookupElement(t.id))&&void 0!==n?n:void 0,o=new a.default(...t.transfm),s=t.targetZIndex,l=null!==(i=t.origZIndex)&&void 0!==i?i:void 0;return new c.TransformElementCommand(o,t.id,r,s,l)})),i)},7520:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.backgroundTypeToClassNameMap=e.imageBackgroundNonAutomaticSecondaryColorCSSClassName=e.imageBackgroundGridSizeCSSPrefix=e.imageBackgroundCSSClassName=e.BackgroundType=void 0;const a=s(n(8233)),l=n(4721),c=s(n(5085)),d=s(n(7747)),u=n(8258),h=o(n(9765)),p=n(6750),f=s(n(8831)),m=n(1520);var g;!function(t){t[t.SolidColor=0]="SolidColor",t[t.Grid=1]="Grid",t[t.None=2]="None"}(g=e.BackgroundType||(e.BackgroundType={})),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={[g.Grid]:"js-draw-image-background-grid",[g.SolidColor]:e.imageBackgroundCSSClassName,[g.None]:""};class v extends d.default{constructor(t,e){super("image-background",0),this.backgroundType=t,this.mainColor=e,this.viewportSizeChangeListener=null,this.gridSize=f.default.getGridSize(2),this.gridStrokeWidth=.7,this.secondaryColor=null,this.isRestylableComponent=!0,this.contentBBox=c.default.empty}static ofGrid(t,e,n,i){const r=new v(g.Grid,t);return void 0!==e&&(r.gridSize=e),void 0!==n&&(r.secondaryColor=n),void 0!==i&&(r.gridStrokeWidth=i),r}getBackgroundType(){return this.backgroundType}getMainColor(){return this.mainColor}getSecondaryColor(){return this.secondaryColor}getGridSize(){return this.gridSize}getStyle(){let t=this.mainColor;return this.backgroundType===g.None&&(t=void 0),{color:t}}updateStyle(t){return(0,u.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){const n=t.color;n&&(this.mainColor=n,n.eq(a.default.transparent)&&this.backgroundType===g.SolidColor?this.backgroundType=g.None:this.backgroundType===g.None&&(this.backgroundType=g.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.recomputeBBox(t)}onRemoveFromImage(){var t;null===(t=this.viewportSizeChangeListener)||void 0===t||t.remove(),this.viewportSizeChangeListener=null}recomputeBBox(t){const e=t.getImportExportViewport().visibleRect;this.contentBBox.eq(e)||(this.contentBBox=e,t.queueRerenderOf(this))}generateGridPath(t){var e,n;const i=null!==(n=null===(e=null==t?void 0:t.grownBy(this.gridStrokeWidth))||void 0===e?void 0:e.intersection(this.contentBBox))&&void 0!==n?n:this.contentBBox,r=t=>Math.floor(t/this.gridSize)*this.gridSize,o=t=>Math.ceil(t/this.gridSize)*this.gridSize,s=o(i.y),a=r(i.y+i.h),l=o(i.x),c=r(i.x+i.w),d=[],u=(a-s)/this.gridSize,f=(c-l)/this.gridSize;if(u>1e3||f>1e3)return h.default.empty;const m=p.Vec2.of(i.x,s);for(let t=s;t<=a;t+=this.gridSize)d.push({kind:h.PathCommandType.MoveTo,point:p.Vec2.of(i.x,t)}),d.push({kind:h.PathCommandType.LineTo,point:p.Vec2.of(i.x+i.w,t)});for(let t=l;t<=c;t+=this.gridSize)d.push({kind:h.PathCommandType.MoveTo,point:p.Vec2.of(t,i.y)}),d.push({kind:h.PathCommandType.LineTo,point:p.Vec2.of(t,i.y+i.h)});return new h.default(m,d)}render(t,n){if(this.backgroundType===g.None)return;if(t.startObject(this.contentBBox,!0),this.backgroundType===g.SolidColor||this.backgroundType===g.Grid)if(n){const e=n.intersection(this.contentBBox);e&&t.fillRect(e,this.mainColor)}else t.fillRect(this.contentBBox,this.mainColor);if(this.backgroundType===g.Grid){let e=this.secondaryColor;null!=e||(e=a.default.ofRGBA(1-this.mainColor.r,1-this.mainColor.g,1-this.mainColor.b,.2)),0===this.mainColor.a&&(e=a.default.ofRGBA(.5,.5,.5,.2));const i={fill:a.default.transparent,stroke:{width:this.gridStrokeWidth,color:e}};t.drawPath(this.generateGridPath(n).toRenderable(i))}const i=e.backgroundTypeToClassNameMap[this.backgroundType],r=[e.imageBackgroundCSSClassName];if(i!==e.imageBackgroundCSSClassName){r.push(i);const t=(0,m.toRoundedString)(this.gridSize).replace(/[.]/g,"p");r.push(e.imageBackgroundGridSizeCSSPrefix+t)}null!==this.secondaryColor&&r.push(e.imageBackgroundNonAutomaticSecondaryColorCSSClassName),t.endObject(this.getLoadSaveData(),r)}intersects(t){return this.contentBBox.getEdges().some((e=>e.intersects(t)))}isSelectable(){return!1}isBackground(){return!0}serializeToJSON(){var t;return{mainColor:this.mainColor.toHexString(),secondaryColor:null===(t=this.secondaryColor)||void 0===t?void 0:t.toHexString(),backgroundType:this.backgroundType,gridSize:this.gridSize,gridStrokeWidth:this.gridStrokeWidth}}applyTransformation(t){}description(t){return this.backgroundType===g.SolidColor?t.filledBackgroundWithColor(this.mainColor.toString()):t.emptyBackground}createClone(){return new v(this.backgroundType,this.mainColor)}static deserializeFromJSON(t){var e,n;if("string"==typeof t&&(t=JSON.parse(t)),"string"!=typeof t.mainColor)throw new Error("Error deserializing — mainColor must be of type string.");let i;const r=t.backgroundType;if(r!==g.None&&r!==g.Grid&&r!==g.SolidColor){return r}i=r;const o=a.default.fromHex(t.mainColor),s=t.secondaryColor?a.default.fromHex(t.secondaryColor):null,l=null!==(e=t.gridSize)&&void 0!==e?e:void 0,c=null!==(n=t.gridStrokeWidth)&&void 0!==n?n:void 0,d=new v(i,o);return d.secondaryColor=s,l&&(d.gridSize=l),c&&(d.gridStrokeWidth=c),d}}e.default=v,d.default.registerComponent("image-background",v.deserializeFromJSON)},5249:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(2054)),s=r(n(5085)),a=r(n(7747));class l extends a.default{constructor(t){var e,n,i;super("image-component"),this.image=Object.assign(Object.assign({},t),{label:null!==(i=null!==(n=null!==(e=t.label)&&void 0!==e?e:t.image.getAttribute("alt"))&&void 0!==n?n:t.image.getAttribute("aria-label"))&&void 0!==i?i:void 0});void 0===t.image.getAttribute("src")||t.image.complete||(t.image.onload=()=>this.recomputeBBox()),this.recomputeBBox()}getImageRect(){return new s.default(0,0,this.image.image.width,this.image.image.height)}recomputeBBox(){this.contentBBox=this.getImageRect(),this.contentBBox=this.contentBBox.transformedBoundingBox(this.image.transform)}static fromImage(t,e){var n,r,o;return i(this,void 0,void 0,(function*(){let i,s,a;t.complete||(yield new Promise(((e,n)=>{t.onload=e,t.onerror=n,t.onabort=n}))),"number"==typeof t.width&&"number"==typeof t.height&&0!==t.width&&0!==t.height?(i=t.width,s=t.height):(i=t.clientWidth,s=t.clientHeight);let c=null!==(n=t.src)&&void 0!==n?n:"";if(c.startsWith("data:image/"))a=new Image,a.src=c,a.width=i,a.height=s;else{const e=document.createElement("canvas");e.width=i,e.height=s;e.getContext("2d").drawImage(t,0,0,e.width,e.height),c=e.toDataURL(),a=e}return a.setAttribute("alt",null!==(r=t.getAttribute("alt"))&&void 0!==r?r:""),a.setAttribute("aria-label",null!==(o=t.getAttribute("aria-label"))&&void 0!==o?o:""),new l({image:a,base64Url:c,transform:e})}))}render(t,e){t.startObject(this.contentBBox),t.drawImage(this.image),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return 10}intersects(t){const e=this.getImageRect().getEdges().map((t=>t.transformedBy(this.image.transform)));for(const n of e)if(n.intersects(t))return!0;return!1}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()}}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(Object.assign({},this.image))}static deserializeFromJSON(t){if("string"!=typeof t.src)throw new Error(`${t} has invalid format! Expected src property.`);const e=new Image;return e.src=t.src,e.width=t.width,e.height=t.height,new l({image:e,base64Url:e.src,label:t.label,transform:new o.default(...t.transform)})}}e.default=l,a.default.registerComponent("image-component",l.deserializeFromJSON)},8258:function(t,e,n){"use strict";var i=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 r=i(n(8233)),o=i(n(1386)),s=i(n(6498)),a=n(1281),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?r.default.fromHex(t.color):void 0,textStyle:t.textStyle?(0,a.textStyleFromJSON)(t.textStyle):void 0});e.createRestyleComponentCommand=(t,e,n)=>new u(t,e,n.getId(),n);e.isRestylableComponent=t=>!!("getStyle"in t&&"updateStyle"in t&&"forceStyle"in t)&&!(!("isRestylableComponent"in t)||!t.isRestylableComponent);const d="default-restyle-element";class u extends s.default{constructor(t,e,n,i){super(d,n,i),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)}}}o.default.register(d,((t,e)=>{const n=c(t.originalStyle),i=c(t.newStyle),r=t.id;if("string"!=typeof t.id)throw new Error(`json.id is of type ${typeof t.id}, not string.`);return new u(n,i,r)}))},9276:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=i(n(9563)),s=i(n(7747)),a="svg-global-attributes";class l extends s.default{constructor(t){super(a),this.attrs=t,this.contentBBox=r.default.empty}render(t,e){if(t instanceof o.default)for(const[e,n]of this.attrs)t.setRootSVGAttribute(e,n)}intersects(t){return!1}applyTransformation(t){}isSelectable(){return!1}createClone(){return new l(this.attrs)}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify(this.attrs)}static deserializeFromString(t){const e=JSON.parse(t),n=[],i=/^[ \t\n0-9.-eE]+$/;for(const[t,r]of e)"viewBox"!==t&&"width"!==t&&"height"!==t||r&&i.exec(r)&&n.push([t,r]);return new l(n)}}e.default=l,s.default.registerComponent(a,l.deserializeFromString)},9984:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9765)),o=i(n(5085)),s=n(9604),a=i(n(7747)),l=n(8258);class c extends a.default{constructor(t){var e;super("stroke"),this.isRestylableComponent=!0,this.approximateRenderingTime=0,this.parts=[];for(const e of t){const t=r.default.fromRenderable(e),n=this.bboxForPart(t.bbox,e.style);this.contentBBox?this.contentBBox=this.contentBBox.union(n):this.contentBBox=n,this.parts.push({path:t,startPoint:t.startPoint,style:e.style,commands:t.parts}),this.approximateRenderingTime+=t.parts.length}null!==(e=this.contentBBox)&&void 0!==e||(this.contentBBox=o.default.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,l.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){t.color&&(this.parts=this.parts.map((e=>{const n=Object.assign(Object.assign({},e.style),{stroke:e.style.stroke?Object.assign({},e.style.stroke):void 0});return n.stroke&&n.stroke.width>0?n.stroke.color=t.color:n.fill=t.color,{path:e.path,startPoint:e.startPoint,commands:e.commands,style:n}})),e&&(e.image.queueRerenderOf(this),e.queueRerender()))}intersects(t){var e;for(const n of this.parts){const i=null===(e=n.style.stroke)||void 0===e?void 0:e.width,r=i?i/2:void 0;if(n.path.intersection(t,r).length>0)return!0}return!1}render(t,e){var n,i;t.startObject(this.getBBox());for(const r of this.parts){const o=this.bboxForPart(r.path.bbox,r.style);if(e){if(!o.intersects(e))continue;if((o.size.x>3*e.size.x||o.size.y>3*e.size.y)&&!r.path.roughlyIntersects(e,null!==(i=null===(n=r.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0))continue}t.drawPath(r)}t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.approximateRenderingTime}bboxForPart(t,e){return e.stroke?t.grownBy(e.stroke.width/2):t}getExactBBox(){let t=null;for(const{path:e,style:n}of this.parts){const i=this.bboxForPart(e.getExactBBox(),n);null!=t||(t=i),t=t.union(i)}return null!=t?t:o.default.empty}applyTransformation(t){this.contentBBox=o.default.empty;let e=!0;this.parts=this.parts.map((n=>{const i=n.path.transformedBy(t),r=Object.assign(Object.assign({},n.style),{stroke:n.style.stroke?Object.assign({},n.style.stroke):void 0});if(r.stroke){const e=t.getScaleFactor();r.stroke.width*=e}const o=this.bboxForPart(i.bbox,r);return e?(this.contentBBox=o,e=!1):this.contentBBox=this.contentBBox.union(o),{path:i,startPoint:i.startPoint,commands:i.parts,style:r}}))}getPath(){let t=null;for(const e of this.parts)t?t=t.union(e.path):null!=t||(t=e.path);return null!=t?t:r.default.empty}description(t){return t.stroke}createClone(){return new c(this.parts)}serializeToJSON(){return this.parts.map((t=>({style:(0,s.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,s.styleFromJSON)(t.style);return r.default.fromString(t.path).toRenderable(e)}));return new c(e)}}e.default=c,a.default.registerComponent("stroke",c.deserializeFromJSON)},6205:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9784)),o=i(n(2054)),s=i(n(5085)),a=n(6750),l=n(1281),c=i(n(7747)),d=n(8258),u="text";class h extends c.default{constructor(t,e,n){super(u),this.textObjects=t,this.transform=e,this.style=n,this.isRestylableComponent=!0,this.recomputeBBox();!t.some((t=>"string"==typeof t))&&t.length>0&&(this.style=t[0].getTextStyle())}static applyTextStyles(t,e){var n,i;const r=e.fontFamily.match(/\s/)?e.fontFamily.replace(/["]/g,'\\"'):e.fontFamily;t.font=[(null!==(n=e.size)&&void 0!==n?n:12)+"px",null!==(i=e.fontWeight)&&void 0!==i?i:"",`${r}`,e.fontWeight].join(" "),t.textAlign="left"}static estimateTextDimens(t,e){const n=t.length*e.size,i=e.size;return new s.default(0,2*-i/3,n,i)}static getTextDimens(t,e){var n,i;if(null!==(n=h.textMeasuringCtx)&&void 0!==n||(h.textMeasuringCtx=null!==(i=document.createElement("canvas").getContext("2d"))&&void 0!==i?i:null),!h.textMeasuringCtx)return this.estimateTextDimens(t,e);const r=h.textMeasuringCtx;h.applyTextStyles(r,e);const o=r.measureText(t),a=-o.actualBoundingBoxAscent,l=o.actualBoundingBoxAscent+o.actualBoundingBoxDescent;return new s.default(0,a,o.width,l)}computeBBoxOfPart(t){if("string"==typeof t){return h.getTextDimens(t,this.style).transformedBoundingBox(this.transform)}return t.contentBBox.transformedBoundingBox(this.transform)}recomputeBBox(){let t=null;for(const e of this.textObjects){const n=this.computeBBoxOfPart(e);null!=t||(t=n),t=t.union(n)}this.contentBBox=null!=t?t:s.default.empty}renderInternal(t){const e=this.transform;for(const n of this.textObjects)"string"==typeof n?t.drawText(n,e,this.style):(t.pushTransform(e),n.renderInternal(t),t.popTransform())}render(t,e){t.startObject(this.contentBBox),this.renderInternal(t),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(t){const e=this.transform.inverse(),n=e.transformVec2(t.p1),i=e.transformVec2(t.p2);t=new r.default(n,i);for(const e of this.textObjects)if("string"==typeof e){if(h.getTextDimens(e,this.style).getEdges().some((e=>null!==t.intersection(e))))return!0}else if(e.intersects(t))return!0;return!1}getStyle(){return{color:this.style.renderingStyle.fill,textStyle:Object.assign(Object.assign({},this.style),{renderingStyle:Object.assign({},this.style.renderingStyle)})}}updateStyle(t){return(0,d.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){if(t.textStyle)this.style=(0,l.cloneTextStyle)(t.textStyle);else{if(!t.color)return;this.style=Object.assign(Object.assign({},this.style),{renderingStyle:Object.assign(Object.assign({},this.style.renderingStyle),{fill:t.color})})}for(const n of this.textObjects)n instanceof h&&n.forceStyle(t,e);e&&(e.image.queueRerenderOf(this),e.queueRerender())}getTextStyle(){return(0,l.cloneTextStyle)(this.style)}getBaselinePos(){return this.transform.transformVec2(a.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,l.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,l.textStyleFromJSON)(t.style),n=t.textObjects.map((t=>{var e;return null!==(null!==(e=t.text)&&void 0!==e?e: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 i=t.transform,r=new o.default(...i);return new h(n,r,e)}static fromLines(t,e,n){let i=null;const r=[];for(const e of t){let t=a.Vec2.zero;if(i){const e=Math.floor(n.size);t=i.getBBox().bottomLeft.plus(a.Vec2.unitY.times(e))}const s=new h([e],o.default.translation(t),n);r.push(s),i=s}return new h(r,e,n)}}e.default=h,h.textMeasuringCtx=null,c.default.registerComponent(u,(t=>h.deserializeFromString(t)))},5807:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=i(n(9563)),s=i(n(7747)),a="unknown-svg-object";class l extends s.default{constructor(t){super(a),this.svgObject=t,this.contentBBox=r.default.of(t.getBoundingClientRect())}render(t,e){t instanceof o.default&&t.drawSVGElem(this.svgObject)}intersects(t){return this.contentBBox.getEdges().some((e=>null!==e.intersection(t)))}applyTransformation(t){}isSelectable(){return!1}createClone(){return new l(this.svgObject.cloneNode(!0))}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify({html:this.svgObject.outerHTML})}}e.default=l,s.default.registerComponent(a,null)},6645:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeArrowBuilder=void 0;const a=o(n(9765)),l=s(n(9984));e.makeArrowBuilder=(t,e)=>new c(t,e);class c{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getLineWidth(){return Math.max(this.endPoint.width,this.startPoint.width)}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),i=e.minus(t).length(),r=Math.min(this.getLineWidth(),i/2),o=this.startPoint.width/2,s=this.endPoint.width/2,c=e.minus(n.times(r)),d=n.orthog(),u=d.times(o),h=d.times(s),p=new a.default(c.minus(h),[{kind:a.PathCommandType.LineTo,point:t.minus(u)},{kind:a.PathCommandType.LineTo,point:t.plus(u)},{kind:a.PathCommandType.LineTo,point:c.plus(h)},{kind:a.PathCommandType.LineTo,point:c.plus(d.times(r).plus(h))},{kind:a.PathCommandType.LineTo,point:e.plus(n.times(s))},{kind:a.PathCommandType.LineTo,point:c.plus(d.times(-r).minus(h))},{kind:a.PathCommandType.LineTo,point:c.minus(h)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new l.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=c},1173:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeFreehandLineBuilder=void 0;const r=n(6750),o=i(n(5085)),s=n(9765),a=i(n(9984)),l=i(n(8831)),c=n(3450),d=i(n(8233));e.makeFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),i=e.getSizeOfPixelOnCanvas();return new u(t,i,n,e)};class u{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.viewport=i,this.isFirstSegment=!0,this.parts=[],this.widthAverageNumSamples=1,this.curveFitter=new c.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.averageWidth=t.width,this.bbox=new o.default(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:d.default.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 a.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.previewStroke()}getMinFit(){let t=Math.min(this.minFitAllowed,this.averageWidth/3);return t<1e-10&&(t=this.minFitAllowed),t}roundPoint(t){const e=this.getMinFit();return l.default.roundPoint(t,e)}roundDistance(t){const e=this.getMinFit();return l.default.roundPoint(t,e)}curveToPathCommands(t){if(!t){if(!this.isFirstSegment)return[];const t=l.default.roundPoint(this.averageWidth/10,Math.min(this.minFitAllowed,this.averageWidth/10)),e=this.roundPoint(this.startPoint.pos);return[{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,t)),endPoint:e.plus(r.Vec2.of(0,t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,t)),endPoint:e.plus(r.Vec2.of(-t,0))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,-t)),endPoint:e.plus(r.Vec2.of(0,-t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,-t)),endPoint:e.plus(r.Vec2.of(t,0))}]}const e=[];return this.isFirstSegment&&e.push({kind:s.PathCommandType.MoveTo,point:this.roundPoint(t.startPoint)}),e.push({kind:s.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=u},5607:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeLineBuilder=void 0;const a=o(n(9765)),l=s(n(9984));e.makeLineBuilder=(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=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),i=this.startPoint.width/2,r=this.endPoint.width/2,o=n.orthog(),s=o.times(i),c=o.times(r),d=t.minus(s),u=new a.default(d,[{kind:a.PathCommandType.LineTo,point:t.plus(s)},{kind:a.PathCommandType.LineTo,point:e.plus(c)},{kind:a.PathCommandType.LineTo,point:e.minus(c)},{kind:a.PathCommandType.LineTo,point:t.minus(s)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new l.default([u.toRenderable({fill:this.startPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=c},4856:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makePressureSensitiveFreehandLineBuilder=void 0;const r=n(8405),o=n(6750),s=i(n(5085)),a=n(9765),l=i(n(9984)),c=i(n(8831)),d=n(3450);e.makePressureSensitiveFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),i=e.getSizeOfPixelOnCanvas();return new u(t,i,n,e)};class u{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.viewport=i,this.isFirstSegment=!0,this.pathStartConnector=null,this.mostRecentConnector=null,this.lastUpperBezier=null,this.lastLowerBezier=null,this.parts=[],this.upperSegments=[],this.lowerSegments=[],this.curveFitter=new d.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.curveStartWidth=t.width,this.bbox=new s.default(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){var t;return{fill:null!==(t=this.startPoint.color)&&void 0!==t?t:null}}previewCurrentPath(){var t;const e=this.upperSegments.slice(),n=this.lowerSegments.slice();let i,r;const o=this.curveFitter.preview();if(o){const{upperCurveCommand:s,lowerToUpperConnector:a,upperToLowerConnector:l,lowerCurveCommand:c}=this.segmentToPath(o);e.push(s),n.push(c),i=a,r=null!==(t=this.pathStartConnector)&&void 0!==t?t:l}else{if(null===this.mostRecentConnector||null===this.pathStartConnector)return null;i=this.mostRecentConnector,r=this.pathStartConnector}let s;const l=n[n.length-1];return s=l.kind===a.PathCommandType.LineTo||l.kind===a.PathCommandType.MoveTo?l.point:l.endPoint,{startPoint:s,commands:[i,...e.reverse(),r,...n],style:this.getRenderingStyle()}}previewFullPath(){const t=this.previewCurrentPath();return t?[...this.parts,t]:null}previewStroke(){const t=this.previewFullPath();return t?new l.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.isFirstSegment&&this.addCurve(null),this.previewStroke()}roundPoint(t){let e=Math.min(this.minFitAllowed,this.curveStartWidth/3);return e<1e-10&&(e=this.minFitAllowed),c.default.roundPoint(t,e)}shouldStartNewSegment(t,e){if(!this.lastLowerBezier||!this.lastUpperBezier)return!1;const n=(t,e)=>{const n=t.intersects(e);if(!n||0===n.length)return null;const i=n[0],r=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(i);if(!r)throw new Error(`Incorrect format returned by .intersects: ${n} should be array of "number/number"!`);const s=parseFloat(r[1]);return o.Vec2.ofXY(t.get(s))},i=t=>o.Vec2.ofXY(t.points[2]).minus(o.Vec2.ofXY(t.points[1])).normalized(),r=t=>o.Vec2.ofXY(t.points[1]).minus(o.Vec2.ofXY(t.points[0])).normalized();if(r(e).dot(i(this.lastUpperBezier))<.3||r(t).dot(i(this.lastLowerBezier))<.3||r(e).dot(i(e))<0||r(t).dot(i(t))<0)return!0;const s=n(t,this.lastUpperBezier),a=n(e,this.lastLowerBezier);return!(!s&&!a)}addCurve(t){if(!t){if(!this.isFirstSegment)return;const t=c.default.roundPoint(this.startPoint.width/2.2,Math.min(this.minFitAllowed,this.startPoint.width/4)),e=this.roundPoint(this.startPoint.pos),n=this.startPoint.pos.plus(o.Vec2.of(t,0));return this.lowerSegments.push({kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(t,t)),endPoint:e.plus(o.Vec2.of(0,t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,t)),endPoint:e.plus(o.Vec2.of(-t,0))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,-t)),endPoint:e.plus(o.Vec2.of(0,-t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(t,-t)),endPoint:e.plus(o.Vec2.of(t,0))}),this.pathStartConnector={kind:a.PathCommandType.LineTo,point:n},void(this.mostRecentConnector=this.pathStartConnector)}const{upperCurveCommand:e,lowerToUpperConnector:n,upperToLowerConnector:i,lowerCurveCommand:r,lowerCurve:s,upperCurve:l}=this.segmentToPath(t),d=this.shouldStartNewSegment(s,l);if(d){const t=this.previewCurrentPath();t&&(this.parts.push(t),this.upperSegments=[],this.lowerSegments=[])}(this.isFirstSegment||d)&&(this.pathStartConnector=i,this.isFirstSegment=!1),this.mostRecentConnector=n,this.lowerSegments.push(r),this.upperSegments.push(e),this.lastLowerBezier=s,this.lastUpperBezier=l,this.curveStartWidth=t.startWidth}segmentToPath(t){const e=new r.Bezier(t.startPoint.xy,t.controlPoint.xy,t.endPoint.xy);let n=o.Vec2.ofXY(e.normal(0)).normalized(),i=o.Vec2.ofXY(e.normal(1)).normalized();n=n.times(t.startWidth/2),i=i.times(t.endWidth/2),isFinite(n.magnitude())||(console.error("Warning: startVec is NaN or ∞",n,i,t),n=i);const s=t.startPoint,l=t.endPoint,c=t.controlPoint;let d=e.project(c.xy).t;d||(d=s.minus(c).magnitudeSquared()<l.minus(c).magnitudeSquared()?.1:.9);const u=d,h=o.Vec2.ofXY(e.normal(u)).normalized().times(t.startWidth/2*u+t.endWidth/2*(1-u)),p=this.roundPoint(s.plus(n)),f=this.roundPoint(c.plus(h)),m=this.roundPoint(l.plus(i)),g=this.roundPoint(c.minus(h)),v=this.roundPoint(l.minus(i)),y=this.roundPoint(s.minus(n)),b={kind:a.PathCommandType.QuadraticBezierTo,controlPoint:f,endPoint:m},x={kind:a.PathCommandType.LineTo,point:p},w={kind:a.PathCommandType.LineTo,point:v};return{upperCurveCommand:{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:g,endPoint:y},upperToLowerConnector:x,lowerToUpperConnector:w,lowerCurveCommand:b,upperCurve:new r.Bezier(v,g,y),lowerCurve:new r.Bezier(p,f,m)}}addPoint(t){this.curveFitter.addPoint(t)}}e.default=u},7124:function(t,e,n){"use strict";var i=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 r=i(n(2054)),o=i(n(9765)),s=i(n(5085)),a=i(n(9984));e.makeFilledRectangleBuilder=(t,e)=>new l(t,!0,e);e.makeOutlinedRectangleBuilder=(t,e)=>new l(t,!1,e);class l{constructor(t,e,n){this.startPoint=t,this.filled=e,this.viewport=n,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.viewport.getRotationAngle(),e=r.default.zRotation(-t),n=e.inverse().transformVec2(this.startPoint.pos),i=e.inverse().transformVec2(this.endPoint.pos),l=s.default.fromCorners(n,i),c=o.default.fromRect(l,this.filled?null:this.endPoint.width).transformedBy(e).mapPoints((t=>this.viewport.roundPoint(t)));return new a.default([c.toRenderable({fill:this.endPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=l},6643:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1632:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ImageComponent=e.BackgroundComponent=e.StrokeComponent=e.TextComponent=e.isRestylableComponent=e.createRestyleComponentCommand=e.Text=e.Stroke=e.AbstractComponent=e.StrokeSmoother=e.makePressureSensitiveFreehandLineBuilder=e.makeFreehandLineBuilder=void 0,r(n(6643),e);var s=n(1173);Object.defineProperty(e,"makeFreehandLineBuilder",{enumerable:!0,get:function(){return s.makeFreehandLineBuilder}});var a=n(4856);Object.defineProperty(e,"makePressureSensitiveFreehandLineBuilder",{enumerable:!0,get:function(){return a.makePressureSensitiveFreehandLineBuilder}});var l=n(3450);Object.defineProperty(e,"StrokeSmoother",{enumerable:!0,get:function(){return o(l).default}}),r(n(7747),e);var c=n(7747);Object.defineProperty(e,"AbstractComponent",{enumerable:!0,get:function(){return o(c).default}});const d=o(n(9984));e.Stroke=d.default,e.StrokeComponent=d.default;const u=o(n(6205));e.Text=u.default,e.TextComponent=u.default;const h=o(n(5249));e.ImageComponent=h.default;const p=n(8258);Object.defineProperty(e,"createRestyleComponentCommand",{enumerable:!0,get:function(){return p.createRestyleComponentCommand}}),Object.defineProperty(e,"isRestylableComponent",{enumerable:!0,get:function(){return p.isRestylableComponent}});const f=o(n(7520));e.BackgroundComponent=f.default},4163:(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",filledBackgroundWithColor:t=>`Filled background (${t})`,text:t=>`Text object: ${t}`,imageNode:t=>`Image: ${t}`,restyledElement:t=>`Restyled ${t}`}},3450:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.StrokeSmoother=void 0;const r=n(6750),o=i(n(5085)),s=i(n(9784)),a=i(n(148));class l{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.maxFitAllowed=n,this.onCurveAdded=i,this.isFirstSegment=!0,this.lastExitingVec=null,this.currentCurve=null,this.lastPoint=this.startPoint,this.buffer=[this.startPoint.pos],this.momentum=r.Vec2.zero,this.currentCurve=null,this.curveStartWidth=t.width,this.bbox=new o.default(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}preview(){return this.currentCurve?this.currentSegmentToPath():null}approxCurrentCurveLength(){if(!this.currentCurve)return 0;const t=this.currentCurve.p0,e=this.currentCurve.p1,n=this.currentCurve.p2;return t.minus(e).length()+n.minus(e).length()}finalizeCurrentCurve(){if(!this.currentCurve)return;this.onCurveAdded(this.currentSegmentToPath());const t=this.buffer[this.buffer.length-1];this.lastExitingVec=this.currentCurve.p2.minus(this.currentCurve.p1),console.assert(0!==this.lastExitingVec.magnitude(),"lastExitingVec has zero length!"),this.buffer=[this.buffer[this.buffer.length-2],t],this.currentCurve=null,this.isFirstSegment=!1}currentSegmentToPath(){if(null==this.currentCurve)throw new Error("Invalid State: currentCurve is null!");const t=this.currentCurve.normal(0).normalized();if(!isFinite(t.magnitude()))throw new Error(`startVec(${t}) is NaN or ∞`);const e=this.currentCurve.at(0),n=this.currentCurve.at(1);return{startPoint:e,controlPoint:this.currentCurve.p1,endPoint:n,startWidth:this.curveStartWidth,endWidth:this.curveEndWidth}}computeExitingVec(){return this.momentum.normalized().times(this.lastPoint.width/2)}addPoint(t){var e,n;if(this.lastPoint){const e=1e-10,n=t.time-this.lastPoint.time;if(t.pos.eq(this.lastPoint.pos,e)||0===n)return;if(isNaN(t.pos.magnitude()))return void console.warn("Discarding NaN point.",t);const i=Math.min(this.lastPoint.width,t.width)/3;if(this.startPoint.pos.minus(t.pos).magnitude()<i&&this.isFirstSegment)return;const r=t.pos.minus(this.lastPoint.pos).times(1/n*1e3);this.momentum=this.momentum.lerp(r,.9)}const i=null!==(e=this.lastPoint)&&void 0!==e?e:t;this.lastPoint=t,this.buffer.push(t.pos);const o=t.width,l=this.curveEndWidth;if(this.curveEndWidth=o,this.bbox=this.bbox.grownToPoint(t.pos,o),null===this.currentCurve){const e=i.pos,s=i.pos.plus(null!==(n=this.lastExitingVec)&&void 0!==n?n:r.Vec2.unitX),c=t.pos;this.currentCurve=new a.default(e,s,c),console.assert(!isNaN(e.magnitude())&&!isNaN(s.magnitude())&&!isNaN(c.magnitude()),"Expected !NaN"),this.isFirstSegment?this.curveStartWidth=(this.curveStartWidth+o)/2:this.curveStartWidth=l}let c=this.lastExitingVec;if(!c){let t=Math.ceil(this.buffer.length/2);(0===t||t>=this.buffer.length)&&(t=this.buffer.length-1),c=this.buffer[t].minus(this.buffer[0])}let d=this.computeExitingVec();const u=this.buffer[0],h=t.pos,p=h.minus(u).magnitude(),f=2*p;if(0===f||0===d.magnitude()||!isFinite(d.magnitude()))return;console.assert(isFinite(c.magnitude()),"Pre-normalized enteringVec has NaN or ∞ magnitude!"),c=c.normalized(),d=d.normalized(),console.assert(isFinite(c.magnitude()),"Normalized enteringVec has NaN or ∞ magnitude!");const m=new s.default(u,u.plus(c.times(f))),g=new s.default(h.minus(d.times(f)),h).intersection(m);let v=null;g&&(v=g.point),(!v||u.eq(v)||h.eq(v))&&(v=u.plus(c.times(p/4))),console.assert(!u.eq(v,1e-11),"Start and control points are equal!"),console.assert(!v.eq(h,1e-11),"Control and end points are equal!");const y=this.currentCurve;this.currentCurve=new a.default(u,v,h),isNaN(this.currentCurve.normal(0).magnitude())&&(console.error("NaN normal at 0. Curve:",this.currentCurve),this.currentCurve=y);const b=t=>{const e=Math.min(Math.max(Math.min(this.curveStartWidth,this.curveEndWidth)/4,this.minFitAllowed),this.maxFitAllowed),n=e;let i=0;for(const r of this.buffer){let o=t.approximateDistance(r);if(o>e&&(o=t.distance(r),i+=Math.max(0,o-e),i>n))return!1}return!0};return this.buffer.length>3&&this.approxCurrentCurveLength()>this.curveStartWidth/2&&!b(this.currentCurve)?(this.currentCurve=y,this.curveEndWidth=l,this.lastPoint=i,void this.finalizeCurrentCurve()):void 0}}e.StrokeSmoother=l,e.default=l},6792:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{if(0===e.length)return null;const n=e[0].description(t);for(const i of e)if(i.description(t)!==n)return null;return n}},5563:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Editor=e.UndoRedoHistory=e.HTMLToolbar=e.PointerDevice=e.Pointer=e.Viewport=e.SVGLoader=e.Color4=e.getLocalizationTable=e.EditorImage=void 0;const s=o(n(169));e.Editor=s.default;var a=n(4721);Object.defineProperty(e,"EditorImage",{enumerable:!0,get:function(){return o(a).default}}),r(n(9699),e);var l=n(7282);Object.defineProperty(e,"getLocalizationTable",{enumerable:!0,get:function(){return o(l).default}}),r(n(2843),e);var c=n(8233);Object.defineProperty(e,"Color4",{enumerable:!0,get:function(){return o(c).default}});var d=n(8684);Object.defineProperty(e,"SVGLoader",{enumerable:!0,get:function(){return o(d).default}});var u=n(8831);Object.defineProperty(e,"Viewport",{enumerable:!0,get:function(){return o(u).default}}),r(n(4915),e),r(n(1632),e),r(n(3707),e),r(n(1637),e),r(n(4087),e),r(n(5414),e),r(n(2862),e);var h=n(306);Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return o(h).default}}),Object.defineProperty(e,"PointerDevice",{enumerable:!0,get:function(){return h.PointerDevice}});var p=n(7389);Object.defineProperty(e,"HTMLToolbar",{enumerable:!0,get:function(){return o(p).default}});var f=n(5467);Object.defineProperty(e,"UndoRedoHistory",{enumerable:!0,get:function(){return o(f).default}}),e.default=s.default},2843:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultEditorLocalization=void 0;const i=n(3814),r=n(4163),o=n(1603),s=n(3940),a=n(318);e.defaultEditorLocalization=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s.defaultToolbarLocalization),a.defaultToolLocalization),i.defaultCommandLocalization),r.defaultComponentLocalization),o.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}`})},8792:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2843),r=Object.assign(Object.assign({},i.defaultEditorLocalization),{pen:"Stift",eraser:"Radierer",select:"Auswahl",handTool:"Verschieben",zoom:"Vergrößerung",resetView:"Ansicht zurücksetzen",thicknessLabel:"Dicke: ",colorLabel:"Farbe: ",fontLabel:"Schriftart: ",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: ",freehandPen:"Freihand",arrowPen:"Pfeil",linePen:"Linie",outlinedRectanglePen:"Umrissenes Rechteck",filledRectanglePen:"Ausgefülltes Rechteck",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`,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",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=>`Umkehrung von ${t}`,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}`,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=>`Rückgangig gemacht ${t}`,redoAnnouncement:t=>`Wiederholt ${t}`});e.default=r},8309:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2843),r=Object.assign({},i.defaultEditorLocalization);e.default=r},3790:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2843),r=Object.assign(Object.assign({},i.defaultEditorLocalization),{loading:t=>`Cargando: ${t}%...`,imageEditor:"Editor de dibujos",undoAnnouncement:t=>`${t} fue deshecho`,redoAnnouncement:t=>`${t} fue rehecho`,undo:"Deshace",redo:"Rehace",pen:"Lapiz",eraser:"Borrador",select:"Selecciona",thicknessLabel:"Tamaño: ",colorLabel:"Color: ",doneLoading:"El cargado terminó",fontLabel:"Fuente: ",anyDevicePanning:"Mover la pantalla con todo dispotivo",touchPanning:"Mover la pantalla con un dedo",touchPanTool:"Instrumento de mover la pantalla con un dedo",outlinedRectanglePen:"Rectángulo con nada más que un borde",filledRectanglePen:"Rectángulo sin borde",linePen:"Línea",arrowPen:"Flecha",freehandPen:"Dibuja sin restricción de forma",selectPenType:"Forma de dibuja:",handTool:"Mover",zoom:"Zoom",resetView:"Reiniciar vista",resizeImageToSelection:"Redimensionar la imagen a lo que está seleccionado",deleteSelection:"Borra la selección",duplicateSelection:"Duplica la selección",pickColorFromScreen:"Selecciona un color de la pantalla",clickToPickColorAnnouncement:"Haga un clic en la pantalla para seleccionar un color",dropdownShown:t=>`Menú por ${t} es visible`,dropdownHidden:function(t){return`Menú por ${t} fue ocultado`},colorChangedAnnouncement:function(t){return`Color fue cambiado a ${t}`},keyboardPanZoom:"Mover la pantalla con el teclado",penTool:function(t){return`Lapiz ${t}`},selectionTool:"Selecciona",eraserTool:"Borrador",textTool:"Texto",enterTextToInsert:"Entra texto",textSize:"Tamaño",rerenderAsText:"Redibuja la pantalla al texto",lockRotation:"Bloquea rotación",image:"Imagen",imageSize:(t,e)=>`Tamaño del imagen: ${t} ${e}`,imageLoadError:t=>`Error cargando imagen: ${t}`,toggleOverflow:"Más",documentProperties:"Fondo",imageWidthOption:"Ancho: ",imageHeightOption:"Alto: ",backgroundColor:"Color de fondo: "});e.default=r},7282:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(2843),o=i(n(8792)),s=i(n(8309)),a=i(n(3790)),l={de:o.default,en:s.default,es:a.default},c=t=>{const e=/^(\w+)[_-](\w+)$/.exec(t);return e?e[1]:t};e.default=t=>{let e;null!=t||(t=navigator.languages);for(const n of t){const t=c(n);if(e&&t!==e&&e in l)return l[e];if(n in l)return l[n];e=t}return e&&e in l?l[e]:r.defaultEditorLocalization}},9784:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=n(6750);class s{constructor(t,e){this.point1=t,this.point2=e,this.bbox=r.default.bboxOf([t,e]),this.direction=e.minus(t),this.length=this.direction.magnitude(),this.length>0&&(this.direction=this.direction.times(1/this.length))}get p1(){return this.point1}get p2(){return this.point2}get(t){return this.point1.plus(this.direction.times(t))}intersection(t){let e,n;if(0===this.direction.x){if(0===t.direction.x||0===this.direction.y)return null;const i=this.point1.x,r=(this.point1.x-t.point1.x)*t.direction.y/t.direction.x+t.point1.y;e=o.Vec2.of(i,r),n=(r-this.point1.y)/this.direction.y}else{const i=(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,r=t.direction.y*this.direction.x-this.direction.y*t.direction.x;if(0===r)return null;const s=i/r,a=(s-this.point1.x)/this.direction.x,l=this.point1.y+this.direction.y*a;e=o.Vec2.of(s,l),n=(s-this.point1.x)/this.direction.x}const i=e.minus(this.point1).magnitude(),r=e.minus(this.point2).magnitude(),s=e.minus(t.point1).magnitude(),a=e.minus(t.point2).magnitude();return i>this.length||r>this.length||s>t.length||a>t.length?null:{point:e,t:n}}intersects(t){return null!==this.intersection(t)}closestPointTo(t){const e=t.minus(this.p1).dot(this.direction),n=this.length-e,i=this.p1.plus(this.direction.times(e));return e>0&&e<this.length?i:Math.abs(n)<Math.abs(e)?this.p2:this.p1}distance(t){return this.closestPointTo(t).minus(t).magnitude()}transformedBy(t){return new s(t.transformVec2(this.p1),t.transformVec2(this.p2))}toString(){return`LineSegment(${this.p1.toString()}, ${this.p2.toString()})`}}e.default=s},2054:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6750),o=i(n(3785));class s{constructor(t,e,n,i,r,s,a,l,c){this.a1=t,this.a2=e,this.a3=n,this.b1=i,this.b2=r,this.b3=s,this.c1=a,this.c2=l,this.c3=c,this.cachedInverse=void 0,this.rows=[o.default.of(t,e,n),o.default.of(i,r,s),o.default.of(a,l,c)]}static ofRows(t,e,n){return new s(t.x,t.y,t.z,e.x,e.y,e.z,n.x,n.y,n.z)}inverse(){var t;return null!==(t=this.computeInverse())&&void 0!==t?t: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=[o.default.unitX,o.default.unitY,o.default.unitZ];for(let n=0;n<3;n++){let i=t[n].at(n);const r=1e-10;if(Math.abs(i)<r){let o=-1;for(let e=1;e<=2;e++){const i=(n+e)%3;if(Math.abs(t[i].at(n))>=r){o=i;break}}if(-1===o)return this.cachedInverse=null,null;const s=t[n],a=e[n];t[n]=t[o],e[n]=e[o],t[o]=s,e[o]=a,i=t[n].at(n)}let o=1/i;t[n]=t[n].times(o),e[n]=e[n].times(o);const s=t[n],a=e[n];for(let i=1;i<=2;i++){const r=(n+i)%3;o=-t[r].at(n),t[r]=t[r].plus(s.times(o)),e[r]=e[r].plus(a.times(o))}}const n=s.ofRows(e[0],e[1],e[2]);return this.cachedInverse=n,n}transposed(){return new s(this.a1,this.b1,this.c1,this.a2,this.b2,this.c2,this.a3,this.b3,this.c3)}rightMul(t){t=t.transposed();const e=(e,n)=>this.rows[e].dot(t.rows[n]);return new s(e(0,0),e(0,1),e(0,2),e(1,0),e(1,1),e(1,2),e(2,0),e(2,1),e(2,2))}transformVec2(t){let e=o.default.of(t.x,t.y,1);return e=this.transformVec3(e),r.Vec2.of(e.x,e.y)}transformVec3(t){return o.default.of(this.rows[0].dot(t),this.rows[1].dot(t),this.rows[2].dot(t))}isIdentity(){return this===s.identity||this.eq(s.identity)}eq(t,e=0){for(let n=0;n<3;n++)if(!this.rows[n].eq(t.rows[n],e))return!1;return!0}toString(){let t="";const e=[0,0,0];for(const t of this.rows)for(let n=0;n<3;n++)e[n]=Math.max(e[0],`${t.at(n)}`.length);for(let n=0;n<3;n++){t+=0===n?"⎡ ":1===n?"⎢ ":"⎣ ";for(let i=0;i<3;i++){const r=this.rows[n].at(i).toString();let o="";for(let t=r.length;t<e[i];t++)o+=" ";t+=r+", "+o}t+=0===n?" ⎤":1===n?" ⎥":" ⎦",t+="\n"}return t.trimEnd()}toArray(){return[this.a1,this.a2,this.a3,this.b1,this.b2,this.b3,this.c1,this.c2,this.c3]}mapEntries(t){return new s(t(this.a1),t(this.a2),t(this.a3),t(this.b1),t(this.b2),t(this.b3),t(this.c1),t(this.c2),t(this.c3))}getScaleFactor(){return Math.hypot(this.a1,this.a2)}static translation(t){return new s(1,0,t.x,0,1,t.y,0,0,1)}static zRotation(t,e=r.Vec2.zero){if(0===t)return s.identity;const n=Math.cos(t),i=Math.sin(t);let o=s.translation(e);return o=o.rightMul(new s(n,-i,0,i,n,0,0,0,1)),o.rightMul(s.translation(e.times(-1)))}static scaling2D(t,e=r.Vec2.zero){let n,i,o=s.translation(e);return"number"==typeof t?(n=t,i=t):(n=t.x,i=t.y),o=o.rightMul(new s(n,0,0,0,i,0,0,0,1)),o.rightMul(s.translation(e.times(-1)))}toCSSMatrix(){return`matrix(${this.a1},${this.b1},${this.a2},${this.b2},${this.a3},${this.b3})`}static fromCSSMatrix(t){if(""===t||"none"===t)return s.identity;const e="([-]?\\d*(?:\\.\\d*)?(?:[eE][-]?\\d+)?)",n="[, \\t\\n]",i=`^\\s*matrix\\s*\\(${[e,e,e,e,e,e].join(`${n}+`)}${n}*\\)\\s*$`,r=new RegExp(i,"i").exec(t);if(!r)throw new Error(`Unsupported transformation: ${t}`);const o=r.slice(1).map((t=>parseFloat(t))),a=o[0],l=o[1],c=o[2],d=o[3],u=o[4],h=o[5];return new s(a,c,u,l,d,h,0,0,1)}}e.default=s,s.identity=new s(1,0,0,0,1,0,0,0,1)},9765:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PathCommandType=void 0;const r=n(8405),o=n(1520),s=i(n(9784)),a=i(n(2054)),l=i(n(5085)),c=n(6750),d=i(n(3785));var u;!function(t){t[t.LineTo=0]="LineTo",t[t.MoveTo=1]="MoveTo",t[t.CubicBezierTo=2]="CubicBezierTo",t[t.QuadraticBezierTo=3]="QuadraticBezierTo"}(u=e.PathCommandType||(e.PathCommandType={}));const h=t=>{let e;if(t instanceof s.default)e=t.bbox;else if(t instanceof r.Bezier){const n=t.bbox(),i=n.x.max-n.x.min,r=n.y.max-n.y.min;e=new l.default(n.x.min,n.y.min,i,r)}else e=new l.default(t.x,t.y,0,0);return e};class p{constructor(t,e){this.startPoint=t,this.parts=e,this.cachedGeometry=null,this.cachedPolylineApproximation=null,this.cachedStringVersion=null,this.bbox=l.default.bboxOf([t]);for(const n of e)this.bbox=this.bbox.union(p.computeBBoxForSegment(t,n))}getExactBBox(){const t=[];for(const e of this.geometry)t.push(h(e));return l.default.union(...t)}get geometry(){if(this.cachedGeometry)return this.cachedGeometry;let t=this.startPoint;const e=[];for(const n of this.parts)switch(n.kind){case u.CubicBezierTo:e.push(new r.Bezier(t.xy,n.controlPoint1.xy,n.controlPoint2.xy,n.endPoint.xy)),t=n.endPoint;break;case u.QuadraticBezierTo:e.push(new r.Bezier(t.xy,n.controlPoint.xy,n.endPoint.xy)),t=n.endPoint;break;case u.LineTo:e.push(new s.default(t,n.point)),t=n.point;break;case u.MoveTo:e.push(n.point),t=n.point}return this.cachedGeometry=e,this.cachedGeometry}polylineApproximation(){if(this.cachedPolylineApproximation)return this.cachedPolylineApproximation;const t=[];for(const e of this.parts)switch(e.kind){case u.CubicBezierTo:t.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case u.QuadraticBezierTo:t.push(e.controlPoint,e.endPoint);break;case u.MoveTo:case u.LineTo:t.push(e.point)}const e=[];let n=this.startPoint;for(const i of t)e.push(new s.default(n,i)),n=i;return e}static computeBBoxForSegment(t,e){const n=[t];let i;switch(e.kind){case u.MoveTo:case u.LineTo:n.push(e.point);break;case u.CubicBezierTo:n.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case u.QuadraticBezierTo:n.push(e.controlPoint,e.endPoint);break;default:return i=e,i}return l.default.bboxOf(n)}raymarchIntersectionWith(t,e,n=[]){var i,r;if(!t.bbox.intersects(this.bbox.grownBy(e)))return[];const o=t.length,a=[];for(const n of this.geometry){const i=h(n).grownBy(e);if(!i.intersects(t.bbox))continue;let r;r=n instanceof s.default?t=>n.distance(t):n instanceof d.default?t=>n.minus(t).magnitude():t=>n.project(t).d;const l=t=>r(t)-e;l(t.p1)>o&&l(t.p2)>o||a.push({part:n,distFn:r,bbox:i})}if(0===a.length)return[];const l=t=>{let n=1/0,i=null;const r=[];for(const e of a){const{part:o,distFn:s,bbox:a}=e;if(!a.containsPoint(t)){r.push(e);continue}const l=s(t);l<=n&&(n=l,i=o)}for(const{part:e,distFn:o,bbox:s}of r){if(!s.grownBy(n).containsPoint(t))continue;const r=o(t);r<=n&&(n=r,i=e)}return[i,n-e]},c=[t.p1,...n,t.p2],u=e=>e.minus(t.p1).dot(t.direction);c.sort(((t,e)=>u(t)-u(e)));const p=[],f=e/1e3,m=(e,n,i)=>{let r=e,[s,a]=l(r),c=u(r);if(a>o)return c;const d=t.direction.times(n);for(let t=0;t<7;t++){const t=a;if(r=r.plus(d.times(t)),c=u(r),c<=i)return c;const[e,n]=l(r);if(Math.abs(n)>Math.abs(a))return null;if(a=n,s=e,Math.abs(a)<f)break}return s&&(c>=0&&c<=o)&&Math.abs(a)<f&&p.push({point:r,parameterValue:NaN,curve:s}),c};let g=0;for(let t=0;t<c.length;t++){const e=c[t];g=Math.max(g,null!==(i=m(e,1,g))&&void 0!==i?i:g),g=Math.max(g,null!==(r=m(e,-1,g))&&void 0!==r?r:g)}return p}intersection(t,e){let n=[];if(!t.bbox.intersects(this.bbox.grownBy(null!=e?e:0)))return[];for(const e of this.geometry)if(e instanceof s.default){const i=e.intersection(t);i&&n.push({curve:e,parameterValue:i.t,point:i.point})}else if(e instanceof r.Bezier){const i=e.intersects(t).map((n=>{"string"==typeof n&&(n=parseFloat(n));const i=c.Vec2.ofXY(e.get(n));return i.minus(t.p1).magnitude()>t.length||i.minus(t.p2).magnitude()>t.length?null:{point:i,parameterValue:n,curve:e}})).filter((t=>null!==t));n.push(...i)}if(e&&e>1e-8){const i=n.map((t=>t.point));n=this.raymarchIntersectionWith(t,e,i)}return n}static mapPathCommand(t,e){switch(t.kind){case u.MoveTo:case u.LineTo:return{kind:t.kind,point:e(t.point)};case u.CubicBezierTo:return{kind:t.kind,controlPoint1:e(t.controlPoint1),controlPoint2:e(t.controlPoint2),endPoint:e(t.endPoint)};case u.QuadraticBezierTo:return{kind:t.kind,controlPoint:e(t.controlPoint),endPoint:e(t.endPoint)}}return t}mapPoints(t){const e=t(this.startPoint),n=[];for(const e of this.parts)n.push(p.mapPathCommand(e,t));return new p(e,n)}transformedBy(t){return t.isIdentity()?this:this.mapPoints((e=>t.transformVec2(e)))}union(t){return t?new p(this.startPoint,[...this.parts,{kind:u.MoveTo,point:t.startPoint},...t.parts]):this}getEndPoint(){if(0===this.parts.length)return this.startPoint;const t=this.parts[this.parts.length-1];return t.kind===u.QuadraticBezierTo||t.kind===u.CubicBezierTo?t.endPoint:t.point}roughlyIntersects(t,e=0){if(0===this.parts.length)return t.containsPoint(this.startPoint);if(this.startPoint.eq(this.getEndPoint())&&0===e)return this.closedRoughlyIntersects(t);if(t.containsRect(this.bbox))return!0;let n=this.startPoint;for(const i of this.parts){const r=p.computeBBoxForSegment(n,i).grownBy(e);if(n=i.kind===u.LineTo||i.kind===u.MoveTo?i.point:i.endPoint,t.intersects(r))return!0}return!1}closedRoughlyIntersects(t){if(t.containsRect(this.bbox))return!0;const e=this.bbox.topLeft.minus(c.Vec2.of(1,1)),n=t.corners,i=this.polylineApproximation();for(const t of n){const n=new s.default(t,e);let r=0;for(const t of i)t.intersects(n)&&r++;if(r%2==1)return!0}const r=t.grownBy(Math.min(t.size.x,t.size.y)),o=[];for(const t of r.divideIntoGrid(4,4))o.push(...t.getEdges());for(const t of o)for(const e of i)if(t.intersects(e))return!0;return!1}static fromRect(t,e=null){const n=[];let i,r;if(null!==e){const n=c.Vec2.of(e,e).times(.5),o=l.default.fromCorners(t.topLeft.plus(n),t.bottomRight.minus(n)),s=l.default.fromCorners(t.topLeft.minus(n),t.bottomRight.plus(n));i=[o.corners[3],...o.corners,...s.corners.reverse()],r=s.corners[3]}else i=t.corners.slice(1),r=t.corners[0];for(const t of i)n.push({kind:u.LineTo,point:t});return n.push({kind:u.LineTo,point:r}),new p(r,n)}static fromRenderable(t){return t.path?t.path:new p(t.startPoint,t.commands)}toRenderable(t){return{startPoint:this.startPoint,style:t,commands:this.parts,path:this}}static visualEquivalent(t,e){var n,i;const r=p.fromRenderable(t),o=null!==(i=null===(n=t.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0,s=o>0&&0===t.style.fill.a;if(e.grownBy(o).transformedBoundingBox(a.default.scaling2D(4,e.center)).containsRect(r.bbox.grownBy(o)))return t;const l=[];let c=r.startPoint;for(const t of r.parts){const n=p.computeBBoxForSegment(c,t).grownBy(o);let i;i=t.kind===u.LineTo||t.kind===u.MoveTo?t.point:t.endPoint;n.intersects(e)?l.push(t):s||t.kind===u.MoveTo?l.push({kind:u.MoveTo,point:i}):l.push({kind:u.LineTo,point:i}),c=i}return new p(r.startPoint,l).toRenderable(t.style)}toString(t){if(this.cachedStringVersion)return this.cachedStringVersion;void 0===t&&(t=Math.abs(this.bbox.topLeft.x)>10&&Math.abs(this.bbox.topLeft.y)>10);const e=p.toString(this.startPoint,this.parts,!t);return this.cachedStringVersion=e,e}serialize(){return this.toString()}static toString(t,e,n){var i;const r=[];let s;const a=(t,...e)=>{const i=[],a=[],l=!s||n,c=s?(0,o.toRoundedString)(s.x):"",d=s?(0,o.toRoundedString)(s.y):"";for(const t of e){const e=(0,o.toRoundedString)(t.x),n=(0,o.toRoundedString)(t.y);if(l)i.push(`${e},${n}`);else{const i=(0,o.toStringOfSamePrecision)(t.x-s.x,e,c,d),r=(0,o.toStringOfSamePrecision)(t.y-s.y,n,c,d);"-"===r.charAt(0)?a.push(`${i}${r}`):a.push(`${i},${r}`)}}let u;u=l?`${t}${i.join(" ")}`:`${t.toLowerCase()}${a.join(" ")}`,"l0,0"!==u&&"m0,0"!==u&&(r.push(u),e.length>0&&(s=e[e.length-1]))};let l;(null===(i=e[0])||void 0===i?void 0:i.kind)!==u.MoveTo&&a("M",t);for(let t=0;t<e.length;t++){const n=e[t];switch(n.kind){case u.MoveTo:a("M",n.point);break;case u.LineTo:a("L",n.point);break;case u.CubicBezierTo:a("C",n.controlPoint1,n.controlPoint2,n.endPoint);break;case u.QuadraticBezierTo:a("Q",n.controlPoint,n.endPoint);break;default:return l=n,l}}return r.join("")}static fromString(t){var e;t=t.split("\n").join(" ");let n=c.Vec2.zero,i=null,r=null,o=!0;const s=[],a=t=>{o?o=!1:s.push({kind:u.LineTo,point:t})},l={m:1,l:1,c:3,q:2,z:0,h:1,v:1},d=/([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/gi;let h;for(;null!==(h=d.exec(t));){const t=h[2].trim().split(/[^0-9Ee.-]/).filter((t=>t.length>0)).reduce(((t,e)=>{const n=(e=e.replace(/([^eE])[-]/g,"$1 -")).split(" -");return""!==n[0]&&t.push(n[0]),t.push(...n.slice(1).map((t=>`-${t}`))),t}),[]);let d=t.map((t=>parseFloat(t))),p=h[1].toLowerCase(),x=h[1]!==p;if("v"===p||"h"===p)d=d.reduce(((t,e)=>"v"===p?t.concat(x?n.x:0,e):t.concat(e,x?n.y:0)),[]),p="l";else if("z"===p){if(!i)continue;d=[i.x,i.y],i=n,x=!0,p="l"}const w=null!==(e=l[p])&&void 0!==e?e:0,T=d.reduce(((t,e,n,i)=>{if(n%2!=0){const r=e,o=i[n-1];return t.concat(c.Vec2.of(o,r))}return t}),[]).map(((t,e)=>{let i;return i=x?t:n.plus(t),(e+1)%w==0&&(n=i),i}));if(T.length%w!=0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(T)} with a length of ${T.length} ≠ ${w}k, k ∈ ℤ.`,`The number of arguments to ${p} must be a multiple of ${w}!`,`Command: ${h[0]}`].join("\n"));for(let t=0;t<T.length;t+=w){const e=T.slice(t,t+w);switch(p.toLowerCase()){case"m":0===t?(b=e[0],o?o=!1:s.push({kind:u.MoveTo,point:b})):a(e[0]);break;case"l":a(e[0]);break;case"c":g=e[0],v=e[1],y=e[2],s.push({kind:u.CubicBezierTo,controlPoint1:g,controlPoint2:v,endPoint:y});break;case"q":f=e[0],m=e[1],s.push({kind:u.QuadraticBezierTo,controlPoint:f,endPoint:m});break;default:throw new Error(`Unknown path command ${p}`)}o=!1}T.length>0&&(null!=i||(i=T[0]),null!=r||(r=i),n=T[T.length-1])}var f,m,g,v,y,b;const x=new p(null!=r?r:c.Vec2.zero,s);return x.cachedStringVersion=t,x}}e.default=p,p.empty=new p(c.Vec2.zero,[])},5085:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9784)),o=n(6750);class s{constructor(t,e,n,i){this.x=t,this.y=e,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=o.Vec2.of(this.x,this.y),this.size=o.Vec2.of(this.w,this.h),this.bottomRight=this.topLeft.plus(this.size),this.center=this.topLeft.plus(this.size.times(.5)),this.area=this.w*this.h}translatedBy(t){return new s(t.x+this.x,t.y+this.y,this.w,this.h)}resizedTo(t){return new s(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.bottomRight.x>=t.bottomRight.x&&this.bottomRight.y>=t.bottomRight.y}intersects(t){const e=this.x,n=e+this.w,i=t.x,r=t.x+t.w;if(n<i||e>r)return!1;const o=this.y,s=o+this.h,a=t.y,l=t.y+t.h;return!(s<a||o>l)}intersection(t){if(!this.intersects(t))return null;const e=this.topLeft.zip(t.topLeft,Math.max),n=this.bottomRight.zip(t.bottomRight,Math.min);return s.fromCorners(e,n)}union(t){return s.union(this,t)}divideIntoGrid(t,e){const n=[];if(t<=0||e<=0)return n;const i=this.w/t,r=this.h/e;0===i&&(t=1),0===r&&(e=1);for(let o=0;o<e;o++)for(let e=0;e<t;e++){const t=i*e+this.x,a=r*o+this.y;n.push(new s(t,a,i,r))}return n}grownToPoint(t,e=0){const n=new s(t.x-e,t.y-e,2*e,2*e);return this.union(n)}grownBy(t){return 0===t?this:new s(this.x-t,this.y-t,this.w+2*t,this.h+2*t)}getClosestPointOnBoundaryTo(t){const e=this.getEdges().map((e=>e.closestPointTo(t)));let n=null,i=null;for(const r of e){const e=r.minus(t).length();(null===i||e<i)&&(n=r,i=e)}return n}get corners(){return[this.bottomRight,this.topRight,this.topLeft,this.bottomLeft]}get maxDimension(){return Math.max(this.w,this.h)}get topRight(){return this.bottomRight.plus(o.Vec2.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(o.Vec2.of(0,this.h))}get width(){return this.w}get height(){return this.h}getEdges(){const t=this.corners;return[new r.default(t[0],t[1]),new r.default(t[1],t[2]),new r.default(t[2],t[3]),new r.default(t[3],t[0])]}transformedBoundingBox(t){return s.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 s(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.abs(t.x-e.x),Math.abs(t.y-e.y))}static bboxOf(t,e=0){let n=0,i=0,r=0,a=0,l=!0;for(const e of t)l&&(n=e.x,i=e.y,r=e.x,a=e.y,l=!1),n=Math.min(n,e.x),i=Math.min(i,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y);return s.fromCorners(o.Vec2.of(n-e,i-e),o.Vec2.of(r+e,a+e))}static union(...t){if(0===t.length)return s.empty;const e=t[0];let n=e.topLeft.x,i=e.topLeft.y,r=e.bottomRight.x,o=e.bottomRight.y;for(let e=1;e<t.length;e++){const s=t[e];n=Math.min(n,s.topLeft.x),i=Math.min(i,s.topLeft.y),r=Math.max(r,s.bottomRight.x),o=Math.max(o,s.bottomRight.y)}return new s(n,i,r-n,o-i)}static of(t){var e,n,i,r;const o=null!==(n=null!==(e=t.width)&&void 0!==e?e:t.w)&&void 0!==n?n:0,a=null!==(r=null!==(i=t.height)&&void 0!==i?i:t.h)&&void 0!==r?r:0;return new s(t.x,t.y,o,a)}}e.default=s,s.empty=new s(0,0,0,0),s.unitSquare=new s(0,0,1,1)},6750:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Vec2=void 0;const r=i(n(3785));!function(t){t.of=(t,e)=>r.default.of(t,e,0),t.ofXY=({x:t,y:e})=>r.default.of(t,e,0),t.unitX=t.of(1,0),t.unitY=t.of(0,1),t.zero=t.of(0,0)}(e.Vec2||(e.Vec2={}))},3785:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{constructor(t,e,n){this.x=t,this.y=e,this.z=n}get xy(){return{x:this.x,y:this.y}}static of(t,e,i){return new n(t,e,i)}at(t){if(0===t)return this.x;if(1===t)return this.y;if(2===t)return this.z;throw new Error(`${t} out of bounds!`)}length(){return this.magnitude()}magnitude(){return Math.sqrt(this.dot(this))}magnitudeSquared(){return this.dot(this)}angle(){return Math.atan2(this.y,this.x)}normalized(){const t=this.magnitude();return n.of(this.x/t,this.y/t,this.z/t)}times(t){return n.of(this.x*t,this.y*t,this.z*t)}plus(t){return n.of(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){return n.of(this.x-t.x,this.y-t.y,this.z-t.z)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){return n.of(this.y*t.z-t.y*this.z,t.x*this.z-this.x*t.z,this.x*t.y-t.x*this.y)}scale(t){return"number"==typeof t?this.times(t):n.of(this.x*t.x,this.y*t.y,this.z*t.z)}orthog(){return 0===this.dot(n.unitX)&&0===this.dot(n.unitY)?0===this.dot(n.unitX)?n.unitX:this.cross(n.unitX).normalized():this.cross(n.unitZ.times(-1)).normalized()}extend(t,e){return this.plus(e.normalized().times(t))}lerp(t,e){return this.times(1-e).plus(t.times(e))}zip(t,e){return n.of(e(t.x,this.x),e(t.y,this.y),e(t.z,this.z))}map(t){return n.of(t(this.x,0),t(this.y,1),t(this.z,2))}asArray(){return[this.x,this.y,this.z]}eq(t,e=1e-10){for(let n=0;n<3;n++)if(Math.abs(t.at(n)-this.at(n))>e)return!1;return!0}toString(){return`Vec(${this.x}, ${this.y}, ${this.z})`}}e.default=n,n.unitX=n.of(1,0,0),n.unitY=n.of(0,1,0),n.unitZ=n.of(0,0,1),n.zero=n.of(0,0,0)},4915:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Vec2=e.Vec3=e.Rect2=e.Path=e.Mat33=e.LineSegment2=void 0;const r=i(n(9784));e.LineSegment2=r.default;const o=i(n(2054));e.Mat33=o.default;const s=i(n(9765));e.Path=s.default;const a=i(n(5085));e.Rect2=a.default;const l=n(6750);Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return l.Vec2}});const c=i(n(3785));e.Vec3=c.default},148:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(8405),o=n(6750),s=i(n(8198));class a{constructor(t,e,n){this.p0=t,this.p1=e,this.p2=n,this.bezierJs=null}static componentAt(t,e,n,i){return e+t*(-2*e+2*n)+t*t*(e-2*n+i)}static derivativeComponentAt(t,e,n,i){return-2*e+2*n+2*t*(e-2*n+i)}at(t){const e=this.p0,n=this.p1,i=this.p2;return o.Vec2.of(a.componentAt(t,e.x,n.x,i.x),a.componentAt(t,e.y,n.y,i.y))}derivativeAt(t){const e=this.p0,n=this.p1,i=this.p2;return o.Vec2.of(a.derivativeComponentAt(t,e.x,n.x,i.x),a.derivativeComponentAt(t,e.y,n.y,i.y))}approximateDistance(t){const e=this.p0.x-t.x,n=-2*this.p0.x+2*this.p1.x,i=this.p0.x-2*this.p1.x+this.p2.x,r=this.p0.y-t.y,o=-2*this.p0.y+2*this.p1.y,a=this.p0.y-2*this.p1.y+this.p2.y,l=2*e*n+2*r*o-t.x*n-t.y*o,c=2*n*n+2*o*o+2*i*e+2*a*r-t.x*i-t.y*a,d=2*(2*o*a+2*n*i+2*i*n+2*a*o);let[u,h]=(0,s.default)(d/2,c,l);isNaN(u)&&(u=.25),isNaN(h)&&(h=.75);const p=this.at(u),f=this.at(h),m=p.minus(t).magnitudeSquared(),g=f.minus(t).magnitudeSquared(),v=this.at(0).minus(t).magnitudeSquared(),y=this.at(1).minus(t).magnitudeSquared();return Math.sqrt(Math.min(m,g,v,y))}distance(t){return this.bezierJs||(this.bezierJs=new r.Bezier([this.p0.xy,this.p1.xy,this.p2.xy])),this.bezierJs.project(t.xy).d}normal(t){return this.derivativeAt(t).orthog().normalized()}}e.default=a},8198:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e,n)=>{if(0===t){let t;return t=0===e?0===n?0:NaN:-n/e,[t,t]}const i=e*e-4*t*n;if(i<0)return[NaN,NaN];const r=Math.sqrt(i),o=(-e+r)/(2*t),s=(-e-r)/(2*t);return o>s?[o,s]:[s,o]}},1520:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toStringOfSamePrecision=e.getLenAfterDecimal=e.toRoundedString=e.cleanUpNumber=void 0;e.cleanUpNumber=t=>{if(t.indexOf("e")>0&&t.match(/[eE][-]\d{2,}$/))return"0";const e=t.charAt(t.length-1);"0"!==e&&"."!==e||(t=(t=(t=t.replace(/([.]\d*[^0]+)0+$/,"$1")).replace(/[.]0+$/,".")).replace(/[.]$/,""));const n=t.charAt(0);return"0"!==n&&"-"!==n||(t=(t=(t=t.replace(/^(0+)[.]/,".")).replace(/^-(0+)[.]/,"-.")).replace(/^(-?)0+$/,"$10")),"-0"===t?"0":t};e.toRoundedString=t=>{let n=t.toString(10);if(-1===n.indexOf("."))return n;const i=/^([-]?)(\d*)\.(\d{3,}9{4,})\d{1,4}$/.exec(n);if(i){const t=i[1],e=i[3],r=parseInt(e.charAt(e.length-1),10),o=parseInt(e,10),s=parseInt(i[2],10),a=i[3];let l=(o+10-r).toString(),c=0;for(l.length>o.toString().length&&(l=l.substring(1),c=1);l.length<a.length;)l=c.toString(10)+l,c=0;n=`${t+(s+c).toString()}.${l}`}return n=n.replace(/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,"$1"),(0,e.cleanUpNumber)(n)};const n=/^([-]?)(\d*)[.](\d+)$/;e.getLenAfterDecimal=t=>{const e=n.exec(t);if(!e)return-1!==t.search(/[eE]/)||/^[a-zA-Z]+$/.exec(t)?-1:0;return e[3].length};e.toStringOfSamePrecision=(t,...i)=>{const r=t.toString(10),o=n.exec(r);if(!o)return r;let s=-1;for(const t of i)s=Math.max((0,e.getLenAfterDecimal)(t),s);if(-1===s)return(0,e.toRoundedString)(t);let a=o[3].substring(0,s),l=o[2];const c=o[3].charAt(s);if(""!==c){if(parseInt(c,10)>=5){if(a.length>0){const t=/^(0+)(\d*)$/.exec(a);let e="",n=a;t&&(e=t[1],n=t[2]),a=(parseInt(a)+1).toString(),a.length>n.length&&e.length>0&&(e=e.substring(1)),a=e+a}(0===a.length||a.length>s)&&(l=(parseInt(l)+1).toString(),a=a.substring(1))}}const d=o[1];return(0,e.cleanUpNumber)(`${d}${l}.${a}`)}},5860:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RenderingMode=void 0;const r=i(n(972)),o=n(9699),s=i(n(1782)),a=n(6750),l=i(n(3061)),c=i(n(2634)),d=i(n(8233));var u;!function(t){t[t.DummyRenderer=0]="DummyRenderer",t[t.CanvasRenderer=1]="CanvasRenderer"}(u=e.RenderingMode||(e.RenderingMode={}));e.default=class{constructor(t,e,n){if(this.editor=t,this.parent=n,this.textRerenderOutput=null,this.getColorAt=t=>null,e===u.CanvasRenderer)this.initializeCanvasRendering();else{if(e!==u.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 i=a.Vec2.of(600,600);this.cache=new l.default({createRenderer:()=>{if(e===u.DummyRenderer)return new s.default(t.viewport);if(e!==u.CanvasRenderer)throw new Error("Unspported rendering mode");const n=document.createElement("canvas");n.width=i.x+1,n.height=i.y+1;const o=n.getContext("2d");return new r.default(o,t.viewport)},isOfCorrectType:t=>this.dryInkRenderer.canRenderFromWithoutDataLoss(t),blockResolution:i,cacheSize:1296e5,maxScale:1.3,minProportionalRenderTimePerCache:80,minProportionalRenderTimeToUseCache:420}),this.editor.notifier.on(o.EditorEventType.DisplayResized,(t=>{var e;if(t.kind!==o.EditorEventType.DisplayResized)throw new Error("Mismatched event.kinds!");null===(e=this.resizeSurfacesCallback)||void 0===e||e.call(this)}))}get width(){return this.dryInkRenderer.displaySize().x}get height(){return this.dryInkRenderer.displaySize().y}getCache(){return this.cache}initializeCanvasRendering(){const t=document.createElement("canvas"),e=document.createElement("canvas"),n=t.getContext("2d"),i=e.getContext("2d");this.dryInkRenderer=new r.default(n,this.editor.viewport),this.wetInkRenderer=new r.default(i,this.editor.viewport),t.className="dryInkCanvas",e.className="wetInkCanvas",this.parent&&(this.parent.appendChild(t),this.parent.appendChild(e)),this.resizeSurfacesCallback=()=>{const n=t=>t.clientHeight!==t.height||t.clientWidth!==t.width;(n(t)||n(e))&&(t.width=t.clientWidth,t.height=t.clientHeight,e.width=e.clientWidth,e.height=e.clientHeight,this.editor.notifier.dispatch(o.EditorEventType.DisplayResized,{kind:o.EditorEventType.DisplayResized,newSize:a.Vec2.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{n.drawImage(e,0,0)},this.getColorAt=t=>{const e=n.getImageData(t.x,t.y,1,1),i=null==e?void 0:e.data;if(i){return d.default.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)}rerenderAsText(){this.textRenderer.clear(),this.editor.image.render(this.textRenderer,this.editor.viewport),this.textRerenderOutput&&(this.textRerenderOutput.innerText=this.textRenderer.getDescription())}startRerender(){var t;return null===(t=this.resizeSurfacesCallback)||void 0===t||t.call(this),this.wetInkRenderer.clear(),this.dryInkRenderer.clear(),this.dryInkRenderer}setDraftMode(t){this.dryInkRenderer.setDraftMode(t)}getDryInkRenderer(){return this.dryInkRenderer}getWetInkRenderer(){return this.wetInkRenderer}flatten(){var t;null===(t=this.flattenCallback)||void 0===t||t.call(this)}}},9604:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.styleFromJSON=e.styleToJSON=e.stylesEqual=e.cloneStyle=void 0;const r=i(n(8233));e.cloneStyle=t=>({fill:t.fill,stroke:t.stroke?Object.assign({},t.stroke):void 0});e.stylesEqual=(t,e)=>{var n,i,r,o,s,a;const l=t===e||t.fill.eq(e.fill)&&null==t.stroke==(null==e.stroke)&&(null===(o=null===(i=null===(n=t.stroke)||void 0===n?void 0:n.color)||void 0===i?void 0:i.eq(null===(r=e.stroke)||void 0===r?void 0:r.color))||void 0===o||o)&&(null===(s=t.stroke)||void 0===s?void 0:s.width)===(null===(a=e.stroke)||void 0===a?void 0:a.width);return null!=l&&l};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:r.default.fromHex(t.stroke.color),width:t.stroke.width}:void 0;return{fill:r.default.fromHex(t.fill),stroke:e}}},1281:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.textStyleToJSON=e.textStyleFromJSON=e.cloneTextStyle=void 0;const i=n(9604);e.cloneTextStyle=t=>Object.assign(Object.assign({},t),{renderingStyle:(0,i.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,i.styleFromJSON)(t.renderingStyle),size:t.size,fontWeight:t.fontWeight,fontVariant:t.fontVariant,fontFamily:t.fontFamily}};e.textStyleToJSON=t=>Object.assign(Object.assign({},t),{renderingStyle:(0,i.styleToJSON)(t.renderingStyle)})},4999:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2054));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(){var t;null===(t=this.onBeforeDeallocCallback)||void 0===t||t.call(this),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 r.default.scaling2D(this.cacheState.props.blockResolution.x/t.size.x).rightMul(r.default.translation(t.topLeft.times(-1)))}setRenderingRegion(t){this.renderer.setTransform(this.getTransform(t))}}},1390:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CacheRecordManager=void 0;const r=i(n(4999));e.CacheRecordManager=class{constructor(t){this.cacheRecords=[],this.maxCanvases=Math.ceil(t.cacheSize/4/t.blockResolution.x/t.blockResolution.y)}setSharedState(t){this.cacheState=t}allocCanvas(t,e){if(this.cacheRecords.length<this.maxCanvases){const n=new r.default(e,this.cacheState);return n.setRenderingRegion(t),this.cacheRecords.push(n),n}{const n=this.getLeastRecentlyUsedRecord();return n.realloc(e),n.setRenderingRegion(t),n}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort(((t,e)=>t.getLastUsedCycle()-e.getLastUsedCycle())),this.cacheRecords[0]}}},3061:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=i(n(6899)),s=n(1390);e.default=class{constructor(t){this.recordManager=new s.CacheRecordManager(t),this.sharedState={props:t,currentRenderingCycle:0,recordManager:this.recordManager},this.recordManager.setSharedState(this.sharedState)}render(t,e,n){var i;const s=n.visibleRect;if(this.sharedState.currentRenderingCycle++,!this.sharedState.props.isOfCorrectType(t))return void e.render(t,s);if(!this.rootNode){const t=this.sharedState.props.blockResolution,e=s.topLeft;this.rootNode=new o.default(new r.default(e.x,e.y,t.x,t.y),this.sharedState)}for(;!this.rootNode.region.containsRect(s);)this.rootNode=this.rootNode.generateParent();this.rootNode=null!==(i=this.rootNode.smallestChildContaining(s))&&void 0!==i?i:this.rootNode;const a=e.getLeavesIntersectingRegion(n.visibleRect,(e=>t.isTooSmallToRender(e)));let l=0;for(const t of a)l+=t.getContent().getProportionalRenderingTime();l>this.sharedState.props.minProportionalRenderTimeToUseCache?this.rootNode.renderItems(t,[e],n):e.render(t,s)}}},6899:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});i(n(8233));const r=n(4721),o=i(n(5085)),s=!1;class a{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=o.default.fromCorners(this.region.topLeft.minus(this.region.size),this.region.bottomRight.plus(this.region.size)),e=new a(t,this.cacheState);e.generateChildren();const n=this.region.maxDimension/100,i=(e.instantiatedChildren.length-1)/2;if(!e.instantiatedChildren[i].region.eq(this.region,n))throw console.error(e.instantiatedChildren[i].region,"≠",this.region),new Error("Logic error: [this] is not contained within its parent's center child");return e.instantiatedChildren[i]=this,this.parent=e,e}generateChildren(){if(0===this.instantiatedChildren.length){const t=this.region.divideIntoGrid(3,3);if(0===this.region.size.x||0===this.region.size.y)return void console.warn("Cache element has zero size! Not generating children.");for(const e of t){const t=new a(e,this.cacheState);t.parent=this,this.instantiatedChildren.push(t)}}this.checkRep()}getChildren(){return this.checkRep(),this.generateChildren(),this.instantiatedChildren}smallestChildContaining(t){var e;const n=t.maxDimension>this.region.maxDimension/3;if(!this.region.containsRect(t)||n)return null;for(const n of this.getChildren())if(n.region.containsRect(t))return null!==(e=n.smallestChildContaining(t))&&void 0!==e?e:n;return null}renderingWouldBeHighEnoughResolution(t){const e=this.region.w/this.cacheState.props.blockResolution.x;return!(t.getScaleFactor()*e>this.cacheState.props.maxScale)}allChildrenCanRender(t,e){if(0===this.instantiatedChildren.length)return!1;for(const n of this.instantiatedChildren)if(n.region.intersects(t.visibleRect)&&!n.renderingIsUpToDate(this.idsOfIntersecting(e)))return!1;return!0}computeSortedByLeafIds(t){const e=t.slice();return e.sort(((t,e)=>t.getId()-e.getId())),e}idsOfIntersecting(t){const e=[];for(const n of t)n.getBBox().intersects(this.region)&&e.push(n.getId());return e}allRenderedIdsIn(t){if(this.renderedIds.length>t.length)return!1;for(let e=0;e<this.renderedIds.length;e++)if(t[e]!==this.renderedIds[e])return!1;return!0}renderingIsUpToDate(t){return null!==this.cachedRenderer&&t.length===this.renderedIds.length&&this.allRenderedIdsIn(t)}renderItems(t,e,n){var i,a;if(!n.visibleRect.intersects(this.region)||0===e.length)return;const l=[];for(const t of e){const e=t.getBBox();e.intersects(this.region)&&(e.maxDimension>=this.region.maxDimension?l.push(...t.getChildrenOrSelfIntersectingRegion(this.region)):l.push(t))}if(e=l,!this.cacheState.props.isOfCorrectType(t))return void e.forEach((e=>e.render(t,n.visibleRect)));if(this.renderingWouldBeHighEnoughResolution(n)){const l=t=>t.w/this.region.w<1/this.cacheState.props.blockResolution.x,c=[];for(const t of e)c.push(...t.getLeavesIntersectingRegion(this.region,l));(0,r.sortLeavesByZIndex)(c);const d=this.computeSortedByLeafIds(c);if(0===d.length)return;const u=d.map((t=>t.getId()));let h;if(this.renderingIsUpToDate(u))h=this.cachedRenderer.startRender();else{if(this.allChildrenCanRender(n,d)){for(const i of this.getChildren())i.renderItems(t,e,n);return}let r=0;for(const t of d)r+=t.getContent().getProportionalRenderingTime();if(r>this.cacheState.props.minProportionalRenderTimePerCache){let t=!0;if(this.cachedRenderer)if(d.length>this.renderedIds.length&&this.allRenderedIdsIn(u)&&null!==this.renderedMaxZIndex){const e=[];let n=null;for(let t=0;t<d.length;t++){const i=d[t],r=i.getContent().getZIndex();(t>=this.renderedIds.length||i.getId()!==this.renderedIds[t])&&(e.push(i),(null===n||r<n)&&(n=r))}if(null!==n&&n>this.renderedMaxZIndex){t=!1,h=this.cachedRenderer.startRender();for(let t=0;t<c.length;t++){const e=c[t],n=e.getContent().getZIndex();n>this.renderedMaxZIndex&&(e.render(h,this.region),this.renderedMaxZIndex=n)}s}}else s;else this.cachedRenderer=this.cacheState.recordManager.allocCanvas(this.region,(()=>this.onRegionDealloc()));if(t){h=this.cachedRenderer.startRender(),h.clear(),this.renderedMaxZIndex=null;for(const t of c){const e=t.getContent();null!==(i=this.renderedMaxZIndex)&&void 0!==i||(this.renderedMaxZIndex=e.getZIndex()),this.renderedMaxZIndex=Math.max(this.renderedMaxZIndex,e.getZIndex()),t.render(h,this.region)}s}this.renderedIds=u}else{null===(a=this.cachedRenderer)||void 0===a||a.dealloc();const e=n.getSizeOfPixelOnCanvas(),i=new o.default(this.region.x,this.region.y,this.region.w+e,this.region.h+e),r=!0;t.startObject(i,r);for(const e of c)e.render(t,this.region.intersection(n.visibleRect));t.endObject()}}if(h){const e=this.cachedRenderer.getTransform(this.region).inverse();t.renderFromOtherOfSameType(e,h)}this.instantiatedChildren.every((t=>t.isEmpty()))&&(this.instantiatedChildren=[])}else for(const i of this.getChildren())i.renderItems(t,e.filter((t=>t.getBBox().intersects(i.region))),n);this.checkRep()}isEmpty(){return null===this.cachedRenderer&&this.instantiatedChildren.every((t=>t.isEmpty()))}onRegionDealloc(){this.cachedRenderer=null,this.isEmpty()&&(this.instantiatedChildren=[])}checkRep(){if(9!==this.instantiatedChildren.length&&0!==this.instantiatedChildren.length)throw new Error(`Repcheck: Wrong number of children. Got ${this.instantiatedChildren.length}`);if(void 0!==this.renderedIds[1]&&this.renderedIds[0]>=this.renderedIds[1])throw console.error(this.renderedIds),new Error("Repcheck: First two ids are not in ascending order!");for(const t of this.instantiatedChildren)if(t.parent!==this)throw new Error("Children should be linked to their parents!");if(this.cachedRenderer&&!this.cachedRenderer.isAllocd())throw new Error("this' cachedRenderer != null, but is dealloc'd")}}e.default=a},5414:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RenderingMode=e.Display=e.CanvasRenderer=e.SVGRenderer=e.DummyRenderer=e.AbstractRenderer=void 0;var r=n(8157);Object.defineProperty(e,"AbstractRenderer",{enumerable:!0,get:function(){return i(r).default}});var o=n(1782);Object.defineProperty(e,"DummyRenderer",{enumerable:!0,get:function(){return i(o).default}});var s=n(9563);Object.defineProperty(e,"SVGRenderer",{enumerable:!0,get:function(){return i(s).default}});var a=n(972);Object.defineProperty(e,"CanvasRenderer",{enumerable:!0,get:function(){return i(a).default}});var l=n(5860);Object.defineProperty(e,"Display",{enumerable:!0,get:function(){return i(l).default}}),Object.defineProperty(e,"RenderingMode",{enumerable:!0,get:function(){return l.RenderingMode}})},1603:(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"}},8157:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});const s=o(n(9765)),a=n(6750),l=n(9604);e.default=class{constructor(t){this.viewport=t,this.selfTransform=null,this.transformStack=[],this.objectLevel=0,this.currentPaths=null}getViewport(){return this.viewport}setDraftMode(t){}flushPath(){if(!this.currentPaths)return;let t=null;for(const e of this.currentPaths){const{startPoint:n,commands:i,style:r}=e;t&&(0,l.stylesEqual)(t,r)?this.moveTo(n):(t&&this.endPath(t),this.beginPath(n),t=r);for(const t of i)t.kind===s.PathCommandType.LineTo?this.lineTo(t.point):t.kind===s.PathCommandType.MoveTo?this.moveTo(t.point):t.kind===s.PathCommandType.CubicBezierTo?this.traceCubicBezierCurve(t.controlPoint1,t.controlPoint2,t.endPoint):t.kind===s.PathCommandType.QuadraticBezierTo&&this.traceQuadraticBezierCurve(t.controlPoint,t.endPoint)}t&&this.endPath(t)}drawPath(t){0===this.objectLevel?(this.currentPaths=[t],this.flushPath(),this.currentPaths=null):this.currentPaths.push(t)}drawRect(t,e,n){const i=s.default.fromRect(t,e);this.drawPath(i.toRenderable(n))}fillRect(t,e){const n=s.default.fromRect(t);this.drawPath(n.toRenderable({fill:e}))}startObject(t,e){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(){var t;if(0===this.transformStack.length)throw new Error("Unable to pop more transforms than have been pushed!");this.setTransform(null!==(t=this.transformStack.pop())&&void 0!==t?t:null)}getCanvasToScreenTransform(){return this.selfTransform?this.selfTransform:this.viewport.canvasToScreenTransform}canvasToScreen(t){return this.getCanvasToScreenTransform().transformVec2(t)}getSizeOfCanvasPixelOnScreen(){return this.getCanvasToScreenTransform().transformVec3(a.Vec2.unitX).length()}}},972:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=i(n(6205)),s=i(n(9765)),a=n(6750),l=i(n(8157));class c extends l.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 c}renderFromOtherOfSameType(t,e){if(!(e instanceof c))throw new Error(`${e} cannot be rendered onto ${this}`);t=this.getCanvasToScreenTransform().rightMul(t),this.ctx.save(),this.transformBy(t),this.ctx.drawImage(e.ctx.canvas,0,0),this.ctx.restore()}setDraftMode(t){t?(this.minSquareCurveApproxDist=9,this.minRenderSizeBothDimens=2,this.minRenderSizeAnyDimen=.5):(this.minSquareCurveApproxDist=.5,this.minRenderSizeBothDimens=.2,this.minRenderSizeAnyDimen=1e-6)}displaySize(){return a.Vec2.of(this.ctx.canvas.clientWidth,this.ctx.canvas.clientHeight)}clear(){this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}beginPath(t){t=this.canvasToScreen(t),this.ctx.beginPath(),this.ctx.moveTo(t.x,t.y)}endPath(t){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.closePath()}lineTo(t){t=this.canvasToScreen(t),this.ctx.lineTo(t.x,t.y)}moveTo(t){t=this.canvasToScreen(t),this.ctx.moveTo(t.x,t.y)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n);const i=e.minus(t),r=n.minus(e);i.magnitudeSquared()<this.minSquareCurveApproxDist&&r.magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(n.x,n.y):this.ctx.bezierCurveTo(t.x,t.y,e.x,e.y,n.x,n.y)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e);t.minus(e).magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(e.x,e.y):this.ctx.quadraticCurveTo(t.x,t.y,e.x,e.y)}drawPath(t){var e;this.ignoringObject||((null===(e=this.currentObjectBBox)||void 0===e?void 0:e.containsRect(this.getViewport().visibleRect))&&(t=s.default.visualEquivalent(t,this.getViewport().visibleRect)),super.drawPath(t))}drawText(t,e,n){this.ctx.save(),e=this.getCanvasToScreenTransform().rightMul(e),this.transformBy(e),o.default.applyTextStyles(this.ctx,n),0!==n.renderingStyle.fill.a&&(this.ctx.fillStyle=n.renderingStyle.fill.toHexString(),this.ctx.fillText(t,0,0)),n.renderingStyle.stroke&&(this.ctx.strokeStyle=n.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=n.renderingStyle.stroke.width,this.ctx.strokeText(t,0,0)),this.ctx.restore()}drawImage(t){this.ctx.save();const e=this.getCanvasToScreenTransform().rightMul(t.transform);this.transformBy(e),this.ctx.drawImage(t.image,0,0),this.ctx.restore()}startObject(t,e){if(this.isTooSmallToRender(t)&&(this.ignoreObjectsAboveLevel=this.getNestingLevel(),this.ignoringObject=!0),super.startObject(t),this.currentObjectBBox=t,!this.ignoringObject&&e){this.clipLevels.push(this.objectLevel),this.ctx.save(),this.ctx.beginPath();for(const e of t.corners){const t=this.canvasToScreen(e);this.ctx.lineTo(t.x,t.y)}this.ctx.clip()}}endObject(){const t=this.objectLevel;this.currentObjectBBox=null,super.endObject(),!this.ignoringObject&&this.clipLevels.length>0&&this.clipLevels[this.clipLevels.length-1]===t&&(this.ctx.restore(),this.clipLevels.pop()),null!==this.ignoreObjectsAboveLevel&&this.getNestingLevel()<=this.ignoreObjectsAboveLevel&&(this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1)}drawPoints(...t){for(let e=0;e<t.length;e++){const n=this.canvasToScreen(t[e]);this.ctx.beginPath(),this.ctx.arc(n.x,n.y,10,0,2*Math.PI),this.ctx.fillStyle=r.default.ofRGBA(.5+Math.sin(e)/2,1,.5+Math.cos(.2*e)/4,.5).toHexString(),this.ctx.fill(),this.ctx.stroke(),this.ctx.closePath(),this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillStyle="black",this.ctx.fillText(`${e}`,n.x,n.y,20)}}isTooSmallToRender(t){const e=this.getCanvasToScreenTransform().transformVec3(t.size),n=this.minRenderSizeBothDimens,i=Math.abs(e.x)<n&&Math.abs(e.y)<n,r=this.minRenderSizeAnyDimen,o=Math.abs(e.x)<r||Math.abs(e.y)<r;return i||o}}e.default=c},1782:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6750),o=i(n(8157));class s extends o.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?r.Vec2.of(640,480):t}clear(){if(this.clearedCount++,this.renderedPathCount=0,this.pointBuffer=[],this.lastText=null,this.lastImage=null,this.objectNestingLevel>0)throw new Error(`Within an object while clearing! Nesting level: ${this.objectNestingLevel}`)}beginPath(t){this.lastPoint=t,this.pointBuffer.push(t)}endPath(t){this.renderedPathCount++,this.lastFillStyle=t}lineTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}moveTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n),this.lastPoint=n,this.pointBuffer.push(t,e,n)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(t,e)}drawPoints(...t){}drawText(t,e,n){this.lastText=t}drawImage(t){this.lastImage=t}startObject(t,e){super.startObject(t),this.objectNestingLevel+=1}endObject(){super.endObject(),this.objectNestingLevel-=1}isTooSmallToRender(t){return!1}canRenderFromWithoutDataLoss(t){return t instanceof s}renderFromOtherOfSameType(t,e){if(!(e instanceof s))throw new Error(`${e} cannot be rendered onto ${this}`);this.renderedPathCount+=e.renderedPathCount,this.lastFillStyle=e.lastFillStyle,this.lastPoint=e.lastPoint,this.pointBuffer.push(...e.pointBuffer.map((e=>t.transformVec2(e))))}}e.default=s},9563:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.renderedStylesheetId=void 0;const r=i(n(2054)),o=i(n(9765)),s=n(1520),a=n(6750),l=n(8684),c=n(9604),d=i(n(8157));e.renderedStylesheetId="js-draw-style-sheet";const u="http://www.w3.org/2000/svg";class h extends d.default{constructor(t,e,n=!1){super(e),this.elem=t,this.sanitize=n,this.lastPathStyle=null,this.lastPathString=[],this.objectElems=null,this.overwrittenAttrs={},this.textContainer=null,this.textContainerTransform=null,this.textParentStyle=null,this.clear(),this.addStyleSheet()}addStyleSheet(){if(!this.elem.querySelector(`#${e.renderedStylesheetId}`)){const t=document.createElementNS("http://www.w3.org/2000/svg","style");t.innerHTML="\n\t\t\t\tpath {\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t}\n\n\t\t\t\ttext {\n\t\t\t\t\twhite-space: pre;\n\t\t\t\t}\n\t\t\t".replace(/\s+/g,""),t.setAttribute("id",e.renderedStylesheetId),this.elem.appendChild(t)}}setRootSVGAttribute(t,e){this.sanitize||(t in this.overwrittenAttrs||(this.overwrittenAttrs[t]=this.elem.getAttribute(t)),null!==e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t))}displaySize(){return a.Vec2.of(this.elem.clientWidth,this.elem.clientHeight)}clear(){if(this.lastPathString=[],!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(){var t;if(!this.lastPathStyle||0===this.lastPathString.length)return;const e=document.createElementNS(u,"path");e.setAttribute("d",this.lastPathString.join(" "));const n=this.lastPathStyle;n.fill.a>0?e.setAttribute("fill",n.fill.toHexString()):e.setAttribute("fill","none"),n.stroke&&(e.setAttribute("stroke",n.stroke.color.toHexString()),e.setAttribute("stroke-width",(0,s.toRoundedString)(n.stroke.width))),this.elem.appendChild(e),null===(t=this.objectElems)||void 0===t||t.push(e)}drawPath(t){const e=t.style,n=o.default.fromRenderable(t).transformedBy(this.getCanvasToScreenTransform());0!==this.lastPathString.length&&this.lastPathStyle&&(0,c.stylesEqual)(this.lastPathStyle,e)||(this.addPathToSVG(),this.lastPathStyle=e,this.lastPathString=[]),this.lastPathString.push(n.toString())}transformFrom(t,e,n=!1,i=!0){let o=n?t:this.getCanvasToScreenTransform().rightMul(t);const l=o.transformVec2(a.Vec2.zero);i&&(o=o.rightMul(r.default.translation(l.times(-1)))),o.eq(r.default.identity)?e.style.transform="":e.style.transform=`matrix(\n\t\t\t\t${o.a1}, ${o.b1},\n\t\t\t\t${o.a2}, ${o.b2},\n\t\t\t\t${o.a3}, ${o.b3}\n\t\t\t)`,i&&(e.setAttribute("x",`${(0,s.toRoundedString)(l.x)}`),e.setAttribute("y",`${(0,s.toRoundedString)(l.y)}`))}drawText(t,e,n){var i;const r=(t,e)=>{var n,i,r,o,s,a;e.fontFamily!==(null===(n=this.textParentStyle)||void 0===n?void 0:n.fontFamily)&&(t.style.fontFamily=e.fontFamily),e.fontVariant!==(null===(i=this.textParentStyle)||void 0===i?void 0:i.fontVariant)&&(t.style.fontVariant=null!==(r=e.fontVariant)&&void 0!==r?r:""),e.fontWeight!==(null===(o=this.textParentStyle)||void 0===o?void 0:o.fontWeight)&&(t.style.fontWeight=null!==(s=e.fontWeight)&&void 0!==s?s:""),e.size!==(null===(a=this.textParentStyle)||void 0===a?void 0:a.size)&&(t.style.fontSize=e.size+"px");const l=e.renderingStyle.fill.toHexString();if(t.style.fill=l,e.renderingStyle.stroke){const n=e.renderingStyle.stroke;t.style.stroke=n.color.toHexString(),t.style.strokeWidth=n.width+"px"}};if(e=this.getCanvasToScreenTransform().rightMul(e),this.textContainer){const i=document.createElementNS(u,"tspan");i.appendChild(document.createTextNode(t)),this.textContainer.appendChild(i);const o=(e=this.textContainerTransform.inverse().rightMul(e)).transformVec2(a.Vec2.zero);i.setAttribute("x",`${(0,s.toRoundedString)(o.x)}`),i.setAttribute("y",`${(0,s.toRoundedString)(o.y)}`),r(i,n)}else{const o=document.createElementNS(u,"text");o.appendChild(document.createTextNode(t));const s=!1;this.transformFrom(e,o,!0,s),r(o,n),this.elem.appendChild(o),null===(i=this.objectElems)||void 0===i||i.push(o),this.objectLevel>0&&(this.textContainer=o,this.textContainerTransform=e,this.textParentStyle=n)}}drawImage(t){var e,n,i,r,o,s;let a=null!==(n=null!==(e=t.label)&&void 0!==e?e:t.image.getAttribute("aria-label"))&&void 0!==n?n:"";""===a&&(a=null!==(i=t.image.getAttribute("alt"))&&void 0!==i?i:"");const l=document.createElementNS(u,"image");l.setAttribute("href",t.base64Url),l.setAttribute("width",null!==(r=t.image.getAttribute("width"))&&void 0!==r?r:""),l.setAttribute("height",null!==(o=t.image.getAttribute("height"))&&void 0!==o?o:""),l.setAttribute("aria-label",a),this.transformFrom(t.transform,l),this.elem.appendChild(l),null===(s=this.objectElems)||void 0===s||s.push(l)}startObject(t){super.startObject(t),this.lastPathString=[],this.lastPathStyle=null,this.textContainer=null,this.textParentStyle=null,this.objectElems=[]}endObject(t,e){var n;if(super.endObject(t),this.addPathToSVG(),t&&!this.sanitize)for(const e of null!==(n=this.objectElems)&&void 0!==n?n:[]){const n=t[l.svgAttributesDataKey],i=t[l.svgStyleAttributesDataKey];if(n)for(const[t,i]of n)e.setAttribute(t,i);if(i)for(const t of i)e.style.setProperty(t.key,t.value,t.priority)}if(e&&this.objectElems)if(1===this.objectElems.length)this.objectElems[0].classList.add(...e);else{const t=document.createElementNS(u,"g");t.classList.add(...e);for(const e of this.objectElems)e.remove(),t.appendChild(e);this.elem.appendChild(t)}}unimplementedMessage(){throw new Error("Not implemenented!")}beginPath(t){this.unimplementedMessage()}endPath(t){this.unimplementedMessage()}lineTo(t){this.unimplementedMessage()}moveTo(t){this.unimplementedMessage()}traceCubicBezierCurve(t,e,n){this.unimplementedMessage()}traceQuadraticBezierCurve(t,e){this.unimplementedMessage()}drawPoints(...t){t.map((t=>{const e=document.createElementNS(u,"circle");e.setAttribute("cx",`${t.x}`),e.setAttribute("cy",`${t.y}`),e.setAttribute("r","15"),this.elem.appendChild(e)}))}drawSVGElem(t){this.sanitize||"style"===t.tagName.toLowerCase()&&t.getAttribute("id")===e.renderedStylesheetId||this.elem.appendChild(t.cloneNode(!0))}isTooSmallToRender(t){return!1}static fromViewport(t,e=!0){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg"),r=t.getScreenRectSize();return i.setAttribute("viewBox",[0,0,r.x,r.y].map((t=>(0,s.toRoundedString)(t))).join(" ")),i.setAttribute("width",(0,s.toRoundedString)(r.x)),i.setAttribute("height",(0,s.toRoundedString)(r.y)),i.setAttribute("version","1.1"),i.setAttribute("baseProfile","full"),i.setAttribute("xmlns",n),{element:i,renderer:new h(i,t,e)}}}e.default=h},2634:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6750),o=i(n(8157));class s extends o.default{constructor(t,e){super(t),this.localizationTable=e,this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}displaySize(){return r.Vec2.of(500,500)}clear(){this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0}getDescription(){return[this.localizationTable.pathNodeCount(this.pathCount),...this.textNodeCount>0?[this.localizationTable.textNodeCount(this.textNodeCount)]:[],...this.imageNodeCount>0?[this.localizationTable.imageNodeCount(this.imageNodeCount)]:[],...this.descriptionBuilder].join("\n")}beginPath(t){}endPath(t){this.pathCount++}lineTo(t){}moveTo(t){}traceCubicBezierCurve(t,e,n){}traceQuadraticBezierCurve(t,e){}drawText(t,e,n){this.descriptionBuilder.push(this.localizationTable.textNode(t)),this.textNodeCount++}drawImage(t){const e=t.label?this.localizationTable.imageNode(t.label):this.localizationTable.unlabeledImageNode;this.descriptionBuilder.push(e),this.imageNodeCount++}isTooSmallToRender(t){return t.maxDimension<15/this.getSizeOfCanvasPixelOnScreen()}drawPoints(...t){}}e.default=s},2862:function(t,e,n){"use strict";var i=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 r=n(6485);Object.defineProperty(e,"sendPenEvent",{enumerable:!0,get:function(){return i(r).default}});var o=n(7236);Object.defineProperty(e,"sendTouchEvent",{enumerable:!0,get:function(){return i(o).default}})},6485:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(306)),o=n(9699);e.default=(t,e,n,i)=>{const s=r.default.ofCanvasPoint(n,e!==o.InputEvtType.PointerUpEvt,t.viewport);t.toolController.dispatchInputEvent({kind:e,allPointers:null!=i?i:[s],current:s})}},7236:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});const s=o(n(306)),a=n(9699);e.default=(t,e,n,i)=>{const r=t.viewport.screenToCanvas(n);let o=0,l=0;for(const t of null!=i?i:[])l=Math.max(t.id,l),t.id===o&&(o=l+1);const c=s.default.ofCanvasPoint(r,e!==a.InputEvtType.PointerUpEvt,t.viewport,o,s.PointerDevice.Touch);return t.toolController.dispatchInputEvent({kind:e,allPointers:[...null!=i?i:[],c],current:c}),c}},7389:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.toolbarCSSPrefix=void 0;const r=n(9699),o=n(7629),s=i(n(8233)),a=n(3940),l=i(n(1626)),c=i(n(135)),d=i(n(2100)),u=i(n(9270)),h=i(n(7052)),p=i(n(3770)),f=i(n(2297)),m=i(n(6282)),g=i(n(6937)),v=i(n(5627)),y=i(n(5710)),b=i(n(2085)),x=i(n(234)),w=i(n(1278));e.toolbarCSSPrefix="toolbar-";class T{constructor(t,n,i=a.defaultToolbarLocalization){this.editor=t,this.localizationTable=i,this.listeners=[],this.widgetOrderCounter=0,this.widgetsById={},this.widgetList=[],this.overflowWidget=null,this.updateColoris=null,this.reLayoutQueued=!1,this.container=document.createElement("div"),this.container.classList.add(`${e.toolbarCSSPrefix}root`),this.container.setAttribute("role","toolbar"),n.appendChild(this.container),T.colorisStarted||((0,o.init)(),T.colorisStarted=!0),this.setupColorPickers(),"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver((t=>{this.reLayout()})),this.resizeObserver.observe(this.container)):console.warn("ResizeObserver not supported. Toolbar will not resize.")}setupColorPickers(){if(this.updateColoris)return void this.updateColoris();const t=document.createElement("div");t.className=`${e.toolbarCSSPrefix}closeColorPickerOverlay`,this.editor.createHTMLOverlay(t),this.listeners.push(this.editor.handlePointerEventsFrom(t,(t=>("pointerdown"===t&&(0,o.close)(),!0))));const n=[s.default.red.toHexString(),s.default.purple.toHexString(),s.default.blue.toHexString(),s.default.clay.toHexString(),s.default.black.toHexString(),s.default.white.toHexString()],i=n.length,a=()=>{(0,o.coloris)({el:".coloris_input",format:"hex",selectInput:!1,focusInput:!1,themeMode:"auto",swatches:n})};a(),this.updateColoris=a;this.listeners.push(this.editor.notifier.on(r.EditorEventType.ColorPickerToggled,(e=>{e.kind===r.EditorEventType.ColorPickerToggled&&(t.style.display=e.open?"block":"none")}))),this.listeners.push(this.editor.notifier.on(r.EditorEventType.ColorPickerColorSelected,(t=>{t.kind===r.EditorEventType.ColorPickerColorSelected&&(t=>{let e=!1;for(const i of n)i===t&&(e=!0);e||(n.push(t),n.length>12&&n.splice(i,1),a())})(t.color.toHexString())})))}queueReLayout(){this.reLayoutQueued||(this.reLayoutQueued=!0,requestAnimationFrame((()=>this.reLayout())))}reLayout(){if(this.reLayoutQueued=!1,!this.overflowWidget)return;const t=t=>{let e=0;for(const n of t)n.isHidden()||(e+=n.getButtonWidth());return e};let e=t(this.overflowWidget.getChildWidgets()),n=t(this.widgetList)-e,i=.87*this.container.clientWidth;window.innerHeight>1.75*i&&(i*=1.75);let r=!1;if((t=>{var e,n;const i=null!==(n=null===(e=this.overflowWidget)||void 0===e?void 0:e.getChildWidgets())&&void 0!==n?n:[];return 0!==i.length&&i[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());e=0,r=!0}if(n>=i){for(let t=this.widgetList.length-1;t>=0&&n>=i;t--){const e=this.widgetList[t];this.overflowWidget.hasAsChild(e)||e.canBeInOverflowMenu()&&(n-=e.getButtonWidth(),this.overflowWidget.addToOverflow(e))}r=!0}this.overflowWidget.setHidden(0===this.overflowWidget.getChildWidgets().length),r&&this.setupColorPickers()}addWidget(t){const e=t.getUniqueIdIn(this.widgetsById);this.widgetsById[e]=t,this.widgetList.push(t);const n=t.addTo(this.container);this.setupColorPickers(),n.style.order=""+this.widgetOrderCounter++,this.queueReLayout()}addSpacer(t={}){const n=document.createElement("div");n.classList.add(`${e.toolbarCSSPrefix}spacer`),t.grow&&(n.style.flexGrow=`${t.grow}`),t.minSize&&(n.style.minWidth=t.minSize),t.maxSize&&(n.style.maxWidth=t.maxSize),n.style.order=""+this.widgetOrderCounter++,this.container.appendChild(n)}serializeState(){const t={};for(const e in this.widgetsById)t[e]=this.widgetsById[e].serializeState();return JSON.stringify(t)}deserializeState(t){const e=JSON.parse(t);for(const t in e)t in this.widgetsById||console.warn(`Unable to deserialize widget ${t} — no such widget.`),this.widgetsById[t].deserializeFrom(e[t])}addActionButton(t,e,n=!0){const i="string"==typeof t?t:t.label,r=new y.default(this.editor,"action-button",(()=>"string"==typeof t?null:t.icon),i,e,this.editor.localization,n);return this.addWidget(r),r}addUndoRedoButtons(){const t=this.addActionButton({label:this.localizationTable.undo,icon:this.editor.icons.makeUndoIcon()},(()=>{this.editor.history.undo()})),e=this.addActionButton({label:this.localizationTable.redo,icon:this.editor.icons.makeRedoIcon()},(()=>{this.editor.history.redo()}));t.setDisabled(!0),e.setDisabled(!0),this.editor.notifier.on(r.EditorEventType.UndoRedoStackUpdated,(n=>{if(n.kind!==r.EditorEventType.UndoRedoStackUpdated)throw new Error("Wrong event type!");t.setDisabled(0===n.undoStackSize),e.setDisabled(0===n.redoStackSize)}))}addDefaultToolWidgets(){const t=this.editor.toolController;for(const e of t.getMatchingTools(h.default)){const t=new p.default(this.editor,e,this.localizationTable);this.addWidget(t)}for(const e of t.getMatchingTools(u.default))this.addWidget(new f.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(l.default))this.addWidget(new m.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(d.default))this.addWidget(new g.default(this.editor,e,this.localizationTable));const e=t.getMatchingTools(c.default)[0];e&&this.addWidget(new v.default(this.editor,e,this.localizationTable)),this.addWidget(new b.default(this.editor,this.localizationTable))}addDefaultActionButtons(){this.addWidget(new x.default(this.editor,this.localizationTable)),this.addUndoRedoButtons()}addOverflowWidget(){this.overflowWidget=new w.default(this.editor,this.localizationTable),this.addWidget(this.overflowWidget)}addDefaults(){this.addDefaultToolWidgets(),this.addOverflowWidget(),this.addDefaultActionButtons()}remove(){this.container.remove(),this.resizeObserver.disconnect();for(const t of this.listeners)t.remove()}}e.default=T,T.colorisStarted=!1},5818:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=n(6750),s=i(n(9563)),a=i(n(8831)),l="http://www.w3.org/2000/svg",c="\n\tstyle='fill: var(--icon-color);'\n",d="\n\t<pattern\n\t\tid='checkerboard'\n\t\tviewBox='0,0,10,10'\n\t\twidth='20%'\n\t\theight='20%'\n\t\tpatternUnits='userSpaceOnUse'\n\t>\n\t\t<rect x=0 y=0 width=10 height=10 fill='white'/>\n\t\t<rect x=0 y=0 width=5 height=5 fill='gray'/>\n\t\t<rect x=5 y=5 width=5 height=5 fill='gray'/>\n\t</pattern>\n",u="url(#checkerboard)";e.default=class{makeUndoIcon(){return this.makeRedoIcon(!0)}makeRedoIcon(t=!1){const e=document.createElementNS(l,"svg");return e.innerHTML=`\n\t\t\t<style>\n\t\t\t\t.toolbar-svg-undo-redo-icon {\n\t\t\t\t\tstroke: var(--icon-color);\n\t\t\t\t\tstroke-width: 12;\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\n\t\t\t\t\ttransform-origin: center;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<path\n\t\t\t\td='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'\n\t\t\t\tclass='toolbar-svg-undo-redo-icon'\n\t\t\t\tstyle='${t?"transform: scale(-1, 1);":""}'/>\n\t\t`,e.setAttribute("viewBox","0 0 100 100"),e}makeDropdownIcon(){const t=document.createElementNS(l,"svg");return t.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\td='M5,10 L50,90 L95,10 Z'\n\t\t\t\t${c}\n\t\t\t/>\n\t\t</g>\n\t\t`,t.setAttribute("viewBox","0 0 100 100"),t}makeEraserIcon(t){const e=document.createElementNS(l,"svg");null!=t||(t=10);const n=t/4;return e.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\tstyle="fill:#ff70af"\n\t\t\t\tstroke="black"\n\t\t\t\ttransform="rotate(41.35)"\n\t\t\t\td="M 52.5 27\n\t\t\t\t\tC 50 28.9 48.9 31.7 48.9 34.8\n\t\t\t\t\tL 48.9 39.8\n\t\t\t\t\tC 48.9 45.3 53.4 49.8 58.9 49.8\n\t\t\t\t\tL 103.9 49.8\n\t\t\t\t\tC 105.8 49.8 107.6 49.2 109.1 48.3\n\t\t\t\t\tL 110.2 ${n+49.5} L 159.7 ${n+5}\n\t\t\t\t\tL 157.7 ${5.2-n} L 112.4 ${49.5-n}\n\t\t\t\t\tC 113.4 43.5 113.9 41.7 113.9 39.8\n\t\t\t\t\tL 113.9 34.8\n\t\t\t\t\tC 113.9 29.3 109.4 24.8 103.9 24.8\n\t\t\t\t\tL 58.9 24.8\n\t\t\t\t\tC 56.5 24.8 54.3 25.7 52.5 27\n\t\t\t\t\tz "\n\t\t\t\tid="path438" />\n\n\t\t\t<rect\n\t\t\t\tstroke="#cc8077"\n\t\t\t\t${c}\n\t\t\t\tid="rect218"\n\t\t\t\twidth="65"\n\t\t\t\theight="75"\n\t\t\t\tx="48.9"\n\t\t\t\ty="-38.7"\n\t\t\t\ttransform="rotate(41.35)" />\n\t\t</g>\n\t\t`,e.setAttribute("viewBox","0 0 120 120"),e}makeSelectionIcon(){const t=document.createElementNS(l,"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}makeIconFromPath(t,e="var(--icon-color)",n="none",i="0px"){const r=document.createElementNS(l,"svg"),o=document.createElementNS(l,"path");return o.setAttribute("d",t),o.style.fill=e,o.style.stroke=n,o.style.strokeWidth=i,r.appendChild(o),r.setAttribute("viewBox","0 0 100 100"),r}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(l,"svg");t.setAttribute("viewBox","0 0 100 100");const e=(e,n,i)=>{const r=document.createElementNS(l,"text");r.appendChild(document.createTextNode(e)),r.setAttribute("x",n.toString()),r.setAttribute("y",i.toString()),r.style.textAlign="center",r.style.textAnchor="middle",r.style.fontSize="55px",r.style.fill="var(--icon-color)",r.style.fontFamily="monospace",t.appendChild(r)};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")}makeTextIcon(t){var e,n;const i=document.createElementNS(l,"svg");i.setAttribute("viewBox","0 0 100 100");const r=document.createElementNS(l,"text");return r.appendChild(document.createTextNode("T")),r.style.fontFamily=t.fontFamily,r.style.fontWeight=null!==(e=t.fontWeight)&&void 0!==e?e:"",r.style.fontVariant=null!==(n=t.fontVariant)&&void 0!==n?n:"",r.style.fill=t.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(--primary-shadow-color))",i.appendChild(r),i}makePenIcon(t,e,n){e instanceof r.default&&(e=e.toHexString());const i=document.createElementNS(l,"svg");i.setAttribute("viewBox","0 0 100 100");const o=t/2,s=`\n\t\t\tM ${15-o},${80-o}\n\t\t\t ${15-o},${80+o}\n\t\t\t 30,83\n\t\t\t 15,65\n\t\t\tZ\n\t\t`,a=80+o,c=`\n\t\t\tm ${15-1.1*o},${a}\n\t\t\tc 35,10 55,15 60,30\n\t\t\tl ${35+1.2*o},${-10-o}\n\t\t\tC 80.47,98.32 50.5,${90+o} 20,${a} Z\n\t\t`,h="\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 p="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",f="M 25,35 H 35 L 90,-15 85,-25 Z",m="M 60,75 65,65 H 55 l 55,-55 10,5 z";n&&(p="M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z",f="m 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z",m="M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z");const g=`M 25,35 ${10-o/4},${70-o/2} 20,75 25,85 60,75 70,55 45,25 Z`,v=r.default.fromHex("#f4d7d7").mix(r.default.fromString(e),o/40-.1).toHexString(),y=`\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${e}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${e}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t`,b=`\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${v}"\n\t\t\t\tstroke="${e}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t`,x=`\n\t\t\t<path\n\t\t\t\t\n\tstyle='fill: var(--icon-color); stroke: var(--icon-color);'\n\n\t\t\t\td="${p}"\n\t\t\t/>\n\n\t\t\t\x3c!-- shadows --\x3e\n\t\t\t<path\n\t\t\t\tfill="rgba(150, 150, 150, 0.3)"\n\t\t\t\td="${f}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="rgba(100, 100, 100, 0.2)"\n\t\t\t\td="${m}"\n\t\t\t/>\n\n\t\t\t\x3c!-- color bubble --\x3e\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${h}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${e}"\n\t\t\t\td="${h}"\n\t\t\t/>\n\t\t`;return i.innerHTML=`\n\t\t<defs>\n\t\t\t${d}\n\t\t</defs>\n\t\t<g>\n\t\t\t${y}\n\t\t\t${b}\n\t\t\t${x}\n\t\t</g>\n\t\t`,i}makeIconFromFactory(t,e){const n=3*Math.sqrt(t.getThickness()),i=(new Date).getTime(),r={pos:o.Vec2.of(10,10),width:n,color:t.getColor(),time:i-100},c={pos:o.Vec2.of(90,90),width:n,color:t.getColor(),time:i},d=new a.default((()=>{})),u=e(r,d);u.addPoint(c);const h=document.createElementNS(l,"svg");h.setAttribute("viewBox","0 0 100 100"),d.updateScreenSize(o.Vec2.of(100,100));const p=new s.default(h,d);return u.preview(p),h}makePipetteIcon(t){const e=document.createElementNS(l,"svg"),n=document.createElementNS(l,"path");if(n.setAttribute("d","\n\t\t\tM 47,6\n\t\t\tC 35,5 25,15 35,30\n\t\t\tc -9.2,1.3 -15,0 -15,3\n\t\t\t\t0,2 5,5 15,7\n\t\t\tV 81\n\t\t\tL 40,90\n\t\t\th 6\n\t\t\tL 40,80\n\t\t\tV 40\n\t\t\th 15\n\t\t\tv 40\n\t\t\tl -6,10\n\t\t\th 6\n\t\t\tl 5,-9.2\n\t\t\tV 40\n\t\t\tC 70,38 75,35 75,33\n\t\t\t\t75,30 69.2,31.2 60,30\n\t\t\t\t65,15 65,5 47,6\n\t\t\tZ\n\t\t"),n.style.fill="var(--icon-color)",t){const n=document.createElementNS(l,"defs");n.innerHTML=d,e.appendChild(n);const i=document.createElementNS(l,"path"),r=document.createElementNS(l,"path"),o="\n\t\t\t\tm 40,50 c 5,5 10,0 15,-5 V 80 L 50,90 H 45 L 40,80 Z\n\t\t\t";r.setAttribute("d",o),i.setAttribute("d",o),r.style.fill=t.toHexString(),i.style.fill=u,e.appendChild(i),e.appendChild(r)}return e.appendChild(n),e.setAttribute("viewBox","0 0 100 100"),e}makeFormatSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 5 10\n\t\t\tL 5 20 L 10 20 L 10 15 L 20 15 L 20 40 L 15 40 L 15 45 L 35 45 L 35 40 L 30 40 L 30 15 L 40 15 L 40 20 L 45 20 L 45 15 L 45 10 L 5 10 z\n\t\t\tM 90 10 C 90 10 86.5 13.8 86 14 C 86 14 76.2 24.8 76 25 L 60 25 L 60 65 C 75 70 85 70 90 65 L 90 25 L 80 25 L 76.7 25 L 90 10 z\n\t\t\tM 60 25 L 55 25 L 50 30 L 60 25 z\n\t\t\tM 10 55 L 10 90 L 41 90 L 41 86 L 45 86 L 45 55 L 10 55 z\n\t\t\tM 42 87 L 42 93 L 48 93 L 48 87 L 42 87 z \n\t\t")}makeResizeViewportIcon(){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")}makeDuplicateSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 45,10 45,55 90,55 90,10 45,10 z\n\t\t\tM 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z \n\t\t")}makePasteIcon(){const t=this.makeIconFromPath("\n\t\t\tM 50 0 L 50 5 L 35 5 L 40 24.75 L 20 25 L 20 100 L 85 100 L 100 90 L 100 24 L 75.1 24.3 L 80 5 L 65 5 L 65 0 L 50 0 z\n\t\t\tM 10 15 L 10 115 L 110 115 L 110 15 L 85 15 L 83 20 L 105 20 L 105 110 L 15 110 L 15 20 L 32 20 L 30 15 L 10 15 z\n\t\t\tM 25 35 L 90 35 L 90 40 L 25 40 L 25 35 z\n\t\t\tM 25 45 L 90 45 L 90 50 L 25 50 L 25 45 z\n\t\t\tM 25 55 L 85 55 L 85 60 L 25 60 L 25 55 z\n\t\t\tM 25 65 L 90 65 L 90 70 L 25 70 L 25 65 z \n\t\t");return t.setAttribute("viewBox","0 0 120 120"),t}makeDeleteSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 10,10 90,90\n\t\t\tM 10,90 90,10\n\t\t","none","var(--icon-color)","5px")}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: 10;\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")}}},4087:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.IconProvider=void 0,r(n(7788),e),r(n(5768),e);var s=n(5818);Object.defineProperty(e,"IconProvider",{enumerable:!0,get:function(){return o(s).default}})},3940:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarLocalization=void 0,e.defaultToolbarLocalization={pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text: ",chooseFile:"Choose file: ",submit:"Submit",cancel:"Cancel",resetView:"Reset view",thicknessLabel:"Thickness: ",colorLabel:"Color: ",fontLabel:"Font: ",textSize:"Size: ",resizeImageToSelection:"Resize image to selection",deleteSelection:"Delete selection",duplicateSelection:"Duplicate selection",undo:"Undo",redo:"Redo",selectPenType:"Pen type: ",pickColorFromScreen:"Pick color from screen",clickToPickColorAnnouncement:"Click on the screen to pick a color",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: ",toggleOverflow:"More",touchPanning:"Touchscreen panning",freehandPen:"Freehand",pressureSensitiveFreehandPen:"Freehand (pressure sensitive)",arrowPen:"Arrow",linePen:"Line",outlinedRectanglePen:"Outlined rectangle",filledRectanglePen:"Filled rectangle",lockRotation:"Lock rotation",paste:"Paste",dropdownShown:t=>`Dropdown for ${t} shown`,dropdownHidden:t=>`Dropdown for ${t} hidden`,zoomLevel:t=>`Zoom: ${t}%`,colorChangedAnnouncement:t=>`Color changed to ${t}`,imageSize:(t,e)=>`Image size: ${t} ${e}`,errorImageHasZeroSize:"Error: Image has zero size",imageLoadError:t=>`Error loading image: ${t}`}},5768:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeColorInput=void 0;const r=i(n(8233)),o=i(n(5529)),s=n(9699);e.makeColorInput=(t,e)=>{const n=document.createElement("span"),i=document.createElement("input");i.type="button",i.classList.add("coloris_input"),n.classList.add("color-input-container"),n.appendChild(i);const o=a(t,n,(t=>{i.value=t.toHexString(),d();const e=i.parentElement;e&&e.classList.contains("clr-field")&&(e.style.color=i.value)}));let l;const c=()=>{l=r.default.fromHex(i.value)},d=()=>{c(),l&&(t.announceForAccessibility(t.localization.colorChangedAnnouncement(l.toHexString())),e(l),t.notifier.dispatch(s.EditorEventType.ColorPickerColorSelected,{kind:s.EditorEventType.ColorPickerColorSelected,color:l}))};i.oninput=c,i.addEventListener("open",(()=>{t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!0}),o.cancel()})),i.addEventListener("close",(()=>{t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!1}),d()}));return[i,n,t=>{"object"==typeof t&&(t=t.toHexString()),i.value=t,i.dispatchEvent(new Event("input",{bubbles:!0}))}]};const a=(t,e,n)=>{const i=document.createElement("button");i.classList.add("pipetteButton"),i.title=t.localization.pickColorFromScreen,i.setAttribute("alt",i.title);const r=e=>{i.replaceChildren(t.icons.makePipetteIcon(e))};r();const s=t.toolController.getMatchingTools(o.default)[0],a=()=>{null==s||s.clearColorListener(),r(),i.classList.remove("active")},l=t=>{a(),t&&n(t)},c=t=>{t?r(t):r()};return i.onclick=()=>{i.classList.contains("active")?a():(null==s||s.setColorListener(c,l),s&&(i.classList.add("active"),t.announceForAccessibility(t.localization.clickToPickColorAnnouncement)))},e.appendChild(i),{cancel:()=>{a()}}};e.default=e.makeColorInput},5710:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(1455));class o extends r.default{constructor(t,e,n,i,r,o,s=!1){super(t,e,o),this.makeIcon=n,this.title=i,this.clickAction=r,this.mustBeToplevel=s}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}canBeInOverflowMenu(){return!this.mustBeToplevel}}e.default=o},6763:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9699),o=i(n(1455));class s extends o.default{constructor(t,e,n,i){super(t,n,i),this.editor=t,this.targetTool=e,t.notifier.on(r.EditorEventType.ToolEnabled,(t=>{if(t.kind!==r.EditorEventType.ToolEnabled)throw new Error("Incorrect event type! (Expected ToolEnabled)");t.tool===e&&this.setSelected(!0)})),t.notifier.on(r.EditorEventType.ToolDisabled,(t=>{if(t.kind!==r.EditorEventType.ToolDisabled)throw new Error("Incorrect event type! (Expected ToolDisabled)");t.tool===e&&(this.setSelected(!1),this.setDropdownVisible(!1))}))}handleClick(){this.hasDropdown?this.targetTool.isEnabled()?this.setDropdownVisible(!this.isDropdownVisible()):this.targetTool.setEnabled(!0):this.targetTool.setEnabled(!this.targetTool.isEnabled())}addTo(t){const e=super.addTo(t);return this.setSelected(this.targetTool.isEnabled()),e}}e.default=s},1455:function(t,e,n){"use strict";var i,r=this&&this.__classPrivateFieldSet||function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},o=this&&this.__classPrivateFieldGet||function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(2375)),l=n(9699),c=n(7389);class d{constructor(t,e,n){this.editor=t,this.id=e,i.set(this,void 0),this.disabled=!1,this.subWidgets={},this.toplevel=!0,this.toolbarWidgetToggleListener=null,this.localizationTable=null!=n?n:t.localization,this.icon=null,this.container=document.createElement("div"),this.container.classList.add(`${c.toolbarCSSPrefix}toolContainer`),this.dropdownContainer=document.createElement("div"),this.dropdownContainer.classList.add(`${c.toolbarCSSPrefix}dropdown`),this.dropdownContainer.classList.add("hidden"),r(this,i,!1,"f"),this.button=document.createElement("div"),this.button.classList.add(`${c.toolbarCSSPrefix}button`),this.label=document.createElement("label"),this.button.setAttribute("role","button"),this.button.tabIndex=0;const o=this.editor.toolController.getMatchingTools(a.default);o.length>0&&this.onKeyPress!==d.prototype.onKeyPress&&o[0].registerListener((t=>this.onKeyPress(t)))}getId(){return this.id}getUniqueIdIn(t){let e=this.getId(),n=0;for(;e in t&&t[e]!==this;)e=this.getId()+"-"+n.toString(),n++;return e}fillDropdown(t){if(0===Object.keys(this.subWidgets).length)return!1;for(const e in this.subWidgets){const n=this.subWidgets[e];n.addTo(t),n.setIsToplevel(!1)}return!0}setupActionBtnClickListener(t){const e={Enter:!0," ":!0};t.onkeydown=t=>{let n=!1;t.key in e&&(this.disabled||(this.handleClick(),n=!0)),n||(n=this.editor.toolController.dispatchInputEvent({kind:l.InputEvtType.KeyPressEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})),n&&t.preventDefault()},t.onkeyup=t=>{if(t.key in e)return;this.editor.toolController.dispatchInputEvent({kind:l.InputEvtType.KeyUpEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})&&t.preventDefault()},t.onclick=()=>{this.disabled||this.handleClick()}}onKeyPress(t){return!1}get hasDropdown(){return o(this,i,"f")}addSubWidget(t){const e=t.getUniqueIdIn(this.subWidgets);this.subWidgets[e]=t}addTo(t){return this.label.innerText=this.getTitle(),this.setupActionBtnClickListener(this.button),this.icon=null,this.updateIcon(),this.container.replaceChildren(),this.button.replaceChildren(this.icon,this.label),this.container.appendChild(this.button),r(this,i,this.fillDropdown(this.dropdownContainer),"f"),o(this,i,"f")&&(this.dropdownIcon=this.createDropdownIcon(),this.button.appendChild(this.dropdownIcon),this.container.appendChild(this.dropdownContainer),this.toolbarWidgetToggleListener&&this.toolbarWidgetToggleListener.remove(),this.toolbarWidgetToggleListener=this.editor.notifier.on(l.EditorEventType.ToolbarDropdownShown,(t=>{t.kind===l.EditorEventType.ToolbarDropdownShown&&t.parentWidget!==this&&t.parentWidget.toplevel&&this.setDropdownVisible(!1)}))),this.setDropdownVisible(!1),this.container.parentElement&&this.container.remove(),t.appendChild(this.container),this.container}updateIcon(){var t,e;const n=this.createIcon();n?(null===(t=this.icon)||void 0===t||t.replaceWith(n),this.icon=n,this.icon.classList.add(`${c.toolbarCSSPrefix}icon`)):null===(e=this.icon)||void 0===e||e.remove()}setDisabled(t){this.disabled=t,this.disabled?(this.button.classList.add("disabled"),this.button.setAttribute("aria-disabled","true")):(this.button.classList.remove("disabled"),this.button.removeAttribute("aria-disabled"))}setSelected(t){this.isSelected()!==t&&(t?(this.container.classList.add("selected"),this.button.ariaSelected="true"):(this.container.classList.remove("selected"),this.button.ariaSelected="false"))}setDropdownVisible(t){this.container.classList.contains("dropdownVisible")!==t&&(t?(this.dropdownContainer.classList.remove("hidden"),this.container.classList.add("dropdownVisible"),this.editor.announceForAccessibility(this.localizationTable.dropdownShown(this.getTitle())),this.editor.notifier.dispatch(l.EditorEventType.ToolbarDropdownShown,{kind:l.EditorEventType.ToolbarDropdownShown,parentWidget:this})):(this.dropdownContainer.classList.add("hidden"),this.container.classList.remove("dropdownVisible"),this.editor.announceForAccessibility(this.localizationTable.dropdownHidden(this.getTitle()))),this.repositionDropdown())}canBeInOverflowMenu(){return!0}getButtonWidth(){return this.button.clientWidth}isHidden(){return"none"===this.container.style.display}setHidden(t){this.container.style.display=t?"none":""}repositionDropdown(){const t=this.dropdownContainer.getBoundingClientRect(),e=document.body.clientWidth;t.left>e/2?(this.dropdownContainer.style.marginLeft=this.button.clientWidth+"px",this.dropdownContainer.style.transform="translate(-100%, 0)"):(this.dropdownContainer.style.marginLeft="",this.dropdownContainer.style.transform="")}setIsToplevel(t){this.toplevel=t}isDropdownVisible(){return!this.dropdownContainer.classList.contains("hidden")}isSelected(){return this.container.classList.contains("selected")}createDropdownIcon(){const t=this.editor.icons.makeDropdownIcon();return t.classList.add(`${c.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])}}e.default=d,i=new WeakMap},234:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(529)),l=s(n(3966)),c=o(n(7520)),d=n(4721),u=s(n(5085)),h=n(9699),p=n(7389),f=s(n(5768)),m=s(n(1455));class g extends m.default{constructor(t,e){super(t,"document-properties-widget",e),this.updateDropdownContent=()=>{},this.dropdownUpdateQueued=!1,this.container.classList.add("dropdownShowable"),this.editor.notifier.on(h.EditorEventType.UndoRedoStackUpdated,(()=>{this.queueDropdownUpdate()})),this.editor.image.notifier.on(d.EditorImageEventType.ExportViewportChanged,(()=>{this.queueDropdownUpdate()}))}getTitle(){return this.localizationTable.documentProperties}createIcon(){return this.editor.icons.makeConfigureDocumentIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible()),this.queueDropdownUpdate()}queueDropdownUpdate(){this.dropdownUpdateQueued||(requestAnimationFrame((()=>this.updateDropdown())),this.dropdownUpdateQueued=!0)}updateDropdown(){this.dropdownUpdateQueued=!1,this.isDropdownVisible()&&this.updateDropdownContent()}setBackgroundColor(t){this.editor.dispatch(this.editor.setBackgroundColor(t))}getBackgroundColor(){return this.editor.estimateBackgroundColor()}removeBackgroundComponents(){const t=[];for(const e of this.editor.image.getBackgroundComponents())e instanceof c.default&&t.push(e);return new a.default(t)}setBackgroundType(t){const e=this.editor.estimateBackgroundColor(),n=new c.default(t,e),i=this.editor.image.addElement(n);return(0,l.default)([this.removeBackgroundComponents(),i])}getBackgroundType(){const t=this.editor.image.getBackgroundComponents();for(let e=t.length-1;e>=0;e--){const n=t[e];if(n instanceof c.default)return n.getBackgroundType()}return c.BackgroundType.None}updateImportExportRectSize(t){const e=t=>(void 0!==t&&(!isFinite(t)||t<=0)&&(t=100),t),n=e(t.width),i=e(t.height),r=this.editor.getImportExportRect(),o=new u.default(r.x,r.y,null!=n?n:r.w,null!=i?i:r.h);this.editor.dispatch(this.editor.image.setImportExportRect(o)),this.editor.queueRerender()}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("label");i.innerText=this.localizationTable.backgroundColor;const[r,o,s]=(0,f.default)(this.editor,(t=>{t.eq(this.getBackgroundColor())||this.setBackgroundColor(t)}));r.id=`${p.toolbarCSSPrefix}docPropertiesColorInput-${g.idCounter++}`,i.htmlFor=r.id,n.replaceChildren(i,o);const a=document.createElement("div"),l=document.createElement("label"),d=document.createElement("input");d.id=`${p.toolbarCSSPrefix}docPropertiesUseGridCheckbox-${g.idCounter++}`,l.htmlFor=d.id,d.type="checkbox",l.innerText=this.localizationTable.useGridOption,d.oninput=()=>{if(this.getBackgroundType()===c.BackgroundType.Grid===d.checked)return;let t=c.BackgroundType.SolidColor;d.checked&&(t=c.BackgroundType.Grid),this.editor.dispatch(this.setBackgroundType(t))},a.replaceChildren(l,d);const u=(t,e)=>{const n=document.createElement("div"),i=document.createElement("label"),r=document.createElement("span"),o=document.createElement("input");return i.innerText=t,o.type="number",o.min="0",o.id=`${p.toolbarCSSPrefix}docPropertiesDimensionRow-${g.idCounter++}`,i.htmlFor=o.id,r.style.flexGrow="1",o.style.flexGrow="2",o.style.width="25px",n.style.display="flex",o.oninput=()=>{e(parseFloat(o.value))},n.replaceChildren(i,r,o),{setValue:t=>{o.value=t.toString()},element:n}},h=u(this.localizationTable.imageWidthOption,(t=>{this.updateImportExportRectSize({width:t})})),m=u(this.localizationTable.imageHeightOption,(t=>{this.updateImportExportRectSize({height:t})}));return this.updateDropdownContent=()=>{s(this.getBackgroundColor());const t=this.editor.getImportExportRect();h.setValue(t.width),m.setValue(t.height),d.checked=this.getBackgroundType()===c.BackgroundType.Grid},this.updateDropdownContent(),e.replaceChildren(n,a,h.element,m.element),t.replaceChildren(e),!0}}e.default=g,g.idCounter=0},2297:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9699),o=n(7389),s=i(n(6763));class a extends s.default{constructor(t,e,n){super(t,e,"eraser-tool-widget",n),this.tool=e,this.thicknessInput=null,this.editor.notifier.on(r.EditorEventType.ToolUpdated,(t=>{t.kind===r.EditorEventType.ToolUpdated&&t.tool===this.tool&&(this.updateInputs(),this.updateIcon())}))}getTitle(){return this.localizationTable.eraser}createIcon(){return this.editor.icons.makeEraserIcon(this.tool.getThickness())}updateInputs(){this.thicknessInput&&(this.thicknessInput.value=`${this.tool.getThickness()}`)}fillDropdown(t){const e=document.createElement("label");return this.thicknessInput=document.createElement("input"),this.thicknessInput.type="range",this.thicknessInput.min="4",this.thicknessInput.max="40",this.thicknessInput.oninput=()=>{this.tool.setThickness(parseFloat(this.thicknessInput.value))},this.thicknessInput.id=`${o.toolbarCSSPrefix}eraserThicknessInput${a.nextThicknessInputId++}`,e.innerText=this.localizationTable.thicknessLabel,e.htmlFor=this.thicknessInput.id,this.updateInputs(),t.replaceChildren(e,this.thicknessInput),!0}serializeState(){return Object.assign(Object.assign({},super.serializeState()),{thickness:this.tool.getThickness()})}deserializeFrom(t){if(super.deserializeFrom(t),t.thickness){const e=parseFloat(t.thickness);if("number"!=typeof e||!isFinite(e))throw new Error(`Deserializing property ${e} is not a number or is not finite.`);this.tool.setThickness(e)}}}e.default=a,a.nextThicknessInputId=0},5627:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(2054)),l=o(n(135)),c=n(9699),d=s(n(8831)),u=n(7389),h=s(n(6763)),p=s(n(1455));class f extends p.default{constructor(t,e){super(t,"zoom-widget",e),this.container.classList.add("dropdownShowable")}getTitle(){return this.localizationTable.zoom}createIcon(){return this.editor.icons.makeZoomIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){return t.replaceChildren(((t,e)=>{const n=document.createElement("div"),i=document.createElement("button"),r=document.createElement("button"),o=document.createElement("button"),s=document.createElement("span");let l;i.innerText="+",r.innerText="-",o.innerText=t.resetView,n.replaceChildren(s,i,r,o),n.classList.add(`${u.toolbarCSSPrefix}zoomLevelEditor`),s.classList.add("zoomDisplay");const h=()=>{let n=100*e.viewport.getScaleFactor();n=n>.1?Math.round(10*n)/10:Math.round(1e3*n)/1e3,n!==l&&(s.innerText=t.zoomLevel(n),l=n)};h(),e.notifier.on(c.EditorEventType.ViewportChanged,(t=>{t.kind===c.EditorEventType.ViewportChanged&&(h(),o.disabled=t.newTransform.eq(a.default.identity))}));const p=t=>{const n=e.viewport.visibleRect.center,i=a.default.scaling2D(t,n);e.dispatch(d.default.transformBy(i),!1)};return i.onclick=()=>{p(5/4)},r.onclick=()=>{p(.8)},o.onclick=()=>{e.dispatch(d.default.transformBy(e.viewport.canvasToScreenTransform.inverse()),!0)},n})(this.localizationTable,this.editor)),!0}}class m extends p.default{constructor(t,e,n,i,r,o){super(t,`pan-mode-${n}`,o),this.tool=e,this.flag=n,this.makeIcon=i,this.title=r,t.notifier.on(c.EditorEventType.ToolUpdated,(t=>{if(t.kind===c.EditorEventType.ToolUpdated&&t.tool===e){const t=!!(e.getMode()&l.PanZoomMode.SinglePointerGestures);this.setSelected(!!(e.getMode()&n)||t),this.setDisabled(t&&n!==l.PanZoomMode.SinglePointerGestures)}})),this.setSelected(!1)}setModeFlag(t){this.tool.setModeEnabled(this.flag,t)}handleClick(){this.setModeFlag(!this.isSelected())}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}}class g extends h.default{constructor(t,e,n){const i=g.getPrimaryHandTool(t.toolController);super(t,null!=i?i:e,"hand-tool-widget",n),this.overridePanZoomTool=e,this.allowTogglingBaseTool=null!==i,this.allowTogglingBaseTool||this.container.classList.add("dropdownShowable");const r=new m(t,e,l.PanZoomMode.OneFingerTouchGestures,(()=>this.editor.icons.makeTouchPanningIcon()),n.touchPanning,n),o=new m(t,e,l.PanZoomMode.RotationLocked,(()=>this.editor.icons.makeRotationLockIcon()),n.lockRotation,n);this.addSubWidget(r),this.addSubWidget(o),this.addSubWidget(new f(t,n))}static getPrimaryHandTool(t){return t.getPrimaryTools().filter((t=>t instanceof l.default))[0]}getTitle(){return this.localizationTable.handTool}createIcon(){return this.editor.icons.makeHandToolIcon()}handleClick(){this.allowTogglingBaseTool?super.handleClick():this.setDropdownVisible(!this.isDropdownVisible())}setSelected(t){this.allowTogglingBaseTool&&super.setSelected(t)}serializeState(){const t=this.overridePanZoomTool.getMode();return Object.assign(Object.assign({},super.serializeState()),{touchPanning:t&l.PanZoomMode.OneFingerTouchGestures,rotationLocked:t&l.PanZoomMode.RotationLocked})}deserializeFrom(t){void 0!==t.touchPanning&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.OneFingerTouchGestures,t.touchPanning),void 0!==t.rotationLocked&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.RotationLocked,t.rotationLocked),super.deserializeFrom(t)}}e.default=g},2085:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(5249)),s=r(n(529)),a=r(n(4721)),l=r(n(3966)),c=r(n(1626)),d=r(n(2054)),u=r(n(9161)),h=r(n(5710));class p extends h.default{constructor(t,e){null!=e||(e=t.localization),super(t,"insert-image-widget",(()=>t.icons.makeInsertImageIcon()),e.image,(()=>this.onClicked())),this.imageSelectionOverlay=document.createElement("div"),this.imageSelectionOverlay.classList.add("toolbar-image-selection-overlay"),this.fillOverlay(),this.editor.createHTMLOverlay(this.imageSelectionOverlay),this.imageSelectionOverlay.style.display="none"}fillOverlay(){const t=document.createElement("div"),e=document.createElement("div"),n=document.createElement("div");this.imagePreview=document.createElement("img"),this.statusView=document.createElement("div");const r=document.createElement("div");r.classList.add("action-button-row"),this.submitButton=document.createElement("button");const o=document.createElement("button");this.imageFileInput=document.createElement("input"),this.imageAltTextInput=document.createElement("input");const s=document.createElement("label"),a=document.createElement("label"),l="insert-image-file-input-"+p.nextInputId++,c="insert-image-alt-text-input-"+p.nextInputId++;this.imageFileInput.setAttribute("id",l),this.imageAltTextInput.setAttribute("id",c),a.htmlFor=c,s.htmlFor=l,this.imageFileInput.accept="image/*",a.innerText=this.localizationTable.inputAltText,s.innerText=this.localizationTable.chooseFile,this.imageFileInput.type="file",this.imageAltTextInput.type="text",this.statusView.setAttribute("aria-live","polite"),o.innerText=this.localizationTable.cancel,this.submitButton.innerText=this.localizationTable.submit,this.imageFileInput.onchange=()=>i(this,void 0,void 0,(function*(){if(""===this.imageFileInput.value||!this.imageFileInput.files||!this.imageFileInput.files[0])return this.imagePreview.style.display="none",void(this.submitButton.disabled=!0);this.imagePreview.style.display="block";const t=this.imageFileInput.files[0];let e=null;try{e=yield(0,u.default)(t)}catch(t){this.statusView.innerText=this.localizationTable.imageLoadError(t)}this.imageBase64URL=e,e?(this.imagePreview.src=e,this.submitButton.disabled=!1,this.updateImageSizeDisplay()):(this.submitButton.disabled=!0,this.statusView.innerText="")})),o.onclick=()=>{this.hideDialog()},this.imageSelectionOverlay.onclick=t=>{t.target===this.imageSelectionOverlay&&this.hideDialog()},e.replaceChildren(s,this.imageFileInput),n.replaceChildren(a,this.imageAltTextInput),r.replaceChildren(o,this.submitButton),t.replaceChildren(e,n,this.imagePreview,this.statusView,r),this.imageSelectionOverlay.replaceChildren(t)}hideDialog(){this.imageSelectionOverlay.style.display="none"}updateImageSizeDisplay(){var t;const e=(null!==(t=this.imageBase64URL)&&void 0!==t?t:"").length/1024,n=e/1024;let i="KiB",r=e;n>=1&&(r=n,i="MiB"),this.statusView.innerText=this.localizationTable.imageSize(Math.round(r),i)}clearInputs(){this.imageFileInput.value="",this.imageAltTextInput.value="",this.imagePreview.style.display="none",this.submitButton.disabled=!0,this.statusView.innerText=""}onClicked(){var t;this.imageSelectionOverlay.style.display="",this.clearInputs(),this.imageFileInput.focus();const e=this.editor.toolController.getMatchingTools(c.default),n=e.map((t=>t.getSelectedObjects())).flat();let r=null;1===n.length&&n[0]instanceof o.default?(r=n[0],this.imageAltTextInput.value=null!==(t=r.getAltText())&&void 0!==t?t:"",this.imagePreview.style.display="block",this.submitButton.disabled=!1,this.imageBase64URL=r.getURL(),this.imagePreview.src=this.imageBase64URL,this.updateImageSizeDisplay()):e.forEach((t=>t.clearSelection())),this.submitButton.onclick=()=>i(this,void 0,void 0,(function*(){var t;if(!this.imageBase64URL)return;const n=new Image;n.src=this.imageBase64URL,n.setAttribute("alt",this.imageAltTextInput.value);const i=yield o.default.fromImage(n,d.default.identity);if(0!==i.getBBox().area)if(this.imageSelectionOverlay.style.display="none",r){const n=new s.default([r]);yield this.editor.dispatch((0,l.default)([a.default.addElement(i),i.transformBy(r.getTransformation()),i.setZIndex(r.getZIndex()),n])),null===(t=e[0])||void 0===t||t.setSelection([i])}else yield this.editor.addAndCenterComponents([i]);else this.statusView.innerText=this.localizationTable.errorImageHasZeroSize}))}}e.default=p,p.nextInputId=0},1278:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(1455));class o extends r.default{constructor(t,e){var n;super(t,"overflow-widget",e),this.overflowChildren=[],this.container.classList.add("toolbar-overflow-widget"),this.container.classList.add("dropdownShowable"),null!==(n=this.overflowContainer)&&void 0!==n||(this.overflowContainer=document.createElement("div"))}getTitle(){return this.localizationTable.toggleOverflow}createIcon(){return this.editor.icons.makeOverflowIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){var e;return null!==(e=this.overflowContainer)&&void 0!==e||(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=o},3770:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6645),o=n(1173),s=n(4856),a=n(5607),l=n(7124),c=n(9699),d=n(7389),u=i(n(5768)),h=i(n(6763)),p=i(n(8233));class f extends h.default{constructor(t,e,n){super(t,e,"pen",n),this.tool=e,this.updateInputs=()=>{},this.penTypes=[{name:this.localizationTable.pressureSensitiveFreehandPen,id:"pressure-sensitive-pen",factory:s.makePressureSensitiveFreehandLineBuilder},{name:this.localizationTable.freehandPen,id:"freehand-pen",factory:o.makeFreehandLineBuilder},{name:this.localizationTable.arrowPen,id:"arrow",factory:r.makeArrowBuilder},{name:this.localizationTable.linePen,id:"line",factory:a.makeLineBuilder},{name:this.localizationTable.filledRectanglePen,id:"filled-rectangle",factory:l.makeFilledRectangleBuilder},{name:this.localizationTable.outlinedRectanglePen,id:"outlined-rectangle",factory:l.makeOutlinedRectangleBuilder}],this.editor.notifier.on(c.EditorEventType.ToolUpdated,(t=>{if(t.kind!==c.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}createIcon(){const t=this.tool.getStrokeFactory();if(t===o.makeFreehandLineBuilder||t===s.makePressureSensitiveFreehandLineBuilder){const e=Math.round(4*Math.sqrt(this.tool.getThickness())),n=this.tool.getColor(),i=t===o.makeFreehandLineBuilder;return this.editor.icons.makePenIcon(e,n.toHexString(),i)}{const t=this.tool.getStrokeFactory();return this.editor.icons.makeIconFromFactory(this.tool,t)}}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${d.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("div"),r=document.createElement("label"),o=document.createElement("input"),s=document.createElement("label"),a=document.createElement("select");o.id=`${d.toolbarCSSPrefix}penThicknessInput${f.idCounter++}`,a.id=`${d.toolbarCSSPrefix}penBuilderSelect${f.idCounter++}`,r.innerText=this.localizationTable.thicknessLabel,r.setAttribute("for",o.id),s.innerText=this.localizationTable.selectPenType,s.setAttribute("for",a.id);const l=t=>Math.log10(t);o.type="range",o.min=`${l(2)}`,o.max=`${l(400)}`,o.step="0.1",o.oninput=()=>{this.tool.setThickness((t=>Math.pow(10,t))(parseFloat(o.value)))},n.appendChild(r),n.appendChild(o),a.oninput=()=>{const t=parseInt(a.value);t<0||t>=this.penTypes.length?console.error("Invalid pen type index",t):this.tool.setStrokeFactory(this.penTypes[t].factory)},i.appendChild(s),i.appendChild(a);const c=document.createElement("div"),h=document.createElement("label"),[p,m,g]=(0,u.default)(this.editor,(t=>{this.tool.setColor(t)}));return p.id=`${d.toolbarCSSPrefix}colorInput${f.idCounter++}`,h.innerText=this.localizationTable.colorLabel,h.setAttribute("for",p.id),c.appendChild(h),c.appendChild(m),this.updateInputs=()=>{g(this.tool.getColor()),o.value=l(this.tool.getThickness()).toString(),a.replaceChildren();for(let t=0;t<this.penTypes.length;t++){const e=this.penTypes[t],n=document.createElement("option");n.value=t.toString(),n.innerText=e.name,a.appendChild(n)}const t=this.getCurrentPenTypeIdx();a.value=-1===t?"":t.toString()},this.updateInputs(),e.replaceChildren(c,n,i),t.replaceChildren(e),!0}onKeyPress(t){if(!this.isSelected())return!1;if(/^[0-9]$/.exec(t.key)&&t.ctrlKey){const e=parseInt(t.key)-1;if(e>=0&&e<this.penTypes.length)return this.tool.setStrokeFactory(this.penTypes[e].factory),!0}return!1}serializeState(){var t;return Object.assign(Object.assign({},super.serializeState()),{color:this.tool.getColor().toHexString(),thickness:this.tool.getThickness(),strokeFactoryId:null===(t=this.getCurrentPenType())||void 0===t?void 0:t.id})}deserializeFrom(t){super.deserializeFrom(t);const e=(e,n)=>{const i=typeof t[e];if(i!==n)throw new Error(`Deserializing property ${e}: Invalid type. Expected ${n}, was ${i}.`)};if(t.color&&(e("color","string"),this.tool.setColor(p.default.fromHex(t.color))),t.thickness&&(e("thickness","number"),this.tool.setThickness(t.thickness)),t.strokeFactoryId){e("strokeFactoryId","string");const n=t.strokeFactoryId;for(const t of this.penTypes)if(n===t.id){this.tool.setStrokeFactory(t.factory);break}}}}e.default=f,f.idCounter=0},6282:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(8233)),s=n(8258),a=r(n(3966)),l=n(9699),c=r(n(5768)),d=r(n(5710)),u=r(n(6763)),h=r(n(1455));class p extends h.default{constructor(t,e,n){super(t,"restyle-selection",n),this.selectionTool=e,this.updateFormatData=()=>{},this.container.classList.add("dropdownShowable"),this.editor.notifier.on(l.EditorEventType.ToolUpdated,(t=>{if(t.kind!==l.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");t.tool===this.selectionTool&&this.updateFormatData()}))}getTitle(){return this.localizationTable.reformatSelection}createIcon(){return this.editor.icons.makeFormatSelectionIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){const e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("label"),[r,l,d]=(0,c.default)(this.editor,(t=>{const e=this.selectionTool.getSelection();if(e){const n=[];for(const i of e.getSelectedObjects())(0,s.isRestylableComponent)(i)&&n.push(i.updateStyle({color:t}));const i=(0,a.default)(n);this.editor.dispatch(i)}}));return i.innerText=this.localizationTable.colorLabel,this.updateFormatData=()=>{const t=this.selectionTool.getSelection();if(t){r.disabled=!1;const e=[];for(const n of t.getSelectedObjects())if((0,s.isRestylableComponent)(n)){const t=n.getStyle().color;t&&e.push(t)}d(o.default.average(e))}else r.disabled=!0},n.replaceChildren(i,l),e.replaceChildren(n),t.replaceChildren(e),!0}}class f extends u.default{constructor(t,e,n){super(t,e,"selection-tool-widget",n),this.tool=e;const r=new d.default(t,"resize-btn",(()=>t.icons.makeResizeViewportIcon()),this.localizationTable.resizeImageToSelection,(()=>{this.resizeImageToSelection()}),n),o=new d.default(t,"delete-btn",(()=>t.icons.makeDeleteSelectionIcon()),this.localizationTable.deleteSelection,(()=>{const t=this.tool.getSelection();this.editor.dispatch(t.deleteSelectedObjects()),this.tool.clearSelection()}),n),s=new d.default(t,"duplicate-btn",(()=>t.icons.makeDuplicateSelectionIcon()),this.localizationTable.duplicateSelection,(()=>i(this,void 0,void 0,(function*(){const t=this.tool.getSelection();this.editor.dispatch(yield t.duplicateSelectedObjects())}))),n),a=new p(t,this.tool,n);this.addSubWidget(r),this.addSubWidget(o),this.addSubWidget(s),this.addSubWidget(a);const c=t=>{r.setDisabled(t),o.setDisabled(t),s.setDisabled(t),a.setDisabled(t)};c(!0),this.editor.notifier.on(l.EditorEventType.ToolUpdated,(t=>{if(t.kind!==l.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");if(t.tool===this.tool){const t=this.tool.getSelection(),e=t&&t.getSelectedItemCount()>0;c(!e)}}))}resizeImageToSelection(){const t=this.tool.getSelection();t&&this.editor.dispatch(this.editor.setImportExportRect(t.region))}onKeyPress(t){return!(!t.ctrlKey||"r"!==t.key)&&(this.resizeImageToSelection(),!0)}getTitle(){return this.localizationTable.select}createIcon(){return this.editor.icons.makeSelectionIcon()}}e.default=f},6937:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=n(9699),s=n(7389),a=i(n(5768)),l=i(n(6763));class c extends l.default{constructor(t,e,n){super(t,e,"text-tool-widget",n),this.tool=e,this.updateDropdownInputs=null,t.notifier.on(o.EditorEventType.ToolUpdated,(t=>{var n;t.kind===o.EditorEventType.ToolUpdated&&t.tool===e&&(this.updateIcon(),null===(n=this.updateDropdownInputs)||void 0===n||n.call(this))}))}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`);const n=document.createElement("div"),i=document.createElement("div"),r=document.createElement("div"),o=document.createElement("select"),l=document.createElement("label"),d=document.createElement("input"),u=document.createElement("label"),[h,p,f]=(0,a.default)(this.editor,(t=>{this.tool.setColor(t)})),m=document.createElement("label"),g=new Set,v=t=>{const e=document.createElement("option");e.value=t,e.textContent=t,o.appendChild(e),g.add(t)};return d.setAttribute("type","number"),d.min="1",d.max="128",l.innerText=this.localizationTable.fontLabel,m.innerText=this.localizationTable.colorLabel,u.innerText=this.localizationTable.textSize,h.id=`${s.toolbarCSSPrefix}-text-color-input-${c.idCounter++}`,m.setAttribute("for",h.id),d.id=`${s.toolbarCSSPrefix}-text-size-input-${c.idCounter++}`,u.setAttribute("for",d.id),v("monospace"),v("serif"),v("sans-serif"),o.id=`${s.toolbarCSSPrefix}-text-font-input-${c.idCounter++}`,l.setAttribute("for",o.id),o.onchange=()=>{this.tool.setFontFamily(o.value)},d.onchange=()=>{const t=parseInt(d.value);!isNaN(t)&&t>0&&this.tool.setFontSize(t)},i.appendChild(m),i.appendChild(p),n.appendChild(l),n.appendChild(o),r.appendChild(u),r.appendChild(d),this.updateDropdownInputs=()=>{const t=this.tool.getTextStyle();f(t.renderingStyle.fill),g.has(t.fontFamily)||v(t.fontFamily),o.value=t.fontFamily,d.value=`${t.size}`},this.updateDropdownInputs(),e.replaceChildren(i,r,n),t.appendChild(e),!0}serializeState(){const t=this.tool.getTextStyle();return Object.assign(Object.assign({},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(r.default.fromHex(t.color)),t.textSize&&"number"==typeof t.textSize&&this.tool.setFontSize(t.textSize),super.deserializeFrom(t)}}e.default=c,c.idCounter=0},7788:function(t,e,n){"use strict";var i=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.BaseWidget=e.BaseToolWidget=e.ActionButtonWidget=void 0;var r=n(5710);Object.defineProperty(e,"ActionButtonWidget",{enumerable:!0,get:function(){return i(r).default}});var o=n(6763);Object.defineProperty(e,"BaseToolWidget",{enumerable:!0,get:function(){return i(o).default}});var s=n(1455);Object.defineProperty(e,"BaseWidget",{enumerable:!0,get:function(){return i(s).default}});var a=n(3770);Object.defineProperty(e,"PenToolWidget",{enumerable:!0,get:function(){return i(a).default}});var l=n(6937);Object.defineProperty(e,"TextToolWidget",{enumerable:!0,get:function(){return i(l).default}});var c=n(5627);Object.defineProperty(e,"HandToolWidget",{enumerable:!0,get:function(){return i(c).default}});var d=n(6282);Object.defineProperty(e,"SelectionToolWidget",{enumerable:!0,get:function(){return i(d).default}});var u=n(2297);Object.defineProperty(e,"EraserToolWidget",{enumerable:!0,get:function(){return i(u).default}});var h=n(2085);Object.defineProperty(e,"InsertImageWidget",{enumerable:!0,get:function(){return i(h).default}});var p=n(234);Object.defineProperty(e,"DocumentPropertiesWidget",{enumerable:!0,get:function(){return i(p).default}})},2131:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9699);e.default=class{onPointerDown(t){return!1}onPointerMove(t){}onPointerUp(t){}onGestureCancel(){}constructor(t,e){this.notifier=t,this.description=e,this.enabled=!0,this.group=null}onWheel(t){return!1}onCopy(t){return!1}onPaste(t){return!1}onKeyPress(t){return!1}onKeyUp(t){return!1}setEnabled(t){var e;this.enabled=t,t?(null===(e=this.group)||void 0===e||e.notifyEnabled(this),this.notifier.dispatch(i.EditorEventType.ToolEnabled,{kind:i.EditorEventType.ToolEnabled,tool:this})):this.notifier.dispatch(i.EditorEventType.ToolDisabled,{kind:i.EditorEventType.ToolDisabled,tool:this})}isEnabled(){return this.enabled}setToolGroup(t){this.isEnabled()&&t.notifyEnabled(this),this.group=t}getToolGroup(){return this.group?this.group:null}}},9270:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9699),o=i(n(2131)),s=n(6750),a=i(n(9784)),l=i(n(529)),c=n(306),d=i(n(8233)),u=i(n(5085));class h extends o.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastPoint=null,this.isFirstEraseEvt=!0,this.thickness=10,this.partialCommands=[]}clearPreview(){this.editor.clearWetInk()}getSizeOnCanvas(){return this.thickness/this.editor.viewport.getScaleFactor()}drawPreviewAt(t){this.clearPreview();const e=this.getSizeOnCanvas(),n=this.editor.display.getWetInkRenderer(),i=this.getEraserRect(t),r={fill:d.default.gray};n.drawRect(i,e/4,r)}getEraserRect(t){const e=this.getSizeOnCanvas(),n=s.Vec2.of(e/2,e/2);return u.default.fromCorners(t.minus(n),t.plus(n))}eraseTo(t){if(!this.isFirstEraseEvt&&0===t.minus(this.lastPoint).magnitude())return;this.isFirstEraseEvt=!1;const e=this.getEraserRect(t),n=new a.default(this.lastPoint,t),i=u.default.union(n.bbox,e),r=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t.intersects(n)||t.intersectsRect(e))).filter((t=>t.isSelectable()));this.toRemove.push(...r);const o=r.map((t=>new l.default([t])));o.forEach((t=>t.apply(this.editor))),this.partialCommands.push(...o),this.drawPreviewAt(t),this.lastPoint=t}onPointerDown(t){return(1===t.allPointers.length||t.current.device===c.PointerDevice.Eraser)&&(this.lastPoint=t.current.canvasPos,this.toRemove=[],this.isFirstEraseEvt=!0,this.drawPreviewAt(t.current.canvasPos),!0)}onPointerMove(t){const e=t.current.canvasPos;this.eraseTo(e)}onPointerUp(t){if(this.eraseTo(t.current.canvasPos),this.toRemove.length>0){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[];const t=new l.default(this.toRemove);this.editor.dispatch(t)}this.clearPreview()}onGestureCancel(){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[],this.clearPreview()}getThickness(){return this.thickness}setThickness(t){this.thickness=t,this.editor.notifier.dispatch(r.EditorEventType.ToolUpdated,{kind:r.EditorEventType.ToolUpdated,tool:this})}}e.default=h},3252:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.cssPrefix=void 0;const r=i(n(6205)),o=i(n(2131));e.cssPrefix="find-tool";class s extends o.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(`${e.cssPrefix}-overlay`)}getMatches(t){t=t.toLocaleLowerCase();return this.editor.image.getAllElements().filter((t=>t instanceof r.default)).filter((e=>-1!==e.getText().toLocaleLowerCase().indexOf(t))).map((t=>t.getBBox()))}focusCurrentMatch(){const t=this.getMatches(this.searchInput.value);let e=this.currentMatchIdx%t.length;if(e<0&&(e=t.length+e),e<t.length){const n=!1;this.editor.dispatch(this.editor.viewport.zoomTo(t[e],!0,!0),n),this.editor.announceForAccessibility(this.editor.localization.focusedFoundText(e+1,t.length))}}toNextMatch(){this.currentMatchIdx++,this.focusCurrentMatch()}toPrevMatch(){this.currentMatchIdx--,this.focusCurrentMatch()}fillOverlay(){const t=document.createElement("label");this.searchInput=document.createElement("input");const n=document.createElement("button"),i=document.createElement("button");this.searchInput.setAttribute("id",`${e.cssPrefix}-searchInput-${Math.random()}`),t.htmlFor=this.searchInput.getAttribute("id"),t.innerText=this.editor.localization.findLabel,n.innerText=this.editor.localization.toNextMatch,i.innerText=this.editor.localization.closeFindDialog,this.searchInput.onkeydown=t=>{"Enter"===t.key?t.shiftKey?this.toPrevMatch():this.toNextMatch():"Escape"===t.key?this.setVisible(!1):"f"===t.key&&t.ctrlKey&&(t.preventDefault(),this.toggleVisible())},n.onclick=()=>{this.toNextMatch()},i.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(t,this.searchInput,n,i)}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!(!t.ctrlKey||"f"!==t.key)&&(this.toggleVisible(),!0)}setEnabled(t){super.setEnabled(t),t&&this.setVisible(!1)}}e.default=s},135:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanZoomMode=void 0;const o=r(n(2054)),s=n(6750),a=r(n(3785)),l=n(306),c=n(9699),d=r(n(2822)),u=n(8831),h=r(n(2131));var p;!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"}(p=e.PanZoomMode||(e.PanZoomMode={}));class f{constructor(t,e,n){this.initialVelocity=t,this.scrollBy=e,this.onComplete=n,this.running=!1,this.start()}start(){return i(this,void 0,void 0,(function*(){if(this.running)return;this.currentVelocity=this.initialVelocity;let t=(new Date).getTime();this.running=!0;for(this.currentVelocity.magnitude()>5e3&&(this.currentVelocity=this.currentVelocity.normalized().times(5e3));this.running&&this.currentVelocity.magnitude()>200;){const e=(new Date).getTime(),n=(e-t)/1e3;this.currentVelocity=this.currentVelocity.times(Math.pow(1/8,n)),this.scrollBy(this.currentVelocity.times(n)),yield(0,d.default)(),t=e}this.running&&this.stop()}))}getCurrentVelocity(){return this.running?this.currentVelocity:null}stop(){this.running&&(this.running=!1,this.onComplete())}}class m extends h.default{constructor(t,e,n){super(t.notifier,n),this.editor=t,this.mode=e,this.transform=null,this.lastPointerDownTimestamp=0,this.initialTouchAngle=0,this.initialViewportRotation=0,this.inertialScroller=null,this.velocity=null}computePinchData(t,e){if(t.id<e.id){const n=t;t=e,e=n}const n=e.screenPos.minus(t.screenPos),i=n.angle(),r=n.magnitude();return{canvasCenter:e.canvasPos.plus(t.canvasPos).times(.5),screenCenter:e.screenPos.plus(t.screenPos).times(.5),angle:i,dist:r}}allPointersAreOfType(t,e){return t.every((t=>t.device===e))}onPointerDown({allPointers:t,current:e}){var n,i,r,a;let c=!1;const d=null!==(i=null===(n=this.inertialScroller)||void 0===n?void 0:n.getCurrentVelocity())&&void 0!==i?i:s.Vec2.zero;null===(r=this.inertialScroller)||void 0===r||r.stop(),this.velocity=d,this.lastPointerDownTimestamp=e.timeStamp;const h=this.allPointersAreOfType(t,l.PointerDevice.Touch),f=this.allPointersAreOfType(t,l.PointerDevice.RightButtonMouse);if(h&&2===t.length&&this.mode&p.TwoFingerTouchGestures){const{screenCenter:e,angle:n,dist:i}=this.computePinchData(t[0],t[1]);this.lastDist=i,this.lastScreenCenter=e,this.initialTouchAngle=n,this.initialViewportRotation=this.editor.viewport.getRotationAngle(),c=!0}else 1===t.length&&(this.mode&p.OneFingerTouchGestures&&h||f&&this.mode&p.RightClickDrags||this.mode&p.SinglePointerGestures)&&(this.lastScreenCenter=t[0].screenPos,c=!0);return c&&(this.lastTimestamp=(new Date).getTime(),null!==(a=this.transform)&&void 0!==a||(this.transform=u.Viewport.transformBy(o.default.identity)),this.editor.display.setDraftMode(!0)),c}updateVelocity(t){const e=t.minus(this.lastScreenCenter);let n=((new Date).getTime()-this.lastTimestamp)/1e3;if(0===e.magnitude()&&n<.1)return;if(0===n)return;n=Math.max(n,.01);const i=e.times(1/n);let r=i;this.velocity&&(r=this.velocity.lerp(i,.5)),this.velocity=r}getCenterDelta(t){return this.editor.viewport.screenToCanvasTransform.transformVec3(t.minus(this.lastScreenCenter))}toSnappedRotationDelta(t){let e=t-this.initialTouchAngle+this.initialViewportRotation;const n=Math.PI/2,i=Math.round(e/n)*n;return Math.abs(e-i)<.07&&(e=i,0!==e&&(e+=1e-4)),e-this.editor.viewport.getRotationAngle()}handleTwoFingerMove(t){const{screenCenter:e,canvasCenter:n,angle:i,dist:r}=this.computePinchData(t[0],t[1]),s=this.getCenterDelta(e);let a;a=this.isRotationLocked()?0:this.toSnappedRotationDelta(i),this.updateVelocity(e);const l=o.default.translation(s).rightMul(o.default.scaling2D(r/this.lastDist,n)).rightMul(o.default.zRotation(a,n));this.lastScreenCenter=e,this.lastDist=r,this.transform=u.Viewport.transformBy(this.transform.transform.rightMul(l))}handleOneFingerMove(t){const e=this.getCenterDelta(t.screenPos);this.transform=u.Viewport.transformBy(this.transform.transform.rightMul(o.default.translation(e))),this.updateVelocity(t.screenPos),this.lastScreenCenter=t.screenPos}onPointerMove({allPointers:t}){var e;null!==(e=this.transform)&&void 0!==e||(this.transform=u.Viewport.transformBy(o.default.identity));const n=this.transform;2===t.length?this.handleTwoFingerMove(t):1===t.length&&this.handleOneFingerMove(t[0]),n.unapply(this.editor),this.transform.apply(this.editor),this.lastTimestamp=(new Date).getTime()}onPointerUp(t){var e;const n=()=>{this.transform&&(this.transform.unapply(this.editor),this.editor.dispatch(this.transform,!1)),this.editor.display.setDraftMode(!1),this.transform=null,this.velocity=s.Vec2.zero};if(t.current.device===l.PointerDevice.Touch&&1===t.allPointers.length&&null!==this.velocity&&t.current.timeStamp-this.lastPointerDownTimestamp>30&&null!==this.velocity){const i=this.velocity;this.updateVelocity(t.current.screenPos),i.magnitude()<this.velocity.magnitude()&&(this.velocity=i),null===(e=this.inertialScroller)||void 0===e||e.stop(),this.inertialScroller=new f(this.velocity,(t=>{if(!this.transform)return;const e=this.editor.viewport.screenToCanvasTransform.transformVec3(t);this.transform.unapply(this.editor),this.transform=u.Viewport.transformBy(this.transform.transform.rightMul(o.default.translation(e))),this.transform.apply(this.editor)}),n)}else n()}onGestureCancel(){var t,e;null===(t=this.inertialScroller)||void 0===t||t.stop(),this.velocity=s.Vec2.zero,null===(e=this.transform)||void 0===e||e.unapply(this.editor),this.editor.display.setDraftMode(!1),this.transform=null}updateTransform(t,e=!1){var n;let i=t;this.transform&&(i=this.transform.transform.rightMul(t)),null===(n=this.transform)||void 0===n||n.unapply(this.editor),this.transform=u.Viewport.transformBy(i),this.transform.apply(this.editor),e&&this.editor.announceForAccessibility(this.transform.description(this.editor,this.editor.localization))}onWheel({delta:t,screenPos:e}){var n;null===(n=this.inertialScroller)||void 0===n||n.stop(),this.transform=u.Viewport.transformBy(o.default.identity);const i=this.editor.viewport.screenToCanvas(e),r=this.editor.viewport.screenToCanvasTransform.transformVec3(a.default.of(-t.x,-t.y,0)),s=o.default.scaling2D(Math.max(.25,Math.min(Math.pow(1.03,-t.z),4)),i).rightMul(o.default.translation(r));return this.updateTransform(s,!0),!0}onKeyPress({key:t,ctrlKey:e,altKey:n}){var i;if(null===(i=this.inertialScroller)||void 0===i||i.stop(),!(this.mode&p.Keyboard))return!1;if(e||n)return!1;this.transform=u.Viewport.transformBy(o.default.identity);let r=s.Vec2.zero,a=1,l=0;switch(t){case"a":case"h":case"ArrowLeft":r=s.Vec2.of(-1,0);break;case"d":case"l":case"ArrowRight":r=s.Vec2.of(1,0);break;case"q":case"k":case"ArrowUp":r=s.Vec2.of(0,-1);break;case"e":case"j":case"ArrowDown":r=s.Vec2.of(0,1);break;case"w":a=.5;break;case"s":a=2;break;case"r":l=1;break;case"R":l=-1;break;default:return!1}r=r.times(30),l*=Math.PI/8,r=r.times(-1),l*=-1,a=1/a,0!==l&&(l+=1e-4),this.isRotationLocked()&&(l=0);r=this.editor.viewport.screenToCanvasTransform.transformVec3(r);const c=this.editor.viewport.visibleRect.center,d=o.default.scaling2D(a,c).rightMul(o.default.zRotation(l,c)).rightMul(o.default.translation(r));return this.updateTransform(d,!0),!0}isRotationLocked(){return!!(this.mode&p.RotationLocked)}setModeEnabled(t,e){let n=this.mode;e?n|=t:n&=~t,this.setMode(n)}setMode(t){t!==this.mode&&(this.mode=t,this.editor.notifier.dispatch(c.EditorEventType.ToolUpdated,{kind:c.EditorEventType.ToolUpdated,tool:this}))}getMode(){return this.mode}}e.default=m},3947:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(6205)),s=r(n(8684)),a=r(n(2054)),l=r(n(2131)),c=r(n(2100)),d=r(n(8233)),u=r(n(5249));class h extends l.default{constructor(t){super(t.notifier,t.localization.pasteHandler),this.editor=t}onPaste(t){const e=t.mime.toLowerCase();return"image/svg+xml"===e?(this.doSVGPaste(t.data),!0):"text/plain"===e?(this.doTextPaste(t.data),!0):("image/png"===e||"image/jpeg"===e)&&(this.doImagePaste(t.data),!0)}addComponentsFromPaste(t){return i(this,void 0,void 0,(function*(){yield this.editor.addAndCenterComponents(t)}))}doSVGPaste(t){return i(this,void 0,void 0,(function*(){const e=s.default.fromString(t,!0),n=[];yield e.start((t=>{n.push(t)}),((t,e)=>null)),yield this.addComponentsFromPaste(n)}))}doTextPaste(t){var e,n;return i(this,void 0,void 0,(function*(){const i=this.editor.toolController.getMatchingTools(c.default);i.sort(((t,e)=>!t.isEnabled()&&e.isEnabled()?-1:!e.isEnabled()&&t.isEnabled()?1:0));const r={size:12,fontFamily:"sans",renderingStyle:{fill:d.default.red}},s=null!==(n=null===(e=i[0])||void 0===e?void 0:e.getTextStyle())&&void 0!==n?n:r,l=t.split("\n");yield this.addComponentsFromPaste([o.default.fromLines(l,a.default.identity,s)])}))}doImagePaste(t){return i(this,void 0,void 0,(function*(){const e=new Image;e.src=t;const n=yield u.default.fromImage(e,a.default.identity);yield this.addComponentsFromPaste([n])}))}}e.default=h},7052:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(4721)),o=n(306),s=n(1173),a=n(9699),l=i(n(2131));class c extends l.default{constructor(t,e,n,i=s.makeFreehandLineBuilder){super(t.notifier,e),this.editor=t,this.style=n,this.builderFactory=i,this.builder=null,this.lastPoint=null,this.ctrlKeyPressed=!1}getPressureMultiplier(){return 1/this.editor.viewport.getScaleFactor()*this.style.thickness}toStrokePoint(t){var e;this.isSnappingToGrid()&&(t=t.snappedToGrid(this.editor.viewport));let n=Math.max(null!==(e=t.pressure)&&void 0!==e?e:1,.3);isFinite(n)||(console.warn("Non-finite pressure!",t),n=.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:n*this.getPressureMultiplier(),color:this.style.color,time:t.timeStamp}}previewStroke(){var t;this.editor.clearWetInk(),null===(t=this.builder)||void 0===t||t.preview(this.editor.display.getWetInkRenderer())}addPointToStroke(t){if(!this.builder)throw new Error("No stroke is currently being generated.");this.builder.addPoint(t),this.lastPoint=t,this.previewStroke()}onPointerDown({current:t,allPointers:e}){const n=t.device===o.PointerDevice.Eraser;let i=!1;for(const t of e)if(t.device===o.PointerDevice.Pen){i=!0;break}return!((1!==e.length||n)&&!i)&&(this.builder=this.builderFactory(this.toStrokePoint(t),this.editor.viewport),!0)}onPointerMove({current:t}){this.builder&&this.addPointToStroke(this.toStrokePoint(t))}onPointerUp({current:t}){var e,n;if(!this.builder)return;const i=this.toStrokePoint(t),r=Object.assign(Object.assign({},i),{width:null!==(n=null===(e=this.lastPoint)||void 0===e?void 0:e.width)&&void 0!==n?n:i.width});this.addPointToStroke(r),t.isPrimary&&this.finalizeStroke()}onGestureCancel(){this.editor.clearWetInk()}finalizeStroke(){if(this.builder){const t=this.builder.build();if(this.previewStroke(),t.getBBox().area>0){const e=!0,n=r.default.addElement(t,e);this.editor.dispatch(n)}else console.warn("Pen: Not adding empty stroke",t,"to the canvas.")}this.builder=null,this.editor.clearWetInk()}noteUpdated(){this.editor.notifier.dispatch(a.EditorEventType.ToolUpdated,{kind:a.EditorEventType.ToolUpdated,tool:this})}setColor(t){t.toHexString()!==this.style.color.toHexString()&&(this.style=Object.assign(Object.assign({},this.style),{color:t}),this.noteUpdated())}setThickness(t){t!==this.style.thickness&&(this.style=Object.assign(Object.assign({},this.style),{thickness:t}),this.noteUpdated())}setStrokeFactory(t){t!==this.builderFactory&&(this.builderFactory=t,this.noteUpdated())}getThickness(){return this.style.thickness}getColor(){return this.style.color}getStrokeFactory(){return this.builderFactory}setEnabled(t){super.setEnabled(t),this.ctrlKeyPressed=!1}isSnappingToGrid(){return this.ctrlKeyPressed}onKeyPress({key:t,ctrlKey:e}){let n;return"-"===(t=t.toLowerCase())||"_"===t?n=2*this.getThickness()/3:"+"!==t&&"="!==t||(n=3*this.getThickness()/2),void 0!==n?(n=Math.min(Math.max(1,n),256),this.setThickness(n),!0):"control"===t||"meta"===t?(this.ctrlKeyPressed=!0,!0):("z"===t&&e&&this.builder&&this.finalizeStroke(),!1)}onKeyUp({key:t}){return("control"===(t=t.toLowerCase())||"meta"===t)&&(this.ctrlKeyPressed=!1,!0)}}e.default=c},5529:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.colorPreviewListener=null,this.colorSelectListener=null}setColorListener(t,e){this.colorPreviewListener=t,this.colorSelectListener=e}clearColorListener(){this.colorPreviewListener=null,this.colorSelectListener=null}onPointerDown({current:t,allPointers:e}){return!(!this.colorPreviewListener||1!==e.length)&&(this.colorPreviewListener(this.editor.display.getColorAt(t.screenPos)),!0)}onPointerMove({current:t}){var e;null===(e=this.colorPreviewListener)||void 0===e||e.call(this,this.editor.display.getColorAt(t.screenPos))}onPointerUp({current:t}){var e;null===(e=this.colorSelectListener)||void 0===e||e.call(this,this.editor.display.getColorAt(t.screenPos))}onGestureCancel(){var t;null===(t=this.colorSelectListener)||void 0===t||t.call(this,null)}}e.default=o},6009:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131)),o=i(n(1626));class s extends r.default{constructor(t){super(t.notifier,t.localization.selectAllTool),this.editor=t}onKeyPress({key:t,ctrlKey:e}){if(e&&"a"===t){const t=this.editor.toolController.getMatchingTools(o.default);if(t.length>0){const e=t[0];return e.setEnabled(!0),e.setSelection(this.editor.image.getAllElements()),!0}}return!1}}e.default=s},7754:function(t,e,n){"use strict";var i,r=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},a=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const c=l(n(1386)),d=l(n(2054)),u=l(n(5085)),h=n(6750),p=s(n(9975)),f=n(1626),m=l(n(8831)),g=l(n(529)),v=l(n(9098)),y=n(2537),b=n(9196),x=l(n(4721));class w{constructor(t,e){this.editor=e,this.transform=d.default.identity,this.selectedElems=[],this.hasParent=!0,this.removedFromImage={},this.targetHandle=null,this.backgroundDragging=!1,this.originalRegion=new u.default(t.x,t.y,0,0),this.transformers={drag:new y.DragTransformer(e,this),resize:new y.ResizeTransformer(e,this),rotate:new y.RotateTransformer(e,this)},this.container=document.createElement("div"),this.backgroundElem=document.createElement("div"),this.backgroundElem.classList.add(`${f.cssPrefix}selection-background`),this.container.appendChild(this.backgroundElem);const n=new p.default(p.HandleShape.Square,h.Vec2.of(1,.5),this,(t=>this.transformers.resize.onDragStart(t,b.ResizeMode.HorizontalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),i=new p.default(p.HandleShape.Square,h.Vec2.of(.5,1),this,(t=>this.transformers.resize.onDragStart(t,b.ResizeMode.VerticalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),r=new p.default(p.HandleShape.Square,h.Vec2.of(1,1),this,(t=>this.transformers.resize.onDragStart(t,b.ResizeMode.Both)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),o=new p.default(p.HandleShape.Circle,h.Vec2.of(.5,0),this,(t=>this.transformers.rotate.onDragStart(t)),(t=>this.transformers.rotate.onDragUpdate(t)),(()=>this.transformers.rotate.onDragEnd()));this.handles=[r,n,i,o];for(const t of this.handles)t.addTo(this.backgroundElem)}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){const t=d.default.zRotation(this.regionRotation,this.originalRegion.center),e=this.transform.rightMul(t.inverse());return this.originalRegion.transformedBoundingBox(e)}computeTightBoundingBox(){const t=this.selectedElems.reduce(((t,e)=>(null!=t?t:e.getBBox()).union(e.getBBox())),null);return null!=t?t:u.default.empty}get regionRotation(){return this.transform.transformVec3(h.Vec2.unitX).angle()}get preTransformedScreenRegion(){const t=t=>this.editor.viewport.canvasToScreen(t);return u.default.fromCorners(t(this.preTransformRegion.topLeft),t(this.preTransformRegion.bottomRight))}get preTransformedScreenRegionRotation(){return this.editor.viewport.getRotationAngle()}get screenRegion(){const t=this.editor.viewport.canvasToScreenTransform,e=this.editor.viewport.getScaleFactor(),n=t.transformVec2(this.region.center);return new u.default(n.x,n.y,e*this.region.width,e*this.region.height).translatedBy(this.region.size.times(-e/2))}get screenRegionRotation(){return this.regionRotation+this.editor.viewport.getRotationAngle()}setTransform(t,e=!0){this.transform=t,e&&this.hasParent&&(this.scrollTo(),this.previewTransformCmds())}finalizeTransform(){const t=this.transform,e=this.selectedElems;this.originalRegion=this.originalRegion.transformedBoundingBox(this.transform),this.transform=d.default.identity,this.editor.dispatch(new w.ApplyTransformationCommand(this,e,t))}previewTransformCmds(){if(this.selectedElems.length>500)return void this.updateUI();const t=this.editor.display.getWetInkRenderer();t.clear(),t.pushTransform(this.transform);const e=this.editor.viewport.visibleRect.transformedBoundingBox(this.transform.inverse());for(const n of this.selectedElems)n.render(t,e);t.popTransform(),this.updateUI()}resolveToObjects(){let t=!1;if(this.transform=d.default.identity,0===this.region.w||0===this.region.h){const e=this.editor.viewport.visibleRect.maxDimension/200;this.originalRegion=u.default.bboxOf(this.region.corners,e),t=!0}return this.selectedElems=this.editor.image.getElementsIntersectingRegion(this.region).filter((t=>t.intersectsRect(this.region)&&t.isSelectable())),t&&this.selectedElems.length>0&&(this.selectedElems=[this.selectedElems[this.selectedElems.length-1]]),!!this.recomputeRegion()&&(this.updateUI(),!0)}recomputeRegion(){const t=this.computeTightBoundingBox();if(!t)return this.cancelSelection(),!1;this.originalRegion=t;const e=this.getMinCanvasSize();if(this.originalRegion.w<e||this.originalRegion.h<e){const t=e/2;this.originalRegion=u.default.bboxOf(this.originalRegion.corners,t)}return!0}getMinCanvasSize(){return 2*(p.handleSize/this.editor.viewport.getScaleFactor())}getSelectedItemCount(){return this.selectedElems.length}updateUI(){if(!this.hasParent)return;this.backgroundElem.style.marginLeft=`${this.screenRegion.topLeft.x}px`,this.backgroundElem.style.marginTop=`${this.screenRegion.topLeft.y}px`,this.backgroundElem.style.width=`${this.screenRegion.width}px`,this.backgroundElem.style.height=`${this.screenRegion.height}px`;const t=180*this.screenRegionRotation/Math.PI;this.backgroundElem.style.transform=`rotate(${t}deg)`,this.backgroundElem.style.transformOrigin="center";for(const t of this.handles)t.updatePosition()}addRemoveSelectionFromImage(t){if(t||!(this.selectedElems.length>500)){for(const e of this.selectedElems){const n=this.editor.image.findParent(e);!t&&n?(this.removedFromImage[e.getId()]=!0,n.remove()):!n&&this.removedFromImage[e.getId()]&&(x.default.addElement(e).apply(this.editor),this.removedFromImage[e.getId()]=!1,delete this.removedFromImage[e.getId()])}this.editor.queueRerender().then((()=>{t||this.previewTransformCmds()}))}}removeDeletedElemsFromSelection(){this.selectedElems=this.selectedElems.filter((t=>{const e=!!this.editor.image.findParent(t),n=this.removedFromImage[t.getId()];return e||n}))}onDragStart(t,e){this.removeDeletedElemsFromSelection(),this.addRemoveSelectionFromImage(!1);for(const n of this.handles)if(n.isTarget(e))return n.handleDragStart(t),this.targetHandle=n,!0;return this.backgroundElem===e&&(this.backgroundDragging=!0,this.transformers.drag.onDragStart(t.canvasPos),!0)}onDragUpdate(t){this.backgroundDragging&&this.transformers.drag.onDragUpdate(t.canvasPos),this.targetHandle&&this.targetHandle.handleDragUpdate(t)}onDragEnd(){this.backgroundDragging?this.transformers.drag.onDragEnd():this.targetHandle&&this.targetHandle.handleDragEnd(),this.addRemoveSelectionFromImage(!0),this.backgroundDragging=!1,this.targetHandle=null,this.updateUI()}onDragCancel(){this.backgroundDragging=!1,this.targetHandle=null,this.setTransform(d.default.identity),this.addRemoveSelectionFromImage(!0)}scrollTo(){return a(this,void 0,void 0,(function*(){if(0===this.selectedElems.length)return;const t=new u.default(0,0,this.editor.display.width,this.editor.display.height);if(!t.containsPoint(this.screenRegion.center)){const e=t.getClosestPointOnBoundaryTo(this.screenRegion.center),n=this.screenRegion.center.minus(e),i=this.editor.viewport.screenToCanvasTransform.transformVec3(n);yield this.editor.dispatchNoAnnounce(m.default.transformBy(d.default.translation(i.times(-1))),!1),yield this.editor.queueRerender(),this.previewTransformCmds()}}))}deleteSelectedObjects(){return(this.backgroundDragging||this.targetHandle)&&this.onDragEnd(),new g.default(this.selectedElems)}duplicateSelectedObjects(){return a(this,void 0,void 0,(function*(){const t=this.backgroundDragging||this.targetHandle;let e=null;if(t){const t=null;e=new w.ApplyTransformationCommand(t,this.selectedElems,this.transform),yield e.apply(this.editor),this.addRemoveSelectionFromImage(!0)}const n=new v.default(this.selectedElems);return t&&(yield null==e?void 0:e.unapply(this.editor),this.addRemoveSelectionFromImage(!1),this.previewTransformCmds(),this.updateUI()),n}))}addTo(t){this.container.parentElement&&this.container.remove(),t.appendChild(this.container),this.hasParent=!0}setToPoint(t){this.originalRegion=this.originalRegion.grownToPoint(t),this.updateUI()}cancelSelection(){this.container.parentElement&&this.container.remove(),this.originalRegion=u.default.empty,this.hasParent=!1}setSelectedObjects(t,e){this.addRemoveSelectionFromImage(!0),this.originalRegion=e,this.selectedElems=t.filter((t=>t.isSelectable())),this.updateUI()}getSelectedObjects(){return this.selectedElems}}e.default=w,i=w,c.default.register("selection-tool-transform",((t,e)=>{var n;const r=new d.default(...t.transform),o=null!==(n=t.elems)&&void 0!==n?n:[];return new i.ApplyTransformationCommand(null,o,r)})),w.ApplyTransformationCommand=class extends c.default{constructor(t,e,n){super("selection-tool-transform"),this.selection=t,this.fullTransform=n;"string"==typeof e[0]?this.selectedElemIds=e:(this.selectedElemIds=e.map((t=>t.getId())),this.transformCommands=e.map((t=>t.transformBy(this.fullTransform))))}resolveToElems(t){this.transformCommands||(this.transformCommands=this.selectedElemIds.map((e=>{const n=t.image.lookupElement(e);if(!n)throw new Error(`Unable to find element with ID, ${e}.`);return n.transformBy(this.fullTransform)})))}apply(t){var e,n,i,r,o;return a(this,void 0,void 0,(function*(){this.resolveToElems(t),null===(e=this.selection)||void 0===e||e.setTransform(this.fullTransform,!1),null===(n=this.selection)||void 0===n||n.updateUI(),yield t.asyncApplyCommands(this.transformCommands,100),null===(i=this.selection)||void 0===i||i.setTransform(d.default.identity,!1),null===(r=this.selection)||void 0===r||r.recomputeRegion(),null===(o=this.selection)||void 0===o||o.updateUI()}))}unapply(t){var e,n,i,r,o;return a(this,void 0,void 0,(function*(){this.resolveToElems(t),null===(e=this.selection)||void 0===e||e.setTransform(this.fullTransform.inverse(),!1),null===(n=this.selection)||void 0===n||n.updateUI(),yield t.asyncUnapplyCommands(this.transformCommands,100,!0),null===(i=this.selection)||void 0===i||i.setTransform(d.default.identity),null===(r=this.selection)||void 0===r||r.recomputeRegion(),null===(o=this.selection)||void 0===o||o.updateUI()}))}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray()}}description(t,e){return e.transformedElements(this.selectedElemIds.length)}}},9975:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.handleSize=e.HandleShape=void 0;const i=n(246),r=n(6750),o=n(1626);var s;!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square"}(s=e.HandleShape||(e.HandleShape={})),e.handleSize=30;e.default=class{constructor(t,e,n,r,a,l){switch(this.shape=t,this.parentSide=e,this.parent=n,this.onDragStart=r,this.onDragUpdate=a,this.onDragEnd=l,this.dragLastPos=null,this.element=document.createElement("div"),this.element.classList.add(`${o.cssPrefix}handle`),t){case s.Circle:this.element.classList.add(`${o.cssPrefix}circle`);break;case s.Square:this.element.classList.add(`${o.cssPrefix}square`);break;default:(0,i.assertUnreachable)(t)}this.updatePosition()}addTo(t){t.appendChild(this.element)}updatePosition(){const t=this.parent.screenRegion,n=r.Vec2.of(e.handleSize,e.handleSize),i=t.size.scale(this.parentSide).minus(n.times(.5));this.element.style.marginLeft=`${i.x}px`,this.element.style.marginTop=`${i.y}px`,this.element.style.width=`${n.x}px`,this.element.style.height=`${n.y}px`}isTarget(t){return t===this.element}handleDragStart(t){this.onDragStart(t.canvasPos),this.dragLastPos=t.canvasPos}handleDragUpdate(t){this.dragLastPos&&this.onDragUpdate(t.canvasPos)}handleDragEnd(){this.dragLastPos&&this.onDragEnd()}setSnapToGrid(t){this.snapToGrid=t}isSnappingToGrid(){return this.snapToGrid}}},1626:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.cssPrefix=void 0;const r=i(n(2054)),o=n(6750),s=n(9699),a=i(n(8831)),l=i(n(2131)),c=i(n(9563)),d=i(n(7754)),u=i(n(6205));e.cssPrefix="selection-tool-";class h extends l.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastEvtTarget=null,this.expandingSelectionBox=!1,this.shiftKeyPressed=!1,this.ctrlKeyPressed=!1,this.selectionBoxHandlingEvt=!1,this.handleOverlay=document.createElement("div"),t.createHTMLOverlay(this.handleOverlay),this.handleOverlay.style.display="none",this.handleOverlay.classList.add("handleOverlay"),t.notifier.on(s.EditorEventType.ViewportChanged,(t=>{var e;null===(e=this.selectionBox)||void 0===e||e.updateUI()})),this.editor.handleKeyEventsFrom(this.handleOverlay),this.editor.handlePointerEventsFrom(this.handleOverlay,((t,e)=>("pointerdown"===t&&(this.lastEvtTarget=e.target),!0)))}makeSelectionBox(t){var e;this.prevSelectionBox=this.selectionBox,this.selectionBox=new d.default(t,this.editor),this.expandingSelectionBox||null===(e=this.prevSelectionBox)||void 0===e||e.cancelSelection(),this.selectionBox.addTo(this.handleOverlay)}snapSelectionToGrid(){if(!this.selectionBox)throw new Error("No selection to snap!");const t=this.selectionBox.computeTightBoundingBox().topLeft,e=this.editor.viewport.snapToGrid(t).minus(t),n=this.selectionBox.getTransform();this.selectionBox.setTransform(n.rightMul(r.default.translation(e))),this.selectionBox.finalizeTransform()}onPointerDown({allPointers:t,current:e}){const n=this.ctrlKeyPressed;if(n&&(e=e.snappedToGrid(this.editor.viewport)),1===t.length&&e.isPrimary){let t=!1;if(this.lastEvtTarget&&this.selectionBox){n&&this.snapSelectionToGrid();this.selectionBox.onDragStart(e,this.lastEvtTarget)&&(t=!0,this.selectionBoxHandlingEvt=!0,this.expandingSelectionBox=!1)}return t||(this.expandingSelectionBox=this.shiftKeyPressed,this.makeSelectionBox(e.canvasPos)),!0}return!1}onPointerMove(t){if(!this.selectionBox)return;let e=t.current;this.ctrlKeyPressed&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox.onDragUpdate(e):this.selectionBox.setToPoint(e.canvasPos)}onSelectionUpdated(){var t,e;this.editor.notifier.dispatch(s.EditorEventType.ToolUpdated,{kind:s.EditorEventType.ToolUpdated,tool:this});const n=null!==(e=null===(t=this.selectionBox)||void 0===t?void 0:t.getSelectedItemCount())&&void 0!==e?e:0;n>0?(this.editor.announceForAccessibility(this.editor.localization.selectedElements(n)),this.zoomToSelection()):this.selectionBox&&(this.selectionBox.cancelSelection(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null)}onGestureEnd(){this.lastEvtTarget=null,this.selectionBox&&(this.selectionBoxHandlingEvt?this.selectionBox.onDragEnd():(this.selectionBox.resolveToObjects(),this.onSelectionUpdated()),this.selectionBoxHandlingEvt=!1)}zoomToSelection(){if(this.selectionBox){const t=this.selectionBox.region;this.editor.dispatchNoAnnounce(this.editor.viewport.zoomTo(t,!1),!1)}}onPointerUp(t){if(!this.selectionBox)return;let e=t.current;this.ctrlKeyPressed&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBox.setToPoint(e.canvasPos),this.expandingSelectionBox&&this.prevSelectionBox?(this.expandingSelectionBox=!1,this.selectionBox.resolveToObjects(),this.setSelection([...this.selectionBox.getSelectedObjects(),...this.prevSelectionBox.getSelectedObjects()])):this.onGestureEnd()}onGestureCancel(){var t,e,n,i;this.selectionBoxHandlingEvt?null===(t=this.selectionBox)||void 0===t||t.onDragCancel():(null===(e=this.selectionBox)||void 0===e||e.cancelSelection(),this.selectionBox=this.prevSelectionBox,null===(n=this.selectionBox)||void 0===n||n.addTo(this.handleOverlay),null===(i=this.selectionBox)||void 0===i||i.recomputeRegion(),this.prevSelectionBox=null),this.expandingSelectionBox=!1}onKeyPress(t){if("Control"===t.key||"Meta"===t.key)return this.ctrlKeyPressed=!0,!0;if(this.selectionBox&&t.ctrlKey&&"d"===t.key)return!0;if("a"===t.key&&t.ctrlKey)return this.setSelection(this.editor.image.getAllElements()),!0;if(t.ctrlKey)return!1;if("Shift"===t.key)return this.shiftKeyPressed=!0,!0;let e=0,n=0,i=0,s=0,l=0;switch(t.key){case"a":case"h":case"ArrowLeft":n-=1;break;case"d":case"l":case"ArrowRight":n+=1;break;case"q":case"k":case"ArrowUp":i-=1;break;case"e":case"j":case"ArrowDown":i+=1;break;case"r":e+=1;break;case"R":e-=1;break;case"i":s-=1;break;case"I":s+=1;break;case"o":l-=1;break;case"O":l+=1}let c=0!==n||0!==i||0!==e||0!==s||0!==l;if(this.selectionBox){if(c){const t=10*this.editor.viewport.getSizeOfPixelOnCanvas(),c=Math.PI/8,d=5/4,u=this.selectionBox.region,h=o.Vec2.of(Math.pow(d,s),Math.pow(d,l)),p=r.default.zRotation(e*c).mapEntries((t=>a.default.roundScaleRatio(t))),f=this.editor.viewport.roundPoint(u.center),m=r.default.scaling2D(h,this.editor.viewport.roundPoint(u.topLeft)).rightMul(r.default.translation(f).rightMul(p).rightMul(r.default.translation(f.times(-1)))).rightMul(r.default.translation(this.editor.viewport.roundPoint(o.Vec2.of(n,i).times(t)))),g=this.selectionBox.getTransform();this.selectionBox.setTransform(g.rightMul(m))}}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){if("Control"===t.key||"Meta"===t.key)return this.ctrlKeyPressed=!1,!0;if("Shift"===t.key)return this.shiftKeyPressed=!1,!0;if(t.ctrlKey){if(this.selectionBox&&"d"===t.key)return this.selectionBox.duplicateSelectedObjects().then((t=>{this.editor.dispatch(t)})),!0;if("a"===t.key||"r"===t.key)return!0}return!(!this.selectionBox||!h.handleableKeys.some((e=>e===t.key)))&&(this.selectionBox.finalizeTransform(),!0)}onCopy(t){if(!this.selectionBox)return!1;const e=this.selectionBox.getSelectedObjects(),n=this.selectionBox.region;if(0===e.length)return!1;const i=new a.default((()=>{}));i.updateScreenSize(o.Vec2.of(n.w,n.h)),i.resetTransform(r.default.translation(n.topLeft.times(-1)));const{element:s,renderer:l}=c.default.fromViewport(i,!0),d=[];for(const t of e)t.render(l),t instanceof u.default&&d.push(t.getText());return t.setData("image/svg+xml",s.outerHTML),t.setData("text/html",s.outerHTML),d.length>0&&t.setData("text/plain",d.join("\n")),!0}setEnabled(t){super.setEnabled(t),this.handleOverlay.replaceChildren(),this.selectionBox=null,this.shiftKeyPressed=!1,this.ctrlKeyPressed=!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(){var t,e;return null!==(e=null===(t=this.selectionBox)||void 0===t?void 0:t.getSelectedObjects())&&void 0!==e?e:[]}setSelection(t){(t=t.filter((t=>t.isSelectable()))).sort(((t,e)=>t.getZIndex()-e.getZIndex())),t=t.filter(((e,n)=>!(n>0)||e!==t[n-1]));let e=null;for(const n of t)e=e?e.union(n.getBBox()):n.getBBox();e&&(this.clearSelection(),this.selectionBox||this.makeSelectionBox(e.topLeft),this.selectionBox.setSelectedObjects(t,e),this.onSelectionUpdated())}clearSelection(){this.handleOverlay.replaceChildren(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null,this.onSelectionUpdated()}}e.default=h,h.handleableKeys=["a","h","ArrowLeft","d","l","ArrowRight","q","k","ArrowUp","e","j","ArrowDown","r","R","i","I","o","O","Control","Meta"]},2537:function(t,e,n){"use strict";var i=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 r=i(n(2054)),o=n(6750),s=i(n(8831)),a=n(9196);e.DragTransformer=class{constructor(t,e){this.editor=t,this.selection=e}onDragStart(t){this.selection.setTransform(r.default.identity),this.dragStartPoint=t}onDragUpdate(t){const e=this.editor.viewport.roundPoint(t.minus(this.dragStartPoint));this.selection.setTransform(r.default.translation(e))}onDragEnd(){this.selection.finalizeTransform()}};e.ResizeTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.mode=a.ResizeMode.Both}onDragStart(t,e){this.selection.setTransform(r.default.identity),this.mode=e,this.dragStartPoint=t}onDragUpdate(t){const e=t.minus(this.dragStartPoint),n=this.selection.preTransformRegion.width,i=this.selection.preTransformRegion.height;let l=o.Vec2.of(1,1);if(this.mode===a.ResizeMode.HorizontalOnly){const t=n+e.x;l=o.Vec2.of(t/n,l.y)}if(this.mode===a.ResizeMode.VerticalOnly){const t=i+e.y;l=o.Vec2.of(l.x,t/i)}if(this.mode===a.ResizeMode.Both){const t=n+(Math.abs(e.x)>Math.abs(e.y)?e.x:e.y);l=o.Vec2.of(t/n,t/n)}if(l=l.map((t=>s.default.roundScaleRatio(t,2))),0!==l.x&&0!==l.y){const t=this.editor.viewport.roundPoint(this.selection.preTransformRegion.topLeft);this.selection.setTransform(r.default.scaling2D(l,t))}}onDragEnd(){this.selection.finalizeTransform()}};e.RotateTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.startAngle=0}getAngle(t){const e=this.selection.preTransformRegion.center;return t.minus(e).angle()}roundAngle(t){const e=8/Math.PI;return Math.round(t*e)/e}onDragStart(t){this.selection.setTransform(r.default.identity),this.startAngle=this.getAngle(t)}onDragUpdate(t){const e=this.roundAngle(this.getAngle(t)-this.startAngle),n=this.editor.viewport.roundPoint(this.selection.preTransformRegion.center),i=r.default.zRotation(e).mapEntries((t=>s.default.roundScaleRatio(t))),o=r.default.translation(n).rightMul(i).rightMul(r.default.translation(n.times(-1)));this.selection.setTransform(o)}onDragEnd(){this.selection.finalizeTransform()}}},9196:(t,e)=>{"use strict";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"}(e.ResizeMode||(e.ResizeMode={})),function(t){t[t.Snap=0]="Snap",t[t.NoSnap=1]="NoSnap"}(e.TransformMode||(e.TransformMode={}))},8838:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=i(n(9784)),s=i(n(2131));class a{constructor(){if(this.closed=!1,!window.AudioContext)return console.warn("Accessibility sound UI: Unable to open AudioContext."),void(this.closed=!0);this.ctx=new AudioContext,this.colorOscHue=this.ctx.createOscillator(),this.colorOscValue=this.ctx.createOscillator(),this.colorOscSaturation=this.ctx.createOscillator(),this.colorOscHue.type="triangle",this.colorOscSaturation.type="sine",this.colorOscValue.type="sawtooth",this.valueGain=this.ctx.createGain(),this.colorOscValue.connect(this.valueGain),this.valueGain.gain.setValueAtTime(.18,this.ctx.currentTime),this.colorGain=this.ctx.createGain(),this.colorOscHue.connect(this.colorGain),this.valueGain.connect(this.colorGain),this.colorOscSaturation.connect(this.colorGain),this.colorGain.connect(this.ctx.destination),this.boundaryGain=this.ctx.createGain(),this.boundaryOsc=this.ctx.createOscillator(),this.boundaryOsc.type="sawtooth",this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryOsc.connect(this.boundaryGain),this.boundaryGain.connect(this.ctx.destination),this.colorOscHue.start(),this.colorOscSaturation.start(),this.colorOscValue.start(),this.boundaryOsc.start(),this.pause()}pause(){this.closed||(this.colorGain.gain.setValueAtTime(0,this.ctx.currentTime),this.ctx.suspend())}play(){this.closed||this.ctx.resume()}setColor(t){const e=t.asHSV(),n=220*-Math.cos(e.x/2)+440,i=440*e.y+220,r=440*(e.z+.1),o=.25*Math.min(1,t.a)/(1+Math.exp(3*-(e.z-.5)));this.colorOscHue.frequency.setValueAtTime(n,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(i,this.ctx.currentTime),this.colorOscValue.frequency.setValueAtTime(r,this.ctx.currentTime),this.valueGain.gain.setValueAtTime(.4*(1-e.z),this.ctx.currentTime),this.colorGain.gain.setValueAtTime(o,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 l extends s.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.soundFeedback=null,this.toggleButtonContainer=document.createElement("div"),this.toggleButtonContainer.classList.add("js-draw-sound-ui-toggle"),this.toggleButton=document.createElement("button"),this.toggleButton.onclick=()=>{this.setEnabled(!this.isEnabled())},this.toggleButtonContainer.appendChild(this.toggleButton),this.updateToggleButtonText(),t.createHTMLOverlay(this.toggleButtonContainer)}updateToggleButtonText(){const t="sound-ui-tool-enabled";this.isEnabled()?(this.toggleButton.innerText=this.editor.localization.disableAccessibilityExploreTool,this.toggleButtonContainer.classList.add(t)):(this.toggleButton.innerText=this.editor.localization.enableAccessibilityExploreTool,this.toggleButtonContainer.classList.remove(t))}setEnabled(t){var e;super.setEnabled(t),t||(null===(e=this.soundFeedback)||void 0===e||e.close(),this.soundFeedback=null),this.updateToggleButtonText()}onPointerDown({current:t,allPointers:e}){var n,i,o;return this.soundFeedback||(this.soundFeedback=new a),!(e.length>=2)&&(null===(n=this.soundFeedback)||void 0===n||n.play(),null===(i=this.soundFeedback)||void 0===i||i.setColor(null!==(o=this.editor.display.getColorAt(t.screenPos))&&void 0!==o?o:r.default.black),this.lastPointerPos=t.canvasPos,!0)}onPointerMove({current:t}){var e,n,i;null===(e=this.soundFeedback)||void 0===e||e.setColor(null!==(n=this.editor.display.getColorAt(t.screenPos))&&void 0!==n?n:r.default.black);const s=new o.default(this.lastPointerPos,t.canvasPos),a=this.editor.image.getElementsIntersectingRegion(s.bbox).filter((t=>t.intersects(s)));this.lastPointerPos=t.canvasPos,a.length>0&&(null===(i=this.soundFeedback)||void 0===i||i.announceBoundaryCross(a.length))}onPointerUp(t){var e;null===(e=this.soundFeedback)||void 0===e||e.pause()}onGestureCancel(){var t;null===(t=this.soundFeedback)||void 0===t||t.pause()}}e.default=l},2100:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=i(n(6205)),s=i(n(4721)),a=i(n(5085)),l=i(n(2054)),c=n(6750),d=n(306),u=n(9699),h=i(n(2131)),p=i(n(529)),f=i(n(3966)),m="textEditorOverlay";class g extends h.default{constructor(t,e,n){super(t.notifier,e),this.editor=t,this.localizationTable=n,this.textInputElem=null,this.textTargetPosition=null,this.textMeasuringCtx=null,this.textScale=c.Vec2.of(1,1),this.removeExistingCommand=null,this.textStyle={size:32,fontFamily:"sans-serif",renderingStyle:{fill:r.default.purple}},this.textEditOverlay=document.createElement("div"),this.textEditOverlay.classList.add(m),this.editor.addStyleSheet(`\n\t\t\t.${m} {\n\t\t\t\theight: 0;\n\t\t\t\toverflow: visible;\n\t\t\t}\n\n\t\t\t.${m} textarea {\n\t\t\t\tbackground-color: rgba(0, 0, 0, 0);\n\n\t\t\t\twhite-space: pre;\n\t\t\t\toverflow: hidden;\n\n\t\t\t\tpadding: 0;\n\t\t\t\tmargin: 0;\n\t\t\t\tborder: none;\n\t\t\t\tpadding: 0;\n\n\t\t\t\tmin-width: 100px;\n\t\t\t\tmin-height: 1.1em;\n\t\t\t}\n\t\t`),this.editor.createHTMLOverlay(this.textEditOverlay),this.editor.notifier.on(u.EditorEventType.ViewportChanged,(()=>this.updateTextInput()))}getTextAscent(t,e){var n;return null!==(n=this.textMeasuringCtx)&&void 0!==n||(this.textMeasuringCtx=document.createElement("canvas").getContext("2d")),this.textMeasuringCtx?(o.default.applyTextStyles(this.textMeasuringCtx,e),this.textMeasuringCtx.measureText(t).actualBoundingBoxAscent):2*e.size/3}flushInput(t=!0){if(this.textInputElem&&this.textTargetPosition){const e=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",t){const t=this.textInputElem;this.textInputElem=null,t.remove()}if(""===e)return;const n=l.default.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(l.default.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(l.default.zRotation(this.textRotation)),i=o.default.fromLines(e.split("\n"),n,this.textStyle),r=s.default.addElement(i);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch((0,f.default)([this.removeExistingCommand,r])),this.removeExistingCommand=null):this.editor.dispatch(r)}}getTextScaleMatrix(){return l.default.scaling2D(this.textScale.times(1/this.editor.viewport.getSizeOfPixelOnCanvas()))}updateTextInput(){var t,e,n;if(!this.textInputElem||!this.textTargetPosition)return void(null===(t=this.textInputElem)||void 0===t||t.remove());const i=this.editor.viewport,r=i.canvasToScreen(this.textTargetPosition);this.textInputElem.placeholder=this.localizationTable.enterTextToInsert,this.textInputElem.style.fontFamily=this.textStyle.fontFamily,this.textInputElem.style.fontVariant=null!==(e=this.textStyle.fontVariant)&&void 0!==e?e:"",this.textInputElem.style.fontWeight=null!==(n=this.textStyle.fontWeight)&&void 0!==n?n:"",this.textInputElem.style.fontSize=`${this.textStyle.size}px`,this.textInputElem.style.color=this.textStyle.renderingStyle.fill.toHexString(),this.textInputElem.style.position="relative",this.textInputElem.style.left=`${r.x}px`,this.textInputElem.style.top=`${r.y}px`,this.textInputElem.style.margin="0",this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`;const o=this.getTextAscent("⎢",this.textStyle),s=this.textRotation+i.getRotationAngle(),a=this.getTextScaleMatrix();this.textInputElem.style.transform=`${a.toCSSMatrix()} rotate(${180*s/Math.PI}deg) translate(0, ${-o}px)`,this.textInputElem.style.transformOrigin="top left"}startTextInput(t,e){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=e,this.textInputElem.style.display="inline-block",this.textTargetPosition=this.editor.viewport.roundPoint(t),this.textRotation=-this.editor.viewport.getRotationAngle(),this.textScale=c.Vec2.of(1,1).times(this.editor.viewport.getSizeOfPixelOnCanvas()),this.updateTextInput(),setTimeout((()=>this.updateTextInput()),0),this.textInputElem.oninput=()=>{this.textInputElem&&(this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`)},this.textInputElem.onblur=()=>{const t=this.textInputElem;this.flushInput(!1),this.textInputElem=null,setTimeout((()=>{null==t||t.remove()}),0)},this.textInputElem.onkeyup=t=>{var e,n;"Enter"!==t.key||t.shiftKey?"Escape"===t.key&&(null===(e=this.textInputElem)||void 0===e||e.remove(),this.textInputElem=null,this.editor.focus(),null===(n=this.removeExistingCommand)||void 0===n||n.unapply(this.editor),this.removeExistingCommand=null):(this.flushInput(),this.editor.focus())},this.textEditOverlay.replaceChildren(this.textInputElem),setTimeout((()=>{var t;return null===(t=this.textInputElem)||void 0===t?void 0:t.focus()}),0)}setEnabled(t){super.setEnabled(t),t||this.flushInput(),this.textEditOverlay.style.display=t?"block":"none"}onPointerDown({current:t,allPointers:e}){if(t.device===d.PointerDevice.Eraser)return!1;if(1===e.length){const e=t.canvasPos,n=c.Vec2.of(2.5,2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas()),i=a.default.fromCorners(e.minus(n),e.plus(n));let r=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t instanceof o.default));const s=this.editor.viewport.visibleRect;if(r=r.filter((t=>!t.getBBox().containsRect(s))),this.flushInput(),r.length>0){const t=r[r.length-1];this.setTextStyle(t.getTextStyle()),this.removeExistingCommand=new p.default([t]),this.removeExistingCommand.apply(this.editor),this.startTextInput(t.getBaselinePos(),t.getText());const e=t.getTransform();this.textRotation=e.transformVec3(c.Vec2.unitX).angle();const n=e.transformVec3(c.Vec2.unitX).magnitude();this.textScale=c.Vec2.of(1,1).times(n),this.updateTextInput()}else this.removeExistingCommand=null,this.startTextInput(t.canvasPos,"");return!0}return!1}onGestureCancel(){this.flushInput(),this.editor.focus()}dispatchUpdateEvent(){this.updateTextInput(),this.editor.notifier.dispatch(u.EditorEventType.ToolUpdated,{kind:u.EditorEventType.ToolUpdated,tool:this})}setFontFamily(t){t!==this.textStyle.fontFamily&&(this.textStyle=Object.assign(Object.assign({},this.textStyle),{fontFamily:t}),this.dispatchUpdateEvent())}setColor(t){t.eq(this.textStyle.renderingStyle.fill)||(this.textStyle=Object.assign(Object.assign({},this.textStyle),{renderingStyle:Object.assign(Object.assign({},this.textStyle.renderingStyle),{fill:t})}),this.dispatchUpdateEvent())}setFontSize(t){t!==this.textStyle.size&&(this.textStyle=Object.assign(Object.assign({},this.textStyle),{size:t}),this.dispatchUpdateEvent())}getTextStyle(){return this.textStyle}setTextStyle(t){this.textStyle=Object.assign(Object.assign({},t),{renderingStyle:Object.assign({},t.renderingStyle)}),this.dispatchUpdateEvent()}}e.default=g},1769:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(9699),l=o(n(135)),c=s(n(7052)),d=s(n(2195)),u=s(n(9270)),h=s(n(1626)),p=s(n(8233)),f=s(n(991)),m=s(n(2100)),g=s(n(5529)),v=s(n(8840)),y=s(n(3947)),b=s(n(2375)),x=n(4856),w=s(n(3252)),T=s(n(6009)),S=s(n(8838));e.default=class{constructor(t,e){this.activeTool=null;const n=new d.default;this.primaryToolGroup=n;const i=new l.default(t,l.PanZoomMode.TwoFingerTouchGestures|l.PanZoomMode.RightClickDrags,e.touchPanTool),r=new l.default(t,l.PanZoomMode.Keyboard,e.keyboardPanZoom),o=new c.default(t,e.penTool(1),{color:p.default.purple,thickness:8}),s=[o,new c.default(t,e.penTool(2),{color:p.default.clay,thickness:4}),new c.default(t,e.penTool(3),{color:p.default.ofRGBA(1,1,0,.5),thickness:40},x.makePressureSensitiveFreehandLineBuilder),new u.default(t,e.eraserTool),new h.default(t,e.selectionTool),new m.default(t,e.textTool,e),new l.default(t,l.PanZoomMode.SinglePointerGestures,e.anyDevicePanning)],C=new S.default(t,e.soundExplorer);C.setEnabled(!1),this.tools=[new g.default(t,e.pipetteTool),C,i,...s,r,new f.default(t),new b.default(t),new v.default(t),new w.default(t),new y.default(t),new T.default(t)],s.forEach((t=>t.setToolGroup(n))),i.setEnabled(!0),o.setEnabled(!0),t.notifier.on(a.EditorEventType.ToolEnabled,(n=>{n.kind===a.EditorEventType.ToolEnabled&&t.announceForAccessibility(e.toolEnabledAnnouncement(n.tool.description))})),t.notifier.on(a.EditorEventType.ToolDisabled,(n=>{n.kind===a.EditorEventType.ToolDisabled&&t.announceForAccessibility(e.toolDisabledAnnouncement(n.tool.description))})),this.activeTool=null}setTools(t,e){this.tools=t,this.primaryToolGroup=null!=e?e:new d.default}addPrimaryTool(t){t.setToolGroup(this.primaryToolGroup),t.isEnabled()&&this.primaryToolGroup.notifyEnabled(t),this.addTool(t)}getPrimaryTools(){return this.tools.filter((t=>t.getToolGroup()===this.primaryToolGroup))}addTool(t){this.tools.push(t)}dispatchInputEvent(t){var e,n;let i=!1;if(t.kind===a.InputEvtType.PointerDownEvt){for(const n of this.tools)if(n.isEnabled()&&n.onPointerDown(t)){this.activeTool!==n&&(null===(e=this.activeTool)||void 0===e||e.onGestureCancel()),this.activeTool=n,i=!0;break}}else if(t.kind===a.InputEvtType.PointerUpEvt)null===(n=this.activeTool)||void 0===n||n.onPointerUp(t),this.activeTool=null,i=!0;else if(t.kind===a.InputEvtType.PointerMoveEvt)null!==this.activeTool&&(this.activeTool.onPointerMove(t),i=!0);else if(t.kind===a.InputEvtType.GestureCancelEvt)null!==this.activeTool&&(this.activeTool.onGestureCancel(),this.activeTool=null);else{let e;for(const n of this.tools)if(n.isEnabled()){switch(t.kind){case a.InputEvtType.KeyPressEvent:i=n.onKeyPress(t);break;case a.InputEvtType.KeyUpEvent:i=n.onKeyUp(t);break;case a.InputEvtType.WheelEvt:i=n.onWheel(t);break;case a.InputEvtType.CopyEvent:i=n.onCopy(t);break;case a.InputEvtType.PasteEvent:i=n.onPaste(t);break;default:return e=t,e}if(i)break}}return i}getMatchingTools(t){return this.tools.filter((e=>e instanceof t))}}},2195:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){}notifyEnabled(t){var e;t!==this.activeTool&&(null===(e=this.activeTool)||void 0===e||e.setEnabled(!1),this.activeTool=t)}}},8840:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.default{constructor(t){super(t.notifier,t.localization.changeTool),this.editor=t}onKeyPress({key:t}){const e=this.editor.toolController.getPrimaryTools(),n=/^[0-9]$/.exec(t);let i;if(n){i=e[parseInt(n[0],10)-1]}return!!i&&(i.setEnabled(!0),!0)}}e.default=o},2375:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.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){for(const e of this.listeners)if(e(t))return!0;return!1}}e.default=o},991:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.default{constructor(t){super(t.notifier,t.localization.undoRedoTool),this.editor=t}onKeyPress({key:t,ctrlKey:e}){if(e){if("z"===t)return this.editor.history.undo(),!0;if("Z"===t)return this.editor.history.redo(),!0}return!1}}e.default=o},1637:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ToolbarShortcutHandler=e.SoundUITool=e.PasteHandler=e.EraserTool=e.SelectAllShortcutHandler=e.SelectionTool=e.TextTool=e.PenTool=e.PanZoomMode=e.PanZoomTool=e.ToolSwitcherShortcut=e.UndoRedoShortcut=e.ToolEnabledGroup=e.ToolController=e.BaseTool=void 0;var r=n(2131);Object.defineProperty(e,"BaseTool",{enumerable:!0,get:function(){return i(r).default}});var o=n(1769);Object.defineProperty(e,"ToolController",{enumerable:!0,get:function(){return i(o).default}});var s=n(2195);Object.defineProperty(e,"ToolEnabledGroup",{enumerable:!0,get:function(){return i(s).default}});var a=n(991);Object.defineProperty(e,"UndoRedoShortcut",{enumerable:!0,get:function(){return i(a).default}});var l=n(8840);Object.defineProperty(e,"ToolSwitcherShortcut",{enumerable:!0,get:function(){return i(l).default}});var c=n(135);Object.defineProperty(e,"PanZoomTool",{enumerable:!0,get:function(){return i(c).default}}),Object.defineProperty(e,"PanZoomMode",{enumerable:!0,get:function(){return c.PanZoomMode}});var d=n(7052);Object.defineProperty(e,"PenTool",{enumerable:!0,get:function(){return i(d).default}});var u=n(2100);Object.defineProperty(e,"TextTool",{enumerable:!0,get:function(){return i(u).default}});var h=n(1626);Object.defineProperty(e,"SelectionTool",{enumerable:!0,get:function(){return i(h).default}});var p=n(6009);Object.defineProperty(e,"SelectAllShortcutHandler",{enumerable:!0,get:function(){return i(p).default}});var f=n(9270);Object.defineProperty(e,"EraserTool",{enumerable:!0,get:function(){return i(f).default}});var m=n(3947);Object.defineProperty(e,"PasteHandler",{enumerable:!0,get:function(){return i(m).default}});var g=n(8838);Object.defineProperty(e,"SoundUITool",{enumerable:!0,get:function(){return i(g).default}});var v=n(2375);Object.defineProperty(e,"ToolbarShortcutHandler",{enumerable:!0,get:function(){return i(v).default}})},318:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolLocalization=void 0,e.defaultToolLocalization={penTool:t=>`Pen ${t}`,selectionTool:"Selection",selectAllTool:"Select all shortcut",eraserTool:"Eraser",touchPanTool:"Touch panning",twoFingerPanZoomTool:"Panning and zooming",undoRedoTool:"Undo/Redo",rightClickDragPanTool:"Right-click drag",pipetteTool:"Pick color from screen",keyboardPanZoom:"Keyboard pan/zoom shortcuts",textTool:"Text",enterTextToInsert:"Text to insert",changeTool:"Change tool",pasteHandler:"Copy paste handler",soundExplorer:"Sound-based image exploration",disableAccessibilityExploreTool:"Disable sound-based exploration",enableAccessibilityExploreTool:"Enable sound-based exploration",findLabel:"Find",toNextMatch:"Next",closeFindDialog:"Close",findDialogShown:"Find dialog shown",findDialogHidden:"Find dialog hidden",focusedFoundText:(t,e)=>`Viewing match ${t} of ${e}`,anyDevicePanning:"Any device panning",copied:(t,e)=>`Copied ${t} ${e}`,pasted:(t,e)=>`Pasted ${t} ${e}`,toolEnabledAnnouncement:t=>`${t} enabled`,toolDisabledAnnouncement:t=>`${t} disabled`}},9699:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UndoEventType=e.EditorEventType=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"}(e.InputEvtType||(e.InputEvtType={})),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.ColorPickerToggled=9]="ColorPickerToggled",t[t.ColorPickerColorSelected=10]="ColorPickerColorSelected",t[t.ToolbarDropdownShown=11]="ToolbarDropdownShown"}(e.EditorEventType||(e.EditorEventType={})),function(t){t[t.CommandDone=0]="CommandDone",t[t.CommandUndone=1]="CommandUndone",t[t.CommandRedone=2]="CommandRedone"}(e.UndoEventType||(e.UndoEventType={}))},246:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertIsNumberArray=e.assertIsNumber=e.assertUnreachable=void 0;e.assertUnreachable=t=>{throw new Error(`Should be unreachable. Key: ${t}.`)};e.assertIsNumber=(t,e=!1)=>{if("number"!=typeof t||!e&&isNaN(t))throw new Error("Given value is not a number");return!0};e.assertIsNumberArray=(t,n=!1)=>{if("object"!=typeof t)throw new Error("Asserting isNumberArray: Given entity is not an array");if(!(0,e.assertIsNumber)(t.length))return!1;for(const i of t)if(!(0,e.assertIsNumber)(i,n))return!1;return!0}},9161:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=new FileReader;return new Promise(((i,r)=>{n.onload=()=>i(n.result),n.onerror=r,n.onabort=r,n.onprogress=t=>{null==e||e(t)},n.readAsDataURL(t)}))}},2822:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=()=>new Promise((t=>{requestAnimationFrame((()=>t()))}))},3732:(t,e,n)=>{"use strict";n.r(e);var i=n(3379),r=n.n(i),o=n(7795),s=n.n(o),a=n(569),l=n.n(a),c=n(3565),d=n.n(c),u=n(9216),h=n.n(u),p=n(4589),f=n.n(p),m=n(4059),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=h();r()(m.Z,g);m.Z&&m.Z.locals&&m.Z.locals;var v=n(7786),y={};y.styleTagTransform=f(),y.setAttributes=d(),y.insert=l().bind(null,"head"),y.domAPI=s(),y.insertStyleElement=h();r()(v.Z,y);v.Z&&v.Z.locals&&v.Z.locals},7629:(t,e)=>{var n,i,r;"undefined"!=typeof self&&self,i=[],void 0===(r="function"==typeof(n=function(){
|
1
|
+
(()=>{var e={7786:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,'.clr-picker {\r\n display: none;\r\n flex-wrap: wrap;\r\n position: absolute;\r\n width: 200px;\r\n z-index: 1000;\r\n border-radius: 10px;\r\n background-color: #fff;\r\n justify-content: flex-end;\r\n direction: ltr;\r\n box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1);\r\n -moz-user-select: none;\r\n -webkit-user-select: none;\r\n user-select: none;\r\n}\r\n\r\n.clr-picker.clr-open,\r\n.clr-picker[data-inline="true"] {\r\n display: flex;\r\n}\r\n\r\n.clr-picker[data-inline="true"] {\r\n position: relative;\r\n}\r\n\r\n.clr-gradient {\r\n position: relative;\r\n width: 100%;\r\n height: 100px;\r\n margin-bottom: 15px;\r\n border-radius: 3px 3px 0 0;\r\n background-image: linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor);\r\n cursor: pointer;\r\n}\r\n\r\n.clr-marker {\r\n position: absolute;\r\n width: 12px;\r\n height: 12px;\r\n margin: -6px 0 0 -6px;\r\n border: 1px solid #fff;\r\n border-radius: 50%;\r\n background-color: currentColor;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-picker input[type="range"]::-webkit-slider-runnable-track {\r\n width: 100%;\r\n height: 8px;\r\n}\r\n\r\n.clr-picker input[type="range"]::-webkit-slider-thumb {\r\n width: 8px;\r\n height: 8px;\r\n -webkit-appearance: none;\r\n}\r\n\r\n.clr-picker input[type="range"]::-moz-range-track {\r\n width: 100%;\r\n height: 8px;\r\n border: 0;\r\n}\r\n\r\n.clr-picker input[type="range"]::-moz-range-thumb {\r\n width: 8px;\r\n height: 8px;\r\n border: 0;\r\n}\r\n\r\n.clr-hue {\r\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%);\r\n}\r\n\r\n.clr-hue,\r\n.clr-alpha {\r\n position: relative;\r\n width: calc(100% - 40px);\r\n height: 8px;\r\n margin: 5px 20px;\r\n border-radius: 4px;\r\n}\r\n\r\n.clr-alpha span {\r\n display: block;\r\n height: 100%;\r\n width: 100%;\r\n border-radius: inherit;\r\n background-image: linear-gradient(90deg, rgba(0,0,0,0), currentColor);\r\n}\r\n\r\n.clr-hue input,\r\n.clr-alpha input {\r\n position: absolute;\r\n width: calc(100% + 16px);\r\n height: 16px;\r\n left: -8px;\r\n top: -4px;\r\n margin: 0;\r\n background-color: transparent;\r\n opacity: 0;\r\n cursor: pointer;\r\n appearance: none;\r\n -webkit-appearance: none;\r\n}\r\n\r\n.clr-hue div,\r\n.clr-alpha div {\r\n position: absolute;\r\n width: 16px;\r\n height: 16px;\r\n left: 0;\r\n top: 50%;\r\n margin-left: -8px;\r\n transform: translateY(-50%);\r\n border: 2px solid #fff;\r\n border-radius: 50%;\r\n background-color: currentColor;\r\n box-shadow: 0 0 1px #888;\r\n pointer-events: none;\r\n}\r\n\r\n.clr-alpha div:before {\r\n content: \'\';\r\n position: absolute;\r\n height: 100%;\r\n width: 100%;\r\n left: 0;\r\n top: 0;\r\n border-radius: 50%;\r\n background-color: currentColor;\r\n}\r\n\r\n.clr-format {\r\n display: none;\r\n order: 1;\r\n width: calc(100% - 40px);\r\n margin: 0 20px 20px;\r\n}\r\n\r\n.clr-segmented {\r\n display: flex;\r\n position: relative;\r\n width: 100%;\r\n margin: 0;\r\n padding: 0;\r\n border: 1px solid #ddd;\r\n border-radius: 15px;\r\n box-sizing: border-box;\r\n color: #999;\r\n font-size: 12px;\r\n}\r\n\r\n.clr-segmented input,\r\n.clr-segmented legend {\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n left: 0;\r\n top: 0;\r\n opacity: 0;\r\n pointer-events: none;\r\n}\r\n\r\n.clr-segmented label {\r\n flex-grow: 1;\r\n margin: 0;\r\n padding: 4px 0;\r\n font-size: inherit;\r\n font-weight: normal;\r\n line-height: initial;\r\n text-align: center;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-segmented label:first-of-type {\r\n border-radius: 10px 0 0 10px;\r\n}\r\n\r\n.clr-segmented label:last-of-type {\r\n border-radius: 0 10px 10px 0;\r\n}\r\n\r\n.clr-segmented input:checked + label {\r\n color: #fff;\r\n background-color: #666;\r\n}\r\n\r\n.clr-swatches {\r\n order: 2;\r\n width: calc(100% - 32px);\r\n margin: 0 16px;\r\n}\r\n\r\n.clr-swatches div {\r\n display: flex;\r\n flex-wrap: wrap;\r\n padding-bottom: 12px;\r\n justify-content: center;\r\n}\r\n\r\n.clr-swatches button {\r\n position: relative;\r\n width: 20px;\r\n height: 20px;\r\n margin: 0 4px 6px 4px;\r\n padding: 0;\r\n border: 0;\r\n border-radius: 50%;\r\n color: inherit;\r\n text-indent: -1000px;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-swatches button:after {\r\n content: \'\';\r\n display: block;\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n left: 0;\r\n top: 0;\r\n border-radius: inherit;\r\n background-color: currentColor;\r\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\r\n}\r\n\r\ninput.clr-color {\r\n order: 1;\r\n width: calc(100% - 80px);\r\n height: 32px;\r\n margin: 15px 20px 20px auto;\r\n padding: 0 10px;\r\n border: 1px solid #ddd;\r\n border-radius: 16px;\r\n color: #444;\r\n background-color: #fff;\r\n font-family: sans-serif;\r\n font-size: 14px;\r\n text-align: center;\r\n box-shadow: none;\r\n}\r\n\r\ninput.clr-color:focus {\r\n outline: none;\r\n border: 1px solid #1e90ff;\r\n}\r\n\r\n.clr-close,\r\n.clr-clear {\r\n display: none;\r\n order: 2;\r\n height: 24px;\r\n margin: 0 20px 20px;\r\n padding: 0 20px;\r\n border: 0;\r\n border-radius: 12px;\r\n color: #fff;\r\n background-color: #666;\r\n font-family: inherit;\r\n font-size: 12px;\r\n font-weight: 400;\r\n cursor: pointer;\r\n}\r\n\r\n.clr-close {\r\n display: block;\r\n margin: 0 20px 20px auto;\r\n}\r\n\r\n.clr-preview {\r\n position: relative;\r\n width: 32px;\r\n height: 32px;\r\n margin: 15px 0 20px 20px;\r\n border-radius: 50%;\r\n overflow: hidden;\r\n}\r\n\r\n.clr-preview:before,\r\n.clr-preview:after {\r\n content: \'\';\r\n position: absolute;\r\n height: 100%;\r\n width: 100%;\r\n left: 0;\r\n top: 0;\r\n border: 1px solid #fff;\r\n border-radius: 50%;\r\n}\r\n\r\n.clr-preview:after {\r\n border: 0;\r\n background-color: currentColor;\r\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\r\n}\r\n\r\n.clr-preview button {\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n z-index: 1;\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n border-radius: 50%;\r\n outline-offset: -2px;\r\n background-color: transparent;\r\n text-indent: -9999px;\r\n cursor: pointer;\r\n overflow: hidden;\r\n}\r\n\r\n.clr-marker,\r\n.clr-hue div,\r\n.clr-alpha div,\r\n.clr-color {\r\n box-sizing: border-box;\r\n}\r\n\r\n.clr-field {\r\n display: inline-block;\r\n position: relative;\r\n color: transparent;\r\n}\r\n\r\n.clr-field input {\r\n margin: 0;\r\n direction: ltr;\r\n}\r\n\r\n.clr-field.clr-rtl input {\r\n text-align: right;\r\n}\r\n\r\n.clr-field button {\r\n position: absolute;\r\n width: 30px;\r\n height: 100%;\r\n right: 0;\r\n top: 50%;\r\n transform: translateY(-50%);\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n color: inherit;\r\n text-indent: -1000px;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n pointer-events: none;\r\n}\r\n\r\n.clr-field.clr-rtl button {\r\n right: auto;\r\n left: 0;\r\n}\r\n\r\n.clr-field button:after {\r\n content: \'\';\r\n display: block;\r\n position: absolute;\r\n width: 100%;\r\n height: 100%;\r\n left: 0;\r\n top: 0;\r\n border-radius: inherit;\r\n background-color: currentColor;\r\n box-shadow: inset 0 0 1px rgba(0,0,0,.5);\r\n}\r\n\r\n.clr-alpha,\r\n.clr-alpha div,\r\n.clr-swatches button,\r\n.clr-preview:before,\r\n.clr-field button {\r\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);\r\n background-position: 0 0, 4px 4px;\r\n background-size: 8px 8px;\r\n}\r\n\r\n.clr-marker:focus {\r\n outline: none;\r\n}\r\n\r\n.clr-keyboard-nav .clr-marker:focus,\r\n.clr-keyboard-nav .clr-hue input:focus + div,\r\n.clr-keyboard-nav .clr-alpha input:focus + div,\r\n.clr-keyboard-nav .clr-segmented input:focus + label {\r\n outline: none;\r\n box-shadow: 0 0 0 2px #1e90ff, 0 0 2px 2px #fff;\r\n}\r\n\r\n.clr-picker[data-alpha="false"] .clr-alpha {\r\n display: none;\r\n}\r\n\r\n.clr-picker[data-minimal="true"] {\r\n padding-top: 16px;\r\n}\r\n\r\n.clr-picker[data-minimal="true"] .clr-gradient,\r\n.clr-picker[data-minimal="true"] .clr-hue,\r\n.clr-picker[data-minimal="true"] .clr-alpha,\r\n.clr-picker[data-minimal="true"] .clr-color,\r\n.clr-picker[data-minimal="true"] .clr-preview {\r\n display: none;\r\n}\r\n\r\n/** Dark theme **/\r\n\r\n.clr-dark {\r\n background-color: #444;\r\n}\r\n\r\n.clr-dark .clr-segmented {\r\n border-color: #777;\r\n}\r\n\r\n.clr-dark .clr-swatches button:after {\r\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);\r\n}\r\n\r\n.clr-dark input.clr-color {\r\n color: #fff;\r\n border-color: #777;\r\n background-color: #555;\r\n}\r\n\r\n.clr-dark input.clr-color:focus {\r\n border-color: #1e90ff;\r\n}\r\n\r\n.clr-dark .clr-preview:after {\r\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);\r\n}\r\n\r\n.clr-dark .clr-alpha,\r\n.clr-dark .clr-alpha div,\r\n.clr-dark .clr-swatches button,\r\n.clr-dark .clr-preview:before {\r\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);\r\n}\r\n\r\n/** Polaroid theme **/\r\n\r\n.clr-picker.clr-polaroid {\r\n border-radius: 6px;\r\n box-shadow: 0 0 5px rgba(0,0,0,.1), 0 5px 30px rgba(0,0,0,.2);\r\n}\r\n\r\n.clr-picker.clr-polaroid:before {\r\n content: \'\';\r\n display: block;\r\n position: absolute;\r\n width: 16px;\r\n height: 10px;\r\n left: 20px;\r\n top: -10px;\r\n border: solid transparent;\r\n border-width: 0 8px 10px 8px;\r\n border-bottom-color: currentColor;\r\n box-sizing: border-box;\r\n color: #fff;\r\n filter: drop-shadow(0 -4px 3px rgba(0,0,0,.1));\r\n pointer-events: none;\r\n}\r\n\r\n.clr-picker.clr-polaroid.clr-dark:before {\r\n color: #444;\r\n}\r\n\r\n.clr-picker.clr-polaroid.clr-left:before {\r\n left: auto;\r\n right: 20px;\r\n}\r\n\r\n.clr-picker.clr-polaroid.clr-top:before {\r\n top: auto;\r\n bottom: -10px;\r\n transform: rotateZ(180deg);\r\n}\r\n\r\n.clr-polaroid .clr-gradient {\r\n width: calc(100% - 20px);\r\n height: 120px;\r\n margin: 10px;\r\n border-radius: 3px;\r\n}\r\n\r\n.clr-polaroid .clr-hue,\r\n.clr-polaroid .clr-alpha {\r\n width: calc(100% - 30px);\r\n height: 10px;\r\n margin: 6px 15px;\r\n border-radius: 5px;\r\n}\r\n\r\n.clr-polaroid .clr-hue div,\r\n.clr-polaroid .clr-alpha div {\r\n box-shadow: 0 0 5px rgba(0,0,0,.2);\r\n}\r\n\r\n.clr-polaroid .clr-format {\r\n width: calc(100% - 20px);\r\n margin: 0 10px 15px;\r\n}\r\n\r\n.clr-polaroid .clr-swatches {\r\n width: calc(100% - 12px);\r\n margin: 0 6px;\r\n}\r\n.clr-polaroid .clr-swatches div {\r\n padding-bottom: 10px;\r\n}\r\n\r\n.clr-polaroid .clr-swatches button {\r\n width: 22px;\r\n height: 22px;\r\n}\r\n\r\n.clr-polaroid input.clr-color {\r\n width: calc(100% - 60px);\r\n margin: 10px 10px 15px auto;\r\n}\r\n\r\n.clr-polaroid .clr-clear {\r\n margin: 0 10px 15px 10px;\r\n}\r\n\r\n.clr-polaroid .clr-close {\r\n margin: 0 10px 15px auto;\r\n}\r\n\r\n.clr-polaroid .clr-preview {\r\n margin: 10px 0 15px 10px;\r\n}\r\n\r\n/** Large theme **/\r\n\r\n.clr-picker.clr-large {\r\n width: 275px;\r\n}\r\n\r\n.clr-large .clr-gradient {\r\n height: 150px;\r\n}\r\n\r\n.clr-large .clr-swatches button {\r\n width: 22px;\r\n height: 22px;\r\n}\r\n\r\n/** Pill (horizontal) theme **/\r\n\r\n.clr-picker.clr-pill {\r\n width: 380px;\r\n padding-left: 180px;\r\n box-sizing: border-box;\r\n}\r\n\r\n.clr-pill .clr-gradient {\r\n position: absolute;\r\n width: 180px;\r\n height: 100%;\r\n left: 0;\r\n top: 0;\r\n margin-bottom: 0;\r\n border-radius: 3px 0 0 3px;\r\n}\r\n\r\n.clr-pill .clr-hue {\r\n margin-top: 20px;\r\n}',""]);const a=s},3521:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,'\n/* Imports Coloris\' CSS and makes additional changes to the color picker */\n\n#clr-picker {\n --clr-slider-size: 30px;\n}\n\n/* Coloris: Try to avoid scrolling instead of updating the color input. */\n#clr-picker #clr-color-area, #clr-picker .clr_hue {\n\ttouch-action: none;\n}\n\n/* Increase space between inputs */\n#clr-picker .clr-alpha {\n\tmargin-top: 15px;\n\tmargin-bottom: 15px;\n}\n\n/* Increase size of input thumb to make it easier to select colors. */\n#clr-picker.clr-picker input[type="range"]::-moz-range-thumb {\n\twidth: var(--clr-slider-size);\n\theight: var(--clr-slider-size);\n}\n\n/* Also apply to Chrome/iOS */\n#clr-picker.clr-picker input[type="range"]::-webkit-slider-thumb {\n /*\n Note: This doesn\'t seem to take effect in iOS if it\'s combined with the\n ::-moz-range-thumb rule above\n */\n\twidth: var(--clr-slider-size);\n\theight: var(--clr-slider-size);\n}\n\n#clr-picker.clr-picker input[type="range"]::-webkit-slider-runnable-track {\n\theight: var(--clr-slider-size);\n}\n\n#clr-picker.clr-picker input[type="range"]::-moz-range-track {\n\theight: var(--clr-slider-size);\n}\n\n/*\nDebugging: Uncommenting this rule makes Coloris\' sliders more\nvisible.\n\n#clr-picker.clr-picker input[type="range"] {\n opacity: 0.5;\n -webkit-appearance: auto;\n appearance: auto;\n}\n*/\n',""]);const a=s},4059:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o),a=n(7771),l=n(1443),c=n(3521),d=s()(r());d.i(a.Z),d.i(l.Z),d.i(c.Z),d.push([t.id,"\n.imageEditorContainer {\n\t/* Deafult colors for the editor */\n --primary-background-color: white;\n --primary-background-color-transparent: rgba(255, 255, 255, 0.5);\n --secondary-background-color: #faf;\n --primary-foreground-color: black;\n --secondary-foreground-color: black;\n\t--primary-shadow-color: rgba(0, 0, 0, 0.5);\n}\n\n@media (prefers-color-scheme: dark) {\n\t.imageEditorContainer {\n\t\t--primary-background-color: #151515;\n\t\t--primary-background-color-transparent: rgba(50, 50, 50, 0.5);\n\t\t--secondary-background-color: #607;\n\t\t--primary-foreground-color: white;\n\t\t--secondary-foreground-color: white;\n\t\t--primary-shadow-color: rgba(250, 250, 250, 0.5);\n\t}\n}\n\n.imageEditorContainer {\n\tcolor: var(--primary-foreground-color);\n\tfont-family: system-ui, -apple-system, sans-serif;\n\tbackground-color: var(--primary-background-color);\n\n\tdisplay: flex;\n\tflex-direction: column-reverse;\n}\n\n.imageEditorContainer .imageEditorRenderArea {\n\tdisplay: grid;\n\tgrid-template-columns: 1fr;\n\tflex-grow: 2;\n\tflex-shrink: 1;\n\tmin-height: 100px;\n}\n\n.imageEditorContainer .imageEditorRenderArea canvas {\n\t/* Stack all canvases on top of each other */\n\tgrid-row: 1 / 1;\n\tgrid-column: 1 / 1;\n\ttouch-action: none;\n\n\t/* Fill the container */\n\tbox-sizing: border-box;\n\twidth: 100%;\n\theight: 100%;\n\n\t/* Allow the canvas to shrink (needed in Chrome) */\n\tmin-height: 0px;\n\tmax-height: inherit;\n}\n\n.imageEditorContainer .loadingMessage {\n\tposition: fixed;\n\ttext-align: center;\n\tfont-size: 2em;\n\n\tbottom: 0;\n\tleft: 0;\n\tright: 0;\n}\n\n.imageEditorContainer .accessibilityAnnouncement {\n\topacity: 0;\n\twidth: 0;\n\theight: 0;\n\toverflow: hidden;\n\tpointer-events: none;\n}\n\n.imageEditorContainer .textRendererOutputContainer {\n\twidth: 1px;\n\theight: 1px;\n\toverflow: hidden;\n}\n\n.imageEditorContainer .textRendererOutputContainer:focus-within {\n\toverflow: visible;\n\tz-index: 5;\n}\n\n@media print {\n\t.imageEditorContainer .loadingMessage {\n\t\tdisplay: none;\n\t}\n\n\t.imageEditorContainer .imageEditorRenderArea canvas {\n\t\twidth: 100%;\n\t\theight: initial;\n\t}\n}",""]);const u=d},7771:(t,e,n)=>{"use strict";n.d(e,{Z:()=>d});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o),a=n(6350),l=n(519),c=s()(r());c.i(a.Z),c.i(l.Z),c.push([t.id,".toolbar-root {\n\tbackground-color: var(--primary-background-color);\n\t--icon-color: var(--primary-foreground-color);\n\n\n\tborder: 1px solid var(--secondary-background-color);\n\tborder-radius: 2px;\n\tflex-wrap: wrap;\n\n\tbox-sizing: border-box;\n\twidth: 100%;\n\n\tdisplay: flex;\n\tflex-direction: row;\n\tjustify-content: center;\n\n\t--toolbar-button-height: min(20vh, 60px);\n\n\t/* Display above selection dialogs, etc. */\n\tz-index: 2;\n\n\tfont-family: system-ui, -apple-system, sans-serif;\n}\n\n.toolbar-root > .toolbar-toolContainer > .toolbar-button,\n.toolbar-root > .toolbar-toolContainer > * > button,\n.toolbar-root > .toolbar-buttonGroup > button,\n.toolbar-root > .toolbar-button {\n\twidth: min-content;\n\twhite-space: pre;\n\theight: var(--toolbar-button-height);\n}\n\n.toolbar-dropdown .toolbar-button > .toolbar-icon {\n\tmax-width: 50px;\n\twidth: 100%;\n}\n\n.toolbar-button.disabled {\n\tfilter: opacity(0.5) sepia(0.2);\n\tcursor: unset;\n}\n\n.toolbar-button, .toolbar-root button {\n\tcursor: pointer;\n\ttext-align: center;\n\tborder-radius: 6px;\n\n\t--icon-color: var(--primary-foreground-color);\n\tbackground-color: var(--primary-background-color);\n\tcolor: var(--primary-foreground-color);\n\tborder: none;\n\tbox-shadow: 0px 0px 2px var(--primary-shadow-color);\n\n\ttransition: background-color 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease;\n}\n\n.toolbar-button,\n.toolbar-buttonGroup > button,\n.toolbar-toolContainer > * > button,\n.toolbar-root > button {\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\n\tpadding-left: 3px;\n\tpadding-right: 3px;\n\tmargin-left: 3px;\n\tmargin-right: 3px;\n\n\tmin-width: 40px;\n\tmax-width: 105px;\n\twidth: min-content;\n\tfont-size: 1em;\n}\n\n.toolbar-button > label {\n\tcursor: inherit;\n}\n\n/* Decrease the font size of labels in the main toolbar if they're long. */\n:not(.toolbar-dropdown) > .toolbar-toolContainer >\n\t\t.toolbar-button > label.long-label {\n\tfont-size: 0.75em;\n}\n\n.toolbar-dropdown > .toolbar-toolContainer > button,\n.toolbar-dropdown > .toolbar-toolContainer > .toolbar-button {\n\twidth: 6em;\n}\n\n.toolbar-button:not(.disabled):hover, .toolbar-root button:not(:disabled):hover {\n\tbox-shadow: 0px 2px 4px var(--primary-shadow-color);\n}\n\n.toolbar-root button:disabled {\n\tcursor: inherit;\n\tfilter: opacity(0.5);\n}\n\n.toolbar-root .toolbar-icon {\n\tflex-shrink: 1;\n\n\twidth: 100%;\n\tmin-width: 30px;\n\tmin-height: 30px;\n}\n\n.toolbar-toolContainer.selected > .toolbar-button {\n\tbackground-color: var(--secondary-background-color);\n\tcolor: var(--secondary-foreground-color);\n\t--icon-color: var(--secondary-foreground-color);\n}\n\n.toolbar-toolContainer:not(.selected):not(.dropdownShowable) > .toolbar-button > .toolbar-showHideDropdownIcon {\n\tdisplay: none;\n}\n\n.toolbar-toolContainer > .toolbar-button > .toolbar-showHideDropdownIcon {\n\theight: 10px;\n\ttransition: transform 0.5s ease;\n}\n\n.toolbar-toolContainer.dropdownVisible > .toolbar-button > .toolbar-showHideDropdownIcon {\n\ttransform: rotate(180deg);\n}\n\n.toolbar-dropdown.hidden,\n.toolbar-toolContainer:not(.selected):not(.dropdownShowable) > .toolbar-dropdown {\n\tdisplay: none;\n}\n\n.toolbar-dropdown {\n\tposition: absolute;\n\tpadding: 15px;\n\tpadding-top: 5px;\n\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tflex-direction: column;\n\tmax-height: 80vh;\n\n\tmax-width: fit-content;\n\n\t/* Prevent overlap/being displayed under the undo/redo buttons */\n\tz-index: 2;\n\tbackground-color: var(--primary-background-color);\n\tbox-shadow: 0px 3px 3px var(--primary-shadow-color);\n}\n\n.toolbar-buttonGroup {\n\tdisplay: flex;\n\tflex-direction: row;\n\tjustify-content: center;\n}\n\n.toolbar-closeColorPickerOverlay {\n\tdisplay: none;\n\tposition: fixed;\n\ttop: 0;\n\tleft: 0;\n\tbottom: 0;\n\tright: 0;\n\n\ttouch-action: none;\n\n\tbackground-color: var(--primary-background-color);\n\topacity: 0.3;\n}\n\n/* Make color selection buttons fill their containing label */\n.toolbar-dropdown .clr-field button {\n\twidth: 100%;\n\theight: 100%;\n\tborder-radius: 2px;\n\tmargin-left: 0;\n\tmargin-right: 0;\n}\n\n.toolbar-root .toolbar-zoomLevelEditor {\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.toolbar-root .toolbar-zoomLevelEditor .zoomDisplay {\n\tflex-grow: 1;\n}\n\n.toolbar-root .toolbar-zoomLevelEditor button {\n\tmin-width: 48px;\n}\n\n.color-input-container {\n\tdisplay: inline-flex;\n\tflex-direction: row;\n}\n\n.color-input-container .pipetteButton {\n\twidth: 30px;\n\theight: 30px;\n\tpadding: 0;\n\tdisplay: inline-flex;\n}\n\n.color-input-container .pipetteButton > svg {\n\twidth: 100%;\n}\n\n.color-input-container .pipetteButton.active {\n\tbackground-color: var(--secondary-background-color);\n\t--icon-color: var(--secondary-foreground-color);\n}\n\n.toolbar-spacedList > * {\n\tpadding-bottom: 5px;\n\tpadding-top: 5px;\n}\n\n@media print {\n\t/* Hide the toolbar on print. */\n\t.toolbar-root {\n\t\tdisplay: none;\n\t}\n}",""]);const d=c},6350:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.toolbar-image-selection-overlay {\n\tposition: absolute;\n\n\twidth: 100%;\n\theight: 100%;\n\tz-index: 10;\n\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.toolbar-image-selection-overlay > div {\n\tbackground: var(--primary-background-color);\n\tbox-shadow: 1px 1px 3px var(--primary-shadow-color);\n\n\tpadding: 18px;\n\tborder-radius: 3px;\n}\n\n.toolbar-image-selection-overlay > div > div {\n\tpadding: 5px;\n}\n\n.toolbar-image-selection-overlay img {\n\tmax-width: min(50vw, 75%);\n\tmax-height: 50vh;\n\n\t/* Center */\n\tdisplay: block;\n\tmargin-left: auto;\n\tmargin-right: auto;\n}\n\n.toolbar-image-selection-overlay .action-button-row {\n\tmargin-top: 4px;\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.toolbar-image-selection-overlay .action-button-row > button {\n\tflex-grow: 1;\n}",""]);const a=s},519:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.toolbar-overflow-widget-overflow-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\tflex-wrap: wrap;\n\tjustify-content: center;\n}\n\n.toolbar-overflow-widget-overflow-list > .toolbar-toolContainer > .toolbar-button {\n\theight: var(--toolbar-button-height);\n}\n\n.toolbar-overflow-widget.horizontal .toolbar-overflow-widget-overflow-list {\n\tflex-direction: row;\n}\n\n.toolbar-overflow-widget.horizontal > .toolbar-dropdown {\n\tmax-width: 100%;\n\tleft: 15px;\n\tright: 15px;\n\n\t/* Override the default transform and margin-left */\n\tmargin-left: 0 !important;\n\ttransform: none !important;\n\n\tpadding: 4px;\n}",""]);const a=s},3324:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.find-tool-overlay {\n /* Show at the bottom of the screen. */\n order: -1;\n\n position: absolute;\n}",""]);const a=s},6611:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.selection-tool-selection-background {\n background-color: var(--secondary-background-color);\n opacity: 0.5;\n overflow: visible;\n position: absolute;\n}\n\n.selection-tool-handle {\n border: 1px solid var(--primary-foreground-color);\n background: var(--primary-background-color);\n position: absolute;\n cursor: grab;\n}\n\n.selection-tool-handle.selection-tool-circle {\n border-radius: 100%;\n}\n\n.overlay.handleOverlay {\n height: 0;\n overflow: visible;\n}",""]);const a=s},7034:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o)()(r());s.push([t.id,"\n.js-draw-sound-ui-toggle {\n\twidth: 0px;\n\theight: 0px;\n\toverflow: hidden; \n}\n\n.js-draw-sound-ui-toggle:focus-within, .js-draw-sound-ui-toggle.sound-ui-tool-enabled {\n\toverflow: visible;\n\tz-index: 5;\n}\n\n.js-draw-sound-ui-toggle:not(:focus-within):not(:hover).sound-ui-tool-enabled {\n\topacity: 0.5;\n}\n",""]);const a=s},1443:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(8081),r=n.n(i),o=n(3645),s=n.n(o),a=n(6611),l=n(3324),c=n(7034),d=s()(r());d.i(a.Z),d.i(l.Z),d.i(c.Z),d.push([t.id,"",""]);const u=d},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,r,o){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)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]);i&&s[d[0]]||(void 0!==o&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=o),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),r&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=r):d[4]="".concat(r)),e.push(d))}},e}},8081:t=>{"use strict";t.exports=function(t){return t[1]}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var o={},s=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],d=o[c]||0,u="".concat(c," ").concat(d);o[c]=d+1;var h=n(u),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var f=r(p,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:f,references:1})}s.push(u)}return s}function r(t,e){var n=e.domAPI(e);n.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,r){var o=i(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<o.length;s++){var a=n(o[s]);e[a].references--}for(var l=i(t,r),c=0;c<o.length;c++){var d=n(o[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,r&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589: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))}}},8233:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Color4=void 0;const r=i(n(3785));class o{constructor(t,e,n,i){this.r=t,this.g=e,this.b=n,this.a=i,this.hexString=null}static ofRGB(t,e,n){return o.ofRGBA(t,e,n,1)}static ofRGBA(t,e,n,i){return t=Math.max(0,Math.min(t,1)),e=Math.max(0,Math.min(e,1)),n=Math.max(0,Math.min(n,1)),i=Math.max(0,Math.min(i,1)),new o(t,e,n,i)}static fromHex(t){var e;if(!(t=(t=(null!==(e=t.match(/^[#]?(.*)$/))&&void 0!==e?e:[])[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 n=[];for(let e=2;e<=t.length;e+=2){const i=t.substring(e-2,e);n.push(parseInt(i,16)/255)}if(4!==n.length)throw new Error(`Unable to parse ${t}: Wrong number of components.`);return o.ofRGBA(n[0],n[1],n[2],n[3])}static fromString(t){if(t.startsWith("#"))return o.fromHex(t);if("none"===t||"transparent"===t)return o.transparent;const e=t.replace(/\s*/g,"").match(/^rgba?\(([,0-9.]+)\)$/i);if(e){const n=e[1],i=JSON.parse(`[ ${n} ]`);if(3===i.length)return o.ofRGB(i[0]/255,i[1]/255,i[2]/255);if(4===i.length)return o.ofRGBA(i[0]/255,i[1]/255,i[2]/255,i[3]);throw new Error(`RGB string, ${t}, has wrong number of components: ${i.length}`)}const n=document.createElement("canvas");n.width=1,n.height=1;const i=n.getContext("2d");i.fillStyle=t,i.fillRect(0,0,1,1);const r=i.getImageData(0,0,1,1),s=r.data[0]/255,a=r.data[1]/255,l=r.data[2]/255,c=r.data[3]/255;return o.ofRGBA(s,a,l,c)}eq(t){return null!=t&&(0===this.a&&0===t.a||this.toHexString()===t.toHexString())}mix(t,e){const n=1-(e=Math.min(Math.max(e,0),1));return new o(this.r*n+t.r*e,this.g*n+t.g*e,this.b*n+t.b*e,this.a*n+t.a*e)}static average(t){let e=0,n=0,i=0,r=0;for(const o of t)e+=o.a,n+=o.r,i+=o.g,r+=o.b;return t.length>0&&(e/=t.length,n/=t.length,i/=t.length,r/=t.length),new o(n,i,r,e)}asHSV(){const t=Math.min(this.r,this.g,this.b),e=Math.max(this.r,this.g,this.b),n=e-t;let i;i=0===n?0:this.r>=this.g&&this.r>=this.b?(this.g-this.b)/n%6:this.g>=this.r&&this.g>=this.b?(this.b-this.r)/n+2:(this.r-this.g)/n+4,i*=60,i*=Math.PI/180,i<0&&(i+=2*Math.PI);const o=e,s=o>0?n/o:0;return r.default.of(i,s,o)}toHexString(){if(this.hexString)return this.hexString;const t=t=>{const e=Math.round(255*t).toString(16);return 1===e.length?`0${e}`:e},e=t(this.a),n=t(this.r),i=t(this.g),r=t(this.b);return"ff"===e?`#${n}${i}${r}`:(this.hexString=`#${n}${i}${r}${e}`,this.hexString)}toString(){return this.toHexString()}}o.transparent=o.ofRGBA(0,0,0,0),o.red=o.ofRGB(1,0,0),o.green=o.ofRGB(0,1,0),o.blue=o.ofRGB(0,0,1),o.purple=o.ofRGB(.5,.2,.5),o.yellow=o.ofRGB(1,1,.1),o.clay=o.ofRGB(.8,.4,.2),o.black=o.ofRGB(0,0,0),o.gray=o.ofRGB(.5,.5,.5),o.white=o.ofRGB(1,1,1),e.default=o,e.Color4=o},169:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},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(n(4721)),c=a(n(1769)),d=n(9699),u=a(n(5467)),h=a(n(8831)),p=a(n(5559)),f=n(6750),m=a(n(3785)),g=a(n(7389)),v=o(n(5860)),y=a(n(9563)),b=a(n(8233)),x=a(n(8684)),w=a(n(306)),T=a(n(2054)),S=a(n(7282)),C=a(n(5818)),P=n(1520),k=a(n(972)),E=a(n(2822)),z=a(n(9161)),_=a(n(3966)),O=a(n(1626)),M=a(n(529)),B=o(n(7520)),I=a(n(6485));class R{constructor(t,e={}){var n,i,r,o,s;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.localization=Object.assign(Object.assign({},(0,S.default)()),e.localization),this.settings={wheelEventsEnabled:null===(n=e.wheelEventsEnabled)||void 0===n||n,renderingMode:null!==(i=e.renderingMode)&&void 0!==i?i:v.RenderingMode.CanvasRenderer,localization:this.localization,minZoom:null!==(r=e.minZoom)&&void 0!==r?r:2e-10,maxZoom:null!==(o=e.maxZoom)&&void 0!==o?o:1e12,iconProvider:null!==(s=e.iconProvider)&&void 0!==s?s:new C.default},this.icons=this.settings.iconProvider,this.container=document.createElement("div"),this.renderingRegion=document.createElement("div"),this.container.appendChild(this.renderingRegion),this.container.className="imageEditorContainer",this.loadingWarning=document.createElement("div"),this.loadingWarning.classList.add("loadingMessage"),this.loadingWarning.ariaLive="polite",this.container.appendChild(this.loadingWarning),this.accessibilityControlArea=document.createElement("textarea"),this.accessibilityControlArea.setAttribute("placeholder",this.localization.accessibilityInputInstructions),this.accessibilityControlArea.style.opacity="0",this.accessibilityControlArea.style.width="0",this.accessibilityControlArea.style.height="0",this.accessibilityControlArea.style.position="absolute",this.accessibilityAnnounceArea=document.createElement("div"),this.accessibilityAnnounceArea.setAttribute("aria-live","assertive"),this.accessibilityAnnounceArea.className="accessibilityAnnouncement",this.container.appendChild(this.accessibilityAnnounceArea),this.renderingRegion.style.touchAction="none",this.renderingRegion.className="imageEditorRenderArea",this.renderingRegion.appendChild(this.accessibilityControlArea),this.renderingRegion.setAttribute("tabIndex","0"),this.renderingRegion.setAttribute("alt",""),this.notifier=new p.default,this.viewport=new h.default(((t,e)=>{this.notifier.dispatch(d.EditorEventType.ViewportChanged,{kind:d.EditorEventType.ViewportChanged,newTransform:e,oldTransform:t})})),this.display=new v.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),t.appendChild(this.container),this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.registerListeners(),this.queueRerender(),this.hideLoadingWarning(),this.notifier.on(d.EditorEventType.ViewportChanged,(t=>{if(t.kind===d.EditorEventType.ViewportChanged){const e=t.newTransform.transformVec3(f.Vec2.unitX).length();if(e>this.settings.maxZoom||e<this.settings.minZoom){const e=t.oldTransform.transformVec3(f.Vec2.unitX).length();let n=T.default.identity;e<=this.settings.maxZoom&&e>=this.settings.minZoom&&(n=t.oldTransform),this.viewport.resetTransform(n)}}}))}getRootElement(){return this.container}showLoadingWarning(t){const e=Math.round(100*t);this.loadingWarning.innerText=this.localization.loading(e),this.loadingWarning.style.display="block"}hideLoadingWarning(){this.loadingWarning.style.display="none",this.announceForAccessibility(this.localization.doneLoading)}announceForAccessibility(t){t===this.previousAccessibilityAnnouncement&&(t+=". "),this.accessibilityAnnounceArea.innerText=t,this.previousAccessibilityAnnouncement=t}addToolbar(t=!0){const e=new g.default(this,this.container,this.localization);return t&&e.addDefaults(),e}registerListeners(){this.handlePointerEventsFrom(this.renderingRegion),this.handleKeyEventsFrom(this.renderingRegion),this.container.addEventListener("wheel",(t=>{let e=m.default.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.default.of(0,0,t.deltaY));const n=this.renderingRegion.getBoundingClientRect(),i=f.Vec2.of(t.clientX,t.clientY).minus(f.Vec2.of(n.left,n.top));return!!this.toolController.dispatchInputEvent({kind:d.InputEvtType.WheelEvt,delta:e,screenPos:i})&&(t.preventDefault(),!0)})),this.notifier.on(d.EditorEventType.DisplayResized,(t=>{this.viewport.updateScreenSize(f.Vec2.of(this.display.width,this.display.height)),this.queueRerender()}));const t=()=>{this.notifier.dispatch(d.EditorEventType.DisplayResized,{kind:d.EditorEventType.DisplayResized,newSize:f.Vec2.of(this.display.width,this.display.height)})};if("ResizeObserver"in window){new ResizeObserver(t).observe(this.container)}else addEventListener("resize",t);this.accessibilityControlArea.addEventListener("input",(()=>{this.accessibilityControlArea.value=""})),document.addEventListener("copy",(t=>{if(!this.isEventSink(document.querySelector(":focus")))return;const e=t.clipboardData;this.toolController.dispatchInputEvent({kind:d.InputEvtType.CopyEvent,setData:(t,n)=>{null==e||e.setData(t,n)}})&&t.preventDefault()})),document.addEventListener("paste",(t=>{this.handlePaste(t)}))}getPointerList(){const t=(new Date).getTime(),e=[];for(const n in this.pointers){const i=2e3;this.pointers[n]&&t-this.pointers[n].timeStamp<i&&e.push(this.pointers[n])}return e}handleHTMLPointerEvent(t,e){var n,i,r;const o=this.renderingRegion,s=null!==(n=e.target)&&void 0!==n?n:this.renderingRegion;if("pointerdown"===t){const t=w.default.ofEvent(e,!0,this.viewport,o);this.pointers[t.id]=t,s.setPointerCapture(t.id);const n={kind:d.InputEvtType.PointerDownEvt,current:t,allPointers:this.getPointerList()};return this.toolController.dispatchInputEvent(n),!0}if("pointermove"===t){const t=w.default.ofEvent(e,null!==(r=null===(i=this.pointers[e.pointerId])||void 0===i?void 0:i.down)&&void 0!==r&&r,this.viewport,o);if(t.down){const n=this.pointers[t.id];if(n){if(t.screenPos.minus(n.screenPos).magnitude()<2)return!1}this.pointers[t.id]=t,this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerMoveEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault()}return!0}if("pointercancel"===t||"pointerup"===t){const t=w.default.ofEvent(e,!1,this.viewport,o);return!!this.pointers[t.id]&&(this.pointers[t.id]=t,s.releasePointerCapture(t.id),this.toolController.dispatchInputEvent({kind:d.InputEvtType.PointerUpEvt,current:t,allPointers:this.getPointerList()})&&e.preventDefault(),delete this.pointers[t.id],!0)}return t}isEventSink(t){let e=t;for(;null!==e;){for(const t of this.eventListenerTargets)if(t===e)return!0;e=e.parentElement}return!1}handlePaste(t){var e,n;return s(this,void 0,void 0,(function*(){const i=null!==(e=document.querySelector(":focus"))&&void 0!==e?e:t.target;if(!this.isEventSink(i))return;const r=null!==(n=t.dataTransfer)&&void 0!==n?n:t.clipboardData;if(!r)return;for(const e of r.files)if("image/svg+xml"===e.type.toLowerCase()){const n=yield e.text();if(this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e.type,data:n}))return void t.preventDefault()}for(const e of r.files){const n=e.type.toLowerCase();if("image/png"===n||"image/jpg"===n){this.showLoadingWarning(0);const i=t=>{this.showLoadingWarning(t.loaded/t.total)};try{const r=yield(0,z.default)(e,i);if(r&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:n,data:r}))return t.preventDefault(),void this.hideLoadingWarning()}catch(t){console.error("Error reading image:",t)}this.hideLoadingWarning()}}const o=["image/svg+xml","text/plain"];for(const e of o){const n=r.getData(e);if(n&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:e,data:n}))return void t.preventDefault()}}))}handlePointerEventsFrom(t,e){const n={touchstart:t=>t.preventDefault(),contextmenu:t=>{t.preventDefault()}},i=["pointerdown","pointermove","pointerup","pointercancel"];for(const t of i)n[t]=n=>{const i=n;return!(!e||e(t,i))||this.handleHTMLPointerEvent(t,i)};for(const e in n)t.addEventListener(e,n[e]);return{remove:()=>{for(const e in n)t.removeEventListener(e,n[e])}}}handleKeyEventsFrom(t){t.addEventListener("keydown",(t=>{"t"===t.key||"T"===t.key?(t.preventDefault(),this.display.rerenderAsText()):this.toolController.dispatchInputEvent({kind:d.InputEvtType.KeyPressEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})?t.preventDefault():"Escape"===t.key&&this.renderingRegion.blur()})),t.addEventListener("keyup",(t=>{this.toolController.dispatchInputEvent({kind:d.InputEvtType.KeyUpEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})&&t.preventDefault()})),t.ondragover=t=>{t.preventDefault()},t.ondrop=t=>{t.preventDefault(),this.handlePaste(t)},this.eventListenerTargets.push(t)}dispatch(t,e=!0){const n=this.dispatchNoAnnounce(t,e);return this.announceForAccessibility(t.description(this,this.localization)),n}dispatchNoAnnounce(t,e=!1){const n=t.apply(this);if(e){const e=!1;this.history.push(t,e)}return n}asyncApplyOrUnapplyCommands(t,e,n){return s(this,void 0,void 0,(function*(){console.assert(n>0),this.display.setDraftMode(!0);for(let i=0;i<t.length;i+=n){this.showLoadingWarning(i/t.length);for(let r=i;r<t.length&&r<i+n;r++){const n=t[r];e?n.apply(this):n.unapply(this)}i+n<t.length&&(yield new Promise((t=>{this.rerender(),requestAnimationFrame(t)})))}this.display.setDraftMode(!1),this.hideLoadingWarning()}))}asyncApplyCommands(t,e){return this.asyncApplyOrUnapplyCommands(t,!0,e)}asyncUnapplyCommands(t,e,n=!1){return n&&(t=[...t]).reverse(),this.asyncApplyOrUnapplyCommands(t,!1,e)}queueRerender(){return this.rerenderQueued||(this.rerenderQueued=!0,requestAnimationFrame((()=>{this.rerenderQueued&&(this.rerender(),this.rerenderQueued=!1)}))),new Promise((t=>{this.nextRerenderListeners.push((()=>t()))}))}isRerenderQueued(){return this.rerenderQueued}rerender(t=!0){if(this.display.startRerender(),0===this.display.width||0===this.display.height)return;const e=this.display.getDryInkRenderer();if(this.image.renderWithCache(e,this.display.getCache(),this.viewport),t){const t={fill:b.default.fromHex("#44444455")},n=5*this.viewport.getSizeOfPixelOnCanvas();e.drawRect(this.getImportExportRect(),n,t)}this.rerenderQueued=!1,this.nextRerenderListeners.forEach((t=>t())),this.nextRerenderListeners=[]}drawWetInk(...t){for(const e of t)this.display.getWetInkRenderer().drawPath(e)}clearWetInk(){this.display.getWetInkRenderer().clear()}focus(){this.renderingRegion.focus()}createHTMLOverlay(t){return t.classList.add("overlay"),this.container.appendChild(t),{remove:()=>t.remove()}}addStyleSheet(t){const e=document.createElement("style");return e.innerText=t,this.container.appendChild(e),e}sendKeyboardEvent(t,e,n=!1,i=!1){this.toolController.dispatchInputEvent({kind:t,key:e,ctrlKey:n,altKey:i})}sendPenEvent(t,e,n){(0,I.default)(this,t,e,n)}addAndCenterComponents(t,e=!0){return s(this,void 0,void 0,(function*(){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,o=i.height/n.height;let s=r;(n.width*s>i.width||n.height*s>i.height)&&(s=o),s*=2/3,s=h.default.roundScaleRatio(s);const a=T.default.translation(i.center.minus(n.center)).rightMul(T.default.scaling2D(s,n.center)),c=[];for(const e of t)c.push(l.default.addElement(e)),c.push(e.transformBy(a));if(yield this.dispatch((0,_.default)(c,100),!0),e)for(const e of this.toolController.getMatchingTools(O.default))e.setEnabled(!0),e.setSelection(t)}))}toDataURL(t="image/png"){const e=document.createElement("canvas"),n=this.image.getImportExportViewport(),i=n.getScreenRectSize();e.width=i.x,e.height=i.y;const r=e.getContext("2d"),o=new k.default(r,n);this.image.renderAll(o);return e.toDataURL(t)}toSVG(){const t=this.image.getImportExportViewport().getTemporaryClone(),{element:e,renderer:n}=y.default.fromViewport(t,!1),i=t.canvasToScreenTransform;t.resetTransform(T.default.identity),this.image.renderAll(n),t.resetTransform(i);const r=t.visibleRect;return e.setAttribute("viewBox",[r.x,r.y,r.w,r.h].map((t=>(0,P.toRoundedString)(t))).join(" ")),e.setAttribute("width",(0,P.toRoundedString)(r.w)),e.setAttribute("height",(0,P.toRoundedString)(r.h)),e}loadFrom(t){return s(this,void 0,void 0,(function*(){this.showLoadingWarning(0),this.display.setDraftMode(!0);const e=this.image.getBackgroundComponents(),n=new M.default(e);yield t.start((t=>s(this,void 0,void 0,(function*(){yield this.dispatchNoAnnounce(l.default.addElement(t))}))),((t,e)=>t%500==0?(this.showLoadingWarning(t/e),this.rerender(),(0,E.default)()):null),(t=>{this.dispatchNoAnnounce(this.setImportExportRect(t),!1),this.dispatchNoAnnounce(this.viewport.zoomTo(t),!1)})),this.image.getBackgroundComponents().length!==e.length&&(yield this.dispatchNoAnnounce(n)),this.hideLoadingWarning(),this.display.setDraftMode(!1),this.queueRerender()}))}getTopmostBackgroundComponent(){let t=null;for(const e of this.image.getBackgroundComponents())e instanceof B.default&&(t=e);return t}setBackgroundColor(t){let e=this.getTopmostBackgroundComponent();if(e)return e.updateStyle({color:t});{const n=t.eq(b.default.transparent)?B.BackgroundType.None:B.BackgroundType.SolidColor;return e=new B.default(n,t),this.image.addElement(e)}}estimateBackgroundColor(){var t;const e=[];for(const n of this.image.getBackgroundComponents())n instanceof B.default&&e.push(null!==(t=n.getStyle().color)&&void 0!==t?t:b.default.transparent);return b.default.average(e)}getImportExportRect(){return this.image.getImportExportViewport().visibleRect}setImportExportRect(t){return this.image.setImportExportRect(t)}loadFromSVG(t,e=!1){return s(this,void 0,void 0,(function*(){const n=x.default.fromString(t,e);yield this.loadFrom(n)}))}}e.Editor=R,e.default=R},4721:function(t,e,n){"use strict";var i,r,o=this&&this.__setFunctionName||function(t,e,n){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ImageNode=e.EditorImageEventType=e.sortLeavesByZIndex=void 0;const a=s(n(8831)),l=s(n(7747)),c=s(n(5085)),d=s(n(1386)),u=s(n(5559)),h=n(6750),p=s(n(2054)),f=n(246);var m;e.sortLeavesByZIndex=t=>{t.sort(((t,e)=>t.getContent().getZIndex()-e.getContent().getZIndex()))},function(t){t[t.ExportViewportChanged=0]="ExportViewportChanged"}(m=e.EditorImageEventType||(e.EditorImageEventType={}));class g{constructor(){this.root=new v,this.background=new v,this.componentsById={},this.notifier=new u.default,this.importExportViewport=new a.default((()=>{this.notifier.dispatch(m.ExportViewportChanged,{image:this})})),this.importExportViewport.updateScreenSize(h.Vec2.of(500,500))}getBackgroundComponents(){const t=[],n=this.background.getLeaves();(0,e.sortLeavesByZIndex)(n);for(const e of n){const n=e.getContent();n&&t.push(n)}return t}findParent(t){var e;return null!==(e=this.background.getChildWithContent(t))&&void 0!==e?e:this.root.getChildWithContent(t)}queueRerenderOf(t){const e=this.findParent(t);e&&(e.remove(),this.addElementDirectly(t))}renderWithCache(t,e,n){this.background.render(t,n.visibleRect),e.render(t,this.root,n)}render(t,e){this.background.render(t,null==e?void 0:e.visibleRect),this.root.render(t,null==e?void 0:e.visibleRect)}renderAll(t){this.render(t,null)}getAllElements(){const t=this.root.getLeaves();return(0,e.sortLeavesByZIndex)(t),t.map((t=>t.getContent()))}getElementsIntersectingRegion(t){const n=this.root.getLeavesIntersectingRegion(t);return(0,e.sortLeavesByZIndex)(n),n.map((t=>t.getContent()))}onDestroyElement(t){delete this.componentsById[t.getId()]}lookupElement(t){var e;return null!==(e=this.componentsById[t])&&void 0!==e?e:null}addElementDirectly(t){t.onAddToImage(this),this.componentsById[t.getId()]=t;return(t.isBackground()?this.background:this.root).addLeaf(t)}removeElementDirectly(t){const e=this.findParent(t);return null==e||e.remove(),!!e&&(this.onDestroyElement(t),!0)}static addElement(t,e=!1){return new g.AddElementCommand(t,e)}addElement(t,e){return g.addElement(t,e)}getImportExportViewport(){return this.importExportViewport}setImportExportRect(t){const e=this.getImportExportViewport(),n=e.visibleRect.size,i=e.canvasToScreenTransform;return new g.SetImportExportRectCommand(n,i,t)}}g.AddElementCommand=(o(i=class extends d.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(){var t;return{elemData:null!==(t=this.serializedElem)&&void 0!==t?t:this.element.serialize()}}},"AddElementCommand"),d.default.register("add-element",((t,e)=>{const n=t.elemData.id,i=e.image.lookupElement(n),r=null!=i?i:l.default.deserialize(t.elemData),o=new g.AddElementCommand(r);return o.serializedElem=t.elemData,o})),i),g.SetImportExportRectCommand=(o(r=class extends d.default{constructor(t,e,n){super(g.SetImportExportRectCommand.commandId),this.originalSize=t,this.originalTransform=e,this.finalRect=n}apply(t){const e=t.image.getImportExportViewport();e.updateScreenSize(this.finalRect.size),e.resetTransform(p.default.translation(this.finalRect.topLeft.times(-1))),t.queueRerender()}unapply(t){const e=t.image.getImportExportViewport();e.updateScreenSize(this.originalSize),e.resetTransform(this.originalTransform),t.queueRerender()}description(t,e){return e.resizeOutputCommand(this.finalRect)}serializeToJSON(){return{originalSize:this.originalSize.xy,originalTransform:this.originalTransform.toArray(),newRegion:{x:this.finalRect.x,y:this.finalRect.y,w:this.finalRect.w,h:this.finalRect.h}}}},"SetImportExportRectCommand"),r.commandId="set-import-export-rect",(()=>{const t=r.commandId;d.default.register(t,((t,e)=>{(0,f.assertIsNumber)(t.originalSize.x),(0,f.assertIsNumber)(t.originalSize.y),(0,f.assertIsNumberArray)(t.originalTransform),(0,f.assertIsNumberArray)([t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h]);const n=h.Vec2.ofXY(t.originalSize),i=new p.default(...t.originalTransform),r=new c.default(t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h);return new g.SetImportExportRectCommand(n,i,r)}))})(),r),e.default=g;class v{constructor(t=null){this.parent=t,this.targetChildCount=30,this.children=[],this.bbox=c.default.empty,this.content=null,this.id=v.idCounter++}getId(){return this.id}onContentChange(){this.id=v.idCounter++}getContent(){return this.content}getParent(){return this.parent}getChildrenIntersectingRegion(t){return this.children.filter((e=>e.getBBox().intersects(t)))}getChildrenOrSelfIntersectingRegion(t){return this.content?[this]:this.getChildrenIntersectingRegion(t)}getLeavesIntersectingRegion(t,e){const n=[];let i;const r=[];r.push(this);const o=()=>{i=void 0;const o=r.pop();o&&!(null==e?void 0:e(o.bbox))&&(i=o,null!==i.content&&i.getBBox().intersection(t)&&n.push(i),r.push(...i.getChildrenIntersectingRegion(t)))};for(;r.length>0;)o();return n}getChildWithContent(t){const e=this.getLeavesIntersectingRegion(t.getBBox());for(const n of e)if(n.getContent()===t)return n;return null}getLeaves(){if(this.content)return[this];const t=[];for(const e of this.children)t.push(...e.getLeaves());return t}addLeaf(t){if(this.onContentChange(),null===this.content&&0===this.children.length)return this.content=t,this.recomputeBBox(!0),this;if(null!==this.content){console.assert(0===this.children.length);const t=new v(this);t.content=this.content,this.content=null,this.children.push(t),t.recomputeBBox(!1)}const e=t.getBBox();if(e.containsRect(this.getBBox())){const e=new v(this);if(this.children.length<this.targetChildCount)this.children.push(e);else{const t=new v(this);t.children=this.children,this.children=[e,t],t.recomputeBBox(!0),t.updateParents()}return e.addLeaf(t)}const n=this.children.filter((t=>t.getBBox().containsRect(e)));if(n.length>0&&this.children.length>=this.targetChildCount){n.sort(((t,e)=>t.getBBox().area-e.getBBox().area));const e=n[0].addLeaf(t);return e.rebalance(),e}const i=new v(this);return this.children.push(i),i.content=t,i.recomputeBBox(!0),i}getBBox(){return this.bbox}recomputeBBox(t){var e;const n=this.bbox;null!==this.content?this.bbox=this.content.getBBox():this.bbox=c.default.union(...this.children.map((t=>t.getBBox()))),t&&!n.eq(this.bbox)&&(null===(e=this.parent)||void 0===e||e.recomputeBBox(!0))}updateParents(t=!1){for(const e of this.children)e.parent=this,t&&e.updateParents(t)}rebalance(){if(this.parent&&1===this.parent.children.length){console.assert(null===this.parent.content),console.assert(this.parent.children[0]===this);const t=this.parent;null!==t.parent?(t.children=[],this.parent=t.parent,this.parent.children.push(this),t.parent=null,this.parent.recomputeBBox(!1)):null===this.content&&(this.parent.children=this.children,this.parent.updateParents(),this.parent=null)}}remove(){var t;if(null===(t=this.content)||void 0===t||t.onRemoveFromImage(),!this.parent)return this.content=null,void(this.children=[]);const e=this.parent.children.length;this.parent.children=this.parent.children.filter((t=>t!==this)),console.assert(this.parent.children.length===e-1,`${e-1} ≠ ${this.parent.children.length} after removing all nodes equal to ${this}. Nodes should only be removed once.`),this.parent.children.forEach((t=>{t.rebalance()})),this.parent.recomputeBBox(!0),this.content=null,this.parent=null,this.children=[]}render(t,n){let i;i=n?this.getLeavesIntersectingRegion(n,(e=>t.isTooSmallToRender(e))):this.getLeaves(),(0,e.sortLeavesByZIndex)(i);for(const e of i)e.getContent().render(t,n)}}v.idCounter=0,e.ImageNode=v},5559:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.listeners={}}dispatch(t,e){const n=this.listeners[t];if(n)for(let t=0;t<n.length;t++)n[t](e)}on(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),{remove:()=>{const n=this.listeners[t];return this.off(t,e),n.length!==this.listeners[t].length}}}off(t,e){const n=this.listeners[t];n&&(this.listeners[t]=n.filter((t=>t!==e)))}}},306:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointerDevice=void 0;const i=n(6750);var r;!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"}(r=e.PointerDevice||(e.PointerDevice={}));class o{constructor(t,e,n,i,r,o,s,a){this.screenPos=t,this.canvasPos=e,this.pressure=n,this.isPrimary=i,this.down=r,this.device=o,this.id=s,this.timeStamp=a}snappedToGrid(t){const e=t.snapToGrid(this.canvasPos),n=t.canvasToScreen(e);return new o(n,e,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(t,e,n,s){var a,l;let c=i.Vec2.of(t.clientX,t.clientY);if(s){const t=s.getBoundingClientRect();c=c.minus(i.Vec2.of(t.left,t.top))}let d=null!==(a={mouse:r.PrimaryButtonMouse,pen:r.Pen,touch:r.Touch}[t.pointerType])&&void 0!==a?a:r.Other;d===r.Pen&&0!=(32&t.buttons)&&(d=r.Eraser);const u=(new Date).getTime(),h=n.roundPoint(n.screenToCanvas(c));return d===r.PrimaryButtonMouse&&(2&t.buttons?d=r.RightButtonMouse:1&t.buttons||(d=r.Other)),new o(c,h,null!==(l=t.pressure)&&void 0!==l?l:null,t.isPrimary,e,d,t.pointerId,u)}static ofCanvasPoint(t,e,n,i=0,s=r.Pen,a=!0,l=null){const c=n.canvasToScreen(t),d=(new Date).getTime();return new o(c,t,l,a,e,s,i,d)}}e.default=o},8684:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.svgStyleAttributesDataKey=e.svgAttributesDataKey=e.defaultSVGViewRect=void 0;const l=a(n(8233)),c=o(n(7520)),d=a(n(5249)),u=a(n(9984)),h=a(n(9276)),p=a(n(6205)),f=a(n(5807)),m=a(n(2054)),g=a(n(9765)),v=a(n(5085)),y=n(6750);e.defaultSVGViewRect=new v.default(0,0,500,500),e.svgAttributesDataKey="svgAttrs",e.svgStyleAttributesDataKey="svgStyleAttrs";const b=["stroke","fill","stroke-width"];class x{constructor(t,e,n=!0){this.source=t,this.onFinish=e,this.storeUnknown=n,this.onAddComponent=null,this.onProgress=null,this.onDetermineExportRect=null,this.processedCount=0,this.totalToProcess=0}getStyle(t,e){var n,i,r,o,s,a;let c,d=l.default.transparent;const u=null!==(i=null!==(n=t.getAttribute("fill"))&&void 0!==n?n:null==e?void 0:e.fill)&&void 0!==i?i:t.style.fill;if(u)try{d=l.default.fromString(u)}catch(t){console.error("Unknown fill color,",u)}const h=null!==(o=null!==(r=t.getAttribute("stroke"))&&void 0!==r?r:null==e?void 0:e.stroke)&&void 0!==o?o:t.style.stroke,p=null!==(a=null!==(s=t.getAttribute("stroke-width"))&&void 0!==s?s:null==e?void 0:e.strokeWidth)&&void 0!==a?a:t.style.strokeWidth;if(h&&p)try{let t=parseFloat(null!=p?p:"1");isFinite(t)||(t=0);const e=l.default.fromString(h);e.a>0&&(c={width:t,color:e})}catch(t){console.error("Error parsing stroke data:",t)}return{fill:d,stroke:c}}strokeDataFromElem(t){var e;const n=[],i=null!==(e=t.getAttribute("d"))&&void 0!==e?e:"",r=this.getStyle(t),o=i.split("M");let s=!0;for(const t of o){const e=/^[0-9., \t\n]+$/.exec(t);if(""!==t&&!e){const e=s?t:`M${t}`,i=g.default.fromString(e).toRenderable(r);n.push(i)}s=!1}return n}attachUnrecognisedAttrs(t,n,i,r){if(this.storeUnknown){for(const o of n.getAttributeNames())i.has(o)||"style"===o&&r||t.attachLoadSaveData(e.svgAttributesDataKey,[o,n.getAttribute(o)]);if(r&&n.style)for(const i of n.style)""!==i&&i&&(r.has(i)||t.attachLoadSaveData(e.svgStyleAttributesDataKey,{key:i,value:n.style.getPropertyValue(i),priority:n.style.getPropertyPriority(i)}))}}addPath(t){var e;return s(this,void 0,void 0,(function*(){let n;try{const e=this.strokeDataFromElem(t);n=new u.default(e),this.attachUnrecognisedAttrs(n,t,new Set([...b,"d"]),new Set(b))}catch(e){if(console.error("Invalid path in node",t,"\nError:",e,"\nAdding as an unknown object."),!this.storeUnknown)return;n=new f.default(t)}yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,n)}))}addBackground(t){var e,n,i,r;return s(this,void 0,void 0,(function*(){if(t.classList.contains(c.backgroundTypeToClassNameMap[c.BackgroundType.Grid])){let n,i,r,o,s;if("g"===t.tagName.toLowerCase()){if(2!==t.children.length)return void(yield this.addUnknownNode(t));const e=t.children[0],o=t.children[1];i=e.getAttribute("fill"),n=o.getAttribute("stroke"),r=o.getAttribute("stroke-width")}else i=t.getAttribute("fill"),n=t.getAttribute("stroke"),r=t.getAttribute("stroke-width");if(null!=i||(i=l.default.transparent.toHexString()),!n)return void(yield this.addUnknownNode(t));for(const e of t.classList)if(e.startsWith(c.imageBackgroundGridSizeCSSPrefix)){const t=e.substring(c.imageBackgroundGridSizeCSSPrefix.length);o=parseFloat(t.replace(/p/g,"."))}r&&(s=parseFloat(r));const a=l.default.fromString(i);let d=l.default.fromString(n);t.classList.contains(c.imageBackgroundNonAutomaticSecondaryColorCSSClassName)||(d=void 0);const u=c.default.ofGrid(a,o,d,s);yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,u)}else if("path"===t.tagName.toLowerCase()){const e=l.default.fromString(null!==(i=null!==(n=t.getAttribute("fill"))&&void 0!==n?n:t.style.fill)&&void 0!==i?i:"black"),o=new c.default(c.BackgroundType.SolidColor,e);yield null===(r=this.onAddComponent)||void 0===r?void 0:r.call(this,o)}else yield this.addUnknownNode(t)}))}getTransform(t,e,n){null!=n||(n=window.getComputedStyle(t));let i,r=n.transform;""!==r&&"none"!==r||(r=t.style.transform||"none");try{i=m.default.fromCSSMatrix(t.style.transform)}catch(t){i=m.default.fromCSSMatrix(r)}const o=t.getAttribute("x"),s=t.getAttribute("y");if(o||s){const t=parseFloat(null!=o?o:"0"),n=parseFloat(null!=s?s:"0");isNaN(t)||isNaN(n)||(null==e||e.push("x","y"),i=i.rightMul(m.default.translation(y.Vec2.of(t,n))))}return i}makeText(t){var e;const n=[];for(const i of t.childNodes)if(i.nodeType===Node.TEXT_NODE)n.push(null!==(e=i.nodeValue)&&void 0!==e?e:"");else{if(i.nodeType!==Node.ELEMENT_NODE)throw new Error(`Unrecognized text child node: ${i}.`);{const t=i;if("tspan"!==t.tagName.toLowerCase())throw new Error(`Unrecognized text child element: ${t}`);n.push(this.makeText(t))}}0===n.length&&n.push("");const i=window.getComputedStyle(t),r=/^([-0-9.e]+)px/i;let o=r.exec(t.style.fontSize);!o&&"tspan"===t.tagName.toLowerCase()&&t.parentElement&&(o=r.exec(t.parentElement.style.fontSize)),o||(o=r.exec(i.fontSize));const s=["fontFamily","transform",...b];let a=12;o&&(s.push("fontSize"),a=parseFloat(o[1]));const l={size:a,fontFamily:i.fontFamily||t.style.fontFamily||"sans-serif",renderingStyle:this.getStyle(t,i)},c=[],d=this.getTransform(t,c,i),u=new p.default(n,d,l);return this.attachUnrecognisedAttrs(u,t,new Set(c),new Set(s)),u}addText(t){var e;return s(this,void 0,void 0,(function*(){try{const n=this.makeText(t);yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,n)}catch(e){console.error("Invalid text object in node",t,". Continuing.... Error:",e),this.addUnknownNode(t)}}))}addImage(t){var e,n,i;return s(this,void 0,void 0,(function*(){const r=new Image;r.src=null!==(e=t.getAttribute("xlink:href"))&&void 0!==e?e:t.href.baseVal,r.setAttribute("alt",null!==(n=t.getAttribute("aria-label"))&&void 0!==n?n:"");try{const e=[],n=this.getTransform(t,e),o=yield d.default.fromImage(r,n);this.attachUnrecognisedAttrs(o,t,new Set(e),new Set(["transform"])),yield null===(i=this.onAddComponent)||void 0===i?void 0:i.call(this,o)}catch(e){console.error("Error loading image:",e,". Element: ",t,". Continuing..."),yield this.addUnknownNode(t)}}))}addUnknownNode(t){var e;return s(this,void 0,void 0,(function*(){if(this.storeUnknown){const n=new f.default(t);yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,n)}}))}updateViewBox(t){var e;const n=t.getAttribute("viewBox");if(this.rootViewBox||!n)return;const i=n.split(/[ \t\n,]+/),r=parseFloat(i[0]),o=parseFloat(i[1]),s=parseFloat(i[2]),a=parseFloat(i[3]);isNaN(r)||isNaN(o)||isNaN(s)||isNaN(a)?console.warn(`node ${t} has an unparsable viewbox. Viewbox: ${n}. Match: ${i}.`):(this.rootViewBox=new v.default(r,o,s,a),null===(e=this.onDetermineExportRect)||void 0===e||e.call(this,this.rootViewBox))}updateSVGAttrs(t){var e;return s(this,void 0,void 0,(function*(){this.storeUnknown&&(yield null===(e=this.onAddComponent)||void 0===e?void 0:e.call(this,new h.default(this.getSourceAttrs(t))))}))}visit(t){var e;return s(this,void 0,void 0,(function*(){this.totalToProcess+=t.childElementCount;let n=!0;switch(t.tagName.toLowerCase()){case"g":t.classList.contains(c.imageBackgroundCSSClassName)&&(yield this.addBackground(t),n=!1);break;case"path":t.classList.contains(c.imageBackgroundCSSClassName)?yield this.addBackground(t):yield this.addPath(t);break;case"text":yield this.addText(t),n=!1;break;case"image":yield this.addImage(t),n=!1;break;case"svg":this.updateViewBox(t),this.updateSVGAttrs(t);break;case"style":yield this.addUnknownNode(t);break;default:return console.warn("Unknown SVG element,",t),t instanceof SVGElement||console.warn("Element",t,"is not an SVGElement!",this.storeUnknown?"Continuing anyway.":"Skipping."),void(yield this.addUnknownNode(t))}if(n)for(const e of t.children)yield this.visit(e);this.processedCount++,yield null===(e=this.onProgress)||void 0===e?void 0:e.call(this,this.processedCount,this.totalToProcess)}))}getSourceAttrs(t){return t.getAttributeNames().map((e=>[e,t.getAttribute(e)]))}start(t,n,i=null){var r,o;return s(this,void 0,void 0,(function*(){this.onAddComponent=t,this.onProgress=n,this.onDetermineExportRect=i,this.totalToProcess=this.source.childElementCount,this.processedCount=0,this.rootViewBox=null,yield this.visit(this.source);this.rootViewBox||null===(r=this.onDetermineExportRect)||void 0===r||r.call(this,e.defaultSVGViewRect),null===(o=this.onFinish)||void 0===o||o.call(this)}))}static fromString(t,e=!1){var n,i;const r=document.createElement("iframe");if(r.src="about:blank",r.setAttribute("sandbox","allow-same-origin"),r.setAttribute("csp","default-src 'about:blank'"),r.style.display="none",document.body.appendChild(r),!r.hasAttribute("sandbox"))throw r.remove(),new Error("SVG loading iframe is not sandboxed.");const o=null!==(i=null===(n=r.contentWindow)||void 0===n?void 0:n.document)&&void 0!==i?i:r.contentDocument;if(null==o)throw new Error("Unable to open a sandboxed iframe!");o.open(),o.write("\n\t\t\t<!DOCTYPE html>\n\t\t\t<html>\n\t\t\t\t<head>\n\t\t\t\t\t<title>SVG Loading Sandbox</title>\n\t\t\t\t\t<meta name='viewport' conent='width=device-width,initial-scale=1.0'/>\n\t\t\t\t\t<meta charset='utf-8'/>\n\t\t\t\t</head>\n\t\t\t\t<body style='font-size: 12px;'>\n\t\t\t\t\t<script>\n\t\t\t\t\t\tconsole.error('JavaScript should not be able to run here!');\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'The SVG sandbox is broken! Please double-check the sandboxing setting.'\n\t\t\t\t\t\t);\n\t\t\t\t\t<\/script>\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t"),o.close();const s=o.createElementNS("http://www.w3.org/2000/svg","svg");return s.innerHTML=t,o.body.appendChild(s),new x(s,(()=>{s.remove(),r.remove()}),!e)}}e.default=x},5467:function(t,e,n){"use strict";var i,r,o=this&&this.__classPrivateFieldSet||function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0});const a=n(9699);i=new WeakMap,r=new WeakMap,e.default=class{constructor(t,e,n){this.editor=t,this.announceRedoCallback=e,this.announceUndoCallback=n,i.set(this,void 0),r.set(this,void 0),this.maxUndoRedoStackSize=700,o(this,i,[],"f"),o(this,r,[],"f")}fireUpdateEvent(t,e){this.editor.notifier.dispatch(a.EditorEventType.UndoRedoStackUpdated,{kind:a.EditorEventType.UndoRedoStackUpdated,undoStackSize:s(this,i,"f").length,redoStackSize:s(this,r,"f").length,command:e,stackUpdateType:t})}push(t,e=!0){e&&t.apply(this.editor),s(this,i,"f").push(t);for(const t of s(this,r,"f"))t.onDrop(this.editor);if(o(this,r,[],"f"),s(this,i,"f").length>this.maxUndoRedoStackSize){const t=Math.ceil(this.maxUndoRedoStackSize/100);s(this,i,"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,i,"f").pop();t&&(s(this,r,"f").push(t),t.unapply(this.editor),this.announceUndoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandUndone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandUndone,{kind:a.EditorEventType.CommandUndone,command:t}))}redo(){const t=s(this,r,"f").pop();t&&(s(this,i,"f").push(t),t.apply(this.editor),this.announceRedoCallback(t),this.fireUpdateEvent(a.UndoEventType.CommandRedone,t),this.editor.notifier.dispatch(a.EditorEventType.CommandDone,{kind:a.EditorEventType.CommandDone,command:t}))}get undoStackSize(){return s(this,i,"f").length}get redoStackSize(){return s(this,r,"f").length}}},8831:function(t,e,n){"use strict";var i,r,o=this&&this.__classPrivateFieldSet||function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},s=this&&this.__classPrivateFieldGet||function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Viewport=e.ViewportTransform=void 0;const l=a(n(9205)),c=a(n(2054)),d=a(n(5085)),u=n(6750),h=a(n(3785));class p extends l.default{}e.ViewportTransform=p;class f{constructor(t){this.onTransformChangeCallback=t,this.resetTransform(c.default.identity),this.screenRect=d.default.empty}getTemporaryClone(){const t=new f((()=>{}));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 f.ViewportTransform(t)}resetTransform(t=c.default.identity){var e;const n=this.transform;this.transform=t,this.inverseTransform=t.inverse(),null===(e=this.onTransformChangeCallback)||void 0===e||e.call(this,n,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(h.default.unitX).magnitude()}getScaleFactorToNearestPowerOfTen(){return this.getScaleFactorToNearestPowerOf(10)}getScaleFactorToNearestPowerOf(t){const e=this.getScaleFactor();return Math.pow(t,Math.round(Math.log(e)/Math.log(t)))}static getGridSize(t){return 50/t}snapToGrid(t){const e=this.getScaleFactorToNearestPowerOf(2),n=t=>{const n=1/f.getGridSize(e);return Math.round(t*n)/n};return u.Vec2.of(n(t.x),n(t.y))}getSizeOfPixelOnCanvas(){return 1/this.getScaleFactor()}getRotationAngle(){return this.transform.transformVec3(h.default.unitX).angle()}static roundPoint(t,e){const n=Math.pow(10,Math.floor(Math.log10(e))),i=t=>Math.round(t/n)*n;return"number"==typeof t?i(t):t.map(i)}roundPoint(t){return f.roundPoint(t,1/this.getScaleFactor())}static roundScaleRatio(t,e=1){if(Math.abs(t)<=1e-12)return 0;const n=Math.pow(10,Math.floor(Math.log10(Math.abs(t)))),i=Math.pow(2,e);return t=Math.round(t/n*i)/i*n}computeZoomToTransform(t,e=!0,n=!0){let i=c.default.identity;if(0===t.w||0===t.h)throw new Error(`${t.toString()} rectangle is empty! Cannot zoom to!`);if(isNaN(t.size.magnitude()))throw new Error(`${t.toString()} rectangle has NaN size! Cannot zoom to!`);const r=()=>{const t=this.visibleRect.transformedBoundingBox(i.inverse());return t.transformedBoundingBox(c.default.scaling2D(.8,t.center))};let o=r();const s=o.w<t.w||o.h<t.h,a=t.maxDimension/o.maxDimension<1/3;if(s&&n||a&&e){const e=Math.max(t.w/o.w,t.h/o.h),n=c.default.scaling2D(e,o.topLeft).inverse();i=i.rightMul(n)}if(o=r(),!o.containsRect(t)){const e=t.center.minus(o.center),n=c.default.translation(e).inverse();i=i.rightMul(n)}return i.invertable()||(console.warn("Unable to zoom to ",t,"! Computed transform",i,"is singular."),i=c.default.identity),i}zoomTo(t,e=!0,n=!0){const i=this.computeZoomToTransform(t,e,n);return new f.ViewportTransform(i)}}f.ViewportTransform=(r=class extends p{constructor(t){super(),this.transform=t,i.set(this,void 0),o(this,i,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,i,"f"))),t.queueRerender()}description(t,e){const n=[],i=t.viewport.visibleRect.center,r=this.transform.transformVec3(u.Vec2.unitX),o=this.transform.transformVec2(i),s=r.magnitude(),a=180/Math.PI*r.angle(),l=o.minus(i);s>1.2?n.push(e.zoomedIn):s<.8&&n.push(e.zoomedOut),Math.floor(Math.abs(a))>0&&n.push(e.rotatedBy(Math.round(a)));const c=1e-4;return l.x>c?n.push(e.movedLeft):l.x<-1e-4&&n.push(e.movedRight),l.y<-1e-4?n.push(e.movedDown):l.y>c&&n.push(e.movedUp),n.join("; ")}},i=new WeakMap,r),e.Viewport=f,e.default=f},8088:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),n(3732);const s=o(n(169));r(n(5563),e),e.default=s.default},9205:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Command=void 0;class n{onDrop(t){}static union(t,e){return new class extends n{apply(n){t.apply(n),e.apply(n)}unapply(n){e.unapply(n),t.unapply(n)}description(n,i){const r=t.description(n,i),o=e.description(n,i);return r===o?r:`${r}, ${o}`}}}}n.empty=new class extends n{description(t,e){return""}apply(t){}unapply(t){}},e.Command=n,e.default=n},9098:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(6792)),o=i(n(529)),s=i(n(1386));class a extends s.default{constructor(t){super("duplicate"),this.toDuplicate=t,this.duplicates=t.map((t=>t.clone())),this.reverse=new o.default(this.duplicates)}apply(t){this.reverse.unapply(t)}unapply(t){this.reverse.apply(t)}description(t,e){var n;return 0===this.duplicates.length?e.duplicatedNoElements:e.duplicateAction(null!==(n=(0,r.default)(e,this.duplicates))&&void 0!==n?n:e.elements,this.duplicates.length)}serializeToJSON(){return this.toDuplicate.map((t=>t.getId()))}}e.default=a,s.default.register("duplicate",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t)));return new a(n)}))},529:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(6792)),o=i(n(4721)),s=i(n(1386));class a extends s.default{constructor(t){super("erase"),this.toRemove=t.map((t=>t)),this.applied=!1}apply(t){for(const e of this.toRemove){const n=t.image.findParent(e);n&&n.remove()}this.applied=!0,t.queueRerender()}unapply(t){for(const e of this.toRemove)t.image.findParent(e)||o.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){var n;if(0===this.toRemove.length)return e.erasedNoElements;const i=null!==(n=(0,r.default)(e,this.toRemove))&&void 0!==n?n:e.elements;return e.eraseAction(i,this.toRemove.length)}serializeToJSON(){return this.toRemove.map((t=>t.getId()))}}e.default=a,s.default.register("erase",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t))).filter((t=>null!==t));return new a(n)}))},1386:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9205));class o extends r.default{constructor(t){if(super(),this.commandTypeId=t,!(t in o.deserializationCallbacks))throw new Error(`Command ${t} must have a registered deserialization callback. To do this, call SerializableCommand.register.`)}serialize(){return{data:this.serializeToJSON(),commandType:this.commandTypeId}}static deserialize(t,e){const n="string"==typeof t?JSON.parse(t):t,i=n.commandType;if(!(i in o.deserializationCallbacks))throw new Error(`Unrecognised command type ${i}!`);return o.deserializationCallbacks[i](n.data,e)}static register(t,e){o.deserializationCallbacks[t]=e}}o.deserializationCallbacks={},e.default=o},6498:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(1386));class o extends r.default{constructor(t,e,n){super(t),this.component=null!=n?n:null,this.componentID=e}resolveComponent(t){if(this.component)return;const e=t.lookupElement(this.componentID);if(!e)throw new Error(`Unable to resolve component with ID ${this.componentID}`);this.component=e}}e.default=o},1408:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9205)),o=i(n(1386)),s=t=>{if(t instanceof o.default)return new class extends o.default{serializeToJSON(){return t.serialize()}apply(e){t.unapply(e)}unapply(e){t.unapply(e)}description(e,n){return n.inverseOf(t.description(e,n))}}("inverse");return new class extends r.default{apply(e){t.unapply(e)}unapply(e){t.apply(e)}description(e,n){return n.inverseOf(t.description(e,n))}}};o.default.register("inverse",((t,e)=>s(o.default.deserialize(t,e)))),e.default=s},3707:function(t,e,n){"use strict";var i=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 r=i(n(9205));e.Command=r.default;const o=i(n(9098));e.Duplicate=o.default;const s=i(n(529));e.Erase=s.default;const a=i(n(1408));e.invertCommand=a.default;const l=i(n(1386));e.SerializableCommand=l.default;const c=i(n(3966));e.uniteCommands=c.default},3814:(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}`,addElementAction:t=>`Added ${t}`,eraseAction:(t,e)=>`Erased ${e} ${t}`,duplicateAction:(t,e)=>`Duplicated ${e} ${t}`,unionOf:(t,e)=>`Union: ${e} ${t}`,inverseOf:t=>`Inverse of ${t}`,elements:"Elements",erasedNoElements:"Erased nothing",duplicatedNoElements:"Duplicated nothing",rotatedBy:t=>`Rotated by ${Math.abs(t)} degrees ${t<0?"clockwise":"counter-clockwise"}`,movedLeft:"Moved left",movedUp:"Moved up",movedDown:"Moved down",movedRight:"Moved right",zoomedOut:"Zoomed out",zoomedIn:"Zoomed in",selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`}},3966:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9205)),o=i(n(1386));class s extends r.default{constructor(t,e){super(),this.commands=t,this.applyChunkSize=e}static waitForAll(t){if(t.some((t=>t&&t.then)))return console.log("waiting..."),Promise.all(t).then((()=>{}))}apply(t){if(void 0===this.applyChunkSize){const e=this.commands.map((e=>e.apply(t)));return s.waitForAll(e)}return t.asyncApplyCommands(this.commands,this.applyChunkSize)}unapply(t){const e=[...this.commands];if(e.reverse(),void 0===this.applyChunkSize){const n=e.map((e=>e.unapply(t)));return s.waitForAll(n)}return t.asyncUnapplyCommands(e,this.applyChunkSize,!1)}description(t,e){const n=[];let i=null,r=0;for(const o of this.commands){const s=o.description(t,e);s!==i&&null!==i&&(n.push(e.unionOf(i,r)),i=null,r=0),r++,null!=i||(i=s)}return r>1?n.push(e.unionOf(i,r)):1===r&&n.push(i),n.join(", ")}}class a extends o.default{constructor(t,e){super("union"),this.commands=t,this.applyChunkSize=e,this.nonserializableCommand=new s(t,e)}serializeToJSON(){return this.serializedData?this.serializedData:{applyChunkSize:this.applyChunkSize,data:this.commands.map((t=>t.serialize()))}}apply(t){return this.serializedData=this.serializeToJSON(),this.nonserializableCommand.apply(t)}unapply(t){return this.nonserializableCommand.unapply(t)}description(t,e){return this.nonserializableCommand.description(t,e)}}const l=(t,e)=>{let n=!0;for(const e of t)if(!(e instanceof o.default)){n=!1;break}if(n){return new a(t,e)}return new s(t,e)};o.default.register("union",((t,e)=>{if("number"!=typeof t.data.length)throw new Error("Unions of commands must serialize to lists of serialization data.");const n=t.applyChunkSize;if("number"!=typeof n&&void 0!==n)throw new Error("serialized applyChunkSize is neither undefined nor a number.");const i=[];for(const n of t.data)i.push(o.default.deserialize(n,e));return l(i,n)})),e.default=l},7747:function(t,e,n){"use strict";var i,r=this&&this.__setFunctionName||function(t,e,n){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=o(n(1386)),a=o(n(4721)),l=o(n(2054)),c=o(n(6498));class d{constructor(t,e){if(this.componentKind=t,this.loadSaveData={},this.lastChangedTime=(new Date).getTime(),this.zIndex=void 0!==e?e:d.zIndexCounter++,this.id=`${(new Date).getTime()}-${Math.random()}`,void 0===d.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]=null!=e?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()}onAddToImage(t){}onRemoveFromImage(){}intersectsRect(t){if(t.containsRect(this.getExactBBox()))return!0;return t.getEdges().some((t=>this.intersects(t)))}transformBy(t){return new d.TransformElementCommand(t,this.getId(),this)}setZIndex(t){return new d.TransformElementCommand(l.default.identity,this.getId(),this,t,this.getZIndex())}isSelectable(){return!0}isBackground(){return!1}getProportionalRenderingTime(){return 1}clone(){const t=this.createClone();for(const e in this.loadSaveData)for(const n of this.loadSaveData[e])t.attachLoadSaveData(e,n);return t}serialize(){const t=this.serializeToJSON();if(null===t)throw new Error(`${this} cannot be serialized.`);return{name:this.componentKind,zIndex:this.zIndex,id:this.id,loadSaveData:this.loadSaveData,data:t}}static isNotDeserializable(t){return"string"==typeof t&&(t=JSON.parse(t)),"object"!=typeof t||(!this.deserializationCallbacks[null==t?void 0:t.name]||!t.data)}static deserialize(t){if("string"==typeof t&&(t=JSON.parse(t)),d.isNotDeserializable(t))throw new Error(`Element with data ${t} cannot be deserialized.`);const e=this.deserializationCallbacks[t.name](t.data);return e.zIndex=t.zIndex,e.id=t.id,e}}d.zIndexCounter=0,d.deserializationCallbacks={},d.transformElementCommandId="transform-element",d.TransformElementCommand=(r(i=class extends c.default{constructor(t,e,n,i,r){super(d.transformElementCommandId,e,n),this.affineTransfm=t,this.origZIndex=r,this.targetZIndex=null!=i?i:d.zIndexCounter++,this.targetZIndex>=d.zIndexCounter&&(d.zIndexCounter=this.targetZIndex+1),n&&void 0===r&&(this.origZIndex=n.getZIndex())}resolveComponent(t){var e;this.component||(super.resolveComponent(t),null!==(e=this.origZIndex)&&void 0!==e||(this.origZIndex=this.component.getZIndex()))}updateTransform(t,e){if(!this.component)throw new Error("this.component is undefined or null!");const n=t.image.findParent(this.component);let i=!1;n&&(n.remove(),i=!0),this.component.applyTransformation(e),this.component.lastChangedTime=(new Date).getTime(),i&&a.default.addElement(this.component).apply(t)}apply(t){this.resolveComponent(t.image),this.component.zIndex=this.targetZIndex,this.updateTransform(t,this.affineTransfm),t.queueRerender()}unapply(t){this.resolveComponent(t.image),this.component.zIndex=this.origZIndex,this.updateTransform(t,this.affineTransfm.inverse()),t.queueRerender()}description(t,e){return e.transformedElements(1)}serializeToJSON(){return{id:this.componentID,transfm:this.affineTransfm.toArray(),targetZIndex:this.targetZIndex,origZIndex:this.origZIndex}}},"TransformElementCommand"),s.default.register(d.transformElementCommandId,((t,e)=>{var n,i;const r=null!==(n=e.image.lookupElement(t.id))&&void 0!==n?n:void 0,o=new l.default(...t.transfm),s=t.targetZIndex,a=null!==(i=t.origZIndex)&&void 0!==i?i:void 0;return new d.TransformElementCommand(o,t.id,r,s,a)})),i),e.default=d},7520:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.backgroundTypeToClassNameMap=e.imageBackgroundNonAutomaticSecondaryColorCSSClassName=e.imageBackgroundGridSizeCSSPrefix=e.imageBackgroundCSSClassName=e.BackgroundType=void 0;const a=s(n(8233)),l=n(4721),c=s(n(5085)),d=s(n(7747)),u=n(8258),h=o(n(9765)),p=n(6750),f=s(n(8831)),m=n(1520);var g;!function(t){t[t.SolidColor=0]="SolidColor",t[t.Grid=1]="Grid",t[t.None=2]="None"}(g=e.BackgroundType||(e.BackgroundType={})),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={[g.Grid]:"js-draw-image-background-grid",[g.SolidColor]:e.imageBackgroundCSSClassName,[g.None]:""};class v extends d.default{constructor(t,e){super("image-background",0),this.backgroundType=t,this.mainColor=e,this.viewportSizeChangeListener=null,this.gridSize=f.default.getGridSize(2),this.gridStrokeWidth=.7,this.secondaryColor=null,this.isRestylableComponent=!0,this.contentBBox=c.default.empty}static ofGrid(t,e,n,i){const r=new v(g.Grid,t);return void 0!==e&&(r.gridSize=e),void 0!==n&&(r.secondaryColor=n),void 0!==i&&(r.gridStrokeWidth=i),r}getBackgroundType(){return this.backgroundType}getMainColor(){return this.mainColor}getSecondaryColor(){return this.secondaryColor}getGridSize(){return this.gridSize}getStyle(){let t=this.mainColor;return this.backgroundType===g.None&&(t=void 0),{color:t}}updateStyle(t){return(0,u.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){const n=t.color;n&&(this.mainColor=n,n.eq(a.default.transparent)&&this.backgroundType===g.SolidColor?this.backgroundType=g.None:this.backgroundType===g.None&&(this.backgroundType=g.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.recomputeBBox(t)}onRemoveFromImage(){var t;null===(t=this.viewportSizeChangeListener)||void 0===t||t.remove(),this.viewportSizeChangeListener=null}recomputeBBox(t){const e=t.getImportExportViewport().visibleRect;this.contentBBox.eq(e)||(this.contentBBox=e,t.queueRerenderOf(this))}generateGridPath(t){var e,n;const i=null!==(n=null===(e=null==t?void 0:t.grownBy(this.gridStrokeWidth))||void 0===e?void 0:e.intersection(this.contentBBox))&&void 0!==n?n:this.contentBBox,r=t=>Math.floor(t/this.gridSize)*this.gridSize,o=t=>Math.ceil(t/this.gridSize)*this.gridSize,s=o(i.y),a=r(i.y+i.h),l=o(i.x),c=r(i.x+i.w),d=[],u=(a-s)/this.gridSize,f=(c-l)/this.gridSize;if(u>1e3||f>1e3)return h.default.empty;const m=p.Vec2.of(i.x,s);for(let t=s;t<=a;t+=this.gridSize)d.push({kind:h.PathCommandType.MoveTo,point:p.Vec2.of(i.x,t)}),d.push({kind:h.PathCommandType.LineTo,point:p.Vec2.of(i.x+i.w,t)});for(let t=l;t<=c;t+=this.gridSize)d.push({kind:h.PathCommandType.MoveTo,point:p.Vec2.of(t,i.y)}),d.push({kind:h.PathCommandType.LineTo,point:p.Vec2.of(t,i.y+i.h)});return new h.default(m,d)}render(t,n){if(this.backgroundType===g.None)return;if(t.startObject(this.contentBBox,!0),this.backgroundType===g.SolidColor||this.backgroundType===g.Grid)if(n){const e=n.intersection(this.contentBBox);e&&t.fillRect(e,this.mainColor)}else t.fillRect(this.contentBBox,this.mainColor);if(this.backgroundType===g.Grid){let e=this.secondaryColor;null!=e||(e=a.default.ofRGBA(1-this.mainColor.r,1-this.mainColor.g,1-this.mainColor.b,.2)),0===this.mainColor.a&&(e=a.default.ofRGBA(.5,.5,.5,.2));const i={fill:a.default.transparent,stroke:{width:this.gridStrokeWidth,color:e}};t.drawPath(this.generateGridPath(n).toRenderable(i))}const i=e.backgroundTypeToClassNameMap[this.backgroundType],r=[e.imageBackgroundCSSClassName];if(i!==e.imageBackgroundCSSClassName){r.push(i);const t=(0,m.toRoundedString)(this.gridSize).replace(/[.]/g,"p");r.push(e.imageBackgroundGridSizeCSSPrefix+t)}null!==this.secondaryColor&&r.push(e.imageBackgroundNonAutomaticSecondaryColorCSSClassName),t.endObject(this.getLoadSaveData(),r)}intersects(t){return this.contentBBox.getEdges().some((e=>e.intersects(t)))}isSelectable(){return!1}isBackground(){return!0}serializeToJSON(){var t;return{mainColor:this.mainColor.toHexString(),secondaryColor:null===(t=this.secondaryColor)||void 0===t?void 0:t.toHexString(),backgroundType:this.backgroundType,gridSize:this.gridSize,gridStrokeWidth:this.gridStrokeWidth}}applyTransformation(t){}description(t){return this.backgroundType===g.SolidColor?t.filledBackgroundWithColor(this.mainColor.toString()):t.emptyBackground}createClone(){return new v(this.backgroundType,this.mainColor)}static deserializeFromJSON(t){var e,n;if("string"==typeof t&&(t=JSON.parse(t)),"string"!=typeof t.mainColor)throw new Error("Error deserializing — mainColor must be of type string.");let i;const r=t.backgroundType;if(r!==g.None&&r!==g.Grid&&r!==g.SolidColor){return r}i=r;const o=a.default.fromHex(t.mainColor),s=t.secondaryColor?a.default.fromHex(t.secondaryColor):null,l=null!==(e=t.gridSize)&&void 0!==e?e:void 0,c=null!==(n=t.gridStrokeWidth)&&void 0!==n?n:void 0,d=new v(i,o);return d.secondaryColor=s,l&&(d.gridSize=l),c&&(d.gridStrokeWidth=c),d}}e.default=v,d.default.registerComponent("image-background",v.deserializeFromJSON)},5249:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(2054)),s=r(n(5085)),a=n(246),l=r(n(7747));class c extends l.default{constructor(t){var e,n,i;super("image-component"),this.image=Object.assign(Object.assign({},t),{label:null!==(i=null!==(n=null!==(e=t.label)&&void 0!==e?e:t.image.getAttribute("alt"))&&void 0!==n?n:t.image.getAttribute("aria-label"))&&void 0!==i?i:void 0});void 0===t.image.getAttribute("src")||t.image.complete||(t.image.onload=()=>this.recomputeBBox()),this.recomputeBBox()}getImageRect(){return new s.default(0,0,this.image.image.width,this.image.image.height)}recomputeBBox(){this.contentBBox=this.getImageRect(),this.contentBBox=this.contentBBox.transformedBoundingBox(this.image.transform)}static fromImage(t,e){var n,r,o;return i(this,void 0,void 0,(function*(){let i,s,a;t.complete||(yield new Promise(((e,n)=>{t.onload=e,t.onerror=n,t.onabort=n}))),"number"==typeof t.width&&"number"==typeof t.height&&0!==t.width&&0!==t.height?(i=t.width,s=t.height):(i=t.clientWidth,s=t.clientHeight);let l=null!==(n=t.src)&&void 0!==n?n:"";if(l.startsWith("data:image/"))a=new Image,a.src=l,a.width=i,a.height=s;else{const e=document.createElement("canvas");e.width=i,e.height=s;e.getContext("2d").drawImage(t,0,0,e.width,e.height),l=e.toDataURL(),a=e}return a.setAttribute("alt",null!==(r=t.getAttribute("alt"))&&void 0!==r?r:""),a.setAttribute("aria-label",null!==(o=t.getAttribute("aria-label"))&&void 0!==o?o:""),new c({image:a,base64Url:l,transform:e})}))}render(t,e){t.startObject(this.contentBBox),t.drawImage(this.image),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return 10}intersects(t){const e=this.getImageRect().getEdges().map((t=>t.transformedBy(this.image.transform)));for(const n of e)if(n.intersects(t))return!0;return!1}applyTransformation(t){this.image.transform=t.rightMul(this.image.transform),this.recomputeBBox()}description(t){return this.image.label?t.imageNode(this.image.label):t.unlabeledImageNode}getAltText(){return this.image.label}getURL(){return this.image.base64Url}getTransformation(){return this.image.transform}createClone(){return new c(Object.assign({},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,a.assertIsNumberArray)(t.transform),(0,a.assertIsNumber)(t.width),(0,a.assertIsNumber)(t.height);const e=new Image;e.src=t.src,e.width=t.width,e.height=t.height;const n=new o.default(...t.transform);return new c({image:e,base64Url:t.src,label:t.label,transform:n})}}e.default=c,l.default.registerComponent("image-component",c.deserializeFromJSON)},8258:function(t,e,n){"use strict";var i=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 r=i(n(8233)),o=i(n(1386)),s=i(n(6498)),a=n(1281),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?r.default.fromHex(t.color):void 0,textStyle:t.textStyle?(0,a.textStyleFromJSON)(t.textStyle):void 0});e.createRestyleComponentCommand=(t,e,n)=>new u(t,e,n.getId(),n);e.isRestylableComponent=t=>!!("getStyle"in t&&"updateStyle"in t&&"forceStyle"in t)&&!(!("isRestylableComponent"in t)||!t.isRestylableComponent);const d="default-restyle-element";class u extends s.default{constructor(t,e,n,i){super(d,n,i),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)}}}o.default.register(d,((t,e)=>{const n=c(t.originalStyle),i=c(t.newStyle),r=t.id;if("string"!=typeof t.id)throw new Error(`json.id is of type ${typeof t.id}, not string.`);return new u(n,i,r)}))},9276:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=i(n(9563)),s=i(n(7747)),a="svg-global-attributes";class l extends s.default{constructor(t){super(a),this.attrs=t,this.contentBBox=r.default.empty}render(t,e){if(t instanceof o.default)for(const[e,n]of this.attrs)t.setRootSVGAttribute(e,n)}intersects(t){return!1}applyTransformation(t){}isSelectable(){return!1}createClone(){return new l(this.attrs)}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify(this.attrs)}static deserializeFromString(t){const e=JSON.parse(t),n=[],i=/^[ \t\n0-9.-eE]+$/;for(const[t,r]of e)"viewBox"!==t&&"width"!==t&&"height"!==t||r&&i.exec(r)&&n.push([t,r]);return new l(n)}}e.default=l,s.default.registerComponent(a,l.deserializeFromString)},9984:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9765)),o=i(n(5085)),s=n(9604),a=i(n(7747)),l=n(8258);class c extends a.default{constructor(t){var e;super("stroke"),this.isRestylableComponent=!0,this.approximateRenderingTime=0,this.parts=[];for(const e of t){const t=r.default.fromRenderable(e),n=this.bboxForPart(t.bbox,e.style);this.contentBBox?this.contentBBox=this.contentBBox.union(n):this.contentBBox=n,this.parts.push({path:t,startPoint:t.startPoint,style:e.style,commands:t.parts}),this.approximateRenderingTime+=t.parts.length}null!==(e=this.contentBBox)&&void 0!==e||(this.contentBBox=o.default.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,l.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){t.color&&(this.parts=this.parts.map((e=>{const n=Object.assign(Object.assign({},e.style),{stroke:e.style.stroke?Object.assign({},e.style.stroke):void 0});return n.stroke&&n.stroke.width>0?n.stroke.color=t.color:n.fill=t.color,{path:e.path,startPoint:e.startPoint,commands:e.commands,style:n}})),e&&(e.image.queueRerenderOf(this),e.queueRerender()))}intersects(t){var e;for(const n of this.parts){const i=null===(e=n.style.stroke)||void 0===e?void 0:e.width,r=i?i/2:void 0;if(n.path.intersection(t,r).length>0)return!0}return!1}render(t,e){var n,i;t.startObject(this.getBBox());for(const r of this.parts){const o=this.bboxForPart(r.path.bbox,r.style);if(e){if(!o.intersects(e))continue;if((o.size.x>3*e.size.x||o.size.y>3*e.size.y)&&!r.path.roughlyIntersects(e,null!==(i=null===(n=r.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0))continue}t.drawPath(r)}t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.approximateRenderingTime}bboxForPart(t,e){return e.stroke?t.grownBy(e.stroke.width/2):t}getExactBBox(){let t=null;for(const{path:e,style:n}of this.parts){const i=this.bboxForPart(e.getExactBBox(),n);null!=t||(t=i),t=t.union(i)}return null!=t?t:o.default.empty}applyTransformation(t){this.contentBBox=o.default.empty;let e=!0;this.parts=this.parts.map((n=>{const i=n.path.transformedBy(t),r=Object.assign(Object.assign({},n.style),{stroke:n.style.stroke?Object.assign({},n.style.stroke):void 0});if(r.stroke){const e=t.getScaleFactor();r.stroke.width*=e}const o=this.bboxForPart(i.bbox,r);return e?(this.contentBBox=o,e=!1):this.contentBBox=this.contentBBox.union(o),{path:i,startPoint:i.startPoint,commands:i.parts,style:r}}))}getPath(){let t=null;for(const e of this.parts)t?t=t.union(e.path):null!=t||(t=e.path);return null!=t?t:r.default.empty}description(t){return t.stroke}createClone(){return new c(this.parts)}serializeToJSON(){return this.parts.map((t=>({style:(0,s.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,s.styleFromJSON)(t.style);return r.default.fromString(t.path).toRenderable(e)}));return new c(e)}}e.default=c,a.default.registerComponent("stroke",c.deserializeFromJSON)},6205:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9784)),o=i(n(2054)),s=i(n(5085)),a=n(6750),l=n(1281),c=i(n(7747)),d=n(8258),u="text";class h extends c.default{constructor(t,e,n){super(u),this.textObjects=t,this.transform=e,this.style=n,this.isRestylableComponent=!0,this.recomputeBBox();!t.some((t=>"string"==typeof t))&&t.length>0&&(this.style=t[0].getTextStyle())}static applyTextStyles(t,e){var n,i;const r=e.fontFamily.match(/\s/)?e.fontFamily.replace(/["]/g,'\\"'):e.fontFamily;t.font=[(null!==(n=e.size)&&void 0!==n?n:12)+"px",null!==(i=e.fontWeight)&&void 0!==i?i:"",`${r}`,e.fontWeight].join(" "),t.textAlign="left"}static estimateTextDimens(t,e){const n=t.length*e.size,i=e.size;return new s.default(0,2*-i/3,n,i)}static getTextDimens(t,e){var n,i;if(null!==(n=h.textMeasuringCtx)&&void 0!==n||(h.textMeasuringCtx=null!==(i=document.createElement("canvas").getContext("2d"))&&void 0!==i?i:null),!h.textMeasuringCtx)return this.estimateTextDimens(t,e);const r=h.textMeasuringCtx;h.applyTextStyles(r,e);const o=r.measureText(t),a=-o.actualBoundingBoxAscent,l=o.actualBoundingBoxAscent+o.actualBoundingBoxDescent;return new s.default(0,a,o.width,l)}computeBBoxOfPart(t){if("string"==typeof t){return h.getTextDimens(t,this.style).transformedBoundingBox(this.transform)}return t.contentBBox.transformedBoundingBox(this.transform)}recomputeBBox(){let t=null;for(const e of this.textObjects){const n=this.computeBBoxOfPart(e);null!=t||(t=n),t=t.union(n)}this.contentBBox=null!=t?t:s.default.empty}renderInternal(t){const e=this.transform;for(const n of this.textObjects)"string"==typeof n?t.drawText(n,e,this.style):(t.pushTransform(e),n.renderInternal(t),t.popTransform())}render(t,e){t.startObject(this.contentBBox),this.renderInternal(t),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(t){const e=this.transform.inverse(),n=e.transformVec2(t.p1),i=e.transformVec2(t.p2);t=new r.default(n,i);for(const e of this.textObjects)if("string"==typeof e){if(h.getTextDimens(e,this.style).getEdges().some((e=>null!==t.intersection(e))))return!0}else if(e.intersects(t))return!0;return!1}getStyle(){return{color:this.style.renderingStyle.fill,textStyle:Object.assign(Object.assign({},this.style),{renderingStyle:Object.assign({},this.style.renderingStyle)})}}updateStyle(t){return(0,d.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){if(t.textStyle)this.style=(0,l.cloneTextStyle)(t.textStyle);else{if(!t.color)return;this.style=Object.assign(Object.assign({},this.style),{renderingStyle:Object.assign(Object.assign({},this.style.renderingStyle),{fill:t.color})})}for(const n of this.textObjects)n instanceof h&&n.forceStyle(t,e);e&&(e.image.queueRerenderOf(this),e.queueRerender())}getTextStyle(){return(0,l.cloneTextStyle)(this.style)}getBaselinePos(){return this.transform.transformVec2(a.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,l.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,l.textStyleFromJSON)(t.style),n=t.textObjects.map((t=>{var e;return null!==(null!==(e=t.text)&&void 0!==e?e: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 i=t.transform,r=new o.default(...i);return new h(n,r,e)}static fromLines(t,e,n){let i=null;const r=[];for(const e of t){let t=a.Vec2.zero;if(i){const e=Math.floor(n.size);t=i.getBBox().bottomLeft.plus(a.Vec2.unitY.times(e))}const s=new h([e],o.default.translation(t),n);r.push(s),i=s}return new h(r,e,n)}}h.textMeasuringCtx=null,e.default=h,c.default.registerComponent(u,(t=>h.deserializeFromString(t)))},5807:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=i(n(9563)),s=i(n(7747)),a="unknown-svg-object";class l extends s.default{constructor(t){super(a),this.svgObject=t,this.contentBBox=r.default.of(t.getBoundingClientRect())}render(t,e){t instanceof o.default&&t.drawSVGElem(this.svgObject)}intersects(t){return this.contentBBox.getEdges().some((e=>null!==e.intersection(t)))}applyTransformation(t){}isSelectable(){return!1}createClone(){return new l(this.svgObject.cloneNode(!0))}description(t){return t.svgObject}serializeToJSON(){return JSON.stringify({html:this.svgObject.outerHTML})}}e.default=l,s.default.registerComponent(a,null)},6645:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeArrowBuilder=void 0;const a=o(n(9765)),l=s(n(9984));e.makeArrowBuilder=(t,e)=>new c(t,e);class c{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getLineWidth(){return Math.max(this.endPoint.width,this.startPoint.width)}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),i=e.minus(t).length(),r=Math.min(this.getLineWidth(),i/2),o=this.startPoint.width/2,s=this.endPoint.width/2,c=e.minus(n.times(r)),d=n.orthog(),u=d.times(o),h=d.times(s),p=new a.default(c.minus(h),[{kind:a.PathCommandType.LineTo,point:t.minus(u)},{kind:a.PathCommandType.LineTo,point:t.plus(u)},{kind:a.PathCommandType.LineTo,point:c.plus(h)},{kind:a.PathCommandType.LineTo,point:c.plus(d.times(r).plus(h))},{kind:a.PathCommandType.LineTo,point:e.plus(n.times(s))},{kind:a.PathCommandType.LineTo,point:c.plus(d.times(-r).minus(h))},{kind:a.PathCommandType.LineTo,point:c.minus(h)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new l.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=c},1173:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeFreehandLineBuilder=void 0;const r=n(6750),o=i(n(5085)),s=n(9765),a=i(n(9984)),l=i(n(8831)),c=n(3450),d=i(n(8233));e.makeFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),i=e.getSizeOfPixelOnCanvas();return new u(t,i,n,e)};class u{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.viewport=i,this.isFirstSegment=!0,this.parts=[],this.widthAverageNumSamples=1,this.curveFitter=new c.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.averageWidth=t.width,this.bbox=new o.default(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){return{fill:d.default.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 a.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.previewStroke()}getMinFit(){let t=Math.min(this.minFitAllowed,this.averageWidth/3);return t<1e-10&&(t=this.minFitAllowed),t}roundPoint(t){const e=this.getMinFit();return l.default.roundPoint(t,e)}roundDistance(t){const e=this.getMinFit();return l.default.roundPoint(t,e)}curveToPathCommands(t){if(!t){if(!this.isFirstSegment)return[];const t=l.default.roundPoint(this.averageWidth/10,Math.min(this.minFitAllowed,this.averageWidth/10)),e=this.roundPoint(this.startPoint.pos);return[{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,t)),endPoint:e.plus(r.Vec2.of(0,t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,t)),endPoint:e.plus(r.Vec2.of(-t,0))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,-t)),endPoint:e.plus(r.Vec2.of(0,-t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,-t)),endPoint:e.plus(r.Vec2.of(t,0))}]}const e=[];return this.isFirstSegment&&e.push({kind:s.PathCommandType.MoveTo,point:this.roundPoint(t.startPoint)}),e.push({kind:s.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=u},5607:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeLineBuilder=void 0;const a=o(n(9765)),l=s(n(9984));e.makeLineBuilder=(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=this.startPoint.pos,e=this.endPoint.pos,n=e.minus(t).normalized(),i=this.startPoint.width/2,r=this.endPoint.width/2,o=n.orthog(),s=o.times(i),c=o.times(r),d=t.minus(s),u=new a.default(d,[{kind:a.PathCommandType.LineTo,point:t.plus(s)},{kind:a.PathCommandType.LineTo,point:e.plus(c)},{kind:a.PathCommandType.LineTo,point:e.minus(c)},{kind:a.PathCommandType.LineTo,point:t.minus(s)}]).mapPoints((t=>this.viewport.roundPoint(t)));return new l.default([u.toRenderable({fill:this.startPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=c},4856:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makePressureSensitiveFreehandLineBuilder=void 0;const r=n(8405),o=n(6750),s=i(n(5085)),a=n(9765),l=i(n(9984)),c=i(n(8831)),d=n(3450);e.makePressureSensitiveFreehandLineBuilder=(t,e)=>{const n=3*e.getSizeOfPixelOnCanvas(),i=e.getSizeOfPixelOnCanvas();return new u(t,i,n,e)};class u{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.viewport=i,this.isFirstSegment=!0,this.pathStartConnector=null,this.mostRecentConnector=null,this.lastUpperBezier=null,this.lastLowerBezier=null,this.parts=[],this.upperSegments=[],this.lowerSegments=[],this.curveFitter=new d.StrokeSmoother(t,e,n,(t=>this.addCurve(t))),this.curveStartWidth=t.width,this.bbox=new s.default(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}getRenderingStyle(){var t;return{fill:null!==(t=this.startPoint.color)&&void 0!==t?t:null}}previewCurrentPath(){var t;const e=this.upperSegments.slice(),n=this.lowerSegments.slice();let i,r;const o=this.curveFitter.preview();if(o){const{upperCurveCommand:s,lowerToUpperConnector:a,upperToLowerConnector:l,lowerCurveCommand:c}=this.segmentToPath(o);e.push(s),n.push(c),i=a,r=null!==(t=this.pathStartConnector)&&void 0!==t?t:l}else{if(null===this.mostRecentConnector||null===this.pathStartConnector)return null;i=this.mostRecentConnector,r=this.pathStartConnector}let s;const l=n[n.length-1];return s=l.kind===a.PathCommandType.LineTo||l.kind===a.PathCommandType.MoveTo?l.point:l.endPoint,{startPoint:s,commands:[i,...e.reverse(),r,...n],style:this.getRenderingStyle()}}previewFullPath(){const t=this.previewCurrentPath();return t?[...this.parts,t]:null}previewStroke(){const t=this.previewFullPath();return t?new l.default(t):null}preview(t){const e=this.previewFullPath();if(e){const n=this.viewport.visibleRect;t.startObject(n);for(const n of e)t.drawPath(n);t.endObject()}}build(){return this.curveFitter.finalizeCurrentCurve(),this.isFirstSegment&&this.addCurve(null),this.previewStroke()}roundPoint(t){let e=Math.min(this.minFitAllowed,this.curveStartWidth/3);return e<1e-10&&(e=this.minFitAllowed),c.default.roundPoint(t,e)}shouldStartNewSegment(t,e){if(!this.lastLowerBezier||!this.lastUpperBezier)return!1;const n=(t,e)=>{const n=t.intersects(e);if(!n||0===n.length)return null;const i=n[0],r=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(i);if(!r)throw new Error(`Incorrect format returned by .intersects: ${n} should be array of "number/number"!`);const s=parseFloat(r[1]);return o.Vec2.ofXY(t.get(s))},i=t=>o.Vec2.ofXY(t.points[2]).minus(o.Vec2.ofXY(t.points[1])).normalized(),r=t=>o.Vec2.ofXY(t.points[1]).minus(o.Vec2.ofXY(t.points[0])).normalized();if(r(e).dot(i(this.lastUpperBezier))<.3||r(t).dot(i(this.lastLowerBezier))<.3||r(e).dot(i(e))<0||r(t).dot(i(t))<0)return!0;const s=n(t,this.lastUpperBezier),a=n(e,this.lastLowerBezier);return!(!s&&!a)}addCurve(t){if(!t){if(!this.isFirstSegment)return;const t=c.default.roundPoint(this.startPoint.width/2.2,Math.min(this.minFitAllowed,this.startPoint.width/4)),e=this.roundPoint(this.startPoint.pos),n=this.startPoint.pos.plus(o.Vec2.of(t,0));return this.lowerSegments.push({kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(t,t)),endPoint:e.plus(o.Vec2.of(0,t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,t)),endPoint:e.plus(o.Vec2.of(-t,0))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,-t)),endPoint:e.plus(o.Vec2.of(0,-t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(t,-t)),endPoint:e.plus(o.Vec2.of(t,0))}),this.pathStartConnector={kind:a.PathCommandType.LineTo,point:n},void(this.mostRecentConnector=this.pathStartConnector)}const{upperCurveCommand:e,lowerToUpperConnector:n,upperToLowerConnector:i,lowerCurveCommand:r,lowerCurve:s,upperCurve:l}=this.segmentToPath(t),d=this.shouldStartNewSegment(s,l);if(d){const t=this.previewCurrentPath();t&&(this.parts.push(t),this.upperSegments=[],this.lowerSegments=[])}(this.isFirstSegment||d)&&(this.pathStartConnector=i,this.isFirstSegment=!1),this.mostRecentConnector=n,this.lowerSegments.push(r),this.upperSegments.push(e),this.lastLowerBezier=s,this.lastUpperBezier=l,this.curveStartWidth=t.startWidth}segmentToPath(t){const e=new r.Bezier(t.startPoint.xy,t.controlPoint.xy,t.endPoint.xy);let n=o.Vec2.ofXY(e.normal(0)).normalized(),i=o.Vec2.ofXY(e.normal(1)).normalized();n=n.times(t.startWidth/2),i=i.times(t.endWidth/2),isFinite(n.magnitude())||(console.error("Warning: startVec is NaN or ∞",n,i,t),n=i);const s=t.startPoint,l=t.endPoint,c=t.controlPoint;let d=e.project(c.xy).t;d||(d=s.minus(c).magnitudeSquared()<l.minus(c).magnitudeSquared()?.1:.9);const u=d,h=o.Vec2.ofXY(e.normal(u)).normalized().times(t.startWidth/2*u+t.endWidth/2*(1-u)),p=this.roundPoint(s.plus(n)),f=this.roundPoint(c.plus(h)),m=this.roundPoint(l.plus(i)),g=this.roundPoint(c.minus(h)),v=this.roundPoint(l.minus(i)),y=this.roundPoint(s.minus(n)),b={kind:a.PathCommandType.QuadraticBezierTo,controlPoint:f,endPoint:m},x={kind:a.PathCommandType.LineTo,point:p},w={kind:a.PathCommandType.LineTo,point:v};return{upperCurveCommand:{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:g,endPoint:y},upperToLowerConnector:x,lowerToUpperConnector:w,lowerCurveCommand:b,upperCurve:new r.Bezier(v,g,y),lowerCurve:new r.Bezier(p,f,m)}}addPoint(t){this.curveFitter.addPoint(t)}}e.default=u},7124:function(t,e,n){"use strict";var i=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 r=i(n(2054)),o=i(n(9765)),s=i(n(5085)),a=i(n(9984));e.makeFilledRectangleBuilder=(t,e)=>new l(t,!0,e);e.makeOutlinedRectangleBuilder=(t,e)=>new l(t,!1,e);class l{constructor(t,e,n){this.startPoint=t,this.filled=e,this.viewport=n,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=this.viewport.getRotationAngle(),e=r.default.zRotation(-t),n=e.inverse().transformVec2(this.startPoint.pos),i=e.inverse().transformVec2(this.endPoint.pos),l=s.default.fromCorners(n,i),c=o.default.fromRect(l,this.filled?null:this.endPoint.width).transformedBy(e).mapPoints((t=>this.viewport.roundPoint(t)));return new a.default([c.toRenderable({fill:this.endPoint.color})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}e.default=l},6643:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1632:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ImageComponent=e.BackgroundComponent=e.StrokeComponent=e.TextComponent=e.isRestylableComponent=e.createRestyleComponentCommand=e.Text=e.Stroke=e.AbstractComponent=e.StrokeSmoother=e.makePressureSensitiveFreehandLineBuilder=e.makeFreehandLineBuilder=void 0,r(n(6643),e);var s=n(1173);Object.defineProperty(e,"makeFreehandLineBuilder",{enumerable:!0,get:function(){return s.makeFreehandLineBuilder}});var a=n(4856);Object.defineProperty(e,"makePressureSensitiveFreehandLineBuilder",{enumerable:!0,get:function(){return a.makePressureSensitiveFreehandLineBuilder}});var l=n(3450);Object.defineProperty(e,"StrokeSmoother",{enumerable:!0,get:function(){return o(l).default}}),r(n(7747),e);var c=n(7747);Object.defineProperty(e,"AbstractComponent",{enumerable:!0,get:function(){return o(c).default}});const d=o(n(9984));e.Stroke=d.default,e.StrokeComponent=d.default;const u=o(n(6205));e.Text=u.default,e.TextComponent=u.default;const h=o(n(5249));e.ImageComponent=h.default;const p=n(8258);Object.defineProperty(e,"createRestyleComponentCommand",{enumerable:!0,get:function(){return p.createRestyleComponentCommand}}),Object.defineProperty(e,"isRestylableComponent",{enumerable:!0,get:function(){return p.isRestylableComponent}});const f=o(n(7520));e.BackgroundComponent=f.default},4163:(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",filledBackgroundWithColor:t=>`Filled background (${t})`,text:t=>`Text object: ${t}`,imageNode:t=>`Image: ${t}`,restyledElement:t=>`Restyled ${t}`}},3450:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.StrokeSmoother=void 0;const r=n(6750),o=i(n(5085)),s=i(n(9784)),a=i(n(148));class l{constructor(t,e,n,i){this.startPoint=t,this.minFitAllowed=e,this.maxFitAllowed=n,this.onCurveAdded=i,this.isFirstSegment=!0,this.lastExitingVec=null,this.currentCurve=null,this.lastPoint=this.startPoint,this.buffer=[this.startPoint.pos],this.momentum=r.Vec2.zero,this.currentCurve=null,this.curveStartWidth=t.width,this.bbox=new o.default(this.startPoint.pos.x,this.startPoint.pos.y,0,0)}getBBox(){return this.bbox}preview(){return this.currentCurve?this.currentSegmentToPath():null}approxCurrentCurveLength(){if(!this.currentCurve)return 0;const t=this.currentCurve.p0,e=this.currentCurve.p1,n=this.currentCurve.p2;return t.minus(e).length()+n.minus(e).length()}finalizeCurrentCurve(){if(!this.currentCurve)return;this.onCurveAdded(this.currentSegmentToPath());const t=this.buffer[this.buffer.length-1];this.lastExitingVec=this.currentCurve.p2.minus(this.currentCurve.p1),console.assert(0!==this.lastExitingVec.magnitude(),"lastExitingVec has zero length!"),this.buffer=[this.buffer[this.buffer.length-2],t],this.currentCurve=null,this.isFirstSegment=!1}currentSegmentToPath(){if(null==this.currentCurve)throw new Error("Invalid State: currentCurve is null!");const t=this.currentCurve.normal(0).normalized();if(!isFinite(t.magnitude()))throw new Error(`startVec(${t}) is NaN or ∞`);const e=this.currentCurve.at(0),n=this.currentCurve.at(1);return{startPoint:e,controlPoint:this.currentCurve.p1,endPoint:n,startWidth:this.curveStartWidth,endWidth:this.curveEndWidth}}computeExitingVec(){return this.momentum.normalized().times(this.lastPoint.width/2)}addPoint(t){var e,n;if(this.lastPoint){const e=1e-10,n=t.time-this.lastPoint.time;if(t.pos.eq(this.lastPoint.pos,e)||0===n)return;if(isNaN(t.pos.magnitude()))return void console.warn("Discarding NaN point.",t);const i=Math.min(this.lastPoint.width,t.width)/3;if(this.startPoint.pos.minus(t.pos).magnitude()<i&&this.isFirstSegment)return;const r=t.pos.minus(this.lastPoint.pos).times(1/n*1e3);this.momentum=this.momentum.lerp(r,.9)}const i=null!==(e=this.lastPoint)&&void 0!==e?e:t;this.lastPoint=t,this.buffer.push(t.pos);const o=t.width,l=this.curveEndWidth;if(this.curveEndWidth=o,this.bbox=this.bbox.grownToPoint(t.pos,o),null===this.currentCurve){const e=i.pos,s=i.pos.plus(null!==(n=this.lastExitingVec)&&void 0!==n?n:r.Vec2.unitX),c=t.pos;this.currentCurve=new a.default(e,s,c),console.assert(!isNaN(e.magnitude())&&!isNaN(s.magnitude())&&!isNaN(c.magnitude()),"Expected !NaN"),this.isFirstSegment?this.curveStartWidth=(this.curveStartWidth+o)/2:this.curveStartWidth=l}let c=this.lastExitingVec;if(!c){let t=Math.ceil(this.buffer.length/2);(0===t||t>=this.buffer.length)&&(t=this.buffer.length-1),c=this.buffer[t].minus(this.buffer[0])}let d=this.computeExitingVec();const u=this.buffer[0],h=t.pos,p=h.minus(u).magnitude(),f=2*p;if(0===f||0===d.magnitude()||!isFinite(d.magnitude()))return;console.assert(isFinite(c.magnitude()),"Pre-normalized enteringVec has NaN or ∞ magnitude!"),c=c.normalized(),d=d.normalized(),console.assert(isFinite(c.magnitude()),"Normalized enteringVec has NaN or ∞ magnitude!");const m=new s.default(u,u.plus(c.times(f))),g=new s.default(h.minus(d.times(f)),h).intersection(m);let v=null;g&&(v=g.point),(!v||u.eq(v)||h.eq(v))&&(v=u.plus(c.times(p/4))),console.assert(!u.eq(v,1e-11),"Start and control points are equal!"),console.assert(!v.eq(h,1e-11),"Control and end points are equal!");const y=this.currentCurve;this.currentCurve=new a.default(u,v,h),isNaN(this.currentCurve.normal(0).magnitude())&&(console.error("NaN normal at 0. Curve:",this.currentCurve),this.currentCurve=y);const b=t=>{const e=Math.min(Math.max(Math.min(this.curveStartWidth,this.curveEndWidth)/4,this.minFitAllowed),this.maxFitAllowed),n=e;let i=0;for(const r of this.buffer){let o=t.approximateDistance(r);if(o>e&&(o=t.distance(r),i+=Math.max(0,o-e),i>n))return!1}return!0};return this.buffer.length>3&&this.approxCurrentCurveLength()>this.curveStartWidth/2&&!b(this.currentCurve)?(this.currentCurve=y,this.curveEndWidth=l,this.lastPoint=i,void this.finalizeCurrentCurve()):void 0}}e.StrokeSmoother=l,e.default=l},6792:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{if(0===e.length)return null;const n=e[0].description(t);for(const i of e)if(i.description(t)!==n)return null;return n}},5563:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Editor=e.UndoRedoHistory=e.HTMLToolbar=e.PointerDevice=e.Pointer=e.Viewport=e.SVGLoader=e.Color4=e.getLocalizationTable=e.EditorImage=void 0;const s=o(n(169));e.Editor=s.default;var a=n(4721);Object.defineProperty(e,"EditorImage",{enumerable:!0,get:function(){return o(a).default}}),r(n(9699),e);var l=n(7282);Object.defineProperty(e,"getLocalizationTable",{enumerable:!0,get:function(){return o(l).default}}),r(n(2843),e);var c=n(8233);Object.defineProperty(e,"Color4",{enumerable:!0,get:function(){return o(c).default}});var d=n(8684);Object.defineProperty(e,"SVGLoader",{enumerable:!0,get:function(){return o(d).default}});var u=n(8831);Object.defineProperty(e,"Viewport",{enumerable:!0,get:function(){return o(u).default}}),r(n(4915),e),r(n(1632),e),r(n(3707),e),r(n(1637),e),r(n(4087),e),r(n(5414),e),r(n(2862),e);var h=n(306);Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return o(h).default}}),Object.defineProperty(e,"PointerDevice",{enumerable:!0,get:function(){return h.PointerDevice}});var p=n(7389);Object.defineProperty(e,"HTMLToolbar",{enumerable:!0,get:function(){return o(p).default}});var f=n(5467);Object.defineProperty(e,"UndoRedoHistory",{enumerable:!0,get:function(){return o(f).default}}),e.default=s.default},2843:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultEditorLocalization=void 0;const i=n(3814),r=n(4163),o=n(1603),s=n(3940),a=n(318);e.defaultEditorLocalization=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s.defaultToolbarLocalization),a.defaultToolLocalization),i.defaultCommandLocalization),r.defaultComponentLocalization),o.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}`})},8792:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2843),r=Object.assign(Object.assign({},i.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: ",freehandPen:"Freihand",pressureSensitiveFreehandPen:"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",closeFindDialog:"Schließen",findDialogShown:"Finde-Dialog angezeigt",findDialogHidden:"Finde-Dialog versteckt",focusedFoundText:(t,e)=>`Sieh Treffer ${t} von ${e} an`,toolEnabledAnnouncement:t=>`${t} aktiviert`,toolDisabledAnnouncement:t=>`${t} deaktiviert`,updatedViewport:"Transformierte Ansicht",transformedElements:t=>`${t} Element${1===t?"":"e"} transformiert`,resizeOutputCommand:t=>`Bildgröße auf ${t.w}x${t.h} geändert`,addElementAction:t=>`${t} hinzugefügt`,eraseAction:(t,e)=>`${e} ${t} gelöscht`,duplicateAction:(t,e)=>`${e} ${t} dupliziert`,inverseOf:t=>`${t} umgekehrt`,elements:"Elemente",erasedNoElements:"Nichts entfernt",duplicatedNoElements:"Nichts dupliziert",rotatedBy:t=>`${Math.abs(t)} Grad ${t<0?"im Uhrzeigersinn":"gegen den Uhrzeigersinn"} gedreht`,movedLeft:"Nacht links bewegt",movedUp:"Nacht oben bewegt",movedDown:"Nacht unten bewegt",movedRight:"Nacht rechts bewegt",zoomedOut:"Ansicht verkleinert",zoomedIn:"Ansicht vergrößert",selectedElements:t=>`${t} Element${1===t?"":"e"} ausgewählt`,stroke:"Strich",svgObject:"SVG-Objekt",text:t=>`Text-Objekt: ${t}`,pathNodeCount:t=>`Es gibt ${t} sichtbare Pfad-Objekte.`,textNodeCount:t=>`Es gibt ${t} sichtbare Text-Knotenpunkte.`,textNode:t=>`Text: ${t}`,imageNodeCount:t=>`Es gibt ${t} sichtbare Bild-Knoten.`,imageNode:t=>`Bild: ${t}`,unlabeledImageNode:"Bild ohne Label",rerenderAsText:"Als Text darstellen",accessibilityInputInstructions:"Drücke ‚t‘, um den Inhalt des Ansichtsfensters als Text zu lesen. Verwende die Pfeiltasten, um die Ansicht zu verschieben, und klicke und ziehe, um Striche zu zeichnen. Drücke ‚w‘ zum Vergrößern und ‚s‘ zum Verkleinern der Ansicht.",loading:t=>`Laden ${t}%...`,doneLoading:"Laden fertig",imageEditor:"Bild-Editor",undoAnnouncement:t=>`${t} rückgängig gemacht`,redoAnnouncement:t=>`${t} wiederholt`,reformatSelection:"Formatiere Auswahl",documentProperties:"Seite",backgroundColor:"Hintergrundfarbe: ",imageWidthOption:"Breite: ",imageHeightOption:"Höhe: ",useGridOption:"Gitter: ",toggleOverflow:"Mehr",selectAllTool:"Alle auswählen",soundExplorer:"Klangbasierte Bilderkundung",disableAccessibilityExploreTool:"Deaktiviere klangbasierte Erkundung",enableAccessibilityExploreTool:"Aktiviere klangbasierte Erkundung",copied:(t,e)=>`${t} ${e} kopiert`,pasted:(t,e)=>`${t} ${e} eingefügt`,unionOf:(t,e)=>`Vereinigung: ${e} ${t}`,emptyBackground:"Leerer Hintergrund",filledBackgroundWithColor:t=>`Gefüllter Hintergrund (${t})`,restyledElement:t=>`${t} umgestaltet`});e.default=r},8309:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2843),r=Object.assign({},i.defaultEditorLocalization);e.default=r},3790:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2843),r=Object.assign(Object.assign({},i.defaultEditorLocalization),{loading:t=>`Cargando: ${t}%...`,imageEditor:"Editor de dibujos",undoAnnouncement:t=>`${t} fue deshecho`,redoAnnouncement:t=>`${t} fue rehecho`,undo:"Deshace",redo:"Rehace",pen:"Lapiz",eraser:"Borrador",select:"Selecciona",thicknessLabel:"Tamaño: ",colorLabel:"Color: ",doneLoading:"El cargado terminó",fontLabel:"Fuente: ",anyDevicePanning:"Mover la pantalla con todo dispotivo",touchPanning:"Mover la pantalla con un dedo",touchPanTool:"Instrumento de mover la pantalla con un dedo",outlinedRectanglePen:"Rectángulo con nada más que un borde",filledRectanglePen:"Rectángulo sin borde",linePen:"Línea",arrowPen:"Flecha",freehandPen:"Dibuja sin restricción de forma",selectPenType:"Forma de dibuja:",handTool:"Mover",zoom:"Zoom",resetView:"Reiniciar vista",resizeImageToSelection:"Redimensionar la imagen a lo que está seleccionado",deleteSelection:"Borra la selección",duplicateSelection:"Duplica la selección",pickColorFromScreen:"Selecciona un color de la pantalla",clickToPickColorAnnouncement:"Haga un clic en la pantalla para seleccionar un color",dropdownShown:t=>`Menú por ${t} es visible`,dropdownHidden:function(t){return`Menú por ${t} fue ocultado`},colorChangedAnnouncement:function(t){return`Color fue cambiado a ${t}`},keyboardPanZoom:"Mover la pantalla con el teclado",penTool:function(t){return`Lapiz ${t}`},selectionTool:"Selecciona",eraserTool:"Borrador",textTool:"Texto",enterTextToInsert:"Entra texto",textSize:"Tamaño",rerenderAsText:"Redibuja la pantalla al texto",lockRotation:"Bloquea rotación",image:"Imagen",imageSize:(t,e)=>`Tamaño del imagen: ${t} ${e}`,imageLoadError:t=>`Error cargando imagen: ${t}`,toggleOverflow:"Más",documentProperties:"Fondo",imageWidthOption:"Ancho: ",imageHeightOption:"Alto: ",backgroundColor:"Color de fondo: "});e.default=r},7282:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(2843),o=i(n(8792)),s=i(n(8309)),a=i(n(3790)),l={de:o.default,en:s.default,es:a.default},c=t=>{const e=/^(\w+)[_-](\w+)$/.exec(t);return e?e[1]:t};e.default=t=>{let e;null!=t||(t=navigator.languages);for(const n of t){const t=c(n);if(e&&t!==e&&e in l)return l[e];if(n in l)return l[n];e=t}return e&&e in l?l[e]:r.defaultEditorLocalization}},9784:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=n(6750);class s{constructor(t,e){this.point1=t,this.point2=e,this.bbox=r.default.bboxOf([t,e]),this.direction=e.minus(t),this.length=this.direction.magnitude(),this.length>0&&(this.direction=this.direction.times(1/this.length))}get p1(){return this.point1}get p2(){return this.point2}get(t){return this.point1.plus(this.direction.times(t))}intersection(t){let e,n;if(0===this.direction.x){if(0===t.direction.x||0===this.direction.y)return null;const i=this.point1.x,r=(this.point1.x-t.point1.x)*t.direction.y/t.direction.x+t.point1.y;e=o.Vec2.of(i,r),n=(r-this.point1.y)/this.direction.y}else{const i=(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,r=t.direction.y*this.direction.x-this.direction.y*t.direction.x;if(0===r)return null;const s=i/r,a=(s-this.point1.x)/this.direction.x,l=this.point1.y+this.direction.y*a;e=o.Vec2.of(s,l),n=(s-this.point1.x)/this.direction.x}const i=e.minus(this.point1).magnitude(),r=e.minus(this.point2).magnitude(),s=e.minus(t.point1).magnitude(),a=e.minus(t.point2).magnitude();return i>this.length||r>this.length||s>t.length||a>t.length?null:{point:e,t:n}}intersects(t){return null!==this.intersection(t)}closestPointTo(t){const e=t.minus(this.p1).dot(this.direction),n=this.length-e,i=this.p1.plus(this.direction.times(e));return e>0&&e<this.length?i:Math.abs(n)<Math.abs(e)?this.p2:this.p1}distance(t){return this.closestPointTo(t).minus(t).magnitude()}transformedBy(t){return new s(t.transformVec2(this.p1),t.transformVec2(this.p2))}toString(){return`LineSegment(${this.p1.toString()}, ${this.p2.toString()})`}}e.default=s},2054:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6750),o=i(n(3785));class s{constructor(t,e,n,i,r,s,a,l,c){this.a1=t,this.a2=e,this.a3=n,this.b1=i,this.b2=r,this.b3=s,this.c1=a,this.c2=l,this.c3=c,this.cachedInverse=void 0,this.rows=[o.default.of(t,e,n),o.default.of(i,r,s),o.default.of(a,l,c)]}static ofRows(t,e,n){return new s(t.x,t.y,t.z,e.x,e.y,e.z,n.x,n.y,n.z)}inverse(){var t;return null!==(t=this.computeInverse())&&void 0!==t?t: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=[o.default.unitX,o.default.unitY,o.default.unitZ];for(let n=0;n<3;n++){let i=t[n].at(n);const r=1e-10;if(Math.abs(i)<r){let o=-1;for(let e=1;e<=2;e++){const i=(n+e)%3;if(Math.abs(t[i].at(n))>=r){o=i;break}}if(-1===o)return this.cachedInverse=null,null;const s=t[n],a=e[n];t[n]=t[o],e[n]=e[o],t[o]=s,e[o]=a,i=t[n].at(n)}let o=1/i;t[n]=t[n].times(o),e[n]=e[n].times(o);const s=t[n],a=e[n];for(let i=1;i<=2;i++){const r=(n+i)%3;o=-t[r].at(n),t[r]=t[r].plus(s.times(o)),e[r]=e[r].plus(a.times(o))}}const n=s.ofRows(e[0],e[1],e[2]);return this.cachedInverse=n,n}transposed(){return new s(this.a1,this.b1,this.c1,this.a2,this.b2,this.c2,this.a3,this.b3,this.c3)}rightMul(t){t=t.transposed();const e=(e,n)=>this.rows[e].dot(t.rows[n]);return new s(e(0,0),e(0,1),e(0,2),e(1,0),e(1,1),e(1,2),e(2,0),e(2,1),e(2,2))}transformVec2(t){let e=o.default.of(t.x,t.y,1);return e=this.transformVec3(e),r.Vec2.of(e.x,e.y)}transformVec3(t){return o.default.of(this.rows[0].dot(t),this.rows[1].dot(t),this.rows[2].dot(t))}isIdentity(){return this===s.identity||this.eq(s.identity)}eq(t,e=0){for(let n=0;n<3;n++)if(!this.rows[n].eq(t.rows[n],e))return!1;return!0}toString(){let t="";const e=[0,0,0];for(const t of this.rows)for(let n=0;n<3;n++)e[n]=Math.max(e[0],`${t.at(n)}`.length);for(let n=0;n<3;n++){t+=0===n?"⎡ ":1===n?"⎢ ":"⎣ ";for(let i=0;i<3;i++){const r=this.rows[n].at(i).toString();let o="";for(let t=r.length;t<e[i];t++)o+=" ";t+=r+", "+o}t+=0===n?" ⎤":1===n?" ⎥":" ⎦",t+="\n"}return t.trimEnd()}toArray(){return[this.a1,this.a2,this.a3,this.b1,this.b2,this.b3,this.c1,this.c2,this.c3]}mapEntries(t){return new s(t(this.a1),t(this.a2),t(this.a3),t(this.b1),t(this.b2),t(this.b3),t(this.c1),t(this.c2),t(this.c3))}getScaleFactor(){return Math.hypot(this.a1,this.a2)}static translation(t){return new s(1,0,t.x,0,1,t.y,0,0,1)}static zRotation(t,e=r.Vec2.zero){if(0===t)return s.identity;const n=Math.cos(t),i=Math.sin(t);let o=s.translation(e);return o=o.rightMul(new s(n,-i,0,i,n,0,0,0,1)),o.rightMul(s.translation(e.times(-1)))}static scaling2D(t,e=r.Vec2.zero){let n,i,o=s.translation(e);return"number"==typeof t?(n=t,i=t):(n=t.x,i=t.y),o=o.rightMul(new s(n,0,0,0,i,0,0,0,1)),o.rightMul(s.translation(e.times(-1)))}toCSSMatrix(){return`matrix(${this.a1},${this.b1},${this.a2},${this.b2},${this.a3},${this.b3})`}static fromCSSMatrix(t){if(""===t||"none"===t)return s.identity;const e="([-]?\\d*(?:\\.\\d*)?(?:[eE][-]?\\d+)?)",n="[, \\t\\n]",i=`^\\s*matrix\\s*\\(${[e,e,e,e,e,e].join(`${n}+`)}${n}*\\)\\s*$`,r=new RegExp(i,"i").exec(t);if(!r)throw new Error(`Unsupported transformation: ${t}`);const o=r.slice(1).map((t=>parseFloat(t))),a=o[0],l=o[1],c=o[2],d=o[3],u=o[4],h=o[5];return new s(a,c,u,l,d,h,0,0,1)}}s.identity=new s(1,0,0,0,1,0,0,0,1),e.default=s},9765:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PathCommandType=void 0;const r=n(8405),o=n(1520),s=i(n(9784)),a=i(n(2054)),l=i(n(5085)),c=n(6750),d=i(n(3785));var u;!function(t){t[t.LineTo=0]="LineTo",t[t.MoveTo=1]="MoveTo",t[t.CubicBezierTo=2]="CubicBezierTo",t[t.QuadraticBezierTo=3]="QuadraticBezierTo"}(u=e.PathCommandType||(e.PathCommandType={}));const h=t=>{let e;if(t instanceof s.default)e=t.bbox;else if(t instanceof r.Bezier){const n=t.bbox(),i=n.x.max-n.x.min,r=n.y.max-n.y.min;e=new l.default(n.x.min,n.y.min,i,r)}else e=new l.default(t.x,t.y,0,0);return e};class p{constructor(t,e){this.startPoint=t,this.parts=e,this.cachedGeometry=null,this.cachedPolylineApproximation=null,this.cachedStringVersion=null,this.bbox=l.default.bboxOf([t]);for(const n of e)this.bbox=this.bbox.union(p.computeBBoxForSegment(t,n))}getExactBBox(){const t=[];for(const e of this.geometry)t.push(h(e));return l.default.union(...t)}get geometry(){if(this.cachedGeometry)return this.cachedGeometry;let t=this.startPoint;const e=[];for(const n of this.parts)switch(n.kind){case u.CubicBezierTo:e.push(new r.Bezier(t.xy,n.controlPoint1.xy,n.controlPoint2.xy,n.endPoint.xy)),t=n.endPoint;break;case u.QuadraticBezierTo:e.push(new r.Bezier(t.xy,n.controlPoint.xy,n.endPoint.xy)),t=n.endPoint;break;case u.LineTo:e.push(new s.default(t,n.point)),t=n.point;break;case u.MoveTo:e.push(n.point),t=n.point}return this.cachedGeometry=e,this.cachedGeometry}polylineApproximation(){if(this.cachedPolylineApproximation)return this.cachedPolylineApproximation;const t=[];for(const e of this.parts)switch(e.kind){case u.CubicBezierTo:t.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case u.QuadraticBezierTo:t.push(e.controlPoint,e.endPoint);break;case u.MoveTo:case u.LineTo:t.push(e.point)}const e=[];let n=this.startPoint;for(const i of t)e.push(new s.default(n,i)),n=i;return e}static computeBBoxForSegment(t,e){const n=[t];let i;switch(e.kind){case u.MoveTo:case u.LineTo:n.push(e.point);break;case u.CubicBezierTo:n.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case u.QuadraticBezierTo:n.push(e.controlPoint,e.endPoint);break;default:return i=e,i}return l.default.bboxOf(n)}raymarchIntersectionWith(t,e,n=[]){var i,r;if(!t.bbox.intersects(this.bbox.grownBy(e)))return[];const o=t.length,a=[];for(const n of this.geometry){const i=h(n).grownBy(e);if(!i.intersects(t.bbox))continue;let r;r=n instanceof s.default?t=>n.distance(t):n instanceof d.default?t=>n.minus(t).magnitude():t=>n.project(t).d;const l=t=>r(t)-e;l(t.p1)>o&&l(t.p2)>o||a.push({part:n,distFn:r,bbox:i})}if(0===a.length)return[];const l=t=>{let n=1/0,i=null;const r=[];for(const e of a){const{part:o,distFn:s,bbox:a}=e;if(!a.containsPoint(t)){r.push(e);continue}const l=s(t);l<=n&&(n=l,i=o)}for(const{part:e,distFn:o,bbox:s}of r){if(!s.grownBy(n).containsPoint(t))continue;const r=o(t);r<=n&&(n=r,i=e)}return[i,n-e]},c=[t.p1,...n,t.p2],u=e=>e.minus(t.p1).dot(t.direction);c.sort(((t,e)=>u(t)-u(e)));const p=[],f=e/1e3,m=(e,n,i)=>{let r=e,[s,a]=l(r),c=u(r);if(a>o)return c;const d=t.direction.times(n);for(let t=0;t<7;t++){const t=a;if(r=r.plus(d.times(t)),c=u(r),c<=i)return c;const[e,n]=l(r);if(Math.abs(n)>Math.abs(a))return null;if(a=n,s=e,Math.abs(a)<f)break}return s&&(c>=0&&c<=o)&&Math.abs(a)<f&&p.push({point:r,parameterValue:NaN,curve:s}),c};let g=0;for(let t=0;t<c.length;t++){const e=c[t];g=Math.max(g,null!==(i=m(e,1,g))&&void 0!==i?i:g),g=Math.max(g,null!==(r=m(e,-1,g))&&void 0!==r?r:g)}return p}intersection(t,e){let n=[];if(!t.bbox.intersects(this.bbox.grownBy(null!=e?e:0)))return[];for(const e of this.geometry)if(e instanceof s.default){const i=e.intersection(t);i&&n.push({curve:e,parameterValue:i.t,point:i.point})}else if(e instanceof r.Bezier){const i=e.intersects(t).map((n=>{"string"==typeof n&&(n=parseFloat(n));const i=c.Vec2.ofXY(e.get(n));return i.minus(t.p1).magnitude()>t.length||i.minus(t.p2).magnitude()>t.length?null:{point:i,parameterValue:n,curve:e}})).filter((t=>null!==t));n.push(...i)}if(e&&e>1e-8){const i=n.map((t=>t.point));n=this.raymarchIntersectionWith(t,e,i)}return n}static mapPathCommand(t,e){switch(t.kind){case u.MoveTo:case u.LineTo:return{kind:t.kind,point:e(t.point)};case u.CubicBezierTo:return{kind:t.kind,controlPoint1:e(t.controlPoint1),controlPoint2:e(t.controlPoint2),endPoint:e(t.endPoint)};case u.QuadraticBezierTo:return{kind:t.kind,controlPoint:e(t.controlPoint),endPoint:e(t.endPoint)}}return t}mapPoints(t){const e=t(this.startPoint),n=[];for(const e of this.parts)n.push(p.mapPathCommand(e,t));return new p(e,n)}transformedBy(t){return t.isIdentity()?this:this.mapPoints((e=>t.transformVec2(e)))}union(t){return t?new p(this.startPoint,[...this.parts,{kind:u.MoveTo,point:t.startPoint},...t.parts]):this}getEndPoint(){if(0===this.parts.length)return this.startPoint;const t=this.parts[this.parts.length-1];return t.kind===u.QuadraticBezierTo||t.kind===u.CubicBezierTo?t.endPoint:t.point}roughlyIntersects(t,e=0){if(0===this.parts.length)return t.containsPoint(this.startPoint);if(this.startPoint.eq(this.getEndPoint())&&0===e)return this.closedRoughlyIntersects(t);if(t.containsRect(this.bbox))return!0;let n=this.startPoint;for(const i of this.parts){const r=p.computeBBoxForSegment(n,i).grownBy(e);if(n=i.kind===u.LineTo||i.kind===u.MoveTo?i.point:i.endPoint,t.intersects(r))return!0}return!1}closedRoughlyIntersects(t){if(t.containsRect(this.bbox))return!0;const e=this.bbox.topLeft.minus(c.Vec2.of(1,1)),n=t.corners,i=this.polylineApproximation();for(const t of n){const n=new s.default(t,e);let r=0;for(const t of i)t.intersects(n)&&r++;if(r%2==1)return!0}const r=t.grownBy(Math.min(t.size.x,t.size.y)),o=[];for(const t of r.divideIntoGrid(4,4))o.push(...t.getEdges());for(const t of o)for(const e of i)if(t.intersects(e))return!0;return!1}static fromRect(t,e=null){const n=[];let i,r;if(null!==e){const n=c.Vec2.of(e,e).times(.5),o=l.default.fromCorners(t.topLeft.plus(n),t.bottomRight.minus(n)),s=l.default.fromCorners(t.topLeft.minus(n),t.bottomRight.plus(n));i=[o.corners[3],...o.corners,...s.corners.reverse()],r=s.corners[3]}else i=t.corners.slice(1),r=t.corners[0];for(const t of i)n.push({kind:u.LineTo,point:t});return n.push({kind:u.LineTo,point:r}),new p(r,n)}static fromRenderable(t){return t.path?t.path:new p(t.startPoint,t.commands)}toRenderable(t){return{startPoint:this.startPoint,style:t,commands:this.parts,path:this}}static visualEquivalent(t,e){var n,i;const r=p.fromRenderable(t),o=null!==(i=null===(n=t.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0,s=o>0&&0===t.style.fill.a;if(e.grownBy(o).transformedBoundingBox(a.default.scaling2D(4,e.center)).containsRect(r.bbox.grownBy(o)))return t;const l=[];let c=r.startPoint;for(const t of r.parts){const n=p.computeBBoxForSegment(c,t).grownBy(o);let i;i=t.kind===u.LineTo||t.kind===u.MoveTo?t.point:t.endPoint;n.intersects(e)?l.push(t):s||t.kind===u.MoveTo?l.push({kind:u.MoveTo,point:i}):l.push({kind:u.LineTo,point:i}),c=i}return new p(r.startPoint,l).toRenderable(t.style)}toString(t){if(this.cachedStringVersion)return this.cachedStringVersion;void 0===t&&(t=Math.abs(this.bbox.topLeft.x)>10&&Math.abs(this.bbox.topLeft.y)>10);const e=p.toString(this.startPoint,this.parts,!t);return this.cachedStringVersion=e,e}serialize(){return this.toString()}static toString(t,e,n){var i;const r=[];let s;const a=(t,...e)=>{const i=[],a=[],l=!s||n,c=s?(0,o.toRoundedString)(s.x):"",d=s?(0,o.toRoundedString)(s.y):"";for(const t of e){const e=(0,o.toRoundedString)(t.x),n=(0,o.toRoundedString)(t.y);if(l)i.push(`${e},${n}`);else{const i=(0,o.toStringOfSamePrecision)(t.x-s.x,e,c,d),r=(0,o.toStringOfSamePrecision)(t.y-s.y,n,c,d);"-"===r.charAt(0)?a.push(`${i}${r}`):a.push(`${i},${r}`)}}let u;u=l?`${t}${i.join(" ")}`:`${t.toLowerCase()}${a.join(" ")}`,"l0,0"!==u&&"m0,0"!==u&&(r.push(u),e.length>0&&(s=e[e.length-1]))};let l;(null===(i=e[0])||void 0===i?void 0:i.kind)!==u.MoveTo&&a("M",t);for(let t=0;t<e.length;t++){const n=e[t];switch(n.kind){case u.MoveTo:a("M",n.point);break;case u.LineTo:a("L",n.point);break;case u.CubicBezierTo:a("C",n.controlPoint1,n.controlPoint2,n.endPoint);break;case u.QuadraticBezierTo:a("Q",n.controlPoint,n.endPoint);break;default:return l=n,l}}return r.join("")}static fromString(t){var e;t=t.split("\n").join(" ");let n=c.Vec2.zero,i=null,r=null,o=!0;const s=[],a=t=>{o?o=!1:s.push({kind:u.LineTo,point:t})},l={m:1,l:1,c:3,q:2,z:0,h:1,v:1},d=/([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/gi;let h;for(;null!==(h=d.exec(t));){const t=h[2].trim().split(/[^0-9Ee.-]/).filter((t=>t.length>0)).reduce(((t,e)=>{const n=(e=e.replace(/([^eE])[-]/g,"$1 -")).split(" -");return""!==n[0]&&t.push(n[0]),t.push(...n.slice(1).map((t=>`-${t}`))),t}),[]);let d=t.map((t=>parseFloat(t))),p=h[1].toLowerCase(),x=h[1]!==p;if("v"===p||"h"===p)d=d.reduce(((t,e)=>"v"===p?t.concat(x?n.x:0,e):t.concat(e,x?n.y:0)),[]),p="l";else if("z"===p){if(!i)continue;d=[i.x,i.y],i=n,x=!0,p="l"}const w=null!==(e=l[p])&&void 0!==e?e:0,T=d.reduce(((t,e,n,i)=>{if(n%2!=0){const r=e,o=i[n-1];return t.concat(c.Vec2.of(o,r))}return t}),[]).map(((t,e)=>{let i;return i=x?t:n.plus(t),(e+1)%w==0&&(n=i),i}));if(T.length%w!=0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(T)} with a length of ${T.length} ≠ ${w}k, k ∈ ℤ.`,`The number of arguments to ${p} must be a multiple of ${w}!`,`Command: ${h[0]}`].join("\n"));for(let t=0;t<T.length;t+=w){const e=T.slice(t,t+w);switch(p.toLowerCase()){case"m":0===t?(b=e[0],o?o=!1:s.push({kind:u.MoveTo,point:b})):a(e[0]);break;case"l":a(e[0]);break;case"c":g=e[0],v=e[1],y=e[2],s.push({kind:u.CubicBezierTo,controlPoint1:g,controlPoint2:v,endPoint:y});break;case"q":f=e[0],m=e[1],s.push({kind:u.QuadraticBezierTo,controlPoint:f,endPoint:m});break;default:throw new Error(`Unknown path command ${p}`)}o=!1}T.length>0&&(null!=i||(i=T[0]),null!=r||(r=i),n=T[T.length-1])}var f,m,g,v,y,b;const x=new p(null!=r?r:c.Vec2.zero,s);return x.cachedStringVersion=t,x}}p.empty=new p(c.Vec2.zero,[]),e.default=p},5085:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(9784)),o=n(6750);class s{constructor(t,e,n,i){this.x=t,this.y=e,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=o.Vec2.of(this.x,this.y),this.size=o.Vec2.of(this.w,this.h),this.bottomRight=this.topLeft.plus(this.size),this.center=this.topLeft.plus(this.size.times(.5)),this.area=this.w*this.h}translatedBy(t){return new s(t.x+this.x,t.y+this.y,this.w,this.h)}resizedTo(t){return new s(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.bottomRight.x>=t.bottomRight.x&&this.bottomRight.y>=t.bottomRight.y}intersects(t){const e=this.x,n=e+this.w,i=t.x,r=t.x+t.w;if(n<i||e>r)return!1;const o=this.y,s=o+this.h,a=t.y,l=t.y+t.h;return!(s<a||o>l)}intersection(t){if(!this.intersects(t))return null;const e=this.topLeft.zip(t.topLeft,Math.max),n=this.bottomRight.zip(t.bottomRight,Math.min);return s.fromCorners(e,n)}union(t){return s.union(this,t)}divideIntoGrid(t,e){const n=[];if(t<=0||e<=0)return n;const i=this.w/t,r=this.h/e;0===i&&(t=1),0===r&&(e=1);for(let o=0;o<e;o++)for(let e=0;e<t;e++){const t=i*e+this.x,a=r*o+this.y;n.push(new s(t,a,i,r))}return n}grownToPoint(t,e=0){const n=new s(t.x-e,t.y-e,2*e,2*e);return this.union(n)}grownBy(t){return 0===t?this:new s(this.x-t,this.y-t,this.w+2*t,this.h+2*t)}getClosestPointOnBoundaryTo(t){const e=this.getEdges().map((e=>e.closestPointTo(t)));let n=null,i=null;for(const r of e){const e=r.minus(t).length();(null===i||e<i)&&(n=r,i=e)}return n}get corners(){return[this.bottomRight,this.topRight,this.topLeft,this.bottomLeft]}get maxDimension(){return Math.max(this.w,this.h)}get topRight(){return this.bottomRight.plus(o.Vec2.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(o.Vec2.of(0,this.h))}get width(){return this.w}get height(){return this.h}getEdges(){const t=this.corners;return[new r.default(t[0],t[1]),new r.default(t[1],t[2]),new r.default(t[2],t[3]),new r.default(t[3],t[0])]}transformedBoundingBox(t){return s.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 s(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.abs(t.x-e.x),Math.abs(t.y-e.y))}static bboxOf(t,e=0){let n=0,i=0,r=0,a=0,l=!0;for(const e of t)l&&(n=e.x,i=e.y,r=e.x,a=e.y,l=!1),n=Math.min(n,e.x),i=Math.min(i,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y);return s.fromCorners(o.Vec2.of(n-e,i-e),o.Vec2.of(r+e,a+e))}static union(...t){if(0===t.length)return s.empty;const e=t[0];let n=e.topLeft.x,i=e.topLeft.y,r=e.bottomRight.x,o=e.bottomRight.y;for(let e=1;e<t.length;e++){const s=t[e];n=Math.min(n,s.topLeft.x),i=Math.min(i,s.topLeft.y),r=Math.max(r,s.bottomRight.x),o=Math.max(o,s.bottomRight.y)}return new s(n,i,r-n,o-i)}static of(t){var e,n,i,r;const o=null!==(n=null!==(e=t.width)&&void 0!==e?e:t.w)&&void 0!==n?n:0,a=null!==(r=null!==(i=t.height)&&void 0!==i?i:t.h)&&void 0!==r?r:0;return new s(t.x,t.y,o,a)}}s.empty=new s(0,0,0,0),s.unitSquare=new s(0,0,1,1),e.default=s},6750:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Vec2=void 0;const r=i(n(3785));!function(t){t.of=(t,e)=>r.default.of(t,e,0),t.ofXY=({x:t,y:e})=>r.default.of(t,e,0),t.unitX=t.of(1,0),t.unitY=t.of(0,1),t.zero=t.of(0,0)}(e.Vec2||(e.Vec2={}))},3785:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{constructor(t,e,n){this.x=t,this.y=e,this.z=n}get xy(){return{x:this.x,y:this.y}}static of(t,e,i){return new n(t,e,i)}at(t){if(0===t)return this.x;if(1===t)return this.y;if(2===t)return this.z;throw new Error(`${t} out of bounds!`)}length(){return this.magnitude()}magnitude(){return Math.sqrt(this.dot(this))}magnitudeSquared(){return this.dot(this)}angle(){return Math.atan2(this.y,this.x)}normalized(){const t=this.magnitude();return n.of(this.x/t,this.y/t,this.z/t)}times(t){return n.of(this.x*t,this.y*t,this.z*t)}plus(t){return n.of(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){return n.of(this.x-t.x,this.y-t.y,this.z-t.z)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){return n.of(this.y*t.z-t.y*this.z,t.x*this.z-this.x*t.z,this.x*t.y-t.x*this.y)}scale(t){return"number"==typeof t?this.times(t):n.of(this.x*t.x,this.y*t.y,this.z*t.z)}orthog(){return 0===this.dot(n.unitX)&&0===this.dot(n.unitY)?0===this.dot(n.unitX)?n.unitX:this.cross(n.unitX).normalized():this.cross(n.unitZ.times(-1)).normalized()}extend(t,e){return this.plus(e.normalized().times(t))}lerp(t,e){return this.times(1-e).plus(t.times(e))}zip(t,e){return n.of(e(t.x,this.x),e(t.y,this.y),e(t.z,this.z))}map(t){return n.of(t(this.x,0),t(this.y,1),t(this.z,2))}asArray(){return[this.x,this.y,this.z]}eq(t,e=1e-10){for(let n=0;n<3;n++)if(Math.abs(t.at(n)-this.at(n))>e)return!1;return!0}toString(){return`Vec(${this.x}, ${this.y}, ${this.z})`}}n.unitX=n.of(1,0,0),n.unitY=n.of(0,1,0),n.unitZ=n.of(0,0,1),n.zero=n.of(0,0,0),e.default=n},4915:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Vec2=e.Vec3=e.Rect2=e.Path=e.Mat33=e.LineSegment2=void 0;const r=i(n(9784));e.LineSegment2=r.default;const o=i(n(2054));e.Mat33=o.default;const s=i(n(9765));e.Path=s.default;const a=i(n(5085));e.Rect2=a.default;const l=n(6750);Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return l.Vec2}});const c=i(n(3785));e.Vec3=c.default},148:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(8405),o=n(6750),s=i(n(8198));class a{constructor(t,e,n){this.p0=t,this.p1=e,this.p2=n,this.bezierJs=null}static componentAt(t,e,n,i){return e+t*(-2*e+2*n)+t*t*(e-2*n+i)}static derivativeComponentAt(t,e,n,i){return-2*e+2*n+2*t*(e-2*n+i)}at(t){const e=this.p0,n=this.p1,i=this.p2;return o.Vec2.of(a.componentAt(t,e.x,n.x,i.x),a.componentAt(t,e.y,n.y,i.y))}derivativeAt(t){const e=this.p0,n=this.p1,i=this.p2;return o.Vec2.of(a.derivativeComponentAt(t,e.x,n.x,i.x),a.derivativeComponentAt(t,e.y,n.y,i.y))}approximateDistance(t){const e=this.p0.x-t.x,n=-2*this.p0.x+2*this.p1.x,i=this.p0.x-2*this.p1.x+this.p2.x,r=this.p0.y-t.y,o=-2*this.p0.y+2*this.p1.y,a=this.p0.y-2*this.p1.y+this.p2.y,l=2*e*n+2*r*o-t.x*n-t.y*o,c=2*n*n+2*o*o+2*i*e+2*a*r-t.x*i-t.y*a,d=2*(2*o*a+2*n*i+2*i*n+2*a*o);let[u,h]=(0,s.default)(d/2,c,l);isNaN(u)&&(u=.25),isNaN(h)&&(h=.75);const p=this.at(u),f=this.at(h),m=p.minus(t).magnitudeSquared(),g=f.minus(t).magnitudeSquared(),v=this.at(0).minus(t).magnitudeSquared(),y=this.at(1).minus(t).magnitudeSquared();return Math.sqrt(Math.min(m,g,v,y))}distance(t){return this.bezierJs||(this.bezierJs=new r.Bezier([this.p0.xy,this.p1.xy,this.p2.xy])),this.bezierJs.project(t.xy).d}normal(t){return this.derivativeAt(t).orthog().normalized()}}e.default=a},8198:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e,n)=>{if(0===t){let t;return t=0===e?0===n?0:NaN:-n/e,[t,t]}const i=e*e-4*t*n;if(i<0)return[NaN,NaN];const r=Math.sqrt(i),o=(-e+r)/(2*t),s=(-e-r)/(2*t);return o>s?[o,s]:[s,o]}},1520:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toStringOfSamePrecision=e.getLenAfterDecimal=e.toRoundedString=e.cleanUpNumber=void 0;e.cleanUpNumber=t=>{if(t.indexOf("e")>0&&t.match(/[eE][-]\d{2,}$/))return"0";const e=t.charAt(t.length-1);"0"!==e&&"."!==e||(t=(t=(t=t.replace(/([.]\d*[^0]+)0+$/,"$1")).replace(/[.]0+$/,".")).replace(/[.]$/,""));const n=t.charAt(0);return"0"!==n&&"-"!==n||(t=(t=(t=t.replace(/^(0+)[.]/,".")).replace(/^-(0+)[.]/,"-.")).replace(/^(-?)0+$/,"$10")),"-0"===t?"0":t};e.toRoundedString=t=>{let n=t.toString(10);if(-1===n.indexOf("."))return n;const i=/^([-]?)(\d*)\.(\d{3,}9{4,})\d{1,4}$/.exec(n);if(i){const t=i[1],e=i[3],r=parseInt(e.charAt(e.length-1),10),o=parseInt(e,10),s=parseInt(i[2],10),a=i[3];let l=(o+10-r).toString(),c=0;for(l.length>o.toString().length&&(l=l.substring(1),c=1);l.length<a.length;)l=c.toString(10)+l,c=0;n=`${t+(s+c).toString()}.${l}`}return n=n.replace(/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,"$1"),(0,e.cleanUpNumber)(n)};const n=/^([-]?)(\d*)[.](\d+)$/;e.getLenAfterDecimal=t=>{const e=n.exec(t);if(!e)return-1!==t.search(/[eE]/)||/^[a-zA-Z]+$/.exec(t)?-1:0;return e[3].length};e.toStringOfSamePrecision=(t,...i)=>{const r=t.toString(10),o=n.exec(r);if(!o)return r;let s=-1;for(const t of i)s=Math.max((0,e.getLenAfterDecimal)(t),s);if(-1===s)return(0,e.toRoundedString)(t);let a=o[3].substring(0,s),l=o[2];const c=o[3].charAt(s);if(""!==c){if(parseInt(c,10)>=5){if(a.length>0){const t=/^(0+)(\d*)$/.exec(a);let e="",n=a;t&&(e=t[1],n=t[2]),a=(parseInt(a)+1).toString(),a.length>n.length&&e.length>0&&(e=e.substring(1)),a=e+a}(0===a.length||a.length>s)&&(l=(parseInt(l)+1).toString(),a=a.substring(1))}}const d=o[1];return(0,e.cleanUpNumber)(`${d}${l}.${a}`)}},5860:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RenderingMode=void 0;const r=i(n(972)),o=n(9699),s=i(n(1782)),a=n(6750),l=i(n(3061)),c=i(n(2634)),d=i(n(8233));var u;!function(t){t[t.DummyRenderer=0]="DummyRenderer",t[t.CanvasRenderer=1]="CanvasRenderer"}(u=e.RenderingMode||(e.RenderingMode={}));e.default=class{constructor(t,e,n){if(this.editor=t,this.parent=n,this.textRerenderOutput=null,this.getColorAt=t=>null,e===u.CanvasRenderer)this.initializeCanvasRendering();else{if(e!==u.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 i=a.Vec2.of(600,600);this.cache=new l.default({createRenderer:()=>{if(e===u.DummyRenderer)return new s.default(t.viewport);if(e!==u.CanvasRenderer)throw new Error("Unspported rendering mode");const n=document.createElement("canvas");n.width=i.x+1,n.height=i.y+1;const o=n.getContext("2d");return new r.default(o,t.viewport)},isOfCorrectType:t=>this.dryInkRenderer.canRenderFromWithoutDataLoss(t),blockResolution:i,cacheSize:1296e5,maxScale:1.3,minProportionalRenderTimePerCache:80,minProportionalRenderTimeToUseCache:420}),this.editor.notifier.on(o.EditorEventType.DisplayResized,(t=>{var e;if(t.kind!==o.EditorEventType.DisplayResized)throw new Error("Mismatched event.kinds!");null===(e=this.resizeSurfacesCallback)||void 0===e||e.call(this)}))}get width(){return this.dryInkRenderer.displaySize().x}get height(){return this.dryInkRenderer.displaySize().y}getCache(){return this.cache}initializeCanvasRendering(){const t=document.createElement("canvas"),e=document.createElement("canvas"),n=t.getContext("2d"),i=e.getContext("2d");this.dryInkRenderer=new r.default(n,this.editor.viewport),this.wetInkRenderer=new r.default(i,this.editor.viewport),t.className="dryInkCanvas",e.className="wetInkCanvas",this.parent&&(this.parent.appendChild(t),this.parent.appendChild(e)),this.resizeSurfacesCallback=()=>{const n=t=>t.clientHeight!==t.height||t.clientWidth!==t.width;(n(t)||n(e))&&(t.width=t.clientWidth,t.height=t.clientHeight,e.width=e.clientWidth,e.height=e.clientHeight,this.editor.notifier.dispatch(o.EditorEventType.DisplayResized,{kind:o.EditorEventType.DisplayResized,newSize:a.Vec2.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{n.drawImage(e,0,0)},this.getColorAt=t=>{const e=n.getImageData(t.x,t.y,1,1),i=null==e?void 0:e.data;if(i){return d.default.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)}rerenderAsText(){this.textRenderer.clear(),this.editor.image.render(this.textRenderer,this.editor.viewport),this.textRerenderOutput&&(this.textRerenderOutput.innerText=this.textRenderer.getDescription())}startRerender(){var t;return null===(t=this.resizeSurfacesCallback)||void 0===t||t.call(this),this.dryInkRenderer.clear(),this.dryInkRenderer}setDraftMode(t){this.dryInkRenderer.setDraftMode(t)}getDryInkRenderer(){return this.dryInkRenderer}getWetInkRenderer(){return this.wetInkRenderer}flatten(){var t;null===(t=this.flattenCallback)||void 0===t||t.call(this)}}},9604:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.styleFromJSON=e.styleToJSON=e.stylesEqual=e.cloneStyle=void 0;const r=i(n(8233));e.cloneStyle=t=>({fill:t.fill,stroke:t.stroke?Object.assign({},t.stroke):void 0});e.stylesEqual=(t,e)=>{var n,i,r,o,s,a;const l=t===e||t.fill.eq(e.fill)&&null==t.stroke==(null==e.stroke)&&(null===(o=null===(i=null===(n=t.stroke)||void 0===n?void 0:n.color)||void 0===i?void 0:i.eq(null===(r=e.stroke)||void 0===r?void 0:r.color))||void 0===o||o)&&(null===(s=t.stroke)||void 0===s?void 0:s.width)===(null===(a=e.stroke)||void 0===a?void 0:a.width);return null!=l&&l};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:r.default.fromHex(t.stroke.color),width:t.stroke.width}:void 0;return{fill:r.default.fromHex(t.fill),stroke:e}}},1281:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.textStyleToJSON=e.textStyleFromJSON=e.cloneTextStyle=void 0;const i=n(9604);e.cloneTextStyle=t=>Object.assign(Object.assign({},t),{renderingStyle:(0,i.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,i.styleFromJSON)(t.renderingStyle),size:t.size,fontWeight:t.fontWeight,fontVariant:t.fontVariant,fontFamily:t.fontFamily}};e.textStyleToJSON=t=>Object.assign(Object.assign({},t),{renderingStyle:(0,i.styleToJSON)(t.renderingStyle)})},4999:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2054));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(){var t;null===(t=this.onBeforeDeallocCallback)||void 0===t||t.call(this),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 r.default.scaling2D(this.cacheState.props.blockResolution.x/t.size.x).rightMul(r.default.translation(t.topLeft.times(-1)))}setRenderingRegion(t){this.renderer.setTransform(this.getTransform(t))}}},1390:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CacheRecordManager=void 0;const r=i(n(4999));e.CacheRecordManager=class{constructor(t){this.cacheRecords=[],this.maxCanvases=Math.ceil(t.cacheSize/4/t.blockResolution.x/t.blockResolution.y)}setSharedState(t){this.cacheState=t}allocCanvas(t,e){if(this.cacheRecords.length<this.maxCanvases){const n=new r.default(e,this.cacheState);return n.setRenderingRegion(t),this.cacheRecords.push(n),n}{const n=this.getLeastRecentlyUsedRecord();return n.realloc(e),n.setRenderingRegion(t),n}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort(((t,e)=>t.getLastUsedCycle()-e.getLastUsedCycle())),this.cacheRecords[0]}}},3061:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(5085)),o=i(n(6899)),s=n(1390);e.default=class{constructor(t){this.recordManager=new s.CacheRecordManager(t),this.sharedState={props:t,currentRenderingCycle:0,recordManager:this.recordManager},this.recordManager.setSharedState(this.sharedState)}render(t,e,n){var i;const s=n.visibleRect;if(this.sharedState.currentRenderingCycle++,!this.sharedState.props.isOfCorrectType(t))return void e.render(t,s);if(!this.rootNode){const t=this.sharedState.props.blockResolution,e=s.topLeft;this.rootNode=new o.default(new r.default(e.x,e.y,t.x,t.y),this.sharedState)}for(;!this.rootNode.region.containsRect(s);)this.rootNode=this.rootNode.generateParent();this.rootNode=null!==(i=this.rootNode.smallestChildContaining(s))&&void 0!==i?i:this.rootNode;const a=e.getLeavesIntersectingRegion(n.visibleRect,(e=>t.isTooSmallToRender(e)));let l=0;for(const t of a)l+=t.getContent().getProportionalRenderingTime();l>this.sharedState.props.minProportionalRenderTimeToUseCache?this.rootNode.renderItems(t,[e],n):e.render(t,s)}}},6899:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});i(n(8233));const r=n(4721),o=i(n(5085)),s=!1;class a{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=o.default.fromCorners(this.region.topLeft.minus(this.region.size),this.region.bottomRight.plus(this.region.size)),e=new a(t,this.cacheState);e.generateChildren();const n=this.region.maxDimension/100,i=(e.instantiatedChildren.length-1)/2;if(!e.instantiatedChildren[i].region.eq(this.region,n))throw console.error(e.instantiatedChildren[i].region,"≠",this.region),new Error("Logic error: [this] is not contained within its parent's center child");return e.instantiatedChildren[i]=this,this.parent=e,e}generateChildren(){if(0===this.instantiatedChildren.length){const t=this.region.divideIntoGrid(3,3);if(0===this.region.size.x||0===this.region.size.y)return void console.warn("Cache element has zero size! Not generating children.");for(const e of t){const t=new a(e,this.cacheState);t.parent=this,this.instantiatedChildren.push(t)}}this.checkRep()}getChildren(){return this.checkRep(),this.generateChildren(),this.instantiatedChildren}smallestChildContaining(t){var e;const n=t.maxDimension>this.region.maxDimension/3;if(!this.region.containsRect(t)||n)return null;for(const n of this.getChildren())if(n.region.containsRect(t))return null!==(e=n.smallestChildContaining(t))&&void 0!==e?e:n;return null}renderingWouldBeHighEnoughResolution(t){const e=this.region.w/this.cacheState.props.blockResolution.x;return!(t.getScaleFactor()*e>this.cacheState.props.maxScale)}allChildrenCanRender(t,e){if(0===this.instantiatedChildren.length)return!1;for(const n of this.instantiatedChildren)if(n.region.intersects(t.visibleRect)&&!n.renderingIsUpToDate(this.idsOfIntersecting(e)))return!1;return!0}computeSortedByLeafIds(t){const e=t.slice();return e.sort(((t,e)=>t.getId()-e.getId())),e}idsOfIntersecting(t){const e=[];for(const n of t)n.getBBox().intersects(this.region)&&e.push(n.getId());return e}allRenderedIdsIn(t){if(this.renderedIds.length>t.length)return!1;for(let e=0;e<this.renderedIds.length;e++)if(t[e]!==this.renderedIds[e])return!1;return!0}renderingIsUpToDate(t){return null!==this.cachedRenderer&&t.length===this.renderedIds.length&&this.allRenderedIdsIn(t)}renderItems(t,e,n){var i,a;if(!n.visibleRect.intersects(this.region)||0===e.length)return;const l=[];for(const t of e){const e=t.getBBox();e.intersects(this.region)&&(e.maxDimension>=this.region.maxDimension?l.push(...t.getChildrenOrSelfIntersectingRegion(this.region)):l.push(t))}if(e=l,!this.cacheState.props.isOfCorrectType(t))return void e.forEach((e=>e.render(t,n.visibleRect)));if(this.renderingWouldBeHighEnoughResolution(n)){const l=t=>t.w/this.region.w<1/this.cacheState.props.blockResolution.x,c=[];for(const t of e)c.push(...t.getLeavesIntersectingRegion(this.region,l));(0,r.sortLeavesByZIndex)(c);const d=this.computeSortedByLeafIds(c);if(0===d.length)return;const u=d.map((t=>t.getId()));let h;if(this.renderingIsUpToDate(u))h=this.cachedRenderer.startRender();else{if(this.allChildrenCanRender(n,d)){for(const i of this.getChildren())i.renderItems(t,e,n);return}let r=0;for(const t of d)r+=t.getContent().getProportionalRenderingTime();if(r>this.cacheState.props.minProportionalRenderTimePerCache){let t=!0;if(this.cachedRenderer)if(d.length>this.renderedIds.length&&this.allRenderedIdsIn(u)&&null!==this.renderedMaxZIndex){const e=[];let n=null;for(let t=0;t<d.length;t++){const i=d[t],r=i.getContent().getZIndex();(t>=this.renderedIds.length||i.getId()!==this.renderedIds[t])&&(e.push(i),(null===n||r<n)&&(n=r))}if(null!==n&&n>this.renderedMaxZIndex){t=!1,h=this.cachedRenderer.startRender();for(let t=0;t<c.length;t++){const e=c[t],n=e.getContent().getZIndex();n>this.renderedMaxZIndex&&(e.render(h,this.region),this.renderedMaxZIndex=n)}s}}else s;else this.cachedRenderer=this.cacheState.recordManager.allocCanvas(this.region,(()=>this.onRegionDealloc()));if(t){h=this.cachedRenderer.startRender(),h.clear(),this.renderedMaxZIndex=null;for(const t of c){const e=t.getContent();null!==(i=this.renderedMaxZIndex)&&void 0!==i||(this.renderedMaxZIndex=e.getZIndex()),this.renderedMaxZIndex=Math.max(this.renderedMaxZIndex,e.getZIndex()),t.render(h,this.region)}s}this.renderedIds=u}else{null===(a=this.cachedRenderer)||void 0===a||a.dealloc();const e=n.getSizeOfPixelOnCanvas(),i=new o.default(this.region.x,this.region.y,this.region.w+e,this.region.h+e),r=!0;t.startObject(i,r);for(const e of c)e.render(t,this.region.intersection(n.visibleRect));t.endObject()}}if(h){const e=this.cachedRenderer.getTransform(this.region).inverse();t.renderFromOtherOfSameType(e,h)}this.instantiatedChildren.every((t=>t.isEmpty()))&&(this.instantiatedChildren=[])}else for(const i of this.getChildren())i.renderItems(t,e.filter((t=>t.getBBox().intersects(i.region))),n);this.checkRep()}isEmpty(){return null===this.cachedRenderer&&this.instantiatedChildren.every((t=>t.isEmpty()))}onRegionDealloc(){this.cachedRenderer=null,this.isEmpty()&&(this.instantiatedChildren=[])}checkRep(){if(9!==this.instantiatedChildren.length&&0!==this.instantiatedChildren.length)throw new Error(`Repcheck: Wrong number of children. Got ${this.instantiatedChildren.length}`);if(void 0!==this.renderedIds[1]&&this.renderedIds[0]>=this.renderedIds[1])throw console.error(this.renderedIds),new Error("Repcheck: First two ids are not in ascending order!");for(const t of this.instantiatedChildren)if(t.parent!==this)throw new Error("Children should be linked to their parents!");if(this.cachedRenderer&&!this.cachedRenderer.isAllocd())throw new Error("this' cachedRenderer != null, but is dealloc'd")}}e.default=a},5414:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RenderingMode=e.Display=e.CanvasRenderer=e.SVGRenderer=e.DummyRenderer=e.AbstractRenderer=void 0;var r=n(8157);Object.defineProperty(e,"AbstractRenderer",{enumerable:!0,get:function(){return i(r).default}});var o=n(1782);Object.defineProperty(e,"DummyRenderer",{enumerable:!0,get:function(){return i(o).default}});var s=n(9563);Object.defineProperty(e,"SVGRenderer",{enumerable:!0,get:function(){return i(s).default}});var a=n(972);Object.defineProperty(e,"CanvasRenderer",{enumerable:!0,get:function(){return i(a).default}});var l=n(5860);Object.defineProperty(e,"Display",{enumerable:!0,get:function(){return i(l).default}}),Object.defineProperty(e,"RenderingMode",{enumerable:!0,get:function(){return l.RenderingMode}})},1603:(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"}},8157:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});const s=o(n(9765)),a=n(6750),l=n(9604);e.default=class{constructor(t){this.viewport=t,this.selfTransform=null,this.transformStack=[],this.objectLevel=0,this.currentPaths=null}getViewport(){return this.viewport}setDraftMode(t){}flushPath(){if(!this.currentPaths)return;let t=null;for(const e of this.currentPaths){const{startPoint:n,commands:i,style:r}=e;t&&(0,l.stylesEqual)(t,r)?this.moveTo(n):(t&&this.endPath(t),this.beginPath(n),t=r);for(const t of i)t.kind===s.PathCommandType.LineTo?this.lineTo(t.point):t.kind===s.PathCommandType.MoveTo?this.moveTo(t.point):t.kind===s.PathCommandType.CubicBezierTo?this.traceCubicBezierCurve(t.controlPoint1,t.controlPoint2,t.endPoint):t.kind===s.PathCommandType.QuadraticBezierTo&&this.traceQuadraticBezierCurve(t.controlPoint,t.endPoint)}t&&this.endPath(t)}drawPath(t){0===this.objectLevel?(this.currentPaths=[t],this.flushPath(),this.currentPaths=null):this.currentPaths.push(t)}drawRect(t,e,n){const i=s.default.fromRect(t,e);this.drawPath(i.toRenderable(n))}fillRect(t,e){const n=s.default.fromRect(t);this.drawPath(n.toRenderable({fill:e}))}startObject(t,e){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(){var t;if(0===this.transformStack.length)throw new Error("Unable to pop more transforms than have been pushed!");this.setTransform(null!==(t=this.transformStack.pop())&&void 0!==t?t:null)}getCanvasToScreenTransform(){return this.selfTransform?this.selfTransform:this.viewport.canvasToScreenTransform}canvasToScreen(t){return this.getCanvasToScreenTransform().transformVec2(t)}getSizeOfCanvasPixelOnScreen(){return this.getCanvasToScreenTransform().transformVec3(a.Vec2.unitX).length()}}},972:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=i(n(6205)),s=i(n(9765)),a=n(6750),l=i(n(8157));class c extends l.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 c}renderFromOtherOfSameType(t,e){if(!(e instanceof c))throw new Error(`${e} cannot be rendered onto ${this}`);t=this.getCanvasToScreenTransform().rightMul(t),this.ctx.save(),this.transformBy(t),this.ctx.drawImage(e.ctx.canvas,0,0),this.ctx.restore()}setDraftMode(t){t?(this.minSquareCurveApproxDist=9,this.minRenderSizeBothDimens=2,this.minRenderSizeAnyDimen=.5):(this.minSquareCurveApproxDist=.5,this.minRenderSizeBothDimens=.2,this.minRenderSizeAnyDimen=1e-6)}displaySize(){return a.Vec2.of(this.ctx.canvas.clientWidth,this.ctx.canvas.clientHeight)}clear(){this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}beginPath(t){t=this.canvasToScreen(t),this.ctx.beginPath(),this.ctx.moveTo(t.x,t.y)}endPath(t){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.closePath()}lineTo(t){t=this.canvasToScreen(t),this.ctx.lineTo(t.x,t.y)}moveTo(t){t=this.canvasToScreen(t),this.ctx.moveTo(t.x,t.y)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n);const i=e.minus(t),r=n.minus(e);i.magnitudeSquared()<this.minSquareCurveApproxDist&&r.magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(n.x,n.y):this.ctx.bezierCurveTo(t.x,t.y,e.x,e.y,n.x,n.y)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e);t.minus(e).magnitudeSquared()<this.minSquareCurveApproxDist?this.ctx.lineTo(e.x,e.y):this.ctx.quadraticCurveTo(t.x,t.y,e.x,e.y)}drawPath(t){var e;this.ignoringObject||((null===(e=this.currentObjectBBox)||void 0===e?void 0:e.containsRect(this.getViewport().visibleRect))&&(t=s.default.visualEquivalent(t,this.getViewport().visibleRect)),super.drawPath(t))}drawText(t,e,n){this.ctx.save(),e=this.getCanvasToScreenTransform().rightMul(e),this.transformBy(e),o.default.applyTextStyles(this.ctx,n),0!==n.renderingStyle.fill.a&&(this.ctx.fillStyle=n.renderingStyle.fill.toHexString(),this.ctx.fillText(t,0,0)),n.renderingStyle.stroke&&(this.ctx.strokeStyle=n.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=n.renderingStyle.stroke.width,this.ctx.strokeText(t,0,0)),this.ctx.restore()}drawImage(t){this.ctx.save();const e=this.getCanvasToScreenTransform().rightMul(t.transform);this.transformBy(e),this.ctx.drawImage(t.image,0,0),this.ctx.restore()}startObject(t,e){if(this.isTooSmallToRender(t)&&(this.ignoreObjectsAboveLevel=this.getNestingLevel(),this.ignoringObject=!0),super.startObject(t),this.currentObjectBBox=t,!this.ignoringObject&&e){this.clipLevels.push(this.objectLevel),this.ctx.save(),this.ctx.beginPath();for(const e of t.corners){const t=this.canvasToScreen(e);this.ctx.lineTo(t.x,t.y)}this.ctx.clip()}}endObject(){const t=this.objectLevel;this.currentObjectBBox=null,super.endObject(),!this.ignoringObject&&this.clipLevels.length>0&&this.clipLevels[this.clipLevels.length-1]===t&&(this.ctx.restore(),this.clipLevels.pop()),null!==this.ignoreObjectsAboveLevel&&this.getNestingLevel()<=this.ignoreObjectsAboveLevel&&(this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1)}drawPoints(...t){for(let e=0;e<t.length;e++){const n=this.canvasToScreen(t[e]);this.ctx.beginPath(),this.ctx.arc(n.x,n.y,10,0,2*Math.PI),this.ctx.fillStyle=r.default.ofRGBA(.5+Math.sin(e)/2,1,.5+Math.cos(.2*e)/4,.5).toHexString(),this.ctx.fill(),this.ctx.stroke(),this.ctx.closePath(),this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillStyle="black",this.ctx.fillText(`${e}`,n.x,n.y,20)}}isTooSmallToRender(t){const e=this.getCanvasToScreenTransform().transformVec3(t.size),n=this.minRenderSizeBothDimens,i=Math.abs(e.x)<n&&Math.abs(e.y)<n,r=this.minRenderSizeAnyDimen,o=Math.abs(e.x)<r||Math.abs(e.y)<r;return i||o}}e.default=c},1782:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6750),o=i(n(8157));class s extends o.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?r.Vec2.of(640,480):t}clear(){if(this.clearedCount++,this.renderedPathCount=0,this.pointBuffer=[],this.lastText=null,this.lastImage=null,this.objectNestingLevel>0)throw new Error(`Within an object while clearing! Nesting level: ${this.objectNestingLevel}`)}beginPath(t){this.lastPoint=t,this.pointBuffer.push(t)}endPath(t){this.renderedPathCount++,this.lastFillStyle=t}lineTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}moveTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n),this.lastPoint=n,this.pointBuffer.push(t,e,n)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(t,e)}drawPoints(...t){}drawText(t,e,n){this.lastText=t}drawImage(t){this.lastImage=t}startObject(t,e){super.startObject(t),this.objectNestingLevel+=1}endObject(){super.endObject(),this.objectNestingLevel-=1}isTooSmallToRender(t){return!1}canRenderFromWithoutDataLoss(t){return t instanceof s}renderFromOtherOfSameType(t,e){if(!(e instanceof s))throw new Error(`${e} cannot be rendered onto ${this}`);this.renderedPathCount+=e.renderedPathCount,this.lastFillStyle=e.lastFillStyle,this.lastPoint=e.lastPoint,this.pointBuffer.push(...e.pointBuffer.map((e=>t.transformVec2(e))))}}e.default=s},9563:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.renderedStylesheetId=void 0;const r=i(n(2054)),o=i(n(9765)),s=n(1520),a=n(6750),l=n(8684),c=n(9604),d=i(n(8157));e.renderedStylesheetId="js-draw-style-sheet";const u="http://www.w3.org/2000/svg";class h extends d.default{constructor(t,e,n=!1){super(e),this.elem=t,this.sanitize=n,this.lastPathStyle=null,this.lastPathString=[],this.objectElems=null,this.overwrittenAttrs={},this.textContainer=null,this.textContainerTransform=null,this.textParentStyle=null,this.clear(),this.addStyleSheet()}addStyleSheet(){if(!this.elem.querySelector(`#${e.renderedStylesheetId}`)){const t=document.createElementNS("http://www.w3.org/2000/svg","style");t.innerHTML="\n\t\t\t\tpath {\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t}\n\n\t\t\t\ttext {\n\t\t\t\t\twhite-space: pre;\n\t\t\t\t}\n\t\t\t".replace(/\s+/g,""),t.setAttribute("id",e.renderedStylesheetId),this.elem.appendChild(t)}}setRootSVGAttribute(t,e){this.sanitize||(t in this.overwrittenAttrs||(this.overwrittenAttrs[t]=this.elem.getAttribute(t)),null!==e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t))}displaySize(){return a.Vec2.of(this.elem.clientWidth,this.elem.clientHeight)}clear(){if(this.lastPathString=[],!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(){var t;if(!this.lastPathStyle||0===this.lastPathString.length)return;const e=document.createElementNS(u,"path");e.setAttribute("d",this.lastPathString.join(" "));const n=this.lastPathStyle;n.fill.a>0?e.setAttribute("fill",n.fill.toHexString()):e.setAttribute("fill","none"),n.stroke&&(e.setAttribute("stroke",n.stroke.color.toHexString()),e.setAttribute("stroke-width",(0,s.toRoundedString)(n.stroke.width))),this.elem.appendChild(e),null===(t=this.objectElems)||void 0===t||t.push(e)}drawPath(t){const e=t.style,n=o.default.fromRenderable(t).transformedBy(this.getCanvasToScreenTransform());0!==this.lastPathString.length&&this.lastPathStyle&&(0,c.stylesEqual)(this.lastPathStyle,e)||(this.addPathToSVG(),this.lastPathStyle=e,this.lastPathString=[]),this.lastPathString.push(n.toString())}transformFrom(t,e,n=!1,i=!0){let o=n?t:this.getCanvasToScreenTransform().rightMul(t);const l=o.transformVec2(a.Vec2.zero);i&&(o=o.rightMul(r.default.translation(l.times(-1)))),o.eq(r.default.identity)?e.style.transform="":e.style.transform=`matrix(\n\t\t\t\t${o.a1}, ${o.b1},\n\t\t\t\t${o.a2}, ${o.b2},\n\t\t\t\t${o.a3}, ${o.b3}\n\t\t\t)`,i&&(e.setAttribute("x",`${(0,s.toRoundedString)(l.x)}`),e.setAttribute("y",`${(0,s.toRoundedString)(l.y)}`))}drawText(t,e,n){var i;const r=(t,e)=>{var n,i,r,o,s,a;e.fontFamily!==(null===(n=this.textParentStyle)||void 0===n?void 0:n.fontFamily)&&(t.style.fontFamily=e.fontFamily),e.fontVariant!==(null===(i=this.textParentStyle)||void 0===i?void 0:i.fontVariant)&&(t.style.fontVariant=null!==(r=e.fontVariant)&&void 0!==r?r:""),e.fontWeight!==(null===(o=this.textParentStyle)||void 0===o?void 0:o.fontWeight)&&(t.style.fontWeight=null!==(s=e.fontWeight)&&void 0!==s?s:""),e.size!==(null===(a=this.textParentStyle)||void 0===a?void 0:a.size)&&(t.style.fontSize=e.size+"px");const l=e.renderingStyle.fill.toHexString();if(t.style.fill=l,e.renderingStyle.stroke){const n=e.renderingStyle.stroke;t.style.stroke=n.color.toHexString(),t.style.strokeWidth=n.width+"px"}};if(e=this.getCanvasToScreenTransform().rightMul(e),this.textContainer){const i=document.createElementNS(u,"tspan");i.appendChild(document.createTextNode(t)),this.textContainer.appendChild(i);const o=(e=this.textContainerTransform.inverse().rightMul(e)).transformVec2(a.Vec2.zero);i.setAttribute("x",`${(0,s.toRoundedString)(o.x)}`),i.setAttribute("y",`${(0,s.toRoundedString)(o.y)}`),r(i,n)}else{const o=document.createElementNS(u,"text");o.appendChild(document.createTextNode(t));const s=!1;this.transformFrom(e,o,!0,s),r(o,n),this.elem.appendChild(o),null===(i=this.objectElems)||void 0===i||i.push(o),this.objectLevel>0&&(this.textContainer=o,this.textContainerTransform=e,this.textParentStyle=n)}}drawImage(t){var e,n,i,r,o,s;let a=null!==(n=null!==(e=t.label)&&void 0!==e?e:t.image.getAttribute("aria-label"))&&void 0!==n?n:"";""===a&&(a=null!==(i=t.image.getAttribute("alt"))&&void 0!==i?i:"");const l=document.createElementNS(u,"image");l.setAttribute("href",t.base64Url),l.setAttribute("width",null!==(r=t.image.getAttribute("width"))&&void 0!==r?r:""),l.setAttribute("height",null!==(o=t.image.getAttribute("height"))&&void 0!==o?o:""),l.setAttribute("aria-label",a),this.transformFrom(t.transform,l),this.elem.appendChild(l),null===(s=this.objectElems)||void 0===s||s.push(l)}startObject(t){super.startObject(t),this.lastPathString=[],this.lastPathStyle=null,this.textContainer=null,this.textParentStyle=null,this.objectElems=[]}endObject(t,e){var n;if(super.endObject(t),this.addPathToSVG(),t&&!this.sanitize)for(const e of null!==(n=this.objectElems)&&void 0!==n?n:[]){const n=t[l.svgAttributesDataKey],i=t[l.svgStyleAttributesDataKey];if(n)for(const[t,i]of n)e.setAttribute(t,i);if(i)for(const t of i)e.style.setProperty(t.key,t.value,t.priority)}if(e&&this.objectElems)if(1===this.objectElems.length)this.objectElems[0].classList.add(...e);else{const t=document.createElementNS(u,"g");t.classList.add(...e);for(const e of this.objectElems)e.remove(),t.appendChild(e);this.elem.appendChild(t)}}unimplementedMessage(){throw new Error("Not implemenented!")}beginPath(t){this.unimplementedMessage()}endPath(t){this.unimplementedMessage()}lineTo(t){this.unimplementedMessage()}moveTo(t){this.unimplementedMessage()}traceCubicBezierCurve(t,e,n){this.unimplementedMessage()}traceQuadraticBezierCurve(t,e){this.unimplementedMessage()}drawPoints(...t){t.map((t=>{const e=document.createElementNS(u,"circle");e.setAttribute("cx",`${t.x}`),e.setAttribute("cy",`${t.y}`),e.setAttribute("r","15"),this.elem.appendChild(e)}))}drawSVGElem(t){this.sanitize||"style"===t.tagName.toLowerCase()&&t.getAttribute("id")===e.renderedStylesheetId||this.elem.appendChild(t.cloneNode(!0))}isTooSmallToRender(t){return!1}static fromViewport(t,e=!0){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg"),r=t.getScreenRectSize();return i.setAttribute("viewBox",[0,0,r.x,r.y].map((t=>(0,s.toRoundedString)(t))).join(" ")),i.setAttribute("width",(0,s.toRoundedString)(r.x)),i.setAttribute("height",(0,s.toRoundedString)(r.y)),i.setAttribute("version","1.1"),i.setAttribute("baseProfile","full"),i.setAttribute("xmlns",n),{element:i,renderer:new h(i,t,e)}}}e.default=h},2634:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6750),o=i(n(8157));class s extends o.default{constructor(t,e){super(t),this.localizationTable=e,this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}displaySize(){return r.Vec2.of(500,500)}clear(){this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0}getDescription(){return[this.localizationTable.pathNodeCount(this.pathCount),...this.textNodeCount>0?[this.localizationTable.textNodeCount(this.textNodeCount)]:[],...this.imageNodeCount>0?[this.localizationTable.imageNodeCount(this.imageNodeCount)]:[],...this.descriptionBuilder].join("\n")}beginPath(t){}endPath(t){this.pathCount++}lineTo(t){}moveTo(t){}traceCubicBezierCurve(t,e,n){}traceQuadraticBezierCurve(t,e){}drawText(t,e,n){this.descriptionBuilder.push(this.localizationTable.textNode(t)),this.textNodeCount++}drawImage(t){const e=t.label?this.localizationTable.imageNode(t.label):this.localizationTable.unlabeledImageNode;this.descriptionBuilder.push(e),this.imageNodeCount++}isTooSmallToRender(t){return t.maxDimension<15/this.getSizeOfCanvasPixelOnScreen()}drawPoints(...t){}}e.default=s},2862:function(t,e,n){"use strict";var i=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 r=n(6485);Object.defineProperty(e,"sendPenEvent",{enumerable:!0,get:function(){return i(r).default}});var o=n(7236);Object.defineProperty(e,"sendTouchEvent",{enumerable:!0,get:function(){return i(o).default}})},6485:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(306)),o=n(9699);e.default=(t,e,n,i)=>{const s=r.default.ofCanvasPoint(n,e!==o.InputEvtType.PointerUpEvt,t.viewport);t.toolController.dispatchInputEvent({kind:e,allPointers:null!=i?i:[s],current:s})}},7236:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});const s=o(n(306)),a=n(9699);e.default=(t,e,n,i)=>{const r=t.viewport.screenToCanvas(n);let o=0,l=0;for(const t of null!=i?i:[])l=Math.max(t.id,l),t.id===o&&(o=l+1);const c=s.default.ofCanvasPoint(r,e!==a.InputEvtType.PointerUpEvt,t.viewport,o,s.PointerDevice.Touch);return t.toolController.dispatchInputEvent({kind:e,allPointers:[...null!=i?i:[],c],current:c}),c}},7389:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.toolbarCSSPrefix=void 0;const r=n(9699),o=n(7629),s=i(n(8233)),a=n(3940),l=i(n(1626)),c=i(n(135)),d=i(n(2100)),u=i(n(9270)),h=i(n(7052)),p=i(n(3770)),f=i(n(2297)),m=i(n(6282)),g=i(n(6937)),v=i(n(5627)),y=i(n(5710)),b=i(n(2085)),x=i(n(234)),w=i(n(1278)),T=n(6750);e.toolbarCSSPrefix="toolbar-";class S{constructor(t,n,i=a.defaultToolbarLocalization){this.editor=t,this.localizationTable=i,this.listeners=[],this.widgetOrderCounter=0,this.widgetsById={},this.widgetList=[],this.overflowWidget=null,this.updateColoris=null,this.closeColorPickerOverlay=null,this.reLayoutQueued=!1,this.container=document.createElement("div"),this.container.classList.add(`${e.toolbarCSSPrefix}root`),this.container.setAttribute("role","toolbar"),n.appendChild(this.container),S.colorisStarted||((0,o.init)(),S.colorisStarted=!0),this.setupColorPickers(),"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver((t=>{this.reLayout()})),this.resizeObserver.observe(this.container)):console.warn("ResizeObserver not supported. Toolbar will not resize.")}setupCloseColorPickerOverlay(){if(this.closeColorPickerOverlay)return;this.closeColorPickerOverlay=document.createElement("div"),this.closeColorPickerOverlay.className=`${e.toolbarCSSPrefix}closeColorPickerOverlay`,this.editor.createHTMLOverlay(this.closeColorPickerOverlay);let t=[],n=null;this.listeners.push(this.editor.handlePointerEventsFrom(this.closeColorPickerOverlay,((e,i)=>{var r,s;const a=T.Vec2.of(i.pageX,i.pageY);let l=!0;if("pointerdown"===e)(0,o.close)(),t=[],t.push([e,i]),n=a,null===(r=this.closeColorPickerOverlay)||void 0===r||r.setPointerCapture(i.pointerId),l=!1;else if("pointermove"===e){const r=10;if(n&&a.minus(n).magnitude()<r)t.push([e,i]),l=!1;else{for(const[e,n]of t)this.editor.handleHTMLPointerEvent(e,n);t=[],l=!0}}else("pointerup"===e||"pointercancel"===e)&&t.length>0&&(null===(s=this.closeColorPickerOverlay)||void 0===s||s.releasePointerCapture(i.pointerId),t=[],l=!1);return"pointerup"===e&&this.editor.focus(),l})))}setupColorPickers(){if(this.updateColoris)return void this.updateColoris();this.setupCloseColorPickerOverlay();const t=[s.default.red.toHexString(),s.default.purple.toHexString(),s.default.blue.toHexString(),s.default.clay.toHexString(),s.default.black.toHexString(),s.default.white.toHexString()],e=t.length,n=()=>{(0,o.coloris)({el:".coloris_input",format:"hex",selectInput:!1,focusInput:!1,themeMode:"auto",swatches:t})};n(),this.updateColoris=n;this.listeners.push(this.editor.notifier.on(r.EditorEventType.ColorPickerToggled,(t=>{t.kind===r.EditorEventType.ColorPickerToggled&&this.closeColorPickerOverlay&&(this.closeColorPickerOverlay.style.display=t.open?"block":"none")}))),this.listeners.push(this.editor.notifier.on(r.EditorEventType.ColorPickerColorSelected,(i=>{i.kind===r.EditorEventType.ColorPickerColorSelected&&(i=>{let r=!1;for(const e of t)e===i&&(r=!0);r||(t.push(i),t.length>12&&t.splice(e,1),n())})(i.color.toHexString())})))}queueReLayout(){this.reLayoutQueued||(this.reLayoutQueued=!0,requestAnimationFrame((()=>this.reLayout())))}reLayout(){if(this.reLayoutQueued=!1,!this.overflowWidget)return;const t=t=>{let e=0;for(const n of t)n.isHidden()||(e+=n.getButtonWidth());return e};let e=t(this.overflowWidget.getChildWidgets()),n=t(this.widgetList)-e,i=.87*this.container.clientWidth;window.innerHeight>1.75*i&&(i*=1.75);let r=!1;if((t=>{var e,n;const i=null!==(n=null===(e=this.overflowWidget)||void 0===e?void 0:e.getChildWidgets())&&void 0!==n?n:[];return 0!==i.length&&i[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());e=0,r=!0}if(n>=i){for(let t=this.widgetList.length-1;t>=0&&n>=i;t--){const e=this.widgetList[t];this.overflowWidget.hasAsChild(e)||e.canBeInOverflowMenu()&&(n-=e.getButtonWidth(),this.overflowWidget.addToOverflow(e))}r=!0}this.overflowWidget.setHidden(0===this.overflowWidget.getChildWidgets().length),r&&this.setupColorPickers()}addWidget(t){const e=t.getUniqueIdIn(this.widgetsById);this.widgetsById[e]=t,this.widgetList.push(t);const n=t.addTo(this.container);this.setupColorPickers(),n.style.order=""+this.widgetOrderCounter++,this.queueReLayout()}addSpacer(t={}){const n=document.createElement("div");n.classList.add(`${e.toolbarCSSPrefix}spacer`),t.grow&&(n.style.flexGrow=`${t.grow}`),t.minSize&&(n.style.minWidth=t.minSize),t.maxSize&&(n.style.maxWidth=t.maxSize),n.style.order=""+this.widgetOrderCounter++,this.container.appendChild(n)}serializeState(){const t={};for(const e in this.widgetsById)t[e]=this.widgetsById[e].serializeState();return JSON.stringify(t)}deserializeState(t){const e=JSON.parse(t);for(const t in e)t in this.widgetsById||console.warn(`Unable to deserialize widget ${t} — no such widget.`),this.widgetsById[t].deserializeFrom(e[t])}addActionButton(t,e,n=!0){const i="string"==typeof t?t:t.label,r=new y.default(this.editor,"action-button",(()=>"string"==typeof t?null:t.icon),i,e,this.editor.localization,n);return this.addWidget(r),r}addUndoRedoButtons(){const t=this.addActionButton({label:this.localizationTable.undo,icon:this.editor.icons.makeUndoIcon()},(()=>{this.editor.history.undo()})),e=this.addActionButton({label:this.localizationTable.redo,icon:this.editor.icons.makeRedoIcon()},(()=>{this.editor.history.redo()}));t.setDisabled(!0),e.setDisabled(!0),this.editor.notifier.on(r.EditorEventType.UndoRedoStackUpdated,(n=>{if(n.kind!==r.EditorEventType.UndoRedoStackUpdated)throw new Error("Wrong event type!");t.setDisabled(0===n.undoStackSize),e.setDisabled(0===n.redoStackSize)}))}addDefaultToolWidgets(){const t=this.editor.toolController;for(const e of t.getMatchingTools(h.default)){const t=new p.default(this.editor,e,this.localizationTable);this.addWidget(t)}for(const e of t.getMatchingTools(u.default))this.addWidget(new f.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(l.default))this.addWidget(new m.default(this.editor,e,this.localizationTable));for(const e of t.getMatchingTools(d.default))this.addWidget(new g.default(this.editor,e,this.localizationTable));const e=t.getMatchingTools(c.default)[0];e&&this.addWidget(new v.default(this.editor,e,this.localizationTable)),this.addWidget(new b.default(this.editor,this.localizationTable))}addDefaultActionButtons(){this.addWidget(new x.default(this.editor,this.localizationTable)),this.addUndoRedoButtons()}addOverflowWidget(){this.overflowWidget=new w.default(this.editor,this.localizationTable),this.addWidget(this.overflowWidget)}addDefaults(){this.addDefaultToolWidgets(),this.addOverflowWidget(),this.addDefaultActionButtons()}remove(){var t;this.container.remove(),this.resizeObserver.disconnect(),null===(t=this.closeColorPickerOverlay)||void 0===t||t.remove();for(const t of this.listeners)t.remove()}}S.colorisStarted=!1,e.default=S},5818:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=n(6750),s=i(n(9563)),a=i(n(8831)),l="http://www.w3.org/2000/svg",c="\n\tstyle='fill: var(--icon-color);'\n",d="\n\t<pattern\n\t\tid='checkerboard'\n\t\tviewBox='0,0,10,10'\n\t\twidth='20%'\n\t\theight='20%'\n\t\tpatternUnits='userSpaceOnUse'\n\t>\n\t\t<rect x=0 y=0 width=10 height=10 fill='white'/>\n\t\t<rect x=0 y=0 width=5 height=5 fill='gray'/>\n\t\t<rect x=5 y=5 width=5 height=5 fill='gray'/>\n\t</pattern>\n",u="url(#checkerboard)";e.default=class{makeUndoIcon(){return this.makeRedoIcon(!0)}makeRedoIcon(t=!1){const e=document.createElementNS(l,"svg");return e.innerHTML=`\n\t\t\t<style>\n\t\t\t\t.toolbar-svg-undo-redo-icon {\n\t\t\t\t\tstroke: var(--icon-color);\n\t\t\t\t\tstroke-width: 12;\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\n\t\t\t\t\ttransform-origin: center;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<path\n\t\t\t\td='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'\n\t\t\t\tclass='toolbar-svg-undo-redo-icon'\n\t\t\t\tstyle='${t?"transform: scale(-1, 1);":""}'/>\n\t\t`,e.setAttribute("viewBox","0 0 100 100"),e}makeDropdownIcon(){const t=document.createElementNS(l,"svg");return t.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\td='M5,10 L50,90 L95,10 Z'\n\t\t\t\t${c}\n\t\t\t/>\n\t\t</g>\n\t\t`,t.setAttribute("viewBox","0 0 100 100"),t}makeEraserIcon(t){const e=document.createElementNS(l,"svg");null!=t||(t=10);const n=t/4;return e.innerHTML=`\n\t\t<g>\n\t\t\t<path\n\t\t\t\tstyle="fill:#ff70af"\n\t\t\t\tstroke="black"\n\t\t\t\ttransform="rotate(41.35)"\n\t\t\t\td="M 52.5 27\n\t\t\t\t\tC 50 28.9 48.9 31.7 48.9 34.8\n\t\t\t\t\tL 48.9 39.8\n\t\t\t\t\tC 48.9 45.3 53.4 49.8 58.9 49.8\n\t\t\t\t\tL 103.9 49.8\n\t\t\t\t\tC 105.8 49.8 107.6 49.2 109.1 48.3\n\t\t\t\t\tL 110.2 ${n+49.5} L 159.7 ${n+5}\n\t\t\t\t\tL 157.7 ${5.2-n} L 112.4 ${49.5-n}\n\t\t\t\t\tC 113.4 43.5 113.9 41.7 113.9 39.8\n\t\t\t\t\tL 113.9 34.8\n\t\t\t\t\tC 113.9 29.3 109.4 24.8 103.9 24.8\n\t\t\t\t\tL 58.9 24.8\n\t\t\t\t\tC 56.5 24.8 54.3 25.7 52.5 27\n\t\t\t\t\tz "\n\t\t\t\tid="path438" />\n\n\t\t\t<rect\n\t\t\t\tstroke="#cc8077"\n\t\t\t\t${c}\n\t\t\t\tid="rect218"\n\t\t\t\twidth="65"\n\t\t\t\theight="75"\n\t\t\t\tx="48.9"\n\t\t\t\ty="-38.7"\n\t\t\t\ttransform="rotate(41.35)" />\n\t\t</g>\n\t\t`,e.setAttribute("viewBox","0 0 120 120"),e}makeSelectionIcon(){const t=document.createElementNS(l,"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}makeIconFromPath(t,e="var(--icon-color)",n="none",i="0px"){const r=document.createElementNS(l,"svg"),o=document.createElementNS(l,"path");return o.setAttribute("d",t),o.style.fill=e,o.style.stroke=n,o.style.strokeWidth=i,r.appendChild(o),r.setAttribute("viewBox","0 0 100 100"),r}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(l,"svg");t.setAttribute("viewBox","0 0 100 100");const e=(e,n,i)=>{const r=document.createElementNS(l,"text");r.appendChild(document.createTextNode(e)),r.setAttribute("x",n.toString()),r.setAttribute("y",i.toString()),r.style.textAlign="center",r.style.textAnchor="middle",r.style.fontSize="55px",r.style.fill="var(--icon-color)",r.style.fontFamily="monospace",t.appendChild(r)};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")}makeTextIcon(t){var e,n;const i=document.createElementNS(l,"svg");i.setAttribute("viewBox","0 0 100 100");const r=document.createElementNS(l,"text");return r.appendChild(document.createTextNode("T")),r.style.fontFamily=t.fontFamily,r.style.fontWeight=null!==(e=t.fontWeight)&&void 0!==e?e:"",r.style.fontVariant=null!==(n=t.fontVariant)&&void 0!==n?n:"",r.style.fill=t.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(--primary-shadow-color))",i.appendChild(r),i}makePenIcon(t,e,n){e instanceof r.default&&(e=e.toHexString());const i=document.createElementNS(l,"svg");i.setAttribute("viewBox","0 0 100 100");const o=t/2,s=`\n\t\t\tM ${15-o},${80-o}\n\t\t\t ${15-o},${80+o}\n\t\t\t 30,83\n\t\t\t 15,65\n\t\t\tZ\n\t\t`,a=80+o,c=`\n\t\t\tm ${15-1.1*o},${a}\n\t\t\tc 35,10 55,15 60,30\n\t\t\tl ${35+1.2*o},${-10-o}\n\t\t\tC 80.47,98.32 50.5,${90+o} 20,${a} Z\n\t\t`,h="\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 p="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",f="M 25,35 H 35 L 90,-15 85,-25 Z",m="M 60,75 65,65 H 55 l 55,-55 10,5 z";n&&(p="M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z",f="m 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z",m="M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z");const g=`M 25,35 ${10-o/4},${70-o/2} 20,75 25,85 60,75 70,55 45,25 Z`,v=r.default.fromHex("#f4d7d7").mix(r.default.fromString(e),o/40-.1).toHexString(),y=`\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${e}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${e}"\n\t\t\t\td="${c}"\n\t\t\t/>\n\t\t`,b=`\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${v}"\n\t\t\t\tstroke="${e}"\n\t\t\t\td="${g}"\n\t\t\t/>\n\t\t`,x=`\n\t\t\t<path\n\t\t\t\t\n\tstyle='fill: var(--icon-color); stroke: var(--icon-color);'\n\n\t\t\t\td="${p}"\n\t\t\t/>\n\n\t\t\t\x3c!-- shadows --\x3e\n\t\t\t<path\n\t\t\t\tfill="rgba(150, 150, 150, 0.3)"\n\t\t\t\td="${f}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="rgba(100, 100, 100, 0.2)"\n\t\t\t\td="${m}"\n\t\t\t/>\n\n\t\t\t\x3c!-- color bubble --\x3e\n\t\t\t<path\n\t\t\t\tfill="${u}"\n\t\t\t\td="${h}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${e}"\n\t\t\t\td="${h}"\n\t\t\t/>\n\t\t`;return i.innerHTML=`\n\t\t<defs>\n\t\t\t${d}\n\t\t</defs>\n\t\t<g>\n\t\t\t${y}\n\t\t\t${b}\n\t\t\t${x}\n\t\t</g>\n\t\t`,i}makeIconFromFactory(t,e){const n=3*Math.sqrt(t.getThickness()),i=(new Date).getTime(),r={pos:o.Vec2.of(10,10),width:n,color:t.getColor(),time:i-100},c={pos:o.Vec2.of(90,90),width:n,color:t.getColor(),time:i},d=new a.default((()=>{})),u=e(r,d);u.addPoint(c);const h=document.createElementNS(l,"svg");h.setAttribute("viewBox","0 0 100 100"),d.updateScreenSize(o.Vec2.of(100,100));const p=new s.default(h,d);return u.preview(p),h}makePipetteIcon(t){const e=document.createElementNS(l,"svg"),n=document.createElementNS(l,"path");if(n.setAttribute("d","\n\t\t\tM 47,6\n\t\t\tC 35,5 25,15 35,30\n\t\t\tc -9.2,1.3 -15,0 -15,3\n\t\t\t\t0,2 5,5 15,7\n\t\t\tV 81\n\t\t\tL 40,90\n\t\t\th 6\n\t\t\tL 40,80\n\t\t\tV 40\n\t\t\th 15\n\t\t\tv 40\n\t\t\tl -6,10\n\t\t\th 6\n\t\t\tl 5,-9.2\n\t\t\tV 40\n\t\t\tC 70,38 75,35 75,33\n\t\t\t\t75,30 69.2,31.2 60,30\n\t\t\t\t65,15 65,5 47,6\n\t\t\tZ\n\t\t"),n.style.fill="var(--icon-color)",t){const n=document.createElementNS(l,"defs");n.innerHTML=d,e.appendChild(n);const i=document.createElementNS(l,"path"),r=document.createElementNS(l,"path"),o="\n\t\t\t\tm 40,50 c 5,5 10,0 15,-5 V 80 L 50,90 H 45 L 40,80 Z\n\t\t\t";r.setAttribute("d",o),i.setAttribute("d",o),r.style.fill=t.toHexString(),i.style.fill=u,e.appendChild(i),e.appendChild(r)}return e.appendChild(n),e.setAttribute("viewBox","0 0 100 100"),e}makeFormatSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 5 10\n\t\t\tL 5 20 L 10 20 L 10 15 L 20 15 L 20 40 L 15 40 L 15 45 L 35 45 L 35 40 L 30 40 L 30 15 L 40 15 L 40 20 L 45 20 L 45 15 L 45 10 L 5 10 z\n\t\t\tM 90 10 C 90 10 86.5 13.8 86 14 C 86 14 76.2 24.8 76 25 L 60 25 L 60 65 C 75 70 85 70 90 65 L 90 25 L 80 25 L 76.7 25 L 90 10 z\n\t\t\tM 60 25 L 55 25 L 50 30 L 60 25 z\n\t\t\tM 10 55 L 10 90 L 41 90 L 41 86 L 45 86 L 45 55 L 10 55 z\n\t\t\tM 42 87 L 42 93 L 48 93 L 48 87 L 42 87 z \n\t\t")}makeResizeViewportIcon(){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")}makeDuplicateSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 45,10 45,55 90,55 90,10 45,10 z\n\t\t\tM 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z \n\t\t")}makePasteIcon(){const t=this.makeIconFromPath("\n\t\t\tM 50 0 L 50 5 L 35 5 L 40 24.75 L 20 25 L 20 100 L 85 100 L 100 90 L 100 24 L 75.1 24.3 L 80 5 L 65 5 L 65 0 L 50 0 z\n\t\t\tM 10 15 L 10 115 L 110 115 L 110 15 L 85 15 L 83 20 L 105 20 L 105 110 L 15 110 L 15 20 L 32 20 L 30 15 L 10 15 z\n\t\t\tM 25 35 L 90 35 L 90 40 L 25 40 L 25 35 z\n\t\t\tM 25 45 L 90 45 L 90 50 L 25 50 L 25 45 z\n\t\t\tM 25 55 L 85 55 L 85 60 L 25 60 L 25 55 z\n\t\t\tM 25 65 L 90 65 L 90 70 L 25 70 L 25 65 z \n\t\t");return t.setAttribute("viewBox","0 0 120 120"),t}makeDeleteSelectionIcon(){return this.makeIconFromPath("\n\t\t\tM 10,10 90,90\n\t\t\tM 10,90 90,10\n\t\t","none","var(--icon-color)","5px")}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: 10;\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")}}},4087:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.IconProvider=void 0,r(n(7788),e),r(n(5768),e);var s=n(5818);Object.defineProperty(e,"IconProvider",{enumerable:!0,get:function(){return o(s).default}})},3940:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarLocalization=void 0,e.defaultToolbarLocalization={pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text: ",chooseFile:"Choose file: ",submit:"Submit",cancel:"Cancel",resetView:"Reset view",thicknessLabel:"Thickness: ",colorLabel:"Color: ",fontLabel:"Font: ",textSize:"Size: ",resizeImageToSelection:"Resize image to selection",deleteSelection:"Delete selection",duplicateSelection:"Duplicate selection",undo:"Undo",redo:"Redo",selectPenType:"Pen type: ",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: ",toggleOverflow:"More",touchPanning:"Touchscreen panning",freehandPen:"Freehand",pressureSensitiveFreehandPen:"Freehand (pressure sensitive)",arrowPen:"Arrow",linePen:"Line",outlinedRectanglePen:"Outlined rectangle",filledRectanglePen:"Filled rectangle",lockRotation:"Lock rotation",paste:"Paste",dropdownShown:t=>`Dropdown for ${t} shown`,dropdownHidden:t=>`Dropdown for ${t} hidden`,zoomLevel:t=>`Zoom: ${t}%`,colorChangedAnnouncement:t=>`Color changed to ${t}`,imageSize:(t,e)=>`Image size: ${t} ${e}`,errorImageHasZeroSize:"Error: Image has zero size",imageLoadError:t=>`Error loading image: ${t}`}},5768:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeColorInput=void 0;const r=i(n(8233)),o=i(n(5529)),s=n(9699);e.makeColorInput=(t,e)=>{const n=document.createElement("span"),i=document.createElement("input");i.type="button",i.classList.add("coloris_input"),n.classList.add("color-input-container"),n.appendChild(i);const o=a(t,n,(t=>{i.value=t.toHexString(),d();const e=i.parentElement;e&&e.classList.contains("clr-field")&&(e.style.color=i.value)}));let l;const c=()=>{l=r.default.fromHex(i.value)},d=()=>{c(),l&&(t.announceForAccessibility(t.localization.colorChangedAnnouncement(l.toHexString())),e(l),t.notifier.dispatch(s.EditorEventType.ColorPickerColorSelected,{kind:s.EditorEventType.ColorPickerColorSelected,color:l}))};i.oninput=c,i.addEventListener("open",(()=>{t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!0}),o.cancel();const e=document.querySelector("#clr-picker #clr-hue-slider");null==e||e.focus()})),i.addEventListener("close",(()=>{t.notifier.dispatch(s.EditorEventType.ColorPickerToggled,{kind:s.EditorEventType.ColorPickerToggled,open:!1}),d(),i.focus()}));return[i,n,t=>{"object"==typeof t&&(t=t.toHexString()),i.value=t,i.dispatchEvent(new Event("input",{bubbles:!0}))}]};const a=(t,e,n)=>{const i=document.createElement("button");i.classList.add("pipetteButton"),i.title=t.localization.pickColorFromScreen,i.setAttribute("alt",i.title);const r=e=>{i.replaceChildren(t.icons.makePipetteIcon(e))};r();const s=t.toolController.getMatchingTools(o.default)[0],a=()=>{null==s||s.clearColorListener(),r(),i.classList.remove("active")},l=t=>{a(),t&&n(t)},c=t=>{t?r(t):r()};return i.onclick=()=>{if(i.classList.contains("active"))return a(),void t.announceForAccessibility(t.localization.colorSelectionCanceledAnnouncement);null==s||s.setColorListener(c,l),s&&(i.classList.add("active"),t.announceForAccessibility(t.localization.clickToPickColorAnnouncement))},e.appendChild(i),{cancel:()=>{a()}}};e.default=e.makeColorInput},5710:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(1455));class o extends r.default{constructor(t,e,n,i,r,o,s=!1){super(t,e,o),this.makeIcon=n,this.title=i,this.clickAction=r,this.mustBeToplevel=s}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}canBeInOverflowMenu(){return!this.mustBeToplevel}}e.default=o},6763:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9699),o=i(n(1455));class s extends o.default{constructor(t,e,n,i){super(t,n,i),this.targetTool=e,t.notifier.on(r.EditorEventType.ToolEnabled,(t=>{if(t.kind!==r.EditorEventType.ToolEnabled)throw new Error("Incorrect event type! (Expected ToolEnabled)");t.tool===e&&this.setSelected(!0)})),t.notifier.on(r.EditorEventType.ToolDisabled,(t=>{if(t.kind!==r.EditorEventType.ToolDisabled)throw new Error("Incorrect event type! (Expected ToolDisabled)");t.tool===e&&(this.setSelected(!1),this.setDropdownVisible(!1))}))}handleClick(){this.hasDropdown?this.targetTool.isEnabled()?this.setDropdownVisible(!this.isDropdownVisible()):this.targetTool.setEnabled(!0):this.targetTool.setEnabled(!this.targetTool.isEnabled())}addTo(t){const e=super.addTo(t);return this.setSelected(this.targetTool.isEnabled()),e}}e.default=s},1455:function(t,e,n){"use strict";var i,r=this&&this.__classPrivateFieldSet||function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},o=this&&this.__classPrivateFieldGet||function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(2375)),l=n(9699),c=n(7389);class d{constructor(t,e,n){this.editor=t,this.id=e,i.set(this,void 0),this.disabled=!1,this.subWidgets={},this.toplevel=!0,this.toolbarWidgetToggleListener=null,this.localizationTable=null!=n?n:t.localization,this.icon=null,this.container=document.createElement("div"),this.container.classList.add(`${c.toolbarCSSPrefix}toolContainer`),this.dropdownContainer=document.createElement("div"),this.dropdownContainer.classList.add(`${c.toolbarCSSPrefix}dropdown`),this.dropdownContainer.classList.add("hidden"),r(this,i,!1,"f"),this.button=document.createElement("div"),this.button.classList.add(`${c.toolbarCSSPrefix}button`),this.label=document.createElement("label"),this.button.setAttribute("role","button"),this.button.tabIndex=0;const o=this.editor.toolController.getMatchingTools(a.default);o.length>0&&this.onKeyPress!==d.prototype.onKeyPress&&o[0].registerListener((t=>this.onKeyPress(t)))}getId(){return this.id}getUniqueIdIn(t){let e=this.getId(),n=0;for(;e in t&&t[e]!==this;)e=this.getId()+"-"+n.toString(),n++;return e}fillDropdown(t){if(0===Object.keys(this.subWidgets).length)return!1;for(const e in this.subWidgets){const n=this.subWidgets[e];n.addTo(t),n.setIsToplevel(!1)}return!0}setupActionBtnClickListener(t){const e={Enter:!0," ":!0};t.onkeydown=t=>{let n=!1;t.key in e&&(this.disabled||(this.handleClick(),n=!0)),n||(n=this.editor.toolController.dispatchInputEvent({kind:l.InputEvtType.KeyPressEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})),n&&t.preventDefault()},t.onkeyup=t=>{if(t.key in e)return;this.editor.toolController.dispatchInputEvent({kind:l.InputEvtType.KeyUpEvent,key:t.key,ctrlKey:t.ctrlKey||t.metaKey,altKey:t.altKey})&&t.preventDefault()},t.onclick=()=>{this.disabled||this.handleClick()}}onKeyPress(t){return!1}get hasDropdown(){return o(this,i,"f")}addSubWidget(t){const e=t.getUniqueIdIn(this.subWidgets);this.subWidgets[e]=t}addTo(t){this.icon=null,this.updateIcon(),this.label.innerText=this.getTitle();const e="long-label";return this.label.innerText.length>7?this.label.classList.add(e):this.label.classList.remove(e),this.setupActionBtnClickListener(this.button),this.container.replaceChildren(),this.button.replaceChildren(this.icon,this.label),this.container.appendChild(this.button),r(this,i,this.fillDropdown(this.dropdownContainer),"f"),o(this,i,"f")&&(this.dropdownIcon=this.createDropdownIcon(),this.button.appendChild(this.dropdownIcon),this.container.appendChild(this.dropdownContainer),this.toolbarWidgetToggleListener&&this.toolbarWidgetToggleListener.remove(),this.toolbarWidgetToggleListener=this.editor.notifier.on(l.EditorEventType.ToolbarDropdownShown,(t=>{t.kind===l.EditorEventType.ToolbarDropdownShown&&t.parentWidget!==this&&t.parentWidget.toplevel&&this.setDropdownVisible(!1)}))),this.setDropdownVisible(!1),this.container.parentElement&&this.container.remove(),t.appendChild(this.container),this.container}updateIcon(){var t,e;const n=this.createIcon();n?(null===(t=this.icon)||void 0===t||t.replaceWith(n),this.icon=n,this.icon.classList.add(`${c.toolbarCSSPrefix}icon`)):null===(e=this.icon)||void 0===e||e.remove()}setDisabled(t){this.disabled=t,this.disabled?(this.button.classList.add("disabled"),this.button.setAttribute("aria-disabled","true")):(this.button.classList.remove("disabled"),this.button.removeAttribute("aria-disabled"))}setSelected(t){this.isSelected()!==t&&(this.button.setAttribute("role","switch"),t?(this.container.classList.add("selected"),this.button.setAttribute("aria-checked","true")):(this.container.classList.remove("selected"),this.button.setAttribute("aria-checked","false")))}setDropdownVisible(t){this.container.classList.contains("dropdownVisible")!==t&&(t?(this.dropdownContainer.classList.remove("hidden"),this.container.classList.add("dropdownVisible"),this.editor.announceForAccessibility(this.localizationTable.dropdownShown(this.getTitle())),this.editor.notifier.dispatch(l.EditorEventType.ToolbarDropdownShown,{kind:l.EditorEventType.ToolbarDropdownShown,parentWidget:this})):(this.dropdownContainer.classList.add("hidden"),this.container.classList.remove("dropdownVisible"),this.editor.announceForAccessibility(this.localizationTable.dropdownHidden(this.getTitle()))),this.repositionDropdown())}canBeInOverflowMenu(){return!0}getButtonWidth(){return this.button.clientWidth}isHidden(){return"none"===this.container.style.display}setHidden(t){this.container.style.display=t?"none":""}repositionDropdown(){const t=this.dropdownContainer.getBoundingClientRect(),e=document.body.clientWidth;t.left>e/2?(this.dropdownContainer.style.marginLeft=this.button.clientWidth+"px",this.dropdownContainer.style.transform="translate(-100%, 0)"):(this.dropdownContainer.style.marginLeft="",this.dropdownContainer.style.transform="")}setIsToplevel(t){this.toplevel=t}isDropdownVisible(){return!this.dropdownContainer.classList.contains("hidden")}isSelected(){return this.container.classList.contains("selected")}createDropdownIcon(){const t=this.editor.icons.makeDropdownIcon();return t.classList.add(`${c.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])}}e.default=d,i=new WeakMap},234:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(529)),l=s(n(3966)),c=o(n(7520)),d=n(4721),u=s(n(5085)),h=n(9699),p=n(7389),f=s(n(5768)),m=s(n(1455));class g extends m.default{constructor(t,e){super(t,"document-properties-widget",e),this.updateDropdownContent=()=>{},this.dropdownUpdateQueued=!1,this.container.classList.add("dropdownShowable"),this.editor.notifier.on(h.EditorEventType.UndoRedoStackUpdated,(()=>{this.queueDropdownUpdate()})),this.editor.image.notifier.on(d.EditorImageEventType.ExportViewportChanged,(()=>{this.queueDropdownUpdate()}))}getTitle(){return this.localizationTable.documentProperties}createIcon(){return this.editor.icons.makeConfigureDocumentIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible()),this.queueDropdownUpdate()}queueDropdownUpdate(){this.dropdownUpdateQueued||(requestAnimationFrame((()=>this.updateDropdown())),this.dropdownUpdateQueued=!0)}updateDropdown(){this.dropdownUpdateQueued=!1,this.isDropdownVisible()&&this.updateDropdownContent()}setBackgroundColor(t){this.editor.dispatch(this.editor.setBackgroundColor(t))}getBackgroundColor(){return this.editor.estimateBackgroundColor()}removeBackgroundComponents(){const t=[];for(const e of this.editor.image.getBackgroundComponents())e instanceof c.default&&t.push(e);return new a.default(t)}setBackgroundType(t){const e=this.editor.estimateBackgroundColor(),n=new c.default(t,e),i=this.editor.image.addElement(n);return(0,l.default)([this.removeBackgroundComponents(),i])}getBackgroundType(){const t=this.editor.image.getBackgroundComponents();for(let e=t.length-1;e>=0;e--){const n=t[e];if(n instanceof c.default)return n.getBackgroundType()}return c.BackgroundType.None}updateImportExportRectSize(t){const e=t=>(void 0!==t&&(!isFinite(t)||t<=0)&&(t=100),t),n=e(t.width),i=e(t.height),r=this.editor.getImportExportRect(),o=new u.default(r.x,r.y,null!=n?n:r.w,null!=i?i:r.h);this.editor.dispatch(this.editor.image.setImportExportRect(o)),this.editor.queueRerender()}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("label");i.innerText=this.localizationTable.backgroundColor;const[r,o,s]=(0,f.default)(this.editor,(t=>{t.eq(this.getBackgroundColor())||this.setBackgroundColor(t)}));r.id=`${p.toolbarCSSPrefix}docPropertiesColorInput-${g.idCounter++}`,i.htmlFor=r.id,n.replaceChildren(i,o);const a=document.createElement("div"),l=document.createElement("label"),d=document.createElement("input");d.id=`${p.toolbarCSSPrefix}docPropertiesUseGridCheckbox-${g.idCounter++}`,l.htmlFor=d.id,d.type="checkbox",l.innerText=this.localizationTable.useGridOption,d.oninput=()=>{if(this.getBackgroundType()===c.BackgroundType.Grid===d.checked)return;let t=c.BackgroundType.SolidColor;d.checked&&(t=c.BackgroundType.Grid),this.editor.dispatch(this.setBackgroundType(t))},a.replaceChildren(l,d);const u=(t,e)=>{const n=document.createElement("div"),i=document.createElement("label"),r=document.createElement("span"),o=document.createElement("input");return i.innerText=t,o.type="number",o.min="0",o.id=`${p.toolbarCSSPrefix}docPropertiesDimensionRow-${g.idCounter++}`,i.htmlFor=o.id,r.style.flexGrow="1",o.style.flexGrow="2",o.style.width="25px",n.style.display="flex",o.oninput=()=>{e(parseFloat(o.value))},n.replaceChildren(i,r,o),{setValue:t=>{o.value=t.toString()},element:n}},h=u(this.localizationTable.imageWidthOption,(t=>{this.updateImportExportRectSize({width:t})})),m=u(this.localizationTable.imageHeightOption,(t=>{this.updateImportExportRectSize({height:t})}));return this.updateDropdownContent=()=>{s(this.getBackgroundColor());const t=this.editor.getImportExportRect();h.setValue(t.width),m.setValue(t.height),d.checked=this.getBackgroundType()===c.BackgroundType.Grid},this.updateDropdownContent(),e.replaceChildren(n,a,h.element,m.element),t.replaceChildren(e),!0}}g.idCounter=0,e.default=g},2297:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9699),o=n(7389),s=i(n(6763));class a extends s.default{constructor(t,e,n){super(t,e,"eraser-tool-widget",n),this.tool=e,this.thicknessInput=null,this.editor.notifier.on(r.EditorEventType.ToolUpdated,(t=>{t.kind===r.EditorEventType.ToolUpdated&&t.tool===this.tool&&(this.updateInputs(),this.updateIcon())}))}getTitle(){return this.localizationTable.eraser}createIcon(){return this.editor.icons.makeEraserIcon(this.tool.getThickness())}updateInputs(){this.thicknessInput&&(this.thicknessInput.value=`${this.tool.getThickness()}`)}fillDropdown(t){const e=document.createElement("label");return this.thicknessInput=document.createElement("input"),this.thicknessInput.type="range",this.thicknessInput.min="4",this.thicknessInput.max="40",this.thicknessInput.oninput=()=>{this.tool.setThickness(parseFloat(this.thicknessInput.value))},this.thicknessInput.id=`${o.toolbarCSSPrefix}eraserThicknessInput${a.nextThicknessInputId++}`,e.innerText=this.localizationTable.thicknessLabel,e.htmlFor=this.thicknessInput.id,this.updateInputs(),t.replaceChildren(e,this.thicknessInput),!0}serializeState(){return Object.assign(Object.assign({},super.serializeState()),{thickness:this.tool.getThickness()})}deserializeFrom(t){if(super.deserializeFrom(t),t.thickness){const e=parseFloat(t.thickness);if("number"!=typeof e||!isFinite(e))throw new Error(`Deserializing property ${e} is not a number or is not finite.`);this.tool.setThickness(e)}}}a.nextThicknessInputId=0,e.default=a},5627:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(2054)),l=o(n(135)),c=n(9699),d=s(n(8831)),u=n(7389),h=s(n(6763)),p=s(n(1455));class f extends p.default{constructor(t,e){super(t,"zoom-widget",e),this.container.classList.add("dropdownShowable")}getTitle(){return this.localizationTable.zoom}createIcon(){return this.editor.icons.makeZoomIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){return t.replaceChildren(((t,e)=>{const n=document.createElement("div"),i=document.createElement("button"),r=document.createElement("button"),o=document.createElement("button"),s=document.createElement("span");let l;i.innerText="+",r.innerText="-",o.innerText=t.resetView,n.replaceChildren(s,i,r,o),n.classList.add(`${u.toolbarCSSPrefix}zoomLevelEditor`),s.classList.add("zoomDisplay");const h=()=>{let n=100*e.viewport.getScaleFactor();n=n>.1?Math.round(10*n)/10:Math.round(1e3*n)/1e3,n!==l&&(s.innerText=t.zoomLevel(n),l=n)};h(),e.notifier.on(c.EditorEventType.ViewportChanged,(t=>{t.kind===c.EditorEventType.ViewportChanged&&(h(),o.disabled=t.newTransform.eq(a.default.identity))}));const p=t=>{const n=e.viewport.visibleRect.center,i=a.default.scaling2D(t,n);e.dispatch(d.default.transformBy(i),!1)};return i.onclick=()=>{p(5/4)},r.onclick=()=>{p(.8)},o.onclick=()=>{e.dispatch(d.default.transformBy(e.viewport.canvasToScreenTransform.inverse()),!0)},n})(this.localizationTable,this.editor)),!0}}class m extends p.default{constructor(t,e,n,i,r,o){super(t,`pan-mode-${n}`,o),this.tool=e,this.flag=n,this.makeIcon=i,this.title=r,t.notifier.on(c.EditorEventType.ToolUpdated,(t=>{if(t.kind===c.EditorEventType.ToolUpdated&&t.tool===e){const t=!!(e.getMode()&l.PanZoomMode.SinglePointerGestures);this.setSelected(!!(e.getMode()&n)||t),this.setDisabled(t&&n!==l.PanZoomMode.SinglePointerGestures)}})),this.setSelected(!1)}setModeFlag(t){this.tool.setModeEnabled(this.flag,t)}handleClick(){this.setModeFlag(!this.isSelected())}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}}class g extends h.default{constructor(t,e,n){const i=g.getPrimaryHandTool(t.toolController);super(t,null!=i?i:e,"hand-tool-widget",n),this.overridePanZoomTool=e,this.allowTogglingBaseTool=null!==i,this.allowTogglingBaseTool||this.container.classList.add("dropdownShowable");const r=new m(t,e,l.PanZoomMode.OneFingerTouchGestures,(()=>this.editor.icons.makeTouchPanningIcon()),n.touchPanning,n),o=new m(t,e,l.PanZoomMode.RotationLocked,(()=>this.editor.icons.makeRotationLockIcon()),n.lockRotation,n);this.addSubWidget(r),this.addSubWidget(o),this.addSubWidget(new f(t,n))}static getPrimaryHandTool(t){return t.getPrimaryTools().filter((t=>t instanceof l.default))[0]}getTitle(){return this.localizationTable.handTool}createIcon(){return this.editor.icons.makeHandToolIcon()}handleClick(){this.allowTogglingBaseTool?super.handleClick():this.setDropdownVisible(!this.isDropdownVisible())}setSelected(t){this.allowTogglingBaseTool&&super.setSelected(t)}serializeState(){const t=this.overridePanZoomTool.getMode();return Object.assign(Object.assign({},super.serializeState()),{touchPanning:t&l.PanZoomMode.OneFingerTouchGestures,rotationLocked:t&l.PanZoomMode.RotationLocked})}deserializeFrom(t){void 0!==t.touchPanning&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.OneFingerTouchGestures,t.touchPanning),void 0!==t.rotationLocked&&this.overridePanZoomTool.setModeEnabled(l.PanZoomMode.RotationLocked,t.rotationLocked),super.deserializeFrom(t)}}e.default=g},2085:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(5249)),s=r(n(529)),a=r(n(4721)),l=r(n(3966)),c=r(n(1626)),d=r(n(2054)),u=r(n(9161)),h=r(n(5710));class p extends h.default{constructor(t,e){null!=e||(e=t.localization),super(t,"insert-image-widget",(()=>t.icons.makeInsertImageIcon()),e.image,(()=>this.onClicked())),this.imageSelectionOverlay=document.createElement("div"),this.imageSelectionOverlay.classList.add("toolbar-image-selection-overlay"),this.fillOverlay(),this.editor.createHTMLOverlay(this.imageSelectionOverlay),this.imageSelectionOverlay.style.display="none"}fillOverlay(){const t=document.createElement("div"),e=document.createElement("div"),n=document.createElement("div");this.imagePreview=document.createElement("img"),this.statusView=document.createElement("div");const r=document.createElement("div");r.classList.add("action-button-row"),this.submitButton=document.createElement("button");const o=document.createElement("button");this.imageFileInput=document.createElement("input"),this.imageAltTextInput=document.createElement("input");const s=document.createElement("label"),a=document.createElement("label"),l="insert-image-file-input-"+p.nextInputId++,c="insert-image-alt-text-input-"+p.nextInputId++;this.imageFileInput.setAttribute("id",l),this.imageAltTextInput.setAttribute("id",c),a.htmlFor=c,s.htmlFor=l,this.imageFileInput.accept="image/*",a.innerText=this.localizationTable.inputAltText,s.innerText=this.localizationTable.chooseFile,this.imageFileInput.type="file",this.imageAltTextInput.type="text",this.statusView.setAttribute("aria-live","polite"),o.innerText=this.localizationTable.cancel,this.submitButton.innerText=this.localizationTable.submit,this.imageFileInput.onchange=()=>i(this,void 0,void 0,(function*(){if(""===this.imageFileInput.value||!this.imageFileInput.files||!this.imageFileInput.files[0])return this.imagePreview.style.display="none",void(this.submitButton.disabled=!0);this.imagePreview.style.display="block";const t=this.imageFileInput.files[0];let e=null;try{e=yield(0,u.default)(t)}catch(t){this.statusView.innerText=this.localizationTable.imageLoadError(t)}this.imageBase64URL=e,e?(this.imagePreview.src=e,this.submitButton.disabled=!1,this.updateImageSizeDisplay()):(this.submitButton.disabled=!0,this.statusView.innerText="")})),o.onclick=()=>{this.hideDialog()},this.imageSelectionOverlay.onclick=t=>{t.target===this.imageSelectionOverlay&&this.hideDialog()},e.replaceChildren(s,this.imageFileInput),n.replaceChildren(a,this.imageAltTextInput),r.replaceChildren(o,this.submitButton),t.replaceChildren(e,n,this.imagePreview,this.statusView,r),this.imageSelectionOverlay.replaceChildren(t)}hideDialog(){this.imageSelectionOverlay.style.display="none"}updateImageSizeDisplay(){var t;const e=(null!==(t=this.imageBase64URL)&&void 0!==t?t:"").length/1024,n=e/1024;let i="KiB",r=e;n>=1&&(r=n,i="MiB"),this.statusView.innerText=this.localizationTable.imageSize(Math.round(r),i)}clearInputs(){this.imageFileInput.value="",this.imageAltTextInput.value="",this.imagePreview.style.display="none",this.submitButton.disabled=!0,this.statusView.innerText=""}onClicked(){var t;this.imageSelectionOverlay.style.display="",this.clearInputs(),this.imageFileInput.focus();const e=this.editor.toolController.getMatchingTools(c.default),n=e.map((t=>t.getSelectedObjects())).flat();let r=null;1===n.length&&n[0]instanceof o.default?(r=n[0],this.imageAltTextInput.value=null!==(t=r.getAltText())&&void 0!==t?t:"",this.imagePreview.style.display="block",this.submitButton.disabled=!1,this.imageBase64URL=r.getURL(),this.imagePreview.src=this.imageBase64URL,this.updateImageSizeDisplay()):e.forEach((t=>t.clearSelection())),this.submitButton.onclick=()=>i(this,void 0,void 0,(function*(){var t;if(!this.imageBase64URL)return;const n=new Image;n.src=this.imageBase64URL,n.setAttribute("alt",this.imageAltTextInput.value);const i=yield o.default.fromImage(n,d.default.identity);if(0!==i.getBBox().area)if(this.imageSelectionOverlay.style.display="none",r){const n=new s.default([r]);yield this.editor.dispatch((0,l.default)([a.default.addElement(i),i.transformBy(r.getTransformation()),i.setZIndex(r.getZIndex()),n])),null===(t=e[0])||void 0===t||t.setSelection([i])}else yield this.editor.addAndCenterComponents([i]);else this.statusView.innerText=this.localizationTable.errorImageHasZeroSize}))}}p.nextInputId=0,e.default=p},1278:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(1455));class o extends r.default{constructor(t,e){var n;super(t,"overflow-widget",e),this.overflowChildren=[],this.container.classList.add("toolbar-overflow-widget"),this.container.classList.add("dropdownShowable"),null!==(n=this.overflowContainer)&&void 0!==n||(this.overflowContainer=document.createElement("div"))}getTitle(){return this.localizationTable.toggleOverflow}createIcon(){return this.editor.icons.makeOverflowIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){var e;return null!==(e=this.overflowContainer)&&void 0!==e||(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=o},3770:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(6645),o=n(1173),s=n(4856),a=n(5607),l=n(7124),c=n(9699),d=n(7389),u=i(n(5768)),h=i(n(6763)),p=i(n(8233));class f extends h.default{constructor(t,e,n){super(t,e,"pen",n),this.tool=e,this.updateInputs=()=>{},this.penTypes=[{name:this.localizationTable.pressureSensitiveFreehandPen,id:"pressure-sensitive-pen",factory:s.makePressureSensitiveFreehandLineBuilder},{name:this.localizationTable.freehandPen,id:"freehand-pen",factory:o.makeFreehandLineBuilder},{name:this.localizationTable.arrowPen,id:"arrow",factory:r.makeArrowBuilder},{name:this.localizationTable.linePen,id:"line",factory:a.makeLineBuilder},{name:this.localizationTable.filledRectanglePen,id:"filled-rectangle",factory:l.makeFilledRectangleBuilder},{name:this.localizationTable.outlinedRectanglePen,id:"outlined-rectangle",factory:l.makeOutlinedRectangleBuilder}],this.editor.notifier.on(c.EditorEventType.ToolUpdated,(t=>{if(t.kind!==c.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}createIcon(){const t=this.tool.getStrokeFactory();if(t===o.makeFreehandLineBuilder||t===s.makePressureSensitiveFreehandLineBuilder){const e=Math.round(4*Math.sqrt(this.tool.getThickness())),n=this.tool.getColor(),i=t===o.makeFreehandLineBuilder;return this.editor.icons.makePenIcon(e,n.toHexString(),i)}{const t=this.tool.getStrokeFactory();return this.editor.icons.makeIconFromFactory(this.tool,t)}}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${d.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("div"),r=document.createElement("label"),o=document.createElement("input"),s=document.createElement("label"),a=document.createElement("select");o.id=`${d.toolbarCSSPrefix}penThicknessInput${f.idCounter++}`,a.id=`${d.toolbarCSSPrefix}penBuilderSelect${f.idCounter++}`,r.innerText=this.localizationTable.thicknessLabel,r.setAttribute("for",o.id),s.innerText=this.localizationTable.selectPenType,s.setAttribute("for",a.id);const l=t=>Math.log10(t);o.type="range",o.min=`${l(2)}`,o.max=`${l(400)}`,o.step="0.1",o.oninput=()=>{this.tool.setThickness((t=>Math.pow(10,t))(parseFloat(o.value)))},n.appendChild(r),n.appendChild(o),a.oninput=()=>{const t=parseInt(a.value);t<0||t>=this.penTypes.length?console.error("Invalid pen type index",t):this.tool.setStrokeFactory(this.penTypes[t].factory)},i.appendChild(s),i.appendChild(a);const c=document.createElement("div"),h=document.createElement("label"),[p,m,g]=(0,u.default)(this.editor,(t=>{this.tool.setColor(t)}));return p.id=`${d.toolbarCSSPrefix}colorInput${f.idCounter++}`,h.innerText=this.localizationTable.colorLabel,h.setAttribute("for",p.id),c.appendChild(h),c.appendChild(m),this.updateInputs=()=>{g(this.tool.getColor()),o.value=l(this.tool.getThickness()).toString(),a.replaceChildren();for(let t=0;t<this.penTypes.length;t++){const e=this.penTypes[t],n=document.createElement("option");n.value=t.toString(),n.innerText=e.name,a.appendChild(n)}const t=this.getCurrentPenTypeIdx();a.value=-1===t?"":t.toString()},this.updateInputs(),e.replaceChildren(c,n,i),t.replaceChildren(e),!0}onKeyPress(t){if(!this.isSelected())return!1;if(/^[0-9]$/.exec(t.key)&&t.ctrlKey){const e=parseInt(t.key)-1;if(e>=0&&e<this.penTypes.length)return this.tool.setStrokeFactory(this.penTypes[e].factory),!0}return!1}serializeState(){var t;return Object.assign(Object.assign({},super.serializeState()),{color:this.tool.getColor().toHexString(),thickness:this.tool.getThickness(),strokeFactoryId:null===(t=this.getCurrentPenType())||void 0===t?void 0:t.id})}deserializeFrom(t){super.deserializeFrom(t);const e=(e,n)=>{const i=typeof t[e];if(i!==n)throw new Error(`Deserializing property ${e}: Invalid type. Expected ${n}, was ${i}.`)};if(t.color&&(e("color","string"),this.tool.setColor(p.default.fromHex(t.color))),t.thickness&&(e("thickness","number"),this.tool.setThickness(t.thickness)),t.strokeFactoryId){e("strokeFactoryId","string");const n=t.strokeFactoryId;for(const t of this.penTypes)if(n===t.id){this.tool.setStrokeFactory(t.factory);break}}}}f.idCounter=0,e.default=f},6282:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(8233)),s=n(8258),a=r(n(3966)),l=n(9699),c=r(n(5768)),d=r(n(5710)),u=r(n(6763)),h=r(n(1455));class p extends h.default{constructor(t,e,n){super(t,"restyle-selection",n),this.selectionTool=e,this.updateFormatData=()=>{},this.container.classList.add("dropdownShowable"),this.editor.notifier.on(l.EditorEventType.ToolUpdated,(t=>{if(t.kind!==l.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");t.tool===this.selectionTool&&this.updateFormatData()}))}getTitle(){return this.localizationTable.reformatSelection}createIcon(){return this.editor.icons.makeFormatSelectionIcon()}handleClick(){this.setDropdownVisible(!this.isDropdownVisible())}fillDropdown(t){const e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("label"),[r,l,d]=(0,c.default)(this.editor,(t=>{const e=this.selectionTool.getSelection();if(e){const n=[];for(const i of e.getSelectedObjects())(0,s.isRestylableComponent)(i)&&n.push(i.updateStyle({color:t}));const i=(0,a.default)(n);this.editor.dispatch(i)}}));return i.innerText=this.localizationTable.colorLabel,this.updateFormatData=()=>{const t=this.selectionTool.getSelection();if(t){r.disabled=!1;const e=[];for(const n of t.getSelectedObjects())if((0,s.isRestylableComponent)(n)){const t=n.getStyle().color;t&&e.push(t)}d(o.default.average(e))}else r.disabled=!0},n.replaceChildren(i,l),e.replaceChildren(n),t.replaceChildren(e),!0}}class f extends u.default{constructor(t,e,n){super(t,e,"selection-tool-widget",n),this.tool=e;const r=new d.default(t,"resize-btn",(()=>t.icons.makeResizeViewportIcon()),this.localizationTable.resizeImageToSelection,(()=>{this.resizeImageToSelection()}),n),o=new d.default(t,"delete-btn",(()=>t.icons.makeDeleteSelectionIcon()),this.localizationTable.deleteSelection,(()=>{const t=this.tool.getSelection();this.editor.dispatch(t.deleteSelectedObjects()),this.tool.clearSelection()}),n),s=new d.default(t,"duplicate-btn",(()=>t.icons.makeDuplicateSelectionIcon()),this.localizationTable.duplicateSelection,(()=>i(this,void 0,void 0,(function*(){const t=this.tool.getSelection();this.editor.dispatch(yield t.duplicateSelectedObjects())}))),n),a=new p(t,this.tool,n);this.addSubWidget(r),this.addSubWidget(o),this.addSubWidget(s),this.addSubWidget(a);const c=t=>{r.setDisabled(t),o.setDisabled(t),s.setDisabled(t),a.setDisabled(t)};c(!0),this.editor.notifier.on(l.EditorEventType.ToolUpdated,(t=>{if(t.kind!==l.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");if(t.tool===this.tool){const t=this.tool.getSelection(),e=t&&t.getSelectedItemCount()>0;c(!e)}}))}resizeImageToSelection(){const t=this.tool.getSelection();t&&this.editor.dispatch(this.editor.setImportExportRect(t.region))}onKeyPress(t){return!(!t.ctrlKey||"r"!==t.key)&&(this.resizeImageToSelection(),!0)}getTitle(){return this.localizationTable.select}createIcon(){return this.editor.icons.makeSelectionIcon()}}e.default=f},6937:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=n(9699),s=n(7389),a=i(n(5768)),l=i(n(6763));class c extends l.default{constructor(t,e,n){super(t,e,"text-tool-widget",n),this.tool=e,this.updateDropdownInputs=null,t.notifier.on(o.EditorEventType.ToolUpdated,(t=>{var n;t.kind===o.EditorEventType.ToolUpdated&&t.tool===e&&(this.updateIcon(),null===(n=this.updateDropdownInputs)||void 0===n||n.call(this))}))}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`);const n=document.createElement("div"),i=document.createElement("div"),r=document.createElement("div"),o=document.createElement("select"),l=document.createElement("label"),d=document.createElement("input"),u=document.createElement("label"),[h,p,f]=(0,a.default)(this.editor,(t=>{this.tool.setColor(t)})),m=document.createElement("label"),g=new Set,v=t=>{const e=document.createElement("option");e.value=t,e.textContent=t,o.appendChild(e),g.add(t)};return d.setAttribute("type","number"),d.min="1",d.max="128",l.innerText=this.localizationTable.fontLabel,m.innerText=this.localizationTable.colorLabel,u.innerText=this.localizationTable.textSize,h.id=`${s.toolbarCSSPrefix}-text-color-input-${c.idCounter++}`,m.setAttribute("for",h.id),d.id=`${s.toolbarCSSPrefix}-text-size-input-${c.idCounter++}`,u.setAttribute("for",d.id),v("monospace"),v("serif"),v("sans-serif"),o.id=`${s.toolbarCSSPrefix}-text-font-input-${c.idCounter++}`,l.setAttribute("for",o.id),o.onchange=()=>{this.tool.setFontFamily(o.value)},d.onchange=()=>{const t=parseInt(d.value);!isNaN(t)&&t>0&&this.tool.setFontSize(t)},i.appendChild(m),i.appendChild(p),n.appendChild(l),n.appendChild(o),r.appendChild(u),r.appendChild(d),this.updateDropdownInputs=()=>{const t=this.tool.getTextStyle();f(t.renderingStyle.fill),g.has(t.fontFamily)||v(t.fontFamily),o.value=t.fontFamily,d.value=`${t.size}`},this.updateDropdownInputs(),e.replaceChildren(i,r,n),t.appendChild(e),!0}serializeState(){const t=this.tool.getTextStyle();return Object.assign(Object.assign({},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(r.default.fromHex(t.color)),t.textSize&&"number"==typeof t.textSize&&this.tool.setFontSize(t.textSize),super.deserializeFrom(t)}}c.idCounter=0,e.default=c},7788:function(t,e,n){"use strict";var i=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.BaseWidget=e.BaseToolWidget=e.ActionButtonWidget=void 0;var r=n(5710);Object.defineProperty(e,"ActionButtonWidget",{enumerable:!0,get:function(){return i(r).default}});var o=n(6763);Object.defineProperty(e,"BaseToolWidget",{enumerable:!0,get:function(){return i(o).default}});var s=n(1455);Object.defineProperty(e,"BaseWidget",{enumerable:!0,get:function(){return i(s).default}});var a=n(3770);Object.defineProperty(e,"PenToolWidget",{enumerable:!0,get:function(){return i(a).default}});var l=n(6937);Object.defineProperty(e,"TextToolWidget",{enumerable:!0,get:function(){return i(l).default}});var c=n(5627);Object.defineProperty(e,"HandToolWidget",{enumerable:!0,get:function(){return i(c).default}});var d=n(6282);Object.defineProperty(e,"SelectionToolWidget",{enumerable:!0,get:function(){return i(d).default}});var u=n(2297);Object.defineProperty(e,"EraserToolWidget",{enumerable:!0,get:function(){return i(u).default}});var h=n(2085);Object.defineProperty(e,"InsertImageWidget",{enumerable:!0,get:function(){return i(h).default}});var p=n(234);Object.defineProperty(e,"DocumentPropertiesWidget",{enumerable:!0,get:function(){return i(p).default}})},2131:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(9699);e.default=class{onPointerDown(t){return!1}onPointerMove(t){}onPointerUp(t){}onGestureCancel(){}constructor(t,e){this.notifier=t,this.description=e,this.enabled=!0,this.group=null}onWheel(t){return!1}onCopy(t){return!1}onPaste(t){return!1}onKeyPress(t){return!1}onKeyUp(t){return!1}setEnabled(t){var e;this.enabled=t,t?(null===(e=this.group)||void 0===e||e.notifyEnabled(this),this.notifier.dispatch(i.EditorEventType.ToolEnabled,{kind:i.EditorEventType.ToolEnabled,tool:this})):this.notifier.dispatch(i.EditorEventType.ToolDisabled,{kind:i.EditorEventType.ToolDisabled,tool:this})}isEnabled(){return this.enabled}setToolGroup(t){this.isEnabled()&&t.notifyEnabled(this),this.group=t}getToolGroup(){return this.group?this.group:null}}},9270:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9699),o=i(n(2131)),s=n(6750),a=i(n(9784)),l=i(n(529)),c=n(306),d=i(n(8233)),u=i(n(5085));class h extends o.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastPoint=null,this.isFirstEraseEvt=!0,this.thickness=10,this.partialCommands=[]}clearPreview(){this.editor.clearWetInk()}getSizeOnCanvas(){return this.thickness/this.editor.viewport.getScaleFactor()}drawPreviewAt(t){this.clearPreview();const e=this.getSizeOnCanvas(),n=this.editor.display.getWetInkRenderer(),i=this.getEraserRect(t),r={fill:d.default.gray};n.drawRect(i,e/4,r)}getEraserRect(t){const e=this.getSizeOnCanvas(),n=s.Vec2.of(e/2,e/2);return u.default.fromCorners(t.minus(n),t.plus(n))}eraseTo(t){if(!this.isFirstEraseEvt&&0===t.minus(this.lastPoint).magnitude())return;this.isFirstEraseEvt=!1;const e=this.getEraserRect(t),n=new a.default(this.lastPoint,t),i=u.default.union(n.bbox,e),r=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t.intersects(n)||t.intersectsRect(e))).filter((t=>t.isSelectable()));this.toRemove.push(...r);const o=r.map((t=>new l.default([t])));o.forEach((t=>t.apply(this.editor))),this.partialCommands.push(...o),this.drawPreviewAt(t),this.lastPoint=t}onPointerDown(t){return(1===t.allPointers.length||t.current.device===c.PointerDevice.Eraser)&&(this.lastPoint=t.current.canvasPos,this.toRemove=[],this.isFirstEraseEvt=!0,this.drawPreviewAt(t.current.canvasPos),!0)}onPointerMove(t){const e=t.current.canvasPos;this.eraseTo(e)}onPointerUp(t){if(this.eraseTo(t.current.canvasPos),this.toRemove.length>0){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[];const t=new l.default(this.toRemove);this.editor.dispatch(t)}this.clearPreview()}onGestureCancel(){this.partialCommands.forEach((t=>t.unapply(this.editor))),this.partialCommands=[],this.clearPreview()}getThickness(){return this.thickness}setThickness(t){this.thickness=t,this.editor.notifier.dispatch(r.EditorEventType.ToolUpdated,{kind:r.EditorEventType.ToolUpdated,tool:this})}}e.default=h},3252:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.cssPrefix=void 0;const r=i(n(6205)),o=i(n(2131));e.cssPrefix="find-tool";class s extends o.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(`${e.cssPrefix}-overlay`)}getMatches(t){t=t.toLocaleLowerCase();return this.editor.image.getAllElements().filter((t=>t instanceof r.default)).filter((e=>-1!==e.getText().toLocaleLowerCase().indexOf(t))).map((t=>t.getBBox()))}focusCurrentMatch(){const t=this.getMatches(this.searchInput.value);let e=this.currentMatchIdx%t.length;if(e<0&&(e=t.length+e),e<t.length){const n=!1;this.editor.dispatch(this.editor.viewport.zoomTo(t[e],!0,!0),n),this.editor.announceForAccessibility(this.editor.localization.focusedFoundText(e+1,t.length))}}toNextMatch(){this.currentMatchIdx++,this.focusCurrentMatch()}toPrevMatch(){this.currentMatchIdx--,this.focusCurrentMatch()}fillOverlay(){const t=document.createElement("label");this.searchInput=document.createElement("input");const n=document.createElement("button"),i=document.createElement("button");this.searchInput.setAttribute("id",`${e.cssPrefix}-searchInput-${Math.random()}`),t.htmlFor=this.searchInput.getAttribute("id"),t.innerText=this.editor.localization.findLabel,n.innerText=this.editor.localization.toNextMatch,i.innerText=this.editor.localization.closeFindDialog,this.searchInput.onkeydown=t=>{"Enter"===t.key?t.shiftKey?this.toPrevMatch():this.toNextMatch():"Escape"===t.key?this.setVisible(!1):"f"===t.key&&t.ctrlKey&&(t.preventDefault(),this.toggleVisible())},n.onclick=()=>{this.toNextMatch()},i.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(t,this.searchInput,n,i)}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!(!t.ctrlKey||"f"!==t.key)&&(this.toggleVisible(),!0)}setEnabled(t){super.setEnabled(t),t&&this.setVisible(!1)}}e.default=s},135:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanZoomMode=void 0;const o=r(n(2054)),s=n(6750),a=r(n(3785)),l=n(306),c=n(9699),d=r(n(2822)),u=n(8831),h=r(n(2131));var p;!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"}(p=e.PanZoomMode||(e.PanZoomMode={}));class f{constructor(t,e,n){this.initialVelocity=t,this.scrollBy=e,this.onComplete=n,this.running=!1,this.start()}start(){return i(this,void 0,void 0,(function*(){if(this.running)return;this.currentVelocity=this.initialVelocity;let t=(new Date).getTime();this.running=!0;for(this.currentVelocity.magnitude()>5e3&&(this.currentVelocity=this.currentVelocity.normalized().times(5e3));this.running&&this.currentVelocity.magnitude()>200;){const e=(new Date).getTime(),n=(e-t)/1e3;this.currentVelocity=this.currentVelocity.times(Math.pow(1/8,n)),this.scrollBy(this.currentVelocity.times(n)),yield(0,d.default)(),t=e}this.running&&this.stop()}))}getCurrentVelocity(){return this.running?this.currentVelocity:null}stop(){this.running&&(this.running=!1,this.onComplete())}}class m extends h.default{constructor(t,e,n){super(t.notifier,n),this.editor=t,this.mode=e,this.transform=null,this.lastPointerDownTimestamp=0,this.initialTouchAngle=0,this.initialViewportRotation=0,this.inertialScroller=null,this.velocity=null}computePinchData(t,e){if(t.id<e.id){const n=t;t=e,e=n}const n=e.screenPos.minus(t.screenPos),i=n.angle(),r=n.magnitude();return{canvasCenter:e.canvasPos.plus(t.canvasPos).times(.5),screenCenter:e.screenPos.plus(t.screenPos).times(.5),angle:i,dist:r}}allPointersAreOfType(t,e){return t.every((t=>t.device===e))}onPointerDown({allPointers:t,current:e}){var n,i,r,a;let c=!1;const d=null!==(i=null===(n=this.inertialScroller)||void 0===n?void 0:n.getCurrentVelocity())&&void 0!==i?i:s.Vec2.zero;null===(r=this.inertialScroller)||void 0===r||r.stop(),this.velocity=d,this.lastPointerDownTimestamp=e.timeStamp;const h=this.allPointersAreOfType(t,l.PointerDevice.Touch),f=this.allPointersAreOfType(t,l.PointerDevice.RightButtonMouse);if(h&&2===t.length&&this.mode&p.TwoFingerTouchGestures){const{screenCenter:e,angle:n,dist:i}=this.computePinchData(t[0],t[1]);this.lastDist=i,this.lastScreenCenter=e,this.initialTouchAngle=n,this.initialViewportRotation=this.editor.viewport.getRotationAngle(),c=!0}else 1===t.length&&(this.mode&p.OneFingerTouchGestures&&h||f&&this.mode&p.RightClickDrags||this.mode&p.SinglePointerGestures)&&(this.lastScreenCenter=t[0].screenPos,c=!0);return c&&(this.lastTimestamp=(new Date).getTime(),null!==(a=this.transform)&&void 0!==a||(this.transform=u.Viewport.transformBy(o.default.identity)),this.editor.display.setDraftMode(!0)),c}updateVelocity(t){const e=t.minus(this.lastScreenCenter);let n=((new Date).getTime()-this.lastTimestamp)/1e3;if(0===e.magnitude()&&n<.1)return;if(0===n)return;n=Math.max(n,.01);const i=e.times(1/n);let r=i;this.velocity&&(r=this.velocity.lerp(i,.5)),this.velocity=r}getCenterDelta(t){return this.editor.viewport.screenToCanvasTransform.transformVec3(t.minus(this.lastScreenCenter))}toSnappedRotationDelta(t){let e=t-this.initialTouchAngle+this.initialViewportRotation;const n=Math.PI/2,i=Math.round(e/n)*n;return Math.abs(e-i)<.07&&(e=i,0!==e&&(e+=1e-4)),e-this.editor.viewport.getRotationAngle()}handleTwoFingerMove(t){const{screenCenter:e,canvasCenter:n,angle:i,dist:r}=this.computePinchData(t[0],t[1]),s=this.getCenterDelta(e);let a;a=this.isRotationLocked()?0:this.toSnappedRotationDelta(i),this.updateVelocity(e);const l=o.default.translation(s).rightMul(o.default.scaling2D(r/this.lastDist,n)).rightMul(o.default.zRotation(a,n));this.lastScreenCenter=e,this.lastDist=r,this.transform=u.Viewport.transformBy(this.transform.transform.rightMul(l))}handleOneFingerMove(t){const e=this.getCenterDelta(t.screenPos);this.transform=u.Viewport.transformBy(this.transform.transform.rightMul(o.default.translation(e))),this.updateVelocity(t.screenPos),this.lastScreenCenter=t.screenPos}onPointerMove({allPointers:t}){var e;null!==(e=this.transform)&&void 0!==e||(this.transform=u.Viewport.transformBy(o.default.identity));const n=this.transform;2===t.length?this.handleTwoFingerMove(t):1===t.length&&this.handleOneFingerMove(t[0]),n.unapply(this.editor),this.transform.apply(this.editor),this.lastTimestamp=(new Date).getTime()}onPointerUp(t){var e;const n=()=>{this.transform&&(this.transform.unapply(this.editor),this.editor.dispatch(this.transform,!1)),this.editor.display.setDraftMode(!1),this.transform=null,this.velocity=s.Vec2.zero};if(t.current.device===l.PointerDevice.Touch&&1===t.allPointers.length&&null!==this.velocity&&t.current.timeStamp-this.lastPointerDownTimestamp>30&&null!==this.velocity){const i=this.velocity;this.updateVelocity(t.current.screenPos),i.magnitude()<this.velocity.magnitude()&&(this.velocity=i),null===(e=this.inertialScroller)||void 0===e||e.stop(),this.inertialScroller=new f(this.velocity,(t=>{if(!this.transform)return;const e=this.editor.viewport.screenToCanvasTransform.transformVec3(t);this.transform.unapply(this.editor),this.transform=u.Viewport.transformBy(this.transform.transform.rightMul(o.default.translation(e))),this.transform.apply(this.editor)}),n)}else n()}onGestureCancel(){var t,e;null===(t=this.inertialScroller)||void 0===t||t.stop(),this.velocity=s.Vec2.zero,null===(e=this.transform)||void 0===e||e.unapply(this.editor),this.editor.display.setDraftMode(!1),this.transform=null}updateTransform(t,e=!1){var n;let i=t;this.transform&&(i=this.transform.transform.rightMul(t)),null===(n=this.transform)||void 0===n||n.unapply(this.editor),this.transform=u.Viewport.transformBy(i),this.transform.apply(this.editor),e&&this.editor.announceForAccessibility(this.transform.description(this.editor,this.editor.localization))}onWheel({delta:t,screenPos:e}){var n;null===(n=this.inertialScroller)||void 0===n||n.stop(),this.transform=u.Viewport.transformBy(o.default.identity);const i=this.editor.viewport.screenToCanvas(e),r=this.editor.viewport.screenToCanvasTransform.transformVec3(a.default.of(-t.x,-t.y,0)),s=o.default.scaling2D(Math.max(.25,Math.min(Math.pow(1.03,-t.z),4)),i).rightMul(o.default.translation(r));return this.updateTransform(s,!0),!0}onKeyPress({key:t,ctrlKey:e,altKey:n}){var i;if(null===(i=this.inertialScroller)||void 0===i||i.stop(),!(this.mode&p.Keyboard))return!1;if(e||n)return!1;this.transform=u.Viewport.transformBy(o.default.identity);let r=s.Vec2.zero,a=1,l=0;switch(t){case"a":case"h":case"ArrowLeft":r=s.Vec2.of(-1,0);break;case"d":case"l":case"ArrowRight":r=s.Vec2.of(1,0);break;case"q":case"k":case"ArrowUp":r=s.Vec2.of(0,-1);break;case"e":case"j":case"ArrowDown":r=s.Vec2.of(0,1);break;case"w":a=.5;break;case"s":a=2;break;case"r":l=1;break;case"R":l=-1;break;default:return!1}r=r.times(30),l*=Math.PI/8,r=r.times(-1),l*=-1,a=1/a,0!==l&&(l+=1e-4),this.isRotationLocked()&&(l=0);r=this.editor.viewport.screenToCanvasTransform.transformVec3(r);const c=this.editor.viewport.visibleRect.center,d=o.default.scaling2D(a,c).rightMul(o.default.zRotation(l,c)).rightMul(o.default.translation(r));return this.updateTransform(d,!0),!0}isRotationLocked(){return!!(this.mode&p.RotationLocked)}setModeEnabled(t,e){let n=this.mode;e?n|=t:n&=~t,this.setMode(n)}setMode(t){t!==this.mode&&(this.mode=t,this.editor.notifier.dispatch(c.EditorEventType.ToolUpdated,{kind:c.EditorEventType.ToolUpdated,tool:this}))}getMode(){return this.mode}}e.default=m},3947:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(6205)),s=r(n(8684)),a=r(n(2054)),l=r(n(2131)),c=r(n(2100)),d=r(n(8233)),u=r(n(5249));class h extends l.default{constructor(t){super(t.notifier,t.localization.pasteHandler),this.editor=t}onPaste(t){const e=t.mime.toLowerCase();return"image/svg+xml"===e?(this.doSVGPaste(t.data),!0):"text/plain"===e?(this.doTextPaste(t.data),!0):("image/png"===e||"image/jpeg"===e)&&(this.doImagePaste(t.data),!0)}addComponentsFromPaste(t){return i(this,void 0,void 0,(function*(){yield this.editor.addAndCenterComponents(t)}))}doSVGPaste(t){return i(this,void 0,void 0,(function*(){const e=s.default.fromString(t,!0),n=[];yield e.start((t=>{n.push(t)}),((t,e)=>null)),yield this.addComponentsFromPaste(n)}))}doTextPaste(t){var e,n;return i(this,void 0,void 0,(function*(){const i=this.editor.toolController.getMatchingTools(c.default);i.sort(((t,e)=>!t.isEnabled()&&e.isEnabled()?-1:!e.isEnabled()&&t.isEnabled()?1:0));const r={size:12,fontFamily:"sans",renderingStyle:{fill:d.default.red}},s=null!==(n=null===(e=i[0])||void 0===e?void 0:e.getTextStyle())&&void 0!==n?n:r,l=t.split("\n");yield this.addComponentsFromPaste([o.default.fromLines(l,a.default.identity,s)])}))}doImagePaste(t){return i(this,void 0,void 0,(function*(){const e=new Image;e.src=t;const n=yield u.default.fromImage(e,a.default.identity);yield this.addComponentsFromPaste([n])}))}}e.default=h},7052:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(4721)),o=n(306),s=n(1173),a=n(9699),l=i(n(2131));class c extends l.default{constructor(t,e,n,i=s.makeFreehandLineBuilder){super(t.notifier,e),this.editor=t,this.style=n,this.builderFactory=i,this.builder=null,this.lastPoint=null,this.ctrlKeyPressed=!1}getPressureMultiplier(){return 1/this.editor.viewport.getScaleFactor()*this.style.thickness}toStrokePoint(t){var e;this.isSnappingToGrid()&&(t=t.snappedToGrid(this.editor.viewport));let n=Math.max(null!==(e=t.pressure)&&void 0!==e?e:1,.3);isFinite(n)||(console.warn("Non-finite pressure!",t),n=.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:n*this.getPressureMultiplier(),color:this.style.color,time:t.timeStamp}}previewStroke(){var t;this.editor.clearWetInk(),null===(t=this.builder)||void 0===t||t.preview(this.editor.display.getWetInkRenderer())}addPointToStroke(t){if(!this.builder)throw new Error("No stroke is currently being generated.");this.builder.addPoint(t),this.lastPoint=t,this.previewStroke()}onPointerDown({current:t,allPointers:e}){const n=t.device===o.PointerDevice.Eraser;let i=!1;for(const t of e)if(t.device===o.PointerDevice.Pen){i=!0;break}return!((1!==e.length||n)&&!i)&&(this.builder=this.builderFactory(this.toStrokePoint(t),this.editor.viewport),!0)}onPointerMove({current:t}){this.builder&&this.addPointToStroke(this.toStrokePoint(t))}onPointerUp({current:t}){var e,n;if(!this.builder)return;const i=this.toStrokePoint(t),r=Object.assign(Object.assign({},i),{width:null!==(n=null===(e=this.lastPoint)||void 0===e?void 0:e.width)&&void 0!==n?n:i.width});this.addPointToStroke(r),t.isPrimary&&this.finalizeStroke()}onGestureCancel(){this.editor.clearWetInk()}finalizeStroke(){if(this.builder){const t=this.builder.build();if(this.previewStroke(),t.getBBox().area>0){const e=!0,n=r.default.addElement(t,e);this.editor.dispatch(n)}else console.warn("Pen: Not adding empty stroke",t,"to the canvas.")}this.builder=null,this.editor.clearWetInk()}noteUpdated(){this.editor.notifier.dispatch(a.EditorEventType.ToolUpdated,{kind:a.EditorEventType.ToolUpdated,tool:this})}setColor(t){t.toHexString()!==this.style.color.toHexString()&&(this.style=Object.assign(Object.assign({},this.style),{color:t}),this.noteUpdated())}setThickness(t){t!==this.style.thickness&&(this.style=Object.assign(Object.assign({},this.style),{thickness:t}),this.noteUpdated())}setStrokeFactory(t){t!==this.builderFactory&&(this.builderFactory=t,this.noteUpdated())}getThickness(){return this.style.thickness}getColor(){return this.style.color}getStrokeFactory(){return this.builderFactory}setEnabled(t){super.setEnabled(t),this.ctrlKeyPressed=!1}isSnappingToGrid(){return this.ctrlKeyPressed}onKeyPress({key:t,ctrlKey:e}){let n;return"-"===(t=t.toLowerCase())||"_"===t?n=2*this.getThickness()/3:"+"!==t&&"="!==t||(n=3*this.getThickness()/2),void 0!==n?(n=Math.min(Math.max(1,n),256),this.setThickness(n),!0):"control"===t||"meta"===t?(this.ctrlKeyPressed=!0,!0):("z"===t&&e&&this.builder&&this.finalizeStroke(),!1)}onKeyUp({key:t}){return("control"===(t=t.toLowerCase())||"meta"===t)&&(this.ctrlKeyPressed=!1,!0)}}e.default=c},5529:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.colorPreviewListener=null,this.colorSelectListener=null}setColorListener(t,e){this.colorPreviewListener=t,this.colorSelectListener=e}clearColorListener(){this.colorPreviewListener=null,this.colorSelectListener=null}onPointerDown({current:t,allPointers:e}){return!(!this.colorPreviewListener||1!==e.length)&&(this.colorPreviewListener(this.editor.display.getColorAt(t.screenPos)),!0)}onPointerMove({current:t}){var e;null===(e=this.colorPreviewListener)||void 0===e||e.call(this,this.editor.display.getColorAt(t.screenPos))}onPointerUp({current:t}){var e;null===(e=this.colorSelectListener)||void 0===e||e.call(this,this.editor.display.getColorAt(t.screenPos))}onGestureCancel(){var t;null===(t=this.colorSelectListener)||void 0===t||t.call(this,null)}}e.default=o},6009:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131)),o=i(n(1626));class s extends r.default{constructor(t){super(t.notifier,t.localization.selectAllTool),this.editor=t}onKeyPress({key:t,ctrlKey:e}){if(e&&"a"===t){const t=this.editor.toolController.getMatchingTools(o.default);if(t.length>0){const e=t[0];return e.setEnabled(!0),e.setSelection(this.editor.image.getAllElements()),!0}}return!1}}e.default=s},7754:function(t,e,n){"use strict";var i,r=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},a=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const c=l(n(1386)),d=l(n(2054)),u=l(n(5085)),h=n(6750),p=s(n(9975)),f=n(1626),m=l(n(8831)),g=l(n(529)),v=l(n(9098)),y=n(2537),b=n(9196),x=l(n(4721));class w{constructor(t,e){this.editor=e,this.transform=d.default.identity,this.selectedElems=[],this.hasParent=!0,this.removedFromImage={},this.targetHandle=null,this.backgroundDragging=!1,this.originalRegion=new u.default(t.x,t.y,0,0),this.transformers={drag:new y.DragTransformer(e,this),resize:new y.ResizeTransformer(e,this),rotate:new y.RotateTransformer(e,this)},this.container=document.createElement("div"),this.backgroundElem=document.createElement("div"),this.backgroundElem.classList.add(`${f.cssPrefix}selection-background`),this.container.appendChild(this.backgroundElem);const n=new p.default(p.HandleShape.Square,h.Vec2.of(1,.5),this,(t=>this.transformers.resize.onDragStart(t,b.ResizeMode.HorizontalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),i=new p.default(p.HandleShape.Square,h.Vec2.of(.5,1),this,(t=>this.transformers.resize.onDragStart(t,b.ResizeMode.VerticalOnly)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),r=new p.default(p.HandleShape.Square,h.Vec2.of(1,1),this,(t=>this.transformers.resize.onDragStart(t,b.ResizeMode.Both)),(t=>this.transformers.resize.onDragUpdate(t)),(()=>this.transformers.resize.onDragEnd())),o=new p.default(p.HandleShape.Circle,h.Vec2.of(.5,0),this,(t=>this.transformers.rotate.onDragStart(t)),(t=>this.transformers.rotate.onDragUpdate(t)),(()=>this.transformers.rotate.onDragEnd()));this.handles=[r,n,i,o];for(const t of this.handles)t.addTo(this.backgroundElem)}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){const t=d.default.zRotation(this.regionRotation,this.originalRegion.center),e=this.transform.rightMul(t.inverse());return this.originalRegion.transformedBoundingBox(e)}computeTightBoundingBox(){const t=this.selectedElems.reduce(((t,e)=>(null!=t?t:e.getBBox()).union(e.getBBox())),null);return null!=t?t:u.default.empty}get regionRotation(){return this.transform.transformVec3(h.Vec2.unitX).angle()}get preTransformedScreenRegion(){const t=t=>this.editor.viewport.canvasToScreen(t);return u.default.fromCorners(t(this.preTransformRegion.topLeft),t(this.preTransformRegion.bottomRight))}get preTransformedScreenRegionRotation(){return this.editor.viewport.getRotationAngle()}get screenRegion(){const t=this.editor.viewport.canvasToScreenTransform,e=this.editor.viewport.getScaleFactor(),n=t.transformVec2(this.region.center);return new u.default(n.x,n.y,e*this.region.width,e*this.region.height).translatedBy(this.region.size.times(-e/2))}get screenRegionRotation(){return this.regionRotation+this.editor.viewport.getRotationAngle()}setTransform(t,e=!0){this.transform=t,e&&this.hasParent&&(this.scrollTo(),this.previewTransformCmds())}finalizeTransform(){const t=this.transform,e=this.selectedElems;this.originalRegion=this.originalRegion.transformedBoundingBox(this.transform),this.transform=d.default.identity,this.editor.dispatch(new w.ApplyTransformationCommand(this,e,t));this.editor.display.getWetInkRenderer().clear()}previewTransformCmds(){if(this.selectedElems.length>500)return void this.updateUI();const t=this.editor.display.getWetInkRenderer();t.clear(),t.pushTransform(this.transform);const e=this.editor.viewport.visibleRect.transformedBoundingBox(this.transform.inverse());for(const n of this.selectedElems)n.render(t,e);t.popTransform(),this.updateUI()}resolveToObjects(){let t=!1;if(this.transform=d.default.identity,0===this.region.w||0===this.region.h){const e=this.editor.viewport.visibleRect.maxDimension/200;this.originalRegion=u.default.bboxOf(this.region.corners,e),t=!0}return this.selectedElems=this.editor.image.getElementsIntersectingRegion(this.region).filter((t=>t.intersectsRect(this.region)&&t.isSelectable())),t&&this.selectedElems.length>0&&(this.selectedElems=[this.selectedElems[this.selectedElems.length-1]]),!!this.recomputeRegion()&&(this.updateUI(),!0)}recomputeRegion(){const t=this.computeTightBoundingBox();if(!t)return this.cancelSelection(),!1;this.originalRegion=t;const e=this.getMinCanvasSize();if(this.originalRegion.w<e||this.originalRegion.h<e){const t=e/2;this.originalRegion=u.default.bboxOf(this.originalRegion.corners,t)}return!0}getMinCanvasSize(){return 2*(p.handleSize/this.editor.viewport.getScaleFactor())}getSelectedItemCount(){return this.selectedElems.length}updateUI(){if(!this.hasParent)return;this.backgroundElem.style.marginLeft=`${this.screenRegion.topLeft.x}px`,this.backgroundElem.style.marginTop=`${this.screenRegion.topLeft.y}px`,this.backgroundElem.style.width=`${this.screenRegion.width}px`,this.backgroundElem.style.height=`${this.screenRegion.height}px`;const t=180*this.screenRegionRotation/Math.PI;this.backgroundElem.style.transform=`rotate(${t}deg)`,this.backgroundElem.style.transformOrigin="center";for(const t of this.handles)t.updatePosition()}addRemoveSelectionFromImage(t){if(t||!(this.selectedElems.length>500)){for(const e of this.selectedElems){const n=this.editor.image.findParent(e);!t&&n?(this.removedFromImage[e.getId()]=!0,n.remove()):!n&&this.removedFromImage[e.getId()]&&(x.default.addElement(e).apply(this.editor),this.removedFromImage[e.getId()]=!1,delete this.removedFromImage[e.getId()])}this.editor.queueRerender().then((()=>{t||this.previewTransformCmds()}))}}removeDeletedElemsFromSelection(){this.selectedElems=this.selectedElems.filter((t=>{const e=!!this.editor.image.findParent(t),n=this.removedFromImage[t.getId()];return e||n}))}onDragStart(t,e){this.removeDeletedElemsFromSelection(),this.addRemoveSelectionFromImage(!1);for(const n of this.handles)if(n.isTarget(e))return n.handleDragStart(t),this.targetHandle=n,!0;return this.backgroundElem===e&&(this.backgroundDragging=!0,this.transformers.drag.onDragStart(t.canvasPos),!0)}onDragUpdate(t){this.backgroundDragging&&this.transformers.drag.onDragUpdate(t.canvasPos),this.targetHandle&&this.targetHandle.handleDragUpdate(t)}onDragEnd(){this.backgroundDragging?this.transformers.drag.onDragEnd():this.targetHandle&&this.targetHandle.handleDragEnd(),this.addRemoveSelectionFromImage(!0),this.backgroundDragging=!1,this.targetHandle=null,this.updateUI()}onDragCancel(){this.backgroundDragging=!1,this.targetHandle=null,this.setTransform(d.default.identity),this.addRemoveSelectionFromImage(!0)}scrollTo(){return a(this,void 0,void 0,(function*(){if(0===this.selectedElems.length)return;const t=new u.default(0,0,this.editor.display.width,this.editor.display.height);if(!t.containsPoint(this.screenRegion.center)){const e=t.getClosestPointOnBoundaryTo(this.screenRegion.center),n=this.screenRegion.center.minus(e),i=this.editor.viewport.screenToCanvasTransform.transformVec3(n);yield this.editor.dispatchNoAnnounce(m.default.transformBy(d.default.translation(i.times(-1))),!1),yield this.editor.queueRerender(),this.previewTransformCmds()}}))}deleteSelectedObjects(){return(this.backgroundDragging||this.targetHandle)&&this.onDragEnd(),new g.default(this.selectedElems)}duplicateSelectedObjects(){return a(this,void 0,void 0,(function*(){const t=this.backgroundDragging||this.targetHandle;let e=null;if(t){const t=null;e=new w.ApplyTransformationCommand(t,this.selectedElems,this.transform),yield e.apply(this.editor),this.addRemoveSelectionFromImage(!0)}const n=new v.default(this.selectedElems);return t&&(yield null==e?void 0:e.unapply(this.editor),this.addRemoveSelectionFromImage(!1),this.previewTransformCmds(),this.updateUI()),n}))}addTo(t){this.container.parentElement&&this.container.remove(),t.appendChild(this.container),this.hasParent=!0}setToPoint(t){this.originalRegion=this.originalRegion.grownToPoint(t),this.updateUI()}cancelSelection(){this.container.parentElement&&this.container.remove(),this.originalRegion=u.default.empty,this.hasParent=!1}setSelectedObjects(t,e){this.addRemoveSelectionFromImage(!0),this.originalRegion=e,this.selectedElems=t.filter((t=>t.isSelectable())),this.updateUI()}getSelectedObjects(){return this.selectedElems}}i=w,c.default.register("selection-tool-transform",((t,e)=>{var n;const r=new d.default(...t.transform),o=null!==(n=t.elems)&&void 0!==n?n:[];return new i.ApplyTransformationCommand(null,o,r)})),w.ApplyTransformationCommand=class extends c.default{constructor(t,e,n){super("selection-tool-transform"),this.selection=t,this.fullTransform=n;"string"==typeof e[0]?this.selectedElemIds=e:(this.selectedElemIds=e.map((t=>t.getId())),this.transformCommands=e.map((t=>t.transformBy(this.fullTransform))))}resolveToElems(t){this.transformCommands||(this.transformCommands=this.selectedElemIds.map((e=>{const n=t.image.lookupElement(e);if(!n)throw new Error(`Unable to find element with ID, ${e}.`);return n.transformBy(this.fullTransform)})))}apply(t){var e,n,i,r,o;return a(this,void 0,void 0,(function*(){this.resolveToElems(t),null===(e=this.selection)||void 0===e||e.setTransform(this.fullTransform,!1),null===(n=this.selection)||void 0===n||n.updateUI(),yield t.asyncApplyCommands(this.transformCommands,100),null===(i=this.selection)||void 0===i||i.setTransform(d.default.identity,!1),null===(r=this.selection)||void 0===r||r.recomputeRegion(),null===(o=this.selection)||void 0===o||o.updateUI()}))}unapply(t){var e,n,i,r,o;return a(this,void 0,void 0,(function*(){this.resolveToElems(t),null===(e=this.selection)||void 0===e||e.setTransform(this.fullTransform.inverse(),!1),null===(n=this.selection)||void 0===n||n.updateUI(),yield t.asyncUnapplyCommands(this.transformCommands,100,!0),null===(i=this.selection)||void 0===i||i.setTransform(d.default.identity,!1),null===(r=this.selection)||void 0===r||r.recomputeRegion(),null===(o=this.selection)||void 0===o||o.updateUI()}))}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray()}}description(t,e){return e.transformedElements(this.selectedElemIds.length)}},e.default=w},9975:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.handleSize=e.HandleShape=void 0;const i=n(246),r=n(6750),o=n(1626);var s;!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square"}(s=e.HandleShape||(e.HandleShape={})),e.handleSize=30;e.default=class{constructor(t,e,n,r,a,l){switch(this.shape=t,this.parentSide=e,this.parent=n,this.onDragStart=r,this.onDragUpdate=a,this.onDragEnd=l,this.dragLastPos=null,this.element=document.createElement("div"),this.element.classList.add(`${o.cssPrefix}handle`),t){case s.Circle:this.element.classList.add(`${o.cssPrefix}circle`);break;case s.Square:this.element.classList.add(`${o.cssPrefix}square`);break;default:(0,i.assertUnreachable)(t)}this.updatePosition()}addTo(t){t.appendChild(this.element)}updatePosition(){const t=this.parent.screenRegion,n=r.Vec2.of(e.handleSize,e.handleSize),i=t.size.scale(this.parentSide).minus(n.times(.5));this.element.style.marginLeft=`${i.x}px`,this.element.style.marginTop=`${i.y}px`,this.element.style.width=`${n.x}px`,this.element.style.height=`${n.y}px`}isTarget(t){return t===this.element}handleDragStart(t){this.onDragStart(t.canvasPos),this.dragLastPos=t.canvasPos}handleDragUpdate(t){this.dragLastPos&&this.onDragUpdate(t.canvasPos)}handleDragEnd(){this.dragLastPos&&this.onDragEnd()}setSnapToGrid(t){this.snapToGrid=t}isSnappingToGrid(){return this.snapToGrid}}},1626:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.cssPrefix=void 0;const r=i(n(2054)),o=n(6750),s=n(9699),a=i(n(8831)),l=i(n(2131)),c=i(n(9563)),d=i(n(7754)),u=i(n(6205));e.cssPrefix="selection-tool-";class h extends l.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastEvtTarget=null,this.expandingSelectionBox=!1,this.shiftKeyPressed=!1,this.ctrlKeyPressed=!1,this.selectionBoxHandlingEvt=!1,this.handleOverlay=document.createElement("div"),t.createHTMLOverlay(this.handleOverlay),this.handleOverlay.style.display="none",this.handleOverlay.classList.add("handleOverlay"),t.notifier.on(s.EditorEventType.ViewportChanged,(t=>{var e;null===(e=this.selectionBox)||void 0===e||e.updateUI()})),this.editor.handleKeyEventsFrom(this.handleOverlay),this.editor.handlePointerEventsFrom(this.handleOverlay,((t,e)=>("pointerdown"===t&&(this.lastEvtTarget=e.target),!0)))}makeSelectionBox(t){var e;this.prevSelectionBox=this.selectionBox,this.selectionBox=new d.default(t,this.editor),this.expandingSelectionBox||null===(e=this.prevSelectionBox)||void 0===e||e.cancelSelection(),this.selectionBox.addTo(this.handleOverlay)}snapSelectionToGrid(){if(!this.selectionBox)throw new Error("No selection to snap!");const t=this.selectionBox.computeTightBoundingBox().topLeft,e=this.editor.viewport.snapToGrid(t).minus(t),n=this.selectionBox.getTransform();this.selectionBox.setTransform(n.rightMul(r.default.translation(e))),this.selectionBox.finalizeTransform()}onPointerDown({allPointers:t,current:e}){const n=this.ctrlKeyPressed;if(n&&(e=e.snappedToGrid(this.editor.viewport)),1===t.length&&e.isPrimary){let t=!1;if(this.lastEvtTarget&&this.selectionBox){n&&this.snapSelectionToGrid();this.selectionBox.onDragStart(e,this.lastEvtTarget)&&(t=!0,this.selectionBoxHandlingEvt=!0,this.expandingSelectionBox=!1)}return t||(this.expandingSelectionBox=this.shiftKeyPressed,this.makeSelectionBox(e.canvasPos)),!0}return!1}onPointerMove(t){if(!this.selectionBox)return;let e=t.current;this.ctrlKeyPressed&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox.onDragUpdate(e):this.selectionBox.setToPoint(e.canvasPos)}onSelectionUpdated(){var t,e;this.editor.notifier.dispatch(s.EditorEventType.ToolUpdated,{kind:s.EditorEventType.ToolUpdated,tool:this});const n=null!==(e=null===(t=this.selectionBox)||void 0===t?void 0:t.getSelectedItemCount())&&void 0!==e?e:0;n>0?(this.editor.announceForAccessibility(this.editor.localization.selectedElements(n)),this.zoomToSelection()):this.selectionBox&&(this.selectionBox.cancelSelection(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null)}onGestureEnd(){this.lastEvtTarget=null,this.selectionBox&&(this.selectionBoxHandlingEvt?this.selectionBox.onDragEnd():(this.selectionBox.resolveToObjects(),this.onSelectionUpdated()),this.selectionBoxHandlingEvt=!1)}zoomToSelection(){if(this.selectionBox){const t=this.selectionBox.region;this.editor.dispatchNoAnnounce(this.editor.viewport.zoomTo(t,!1),!1)}}onPointerUp(t){if(!this.selectionBox)return;let e=t.current;this.ctrlKeyPressed&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBox.setToPoint(e.canvasPos),this.expandingSelectionBox&&this.prevSelectionBox?(this.expandingSelectionBox=!1,this.selectionBox.resolveToObjects(),this.setSelection([...this.selectionBox.getSelectedObjects(),...this.prevSelectionBox.getSelectedObjects()])):this.onGestureEnd()}onGestureCancel(){var t,e,n,i;this.selectionBoxHandlingEvt?null===(t=this.selectionBox)||void 0===t||t.onDragCancel():(null===(e=this.selectionBox)||void 0===e||e.cancelSelection(),this.selectionBox=this.prevSelectionBox,null===(n=this.selectionBox)||void 0===n||n.addTo(this.handleOverlay),null===(i=this.selectionBox)||void 0===i||i.recomputeRegion(),this.prevSelectionBox=null),this.expandingSelectionBox=!1}onKeyPress(t){if("Control"===t.key||"Meta"===t.key)return this.ctrlKeyPressed=!0,!0;if(this.selectionBox&&t.ctrlKey&&"d"===t.key)return!0;if("a"===t.key&&t.ctrlKey)return this.setSelection(this.editor.image.getAllElements()),!0;if(t.ctrlKey)return!1;if("Shift"===t.key)return this.shiftKeyPressed=!0,!0;let e=0,n=0,i=0,s=0,l=0;switch(t.key){case"a":case"h":case"ArrowLeft":n-=1;break;case"d":case"l":case"ArrowRight":n+=1;break;case"q":case"k":case"ArrowUp":i-=1;break;case"e":case"j":case"ArrowDown":i+=1;break;case"r":e+=1;break;case"R":e-=1;break;case"i":s-=1;break;case"I":s+=1;break;case"o":l-=1;break;case"O":l+=1}let c=0!==n||0!==i||0!==e||0!==s||0!==l;if(this.selectionBox){if(c){const t=10*this.editor.viewport.getSizeOfPixelOnCanvas(),c=Math.PI/8,d=5/4,u=this.selectionBox.region,h=o.Vec2.of(Math.pow(d,s),Math.pow(d,l)),p=r.default.zRotation(e*c).mapEntries((t=>a.default.roundScaleRatio(t))),f=this.editor.viewport.roundPoint(u.center),m=r.default.scaling2D(h,this.editor.viewport.roundPoint(u.topLeft)).rightMul(r.default.translation(f).rightMul(p).rightMul(r.default.translation(f.times(-1)))).rightMul(r.default.translation(this.editor.viewport.roundPoint(o.Vec2.of(n,i).times(t)))),g=this.selectionBox.getTransform();this.selectionBox.setTransform(g.rightMul(m))}}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){if("Control"===t.key||"Meta"===t.key)return this.ctrlKeyPressed=!1,!0;if("Shift"===t.key)return this.shiftKeyPressed=!1,!0;if(t.ctrlKey){if(this.selectionBox&&"d"===t.key)return this.selectionBox.duplicateSelectedObjects().then((t=>{this.editor.dispatch(t)})),!0;if("a"===t.key||"r"===t.key)return!0}return!(!this.selectionBox||!h.handleableKeys.some((e=>e===t.key)))&&(this.selectionBox.finalizeTransform(),!0)}onCopy(t){if(!this.selectionBox)return!1;const e=this.selectionBox.getSelectedObjects(),n=this.selectionBox.region;if(0===e.length)return!1;const i=new a.default((()=>{}));i.updateScreenSize(o.Vec2.of(n.w,n.h)),i.resetTransform(r.default.translation(n.topLeft.times(-1)));const{element:s,renderer:l}=c.default.fromViewport(i,!0),d=[];for(const t of e)t.render(l),t instanceof u.default&&d.push(t.getText());return t.setData("image/svg+xml",s.outerHTML),t.setData("text/html",s.outerHTML),d.length>0&&t.setData("text/plain",d.join("\n")),!0}setEnabled(t){super.setEnabled(t),this.handleOverlay.replaceChildren(),this.selectionBox=null,this.shiftKeyPressed=!1,this.ctrlKeyPressed=!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(){var t,e;return null!==(e=null===(t=this.selectionBox)||void 0===t?void 0:t.getSelectedObjects())&&void 0!==e?e:[]}setSelection(t){(t=t.filter((t=>t.isSelectable()))).sort(((t,e)=>t.getZIndex()-e.getZIndex())),t=t.filter(((e,n)=>!(n>0)||e!==t[n-1]));let e=null;for(const n of t)e=e?e.union(n.getBBox()):n.getBBox();e&&(this.clearSelection(),this.selectionBox||this.makeSelectionBox(e.topLeft),this.selectionBox.setSelectedObjects(t,e),this.onSelectionUpdated())}clearSelection(){this.handleOverlay.replaceChildren(),this.prevSelectionBox=this.selectionBox,this.selectionBox=null,this.onSelectionUpdated()}}h.handleableKeys=["a","h","ArrowLeft","d","l","ArrowRight","q","k","ArrowUp","e","j","ArrowDown","r","R","i","I","o","O","Control","Meta"],e.default=h},2537:function(t,e,n){"use strict";var i=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 r=i(n(2054)),o=n(6750),s=i(n(8831)),a=n(9196);e.DragTransformer=class{constructor(t,e){this.editor=t,this.selection=e}onDragStart(t){this.selection.setTransform(r.default.identity),this.dragStartPoint=t}onDragUpdate(t){const e=this.editor.viewport.roundPoint(t.minus(this.dragStartPoint));this.selection.setTransform(r.default.translation(e))}onDragEnd(){this.selection.finalizeTransform()}};e.ResizeTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.mode=a.ResizeMode.Both}onDragStart(t,e){this.selection.setTransform(r.default.identity),this.mode=e,this.dragStartPoint=t}onDragUpdate(t){const e=t.minus(this.dragStartPoint),n=this.selection.preTransformRegion.width,i=this.selection.preTransformRegion.height;let l=o.Vec2.of(1,1);if(this.mode===a.ResizeMode.HorizontalOnly){const t=n+e.x;l=o.Vec2.of(t/n,l.y)}if(this.mode===a.ResizeMode.VerticalOnly){const t=i+e.y;l=o.Vec2.of(l.x,t/i)}if(this.mode===a.ResizeMode.Both){const t=n+(Math.abs(e.x)>Math.abs(e.y)?e.x:e.y);l=o.Vec2.of(t/n,t/n)}if(l=l.map((t=>s.default.roundScaleRatio(t,2))),0!==l.x&&0!==l.y){const t=this.editor.viewport.roundPoint(this.selection.preTransformRegion.topLeft);this.selection.setTransform(r.default.scaling2D(l,t))}}onDragEnd(){this.selection.finalizeTransform()}};e.RotateTransformer=class{constructor(t,e){this.editor=t,this.selection=e,this.startAngle=0}getAngle(t){const e=this.selection.preTransformRegion.center;return t.minus(e).angle()}roundAngle(t){const e=8/Math.PI;return Math.round(t*e)/e}onDragStart(t){this.selection.setTransform(r.default.identity),this.startAngle=this.getAngle(t)}onDragUpdate(t){const e=this.roundAngle(this.getAngle(t)-this.startAngle),n=this.editor.viewport.roundPoint(this.selection.preTransformRegion.center),i=r.default.zRotation(e).mapEntries((t=>s.default.roundScaleRatio(t))),o=r.default.translation(n).rightMul(i).rightMul(r.default.translation(n.times(-1)));this.selection.setTransform(o)}onDragEnd(){this.selection.finalizeTransform()}}},9196:(t,e)=>{"use strict";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"}(e.ResizeMode||(e.ResizeMode={})),function(t){t[t.Snap=0]="Snap",t[t.NoSnap=1]="NoSnap"}(e.TransformMode||(e.TransformMode={}))},8838:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=i(n(9784)),s=i(n(2131));class a{constructor(){if(this.closed=!1,!window.AudioContext)return console.warn("Accessibility sound UI: Unable to open AudioContext."),void(this.closed=!0);this.ctx=new AudioContext,this.colorOscHue=this.ctx.createOscillator(),this.colorOscValue=this.ctx.createOscillator(),this.colorOscSaturation=this.ctx.createOscillator(),this.colorOscHue.type="triangle",this.colorOscSaturation.type="sine",this.colorOscValue.type="sawtooth",this.valueGain=this.ctx.createGain(),this.colorOscValue.connect(this.valueGain),this.valueGain.gain.setValueAtTime(.18,this.ctx.currentTime),this.colorGain=this.ctx.createGain(),this.colorOscHue.connect(this.colorGain),this.valueGain.connect(this.colorGain),this.colorOscSaturation.connect(this.colorGain),this.colorGain.connect(this.ctx.destination),this.boundaryGain=this.ctx.createGain(),this.boundaryOsc=this.ctx.createOscillator(),this.boundaryOsc.type="sawtooth",this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryOsc.connect(this.boundaryGain),this.boundaryGain.connect(this.ctx.destination),this.colorOscHue.start(),this.colorOscSaturation.start(),this.colorOscValue.start(),this.boundaryOsc.start(),this.pause()}pause(){this.closed||(this.colorGain.gain.setValueAtTime(0,this.ctx.currentTime),this.ctx.suspend())}play(){this.closed||this.ctx.resume()}setColor(t){const e=t.asHSV(),n=220*-Math.cos(e.x/2)+440,i=440*e.y+220,r=440*(e.z+.1),o=.25*Math.min(1,t.a)/(1+Math.exp(3*-(e.z-.5)));this.colorOscHue.frequency.setValueAtTime(n,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(i,this.ctx.currentTime),this.colorOscValue.frequency.setValueAtTime(r,this.ctx.currentTime),this.valueGain.gain.setValueAtTime(.4*(1-e.z),this.ctx.currentTime),this.colorGain.gain.setValueAtTime(o,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 l extends s.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.soundFeedback=null,this.toggleButtonContainer=document.createElement("div"),this.toggleButtonContainer.classList.add("js-draw-sound-ui-toggle"),this.toggleButton=document.createElement("button"),this.toggleButton.onclick=()=>{this.setEnabled(!this.isEnabled())},this.toggleButtonContainer.appendChild(this.toggleButton),this.updateToggleButtonText(),t.createHTMLOverlay(this.toggleButtonContainer)}updateToggleButtonText(){const t="sound-ui-tool-enabled";this.isEnabled()?(this.toggleButton.innerText=this.editor.localization.disableAccessibilityExploreTool,this.toggleButtonContainer.classList.add(t)):(this.toggleButton.innerText=this.editor.localization.enableAccessibilityExploreTool,this.toggleButtonContainer.classList.remove(t))}setEnabled(t){var e;super.setEnabled(t),t||(null===(e=this.soundFeedback)||void 0===e||e.close(),this.soundFeedback=null),this.updateToggleButtonText()}onPointerDown({current:t,allPointers:e}){var n,i,o;return this.soundFeedback||(this.soundFeedback=new a),!(e.length>=2)&&(null===(n=this.soundFeedback)||void 0===n||n.play(),null===(i=this.soundFeedback)||void 0===i||i.setColor(null!==(o=this.editor.display.getColorAt(t.screenPos))&&void 0!==o?o:r.default.black),this.lastPointerPos=t.canvasPos,!0)}onPointerMove({current:t}){var e,n,i;null===(e=this.soundFeedback)||void 0===e||e.setColor(null!==(n=this.editor.display.getColorAt(t.screenPos))&&void 0!==n?n:r.default.black);const s=new o.default(this.lastPointerPos,t.canvasPos),a=this.editor.image.getElementsIntersectingRegion(s.bbox).filter((t=>t.intersects(s)));this.lastPointerPos=t.canvasPos,a.length>0&&(null===(i=this.soundFeedback)||void 0===i||i.announceBoundaryCross(a.length))}onPointerUp(t){var e;null===(e=this.soundFeedback)||void 0===e||e.pause()}onGestureCancel(){var t;null===(t=this.soundFeedback)||void 0===t||t.pause()}}e.default=l},2100:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(8233)),o=i(n(6205)),s=i(n(4721)),a=i(n(5085)),l=i(n(2054)),c=n(6750),d=n(306),u=n(9699),h=i(n(2131)),p=i(n(529)),f=i(n(3966)),m="textEditorOverlay";class g extends h.default{constructor(t,e,n){super(t.notifier,e),this.editor=t,this.localizationTable=n,this.textInputElem=null,this.textTargetPosition=null,this.textMeasuringCtx=null,this.textScale=c.Vec2.of(1,1),this.removeExistingCommand=null,this.textStyle={size:32,fontFamily:"sans-serif",renderingStyle:{fill:r.default.purple}},this.textEditOverlay=document.createElement("div"),this.textEditOverlay.classList.add(m),this.editor.addStyleSheet(`\n\t\t\t.${m} {\n\t\t\t\theight: 0;\n\t\t\t\toverflow: visible;\n\t\t\t}\n\n\t\t\t.${m} textarea {\n\t\t\t\tbackground-color: rgba(0, 0, 0, 0);\n\n\t\t\t\twhite-space: pre;\n\t\t\t\toverflow: hidden;\n\n\t\t\t\tpadding: 0;\n\t\t\t\tmargin: 0;\n\t\t\t\tborder: none;\n\t\t\t\tpadding: 0;\n\n\t\t\t\tmin-width: 100px;\n\t\t\t\tmin-height: 1.1em;\n\t\t\t}\n\t\t`),this.editor.createHTMLOverlay(this.textEditOverlay),this.editor.notifier.on(u.EditorEventType.ViewportChanged,(()=>this.updateTextInput()))}getTextAscent(t,e){var n;return null!==(n=this.textMeasuringCtx)&&void 0!==n||(this.textMeasuringCtx=document.createElement("canvas").getContext("2d")),this.textMeasuringCtx?(o.default.applyTextStyles(this.textMeasuringCtx,e),this.textMeasuringCtx.measureText(t).actualBoundingBoxAscent):2*e.size/3}flushInput(t=!0){if(this.textInputElem&&this.textTargetPosition){const e=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",t){const t=this.textInputElem;this.textInputElem=null,t.remove()}if(""===e)return;const n=l.default.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(l.default.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(l.default.zRotation(this.textRotation)),i=o.default.fromLines(e.split("\n"),n,this.textStyle),r=s.default.addElement(i);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch((0,f.default)([this.removeExistingCommand,r])),this.removeExistingCommand=null):this.editor.dispatch(r)}}getTextScaleMatrix(){return l.default.scaling2D(this.textScale.times(1/this.editor.viewport.getSizeOfPixelOnCanvas()))}updateTextInput(){var t,e,n;if(!this.textInputElem||!this.textTargetPosition)return void(null===(t=this.textInputElem)||void 0===t||t.remove());const i=this.editor.viewport,r=i.canvasToScreen(this.textTargetPosition);this.textInputElem.placeholder=this.localizationTable.enterTextToInsert,this.textInputElem.style.fontFamily=this.textStyle.fontFamily,this.textInputElem.style.fontVariant=null!==(e=this.textStyle.fontVariant)&&void 0!==e?e:"",this.textInputElem.style.fontWeight=null!==(n=this.textStyle.fontWeight)&&void 0!==n?n:"",this.textInputElem.style.fontSize=`${this.textStyle.size}px`,this.textInputElem.style.color=this.textStyle.renderingStyle.fill.toHexString(),this.textInputElem.style.position="relative",this.textInputElem.style.left=`${r.x}px`,this.textInputElem.style.top=`${r.y}px`,this.textInputElem.style.margin="0",this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`;const o=this.getTextAscent("⎢",this.textStyle),s=this.textRotation+i.getRotationAngle(),a=this.getTextScaleMatrix();this.textInputElem.style.transform=`${a.toCSSMatrix()} rotate(${180*s/Math.PI}deg) translate(0, ${-o}px)`,this.textInputElem.style.transformOrigin="top left"}startTextInput(t,e){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=e,this.textInputElem.style.display="inline-block",this.textTargetPosition=this.editor.viewport.roundPoint(t),this.textRotation=-this.editor.viewport.getRotationAngle(),this.textScale=c.Vec2.of(1,1).times(this.editor.viewport.getSizeOfPixelOnCanvas()),this.updateTextInput(),setTimeout((()=>this.updateTextInput()),0),this.textInputElem.oninput=()=>{this.textInputElem&&(this.textInputElem.style.width=`${this.textInputElem.scrollWidth}px`,this.textInputElem.style.height=`${this.textInputElem.scrollHeight}px`)},this.textInputElem.onblur=()=>{const t=this.textInputElem;this.flushInput(!1),this.textInputElem=null,setTimeout((()=>{null==t||t.remove()}),0)},this.textInputElem.onkeyup=t=>{var e,n;"Enter"!==t.key||t.shiftKey?"Escape"===t.key&&(null===(e=this.textInputElem)||void 0===e||e.remove(),this.textInputElem=null,this.editor.focus(),null===(n=this.removeExistingCommand)||void 0===n||n.unapply(this.editor),this.removeExistingCommand=null):(this.flushInput(),this.editor.focus())},this.textEditOverlay.replaceChildren(this.textInputElem),setTimeout((()=>{var t;return null===(t=this.textInputElem)||void 0===t?void 0:t.focus()}),0)}setEnabled(t){super.setEnabled(t),t||this.flushInput(),this.textEditOverlay.style.display=t?"block":"none"}onPointerDown({current:t,allPointers:e}){if(t.device===d.PointerDevice.Eraser)return!1;if(1===e.length){const e=t.canvasPos,n=c.Vec2.of(2.5,2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas()),i=a.default.fromCorners(e.minus(n),e.plus(n));let r=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t instanceof o.default));const s=this.editor.viewport.visibleRect;if(r=r.filter((t=>!t.getBBox().containsRect(s))),this.flushInput(),r.length>0){const t=r[r.length-1];this.setTextStyle(t.getTextStyle()),this.removeExistingCommand=new p.default([t]),this.removeExistingCommand.apply(this.editor),this.startTextInput(t.getBaselinePos(),t.getText());const e=t.getTransform();this.textRotation=e.transformVec3(c.Vec2.unitX).angle();const n=e.transformVec3(c.Vec2.unitX).magnitude();this.textScale=c.Vec2.of(1,1).times(n),this.updateTextInput()}else this.removeExistingCommand=null,this.startTextInput(t.canvasPos,"");return!0}return!1}onGestureCancel(){this.flushInput(),this.editor.focus()}dispatchUpdateEvent(){this.updateTextInput(),this.editor.notifier.dispatch(u.EditorEventType.ToolUpdated,{kind:u.EditorEventType.ToolUpdated,tool:this})}setFontFamily(t){t!==this.textStyle.fontFamily&&(this.textStyle=Object.assign(Object.assign({},this.textStyle),{fontFamily:t}),this.dispatchUpdateEvent())}setColor(t){t.eq(this.textStyle.renderingStyle.fill)||(this.textStyle=Object.assign(Object.assign({},this.textStyle),{renderingStyle:Object.assign(Object.assign({},this.textStyle.renderingStyle),{fill:t})}),this.dispatchUpdateEvent())}setFontSize(t){t!==this.textStyle.size&&(this.textStyle=Object.assign(Object.assign({},this.textStyle),{size:t}),this.dispatchUpdateEvent())}getTextStyle(){return this.textStyle}setTextStyle(t){this.textStyle=Object.assign(Object.assign({},t),{renderingStyle:Object.assign({},t.renderingStyle)}),this.dispatchUpdateEvent()}}e.default=g},1769:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return r(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(9699),l=o(n(135)),c=s(n(7052)),d=s(n(2195)),u=s(n(9270)),h=s(n(1626)),p=s(n(8233)),f=s(n(991)),m=s(n(2100)),g=s(n(5529)),v=s(n(8840)),y=s(n(3947)),b=s(n(2375)),x=n(4856),w=s(n(3252)),T=s(n(6009)),S=s(n(8838));e.default=class{constructor(t,e){this.activeTool=null;const n=new d.default;this.primaryToolGroup=n;const i=new l.default(t,l.PanZoomMode.TwoFingerTouchGestures|l.PanZoomMode.RightClickDrags,e.touchPanTool),r=new l.default(t,l.PanZoomMode.Keyboard,e.keyboardPanZoom),o=new c.default(t,e.penTool(1),{color:p.default.purple,thickness:8}),s=[o,new c.default(t,e.penTool(2),{color:p.default.clay,thickness:4}),new c.default(t,e.penTool(3),{color:p.default.ofRGBA(1,1,0,.5),thickness:40},x.makePressureSensitiveFreehandLineBuilder),new u.default(t,e.eraserTool),new h.default(t,e.selectionTool),new m.default(t,e.textTool,e),new l.default(t,l.PanZoomMode.SinglePointerGestures,e.anyDevicePanning)],C=new S.default(t,e.soundExplorer);C.setEnabled(!1),this.tools=[new g.default(t,e.pipetteTool),C,i,...s,r,new f.default(t),new b.default(t),new v.default(t),new w.default(t),new y.default(t),new T.default(t)],s.forEach((t=>t.setToolGroup(n))),i.setEnabled(!0),o.setEnabled(!0),t.notifier.on(a.EditorEventType.ToolEnabled,(n=>{n.kind===a.EditorEventType.ToolEnabled&&t.announceForAccessibility(e.toolEnabledAnnouncement(n.tool.description))})),t.notifier.on(a.EditorEventType.ToolDisabled,(n=>{n.kind===a.EditorEventType.ToolDisabled&&t.announceForAccessibility(e.toolDisabledAnnouncement(n.tool.description))})),this.activeTool=null}setTools(t,e){this.tools=t,this.primaryToolGroup=null!=e?e:new d.default}addPrimaryTool(t){t.setToolGroup(this.primaryToolGroup),t.isEnabled()&&this.primaryToolGroup.notifyEnabled(t),this.addTool(t)}getPrimaryTools(){return this.tools.filter((t=>t.getToolGroup()===this.primaryToolGroup))}addTool(t){this.tools.push(t)}dispatchInputEvent(t){var e,n;let i=!1;if(t.kind===a.InputEvtType.PointerDownEvt){for(const n of this.tools)if(n.isEnabled()&&n.onPointerDown(t)){this.activeTool!==n&&(null===(e=this.activeTool)||void 0===e||e.onGestureCancel()),this.activeTool=n,i=!0;break}}else if(t.kind===a.InputEvtType.PointerUpEvt)null===(n=this.activeTool)||void 0===n||n.onPointerUp(t),this.activeTool=null,i=!0;else if(t.kind===a.InputEvtType.PointerMoveEvt)null!==this.activeTool&&(this.activeTool.onPointerMove(t),i=!0);else if(t.kind===a.InputEvtType.GestureCancelEvt)null!==this.activeTool&&(this.activeTool.onGestureCancel(),this.activeTool=null);else{let e;for(const n of this.tools)if(n.isEnabled()){switch(t.kind){case a.InputEvtType.KeyPressEvent:i=n.onKeyPress(t);break;case a.InputEvtType.KeyUpEvent:i=n.onKeyUp(t);break;case a.InputEvtType.WheelEvt:i=n.onWheel(t);break;case a.InputEvtType.CopyEvent:i=n.onCopy(t);break;case a.InputEvtType.PasteEvent:i=n.onPaste(t);break;default:return e=t,e}if(i)break}}return i}getMatchingTools(t){return this.tools.filter((e=>e instanceof t))}}},2195:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){}notifyEnabled(t){var e;t!==this.activeTool&&(null===(e=this.activeTool)||void 0===e||e.setEnabled(!1),this.activeTool=t)}}},8840:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.default{constructor(t){super(t.notifier,t.localization.changeTool),this.editor=t}onKeyPress({key:t}){const e=this.editor.toolController.getPrimaryTools(),n=/^[0-9]$/.exec(t);let i;if(n){i=e[parseInt(n[0],10)-1]}return!!i&&(i.setEnabled(!0),!0)}}e.default=o},2375:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.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){for(const e of this.listeners)if(e(t))return!0;return!1}}e.default=o},991:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(n(2131));class o extends r.default{constructor(t){super(t.notifier,t.localization.undoRedoTool),this.editor=t}onKeyPress({key:t,ctrlKey:e}){if(e){if("z"===t)return this.editor.history.undo(),!0;if("Z"===t)return this.editor.history.redo(),!0}return!1}}e.default=o},1637:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ToolbarShortcutHandler=e.SoundUITool=e.PasteHandler=e.EraserTool=e.SelectAllShortcutHandler=e.SelectionTool=e.TextTool=e.PenTool=e.PanZoomMode=e.PanZoomTool=e.ToolSwitcherShortcut=e.UndoRedoShortcut=e.ToolEnabledGroup=e.ToolController=e.BaseTool=void 0;var r=n(2131);Object.defineProperty(e,"BaseTool",{enumerable:!0,get:function(){return i(r).default}});var o=n(1769);Object.defineProperty(e,"ToolController",{enumerable:!0,get:function(){return i(o).default}});var s=n(2195);Object.defineProperty(e,"ToolEnabledGroup",{enumerable:!0,get:function(){return i(s).default}});var a=n(991);Object.defineProperty(e,"UndoRedoShortcut",{enumerable:!0,get:function(){return i(a).default}});var l=n(8840);Object.defineProperty(e,"ToolSwitcherShortcut",{enumerable:!0,get:function(){return i(l).default}});var c=n(135);Object.defineProperty(e,"PanZoomTool",{enumerable:!0,get:function(){return i(c).default}}),Object.defineProperty(e,"PanZoomMode",{enumerable:!0,get:function(){return c.PanZoomMode}});var d=n(7052);Object.defineProperty(e,"PenTool",{enumerable:!0,get:function(){return i(d).default}});var u=n(2100);Object.defineProperty(e,"TextTool",{enumerable:!0,get:function(){return i(u).default}});var h=n(1626);Object.defineProperty(e,"SelectionTool",{enumerable:!0,get:function(){return i(h).default}});var p=n(6009);Object.defineProperty(e,"SelectAllShortcutHandler",{enumerable:!0,get:function(){return i(p).default}});var f=n(9270);Object.defineProperty(e,"EraserTool",{enumerable:!0,get:function(){return i(f).default}});var m=n(3947);Object.defineProperty(e,"PasteHandler",{enumerable:!0,get:function(){return i(m).default}});var g=n(8838);Object.defineProperty(e,"SoundUITool",{enumerable:!0,get:function(){return i(g).default}});var v=n(2375);Object.defineProperty(e,"ToolbarShortcutHandler",{enumerable:!0,get:function(){return i(v).default}})},318:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolLocalization=void 0,e.defaultToolLocalization={penTool:t=>`Pen ${t}`,selectionTool:"Selection",selectAllTool:"Select all shortcut",eraserTool:"Eraser",touchPanTool:"Touch panning",twoFingerPanZoomTool:"Panning and zooming",undoRedoTool:"Undo/Redo",rightClickDragPanTool:"Right-click drag",pipetteTool:"Pick color from screen",keyboardPanZoom:"Keyboard pan/zoom shortcuts",textTool:"Text",enterTextToInsert:"Text to insert",changeTool:"Change tool",pasteHandler:"Copy paste handler",soundExplorer:"Sound-based image exploration",disableAccessibilityExploreTool:"Disable sound-based exploration",enableAccessibilityExploreTool:"Enable sound-based exploration",findLabel:"Find",toNextMatch:"Next",closeFindDialog:"Close",findDialogShown:"Find dialog shown",findDialogHidden:"Find dialog hidden",focusedFoundText:(t,e)=>`Viewing match ${t} of ${e}`,anyDevicePanning:"Any device panning",copied:(t,e)=>`Copied ${t} ${e}`,pasted:(t,e)=>`Pasted ${t} ${e}`,toolEnabledAnnouncement:t=>`${t} enabled`,toolDisabledAnnouncement:t=>`${t} disabled`}},9699:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UndoEventType=e.EditorEventType=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"}(e.InputEvtType||(e.InputEvtType={})),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.ColorPickerToggled=9]="ColorPickerToggled",t[t.ColorPickerColorSelected=10]="ColorPickerColorSelected",t[t.ToolbarDropdownShown=11]="ToolbarDropdownShown"}(e.EditorEventType||(e.EditorEventType={})),function(t){t[t.CommandDone=0]="CommandDone",t[t.CommandUndone=1]="CommandUndone",t[t.CommandRedone=2]="CommandRedone"}(e.UndoEventType||(e.UndoEventType={}))},246:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertIsNumberArray=e.assertIsNumber=e.assertUnreachable=void 0;e.assertUnreachable=t=>{throw new Error(`Should be unreachable. Key: ${t}.`)};e.assertIsNumber=(t,e=!1)=>{if("number"!=typeof t||!e&&isNaN(t))throw new Error("Given value is not a number");return!0};e.assertIsNumberArray=(t,n=!1)=>{if("object"!=typeof t)throw new Error("Asserting isNumberArray: Given entity is not an array");if(!(0,e.assertIsNumber)(t.length))return!1;for(const i of t)if(!(0,e.assertIsNumber)(i,n))return!1;return!0}},9161:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=new FileReader;return new Promise(((i,r)=>{n.onload=()=>i(n.result),n.onerror=r,n.onabort=r,n.onprogress=t=>{null==e||e(t)},n.readAsDataURL(t)}))}},2822:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=()=>new Promise((t=>{requestAnimationFrame((()=>t()))}))},3732:(t,e,n)=>{"use strict";n.r(e);var i=n(3379),r=n.n(i),o=n(7795),s=n.n(o),a=n(569),l=n.n(a),c=n(3565),d=n.n(c),u=n(9216),h=n.n(u),p=n(4589),f=n.n(p),m=n(4059),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=h();r()(m.Z,g);m.Z&&m.Z.locals&&m.Z.locals;var v=n(7786),y={};y.styleTagTransform=f(),y.setAttributes=d(),y.insert=l().bind(null,"head"),y.domAPI=s(),y.insertStyleElement=h();r()(v.Z,y);v.Z&&v.Z.locals&&v.Z.locals},7629:(t,e)=>{var n,i,r;"undefined"!=typeof self&&self,i=[],void 0===(r="function"==typeof(n=function(){
|
2
2
|
/*!
|
3
3
|
* Copyright (c) 2021-2023 Momo Bassit.
|
4
4
|
* Licensed under the MIT License (MIT)
|
5
5
|
* https://github.com/mdbassit/Coloris
|
6
|
-
* Version: 0.
|
6
|
+
* Version: 0.19.0
|
7
7
|
* NPM: https://github.com/melloware/coloris-npm
|
8
8
|
*/
|
9
|
-
return function(t,e,n){var i,r,o,s,a,l,c,d,u,h,p,f,m,g,v,y,b=e.createElement("canvas").getContext("2d"),x={r:0,g:0,b:0,h:0,s:0,v:0,a:1},w={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:function(){},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."}},T={},S="",C={},P=!1;function k(n){if("object"==typeof n){var s=function(){switch(a){case"el":B(n.el),!1!==n.wrap&&I(n.el);break;case"parent":(i=e.querySelector(n.parent))&&(i.appendChild(r),w.parent=n.parent,i===e.body&&(i=null));break;case"themeMode":w.themeMode=n.themeMode,"auto"===n.themeMode&&t.matchMedia&&t.matchMedia("(prefers-color-scheme: dark)").matches&&(w.themeMode="dark");case"theme":n.theme&&(w.theme=n.theme),r.className="clr-picker clr-"+w.theme+" clr-"+w.themeMode,w.inline&&O();break;case"rtl":w.rtl=!!n.rtl,e.querySelectorAll(".clr-field").forEach((function(t){return t.classList.toggle("clr-rtl",w.rtl)}));break;case"margin":n.margin*=1,w.margin=isNaN(n.margin)?w.margin:n.margin;break;case"wrap":n.el&&n.wrap&&I(n.el);break;case"formatToggle":w.formatToggle=!!n.formatToggle,et("clr-format").style.display=w.formatToggle?"block":"none",w.formatToggle&&(w.format="auto");break;case"swatches":if(Array.isArray(n.swatches)){var s=[];n.swatches.forEach((function(t,e){s.push('<button type="button" id="clr-swatch-'+e+'" aria-labelledby="clr-swatch-label clr-swatch-'+e+'" style="color: '+t+';">'+t+"</button>")})),et("clr-swatches").innerHTML=s.length?"<div>"+s.join("")+"</div>":"",w.swatches=n.swatches.slice()}break;case"swatchesOnly":w.swatchesOnly=!!n.swatchesOnly,r.setAttribute("data-minimal",w.swatchesOnly);break;case"alpha":w.alpha=!!n.alpha,r.setAttribute("data-alpha",w.alpha);break;case"inline":if(w.inline=!!n.inline,r.setAttribute("data-inline",w.inline),w.inline){var p=n.defaultColor||w.defaultColor;v=D(p),O(),L(p)}break;case"clearButton":"object"==typeof n.clearButton&&(n.clearButton.label&&(w.clearLabel=n.clearButton.label,d.innerHTML=w.clearLabel),n.clearButton=n.clearButton.show),w.clearButton=!!n.clearButton,d.style.display=w.clearButton?"block":"none";break;case"clearLabel":w.clearLabel=n.clearLabel,d.innerHTML=w.clearLabel;break;case"closeButton":w.closeButton=!!n.closeButton,w.closeButton?r.insertBefore(u,l):l.appendChild(u);break;case"closeLabel":w.closeLabel=n.closeLabel,u.innerHTML=w.closeLabel;break;case"a11y":var m=n.a11y,g=!1;if("object"==typeof m)for(var y in m)m[y]&&w.a11y[y]&&(w.a11y[y]=m[y],g=!0);if(g){var b=et("clr-open-label"),x=et("clr-swatch-label");b.innerHTML=w.a11y.open,x.innerHTML=w.a11y.swatch,u.setAttribute("aria-label",w.a11y.close),d.setAttribute("aria-label",w.a11y.clear),h.setAttribute("aria-label",w.a11y.hueSlider),f.setAttribute("aria-label",w.a11y.alphaSlider),c.setAttribute("aria-label",w.a11y.input),o.setAttribute("aria-label",w.a11y.instruction)}break;default:w[a]=n[a]}};for(var a in n)s()}}function E(t,e){"string"==typeof t&&"object"==typeof e&&(T[t]=e,P=!0)}function z(t){delete T[t],0===Object.keys(T).length&&(P=!1,t===S&&M())}function _(t){if(P){var e=["el","wrap","rtl","inline","defaultColor","a11y"],n=function(){var n=T[i];if(t.matches(i)){for(var r in S=i,C={},e.forEach((function(t){return delete n[t]})),n)C[r]=Array.isArray(w[r])?w[r].slice():w[r];return k(n),"break"}};for(var i in T)if("break"===n())break}}function M(){Object.keys(C).length>0&&(k(C),S="",C={})}function B(t){nt(e,"click",t,(function(t){w.inline||(_(t.target),g=t.target,y=g.value,v=D(y),r.classList.add("clr-open"),O(),L(y),(w.focusInput||w.selectInput)&&c.focus({preventScroll:!0}),w.selectInput&&c.select(),g.dispatchEvent(new Event("open",{bubbles:!0})))})),nt(e,"input",t,(function(t){var e=t.target.parentNode;e.classList.contains("clr-field")&&(e.style.color=t.target.value)}))}function O(){var n,a,l,c=i,d=t.scrollY,u=r.offsetWidth,h=r.offsetHeight,p={left:!1,top:!1},f={x:0,y:0};if(c&&(n=t.getComputedStyle(c),a=parseFloat(n.marginTop),l=parseFloat(n.borderTopWidth),(f=c.getBoundingClientRect()).y+=l+d),!w.inline){var m=g.getBoundingClientRect(),v=m.x,y=d+m.y+m.height+w.margin;c?(v-=f.x,y-=f.y,v+u>c.clientWidth&&(v+=m.width-u,p.left=!0),y+h>c.clientHeight-a&&h+w.margin<=m.top-(f.y-d)&&(y-=m.height+h+2*w.margin,p.top=!0),y+=c.scrollTop):(v+u>e.documentElement.clientWidth&&(v+=m.width-u,p.left=!0),y+h-d>e.documentElement.clientHeight&&h+w.margin<=m.top&&(y=d+m.y-h-w.margin,p.top=!0)),r.classList.toggle("clr-left",p.left),r.classList.toggle("clr-top",p.top),r.style.left=v+"px",r.style.top=y+"px",f.x+=r.offsetLeft,f.y+=r.offsetTop}s={width:o.offsetWidth,height:o.offsetHeight,x:o.offsetLeft+f.x,y:o.offsetTop+f.y}}function I(t){e.querySelectorAll(t).forEach((function(t){var n=t.parentNode;if(!n.classList.contains("clr-field")){var i=e.createElement("div"),r="clr-field";(w.rtl||t.classList.contains("clr-rtl"))&&(r+=" clr-rtl"),i.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',n.insertBefore(i,t),i.setAttribute("class",r),i.style.color=t.value,i.appendChild(t)}}))}function R(t){if(g&&!w.inline){var e=g;t&&(g=null,y!==e.value&&(e.value=y,e.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout((function(){y!==e.value&&e.dispatchEvent(new Event("change",{bubbles:!0}))})),r.classList.remove("clr-open"),P&&M(),e.dispatchEvent(new Event("close",{bubbles:!0})),w.focusInput&&e.focus({preventScroll:!0}),g=null}}function L(t){var e=J(t),n=K(e);F(n.s,n.v),W(e,n),h.value=n.h,r.style.color="hsl("+n.h+", 100%, 50%)",p.style.left=n.h/360*100+"%",a.style.left=s.width*n.s/100+"px",a.style.top=s.height-s.height*n.v/100+"px",f.value=100*n.a,m.style.left=100*n.a+"%"}function D(t){var e=t.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function A(n){n=void 0!==n?n:c.value,g&&(g.value=n,g.dispatchEvent(new Event("input",{bubbles:!0}))),w.onChange&&w.onChange.call(t,n),e.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:n}}))}function j(t,e){var n={h:1*h.value,s:t/s.width*100,v:100-e/s.height*100,a:f.value/100},i=Z(n);F(n.s,n.v),W(i,n),A()}function F(t,e){var n=w.a11y.marker;t=1*t.toFixed(1),e=1*e.toFixed(1),n=(n=n.replace("{s}",t)).replace("{v}",e),a.setAttribute("aria-label",n)}function V(t){return{pageX:t.changedTouches?t.changedTouches[0].pageX:t.pageX,pageY:t.changedTouches?t.changedTouches[0].pageY:t.pageY}}function N(t){var e=V(t),n=e.pageX-s.x,r=e.pageY-s.y;i&&(r+=i.scrollTop),U(n,r),t.preventDefault(),t.stopPropagation()}function $(t,e){U(1*a.style.left.replace("px","")+t,1*a.style.top.replace("px","")+e)}function U(t,e){t=t<0?0:t>s.width?s.width:t,e=e<0?0:e>s.height?s.height:e,a.style.left=t+"px",a.style.top=e+"px",j(t,e),a.focus()}function W(t,n){void 0===t&&(t={}),void 0===n&&(n={});var i=w.format;for(var r in t)x[r]=t[r];for(var s in n)x[s]=n[s];var d=Q(x),u=d.substring(0,7);switch(a.style.color=u,m.parentNode.style.color=u,m.style.color=d,l.style.color=d,o.style.display="none",o.offsetHeight,o.style.display="",m.nextElementSibling.style.display="none",m.nextElementSibling.offsetHeight,m.nextElementSibling.style.display="","mixed"===i?i=1===x.a?"hex":"rgb":"auto"===i&&(i=v),i){case"hex":c.value=d;break;case"rgb":c.value=X(x);break;case"hsl":c.value=Y(q(x))}e.querySelector('.clr-format [value="'+i+'"]').checked=!0}function H(){var t=1*h.value,e=1*a.style.left.replace("px",""),n=1*a.style.top.replace("px","");r.style.color="hsl("+t+", 100%, 50%)",p.style.left=t/360*100+"%",j(e,n)}function G(){var t=f.value/100;m.style.left=100*t+"%",W({a:t}),A()}function Z(t){var e=t.s/100,i=t.v/100,r=e*i,o=t.h/60,s=r*(1-n.abs(o%2-1)),a=i-r;r+=a,s+=a;var l=n.floor(o)%6,c=[r,s,a,a,s,r][l],d=[s,r,r,s,a,a][l],u=[a,a,s,r,r,s][l];return{r:n.round(255*c),g:n.round(255*d),b:n.round(255*u),a:t.a}}function q(t){var e,i=t.v/100,r=i*(1-t.s/100/2);return r>0&&r<1&&(e=n.round((i-r)/n.min(r,1-r)*100)),{h:t.h,s:e||0,l:n.round(100*r),a:t.a}}function K(t){var e=t.r/255,i=t.g/255,r=t.b/255,o=n.max(e,i,r),s=o-n.min(e,i,r),a=o,l=0,c=0;return s&&(o===e&&(l=(i-r)/s),o===i&&(l=2+(r-e)/s),o===r&&(l=4+(e-i)/s),o&&(c=s/o)),{h:(l=n.floor(60*l))<0?l+360:l,s:n.round(100*c),v:n.round(100*a),a:t.a}}function J(t){var e,n,i=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;return b.fillStyle="#000",b.fillStyle=t,(e=i.exec(b.fillStyle))?(n={r:1*e[3],g:1*e[4],b:1*e[5],a:1*e[6]}).a=+n.a.toFixed(2):n={r:(e=b.fillStyle.replace("#","").match(/.{2}/g).map((function(t){return parseInt(t,16)})))[0],g:e[1],b:e[2],a:1},n}function Q(t){var e=t.r.toString(16),n=t.g.toString(16),i=t.b.toString(16),r="";if(t.r<16&&(e="0"+e),t.g<16&&(n="0"+n),t.b<16&&(i="0"+i),w.alpha&&(t.a<1||w.forceAlpha)){var o=255*t.a|0;r=o.toString(16),o<16&&(r="0"+r)}return"#"+e+n+i+r}function X(t){return!w.alpha||1===t.a&&!w.forceAlpha?"rgb("+t.r+", "+t.g+", "+t.b+")":"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"}function Y(t){return!w.alpha||1===t.a&&!w.forceAlpha?"hsl("+t.h+", "+t.s+"%, "+t.l+"%)":"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"}function tt(){e.getElementById("clr-picker")||(i=null,(r=e.createElement("div")).setAttribute("id","clr-picker"),r.className="clr-picker",r.innerHTML='<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+w.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+w.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="'+w.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="'+w.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+w.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="'+w.a11y.clear+'">'+w.clearLabel+'</button><div id="clr-color-preview" class="clr-preview"><button type="button" id="clr-close" class="clr-close" aria-label="'+w.a11y.close+'">'+w.closeLabel+'</button></div><span id="clr-open-label" hidden>'+w.a11y.open+'</span><span id="clr-swatch-label" hidden>'+w.a11y.swatch+"</span>",e.body.appendChild(r),o=et("clr-color-area"),a=et("clr-color-marker"),d=et("clr-clear"),u=et("clr-close"),l=et("clr-color-preview"),c=et("clr-color-value"),h=et("clr-hue-slider"),p=et("clr-hue-marker"),f=et("clr-alpha-slider"),m=et("clr-alpha-marker"),B(w.el),I(w.el),nt(r,"mousedown",(function(t){r.classList.remove("clr-keyboard-nav"),t.stopPropagation()})),nt(o,"mousedown",(function(t){nt(e,"mousemove",N)})),nt(o,"touchstart",(function(t){e.addEventListener("touchmove",N,{passive:!1})})),nt(a,"mousedown",(function(t){nt(e,"mousemove",N)})),nt(a,"touchstart",(function(t){e.addEventListener("touchmove",N,{passive:!1})})),nt(c,"change",(function(t){(g||w.inline)&&(L(c.value),A())})),nt(d,"click",(function(t){A(""),R()})),nt(u,"click",(function(t){A(),R()})),nt(e,"click",".clr-format input",(function(t){v=t.target.value,W(),A()})),nt(r,"click",".clr-swatches button",(function(t){L(t.target.textContent),A(),w.swatchesOnly&&R()})),nt(e,"mouseup",(function(t){e.removeEventListener("mousemove",N)})),nt(e,"touchend",(function(t){e.removeEventListener("touchmove",N)})),nt(e,"mousedown",(function(t){r.classList.remove("clr-keyboard-nav"),R()})),nt(e,"keydown",(function(t){var e=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];"Escape"===t.key?R(!0):e.includes(t.key)&&r.classList.add("clr-keyboard-nav")})),nt(e,"click",".clr-field button",(function(t){P&&M(),t.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))})),nt(a,"keydown",(function(t){var e={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(e).includes(t.key)&&($.apply(void 0,e[t.key]),t.preventDefault())})),nt(o,"click",N),nt(h,"input",H),nt(f,"input",G))}function et(t){return e.getElementById(t)}function nt(t,e,n,i){var r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof n?t.addEventListener(e,(function(t){r.call(t.target,n)&&i.call(t.target,t)})):(i=n,t.addEventListener(e,i))}function it(t,n){n=void 0!==n?n:[],"loading"!==e.readyState?t.apply(void 0,n):e.addEventListener("DOMContentLoaded",(function(){t.apply(void 0,n)}))}void 0!==NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var rt=function(){var t={init:tt,set:k,wrap:I,close:R,setInstance:E,removeInstance:z,updatePosition:O};function e(t){it((function(){t&&("string"==typeof t?B(t):k(t))}))}var n=function(n){e[n]=function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];it(t[n],i)}};for(var i in t)n(i);return e}();return rt.coloris=rt,rt}(window,document,Math)})?n.apply(e,i):n)||(t.exports=r)},8405:e=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=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 r(e))o.call(t,l)||!s&&"default"===l||n(t,l,{get:()=>e[l],enumerable:!(a=i(e,l))||a.enumerable});return t})(n({},"__esModule",{value:!0}),e,1),t&&t.set(e,s),s))("undefined"!=typeof WeakMap?new WeakMap:0),a={};((t,e)=>{for(var i in e)n(t,i,{get:e[i],enumerable:!0})})(a,{Bezier:()=>O});var{abs:l,cos:c,sin:d,acos:u,atan2:h,sqrt:p,pow:f}=Math;function m(t){return t<0?-f(-t,1/3):f(t,1/3)}var g=Math.PI,v=2*g,y=g/2,b=Number.MAX_SAFE_INTEGER||9007199254740991,x=Number.MIN_SAFE_INTEGER||-9007199254740991,w={x:0,y:0,z:0},T={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const n=e(t);let i=n.x*n.x+n.y*n.y;return void 0!==n.z&&(i+=n.z*n.z),p(i)},compute:function(t,e,n){if(0===t)return e[0].t=0,e[0];const i=e.length-1;if(1===t)return e[i].t=1,e[i];const r=1-t;let o=e;if(0===i)return e[0].t=t,e[0];if(1===i){const e={x:r*o[0].x+t*o[1].x,y:r*o[0].y+t*o[1].y,t};return n&&(e.z=r*o[0].z+t*o[1].z),e}if(i<4){let e,s,a,l=r*r,c=t*t,d=0;2===i?(o=[o[0],o[1],o[2],w],e=l,s=r*t*2,a=c):3===i&&(e=l*r,s=l*t*3,a=r*c*3,d=t*c);const u={x:e*o[0].x+s*o[1].x+a*o[2].x+d*o[3].x,y:e*o[0].y+s*o[1].y+a*o[2].y+d*o[3].y,t};return n&&(u.z=e*o[0].z+s*o[1].z+a*o[2].z+d*o[3].z),u}const s=JSON.parse(JSON.stringify(e));for(;s.length>1;){for(let e=0;e<s.length-1;e++)s[e]={x:s[e].x+(s[e+1].x-s[e].x)*t,y:s[e].y+(s[e+1].y-s[e].y)*t},void 0!==s[e].z&&(s[e]=s[e].z+(s[e+1].z-s[e].z)*t);s.splice(s.length-1,1)}return s[0].t=t,s[0]},computeWithRatios:function(t,e,n,i){const r=1-t,o=n,s=e;let a,l=o[0],c=o[1],d=o[2],u=o[3];return l*=r,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:!!i&&(l*s[0].z+c*s[1].z)/a,t}):(l*=r,c*=2*r,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:!!i&&(l*s[0].z+c*s[1].z+d*s[2].z)/a,t}):(l*=r,c*=1.5*r,d*=3*r,u*=t*t*t,4===s.length?(a=l+c+d+u,{x:(l*s[0].x+c*s[1].x+d*s[2].x+u*s[3].x)/a,y:(l*s[0].y+c*s[1].y+d*s[2].y+u*s[3].y)/a,z:!!i&&(l*s[0].z+c*s[1].z+d*s[2].z+u*s[3].z)/a,t}):void 0))},derive:function(t,e){const n=[];for(let i=t,r=i.length,o=r-1;r>1;r--,o--){const t=[];for(let n,r=0;r<o;r++)n={x:o*(i[r+1].x-i[r].x),y:o*(i[r+1].y-i[r].y)},e&&(n.z=o*(i[r+1].z-i[r].z)),t.push(n);n.push(t),i=t}return n},between:function(t,e,n){return e<=t&&t<=n||T.approximately(t,e)||T.approximately(t,n)},approximately:function(t,e,n){return l(t-e)<=(n||1e-6)},length:function(t){const e=T.Tvalues.length;let n=0;for(let i,r=0;r<e;r++)i=.5*T.Tvalues[r]+.5,n+=T.Cvalues[r]*T.arcfn(i,t);return.5*n},map:function(t,e,n,i,r){return i+(r-i)*((t-e)/(n-e))},lerp:function(t,e,n){const i={x:e.x+t*(n.x-e.x),y:e.y+t*(n.y-e.y)};return void 0!==e.z&&void 0!==n.z&&(i.z=e.z+t*(n.z-e.z)),i},pointToString:function(t){let e=t.x+"/"+t.y;return void 0!==t.z&&(e+="/"+t.z),e},pointsToString:function(t){return"["+t.map(T.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,n){const i=e.x-t.x,r=e.y-t.y,o=n.x-t.x,s=n.y-t.y;return h(i*s-r*o,i*o+r*s)},round:function(t,e){const n=""+t,i=n.indexOf(".");return parseFloat(n.substring(0,i+1+e))},dist:function(t,e){const n=t.x-e.x,i=t.y-e.y;return p(n*n+i*i)},closest:function(t,e){let n,i,r=f(2,63);return t.forEach((function(t,o){i=T.dist(e,t),i<r&&(r=i,n=o)})),{mdist:r,mpos:n}},abcratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(t,e)+f(1-t,e);return l((n-1)/n)},projectionratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(1-t,e);return n/(f(t,e)+n)},lli8:function(t,e,n,i,r,o,s,a){const l=(t-n)*(o-a)-(e-i)*(r-s);return 0!=l&&{x:((t*i-e*n)*(r-s)-(t-n)*(r*a-o*s))/l,y:((t*i-e*n)*(o-a)-(e-i)*(r*a-o*s))/l}},lli4:function(t,e,n,i){const r=t.x,o=t.y,s=e.x,a=e.y,l=n.x,c=n.y,d=i.x,u=i.y;return T.lli8(r,o,s,a,l,c,d,u)},lli:function(t,e){return T.lli4(t,t.c,e,e.c)},makeline:function(t,e){return new O(t.x,t.y,(t.x+e.x)/2,(t.y+e.y)/2,e.x,e.y)},findbbox:function(t){let e=b,n=b,i=x,r=x;return t.forEach((function(t){const o=t.bbox();e>o.x.min&&(e=o.x.min),n>o.y.min&&(n=o.y.min),i<o.x.max&&(i=o.x.max),r<o.y.max&&(r=o.y.max)})),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:n,mid:(n+r)/2,max:r,size:r-n}}},shapeintersections:function(t,e,n,i,r){if(!T.bboxoverlap(e,i))return[];const o=[],s=[t.startcap,t.forward,t.back,t.endcap],a=[n.startcap,n.forward,n.back,n.endcap];return s.forEach((function(e){e.virtual||a.forEach((function(i){if(i.virtual)return;const s=e.intersects(i,r);s.length>0&&(s.c1=e,s.c2=i,s.s1=t,s.s2=n,o.push(s))}))})),o},makeshape:function(t,e,n){const i=e.points.length,r=t.points.length,o=T.makeline(e.points[i-1],t.points[0]),s=T.makeline(t.points[r-1],e.points[0]),a={startcap:o,forward:t,back:e,endcap:s,bbox:T.findbbox([o,t,e,s]),intersections:function(t){return T.shapeintersections(a,a.bbox,t,t.bbox,n)}};return a},getminmax:function(t,e,n){if(!n)return{min:0,max:0};let i,r,o=b,s=x;-1===n.indexOf(0)&&(n=[0].concat(n)),-1===n.indexOf(1)&&n.push(1);for(let a=0,l=n.length;a<l;a++)i=n[a],r=t.get(i),r[e]<o&&(o=r[e]),r[e]>s&&(s=r[e]);return{min:o,mid:(o+s)/2,max:s,size:s-o}},align:function(t,e){const n=e.p1.x,i=e.p1.y,r=-h(e.p2.y-i,e.p2.x-n);return t.map((function(t){return{x:(t.x-n)*c(r)-(t.y-i)*d(r),y:(t.x-n)*d(r)+(t.y-i)*c(r)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=t.length-1,i=T.align(t,e),r=function(t){return 0<=t&&t<=1};if(2===n){const t=i[0].y,e=i[1].y,n=i[2].y,o=t-2*e+n;if(0!==o){const i=-p(e*e-t*n),s=-t+e;return[-(i+s)/o,-(-i+s)/o].filter(r)}return e!==n&&0===o?[(2*e-n)/(2*e-2*n)].filter(r):[]}const o=i[0].y,s=i[1].y,a=i[2].y;let l=3*s-o-3*a+i[3].y,d=3*o-6*s+3*a,h=-3*o+3*s,f=o;if(T.approximately(l,0)){if(T.approximately(d,0))return T.approximately(h,0)?[]:[-f/h].filter(r);const t=p(h*h-4*d*f),e=2*d;return[(t-h)/e,(-h-t)/e].filter(r)}d/=l,h/=l,f/=l;const g=(3*h-d*d)/3,y=g/3,b=(2*d*d*d-9*d*h+27*f)/27,x=b/2,w=x*x+y*y*y;let S,C,P,k,E;if(w<0){const t=-g/3,e=p(t*t*t),n=-b/(2*e),i=u(n<-1?-1:n>1?1:n),o=2*m(e);return P=o*c(i/3)-d/3,k=o*c((i+v)/3)-d/3,E=o*c((i+2*v)/3)-d/3,[P,k,E].filter(r)}if(0===w)return S=x<0?m(-x):-m(x),P=2*S-d/3,k=-S-d/3,[P,k].filter(r);{const t=p(w);return S=m(-x+t),C=m(x+t),[S-C-d/3].filter(r)}},droots:function(t){if(3===t.length){const e=t[0],n=t[1],i=t[2],r=e-2*n+i;if(0!==r){const t=-p(n*n-e*i),o=-e+n;return[-(t+o)/r,-(-t+o)/r]}return n!==i&&0===r?[(2*n-i)/(2*(n-i))]:[]}if(2===t.length){const e=t[0],n=t[1];return e!==n?[e/(e-n)]:[]}return[]},curvature:function(t,e,n,i,r){let o,s,a,c,d=0,u=0;const h=T.compute(t,e),m=T.compute(t,n),g=h.x*h.x+h.y*h.y;if(i?(o=p(f(h.y*m.z-m.y*h.z,2)+f(h.z*m.x-m.z*h.x,2)+f(h.x*m.y-m.x*h.y,2)),s=f(g+h.z*h.z,1.5)):(o=h.x*m.y-h.y*m.x,s=f(g,1.5)),0===o||0===s)return{k:0,r:0};if(d=o/s,u=s/o,!r){const r=T.curvature(t-.001,e,n,i,!0).k,o=T.curvature(t+.001,e,n,i,!0).k;c=(o-d+(d-r))/2,a=(l(o-d)+l(d-r))/2}return{k:d,r:u,dk:c,adk:a}},inflections:function(t){if(t.length<4)return[];const e=T.align(t,{p1:t[0],p2:t.slice(-1)[0]}),n=e[2].x*e[1].y,i=e[3].x*e[1].y,r=e[1].x*e[2].y,o=18*(-3*n+2*i+3*r-e[3].x*e[2].y),s=18*(3*n-i-3*r),a=18*(r-n);if(T.approximately(o,0)){if(!T.approximately(s,0)){let t=-a/s;if(0<=t&&t<=1)return[t]}return[]}const l=2*o;if(T.approximately(l,0))return[];const c=s*s-4*o*a;if(c<0)return[];const d=Math.sqrt(c);return[(d-s)/l,-(s+d)/l].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const n=["x","y"],i=n.length;for(let r,o,s,a,c=0;c<i;c++)if(r=n[c],o=t[r].mid,s=e[r].mid,a=(t[r].size+e[r].size)/2,l(o-s)>=a)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,n){const i=t.bbox(),r=e.bbox(),o=1e5,s=n||.5;if(i.x.size+i.y.size<s&&r.x.size+r.y.size<s)return[(o*(t._t1+t._t2)/2|0)/o+"/"+(o*(e._t1+e._t2)/2|0)/o];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 T.bboxoverlap(t.left.bbox(),t.right.bbox())}));let d=[];return 0===c.length||(c.forEach((function(t){d=d.concat(T.pairiteration(t.left,t.right,s))})),d=d.filter((function(t,e){return d.indexOf(t)===e}))),d},getccenter:function(t,e,n){const i=e.x-t.x,r=e.y-t.y,o=n.x-e.x,s=n.y-e.y,a=i*c(y)-r*d(y),l=i*d(y)+r*c(y),u=o*c(y)-s*d(y),p=o*d(y)+s*c(y),f=(t.x+e.x)/2,m=(t.y+e.y)/2,g=(e.x+n.x)/2,b=(e.y+n.y)/2,x=f+a,w=m+l,S=g+u,C=b+p,P=T.lli8(f,m,x,w,g,b,S,C),k=T.dist(P,t);let E,z=h(t.y-P.y,t.x-P.x),_=h(e.y-P.y,e.x-P.x),M=h(n.y-P.y,n.x-P.x);return z<M?((z>_||_>M)&&(z+=v),z>M&&(E=M,M=z,z=E)):M<_&&_<z?(E=M,M=z,z=E):M+=v,P.s=z,P.e=M,P.r=k,P},numberSort:function(t,e){return t-e}},S=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 T.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),n=1;n<t.length;n++)T.expandbox(e,t[n].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(n){e.push(...n.offset(t))})),new S(e)}},{abs:C,min:P,max:k,cos:E,sin:z,acos:_,sqrt:M}=Math,B=Math.PI,O=class{constructor(t){let e=t&&t.forEach?t:Array.from(arguments).slice(),n=!1;if("object"==typeof e[0]){n=e.length;const t=[];e.forEach((function(e){["x","y","z"].forEach((function(n){void 0!==e[n]&&t.push(e[n])}))})),e=t}let i=!1;const r=e.length;if(n){if(n>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");i=!0}}else if(6!==r&&8!==r&&9!==r&&12!==r&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const o=this._3d=!i&&(9===r||12===r)||t&&t[0]&&void 0!==t[0].z,s=this.points=[];for(let t=0,n=o?3:2;t<r;t+=n){var a={x:e[t],y:e[t+1]};o&&(a.z=e[t+2]),s.push(a)}const l=this.order=s.length-1,c=this.dims=["x","y"];o&&c.push("z"),this.dimlen=c.length;const d=T.align(s,{p1:s[0],p2:s[l]}),u=T.dist(s[0],s[l]);this._linear=d.reduce(((t,e)=>t+C(e.y)),0)<u/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(t,e,n,i){if(void 0===i&&(i=.5),0===i)return new O(e,e,n);if(1===i)return new O(t,e,e);const r=O.getABC(2,t,e,n,i);return new O(t,r.A,n)}static cubicFromPoints(t,e,n,i,r){void 0===i&&(i=.5);const o=O.getABC(3,t,e,n,i);void 0===r&&(r=T.dist(e,o.C));const s=r*(1-i)/i,a=T.dist(t,n),l=(n.x-t.x)/a,c=(n.y-t.y)/a,d=r*l,u=r*c,h=s*l,p=s*c,f=e.x-d,m=e.y-u,g=e.x+h,v=e.y+p,y=o.A,b=y.x+(f-y.x)/(1-i),x=y.y+(m-y.y)/(1-i),w=y.x+(g-y.x)/i,S=y.y+(v-y.y)/i,C={x:t.x+(b-t.x)/i,y:t.y+(x-t.y)/i},P={x:n.x+(w-n.x)/(1-i),y:n.y+(S-n.y)/(1-i)};return new O(t,C,P,n)}static getUtils(){return T}getUtils(){return O.getUtils()}static get PolyBezier(){return S}valueOf(){return this.toString()}toString(){return T.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let n=1,i=t.length;n<i;n++)e.push(t[n].x),e.push(t[n].y);return e.join(" ")}setRatios(t){if(t.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=t,this._lut=[]}verify(){const t=this.coordDigest();t!==this._print&&(this._print=t,this.update())}coordDigest(){return this.points.map((function(t,e){return""+e+t.x+t.y+(t.z?t.z:0)})).join("")}update(){this._lut=[],this.dpoints=T.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=T.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return T.length(this.derivative.bind(this))}static getABC(t=2,e,n,i,r=.5){const o=T.projectionratio(r,t),s=1-o,a={x:o*e.x+s*i.x,y:o*e.y+s*i.y},l=T.abcratio(r,t);return{A:{x:n.x+(n.x-a.x)/l,y:n.y+(n.y-a.y)/l},B:n,C:a,S:e,E:i}}getABC(t,e){e=e||this.get(t);let n=this.points[0],i=this.points[this.order];return O.getABC(this.order,n,e,i,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t+1)return this._lut;this._lut=[],t++,this._lut=[];for(let e,n,i=0;i<t;i++)n=i/(t-1),e=this.compute(n),e.t=n,this._lut.push(e);return this._lut}on(e,n){n=n||5;const i=this.getLUT(),r=[];for(let t,o=0,s=0;o<i.length;o++)t=i[o],T.dist(t,e)<n&&(r.push(t),s+=o/i.length);return!!r.length&&(t/=r.length)}project(t){const e=this.getLUT(),n=e.length-1,i=T.closest(e,t),r=i.mpos,o=(r-1)/n,s=(r+1)/n,a=.1/n;let l,c=i.mdist,d=o,u=d;c+=1;for(let e;d<s+a;d+=a)l=this.compute(d),e=T.dist(t,l),e<c&&(c=e,u=d);return u=u<0?0:u>1?1:u,l=this.compute(u),l.t=u,l.d=c,l}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?T.computeWithRatios(t,this.points,this.ratios,this._3d):T.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],n=t.length;for(let i,r,o=1;o<n;o++)i=t[o],r=t[o-1],e[o]={x:(n-o)/n*i.x+o/n*r.x,y:(n-o)/n*i.y+o/n*r.y};return e[n]=t[n-1],new O(e)}derivative(t){return T.compute(t,this.dpoints[0],this._3d)}dderivative(t){return T.compute(t,this.dpoints[1],this._3d)}align(){let t=this.points;return new O(T.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return T.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return T.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),n=M(e.x*e.x+e.y*e.y);return{t,x:-e.y/n,y:e.x/n}}__normal3(t){const e=this.derivative(t),n=this.derivative(t+.01),i=M(e.x*e.x+e.y*e.y+e.z*e.z),r=M(n.x*n.x+n.y*n.y+n.z*n.z);e.x/=i,e.y/=i,e.z/=i,n.x/=r,n.y/=r,n.z/=r;const o={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},s=M(o.x*o.x+o.y*o.y+o.z*o.z);o.x/=s,o.y/=s,o.z/=s;const a=[o.x*o.x,o.x*o.y-o.z,o.x*o.z+o.y,o.x*o.y+o.z,o.y*o.y,o.y*o.z-o.x,o.x*o.z-o.y,o.y*o.z+o.x,o.z*o.z];return{t,x:a[0]*e.x+a[1]*e.y+a[2]*e.z,y:a[3]*e.x+a[4]*e.y+a[5]*e.z,z:a[6]*e.x+a[7]*e.y+a[8]*e.z}}hull(t){let e=this.points,n=[],i=[],r=0;for(i[r++]=e[0],i[r++]=e[1],i[r++]=e[2],3===this.order&&(i[r++]=e[3]);e.length>1;){n=[];for(let o,s=0,a=e.length-1;s<a;s++)o=T.lerp(t,e[s],e[s+1]),i[r++]=o,n.push(o);e=n}return i}split(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;const n=this.hull(t),i={left:2===this.order?new O([n[0],n[3],n[5]]):new O([n[0],n[4],n[7],n[9]]),right:2===this.order?new O([n[5],n[4],n[2]]):new O([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=T.map(0,0,1,this._t1,this._t2),i.left._t2=T.map(t,0,1,this._t1,this._t2),i.right._t1=T.map(t,0,1,this._t1,this._t2),i.right._t2=T.map(1,0,1,this._t1,this._t2),e?(e=T.map(e,t,1,0,1),i.right.split(e).left):i}extrema(){const t={};let e=[];return this.dims.forEach(function(n){let i=function(t){return t[n]},r=this.dpoints[0].map(i);t[n]=T.droots(r),3===this.order&&(r=this.dpoints[1].map(i),t[n]=t[n].concat(T.droots(r))),t[n]=t[n].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[n].sort(T.numberSort))}.bind(this)),t.values=e.sort(T.numberSort).filter((function(t,n){return e.indexOf(t)===n})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(n){e[n]=T.getminmax(this,n,t[n])}.bind(this)),e}overlaps(t){const e=this.bbox(),n=t.bbox();return T.bboxoverlap(e,n)}offset(t,e){if(void 0!==e){const n=this.get(t),i=this.normal(t),r={c:n,n:i,x:n.x+i.x*e,y:n.y+i.y*e};return this._3d&&(r.z=n.z+i.z*e),r}if(this._linear){const e=this.normal(0),n=this.points.map((function(n){const i={x:n.x+t*e.x,y:n.y+t*e.y};return n.z&&e.z&&(i.z=n.z+t*e.z),i}));return[new O(n)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=T.angle(this.points[0],this.points[3],this.points[1]),e=T.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let n=t.x*e.x+t.y*e.y;return this._3d&&(n+=t.z*e.z),C(_(n))<B/3}reduce(){let t,e,n=0,i=0,r=.01,o=[],s=[],a=this.extrema().values;for(-1===a.indexOf(0)&&(a=[0].concat(a)),-1===a.indexOf(1)&&a.push(1),n=a[0],t=1;t<a.length;t++)i=a[t],e=this.split(n,i),e._t1=n,e._t2=i,o.push(e),n=i;return o.forEach((function(t){for(n=0,i=0;i<=1;)for(i=n+r;i<=1.01;i+=r)if(e=t.split(n,i),!e.simple()){if(i-=r,C(n-i)<r)return[];e=t.split(n,i),e._t1=T.map(n,0,1,t._t1,t._t2),e._t2=T.map(i,0,1,t._t1,t._t2),s.push(e),n=i;break}n<1&&(e=t.split(n,1),e._t1=T.map(n,0,1,t._t1,t._t2),e._t2=t._t2,s.push(e))})),s}translate(t,e,n){n="number"==typeof n?n:e;const i=this.order;let r=this.points.map(((t,r)=>(1-r/i)*e+r/i*n));return new O(this.points.map(((e,n)=>({x:e.x+t.x*r[n],y:e.y+t.y*r[n]}))))}scale(t){const e=this.order;let n=!1;if("function"==typeof t&&(n=t),n&&2===e)return this.raise().scale(n);const i=this.clockwise,r=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):t,n?n(1):t);const o=n?n(0):t,s=n?n(1):t,a=[this.offset(0,10),this.offset(1,10)],l=[],c=T.lli4(a[0],a[0].c,a[1],a[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const n=l[t*e]=T.copy(r[t*e]);n.x+=(t?s:o)*a[t].n.x,n.y+=(t?s:o)*a[t].n.y})),n?([0,1].forEach((function(o){if(2!==e||!o){var s=r[o+1],a={x:s.x-c.x,y:s.y-c.y},d=n?n((o+1)/e):t;n&&!i&&(d=-d);var u=M(a.x*a.x+a.y*a.y);a.x/=u,a.y/=u,l[o+1]={x:s.x+d*a.x,y:s.y+d*a.y}}})),new O(l)):([0,1].forEach((t=>{if(2===e&&t)return;const n=l[t*e],i=this.derivative(t),o={x:n.x+i.x,y:n.y+i.y};l[t+1]=T.lli4(n,o,c,r[t+1])})),new O(l))}outline(t,e,n,i){if(e=void 0===e?t:e,this._linear){const r=this.normal(0),o=this.points[0],s=this.points[this.points.length-1];let a,l,c;void 0===n&&(n=t,i=e),a={x:o.x+r.x*t,y:o.y+r.y*t},c={x:s.x+r.x*n,y:s.y+r.y*n},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const d=[a,l,c];a={x:o.x-r.x*e,y:o.y-r.y*e},c={x:s.x-r.x*i,y:s.y-r.y*i},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const u=[c,l,a],h=T.makeline(u[2],d[0]),p=T.makeline(d[2],u[0]),f=[h,new O(d),p,new O(u)];return new S(f)}const r=this.reduce(),o=r.length,s=[];let a,l=[],c=0,d=this.length();const u=void 0!==n&&void 0!==i;function h(t,e,n,i,r){return function(o){const s=i/n,a=(i+r)/n,l=e-t;return T.map(o,0,1,t+s*l,t+a*l)}}r.forEach((function(r){const o=r.length();u?(s.push(r.scale(h(t,n,d,c,o))),l.push(r.scale(h(-e,-i,d,c,o)))):(s.push(r.scale(t)),l.push(r.scale(-e))),c+=o})),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[o-1].points[s[o-1].points.length-1],m=l[o-1].points[l[o-1].points.length-1],g=l[0].points[0],v=T.makeline(m,p),y=T.makeline(f,g),b=[v].concat(s).concat([y]).concat(l);return new S(b)}outlineshapes(t,e,n){e=e||t;const i=this.outline(t,e).curves,r=[];for(let t=1,e=i.length;t<e/2;t++){const o=T.makeshape(i[t],i[e-t],n);o.startcap.virtual=t>1,o.endcap.virtual=t<e/2-1,r.push(o)}return r}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof O&&(t=t.reduce()),this.curveintersects(this.reduce(),t,e)):this.selfintersects(e)}lineIntersects(t){const e=P(t.p1.x,t.p2.x),n=P(t.p1.y,t.p2.y),i=k(t.p1.x,t.p2.x),r=k(t.p1.y,t.p2.y);return T.roots(this.points,t).filter((t=>{var o=this.get(t);return T.between(o.x,e,i)&&T.between(o.y,n,r)}))}selfintersects(t){const e=this.reduce(),n=e.length-2,i=[];for(let r,o,s,a=0;a<n;a++)o=e.slice(a,a+1),s=e.slice(a+2),r=this.curveintersects(o,s,t),i.push(...r);return i}curveintersects(t,e,n){const i=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&i.push({left:t,right:e})}))}));let r=[];return i.forEach((function(t){const e=T.pairiteration(t.left,t.right,n);e.length>0&&(r=r.concat(e))})),r}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,n,i){const r=(i-n)/4,o=this.get(n+r),s=this.get(i-r),a=T.dist(t,e),l=T.dist(t,o),c=T.dist(t,s);return C(l-a)+C(c-a)}_iterate(t,e){let n,i=0,r=1;do{n=0,r=1;let o,s,a,l,c,d=this.get(i),u=!1,h=!1,p=r,f=1,m=0;do{if(h=u,l=a,p=(i+r)/2,m++,o=this.get(p),s=this.get(r),a=T.getccenter(d,o,s),a.interval={start:i,end:r},u=this._error(a,d,i,r)<=t,c=h&&!u,c||(f=r),u){if(r>=1){if(a.interval.end=f=1,l=a,r>1){let t={x:a.x+a.r*E(a.e),y:a.y+a.r*z(a.e)};a.e+=T.angle({x:a.x,y:a.y},t,this.get(1))}break}r+=(r-i)/2}else r=p}while(!c&&n++<100);if(n>=100)break;l=l||a,e.push(l),i=f}while(r<1);return e}};e.exports=s(a)}},n={};function i(t){var r=n[t];if(void 0!==r)return r.exports;var o=n[t]={id:t,exports:{}};return e[t].call(o.exports,o,o.exports,i),o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nc=void 0;var r=i(8088);window.jsdraw=r})();
|
9
|
+
return function(t,e,n){var i,r,o,s,a,l,c,d,u,h,p,f,m,g,v,y,b,x=e.createElement("canvas").getContext("2d"),w={r:0,g:0,b:0,h:0,s:0,v:0,a:1},T={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:function(){},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."}},S={},C="",P={},k=!1;function E(n){if("object"==typeof n){var s=function(){switch(a){case"el":B(n.el),!1!==n.wrap&&R(n.el);break;case"parent":(i=e.querySelector(n.parent))&&(i.appendChild(r),T.parent=n.parent,i===e.body&&(i=null));break;case"themeMode":T.themeMode=n.themeMode,"auto"===n.themeMode&&t.matchMedia&&t.matchMedia("(prefers-color-scheme: dark)").matches&&(T.themeMode="dark");case"theme":n.theme&&(T.theme=n.theme),r.className="clr-picker clr-"+T.theme+" clr-"+T.themeMode,T.inline&&I();break;case"rtl":T.rtl=!!n.rtl,e.querySelectorAll(".clr-field").forEach((function(t){return t.classList.toggle("clr-rtl",T.rtl)}));break;case"margin":n.margin*=1,T.margin=isNaN(n.margin)?T.margin:n.margin;break;case"wrap":n.el&&n.wrap&&R(n.el);break;case"formatToggle":T.formatToggle=!!n.formatToggle,it("clr-format").style.display=T.formatToggle?"block":"none",T.formatToggle&&(T.format="auto");break;case"swatches":if(Array.isArray(n.swatches)){var s=[];n.swatches.forEach((function(t,e){s.push('<button type="button" id="clr-swatch-'+e+'" aria-labelledby="clr-swatch-label clr-swatch-'+e+'" style="color: '+t+';">'+t+"</button>")})),it("clr-swatches").innerHTML=s.length?"<div>"+s.join("")+"</div>":"",T.swatches=n.swatches.slice()}break;case"swatchesOnly":T.swatchesOnly=!!n.swatchesOnly,r.setAttribute("data-minimal",T.swatchesOnly);break;case"alpha":T.alpha=!!n.alpha,r.setAttribute("data-alpha",T.alpha);break;case"inline":if(T.inline=!!n.inline,r.setAttribute("data-inline",T.inline),T.inline){var p=n.defaultColor||T.defaultColor;v=A(p),I(),D(p)}break;case"clearButton":"object"==typeof n.clearButton&&(n.clearButton.label&&(T.clearLabel=n.clearButton.label,d.innerHTML=T.clearLabel),n.clearButton=n.clearButton.show),T.clearButton=!!n.clearButton,d.style.display=T.clearButton?"block":"none";break;case"clearLabel":T.clearLabel=n.clearLabel,d.innerHTML=T.clearLabel;break;case"closeButton":T.closeButton=!!n.closeButton,T.closeButton?r.insertBefore(u,l):l.appendChild(u);break;case"closeLabel":T.closeLabel=n.closeLabel,u.innerHTML=T.closeLabel;break;case"a11y":var m=n.a11y,g=!1;if("object"==typeof m)for(var y in m)m[y]&&T.a11y[y]&&(T.a11y[y]=m[y],g=!0);if(g){var b=it("clr-open-label"),x=it("clr-swatch-label");b.innerHTML=T.a11y.open,x.innerHTML=T.a11y.swatch,u.setAttribute("aria-label",T.a11y.close),d.setAttribute("aria-label",T.a11y.clear),h.setAttribute("aria-label",T.a11y.hueSlider),f.setAttribute("aria-label",T.a11y.alphaSlider),c.setAttribute("aria-label",T.a11y.input),o.setAttribute("aria-label",T.a11y.instruction)}break;default:T[a]=n[a]}};for(var a in n)s()}}function z(t,e){"string"==typeof t&&"object"==typeof e&&(S[t]=e,k=!0)}function _(t){delete S[t],0===Object.keys(S).length&&(k=!1,t===C&&M())}function O(t){if(k){var e=["el","wrap","rtl","inline","defaultColor","a11y"],n=function(){var n=S[i];if(t.matches(i)){for(var r in C=i,P={},e.forEach((function(t){return delete n[t]})),n)P[r]=Array.isArray(T[r])?T[r].slice():T[r];return E(n),"break"}};for(var i in S)if("break"===n())break}}function M(){Object.keys(P).length>0&&(E(P),C="",P={})}function B(t){rt(e,"click",t,(function(t){T.inline||(O(t.target),g=t.target,y=g.value,v=A(y),r.classList.add("clr-open"),I(),D(y),(T.focusInput||T.selectInput)&&c.focus({preventScroll:!0}),T.selectInput&&c.select(),(b||T.swatchesOnly)&&nt().shift().focus(),g.dispatchEvent(new Event("open",{bubbles:!0})))})),rt(e,"input",t,(function(t){var e=t.target.parentNode;e.classList.contains("clr-field")&&(e.style.color=t.target.value)}))}function I(){if(r&&(g||T.inline)){var n,a,l,c=i,d=t.scrollY,u=r.offsetWidth,h=r.offsetHeight,p={left:!1,top:!1},f={x:0,y:0};if(c&&(n=t.getComputedStyle(c),a=parseFloat(n.marginTop),l=parseFloat(n.borderTopWidth),(f=c.getBoundingClientRect()).y+=l+d),!T.inline){var m=g.getBoundingClientRect(),v=m.x,y=d+m.y+m.height+T.margin;c?(v-=f.x,y-=f.y,v+u>c.clientWidth&&(v+=m.width-u,p.left=!0),y+h>c.clientHeight-a&&h+T.margin<=m.top-(f.y-d)&&(y-=m.height+h+2*T.margin,p.top=!0),y+=c.scrollTop):(v+u>e.documentElement.clientWidth&&(v+=m.width-u,p.left=!0),y+h-d>e.documentElement.clientHeight&&h+T.margin<=m.top&&(y=d+m.y-h-T.margin,p.top=!0)),r.classList.toggle("clr-left",p.left),r.classList.toggle("clr-top",p.top),r.style.left=v+"px",r.style.top=y+"px",f.x+=r.offsetLeft,f.y+=r.offsetTop}s={width:o.offsetWidth,height:o.offsetHeight,x:o.offsetLeft+f.x,y:o.offsetTop+f.y}}}function R(t){e.querySelectorAll(t).forEach((function(t){var n=t.parentNode;if(!n.classList.contains("clr-field")){var i=e.createElement("div"),r="clr-field";(T.rtl||t.classList.contains("clr-rtl"))&&(r+=" clr-rtl"),i.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',n.insertBefore(i,t),i.setAttribute("class",r),i.style.color=t.value,i.appendChild(t)}}))}function L(t){if(g&&!T.inline){var e=g;t&&(g=null,y!==e.value&&(e.value=y,e.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout((function(){y!==e.value&&e.dispatchEvent(new Event("change",{bubbles:!0}))})),r.classList.remove("clr-open"),k&&M(),e.dispatchEvent(new Event("close",{bubbles:!0})),T.focusInput&&e.focus({preventScroll:!0}),g=null}}function D(t){var e=Q(t),n=J(e);V(n.s,n.v),H(e,n),h.value=n.h,r.style.color="hsl("+n.h+", 100%, 50%)",p.style.left=n.h/360*100+"%",a.style.left=s.width*n.s/100+"px",a.style.top=s.height-s.height*n.v/100+"px",f.value=100*n.a,m.style.left=100*n.a+"%"}function A(t){var e=t.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function j(n){n=void 0!==n?n:c.value,g&&(g.value=n,g.dispatchEvent(new Event("input",{bubbles:!0}))),T.onChange&&T.onChange.call(t,n),e.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:n}}))}function F(t,e){var n={h:1*h.value,s:t/s.width*100,v:100-e/s.height*100,a:f.value/100},i=q(n);V(n.s,n.v),H(i,n),j()}function V(t,e){var n=T.a11y.marker;t=1*t.toFixed(1),e=1*e.toFixed(1),n=(n=n.replace("{s}",t)).replace("{v}",e),a.setAttribute("aria-label",n)}function N(t){return{pageX:t.changedTouches?t.changedTouches[0].pageX:t.pageX,pageY:t.changedTouches?t.changedTouches[0].pageY:t.pageY}}function $(t){var e=N(t),n=e.pageX-s.x,r=e.pageY-s.y;i&&(r+=i.scrollTop),W(n,r),t.preventDefault(),t.stopPropagation()}function U(t,e){W(1*a.style.left.replace("px","")+t,1*a.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,a.style.left=t+"px",a.style.top=e+"px",F(t,e),a.focus()}function H(t,n){void 0===t&&(t={}),void 0===n&&(n={});var i=T.format;for(var r in t)w[r]=t[r];for(var s in n)w[s]=n[s];var d=X(w),u=d.substring(0,7);switch(a.style.color=u,m.parentNode.style.color=u,m.style.color=d,l.style.color=d,o.style.display="none",o.offsetHeight,o.style.display="",m.nextElementSibling.style.display="none",m.nextElementSibling.offsetHeight,m.nextElementSibling.style.display="","mixed"===i?i=1===w.a?"hex":"rgb":"auto"===i&&(i=v),i){case"hex":c.value=d;break;case"rgb":c.value=Y(w);break;case"hsl":c.value=tt(K(w))}e.querySelector('.clr-format [value="'+i+'"]').checked=!0}function G(){var t=1*h.value,e=1*a.style.left.replace("px",""),n=1*a.style.top.replace("px","");r.style.color="hsl("+t+", 100%, 50%)",p.style.left=t/360*100+"%",F(e,n)}function Z(){var t=f.value/100;m.style.left=100*t+"%",H({a:t}),j()}function q(t){var e=t.s/100,i=t.v/100,r=e*i,o=t.h/60,s=r*(1-n.abs(o%2-1)),a=i-r;r+=a,s+=a;var l=n.floor(o)%6,c=[r,s,a,a,s,r][l],d=[s,r,r,s,a,a][l],u=[a,a,s,r,r,s][l];return{r:n.round(255*c),g:n.round(255*d),b:n.round(255*u),a:t.a}}function K(t){var e,i=t.v/100,r=i*(1-t.s/100/2);return r>0&&r<1&&(e=n.round((i-r)/n.min(r,1-r)*100)),{h:t.h,s:e||0,l:n.round(100*r),a:t.a}}function J(t){var e=t.r/255,i=t.g/255,r=t.b/255,o=n.max(e,i,r),s=o-n.min(e,i,r),a=o,l=0,c=0;return s&&(o===e&&(l=(i-r)/s),o===i&&(l=2+(r-e)/s),o===r&&(l=4+(e-i)/s),o&&(c=s/o)),{h:(l=n.floor(60*l))<0?l+360:l,s:n.round(100*c),v:n.round(100*a),a:t.a}}function Q(t){var e,n,i=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;return x.fillStyle="#000",x.fillStyle=t,(e=i.exec(x.fillStyle))?(n={r:1*e[3],g:1*e[4],b:1*e[5],a:1*e[6]}).a=+n.a.toFixed(2):n={r:(e=x.fillStyle.replace("#","").match(/.{2}/g).map((function(t){return parseInt(t,16)})))[0],g:e[1],b:e[2],a:1},n}function X(t){var e=t.r.toString(16),n=t.g.toString(16),i=t.b.toString(16),r="";if(t.r<16&&(e="0"+e),t.g<16&&(n="0"+n),t.b<16&&(i="0"+i),T.alpha&&(t.a<1||T.forceAlpha)){var o=255*t.a|0;r=o.toString(16),o<16&&(r="0"+r)}return"#"+e+n+i+r}function Y(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 tt(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 et(){e.getElementById("clr-picker")||(i=null,(r=e.createElement("div")).setAttribute("id","clr-picker"),r.className="clr-picker",r.innerHTML='<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+T.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+T.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+T.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+T.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+T.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button type="button" id="clr-clear" class="clr-clear" aria-label="'+T.a11y.clear+'">'+T.clearLabel+'</button><div id="clr-color-preview" class="clr-preview"><button type="button" id="clr-close" class="clr-close" aria-label="'+T.a11y.close+'">'+T.closeLabel+'</button></div><span id="clr-open-label" hidden>'+T.a11y.open+'</span><span id="clr-swatch-label" hidden>'+T.a11y.swatch+"</span>",e.body.appendChild(r),o=it("clr-color-area"),a=it("clr-color-marker"),d=it("clr-clear"),u=it("clr-close"),l=it("clr-color-preview"),c=it("clr-color-value"),h=it("clr-hue-slider"),p=it("clr-hue-marker"),f=it("clr-alpha-slider"),m=it("clr-alpha-marker"),B(T.el),R(T.el),rt(r,"mousedown",(function(t){r.classList.remove("clr-keyboard-nav"),t.stopPropagation()})),rt(o,"mousedown",(function(t){rt(e,"mousemove",$)})),rt(o,"touchstart",(function(t){e.addEventListener("touchmove",$,{passive:!1})})),rt(a,"mousedown",(function(t){rt(e,"mousemove",$)})),rt(a,"touchstart",(function(t){e.addEventListener("touchmove",$,{passive:!1})})),rt(c,"change",(function(t){(g||T.inline)&&(D(c.value),j())})),rt(d,"click",(function(t){j(""),L()})),rt(u,"click",(function(t){j(),L()})),rt(e,"click",".clr-format input",(function(t){v=t.target.value,H(),j()})),rt(r,"click",".clr-swatches button",(function(t){D(t.target.textContent),j(),T.swatchesOnly&&L()})),rt(e,"mouseup",(function(t){e.removeEventListener("mousemove",$)})),rt(e,"touchend",(function(t){e.removeEventListener("touchmove",$)})),rt(e,"mousedown",(function(t){b=!1,r.classList.remove("clr-keyboard-nav"),L()})),rt(e,"keydown",(function(t){var e=t.key,n=t.target,i=t.shiftKey,o=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];if("Escape"===e?L(!0):o.includes(e)&&(b=!0,r.classList.add("clr-keyboard-nav")),"Tab"===e&&n.matches(".clr-picker *")){var s=nt(),a=s.shift(),l=s.pop();i&&n===a?(l.focus(),t.preventDefault()):i||n!==l||(a.focus(),t.preventDefault())}})),rt(e,"click",".clr-field button",(function(t){k&&M(),t.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))})),rt(a,"keydown",(function(t){var e={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(e).includes(t.key)&&(U.apply(void 0,e[t.key]),t.preventDefault())})),rt(o,"click",$),rt(h,"input",G),rt(f,"input",Z))}function nt(){return Array.from(r.querySelectorAll("input, button")).filter((function(t){return!!t.offsetWidth}))}function it(t){return e.getElementById(t)}function rt(t,e,n,i){var r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof n?t.addEventListener(e,(function(t){r.call(t.target,n)&&i.call(t.target,t)})):(i=n,t.addEventListener(e,i))}function ot(t,n){n=void 0!==n?n:[],"loading"!==e.readyState?t.apply(void 0,n):e.addEventListener("DOMContentLoaded",(function(){t.apply(void 0,n)}))}function st(t,e){y=(g=e).value,O(e),v=A(t),I(),D(t),j(),y!==t&&g.dispatchEvent(new Event("change",{bubbles:!0}))}void 0!==NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var at=function(){var e={init:et,set:E,wrap:R,close:L,setInstance:z,setColor:st,removeInstance:_,updatePosition:I};function n(t){ot((function(){t&&("string"==typeof t?B(t):E(t))}))}var i=function(t){n[t]=function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];ot(e[t],i)}};for(var r in e)i(r);return ot((function(){t.addEventListener("resize",(function(t){n.updatePosition()})),t.addEventListener("scroll",(function(t){n.updatePosition()}))})),n}();return at.coloris=at,at}(window,document,Math)})?n.apply(e,i):n)||(t.exports=r)},8405:e=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=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 r(e))o.call(t,l)||!s&&"default"===l||n(t,l,{get:()=>e[l],enumerable:!(a=i(e,l))||a.enumerable});return t})(n({},"__esModule",{value:!0}),e,1),t&&t.set(e,s),s))("undefined"!=typeof WeakMap?new WeakMap:0),a={};((t,e)=>{for(var i in e)n(t,i,{get:e[i],enumerable:!0})})(a,{Bezier:()=>B});var{abs:l,cos:c,sin:d,acos:u,atan2:h,sqrt:p,pow:f}=Math;function m(t){return t<0?-f(-t,1/3):f(t,1/3)}var g=Math.PI,v=2*g,y=g/2,b=Number.MAX_SAFE_INTEGER||9007199254740991,x=Number.MIN_SAFE_INTEGER||-9007199254740991,w={x:0,y:0,z:0},T={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const n=e(t);let i=n.x*n.x+n.y*n.y;return void 0!==n.z&&(i+=n.z*n.z),p(i)},compute:function(t,e,n){if(0===t)return e[0].t=0,e[0];const i=e.length-1;if(1===t)return e[i].t=1,e[i];const r=1-t;let o=e;if(0===i)return e[0].t=t,e[0];if(1===i){const e={x:r*o[0].x+t*o[1].x,y:r*o[0].y+t*o[1].y,t};return n&&(e.z=r*o[0].z+t*o[1].z),e}if(i<4){let e,s,a,l=r*r,c=t*t,d=0;2===i?(o=[o[0],o[1],o[2],w],e=l,s=r*t*2,a=c):3===i&&(e=l*r,s=l*t*3,a=r*c*3,d=t*c);const u={x:e*o[0].x+s*o[1].x+a*o[2].x+d*o[3].x,y:e*o[0].y+s*o[1].y+a*o[2].y+d*o[3].y,t};return n&&(u.z=e*o[0].z+s*o[1].z+a*o[2].z+d*o[3].z),u}const s=JSON.parse(JSON.stringify(e));for(;s.length>1;){for(let e=0;e<s.length-1;e++)s[e]={x:s[e].x+(s[e+1].x-s[e].x)*t,y:s[e].y+(s[e+1].y-s[e].y)*t},void 0!==s[e].z&&(s[e]=s[e].z+(s[e+1].z-s[e].z)*t);s.splice(s.length-1,1)}return s[0].t=t,s[0]},computeWithRatios:function(t,e,n,i){const r=1-t,o=n,s=e;let a,l=o[0],c=o[1],d=o[2],u=o[3];return l*=r,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:!!i&&(l*s[0].z+c*s[1].z)/a,t}):(l*=r,c*=2*r,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:!!i&&(l*s[0].z+c*s[1].z+d*s[2].z)/a,t}):(l*=r,c*=1.5*r,d*=3*r,u*=t*t*t,4===s.length?(a=l+c+d+u,{x:(l*s[0].x+c*s[1].x+d*s[2].x+u*s[3].x)/a,y:(l*s[0].y+c*s[1].y+d*s[2].y+u*s[3].y)/a,z:!!i&&(l*s[0].z+c*s[1].z+d*s[2].z+u*s[3].z)/a,t}):void 0))},derive:function(t,e){const n=[];for(let i=t,r=i.length,o=r-1;r>1;r--,o--){const t=[];for(let n,r=0;r<o;r++)n={x:o*(i[r+1].x-i[r].x),y:o*(i[r+1].y-i[r].y)},e&&(n.z=o*(i[r+1].z-i[r].z)),t.push(n);n.push(t),i=t}return n},between:function(t,e,n){return e<=t&&t<=n||T.approximately(t,e)||T.approximately(t,n)},approximately:function(t,e,n){return l(t-e)<=(n||1e-6)},length:function(t){const e=T.Tvalues.length;let n=0;for(let i,r=0;r<e;r++)i=.5*T.Tvalues[r]+.5,n+=T.Cvalues[r]*T.arcfn(i,t);return.5*n},map:function(t,e,n,i,r){return i+(r-i)*((t-e)/(n-e))},lerp:function(t,e,n){const i={x:e.x+t*(n.x-e.x),y:e.y+t*(n.y-e.y)};return void 0!==e.z&&void 0!==n.z&&(i.z=e.z+t*(n.z-e.z)),i},pointToString:function(t){let e=t.x+"/"+t.y;return void 0!==t.z&&(e+="/"+t.z),e},pointsToString:function(t){return"["+t.map(T.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,n){const i=e.x-t.x,r=e.y-t.y,o=n.x-t.x,s=n.y-t.y;return h(i*s-r*o,i*o+r*s)},round:function(t,e){const n=""+t,i=n.indexOf(".");return parseFloat(n.substring(0,i+1+e))},dist:function(t,e){const n=t.x-e.x,i=t.y-e.y;return p(n*n+i*i)},closest:function(t,e){let n,i,r=f(2,63);return t.forEach((function(t,o){i=T.dist(e,t),i<r&&(r=i,n=o)})),{mdist:r,mpos:n}},abcratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(t,e)+f(1-t,e);return l((n-1)/n)},projectionratio:function(t,e){if(2!==e&&3!==e)return!1;if(void 0===t)t=.5;else if(0===t||1===t)return t;const n=f(1-t,e);return n/(f(t,e)+n)},lli8:function(t,e,n,i,r,o,s,a){const l=(t-n)*(o-a)-(e-i)*(r-s);return 0!=l&&{x:((t*i-e*n)*(r-s)-(t-n)*(r*a-o*s))/l,y:((t*i-e*n)*(o-a)-(e-i)*(r*a-o*s))/l}},lli4:function(t,e,n,i){const r=t.x,o=t.y,s=e.x,a=e.y,l=n.x,c=n.y,d=i.x,u=i.y;return T.lli8(r,o,s,a,l,c,d,u)},lli:function(t,e){return T.lli4(t,t.c,e,e.c)},makeline:function(t,e){return new B(t.x,t.y,(t.x+e.x)/2,(t.y+e.y)/2,e.x,e.y)},findbbox:function(t){let e=b,n=b,i=x,r=x;return t.forEach((function(t){const o=t.bbox();e>o.x.min&&(e=o.x.min),n>o.y.min&&(n=o.y.min),i<o.x.max&&(i=o.x.max),r<o.y.max&&(r=o.y.max)})),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:n,mid:(n+r)/2,max:r,size:r-n}}},shapeintersections:function(t,e,n,i,r){if(!T.bboxoverlap(e,i))return[];const o=[],s=[t.startcap,t.forward,t.back,t.endcap],a=[n.startcap,n.forward,n.back,n.endcap];return s.forEach((function(e){e.virtual||a.forEach((function(i){if(i.virtual)return;const s=e.intersects(i,r);s.length>0&&(s.c1=e,s.c2=i,s.s1=t,s.s2=n,o.push(s))}))})),o},makeshape:function(t,e,n){const i=e.points.length,r=t.points.length,o=T.makeline(e.points[i-1],t.points[0]),s=T.makeline(t.points[r-1],e.points[0]),a={startcap:o,forward:t,back:e,endcap:s,bbox:T.findbbox([o,t,e,s]),intersections:function(t){return T.shapeintersections(a,a.bbox,t,t.bbox,n)}};return a},getminmax:function(t,e,n){if(!n)return{min:0,max:0};let i,r,o=b,s=x;-1===n.indexOf(0)&&(n=[0].concat(n)),-1===n.indexOf(1)&&n.push(1);for(let a=0,l=n.length;a<l;a++)i=n[a],r=t.get(i),r[e]<o&&(o=r[e]),r[e]>s&&(s=r[e]);return{min:o,mid:(o+s)/2,max:s,size:s-o}},align:function(t,e){const n=e.p1.x,i=e.p1.y,r=-h(e.p2.y-i,e.p2.x-n);return t.map((function(t){return{x:(t.x-n)*c(r)-(t.y-i)*d(r),y:(t.x-n)*d(r)+(t.y-i)*c(r)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=t.length-1,i=T.align(t,e),r=function(t){return 0<=t&&t<=1};if(2===n){const t=i[0].y,e=i[1].y,n=i[2].y,o=t-2*e+n;if(0!==o){const i=-p(e*e-t*n),s=-t+e;return[-(i+s)/o,-(-i+s)/o].filter(r)}return e!==n&&0===o?[(2*e-n)/(2*e-2*n)].filter(r):[]}const o=i[0].y,s=i[1].y,a=i[2].y;let l=3*s-o-3*a+i[3].y,d=3*o-6*s+3*a,h=-3*o+3*s,f=o;if(T.approximately(l,0)){if(T.approximately(d,0))return T.approximately(h,0)?[]:[-f/h].filter(r);const t=p(h*h-4*d*f),e=2*d;return[(t-h)/e,(-h-t)/e].filter(r)}d/=l,h/=l,f/=l;const g=(3*h-d*d)/3,y=g/3,b=(2*d*d*d-9*d*h+27*f)/27,x=b/2,w=x*x+y*y*y;let S,C,P,k,E;if(w<0){const t=-g/3,e=p(t*t*t),n=-b/(2*e),i=u(n<-1?-1:n>1?1:n),o=2*m(e);return P=o*c(i/3)-d/3,k=o*c((i+v)/3)-d/3,E=o*c((i+2*v)/3)-d/3,[P,k,E].filter(r)}if(0===w)return S=x<0?m(-x):-m(x),P=2*S-d/3,k=-S-d/3,[P,k].filter(r);{const t=p(w);return S=m(-x+t),C=m(x+t),[S-C-d/3].filter(r)}},droots:function(t){if(3===t.length){const e=t[0],n=t[1],i=t[2],r=e-2*n+i;if(0!==r){const t=-p(n*n-e*i),o=-e+n;return[-(t+o)/r,-(-t+o)/r]}return n!==i&&0===r?[(2*n-i)/(2*(n-i))]:[]}if(2===t.length){const e=t[0],n=t[1];return e!==n?[e/(e-n)]:[]}return[]},curvature:function(t,e,n,i,r){let o,s,a,c,d=0,u=0;const h=T.compute(t,e),m=T.compute(t,n),g=h.x*h.x+h.y*h.y;if(i?(o=p(f(h.y*m.z-m.y*h.z,2)+f(h.z*m.x-m.z*h.x,2)+f(h.x*m.y-m.x*h.y,2)),s=f(g+h.z*h.z,1.5)):(o=h.x*m.y-h.y*m.x,s=f(g,1.5)),0===o||0===s)return{k:0,r:0};if(d=o/s,u=s/o,!r){const r=T.curvature(t-.001,e,n,i,!0).k,o=T.curvature(t+.001,e,n,i,!0).k;c=(o-d+(d-r))/2,a=(l(o-d)+l(d-r))/2}return{k:d,r:u,dk:c,adk:a}},inflections:function(t){if(t.length<4)return[];const e=T.align(t,{p1:t[0],p2:t.slice(-1)[0]}),n=e[2].x*e[1].y,i=e[3].x*e[1].y,r=e[1].x*e[2].y,o=18*(-3*n+2*i+3*r-e[3].x*e[2].y),s=18*(3*n-i-3*r),a=18*(r-n);if(T.approximately(o,0)){if(!T.approximately(s,0)){let t=-a/s;if(0<=t&&t<=1)return[t]}return[]}const l=2*o;if(T.approximately(l,0))return[];const c=s*s-4*o*a;if(c<0)return[];const d=Math.sqrt(c);return[(d-s)/l,-(s+d)/l].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const n=["x","y"],i=n.length;for(let r,o,s,a,c=0;c<i;c++)if(r=n[c],o=t[r].mid,s=e[r].mid,a=(t[r].size+e[r].size)/2,l(o-s)>=a)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,n){const i=t.bbox(),r=e.bbox(),o=1e5,s=n||.5;if(i.x.size+i.y.size<s&&r.x.size+r.y.size<s)return[(o*(t._t1+t._t2)/2|0)/o+"/"+(o*(e._t1+e._t2)/2|0)/o];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 T.bboxoverlap(t.left.bbox(),t.right.bbox())}));let d=[];return 0===c.length||(c.forEach((function(t){d=d.concat(T.pairiteration(t.left,t.right,s))})),d=d.filter((function(t,e){return d.indexOf(t)===e}))),d},getccenter:function(t,e,n){const i=e.x-t.x,r=e.y-t.y,o=n.x-e.x,s=n.y-e.y,a=i*c(y)-r*d(y),l=i*d(y)+r*c(y),u=o*c(y)-s*d(y),p=o*d(y)+s*c(y),f=(t.x+e.x)/2,m=(t.y+e.y)/2,g=(e.x+n.x)/2,b=(e.y+n.y)/2,x=f+a,w=m+l,S=g+u,C=b+p,P=T.lli8(f,m,x,w,g,b,S,C),k=T.dist(P,t);let E,z=h(t.y-P.y,t.x-P.x),_=h(e.y-P.y,e.x-P.x),O=h(n.y-P.y,n.x-P.x);return z<O?((z>_||_>O)&&(z+=v),z>O&&(E=O,O=z,z=E)):O<_&&_<z?(E=O,O=z,z=E):O+=v,P.s=z,P.e=O,P.r=k,P},numberSort:function(t,e){return t-e}},S=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 T.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),n=1;n<t.length;n++)T.expandbox(e,t[n].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(n){e.push(...n.offset(t))})),new S(e)}},{abs:C,min:P,max:k,cos:E,sin:z,acos:_,sqrt:O}=Math,M=Math.PI,B=class{constructor(t){let e=t&&t.forEach?t:Array.from(arguments).slice(),n=!1;if("object"==typeof e[0]){n=e.length;const t=[];e.forEach((function(e){["x","y","z"].forEach((function(n){void 0!==e[n]&&t.push(e[n])}))})),e=t}let i=!1;const r=e.length;if(n){if(n>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");i=!0}}else if(6!==r&&8!==r&&9!==r&&12!==r&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const o=this._3d=!i&&(9===r||12===r)||t&&t[0]&&void 0!==t[0].z,s=this.points=[];for(let t=0,n=o?3:2;t<r;t+=n){var a={x:e[t],y:e[t+1]};o&&(a.z=e[t+2]),s.push(a)}const l=this.order=s.length-1,c=this.dims=["x","y"];o&&c.push("z"),this.dimlen=c.length;const d=T.align(s,{p1:s[0],p2:s[l]}),u=T.dist(s[0],s[l]);this._linear=d.reduce(((t,e)=>t+C(e.y)),0)<u/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(t,e,n,i){if(void 0===i&&(i=.5),0===i)return new B(e,e,n);if(1===i)return new B(t,e,e);const r=B.getABC(2,t,e,n,i);return new B(t,r.A,n)}static cubicFromPoints(t,e,n,i,r){void 0===i&&(i=.5);const o=B.getABC(3,t,e,n,i);void 0===r&&(r=T.dist(e,o.C));const s=r*(1-i)/i,a=T.dist(t,n),l=(n.x-t.x)/a,c=(n.y-t.y)/a,d=r*l,u=r*c,h=s*l,p=s*c,f=e.x-d,m=e.y-u,g=e.x+h,v=e.y+p,y=o.A,b=y.x+(f-y.x)/(1-i),x=y.y+(m-y.y)/(1-i),w=y.x+(g-y.x)/i,S=y.y+(v-y.y)/i,C={x:t.x+(b-t.x)/i,y:t.y+(x-t.y)/i},P={x:n.x+(w-n.x)/(1-i),y:n.y+(S-n.y)/(1-i)};return new B(t,C,P,n)}static getUtils(){return T}getUtils(){return B.getUtils()}static get PolyBezier(){return S}valueOf(){return this.toString()}toString(){return T.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let n=1,i=t.length;n<i;n++)e.push(t[n].x),e.push(t[n].y);return e.join(" ")}setRatios(t){if(t.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=t,this._lut=[]}verify(){const t=this.coordDigest();t!==this._print&&(this._print=t,this.update())}coordDigest(){return this.points.map((function(t,e){return""+e+t.x+t.y+(t.z?t.z:0)})).join("")}update(){this._lut=[],this.dpoints=T.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=T.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return T.length(this.derivative.bind(this))}static getABC(t=2,e,n,i,r=.5){const o=T.projectionratio(r,t),s=1-o,a={x:o*e.x+s*i.x,y:o*e.y+s*i.y},l=T.abcratio(r,t);return{A:{x:n.x+(n.x-a.x)/l,y:n.y+(n.y-a.y)/l},B:n,C:a,S:e,E:i}}getABC(t,e){e=e||this.get(t);let n=this.points[0],i=this.points[this.order];return B.getABC(this.order,n,e,i,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t+1)return this._lut;this._lut=[],t++,this._lut=[];for(let e,n,i=0;i<t;i++)n=i/(t-1),e=this.compute(n),e.t=n,this._lut.push(e);return this._lut}on(e,n){n=n||5;const i=this.getLUT(),r=[];for(let t,o=0,s=0;o<i.length;o++)t=i[o],T.dist(t,e)<n&&(r.push(t),s+=o/i.length);return!!r.length&&(t/=r.length)}project(t){const e=this.getLUT(),n=e.length-1,i=T.closest(e,t),r=i.mpos,o=(r-1)/n,s=(r+1)/n,a=.1/n;let l,c=i.mdist,d=o,u=d;c+=1;for(let e;d<s+a;d+=a)l=this.compute(d),e=T.dist(t,l),e<c&&(c=e,u=d);return u=u<0?0:u>1?1:u,l=this.compute(u),l.t=u,l.d=c,l}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?T.computeWithRatios(t,this.points,this.ratios,this._3d):T.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],n=t.length;for(let i,r,o=1;o<n;o++)i=t[o],r=t[o-1],e[o]={x:(n-o)/n*i.x+o/n*r.x,y:(n-o)/n*i.y+o/n*r.y};return e[n]=t[n-1],new B(e)}derivative(t){return T.compute(t,this.dpoints[0],this._3d)}dderivative(t){return T.compute(t,this.dpoints[1],this._3d)}align(){let t=this.points;return new B(T.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return T.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return T.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),n=O(e.x*e.x+e.y*e.y);return{t,x:-e.y/n,y:e.x/n}}__normal3(t){const e=this.derivative(t),n=this.derivative(t+.01),i=O(e.x*e.x+e.y*e.y+e.z*e.z),r=O(n.x*n.x+n.y*n.y+n.z*n.z);e.x/=i,e.y/=i,e.z/=i,n.x/=r,n.y/=r,n.z/=r;const o={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},s=O(o.x*o.x+o.y*o.y+o.z*o.z);o.x/=s,o.y/=s,o.z/=s;const a=[o.x*o.x,o.x*o.y-o.z,o.x*o.z+o.y,o.x*o.y+o.z,o.y*o.y,o.y*o.z-o.x,o.x*o.z-o.y,o.y*o.z+o.x,o.z*o.z];return{t,x:a[0]*e.x+a[1]*e.y+a[2]*e.z,y:a[3]*e.x+a[4]*e.y+a[5]*e.z,z:a[6]*e.x+a[7]*e.y+a[8]*e.z}}hull(t){let e=this.points,n=[],i=[],r=0;for(i[r++]=e[0],i[r++]=e[1],i[r++]=e[2],3===this.order&&(i[r++]=e[3]);e.length>1;){n=[];for(let o,s=0,a=e.length-1;s<a;s++)o=T.lerp(t,e[s],e[s+1]),i[r++]=o,n.push(o);e=n}return i}split(t,e){if(0===t&&e)return this.split(e).left;if(1===e)return this.split(t).right;const n=this.hull(t),i={left:2===this.order?new B([n[0],n[3],n[5]]):new B([n[0],n[4],n[7],n[9]]),right:2===this.order?new B([n[5],n[4],n[2]]):new B([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=T.map(0,0,1,this._t1,this._t2),i.left._t2=T.map(t,0,1,this._t1,this._t2),i.right._t1=T.map(t,0,1,this._t1,this._t2),i.right._t2=T.map(1,0,1,this._t1,this._t2),e?(e=T.map(e,t,1,0,1),i.right.split(e).left):i}extrema(){const t={};let e=[];return this.dims.forEach(function(n){let i=function(t){return t[n]},r=this.dpoints[0].map(i);t[n]=T.droots(r),3===this.order&&(r=this.dpoints[1].map(i),t[n]=t[n].concat(T.droots(r))),t[n]=t[n].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[n].sort(T.numberSort))}.bind(this)),t.values=e.sort(T.numberSort).filter((function(t,n){return e.indexOf(t)===n})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(n){e[n]=T.getminmax(this,n,t[n])}.bind(this)),e}overlaps(t){const e=this.bbox(),n=t.bbox();return T.bboxoverlap(e,n)}offset(t,e){if(void 0!==e){const n=this.get(t),i=this.normal(t),r={c:n,n:i,x:n.x+i.x*e,y:n.y+i.y*e};return this._3d&&(r.z=n.z+i.z*e),r}if(this._linear){const e=this.normal(0),n=this.points.map((function(n){const i={x:n.x+t*e.x,y:n.y+t*e.y};return n.z&&e.z&&(i.z=n.z+t*e.z),i}));return[new B(n)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=T.angle(this.points[0],this.points[3],this.points[1]),e=T.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let n=t.x*e.x+t.y*e.y;return this._3d&&(n+=t.z*e.z),C(_(n))<M/3}reduce(){let t,e,n=0,i=0,r=.01,o=[],s=[],a=this.extrema().values;for(-1===a.indexOf(0)&&(a=[0].concat(a)),-1===a.indexOf(1)&&a.push(1),n=a[0],t=1;t<a.length;t++)i=a[t],e=this.split(n,i),e._t1=n,e._t2=i,o.push(e),n=i;return o.forEach((function(t){for(n=0,i=0;i<=1;)for(i=n+r;i<=1.01;i+=r)if(e=t.split(n,i),!e.simple()){if(i-=r,C(n-i)<r)return[];e=t.split(n,i),e._t1=T.map(n,0,1,t._t1,t._t2),e._t2=T.map(i,0,1,t._t1,t._t2),s.push(e),n=i;break}n<1&&(e=t.split(n,1),e._t1=T.map(n,0,1,t._t1,t._t2),e._t2=t._t2,s.push(e))})),s}translate(t,e,n){n="number"==typeof n?n:e;const i=this.order;let r=this.points.map(((t,r)=>(1-r/i)*e+r/i*n));return new B(this.points.map(((e,n)=>({x:e.x+t.x*r[n],y:e.y+t.y*r[n]}))))}scale(t){const e=this.order;let n=!1;if("function"==typeof t&&(n=t),n&&2===e)return this.raise().scale(n);const i=this.clockwise,r=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):t,n?n(1):t);const o=n?n(0):t,s=n?n(1):t,a=[this.offset(0,10),this.offset(1,10)],l=[],c=T.lli4(a[0],a[0].c,a[1],a[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const n=l[t*e]=T.copy(r[t*e]);n.x+=(t?s:o)*a[t].n.x,n.y+=(t?s:o)*a[t].n.y})),n?([0,1].forEach((function(o){if(2!==e||!o){var s=r[o+1],a={x:s.x-c.x,y:s.y-c.y},d=n?n((o+1)/e):t;n&&!i&&(d=-d);var u=O(a.x*a.x+a.y*a.y);a.x/=u,a.y/=u,l[o+1]={x:s.x+d*a.x,y:s.y+d*a.y}}})),new B(l)):([0,1].forEach((t=>{if(2===e&&t)return;const n=l[t*e],i=this.derivative(t),o={x:n.x+i.x,y:n.y+i.y};l[t+1]=T.lli4(n,o,c,r[t+1])})),new B(l))}outline(t,e,n,i){if(e=void 0===e?t:e,this._linear){const r=this.normal(0),o=this.points[0],s=this.points[this.points.length-1];let a,l,c;void 0===n&&(n=t,i=e),a={x:o.x+r.x*t,y:o.y+r.y*t},c={x:s.x+r.x*n,y:s.y+r.y*n},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const d=[a,l,c];a={x:o.x-r.x*e,y:o.y-r.y*e},c={x:s.x-r.x*i,y:s.y-r.y*i},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const u=[c,l,a],h=T.makeline(u[2],d[0]),p=T.makeline(d[2],u[0]),f=[h,new B(d),p,new B(u)];return new S(f)}const r=this.reduce(),o=r.length,s=[];let a,l=[],c=0,d=this.length();const u=void 0!==n&&void 0!==i;function h(t,e,n,i,r){return function(o){const s=i/n,a=(i+r)/n,l=e-t;return T.map(o,0,1,t+s*l,t+a*l)}}r.forEach((function(r){const o=r.length();u?(s.push(r.scale(h(t,n,d,c,o))),l.push(r.scale(h(-e,-i,d,c,o)))):(s.push(r.scale(t)),l.push(r.scale(-e))),c+=o})),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[o-1].points[s[o-1].points.length-1],m=l[o-1].points[l[o-1].points.length-1],g=l[0].points[0],v=T.makeline(m,p),y=T.makeline(f,g),b=[v].concat(s).concat([y]).concat(l);return new S(b)}outlineshapes(t,e,n){e=e||t;const i=this.outline(t,e).curves,r=[];for(let t=1,e=i.length;t<e/2;t++){const o=T.makeshape(i[t],i[e-t],n);o.startcap.virtual=t>1,o.endcap.virtual=t<e/2-1,r.push(o)}return r}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof B&&(t=t.reduce()),this.curveintersects(this.reduce(),t,e)):this.selfintersects(e)}lineIntersects(t){const e=P(t.p1.x,t.p2.x),n=P(t.p1.y,t.p2.y),i=k(t.p1.x,t.p2.x),r=k(t.p1.y,t.p2.y);return T.roots(this.points,t).filter((t=>{var o=this.get(t);return T.between(o.x,e,i)&&T.between(o.y,n,r)}))}selfintersects(t){const e=this.reduce(),n=e.length-2,i=[];for(let r,o,s,a=0;a<n;a++)o=e.slice(a,a+1),s=e.slice(a+2),r=this.curveintersects(o,s,t),i.push(...r);return i}curveintersects(t,e,n){const i=[];t.forEach((function(t){e.forEach((function(e){t.overlaps(e)&&i.push({left:t,right:e})}))}));let r=[];return i.forEach((function(t){const e=T.pairiteration(t.left,t.right,n);e.length>0&&(r=r.concat(e))})),r}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,n,i){const r=(i-n)/4,o=this.get(n+r),s=this.get(i-r),a=T.dist(t,e),l=T.dist(t,o),c=T.dist(t,s);return C(l-a)+C(c-a)}_iterate(t,e){let n,i=0,r=1;do{n=0,r=1;let o,s,a,l,c,d=this.get(i),u=!1,h=!1,p=r,f=1,m=0;do{if(h=u,l=a,p=(i+r)/2,m++,o=this.get(p),s=this.get(r),a=T.getccenter(d,o,s),a.interval={start:i,end:r},u=this._error(a,d,i,r)<=t,c=h&&!u,c||(f=r),u){if(r>=1){if(a.interval.end=f=1,l=a,r>1){let t={x:a.x+a.r*E(a.e),y:a.y+a.r*z(a.e)};a.e+=T.angle({x:a.x,y:a.y},t,this.get(1))}break}r+=(r-i)/2}else r=p}while(!c&&n++<100);if(n>=100)break;l=l||a,e.push(l),i=f}while(r<1);return e}};e.exports=s(a)}},n={};function i(t){var r=n[t];if(void 0!==r)return r.exports;var o=n[t]={id:t,exports:{}};return e[t].call(o.exports,o,o.exports,i),o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nc=void 0;var r=i(8088);window.jsdraw=r})();
|