js-draw 0.24.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +2 -2
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/localizations/de.js +1 -1
- package/dist/cjs/localizations/es.js +1 -1
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +2 -0
- package/dist/cjs/rendering/renderers/SVGRenderer.d.ts +1 -1
- package/dist/cjs/rendering/renderers/SVGRenderer.js +4 -2
- package/dist/cjs/testing/getUniquePointerId.d.ts +4 -0
- package/dist/cjs/testing/getUniquePointerId.js +16 -0
- package/dist/cjs/testing/sendPenEvent.d.ts +1 -1
- package/dist/cjs/testing/sendPenEvent.js +4 -1
- package/dist/cjs/testing/sendTouchEvent.js +2 -9
- package/dist/cjs/toolbar/IconProvider.d.ts +1 -1
- package/dist/cjs/toolbar/IconProvider.js +76 -10
- package/dist/cjs/toolbar/localization.d.ts +2 -2
- package/dist/cjs/toolbar/localization.js +2 -2
- package/dist/cjs/toolbar/widgets/BaseToolWidget.d.ts +2 -0
- package/dist/cjs/toolbar/widgets/BaseToolWidget.js +7 -0
- package/dist/cjs/toolbar/widgets/PenToolWidget.d.ts +3 -1
- package/dist/cjs/toolbar/widgets/PenToolWidget.js +125 -41
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +4 -0
- package/dist/cjs/tools/BaseTool.d.ts +17 -1
- package/dist/cjs/tools/BaseTool.js +18 -0
- package/dist/cjs/tools/Pen.d.ts +5 -2
- package/dist/cjs/tools/Pen.js +37 -4
- package/dist/cjs/tools/ToolController.js +14 -2
- package/dist/mjs/localizations/de.mjs +1 -1
- package/dist/mjs/localizations/es.mjs +1 -1
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +2 -0
- package/dist/mjs/rendering/renderers/SVGRenderer.d.ts +1 -1
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +4 -2
- package/dist/mjs/testing/getUniquePointerId.d.ts +4 -0
- package/dist/mjs/testing/getUniquePointerId.mjs +14 -0
- package/dist/mjs/testing/sendPenEvent.d.ts +1 -1
- package/dist/mjs/testing/sendPenEvent.mjs +4 -1
- package/dist/mjs/testing/sendTouchEvent.mjs +2 -9
- package/dist/mjs/toolbar/IconProvider.d.ts +1 -1
- package/dist/mjs/toolbar/IconProvider.mjs +76 -10
- package/dist/mjs/toolbar/localization.d.ts +2 -2
- package/dist/mjs/toolbar/localization.mjs +2 -2
- package/dist/mjs/toolbar/widgets/BaseToolWidget.d.ts +2 -0
- package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +7 -0
- package/dist/mjs/toolbar/widgets/PenToolWidget.d.ts +3 -1
- package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +125 -41
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +4 -0
- package/dist/mjs/tools/BaseTool.d.ts +17 -1
- package/dist/mjs/tools/BaseTool.mjs +18 -0
- package/dist/mjs/tools/Pen.d.ts +5 -2
- package/dist/mjs/tools/Pen.mjs +37 -4
- package/dist/mjs/tools/ToolController.mjs +14 -2
- package/package.json +2 -2
- package/src/localizations/de.ts +2 -2
- package/src/localizations/es.ts +1 -1
- package/src/rendering/renderers/CanvasRenderer.ts +2 -0
- package/src/rendering/renderers/SVGRenderer.ts +6 -3
- package/src/testing/getUniquePointerId.ts +18 -0
- package/src/testing/sendPenEvent.ts +6 -1
- package/src/testing/sendTouchEvent.ts +2 -9
- package/src/toolbar/IconProvider.ts +92 -23
- package/src/toolbar/localization.ts +4 -4
- package/src/toolbar/toolbar.css +1 -0
- package/src/toolbar/widgets/BaseToolWidget.ts +10 -1
- package/src/toolbar/widgets/PenToolWidget.css +53 -0
- package/src/toolbar/widgets/PenToolWidget.ts +156 -44
- package/src/toolbar/widgets/SelectionToolWidget.ts +4 -0
- package/src/tools/BaseTool.ts +22 -1
- package/src/tools/Pen.test.ts +68 -0
- package/src/tools/Pen.ts +42 -4
- package/src/tools/ToolController.ts +17 -2
package/dist/bundle.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(()=>{var e={489:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());s.push([t.id,'.clr-picker {\n display: none;\n flex-wrap: wrap;\n position: absolute;\n width: 200px;\n z-index: 1000;\n border-radius: 10px;\n background-color: #fff;\n justify-content: flex-end;\n direction: ltr;\n box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1);\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.clr-picker.clr-open,\n.clr-picker[data-inline="true"] {\n display: flex;\n}\n\n.clr-picker[data-inline="true"] {\n position: relative;\n}\n\n.clr-gradient {\n position: relative;\n width: 100%;\n height: 100px;\n margin-bottom: 15px;\n border-radius: 3px 3px 0 0;\n background-image: linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor);\n cursor: pointer;\n}\n\n.clr-marker {\n position: absolute;\n width: 12px;\n height: 12px;\n margin: -6px 0 0 -6px;\n border: 1px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n cursor: pointer;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-runnable-track {\n width: 100%;\n height: 8px;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-thumb {\n width: 8px;\n height: 8px;\n -webkit-appearance: none;\n}\n\n.clr-picker input[type="range"]::-moz-range-track {\n width: 100%;\n height: 8px;\n border: 0;\n}\n\n.clr-picker input[type="range"]::-moz-range-thumb {\n width: 8px;\n height: 8px;\n border: 0;\n}\n\n.clr-hue {\n background-image: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);\n}\n\n.clr-hue,\n.clr-alpha {\n position: relative;\n width: calc(100% - 40px);\n height: 8px;\n margin: 5px 20px;\n border-radius: 4px;\n}\n\n.clr-alpha span {\n display: block;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n background-image: linear-gradient(90deg, rgba(0,0,0,0), currentColor);\n}\n\n.clr-hue input,\n.clr-alpha input {\n position: absolute;\n width: calc(100% + 16px);\n height: 16px;\n left: -8px;\n top: -4px;\n margin: 0;\n background-color: transparent;\n opacity: 0;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n\n.clr-hue div,\n.clr-alpha div {\n position: absolute;\n width: 16px;\n height: 16px;\n left: 0;\n top: 50%;\n margin-left: -8px;\n transform: translateY(-50%);\n border: 2px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n box-shadow: 0 0 1px #888;\n pointer-events: none;\n}\n\n.clr-alpha div:before {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border-radius: 50%;\n background-color: currentColor;\n}\n\n.clr-format {\n display: none;\n order: 1;\n width: calc(100% - 40px);\n margin: 0 20px 20px;\n}\n\n.clr-segmented {\n display: flex;\n position: relative;\n width: 100%;\n margin: 0;\n padding: 0;\n border: 1px solid #ddd;\n border-radius: 15px;\n box-sizing: border-box;\n color: #999;\n font-size: 12px;\n}\n\n.clr-segmented input,\n.clr-segmented legend {\n position: absolute;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n left: 0;\n top: 0;\n opacity: 0;\n pointer-events: none;\n}\n\n.clr-segmented label {\n flex-grow: 1;\n margin: 0;\n padding: 4px 0;\n font-size: inherit;\n font-weight: normal;\n line-height: initial;\n text-align: center;\n cursor: pointer;\n}\n\n.clr-segmented label:first-of-type {\n border-radius: 10px 0 0 10px;\n}\n\n.clr-segmented label:last-of-type {\n border-radius: 0 10px 10px 0;\n}\n\n.clr-segmented input:checked + label {\n color: #fff;\n background-color: #666;\n}\n\n.clr-swatches {\n order: 2;\n width: calc(100% - 32px);\n margin: 0 16px;\n}\n\n.clr-swatches div {\n display: flex;\n flex-wrap: wrap;\n padding-bottom: 12px;\n justify-content: center;\n}\n\n.clr-swatches button {\n position: relative;\n width: 20px;\n height: 20px;\n margin: 0 4px 6px 4px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n cursor: pointer;\n}\n\n.clr-swatches button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\ninput.clr-color {\n order: 1;\n width: calc(100% - 80px);\n height: 32px;\n margin: 15px 20px 20px auto;\n padding: 0 10px;\n border: 1px solid #ddd;\n border-radius: 16px;\n color: #444;\n background-color: #fff;\n font-family: sans-serif;\n font-size: 14px;\n text-align: center;\n box-shadow: none;\n}\n\ninput.clr-color:focus {\n outline: none;\n border: 1px solid #1e90ff;\n}\n\n.clr-close,\n.clr-clear {\n display: none;\n order: 2;\n height: 24px;\n margin: 0 20px 20px;\n padding: 0 20px;\n border: 0;\n border-radius: 12px;\n color: #fff;\n background-color: #666;\n font-family: inherit;\n font-size: 12px;\n font-weight: 400;\n cursor: pointer;\n}\n\n.clr-close {\n display: block;\n margin: 0 20px 20px auto;\n}\n\n.clr-preview {\n position: relative;\n width: 32px;\n height: 32px;\n margin: 15px 0 20px 20px;\n border-radius: 50%;\n overflow: hidden;\n}\n\n.clr-preview:before,\n.clr-preview:after {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border: 1px solid #fff;\n border-radius: 50%;\n}\n\n.clr-preview:after {\n border: 0;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\n.clr-preview button {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 1;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 50%;\n outline-offset: -2px;\n background-color: transparent;\n text-indent: -9999px;\n cursor: pointer;\n overflow: hidden;\n}\n\n.clr-marker,\n.clr-hue div,\n.clr-alpha div,\n.clr-color {\n box-sizing: border-box;\n}\n\n.clr-field {\n display: inline-block;\n position: relative;\n color: transparent;\n}\n\n.clr-field input {\n margin: 0;\n direction: ltr;\n}\n\n.clr-field.clr-rtl input {\n text-align: right;\n}\n\n.clr-field button {\n position: absolute;\n width: 30px;\n height: 100%;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n margin: 0;\n padding: 0;\n border: 0;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n pointer-events: none;\n}\n\n.clr-field.clr-rtl button {\n right: auto;\n left: 0;\n}\n\n.clr-field button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 1px rgba(0,0,0,.5);\n}\n\n.clr-alpha,\n.clr-alpha div,\n.clr-swatches button,\n.clr-preview:before,\n.clr-field button {\n background-image: repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa), repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position: 0 0, 4px 4px;\n background-size: 8px 8px;\n}\n\n.clr-marker:focus {\n outline: none;\n}\n\n.clr-keyboard-nav .clr-marker:focus,\n.clr-keyboard-nav .clr-hue input:focus + div,\n.clr-keyboard-nav .clr-alpha input:focus + div,\n.clr-keyboard-nav .clr-segmented input:focus + label {\n outline: none;\n box-shadow: 0 0 0 2px #1e90ff, 0 0 2px 2px #fff;\n}\n\n.clr-picker[data-alpha="false"] .clr-alpha {\n display: none;\n}\n\n.clr-picker[data-minimal="true"] {\n padding-top: 16px;\n}\n\n.clr-picker[data-minimal="true"] .clr-gradient,\n.clr-picker[data-minimal="true"] .clr-hue,\n.clr-picker[data-minimal="true"] .clr-alpha,\n.clr-picker[data-minimal="true"] .clr-color,\n.clr-picker[data-minimal="true"] .clr-preview {\n display: none;\n}\n\n/** Dark theme **/\n\n.clr-dark {\n background-color: #444;\n}\n\n.clr-dark .clr-segmented {\n border-color: #777;\n}\n\n.clr-dark .clr-swatches button:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);\n}\n\n.clr-dark input.clr-color {\n color: #fff;\n border-color: #777;\n background-color: #555;\n}\n\n.clr-dark input.clr-color:focus {\n border-color: #1e90ff;\n}\n\n.clr-dark .clr-preview:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);\n}\n\n.clr-dark .clr-alpha,\n.clr-dark .clr-alpha div,\n.clr-dark .clr-swatches button,\n.clr-dark .clr-preview:before {\n background-image: repeating-linear-gradient(45deg, #666 25%, transparent 25%, transparent 75%, #888 75%, #888), repeating-linear-gradient(45deg, #888 25%, #444 25%, #444 75%, #888 75%, #888);\n}\n\n/** Polaroid theme **/\n\n.clr-picker.clr-polaroid {\n border-radius: 6px;\n box-shadow: 0 0 5px rgba(0,0,0,.1), 0 5px 30px rgba(0,0,0,.2);\n}\n\n.clr-picker.clr-polaroid:before {\n content: \'\';\n display: block;\n position: absolute;\n width: 16px;\n height: 10px;\n left: 20px;\n top: -10px;\n border: solid transparent;\n border-width: 0 8px 10px 8px;\n border-bottom-color: currentColor;\n box-sizing: border-box;\n color: #fff;\n filter: drop-shadow(0 -4px 3px rgba(0,0,0,.1));\n pointer-events: none;\n}\n\n.clr-picker.clr-polaroid.clr-dark:before {\n color: #444;\n}\n\n.clr-picker.clr-polaroid.clr-left:before {\n left: auto;\n right: 20px;\n}\n\n.clr-picker.clr-polaroid.clr-top:before {\n top: auto;\n bottom: -10px;\n transform: rotateZ(180deg);\n}\n\n.clr-polaroid .clr-gradient {\n width: calc(100% - 20px);\n height: 120px;\n margin: 10px;\n border-radius: 3px;\n}\n\n.clr-polaroid .clr-hue,\n.clr-polaroid .clr-alpha {\n width: calc(100% - 30px);\n height: 10px;\n margin: 6px 15px;\n border-radius: 5px;\n}\n\n.clr-polaroid .clr-hue div,\n.clr-polaroid .clr-alpha div {\n box-shadow: 0 0 5px rgba(0,0,0,.2);\n}\n\n.clr-polaroid .clr-format {\n width: calc(100% - 20px);\n margin: 0 10px 15px;\n}\n\n.clr-polaroid .clr-swatches {\n width: calc(100% - 12px);\n margin: 0 6px;\n}\n.clr-polaroid .clr-swatches div {\n padding-bottom: 10px;\n}\n\n.clr-polaroid .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n.clr-polaroid input.clr-color {\n width: calc(100% - 60px);\n margin: 10px 10px 15px auto;\n}\n\n.clr-polaroid .clr-clear {\n margin: 0 10px 15px 10px;\n}\n\n.clr-polaroid .clr-close {\n margin: 0 10px 15px auto;\n}\n\n.clr-polaroid .clr-preview {\n margin: 10px 0 15px 10px;\n}\n\n/** Large theme **/\n\n.clr-picker.clr-large {\n width: 275px;\n}\n\n.clr-large .clr-gradient {\n height: 150px;\n}\n\n.clr-large .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n/** Pill (horizontal) theme **/\n\n.clr-picker.clr-pill {\n width: 380px;\n padding-left: 180px;\n box-sizing: border-box;\n}\n\n.clr-pill .clr-gradient {\n position: absolute;\n width: 180px;\n height: 100%;\n left: 0;\n top: 0;\n margin-bottom: 0;\n border-radius: 3px 0 0 3px;\n}\n\n.clr-pill .clr-hue {\n margin-top: 20px;\n}',""]);const a=s},8309:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},6860:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r),a=n(8345),l=n(4883),c=n(8309),d=s()(o());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},8345:(t,e,n)=>{"use strict";n.d(e,{Z:()=>d});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r),a=n(6875),l=n(5701),c=s()(o());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\tuser-select: none;\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\tuser-select: none;\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)\n\t\t> .toolbar-dropdown:not(.hiding) {\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/* Animate showing/hiding the dropdown. Animations triggered in JavaScript. */\n@keyframes dropdown-transition-in {\n\t0% {\n\t\topacity: 0;\n\t\ttransform: scale(1, 0);\n\t}\n\t100% {\n\t\topacity: 1;\n\t\ttransform: scale(1, 1);\n\t}\n}\n\n@keyframes dropdown-transition-out {\n\t0% {\n\t\topacity: 1;\n\t\ttransform: scale(1, 1);\t\n\t}\n\t100% {\n\t\topacity: 0;\n\t\ttransform: scale(1, 0);\n\t}\n}\n\n.toolbar-dropdown {\n\t/* Ensure the animation begins from the correct location. */\n\ttransform-origin: top left;\n\n\t--dropdown-show-animation: dropdown-transition-in;\n\t--dropdown-hide-animation: dropdown-transition-out;\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t/* Disable toolbar animations if reducing motion */\n\t.toolbar-dropdown {\n\t\t--dropdown-show-animation: none;\n\t\t--dropdown-hide-animation: none;\n\t}\n\n\t.toolbar-dropdown.hiding {\n\t\tdisplay: none;\n\t}\n\n\t/* Also disable arrow rotation */\n\t.toolbar-toolContainer > .toolbar-button > .toolbar-showHideDropdownIcon {\n\t\ttransition: none;\n\t}\n\n\t/* ...and background color animation. */\n\t.toolbar-button, .toolbar-root button {\n\t\ttransition: none;\n\t}\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},6875:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},5701:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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/*\n\t Override the default transform and margin-left.\n\n\t Setting translate to none prevents the dropdown from being shifted off the\n\t screen on window resize by dropdown-repositioning logic.\n\t*/\n\tmargin-left: 0 !important;\n\ttranslate: none !important;\n\n\tpadding: 4px;\n}",""]);const a=s},1914:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},3690:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},6609:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},4883:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r),a=n(3690),l=n(1914),c=n(6609),d=s()(o());d.i(a.Z),d.i(l.Z),d.i(c.Z),d.push([t.id,"",""]);const u=d},2609: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,o,r){"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!==r&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),e.push(d))}},e}},9601:t=>{"use strict";t.exports=function(t){return t[1]}},6062:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],d=r[c]||0,u="".concat(c," ").concat(d);r[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=o(p,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:f,references:1})}s.push(u)}return s}function o(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,o){var r=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=i(t,o),c=0;c<r.length;c++){var d=n(r[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}r=l}}},6793:t=>{"use strict";var e={};t.exports=function(t,n){var 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)}},1173:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},7892:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},4036:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},2464:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},3472: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 o=i(n(1486));class r{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 r.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 r(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 r.ofRGBA(n[0],n[1],n[2],n[3])}static fromString(t){if(t.startsWith("#"))return r.fromHex(t);if("none"===t||"transparent"===t)return r.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 r.ofRGB(i[0]/255,i[1]/255,i[2]/255);if(4===i.length)return r.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 o=i.getImageData(0,0,1,1),s=o.data[0]/255,a=o.data[1]/255,l=o.data[2]/255,c=o.data[3]/255;return r.ofRGBA(s,a,l,c)}eq(t){return null!=t&&(0===this.a&&0===t.a||this.toHexString()===t.toHexString())}mix(t,e){const n=1-(e=Math.min(Math.max(e,0),1));return new r(this.r*n+t.r*e,this.g*n+t.g*e,this.b*n+t.b*e,this.a*n+t.a*e)}static average(t){let e=0,n=0,i=0,o=0;for(const r of t)e+=r.a,n+=r.r,i+=r.g,o+=r.b;return t.length>0&&(e/=t.length,n/=t.length,i/=t.length,o/=t.length),new r(n,i,o,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 r=e,s=r>0?n/r:0;return o.default.of(i,s,r)}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),o=t(this.b);return"ff"===e?`#${n}${i}${o}`:(this.hexString=`#${n}${i}${o}${e}`,this.hexString)}toString(){return this.toHexString()}}e.Color4=r,r.transparent=r.ofRGBA(0,0,0,0),r.red=r.ofRGB(1,0,0),r.green=r.ofRGB(0,1,0),r.blue=r.ofRGB(0,0,1),r.purple=r.ofRGB(.5,.2,.5),r.yellow=r.ofRGB(1,1,.1),r.clay=r.ofRGB(.8,.4,.2),r.black=r.ofRGB(0,0,0),r.gray=r.ofRGB(.5,.5,.5),r.white=r.ofRGB(1,1,1),e.default=r},5146:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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(7551)),c=a(n(8169)),d=n(3173),u=a(n(5155)),h=a(n(5566)),p=a(n(1785)),f=n(5378),m=a(n(1486)),g=a(n(3808)),v=r(n(3012)),y=a(n(2001)),b=a(n(3472)),x=a(n(1697)),w=a(n(4318)),S=a(n(8015)),T=a(n(1906)),C=a(n(8282)),P=n(9036),k=a(n(7717)),E=a(n(7395)),z=a(n(9070)),_=a(n(1456)),O=a(n(7591)),M=a(n(9721)),I=r(n(1847)),B=a(n(1380)),L=a(n(5376));class R{constructor(t,e={}){var n,i,o,r,s,a;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,T.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!==(o=e.minZoom)&&void 0!==o?o:2e-10,maxZoom:null!==(r=e.maxZoom)&&void 0!==r?r:1e12,keyboardShortcutOverrides:null!==(s=e.keyboardShortcutOverrides)&&void 0!==s?s:{},iconProvider:null!==(a=e.iconProvider)&&void 0!==a?a:new C.default},this.icons=this.settings.iconProvider,this.shortcuts=new L.default(this.settings.keyboardShortcutOverrides),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=S.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,o;const r=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,r);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!==(o=null===(i=this.pointers[e.pointerId])||void 0===i?void 0:i.down)&&void 0!==o&&o,this.viewport,r);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,r);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 o=null!==(n=t.dataTransfer)&&void 0!==n?n:t.clipboardData;if(!o)return;for(const e of o.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 o.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 o=yield(0,z.default)(e,i);if(o&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:n,data:o}))return t.preventDefault(),void this.hideLoadingWarning()}catch(t){console.error("Error reading image:",t)}this.hideLoadingWarning()}}const r=["image/svg+xml","text/plain"];for(const e of r){const n=o.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 o=i;o<t.length&&o<i+n;o++){const n=t[o];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,B.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,o=i.width/n.width,r=i.height/n.height;let s=o;(n.width*s>i.width||n.height*s>i.height)&&(s=r),s*=2/3,s=h.default.roundScaleRatio(s);const a=S.default.translation(i.center.minus(n.center)).rightMul(S.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",e){const n=document.createElement("canvas"),i=this.image.getImportExportViewport(),o=i.getScreenRectSize(),r=null!=e?e:o;n.width=r.x,n.height=r.y;const s=n.getContext("2d"),a=Math.min(r.x/o.x,r.y/o.y);s.scale(a,a);const l=new k.default(s,i);this.image.renderAll(l);return n.toDataURL(t)}toSVG(){const t=this.image.getImportExportViewport().getTemporaryClone(),{element:e,renderer:n}=y.default.fromViewport(t,!1),i=t.canvasToScreenTransform;t.resetTransform(S.default.identity),this.image.renderAll(n),t.resetTransform(i);const o=t.visibleRect;return e.setAttribute("viewBox",[o.x,o.y,o.w,o.h].map((t=>(0,P.toRoundedString)(t))).join(" ")),e.setAttribute("width",(0,P.toRoundedString)(o.w)),e.setAttribute("height",(0,P.toRoundedString)(o.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 I.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)?I.BackgroundType.None:I.BackgroundType.SolidColor;return e=new I.default(n,t),this.image.addElement(e)}}estimateBackgroundColor(){var t;const e=[];for(const n of this.image.getBackgroundComponents())n instanceof I.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},7551:function(t,e,n){"use strict";var i,o,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})},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(5566)),l=s(n(2655)),c=s(n(8947)),d=s(n(6669)),u=s(n(1785)),h=n(5378),p=s(n(8015)),f=n(6585);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=m={}));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=(r(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),o=null!=i?i:l.default.deserialize(t.elemData),r=new g.AddElementCommand(o);return r.serializedElem=t.elemData,r})),i),g.SetImportExportRectCommand=(r(o=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"),o.commandId="set-import-export-rect",(()=>{const t=o.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),o=new c.default(t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h);return new g.SetImportExportRectCommand(n,i,o)}))})(),o),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 o=[];o.push(this);const r=()=>{i=void 0;const r=o.pop();r&&!(null==e?void 0:e(r.bbox))&&(i=r,null!==i.content&&i.getBBox().intersection(t)&&n.push(i),o.push(...i.getChildrenIntersectingRegion(t)))};for(;o.length>0;)r();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)}}e.ImageNode=v,v.idCounter=0},1785:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.listeners={}}dispatch(t,e){const n=this.listeners[t];if(n)for(let t=0;t<n.length;t++)n[t](e)}on(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),{remove:()=>{const n=this.listeners[t];return this.off(t,e),n.length!==this.listeners[t].length}}}off(t,e){const n=this.listeners[t];n&&(this.listeners[t]=n.filter((t=>t!==e)))}}},4318:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointerDevice=void 0;const i=n(5378);var o;!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"}(o||(e.PointerDevice=o={}));class r{constructor(t,e,n,i,o,r,s,a){this.screenPos=t,this.canvasPos=e,this.pressure=n,this.isPrimary=i,this.down=o,this.device=r,this.id=s,this.timeStamp=a}snappedToGrid(t){const e=t.snapToGrid(this.canvasPos);return this.withCanvasPosition(e,t)}lockedToXYAxesScreen(t,e){const n=this.screenPos.minus(t),o=i.Vec2.unitX.times(n.x),r=i.Vec2.unitY.times(n.y);let s;return s=n.dot(o)>n.dot(r)?o:r,s=s.plus(t),this.withScreenPosition(s,e)}withScreenPosition(t,e){const n=e.screenToCanvas(t);return this.withCanvasPosition(n,e)}withCanvasPosition(t,e){const n=e.canvasToScreen(t);return new r(n,t,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(t,e,n,s){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:o.PrimaryButtonMouse,pen:o.Pen,touch:o.Touch}[t.pointerType])&&void 0!==a?a:o.Other;d===o.Pen&&0!=(32&t.buttons)&&(d=o.Eraser);const u=(new Date).getTime(),h=n.roundPoint(n.screenToCanvas(c));return d===o.PrimaryButtonMouse&&(2&t.buttons?d=o.RightButtonMouse:1&t.buttons||(d=o.Other)),new r(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=o.Pen,a=!0,l=null){const c=n.canvasToScreen(t),d=(new Date).getTime();return new r(c,t,l,a,e,s,i,d)}}e.default=r},1697:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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(3472)),c=r(n(1847)),d=a(n(7077)),u=a(n(9964)),h=a(n(2413)),p=r(n(1151)),f=a(n(9025)),m=a(n(8015)),g=a(n(2487)),v=a(n(8947)),y=n(5378);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,o,r,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!==(r=null!==(o=t.getAttribute("stroke"))&&void 0!==o?o:null==e?void 0:e.stroke)&&void 0!==r?r: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:"",o=this.getStyle(t),r=i.split("M");let s=!0;for(const t of r){const e=/^[0-9., \t\n]+$/.exec(t);if(""!==t&&!e){const e=s?t:`M${t}`,i=g.default.fromString(e).toRenderable(o);n.push(i)}s=!1}return n}attachUnrecognisedAttrs(t,n,i,o){if(this.storeUnknown){for(const r of n.getAttributeNames())i.has(r)||"style"===r&&o||t.attachLoadSaveData(e.svgAttributesDataKey,[r,n.getAttribute(r)]);if(o&&n.style)for(const i of n.style)""!==i&&i&&(o.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,o;return s(this,void 0,void 0,(function*(){if(t.classList.contains(c.backgroundTypeToClassNameMap[c.BackgroundType.Grid])){let n,i,o,r,s;if("g"===t.tagName.toLowerCase()){if(2!==t.children.length)return void(yield this.addUnknownNode(t));const e=t.children[0],r=t.children[1];i=e.getAttribute("fill"),n=r.getAttribute("stroke"),o=r.getAttribute("stroke-width")}else i=t.getAttribute("fill"),n=t.getAttribute("stroke"),o=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);r=parseFloat(t.replace(/p/g,"."))}o&&(s=parseFloat(o));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,r,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"),r=new c.default(c.BackgroundType.SolidColor,e);yield null===(o=this.onAddComponent)||void 0===o?void 0:o.call(this,r)}else yield this.addUnknownNode(t)}))}getTransform(t,e,n){null!=n||(n=window.getComputedStyle(t));let i,o=n.transform;""!==o&&"none"!==o||(o=t.style.transform||"none");try{i=m.default.fromCSSMatrix(t.style.transform)}catch(t){i=m.default.fromCSSMatrix(o)}const r=t.getAttribute("x"),s=t.getAttribute("y");if(r||s){const t=parseFloat(null!=r?r:"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),o=/^([-0-9.e]+)px/i;let r=o.exec(t.style.fontSize);!r&&"tspan"===t.tagName.toLowerCase()&&t.parentElement&&(r=o.exec(t.parentElement.style.fontSize)),r||(r=o.exec(i.fontSize));const s=["fontFamily","transform",...b];let a=12;r&&(s.push("fontSize"),a=parseFloat(r[1]));const l={size:a,fontFamily:i.fontFamily||t.style.fontFamily||"sans-serif",fontWeight:i.fontWeight||t.style.fontWeight||void 0,fontStyle:i.fontStyle||t.style.fontStyle||void 0,renderingStyle:this.getStyle(t,i)},c=[];let d=this.getTransform(t,c,i),u=p.TextTransformMode.ABSOLUTE_XY;const h=t.getAttribute("dx");h&&(u=p.TextTransformMode.RELATIVE_X_ABSOLUTE_Y,d=d.rightMul(m.default.translation(y.Vec2.of(parseFloat(h),0))),c.push("dx"));const f=t.getAttribute("dy");f&&(u=u===p.TextTransformMode.RELATIVE_X_ABSOLUTE_Y?p.TextTransformMode.RELATIVE_XY:p.TextTransformMode.RELATIVE_Y_ABSOLUTE_X,d=d.rightMul(m.default.translation(y.Vec2.of(0,parseFloat(f)))),c.push("dy"));const g=new p.default(n,d,l,u);return this.attachUnrecognisedAttrs(g,t,new Set(c),new Set(s)),g}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 o=new Image;o.src=null!==(e=t.getAttribute("xlink:href"))&&void 0!==e?e:t.href.baseVal,o.setAttribute("alt",null!==(n=t.getAttribute("aria-label"))&&void 0!==n?n:"");try{const e=[],n=this.getTransform(t,e),r=yield d.default.fromImage(o,n);this.attachUnrecognisedAttrs(r,t,new Set(e),new Set(["transform"])),yield null===(i=this.onAddComponent)||void 0===i?void 0:i.call(this,r)}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,]+/),o=parseFloat(i[0]),r=parseFloat(i[1]),s=parseFloat(i[2]),a=parseFloat(i[3]);isNaN(o)||isNaN(r)||isNaN(s)||isNaN(a)?console.warn(`node ${t} has an unparsable viewbox. Viewbox: ${n}. Match: ${i}.`):(this.rootViewBox=new v.default(o,r,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 o,r;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===(o=this.onDetermineExportRect)||void 0===o||o.call(this,e.defaultSVGViewRect),null===(r=this.onFinish)||void 0===r||r.call(this)}))}static fromString(t,e=!1){var n,i;const o=document.createElement("iframe");if(o.src="about:blank",o.setAttribute("sandbox","allow-same-origin"),o.setAttribute("csp","default-src 'about:blank'"),o.style.display="none",document.body.appendChild(o),!o.hasAttribute("sandbox"))throw o.remove(),new Error("SVG loading iframe is not sandboxed.");const r=null!==(i=null===(n=o.contentWindow)||void 0===n?void 0:n.document)&&void 0!==i?i:o.contentDocument;if(null==r)throw new Error("Unable to open a sandboxed iframe!");r.open(),r.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"),r.close();const s=r.createElementNS("http://www.w3.org/2000/svg","svg");return s.innerHTML=t,r.body.appendChild(s),new x(s,(()=>{s.remove(),o.remove()}),!e)}}e.default=x},5155:function(t,e,n){"use strict";var i,o,r=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.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(3173);i=new WeakMap,o=new WeakMap,e.default=class{constructor(t,e,n){this.editor=t,this.announceRedoCallback=e,this.announceUndoCallback=n,i.set(this,void 0),o.set(this,void 0),this.maxUndoRedoStackSize=700,r(this,i,[],"f"),r(this,o,[],"f")}fireUpdateEvent(t,e){this.editor.notifier.dispatch(a.EditorEventType.UndoRedoStackUpdated,{kind:a.EditorEventType.UndoRedoStackUpdated,undoStackSize:s(this,i,"f").length,redoStackSize:s(this,o,"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,o,"f"))t.onDrop(this.editor);if(r(this,o,[],"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,o,"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,o,"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,o,"f").length}}},5566:function(t,e,n){"use strict";var i,o,r=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.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(2216)),c=a(n(8015)),d=a(n(8947)),u=n(5378),h=a(n(1486));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 o=()=>{const t=this.visibleRect.transformedBoundingBox(i.inverse());return t.transformedBoundingBox(c.default.scaling2D(.8,t.center))};let r=o();const s=r.w<t.w||r.h<t.h,a=t.maxDimension/r.maxDimension<1/3;if(s&&n||a&&e){const e=Math.max(t.w/r.w,t.h/r.h),n=c.default.scaling2D(e,r.topLeft).inverse();i=i.rightMul(n)}if(r=o(),!r.containsRect(t)){const e=t.center.minus(r.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=(o=class extends p{constructor(t){super(),this.transform=t,i.set(this,void 0),r(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,o=this.transform.transformVec3(u.Vec2.unitX),r=this.transform.transformVec2(i),s=o.magnitude(),a=180/Math.PI*o.angle(),l=r.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,o),e.default=f},7783:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),n(458);const s=r(n(5146));o(n(6209),e),e.default=s.default},2216:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Command=void 0;class n{onDrop(t){}static union(t,e){return new class extends n{apply(n){t.apply(n),e.apply(n)}unapply(n){e.unapply(n),t.unapply(n)}description(n,i){const o=t.description(n,i),r=e.description(n,i);return o===r?o:`${o}, ${r}`}}}}e.Command=n,n.empty=new class extends n{description(t,e){return""}apply(t){}unapply(t){}},e.default=n},1365:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(2944)),r=i(n(9721)),s=i(n(6669));class a extends s.default{constructor(t){super("duplicate"),this.toDuplicate=t,this.duplicates=t.map((t=>t.clone())),this.reverse=new r.default(this.duplicates)}apply(t){this.reverse.unapply(t)}unapply(t){this.reverse.apply(t)}onDrop(t){this.reverse.onDrop(t)}description(t,e){var n;return 0===this.duplicates.length?e.duplicatedNoElements:e.duplicateAction(null!==(n=(0,o.default)(e,this.duplicates))&&void 0!==n?n:e.elements,this.duplicates.length)}serializeToJSON(){return this.toDuplicate.map((t=>t.getId()))}}s.default.register("duplicate",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t)));return new a(n)})),e.default=a},9721:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(2944)),r=i(n(7551)),s=i(n(6669));class a extends s.default{constructor(t){super("erase"),this.toRemove=t.map((t=>t)),this.applied=!1}apply(t){for(const e of this.toRemove){const n=t.image.findParent(e);n&&n.remove()}this.applied=!0,t.queueRerender()}unapply(t){for(const e of this.toRemove)t.image.findParent(e)||r.default.addElement(e).apply(t);this.applied=!1,t.queueRerender()}onDrop(t){if(this.applied)for(const e of this.toRemove)t.image.onDestroyElement(e)}description(t,e){var n;if(0===this.toRemove.length)return e.erasedNoElements;const i=null!==(n=(0,o.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()))}}s.default.register("erase",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t))).filter((t=>null!==t));return new a(n)})),e.default=a},6669:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(2216));class r extends o.default{constructor(t){if(super(),this.commandTypeId=t,!(t in r.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 r.deserializationCallbacks))throw new Error(`Unrecognised command type ${i}!`);return r.deserializationCallbacks[i](n.data,e)}static register(t,e){r.deserializationCallbacks[t]=e}}r.deserializationCallbacks={},e.default=r},8859: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 o=i(n(6669));class r extends o.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=r},2242: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 o=i(n(2216)),r=i(n(6669)),s=t=>{if(t instanceof r.default)return new class extends r.default{serializeToJSON(){return t.serialize()}apply(e){t.unapply(e)}unapply(e){t.unapply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}("inverse");return new class extends o.default{apply(e){t.unapply(e)}unapply(e){t.apply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}};r.default.register("inverse",((t,e)=>s(r.default.deserialize(t,e)))),e.default=s},7601:function(t,e,n){"use strict";var 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 o=i(n(2216));e.Command=o.default;const r=i(n(1365));e.Duplicate=r.default;const s=i(n(9721));e.Erase=s.default;const a=i(n(2242));e.invertCommand=a.default;const l=i(n(6669));e.SerializableCommand=l.default;const c=i(n(1456));e.uniteCommands=c.default},6985:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultCommandLocalization=void 0,e.defaultCommandLocalization={updatedViewport:"Transformed Viewport",transformedElements:t=>`Transformed ${t} element${1===t?"":"s"}`,resizeOutputCommand:t=>`Resized image to ${t.w}x${t.h}`,addElementAction:t=>`Added ${t}`,eraseAction:(t,e)=>`Erased ${e} ${t}`,duplicateAction:(t,e)=>`Duplicated ${e} ${t}`,unionOf:(t,e)=>`Union: ${e} ${t}`,inverseOf:t=>`Inverse of ${t}`,elements:"Elements",erasedNoElements:"Erased nothing",duplicatedNoElements:"Duplicated nothing",rotatedBy:t=>`Rotated by ${Math.abs(t)} degrees ${t<0?"clockwise":"counter-clockwise"}`,movedLeft:"Moved left",movedUp:"Moved up",movedDown:"Moved down",movedRight:"Moved right",zoomedOut:"Zoomed out",zoomedIn:"Zoomed in",selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`}},1456:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(7129)),r=i(n(2216)),s=i(n(6669));class a extends r.default{constructor(t,e){super(),this.commands=t,this.applyChunkSize=e}apply(t){if(void 0===this.applyChunkSize){const e=this.commands.map((e=>e.apply(t)));return(0,o.default)(e)}return t.asyncApplyCommands(this.commands,this.applyChunkSize)}unapply(t){const e=[...this.commands];if(e.reverse(),void 0===this.applyChunkSize){const n=e.map((e=>e.unapply(t)));return(0,o.default)(n)}return t.asyncUnapplyCommands(e,this.applyChunkSize,!1)}onDrop(t){this.commands.forEach((e=>e.onDrop(t)))}description(t,e){const n=[];let i=null,o=0;for(const r of this.commands){const s=r.description(t,e);s!==i&&null!==i&&(n.push(e.unionOf(i,o)),i=null,o=0),o++,null!=i||(i=s)}return o>1?n.push(e.unionOf(i,o)):1===o&&n.push(i),n.join(", ")}}class l extends s.default{constructor(t,e){super("union"),this.commands=t,this.applyChunkSize=e,this.nonserializableCommand=new a(t,e)}serializeToJSON(){return this.serializedData?this.serializedData:{applyChunkSize:this.applyChunkSize,data:this.commands.map((t=>t.serialize()))}}apply(t){return this.serializedData=this.serializeToJSON(),this.nonserializableCommand.apply(t)}unapply(t){return this.nonserializableCommand.unapply(t)}onDrop(t){this.nonserializableCommand.onDrop(t)}description(t,e){return this.nonserializableCommand.description(t,e)}}const c=(t,e)=>{let n=!0;for(const e of t)if(!(e instanceof s.default)){n=!1;break}if(n){return new l(t,e)}return new a(t,e)};s.default.register("union",((t,e)=>{if("number"!=typeof t.data.length)throw new Error("Unions of commands must serialize to lists of serialization data.");const n=t.applyChunkSize;if("number"!=typeof n&&void 0!==n)throw new Error("serialized applyChunkSize is neither undefined nor a number.");const i=[];for(const n of t.data)i.push(s.default.deserialize(n,e));return c(i,n)})),e.default=c},2655:function(t,e,n){"use strict";var i,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})},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=r(n(6669)),a=r(n(7551)),l=r(n(8015)),c=r(n(8859));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=(o(i=class extends c.default{constructor(t,e,n,i,o){super(d.transformElementCommandId,e,n),this.affineTransfm=t,this.origZIndex=o,this.targetZIndex=null!=i?i:d.zIndexCounter++,this.targetZIndex>=d.zIndexCounter&&(d.zIndexCounter=this.targetZIndex+1),n&&void 0===o&&(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 o=null!==(n=e.image.lookupElement(t.id))&&void 0!==n?n:void 0,r=new l.default(...t.transfm),s=t.targetZIndex,a=null!==(i=t.origZIndex)&&void 0!==i?i:void 0;return new d.TransformElementCommand(r,t.id,o,s,a)})),i),e.default=d},1847:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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(3472)),l=n(7551),c=s(n(8947)),d=s(n(2655)),u=n(739),h=r(n(2487)),p=n(5378),f=s(n(5566)),m=n(9036);var g;!function(t){t[t.SolidColor=0]="SolidColor",t[t.Grid=1]="Grid",t[t.None=2]="None"}(g||(e.BackgroundType=g={})),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 o=new v(g.Grid,t);return void 0!==e&&(o.gridSize=e),void 0!==n&&(o.secondaryColor=n),void 0!==i&&(o.gridStrokeWidth=i),o}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,o=t=>Math.floor(t/this.gridSize)*this.gridSize,r=t=>Math.ceil(t/this.gridSize)*this.gridSize,s=r(i.y),a=o(i.y+i.h),l=r(i.x),c=o(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;const i=this.backgroundType===g.Grid;if(t.startObject(this.contentBBox,i),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 o=e.backgroundTypeToClassNameMap[this.backgroundType],r=[e.imageBackgroundCSSClassName];if(o!==e.imageBackgroundCSSClassName){r.push(o);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){if(this.backgroundType===g.SolidColor)return t.filledBackgroundWithColor(this.mainColor.toString());if(this.backgroundType===g.None)return t.emptyBackground;if(this.backgroundType===g.Grid)return t.gridBackground;return this.backgroundType}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 o=t.backgroundType;if(o!==g.None&&o!==g.Grid&&o!==g.SolidColor){return o}i=o;const r=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,r);return d.secondaryColor=s,l&&(d.gridSize=l),c&&(d.gridStrokeWidth=c),d}}e.default=v,d.default.registerComponent("image-background",v.deserializeFromJSON)},7077:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(8015)),s=o(n(8947)),a=n(6585),l=o(n(2655));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,o,r;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!==(o=t.getAttribute("alt"))&&void 0!==o?o:""),a.setAttribute("aria-label",null!==(r=t.getAttribute("aria-label"))&&void 0!==r?r:""),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 r.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)},739: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 o=i(n(3472)),r=i(n(6669)),s=i(n(8859)),a=n(2788),l=t=>{const e={};return t.color&&(e.color=t.color.toHexString()),t.textStyle&&(e.textStyle=(0,a.textStyleToJSON)(t.textStyle)),e},c=t=>({color:t.color?o.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)}}}r.default.register(d,((t,e)=>{const n=c(t.originalStyle),i=c(t.newStyle),o=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,o)}))},2413: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 o=i(n(8947)),r=i(n(2001)),s=i(n(2655)),a="svg-global-attributes";class l extends s.default{constructor(t){super(a),this.attrs=t,this.contentBBox=o.default.empty}render(t,e){if(t instanceof r.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,o]of e)"viewBox"!==t&&"width"!==t&&"height"!==t||o&&i.exec(o)&&n.push([t,o]);return new l(n)}}e.default=l,s.default.registerComponent(a,l.deserializeFromString)},9964: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 o=i(n(2487)),r=i(n(8947)),s=n(2500),a=i(n(2655)),l=n(739);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=o.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=r.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,o=i?i/2:void 0;if(n.path.intersection(t,o).length>0)return!0}return!1}render(t,e){var n,i;t.startObject(this.getBBox());for(const o of this.parts){const r=this.bboxForPart(o.path.bbox,o.style);if(e){if(!r.intersects(e))continue;if((r.size.x>3*e.size.x||r.size.y>3*e.size.y)&&!o.path.roughlyIntersects(e,null!==(i=null===(n=o.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0))continue}t.drawPath(o)}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:r.default.empty}applyTransformation(t){this.contentBBox=r.default.empty;let e=!0;this.parts=this.parts.map((n=>{const i=n.path.transformedBy(t),o=Object.assign(Object.assign({},n.style),{stroke:n.style.stroke?Object.assign({},n.style.stroke):void 0});if(o.stroke){const e=t.getScaleFactor();o.stroke.width*=e}const r=this.bboxForPart(i.bbox,o);return e?(this.contentBBox=r,e=!1):this.contentBBox=this.contentBBox.union(r),{path:i,startPoint:i.startPoint,commands:i.parts,style:o}}))}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:o.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 o.default.fromString(t.path).toRenderable(e)}));return new c(e)}}e.default=c,a.default.registerComponent("stroke",c.deserializeFromJSON)},1151: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.TextTransformMode=void 0;const o=i(n(8015)),r=i(n(8947)),s=n(5378),a=n(2788),l=i(n(2655)),c=n(739),d="text";var u;!function(t){t[t.ABSOLUTE_XY=0]="ABSOLUTE_XY",t[t.RELATIVE_XY=1]="RELATIVE_XY",t[t.RELATIVE_X_ABSOLUTE_Y=2]="RELATIVE_X_ABSOLUTE_Y",t[t.RELATIVE_Y_ABSOLUTE_X=3]="RELATIVE_Y_ABSOLUTE_X"}(u||(e.TextTransformMode=u={}));class h extends l.default{constructor(t,e,n,i=u.ABSOLUTE_XY){super(d),this.textObjects=t,this.transform=e,this.style=n,this.transformMode=i,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,o;const r=e.fontFamily.match(/\s/)?e.fontFamily.replace(/["]/g,'\\"'):e.fontFamily;t.font=[null!==(n=e.fontStyle)&&void 0!==n?n:"",null!==(i=e.fontWeight)&&void 0!==i?i:"",(null!==(o=e.size)&&void 0!==o?o:12)+"px",`${r}`].join(" "),t.textAlign="left"}static estimateTextDimens(t,e){const n=t.length*e.size,i=e.size;return new r.default(0,2*-i/3,n,i)}static getTextMetrics(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 null;const o=h.textMeasuringCtx;return h.applyTextStyles(o,e),o.measureText(t)}static getTextDimens(t,e){const n=this.getTextMetrics(t,e);if(!n)return this.estimateTextDimens(t,e);const i=-n.actualBoundingBoxAscent,o=n.actualBoundingBoxAscent+n.actualBoundingBoxDescent;return new r.default(0,i,n.width,o)}static getFontHeight(t){return t.size}computeUntransformedBBoxOfPart(t){return"string"==typeof t?h.getTextDimens(t,this.style):t.contentBBox}recomputeBBox(){let t=null;const e=new h.TextCursor(this.transform,this.style);for(const n of this.textObjects){const i=e.update(n),o=this.computeUntransformedBBoxOfPart(n).transformedBoundingBox(i);null!=t||(t=o),t=t.union(o)}this.contentBBox=null!=t?t:r.default.empty}renderInternal(t){const e=new h.TextCursor(this.transform,this.style);for(const n of this.textObjects){const i=e.update(n);"string"==typeof n?t.drawText(n,i,this.style):(t.pushTransform(i),n.renderInternal(t),t.popTransform())}}render(t,e){t.startObject(this.contentBBox),this.renderInternal(t),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(t){const e=new h.TextCursor(this.transform,this.style);for(const n of this.textObjects){const i=e.update(n).inverse(),o=t.transformedBy(i);if("string"==typeof n){if(h.getTextDimens(n,this.style).getEdges().some((t=>null!==o.intersection(t))))return!0}else if(n.intersects(o))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,c.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){if(t.textStyle)this.style=(0,a.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,a.cloneTextStyle)(this.style)}getBaselinePos(){return this.transform.transformVec2(s.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,a.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,a.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=[],a=Math.round(this.getFontHeight(n));let l=s.Vec2.zero;for(const e of t){i&&(l=l.plus(s.Vec2.unitY.times(a)));const t=new h([e],o.default.translation(l),n);r.push(t),i=t}return new h(r,e,n)}}h.textMeasuringCtx=null,h.TextCursor=class{constructor(t=o.default.identity,e){this.parentTransform=t,this.parentStyle=e,this.transform=o.default.identity}update(t){let e,n=o.default.identity,i=o.default.identity;"string"==typeof t?e=h.getTextDimens(t,this.parentStyle):(i=t.transform,e=t.getBBox());const r="string"==typeof t?u.RELATIVE_XY:t.transformMode;if(r===u.RELATIVE_XY)n=this.transform.rightMul(n);else if(r===u.RELATIVE_X_ABSOLUTE_Y||r===u.RELATIVE_Y_ABSOLUTE_X){n=this.transform.mapEntries(((t,[e,n])=>{if(r===u.RELATIVE_X_ABSOLUTE_Y)return 1===e&&2===n?0:t;if(r===u.RELATIVE_Y_ABSOLUTE_X)return 0===e&&2===n?0:t;throw new Error("Unreachable")})).rightMul(n)}const a=o.default.translation(s.Vec2.of(e.width,0));return this.transform=n.rightMul(i).rightMul(a),this.parentTransform.rightMul(n)}},e.default=h,l.default.registerComponent(d,(t=>h.deserializeFromString(t)))},9025: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 o=i(n(8947)),r=i(n(2001)),s=i(n(2655)),a="unknown-svg-object";class l extends s.default{constructor(t){super(a),this.svgObject=t,this.contentBBox=o.default.of(t.getBoundingClientRect())}render(t,e){t instanceof r.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)},9274:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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=r(n(2487)),l=s(n(9964));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(),o=Math.min(this.getLineWidth(),i/2),r=this.startPoint.width/2,s=this.endPoint.width/2,c=e.minus(n.times(o)),d=n.orthog(),u=d.times(r),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(o).plus(h))},{kind:a.PathCommandType.LineTo,point:e.plus(n.times(s))},{kind:a.PathCommandType.LineTo,point:c.plus(d.times(-o).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},7973:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedCircleBuilder=void 0;const a=n(5378),l=r(n(2487)),c=s(n(5566)),d=s(n(9964)),u=s(n(3472));e.makeOutlinedCircleBuilder=(t,e)=>new h(t,e);class h{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=[],e=2*Math.PI/6,n=c.default.roundPoint(this.endPoint.width,5/this.viewport.getScaleFactor()),i=this.startPoint.pos.lerp(this.endPoint.pos,.5),o=this.endPoint.pos.minus(i).length()-n/2,r=i.plus(a.Vec2.of(o,0));for(let n=e;n<=2*Math.PI;n+=e){const r=a.Vec2.of(o*Math.cos(n),-o*Math.sin(n)).plus(i),s=1.141,c=a.Vec2.of(Math.cos(n-e/2),-Math.sin(n-e/2)).times(o*s).plus(i);t.push({kind:l.PathCommandType.QuadraticBezierTo,controlPoint:c,endPoint:r})}t.push({kind:l.PathCommandType.LineTo,point:r});const s=new l.default(r,t).mapPoints((t=>this.viewport.roundPoint(t)));return new d.default([s.toRenderable({fill:u.default.transparent,stroke:{width:n,color:this.endPoint.color}})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}},6951:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeFreehandLineBuilder=void 0;const o=n(5378),r=i(n(8947)),s=n(2487),a=i(n(9964)),l=i(n(5566)),c=n(1003),d=i(n(3472));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 r.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(o.Vec2.of(t,t)),endPoint:e.plus(o.Vec2.of(0,t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,t)),endPoint:e.plus(o.Vec2.of(-t,0))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,-t)),endPoint:e.plus(o.Vec2.of(0,-t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(t,-t)),endPoint:e.plus(o.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},725:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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=r(n(2487)),l=s(n(9964));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,o=this.endPoint.width/2,r=n.orthog(),s=r.times(i),c=r.times(o),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},823: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 o=n(4232),r=n(5378),s=i(n(8947)),a=n(2487),l=i(n(9964)),c=i(n(5566)),d=n(1003);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,o;const r=this.curveFitter.preview();if(r){const{upperCurveCommand:s,lowerToUpperConnector:a,upperToLowerConnector:l,lowerCurveCommand:c}=this.segmentToPath(r);e.push(s),n.push(c),i=a,o=null!==(t=this.pathStartConnector)&&void 0!==t?t:l}else{if(null===this.mostRecentConnector||null===this.pathStartConnector)return null;i=this.mostRecentConnector,o=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(),o,...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],o=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(i);if(!o)throw new Error(`Incorrect format returned by .intersects: ${n} should be array of "number/number"!`);const s=parseFloat(o[1]);return r.Vec2.ofXY(t.get(s))},i=t=>r.Vec2.ofXY(t.points[2]).minus(r.Vec2.ofXY(t.points[1])).normalized(),o=t=>r.Vec2.ofXY(t.points[1]).minus(r.Vec2.ofXY(t.points[0])).normalized();if(o(e).dot(i(this.lastUpperBezier))<.3||o(t).dot(i(this.lastLowerBezier))<.3||o(e).dot(i(e))<0||o(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(r.Vec2.of(t,0));return this.lowerSegments.push({kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,t)),endPoint:e.plus(r.Vec2.of(0,t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,t)),endPoint:e.plus(r.Vec2.of(-t,0))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,-t)),endPoint:e.plus(r.Vec2.of(0,-t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,-t)),endPoint:e.plus(r.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:o,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(o),this.upperSegments.push(e),this.lastLowerBezier=s,this.lastUpperBezier=l,this.curveStartWidth=t.startWidth}segmentToPath(t){const e=new o.Bezier(t.startPoint.xy,t.controlPoint.xy,t.endPoint.xy);let n=r.Vec2.ofXY(e.normal(0)).normalized(),i=r.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=r.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 o.Bezier(v,g,y),lowerCurve:new o.Bezier(p,f,m)}}addPoint(t){this.curveFitter.addPoint(t)}}e.default=u},4666: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 o=i(n(8015)),r=i(n(2487)),s=i(n(8947)),a=i(n(9964));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=o.default.zRotation(-t),n=e.inverse().transformVec2(this.startPoint.pos),i=e.inverse().transformVec2(this.endPoint.pos),l=s.default.fromCorners(n,i),c=r.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},1024:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1576:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=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.Text=e.TextComponent=e.isRestylableComponent=e.createRestyleComponentCommand=e.Stroke=e.AbstractComponent=e.StrokeSmoother=e.makeOutlinedCircleBuilder=e.makePressureSensitiveFreehandLineBuilder=e.makeFreehandLineBuilder=void 0,o(n(1024),e);var s=n(6951);Object.defineProperty(e,"makeFreehandLineBuilder",{enumerable:!0,get:function(){return s.makeFreehandLineBuilder}});var a=n(823);Object.defineProperty(e,"makePressureSensitiveFreehandLineBuilder",{enumerable:!0,get:function(){return a.makePressureSensitiveFreehandLineBuilder}});var l=n(7973);Object.defineProperty(e,"makeOutlinedCircleBuilder",{enumerable:!0,get:function(){return l.makeOutlinedCircleBuilder}});var c=n(1003);Object.defineProperty(e,"StrokeSmoother",{enumerable:!0,get:function(){return r(c).default}}),o(n(2655),e);var d=n(2655);Object.defineProperty(e,"AbstractComponent",{enumerable:!0,get:function(){return r(d).default}});const u=r(n(9964));e.Stroke=u.default,e.StrokeComponent=u.default;const h=r(n(1151));e.TextComponent=h.default,e.Text=h.default;const p=r(n(7077));e.ImageComponent=p.default;const f=n(739);Object.defineProperty(e,"createRestyleComponentCommand",{enumerable:!0,get:function(){return f.createRestyleComponentCommand}}),Object.defineProperty(e,"isRestylableComponent",{enumerable:!0,get:function(){return f.isRestylableComponent}});const m=r(n(1847));e.BackgroundComponent=m.default},7708:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultComponentLocalization=void 0,e.defaultComponentLocalization={unlabeledImageNode:"Unlabeled image node",stroke:"Stroke",svgObject:"SVG Object",emptyBackground:"Empty background",gridBackground:"Grid background",filledBackgroundWithColor:t=>`Filled background (${t})`,text:t=>`Text object: ${t}`,imageNode:t=>`Image: ${t}`,restyledElement:t=>`Restyled ${t}`}},1003: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 o=n(5378),r=i(n(8947)),s=i(n(1885)),a=i(n(1701));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=o.Vec2.zero,this.currentCurve=null,this.curveStartWidth=t.width,this.bbox=new r.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 o=t.pos.minus(this.lastPoint.pos).times(1/n*1e3);this.momentum=this.momentum.lerp(o,.9)}const i=null!==(e=this.lastPoint)&&void 0!==e?e:t;this.lastPoint=t,this.buffer.push(t.pos);const r=t.width,l=this.curveEndWidth;if(this.curveEndWidth=r,this.bbox=this.bbox.grownToPoint(t.pos,r),null===this.currentCurve){const e=i.pos,s=i.pos.plus(null!==(n=this.lastExitingVec)&&void 0!==n?n:o.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+r)/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 o of this.buffer){let r=t.approximateDistance(o);if(r>e&&(r=t.distance(o),i+=Math.max(0,r-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},2944:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{if(0===e.length)return null;const n=e[0].description(t);for(const i of e)if(i.description(t)!==n)return null;return n}},6209:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=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.EventDispatcher=e.Viewport=e.SVGLoader=e.Color4=e.matchingLocalizationTable=e.getLocalizationTable=e.EditorImage=void 0;const s=r(n(5146));e.Editor=s.default;var a=n(7551);Object.defineProperty(e,"EditorImage",{enumerable:!0,get:function(){return r(a).default}}),o(n(3173),e);var l=n(1906);Object.defineProperty(e,"getLocalizationTable",{enumerable:!0,get:function(){return r(l).default}}),Object.defineProperty(e,"matchingLocalizationTable",{enumerable:!0,get:function(){return l.matchingLocalizationTable}}),o(n(8167),e);var c=n(3472);Object.defineProperty(e,"Color4",{enumerable:!0,get:function(){return r(c).default}});var d=n(1697);Object.defineProperty(e,"SVGLoader",{enumerable:!0,get:function(){return r(d).default}});var u=n(5566);Object.defineProperty(e,"Viewport",{enumerable:!0,get:function(){return r(u).default}}),o(n(6557),e),o(n(1576),e),o(n(7601),e),o(n(1709),e),o(n(2994),e),o(n(2670),e),o(n(1797),e),o(n(6843),e);var h=n(1785);Object.defineProperty(e,"EventDispatcher",{enumerable:!0,get:function(){return r(h).default}});var p=n(4318);Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return r(p).default}}),Object.defineProperty(e,"PointerDevice",{enumerable:!0,get:function(){return p.PointerDevice}});var f=n(3808);Object.defineProperty(e,"HTMLToolbar",{enumerable:!0,get:function(){return r(f).default}});var m=n(5155);Object.defineProperty(e,"UndoRedoHistory",{enumerable:!0,get:function(){return r(m).default}}),e.default=s.default},8167:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultEditorLocalization=void 0;const i=n(6985),o=n(7708),r=n(49),s=n(9746),a=n(3376);e.defaultEditorLocalization=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s.defaultToolbarLocalization),a.defaultToolLocalization),i.defaultCommandLocalization),o.defaultComponentLocalization),r.defaultTextRendererLocalization),{accessibilityInputInstructions:['Press "t" to read the contents of the viewport as text.',"Use the arrow keys to move the viewport, click and drag to draw strokes.",'Press "w" to zoom in and "s" to zoom out.'].join(" "),loading:t=>`Loading ${t}%...`,imageEditor:"Image Editor",doneLoading:"Done loading",undoAnnouncement:t=>`Undid ${t}`,redoAnnouncement:t=>`Redid ${t}`})},4540:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8167),o=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=o},512:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8167),o=Object.assign({},i.defaultEditorLocalization);e.default=o},7003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8167),o=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=o},1906: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.matchingLocalizationTable=e.allLocales=void 0;const o=n(8167),r=i(n(4540)),s=i(n(512)),a=i(n(7003));e.allLocales={de:r.default,en:s.default,es:a.default};const l=t=>{const e=/^(\w+)[_-](\w+)$/.exec(t);return e?e[1]:t};e.matchingLocalizationTable=(t,e,n)=>{let i;for(const n of t){const t=l(n);if(i&&t!==i&&i in e)return e[i];if(n in e)return e[n];i=t}return i&&i in e?e[i]:n};e.default=t=>(null!=t||(t=navigator.languages),(0,e.matchingLocalizationTable)(t,e.allLocales,o.defaultEditorLocalization))},8015: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 o=n(5378),r=i(n(1486));class s{constructor(t,e,n,i,o,s,a,l,c){this.a1=t,this.a2=e,this.a3=n,this.b1=i,this.b2=o,this.b3=s,this.c1=a,this.c2=l,this.c3=c,this.cachedInverse=void 0,this.rows=[r.default.of(t,e,n),r.default.of(i,o,s),r.default.of(a,l,c)]}static ofRows(t,e,n){return new s(t.x,t.y,t.z,e.x,e.y,e.z,n.x,n.y,n.z)}inverse(){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=[r.default.unitX,r.default.unitY,r.default.unitZ];for(let n=0;n<3;n++){let i=t[n].at(n);const o=1e-10;if(Math.abs(i)<o){let r=-1;for(let e=1;e<=2;e++){const i=(n+e)%3;if(Math.abs(t[i].at(n))>=o){r=i;break}}if(-1===r)return this.cachedInverse=null,null;const s=t[n],a=e[n];t[n]=t[r],e[n]=e[r],t[r]=s,e[r]=a,i=t[n].at(n)}let r=1/i;t[n]=t[n].times(r),e[n]=e[n].times(r);const s=t[n],a=e[n];for(let i=1;i<=2;i++){const o=(n+i)%3;r=-t[o].at(n),t[o]=t[o].plus(s.times(r)),e[o]=e[o].plus(a.times(r))}}const n=s.ofRows(e[0],e[1],e[2]);return this.cachedInverse=n,n}transposed(){return new s(this.a1,this.b1,this.c1,this.a2,this.b2,this.c2,this.a3,this.b3,this.c3)}rightMul(t){t=t.transposed();const e=(e,n)=>this.rows[e].dot(t.rows[n]);return new s(e(0,0),e(0,1),e(0,2),e(1,0),e(1,1),e(1,2),e(2,0),e(2,1),e(2,2))}transformVec2(t){let e=r.default.of(t.x,t.y,1);return e=this.transformVec3(e),o.Vec2.of(e.x,e.y)}transformVec3(t){return r.default.of(this.rows[0].dot(t),this.rows[1].dot(t),this.rows[2].dot(t))}isIdentity(){return this===s.identity||this.eq(s.identity)}eq(t,e=0){for(let n=0;n<3;n++)if(!this.rows[n].eq(t.rows[n],e))return!1;return!0}toString(){let t="";const e=[0,0,0];for(const t of this.rows)for(let n=0;n<3;n++)e[n]=Math.max(e[0],`${t.at(n)}`.length);for(let n=0;n<3;n++){t+=0===n?"⎡ ":1===n?"⎢ ":"⎣ ";for(let i=0;i<3;i++){const o=this.rows[n].at(i).toString();let r="";for(let t=o.length;t<e[i];t++)r+=" ";t+=o+", "+r}t+=0===n?" ⎤":1===n?" ⎥":" ⎦",t+="\n"}return t.trimEnd()}toArray(){return[this.a1,this.a2,this.a3,this.b1,this.b2,this.b3,this.c1,this.c2,this.c3]}mapEntries(t){return new s(t(this.a1,[0,0]),t(this.a2,[0,1]),t(this.a3,[0,2]),t(this.b1,[1,0]),t(this.b2,[1,1]),t(this.b3,[1,2]),t(this.c1,[2,0]),t(this.c2,[2,1]),t(this.c3,[2,2]))}getScaleFactor(){return Math.hypot(this.a1,this.a2)}static translation(t){return new s(1,0,t.x,0,1,t.y,0,0,1)}static zRotation(t,e=o.Vec2.zero){if(0===t)return s.identity;const n=Math.cos(t),i=Math.sin(t);let r=s.translation(e);return r=r.rightMul(new s(n,-i,0,i,n,0,0,0,1)),r.rightMul(s.translation(e.times(-1)))}static scaling2D(t,e=o.Vec2.zero){let n,i,r=s.translation(e);return"number"==typeof t?(n=t,i=t):(n=t.x,i=t.y),r=r.rightMul(new s(n,0,0,0,i,0,0,0,1)),r.rightMul(s.translation(e.times(-1)))}toCSSMatrix(){return`matrix(${this.a1},${this.b1},${this.a2},${this.b2},${this.a3},${this.b3})`}static fromCSSMatrix(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*$`,o=new RegExp(i,"i").exec(t);if(!o)throw new Error(`Unsupported transformation: ${t}`);const r=o.slice(1).map((t=>parseFloat(t))),a=r[0],l=r[1],c=r[2],d=r[3],u=r[4],h=r[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},5378: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 o=i(n(1486));var r;!function(t){t.of=(t,e)=>o.default.of(t,e,0),t.ofXY=({x:t,y:e})=>o.default.of(t,e,0),t.unitX=t.of(1,0),t.unitY=t.of(0,1),t.zero=t.of(0,0)}(r||(e.Vec2=r={}))},1486:(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},6557: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 o=i(n(1885));e.LineSegment2=o.default;const r=i(n(8015));e.Mat33=r.default;const s=i(n(2487));e.Path=s.default;const a=i(n(8947));e.Rect2=a.default;const l=n(5378);Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return l.Vec2}});const c=i(n(1486));e.Vec3=c.default},2636:(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 o=Math.sqrt(i),r=(-e+o)/(2*t),s=(-e-o)/(2*t);return r>s?[r,s]:[s,r]}},9036:(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],o=parseInt(e.charAt(e.length-1),10),r=parseInt(e,10),s=parseInt(i[2],10),a=i[3];let l=(r+10-o).toString(),c=0;for(l.length>r.toString().length&&(l=l.substring(1),c=1);l.length<a.length;)l=c.toString(10)+l,c=0;n=`${t+(s+c).toString()}.${l}`}return n=n.replace(/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,"$1"),(0,e.cleanUpNumber)(n)};const n=/^([-]?)(\d*)[.](\d+)$/;e.getLenAfterDecimal=t=>{const e=n.exec(t);if(!e)return-1!==t.search(/[eE]/)||/^[a-zA-Z]+$/.exec(t)?-1:0;return e[3].length};e.toStringOfSamePrecision=(t,...i)=>{const o=t.toString(10),r=n.exec(o);if(!r)return o;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=r[3].substring(0,s),l=r[2];const c=r[3].charAt(s);if(""!==c){if(parseInt(c,10)>=5){if(a.length>0){const t=/^(0+)(\d*)$/.exec(a);let e="",n=a;t&&(e=t[1],n=t[2]),a=(parseInt(a)+1).toString(),a.length>n.length&&e.length>0&&(e=e.substring(1)),a=e+a}(0===a.length||a.length>s)&&(l=(parseInt(l)+1).toString(),a=a.substring(1))}}const d=r[1];return(0,e.cleanUpNumber)(`${d}${l}.${a}`)}},1098:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{distance(t){return Math.abs(this.signedDistance(t))}containsPoint(t,e=n.smallValue){return this.signedDistance(t)<e}getLooseBoundingBox(){return this.getTightBoundingBox()}}n.smallValue=1e-12,e.default=n},4769:function(t,e,n){"use strict";var i,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)},r=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(4232),l=n(5378),c=s(n(1098)),d=s(n(8947));class u extends c.default{constructor(){super(...arguments),i.set(this,null)}getBezier(){return o(this,i,"f")||r(this,i,new a.Bezier(this.getPoints().map((t=>t.xy))),"f"),o(this,i,"f")}signedDistance(t){return this.getBezier().project(t.xy).d}distance(t){return this.signedDistance(t)}at(t){return l.Vec2.ofXY(this.getBezier().get(t))}derivativeAt(t){return l.Vec2.ofXY(this.getBezier().derivative(t))}normal(t){return l.Vec2.ofXY(this.getBezier().normal(t))}getTightBoundingBox(){const t=this.getBezier().bbox(),e=t.x.max-t.x.min,n=t.y.max-t.y.min;return new d.default(t.x.min,t.y.min,e,n)}intersectsLineSegment(t){const e=this.getBezier();return e.intersects(t).map((n=>{"string"==typeof n&&(n=parseFloat(n));const i=l.Vec2.ofXY(e.get(n));return i.minus(t.p1).magnitude()>t.length||i.minus(t.p2).magnitude()>t.length?null:i})).filter((t=>null!==t))}}i=new WeakMap,e.default=u},4151: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 o=i(n(4769)),r=i(n(8947));class s extends o.default{constructor(t,e,n,i){super(),this.p0=t,this.p1=e,this.p2=n,this.p3=i}getPoints(){return[this.p0,this.p1,this.p2,this.p3]}getLooseBoundingBox(){return r.default.bboxOf([this.p0,this.p1,this.p2,this.p3])}}e.default=s},1885: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 o=i(n(8947)),r=n(5378),s=i(n(1098));class a extends s.default{constructor(t,e){super(),this.point1=t,this.point2=e,this.bbox=o.default.bboxOf([t,e]),this.direction=e.minus(t),this.length=this.direction.magnitude(),this.length>0&&(this.direction=this.direction.times(1/this.length))}get p1(){return this.point1}get p2(){return this.point2}get(t){return this.point1.plus(this.direction.times(t))}at(t){return this.get(t*this.length)}intersection(t){let e,n;if(0===this.direction.x){if(0===t.direction.x||0===this.direction.y)return null;const i=this.point1.x,o=(this.point1.x-t.point1.x)*t.direction.y/t.direction.x+t.point1.y;e=r.Vec2.of(i,o),n=(o-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,o=t.direction.y*this.direction.x-this.direction.y*t.direction.x;if(0===o)return null;const s=i/o,a=(s-this.point1.x)/this.direction.x,l=this.point1.y+this.direction.y*a;e=r.Vec2.of(s,l),n=(s-this.point1.x)/this.direction.x}const i=e.minus(this.point1).magnitude(),o=e.minus(this.point2).magnitude(),s=e.minus(t.point1).magnitude(),a=e.minus(t.point2).magnitude();return i>this.length||o>this.length||s>t.length||a>t.length?null:{point:e,t:n}}intersects(t){return null!==this.intersection(t)}intersectsLineSegment(t){const e=this.intersection(t);return e?[e.point]:[]}closestPointTo(t){const e=t.minus(this.p1).dot(this.direction),n=this.length-e,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}signedDistance(t){return this.closestPointTo(t).minus(t).magnitude()}transformedBy(t){return new a(t.transformVec2(this.p1),t.transformVec2(this.p2))}getTightBoundingBox(){return this.bbox}toString(){return`LineSegment(${this.p1.toString()}, ${this.p2.toString()})`}}e.default=a},2487: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 o=n(9036),r=i(n(1885)),s=i(n(8015)),a=i(n(8947)),l=n(5378),c=i(n(4151)),d=i(n(1701)),u=i(n(3777));var h;!function(t){t[t.LineTo=0]="LineTo",t[t.MoveTo=1]="MoveTo",t[t.CubicBezierTo=2]="CubicBezierTo",t[t.QuadraticBezierTo=3]="QuadraticBezierTo"}(h||(e.PathCommandType=h={}));class p{constructor(t,e){this.startPoint=t,this.parts=e,this.cachedGeometry=null,this.cachedPolylineApproximation=null,this.cachedStringVersion=null,this.bbox=a.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(e.getTightBoundingBox());return a.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 h.CubicBezierTo:e.push(new c.default(t,n.controlPoint1,n.controlPoint2,n.endPoint)),t=n.endPoint;break;case h.QuadraticBezierTo:e.push(new d.default(t,n.controlPoint,n.endPoint)),t=n.endPoint;break;case h.LineTo:e.push(new r.default(t,n.point)),t=n.point;break;case h.MoveTo:e.push(new u.default(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 h.CubicBezierTo:t.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:t.push(e.controlPoint,e.endPoint);break;case h.MoveTo:case h.LineTo:t.push(e.point)}const e=[];let n=this.startPoint;for(const i of t)e.push(new r.default(n,i)),n=i;return e}static computeBBoxForSegment(t,e){const n=[t];let i;switch(e.kind){case h.MoveTo:case h.LineTo:n.push(e.point);break;case h.CubicBezierTo:n.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:n.push(e.controlPoint,e.endPoint);break;default:return i=e,i}return a.default.bboxOf(n)}raymarchIntersectionWith(t,e,n=[]){var i,o;if(!t.bbox.intersects(this.bbox.grownBy(e)))return[];const r=t.length,s=[];for(const n of this.geometry){const i=n.getTightBoundingBox().grownBy(e);if(!i.intersects(t.bbox))continue;const o=t=>n.signedDistance(t),a=t=>o(t)-e;a(t.p1)>r&&a(t.p2)>r||s.push({part:n,distFn:o,bbox:i})}if(0===s.length)return[];const a=t=>{let n=1/0,i=null;const o=[];for(const e of s){const{part:r,distFn:s,bbox:a}=e;if(!a.containsPoint(t)){o.push(e);continue}const l=s(t);l<=n&&(n=l,i=r)}for(const{part:e,distFn:r,bbox:s}of o){if(!s.grownBy(n).containsPoint(t))continue;const o=r(t);o<=n&&(n=o,i=e)}return[i,n-e]},l=[t.p1,...n,t.p2],c=e=>e.minus(t.p1).dot(t.direction);l.sort(((t,e)=>c(t)-c(e)));const d=[],u=e/1e3,h=(e,n,i)=>{let o=e,[s,l]=a(o),h=c(o);if(l>r)return h;const p=t.direction.times(n);for(let t=0;t<7;t++){const t=l;if(o=o.plus(p.times(t)),h=c(o),h<=i)return h;const[e,n]=a(o);if(Math.abs(n)>Math.abs(l))return null;if(l=n,s=e,Math.abs(l)<u)break}return s&&(h>=0&&h<=r)&&Math.abs(l)<u&&d.push({point:o,parameterValue:NaN,curve:s}),h};let p=0;for(let t=0;t<l.length;t++){const e=l[t];p=Math.max(p,null!==(i=h(e,1,p))&&void 0!==i?i:p),p=Math.max(p,null!==(o=h(e,-1,p))&&void 0!==o?o:p)}return d}intersection(t,e){let n=[];if(!t.bbox.intersects(this.bbox.grownBy(null!=e?e:0)))return[];for(const e of this.geometry){const i=e.intersectsLineSegment(t);i.length>0&&n.push({curve:e,point:i[0]})}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 h.MoveTo:case h.LineTo:return{kind:t.kind,point:e(t.point)};case h.CubicBezierTo:return{kind:t.kind,controlPoint1:e(t.controlPoint1),controlPoint2:e(t.controlPoint2),endPoint:e(t.endPoint)};case h.QuadraticBezierTo:return{kind:t.kind,controlPoint:e(t.controlPoint),endPoint:e(t.endPoint)}}return t}mapPoints(t){const e=t(this.startPoint),n=[];for(const e of this.parts)n.push(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:h.MoveTo,point:t.startPoint},...t.parts]):this}getEndPoint(){if(0===this.parts.length)return this.startPoint;const t=this.parts[this.parts.length-1];return t.kind===h.QuadraticBezierTo||t.kind===h.CubicBezierTo?t.endPoint:t.point}roughlyIntersects(t,e=0){if(0===this.parts.length)return t.containsPoint(this.startPoint);if(this.startPoint.eq(this.getEndPoint())&&0===e)return this.closedRoughlyIntersects(t);if(t.containsRect(this.bbox))return!0;let n=this.startPoint;for(const i of this.parts){const o=p.computeBBoxForSegment(n,i).grownBy(e);if(n=i.kind===h.LineTo||i.kind===h.MoveTo?i.point:i.endPoint,t.intersects(o))return!0}return!1}closedRoughlyIntersects(t){if(t.containsRect(this.bbox))return!0;const e=this.bbox.topLeft.minus(l.Vec2.of(1,1)),n=t.corners,i=this.polylineApproximation();for(const t of n){const n=new r.default(t,e);let o=0;for(const t of i)t.intersects(n)&&o++;if(o%2==1)return!0}const o=t.grownBy(Math.min(t.size.x,t.size.y)),s=[];for(const t of o.divideIntoGrid(4,4))s.push(...t.getEdges());for(const t of s)for(const e of i)if(t.intersects(e))return!0;return!1}static fromRect(t,e=null){const n=[];let i,o;if(null!==e){const n=l.Vec2.of(e,e).times(.5),r=a.default.fromCorners(t.topLeft.plus(n),t.bottomRight.minus(n)),s=a.default.fromCorners(t.topLeft.minus(n),t.bottomRight.plus(n));i=[r.corners[3],...r.corners,...s.corners.reverse()],o=s.corners[3]}else i=t.corners.slice(1),o=t.corners[0];for(const t of i)n.push({kind:h.LineTo,point:t});return n.push({kind:h.LineTo,point:o}),new p(o,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 o=p.fromRenderable(t),r=null!==(i=null===(n=t.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0,a=r>0&&0===t.style.fill.a;if(e.grownBy(r).transformedBoundingBox(s.default.scaling2D(4,e.center)).containsRect(o.bbox.grownBy(r)))return t;const l=[];let c=o.startPoint;for(const t of o.parts){const n=p.computeBBoxForSegment(c,t).grownBy(r);let i;i=t.kind===h.LineTo||t.kind===h.MoveTo?t.point:t.endPoint;n.intersects(e)?l.push(t):a||t.kind===h.MoveTo?l.push({kind:h.MoveTo,point:i}):l.push({kind:h.LineTo,point:i}),c=i}return new p(o.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)!==h.MoveTo&&a("M",t);for(let t=0;t<e.length;t++){const n=e[t];switch(n.kind){case h.MoveTo:a("M",n.point);break;case h.LineTo:a("L",n.point);break;case h.CubicBezierTo:a("C",n.controlPoint1,n.controlPoint2,n.endPoint);break;case h.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=l.Vec2.zero,i=null,o=null,r=!0;const s=[],a=t=>{r?r=!1:s.push({kind:h.LineTo,point:t})},c={m:1,l:1,c:3,q:2,z:0,h:1,v:1},d=/([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/gi;let u;for(;null!==(u=d.exec(t));){const t=u[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=u[1].toLowerCase(),x=u[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=c[p])&&void 0!==e?e:0,S=d.reduce(((t,e,n,i)=>{if(n%2!=0){const o=e,r=i[n-1];return t.concat(l.Vec2.of(r,o))}return t}),[]).map(((t,e)=>{let i;return i=x?t:n.plus(t),(e+1)%w==0&&(n=i),i}));if(S.length%w!=0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(S)} with a length of ${S.length} ≠ ${w}k, k ∈ ℤ.`,`The number of arguments to ${p} must be a multiple of ${w}!`,`Command: ${u[0]}`].join("\n"));for(let t=0;t<S.length;t+=w){const e=S.slice(t,t+w);switch(p.toLowerCase()){case"m":0===t?(b=e[0],r?r=!1:s.push({kind:h.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:h.CubicBezierTo,controlPoint1:g,controlPoint2:v,endPoint:y});break;case"q":f=e[0],m=e[1],s.push({kind:h.QuadraticBezierTo,controlPoint:f,endPoint:m});break;default:throw new Error(`Unknown path command ${p}`)}r=!1}S.length>0&&(null!=i||(i=S[0]),null!=o||(o=i),n=S[S.length-1])}var f,m,g,v,y,b;const x=new p(null!=o?o:l.Vec2.zero,s);return x.cachedStringVersion=t,x}}p.empty=new p(l.Vec2.zero,[]),e.default=p},3777: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 o=i(n(1098)),r=i(n(8947));class s extends o.default{constructor(t){super(),this.p=t}signedDistance(t){return this.p.minus(t).magnitude()}intersectsLineSegment(t,e){return t.containsPoint(this.p,e)?[this.p]:[]}getTightBoundingBox(){return new r.default(this.p.x,this.p.y,0,0)}}e.default=s},1701: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 o=n(5378),r=i(n(2636)),s=i(n(4769)),a=i(n(8947));class l extends s.default{constructor(t,e,n){super(),this.p0=t,this.p1=e,this.p2=n}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(l.componentAt(t,e.x,n.x,i.x),l.componentAt(t,e.y,n.y,i.y))}derivativeAt(t){const e=this.p0,n=this.p1,i=this.p2;return o.Vec2.of(l.derivativeComponentAt(t,e.x,n.x,i.x),l.derivativeComponentAt(t,e.y,n.y,i.y))}normal(t){return this.derivativeAt(t).orthog().normalized()}getLooseBoundingBox(){return a.default.bboxOf([this.p0,this.p1,this.p2])}approximateDistance(t){const e=this.p0.x-t.x,n=-2*this.p0.x+2*this.p1.x,i=this.p0.x-2*this.p1.x+this.p2.x,o=this.p0.y-t.y,s=-2*this.p0.y+2*this.p1.y,a=this.p0.y-2*this.p1.y+this.p2.y,l=2*e*n+2*o*s-t.x*n-t.y*s,c=2*n*n+2*s*s+2*i*e+2*a*o-t.x*i-t.y*a,d=2*(2*s*a+2*n*i+2*i*n+2*a*s);let[u,h]=(0,r.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))}getPoints(){return[this.p0,this.p1,this.p2]}}e.default=l},8947: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 o=i(n(1885)),r=n(5378),s=i(n(1098));class a extends s.default{constructor(t,e,n,i){super(),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=r.Vec2.of(this.x,this.y),this.size=r.Vec2.of(this.w,this.h),this.bottomRight=this.topLeft.plus(this.size),this.area=this.w*this.h}translatedBy(t){return new a(t.x+this.x,t.y+this.y,this.w,this.h)}resizedTo(t){return new a(this.x,this.y,t.x,t.y)}containsPoint(t){return this.x<=t.x&&this.y<=t.y&&this.x+this.w>=t.x&&this.y+this.h>=t.y}containsRect(t){return this.x<=t.x&&this.y<=t.y&&this.bottomRight.x>=t.bottomRight.x&&this.bottomRight.y>=t.bottomRight.y}intersects(t){const e=this.x,n=e+this.w,i=t.x,o=t.x+t.w;if(n<i||e>o)return!1;const r=this.y,s=r+this.h,a=t.y,l=t.y+t.h;return!(s<a||r>l)}intersection(t){if(!this.intersects(t))return null;const e=this.topLeft.zip(t.topLeft,Math.max),n=this.bottomRight.zip(t.bottomRight,Math.min);return a.fromCorners(e,n)}union(t){return a.union(this,t)}divideIntoGrid(t,e){const n=[];if(t<=0||e<=0)return n;const i=this.w/t,o=this.h/e;0===i&&(t=1),0===o&&(e=1);for(let r=0;r<e;r++)for(let e=0;e<t;e++){const t=i*e+this.x,s=o*r+this.y;n.push(new a(t,s,i,o))}return n}grownToPoint(t,e=0){const n=new a(t.x-e,t.y-e,2*e,2*e);return this.union(n)}grownBy(t){return 0===t?this:new a(this.x-t,this.y-t,this.w+2*t,this.h+2*t)}getClosestPointOnBoundaryTo(t){const e=this.getEdges().map((e=>e.closestPointTo(t)));let n=null,i=null;for(const o of e){const e=o.minus(t).length();(null===i||e<i)&&(n=o,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(r.Vec2.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(r.Vec2.of(0,this.h))}get width(){return this.w}get height(){return this.h}get center(){return this.topLeft.plus(this.size.times(.5))}getEdges(){const t=this.corners;return[new o.default(t[0],t[1]),new o.default(t[1],t[2]),new o.default(t[2],t[3]),new o.default(t[3],t[0])]}intersectsLineSegment(t){const e=[];for(const n of this.getEdges()){n.intersectsLineSegment(t).forEach((t=>e.push(t)))}return e}signedDistance(t){const e=this.getClosestPointOnBoundaryTo(t),n=t.minus(e).magnitude();return this.containsPoint(t)?-n:n}getTightBoundingBox(){return this}transformedBoundingBox(t){return a.bboxOf(this.corners.map((e=>t.transformVec2(e))))}eq(t,e=0){return this.topLeft.eq(t.topLeft,e)&&this.size.eq(t.size,e)}toString(){return`Rect(point(${this.x}, ${this.y}), size(${this.w}, ${this.h}))`}static fromCorners(t,e){return new a(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.abs(t.x-e.x),Math.abs(t.y-e.y))}static bboxOf(t,e=0){let n=0,i=0,o=0,s=0,l=!0;for(const e of t)l&&(n=e.x,i=e.y,o=e.x,s=e.y,l=!1),n=Math.min(n,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),s=Math.max(s,e.y);return a.fromCorners(r.Vec2.of(n-e,i-e),r.Vec2.of(o+e,s+e))}static union(...t){if(0===t.length)return a.empty;const e=t[0];let n=e.topLeft.x,i=e.topLeft.y,o=e.bottomRight.x,r=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),o=Math.max(o,s.bottomRight.x),r=Math.max(r,s.bottomRight.y)}return new a(n,i,o-n,r-i)}static of(t){var e,n,i,o;const r=null!==(n=null!==(e=t.width)&&void 0!==e?e:t.w)&&void 0!==n?n:0,s=null!==(o=null!==(i=t.height)&&void 0!==i?i:t.h)&&void 0!==o?o:0;return new a(t.x,t.y,r,s)}}a.empty=new a(0,0,0,0),a.unitSquare=new a(0,0,1,1),e.default=a},3012: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 o=i(n(7717)),r=n(3173),s=i(n(6377)),a=n(5378),l=i(n(5630)),c=i(n(1263)),d=i(n(3472));var u;!function(t){t[t.DummyRenderer=0]="DummyRenderer",t[t.CanvasRenderer=1]="CanvasRenderer"}(u||(e.RenderingMode=u={}));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 r=n.getContext("2d");return new o.default(r,t.viewport)},isOfCorrectType:t=>this.dryInkRenderer.canRenderFromWithoutDataLoss(t),blockResolution:i,cacheSize:1296e5,maxScale:1.3,minProportionalRenderTimePerCache:80,minProportionalRenderTimeToUseCache:420}),this.editor.notifier.on(r.EditorEventType.DisplayResized,(t=>{var e;if(t.kind!==r.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 o.default(n,this.editor.viewport),this.wetInkRenderer=new o.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(r.EditorEventType.DisplayResized,{kind:r.EditorEventType.DisplayResized,newSize:a.Vec2.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{n.drawImage(e,0,0)},this.getColorAt=t=>{const e=n.getImageData(t.x,t.y,1,1),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)}}},2500: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 o=i(n(3472));e.cloneStyle=t=>({fill:t.fill,stroke:t.stroke?Object.assign({},t.stroke):void 0});e.stylesEqual=(t,e)=>{var n,i,o,r,s,a;const l=t===e||t.fill.eq(e.fill)&&null==t.stroke==(null==e.stroke)&&(null===(r=null===(i=null===(n=t.stroke)||void 0===n?void 0:n.color)||void 0===i?void 0:i.eq(null===(o=e.stroke)||void 0===o?void 0:o.color))||void 0===r||r)&&(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:o.default.fromHex(t.stroke.color),width:t.stroke.width}:void 0;return{fill:o.default.fromHex(t.fill),stroke:e}}},2788:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.textStyleToJSON=e.textStyleFromJSON=e.cloneTextStyle=void 0;const i=n(2500);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)})},4619: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 o=i(n(8015));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 o.default.scaling2D(this.cacheState.props.blockResolution.x/t.size.x).rightMul(o.default.translation(t.topLeft.times(-1)))}setRenderingRegion(t){this.renderer.setTransform(this.getTransform(t))}}},8182: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 o=i(n(4619));e.CacheRecordManager=class{constructor(t){this.cacheRecords=[],this.maxCanvases=Math.ceil(t.cacheSize/4/t.blockResolution.x/t.blockResolution.y)}setSharedState(t){this.cacheState=t}allocCanvas(t,e){if(this.cacheRecords.length<this.maxCanvases){const n=new o.default(e,this.cacheState);return n.setRenderingRegion(t),this.cacheRecords.push(n),n}{const n=this.getLeastRecentlyUsedRecord();return n.realloc(e),n.setRenderingRegion(t),n}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort(((t,e)=>t.getLastUsedCycle()-e.getLastUsedCycle())),this.cacheRecords[0]}}},5630:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(8947)),r=i(n(1310)),s=n(8182);e.default=class{constructor(t){this.recordManager=new s.CacheRecordManager(t),this.sharedState={props:t,currentRenderingCycle:0,recordManager:this.recordManager},this.recordManager.setSharedState(this.sharedState)}render(t,e,n){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 r.default(new o.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)}}},1310: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(3472));const o=n(7551),r=i(n(8947)),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=r.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,o.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 o=0;for(const t of d)o+=t.getContent().getProportionalRenderingTime();if(o>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],o=i.getContent().getZIndex();(t>=this.renderedIds.length||i.getId()!==this.renderedIds[t])&&(e.push(i),(null===n||o<n)&&(n=o))}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 r.default(this.region.x,this.region.y,this.region.w+e,this.region.h+e),o=!0;t.startObject(i,o);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},2670: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 o=n(7369);Object.defineProperty(e,"AbstractRenderer",{enumerable:!0,get:function(){return i(o).default}});var r=n(6377);Object.defineProperty(e,"DummyRenderer",{enumerable:!0,get:function(){return i(r).default}});var s=n(2001);Object.defineProperty(e,"SVGRenderer",{enumerable:!0,get:function(){return i(s).default}});var a=n(7717);Object.defineProperty(e,"CanvasRenderer",{enumerable:!0,get:function(){return i(a).default}});var l=n(3012);Object.defineProperty(e,"Display",{enumerable:!0,get:function(){return i(l).default}}),Object.defineProperty(e,"RenderingMode",{enumerable:!0,get:function(){return l.RenderingMode}})},49:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTextRendererLocalization=void 0,e.defaultTextRendererLocalization={pathNodeCount:t=>`There are ${t} visible path objects.`,textNodeCount:t=>`There are ${t} visible text nodes.`,imageNodeCount:t=>`There are ${t} visible image nodes.`,textNode:t=>`Text: ${t}`,imageNode:t=>`Image: ${t}`,unlabeledImageNode:"Unlabeled image",rerenderAsText:"Re-render as text"}},7369:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});const s=r(n(2487)),a=n(5378),l=n(2500);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:o}=e;t&&(0,l.stylesEqual)(t,o)?this.moveTo(n):(t&&this.endPath(t),this.beginPath(n),t=o);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),this.currentPaths=[]}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.objectLevel>0&&this.flushPath(),this.currentPaths=[],this.objectLevel++}endObject(t,e){if(this.flushPath(),this.currentPaths=null,this.objectLevel--,this.objectLevel<0)throw new Error("More objects have ended than have been started (negative object nesting level)!")}getNestingLevel(){return this.objectLevel}canRenderFromWithoutDataLoss(t){return!1}renderFromOtherOfSameType(t,e){throw new Error(`Unable to render from ${e}: Not implemented`)}setTransform(t){this.selfTransform=t}pushTransform(t){this.transformStack.push(this.selfTransform),this.setTransform(this.getCanvasToScreenTransform().rightMul(t))}popTransform(){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()}}},7717: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 o=i(n(3472)),r=i(n(1151)),s=i(n(2487)),a=n(5378),l=i(n(7369));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),o=n.minus(e);i.magnitudeSquared()<this.minSquareCurveApproxDist&&o.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),r.default.applyTextStyles(this.ctx,n),0!==n.renderingStyle.fill.a&&(this.ctx.fillStyle=n.renderingStyle.fill.toHexString(),this.ctx.fillText(t,0,0)),n.renderingStyle.stroke&&(this.ctx.strokeStyle=n.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=n.renderingStyle.stroke.width,this.ctx.strokeText(t,0,0)),this.ctx.restore()}drawImage(t){this.ctx.save();const e=this.getCanvasToScreenTransform().rightMul(t.transform);this.transformBy(e),this.ctx.drawImage(t.image,0,0),this.ctx.restore()}startObject(t,e){if(this.isTooSmallToRender(t)&&(this.ignoreObjectsAboveLevel=this.getNestingLevel(),this.ignoringObject=!0),super.startObject(t),this.currentObjectBBox=t,!this.ignoringObject&&e){if(!t.containsRect(this.getViewport().visibleRect)){this.clipLevels.push(this.objectLevel),this.ctx.save(),this.ctx.beginPath();for(const e of t.corners){const t=this.canvasToScreen(e);this.ctx.lineTo(t.x,t.y)}this.ctx.clip()}}}endObject(){const t=this.objectLevel;this.currentObjectBBox=null,super.endObject(),!this.ignoringObject&&this.clipLevels.length>0&&this.clipLevels[this.clipLevels.length-1]===t&&(this.ctx.restore(),this.clipLevels.pop()),null!==this.ignoreObjectsAboveLevel&&this.getNestingLevel()<=this.ignoreObjectsAboveLevel&&(this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1)}drawPoints(...t){for(let e=0;e<t.length;e++){const n=this.canvasToScreen(t[e]);this.ctx.beginPath(),this.ctx.arc(n.x,n.y,10,0,2*Math.PI),this.ctx.fillStyle=o.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,o=this.minRenderSizeAnyDimen,r=Math.abs(e.x)<o||Math.abs(e.y)<o;return i||r}}e.default=c},6377: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 o=n(5378),r=i(n(7369));class s extends r.default{constructor(t){super(t),this.clearedCount=0,this.renderedPathCount=0,this.lastFillStyle=null,this.lastPoint=null,this.objectNestingLevel=0,this.lastText=null,this.lastImage=null,this.pointBuffer=[]}displaySize(){const t=this.getViewport().getScreenRectSize();return 0===t.x||0===t.y?o.Vec2.of(640,480):t}clear(){if(this.clearedCount++,this.renderedPathCount=0,this.pointBuffer=[],this.lastText=null,this.lastImage=null,this.objectNestingLevel>0)throw new Error(`Within an object while clearing! Nesting level: ${this.objectNestingLevel}`)}beginPath(t){this.lastPoint=t,this.pointBuffer.push(t)}endPath(t){this.renderedPathCount++,this.lastFillStyle=t}lineTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}moveTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n),this.lastPoint=n,this.pointBuffer.push(t,e,n)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(t,e)}drawPoints(...t){}drawText(t,e,n){this.lastText=t}drawImage(t){this.lastImage=t}startObject(t,e){super.startObject(t),this.objectNestingLevel+=1}endObject(){super.endObject(),this.objectNestingLevel-=1}isTooSmallToRender(t){return!1}canRenderFromWithoutDataLoss(t){return t instanceof s}renderFromOtherOfSameType(t,e){if(!(e instanceof s))throw new Error(`${e} cannot be rendered onto ${this}`);this.renderedPathCount+=e.renderedPathCount,this.lastFillStyle=e.lastFillStyle,this.lastPoint=e.lastPoint,this.pointBuffer.push(...e.pointBuffer.map((e=>t.transformVec2(e))))}}e.default=s},2001:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.renderedStylesheetId=void 0;const o=i(n(8015)),r=i(n(2487)),s=n(9036),a=n(5378),l=n(1697),c=n(2500),d=i(n(7369));e.renderedStylesheetId="js-draw-style-sheet";const u="http://www.w3.org/2000/svg",h={fontWeight:"400",fontStyle:"normal"};class p 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=h,this.clear(),this.addStyleSheet()}addStyleSheet(){if(!this.elem.querySelector(`#${e.renderedStylesheetId}`)){const t=document.createElementNS("http://www.w3.org/2000/svg","style");t.innerHTML="\n\t\t\t\tpath {\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t}\n\n\t\t\t\ttext {\n\t\t\t\t\twhite-space: pre;\n\t\t\t\t}\n\t\t\t".replace(/\s+/g,""),t.setAttribute("id",e.renderedStylesheetId),this.elem.appendChild(t)}}setRootSVGAttribute(t,e){this.sanitize||(t in this.overwrittenAttrs||(this.overwrittenAttrs[t]=this.elem.getAttribute(t)),null!==e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t))}displaySize(){return 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=r.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 r=n?t:this.getCanvasToScreenTransform().rightMul(t);const l=r.transformVec2(a.Vec2.zero);i&&(r=r.rightMul(o.default.translation(l.times(-1)))),r.eq(o.default.identity)?e.style.transform="":e.style.transform=`matrix(\n\t\t\t\t${r.a1}, ${r.b1},\n\t\t\t\t${r.a2}, ${r.b2},\n\t\t\t\t${r.a3}, ${r.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 o=(t,e)=>{var n,i,o,r,s,a,l,c;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!==(o=e.fontVariant)&&void 0!==o?o:""),e.fontWeight!==(null===(r=this.textParentStyle)||void 0===r?void 0:r.fontWeight)&&(t.style.fontWeight=null!==(s=e.fontWeight)&&void 0!==s?s:""),e.fontStyle!==(null===(a=this.textParentStyle)||void 0===a?void 0:a.fontStyle)&&(t.style.fontStyle=null!==(l=e.fontStyle)&&void 0!==l?l:""),e.size!==(null===(c=this.textParentStyle)||void 0===c?void 0:c.size)&&(t.style.fontSize=e.size+"px");const d=e.renderingStyle.fill.toHexString();if(t.style.fill=d,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 r=(e=this.textContainerTransform.inverse().rightMul(e)).transformVec2(a.Vec2.zero);i.setAttribute("x",`${(0,s.toRoundedString)(r.x)}`),i.setAttribute("y",`${(0,s.toRoundedString)(r.y)}`),o(i,n)}else{const r=document.createElementNS(u,"text");r.appendChild(document.createTextNode(t));const s=!1;this.transformFrom(e,r,!0,s),o(r,n),this.elem.appendChild(r),null===(i=this.objectElems)||void 0===i||i.push(r),this.objectLevel>0&&(this.textContainer=r,this.textContainerTransform=e,this.textParentStyle=Object.assign(Object.assign({},h),n))}}drawImage(t){var e,n,i,o,r,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!==(o=t.image.getAttribute("width"))&&void 0!==o?o:""),l.setAttribute("height",null!==(r=t.image.getAttribute("height"))&&void 0!==r?r:""),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=h,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"),o=t.getScreenRectSize();return i.setAttribute("viewBox",[0,0,o.x,o.y].map((t=>(0,s.toRoundedString)(t))).join(" ")),i.setAttribute("width",(0,s.toRoundedString)(o.x)),i.setAttribute("height",(0,s.toRoundedString)(o.y)),i.setAttribute("version","1.1"),i.setAttribute("baseProfile","full"),i.setAttribute("xmlns",n),{element:i,renderer:new p(i,t,e)}}}e.default=p},1263: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 o=n(5378),r=i(n(7369));class s extends r.default{constructor(t,e){super(t),this.localizationTable=e,this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}displaySize(){return o.Vec2.of(500,500)}clear(){this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}getDescription(){return[this.localizationTable.pathNodeCount(this.pathCount),...this.textNodeCount>0?[this.localizationTable.textNodeCount(this.textNodeCount)]:[],...this.imageNodeCount>0?[this.localizationTable.imageNodeCount(this.imageNodeCount)]:[],...this.descriptionBuilder].join("\n")}beginPath(t){}endPath(t){this.pathCount++}lineTo(t){}moveTo(t){}traceCubicBezierCurve(t,e,n){}traceQuadraticBezierCurve(t,e){}drawText(t,e,n){this.descriptionBuilder.push(this.localizationTable.textNode(t)),this.textNodeCount++}drawImage(t){const e=t.label?this.localizationTable.imageNode(t.label):this.localizationTable.unlabeledImageNode;this.descriptionBuilder.push(e),this.imageNodeCount++}isTooSmallToRender(t){return t.maxDimension<15/this.getSizeOfCanvasPixelOnScreen()}drawPoints(...t){}}e.default=s},7:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{constructor(t){this.key=t.key,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.controlOrMeta=t.controlOrMeta}matchesEvent(t){var e,n,i,o,r,s,a,l,c,d;const u=null===(e=t.key)||void 0===e?void 0:e.toLowerCase(),h=(null===(n=t.key)||void 0===n?void 0:n.toUpperCase())===t.key&&(null===(i=t.key)||void 0===i?void 0:i.toLowerCase())!==t.key&&1===(null===(o=t.key)||void 0===o?void 0:o.length),p=(null===(r=t.key)||void 0===r?void 0:r.toLowerCase())===t.key&&!h&&1===(null===(s=t.key)||void 0===s?void 0:s.length),f=null!==(a=t.ctrlKey)&&void 0!==a&&a||"control"===u,m=null!==(l=t.altKey)&&void 0!==l&&l||"alt"===u,g=null!==(c=t.metaKey)&&void 0!==c&&c||"meta"===u,v=(null!==(d=t.shiftKey)&&void 0!==d?d:h)||"shift"===u,y=t.controlOrMeta||t.ctrlKey||t.metaKey||!1;if(this.key.toLowerCase()!==u)return!1;if((h||p)&&this.key!==t.key){if(!(!0===this.shiftKey&&this.key.toUpperCase()===t.key))return!1}const b=this.controlOrMeta;return(f===this.ctrlKey&&g===this.metaKey&&!b||b&&y)&&m===this.altKey&&(v===this.shiftKey||void 0===this.shiftKey)}toString(){const t=[];return this.ctrlKey&&"control"!==this.key&&t.push("Ctrl"),this.controlOrMeta&&t.push("CtrlOrMeta"),this.altKey&&"alt"!==this.key&&t.push("Alt"),this.metaKey&&"meta"!==this.key&&t.push("Meta"),this.shiftKey&&"shift"!==this.key&&t.push("Shift"),t.push(this.key),t.join("+")}static fromString(t){var e;if(-1===t.search(/[-+]/)||1===t.length){const e=t.toLowerCase();let i;return"shift"===e&&(i=!0),new n({key:t,shiftKey:i,ctrlKey:"control"===e||"ctrl"===e,altKey:"alt"===e,metaKey:"meta"===e,controlOrMeta:"control or meta"===e||"ctrlormeta"===e})}const i=/^(.*[-+])?(.+)$/g.exec(t);if(!i)throw new Error(`Invalid shortcut expression, ${t}!`);const o=i[2],r=(null!==(e=i[1])&&void 0!==e?e:"").split(/[-+]/);let s,a=!1,l=!1,c=!1,d=!1;for(const e of r)if(""!==e)switch(e.toLowerCase()){case"shift":s=!0;break;case"noshift":s=!1;break;case"ctrl":case"control":a=!0;break;case"meta":c=!0;break;case"ctrlormeta":case"ctrl or meta":case"controlormeta":d=!0;break;case"alt":l=!0;break;default:throw new Error(`Unknown modifier: "${e}" in shortcut ${t}.`)}return new n({key:o,shiftKey:s,ctrlKey:a,altKey:l,metaKey:c,controlOrMeta:d})}}e.default=n},5376: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 o=n(1906),r=i(n(7));class s{constructor(t){this.shortcutOverrides=Object.create(null);for(const e in t)this.overrideShortcut(e,t[e])}overrideShortcut(t,e){this.shortcutOverrides[t]=[...e]}matchesShortcut(t,e){let n=this.shortcutOverrides[t];if(!n){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);n=s.shortcuts[t]}for(const t of n)if(t.matchesEvent(e))return!0;return!1}static registerDefaultKeyboardShortcut(t,e,n){if(t in s.shortcuts)return!1;const i=e.map((t=>"string"==typeof t?r.default.fromString(t):t));return s.shortcuts[t]=[...i],s.shortcutDefaultDescriptions[t]=n,!0}static provideShortcutDescription(t,e,n){e in s.shortcutLocalizedDescriptions||(s.shortcutLocalizedDescriptions[e]=Object.create(null)),s.shortcutLocalizedDescriptions[e][t]=n}static getAllShortcutIds(){const t=[];for(const e in this.shortcuts)t.push(e);return t}static getShortcutDefaultKeybindings(t){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);return s.shortcuts[t]}static getShortcutDescription(t,e){var n,i;return null!==(i=null!==(n=(0,o.matchingLocalizationTable)(null!=e?e:[],this.shortcutLocalizedDescriptions,this.shortcutDefaultDescriptions)[t])&&void 0!==n?n:this.shortcutDefaultDescriptions[t])&&void 0!==i?i:null}}s.shortcuts=Object.create(null),s.shortcutDefaultDescriptions=Object.create(null),s.shortcutLocalizedDescriptions=Object.create(null),e.default=s},6843:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBinding=e.KeyboardShortcutManager=void 0;var o=n(5376);Object.defineProperty(e,"KeyboardShortcutManager",{enumerable:!0,get:function(){return i(o).default}});var r=n(7);Object.defineProperty(e,"KeyBinding",{enumerable:!0,get:function(){return i(r).default}})},1797: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 o=n(1380);Object.defineProperty(e,"sendPenEvent",{enumerable:!0,get:function(){return i(o).default}});var r=n(8783);Object.defineProperty(e,"sendTouchEvent",{enumerable:!0,get:function(){return i(r).default}})},1380: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 o=i(n(4318)),r=n(3173);e.default=(t,e,n,i)=>{const s=o.default.ofCanvasPoint(n,e!==r.InputEvtType.PointerUpEvt,t.viewport);t.toolController.dispatchInputEvent({kind:e,allPointers:null!=i?i:[s],current:s})}},8783:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});const s=r(n(4318)),a=n(3173);e.default=(t,e,n,i)=>{const o=t.viewport.screenToCanvas(n);let r=0,l=0;for(const t of null!=i?i:[])l=Math.max(t.id,l),t.id===r&&(r=l+1);const c=s.default.ofCanvasPoint(o,e!==a.InputEvtType.PointerUpEvt,t.viewport,r,s.PointerDevice.Touch);return t.toolController.dispatchInputEvent({kind:e,allPointers:[...null!=i?i:[],c],current:c}),c}},3808: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 o=n(3173),r=n(5381),s=i(n(3472)),a=n(9746),l=i(n(7591)),c=i(n(4735)),d=i(n(4321)),u=i(n(6416)),h=i(n(2133)),p=i(n(7998)),f=i(n(9944)),m=i(n(5001)),g=i(n(5730)),v=i(n(7956)),y=i(n(3534)),b=i(n(6318)),x=i(n(5771)),w=i(n(3359)),S=n(5378);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.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),T.colorisStarted||((0,r.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.")}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 o,s;const a=S.Vec2.of(i.pageX,i.pageY);let l=!0;if("pointerdown"===e)(0,r.close)(),t=[],t.push([e,i]),n=a,null===(o=this.closeColorPickerOverlay)||void 0===o||o.setPointerCapture(i.pointerId),l=!1;else if("pointermove"===e){const o=10;if(n&&a.minus(n).magnitude()<o)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,r.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(o.EditorEventType.ColorPickerToggled,(t=>{t.kind===o.EditorEventType.ColorPickerToggled&&this.closeColorPickerOverlay&&(this.closeColorPickerOverlay.style.display=t.open?"block":"none")}))),this.listeners.push(this.editor.notifier.on(o.EditorEventType.ColorPickerColorSelected,(i=>{i.kind===o.EditorEventType.ColorPickerColorSelected&&(i=>{let o=!1;for(const e of t)e===i&&(o=!0);o||(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 o=!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,o=!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))}o=!0}this.overflowWidget.setHidden(0===this.overflowWidget.getChildWidgets().length),o&&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,o=new y.default(this.editor,"action-button",(()=>"string"==typeof t?null:t.icon),i,e,this.editor.localization,n);return this.addWidget(o),o}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(o.EditorEventType.UndoRedoStackUpdated,(n=>{if(n.kind!==o.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()}}T.colorisStarted=!1,e.default=T},8282: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 o=i(n(3472)),r=n(5378),s=i(n(2001)),a=i(n(5566)),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 o=document.createElementNS(l,"svg"),r=document.createElementNS(l,"path");return r.setAttribute("d",t),r.style.fill=e,r.style.stroke=n,r.style.strokeWidth=i,o.appendChild(r),o.setAttribute("viewBox","0 0 100 100"),o}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 o=document.createElementNS(l,"text");o.appendChild(document.createTextNode(e)),o.setAttribute("x",n.toString()),o.setAttribute("y",i.toString()),o.style.textAlign="center",o.style.textAnchor="middle",o.style.fontSize="55px",o.style.fill="var(--icon-color)",o.style.fontFamily="monospace",t.appendChild(o)};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 o=document.createElementNS(l,"text");return o.appendChild(document.createTextNode("T")),o.style.fontFamily=t.fontFamily,o.style.fontWeight=null!==(e=t.fontWeight)&&void 0!==e?e:"",o.style.fontVariant=null!==(n=t.fontVariant)&&void 0!==n?n:"",o.style.fill=t.renderingStyle.fill.toHexString(),o.style.textAnchor="middle",o.setAttribute("x","50"),o.setAttribute("y","75"),o.style.fontSize="65px",o.style.filter="drop-shadow(0px 0px 10px var(--primary-shadow-color))",i.appendChild(o),i}makePenIcon(t,e,n){e instanceof o.default&&(e=e.toHexString());const i=document.createElementNS(l,"svg");i.setAttribute("viewBox","0 0 100 100");const r=t/2,s=`\n\t\t\tM ${15-r},${80-r}\n\t\t\t ${15-r},${80+r}\n\t\t\t 30,83\n\t\t\t 15,65\n\t\t\tZ\n\t\t`,a=80+r,c=`\n\t\t\tm ${15-1.1*r},${a}\n\t\t\tc 35,10 55,15 60,30\n\t\t\tl ${35+1.2*r},${-10-r}\n\t\t\tC 80.47,98.32 50.5,${90+r} 20,${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-r/4},${70-r/2} 20,75 25,85 60,75 70,55 45,25 Z`,v=o.default.fromHex("#f4d7d7").mix(o.default.fromString(e),r/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(),o={pos:r.Vec2.of(10,10),width:n,color:t.getColor(),time:i-100},c={pos:r.Vec2.of(90,90),width:n,color:t.getColor(),time:i},d=new a.default((()=>{})),u=e(o,d);u.addPoint(c);const h=document.createElementNS(l,"svg");h.setAttribute("viewBox","0 0 100 100"),d.updateScreenSize(r.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"),o=document.createElementNS(l,"path"),r="\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";o.setAttribute("d",r),i.setAttribute("d",r),o.style.fill=t.toHexString(),i.style.fill=u,e.appendChild(i),e.appendChild(o)}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")}}},2994:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.IconProvider=void 0,o(n(7321),e),o(n(6528),e);var s=n(8282);Object.defineProperty(e,"IconProvider",{enumerable:!0,get:function(){return r(s).default}})},9746:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarLocalization=void 0,e.defaultToolbarLocalization={pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text: ",chooseFile:"Choose file: ",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",outlinedCirclePen:"Outlined circle",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}`}},6528: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 o=i(n(3472)),r=i(n(5248)),s=n(3173);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 r=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=o.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}),r.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 o=e=>{i.replaceChildren(t.icons.makePipetteIcon(e))};o();const s=t.toolController.getMatchingTools(r.default)[0],a=()=>{null==s||s.clearColorListener(),o(),i.classList.remove("active")},l=t=>{a(),t&&n(t)},c=t=>{t?o(t):o()};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},3534: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 o=i(n(3258));class r extends o.default{constructor(t,e,n,i,o,r,s=!1){super(t,e,r),this.makeIcon=n,this.title=i,this.clickAction=o,this.mustBeToplevel=s}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}canBeInOverflowMenu(){return!this.mustBeToplevel}}e.default=r},1421: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 o=n(3173),r=i(n(3258));class s extends r.default{constructor(t,e,n,i){super(t,n,i),this.targetTool=e,t.notifier.on(o.EditorEventType.ToolEnabled,(t=>{if(t.kind!==o.EditorEventType.ToolEnabled)throw new Error("Incorrect event type! (Expected ToolEnabled)");t.tool===e&&this.setSelected(!0)})),t.notifier.on(o.EditorEventType.ToolDisabled,(t=>{if(t.kind!==o.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},3258:function(t,e,n){"use strict";var i,o=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n},r=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(6390)),l=n(3173),c=n(3808);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.hideDropdownTimeout=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"),o(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 r=this.editor.toolController.getMatchingTools(a.default);r.length>0&&this.onKeyPress!==d.prototype.onKeyPress&&r[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 r(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),this.dropdownContainer.replaceChildren(),o(this,i,this.fillDropdown(this.dropdownContainer),"f"),r(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){if(this.container.classList.contains("dropdownVisible")===t)return;this.hideDropdownTimeout&&(clearTimeout(this.hideDropdownTimeout),this.hideDropdownTimeout=null,this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown());if(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.repositionDropdown();else{this.container.classList.remove("dropdownVisible"),this.editor.announceForAccessibility(this.localizationTable.dropdownHidden(this.getTitle())),this.dropdownContainer.classList.add("hiding");const t=142.5;this.hideDropdownTimeout=setTimeout((()=>{this.dropdownContainer.classList.add("hidden"),this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown()}),t)}const e=`var(--dropdown-${t?"show":"hide"}-animation)`;this.dropdownContainer.style.animation=`150ms ease ${e}`}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.translate=`calc(${this.button.clientWidth+"px"} - 100%) 0`:this.dropdownContainer.style.translate=""}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])}}i=new WeakMap,e.default=d},5771:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(9721)),l=s(n(1456)),c=r(n(1847)),d=n(7551),u=s(n(8947)),h=n(3173),p=n(3808),f=s(n(6528)),m=s(n(3258));class g extends m.default{constructor(t,e){super(t,"document-properties-widget",e),this.updateDropdownContent=()=>{},this.dropdownUpdateQueued=!1,this.container.classList.add("dropdownShowable"),this.editor.notifier.on(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),o=this.editor.getImportExportRect(),r=new u.default(o.x,o.y,null!=n?n:o.w,null!=i?i:o.h);this.editor.dispatch(this.editor.image.setImportExportRect(r)),this.editor.queueRerender()}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("label");i.innerText=this.localizationTable.backgroundColor;const[o,r,s]=(0,f.default)(this.editor,(t=>{t.eq(this.getBackgroundColor())||this.setBackgroundColor(t)}));o.id=`${p.toolbarCSSPrefix}docPropertiesColorInput-${g.idCounter++}`,i.htmlFor=o.id,n.replaceChildren(i,r);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"),o=document.createElement("span"),r=document.createElement("input");return i.innerText=t,r.type="number",r.min="0",r.id=`${p.toolbarCSSPrefix}docPropertiesDimensionRow-${g.idCounter++}`,i.htmlFor=r.id,o.style.flexGrow="1",r.style.flexGrow="2",r.style.width="25px",n.style.display="flex",r.oninput=()=>{e(parseFloat(r.value))},n.replaceChildren(i,o,r),{setValue:t=>{r.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},9944: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 o=n(3173),r=n(3808),s=i(n(1421));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(o.EditorEventType.ToolUpdated,(t=>{t.kind===o.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=`${r.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},7956:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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(8015)),l=r(n(4735)),c=n(3173),d=s(n(5566)),u=n(3808),h=s(n(1421)),p=s(n(3258));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"),o=document.createElement("button"),r=document.createElement("button"),s=document.createElement("span");let l;i.innerText="+",o.innerText="-",r.innerText=t.resetView,n.replaceChildren(s,i,o,r),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(),r.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)},o.onclick=()=>{p(.8)},r.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,o,r){super(t,`pan-mode-${n}`,r),this.tool=e,this.flag=n,this.makeIcon=i,this.title=o,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 o=new m(t,e,l.PanZoomMode.OneFingerTouchGestures,(()=>this.editor.icons.makeTouchPanningIcon()),n.touchPanning,n),r=new m(t,e,l.PanZoomMode.RotationLocked,(()=>this.editor.icons.makeRotationLockIcon()),n.lockRotation,n);this.addSubWidget(o),this.addSubWidget(r),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},6318:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(7077)),s=o(n(9721)),a=o(n(7551)),l=o(n(1456)),c=o(n(7591)),d=o(n(8015)),u=o(n(9070)),h=o(n(3534));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 o=document.createElement("div");o.classList.add("action-button-row"),this.submitButton=document.createElement("button");const r=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"),r.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="")})),r.onclick=()=>{this.hideDialog()},this.imageSelectionOverlay.onclick=t=>{t.target===this.imageSelectionOverlay&&this.hideDialog()},e.replaceChildren(s,this.imageFileInput),n.replaceChildren(a,this.imageAltTextInput),o.replaceChildren(r,this.submitButton),t.replaceChildren(e,n,this.imagePreview,this.statusView,o),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",o=e;n>=1&&(o=n,i="MiB"),this.statusView.innerText=this.localizationTable.imageSize(Math.round(o),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 o=null;1===n.length&&n[0]instanceof r.default?(o=n[0],this.imageAltTextInput.value=null!==(t=o.getAltText())&&void 0!==t?t:"",this.imagePreview.style.display="block",this.submitButton.disabled=!1,this.imageBase64URL=o.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 r.default.fromImage(n,d.default.identity);if(0!==i.getBBox().area)if(this.imageSelectionOverlay.style.display="none",o){const n=new s.default([o]);yield this.editor.dispatch((0,l.default)([a.default.addElement(i),i.transformBy(o.getTransformation()),i.setZIndex(o.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},3359: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 o=i(n(3258));class r extends o.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=r},7998: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 o=n(9274),r=n(6951),s=n(823),a=n(725),l=n(4666),c=n(7973),d=n(3173),u=n(3808),h=i(n(6528)),p=i(n(1421)),f=i(n(3472)),m=n(3240);class g extends p.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:r.makeFreehandLineBuilder},{name:this.localizationTable.arrowPen,id:"arrow",factory:o.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},{name:this.localizationTable.outlinedCirclePen,id:"outlined-circle",factory:c.makeOutlinedCircleBuilder}],this.editor.notifier.on(d.EditorEventType.ToolUpdated,(t=>{if(t.kind!==d.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");t.tool===this.tool&&(this.updateIcon(),this.updateInputs())}))}getTitle(){return this.targetTool.description}getCurrentPenTypeIdx(){const t=this.tool.getStrokeFactory();for(let e=0;e<this.penTypes.length;e++)if(this.penTypes[e].factory===t)return e;return-1}getCurrentPenType(){for(const t of this.penTypes)if(t.factory===this.tool.getStrokeFactory())return t;return null}createIcon(){const t=this.tool.getStrokeFactory();if(t===r.makeFreehandLineBuilder||t===s.makePressureSensitiveFreehandLineBuilder){const e=Math.round(4*Math.sqrt(this.tool.getThickness())),n=this.tool.getColor(),i=t===r.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(`${u.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("div"),o=document.createElement("label"),r=document.createElement("input"),s=document.createElement("label"),a=document.createElement("select");r.id=`${u.toolbarCSSPrefix}penThicknessInput${g.idCounter++}`,a.id=`${u.toolbarCSSPrefix}penBuilderSelect${g.idCounter++}`,o.innerText=this.localizationTable.thicknessLabel,o.setAttribute("for",r.id),s.innerText=this.localizationTable.selectPenType,s.setAttribute("for",a.id);const l=t=>Math.log10(t);r.type="range",r.min=`${l(2)}`,r.max=`${l(400)}`,r.step="0.1",r.oninput=()=>{this.tool.setThickness((t=>Math.pow(10,t))(parseFloat(r.value)))},n.appendChild(o),n.appendChild(r),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"),d=document.createElement("label"),[p,f,m]=(0,h.default)(this.editor,(t=>{this.tool.setColor(t)}));return p.id=`${u.toolbarCSSPrefix}colorInput${g.idCounter++}`,d.innerText=this.localizationTable.colorLabel,d.setAttribute("for",p.id),c.appendChild(d),c.appendChild(f),this.updateInputs=()=>{m(this.tool.getColor()),r.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;for(let e=0;e<m.selectStrokeTypeKeyboardShortcutIds.length;e++){const n=m.selectStrokeTypeKeyboardShortcutIds[e];if(this.editor.shortcuts.matchesShortcut(n,t)){const t=e;if(t<this.penTypes.length)return this.tool.setStrokeFactory(this.penTypes[t].factory),!0}}return!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(f.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}}}}g.idCounter=0,e.default=g},5001:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(3472)),s=n(739),a=o(n(1456)),l=n(3173),c=o(n(6528)),d=o(n(3534)),u=o(n(1421)),h=o(n(3258)),p=n(3240);class f 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"),[o,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){o.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(r.default.average(e))}else o.disabled=!0},n.replaceChildren(i,l),e.replaceChildren(n),t.replaceChildren(e),!0}}class m extends u.default{constructor(t,e,n){super(t,e,"selection-tool-widget",n),this.tool=e;const o=new d.default(t,"resize-btn",(()=>t.icons.makeResizeViewportIcon()),this.localizationTable.resizeImageToSelection,(()=>{this.resizeImageToSelection()}),n),r=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 f(t,this.tool,n);this.addSubWidget(o),this.addSubWidget(r),this.addSubWidget(s),this.addSubWidget(a);const c=t=>{o.setDisabled(t),r.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!!this.editor.shortcuts.matchesShortcut(p.resizeImageToSelectionKeyboardShortcut,t)&&(this.resizeImageToSelection(),!0)}getTitle(){return this.localizationTable.select}createIcon(){return this.editor.icons.makeSelectionIcon()}}e.default=m},5730: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 o=i(n(3472)),r=n(3173),s=n(3808),a=i(n(6528)),l=i(n(1421));class c extends l.default{constructor(t,e,n){super(t,e,"text-tool-widget",n),this.tool=e,this.updateDropdownInputs=null,t.notifier.on(r.EditorEventType.ToolUpdated,(t=>{var n;t.kind===r.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"),o=document.createElement("div"),r=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,r.appendChild(e),g.add(t)};return d.setAttribute("type","number"),d.min="1",d.max="128",l.innerText=this.localizationTable.fontLabel,m.innerText=this.localizationTable.colorLabel,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"),r.id=`${s.toolbarCSSPrefix}-text-font-input-${c.idCounter++}`,l.setAttribute("for",r.id),r.onchange=()=>{this.tool.setFontFamily(r.value)},d.onchange=()=>{const t=parseInt(d.value);!isNaN(t)&&t>0&&this.tool.setFontSize(t)},i.appendChild(m),i.appendChild(p),n.appendChild(l),n.appendChild(r),o.appendChild(u),o.appendChild(d),this.updateDropdownInputs=()=>{const t=this.tool.getTextStyle();f(t.renderingStyle.fill),g.has(t.fontFamily)||v(t.fontFamily),r.value=t.fontFamily,d.value=`${t.size}`},this.updateDropdownInputs(),e.replaceChildren(i,o,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(o.default.fromHex(t.color)),t.textSize&&"number"==typeof t.textSize&&this.tool.setFontSize(t.textSize),super.deserializeFrom(t)}}c.idCounter=0,e.default=c},3240: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.selectStrokeTypeKeyboardShortcutIds=e.resizeImageToSelectionKeyboardShortcut=void 0;const o=i(n(5376));e.resizeImageToSelectionKeyboardShortcut="jsdraw.toolbar.SelectionTool.resizeImageToSelection",o.default.registerDefaultKeyboardShortcut(e.resizeImageToSelectionKeyboardShortcut,["ctrlOrMeta+r"],"Resize image to selection"),e.selectStrokeTypeKeyboardShortcutIds=[1,2,3,4,5,6,7].map((t=>`jsdraw.toolbar.PenTool.select-pen-${t}`));for(let t=0;t<e.selectStrokeTypeKeyboardShortcutIds.length;t++){const n=e.selectStrokeTypeKeyboardShortcutIds[t];o.default.registerDefaultKeyboardShortcut(n,[`ctrlOrMeta+${t+1}`],"Select pen style "+(t+1))}},7321: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 o=n(3534);Object.defineProperty(e,"ActionButtonWidget",{enumerable:!0,get:function(){return i(o).default}});var r=n(1421);Object.defineProperty(e,"BaseToolWidget",{enumerable:!0,get:function(){return i(r).default}});var s=n(3258);Object.defineProperty(e,"BaseWidget",{enumerable:!0,get:function(){return i(s).default}});var a=n(7998);Object.defineProperty(e,"PenToolWidget",{enumerable:!0,get:function(){return i(a).default}});var l=n(5730);Object.defineProperty(e,"TextToolWidget",{enumerable:!0,get:function(){return i(l).default}});var c=n(7956);Object.defineProperty(e,"HandToolWidget",{enumerable:!0,get:function(){return i(c).default}});var d=n(5001);Object.defineProperty(e,"SelectionToolWidget",{enumerable:!0,get:function(){return i(d).default}});var u=n(9944);Object.defineProperty(e,"EraserToolWidget",{enumerable:!0,get:function(){return i(u).default}});var h=n(6318);Object.defineProperty(e,"InsertImageWidget",{enumerable:!0,get:function(){return i(h).default}});var p=n(5771);Object.defineProperty(e,"DocumentPropertiesWidget",{enumerable:!0,get:function(){return i(p).default}})},7564:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173);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}}},6416: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 o=n(3173),r=i(n(7564)),s=n(5378),a=i(n(1885)),l=i(n(9721)),c=n(4318),d=i(n(3472)),u=i(n(8947)),h=n(3348);class p extends r.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),o={fill:d.default.gray};n.drawRect(i,e/4,o)}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),o=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t.intersects(n)||t.intersectsRect(e))).filter((t=>t.isSelectable()));this.toRemove.push(...o);const r=o.map((t=>new l.default([t])));r.forEach((t=>t.apply(this.editor))),this.partialCommands.push(...r),this.drawPreviewAt(t),this.lastPoint=t}onPointerDown(t){return(1===t.allPointers.length||t.current.device===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()}onKeyPress(t){const e=this.editor.shortcuts;let n;return e.matchesShortcut(h.decreaseSizeKeyboardShortcutId,t)?n=2*this.getThickness()/3:e.matchesShortcut(h.increaseSizeKeyboardShortcutId,t)&&(n=3*this.getThickness()/2),void 0!==n&&(n=Math.min(Math.max(1,n),200),this.setThickness(n),!0)}getThickness(){return this.thickness}setThickness(t){this.thickness=t,this.editor.notifier.dispatch(o.EditorEventType.ToolUpdated,{kind:o.EditorEventType.ToolUpdated,tool:this})}}e.default=p},5805: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 o=i(n(1151)),r=i(n(7564)),s=n(3348),a="find-tool";class l extends r.default{constructor(t){super(t.notifier,t.localization.findLabel),this.editor=t,this.currentMatchIdx=0,this.overlay=document.createElement("div"),this.fillOverlay(),t.createHTMLOverlay(this.overlay),this.overlay.style.display="none",this.overlay.classList.add(`${a}-overlay`)}getMatches(t){t=t.toLocaleLowerCase();return this.editor.image.getAllElements().filter((t=>t instanceof o.default)).filter((e=>-1!==e.getText().toLocaleLowerCase().indexOf(t))).map((t=>t.getBBox()))}focusCurrentMatch(){const t=this.getMatches(this.searchInput.value);let e=this.currentMatchIdx%t.length;if(e<0&&(e=t.length+e),e<t.length){const n=!1;this.editor.dispatch(this.editor.viewport.zoomTo(t[e],!0,!0),n),this.editor.announceForAccessibility(this.editor.localization.focusedFoundText(e+1,t.length))}}toNextMatch(){this.currentMatchIdx++,this.focusCurrentMatch()}toPrevMatch(){this.currentMatchIdx--,this.focusCurrentMatch()}fillOverlay(){const t=document.createElement("label");this.searchInput=document.createElement("input");const e=document.createElement("button"),n=document.createElement("button");this.searchInput.setAttribute("id",`${a}-searchInput-${Math.random()}`),t.htmlFor=this.searchInput.getAttribute("id"),t.innerText=this.editor.localization.findLabel,e.innerText=this.editor.localization.toNextMatch,n.innerText=this.editor.localization.closeFindDialog,this.searchInput.onkeydown=t=>{"Enter"===t.key?t.shiftKey?this.toPrevMatch():this.toNextMatch():"Escape"===t.key?this.setVisible(!1):this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(t.preventDefault(),this.toggleVisible())},e.onclick=()=>{this.toNextMatch()},n.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(t,this.searchInput,e,n)}isVisible(){return"none"!==this.overlay.style.display}setVisible(t){t!==this.isVisible()&&(this.overlay.style.display=t?"block":"none",t?(this.searchInput.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogShown)):(this.editor.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogHidden)))}toggleVisible(){this.setVisible(!this.isVisible())}onKeyPress(t){return!!this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(this.toggleVisible(),!0)}setEnabled(t){super.setEnabled(t),t&&this.setVisible(!1)}}e.default=l},4735:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanZoomMode=void 0;const r=o(n(8015)),s=n(5378),a=o(n(1486)),l=n(4318),c=n(3173),d=o(n(7395)),u=n(5566),h=o(n(7564)),p=n(3348);var f;!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"}(f||(e.PanZoomMode=f={}));class m{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 g 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(),o=n.magnitude();return{canvasCenter:e.canvasPos.plus(t.canvasPos).times(.5),screenCenter:e.screenPos.plus(t.screenPos).times(.5),angle:i,dist:o}}allPointersAreOfType(t,e){return t.every((t=>t.device===e))}onPointerDown({allPointers:t,current:e}){var n,i,o,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===(o=this.inertialScroller)||void 0===o||o.stop(),this.velocity=d,this.lastPointerDownTimestamp=e.timeStamp;const h=this.allPointersAreOfType(t,l.PointerDevice.Touch),p=this.allPointersAreOfType(t,l.PointerDevice.RightButtonMouse);if(h&&2===t.length&&this.mode&f.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&f.OneFingerTouchGestures&&h||p&&this.mode&f.RightClickDrags||this.mode&f.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(r.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 o=i;this.velocity&&(o=this.velocity.lerp(i,.5)),this.velocity=o}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:o}=this.computePinchData(t[0],t[1]),s=this.getCenterDelta(e);let a;a=this.isRotationLocked()?0:this.toSnappedRotationDelta(i),this.updateVelocity(e);const l=r.default.translation(s).rightMul(r.default.scaling2D(o/this.lastDist,n)).rightMul(r.default.zRotation(a,n));this.lastScreenCenter=e,this.lastDist=o,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(r.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(r.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 m(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(r.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(r.default.identity);const i=this.editor.viewport.screenToCanvas(e),o=this.editor.viewport.screenToCanvasTransform.transformVec3(a.default.of(-t.x,-t.y,0)),s=r.default.scaling2D(Math.max(.25,Math.min(Math.pow(1.03,-t.z),4)),i).rightMul(r.default.translation(o));return this.updateTransform(s,!0),!0}onKeyPress(t){var e;if(null===(e=this.inertialScroller)||void 0===e||e.stop(),!(this.mode&f.Keyboard))return!1;this.transform=u.Viewport.transformBy(r.default.identity);let n=s.Vec2.zero,i=1,o=0;const a=this.editor.shortcuts;if(a.matchesShortcut(p.moveLeftKeyboardShortcutId,t))n=s.Vec2.of(-1,0);else if(a.matchesShortcut(p.moveRightKeyboardShortcutId,t))n=s.Vec2.of(1,0);else if(a.matchesShortcut(p.moveUpKeyboardShortcutId,t))n=s.Vec2.of(0,-1);else if(a.matchesShortcut(p.moveDownKeyboardShortcutId,t))n=s.Vec2.of(0,1);else if(a.matchesShortcut(p.zoomInKeyboardShortcutId,t))i=.5;else if(a.matchesShortcut(p.zoomOutKeyboardShortcutId,t))i=2;else if(a.matchesShortcut(p.rotateClockwiseKeyboardShortcutId,t))o=1;else{if(!a.matchesShortcut(p.rotateCounterClockwiseKeyboardShortcutId,t))return!1;o=-1}n=n.times(30),o*=Math.PI/8,n=n.times(-1),o*=-1,i=1/i,0!==o&&(o+=1e-4),this.isRotationLocked()&&(o=0);n=this.editor.viewport.screenToCanvasTransform.transformVec3(n);const l=this.editor.viewport.visibleRect.center,c=r.default.scaling2D(i,l).rightMul(r.default.zRotation(o,l)).rightMul(r.default.translation(n));return this.updateTransform(c,!0),!0}isRotationLocked(){return!!(this.mode&f.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=g},2719:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(1151)),s=o(n(1697)),a=o(n(8015)),l=o(n(7564)),c=o(n(4321)),d=o(n(3472)),u=o(n(7077));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 o={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:o,l=t.split("\n");yield this.addComponentsFromPaste([r.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},2133: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 o=i(n(7551)),r=n(4318),s=n(6951),a=n(3173),l=i(n(7564)),c=n(3348),d=n(3348);class u 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.startPoint=null,this.snapToGridEnabled=!1,this.angleLockEnabled=!1}getPressureMultiplier(){return 1/this.editor.viewport.getScaleFactor()*this.style.thickness}xyAxesSnap(t){if(!this.startPoint)return t;const e=this.editor.viewport.canvasToScreen(this.startPoint.pos);return t.lockedToXYAxesScreen(e,this.editor.viewport)}toStrokePoint(t){var e;this.angleLockEnabled&&this.lastPoint&&(t=this.xyAxesSnap(t)),this.snapToGridEnabled&&(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===r.PointerDevice.Eraser;let i=!1;for(const t of e)if(t.device===r.PointerDevice.Pen){i=!0;break}return!((1!==e.length||n)&&!i)&&(this.startPoint=this.toStrokePoint(t),this.builder=this.builderFactory(this.startPoint,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),o=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(o),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=o.default.addElement(t,e);this.editor.dispatch(n)}else console.warn("Pen: Not adding empty stroke",t,"to the canvas.")}this.builder=null,this.lastPoint=null,this.editor.clearWetInk()}noteUpdated(){this.editor.notifier.dispatch(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.snapToGridEnabled=!1}onKeyPress(t){const e=this.editor.shortcuts,n=e.matchesShortcut(c.undoKeyboardShortcutId,t);if(this.builder&&n)return this.finalizeStroke(),!1;let i;return e.matchesShortcut(d.decreaseSizeKeyboardShortcutId,t)?i=2*this.getThickness()/3:e.matchesShortcut(d.increaseSizeKeyboardShortcutId,t)&&(i=3*this.getThickness()/2),void 0!==i?(i=Math.min(Math.max(1,i),256),this.setThickness(i),!0):e.matchesShortcut(d.snapToGridKeyboardShortcutId,t)?(this.snapToGridEnabled=!0,!0):!!e.matchesShortcut(d.lineLockKeyboardShortcutId,t)&&(this.angleLockEnabled=!0,!0)}onKeyUp(t){const e=this.editor.shortcuts;return e.matchesShortcut(d.snapToGridKeyboardShortcutId,t)?(this.snapToGridEnabled=!1,!0):!!e.matchesShortcut(d.lineLockKeyboardShortcutId,t)&&(this.angleLockEnabled=!1,!0)}}e.default=u},5248: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 o=i(n(7564));class r extends o.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=r},8519: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 o=i(n(7564)),r=n(3348),s=i(n(7591));class a extends o.default{constructor(t){super(t.notifier,t.localization.selectAllTool),this.editor=t}onKeyPress(t){if(this.editor.shortcuts.matchesShortcut(r.selectAllKeyboardShortcut,t)){const t=this.editor.toolController.getMatchingTools(s.default);if(t.length>0){const e=t[0];return e.setEnabled(!0),e.setSelection(this.editor.image.getAllElements()),!0}}return!1}}e.default=a},2129:function(t,e,n){"use strict";var i,o=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return r(e,t),e},a=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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(6669)),d=l(n(8015)),u=l(n(8947)),h=n(5378),p=s(n(370)),f=n(7591),m=l(n(5566)),g=l(n(9721)),v=l(n(1365)),y=n(8862),b=n(3968),x=l(n(7551));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())),o=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())),r=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=[o,n,i,r];for(const t of this.handles)t.addTo(this.backgroundElem)}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){const t=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 o=new d.default(...t.transform),r=null!==(n=t.elems)&&void 0!==n?n:[];return new i.ApplyTransformationCommand(null,r,o)})),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,o,r;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===(o=this.selection)||void 0===o||o.recomputeRegion(),null===(r=this.selection)||void 0===r||r.updateUI()}))}unapply(t){var e,n,i,o,r;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===(o=this.selection)||void 0===o||o.recomputeRegion(),null===(r=this.selection)||void 0===r||r.updateUI()}))}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray()}}description(t,e){return e.transformedElements(this.selectedElemIds.length)}},e.default=w},370:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.handleSize=e.HandleShape=void 0;const i=n(6585),o=n(5378),r=n(7591);var s;!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square"}(s||(e.HandleShape=s={})),e.handleSize=30;e.default=class{constructor(t,e,n,o,a,l){switch(this.shape=t,this.parentSide=e,this.parent=n,this.onDragStart=o,this.onDragUpdate=a,this.onDragEnd=l,this.dragLastPos=null,this.element=document.createElement("div"),this.element.classList.add(`${r.cssPrefix}handle`),t){case s.Circle:this.element.classList.add(`${r.cssPrefix}circle`);break;case s.Square:this.element.classList.add(`${r.cssPrefix}square`);break;default:(0,i.assertUnreachable)(t)}this.updatePosition()}addTo(t){t.appendChild(this.element)}updatePosition(){const t=this.parent.screenRegion,n=o.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}}},7591: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 o=i(n(8015)),r=n(5378),s=n(3173),a=i(n(5566)),l=i(n(7564)),c=i(n(2001)),d=i(n(2129)),u=i(n(1151)),h=n(3348);e.cssPrefix="selection-tool-";class p extends l.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastEvtTarget=null,this.startPoint=null,this.expandingSelectionBox=!1,this.shiftKeyPressed=!1,this.snapToGrid=!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;this.editor.clearWetInk(),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(o.default.translation(e))),this.selectionBox.finalizeTransform()}onPointerDown({allPointers:t,current:e}){const n=this.snapToGrid;if(n&&(e=e.snappedToGrid(this.editor.viewport)),1===t.length&&e.isPrimary){this.startPoint=e.canvasPos;let t=!1;if(this.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;if(!this.expandingSelectionBox&&this.shiftKeyPressed&&this.startPoint){const t=this.editor.viewport.canvasToScreen(this.startPoint);e=e.lockedToXYAxesScreen(t,this.editor.viewport)}this.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox.onDragUpdate(e):this.selectionBox.setToPoint(e.canvasPos)}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.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBox.setToPoint(e.canvasPos),this.expandingSelectionBox&&this.prevSelectionBox?(this.expandingSelectionBox=!1,this.selectionBox.resolveToObjects(),this.setSelection([...this.selectionBox.getSelectedObjects(),...this.prevSelectionBox.getSelectedObjects()])):this.onGestureEnd()}onGestureCancel(){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){const e=this.editor.shortcuts;if(e.matchesShortcut(h.snapToGridKeyboardShortcutId,t))return this.snapToGrid=!0,!0;if(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t))return!0;if(e.matchesShortcut(h.selectAllKeyboardShortcut,t))return this.setSelection(this.editor.image.getAllElements()),!0;if(t.ctrlKey)return!1;if("Shift"===t.key)return this.shiftKeyPressed=!0,!0;let n=0,i=0,s=0,l=0,c=0;switch(t.key){case"a":case"h":case"ArrowLeft":i-=1;break;case"d":case"l":case"ArrowRight":i+=1;break;case"q":case"k":case"ArrowUp":s-=1;break;case"e":case"j":case"ArrowDown":s+=1;break;case"r":n+=1;break;case"R":n-=1;break;case"i":l-=1;break;case"I":l+=1;break;case"o":c-=1;break;case"O":c+=1}let d=0!==i||0!==s||0!==n||0!==l||0!==c;if(this.selectionBox){if(d){const t=10*this.editor.viewport.getSizeOfPixelOnCanvas(),e=Math.PI/8,d=5/4,u=this.selectionBox.region,h=r.Vec2.of(Math.pow(d,l),Math.pow(d,c)),p=o.default.zRotation(n*e).mapEntries((t=>a.default.roundScaleRatio(t))),f=this.editor.viewport.roundPoint(u.center),m=o.default.scaling2D(h,this.editor.viewport.roundPoint(u.topLeft)).rightMul(o.default.translation(f).rightMul(p).rightMul(o.default.translation(f.times(-1)))).rightMul(o.default.translation(this.editor.viewport.roundPoint(r.Vec2.of(i,s).times(t)))),g=this.selectionBox.getTransform();this.selectionBox.setTransform(g.rightMul(m))}}else d=!1;return!this.selectionBox||d||"Delete"!==t.key&&"Backspace"!==t.key||(this.editor.dispatch(this.selectionBox.deleteSelectedObjects()),this.clearSelection(),d=!0),d}onKeyUp(t){const e=this.editor.shortcuts;return e.matchesShortcut(h.snapToGridKeyboardShortcutId,t)?(this.snapToGrid=!1,!0):!!e.matchesShortcut(h.selectAllKeyboardShortcut,t)||(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t)?(this.selectionBox.duplicateSelectedObjects().then((t=>{this.editor.dispatch(t)})),!0):"Shift"===t.key?(this.shiftKeyPressed=!1,!0):!(!this.selectionBox||!p.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(r.Vec2.of(n.w,n.h)),i.resetTransform(o.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.snapToGrid=!1,this.handleOverlay.style.display=t?"block":"none",t?(this.handleOverlay.tabIndex=0,this.handleOverlay.setAttribute("aria-label",this.editor.localization.selectionToolKeyboardShortcuts)):this.handleOverlay.tabIndex=-1}getSelection(){return this.selectionBox}getSelectedObjects(){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()}}p.handleableKeys=["a","h","ArrowLeft","d","l","ArrowRight","q","k","ArrowUp","e","j","ArrowDown","r","R","i","I","o","O","Control","Meta"],e.default=p},8862: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 o=i(n(8015)),r=n(5378),s=i(n(5566)),a=n(3968);e.DragTransformer=class{constructor(t,e){this.editor=t,this.selection=e}onDragStart(t){this.selection.setTransform(o.default.identity),this.dragStartPoint=t}onDragUpdate(t){const e=this.editor.viewport.roundPoint(t.minus(this.dragStartPoint));this.selection.setTransform(o.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(o.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=r.Vec2.of(1,1);if(this.mode===a.ResizeMode.HorizontalOnly){const t=n+e.x;l=r.Vec2.of(t/n,l.y)}if(this.mode===a.ResizeMode.VerticalOnly){const t=i+e.y;l=r.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=r.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(o.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(o.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=o.default.zRotation(e).mapEntries((t=>s.default.roundScaleRatio(t))),r=o.default.translation(n).rightMul(i).rightMul(o.default.translation(n.times(-1)));this.selection.setTransform(r)}onDragEnd(){this.selection.finalizeTransform()}}},3968:(t,e)=>{"use strict";var n,i;Object.defineProperty(e,"__esModule",{value:!0}),e.TransformMode=e.ResizeMode=void 0,function(t){t[t.Both=0]="Both",t[t.HorizontalOnly=1]="HorizontalOnly",t[t.VerticalOnly=2]="VerticalOnly"}(n||(e.ResizeMode=n={})),function(t){t[t.Snap=0]="Snap",t[t.NoSnap=1]="NoSnap"}(i||(e.TransformMode=i={}))},7893: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 o=i(n(3472)),r=i(n(1885)),s=i(n(7564));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,o=440*(e.z+.1),r=.25*Math.min(1,t.a)/(1+Math.exp(3*-(e.z-.5)));this.colorOscHue.frequency.setValueAtTime(n,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(i,this.ctx.currentTime),this.colorOscValue.frequency.setValueAtTime(o,this.ctx.currentTime),this.valueGain.gain.setValueAtTime(.4*(1-e.z),this.ctx.currentTime),this.colorGain.gain.setValueAtTime(r,this.ctx.currentTime)}announceBoundaryCross(t){this.boundaryGain.gain.cancelScheduledValues(this.ctx.currentTime),this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(.018,this.ctx.currentTime+.1),this.boundaryOsc.frequency.setValueAtTime(440+100*Math.atan(t/2),this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(0,this.ctx.currentTime+.25)}close(){this.ctx.close(),this.closed=!0}}class 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,r;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!==(r=this.editor.display.getColorAt(t.screenPos))&&void 0!==r?r:o.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:o.default.black);const s=new r.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},4321: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 o=i(n(3472)),r=i(n(1151)),s=i(n(7551)),a=i(n(8947)),l=i(n(8015)),c=n(5378),d=n(4318),u=n(3173),h=i(n(7564)),p=i(n(9721)),f=i(n(1456)),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:o.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()))}initTextMeasuringCanvas(){var t;null!==(t=this.textMeasuringCtx)&&void 0!==t||(this.textMeasuringCtx=document.createElement("canvas").getContext("2d"))}getTextAscent(t,e){var n;if(this.initTextMeasuringCanvas(),this.textMeasuringCtx){this.textMeasuringCtx.textBaseline="alphabetic",r.default.applyTextStyles(this.textMeasuringCtx,e);const i=this.textMeasuringCtx.measureText(t);return null!==(n=i.fontBoundingBoxAscent)&&void 0!==n?n:i.actualBoundingBoxAscent}return 2*e.size/3}flushInput(t=!0){if(this.textInputElem&&this.textTargetPosition){const e=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",t){const t=this.textInputElem;this.textInputElem=null,t.remove()}if(""===e)return;const n=l.default.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(l.default.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(l.default.zRotation(this.textRotation)),i=r.default.fromLines(e.split("\n"),n,this.textStyle),o=s.default.addElement(i);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch((0,f.default)([this.removeExistingCommand,o])),this.removeExistingCommand=null):this.editor.dispatch(o)}}getTextScaleMatrix(){return l.default.scaling2D(this.textScale.times(1/this.editor.viewport.getSizeOfPixelOnCanvas()))}updateTextInput(){var t,e,n,i;if(!this.textInputElem||!this.textTargetPosition)return void(null===(t=this.textInputElem)||void 0===t||t.remove());const o=this.editor.viewport,r=o.canvasToScreen(this.textTargetPosition);this.textInputElem.placeholder=this.localizationTable.enterTextToInsert,this.textInputElem.style.fontFamily=this.textStyle.fontFamily,this.textInputElem.style.fontStyle=null!==(e=this.textStyle.fontStyle)&&void 0!==e?e:"",this.textInputElem.style.fontVariant=null!==(n=this.textStyle.fontVariant)&&void 0!==n?n:"",this.textInputElem.style.fontWeight=null!==(i=this.textStyle.fontWeight)&&void 0!==i?i:"",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 s=this.getTextAscent("Testing!",this.textStyle),a=this.textRotation+o.getRotationAngle(),l=this.getTextScaleMatrix();this.textInputElem.style.transform=`${l.toCSSMatrix()} rotate(${180*a/Math.PI}deg) translate(0, ${-s}px)`,this.textInputElem.style.transformOrigin="top left";const c=Math.floor(this.textStyle.size);this.textInputElem.style.lineHeight=`${c}px`}startTextInput(t,e){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=e,this.textInputElem.style.display="inline-block",this.textTargetPosition=this.editor.viewport.roundPoint(t),this.textRotation=-this.editor.viewport.getRotationAngle(),this.textScale=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 o=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t instanceof r.default));const s=this.editor.viewport.visibleRect;if(o=o.filter((t=>!t.getBBox().containsRect(s))),this.flushInput(),o.length>0){const t=o[o.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},8169:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(3173),l=r(n(4735)),c=s(n(2133)),d=s(n(6122)),u=s(n(6416)),h=s(n(7591)),p=s(n(3472)),f=s(n(4074)),m=s(n(4321)),g=s(n(5248)),v=s(n(3448)),y=s(n(2719)),b=s(n(6390)),x=n(823),w=s(n(5805)),S=s(n(8519)),T=s(n(7893));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),o=new l.default(t,l.PanZoomMode.Keyboard,e.keyboardPanZoom),r=new c.default(t,e.penTool(1),{color:p.default.purple,thickness:8}),s=[r,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 T.default(t,e.soundExplorer);C.setEnabled(!1),this.tools=[new g.default(t,e.pipetteTool),C,i,...s,o,new f.default(t),new b.default(t),new v.default(t),new w.default(t),new y.default(t),new S.default(t)],s.forEach((t=>t.setToolGroup(n))),i.setEnabled(!0),r.setEnabled(!0),t.notifier.on(a.EditorEventType.ToolEnabled,(n=>{n.kind===a.EditorEventType.ToolEnabled&&t.announceForAccessibility(e.toolEnabledAnnouncement(n.tool.description))})),t.notifier.on(a.EditorEventType.ToolDisabled,(n=>{n.kind===a.EditorEventType.ToolDisabled&&t.announceForAccessibility(e.toolDisabledAnnouncement(n.tool.description))})),this.activeTool=null}setTools(t,e){this.tools=t,this.primaryToolGroup=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))}}},6122:(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)}}},3448: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 o=i(n(7564));class r extends o.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=r},6390: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 o=i(n(7564));class r extends o.default{constructor(t){super(t.notifier,t.localization.changeTool),this.listeners=new Set([])}registerListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}onKeyPress(t){const e=Array.from(this.listeners.values());for(const n of e)if(n(t))return!0;return!1}}e.default=r},4074:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(7564)),r=n(3348);class s extends o.default{constructor(t){super(t.notifier,t.localization.undoRedoTool),this.editor=t}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(r.undoKeyboardShortcutId,t)?(this.editor.history.undo(),!0):!!this.editor.shortcuts.matchesShortcut(r.redoKeyboardShortcutId,t)&&(this.editor.history.redo(),!0)}}e.default=s},3348:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.duplicateSelectionShortcut=e.selectAllKeyboardShortcut=e.zoomOutKeyboardShortcutId=e.zoomInKeyboardShortcutId=e.rotateCounterClockwiseKeyboardShortcutId=e.rotateClockwiseKeyboardShortcutId=e.moveDownKeyboardShortcutId=e.moveUpKeyboardShortcutId=e.moveRightKeyboardShortcutId=e.moveLeftKeyboardShortcutId=e.toggleFindVisibleShortcutId=e.lineLockKeyboardShortcutId=e.snapToGridKeyboardShortcutId=e.decreaseSizeKeyboardShortcutId=e.increaseSizeKeyboardShortcutId=e.redoKeyboardShortcutId=e.undoKeyboardShortcutId=void 0;const o=i(n(5376));e.undoKeyboardShortcutId="jsdraw.tools.undo",e.redoKeyboardShortcutId="jsdaw.tools.redo",o.default.registerDefaultKeyboardShortcut(e.undoKeyboardShortcutId,["ctrlOrMeta+z"],"Undo"),o.default.registerDefaultKeyboardShortcut(e.redoKeyboardShortcutId,["ctrlOrMeta+Z","ctrlOrMeta+Shift+z"],"Redo"),e.increaseSizeKeyboardShortcutId="jsdraw.tools.increaseSize",o.default.registerDefaultKeyboardShortcut(e.increaseSizeKeyboardShortcutId,["+","="],"Increase pen/eraser size"),e.decreaseSizeKeyboardShortcutId="jsdraw.tools.decreaseSize",o.default.registerDefaultKeyboardShortcut(e.decreaseSizeKeyboardShortcutId,["-","_"],"Decrease pen/eraser size"),e.snapToGridKeyboardShortcutId="jsdraw.tools.snapToGrid",o.default.registerDefaultKeyboardShortcut(e.snapToGridKeyboardShortcutId,["control","meta"],"Snap to grid (press and hold)"),e.lineLockKeyboardShortcutId="jsdraw.tools.lockToLine",o.default.registerDefaultKeyboardShortcut(e.lineLockKeyboardShortcutId,["shift"],"Snap to XY axes (press and hold)"),e.toggleFindVisibleShortcutId="js-draw.tools.FindTool.toggleVisible",o.default.registerDefaultKeyboardShortcut(e.toggleFindVisibleShortcutId,["ctrlOrMeta+f"],"Shows/hides the find tool"),e.moveLeftKeyboardShortcutId="jsdraw.tools.PanZoom.moveLeft",o.default.registerDefaultKeyboardShortcut(e.moveLeftKeyboardShortcutId,["ArrowLeft","h","a"],"Pan left"),e.moveRightKeyboardShortcutId="jsdraw.tools.PanZoom.moveRight",o.default.registerDefaultKeyboardShortcut(e.moveRightKeyboardShortcutId,["ArrowRight","l","d"],"Pan right"),e.moveUpKeyboardShortcutId="jsdraw.tools.PanZoom.moveUp",o.default.registerDefaultKeyboardShortcut(e.moveUpKeyboardShortcutId,["ArrowUp","k","q"],"Pan up"),e.moveDownKeyboardShortcutId="jsdraw.tools.PanZoom.moveDown",o.default.registerDefaultKeyboardShortcut(e.moveDownKeyboardShortcutId,["ArrowDown","j","e"],"Pan down"),e.rotateClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewClockwise",o.default.registerDefaultKeyboardShortcut(e.rotateClockwiseKeyboardShortcutId,["R"],"Rotate viewport clockwise"),e.rotateCounterClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewCounterClockwise",o.default.registerDefaultKeyboardShortcut(e.rotateCounterClockwiseKeyboardShortcutId,["r"],"Rotate viewport counter-clockwise"),e.zoomInKeyboardShortcutId="jsdraw.tools.PanZoom.zoomIn",o.default.registerDefaultKeyboardShortcut(e.zoomInKeyboardShortcutId,["w"],"Zoom in"),e.zoomOutKeyboardShortcutId="jsdraw.tools.PanZoom.zoomOut",o.default.registerDefaultKeyboardShortcut(e.zoomOutKeyboardShortcutId,["s"],"Zoom out"),e.selectAllKeyboardShortcut="jsdraw.tools.SelectionTool.selectAll",o.default.registerDefaultKeyboardShortcut(e.selectAllKeyboardShortcut,["ctrlOrMeta+a"],"Select all"),e.duplicateSelectionShortcut="jsdraw.tools.SelectionTool.duplicateSelection",o.default.registerDefaultKeyboardShortcut(e.duplicateSelectionShortcut,["ctrlOrMeta+d"],"Duplicate selection")},1709: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 o=n(7564);Object.defineProperty(e,"BaseTool",{enumerable:!0,get:function(){return i(o).default}});var r=n(8169);Object.defineProperty(e,"ToolController",{enumerable:!0,get:function(){return i(r).default}});var s=n(6122);Object.defineProperty(e,"ToolEnabledGroup",{enumerable:!0,get:function(){return i(s).default}});var a=n(4074);Object.defineProperty(e,"UndoRedoShortcut",{enumerable:!0,get:function(){return i(a).default}});var l=n(3448);Object.defineProperty(e,"ToolSwitcherShortcut",{enumerable:!0,get:function(){return i(l).default}});var c=n(4735);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(2133);Object.defineProperty(e,"PenTool",{enumerable:!0,get:function(){return i(d).default}});var u=n(4321);Object.defineProperty(e,"TextTool",{enumerable:!0,get:function(){return i(u).default}});var h=n(7591);Object.defineProperty(e,"SelectionTool",{enumerable:!0,get:function(){return i(h).default}});var p=n(8519);Object.defineProperty(e,"SelectAllShortcutHandler",{enumerable:!0,get:function(){return i(p).default}});var f=n(6416);Object.defineProperty(e,"EraserTool",{enumerable:!0,get:function(){return i(f).default}});var m=n(2719);Object.defineProperty(e,"PasteHandler",{enumerable:!0,get:function(){return i(m).default}});var g=n(7893);Object.defineProperty(e,"SoundUITool",{enumerable:!0,get:function(){return i(g).default}});var v=n(6390);Object.defineProperty(e,"ToolbarShortcutHandler",{enumerable:!0,get:function(){return i(v).default}})},3376:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolLocalization=void 0,e.defaultToolLocalization={penTool:t=>`Pen ${t}`,selectionTool:"Selection",selectAllTool:"Select all shortcut",eraserTool:"Eraser",touchPanTool:"Touch panning",twoFingerPanZoomTool:"Panning and zooming",undoRedoTool:"Undo/Redo",rightClickDragPanTool:"Right-click drag",pipetteTool:"Pick color from screen",keyboardPanZoom:"Keyboard pan/zoom shortcuts",textTool:"Text",enterTextToInsert:"Text to insert",changeTool:"Change tool",pasteHandler:"Copy paste handler",soundExplorer:"Sound-based image exploration",disableAccessibilityExploreTool:"Disable sound-based exploration",enableAccessibilityExploreTool:"Enable sound-based exploration",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`}},3173:(t,e)=>{"use strict";var n,i,o;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"}(n||(e.InputEvtType=n={})),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"}(i||(e.EditorEventType=i={})),function(t){t[t.CommandDone=0]="CommandDone",t[t.CommandUndone=1]="CommandUndone",t[t.CommandRedone=2]="CommandRedone"}(o||(e.UndoEventType=o={}))},6585:(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}},9070:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=new FileReader;return new Promise(((i,o)=>{n.onload=()=>i(n.result),n.onerror=o,n.onabort=o,n.onprogress=t=>{null==e||e(t)},n.readAsDataURL(t)}))}},7395:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=()=>new Promise((t=>{requestAnimationFrame((()=>t()))}))},7129:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{if(t.some((t=>t&&t.then)))return Promise.all(t).then((()=>{}))}},458:(t,e,n)=>{"use strict";n.r(e);var i=n(6062),o=n.n(i),r=n(4036),s=n.n(r),a=n(6793),l=n.n(a),c=n(7892),d=n.n(c),u=n(1173),h=n.n(u),p=n(2464),f=n.n(p),m=n(6860),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=h();o()(m.Z,g);m.Z&&m.Z.locals&&m.Z.locals;var v=n(489),y={};y.styleTagTransform=f(),y.setAttributes=d(),y.insert=l().bind(null,"head"),y.domAPI=s(),y.insertStyleElement=h();o()(v.Z,y);v.Z&&v.Z.locals&&v.Z.locals},5381:(t,e)=>{var n,i,o;"undefined"!=typeof self&&self,i=[],void 0===(o="function"==typeof(n=function(){
|
1
|
+
(()=>{var e={489:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());s.push([t.id,'.clr-picker {\n display: none;\n flex-wrap: wrap;\n position: absolute;\n width: 200px;\n z-index: 1000;\n border-radius: 10px;\n background-color: #fff;\n justify-content: flex-end;\n direction: ltr;\n box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1);\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.clr-picker.clr-open,\n.clr-picker[data-inline="true"] {\n display: flex;\n}\n\n.clr-picker[data-inline="true"] {\n position: relative;\n}\n\n.clr-gradient {\n position: relative;\n width: 100%;\n height: 100px;\n margin-bottom: 15px;\n border-radius: 3px 3px 0 0;\n background-image: linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor);\n cursor: pointer;\n}\n\n.clr-marker {\n position: absolute;\n width: 12px;\n height: 12px;\n margin: -6px 0 0 -6px;\n border: 1px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n cursor: pointer;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-runnable-track {\n width: 100%;\n height: 8px;\n}\n\n.clr-picker input[type="range"]::-webkit-slider-thumb {\n width: 8px;\n height: 8px;\n -webkit-appearance: none;\n}\n\n.clr-picker input[type="range"]::-moz-range-track {\n width: 100%;\n height: 8px;\n border: 0;\n}\n\n.clr-picker input[type="range"]::-moz-range-thumb {\n width: 8px;\n height: 8px;\n border: 0;\n}\n\n.clr-hue {\n background-image: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);\n}\n\n.clr-hue,\n.clr-alpha {\n position: relative;\n width: calc(100% - 40px);\n height: 8px;\n margin: 5px 20px;\n border-radius: 4px;\n}\n\n.clr-alpha span {\n display: block;\n height: 100%;\n width: 100%;\n border-radius: inherit;\n background-image: linear-gradient(90deg, rgba(0,0,0,0), currentColor);\n}\n\n.clr-hue input,\n.clr-alpha input {\n position: absolute;\n width: calc(100% + 16px);\n height: 16px;\n left: -8px;\n top: -4px;\n margin: 0;\n background-color: transparent;\n opacity: 0;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n\n.clr-hue div,\n.clr-alpha div {\n position: absolute;\n width: 16px;\n height: 16px;\n left: 0;\n top: 50%;\n margin-left: -8px;\n transform: translateY(-50%);\n border: 2px solid #fff;\n border-radius: 50%;\n background-color: currentColor;\n box-shadow: 0 0 1px #888;\n pointer-events: none;\n}\n\n.clr-alpha div:before {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border-radius: 50%;\n background-color: currentColor;\n}\n\n.clr-format {\n display: none;\n order: 1;\n width: calc(100% - 40px);\n margin: 0 20px 20px;\n}\n\n.clr-segmented {\n display: flex;\n position: relative;\n width: 100%;\n margin: 0;\n padding: 0;\n border: 1px solid #ddd;\n border-radius: 15px;\n box-sizing: border-box;\n color: #999;\n font-size: 12px;\n}\n\n.clr-segmented input,\n.clr-segmented legend {\n position: absolute;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n left: 0;\n top: 0;\n opacity: 0;\n pointer-events: none;\n}\n\n.clr-segmented label {\n flex-grow: 1;\n margin: 0;\n padding: 4px 0;\n font-size: inherit;\n font-weight: normal;\n line-height: initial;\n text-align: center;\n cursor: pointer;\n}\n\n.clr-segmented label:first-of-type {\n border-radius: 10px 0 0 10px;\n}\n\n.clr-segmented label:last-of-type {\n border-radius: 0 10px 10px 0;\n}\n\n.clr-segmented input:checked + label {\n color: #fff;\n background-color: #666;\n}\n\n.clr-swatches {\n order: 2;\n width: calc(100% - 32px);\n margin: 0 16px;\n}\n\n.clr-swatches div {\n display: flex;\n flex-wrap: wrap;\n padding-bottom: 12px;\n justify-content: center;\n}\n\n.clr-swatches button {\n position: relative;\n width: 20px;\n height: 20px;\n margin: 0 4px 6px 4px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n cursor: pointer;\n}\n\n.clr-swatches button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\ninput.clr-color {\n order: 1;\n width: calc(100% - 80px);\n height: 32px;\n margin: 15px 20px 20px auto;\n padding: 0 10px;\n border: 1px solid #ddd;\n border-radius: 16px;\n color: #444;\n background-color: #fff;\n font-family: sans-serif;\n font-size: 14px;\n text-align: center;\n box-shadow: none;\n}\n\ninput.clr-color:focus {\n outline: none;\n border: 1px solid #1e90ff;\n}\n\n.clr-close,\n.clr-clear {\n display: none;\n order: 2;\n height: 24px;\n margin: 0 20px 20px;\n padding: 0 20px;\n border: 0;\n border-radius: 12px;\n color: #fff;\n background-color: #666;\n font-family: inherit;\n font-size: 12px;\n font-weight: 400;\n cursor: pointer;\n}\n\n.clr-close {\n display: block;\n margin: 0 20px 20px auto;\n}\n\n.clr-preview {\n position: relative;\n width: 32px;\n height: 32px;\n margin: 15px 0 20px 20px;\n border-radius: 50%;\n overflow: hidden;\n}\n\n.clr-preview:before,\n.clr-preview:after {\n content: \'\';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n border: 1px solid #fff;\n border-radius: 50%;\n}\n\n.clr-preview:after {\n border: 0;\n background-color: currentColor;\n box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);\n}\n\n.clr-preview button {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 1;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 50%;\n outline-offset: -2px;\n background-color: transparent;\n text-indent: -9999px;\n cursor: pointer;\n overflow: hidden;\n}\n\n.clr-marker,\n.clr-hue div,\n.clr-alpha div,\n.clr-color {\n box-sizing: border-box;\n}\n\n.clr-field {\n display: inline-block;\n position: relative;\n color: transparent;\n}\n\n.clr-field input {\n margin: 0;\n direction: ltr;\n}\n\n.clr-field.clr-rtl input {\n text-align: right;\n}\n\n.clr-field button {\n position: absolute;\n width: 30px;\n height: 100%;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n margin: 0;\n padding: 0;\n border: 0;\n color: inherit;\n text-indent: -1000px;\n white-space: nowrap;\n overflow: hidden;\n pointer-events: none;\n}\n\n.clr-field.clr-rtl button {\n right: auto;\n left: 0;\n}\n\n.clr-field button:after {\n content: \'\';\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n border-radius: inherit;\n background-color: currentColor;\n box-shadow: inset 0 0 1px rgba(0,0,0,.5);\n}\n\n.clr-alpha,\n.clr-alpha div,\n.clr-swatches button,\n.clr-preview:before,\n.clr-field button {\n background-image: repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa), repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position: 0 0, 4px 4px;\n background-size: 8px 8px;\n}\n\n.clr-marker:focus {\n outline: none;\n}\n\n.clr-keyboard-nav .clr-marker:focus,\n.clr-keyboard-nav .clr-hue input:focus + div,\n.clr-keyboard-nav .clr-alpha input:focus + div,\n.clr-keyboard-nav .clr-segmented input:focus + label {\n outline: none;\n box-shadow: 0 0 0 2px #1e90ff, 0 0 2px 2px #fff;\n}\n\n.clr-picker[data-alpha="false"] .clr-alpha {\n display: none;\n}\n\n.clr-picker[data-minimal="true"] {\n padding-top: 16px;\n}\n\n.clr-picker[data-minimal="true"] .clr-gradient,\n.clr-picker[data-minimal="true"] .clr-hue,\n.clr-picker[data-minimal="true"] .clr-alpha,\n.clr-picker[data-minimal="true"] .clr-color,\n.clr-picker[data-minimal="true"] .clr-preview {\n display: none;\n}\n\n/** Dark theme **/\n\n.clr-dark {\n background-color: #444;\n}\n\n.clr-dark .clr-segmented {\n border-color: #777;\n}\n\n.clr-dark .clr-swatches button:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);\n}\n\n.clr-dark input.clr-color {\n color: #fff;\n border-color: #777;\n background-color: #555;\n}\n\n.clr-dark input.clr-color:focus {\n border-color: #1e90ff;\n}\n\n.clr-dark .clr-preview:after {\n box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);\n}\n\n.clr-dark .clr-alpha,\n.clr-dark .clr-alpha div,\n.clr-dark .clr-swatches button,\n.clr-dark .clr-preview:before {\n background-image: repeating-linear-gradient(45deg, #666 25%, transparent 25%, transparent 75%, #888 75%, #888), repeating-linear-gradient(45deg, #888 25%, #444 25%, #444 75%, #888 75%, #888);\n}\n\n/** Polaroid theme **/\n\n.clr-picker.clr-polaroid {\n border-radius: 6px;\n box-shadow: 0 0 5px rgba(0,0,0,.1), 0 5px 30px rgba(0,0,0,.2);\n}\n\n.clr-picker.clr-polaroid:before {\n content: \'\';\n display: block;\n position: absolute;\n width: 16px;\n height: 10px;\n left: 20px;\n top: -10px;\n border: solid transparent;\n border-width: 0 8px 10px 8px;\n border-bottom-color: currentColor;\n box-sizing: border-box;\n color: #fff;\n filter: drop-shadow(0 -4px 3px rgba(0,0,0,.1));\n pointer-events: none;\n}\n\n.clr-picker.clr-polaroid.clr-dark:before {\n color: #444;\n}\n\n.clr-picker.clr-polaroid.clr-left:before {\n left: auto;\n right: 20px;\n}\n\n.clr-picker.clr-polaroid.clr-top:before {\n top: auto;\n bottom: -10px;\n transform: rotateZ(180deg);\n}\n\n.clr-polaroid .clr-gradient {\n width: calc(100% - 20px);\n height: 120px;\n margin: 10px;\n border-radius: 3px;\n}\n\n.clr-polaroid .clr-hue,\n.clr-polaroid .clr-alpha {\n width: calc(100% - 30px);\n height: 10px;\n margin: 6px 15px;\n border-radius: 5px;\n}\n\n.clr-polaroid .clr-hue div,\n.clr-polaroid .clr-alpha div {\n box-shadow: 0 0 5px rgba(0,0,0,.2);\n}\n\n.clr-polaroid .clr-format {\n width: calc(100% - 20px);\n margin: 0 10px 15px;\n}\n\n.clr-polaroid .clr-swatches {\n width: calc(100% - 12px);\n margin: 0 6px;\n}\n.clr-polaroid .clr-swatches div {\n padding-bottom: 10px;\n}\n\n.clr-polaroid .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n.clr-polaroid input.clr-color {\n width: calc(100% - 60px);\n margin: 10px 10px 15px auto;\n}\n\n.clr-polaroid .clr-clear {\n margin: 0 10px 15px 10px;\n}\n\n.clr-polaroid .clr-close {\n margin: 0 10px 15px auto;\n}\n\n.clr-polaroid .clr-preview {\n margin: 10px 0 15px 10px;\n}\n\n/** Large theme **/\n\n.clr-picker.clr-large {\n width: 275px;\n}\n\n.clr-large .clr-gradient {\n height: 150px;\n}\n\n.clr-large .clr-swatches button {\n width: 22px;\n height: 22px;\n}\n\n/** Pill (horizontal) theme **/\n\n.clr-picker.clr-pill {\n width: 380px;\n padding-left: 180px;\n box-sizing: border-box;\n}\n\n.clr-pill .clr-gradient {\n position: absolute;\n width: 180px;\n height: 100%;\n left: 0;\n top: 0;\n margin-bottom: 0;\n border-radius: 3px 0 0 3px;\n}\n\n.clr-pill .clr-hue {\n margin-top: 20px;\n}',""]);const a=s},8309:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},6860:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r),a=n(8345),l=n(4883),c=n(8309),d=s()(o());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},8345:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r),a=n(6875),l=n(5701),c=n(9161),d=s()(o());d.i(a.Z),d.i(l.Z),d.i(c.Z),d.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\tuser-select: none;\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\tuser-select: none;\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)\n\t\t> .toolbar-dropdown:not(.hiding) {\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/* Animate showing/hiding the dropdown. Animations triggered in JavaScript. */\n@keyframes dropdown-transition-in {\n\t0% {\n\t\topacity: 0;\n\t\ttransform: scale(1, 0);\n\t}\n\t100% {\n\t\topacity: 1;\n\t\ttransform: scale(1, 1);\n\t}\n}\n\n@keyframes dropdown-transition-out {\n\t0% {\n\t\topacity: 1;\n\t\ttransform: scale(1, 1);\t\n\t}\n\t100% {\n\t\topacity: 0;\n\t\ttransform: scale(1, 0);\n\t}\n}\n\n.toolbar-dropdown {\n\t/* Ensure the animation begins from the correct location. */\n\ttransform-origin: top left;\n\n\t--dropdown-show-animation: dropdown-transition-in;\n\t--dropdown-hide-animation: dropdown-transition-out;\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t/* Disable toolbar animations if reducing motion */\n\t.toolbar-dropdown {\n\t\t--dropdown-show-animation: none;\n\t\t--dropdown-hide-animation: none;\n\t}\n\n\t.toolbar-dropdown.hiding {\n\t\tdisplay: none;\n\t}\n\n\t/* Also disable arrow rotation */\n\t.toolbar-toolContainer > .toolbar-button > .toolbar-showHideDropdownIcon {\n\t\ttransition: none;\n\t}\n\n\t/* ...and background color animation. */\n\t.toolbar-button, .toolbar-root button {\n\t\ttransition: none;\n\t}\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 u=d},6875:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},5701:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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/*\n\t Override the default transform and margin-left.\n\n\t Setting translate to none prevents the dropdown from being shifted off the\n\t screen on window resize by dropdown-repositioning logic.\n\t*/\n\tmargin-left: 0 !important;\n\ttranslate: none !important;\n\n\tpadding: 4px;\n}",""]);const a=s},9161:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());s.push([t.id,"\n.toolbar-pen-type-selector > div {\n\tdisplay: flex;\n\tflex-direction: row;\n\n\tmax-width: 350px;\n\tflex-wrap: wrap;\n\n\t--button-size: 56px;\n}\n\n.toolbar-pen-type-selector .pen-type-button {\n\tdisplay: flex;\n\tflex-direction: column-reverse;\n\tbox-sizing: border-box;\n\n\tflex-shrink: 1;\n\tmargin: 2px;\n}\n\n.toolbar-pen-type-selector .pen-type-button:focus-within {\n\toutline: 2px solid var(--primary-foreground-color);\n}\n\n.toolbar-pen-type-selector .pen-type-button input {\n\topacity: 0;\n\theight: 0;\n}\n\n.toolbar-pen-type-selector .pen-type-button label {\n\tdisplay: flex;\n\tflex-direction: column;\n\n\twidth: var(--button-size);\n\theight: var(--button-size);\n\n\tfont-size: 0.7rem;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 4px;\n}\n\n\n.toolbar-pen-type-selector .pen-type-button .icon {\n\tflex-grow: 1;\n\tflex-shrink: 1;\n\twidth: 100%;\n}\n\n.toolbar-pen-type-selector .pen-type-button.checked {\n\tbackground-color: var(--secondary-background-color);\n\tcolor: var(--secondary-foreground-color);\n}\n",""]);const a=s},1914:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},3690:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},6609:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r)()(o());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},4883:(t,e,n)=>{"use strict";n.d(e,{Z:()=>u});var i=n(9601),o=n.n(i),r=n(2609),s=n.n(r),a=n(3690),l=n(1914),c=n(6609),d=s()(o());d.i(a.Z),d.i(l.Z),d.i(c.Z),d.push([t.id,"",""]);const u=d},2609: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,o,r){"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!==r&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),e.push(d))}},e}},9601:t=>{"use strict";t.exports=function(t){return t[1]}},6062:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],d=r[c]||0,u="".concat(c," ").concat(d);r[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=o(p,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:f,references:1})}s.push(u)}return s}function o(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,o){var r=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=i(t,o),c=0;c<r.length;c++){var d=n(r[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}r=l}}},6793:t=>{"use strict";var e={};t.exports=function(t,n){var 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)}},1173:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},7892:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},4036:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},2464:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},3472: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 o=i(n(1486));class r{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 r.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 r(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 r.ofRGBA(n[0],n[1],n[2],n[3])}static fromString(t){if(t.startsWith("#"))return r.fromHex(t);if("none"===t||"transparent"===t)return r.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 r.ofRGB(i[0]/255,i[1]/255,i[2]/255);if(4===i.length)return r.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 o=i.getImageData(0,0,1,1),s=o.data[0]/255,a=o.data[1]/255,l=o.data[2]/255,c=o.data[3]/255;return r.ofRGBA(s,a,l,c)}eq(t){return null!=t&&(0===this.a&&0===t.a||this.toHexString()===t.toHexString())}mix(t,e){const n=1-(e=Math.min(Math.max(e,0),1));return new r(this.r*n+t.r*e,this.g*n+t.g*e,this.b*n+t.b*e,this.a*n+t.a*e)}static average(t){let e=0,n=0,i=0,o=0;for(const r of t)e+=r.a,n+=r.r,i+=r.g,o+=r.b;return t.length>0&&(e/=t.length,n/=t.length,i/=t.length,o/=t.length),new r(n,i,o,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 r=e,s=r>0?n/r:0;return o.default.of(i,s,r)}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),o=t(this.b);return"ff"===e?`#${n}${i}${o}`:(this.hexString=`#${n}${i}${o}${e}`,this.hexString)}toString(){return this.toHexString()}}e.Color4=r,r.transparent=r.ofRGBA(0,0,0,0),r.red=r.ofRGB(1,0,0),r.green=r.ofRGB(0,1,0),r.blue=r.ofRGB(0,0,1),r.purple=r.ofRGB(.5,.2,.5),r.yellow=r.ofRGB(1,1,.1),r.clay=r.ofRGB(.8,.4,.2),r.black=r.ofRGB(0,0,0),r.gray=r.ofRGB(.5,.5,.5),r.white=r.ofRGB(1,1,1),e.default=r},5146:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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(7551)),c=a(n(8169)),d=n(3173),u=a(n(5155)),h=a(n(5566)),p=a(n(1785)),f=n(5378),m=a(n(1486)),g=a(n(3808)),v=r(n(3012)),y=a(n(2001)),b=a(n(3472)),x=a(n(1697)),w=a(n(4318)),S=a(n(8015)),T=a(n(1906)),C=a(n(8282)),P=n(9036),k=a(n(7717)),E=a(n(7395)),z=a(n(9070)),_=a(n(1456)),O=a(n(7591)),I=a(n(9721)),M=r(n(1847)),B=a(n(1380)),L=a(n(5376));class R{constructor(t,e={}){var n,i,o,r,s,a;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,T.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!==(o=e.minZoom)&&void 0!==o?o:2e-10,maxZoom:null!==(r=e.maxZoom)&&void 0!==r?r:1e12,keyboardShortcutOverrides:null!==(s=e.keyboardShortcutOverrides)&&void 0!==s?s:{},iconProvider:null!==(a=e.iconProvider)&&void 0!==a?a:new C.default},this.icons=this.settings.iconProvider,this.shortcuts=new L.default(this.settings.keyboardShortcutOverrides),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=S.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,o;const r=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,r);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!==(o=null===(i=this.pointers[e.pointerId])||void 0===i?void 0:i.down)&&void 0!==o&&o,this.viewport,r);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,r);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 o=null!==(n=t.dataTransfer)&&void 0!==n?n:t.clipboardData;if(!o)return;for(const e of o.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 o.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 o=yield(0,z.default)(e,i);if(o&&this.toolController.dispatchInputEvent({kind:d.InputEvtType.PasteEvent,mime:n,data:o}))return t.preventDefault(),void this.hideLoadingWarning()}catch(t){console.error("Error reading image:",t)}this.hideLoadingWarning()}}const r=["image/svg+xml","text/plain"];for(const e of r){const n=o.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 o=i;o<t.length&&o<i+n;o++){const n=t[o];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,B.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,o=i.width/n.width,r=i.height/n.height;let s=o;(n.width*s>i.width||n.height*s>i.height)&&(s=r),s*=2/3,s=h.default.roundScaleRatio(s);const a=S.default.translation(i.center.minus(n.center)).rightMul(S.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",e){const n=document.createElement("canvas"),i=this.image.getImportExportViewport(),o=i.getScreenRectSize(),r=null!=e?e:o;n.width=r.x,n.height=r.y;const s=n.getContext("2d"),a=Math.min(r.x/o.x,r.y/o.y);s.scale(a,a);const l=new k.default(s,i);this.image.renderAll(l);return n.toDataURL(t)}toSVG(){const t=this.image.getImportExportViewport().getTemporaryClone(),{element:e,renderer:n}=y.default.fromViewport(t,!1),i=t.canvasToScreenTransform;t.resetTransform(S.default.identity),this.image.renderAll(n),t.resetTransform(i);const o=t.visibleRect;return e.setAttribute("viewBox",[o.x,o.y,o.w,o.h].map((t=>(0,P.toRoundedString)(t))).join(" ")),e.setAttribute("width",(0,P.toRoundedString)(o.w)),e.setAttribute("height",(0,P.toRoundedString)(o.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 I.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 M.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)?M.BackgroundType.None:M.BackgroundType.SolidColor;return e=new M.default(n,t),this.image.addElement(e)}}estimateBackgroundColor(){var t;const e=[];for(const n of this.image.getBackgroundComponents())n instanceof M.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},7551:function(t,e,n){"use strict";var i,o,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})},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(5566)),l=s(n(2655)),c=s(n(8947)),d=s(n(6669)),u=s(n(1785)),h=n(5378),p=s(n(8015)),f=n(6585);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=m={}));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=(r(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),o=null!=i?i:l.default.deserialize(t.elemData),r=new g.AddElementCommand(o);return r.serializedElem=t.elemData,r})),i),g.SetImportExportRectCommand=(r(o=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"),o.commandId="set-import-export-rect",(()=>{const t=o.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),o=new c.default(t.newRegion.x,t.newRegion.y,t.newRegion.w,t.newRegion.h);return new g.SetImportExportRectCommand(n,i,o)}))})(),o),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 o=[];o.push(this);const r=()=>{i=void 0;const r=o.pop();r&&!(null==e?void 0:e(r.bbox))&&(i=r,null!==i.content&&i.getBBox().intersection(t)&&n.push(i),o.push(...i.getChildrenIntersectingRegion(t)))};for(;o.length>0;)r();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)}}e.ImageNode=v,v.idCounter=0},1785:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.listeners={}}dispatch(t,e){const n=this.listeners[t];if(n)for(let t=0;t<n.length;t++)n[t](e)}on(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),{remove:()=>{const n=this.listeners[t];return this.off(t,e),n.length!==this.listeners[t].length}}}off(t,e){const n=this.listeners[t];n&&(this.listeners[t]=n.filter((t=>t!==e)))}}},4318:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PointerDevice=void 0;const i=n(5378);var o;!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"}(o||(e.PointerDevice=o={}));class r{constructor(t,e,n,i,o,r,s,a){this.screenPos=t,this.canvasPos=e,this.pressure=n,this.isPrimary=i,this.down=o,this.device=r,this.id=s,this.timeStamp=a}snappedToGrid(t){const e=t.snapToGrid(this.canvasPos);return this.withCanvasPosition(e,t)}lockedToXYAxesScreen(t,e){const n=this.screenPos.minus(t),o=i.Vec2.unitX.times(n.x),r=i.Vec2.unitY.times(n.y);let s;return s=n.dot(o)>n.dot(r)?o:r,s=s.plus(t),this.withScreenPosition(s,e)}withScreenPosition(t,e){const n=e.screenToCanvas(t);return this.withCanvasPosition(n,e)}withCanvasPosition(t,e){const n=e.canvasToScreen(t);return new r(n,t,this.pressure,this.isPrimary,this.down,this.device,this.id,this.timeStamp)}static ofEvent(t,e,n,s){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:o.PrimaryButtonMouse,pen:o.Pen,touch:o.Touch}[t.pointerType])&&void 0!==a?a:o.Other;d===o.Pen&&0!=(32&t.buttons)&&(d=o.Eraser);const u=(new Date).getTime(),h=n.roundPoint(n.screenToCanvas(c));return d===o.PrimaryButtonMouse&&(2&t.buttons?d=o.RightButtonMouse:1&t.buttons||(d=o.Other)),new r(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=o.Pen,a=!0,l=null){const c=n.canvasToScreen(t),d=(new Date).getTime();return new r(c,t,l,a,e,s,i,d)}}e.default=r},1697:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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(3472)),c=r(n(1847)),d=a(n(7077)),u=a(n(9964)),h=a(n(2413)),p=r(n(1151)),f=a(n(9025)),m=a(n(8015)),g=a(n(2487)),v=a(n(8947)),y=n(5378);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,o,r,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!==(r=null!==(o=t.getAttribute("stroke"))&&void 0!==o?o:null==e?void 0:e.stroke)&&void 0!==r?r: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:"",o=this.getStyle(t),r=i.split("M");let s=!0;for(const t of r){const e=/^[0-9., \t\n]+$/.exec(t);if(""!==t&&!e){const e=s?t:`M${t}`,i=g.default.fromString(e).toRenderable(o);n.push(i)}s=!1}return n}attachUnrecognisedAttrs(t,n,i,o){if(this.storeUnknown){for(const r of n.getAttributeNames())i.has(r)||"style"===r&&o||t.attachLoadSaveData(e.svgAttributesDataKey,[r,n.getAttribute(r)]);if(o&&n.style)for(const i of n.style)""!==i&&i&&(o.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,o;return s(this,void 0,void 0,(function*(){if(t.classList.contains(c.backgroundTypeToClassNameMap[c.BackgroundType.Grid])){let n,i,o,r,s;if("g"===t.tagName.toLowerCase()){if(2!==t.children.length)return void(yield this.addUnknownNode(t));const e=t.children[0],r=t.children[1];i=e.getAttribute("fill"),n=r.getAttribute("stroke"),o=r.getAttribute("stroke-width")}else i=t.getAttribute("fill"),n=t.getAttribute("stroke"),o=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);r=parseFloat(t.replace(/p/g,"."))}o&&(s=parseFloat(o));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,r,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"),r=new c.default(c.BackgroundType.SolidColor,e);yield null===(o=this.onAddComponent)||void 0===o?void 0:o.call(this,r)}else yield this.addUnknownNode(t)}))}getTransform(t,e,n){null!=n||(n=window.getComputedStyle(t));let i,o=n.transform;""!==o&&"none"!==o||(o=t.style.transform||"none");try{i=m.default.fromCSSMatrix(t.style.transform)}catch(t){i=m.default.fromCSSMatrix(o)}const r=t.getAttribute("x"),s=t.getAttribute("y");if(r||s){const t=parseFloat(null!=r?r:"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),o=/^([-0-9.e]+)px/i;let r=o.exec(t.style.fontSize);!r&&"tspan"===t.tagName.toLowerCase()&&t.parentElement&&(r=o.exec(t.parentElement.style.fontSize)),r||(r=o.exec(i.fontSize));const s=["fontFamily","transform",...b];let a=12;r&&(s.push("fontSize"),a=parseFloat(r[1]));const l={size:a,fontFamily:i.fontFamily||t.style.fontFamily||"sans-serif",fontWeight:i.fontWeight||t.style.fontWeight||void 0,fontStyle:i.fontStyle||t.style.fontStyle||void 0,renderingStyle:this.getStyle(t,i)},c=[];let d=this.getTransform(t,c,i),u=p.TextTransformMode.ABSOLUTE_XY;const h=t.getAttribute("dx");h&&(u=p.TextTransformMode.RELATIVE_X_ABSOLUTE_Y,d=d.rightMul(m.default.translation(y.Vec2.of(parseFloat(h),0))),c.push("dx"));const f=t.getAttribute("dy");f&&(u=u===p.TextTransformMode.RELATIVE_X_ABSOLUTE_Y?p.TextTransformMode.RELATIVE_XY:p.TextTransformMode.RELATIVE_Y_ABSOLUTE_X,d=d.rightMul(m.default.translation(y.Vec2.of(0,parseFloat(f)))),c.push("dy"));const g=new p.default(n,d,l,u);return this.attachUnrecognisedAttrs(g,t,new Set(c),new Set(s)),g}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 o=new Image;o.src=null!==(e=t.getAttribute("xlink:href"))&&void 0!==e?e:t.href.baseVal,o.setAttribute("alt",null!==(n=t.getAttribute("aria-label"))&&void 0!==n?n:"");try{const e=[],n=this.getTransform(t,e),r=yield d.default.fromImage(o,n);this.attachUnrecognisedAttrs(r,t,new Set(e),new Set(["transform"])),yield null===(i=this.onAddComponent)||void 0===i?void 0:i.call(this,r)}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,]+/),o=parseFloat(i[0]),r=parseFloat(i[1]),s=parseFloat(i[2]),a=parseFloat(i[3]);isNaN(o)||isNaN(r)||isNaN(s)||isNaN(a)?console.warn(`node ${t} has an unparsable viewbox. Viewbox: ${n}. Match: ${i}.`):(this.rootViewBox=new v.default(o,r,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 o,r;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===(o=this.onDetermineExportRect)||void 0===o||o.call(this,e.defaultSVGViewRect),null===(r=this.onFinish)||void 0===r||r.call(this)}))}static fromString(t,e=!1){var n,i;const o=document.createElement("iframe");if(o.src="about:blank",o.setAttribute("sandbox","allow-same-origin"),o.setAttribute("csp","default-src 'about:blank'"),o.style.display="none",document.body.appendChild(o),!o.hasAttribute("sandbox"))throw o.remove(),new Error("SVG loading iframe is not sandboxed.");const r=null!==(i=null===(n=o.contentWindow)||void 0===n?void 0:n.document)&&void 0!==i?i:o.contentDocument;if(null==r)throw new Error("Unable to open a sandboxed iframe!");r.open(),r.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"),r.close();const s=r.createElementNS("http://www.w3.org/2000/svg","svg");return s.innerHTML=t,r.body.appendChild(s),new x(s,(()=>{s.remove(),o.remove()}),!e)}}e.default=x},5155:function(t,e,n){"use strict";var i,o,r=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.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(3173);i=new WeakMap,o=new WeakMap,e.default=class{constructor(t,e,n){this.editor=t,this.announceRedoCallback=e,this.announceUndoCallback=n,i.set(this,void 0),o.set(this,void 0),this.maxUndoRedoStackSize=700,r(this,i,[],"f"),r(this,o,[],"f")}fireUpdateEvent(t,e){this.editor.notifier.dispatch(a.EditorEventType.UndoRedoStackUpdated,{kind:a.EditorEventType.UndoRedoStackUpdated,undoStackSize:s(this,i,"f").length,redoStackSize:s(this,o,"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,o,"f"))t.onDrop(this.editor);if(r(this,o,[],"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,o,"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,o,"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,o,"f").length}}},5566:function(t,e,n){"use strict";var i,o,r=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.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(2216)),c=a(n(8015)),d=a(n(8947)),u=n(5378),h=a(n(1486));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 o=()=>{const t=this.visibleRect.transformedBoundingBox(i.inverse());return t.transformedBoundingBox(c.default.scaling2D(.8,t.center))};let r=o();const s=r.w<t.w||r.h<t.h,a=t.maxDimension/r.maxDimension<1/3;if(s&&n||a&&e){const e=Math.max(t.w/r.w,t.h/r.h),n=c.default.scaling2D(e,r.topLeft).inverse();i=i.rightMul(n)}if(r=o(),!r.containsRect(t)){const e=t.center.minus(r.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=(o=class extends p{constructor(t){super(),this.transform=t,i.set(this,void 0),r(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,o=this.transform.transformVec3(u.Vec2.unitX),r=this.transform.transformVec2(i),s=o.magnitude(),a=180/Math.PI*o.angle(),l=r.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,o),e.default=f},7783:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),n(458);const s=r(n(5146));o(n(6209),e),e.default=s.default},2216:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Command=void 0;class n{onDrop(t){}static union(t,e){return new class extends n{apply(n){t.apply(n),e.apply(n)}unapply(n){e.unapply(n),t.unapply(n)}description(n,i){const o=t.description(n,i),r=e.description(n,i);return o===r?o:`${o}, ${r}`}}}}e.Command=n,n.empty=new class extends n{description(t,e){return""}apply(t){}unapply(t){}},e.default=n},1365:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(2944)),r=i(n(9721)),s=i(n(6669));class a extends s.default{constructor(t){super("duplicate"),this.toDuplicate=t,this.duplicates=t.map((t=>t.clone())),this.reverse=new r.default(this.duplicates)}apply(t){this.reverse.unapply(t)}unapply(t){this.reverse.apply(t)}onDrop(t){this.reverse.onDrop(t)}description(t,e){var n;return 0===this.duplicates.length?e.duplicatedNoElements:e.duplicateAction(null!==(n=(0,o.default)(e,this.duplicates))&&void 0!==n?n:e.elements,this.duplicates.length)}serializeToJSON(){return this.toDuplicate.map((t=>t.getId()))}}s.default.register("duplicate",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t)));return new a(n)})),e.default=a},9721:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(2944)),r=i(n(7551)),s=i(n(6669));class a extends s.default{constructor(t){super("erase"),this.toRemove=t.map((t=>t)),this.applied=!1}apply(t){for(const e of this.toRemove){const n=t.image.findParent(e);n&&n.remove()}this.applied=!0,t.queueRerender()}unapply(t){for(const e of this.toRemove)t.image.findParent(e)||r.default.addElement(e).apply(t);this.applied=!1,t.queueRerender()}onDrop(t){if(this.applied)for(const e of this.toRemove)t.image.onDestroyElement(e)}description(t,e){var n;if(0===this.toRemove.length)return e.erasedNoElements;const i=null!==(n=(0,o.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()))}}s.default.register("erase",((t,e)=>{const n=t.map((t=>e.image.lookupElement(t))).filter((t=>null!==t));return new a(n)})),e.default=a},6669:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(2216));class r extends o.default{constructor(t){if(super(),this.commandTypeId=t,!(t in r.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 r.deserializationCallbacks))throw new Error(`Unrecognised command type ${i}!`);return r.deserializationCallbacks[i](n.data,e)}static register(t,e){r.deserializationCallbacks[t]=e}}r.deserializationCallbacks={},e.default=r},8859: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 o=i(n(6669));class r extends o.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=r},2242: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 o=i(n(2216)),r=i(n(6669)),s=t=>{if(t instanceof r.default)return new class extends r.default{serializeToJSON(){return t.serialize()}apply(e){t.unapply(e)}unapply(e){t.unapply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}("inverse");return new class extends o.default{apply(e){t.unapply(e)}unapply(e){t.apply(e)}onDrop(e){t.onDrop(e)}description(e,n){return n.inverseOf(t.description(e,n))}}};r.default.register("inverse",((t,e)=>s(r.default.deserialize(t,e)))),e.default=s},7601:function(t,e,n){"use strict";var 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 o=i(n(2216));e.Command=o.default;const r=i(n(1365));e.Duplicate=r.default;const s=i(n(9721));e.Erase=s.default;const a=i(n(2242));e.invertCommand=a.default;const l=i(n(6669));e.SerializableCommand=l.default;const c=i(n(1456));e.uniteCommands=c.default},6985:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultCommandLocalization=void 0,e.defaultCommandLocalization={updatedViewport:"Transformed Viewport",transformedElements:t=>`Transformed ${t} element${1===t?"":"s"}`,resizeOutputCommand:t=>`Resized image to ${t.w}x${t.h}`,addElementAction:t=>`Added ${t}`,eraseAction:(t,e)=>`Erased ${e} ${t}`,duplicateAction:(t,e)=>`Duplicated ${e} ${t}`,unionOf:(t,e)=>`Union: ${e} ${t}`,inverseOf:t=>`Inverse of ${t}`,elements:"Elements",erasedNoElements:"Erased nothing",duplicatedNoElements:"Duplicated nothing",rotatedBy:t=>`Rotated by ${Math.abs(t)} degrees ${t<0?"clockwise":"counter-clockwise"}`,movedLeft:"Moved left",movedUp:"Moved up",movedDown:"Moved down",movedRight:"Moved right",zoomedOut:"Zoomed out",zoomedIn:"Zoomed in",selectedElements:t=>`Selected ${t} element${1===t?"":"s"}`}},1456:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(7129)),r=i(n(2216)),s=i(n(6669));class a extends r.default{constructor(t,e){super(),this.commands=t,this.applyChunkSize=e}apply(t){if(void 0===this.applyChunkSize){const e=this.commands.map((e=>e.apply(t)));return(0,o.default)(e)}return t.asyncApplyCommands(this.commands,this.applyChunkSize)}unapply(t){const e=[...this.commands];if(e.reverse(),void 0===this.applyChunkSize){const n=e.map((e=>e.unapply(t)));return(0,o.default)(n)}return t.asyncUnapplyCommands(e,this.applyChunkSize,!1)}onDrop(t){this.commands.forEach((e=>e.onDrop(t)))}description(t,e){const n=[];let i=null,o=0;for(const r of this.commands){const s=r.description(t,e);s!==i&&null!==i&&(n.push(e.unionOf(i,o)),i=null,o=0),o++,null!=i||(i=s)}return o>1?n.push(e.unionOf(i,o)):1===o&&n.push(i),n.join(", ")}}class l extends s.default{constructor(t,e){super("union"),this.commands=t,this.applyChunkSize=e,this.nonserializableCommand=new a(t,e)}serializeToJSON(){return this.serializedData?this.serializedData:{applyChunkSize:this.applyChunkSize,data:this.commands.map((t=>t.serialize()))}}apply(t){return this.serializedData=this.serializeToJSON(),this.nonserializableCommand.apply(t)}unapply(t){return this.nonserializableCommand.unapply(t)}onDrop(t){this.nonserializableCommand.onDrop(t)}description(t,e){return this.nonserializableCommand.description(t,e)}}const c=(t,e)=>{let n=!0;for(const e of t)if(!(e instanceof s.default)){n=!1;break}if(n){return new l(t,e)}return new a(t,e)};s.default.register("union",((t,e)=>{if("number"!=typeof t.data.length)throw new Error("Unions of commands must serialize to lists of serialization data.");const n=t.applyChunkSize;if("number"!=typeof n&&void 0!==n)throw new Error("serialized applyChunkSize is neither undefined nor a number.");const i=[];for(const n of t.data)i.push(s.default.deserialize(n,e));return c(i,n)})),e.default=c},2655:function(t,e,n){"use strict";var i,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})},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=r(n(6669)),a=r(n(7551)),l=r(n(8015)),c=r(n(8859));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=(o(i=class extends c.default{constructor(t,e,n,i,o){super(d.transformElementCommandId,e,n),this.affineTransfm=t,this.origZIndex=o,this.targetZIndex=null!=i?i:d.zIndexCounter++,this.targetZIndex>=d.zIndexCounter&&(d.zIndexCounter=this.targetZIndex+1),n&&void 0===o&&(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 o=null!==(n=e.image.lookupElement(t.id))&&void 0!==n?n:void 0,r=new l.default(...t.transfm),s=t.targetZIndex,a=null!==(i=t.origZIndex)&&void 0!==i?i:void 0;return new d.TransformElementCommand(r,t.id,o,s,a)})),i),e.default=d},1847:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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(3472)),l=n(7551),c=s(n(8947)),d=s(n(2655)),u=n(739),h=r(n(2487)),p=n(5378),f=s(n(5566)),m=n(9036);var g;!function(t){t[t.SolidColor=0]="SolidColor",t[t.Grid=1]="Grid",t[t.None=2]="None"}(g||(e.BackgroundType=g={})),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 o=new v(g.Grid,t);return void 0!==e&&(o.gridSize=e),void 0!==n&&(o.secondaryColor=n),void 0!==i&&(o.gridStrokeWidth=i),o}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,o=t=>Math.floor(t/this.gridSize)*this.gridSize,r=t=>Math.ceil(t/this.gridSize)*this.gridSize,s=r(i.y),a=o(i.y+i.h),l=r(i.x),c=o(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;const i=this.backgroundType===g.Grid;if(t.startObject(this.contentBBox,i),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 o=e.backgroundTypeToClassNameMap[this.backgroundType],r=[e.imageBackgroundCSSClassName];if(o!==e.imageBackgroundCSSClassName){r.push(o);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){if(this.backgroundType===g.SolidColor)return t.filledBackgroundWithColor(this.mainColor.toString());if(this.backgroundType===g.None)return t.emptyBackground;if(this.backgroundType===g.Grid)return t.gridBackground;return this.backgroundType}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 o=t.backgroundType;if(o!==g.None&&o!==g.Grid&&o!==g.SolidColor){return o}i=o;const r=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,r);return d.secondaryColor=s,l&&(d.gridSize=l),c&&(d.gridStrokeWidth=c),d}}e.default=v,d.default.registerComponent("image-background",v.deserializeFromJSON)},7077:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(8015)),s=o(n(8947)),a=n(6585),l=o(n(2655));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,o,r;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!==(o=t.getAttribute("alt"))&&void 0!==o?o:""),a.setAttribute("aria-label",null!==(r=t.getAttribute("aria-label"))&&void 0!==r?r:""),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 r.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)},739: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 o=i(n(3472)),r=i(n(6669)),s=i(n(8859)),a=n(2788),l=t=>{const e={};return t.color&&(e.color=t.color.toHexString()),t.textStyle&&(e.textStyle=(0,a.textStyleToJSON)(t.textStyle)),e},c=t=>({color:t.color?o.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)}}}r.default.register(d,((t,e)=>{const n=c(t.originalStyle),i=c(t.newStyle),o=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,o)}))},2413: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 o=i(n(8947)),r=i(n(2001)),s=i(n(2655)),a="svg-global-attributes";class l extends s.default{constructor(t){super(a),this.attrs=t,this.contentBBox=o.default.empty}render(t,e){if(t instanceof r.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,o]of e)"viewBox"!==t&&"width"!==t&&"height"!==t||o&&i.exec(o)&&n.push([t,o]);return new l(n)}}e.default=l,s.default.registerComponent(a,l.deserializeFromString)},9964: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 o=i(n(2487)),r=i(n(8947)),s=n(2500),a=i(n(2655)),l=n(739);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=o.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=r.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,o=i?i/2:void 0;if(n.path.intersection(t,o).length>0)return!0}return!1}render(t,e){var n,i;t.startObject(this.getBBox());for(const o of this.parts){const r=this.bboxForPart(o.path.bbox,o.style);if(e){if(!r.intersects(e))continue;if((r.size.x>3*e.size.x||r.size.y>3*e.size.y)&&!o.path.roughlyIntersects(e,null!==(i=null===(n=o.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0))continue}t.drawPath(o)}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:r.default.empty}applyTransformation(t){this.contentBBox=r.default.empty;let e=!0;this.parts=this.parts.map((n=>{const i=n.path.transformedBy(t),o=Object.assign(Object.assign({},n.style),{stroke:n.style.stroke?Object.assign({},n.style.stroke):void 0});if(o.stroke){const e=t.getScaleFactor();o.stroke.width*=e}const r=this.bboxForPart(i.bbox,o);return e?(this.contentBBox=r,e=!1):this.contentBBox=this.contentBBox.union(r),{path:i,startPoint:i.startPoint,commands:i.parts,style:o}}))}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:o.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 o.default.fromString(t.path).toRenderable(e)}));return new c(e)}}e.default=c,a.default.registerComponent("stroke",c.deserializeFromJSON)},1151: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.TextTransformMode=void 0;const o=i(n(8015)),r=i(n(8947)),s=n(5378),a=n(2788),l=i(n(2655)),c=n(739),d="text";var u;!function(t){t[t.ABSOLUTE_XY=0]="ABSOLUTE_XY",t[t.RELATIVE_XY=1]="RELATIVE_XY",t[t.RELATIVE_X_ABSOLUTE_Y=2]="RELATIVE_X_ABSOLUTE_Y",t[t.RELATIVE_Y_ABSOLUTE_X=3]="RELATIVE_Y_ABSOLUTE_X"}(u||(e.TextTransformMode=u={}));class h extends l.default{constructor(t,e,n,i=u.ABSOLUTE_XY){super(d),this.textObjects=t,this.transform=e,this.style=n,this.transformMode=i,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,o;const r=e.fontFamily.match(/\s/)?e.fontFamily.replace(/["]/g,'\\"'):e.fontFamily;t.font=[null!==(n=e.fontStyle)&&void 0!==n?n:"",null!==(i=e.fontWeight)&&void 0!==i?i:"",(null!==(o=e.size)&&void 0!==o?o:12)+"px",`${r}`].join(" "),t.textAlign="left"}static estimateTextDimens(t,e){const n=t.length*e.size,i=e.size;return new r.default(0,2*-i/3,n,i)}static getTextMetrics(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 null;const o=h.textMeasuringCtx;return h.applyTextStyles(o,e),o.measureText(t)}static getTextDimens(t,e){const n=this.getTextMetrics(t,e);if(!n)return this.estimateTextDimens(t,e);const i=-n.actualBoundingBoxAscent,o=n.actualBoundingBoxAscent+n.actualBoundingBoxDescent;return new r.default(0,i,n.width,o)}static getFontHeight(t){return t.size}computeUntransformedBBoxOfPart(t){return"string"==typeof t?h.getTextDimens(t,this.style):t.contentBBox}recomputeBBox(){let t=null;const e=new h.TextCursor(this.transform,this.style);for(const n of this.textObjects){const i=e.update(n),o=this.computeUntransformedBBoxOfPart(n).transformedBoundingBox(i);null!=t||(t=o),t=t.union(o)}this.contentBBox=null!=t?t:r.default.empty}renderInternal(t){const e=new h.TextCursor(this.transform,this.style);for(const n of this.textObjects){const i=e.update(n);"string"==typeof n?t.drawText(n,i,this.style):(t.pushTransform(i),n.renderInternal(t),t.popTransform())}}render(t,e){t.startObject(this.contentBBox),this.renderInternal(t),t.endObject(this.getLoadSaveData())}getProportionalRenderingTime(){return this.textObjects.length}intersects(t){const e=new h.TextCursor(this.transform,this.style);for(const n of this.textObjects){const i=e.update(n).inverse(),o=t.transformedBy(i);if("string"==typeof n){if(h.getTextDimens(n,this.style).getEdges().some((t=>null!==o.intersection(t))))return!0}else if(n.intersects(o))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,c.createRestyleComponentCommand)(this.getStyle(),t,this)}forceStyle(t,e){if(t.textStyle)this.style=(0,a.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,a.cloneTextStyle)(this.style)}getBaselinePos(){return this.transform.transformVec2(s.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,a.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,a.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=[],a=Math.round(this.getFontHeight(n));let l=s.Vec2.zero;for(const e of t){i&&(l=l.plus(s.Vec2.unitY.times(a)));const t=new h([e],o.default.translation(l),n);r.push(t),i=t}return new h(r,e,n)}}h.textMeasuringCtx=null,h.TextCursor=class{constructor(t=o.default.identity,e){this.parentTransform=t,this.parentStyle=e,this.transform=o.default.identity}update(t){let e,n=o.default.identity,i=o.default.identity;"string"==typeof t?e=h.getTextDimens(t,this.parentStyle):(i=t.transform,e=t.getBBox());const r="string"==typeof t?u.RELATIVE_XY:t.transformMode;if(r===u.RELATIVE_XY)n=this.transform.rightMul(n);else if(r===u.RELATIVE_X_ABSOLUTE_Y||r===u.RELATIVE_Y_ABSOLUTE_X){n=this.transform.mapEntries(((t,[e,n])=>{if(r===u.RELATIVE_X_ABSOLUTE_Y)return 1===e&&2===n?0:t;if(r===u.RELATIVE_Y_ABSOLUTE_X)return 0===e&&2===n?0:t;throw new Error("Unreachable")})).rightMul(n)}const a=o.default.translation(s.Vec2.of(e.width,0));return this.transform=n.rightMul(i).rightMul(a),this.parentTransform.rightMul(n)}},e.default=h,l.default.registerComponent(d,(t=>h.deserializeFromString(t)))},9025: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 o=i(n(8947)),r=i(n(2001)),s=i(n(2655)),a="unknown-svg-object";class l extends s.default{constructor(t){super(a),this.svgObject=t,this.contentBBox=o.default.of(t.getBoundingClientRect())}render(t,e){t instanceof r.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)},9274:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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=r(n(2487)),l=s(n(9964));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(),o=Math.min(this.getLineWidth(),i/2),r=this.startPoint.width/2,s=this.endPoint.width/2,c=e.minus(n.times(o)),d=n.orthog(),u=d.times(r),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(o).plus(h))},{kind:a.PathCommandType.LineTo,point:e.plus(n.times(s))},{kind:a.PathCommandType.LineTo,point:c.plus(d.times(-o).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},7973:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeOutlinedCircleBuilder=void 0;const a=n(5378),l=r(n(2487)),c=s(n(5566)),d=s(n(9964)),u=s(n(3472));e.makeOutlinedCircleBuilder=(t,e)=>new h(t,e);class h{constructor(t,e){this.startPoint=t,this.viewport=e,this.endPoint=t}getBBox(){return this.buildPreview().getBBox()}buildPreview(){const t=[],e=2*Math.PI/6,n=c.default.roundPoint(this.endPoint.width,5/this.viewport.getScaleFactor()),i=this.startPoint.pos.lerp(this.endPoint.pos,.5),o=this.endPoint.pos.minus(i).length()-n/2,r=i.plus(a.Vec2.of(o,0));for(let n=e;n<=2*Math.PI;n+=e){const r=a.Vec2.of(o*Math.cos(n),-o*Math.sin(n)).plus(i),s=1.141,c=a.Vec2.of(Math.cos(n-e/2),-Math.sin(n-e/2)).times(o*s).plus(i);t.push({kind:l.PathCommandType.QuadraticBezierTo,controlPoint:c,endPoint:r})}t.push({kind:l.PathCommandType.LineTo,point:r});const s=new l.default(r,t).mapPoints((t=>this.viewport.roundPoint(t)));return new d.default([s.toRenderable({fill:u.default.transparent,stroke:{width:n,color:this.endPoint.color}})])}build(){return this.buildPreview()}preview(t){this.buildPreview().render(t)}addPoint(t){this.endPoint=t}}},6951:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.makeFreehandLineBuilder=void 0;const o=n(5378),r=i(n(8947)),s=n(2487),a=i(n(9964)),l=i(n(5566)),c=n(1003),d=i(n(3472));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 r.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(o.Vec2.of(t,t)),endPoint:e.plus(o.Vec2.of(0,t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,t)),endPoint:e.plus(o.Vec2.of(-t,0))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(-t,-t)),endPoint:e.plus(o.Vec2.of(0,-t))},{kind:s.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(o.Vec2.of(t,-t)),endPoint:e.plus(o.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},725:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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=r(n(2487)),l=s(n(9964));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,o=this.endPoint.width/2,r=n.orthog(),s=r.times(i),c=r.times(o),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},823: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 o=n(4232),r=n(5378),s=i(n(8947)),a=n(2487),l=i(n(9964)),c=i(n(5566)),d=n(1003);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,o;const r=this.curveFitter.preview();if(r){const{upperCurveCommand:s,lowerToUpperConnector:a,upperToLowerConnector:l,lowerCurveCommand:c}=this.segmentToPath(r);e.push(s),n.push(c),i=a,o=null!==(t=this.pathStartConnector)&&void 0!==t?t:l}else{if(null===this.mostRecentConnector||null===this.pathStartConnector)return null;i=this.mostRecentConnector,o=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(),o,...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],o=/^([-0-9.eE]+)\/([-0-9.eE]+)$/.exec(i);if(!o)throw new Error(`Incorrect format returned by .intersects: ${n} should be array of "number/number"!`);const s=parseFloat(o[1]);return r.Vec2.ofXY(t.get(s))},i=t=>r.Vec2.ofXY(t.points[2]).minus(r.Vec2.ofXY(t.points[1])).normalized(),o=t=>r.Vec2.ofXY(t.points[1]).minus(r.Vec2.ofXY(t.points[0])).normalized();if(o(e).dot(i(this.lastUpperBezier))<.3||o(t).dot(i(this.lastLowerBezier))<.3||o(e).dot(i(e))<0||o(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(r.Vec2.of(t,0));return this.lowerSegments.push({kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,t)),endPoint:e.plus(r.Vec2.of(0,t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,t)),endPoint:e.plus(r.Vec2.of(-t,0))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(-t,-t)),endPoint:e.plus(r.Vec2.of(0,-t))},{kind:a.PathCommandType.QuadraticBezierTo,controlPoint:e.plus(r.Vec2.of(t,-t)),endPoint:e.plus(r.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:o,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(o),this.upperSegments.push(e),this.lastLowerBezier=s,this.lastUpperBezier=l,this.curveStartWidth=t.startWidth}segmentToPath(t){const e=new o.Bezier(t.startPoint.xy,t.controlPoint.xy,t.endPoint.xy);let n=r.Vec2.ofXY(e.normal(0)).normalized(),i=r.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=r.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 o.Bezier(v,g,y),lowerCurve:new o.Bezier(p,f,m)}}addPoint(t){this.curveFitter.addPoint(t)}}e.default=u},4666: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 o=i(n(8015)),r=i(n(2487)),s=i(n(8947)),a=i(n(9964));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=o.default.zRotation(-t),n=e.inverse().transformVec2(this.startPoint.pos),i=e.inverse().transformVec2(this.endPoint.pos),l=s.default.fromCorners(n,i),c=r.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},1024:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1576:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=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.Text=e.TextComponent=e.isRestylableComponent=e.createRestyleComponentCommand=e.Stroke=e.AbstractComponent=e.StrokeSmoother=e.makeOutlinedCircleBuilder=e.makePressureSensitiveFreehandLineBuilder=e.makeFreehandLineBuilder=void 0,o(n(1024),e);var s=n(6951);Object.defineProperty(e,"makeFreehandLineBuilder",{enumerable:!0,get:function(){return s.makeFreehandLineBuilder}});var a=n(823);Object.defineProperty(e,"makePressureSensitiveFreehandLineBuilder",{enumerable:!0,get:function(){return a.makePressureSensitiveFreehandLineBuilder}});var l=n(7973);Object.defineProperty(e,"makeOutlinedCircleBuilder",{enumerable:!0,get:function(){return l.makeOutlinedCircleBuilder}});var c=n(1003);Object.defineProperty(e,"StrokeSmoother",{enumerable:!0,get:function(){return r(c).default}}),o(n(2655),e);var d=n(2655);Object.defineProperty(e,"AbstractComponent",{enumerable:!0,get:function(){return r(d).default}});const u=r(n(9964));e.Stroke=u.default,e.StrokeComponent=u.default;const h=r(n(1151));e.TextComponent=h.default,e.Text=h.default;const p=r(n(7077));e.ImageComponent=p.default;const f=n(739);Object.defineProperty(e,"createRestyleComponentCommand",{enumerable:!0,get:function(){return f.createRestyleComponentCommand}}),Object.defineProperty(e,"isRestylableComponent",{enumerable:!0,get:function(){return f.isRestylableComponent}});const m=r(n(1847));e.BackgroundComponent=m.default},7708:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultComponentLocalization=void 0,e.defaultComponentLocalization={unlabeledImageNode:"Unlabeled image node",stroke:"Stroke",svgObject:"SVG Object",emptyBackground:"Empty background",gridBackground:"Grid background",filledBackgroundWithColor:t=>`Filled background (${t})`,text:t=>`Text object: ${t}`,imageNode:t=>`Image: ${t}`,restyledElement:t=>`Restyled ${t}`}},1003: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 o=n(5378),r=i(n(8947)),s=i(n(1885)),a=i(n(1701));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=o.Vec2.zero,this.currentCurve=null,this.curveStartWidth=t.width,this.bbox=new r.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 o=t.pos.minus(this.lastPoint.pos).times(1/n*1e3);this.momentum=this.momentum.lerp(o,.9)}const i=null!==(e=this.lastPoint)&&void 0!==e?e:t;this.lastPoint=t,this.buffer.push(t.pos);const r=t.width,l=this.curveEndWidth;if(this.curveEndWidth=r,this.bbox=this.bbox.grownToPoint(t.pos,r),null===this.currentCurve){const e=i.pos,s=i.pos.plus(null!==(n=this.lastExitingVec)&&void 0!==n?n:o.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+r)/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 o of this.buffer){let r=t.approximateDistance(o);if(r>e&&(r=t.distance(o),i+=Math.max(0,r-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},2944:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=(t,e)=>{if(0===e.length)return null;const n=e[0].description(t);for(const i of e)if(i.description(t)!==n)return null;return n}},6209:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=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.EventDispatcher=e.Viewport=e.SVGLoader=e.Color4=e.matchingLocalizationTable=e.getLocalizationTable=e.EditorImage=void 0;const s=r(n(5146));e.Editor=s.default;var a=n(7551);Object.defineProperty(e,"EditorImage",{enumerable:!0,get:function(){return r(a).default}}),o(n(3173),e);var l=n(1906);Object.defineProperty(e,"getLocalizationTable",{enumerable:!0,get:function(){return r(l).default}}),Object.defineProperty(e,"matchingLocalizationTable",{enumerable:!0,get:function(){return l.matchingLocalizationTable}}),o(n(8167),e);var c=n(3472);Object.defineProperty(e,"Color4",{enumerable:!0,get:function(){return r(c).default}});var d=n(1697);Object.defineProperty(e,"SVGLoader",{enumerable:!0,get:function(){return r(d).default}});var u=n(5566);Object.defineProperty(e,"Viewport",{enumerable:!0,get:function(){return r(u).default}}),o(n(6557),e),o(n(1576),e),o(n(7601),e),o(n(1709),e),o(n(2994),e),o(n(2670),e),o(n(1797),e),o(n(6843),e);var h=n(1785);Object.defineProperty(e,"EventDispatcher",{enumerable:!0,get:function(){return r(h).default}});var p=n(4318);Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return r(p).default}}),Object.defineProperty(e,"PointerDevice",{enumerable:!0,get:function(){return p.PointerDevice}});var f=n(3808);Object.defineProperty(e,"HTMLToolbar",{enumerable:!0,get:function(){return r(f).default}});var m=n(5155);Object.defineProperty(e,"UndoRedoHistory",{enumerable:!0,get:function(){return r(m).default}}),e.default=s.default},8167:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultEditorLocalization=void 0;const i=n(6985),o=n(7708),r=n(49),s=n(9746),a=n(3376);e.defaultEditorLocalization=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s.defaultToolbarLocalization),a.defaultToolLocalization),i.defaultCommandLocalization),o.defaultComponentLocalization),r.defaultTextRendererLocalization),{accessibilityInputInstructions:['Press "t" to read the contents of the viewport as text.',"Use the arrow keys to move the viewport, click and drag to draw strokes.",'Press "w" to zoom in and "s" to zoom out.'].join(" "),loading:t=>`Loading ${t}%...`,imageEditor:"Image Editor",doneLoading:"Done loading",undoAnnouncement:t=>`Undid ${t}`,redoAnnouncement:t=>`Redid ${t}`})},4540:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8167),o=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: ",roundedTipPen:"Freihand",flatTipPen:"Stift (druckempfindlich)",arrowPen:"Pfeil",linePen:"Linie",outlinedRectanglePen:"Umrissenes Rechteck",filledRectanglePen:"Ausgefülltes Rechteck",lockRotation:"Sperre Rotation",paste:"Einfügen",dropdownShown:t=>`Dropdown-Menü für ${t} angezeigt`,dropdownHidden:t=>`Dropdown-Menü für ${t} versteckt`,zoomLevel:t=>`Vergößerung: ${t}%`,colorChangedAnnouncement:t=>`Farbe zu ${t} geändert`,imageSize:(t,e)=>`Bild-Größe: ${t} ${e}`,imageLoadError:t=>`Fehler beim Laden des Bildes: ${t}`,errorImageHasZeroSize:"Fehler: Bild hat Größe Null",penTool:t=>`Stift ${t}`,selectionTool:"Auswahl",eraserTool:"Radiergummi",touchPanTool:"Ansicht mit Touchscreen verschieben",twoFingerPanZoomTool:"Ansicht verschieben und vergrößern",undoRedoTool:"Rückgängig/Wiederholen",rightClickDragPanTool:"Rechtsklick-Ziehen",pipetteTool:"Farbe von Bildschirm auswählen",keyboardPanZoom:"Tastaturkürzel zum Verschieben/Vergrößern der Ansicht",textTool:"Text",enterTextToInsert:"Einzufügender Text",changeTool:"Wechsle Werkzeug",pasteHandler:"Copy-Paste-Handler",findLabel:"Finde",toNextMatch:"Nächstes",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=o},512:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8167),o=Object.assign({},i.defaultEditorLocalization);e.default=o},7003:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(8167),o=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",roundedTipPen:"Lapiz Redondeado",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=o},1906: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.matchingLocalizationTable=e.allLocales=void 0;const o=n(8167),r=i(n(4540)),s=i(n(512)),a=i(n(7003));e.allLocales={de:r.default,en:s.default,es:a.default};const l=t=>{const e=/^(\w+)[_-](\w+)$/.exec(t);return e?e[1]:t};e.matchingLocalizationTable=(t,e,n)=>{let i;for(const n of t){const t=l(n);if(i&&t!==i&&i in e)return e[i];if(n in e)return e[n];i=t}return i&&i in e?e[i]:n};e.default=t=>(null!=t||(t=navigator.languages),(0,e.matchingLocalizationTable)(t,e.allLocales,o.defaultEditorLocalization))},8015: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 o=n(5378),r=i(n(1486));class s{constructor(t,e,n,i,o,s,a,l,c){this.a1=t,this.a2=e,this.a3=n,this.b1=i,this.b2=o,this.b3=s,this.c1=a,this.c2=l,this.c3=c,this.cachedInverse=void 0,this.rows=[r.default.of(t,e,n),r.default.of(i,o,s),r.default.of(a,l,c)]}static ofRows(t,e,n){return new s(t.x,t.y,t.z,e.x,e.y,e.z,n.x,n.y,n.z)}inverse(){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=[r.default.unitX,r.default.unitY,r.default.unitZ];for(let n=0;n<3;n++){let i=t[n].at(n);const o=1e-10;if(Math.abs(i)<o){let r=-1;for(let e=1;e<=2;e++){const i=(n+e)%3;if(Math.abs(t[i].at(n))>=o){r=i;break}}if(-1===r)return this.cachedInverse=null,null;const s=t[n],a=e[n];t[n]=t[r],e[n]=e[r],t[r]=s,e[r]=a,i=t[n].at(n)}let r=1/i;t[n]=t[n].times(r),e[n]=e[n].times(r);const s=t[n],a=e[n];for(let i=1;i<=2;i++){const o=(n+i)%3;r=-t[o].at(n),t[o]=t[o].plus(s.times(r)),e[o]=e[o].plus(a.times(r))}}const n=s.ofRows(e[0],e[1],e[2]);return this.cachedInverse=n,n}transposed(){return new s(this.a1,this.b1,this.c1,this.a2,this.b2,this.c2,this.a3,this.b3,this.c3)}rightMul(t){t=t.transposed();const e=(e,n)=>this.rows[e].dot(t.rows[n]);return new s(e(0,0),e(0,1),e(0,2),e(1,0),e(1,1),e(1,2),e(2,0),e(2,1),e(2,2))}transformVec2(t){let e=r.default.of(t.x,t.y,1);return e=this.transformVec3(e),o.Vec2.of(e.x,e.y)}transformVec3(t){return r.default.of(this.rows[0].dot(t),this.rows[1].dot(t),this.rows[2].dot(t))}isIdentity(){return this===s.identity||this.eq(s.identity)}eq(t,e=0){for(let n=0;n<3;n++)if(!this.rows[n].eq(t.rows[n],e))return!1;return!0}toString(){let t="";const e=[0,0,0];for(const t of this.rows)for(let n=0;n<3;n++)e[n]=Math.max(e[0],`${t.at(n)}`.length);for(let n=0;n<3;n++){t+=0===n?"⎡ ":1===n?"⎢ ":"⎣ ";for(let i=0;i<3;i++){const o=this.rows[n].at(i).toString();let r="";for(let t=o.length;t<e[i];t++)r+=" ";t+=o+", "+r}t+=0===n?" ⎤":1===n?" ⎥":" ⎦",t+="\n"}return t.trimEnd()}toArray(){return[this.a1,this.a2,this.a3,this.b1,this.b2,this.b3,this.c1,this.c2,this.c3]}mapEntries(t){return new s(t(this.a1,[0,0]),t(this.a2,[0,1]),t(this.a3,[0,2]),t(this.b1,[1,0]),t(this.b2,[1,1]),t(this.b3,[1,2]),t(this.c1,[2,0]),t(this.c2,[2,1]),t(this.c3,[2,2]))}getScaleFactor(){return Math.hypot(this.a1,this.a2)}static translation(t){return new s(1,0,t.x,0,1,t.y,0,0,1)}static zRotation(t,e=o.Vec2.zero){if(0===t)return s.identity;const n=Math.cos(t),i=Math.sin(t);let r=s.translation(e);return r=r.rightMul(new s(n,-i,0,i,n,0,0,0,1)),r.rightMul(s.translation(e.times(-1)))}static scaling2D(t,e=o.Vec2.zero){let n,i,r=s.translation(e);return"number"==typeof t?(n=t,i=t):(n=t.x,i=t.y),r=r.rightMul(new s(n,0,0,0,i,0,0,0,1)),r.rightMul(s.translation(e.times(-1)))}toCSSMatrix(){return`matrix(${this.a1},${this.b1},${this.a2},${this.b2},${this.a3},${this.b3})`}static fromCSSMatrix(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*$`,o=new RegExp(i,"i").exec(t);if(!o)throw new Error(`Unsupported transformation: ${t}`);const r=o.slice(1).map((t=>parseFloat(t))),a=r[0],l=r[1],c=r[2],d=r[3],u=r[4],h=r[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},5378: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 o=i(n(1486));var r;!function(t){t.of=(t,e)=>o.default.of(t,e,0),t.ofXY=({x:t,y:e})=>o.default.of(t,e,0),t.unitX=t.of(1,0),t.unitY=t.of(0,1),t.zero=t.of(0,0)}(r||(e.Vec2=r={}))},1486:(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},6557: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 o=i(n(1885));e.LineSegment2=o.default;const r=i(n(8015));e.Mat33=r.default;const s=i(n(2487));e.Path=s.default;const a=i(n(8947));e.Rect2=a.default;const l=n(5378);Object.defineProperty(e,"Vec2",{enumerable:!0,get:function(){return l.Vec2}});const c=i(n(1486));e.Vec3=c.default},2636:(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 o=Math.sqrt(i),r=(-e+o)/(2*t),s=(-e-o)/(2*t);return r>s?[r,s]:[s,r]}},9036:(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],o=parseInt(e.charAt(e.length-1),10),r=parseInt(e,10),s=parseInt(i[2],10),a=i[3];let l=(r+10-o).toString(),c=0;for(l.length>r.toString().length&&(l=l.substring(1),c=1);l.length<a.length;)l=c.toString(10)+l,c=0;n=`${t+(s+c).toString()}.${l}`}return n=n.replace(/^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/,"$1"),(0,e.cleanUpNumber)(n)};const n=/^([-]?)(\d*)[.](\d+)$/;e.getLenAfterDecimal=t=>{const e=n.exec(t);if(!e)return-1!==t.search(/[eE]/)||/^[a-zA-Z]+$/.exec(t)?-1:0;return e[3].length};e.toStringOfSamePrecision=(t,...i)=>{const o=t.toString(10),r=n.exec(o);if(!r)return o;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=r[3].substring(0,s),l=r[2];const c=r[3].charAt(s);if(""!==c){if(parseInt(c,10)>=5){if(a.length>0){const t=/^(0+)(\d*)$/.exec(a);let e="",n=a;t&&(e=t[1],n=t[2]),a=(parseInt(a)+1).toString(),a.length>n.length&&e.length>0&&(e=e.substring(1)),a=e+a}(0===a.length||a.length>s)&&(l=(parseInt(l)+1).toString(),a=a.substring(1))}}const d=r[1];return(0,e.cleanUpNumber)(`${d}${l}.${a}`)}},1098:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{distance(t){return Math.abs(this.signedDistance(t))}containsPoint(t,e=n.smallValue){return this.signedDistance(t)<e}getLooseBoundingBox(){return this.getTightBoundingBox()}}n.smallValue=1e-12,e.default=n},4769:function(t,e,n){"use strict";var i,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)},r=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(4232),l=n(5378),c=s(n(1098)),d=s(n(8947));class u extends c.default{constructor(){super(...arguments),i.set(this,null)}getBezier(){return o(this,i,"f")||r(this,i,new a.Bezier(this.getPoints().map((t=>t.xy))),"f"),o(this,i,"f")}signedDistance(t){return this.getBezier().project(t.xy).d}distance(t){return this.signedDistance(t)}at(t){return l.Vec2.ofXY(this.getBezier().get(t))}derivativeAt(t){return l.Vec2.ofXY(this.getBezier().derivative(t))}normal(t){return l.Vec2.ofXY(this.getBezier().normal(t))}getTightBoundingBox(){const t=this.getBezier().bbox(),e=t.x.max-t.x.min,n=t.y.max-t.y.min;return new d.default(t.x.min,t.y.min,e,n)}intersectsLineSegment(t){const e=this.getBezier();return e.intersects(t).map((n=>{"string"==typeof n&&(n=parseFloat(n));const i=l.Vec2.ofXY(e.get(n));return i.minus(t.p1).magnitude()>t.length||i.minus(t.p2).magnitude()>t.length?null:i})).filter((t=>null!==t))}}i=new WeakMap,e.default=u},4151: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 o=i(n(4769)),r=i(n(8947));class s extends o.default{constructor(t,e,n,i){super(),this.p0=t,this.p1=e,this.p2=n,this.p3=i}getPoints(){return[this.p0,this.p1,this.p2,this.p3]}getLooseBoundingBox(){return r.default.bboxOf([this.p0,this.p1,this.p2,this.p3])}}e.default=s},1885: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 o=i(n(8947)),r=n(5378),s=i(n(1098));class a extends s.default{constructor(t,e){super(),this.point1=t,this.point2=e,this.bbox=o.default.bboxOf([t,e]),this.direction=e.minus(t),this.length=this.direction.magnitude(),this.length>0&&(this.direction=this.direction.times(1/this.length))}get p1(){return this.point1}get p2(){return this.point2}get(t){return this.point1.plus(this.direction.times(t))}at(t){return this.get(t*this.length)}intersection(t){let e,n;if(0===this.direction.x){if(0===t.direction.x||0===this.direction.y)return null;const i=this.point1.x,o=(this.point1.x-t.point1.x)*t.direction.y/t.direction.x+t.point1.y;e=r.Vec2.of(i,o),n=(o-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,o=t.direction.y*this.direction.x-this.direction.y*t.direction.x;if(0===o)return null;const s=i/o,a=(s-this.point1.x)/this.direction.x,l=this.point1.y+this.direction.y*a;e=r.Vec2.of(s,l),n=(s-this.point1.x)/this.direction.x}const i=e.minus(this.point1).magnitude(),o=e.minus(this.point2).magnitude(),s=e.minus(t.point1).magnitude(),a=e.minus(t.point2).magnitude();return i>this.length||o>this.length||s>t.length||a>t.length?null:{point:e,t:n}}intersects(t){return null!==this.intersection(t)}intersectsLineSegment(t){const e=this.intersection(t);return e?[e.point]:[]}closestPointTo(t){const e=t.minus(this.p1).dot(this.direction),n=this.length-e,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}signedDistance(t){return this.closestPointTo(t).minus(t).magnitude()}transformedBy(t){return new a(t.transformVec2(this.p1),t.transformVec2(this.p2))}getTightBoundingBox(){return this.bbox}toString(){return`LineSegment(${this.p1.toString()}, ${this.p2.toString()})`}}e.default=a},2487: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 o=n(9036),r=i(n(1885)),s=i(n(8015)),a=i(n(8947)),l=n(5378),c=i(n(4151)),d=i(n(1701)),u=i(n(3777));var h;!function(t){t[t.LineTo=0]="LineTo",t[t.MoveTo=1]="MoveTo",t[t.CubicBezierTo=2]="CubicBezierTo",t[t.QuadraticBezierTo=3]="QuadraticBezierTo"}(h||(e.PathCommandType=h={}));class p{constructor(t,e){this.startPoint=t,this.parts=e,this.cachedGeometry=null,this.cachedPolylineApproximation=null,this.cachedStringVersion=null,this.bbox=a.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(e.getTightBoundingBox());return a.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 h.CubicBezierTo:e.push(new c.default(t,n.controlPoint1,n.controlPoint2,n.endPoint)),t=n.endPoint;break;case h.QuadraticBezierTo:e.push(new d.default(t,n.controlPoint,n.endPoint)),t=n.endPoint;break;case h.LineTo:e.push(new r.default(t,n.point)),t=n.point;break;case h.MoveTo:e.push(new u.default(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 h.CubicBezierTo:t.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:t.push(e.controlPoint,e.endPoint);break;case h.MoveTo:case h.LineTo:t.push(e.point)}const e=[];let n=this.startPoint;for(const i of t)e.push(new r.default(n,i)),n=i;return e}static computeBBoxForSegment(t,e){const n=[t];let i;switch(e.kind){case h.MoveTo:case h.LineTo:n.push(e.point);break;case h.CubicBezierTo:n.push(e.controlPoint1,e.controlPoint2,e.endPoint);break;case h.QuadraticBezierTo:n.push(e.controlPoint,e.endPoint);break;default:return i=e,i}return a.default.bboxOf(n)}raymarchIntersectionWith(t,e,n=[]){var i,o;if(!t.bbox.intersects(this.bbox.grownBy(e)))return[];const r=t.length,s=[];for(const n of this.geometry){const i=n.getTightBoundingBox().grownBy(e);if(!i.intersects(t.bbox))continue;const o=t=>n.signedDistance(t),a=t=>o(t)-e;a(t.p1)>r&&a(t.p2)>r||s.push({part:n,distFn:o,bbox:i})}if(0===s.length)return[];const a=t=>{let n=1/0,i=null;const o=[];for(const e of s){const{part:r,distFn:s,bbox:a}=e;if(!a.containsPoint(t)){o.push(e);continue}const l=s(t);l<=n&&(n=l,i=r)}for(const{part:e,distFn:r,bbox:s}of o){if(!s.grownBy(n).containsPoint(t))continue;const o=r(t);o<=n&&(n=o,i=e)}return[i,n-e]},l=[t.p1,...n,t.p2],c=e=>e.minus(t.p1).dot(t.direction);l.sort(((t,e)=>c(t)-c(e)));const d=[],u=e/1e3,h=(e,n,i)=>{let o=e,[s,l]=a(o),h=c(o);if(l>r)return h;const p=t.direction.times(n);for(let t=0;t<7;t++){const t=l;if(o=o.plus(p.times(t)),h=c(o),h<=i)return h;const[e,n]=a(o);if(Math.abs(n)>Math.abs(l))return null;if(l=n,s=e,Math.abs(l)<u)break}return s&&(h>=0&&h<=r)&&Math.abs(l)<u&&d.push({point:o,parameterValue:NaN,curve:s}),h};let p=0;for(let t=0;t<l.length;t++){const e=l[t];p=Math.max(p,null!==(i=h(e,1,p))&&void 0!==i?i:p),p=Math.max(p,null!==(o=h(e,-1,p))&&void 0!==o?o:p)}return d}intersection(t,e){let n=[];if(!t.bbox.intersects(this.bbox.grownBy(null!=e?e:0)))return[];for(const e of this.geometry){const i=e.intersectsLineSegment(t);i.length>0&&n.push({curve:e,point:i[0]})}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 h.MoveTo:case h.LineTo:return{kind:t.kind,point:e(t.point)};case h.CubicBezierTo:return{kind:t.kind,controlPoint1:e(t.controlPoint1),controlPoint2:e(t.controlPoint2),endPoint:e(t.endPoint)};case h.QuadraticBezierTo:return{kind:t.kind,controlPoint:e(t.controlPoint),endPoint:e(t.endPoint)}}return t}mapPoints(t){const e=t(this.startPoint),n=[];for(const e of this.parts)n.push(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:h.MoveTo,point:t.startPoint},...t.parts]):this}getEndPoint(){if(0===this.parts.length)return this.startPoint;const t=this.parts[this.parts.length-1];return t.kind===h.QuadraticBezierTo||t.kind===h.CubicBezierTo?t.endPoint:t.point}roughlyIntersects(t,e=0){if(0===this.parts.length)return t.containsPoint(this.startPoint);if(this.startPoint.eq(this.getEndPoint())&&0===e)return this.closedRoughlyIntersects(t);if(t.containsRect(this.bbox))return!0;let n=this.startPoint;for(const i of this.parts){const o=p.computeBBoxForSegment(n,i).grownBy(e);if(n=i.kind===h.LineTo||i.kind===h.MoveTo?i.point:i.endPoint,t.intersects(o))return!0}return!1}closedRoughlyIntersects(t){if(t.containsRect(this.bbox))return!0;const e=this.bbox.topLeft.minus(l.Vec2.of(1,1)),n=t.corners,i=this.polylineApproximation();for(const t of n){const n=new r.default(t,e);let o=0;for(const t of i)t.intersects(n)&&o++;if(o%2==1)return!0}const o=t.grownBy(Math.min(t.size.x,t.size.y)),s=[];for(const t of o.divideIntoGrid(4,4))s.push(...t.getEdges());for(const t of s)for(const e of i)if(t.intersects(e))return!0;return!1}static fromRect(t,e=null){const n=[];let i,o;if(null!==e){const n=l.Vec2.of(e,e).times(.5),r=a.default.fromCorners(t.topLeft.plus(n),t.bottomRight.minus(n)),s=a.default.fromCorners(t.topLeft.minus(n),t.bottomRight.plus(n));i=[r.corners[3],...r.corners,...s.corners.reverse()],o=s.corners[3]}else i=t.corners.slice(1),o=t.corners[0];for(const t of i)n.push({kind:h.LineTo,point:t});return n.push({kind:h.LineTo,point:o}),new p(o,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 o=p.fromRenderable(t),r=null!==(i=null===(n=t.style.stroke)||void 0===n?void 0:n.width)&&void 0!==i?i:0,a=r>0&&0===t.style.fill.a;if(e.grownBy(r).transformedBoundingBox(s.default.scaling2D(4,e.center)).containsRect(o.bbox.grownBy(r)))return t;const l=[];let c=o.startPoint;for(const t of o.parts){const n=p.computeBBoxForSegment(c,t).grownBy(r);let i;i=t.kind===h.LineTo||t.kind===h.MoveTo?t.point:t.endPoint;n.intersects(e)?l.push(t):a||t.kind===h.MoveTo?l.push({kind:h.MoveTo,point:i}):l.push({kind:h.LineTo,point:i}),c=i}return new p(o.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)!==h.MoveTo&&a("M",t);for(let t=0;t<e.length;t++){const n=e[t];switch(n.kind){case h.MoveTo:a("M",n.point);break;case h.LineTo:a("L",n.point);break;case h.CubicBezierTo:a("C",n.controlPoint1,n.controlPoint2,n.endPoint);break;case h.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=l.Vec2.zero,i=null,o=null,r=!0;const s=[],a=t=>{r?r=!1:s.push({kind:h.LineTo,point:t})},c={m:1,l:1,c:3,q:2,z:0,h:1,v:1},d=/([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/gi;let u;for(;null!==(u=d.exec(t));){const t=u[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=u[1].toLowerCase(),x=u[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=c[p])&&void 0!==e?e:0,S=d.reduce(((t,e,n,i)=>{if(n%2!=0){const o=e,r=i[n-1];return t.concat(l.Vec2.of(r,o))}return t}),[]).map(((t,e)=>{let i;return i=x?t:n.plus(t),(e+1)%w==0&&(n=i),i}));if(S.length%w!=0)throw new Error([`Incorrect number of arguments: got ${JSON.stringify(S)} with a length of ${S.length} ≠ ${w}k, k ∈ ℤ.`,`The number of arguments to ${p} must be a multiple of ${w}!`,`Command: ${u[0]}`].join("\n"));for(let t=0;t<S.length;t+=w){const e=S.slice(t,t+w);switch(p.toLowerCase()){case"m":0===t?(b=e[0],r?r=!1:s.push({kind:h.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:h.CubicBezierTo,controlPoint1:g,controlPoint2:v,endPoint:y});break;case"q":f=e[0],m=e[1],s.push({kind:h.QuadraticBezierTo,controlPoint:f,endPoint:m});break;default:throw new Error(`Unknown path command ${p}`)}r=!1}S.length>0&&(null!=i||(i=S[0]),null!=o||(o=i),n=S[S.length-1])}var f,m,g,v,y,b;const x=new p(null!=o?o:l.Vec2.zero,s);return x.cachedStringVersion=t,x}}p.empty=new p(l.Vec2.zero,[]),e.default=p},3777: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 o=i(n(1098)),r=i(n(8947));class s extends o.default{constructor(t){super(),this.p=t}signedDistance(t){return this.p.minus(t).magnitude()}intersectsLineSegment(t,e){return t.containsPoint(this.p,e)?[this.p]:[]}getTightBoundingBox(){return new r.default(this.p.x,this.p.y,0,0)}}e.default=s},1701: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 o=n(5378),r=i(n(2636)),s=i(n(4769)),a=i(n(8947));class l extends s.default{constructor(t,e,n){super(),this.p0=t,this.p1=e,this.p2=n}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(l.componentAt(t,e.x,n.x,i.x),l.componentAt(t,e.y,n.y,i.y))}derivativeAt(t){const e=this.p0,n=this.p1,i=this.p2;return o.Vec2.of(l.derivativeComponentAt(t,e.x,n.x,i.x),l.derivativeComponentAt(t,e.y,n.y,i.y))}normal(t){return this.derivativeAt(t).orthog().normalized()}getLooseBoundingBox(){return a.default.bboxOf([this.p0,this.p1,this.p2])}approximateDistance(t){const e=this.p0.x-t.x,n=-2*this.p0.x+2*this.p1.x,i=this.p0.x-2*this.p1.x+this.p2.x,o=this.p0.y-t.y,s=-2*this.p0.y+2*this.p1.y,a=this.p0.y-2*this.p1.y+this.p2.y,l=2*e*n+2*o*s-t.x*n-t.y*s,c=2*n*n+2*s*s+2*i*e+2*a*o-t.x*i-t.y*a,d=2*(2*s*a+2*n*i+2*i*n+2*a*s);let[u,h]=(0,r.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))}getPoints(){return[this.p0,this.p1,this.p2]}}e.default=l},8947: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 o=i(n(1885)),r=n(5378),s=i(n(1098));class a extends s.default{constructor(t,e,n,i){super(),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=r.Vec2.of(this.x,this.y),this.size=r.Vec2.of(this.w,this.h),this.bottomRight=this.topLeft.plus(this.size),this.area=this.w*this.h}translatedBy(t){return new a(t.x+this.x,t.y+this.y,this.w,this.h)}resizedTo(t){return new a(this.x,this.y,t.x,t.y)}containsPoint(t){return this.x<=t.x&&this.y<=t.y&&this.x+this.w>=t.x&&this.y+this.h>=t.y}containsRect(t){return this.x<=t.x&&this.y<=t.y&&this.bottomRight.x>=t.bottomRight.x&&this.bottomRight.y>=t.bottomRight.y}intersects(t){const e=this.x,n=e+this.w,i=t.x,o=t.x+t.w;if(n<i||e>o)return!1;const r=this.y,s=r+this.h,a=t.y,l=t.y+t.h;return!(s<a||r>l)}intersection(t){if(!this.intersects(t))return null;const e=this.topLeft.zip(t.topLeft,Math.max),n=this.bottomRight.zip(t.bottomRight,Math.min);return a.fromCorners(e,n)}union(t){return a.union(this,t)}divideIntoGrid(t,e){const n=[];if(t<=0||e<=0)return n;const i=this.w/t,o=this.h/e;0===i&&(t=1),0===o&&(e=1);for(let r=0;r<e;r++)for(let e=0;e<t;e++){const t=i*e+this.x,s=o*r+this.y;n.push(new a(t,s,i,o))}return n}grownToPoint(t,e=0){const n=new a(t.x-e,t.y-e,2*e,2*e);return this.union(n)}grownBy(t){return 0===t?this:new a(this.x-t,this.y-t,this.w+2*t,this.h+2*t)}getClosestPointOnBoundaryTo(t){const e=this.getEdges().map((e=>e.closestPointTo(t)));let n=null,i=null;for(const o of e){const e=o.minus(t).length();(null===i||e<i)&&(n=o,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(r.Vec2.of(0,-this.h))}get bottomLeft(){return this.topLeft.plus(r.Vec2.of(0,this.h))}get width(){return this.w}get height(){return this.h}get center(){return this.topLeft.plus(this.size.times(.5))}getEdges(){const t=this.corners;return[new o.default(t[0],t[1]),new o.default(t[1],t[2]),new o.default(t[2],t[3]),new o.default(t[3],t[0])]}intersectsLineSegment(t){const e=[];for(const n of this.getEdges()){n.intersectsLineSegment(t).forEach((t=>e.push(t)))}return e}signedDistance(t){const e=this.getClosestPointOnBoundaryTo(t),n=t.minus(e).magnitude();return this.containsPoint(t)?-n:n}getTightBoundingBox(){return this}transformedBoundingBox(t){return a.bboxOf(this.corners.map((e=>t.transformVec2(e))))}eq(t,e=0){return this.topLeft.eq(t.topLeft,e)&&this.size.eq(t.size,e)}toString(){return`Rect(point(${this.x}, ${this.y}), size(${this.w}, ${this.h}))`}static fromCorners(t,e){return new a(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.abs(t.x-e.x),Math.abs(t.y-e.y))}static bboxOf(t,e=0){let n=0,i=0,o=0,s=0,l=!0;for(const e of t)l&&(n=e.x,i=e.y,o=e.x,s=e.y,l=!1),n=Math.min(n,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),s=Math.max(s,e.y);return a.fromCorners(r.Vec2.of(n-e,i-e),r.Vec2.of(o+e,s+e))}static union(...t){if(0===t.length)return a.empty;const e=t[0];let n=e.topLeft.x,i=e.topLeft.y,o=e.bottomRight.x,r=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),o=Math.max(o,s.bottomRight.x),r=Math.max(r,s.bottomRight.y)}return new a(n,i,o-n,r-i)}static of(t){var e,n,i,o;const r=null!==(n=null!==(e=t.width)&&void 0!==e?e:t.w)&&void 0!==n?n:0,s=null!==(o=null!==(i=t.height)&&void 0!==i?i:t.h)&&void 0!==o?o:0;return new a(t.x,t.y,r,s)}}a.empty=new a(0,0,0,0),a.unitSquare=new a(0,0,1,1),e.default=a},3012: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 o=i(n(7717)),r=n(3173),s=i(n(6377)),a=n(5378),l=i(n(5630)),c=i(n(1263)),d=i(n(3472));var u;!function(t){t[t.DummyRenderer=0]="DummyRenderer",t[t.CanvasRenderer=1]="CanvasRenderer"}(u||(e.RenderingMode=u={}));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 r=n.getContext("2d");return new o.default(r,t.viewport)},isOfCorrectType:t=>this.dryInkRenderer.canRenderFromWithoutDataLoss(t),blockResolution:i,cacheSize:1296e5,maxScale:1.3,minProportionalRenderTimePerCache:80,minProportionalRenderTimeToUseCache:420}),this.editor.notifier.on(r.EditorEventType.DisplayResized,(t=>{var e;if(t.kind!==r.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 o.default(n,this.editor.viewport),this.wetInkRenderer=new o.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(r.EditorEventType.DisplayResized,{kind:r.EditorEventType.DisplayResized,newSize:a.Vec2.of(this.width,this.height)}))},this.resizeSurfacesCallback(),this.flattenCallback=()=>{n.drawImage(e,0,0)},this.getColorAt=t=>{const e=n.getImageData(t.x,t.y,1,1),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)}}},2500: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 o=i(n(3472));e.cloneStyle=t=>({fill:t.fill,stroke:t.stroke?Object.assign({},t.stroke):void 0});e.stylesEqual=(t,e)=>{var n,i,o,r,s,a;const l=t===e||t.fill.eq(e.fill)&&null==t.stroke==(null==e.stroke)&&(null===(r=null===(i=null===(n=t.stroke)||void 0===n?void 0:n.color)||void 0===i?void 0:i.eq(null===(o=e.stroke)||void 0===o?void 0:o.color))||void 0===r||r)&&(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:o.default.fromHex(t.stroke.color),width:t.stroke.width}:void 0;return{fill:o.default.fromHex(t.fill),stroke:e}}},2788:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.textStyleToJSON=e.textStyleFromJSON=e.cloneTextStyle=void 0;const i=n(2500);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)})},4619: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 o=i(n(8015));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 o.default.scaling2D(this.cacheState.props.blockResolution.x/t.size.x).rightMul(o.default.translation(t.topLeft.times(-1)))}setRenderingRegion(t){this.renderer.setTransform(this.getTransform(t))}}},8182: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 o=i(n(4619));e.CacheRecordManager=class{constructor(t){this.cacheRecords=[],this.maxCanvases=Math.ceil(t.cacheSize/4/t.blockResolution.x/t.blockResolution.y)}setSharedState(t){this.cacheState=t}allocCanvas(t,e){if(this.cacheRecords.length<this.maxCanvases){const n=new o.default(e,this.cacheState);return n.setRenderingRegion(t),this.cacheRecords.push(n),n}{const n=this.getLeastRecentlyUsedRecord();return n.realloc(e),n.setRenderingRegion(t),n}}getLeastRecentlyUsedRecord(){return this.cacheRecords.sort(((t,e)=>t.getLastUsedCycle()-e.getLastUsedCycle())),this.cacheRecords[0]}}},5630:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(8947)),r=i(n(1310)),s=n(8182);e.default=class{constructor(t){this.recordManager=new s.CacheRecordManager(t),this.sharedState={props:t,currentRenderingCycle:0,recordManager:this.recordManager},this.recordManager.setSharedState(this.sharedState)}render(t,e,n){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 r.default(new o.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)}}},1310: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(3472));const o=n(7551),r=i(n(8947)),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=r.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,o.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 o=0;for(const t of d)o+=t.getContent().getProportionalRenderingTime();if(o>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],o=i.getContent().getZIndex();(t>=this.renderedIds.length||i.getId()!==this.renderedIds[t])&&(e.push(i),(null===n||o<n)&&(n=o))}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 r.default(this.region.x,this.region.y,this.region.w+e,this.region.h+e),o=!0;t.startObject(i,o);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},2670: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 o=n(7369);Object.defineProperty(e,"AbstractRenderer",{enumerable:!0,get:function(){return i(o).default}});var r=n(6377);Object.defineProperty(e,"DummyRenderer",{enumerable:!0,get:function(){return i(r).default}});var s=n(2001);Object.defineProperty(e,"SVGRenderer",{enumerable:!0,get:function(){return i(s).default}});var a=n(7717);Object.defineProperty(e,"CanvasRenderer",{enumerable:!0,get:function(){return i(a).default}});var l=n(3012);Object.defineProperty(e,"Display",{enumerable:!0,get:function(){return i(l).default}}),Object.defineProperty(e,"RenderingMode",{enumerable:!0,get:function(){return l.RenderingMode}})},49:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTextRendererLocalization=void 0,e.defaultTextRendererLocalization={pathNodeCount:t=>`There are ${t} visible path objects.`,textNodeCount:t=>`There are ${t} visible text nodes.`,imageNodeCount:t=>`There are ${t} visible image nodes.`,textNode:t=>`Text: ${t}`,imageNode:t=>`Image: ${t}`,unlabeledImageNode:"Unlabeled image",rerenderAsText:"Re-render as text"}},7369:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0});const s=r(n(2487)),a=n(5378),l=n(2500);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:o}=e;t&&(0,l.stylesEqual)(t,o)?this.moveTo(n):(t&&this.endPath(t),this.beginPath(n),t=o);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),this.currentPaths=[]}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.objectLevel>0&&this.flushPath(),this.currentPaths=[],this.objectLevel++}endObject(t,e){if(this.flushPath(),this.currentPaths=null,this.objectLevel--,this.objectLevel<0)throw new Error("More objects have ended than have been started (negative object nesting level)!")}getNestingLevel(){return this.objectLevel}canRenderFromWithoutDataLoss(t){return!1}renderFromOtherOfSameType(t,e){throw new Error(`Unable to render from ${e}: Not implemented`)}setTransform(t){this.selfTransform=t}pushTransform(t){this.transformStack.push(this.selfTransform),this.setTransform(this.getCanvasToScreenTransform().rightMul(t))}popTransform(){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()}}},7717: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 o=i(n(3472)),r=i(n(1151)),s=i(n(2487)),a=n(5378),l=i(n(7369));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.save(),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(),this.ctx.restore()}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),o=n.minus(e);i.magnitudeSquared()<this.minSquareCurveApproxDist&&o.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),r.default.applyTextStyles(this.ctx,n),0!==n.renderingStyle.fill.a&&(this.ctx.fillStyle=n.renderingStyle.fill.toHexString(),this.ctx.fillText(t,0,0)),n.renderingStyle.stroke&&(this.ctx.strokeStyle=n.renderingStyle.stroke.color.toHexString(),this.ctx.lineWidth=n.renderingStyle.stroke.width,this.ctx.strokeText(t,0,0)),this.ctx.restore()}drawImage(t){this.ctx.save();const e=this.getCanvasToScreenTransform().rightMul(t.transform);this.transformBy(e),this.ctx.drawImage(t.image,0,0),this.ctx.restore()}startObject(t,e){if(this.isTooSmallToRender(t)&&(this.ignoreObjectsAboveLevel=this.getNestingLevel(),this.ignoringObject=!0),super.startObject(t),this.currentObjectBBox=t,!this.ignoringObject&&e){if(!t.containsRect(this.getViewport().visibleRect)){this.clipLevels.push(this.objectLevel),this.ctx.save(),this.ctx.beginPath();for(const e of t.corners){const t=this.canvasToScreen(e);this.ctx.lineTo(t.x,t.y)}this.ctx.clip()}}}endObject(){const t=this.objectLevel;this.currentObjectBBox=null,super.endObject(),!this.ignoringObject&&this.clipLevels.length>0&&this.clipLevels[this.clipLevels.length-1]===t&&(this.ctx.restore(),this.clipLevels.pop()),null!==this.ignoreObjectsAboveLevel&&this.getNestingLevel()<=this.ignoreObjectsAboveLevel&&(this.ignoreObjectsAboveLevel=null,this.ignoringObject=!1)}drawPoints(...t){for(let e=0;e<t.length;e++){const n=this.canvasToScreen(t[e]);this.ctx.beginPath(),this.ctx.arc(n.x,n.y,10,0,2*Math.PI),this.ctx.fillStyle=o.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,o=this.minRenderSizeAnyDimen,r=Math.abs(e.x)<o||Math.abs(e.y)<o;return i||r}}e.default=c},6377: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 o=n(5378),r=i(n(7369));class s extends r.default{constructor(t){super(t),this.clearedCount=0,this.renderedPathCount=0,this.lastFillStyle=null,this.lastPoint=null,this.objectNestingLevel=0,this.lastText=null,this.lastImage=null,this.pointBuffer=[]}displaySize(){const t=this.getViewport().getScreenRectSize();return 0===t.x||0===t.y?o.Vec2.of(640,480):t}clear(){if(this.clearedCount++,this.renderedPathCount=0,this.pointBuffer=[],this.lastText=null,this.lastImage=null,this.objectNestingLevel>0)throw new Error(`Within an object while clearing! Nesting level: ${this.objectNestingLevel}`)}beginPath(t){this.lastPoint=t,this.pointBuffer.push(t)}endPath(t){this.renderedPathCount++,this.lastFillStyle=t}lineTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}moveTo(t){t=this.canvasToScreen(t),this.lastPoint=t,this.pointBuffer.push(t)}traceCubicBezierCurve(t,e,n){t=this.canvasToScreen(t),e=this.canvasToScreen(e),n=this.canvasToScreen(n),this.lastPoint=n,this.pointBuffer.push(t,e,n)}traceQuadraticBezierCurve(t,e){t=this.canvasToScreen(t),e=this.canvasToScreen(e),this.lastPoint=e,this.pointBuffer.push(t,e)}drawPoints(...t){}drawText(t,e,n){this.lastText=t}drawImage(t){this.lastImage=t}startObject(t,e){super.startObject(t),this.objectNestingLevel+=1}endObject(){super.endObject(),this.objectNestingLevel-=1}isTooSmallToRender(t){return!1}canRenderFromWithoutDataLoss(t){return t instanceof s}renderFromOtherOfSameType(t,e){if(!(e instanceof s))throw new Error(`${e} cannot be rendered onto ${this}`);this.renderedPathCount+=e.renderedPathCount,this.lastFillStyle=e.lastFillStyle,this.lastPoint=e.lastPoint,this.pointBuffer.push(...e.pointBuffer.map((e=>t.transformVec2(e))))}}e.default=s},2001:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.renderedStylesheetId=void 0;const o=i(n(8015)),r=i(n(2487)),s=n(9036),a=n(5378),l=n(1697),c=n(2500),d=i(n(7369));e.renderedStylesheetId="js-draw-style-sheet";const u="http://www.w3.org/2000/svg",h={fontWeight:"400",fontStyle:"normal"};class p 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=h,this.clear(),this.addStyleSheet()}addStyleSheet(){if(!this.elem.querySelector(`#${e.renderedStylesheetId}`)){const t=document.createElementNS("http://www.w3.org/2000/svg","style");t.innerHTML="\n\t\t\t\tpath {\n\t\t\t\t\tstroke-linecap: round;\n\t\t\t\t\tstroke-linejoin: round;\n\t\t\t\t}\n\n\t\t\t\ttext {\n\t\t\t\t\twhite-space: pre;\n\t\t\t\t}\n\t\t\t".replace(/\s+/g,""),t.setAttribute("id",e.renderedStylesheetId),this.elem.appendChild(t)}}setRootSVGAttribute(t,e){this.sanitize||(t in this.overwrittenAttrs||(this.overwrittenAttrs[t]=this.elem.getAttribute(t)),null!==e?this.elem.setAttribute(t,e):this.elem.removeAttribute(t))}displaySize(){return 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 null;const e=document.createElementNS(u,"path");e.setAttribute("d",this.lastPathString.join(" "));const n=this.lastPathStyle;return 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),e}drawPath(t){const e=t.style,n=r.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 r=n?t:this.getCanvasToScreenTransform().rightMul(t);const l=r.transformVec2(a.Vec2.zero);i&&(r=r.rightMul(o.default.translation(l.times(-1)))),r.eq(o.default.identity)?e.style.transform="":e.style.transform=`matrix(\n\t\t\t\t${r.a1}, ${r.b1},\n\t\t\t\t${r.a2}, ${r.b2},\n\t\t\t\t${r.a3}, ${r.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 o=(t,e)=>{var n,i,o,r,s,a,l,c;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!==(o=e.fontVariant)&&void 0!==o?o:""),e.fontWeight!==(null===(r=this.textParentStyle)||void 0===r?void 0:r.fontWeight)&&(t.style.fontWeight=null!==(s=e.fontWeight)&&void 0!==s?s:""),e.fontStyle!==(null===(a=this.textParentStyle)||void 0===a?void 0:a.fontStyle)&&(t.style.fontStyle=null!==(l=e.fontStyle)&&void 0!==l?l:""),e.size!==(null===(c=this.textParentStyle)||void 0===c?void 0:c.size)&&(t.style.fontSize=e.size+"px");const d=e.renderingStyle.fill.toHexString();if(t.style.fill=d,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 r=(e=this.textContainerTransform.inverse().rightMul(e)).transformVec2(a.Vec2.zero);i.setAttribute("x",`${(0,s.toRoundedString)(r.x)}`),i.setAttribute("y",`${(0,s.toRoundedString)(r.y)}`),o(i,n)}else{const r=document.createElementNS(u,"text");r.appendChild(document.createTextNode(t));const s=!1;this.transformFrom(e,r,!0,s),o(r,n),this.elem.appendChild(r),null===(i=this.objectElems)||void 0===i||i.push(r),this.objectLevel>0&&(this.textContainer=r,this.textContainerTransform=e,this.textParentStyle=Object.assign(Object.assign({},h),n))}}drawImage(t){var e,n,i,o,r,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!==(o=t.image.getAttribute("width"))&&void 0!==o?o:""),l.setAttribute("height",null!==(r=t.image.getAttribute("height"))&&void 0!==r?r:""),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=h,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"),o=t.getScreenRectSize();return i.setAttribute("viewBox",[0,0,o.x,o.y].map((t=>(0,s.toRoundedString)(t))).join(" ")),i.setAttribute("width",(0,s.toRoundedString)(o.x)),i.setAttribute("height",(0,s.toRoundedString)(o.y)),i.setAttribute("version","1.1"),i.setAttribute("baseProfile","full"),i.setAttribute("xmlns",n),{element:i,renderer:new p(i,t,e)}}}e.default=p},1263: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 o=n(5378),r=i(n(7369));class s extends r.default{constructor(t,e){super(t),this.localizationTable=e,this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}displaySize(){return o.Vec2.of(500,500)}clear(){this.descriptionBuilder=[],this.pathCount=0,this.textNodeCount=0,this.imageNodeCount=0}getDescription(){return[this.localizationTable.pathNodeCount(this.pathCount),...this.textNodeCount>0?[this.localizationTable.textNodeCount(this.textNodeCount)]:[],...this.imageNodeCount>0?[this.localizationTable.imageNodeCount(this.imageNodeCount)]:[],...this.descriptionBuilder].join("\n")}beginPath(t){}endPath(t){this.pathCount++}lineTo(t){}moveTo(t){}traceCubicBezierCurve(t,e,n){}traceQuadraticBezierCurve(t,e){}drawText(t,e,n){this.descriptionBuilder.push(this.localizationTable.textNode(t)),this.textNodeCount++}drawImage(t){const e=t.label?this.localizationTable.imageNode(t.label):this.localizationTable.unlabeledImageNode;this.descriptionBuilder.push(e),this.imageNodeCount++}isTooSmallToRender(t){return t.maxDimension<15/this.getSizeOfCanvasPixelOnScreen()}drawPoints(...t){}}e.default=s},7:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{constructor(t){this.key=t.key,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.controlOrMeta=t.controlOrMeta}matchesEvent(t){var e,n,i,o,r,s,a,l,c,d;const u=null===(e=t.key)||void 0===e?void 0:e.toLowerCase(),h=(null===(n=t.key)||void 0===n?void 0:n.toUpperCase())===t.key&&(null===(i=t.key)||void 0===i?void 0:i.toLowerCase())!==t.key&&1===(null===(o=t.key)||void 0===o?void 0:o.length),p=(null===(r=t.key)||void 0===r?void 0:r.toLowerCase())===t.key&&!h&&1===(null===(s=t.key)||void 0===s?void 0:s.length),f=null!==(a=t.ctrlKey)&&void 0!==a&&a||"control"===u,m=null!==(l=t.altKey)&&void 0!==l&&l||"alt"===u,g=null!==(c=t.metaKey)&&void 0!==c&&c||"meta"===u,v=(null!==(d=t.shiftKey)&&void 0!==d?d:h)||"shift"===u,y=t.controlOrMeta||t.ctrlKey||t.metaKey||!1;if(this.key.toLowerCase()!==u)return!1;if((h||p)&&this.key!==t.key){if(!(!0===this.shiftKey&&this.key.toUpperCase()===t.key))return!1}const b=this.controlOrMeta;return(f===this.ctrlKey&&g===this.metaKey&&!b||b&&y)&&m===this.altKey&&(v===this.shiftKey||void 0===this.shiftKey)}toString(){const t=[];return this.ctrlKey&&"control"!==this.key&&t.push("Ctrl"),this.controlOrMeta&&t.push("CtrlOrMeta"),this.altKey&&"alt"!==this.key&&t.push("Alt"),this.metaKey&&"meta"!==this.key&&t.push("Meta"),this.shiftKey&&"shift"!==this.key&&t.push("Shift"),t.push(this.key),t.join("+")}static fromString(t){var e;if(-1===t.search(/[-+]/)||1===t.length){const e=t.toLowerCase();let i;return"shift"===e&&(i=!0),new n({key:t,shiftKey:i,ctrlKey:"control"===e||"ctrl"===e,altKey:"alt"===e,metaKey:"meta"===e,controlOrMeta:"control or meta"===e||"ctrlormeta"===e})}const i=/^(.*[-+])?(.+)$/g.exec(t);if(!i)throw new Error(`Invalid shortcut expression, ${t}!`);const o=i[2],r=(null!==(e=i[1])&&void 0!==e?e:"").split(/[-+]/);let s,a=!1,l=!1,c=!1,d=!1;for(const e of r)if(""!==e)switch(e.toLowerCase()){case"shift":s=!0;break;case"noshift":s=!1;break;case"ctrl":case"control":a=!0;break;case"meta":c=!0;break;case"ctrlormeta":case"ctrl or meta":case"controlormeta":d=!0;break;case"alt":l=!0;break;default:throw new Error(`Unknown modifier: "${e}" in shortcut ${t}.`)}return new n({key:o,shiftKey:s,ctrlKey:a,altKey:l,metaKey:c,controlOrMeta:d})}}e.default=n},5376: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 o=n(1906),r=i(n(7));class s{constructor(t){this.shortcutOverrides=Object.create(null);for(const e in t)this.overrideShortcut(e,t[e])}overrideShortcut(t,e){this.shortcutOverrides[t]=[...e]}matchesShortcut(t,e){let n=this.shortcutOverrides[t];if(!n){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);n=s.shortcuts[t]}for(const t of n)if(t.matchesEvent(e))return!0;return!1}static registerDefaultKeyboardShortcut(t,e,n){if(t in s.shortcuts)return!1;const i=e.map((t=>"string"==typeof t?r.default.fromString(t):t));return s.shortcuts[t]=[...i],s.shortcutDefaultDescriptions[t]=n,!0}static provideShortcutDescription(t,e,n){e in s.shortcutLocalizedDescriptions||(s.shortcutLocalizedDescriptions[e]=Object.create(null)),s.shortcutLocalizedDescriptions[e][t]=n}static getAllShortcutIds(){const t=[];for(const e in this.shortcuts)t.push(e);return t}static getShortcutDefaultKeybindings(t){if(!(t in s.shortcuts))throw new Error(`No shortcut with ID ${t} exists!`);return s.shortcuts[t]}static getShortcutDescription(t,e){var n,i;return null!==(i=null!==(n=(0,o.matchingLocalizationTable)(null!=e?e:[],this.shortcutLocalizedDescriptions,this.shortcutDefaultDescriptions)[t])&&void 0!==n?n:this.shortcutDefaultDescriptions[t])&&void 0!==i?i:null}}s.shortcuts=Object.create(null),s.shortcutDefaultDescriptions=Object.create(null),s.shortcutLocalizedDescriptions=Object.create(null),e.default=s},6843:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBinding=e.KeyboardShortcutManager=void 0;var o=n(5376);Object.defineProperty(e,"KeyboardShortcutManager",{enumerable:!0,get:function(){return i(o).default}});var r=n(7);Object.defineProperty(e,"KeyBinding",{enumerable:!0,get:function(){return i(r).default}})},3311:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{let e=0;const n=t.map((t=>t.id));n.sort();for(const t of n)e===t&&(e=t+1);return e}},1797:function(t,e,n){"use strict";var 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 o=n(1380);Object.defineProperty(e,"sendPenEvent",{enumerable:!0,get:function(){return i(o).default}});var r=n(8783);Object.defineProperty(e,"sendTouchEvent",{enumerable:!0,get:function(){return i(r).default}})},1380: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 o=i(n(4318)),r=n(3173),s=i(n(3311));e.default=(t,e,n,i)=>{const a=(0,s.default)(null!=i?i:[]),l=o.default.ofCanvasPoint(n,e!==r.InputEvtType.PointerUpEvt,t.viewport,a);return t.toolController.dispatchInputEvent({kind:e,allPointers:null!=i?i:[l],current:l}),l}},8783:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=r(n(4318)),l=n(3173),c=s(n(3311));e.default=(t,e,n,i)=>{const o=t.viewport.screenToCanvas(n),r=(0,c.default)(null!=i?i:[]),s=a.default.ofCanvasPoint(o,e!==l.InputEvtType.PointerUpEvt,t.viewport,r,a.PointerDevice.Touch);return t.toolController.dispatchInputEvent({kind:e,allPointers:[...null!=i?i:[],s],current:s}),s}},3808: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 o=n(3173),r=n(5381),s=i(n(3472)),a=n(9746),l=i(n(7591)),c=i(n(4735)),d=i(n(4321)),u=i(n(6416)),h=i(n(2133)),p=i(n(7998)),f=i(n(9944)),m=i(n(5001)),g=i(n(5730)),v=i(n(7956)),y=i(n(3534)),b=i(n(6318)),x=i(n(5771)),w=i(n(3359)),S=n(5378);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.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),T.colorisStarted||((0,r.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.")}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 o,s;const a=S.Vec2.of(i.pageX,i.pageY);let l=!0;if("pointerdown"===e)(0,r.close)(),t=[],t.push([e,i]),n=a,null===(o=this.closeColorPickerOverlay)||void 0===o||o.setPointerCapture(i.pointerId),l=!1;else if("pointermove"===e){const o=10;if(n&&a.minus(n).magnitude()<o)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,r.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(o.EditorEventType.ColorPickerToggled,(t=>{t.kind===o.EditorEventType.ColorPickerToggled&&this.closeColorPickerOverlay&&(this.closeColorPickerOverlay.style.display=t.open?"block":"none")}))),this.listeners.push(this.editor.notifier.on(o.EditorEventType.ColorPickerColorSelected,(i=>{i.kind===o.EditorEventType.ColorPickerColorSelected&&(i=>{let o=!1;for(const e of t)e===i&&(o=!0);o||(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 o=!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,o=!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))}o=!0}this.overflowWidget.setHidden(0===this.overflowWidget.getChildWidgets().length),o&&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,o=new y.default(this.editor,"action-button",(()=>"string"==typeof t?null:t.icon),i,e,this.editor.localization,n);return this.addWidget(o),o}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(o.EditorEventType.UndoRedoStackUpdated,(n=>{if(n.kind!==o.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()}}T.colorisStarted=!1,e.default=T},8282: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 o=i(n(3472)),r=n(5378),s=i(n(2001)),a=i(n(5566)),l="http://www.w3.org/2000/svg",c="\n\tstyle='fill: var(--icon-color);'\n";let d=0;const u=()=>{const t="checkerboard-"+d++;return{patternDef:`\n\t\t<pattern\n\t\t\tid='${t}'\n\t\t\tviewBox='0,0,10,10'\n\t\t\twidth='20%'\n\t\t\theight='20%'\n\t\t\tpatternUnits='userSpaceOnUse'\n\t\t>\n\t\t\t<rect x=0 y=0 width=10 height=10 fill='white'/>\n\t\t\t<rect x=0 y=0 width=5 height=5 fill='gray'/>\n\t\t\t<rect x=5 y=5 width=5 height=5 fill='gray'/>\n\t\t</pattern>\n\t`,patternRef:`url(#${t})`}};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 o=document.createElementNS(l,"svg"),r=document.createElementNS(l,"path");return r.setAttribute("d",t),r.style.fill=e,r.style.stroke=n,r.style.strokeWidth=i,o.appendChild(r),o.setAttribute("viewBox","0 0 100 100"),o}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 o=document.createElementNS(l,"text");o.appendChild(document.createTextNode(e)),o.setAttribute("x",n.toString()),o.setAttribute("y",i.toString()),o.style.textAlign="center",o.style.textAnchor="middle",o.style.fontSize="55px",o.style.fill="var(--icon-color)",o.style.fontFamily="monospace",t.appendChild(o)};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 o=document.createElementNS(l,"text");return o.appendChild(document.createTextNode("T")),o.style.fontFamily=t.fontFamily,o.style.fontWeight=null!==(e=t.fontWeight)&&void 0!==e?e:"",o.style.fontVariant=null!==(n=t.fontVariant)&&void 0!==n?n:"",o.style.fill=t.renderingStyle.fill.toHexString(),o.style.textAnchor="middle",o.setAttribute("x","50"),o.setAttribute("y","75"),o.style.fontSize="65px",o.style.filter="drop-shadow(0px 0px 10px var(--primary-shadow-color))",i.appendChild(o),i}makePenIcon(t,e,n){e instanceof o.default&&(e=e.toHexString());const i=document.createElementNS(l,"svg");i.setAttribute("viewBox","0 0 100 100");const r=t/2,s=`\n\t\t\tM ${15-r},${80-r}\n\t\t\t ${15-r},${80+r}\n\t\t\t 30,83\n\t\t\t 15,65\n\t\t\tZ\n\t\t`,a=80+r,c=`\n\t\t\tm ${15-1.1*r},${a}\n\t\t\tc 35,10 55,15 60,30\n\t\t\tl ${35+1.2*r},${-10-r}\n\t\t\tC 80.47,98.32 50.5,${90+r} 20,${a} Z\n\t\t`,d="\n\t\t\tM 72.45,35.67\n\t\t\tA 10,15 41.8 0 1 55,40.2 10,15 41.8 0 1 57.55,22.3 10,15 41.8 0 1 75,17.8 10,15 41.8 0 1 72.5,35.67\n\t\t\tZ\n\t\t";let h="M 85,-25 25,35 h 10 v 10 h 10 v 10 h 10 v 10 h 10 l -5,10 60,-60 z",p="M 25,35 H 35 L 90,-15 85,-25 Z",f="M 60,75 65,65 H 55 l 55,-55 10,5 z";n&&(h="M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z",p="m 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z",f="M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z");const m=`M 25,35 ${10-r/4},${70-r/2} 20,75 25,85 60,75 70,55 45,25 Z`,g=o.default.fromHex("#f4d7d7").mix(o.default.fromString(e),r/40-.1).toHexString(),v=u(),y=`\n\t\t\t<path\n\t\t\t\tfill="${v.patternRef}"\n\t\t\t\td="${s}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${v.patternRef}"\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="${v.patternRef}"\n\t\t\t\td="${m}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${g}"\n\t\t\t\tstroke="${e}"\n\t\t\t\td="${m}"\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="${h}"\n\t\t\t/>\n\n\t\t\t\x3c!-- shadows --\x3e\n\t\t\t<path\n\t\t\t\tfill="rgba(150, 150, 150, 0.3)"\n\t\t\t\td="${p}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="rgba(100, 100, 100, 0.2)"\n\t\t\t\td="${f}"\n\t\t\t/>\n\n\t\t\t\x3c!-- color bubble --\x3e\n\t\t\t<path\n\t\t\t\tfill="${v.patternRef}"\n\t\t\t\td="${d}"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill="${e}"\n\t\t\t\td="${d}"\n\t\t\t/>\n\t\t`;return i.innerHTML=`\n\t\t<defs>\n\t\t\t${v.patternDef}\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,n=!1){const i=3*Math.sqrt(t.getThickness()),o=(new Date).getTime(),c={pos:r.Vec2.of(10,10),width:i,color:t.getColor(),time:o-100},d={pos:r.Vec2.of(90,90),width:i,color:t.getColor(),time:o},h=new a.default((()=>{})),p=e(c,h);p.addPoint(d);const f=document.createElementNS(l,"svg");let m;if(f.setAttribute("viewBox","0 0 100 100"),h.updateScreenSize(r.Vec2.of(100,100)),n){const t=u(),e=document.createElementNS(l,"defs");e.innerHTML=t.patternDef,f.appendChild(e);const n=document.createElementNS(l,"g");f.appendChild(n),m=new class extends s.default{constructor(){super(f,h)}addPathToSVG(){const e=super.addPathToSVG();if(e){const i=e.cloneNode(!0);i.style.zIndex="-1",i.hasAttribute("fill")&&"transparent"!==i.getAttribute("fill")&&"none"!==i.getAttribute("fill")&&i.setAttribute("fill",t.patternRef),i.hasAttribute("stroke")&&i.setAttribute("stroke",t.patternRef),n.appendChild(i)}return e}}}else m=new s.default(f,h);p.preview(m);const g=p.getBBox();return f.setAttribute("viewBox",`${g.x} ${g.y} ${g.w} ${g.h}`),f}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=u(),i=document.createElementNS(l,"defs");i.innerHTML=n.patternDef,e.appendChild(i);const o=document.createElementNS(l,"path"),r=document.createElementNS(l,"path"),s="\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",s),o.setAttribute("d",s),r.style.fill=t.toHexString(),o.style.fill=n.patternRef,e.appendChild(o),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")}}},2994:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.IconProvider=void 0,o(n(7321),e),o(n(6528),e);var s=n(8282);Object.defineProperty(e,"IconProvider",{enumerable:!0,get:function(){return r(s).default}})},9746:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolbarLocalization=void 0,e.defaultToolbarLocalization={pen:"Pen",eraser:"Eraser",select:"Select",handTool:"Pan",zoom:"Zoom",image:"Image",reformatSelection:"Format selection",inputAltText:"Alt text: ",chooseFile:"Choose file: ",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",roundedTipPen:"Rounded Tip",flatTipPen:"Flat Tip",arrowPen:"Arrow",linePen:"Line",outlinedRectanglePen:"Outlined rectangle",filledRectanglePen:"Filled rectangle",outlinedCirclePen:"Outlined circle",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}`}},6528: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 o=i(n(3472)),r=i(n(5248)),s=n(3173);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 r=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=o.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}),r.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 o=e=>{i.replaceChildren(t.icons.makePipetteIcon(e))};o();const s=t.toolController.getMatchingTools(r.default)[0],a=()=>{null==s||s.clearColorListener(),o(),i.classList.remove("active")},l=t=>{a(),t&&n(t)},c=t=>{t?o(t):o()};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},3534: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 o=i(n(3258));class r extends o.default{constructor(t,e,n,i,o,r,s=!1){super(t,e,r),this.makeIcon=n,this.title=i,this.clickAction=o,this.mustBeToplevel=s}handleClick(){this.clickAction()}getTitle(){return this.title}createIcon(){return this.makeIcon()}fillDropdown(t){return!1}canBeInOverflowMenu(){return!this.mustBeToplevel}}e.default=r},1421: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 o=n(3173),r=i(n(3258));class s extends r.default{constructor(t,e,n,i){super(t,n,i),this.targetTool=e,t.notifier.on(o.EditorEventType.ToolEnabled,(t=>{if(t.kind!==o.EditorEventType.ToolEnabled)throw new Error("Incorrect event type! (Expected ToolEnabled)");t.tool===e&&this.setSelected(!0)})),t.notifier.on(o.EditorEventType.ToolDisabled,(t=>{if(t.kind!==o.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())}onKeyPress(t){return!(!this.isSelected()||" "!==t.key||!this.hasDropdown)&&(this.handleClick(),!0)}addTo(t){const e=super.addTo(t);return this.setSelected(this.targetTool.isEnabled()),e}}e.default=s},3258:function(t,e,n){"use strict";var i,o=this&&this.__classPrivateFieldSet||function(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n},r=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(6390)),l=n(3173),c=n(3808);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.hideDropdownTimeout=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"),o(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 r=this.editor.toolController.getMatchingTools(a.default);r.length>0&&this.onKeyPress!==d.prototype.onKeyPress&&r[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 r(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),this.dropdownContainer.replaceChildren(),o(this,i,this.fillDropdown(this.dropdownContainer),"f"),r(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){if(this.container.classList.contains("dropdownVisible")===t)return;this.hideDropdownTimeout&&(clearTimeout(this.hideDropdownTimeout),this.hideDropdownTimeout=null,this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown());if(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.repositionDropdown();else{this.container.classList.remove("dropdownVisible"),this.editor.announceForAccessibility(this.localizationTable.dropdownHidden(this.getTitle())),this.dropdownContainer.classList.add("hiding");const t=142.5;this.hideDropdownTimeout=setTimeout((()=>{this.dropdownContainer.classList.add("hidden"),this.dropdownContainer.classList.remove("hiding"),this.repositionDropdown()}),t)}const e=`var(--dropdown-${t?"show":"hide"}-animation)`;this.dropdownContainer.style.animation=`150ms ease ${e}`}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.translate=`calc(${this.button.clientWidth+"px"} - 100%) 0`:this.dropdownContainer.style.translate=""}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])}}i=new WeakMap,e.default=d},5771:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=s(n(9721)),l=s(n(1456)),c=r(n(1847)),d=n(7551),u=s(n(8947)),h=n(3173),p=n(3808),f=s(n(6528)),m=s(n(3258));class g extends m.default{constructor(t,e){super(t,"document-properties-widget",e),this.updateDropdownContent=()=>{},this.dropdownUpdateQueued=!1,this.container.classList.add("dropdownShowable"),this.editor.notifier.on(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),o=this.editor.getImportExportRect(),r=new u.default(o.x,o.y,null!=n?n:o.w,null!=i?i:o.h);this.editor.dispatch(this.editor.image.setImportExportRect(r)),this.editor.queueRerender()}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${p.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("label");i.innerText=this.localizationTable.backgroundColor;const[o,r,s]=(0,f.default)(this.editor,(t=>{t.eq(this.getBackgroundColor())||this.setBackgroundColor(t)}));o.id=`${p.toolbarCSSPrefix}docPropertiesColorInput-${g.idCounter++}`,i.htmlFor=o.id,n.replaceChildren(i,r);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"),o=document.createElement("span"),r=document.createElement("input");return i.innerText=t,r.type="number",r.min="0",r.id=`${p.toolbarCSSPrefix}docPropertiesDimensionRow-${g.idCounter++}`,i.htmlFor=r.id,o.style.flexGrow="1",r.style.flexGrow="2",r.style.width="25px",n.style.display="flex",r.oninput=()=>{e(parseFloat(r.value))},n.replaceChildren(i,o,r),{setValue:t=>{r.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},9944: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 o=n(3173),r=n(3808),s=i(n(1421));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(o.EditorEventType.ToolUpdated,(t=>{t.kind===o.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=`${r.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},7956:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(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(8015)),l=r(n(4735)),c=n(3173),d=s(n(5566)),u=n(3808),h=s(n(1421)),p=s(n(3258));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"),o=document.createElement("button"),r=document.createElement("button"),s=document.createElement("span");let l;i.innerText="+",o.innerText="-",r.innerText=t.resetView,n.replaceChildren(s,i,o,r),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(),r.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)},o.onclick=()=>{p(.8)},r.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,o,r){super(t,`pan-mode-${n}`,r),this.tool=e,this.flag=n,this.makeIcon=i,this.title=o,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 o=new m(t,e,l.PanZoomMode.OneFingerTouchGestures,(()=>this.editor.icons.makeTouchPanningIcon()),n.touchPanning,n),r=new m(t,e,l.PanZoomMode.RotationLocked,(()=>this.editor.icons.makeRotationLockIcon()),n.lockRotation,n);this.addSubWidget(o),this.addSubWidget(r),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},6318:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(7077)),s=o(n(9721)),a=o(n(7551)),l=o(n(1456)),c=o(n(7591)),d=o(n(8015)),u=o(n(9070)),h=o(n(3534));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 o=document.createElement("div");o.classList.add("action-button-row"),this.submitButton=document.createElement("button");const r=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"),r.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="")})),r.onclick=()=>{this.hideDialog()},this.imageSelectionOverlay.onclick=t=>{t.target===this.imageSelectionOverlay&&this.hideDialog()},e.replaceChildren(s,this.imageFileInput),n.replaceChildren(a,this.imageAltTextInput),o.replaceChildren(r,this.submitButton),t.replaceChildren(e,n,this.imagePreview,this.statusView,o),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",o=e;n>=1&&(o=n,i="MiB"),this.statusView.innerText=this.localizationTable.imageSize(Math.round(o),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 o=null;1===n.length&&n[0]instanceof r.default?(o=n[0],this.imageAltTextInput.value=null!==(t=o.getAltText())&&void 0!==t?t:"",this.imagePreview.style.display="block",this.submitButton.disabled=!1,this.imageBase64URL=o.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 r.default.fromImage(n,d.default.identity);if(0!==i.getBBox().area)if(this.imageSelectionOverlay.style.display="none",o){const n=new s.default([o]);yield this.editor.dispatch((0,l.default)([a.default.addElement(i),i.transformBy(o.getTransformation()),i.setZIndex(o.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},3359: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 o=i(n(3258));class r extends o.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=r},7998: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 o=n(9274),r=n(6951),s=n(823),a=n(725),l=n(4666),c=n(7973),d=n(3173),u=n(3808),h=i(n(6528)),p=i(n(1421)),f=i(n(3472)),m=n(3240);class g extends p.default{constructor(t,e,n){super(t,e,"pen",n),this.tool=e,this.updateInputs=()=>{},this.penTypes=[{name:this.localizationTable.flatTipPen,id:"pressure-sensitive-pen",factory:s.makePressureSensitiveFreehandLineBuilder},{name:this.localizationTable.roundedTipPen,id:"freehand-pen",factory:r.makeFreehandLineBuilder},{name:this.localizationTable.arrowPen,id:"arrow",factory:o.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},{name:this.localizationTable.outlinedCirclePen,id:"outlined-circle",factory:c.makeOutlinedCircleBuilder}],this.editor.notifier.on(d.EditorEventType.ToolUpdated,(t=>{if(t.kind!==d.EditorEventType.ToolUpdated)throw new Error("Invalid event type!");t.tool===this.tool&&(this.updateIcon(),this.updateInputs())}))}getTitle(){return this.targetTool.description}getCurrentPenTypeIdx(){const t=this.tool.getStrokeFactory();for(let e=0;e<this.penTypes.length;e++)if(this.penTypes[e].factory===t)return e;return-1}getCurrentPenType(){for(const t of this.penTypes)if(t.factory===this.tool.getStrokeFactory())return t;return null}createIconForRecord(t){const e=this.tool.getColor(),n=null==t?void 0:t.factory;if(n&&n!==r.makeFreehandLineBuilder&&n!==s.makePressureSensitiveFreehandLineBuilder){const t=e.a<1;return this.editor.icons.makeIconFromFactory(this.tool,n,t)}{const t=Math.round(4*Math.sqrt(this.tool.getThickness())),i=n===r.makeFreehandLineBuilder;return this.editor.icons.makePenIcon(t,e.toHexString(),i)}}createIcon(){return this.createIconForRecord(this.getCurrentPenType())}createPenTypeSelector(){const t=document.createElement("div");t.classList.add(`${u.toolbarCSSPrefix}pen-type-selector`);const e=document.createElement("div");e.setAttribute("role","menu"),e.id=`${u.toolbarCSSPrefix}-pen-type-selector-id-${g.idCounter++}`,e.onwheel=t=>{const n=e.clientWidth!==e.scrollWidth&&0!==t.deltaX,i=e.scrollLeft+t.deltaX<=0,o=e.scrollLeft+e.clientWidth+t.deltaX>e.scrollWidth;!n||i||o||t.stopPropagation()};const n=document.createElement("label");n.innerText=this.localizationTable.selectPenType,n.htmlFor=e.id,t.appendChild(n);const i=`${u.toolbarCSSPrefix}-pen-type-selector-${g.idCounter++}`,o=t=>{const n=document.createElement("div");n.classList.add("pen-type-button");const o=document.createElement("input");o.type="radio",o.name=i,o.id=`${u.toolbarCSSPrefix}-pen-type-button-${g.idCounter++}`;const r=document.createElement("label"),s=()=>{const e=document.createElement("span"),n=this.createIconForRecord(t);n.classList.add("icon"),e.innerText=t.name,r.htmlFor=o.id,r.replaceChildren(n,e)};s();const a=()=>{o.checked?n.classList.add("checked"):n.classList.remove("checked")};o.oninput=()=>{o.checked&&this.tool.setStrokeFactory(t.factory),a()},n.replaceChildren(o,r),e.appendChild(n);const l=t=>{o.checked=t,a(),t&&o.scrollIntoView()};l(!1);return{setChecked:l,updateIcon:()=>{s()}}},r=[];for(const t of this.penTypes)r.push(o(t));return t.appendChild(e),{setValue:t=>{if(t<0||t>=this.penTypes.length)console.error("Invalid pen type index",t);else for(let e=0;e<r.length;e++)r[e].setChecked(e===t)},updateIcons:()=>{r.forEach((t=>t.updateIcon()))},addTo:e=>{e.appendChild(t)}}}fillDropdown(t){const e=document.createElement("div");e.classList.add(`${u.toolbarCSSPrefix}spacedList`);const n=document.createElement("div"),i=document.createElement("label"),o=document.createElement("input"),r=this.createPenTypeSelector();o.id=`${u.toolbarCSSPrefix}penThicknessInput${g.idCounter++}`,i.innerText=this.localizationTable.thicknessLabel,i.setAttribute("for",o.id);const s=t=>Math.log10(t);o.type="range",o.min=`${s(2)}`,o.max=`${s(400)}`,o.step="0.1",o.oninput=()=>{this.tool.setThickness((t=>Math.pow(10,t))(parseFloat(o.value)))},n.appendChild(i),n.appendChild(o);const a=document.createElement("div"),l=document.createElement("label"),[c,d,p]=(0,h.default)(this.editor,(t=>{this.tool.setColor(t)}));return c.id=`${u.toolbarCSSPrefix}colorInput${g.idCounter++}`,l.innerText=this.localizationTable.colorLabel,l.setAttribute("for",c.id),a.appendChild(l),a.appendChild(d),this.updateInputs=()=>{p(this.tool.getColor()),o.value=s(this.tool.getThickness()).toString(),r.updateIcons(),r.setValue(this.getCurrentPenTypeIdx())},this.updateInputs(),e.replaceChildren(a,n),r.addTo(e),t.replaceChildren(e),!0}onKeyPress(t){if(!this.isSelected())return!1;for(let e=0;e<m.selectStrokeTypeKeyboardShortcutIds.length;e++){const n=m.selectStrokeTypeKeyboardShortcutIds[e];if(this.editor.shortcuts.matchesShortcut(n,t)){const t=e;if(t<this.penTypes.length)return this.tool.setStrokeFactory(this.penTypes[t].factory),!0}}return!!super.onKeyPress(t)}serializeState(){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(f.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}}}}g.idCounter=0,e.default=g},5001:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(3472)),s=n(739),a=o(n(1456)),l=n(3173),c=o(n(6528)),d=o(n(3534)),u=o(n(1421)),h=o(n(3258)),p=n(3240);class f 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"),[o,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){o.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(r.default.average(e))}else o.disabled=!0},n.replaceChildren(i,l),e.replaceChildren(n),t.replaceChildren(e),!0}}class m extends u.default{constructor(t,e,n){super(t,e,"selection-tool-widget",n),this.tool=e;const o=new d.default(t,"resize-btn",(()=>t.icons.makeResizeViewportIcon()),this.localizationTable.resizeImageToSelection,(()=>{this.resizeImageToSelection()}),n),r=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 f(t,this.tool,n);this.addSubWidget(o),this.addSubWidget(r),this.addSubWidget(s),this.addSubWidget(a);const c=t=>{o.setDisabled(t),r.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 this.editor.shortcuts.matchesShortcut(p.resizeImageToSelectionKeyboardShortcut,t)?(this.resizeImageToSelection(),!0):!!super.onKeyPress(t)}getTitle(){return this.localizationTable.select}createIcon(){return this.editor.icons.makeSelectionIcon()}}e.default=m},5730: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 o=i(n(3472)),r=n(3173),s=n(3808),a=i(n(6528)),l=i(n(1421));class c extends l.default{constructor(t,e,n){super(t,e,"text-tool-widget",n),this.tool=e,this.updateDropdownInputs=null,t.notifier.on(r.EditorEventType.ToolUpdated,(t=>{var n;t.kind===r.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"),o=document.createElement("div"),r=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,r.appendChild(e),g.add(t)};return d.setAttribute("type","number"),d.min="1",d.max="128",l.innerText=this.localizationTable.fontLabel,m.innerText=this.localizationTable.colorLabel,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"),r.id=`${s.toolbarCSSPrefix}-text-font-input-${c.idCounter++}`,l.setAttribute("for",r.id),r.onchange=()=>{this.tool.setFontFamily(r.value)},d.onchange=()=>{const t=parseInt(d.value);!isNaN(t)&&t>0&&this.tool.setFontSize(t)},i.appendChild(m),i.appendChild(p),n.appendChild(l),n.appendChild(r),o.appendChild(u),o.appendChild(d),this.updateDropdownInputs=()=>{const t=this.tool.getTextStyle();f(t.renderingStyle.fill),g.has(t.fontFamily)||v(t.fontFamily),r.value=t.fontFamily,d.value=`${t.size}`},this.updateDropdownInputs(),e.replaceChildren(i,o,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(o.default.fromHex(t.color)),t.textSize&&"number"==typeof t.textSize&&this.tool.setFontSize(t.textSize),super.deserializeFrom(t)}}c.idCounter=0,e.default=c},3240: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.selectStrokeTypeKeyboardShortcutIds=e.resizeImageToSelectionKeyboardShortcut=void 0;const o=i(n(5376));e.resizeImageToSelectionKeyboardShortcut="jsdraw.toolbar.SelectionTool.resizeImageToSelection",o.default.registerDefaultKeyboardShortcut(e.resizeImageToSelectionKeyboardShortcut,["ctrlOrMeta+r"],"Resize image to selection"),e.selectStrokeTypeKeyboardShortcutIds=[1,2,3,4,5,6,7].map((t=>`jsdraw.toolbar.PenTool.select-pen-${t}`));for(let t=0;t<e.selectStrokeTypeKeyboardShortcutIds.length;t++){const n=e.selectStrokeTypeKeyboardShortcutIds[t];o.default.registerDefaultKeyboardShortcut(n,[`ctrlOrMeta+${t+1}`],"Select pen style "+(t+1))}},7321: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 o=n(3534);Object.defineProperty(e,"ActionButtonWidget",{enumerable:!0,get:function(){return i(o).default}});var r=n(1421);Object.defineProperty(e,"BaseToolWidget",{enumerable:!0,get:function(){return i(r).default}});var s=n(3258);Object.defineProperty(e,"BaseWidget",{enumerable:!0,get:function(){return i(s).default}});var a=n(7998);Object.defineProperty(e,"PenToolWidget",{enumerable:!0,get:function(){return i(a).default}});var l=n(5730);Object.defineProperty(e,"TextToolWidget",{enumerable:!0,get:function(){return i(l).default}});var c=n(7956);Object.defineProperty(e,"HandToolWidget",{enumerable:!0,get:function(){return i(c).default}});var d=n(5001);Object.defineProperty(e,"SelectionToolWidget",{enumerable:!0,get:function(){return i(d).default}});var u=n(9944);Object.defineProperty(e,"EraserToolWidget",{enumerable:!0,get:function(){return i(u).default}});var h=n(6318);Object.defineProperty(e,"InsertImageWidget",{enumerable:!0,get:function(){return i(h).default}});var p=n(5771);Object.defineProperty(e,"DocumentPropertiesWidget",{enumerable:!0,get:function(){return i(p).default}})},7564:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3173);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}eventCanBeDeliveredToNonActiveTool(t){return!0}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}}},6416: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 o=n(3173),r=i(n(7564)),s=n(5378),a=i(n(1885)),l=i(n(9721)),c=n(4318),d=i(n(3472)),u=i(n(8947)),h=n(3348);class p extends r.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),o={fill:d.default.gray};n.drawRect(i,e/4,o)}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),o=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t.intersects(n)||t.intersectsRect(e))).filter((t=>t.isSelectable()));this.toRemove.push(...o);const r=o.map((t=>new l.default([t])));r.forEach((t=>t.apply(this.editor))),this.partialCommands.push(...r),this.drawPreviewAt(t),this.lastPoint=t}onPointerDown(t){return(1===t.allPointers.length||t.current.device===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()}onKeyPress(t){const e=this.editor.shortcuts;let n;return e.matchesShortcut(h.decreaseSizeKeyboardShortcutId,t)?n=2*this.getThickness()/3:e.matchesShortcut(h.increaseSizeKeyboardShortcutId,t)&&(n=3*this.getThickness()/2),void 0!==n&&(n=Math.min(Math.max(1,n),200),this.setThickness(n),!0)}getThickness(){return this.thickness}setThickness(t){this.thickness=t,this.editor.notifier.dispatch(o.EditorEventType.ToolUpdated,{kind:o.EditorEventType.ToolUpdated,tool:this})}}e.default=p},5805: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 o=i(n(1151)),r=i(n(7564)),s=n(3348),a="find-tool";class l extends r.default{constructor(t){super(t.notifier,t.localization.findLabel),this.editor=t,this.currentMatchIdx=0,this.overlay=document.createElement("div"),this.fillOverlay(),t.createHTMLOverlay(this.overlay),this.overlay.style.display="none",this.overlay.classList.add(`${a}-overlay`)}getMatches(t){t=t.toLocaleLowerCase();return this.editor.image.getAllElements().filter((t=>t instanceof o.default)).filter((e=>-1!==e.getText().toLocaleLowerCase().indexOf(t))).map((t=>t.getBBox()))}focusCurrentMatch(){const t=this.getMatches(this.searchInput.value);let e=this.currentMatchIdx%t.length;if(e<0&&(e=t.length+e),e<t.length){const n=!1;this.editor.dispatch(this.editor.viewport.zoomTo(t[e],!0,!0),n),this.editor.announceForAccessibility(this.editor.localization.focusedFoundText(e+1,t.length))}}toNextMatch(){this.currentMatchIdx++,this.focusCurrentMatch()}toPrevMatch(){this.currentMatchIdx--,this.focusCurrentMatch()}fillOverlay(){const t=document.createElement("label");this.searchInput=document.createElement("input");const e=document.createElement("button"),n=document.createElement("button");this.searchInput.setAttribute("id",`${a}-searchInput-${Math.random()}`),t.htmlFor=this.searchInput.getAttribute("id"),t.innerText=this.editor.localization.findLabel,e.innerText=this.editor.localization.toNextMatch,n.innerText=this.editor.localization.closeFindDialog,this.searchInput.onkeydown=t=>{"Enter"===t.key?t.shiftKey?this.toPrevMatch():this.toNextMatch():"Escape"===t.key?this.setVisible(!1):this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(t.preventDefault(),this.toggleVisible())},e.onclick=()=>{this.toNextMatch()},n.onclick=()=>{this.setVisible(!1)},this.overlay.replaceChildren(t,this.searchInput,e,n)}isVisible(){return"none"!==this.overlay.style.display}setVisible(t){t!==this.isVisible()&&(this.overlay.style.display=t?"block":"none",t?(this.searchInput.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogShown)):(this.editor.focus(),this.editor.announceForAccessibility(this.editor.localization.findDialogHidden)))}toggleVisible(){this.setVisible(!this.isVisible())}onKeyPress(t){return!!this.editor.shortcuts.matchesShortcut(s.toggleFindVisibleShortcutId,t)&&(this.toggleVisible(),!0)}setEnabled(t){super.setEnabled(t),t&&this.setVisible(!1)}}e.default=l},4735:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanZoomMode=void 0;const r=o(n(8015)),s=n(5378),a=o(n(1486)),l=n(4318),c=n(3173),d=o(n(7395)),u=n(5566),h=o(n(7564)),p=n(3348);var f;!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"}(f||(e.PanZoomMode=f={}));class m{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 g 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(),o=n.magnitude();return{canvasCenter:e.canvasPos.plus(t.canvasPos).times(.5),screenCenter:e.screenPos.plus(t.screenPos).times(.5),angle:i,dist:o}}allPointersAreOfType(t,e){return t.every((t=>t.device===e))}onPointerDown({allPointers:t,current:e}){var n,i,o,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===(o=this.inertialScroller)||void 0===o||o.stop(),this.velocity=d,this.lastPointerDownTimestamp=e.timeStamp;const h=this.allPointersAreOfType(t,l.PointerDevice.Touch),p=this.allPointersAreOfType(t,l.PointerDevice.RightButtonMouse);if(h&&2===t.length&&this.mode&f.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&f.OneFingerTouchGestures&&h||p&&this.mode&f.RightClickDrags||this.mode&f.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(r.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 o=i;this.velocity&&(o=this.velocity.lerp(i,.5)),this.velocity=o}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:o}=this.computePinchData(t[0],t[1]),s=this.getCenterDelta(e);let a;a=this.isRotationLocked()?0:this.toSnappedRotationDelta(i),this.updateVelocity(e);const l=r.default.translation(s).rightMul(r.default.scaling2D(o/this.lastDist,n)).rightMul(r.default.zRotation(a,n));this.lastScreenCenter=e,this.lastDist=o,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(r.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(r.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 m(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(r.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(r.default.identity);const i=this.editor.viewport.screenToCanvas(e),o=this.editor.viewport.screenToCanvasTransform.transformVec3(a.default.of(-t.x,-t.y,0)),s=r.default.scaling2D(Math.max(.25,Math.min(Math.pow(1.03,-t.z),4)),i).rightMul(r.default.translation(o));return this.updateTransform(s,!0),!0}onKeyPress(t){var e;if(null===(e=this.inertialScroller)||void 0===e||e.stop(),!(this.mode&f.Keyboard))return!1;this.transform=u.Viewport.transformBy(r.default.identity);let n=s.Vec2.zero,i=1,o=0;const a=this.editor.shortcuts;if(a.matchesShortcut(p.moveLeftKeyboardShortcutId,t))n=s.Vec2.of(-1,0);else if(a.matchesShortcut(p.moveRightKeyboardShortcutId,t))n=s.Vec2.of(1,0);else if(a.matchesShortcut(p.moveUpKeyboardShortcutId,t))n=s.Vec2.of(0,-1);else if(a.matchesShortcut(p.moveDownKeyboardShortcutId,t))n=s.Vec2.of(0,1);else if(a.matchesShortcut(p.zoomInKeyboardShortcutId,t))i=.5;else if(a.matchesShortcut(p.zoomOutKeyboardShortcutId,t))i=2;else if(a.matchesShortcut(p.rotateClockwiseKeyboardShortcutId,t))o=1;else{if(!a.matchesShortcut(p.rotateCounterClockwiseKeyboardShortcutId,t))return!1;o=-1}n=n.times(30),o*=Math.PI/8,n=n.times(-1),o*=-1,i=1/i,0!==o&&(o+=1e-4),this.isRotationLocked()&&(o=0);n=this.editor.viewport.screenToCanvasTransform.transformVec3(n);const l=this.editor.viewport.visibleRect.center,c=r.default.scaling2D(i,l).rightMul(r.default.zRotation(o,l)).rightMul(r.default.translation(n));return this.updateTransform(c,!0),!0}isRotationLocked(){return!!(this.mode&f.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=g},2719:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(n(1151)),s=o(n(1697)),a=o(n(8015)),l=o(n(7564)),c=o(n(4321)),d=o(n(3472)),u=o(n(7077));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 o={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:o,l=t.split("\n");yield this.addComponentsFromPaste([r.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},2133: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 o=i(n(7551)),r=n(4318),s=n(6951),a=n(3173),l=i(n(7564)),c=n(3348),d=n(3348);class u 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.startPoint=null,this.currentDeviceType=null,this.snapToGridEnabled=!1,this.angleLockEnabled=!1}getPressureMultiplier(){return 1/this.editor.viewport.getScaleFactor()*this.style.thickness}xyAxesSnap(t){if(!this.startPoint)return t;const e=this.editor.viewport.canvasToScreen(this.startPoint.pos);return t.lockedToXYAxesScreen(e,this.editor.viewport)}toStrokePoint(t){var e;this.angleLockEnabled&&this.lastPoint&&(t=this.xyAxesSnap(t)),this.snapToGridEnabled&&(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(t){const{current:e,allPointers:n}=t,i=e.device===r.PointerDevice.Eraser;let o=!1;for(const t of n)if(t.device===r.PointerDevice.Pen){o=!0;break}return!(!this.builder||this.eventCanCancelStroke(t))||!((1!==n.length||i)&&!o)&&(this.startPoint=this.toStrokePoint(e),this.builder=this.builderFactory(this.startPoint,this.editor.viewport),this.currentDeviceType=e.device,!0)}eventCanCancelStroke(t){var e,n;const i=null!==(n=null===(e=this.lastPoint)||void 0===e?void 0:e.time)&&void 0!==n?n:0;if(t.current.timeStamp-i>1e3)return!0;const o=this.currentDeviceType===r.PointerDevice.Pen,s=t.current.device===r.PointerDevice.Touch;return!o||!s}eventCanBeDeliveredToNonActiveTool(t){return this.eventCanCancelStroke(t)}onPointerMove({current:t}){this.builder&&t.device===this.currentDeviceType&&this.addPointToStroke(this.toStrokePoint(t))}onPointerUp({current:t}){var e,n;if(!this.builder)return!1;if(t.device!==this.currentDeviceType)return!0;const i=this.toStrokePoint(t),o=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});return this.addPointToStroke(o),t.isPrimary&&this.finalizeStroke(),!1}onGestureCancel(){this.builder=null,this.editor.clearWetInk()}finalizeStroke(){if(this.builder){const t=this.builder.build();if(this.previewStroke(),t.getBBox().area>0){const e=!0,n=o.default.addElement(t,e);this.editor.dispatch(n)}else console.warn("Pen: Not adding empty stroke",t,"to the canvas.")}this.builder=null,this.lastPoint=null,this.editor.clearWetInk()}noteUpdated(){this.editor.notifier.dispatch(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.snapToGridEnabled=!1}onKeyPress(t){const e=this.editor.shortcuts,n=e.matchesShortcut(c.undoKeyboardShortcutId,t);if(this.builder&&n)return this.finalizeStroke(),!1;let i;return e.matchesShortcut(d.decreaseSizeKeyboardShortcutId,t)?i=2*this.getThickness()/3:e.matchesShortcut(d.increaseSizeKeyboardShortcutId,t)&&(i=3*this.getThickness()/2),void 0!==i?(i=Math.min(Math.max(1,i),256),this.setThickness(i),!0):e.matchesShortcut(d.snapToGridKeyboardShortcutId,t)?(this.snapToGridEnabled=!0,!0):!!e.matchesShortcut(d.lineLockKeyboardShortcutId,t)&&(this.angleLockEnabled=!0,!0)}onKeyUp(t){const e=this.editor.shortcuts;return e.matchesShortcut(d.snapToGridKeyboardShortcutId,t)?(this.snapToGridEnabled=!1,!0):!!e.matchesShortcut(d.lineLockKeyboardShortcutId,t)&&(this.angleLockEnabled=!1,!0)}}e.default=u},5248: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 o=i(n(7564));class r extends o.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=r},8519: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 o=i(n(7564)),r=n(3348),s=i(n(7591));class a extends o.default{constructor(t){super(t.notifier,t.localization.selectAllTool),this.editor=t}onKeyPress(t){if(this.editor.shortcuts.matchesShortcut(r.selectAllKeyboardShortcut,t)){const t=this.editor.toolController.getMatchingTools(s.default);if(t.length>0){const e=t[0];return e.setEnabled(!0),e.setSelection(this.editor.image.getAllElements()),!0}}return!1}}e.default=a},2129:function(t,e,n){"use strict";var i,o=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return r(e,t),e},a=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(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(6669)),d=l(n(8015)),u=l(n(8947)),h=n(5378),p=s(n(370)),f=n(7591),m=l(n(5566)),g=l(n(9721)),v=l(n(1365)),y=n(8862),b=n(3968),x=l(n(7551));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())),o=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())),r=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=[o,n,i,r];for(const t of this.handles)t.addTo(this.backgroundElem)}getBackgroundElem(){return this.backgroundElem}getTransform(){return this.transform}get preTransformRegion(){return this.originalRegion}get region(){const t=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 o=new d.default(...t.transform),r=null!==(n=t.elems)&&void 0!==n?n:[];return new i.ApplyTransformationCommand(null,r,o)})),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,o,r;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===(o=this.selection)||void 0===o||o.recomputeRegion(),null===(r=this.selection)||void 0===r||r.updateUI()}))}unapply(t){var e,n,i,o,r;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===(o=this.selection)||void 0===o||o.recomputeRegion(),null===(r=this.selection)||void 0===r||r.updateUI()}))}serializeToJSON(){return{elems:this.selectedElemIds,transform:this.fullTransform.toArray()}}description(t,e){return e.transformedElements(this.selectedElemIds.length)}},e.default=w},370:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.handleSize=e.HandleShape=void 0;const i=n(6585),o=n(5378),r=n(7591);var s;!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square"}(s||(e.HandleShape=s={})),e.handleSize=30;e.default=class{constructor(t,e,n,o,a,l){switch(this.shape=t,this.parentSide=e,this.parent=n,this.onDragStart=o,this.onDragUpdate=a,this.onDragEnd=l,this.dragLastPos=null,this.element=document.createElement("div"),this.element.classList.add(`${r.cssPrefix}handle`),t){case s.Circle:this.element.classList.add(`${r.cssPrefix}circle`);break;case s.Square:this.element.classList.add(`${r.cssPrefix}square`);break;default:(0,i.assertUnreachable)(t)}this.updatePosition()}addTo(t){t.appendChild(this.element)}updatePosition(){const t=this.parent.screenRegion,n=o.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}}},7591: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 o=i(n(8015)),r=n(5378),s=n(3173),a=i(n(5566)),l=i(n(7564)),c=i(n(2001)),d=i(n(2129)),u=i(n(1151)),h=n(3348);e.cssPrefix="selection-tool-";class p extends l.default{constructor(t,e){super(t.notifier,e),this.editor=t,this.lastEvtTarget=null,this.startPoint=null,this.expandingSelectionBox=!1,this.shiftKeyPressed=!1,this.snapToGrid=!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;this.editor.clearWetInk(),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(o.default.translation(e))),this.selectionBox.finalizeTransform()}onPointerDown({allPointers:t,current:e}){const n=this.snapToGrid;if(n&&(e=e.snappedToGrid(this.editor.viewport)),1===t.length&&e.isPrimary){this.startPoint=e.canvasPos;let t=!1;if(this.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;if(!this.expandingSelectionBox&&this.shiftKeyPressed&&this.startPoint){const t=this.editor.viewport.canvasToScreen(this.startPoint);e=e.lockedToXYAxesScreen(t,this.editor.viewport)}this.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBoxHandlingEvt?this.selectionBox.onDragUpdate(e):this.selectionBox.setToPoint(e.canvasPos)}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.snapToGrid&&(e=e.snappedToGrid(this.editor.viewport)),this.selectionBox.setToPoint(e.canvasPos),this.expandingSelectionBox&&this.prevSelectionBox?(this.expandingSelectionBox=!1,this.selectionBox.resolveToObjects(),this.setSelection([...this.selectionBox.getSelectedObjects(),...this.prevSelectionBox.getSelectedObjects()])):this.onGestureEnd()}onGestureCancel(){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){const e=this.editor.shortcuts;if(e.matchesShortcut(h.snapToGridKeyboardShortcutId,t))return this.snapToGrid=!0,!0;if(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t))return!0;if(e.matchesShortcut(h.selectAllKeyboardShortcut,t))return this.setSelection(this.editor.image.getAllElements()),!0;if(t.ctrlKey)return!1;if("Shift"===t.key)return this.shiftKeyPressed=!0,!0;let n=0,i=0,s=0,l=0,c=0;switch(t.key){case"a":case"h":case"ArrowLeft":i-=1;break;case"d":case"l":case"ArrowRight":i+=1;break;case"q":case"k":case"ArrowUp":s-=1;break;case"e":case"j":case"ArrowDown":s+=1;break;case"r":n+=1;break;case"R":n-=1;break;case"i":l-=1;break;case"I":l+=1;break;case"o":c-=1;break;case"O":c+=1}let d=0!==i||0!==s||0!==n||0!==l||0!==c;if(this.selectionBox){if(d){const t=10*this.editor.viewport.getSizeOfPixelOnCanvas(),e=Math.PI/8,d=5/4,u=this.selectionBox.region,h=r.Vec2.of(Math.pow(d,l),Math.pow(d,c)),p=o.default.zRotation(n*e).mapEntries((t=>a.default.roundScaleRatio(t))),f=this.editor.viewport.roundPoint(u.center),m=o.default.scaling2D(h,this.editor.viewport.roundPoint(u.topLeft)).rightMul(o.default.translation(f).rightMul(p).rightMul(o.default.translation(f.times(-1)))).rightMul(o.default.translation(this.editor.viewport.roundPoint(r.Vec2.of(i,s).times(t)))),g=this.selectionBox.getTransform();this.selectionBox.setTransform(g.rightMul(m))}}else d=!1;return!this.selectionBox||d||"Delete"!==t.key&&"Backspace"!==t.key||(this.editor.dispatch(this.selectionBox.deleteSelectedObjects()),this.clearSelection(),d=!0),d}onKeyUp(t){const e=this.editor.shortcuts;return e.matchesShortcut(h.snapToGridKeyboardShortcutId,t)?(this.snapToGrid=!1,!0):!!e.matchesShortcut(h.selectAllKeyboardShortcut,t)||(this.selectionBox&&e.matchesShortcut(h.duplicateSelectionShortcut,t)?(this.selectionBox.duplicateSelectedObjects().then((t=>{this.editor.dispatch(t)})),!0):"Shift"===t.key?(this.shiftKeyPressed=!1,!0):!(!this.selectionBox||!p.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(r.Vec2.of(n.w,n.h)),i.resetTransform(o.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.snapToGrid=!1,this.handleOverlay.style.display=t?"block":"none",t?(this.handleOverlay.tabIndex=0,this.handleOverlay.setAttribute("aria-label",this.editor.localization.selectionToolKeyboardShortcuts)):this.handleOverlay.tabIndex=-1}getSelection(){return this.selectionBox}getSelectedObjects(){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()}}p.handleableKeys=["a","h","ArrowLeft","d","l","ArrowRight","q","k","ArrowUp","e","j","ArrowDown","r","R","i","I","o","O","Control","Meta"],e.default=p},8862: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 o=i(n(8015)),r=n(5378),s=i(n(5566)),a=n(3968);e.DragTransformer=class{constructor(t,e){this.editor=t,this.selection=e}onDragStart(t){this.selection.setTransform(o.default.identity),this.dragStartPoint=t}onDragUpdate(t){const e=this.editor.viewport.roundPoint(t.minus(this.dragStartPoint));this.selection.setTransform(o.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(o.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=r.Vec2.of(1,1);if(this.mode===a.ResizeMode.HorizontalOnly){const t=n+e.x;l=r.Vec2.of(t/n,l.y)}if(this.mode===a.ResizeMode.VerticalOnly){const t=i+e.y;l=r.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=r.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(o.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(o.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=o.default.zRotation(e).mapEntries((t=>s.default.roundScaleRatio(t))),r=o.default.translation(n).rightMul(i).rightMul(o.default.translation(n.times(-1)));this.selection.setTransform(r)}onDragEnd(){this.selection.finalizeTransform()}}},3968:(t,e)=>{"use strict";var n,i;Object.defineProperty(e,"__esModule",{value:!0}),e.TransformMode=e.ResizeMode=void 0,function(t){t[t.Both=0]="Both",t[t.HorizontalOnly=1]="HorizontalOnly",t[t.VerticalOnly=2]="VerticalOnly"}(n||(e.ResizeMode=n={})),function(t){t[t.Snap=0]="Snap",t[t.NoSnap=1]="NoSnap"}(i||(e.TransformMode=i={}))},7893: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 o=i(n(3472)),r=i(n(1885)),s=i(n(7564));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,o=440*(e.z+.1),r=.25*Math.min(1,t.a)/(1+Math.exp(3*-(e.z-.5)));this.colorOscHue.frequency.setValueAtTime(n,this.ctx.currentTime),this.colorOscSaturation.frequency.setValueAtTime(i,this.ctx.currentTime),this.colorOscValue.frequency.setValueAtTime(o,this.ctx.currentTime),this.valueGain.gain.setValueAtTime(.4*(1-e.z),this.ctx.currentTime),this.colorGain.gain.setValueAtTime(r,this.ctx.currentTime)}announceBoundaryCross(t){this.boundaryGain.gain.cancelScheduledValues(this.ctx.currentTime),this.boundaryGain.gain.setValueAtTime(0,this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(.018,this.ctx.currentTime+.1),this.boundaryOsc.frequency.setValueAtTime(440+100*Math.atan(t/2),this.ctx.currentTime),this.boundaryGain.gain.linearRampToValueAtTime(0,this.ctx.currentTime+.25)}close(){this.ctx.close(),this.closed=!0}}class 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,r;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!==(r=this.editor.display.getColorAt(t.screenPos))&&void 0!==r?r:o.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:o.default.black);const s=new r.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},4321: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 o=i(n(3472)),r=i(n(1151)),s=i(n(7551)),a=i(n(8947)),l=i(n(8015)),c=n(5378),d=n(4318),u=n(3173),h=i(n(7564)),p=i(n(9721)),f=i(n(1456)),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:o.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()))}initTextMeasuringCanvas(){var t;null!==(t=this.textMeasuringCtx)&&void 0!==t||(this.textMeasuringCtx=document.createElement("canvas").getContext("2d"))}getTextAscent(t,e){var n;if(this.initTextMeasuringCanvas(),this.textMeasuringCtx){this.textMeasuringCtx.textBaseline="alphabetic",r.default.applyTextStyles(this.textMeasuringCtx,e);const i=this.textMeasuringCtx.measureText(t);return null!==(n=i.fontBoundingBoxAscent)&&void 0!==n?n:i.actualBoundingBoxAscent}return 2*e.size/3}flushInput(t=!0){if(this.textInputElem&&this.textTargetPosition){const e=this.textInputElem.value.trimEnd();if(this.textInputElem.value="",t){const t=this.textInputElem;this.textInputElem=null,t.remove()}if(""===e)return;const n=l.default.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(l.default.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(l.default.zRotation(this.textRotation)),i=r.default.fromLines(e.split("\n"),n,this.textStyle),o=s.default.addElement(i);this.removeExistingCommand?(this.removeExistingCommand.unapply(this.editor),this.editor.dispatch((0,f.default)([this.removeExistingCommand,o])),this.removeExistingCommand=null):this.editor.dispatch(o)}}getTextScaleMatrix(){return l.default.scaling2D(this.textScale.times(1/this.editor.viewport.getSizeOfPixelOnCanvas()))}updateTextInput(){var t,e,n,i;if(!this.textInputElem||!this.textTargetPosition)return void(null===(t=this.textInputElem)||void 0===t||t.remove());const o=this.editor.viewport,r=o.canvasToScreen(this.textTargetPosition);this.textInputElem.placeholder=this.localizationTable.enterTextToInsert,this.textInputElem.style.fontFamily=this.textStyle.fontFamily,this.textInputElem.style.fontStyle=null!==(e=this.textStyle.fontStyle)&&void 0!==e?e:"",this.textInputElem.style.fontVariant=null!==(n=this.textStyle.fontVariant)&&void 0!==n?n:"",this.textInputElem.style.fontWeight=null!==(i=this.textStyle.fontWeight)&&void 0!==i?i:"",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 s=this.getTextAscent("Testing!",this.textStyle),a=this.textRotation+o.getRotationAngle(),l=this.getTextScaleMatrix();this.textInputElem.style.transform=`${l.toCSSMatrix()} rotate(${180*a/Math.PI}deg) translate(0, ${-s}px)`,this.textInputElem.style.transformOrigin="top left";const c=Math.floor(this.textStyle.size);this.textInputElem.style.lineHeight=`${c}px`}startTextInput(t,e){this.flushInput(),this.textInputElem=document.createElement("textarea"),this.textInputElem.value=e,this.textInputElem.style.display="inline-block",this.textTargetPosition=this.editor.viewport.roundPoint(t),this.textRotation=-this.editor.viewport.getRotationAngle(),this.textScale=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 o=this.editor.image.getElementsIntersectingRegion(i).filter((t=>t instanceof r.default));const s=this.editor.viewport.visibleRect;if(o=o.filter((t=>!t.getBBox().containsRect(s))),this.flushInput(),o.length>0){const t=o[o.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},8169:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}: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}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(3173),l=r(n(4735)),c=s(n(2133)),d=s(n(6122)),u=s(n(6416)),h=s(n(7591)),p=s(n(3472)),f=s(n(4074)),m=s(n(4321)),g=s(n(5248)),v=s(n(3448)),y=s(n(2719)),b=s(n(6390)),x=n(823),w=s(n(5805)),S=s(n(8519)),T=s(n(7893));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),o=new l.default(t,l.PanZoomMode.Keyboard,e.keyboardPanZoom),r=new c.default(t,e.penTool(1),{color:p.default.purple,thickness:8}),s=[r,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 T.default(t,e.soundExplorer);C.setEnabled(!1),this.tools=[new g.default(t,e.pipetteTool),C,i,...s,o,new f.default(t),new b.default(t),new v.default(t),new w.default(t),new y.default(t),new S.default(t)],s.forEach((t=>t.setToolGroup(n))),i.setEnabled(!0),r.setEnabled(!0),t.notifier.on(a.EditorEventType.ToolEnabled,(n=>{n.kind===a.EditorEventType.ToolEnabled&&t.announceForAccessibility(e.toolEnabledAnnouncement(n.tool.description))})),t.notifier.on(a.EditorEventType.ToolDisabled,(n=>{n.kind===a.EditorEventType.ToolDisabled&&t.announceForAccessibility(e.toolDisabledAnnouncement(n.tool.description))})),this.activeTool=null}setTools(t,e){this.tools=t,this.primaryToolGroup=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){let n=!1;this.activeTool&&!this.activeTool.eventCanBeDeliveredToNonActiveTool(t)&&(n=!0);for(const o of this.tools)if((!n||o===this.activeTool)&&o.isEnabled()&&o.onPointerDown(t)){this.activeTool!==o&&(null===(e=this.activeTool)||void 0===e||e.onGestureCancel()),this.activeTool=o,i=!0;break}}else if(t.kind===a.InputEvtType.PointerUpEvt){(null===(n=this.activeTool)||void 0===n?void 0:n.onPointerUp(t))&&t.allPointers.length>1||(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))}}},6122:(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)}}},3448: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 o=i(n(7564));class r extends o.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=r},6390: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 o=i(n(7564));class r extends o.default{constructor(t){super(t.notifier,t.localization.changeTool),this.listeners=new Set([])}registerListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}onKeyPress(t){const e=Array.from(this.listeners.values());for(const n of e)if(n(t))return!0;return!1}}e.default=r},4074:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(n(7564)),r=n(3348);class s extends o.default{constructor(t){super(t.notifier,t.localization.undoRedoTool),this.editor=t}onKeyPress(t){return this.editor.shortcuts.matchesShortcut(r.undoKeyboardShortcutId,t)?(this.editor.history.undo(),!0):!!this.editor.shortcuts.matchesShortcut(r.redoKeyboardShortcutId,t)&&(this.editor.history.redo(),!0)}}e.default=s},3348:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.duplicateSelectionShortcut=e.selectAllKeyboardShortcut=e.zoomOutKeyboardShortcutId=e.zoomInKeyboardShortcutId=e.rotateCounterClockwiseKeyboardShortcutId=e.rotateClockwiseKeyboardShortcutId=e.moveDownKeyboardShortcutId=e.moveUpKeyboardShortcutId=e.moveRightKeyboardShortcutId=e.moveLeftKeyboardShortcutId=e.toggleFindVisibleShortcutId=e.lineLockKeyboardShortcutId=e.snapToGridKeyboardShortcutId=e.decreaseSizeKeyboardShortcutId=e.increaseSizeKeyboardShortcutId=e.redoKeyboardShortcutId=e.undoKeyboardShortcutId=void 0;const o=i(n(5376));e.undoKeyboardShortcutId="jsdraw.tools.undo",e.redoKeyboardShortcutId="jsdaw.tools.redo",o.default.registerDefaultKeyboardShortcut(e.undoKeyboardShortcutId,["ctrlOrMeta+z"],"Undo"),o.default.registerDefaultKeyboardShortcut(e.redoKeyboardShortcutId,["ctrlOrMeta+Z","ctrlOrMeta+Shift+z"],"Redo"),e.increaseSizeKeyboardShortcutId="jsdraw.tools.increaseSize",o.default.registerDefaultKeyboardShortcut(e.increaseSizeKeyboardShortcutId,["+","="],"Increase pen/eraser size"),e.decreaseSizeKeyboardShortcutId="jsdraw.tools.decreaseSize",o.default.registerDefaultKeyboardShortcut(e.decreaseSizeKeyboardShortcutId,["-","_"],"Decrease pen/eraser size"),e.snapToGridKeyboardShortcutId="jsdraw.tools.snapToGrid",o.default.registerDefaultKeyboardShortcut(e.snapToGridKeyboardShortcutId,["control","meta"],"Snap to grid (press and hold)"),e.lineLockKeyboardShortcutId="jsdraw.tools.lockToLine",o.default.registerDefaultKeyboardShortcut(e.lineLockKeyboardShortcutId,["shift"],"Snap to XY axes (press and hold)"),e.toggleFindVisibleShortcutId="js-draw.tools.FindTool.toggleVisible",o.default.registerDefaultKeyboardShortcut(e.toggleFindVisibleShortcutId,["ctrlOrMeta+f"],"Shows/hides the find tool"),e.moveLeftKeyboardShortcutId="jsdraw.tools.PanZoom.moveLeft",o.default.registerDefaultKeyboardShortcut(e.moveLeftKeyboardShortcutId,["ArrowLeft","h","a"],"Pan left"),e.moveRightKeyboardShortcutId="jsdraw.tools.PanZoom.moveRight",o.default.registerDefaultKeyboardShortcut(e.moveRightKeyboardShortcutId,["ArrowRight","l","d"],"Pan right"),e.moveUpKeyboardShortcutId="jsdraw.tools.PanZoom.moveUp",o.default.registerDefaultKeyboardShortcut(e.moveUpKeyboardShortcutId,["ArrowUp","k","q"],"Pan up"),e.moveDownKeyboardShortcutId="jsdraw.tools.PanZoom.moveDown",o.default.registerDefaultKeyboardShortcut(e.moveDownKeyboardShortcutId,["ArrowDown","j","e"],"Pan down"),e.rotateClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewClockwise",o.default.registerDefaultKeyboardShortcut(e.rotateClockwiseKeyboardShortcutId,["R"],"Rotate viewport clockwise"),e.rotateCounterClockwiseKeyboardShortcutId="jsdraw.tools.PanZoom.rotateViewCounterClockwise",o.default.registerDefaultKeyboardShortcut(e.rotateCounterClockwiseKeyboardShortcutId,["r"],"Rotate viewport counter-clockwise"),e.zoomInKeyboardShortcutId="jsdraw.tools.PanZoom.zoomIn",o.default.registerDefaultKeyboardShortcut(e.zoomInKeyboardShortcutId,["w"],"Zoom in"),e.zoomOutKeyboardShortcutId="jsdraw.tools.PanZoom.zoomOut",o.default.registerDefaultKeyboardShortcut(e.zoomOutKeyboardShortcutId,["s"],"Zoom out"),e.selectAllKeyboardShortcut="jsdraw.tools.SelectionTool.selectAll",o.default.registerDefaultKeyboardShortcut(e.selectAllKeyboardShortcut,["ctrlOrMeta+a"],"Select all"),e.duplicateSelectionShortcut="jsdraw.tools.SelectionTool.duplicateSelection",o.default.registerDefaultKeyboardShortcut(e.duplicateSelectionShortcut,["ctrlOrMeta+d"],"Duplicate selection")},1709: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 o=n(7564);Object.defineProperty(e,"BaseTool",{enumerable:!0,get:function(){return i(o).default}});var r=n(8169);Object.defineProperty(e,"ToolController",{enumerable:!0,get:function(){return i(r).default}});var s=n(6122);Object.defineProperty(e,"ToolEnabledGroup",{enumerable:!0,get:function(){return i(s).default}});var a=n(4074);Object.defineProperty(e,"UndoRedoShortcut",{enumerable:!0,get:function(){return i(a).default}});var l=n(3448);Object.defineProperty(e,"ToolSwitcherShortcut",{enumerable:!0,get:function(){return i(l).default}});var c=n(4735);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(2133);Object.defineProperty(e,"PenTool",{enumerable:!0,get:function(){return i(d).default}});var u=n(4321);Object.defineProperty(e,"TextTool",{enumerable:!0,get:function(){return i(u).default}});var h=n(7591);Object.defineProperty(e,"SelectionTool",{enumerable:!0,get:function(){return i(h).default}});var p=n(8519);Object.defineProperty(e,"SelectAllShortcutHandler",{enumerable:!0,get:function(){return i(p).default}});var f=n(6416);Object.defineProperty(e,"EraserTool",{enumerable:!0,get:function(){return i(f).default}});var m=n(2719);Object.defineProperty(e,"PasteHandler",{enumerable:!0,get:function(){return i(m).default}});var g=n(7893);Object.defineProperty(e,"SoundUITool",{enumerable:!0,get:function(){return i(g).default}});var v=n(6390);Object.defineProperty(e,"ToolbarShortcutHandler",{enumerable:!0,get:function(){return i(v).default}})},3376:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultToolLocalization=void 0,e.defaultToolLocalization={penTool:t=>`Pen ${t}`,selectionTool:"Selection",selectAllTool:"Select all shortcut",eraserTool:"Eraser",touchPanTool:"Touch panning",twoFingerPanZoomTool:"Panning and zooming",undoRedoTool:"Undo/Redo",rightClickDragPanTool:"Right-click drag",pipetteTool:"Pick color from screen",keyboardPanZoom:"Keyboard pan/zoom shortcuts",textTool:"Text",enterTextToInsert:"Text to insert",changeTool:"Change tool",pasteHandler:"Copy paste handler",soundExplorer:"Sound-based image exploration",disableAccessibilityExploreTool:"Disable sound-based exploration",enableAccessibilityExploreTool:"Enable sound-based exploration",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`}},3173:(t,e)=>{"use strict";var n,i,o;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"}(n||(e.InputEvtType=n={})),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"}(i||(e.EditorEventType=i={})),function(t){t[t.CommandDone=0]="CommandDone",t[t.CommandUndone=1]="CommandUndone",t[t.CommandRedone=2]="CommandRedone"}(o||(e.UndoEventType=o={}))},6585:(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}},9070:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=(t,e)=>{const n=new FileReader;return new Promise(((i,o)=>{n.onload=()=>i(n.result),n.onerror=o,n.onabort=o,n.onprogress=t=>{null==e||e(t)},n.readAsDataURL(t)}))}},7395:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=()=>new Promise((t=>{requestAnimationFrame((()=>t()))}))},7129:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>{if(t.some((t=>t&&t.then)))return Promise.all(t).then((()=>{}))}},458:(t,e,n)=>{"use strict";n.r(e);var i=n(6062),o=n.n(i),r=n(4036),s=n.n(r),a=n(6793),l=n.n(a),c=n(7892),d=n.n(c),u=n(1173),h=n.n(u),p=n(2464),f=n.n(p),m=n(6860),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=h();o()(m.Z,g);m.Z&&m.Z.locals&&m.Z.locals;var v=n(489),y={};y.styleTagTransform=f(),y.setAttributes=d(),y.insert=l().bind(null,"head"),y.domAPI=s(),y.insertStyleElement=h();o()(v.Z,y);v.Z&&v.Z.locals&&v.Z.locals},5381:(t,e)=>{var n,i,o;"undefined"!=typeof self&&self,i=[],void 0===(o="function"==typeof(n=function(){
|
2
2
|
/*!
|
3
3
|
* Copyright (c) 2021-2023 Momo Bassit.
|
4
4
|
* Licensed under the MIT License (MIT)
|
@@ -6,4 +6,4 @@
|
|
6
6
|
* Version: 0.20.0
|
7
7
|
* NPM: https://github.com/melloware/coloris-npm
|
8
8
|
*/
|
9
|
-
return function(t,e,n,i){var o,r,s,a,l,c,d,u,h,p,f,m,g,v,y,b,x,w=e.createElement("canvas").getContext("2d"),S={r:0,g:0,b:0,h:0,s:0,v:0,a:1},T={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:function(){return i},a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},C={},P="",k={},E=!1;function z(n){if("object"==typeof n){var a=function(){switch(l){case"el":B(n.el),!1!==n.wrap&&R(n.el);break;case"parent":(o=e.querySelector(n.parent))&&(o.appendChild(r),T.parent=n.parent,o===e.body&&(o=i));break;case"themeMode":T.themeMode=n.themeMode,"auto"===n.themeMode&&t.matchMedia&&t.matchMedia("(prefers-color-scheme: dark)").matches&&(T.themeMode="dark");case"theme":n.theme&&(T.theme=n.theme),r.className="clr-picker clr-"+T.theme+" clr-"+T.themeMode,T.inline&&L();break;case"rtl":T.rtl=!!n.rtl,e.querySelectorAll(".clr-field").forEach((function(t){return t.classList.toggle("clr-rtl",T.rtl)}));break;case"margin":n.margin*=1,T.margin=isNaN(n.margin)?T.margin:n.margin;break;case"wrap":n.el&&n.wrap&&R(n.el);break;case"formatToggle":T.formatToggle=!!n.formatToggle,ot("clr-format").style.display=T.formatToggle?"block":"none",T.formatToggle&&(T.format="auto");break;case"swatches":if(Array.isArray(n.swatches)){var a=[];n.swatches.forEach((function(t,e){a.push('<button type="button" id="clr-swatch-'+e+'" aria-labelledby="clr-swatch-label clr-swatch-'+e+'" style="color: '+t+';">'+t+"</button>")})),ot("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":"",T.swatches=n.swatches.slice()}break;case"swatchesOnly":T.swatchesOnly=!!n.swatchesOnly,r.setAttribute("data-minimal",T.swatchesOnly);break;case"alpha":T.alpha=!!n.alpha,r.setAttribute("data-alpha",T.alpha);break;case"inline":if(T.inline=!!n.inline,r.setAttribute("data-inline",T.inline),T.inline){var f=n.defaultColor||T.defaultColor;y=j(f),L(),A(f)}break;case"clearButton":"object"==typeof n.clearButton&&(n.clearButton.label&&(T.clearLabel=n.clearButton.label,u.innerHTML=T.clearLabel),n.clearButton=n.clearButton.show),T.clearButton=!!n.clearButton,u.style.display=T.clearButton?"block":"none";break;case"clearLabel":T.clearLabel=n.clearLabel,u.innerHTML=T.clearLabel;break;case"closeButton":T.closeButton=!!n.closeButton,T.closeButton?r.insertBefore(h,c):c.appendChild(h);break;case"closeLabel":T.closeLabel=n.closeLabel,h.innerHTML=T.closeLabel;break;case"a11y":var g=n.a11y,v=!1;if("object"==typeof g)for(var b in g)g[b]&&T.a11y[b]&&(T.a11y[b]=g[b],v=!0);if(v){var x=ot("clr-open-label"),w=ot("clr-swatch-label");x.innerHTML=T.a11y.open,w.innerHTML=T.a11y.swatch,h.setAttribute("aria-label",T.a11y.close),u.setAttribute("aria-label",T.a11y.clear),p.setAttribute("aria-label",T.a11y.hueSlider),m.setAttribute("aria-label",T.a11y.alphaSlider),d.setAttribute("aria-label",T.a11y.input),s.setAttribute("aria-label",T.a11y.instruction)}break;default:T[l]=n[l]}};for(var l in n)a()}}function _(t,e){"string"==typeof t&&"object"==typeof e&&(C[t]=e,E=!0)}function O(t){delete C[t],0===Object.keys(C).length&&(E=!1,t===P&&I())}function M(t){if(E){var e=["el","wrap","rtl","inline","defaultColor","a11y"],n=function(){var n=C[i];if(t.matches(i)){for(var o in P=i,k={},e.forEach((function(t){return delete n[t]})),n)k[o]=Array.isArray(T[o])?T[o].slice():T[o];return z(n),"break"}};for(var i in C)if("break"===n())break}}function I(){Object.keys(k).length>0&&(z(k),P="",k={})}function B(t){rt(e,"click",t,(function(t){T.inline||(M(t.target),v=t.target,b=v.value,y=j(b),r.classList.add("clr-open"),L(),A(b),(T.focusInput||T.selectInput)&&d.focus({preventScroll:!0}),T.selectInput&&d.select(),(x||T.swatchesOnly)&&it().shift().focus(),v.dispatchEvent(new Event("open",{bubbles:!0})))})),rt(e,"input",t,(function(t){var e=t.target.parentNode;e.classList.contains("clr-field")&&(e.style.color=t.target.value)}))}function L(){if(r&&(v||T.inline)){var n,i,l,c=o,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),i=parseFloat(n.marginTop),l=parseFloat(n.borderTopWidth),(f=c.getBoundingClientRect()).y+=l+d),!T.inline){var m=v.getBoundingClientRect(),g=m.x,y=d+m.y+m.height+T.margin;c?(g-=f.x,y-=f.y,g+u>c.clientWidth&&(g+=m.width-u,p.left=!0),y+h>c.clientHeight-i&&h+T.margin<=m.top-(f.y-d)&&(y-=m.height+h+2*T.margin,p.top=!0),y+=c.scrollTop):(g+u>e.documentElement.clientWidth&&(g+=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=g+"px",r.style.top=y+"px",f.x+=r.offsetLeft,f.y+=r.offsetTop}a={width:s.offsetWidth,height:s.offsetHeight,x:s.offsetLeft+f.x,y:s.offsetTop+f.y}}}function R(t){e.querySelectorAll(t).forEach((function(t){var n=t.parentNode;if(!n.classList.contains("clr-field")){var i=e.createElement("div"),o="clr-field";(T.rtl||t.classList.contains("clr-rtl"))&&(o+=" clr-rtl"),i.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',n.insertBefore(i,t),i.setAttribute("class",o),i.style.color=t.value,i.appendChild(t)}}))}function D(t){if(v&&!T.inline){var e=v;t&&(v=i,b!==e.value&&(e.value=b,e.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout((function(){b!==e.value&&e.dispatchEvent(new Event("change",{bubbles:!0}))})),r.classList.remove("clr-open"),E&&I(),e.dispatchEvent(new Event("close",{bubbles:!0})),T.focusInput&&e.focus({preventScroll:!0}),v=i}}function A(t){var e=Y(t),n=J(e);N(n.s,n.v),G(e,n),p.value=n.h,r.style.color="hsl("+n.h+", 100%, 50%)",f.style.left=n.h/360*100+"%",l.style.left=a.width*n.s/100+"px",l.style.top=a.height-a.height*n.v/100+"px",m.value=100*n.a,g.style.left=100*n.a+"%"}function j(t){var e=t.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function F(n){n=n!==i?n:d.value,v&&(v.value=n,v.dispatchEvent(new Event("input",{bubbles:!0}))),T.onChange&&T.onChange.call(t,n,v),e.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:n,currentEl:v}}))}function V(t,e){var n={h:1*p.value,s:t/a.width*100,v:100-e/a.height*100,a:m.value/100},i=q(n);N(n.s,n.v),G(i,n),F()}function N(t,e){var n=T.a11y.marker;t=1*t.toFixed(1),e=1*e.toFixed(1),n=(n=n.replace("{s}",t)).replace("{v}",e),l.setAttribute("aria-label",n)}function $(t){return{pageX:t.changedTouches?t.changedTouches[0].pageX:t.pageX,pageY:t.changedTouches?t.changedTouches[0].pageY:t.pageY}}function U(t){var e=$(t),n=e.pageX-a.x,i=e.pageY-a.y;o&&(i+=o.scrollTop),K(n,i),t.preventDefault(),t.stopPropagation()}function W(t,e){K(1*l.style.left.replace("px","")+t,1*l.style.top.replace("px","")+e)}function K(t,e){t=t<0?0:t>a.width?a.width:t,e=e<0?0:e>a.height?a.height:e,l.style.left=t+"px",l.style.top=e+"px",V(t,e),l.focus()}function G(t,n){void 0===t&&(t={}),void 0===n&&(n={});var i=T.format;for(var o in t)S[o]=t[o];for(var r in n)S[r]=n[r];var a=Q(S),u=a.substring(0,7);switch(l.style.color=u,g.parentNode.style.color=u,g.style.color=a,c.style.color=a,s.style.display="none",s.offsetHeight,s.style.display="",g.nextElementSibling.style.display="none",g.nextElementSibling.offsetHeight,g.nextElementSibling.style.display="","mixed"===i?i=1===S.a?"hex":"rgb":"auto"===i&&(i=y),i){case"hex":d.value=a;break;case"rgb":d.value=tt(S);break;case"hsl":d.value=et(X(S))}e.querySelector('.clr-format [value="'+i+'"]').checked=!0}function H(){var t=1*p.value,e=1*l.style.left.replace("px",""),n=1*l.style.top.replace("px","");r.style.color="hsl("+t+", 100%, 50%)",f.style.left=t/360*100+"%",V(e,n)}function Z(){var t=m.value/100;g.style.left=100*t+"%",G({a:t}),F()}function q(t){var e=t.s/100,i=t.v/100,o=e*i,r=t.h/60,s=o*(1-n.abs(r%2-1)),a=i-o;o+=a,s+=a;var l=n.floor(r)%6,c=[o,s,a,a,s,o][l],d=[s,o,o,s,a,a][l],u=[a,a,s,o,o,s][l];return{r:n.round(255*c),g:n.round(255*d),b:n.round(255*u),a:t.a}}function X(t){var e,i=t.v/100,o=i*(1-t.s/100/2);return o>0&&o<1&&(e=n.round((i-o)/n.min(o,1-o)*100)),{h:t.h,s:e||0,l:n.round(100*o),a:t.a}}function J(t){var e=t.r/255,i=t.g/255,o=t.b/255,r=n.max(e,i,o),s=r-n.min(e,i,o),a=r,l=0,c=0;return s&&(r===e&&(l=(i-o)/s),r===i&&(l=2+(o-e)/s),r===o&&(l=4+(e-i)/s),r&&(c=s/r)),{h:(l=n.floor(60*l))<0?l+360:l,s:n.round(100*c),v:n.round(100*a),a:t.a}}function Y(t){var e,n,i=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;return w.fillStyle="#000",w.fillStyle=t,(e=i.exec(w.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=w.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),o="";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 r=255*t.a|0;o=r.toString(16),r<16&&(o="0"+o)}return"#"+e+n+i+o}function tt(t){return!T.alpha||1===t.a&&!T.forceAlpha?"rgb("+t.r+", "+t.g+", "+t.b+")":"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"}function et(t){return!T.alpha||1===t.a&&!T.forceAlpha?"hsl("+t.h+", "+t.s+"%, "+t.l+"%)":"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"}function nt(){e.getElementById("clr-picker")||(o=i,(r=e.createElement("div")).setAttribute("id","clr-picker"),r.className="clr-picker",r.innerHTML='<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+T.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+T.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+T.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+T.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+T.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button type="button" id="clr-clear" class="clr-clear" aria-label="'+T.a11y.clear+'">'+T.clearLabel+'</button><div id="clr-color-preview" class="clr-preview"><button type="button" id="clr-close" class="clr-close" aria-label="'+T.a11y.close+'">'+T.closeLabel+'</button></div><span id="clr-open-label" hidden>'+T.a11y.open+'</span><span id="clr-swatch-label" hidden>'+T.a11y.swatch+"</span>",e.body.appendChild(r),s=ot("clr-color-area"),l=ot("clr-color-marker"),u=ot("clr-clear"),h=ot("clr-close"),c=ot("clr-color-preview"),d=ot("clr-color-value"),p=ot("clr-hue-slider"),f=ot("clr-hue-marker"),m=ot("clr-alpha-slider"),g=ot("clr-alpha-marker"),B(T.el),R(T.el),rt(r,"mousedown",(function(t){r.classList.remove("clr-keyboard-nav"),t.stopPropagation()})),rt(s,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(s,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(l,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(l,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(d,"change",(function(t){(v||T.inline)&&(A(d.value),F())})),rt(u,"click",(function(t){F(""),D()})),rt(h,"click",(function(t){F(),D()})),rt(e,"click",".clr-format input",(function(t){y=t.target.value,G(),F()})),rt(r,"click",".clr-swatches button",(function(t){A(t.target.textContent),F(),T.swatchesOnly&&D()})),rt(e,"mouseup",(function(t){e.removeEventListener("mousemove",U)})),rt(e,"touchend",(function(t){e.removeEventListener("touchmove",U)})),rt(e,"mousedown",(function(t){x=!1,r.classList.remove("clr-keyboard-nav"),D()})),rt(e,"keydown",(function(t){var e=t.key,n=t.target,i=t.shiftKey,o=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];if("Escape"===e?D(!0):o.includes(e)&&(x=!0,r.classList.add("clr-keyboard-nav")),"Tab"===e&&n.matches(".clr-picker *")){var s=it(),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){E&&I(),t.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))})),rt(l,"keydown",(function(t){var e={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(e).includes(t.key)&&(W.apply(void 0,e[t.key]),t.preventDefault())})),rt(s,"click",U),rt(p,"input",H),rt(m,"input",Z))}function it(){return Array.from(r.querySelectorAll("input, button")).filter((function(t){return!!t.offsetWidth}))}function ot(t){return e.getElementById(t)}function rt(t,e,n,i){var o=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof n?t.addEventListener(e,(function(t){o.call(t.target,n)&&i.call(t.target,t)})):(i=n,t.addEventListener(e,i))}function st(t,n){n=n!==i?n:[],"loading"!==e.readyState?t.apply(void 0,n):e.addEventListener("DOMContentLoaded",(function(){t.apply(void 0,n)}))}function at(t,e){b=(v=e).value,M(e),y=j(t),L(),A(t),F(),b!==t&&v.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==i&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var lt=function(){var e={init:nt,set:z,wrap:R,close:D,setInstance:_,setColor:at,removeInstance:O,updatePosition:L};function n(t){st((function(){t&&("string"==typeof t?B(t):z(t))}))}var i=function(t){n[t]=function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];st(e[t],i)}};for(var o in e)i(o);return st((function(){t.addEventListener("resize",(function(t){n.updatePosition()})),t.addEventListener("scroll",(function(t){n.updatePosition()}))})),n}();return lt.coloris=lt,lt}(window,document,Math)})?n.apply(e,i):n)||(t.exports=o)},4232:e=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=(t=>(e,s)=>t&&t.get(e)||(s=((t,e,s,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let l of o(e))r.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:()=>I});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},S={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const n=e(t);let 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 o=1-t;let r=e;if(0===i)return e[0].t=t,e[0];if(1===i){const e={x:o*r[0].x+t*r[1].x,y:o*r[0].y+t*r[1].y,t};return n&&(e.z=o*r[0].z+t*r[1].z),e}if(i<4){let e,s,a,l=o*o,c=t*t,d=0;2===i?(r=[r[0],r[1],r[2],w],e=l,s=o*t*2,a=c):3===i&&(e=l*o,s=l*t*3,a=o*c*3,d=t*c);const u={x:e*r[0].x+s*r[1].x+a*r[2].x+d*r[3].x,y:e*r[0].y+s*r[1].y+a*r[2].y+d*r[3].y,t};return n&&(u.z=e*r[0].z+s*r[1].z+a*r[2].z+d*r[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 o=1-t,r=n,s=e;let a,l=r[0],c=r[1],d=r[2],u=r[3];return l*=o,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*=o,c*=2*o,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*=o,c*=1.5*o,d*=3*o,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,o=i.length,r=o-1;o>1;o--,r--){const t=[];for(let n,o=0;o<r;o++)n={x:r*(i[o+1].x-i[o].x),y:r*(i[o+1].y-i[o].y)},e&&(n.z=r*(i[o+1].z-i[o].z)),t.push(n);n.push(t),i=t}return n},between:function(t,e,n){return e<=t&&t<=n||S.approximately(t,e)||S.approximately(t,n)},approximately:function(t,e,n){return l(t-e)<=(n||1e-6)},length:function(t){const e=S.Tvalues.length;let n=0;for(let i,o=0;o<e;o++)i=.5*S.Tvalues[o]+.5,n+=S.Cvalues[o]*S.arcfn(i,t);return.5*n},map:function(t,e,n,i,o){return i+(o-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(S.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,n){const i=e.x-t.x,o=e.y-t.y,r=n.x-t.x,s=n.y-t.y;return h(i*s-o*r,i*r+o*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,o=f(2,63);return t.forEach((function(t,r){i=S.dist(e,t),i<o&&(o=i,n=r)})),{mdist:o,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,o,r,s,a){const l=(t-n)*(r-a)-(e-i)*(o-s);return 0!=l&&{x:((t*i-e*n)*(o-s)-(t-n)*(o*a-r*s))/l,y:((t*i-e*n)*(r-a)-(e-i)*(o*a-r*s))/l}},lli4:function(t,e,n,i){const o=t.x,r=t.y,s=e.x,a=e.y,l=n.x,c=n.y,d=i.x,u=i.y;return S.lli8(o,r,s,a,l,c,d,u)},lli:function(t,e){return S.lli4(t,t.c,e,e.c)},makeline:function(t,e){return new I(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,o=x;return t.forEach((function(t){const r=t.bbox();e>r.x.min&&(e=r.x.min),n>r.y.min&&(n=r.y.min),i<r.x.max&&(i=r.x.max),o<r.y.max&&(o=r.y.max)})),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:n,mid:(n+o)/2,max:o,size:o-n}}},shapeintersections:function(t,e,n,i,o){if(!S.bboxoverlap(e,i))return[];const r=[],s=[t.startcap,t.forward,t.back,t.endcap],a=[n.startcap,n.forward,n.back,n.endcap];return s.forEach((function(e){e.virtual||a.forEach((function(i){if(i.virtual)return;const s=e.intersects(i,o);s.length>0&&(s.c1=e,s.c2=i,s.s1=t,s.s2=n,r.push(s))}))})),r},makeshape:function(t,e,n){const i=e.points.length,o=t.points.length,r=S.makeline(e.points[i-1],t.points[0]),s=S.makeline(t.points[o-1],e.points[0]),a={startcap:r,forward:t,back:e,endcap:s,bbox:S.findbbox([r,t,e,s]),intersections:function(t){return S.shapeintersections(a,a.bbox,t,t.bbox,n)}};return a},getminmax:function(t,e,n){if(!n)return{min:0,max:0};let i,o,r=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],o=t.get(i),o[e]<r&&(r=o[e]),o[e]>s&&(s=o[e]);return{min:r,mid:(r+s)/2,max:s,size:s-r}},align:function(t,e){const n=e.p1.x,i=e.p1.y,o=-h(e.p2.y-i,e.p2.x-n);return t.map((function(t){return{x:(t.x-n)*c(o)-(t.y-i)*d(o),y:(t.x-n)*d(o)+(t.y-i)*c(o)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=t.length-1,i=S.align(t,e),o=function(t){return 0<=t&&t<=1};if(2===n){const t=i[0].y,e=i[1].y,n=i[2].y,r=t-2*e+n;if(0!==r){const i=-p(e*e-t*n),s=-t+e;return[-(i+s)/r,-(-i+s)/r].filter(o)}return e!==n&&0===r?[(2*e-n)/(2*e-2*n)].filter(o):[]}const r=i[0].y,s=i[1].y,a=i[2].y;let l=3*s-r-3*a+i[3].y,d=3*r-6*s+3*a,h=-3*r+3*s,f=r;if(S.approximately(l,0)){if(S.approximately(d,0))return S.approximately(h,0)?[]:[-f/h].filter(o);const t=p(h*h-4*d*f),e=2*d;return[(t-h)/e,(-h-t)/e].filter(o)}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 T,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),r=2*m(e);return P=r*c(i/3)-d/3,k=r*c((i+v)/3)-d/3,E=r*c((i+2*v)/3)-d/3,[P,k,E].filter(o)}if(0===w)return T=x<0?m(-x):-m(x),P=2*T-d/3,k=-T-d/3,[P,k].filter(o);{const t=p(w);return T=m(-x+t),C=m(x+t),[T-C-d/3].filter(o)}},droots:function(t){if(3===t.length){const e=t[0],n=t[1],i=t[2],o=e-2*n+i;if(0!==o){const t=-p(n*n-e*i),r=-e+n;return[-(t+r)/o,-(-t+r)/o]}return n!==i&&0===o?[(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,o){let r,s,a,c,d=0,u=0;const h=S.compute(t,e),m=S.compute(t,n),g=h.x*h.x+h.y*h.y;if(i?(r=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)):(r=h.x*m.y-h.y*m.x,s=f(g,1.5)),0===r||0===s)return{k:0,r:0};if(d=r/s,u=s/r,!o){const o=S.curvature(t-.001,e,n,i,!0).k,r=S.curvature(t+.001,e,n,i,!0).k;c=(r-d+(d-o))/2,a=(l(r-d)+l(d-o))/2}return{k:d,r:u,dk:c,adk:a}},inflections:function(t){if(t.length<4)return[];const e=S.align(t,{p1:t[0],p2:t.slice(-1)[0]}),n=e[2].x*e[1].y,i=e[3].x*e[1].y,o=e[1].x*e[2].y,r=18*(-3*n+2*i+3*o-e[3].x*e[2].y),s=18*(3*n-i-3*o),a=18*(o-n);if(S.approximately(r,0)){if(!S.approximately(s,0)){let t=-a/s;if(0<=t&&t<=1)return[t]}return[]}const l=2*r;if(S.approximately(l,0))return[];const c=s*s-4*r*a;if(c<0)return[];const d=Math.sqrt(c);return[(d-s)/l,-(s+d)/l].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const n=["x","y"],i=n.length;for(let o,r,s,a,c=0;c<i;c++)if(o=n[c],r=t[o].mid,s=e[o].mid,a=(t[o].size+e[o].size)/2,l(r-s)>=a)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,n){const i=t.bbox(),o=e.bbox(),r=1e5,s=n||.5;if(i.x.size+i.y.size<s&&o.x.size+o.y.size<s)return[(r*(t._t1+t._t2)/2|0)/r+"/"+(r*(e._t1+e._t2)/2|0)/r];let a=t.split(.5),l=e.split(.5),c=[{left:a.left,right:l.left},{left:a.left,right:l.right},{left:a.right,right:l.right},{left:a.right,right:l.left}];c=c.filter((function(t){return S.bboxoverlap(t.left.bbox(),t.right.bbox())}));let d=[];return 0===c.length||(c.forEach((function(t){d=d.concat(S.pairiteration(t.left,t.right,s))})),d=d.filter((function(t,e){return d.indexOf(t)===e}))),d},getccenter:function(t,e,n){const i=e.x-t.x,o=e.y-t.y,r=n.x-e.x,s=n.y-e.y,a=i*c(y)-o*d(y),l=i*d(y)+o*c(y),u=r*c(y)-s*d(y),p=r*d(y)+s*c(y),f=(t.x+e.x)/2,m=(t.y+e.y)/2,g=(e.x+n.x)/2,b=(e.y+n.y)/2,x=f+a,w=m+l,T=g+u,C=b+p,P=S.lli8(f,m,x,w,g,b,T,C),k=S.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}},T=class{constructor(t){this.curves=[],this._3d=!1,t&&(this.curves=t,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map((function(t){return S.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),n=1;n<t.length;n++)S.expandbox(e,t[n].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(n){e.push(...n.offset(t))})),new T(e)}},{abs:C,min:P,max:k,cos:E,sin:z,acos:_,sqrt:O}=Math,M=Math.PI,I=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 o=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!==o&&8!==o&&9!==o&&12!==o&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const r=this._3d=!i&&(9===o||12===o)||t&&t[0]&&void 0!==t[0].z,s=this.points=[];for(let t=0,n=r?3:2;t<o;t+=n){var a={x:e[t],y:e[t+1]};r&&(a.z=e[t+2]),s.push(a)}const l=this.order=s.length-1,c=this.dims=["x","y"];r&&c.push("z"),this.dimlen=c.length;const d=S.align(s,{p1:s[0],p2:s[l]}),u=S.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 I(e,e,n);if(1===i)return new I(t,e,e);const o=I.getABC(2,t,e,n,i);return new I(t,o.A,n)}static cubicFromPoints(t,e,n,i,o){void 0===i&&(i=.5);const r=I.getABC(3,t,e,n,i);void 0===o&&(o=S.dist(e,r.C));const s=o*(1-i)/i,a=S.dist(t,n),l=(n.x-t.x)/a,c=(n.y-t.y)/a,d=o*l,u=o*c,h=s*l,p=s*c,f=e.x-d,m=e.y-u,g=e.x+h,v=e.y+p,y=r.A,b=y.x+(f-y.x)/(1-i),x=y.y+(m-y.y)/(1-i),w=y.x+(g-y.x)/i,T=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+(T-n.y)/(1-i)};return new I(t,C,P,n)}static getUtils(){return S}getUtils(){return I.getUtils()}static get PolyBezier(){return T}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let n=1,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=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=S.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return S.length(this.derivative.bind(this))}static getABC(t=2,e,n,i,o=.5){const r=S.projectionratio(o,t),s=1-r,a={x:r*e.x+s*i.x,y:r*e.y+s*i.y},l=S.abcratio(o,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 I.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(),o=[];for(let t,r=0,s=0;r<i.length;r++)t=i[r],S.dist(t,e)<n&&(o.push(t),s+=r/i.length);return!!o.length&&(t/=o.length)}project(t){const e=this.getLUT(),n=e.length-1,i=S.closest(e,t),o=i.mpos,r=(o-1)/n,s=(o+1)/n,a=.1/n;let l,c=i.mdist,d=r,u=d;c+=1;for(let e;d<s+a;d+=a)l=this.compute(d),e=S.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?S.computeWithRatios(t,this.points,this.ratios,this._3d):S.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],n=t.length;for(let i,o,r=1;r<n;r++)i=t[r],o=t[r-1],e[r]={x:(n-r)/n*i.x+r/n*o.x,y:(n-r)/n*i.y+r/n*o.y};return e[n]=t[n-1],new I(e)}derivative(t){return S.compute(t,this.dpoints[0],this._3d)}dderivative(t){return S.compute(t,this.dpoints[1],this._3d)}align(){let t=this.points;return new I(S.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return S.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),n=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),o=O(n.x*n.x+n.y*n.y+n.z*n.z);e.x/=i,e.y/=i,e.z/=i,n.x/=o,n.y/=o,n.z/=o;const r={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},s=O(r.x*r.x+r.y*r.y+r.z*r.z);r.x/=s,r.y/=s,r.z/=s;const a=[r.x*r.x,r.x*r.y-r.z,r.x*r.z+r.y,r.x*r.y+r.z,r.y*r.y,r.y*r.z-r.x,r.x*r.z-r.y,r.y*r.z+r.x,r.z*r.z];return{t,x:a[0]*e.x+a[1]*e.y+a[2]*e.z,y:a[3]*e.x+a[4]*e.y+a[5]*e.z,z:a[6]*e.x+a[7]*e.y+a[8]*e.z}}hull(t){let e=this.points,n=[],i=[],o=0;for(i[o++]=e[0],i[o++]=e[1],i[o++]=e[2],3===this.order&&(i[o++]=e[3]);e.length>1;){n=[];for(let r,s=0,a=e.length-1;s<a;s++)r=S.lerp(t,e[s],e[s+1]),i[o++]=r,n.push(r);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 I([n[0],n[3],n[5]]):new I([n[0],n[4],n[7],n[9]]),right:2===this.order?new I([n[5],n[4],n[2]]):new I([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=S.map(0,0,1,this._t1,this._t2),i.left._t2=S.map(t,0,1,this._t1,this._t2),i.right._t1=S.map(t,0,1,this._t1,this._t2),i.right._t2=S.map(1,0,1,this._t1,this._t2),e?(e=S.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]},o=this.dpoints[0].map(i);t[n]=S.droots(o),3===this.order&&(o=this.dpoints[1].map(i),t[n]=t[n].concat(S.droots(o))),t[n]=t[n].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[n].sort(S.numberSort))}.bind(this)),t.values=e.sort(S.numberSort).filter((function(t,n){return e.indexOf(t)===n})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(n){e[n]=S.getminmax(this,n,t[n])}.bind(this)),e}overlaps(t){const e=this.bbox(),n=t.bbox();return S.bboxoverlap(e,n)}offset(t,e){if(void 0!==e){const n=this.get(t),i=this.normal(t),o={c:n,n:i,x:n.x+i.x*e,y:n.y+i.y*e};return this._3d&&(o.z=n.z+i.z*e),o}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 I(n)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=S.angle(this.points[0],this.points[3],this.points[1]),e=S.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let n=t.x*e.x+t.y*e.y;return this._3d&&(n+=t.z*e.z),C(_(n))<M/3}reduce(){let t,e,n=0,i=0,o=.01,r=[],s=[],a=this.extrema().values;for(-1===a.indexOf(0)&&(a=[0].concat(a)),-1===a.indexOf(1)&&a.push(1),n=a[0],t=1;t<a.length;t++)i=a[t],e=this.split(n,i),e._t1=n,e._t2=i,r.push(e),n=i;return r.forEach((function(t){for(n=0,i=0;i<=1;)for(i=n+o;i<=1.01;i+=o)if(e=t.split(n,i),!e.simple()){if(i-=o,C(n-i)<o)return[];e=t.split(n,i),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=S.map(i,0,1,t._t1,t._t2),s.push(e),n=i;break}n<1&&(e=t.split(n,1),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=t._t2,s.push(e))})),s}translate(t,e,n){n="number"==typeof n?n:e;const i=this.order;let o=this.points.map(((t,o)=>(1-o/i)*e+o/i*n));return new I(this.points.map(((e,n)=>({x:e.x+t.x*o[n],y:e.y+t.y*o[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,o=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):t,n?n(1):t);const r=n?n(0):t,s=n?n(1):t,a=[this.offset(0,10),this.offset(1,10)],l=[],c=S.lli4(a[0],a[0].c,a[1],a[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const n=l[t*e]=S.copy(o[t*e]);n.x+=(t?s:r)*a[t].n.x,n.y+=(t?s:r)*a[t].n.y})),n?([0,1].forEach((function(r){if(2!==e||!r){var s=o[r+1],a={x:s.x-c.x,y:s.y-c.y},d=n?n((r+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[r+1]={x:s.x+d*a.x,y:s.y+d*a.y}}})),new I(l)):([0,1].forEach((t=>{if(2===e&&t)return;const n=l[t*e],i=this.derivative(t),r={x:n.x+i.x,y:n.y+i.y};l[t+1]=S.lli4(n,r,c,o[t+1])})),new I(l))}outline(t,e,n,i){if(e=void 0===e?t:e,this._linear){const o=this.normal(0),r=this.points[0],s=this.points[this.points.length-1];let a,l,c;void 0===n&&(n=t,i=e),a={x:r.x+o.x*t,y:r.y+o.y*t},c={x:s.x+o.x*n,y:s.y+o.y*n},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const d=[a,l,c];a={x:r.x-o.x*e,y:r.y-o.y*e},c={x:s.x-o.x*i,y:s.y-o.y*i},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const u=[c,l,a],h=S.makeline(u[2],d[0]),p=S.makeline(d[2],u[0]),f=[h,new I(d),p,new I(u)];return new T(f)}const o=this.reduce(),r=o.length,s=[];let a,l=[],c=0,d=this.length();const u=void 0!==n&&void 0!==i;function h(t,e,n,i,o){return function(r){const s=i/n,a=(i+o)/n,l=e-t;return S.map(r,0,1,t+s*l,t+a*l)}}o.forEach((function(o){const r=o.length();u?(s.push(o.scale(h(t,n,d,c,r))),l.push(o.scale(h(-e,-i,d,c,r)))):(s.push(o.scale(t)),l.push(o.scale(-e))),c+=r})),l=l.map((function(t){return a=t.points,a[3]?t.points=[a[3],a[2],a[1],a[0]]:t.points=[a[2],a[1],a[0]],t})).reverse();const p=s[0].points[0],f=s[r-1].points[s[r-1].points.length-1],m=l[r-1].points[l[r-1].points.length-1],g=l[0].points[0],v=S.makeline(m,p),y=S.makeline(f,g),b=[v].concat(s).concat([y]).concat(l);return new T(b)}outlineshapes(t,e,n){e=e||t;const i=this.outline(t,e).curves,o=[];for(let t=1,e=i.length;t<e/2;t++){const r=S.makeshape(i[t],i[e-t],n);r.startcap.virtual=t>1,r.endcap.virtual=t<e/2-1,o.push(r)}return o}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof I&&(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),o=k(t.p1.y,t.p2.y);return S.roots(this.points,t).filter((t=>{var r=this.get(t);return S.between(r.x,e,i)&&S.between(r.y,n,o)}))}selfintersects(t){const e=this.reduce(),n=e.length-2,i=[];for(let o,r,s,a=0;a<n;a++)r=e.slice(a,a+1),s=e.slice(a+2),o=this.curveintersects(r,s,t),i.push(...o);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 o=[];return i.forEach((function(t){const e=S.pairiteration(t.left,t.right,n);e.length>0&&(o=o.concat(e))})),o}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,n,i){const o=(i-n)/4,r=this.get(n+o),s=this.get(i-o),a=S.dist(t,e),l=S.dist(t,r),c=S.dist(t,s);return C(l-a)+C(c-a)}_iterate(t,e){let n,i=0,o=1;do{n=0,o=1;let r,s,a,l,c,d=this.get(i),u=!1,h=!1,p=o,f=1,m=0;do{if(h=u,l=a,p=(i+o)/2,m++,r=this.get(p),s=this.get(o),a=S.getccenter(d,r,s),a.interval={start:i,end:o},u=this._error(a,d,i,o)<=t,c=h&&!u,c||(f=o),u){if(o>=1){if(a.interval.end=f=1,l=a,o>1){let t={x:a.x+a.r*E(a.e),y:a.y+a.r*z(a.e)};a.e+=S.angle({x:a.x,y:a.y},t,this.get(1))}break}o+=(o-i)/2}else o=p}while(!c&&n++<100);if(n>=100)break;l=l||a,e.push(l),i=f}while(o<1);return e}};e.exports=s(a)}},n={};function i(t){var o=n[t];if(void 0!==o)return o.exports;var r=n[t]={id:t,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.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 o=i(7783);window.jsdraw=o})();
|
9
|
+
return function(t,e,n,i){var o,r,s,a,l,c,d,u,h,p,f,m,g,v,y,b,x,w=e.createElement("canvas").getContext("2d"),S={r:0,g:0,b:0,h:0,s:0,v:0,a:1},T={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:function(){return i},a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},C={},P="",k={},E=!1;function z(n){if("object"==typeof n){var a=function(){switch(l){case"el":B(n.el),!1!==n.wrap&&R(n.el);break;case"parent":(o=e.querySelector(n.parent))&&(o.appendChild(r),T.parent=n.parent,o===e.body&&(o=i));break;case"themeMode":T.themeMode=n.themeMode,"auto"===n.themeMode&&t.matchMedia&&t.matchMedia("(prefers-color-scheme: dark)").matches&&(T.themeMode="dark");case"theme":n.theme&&(T.theme=n.theme),r.className="clr-picker clr-"+T.theme+" clr-"+T.themeMode,T.inline&&L();break;case"rtl":T.rtl=!!n.rtl,e.querySelectorAll(".clr-field").forEach((function(t){return t.classList.toggle("clr-rtl",T.rtl)}));break;case"margin":n.margin*=1,T.margin=isNaN(n.margin)?T.margin:n.margin;break;case"wrap":n.el&&n.wrap&&R(n.el);break;case"formatToggle":T.formatToggle=!!n.formatToggle,ot("clr-format").style.display=T.formatToggle?"block":"none",T.formatToggle&&(T.format="auto");break;case"swatches":if(Array.isArray(n.swatches)){var a=[];n.swatches.forEach((function(t,e){a.push('<button type="button" id="clr-swatch-'+e+'" aria-labelledby="clr-swatch-label clr-swatch-'+e+'" style="color: '+t+';">'+t+"</button>")})),ot("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":"",T.swatches=n.swatches.slice()}break;case"swatchesOnly":T.swatchesOnly=!!n.swatchesOnly,r.setAttribute("data-minimal",T.swatchesOnly);break;case"alpha":T.alpha=!!n.alpha,r.setAttribute("data-alpha",T.alpha);break;case"inline":if(T.inline=!!n.inline,r.setAttribute("data-inline",T.inline),T.inline){var f=n.defaultColor||T.defaultColor;y=j(f),L(),A(f)}break;case"clearButton":"object"==typeof n.clearButton&&(n.clearButton.label&&(T.clearLabel=n.clearButton.label,u.innerHTML=T.clearLabel),n.clearButton=n.clearButton.show),T.clearButton=!!n.clearButton,u.style.display=T.clearButton?"block":"none";break;case"clearLabel":T.clearLabel=n.clearLabel,u.innerHTML=T.clearLabel;break;case"closeButton":T.closeButton=!!n.closeButton,T.closeButton?r.insertBefore(h,c):c.appendChild(h);break;case"closeLabel":T.closeLabel=n.closeLabel,h.innerHTML=T.closeLabel;break;case"a11y":var g=n.a11y,v=!1;if("object"==typeof g)for(var b in g)g[b]&&T.a11y[b]&&(T.a11y[b]=g[b],v=!0);if(v){var x=ot("clr-open-label"),w=ot("clr-swatch-label");x.innerHTML=T.a11y.open,w.innerHTML=T.a11y.swatch,h.setAttribute("aria-label",T.a11y.close),u.setAttribute("aria-label",T.a11y.clear),p.setAttribute("aria-label",T.a11y.hueSlider),m.setAttribute("aria-label",T.a11y.alphaSlider),d.setAttribute("aria-label",T.a11y.input),s.setAttribute("aria-label",T.a11y.instruction)}break;default:T[l]=n[l]}};for(var l in n)a()}}function _(t,e){"string"==typeof t&&"object"==typeof e&&(C[t]=e,E=!0)}function O(t){delete C[t],0===Object.keys(C).length&&(E=!1,t===P&&M())}function I(t){if(E){var e=["el","wrap","rtl","inline","defaultColor","a11y"],n=function(){var n=C[i];if(t.matches(i)){for(var o in P=i,k={},e.forEach((function(t){return delete n[t]})),n)k[o]=Array.isArray(T[o])?T[o].slice():T[o];return z(n),"break"}};for(var i in C)if("break"===n())break}}function M(){Object.keys(k).length>0&&(z(k),P="",k={})}function B(t){rt(e,"click",t,(function(t){T.inline||(I(t.target),v=t.target,b=v.value,y=j(b),r.classList.add("clr-open"),L(),A(b),(T.focusInput||T.selectInput)&&d.focus({preventScroll:!0}),T.selectInput&&d.select(),(x||T.swatchesOnly)&&it().shift().focus(),v.dispatchEvent(new Event("open",{bubbles:!0})))})),rt(e,"input",t,(function(t){var e=t.target.parentNode;e.classList.contains("clr-field")&&(e.style.color=t.target.value)}))}function L(){if(r&&(v||T.inline)){var n,i,l,c=o,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),i=parseFloat(n.marginTop),l=parseFloat(n.borderTopWidth),(f=c.getBoundingClientRect()).y+=l+d),!T.inline){var m=v.getBoundingClientRect(),g=m.x,y=d+m.y+m.height+T.margin;c?(g-=f.x,y-=f.y,g+u>c.clientWidth&&(g+=m.width-u,p.left=!0),y+h>c.clientHeight-i&&h+T.margin<=m.top-(f.y-d)&&(y-=m.height+h+2*T.margin,p.top=!0),y+=c.scrollTop):(g+u>e.documentElement.clientWidth&&(g+=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=g+"px",r.style.top=y+"px",f.x+=r.offsetLeft,f.y+=r.offsetTop}a={width:s.offsetWidth,height:s.offsetHeight,x:s.offsetLeft+f.x,y:s.offsetTop+f.y}}}function R(t){e.querySelectorAll(t).forEach((function(t){var n=t.parentNode;if(!n.classList.contains("clr-field")){var i=e.createElement("div"),o="clr-field";(T.rtl||t.classList.contains("clr-rtl"))&&(o+=" clr-rtl"),i.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',n.insertBefore(i,t),i.setAttribute("class",o),i.style.color=t.value,i.appendChild(t)}}))}function D(t){if(v&&!T.inline){var e=v;t&&(v=i,b!==e.value&&(e.value=b,e.dispatchEvent(new Event("input",{bubbles:!0})))),setTimeout((function(){b!==e.value&&e.dispatchEvent(new Event("change",{bubbles:!0}))})),r.classList.remove("clr-open"),E&&M(),e.dispatchEvent(new Event("close",{bubbles:!0})),T.focusInput&&e.focus({preventScroll:!0}),v=i}}function A(t){var e=Y(t),n=J(e);N(n.s,n.v),G(e,n),p.value=n.h,r.style.color="hsl("+n.h+", 100%, 50%)",f.style.left=n.h/360*100+"%",l.style.left=a.width*n.s/100+"px",l.style.top=a.height-a.height*n.v/100+"px",m.value=100*n.a,g.style.left=100*n.a+"%"}function j(t){var e=t.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function V(n){n=n!==i?n:d.value,v&&(v.value=n,v.dispatchEvent(new Event("input",{bubbles:!0}))),T.onChange&&T.onChange.call(t,n,v),e.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:n,currentEl:v}}))}function F(t,e){var n={h:1*p.value,s:t/a.width*100,v:100-e/a.height*100,a:m.value/100},i=q(n);N(n.s,n.v),G(i,n),V()}function N(t,e){var n=T.a11y.marker;t=1*t.toFixed(1),e=1*e.toFixed(1),n=(n=n.replace("{s}",t)).replace("{v}",e),l.setAttribute("aria-label",n)}function $(t){return{pageX:t.changedTouches?t.changedTouches[0].pageX:t.pageX,pageY:t.changedTouches?t.changedTouches[0].pageY:t.pageY}}function U(t){var e=$(t),n=e.pageX-a.x,i=e.pageY-a.y;o&&(i+=o.scrollTop),K(n,i),t.preventDefault(),t.stopPropagation()}function W(t,e){K(1*l.style.left.replace("px","")+t,1*l.style.top.replace("px","")+e)}function K(t,e){t=t<0?0:t>a.width?a.width:t,e=e<0?0:e>a.height?a.height:e,l.style.left=t+"px",l.style.top=e+"px",F(t,e),l.focus()}function G(t,n){void 0===t&&(t={}),void 0===n&&(n={});var i=T.format;for(var o in t)S[o]=t[o];for(var r in n)S[r]=n[r];var a=Q(S),u=a.substring(0,7);switch(l.style.color=u,g.parentNode.style.color=u,g.style.color=a,c.style.color=a,s.style.display="none",s.offsetHeight,s.style.display="",g.nextElementSibling.style.display="none",g.nextElementSibling.offsetHeight,g.nextElementSibling.style.display="","mixed"===i?i=1===S.a?"hex":"rgb":"auto"===i&&(i=y),i){case"hex":d.value=a;break;case"rgb":d.value=tt(S);break;case"hsl":d.value=et(X(S))}e.querySelector('.clr-format [value="'+i+'"]').checked=!0}function H(){var t=1*p.value,e=1*l.style.left.replace("px",""),n=1*l.style.top.replace("px","");r.style.color="hsl("+t+", 100%, 50%)",f.style.left=t/360*100+"%",F(e,n)}function Z(){var t=m.value/100;g.style.left=100*t+"%",G({a:t}),V()}function q(t){var e=t.s/100,i=t.v/100,o=e*i,r=t.h/60,s=o*(1-n.abs(r%2-1)),a=i-o;o+=a,s+=a;var l=n.floor(r)%6,c=[o,s,a,a,s,o][l],d=[s,o,o,s,a,a][l],u=[a,a,s,o,o,s][l];return{r:n.round(255*c),g:n.round(255*d),b:n.round(255*u),a:t.a}}function X(t){var e,i=t.v/100,o=i*(1-t.s/100/2);return o>0&&o<1&&(e=n.round((i-o)/n.min(o,1-o)*100)),{h:t.h,s:e||0,l:n.round(100*o),a:t.a}}function J(t){var e=t.r/255,i=t.g/255,o=t.b/255,r=n.max(e,i,o),s=r-n.min(e,i,o),a=r,l=0,c=0;return s&&(r===e&&(l=(i-o)/s),r===i&&(l=2+(o-e)/s),r===o&&(l=4+(e-i)/s),r&&(c=s/r)),{h:(l=n.floor(60*l))<0?l+360:l,s:n.round(100*c),v:n.round(100*a),a:t.a}}function Y(t){var e,n,i=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;return w.fillStyle="#000",w.fillStyle=t,(e=i.exec(w.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=w.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),o="";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 r=255*t.a|0;o=r.toString(16),r<16&&(o="0"+o)}return"#"+e+n+i+o}function tt(t){return!T.alpha||1===t.a&&!T.forceAlpha?"rgb("+t.r+", "+t.g+", "+t.b+")":"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"}function et(t){return!T.alpha||1===t.a&&!T.forceAlpha?"hsl("+t.h+", "+t.s+"%, "+t.l+"%)":"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"}function nt(){e.getElementById("clr-picker")||(o=i,(r=e.createElement("div")).setAttribute("id","clr-picker"),r.className="clr-picker",r.innerHTML='<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+T.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+T.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+T.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+T.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+T.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button type="button" id="clr-clear" class="clr-clear" aria-label="'+T.a11y.clear+'">'+T.clearLabel+'</button><div id="clr-color-preview" class="clr-preview"><button type="button" id="clr-close" class="clr-close" aria-label="'+T.a11y.close+'">'+T.closeLabel+'</button></div><span id="clr-open-label" hidden>'+T.a11y.open+'</span><span id="clr-swatch-label" hidden>'+T.a11y.swatch+"</span>",e.body.appendChild(r),s=ot("clr-color-area"),l=ot("clr-color-marker"),u=ot("clr-clear"),h=ot("clr-close"),c=ot("clr-color-preview"),d=ot("clr-color-value"),p=ot("clr-hue-slider"),f=ot("clr-hue-marker"),m=ot("clr-alpha-slider"),g=ot("clr-alpha-marker"),B(T.el),R(T.el),rt(r,"mousedown",(function(t){r.classList.remove("clr-keyboard-nav"),t.stopPropagation()})),rt(s,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(s,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(l,"mousedown",(function(t){rt(e,"mousemove",U)})),rt(l,"touchstart",(function(t){e.addEventListener("touchmove",U,{passive:!1})})),rt(d,"change",(function(t){(v||T.inline)&&(A(d.value),V())})),rt(u,"click",(function(t){V(""),D()})),rt(h,"click",(function(t){V(),D()})),rt(e,"click",".clr-format input",(function(t){y=t.target.value,G(),V()})),rt(r,"click",".clr-swatches button",(function(t){A(t.target.textContent),V(),T.swatchesOnly&&D()})),rt(e,"mouseup",(function(t){e.removeEventListener("mousemove",U)})),rt(e,"touchend",(function(t){e.removeEventListener("touchmove",U)})),rt(e,"mousedown",(function(t){x=!1,r.classList.remove("clr-keyboard-nav"),D()})),rt(e,"keydown",(function(t){var e=t.key,n=t.target,i=t.shiftKey,o=["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];if("Escape"===e?D(!0):o.includes(e)&&(x=!0,r.classList.add("clr-keyboard-nav")),"Tab"===e&&n.matches(".clr-picker *")){var s=it(),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){E&&M(),t.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))})),rt(l,"keydown",(function(t){var e={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(e).includes(t.key)&&(W.apply(void 0,e[t.key]),t.preventDefault())})),rt(s,"click",U),rt(p,"input",H),rt(m,"input",Z))}function it(){return Array.from(r.querySelectorAll("input, button")).filter((function(t){return!!t.offsetWidth}))}function ot(t){return e.getElementById(t)}function rt(t,e,n,i){var o=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof n?t.addEventListener(e,(function(t){o.call(t.target,n)&&i.call(t.target,t)})):(i=n,t.addEventListener(e,i))}function st(t,n){n=n!==i?n:[],"loading"!==e.readyState?t.apply(void 0,n):e.addEventListener("DOMContentLoaded",(function(){t.apply(void 0,n)}))}function at(t,e){b=(v=e).value,I(e),y=j(t),L(),A(t),V(),b!==t&&v.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==i&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var lt=function(){var e={init:nt,set:z,wrap:R,close:D,setInstance:_,setColor:at,removeInstance:O,updatePosition:L};function n(t){st((function(){t&&("string"==typeof t?B(t):z(t))}))}var i=function(t){n[t]=function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];st(e[t],i)}};for(var o in e)i(o);return st((function(){t.addEventListener("resize",(function(t){n.updatePosition()})),t.addEventListener("scroll",(function(t){n.updatePosition()}))})),n}();return lt.coloris=lt,lt}(window,document,Math)})?n.apply(e,i):n)||(t.exports=o)},4232:e=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=(t=>(e,s)=>t&&t.get(e)||(s=((t,e,s,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let l of o(e))r.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:()=>M});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},S={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,e){const n=e(t);let 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 o=1-t;let r=e;if(0===i)return e[0].t=t,e[0];if(1===i){const e={x:o*r[0].x+t*r[1].x,y:o*r[0].y+t*r[1].y,t};return n&&(e.z=o*r[0].z+t*r[1].z),e}if(i<4){let e,s,a,l=o*o,c=t*t,d=0;2===i?(r=[r[0],r[1],r[2],w],e=l,s=o*t*2,a=c):3===i&&(e=l*o,s=l*t*3,a=o*c*3,d=t*c);const u={x:e*r[0].x+s*r[1].x+a*r[2].x+d*r[3].x,y:e*r[0].y+s*r[1].y+a*r[2].y+d*r[3].y,t};return n&&(u.z=e*r[0].z+s*r[1].z+a*r[2].z+d*r[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 o=1-t,r=n,s=e;let a,l=r[0],c=r[1],d=r[2],u=r[3];return l*=o,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*=o,c*=2*o,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*=o,c*=1.5*o,d*=3*o,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,o=i.length,r=o-1;o>1;o--,r--){const t=[];for(let n,o=0;o<r;o++)n={x:r*(i[o+1].x-i[o].x),y:r*(i[o+1].y-i[o].y)},e&&(n.z=r*(i[o+1].z-i[o].z)),t.push(n);n.push(t),i=t}return n},between:function(t,e,n){return e<=t&&t<=n||S.approximately(t,e)||S.approximately(t,n)},approximately:function(t,e,n){return l(t-e)<=(n||1e-6)},length:function(t){const e=S.Tvalues.length;let n=0;for(let i,o=0;o<e;o++)i=.5*S.Tvalues[o]+.5,n+=S.Cvalues[o]*S.arcfn(i,t);return.5*n},map:function(t,e,n,i,o){return i+(o-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(S.pointToString).join(", ")+"]"},copy:function(t){return JSON.parse(JSON.stringify(t))},angle:function(t,e,n){const i=e.x-t.x,o=e.y-t.y,r=n.x-t.x,s=n.y-t.y;return h(i*s-o*r,i*r+o*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,o=f(2,63);return t.forEach((function(t,r){i=S.dist(e,t),i<o&&(o=i,n=r)})),{mdist:o,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,o,r,s,a){const l=(t-n)*(r-a)-(e-i)*(o-s);return 0!=l&&{x:((t*i-e*n)*(o-s)-(t-n)*(o*a-r*s))/l,y:((t*i-e*n)*(r-a)-(e-i)*(o*a-r*s))/l}},lli4:function(t,e,n,i){const o=t.x,r=t.y,s=e.x,a=e.y,l=n.x,c=n.y,d=i.x,u=i.y;return S.lli8(o,r,s,a,l,c,d,u)},lli:function(t,e){return S.lli4(t,t.c,e,e.c)},makeline:function(t,e){return new M(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,o=x;return t.forEach((function(t){const r=t.bbox();e>r.x.min&&(e=r.x.min),n>r.y.min&&(n=r.y.min),i<r.x.max&&(i=r.x.max),o<r.y.max&&(o=r.y.max)})),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:n,mid:(n+o)/2,max:o,size:o-n}}},shapeintersections:function(t,e,n,i,o){if(!S.bboxoverlap(e,i))return[];const r=[],s=[t.startcap,t.forward,t.back,t.endcap],a=[n.startcap,n.forward,n.back,n.endcap];return s.forEach((function(e){e.virtual||a.forEach((function(i){if(i.virtual)return;const s=e.intersects(i,o);s.length>0&&(s.c1=e,s.c2=i,s.s1=t,s.s2=n,r.push(s))}))})),r},makeshape:function(t,e,n){const i=e.points.length,o=t.points.length,r=S.makeline(e.points[i-1],t.points[0]),s=S.makeline(t.points[o-1],e.points[0]),a={startcap:r,forward:t,back:e,endcap:s,bbox:S.findbbox([r,t,e,s]),intersections:function(t){return S.shapeintersections(a,a.bbox,t,t.bbox,n)}};return a},getminmax:function(t,e,n){if(!n)return{min:0,max:0};let i,o,r=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],o=t.get(i),o[e]<r&&(r=o[e]),o[e]>s&&(s=o[e]);return{min:r,mid:(r+s)/2,max:s,size:s-r}},align:function(t,e){const n=e.p1.x,i=e.p1.y,o=-h(e.p2.y-i,e.p2.x-n);return t.map((function(t){return{x:(t.x-n)*c(o)-(t.y-i)*d(o),y:(t.x-n)*d(o)+(t.y-i)*c(o)}}))},roots:function(t,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=t.length-1,i=S.align(t,e),o=function(t){return 0<=t&&t<=1};if(2===n){const t=i[0].y,e=i[1].y,n=i[2].y,r=t-2*e+n;if(0!==r){const i=-p(e*e-t*n),s=-t+e;return[-(i+s)/r,-(-i+s)/r].filter(o)}return e!==n&&0===r?[(2*e-n)/(2*e-2*n)].filter(o):[]}const r=i[0].y,s=i[1].y,a=i[2].y;let l=3*s-r-3*a+i[3].y,d=3*r-6*s+3*a,h=-3*r+3*s,f=r;if(S.approximately(l,0)){if(S.approximately(d,0))return S.approximately(h,0)?[]:[-f/h].filter(o);const t=p(h*h-4*d*f),e=2*d;return[(t-h)/e,(-h-t)/e].filter(o)}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 T,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),r=2*m(e);return P=r*c(i/3)-d/3,k=r*c((i+v)/3)-d/3,E=r*c((i+2*v)/3)-d/3,[P,k,E].filter(o)}if(0===w)return T=x<0?m(-x):-m(x),P=2*T-d/3,k=-T-d/3,[P,k].filter(o);{const t=p(w);return T=m(-x+t),C=m(x+t),[T-C-d/3].filter(o)}},droots:function(t){if(3===t.length){const e=t[0],n=t[1],i=t[2],o=e-2*n+i;if(0!==o){const t=-p(n*n-e*i),r=-e+n;return[-(t+r)/o,-(-t+r)/o]}return n!==i&&0===o?[(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,o){let r,s,a,c,d=0,u=0;const h=S.compute(t,e),m=S.compute(t,n),g=h.x*h.x+h.y*h.y;if(i?(r=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)):(r=h.x*m.y-h.y*m.x,s=f(g,1.5)),0===r||0===s)return{k:0,r:0};if(d=r/s,u=s/r,!o){const o=S.curvature(t-.001,e,n,i,!0).k,r=S.curvature(t+.001,e,n,i,!0).k;c=(r-d+(d-o))/2,a=(l(r-d)+l(d-o))/2}return{k:d,r:u,dk:c,adk:a}},inflections:function(t){if(t.length<4)return[];const e=S.align(t,{p1:t[0],p2:t.slice(-1)[0]}),n=e[2].x*e[1].y,i=e[3].x*e[1].y,o=e[1].x*e[2].y,r=18*(-3*n+2*i+3*o-e[3].x*e[2].y),s=18*(3*n-i-3*o),a=18*(o-n);if(S.approximately(r,0)){if(!S.approximately(s,0)){let t=-a/s;if(0<=t&&t<=1)return[t]}return[]}const l=2*r;if(S.approximately(l,0))return[];const c=s*s-4*r*a;if(c<0)return[];const d=Math.sqrt(c);return[(d-s)/l,-(s+d)/l].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,e){const n=["x","y"],i=n.length;for(let o,r,s,a,c=0;c<i;c++)if(o=n[c],r=t[o].mid,s=e[o].mid,a=(t[o].size+e[o].size)/2,l(r-s)>=a)return!1;return!0},expandbox:function(t,e){e.x.min<t.x.min&&(t.x.min=e.x.min),e.y.min<t.y.min&&(t.y.min=e.y.min),e.z&&e.z.min<t.z.min&&(t.z.min=e.z.min),e.x.max>t.x.max&&(t.x.max=e.x.max),e.y.max>t.y.max&&(t.y.max=e.y.max),e.z&&e.z.max>t.z.max&&(t.z.max=e.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,e,n){const i=t.bbox(),o=e.bbox(),r=1e5,s=n||.5;if(i.x.size+i.y.size<s&&o.x.size+o.y.size<s)return[(r*(t._t1+t._t2)/2|0)/r+"/"+(r*(e._t1+e._t2)/2|0)/r];let a=t.split(.5),l=e.split(.5),c=[{left:a.left,right:l.left},{left:a.left,right:l.right},{left:a.right,right:l.right},{left:a.right,right:l.left}];c=c.filter((function(t){return S.bboxoverlap(t.left.bbox(),t.right.bbox())}));let d=[];return 0===c.length||(c.forEach((function(t){d=d.concat(S.pairiteration(t.left,t.right,s))})),d=d.filter((function(t,e){return d.indexOf(t)===e}))),d},getccenter:function(t,e,n){const i=e.x-t.x,o=e.y-t.y,r=n.x-e.x,s=n.y-e.y,a=i*c(y)-o*d(y),l=i*d(y)+o*c(y),u=r*c(y)-s*d(y),p=r*d(y)+s*c(y),f=(t.x+e.x)/2,m=(t.y+e.y)/2,g=(e.x+n.x)/2,b=(e.y+n.y)/2,x=f+a,w=m+l,T=g+u,C=b+p,P=S.lli8(f,m,x,w,g,b,T,C),k=S.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}},T=class{constructor(t){this.curves=[],this._3d=!1,t&&(this.curves=t,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map((function(t){return S.pointsToString(t.points)})).join(", ")+"]"}addCurve(t){this.curves.push(t),this._3d=this._3d||t._3d}length(){return this.curves.map((function(t){return t.length()})).reduce((function(t,e){return t+e}))}curve(t){return this.curves[t]}bbox(){const t=this.curves;for(var e=t[0].bbox(),n=1;n<t.length;n++)S.expandbox(e,t[n].bbox());return e}offset(t){const e=[];return this.curves.forEach((function(n){e.push(...n.offset(t))})),new T(e)}},{abs:C,min:P,max:k,cos:E,sin:z,acos:_,sqrt:O}=Math,I=Math.PI,M=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 o=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!==o&&8!==o&&9!==o&&12!==o&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const r=this._3d=!i&&(9===o||12===o)||t&&t[0]&&void 0!==t[0].z,s=this.points=[];for(let t=0,n=r?3:2;t<o;t+=n){var a={x:e[t],y:e[t+1]};r&&(a.z=e[t+2]),s.push(a)}const l=this.order=s.length-1,c=this.dims=["x","y"];r&&c.push("z"),this.dimlen=c.length;const d=S.align(s,{p1:s[0],p2:s[l]}),u=S.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 M(e,e,n);if(1===i)return new M(t,e,e);const o=M.getABC(2,t,e,n,i);return new M(t,o.A,n)}static cubicFromPoints(t,e,n,i,o){void 0===i&&(i=.5);const r=M.getABC(3,t,e,n,i);void 0===o&&(o=S.dist(e,r.C));const s=o*(1-i)/i,a=S.dist(t,n),l=(n.x-t.x)/a,c=(n.y-t.y)/a,d=o*l,u=o*c,h=s*l,p=s*c,f=e.x-d,m=e.y-u,g=e.x+h,v=e.y+p,y=r.A,b=y.x+(f-y.x)/(1-i),x=y.y+(m-y.y)/(1-i),w=y.x+(g-y.x)/i,T=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+(T-n.y)/(1-i)};return new M(t,C,P,n)}static getUtils(){return S}getUtils(){return M.getUtils()}static get PolyBezier(){return T}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const t=this.points,e=["M",t[0].x,t[0].y,2===this.order?"Q":"C"];for(let n=1,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=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const t=this.points,e=S.angle(t[0],t[this.order],t[1]);this.clockwise=e>0}length(){return S.length(this.derivative.bind(this))}static getABC(t=2,e,n,i,o=.5){const r=S.projectionratio(o,t),s=1-r,a={x:r*e.x+s*i.x,y:r*e.y+s*i.y},l=S.abcratio(o,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 M.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(),o=[];for(let t,r=0,s=0;r<i.length;r++)t=i[r],S.dist(t,e)<n&&(o.push(t),s+=r/i.length);return!!o.length&&(t/=o.length)}project(t){const e=this.getLUT(),n=e.length-1,i=S.closest(e,t),o=i.mpos,r=(o-1)/n,s=(o+1)/n,a=.1/n;let l,c=i.mdist,d=r,u=d;c+=1;for(let e;d<s+a;d+=a)l=this.compute(d),e=S.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?S.computeWithRatios(t,this.points,this.ratios,this._3d):S.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,e=[t[0]],n=t.length;for(let i,o,r=1;r<n;r++)i=t[r],o=t[r-1],e[r]={x:(n-r)/n*i.x+r/n*o.x,y:(n-r)/n*i.y+r/n*o.y};return e[n]=t[n-1],new M(e)}derivative(t){return S.compute(t,this.dpoints[0],this._3d)}dderivative(t){return S.compute(t,this.dpoints[1],this._3d)}align(){let t=this.points;return new M(S.align(t,{p1:t[0],p2:t[t.length-1]}))}curvature(t){return S.curvature(t,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(t){return this._3d?this.__normal3(t):this.__normal2(t)}__normal2(t){const e=this.derivative(t),n=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),o=O(n.x*n.x+n.y*n.y+n.z*n.z);e.x/=i,e.y/=i,e.z/=i,n.x/=o,n.y/=o,n.z/=o;const r={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},s=O(r.x*r.x+r.y*r.y+r.z*r.z);r.x/=s,r.y/=s,r.z/=s;const a=[r.x*r.x,r.x*r.y-r.z,r.x*r.z+r.y,r.x*r.y+r.z,r.y*r.y,r.y*r.z-r.x,r.x*r.z-r.y,r.y*r.z+r.x,r.z*r.z];return{t,x:a[0]*e.x+a[1]*e.y+a[2]*e.z,y:a[3]*e.x+a[4]*e.y+a[5]*e.z,z:a[6]*e.x+a[7]*e.y+a[8]*e.z}}hull(t){let e=this.points,n=[],i=[],o=0;for(i[o++]=e[0],i[o++]=e[1],i[o++]=e[2],3===this.order&&(i[o++]=e[3]);e.length>1;){n=[];for(let r,s=0,a=e.length-1;s<a;s++)r=S.lerp(t,e[s],e[s+1]),i[o++]=r,n.push(r);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 M([n[0],n[3],n[5]]):new M([n[0],n[4],n[7],n[9]]),right:2===this.order?new M([n[5],n[4],n[2]]):new M([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=S.map(0,0,1,this._t1,this._t2),i.left._t2=S.map(t,0,1,this._t1,this._t2),i.right._t1=S.map(t,0,1,this._t1,this._t2),i.right._t2=S.map(1,0,1,this._t1,this._t2),e?(e=S.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]},o=this.dpoints[0].map(i);t[n]=S.droots(o),3===this.order&&(o=this.dpoints[1].map(i),t[n]=t[n].concat(S.droots(o))),t[n]=t[n].filter((function(t){return t>=0&&t<=1})),e=e.concat(t[n].sort(S.numberSort))}.bind(this)),t.values=e.sort(S.numberSort).filter((function(t,n){return e.indexOf(t)===n})),t}bbox(){const t=this.extrema(),e={};return this.dims.forEach(function(n){e[n]=S.getminmax(this,n,t[n])}.bind(this)),e}overlaps(t){const e=this.bbox(),n=t.bbox();return S.bboxoverlap(e,n)}offset(t,e){if(void 0!==e){const n=this.get(t),i=this.normal(t),o={c:n,n:i,x:n.x+i.x*e,y:n.y+i.y*e};return this._3d&&(o.z=n.z+i.z*e),o}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 M(n)]}return this.reduce().map((function(e){return e._linear?e.offset(t)[0]:e.scale(t)}))}simple(){if(3===this.order){const t=S.angle(this.points[0],this.points[3],this.points[1]),e=S.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&e<0||t<0&&e>0)return!1}const t=this.normal(0),e=this.normal(1);let n=t.x*e.x+t.y*e.y;return this._3d&&(n+=t.z*e.z),C(_(n))<I/3}reduce(){let t,e,n=0,i=0,o=.01,r=[],s=[],a=this.extrema().values;for(-1===a.indexOf(0)&&(a=[0].concat(a)),-1===a.indexOf(1)&&a.push(1),n=a[0],t=1;t<a.length;t++)i=a[t],e=this.split(n,i),e._t1=n,e._t2=i,r.push(e),n=i;return r.forEach((function(t){for(n=0,i=0;i<=1;)for(i=n+o;i<=1.01;i+=o)if(e=t.split(n,i),!e.simple()){if(i-=o,C(n-i)<o)return[];e=t.split(n,i),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=S.map(i,0,1,t._t1,t._t2),s.push(e),n=i;break}n<1&&(e=t.split(n,1),e._t1=S.map(n,0,1,t._t1,t._t2),e._t2=t._t2,s.push(e))})),s}translate(t,e,n){n="number"==typeof n?n:e;const i=this.order;let o=this.points.map(((t,o)=>(1-o/i)*e+o/i*n));return new M(this.points.map(((e,n)=>({x:e.x+t.x*o[n],y:e.y+t.y*o[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,o=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):t,n?n(1):t);const r=n?n(0):t,s=n?n(1):t,a=[this.offset(0,10),this.offset(1,10)],l=[],c=S.lli4(a[0],a[0].c,a[1],a[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach((function(t){const n=l[t*e]=S.copy(o[t*e]);n.x+=(t?s:r)*a[t].n.x,n.y+=(t?s:r)*a[t].n.y})),n?([0,1].forEach((function(r){if(2!==e||!r){var s=o[r+1],a={x:s.x-c.x,y:s.y-c.y},d=n?n((r+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[r+1]={x:s.x+d*a.x,y:s.y+d*a.y}}})),new M(l)):([0,1].forEach((t=>{if(2===e&&t)return;const n=l[t*e],i=this.derivative(t),r={x:n.x+i.x,y:n.y+i.y};l[t+1]=S.lli4(n,r,c,o[t+1])})),new M(l))}outline(t,e,n,i){if(e=void 0===e?t:e,this._linear){const o=this.normal(0),r=this.points[0],s=this.points[this.points.length-1];let a,l,c;void 0===n&&(n=t,i=e),a={x:r.x+o.x*t,y:r.y+o.y*t},c={x:s.x+o.x*n,y:s.y+o.y*n},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const d=[a,l,c];a={x:r.x-o.x*e,y:r.y-o.y*e},c={x:s.x-o.x*i,y:s.y-o.y*i},l={x:(a.x+c.x)/2,y:(a.y+c.y)/2};const u=[c,l,a],h=S.makeline(u[2],d[0]),p=S.makeline(d[2],u[0]),f=[h,new M(d),p,new M(u)];return new T(f)}const o=this.reduce(),r=o.length,s=[];let a,l=[],c=0,d=this.length();const u=void 0!==n&&void 0!==i;function h(t,e,n,i,o){return function(r){const s=i/n,a=(i+o)/n,l=e-t;return S.map(r,0,1,t+s*l,t+a*l)}}o.forEach((function(o){const r=o.length();u?(s.push(o.scale(h(t,n,d,c,r))),l.push(o.scale(h(-e,-i,d,c,r)))):(s.push(o.scale(t)),l.push(o.scale(-e))),c+=r})),l=l.map((function(t){return a=t.points,a[3]?t.points=[a[3],a[2],a[1],a[0]]:t.points=[a[2],a[1],a[0]],t})).reverse();const p=s[0].points[0],f=s[r-1].points[s[r-1].points.length-1],m=l[r-1].points[l[r-1].points.length-1],g=l[0].points[0],v=S.makeline(m,p),y=S.makeline(f,g),b=[v].concat(s).concat([y]).concat(l);return new T(b)}outlineshapes(t,e,n){e=e||t;const i=this.outline(t,e).curves,o=[];for(let t=1,e=i.length;t<e/2;t++){const r=S.makeshape(i[t],i[e-t],n);r.startcap.virtual=t>1,r.endcap.virtual=t<e/2-1,o.push(r)}return o}intersects(t,e){return t?t.p1&&t.p2?this.lineIntersects(t):(t instanceof M&&(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),o=k(t.p1.y,t.p2.y);return S.roots(this.points,t).filter((t=>{var r=this.get(t);return S.between(r.x,e,i)&&S.between(r.y,n,o)}))}selfintersects(t){const e=this.reduce(),n=e.length-2,i=[];for(let o,r,s,a=0;a<n;a++)r=e.slice(a,a+1),s=e.slice(a+2),o=this.curveintersects(r,s,t),i.push(...o);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 o=[];return i.forEach((function(t){const e=S.pairiteration(t.left,t.right,n);e.length>0&&(o=o.concat(e))})),o}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,e,n,i){const o=(i-n)/4,r=this.get(n+o),s=this.get(i-o),a=S.dist(t,e),l=S.dist(t,r),c=S.dist(t,s);return C(l-a)+C(c-a)}_iterate(t,e){let n,i=0,o=1;do{n=0,o=1;let r,s,a,l,c,d=this.get(i),u=!1,h=!1,p=o,f=1,m=0;do{if(h=u,l=a,p=(i+o)/2,m++,r=this.get(p),s=this.get(o),a=S.getccenter(d,r,s),a.interval={start:i,end:o},u=this._error(a,d,i,o)<=t,c=h&&!u,c||(f=o),u){if(o>=1){if(a.interval.end=f=1,l=a,o>1){let t={x:a.x+a.r*E(a.e),y:a.y+a.r*z(a.e)};a.e+=S.angle({x:a.x,y:a.y},t,this.get(1))}break}o+=(o-i)/2}else o=p}while(!c&&n++<100);if(n>=100)break;l=l||a,e.push(l),i=f}while(o<1);return e}};e.exports=s(a)}},n={};function i(t){var o=n[t];if(void 0!==o)return o.exports;var r=n[t]={id:t,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.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 o=i(7783);window.jsdraw=o})();
|