kritzel-stencil 0.0.151 → 0.0.153

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.
Files changed (44) hide show
  1. package/dist/cjs/{default-text-tool.config-BX6sjin6.js → default-text-tool.config-Cds94FE8.js} +18 -3
  2. package/dist/cjs/default-text-tool.config-Cds94FE8.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/kritzel-color_22.cjs.entry.js +26 -21
  5. package/dist/collection/classes/core/viewport.class.js +10 -9
  6. package/dist/collection/classes/core/viewport.class.js.map +1 -1
  7. package/dist/collection/classes/objects/base-object.class.js +6 -0
  8. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  9. package/dist/collection/classes/objects/path.class.js +10 -1
  10. package/dist/collection/classes/objects/path.class.js.map +1 -1
  11. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +15 -10
  12. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  13. package/dist/collection/configs/default-engine-config.js +0 -1
  14. package/dist/collection/configs/default-engine-config.js.map +1 -1
  15. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  16. package/dist/components/index.js +3 -3
  17. package/dist/components/kritzel-controls.js +1 -1
  18. package/dist/components/kritzel-editor.js +3 -3
  19. package/dist/components/kritzel-engine.js +1 -1
  20. package/dist/components/{p-D6oQxYXs.js → p-BDvBsqPy.js} +28 -23
  21. package/dist/components/p-BDvBsqPy.js.map +1 -0
  22. package/dist/components/{p-G2HGJcNm.js → p-BJ-T4laL.js} +18 -3
  23. package/dist/components/{p-G2HGJcNm.js.map → p-BJ-T4laL.js.map} +1 -1
  24. package/dist/components/{p-BP71Fape.js → p-CcqEzr-v.js} +3 -3
  25. package/dist/components/{p-BP71Fape.js.map → p-CcqEzr-v.js.map} +1 -1
  26. package/dist/esm/{default-text-tool.config-Bcel-KfG.js → default-text-tool.config-ClW1W-X4.js} +18 -3
  27. package/dist/esm/default-text-tool.config-ClW1W-X4.js.map +1 -0
  28. package/dist/esm/index.js +2 -2
  29. package/dist/esm/kritzel-color_22.entry.js +26 -21
  30. package/dist/stencil/index.esm.js +1 -1
  31. package/dist/stencil/{p-7d732b05.entry.js → p-843d013b.entry.js} +3 -3
  32. package/dist/stencil/{p-7d732b05.entry.js.map → p-843d013b.entry.js.map} +1 -1
  33. package/dist/stencil/{p-Bcel-KfG.js → p-ClW1W-X4.js} +2 -2
  34. package/dist/stencil/p-ClW1W-X4.js.map +1 -0
  35. package/dist/stencil/stencil.esm.js +1 -1
  36. package/dist/types/classes/core/viewport.class.d.ts +1 -0
  37. package/dist/types/classes/objects/path.class.d.ts +1 -0
  38. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +1 -0
  39. package/dist/types/interfaces/engine-state.interface.d.ts +0 -1
  40. package/package.json +1 -1
  41. package/dist/cjs/default-text-tool.config-BX6sjin6.js.map +0 -1
  42. package/dist/components/p-D6oQxYXs.js.map +0 -1
  43. package/dist/esm/default-text-tool.config-Bcel-KfG.js.map +0 -1
  44. package/dist/stencil/p-Bcel-KfG.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{r as t,h as e,H as i,c as n,g as r}from"./p-SGde3HXB.js";import{T as o,G as s,L as a,U as c,M as l,R as u,I as h,S as f,J as d,Q as v,V as p,W as b,X as g,Y as k,Z as y,_ as w,F as m,K as x,E as z,$ as C,a0 as M,a1 as j,P as I,a2 as S,a3 as _,a4 as T}from"./p-Bcel-KfG.js";var A=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};const $=":host{display:flex}.checkerboard-bg{background:repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;position:relative;overflow:hidden}.color-circle{width:24px;height:24px;border-radius:50%;box-sizing:border-box;display:block}.color-circle.white{border:1px solid var(--kritzel-color-palette-circle-border-color, #dddcdc)}";const E=class{constructor(e){t(this,e)}value;size=24;isLightColor(t){if(!t)return false;let e=0,i=0,n=0;let r=t.startsWith("#")?t.slice(1):t;if(r.length===3){e=parseInt(r[0]+r[0],16);i=parseInt(r[1]+r[1],16);n=parseInt(r[2]+r[2],16)}else if(r.length===6){e=parseInt(r.substring(0,2),16);i=parseInt(r.substring(2,4),16);n=parseInt(r.substring(4,6),16)}else{return false}if(isNaN(e)||isNaN(i)||isNaN(n)){return false}const o=.299*e+.587*i+.114*n;return o>220}render(){const t=this.isLightColor(this.value);return e(i,{key:"000e54c604c8ceca2c44365e95ec1f5bfb1b729a"},e("div",{key:"77b2abeae70e4a80714e1364eb4e11e67f16d066",class:"checkerboard-bg",style:{width:`${this.size}px`,height:`${this.size}px`,borderRadius:"50%",display:"inline-block",position:"relative"}},e("div",{key:"df71720cf51d845a36598499adb900a30770c503",class:{"color-circle":true,white:t},style:{backgroundColor:this.value,width:`${this.size}px`,height:`${this.size}px`,borderRadius:"50%",position:"absolute",top:"0",left:"0",display:"inline-block"}})))}};E.style=$;const O=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;width:100%;box-sizing:border-box}.color-grid{width:100%;display:grid;grid-template-columns:repeat(6, 32px);gap:8px;justify-items:center;overflow:hidden;height:40px;transition:height 0.1s ease-in-out}.color-grid.expanded{height:500px}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.color-container:focus-visible{outline:var(--kritzel-color-palette-focus-outline, 2px auto #e3e3e3)}.color-container:hover{background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.color-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-color-palette-selected-background-color)}";const R=class{constructor(e){t(this,e);this.colorChange=n(this,"colorChange")}colors=[];selectedColor=null;isExpanded=false;isOpaque=false;colorChange;handleColorClick(t){this.selectedColor=t;this.colorChange.emit(t)}calculateHeight(){const t=6;const e=32;const i=8;const n=Math.ceil(this.colors.length/t);return`${n*e+(n-1)*i}px`}render(){const t=this.isExpanded?this.colors:this.colors.slice(0,6);const n=this.isExpanded?this.calculateHeight():"32px";return e(i,{key:"d533725a8ab2019ae963959727283fbbf833c56a"},e("div",{key:"7fb50c16d79e9b7330100b0f4e116f8f07b20827",class:{"color-grid":true,expanded:this.isExpanded},style:{height:n}},t.map((t=>e("div",{tabIndex:0,class:{"color-container":true,selected:this.selectedColor===t},onClick:()=>this.handleColorClick(t)},e("kritzel-color",{value:t}))))))}};R.style=O;const W=":host{display:block}.menu-container{display:flex;flex-direction:column;background-color:var(--kritzel-context-menu-background-color, #ffffff);border-radius:var(--kritzel-context-menu-border-radius, 12px);box-shadow:var(--kritzel-context-menu-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12));border:var(--kritzel-context-menu-border, 1px solid #ebebeb);padding:var(--kritzel-context-menu-padding,4px)}.menu-item{display:flex;align-items:center;gap:var(--kritzel-context-menu-item-gap, 8px);background:none;border:none;text-align:left;padding:var(--kritzel-context-menu-item-padding, 8px);border-radius:var(--kritzel-context-menu-item-border-radius, 12px);cursor:pointer;font-size:var(--kritzel-context-menu-item-font-size, 14px);color:var(--kritzel-context-menu-item-color, #333333);white-space:nowrap;-webkit-tap-highlight-color:transparent}.menu-item:not(.disabled):hover{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item:not(.disabled):active{background-color:var(--kritzel-context-menu-item-active-background-color, hsl(0, 0%, 0%, 8.6%))}.menu-item.disabled{color:var(--kritzel-context-menu-item-disabled-color, #aaaaaa);cursor:default}.menu-item kritzel-icon{opacity:0.8;flex-shrink:0}.menu-item.disabled kritzel-icon{opacity:0.4}.label{flex-grow:1}";const F=class{constructor(e){t(this,e);this.actionSelected=n(this,"actionSelected");this.close=n(this,"close")}get host(){return r(this)}items;onItemsChanged(){this.updateMenuItems()}objects;actionSelected;close;processedItems=[];handleOutsideClick(t){const e=t.composedPath();if(!e.includes(this.host)){this.close.emit()}}componentWillLoad(){this.updateMenuItems()}handleItemClick(t,e){if(!e){this.actionSelected.emit(t)}}async updateMenuItems(){const t=[];for(const e of this.items){const i=await this.evaluateProperty(e.visible,true);if(i){const i=await this.evaluateProperty(e.disabled,false);t.push({item:e,isDisabled:i})}}this.processedItems=t}async evaluateProperty(t,e){if(typeof t==="boolean"){return t}if(typeof t==="function"){return await Promise.resolve(t(null,this.objects))}return e}render(){return e(i,{key:"45b9652285f9c3fe7568cbe222667d23c151622f"},e("div",{key:"9aecc01027f297fa4d991780efaaf51b8d4542dc",class:"menu-container"},this.processedItems.map((({item:t,isDisabled:i},n)=>e("button",{key:`${t.label}-${n}`,class:{"menu-item":true,disabled:i},onClick:()=>this.handleItemClick(t,i),disabled:i},t.icon&&e("kritzel-icon",{name:t.icon,size:16}),e("span",{class:"label"},t.label))))))}static get watchers(){return{items:["onItemsChanged"]}}};F.style=W;const D=":host{display:flex;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:focus-visible{outline:var(--kritzel-color-palette-focus-outline, 2px auto #e3e3e3)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";const B=class{constructor(e){t(this,e);this.toolChange=n(this,"toolChange")}tool;handleToolChange(t){this.palette=t.palettes[t.type]}isExpanded=false;toolChange;palette=[];componentWillLoad(){this.palette=this.tool.palettes[this.tool.type]}handleToggleExpand(){this.isExpanded=!this.isExpanded}handleTypeChange(t){this.palette=this.tool.palettes[t.detail];this.tool.type=t.detail;this.tool.color=this.palette[0];this.toolChange.emit(this.tool)}handleColorChange(t){this.tool.color=t.detail;this.toolChange.emit(this.tool)}handleSizeChange(t){this.tool.size=t.detail;this.toolChange.emit(this.tool)}render(){return e(i,{key:"4b060826312e6d5a2117f5ba9522553af9b02d6f"},e("div",{key:"0975a250184d5bb2d38cc60263bd718157230d8c",style:{display:"flex",flexDirection:"row",alignItems:this.isExpanded?"flex-start":"center",justifyContent:"flex-start",width:"100%",gap:"8px"}},e("kritzel-color-palette",{key:"df84a6fdda01bc7bf3aff42e3b88c4bd9dca500f",colors:this.palette,selectedColor:this.tool.color,isExpanded:this.isExpanded,isOpaque:true,onColorChange:t=>this.handleColorChange(t)}),e("button",{key:"e43c19612807fc4f9cd1bf04f4fb79a048cfd62b",class:"expand-toggle",onClick:()=>this.handleToggleExpand(),title:this.isExpanded?"Collapse":"Expand",style:this.palette.length>6?{visibillity:"visible"}:{visibility:"hidden"}},e("kritzel-icon",{key:"915cce6c4744ad175f3836c946330882de840880",name:this.isExpanded?"chevron-up":"chevron-down"}))),e("kritzel-stroke-size",{key:"c07eebae3ba1785e2644c6b5a22d23f76be950fb",selectedSize:this.tool.size,onSizeChange:t=>this.handleSizeChange(t)}))}static get watchers(){return{tool:["handleToolChange"]}}};B.style=D;const P=":host{display:block;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";const L=class{constructor(e){t(this,e);this.toolChange=n(this,"toolChange")}tool;isExpanded=false;toolChange;handleToggleExpand(){this.isExpanded=!this.isExpanded}handleFamilyChange(t){this.tool.fontFamily=t.detail;this.toolChange.emit(this.tool)}handleColorChange(t){this.tool.fontColor=t.detail;this.toolChange.emit(this.tool)}handleSizeChange(t){this.tool.fontSize=t.detail;this.toolChange.emit(this.tool)}render(){return e(i,{key:"82e611092700f057bd36823e7f7503fe7a0423ed"},e("div",{key:"37ed39adeeeb58981a917918cd185e96d589e973",style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",width:"100%",gap:"8px"}},e("kritzel-font-family",{key:"cd8afc5c4a1eee087610cd3d5a6c05210cfda6b3",selectedFontFamily:this.tool.fontFamily,onFontFamilyChange:t=>this.handleFamilyChange(t)}),e("button",{key:"085f1bba060bde27a7b64dc5477bb51305b76235",class:"expand-toggle",onClick:()=>this.handleToggleExpand(),title:this.isExpanded?"Collapse":"Expand"},e("kritzel-icon",{key:"3ff8fec207120e67f43315c6dace72fc2f6bd0f1",name:this.isExpanded?"chevron-up":"chevron-down"}))),e("kritzel-color-palette",{key:"2e29d01a6b5c0e4a8ec347e63b6a2698c282db40",colors:this.tool.palette,selectedColor:this.tool.fontColor,isExpanded:this.isExpanded,onColorChange:t=>this.handleColorChange(t)}),e("kritzel-font-size",{key:"c972068f1251d66e756b8de72fbdd1b6002d1daa",selectedSize:this.tool.fontSize,fontFamily:this.tool.fontFamily,onSizeChange:t=>this.handleSizeChange(t)}))}};L.style=P;const V=":host{display:flex;flex-direction:column;user-select:none}:host(.mobile){--kritzel-controls-control-hover-background-color:transparent;--kritzel-controls-control-active-background-color:transparent}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 16px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid #ebebeb);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 12px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:focus,.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #007AFF) !important;color:var(--kritzel-controls-control-selected-color, #ffffff) !important}.kritzel-control.selected:focus{background-color:var(--kritzel-controls-control-selected-background-color, #007bffe3) !important}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer;border-radius:50%}.kritzel-config:focus{outline:var(--kritzel-menu-focus-outline, 2px solid #e3e3e3)}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:56px;left:50%;transform:translateX(-50%);z-index:10001}";const U=class{constructor(e){t(this,e);this.isControlsReady=n(this,"isControlsReady")}get host(){return r(this)}controls=[];activeControl=null;isUtilityPanelVisible=true;isControlsReady;firstConfig=null;isTooltipVisible=false;isTouchDevice=o.isTouchDevice();handleDocumentClick(t){const e=t.target;if(!this.kritzelEngine||e.closest(".kritzel-tooltip")){return}this.isTooltipVisible=false}handleKeyDown(t){if(t.key==="Escape"){t.preventDefault();this.closeTooltip();this.kritzelEngine?.enable()}}async handleActiveToolChange(t){this.activeControl=this.controls.find((e=>e.tool===t.detail))||null}async closeTooltip(){this.isTooltipVisible=false}kritzelEngine=null;tooltipRef=null;get activeToolAsTextTool(){return this.activeControl?.tool}get activeToolAsBrushTool(){return this.activeControl?.tool}async componentWillLoad(){await this.initializeEngine();await this.initializeTools();this.isControlsReady.emit()}async initializeEngine(){await customElements.whenDefined("kritzel-engine");this.kritzelEngine=this.host.parentElement.querySelector("kritzel-engine");if(!this.kritzelEngine){throw new Error("kritzel-engine not found in parent element.")}}async initializeTools(){for(const t of this.controls){if(t.type==="tool"&&t.tool){t.tool=await this.kritzelEngine.registerTool(t.name,t.tool,t.config)}if(t.type==="tool"&&t.isDefault&&t.tool){await this.kritzelEngine.changeActiveTool(t.tool);this.activeControl=t}if(t.type==="config"){if(this.firstConfig===null){this.firstConfig=t}else{console.warn("Only one config control is allowed. The first one will be used.")}}}}async handleControlClick(t){this.activeControl=t;if(this.activeControl.type==="tool"){await this.kritzelEngine.changeActiveTool(this.activeControl.tool)}}handleConfigClick(t){t.stopPropagation();this.isTooltipVisible=!this.isTooltipVisible;if(this.isTooltipVisible){this.kritzelEngine?.disable()}else{this.kritzelEngine?.enable()}setTimeout((()=>{this.tooltipRef?.focusContent()}),100)}async handleToolChange(t){this.activeControl={...this.activeControl,tool:t.detail};await this.kritzelEngine.changeActiveTool(this.activeControl.tool)}handleTooltipClosed(){this.isTooltipVisible=false;this.kritzelEngine?.enable()}render(){const t=this.activeControl?.config===undefined||this.activeControl?.config===null;return e(i,{key:"ab3e5f078d6d197c6e10c9dee180c04ef85281bf",class:{mobile:this.isTouchDevice}},this.isUtilityPanelVisible&&e("kritzel-utility-panel",{key:"290ceb6f2c46eb7e869a4741dd6600bc7c47bbb4",style:{position:"absolute",bottom:"56px",left:"12px"},onUndo:()=>this.kritzelEngine?.undo(),onRedo:()=>this.kritzelEngine?.redo(),onDelete:()=>this.kritzelEngine?.delete()}),e("div",{key:"d2590bc56b709e77910e7159296741c8859158d7",class:"kritzel-controls"},this.controls.map((i=>{if(i.type==="tool"){return e("button",{class:{"kritzel-control":true,selected:this.activeControl?.name===i?.name},key:i.name,onClick:t=>this.handleControlClick?.(i)},e("kritzel-icon",{name:i.icon}))}if(i.type==="divider"){return e("div",{class:"kritzel-divider",key:i.name})}if(i.type==="config"&&i.name===this.firstConfig?.name&&this.activeControl){return e("div",{class:"kritzel-config-container",key:i.name},e("kritzel-tooltip",{ref:t=>this.tooltipRef=t,isVisible:this.isTooltipVisible,anchorElement:this.host.shadowRoot?.querySelector(".kritzel-config-container"),onTooltipClosed:()=>this.handleTooltipClosed()},e("div",{style:{width:"294px",height:"100%"}},this.activeControl.name==="brush"&&e("kritzel-control-brush-config",{tool:this.activeToolAsBrushTool,onToolChange:t=>this.handleToolChange?.(t)}),this.activeControl.name==="text"&&e("kritzel-control-text-config",{tool:this.activeToolAsTextTool,onToolChange:t=>this.handleToolChange?.(t)}))),e("div",{tabIndex:0,class:"kritzel-config",onClick:t=>this.handleConfigClick?.(t),onKeyDown:t=>{if(t.key==="Enter"){this.handleConfigClick?.(t)}},style:{cursor:this.activeControl.config?"pointer":"default",pointerEvents:t?"none":"auto"}},this.activeControl.tool instanceof s&&e("div",{class:"color-container"},e("kritzel-color",{value:this.activeToolAsBrushTool?.color,size:this.activeToolAsBrushTool?.size,style:{borderRadius:"50%",border:"none"}})),this.activeControl.tool instanceof a&&e("div",{class:"font-container"},e("kritzel-font",{fontFamily:this.activeToolAsTextTool?.fontFamily,size:this.activeToolAsTextTool?.fontSize,color:this.activeToolAsTextTool?.fontColor})),t&&e("div",{class:"no-config"})))}}))))}static get assetsDirs(){return["../assets"]}};U.style=V;const K=":host{display:block;position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:9000}";const H=class{constructor(e){t(this,e)}core;cursorTrailPoints=[];isLeftButtonDown=false;handleMouseDown(t){if(t.pointerType==="mouse"){if(t.button===c.Left){this.isLeftButtonDown=true;this.cursorTrailPoints=[]}}if(t.pointerType==="touch"){if(this.core.store.state.pointers.size===1){this.isLeftButtonDown=true;this.cursorTrailPoints=[]}}}handlePointerMove(t){if(!this.isLeftButtonDown){return}const e={x:t.clientX,y:t.clientY,timestamp:Date.now()};const i=[e,...this.cursorTrailPoints];if(i.length>this.MAX_TRAIL_POINTS){this.cursorTrailPoints=i.slice(0,this.MAX_TRAIL_POINTS)}else{this.cursorTrailPoints=i}}handlePointerUp(t){if(t.pointerType==="mouse"){if(t.button===c.Left){this.isLeftButtonDown=false;this.cursorTrailPoints=[]}}if(t.pointerType==="touch"){if(this.core.store.state.pointers.size===0){this.isLeftButtonDown=false;this.cursorTrailPoints=[]}}}trailCleanupIntervalId;TRAIL_DURATION_MS=100;MAX_TRAIL_POINTS=50;componentDidLoad(){this.trailCleanupIntervalId=window.setInterval((()=>{const t=Date.now();const e=this.cursorTrailPoints.filter((e=>t-e.timestamp<this.TRAIL_DURATION_MS));if(e.length!==this.cursorTrailPoints.length){this.cursorTrailPoints=e}}),50)}disconnectedCallback(){if(this.trailCleanupIntervalId){window.clearInterval(this.trailCleanupIntervalId)}}render(){return e(i,{key:"10ef620f19d72a8a5c3a12d0d98686bc69308a30"},this.cursorTrailPoints.length>1&&e("svg",{key:"d03403051e53422aaa28d6360aaa9c0391e3ef6a",class:"cursor-trail-svg",xmlns:"http://www.w3.org/2000/svg",style:{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",pointerEvents:"none",opacity:"var(--kritzel-cursor-trail-opacity, 0.6)",zIndex:"9000"}},this.cursorTrailPoints.slice(1).map(((t,i)=>{const n=this.cursorTrailPoints[i];const r=Date.now();const o=r-t.timestamp;const s=Math.max(0,Math.min(1,o/this.TRAIL_DURATION_MS));if(s>=1)return null;const a=Math.max(2,15*(1-s));return e("line",{key:`trail-segment-${t.timestamp}`,x1:n.x.toString(),y1:n.y.toString(),x2:t.x.toString(),y2:t.y.toString(),stroke:"var(--kritzel-cursor-trail-color, rgb(228, 228, 228))","stroke-width":a.toString(),"stroke-linecap":"round"})}))))}};H.style=K;const Y=':host{display:inline-flex;vertical-align:middle;width:100%;}.dropdown-wrapper{display:flex;align-items:center;border:1px solid #333333;border-radius:var(--kritzel-controls-control-border-radius, 12px);overflow:hidden;height:32px;width:100%}.custom-select{padding:0 8px;padding-right:30px;height:100%;width:100%;box-sizing:border-box;border-radius:0;border:none;background-color:#fff;cursor:pointer;outline:none;font-size:inherit;color:var(--kritzel-controls-text-color, #333333);-webkit-tap-highlight-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>\');background-size:16px 16px;background-repeat:no-repeat;background-position:right 8px center}.custom-select.has-suffix-border{border-right:1px solid #333333}.custom-select.has-prefix-border{border-left:1px solid #333333}::slotted(*){height:100%;box-sizing:border-box}';const N=class{constructor(e){t(this,e);this.valueChanged=n(this,"valueChanged")}options=[];optionsChanged(){this.updateInternalValue(this.internalValue,true)}value;externalValueChanged(t){if(t!==this.internalValue){this.updateInternalValue(t,false)}}width;selectStyles={};internalValue;hasSuffixContent=false;hasPrefixContent=false;valueChanged;suffixSlotElement;prefixSlotElement;componentWillLoad(){this.updateInternalValue(this.value,false);this.evaluateSuffixContent();this.evaluatePrefixContent()}updateInternalValue(t,e){let i=t;if(this.options&&this.options.length>0){const t=this.options.some((t=>t.value===i));if(!i||!t){i=this.options[0].value}}else{i=undefined}if(this.internalValue!==i){this.internalValue=i;if(e||t!==i&&t!==undefined){this.valueChanged.emit(this.internalValue)}}}handleSelectChange=t=>{const e=t.target.value;if(this.internalValue!==e){this.internalValue=e;this.valueChanged.emit(this.internalValue)}};evaluateSuffixContent=()=>{if(this.suffixSlotElement){const t=this.suffixSlotElement.assignedNodes({flatten:true}).length>0;if(this.hasSuffixContent!==t){this.hasSuffixContent=t}}else{if(this.hasSuffixContent!==false){this.hasSuffixContent=false}}};evaluatePrefixContent=()=>{if(this.prefixSlotElement){const t=this.prefixSlotElement.assignedNodes({flatten:true}).length>0;if(this.hasPrefixContent!==t){this.hasPrefixContent=t}}else{if(this.hasPrefixContent!==false){this.hasPrefixContent=false}}};render(){const t={"custom-select":true,"has-suffix-border":this.hasSuffixContent,"has-prefix-border":this.hasPrefixContent};return e(i,{key:"f24911715685ced571843ba7be6631248c8519b7"},e("div",{key:"520fdb74afdef8bd5228f76074e51981f44b910d",class:"dropdown-wrapper"},e("slot",{key:"cf6628437946b57ad0b27c066639e0b64b5a28f8",name:"prefix",ref:t=>this.prefixSlotElement=t,onSlotchange:this.evaluatePrefixContent}),e("select",{key:"3203ccd5b9c8b84e8f41bddfcb07786e879f0035",class:t,style:{...this.selectStyles,width:this.width},onInput:this.handleSelectChange},this.options.map((t=>e("option",{value:t.value,style:t.style,selected:t.value===this.internalValue},t.label)))),e("slot",{key:"d0abb52e082db81860c09d2c48b7c065adb406f3",name:"suffix",ref:t=>this.suffixSlotElement=t,onSlotchange:this.evaluateSuffixContent})))}static get watchers(){return{options:["optionsChanged"],value:["externalValueChanged"]}}};N.style=Y;class X{static registry=new Map;static register(t,e){if(this.registry.has(t)){console.warn(`[IconRegistry] Icon "${t}" is already registered. It will be overwritten.`)}this.registry.set(t,e)}static get(t){return this.registry.get(t)}static registerIcons(t){for(const e in t){if(Object.prototype.hasOwnProperty.call(t,e)){this.register(e,t[e])}}}static has(t){return this.registry.has(t)}}X.registerIcons({cursor:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',pen:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',highlighter:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',eraser:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',type:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',image:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',"chevron-down":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',"chevron-up":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',copy:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',paste:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',cut:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',delete:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',"bring-to-front":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',"send-to-back":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',"select-all":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',download:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',undo:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',redo:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>',plus:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus-icon lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>',"ellipsis-vertical":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis-vertical-icon lucide-ellipsis-vertical"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>',x:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>'});const q=1e3;const G=1e-4;const Z="kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-workspace-manager{position:absolute;top:var(--kritzel-editor-workspace-manager-top, 14px);left:var(--kritzel-editor-workspace-manager-left, 14px)}kritzel-controls{position:absolute;bottom:var(--kritzel-editor-controls-bottom, 14px);transition:transform var(--kritzel-editor-controls-transition-duration, 0.1s) var(--kritzel-editor-controls-transition, ease-in-out)}kritzel-controls.keyboard-open{transform:var(--kritzel-editor-controls-transform, translateY(300%))}";const J=class{constructor(e){t(this,e);this.isReady=n(this,"isReady")}get host(){return r(this)}scaleMax=q;scaleMin=G;controls=[{name:"selection",type:"tool",isDefault:true,tool:l,icon:"cursor"},{name:"brush",type:"tool",tool:s,icon:"pen",config:u},{name:"eraser",type:"tool",tool:h,icon:"eraser"},{name:"text",type:"tool",tool:a,icon:"type",config:f},{name:"image",type:"tool",tool:d,icon:"image"},{name:"divider",type:"divider"},{name:"config",type:"config"}];globalContextMenuItems=[{label:"Paste",icon:"paste",disabled:async()=>(await this.engineRef.getCopiedObjects()).length===0,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Select All",icon:"select-all",action:()=>this.selectAllObjectsInViewport()}];objectContextMenuItems=[{label:"Copy",icon:"copy",action:()=>this.engineRef.copy()},{label:"Paste",icon:"paste",disabled:async()=>(await this.engineRef.getCopiedObjects()).length===0,action:(t,e)=>this.engineRef.paste(t.x,t.y)},{label:"Delete",icon:"delete",action:()=>this.engineRef.delete()},{label:"Bring to Front",icon:"bring-to-front",action:()=>this.engineRef.bringToFront()},{label:"Send to Back",icon:"send-to-back",action:()=>this.engineRef.sendToBack()}];customSvgIcons={};isControlsVisible=true;isUtilityPanelVisible=true;syncConfig;isReady;isEngineReady=false;isControlsReady=false;isWorkspaceManagerReady=false;workspaces=[];activeWorkspace;isVirtualKeyboardOpen=false;onIsEngineReady(t){if(t&&this.isControlsReady){this.checkIsReady()}}onIsControlsReady(t){if(t&&this.isEngineReady){this.checkIsReady()}}onWorkspacesChange(t){if(this.activeWorkspace){const e=t.find((t=>t.id===this.activeWorkspace.id));if(e&&e!==this.activeWorkspace){this.activeWorkspace=e}}}handleTouchStart(t){if(t.cancelable){t.preventDefault()}}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async getSelectedObjects(){return this.engineRef.getSelectedObjects()}async selectObjects(t){return this.engineRef.selectObjects(t)}async selectAllObjectsInViewport(){return this.engineRef.selectAllObjectsInViewport()}async clearSelection(){this.engineRef.clearSelection()}async centerObjectInViewport(t){return this.engineRef.centerObjectInViewport(t)}async createWorkspace(t,e){const i=new v(`workspace-${Date.now()}`,t,e);return this.engineRef.createWorkspace(i)}async updateWorkspace(t){return this.engineRef.updateWorkspace(t)}async deleteWorkspace(t){return this.engineRef.deleteWorkspace(t)}async getWorkspaces(){return this.engineRef.getWorkspaces()}async getActiveWorkspace(){return this.engineRef.getActiveWorkspace()}engineRef;controlsRef;splitButtonRef;componentDidLoad(){this.registerCustomSvgIcons();this.listenForMobileKeyboard();this.setOsSpecificCssVariables()}async checkIsReady(){await customElements.whenDefined("kritzel-editor");await customElements.whenDefined("kritzel-workspace-manager");await customElements.whenDefined("kritzel-controls");await customElements.whenDefined("kritzel-engine");if(!this.isEngineReady||!this.isControlsReady||!this.isWorkspaceManagerReady){return}this.isReady.emit(this.host)}onEngineReady(t){this.isEngineReady=true;this.activeWorkspace=t.detail.activeWorkspace;this.workspaces=t.detail.workspaces}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons)){X.register(t,e)}}listenForMobileKeyboard(){p.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){const t=o.detectOS();switch(t){case"iOS":this.host.style.setProperty("--kritzel-editor-workspace-manager-top","14px");this.host.style.setProperty("--kritzel-editor-workspace-manager-left","14px");this.host.style.setProperty("--kritzel-editor-controls-bottom","14px");this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)");this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)");this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;case"Android":this.host.style.setProperty("--kritzel-editor-workspace-manager-top","14px");this.host.style.setProperty("--kritzel-editor-workspace-manager-left","14px");this.host.style.setProperty("--kritzel-editor-controls-bottom","24px");break;default:this.host.style.setProperty("--kritzel-editor-workspace-manager-top","14px");this.host.style.setProperty("--kritzel-editor-workspace-manager-left","14px");this.host.style.setProperty("--kritzel-editor-controls-bottom","14px");break}}render(){return e(i,{key:"97ab11381c7ba448814b6b463a3bd9135e5d328f"},e("kritzel-workspace-manager",{key:"2eb9bb27e0e613537a2ceea4144a7753313d1c78",workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=true}),e("kritzel-engine",{key:"4c3b68eec1c2e2ac879a6fb34edcefcefdf2cea7",ref:t=>this.engineRef=t,workspace:this.activeWorkspace,syncConfig:this.syncConfig,scaleMax:this.scaleMax,scaleMin:this.scaleMin,globalContextMenuItems:this.globalContextMenuItems,objectContextMenuItems:this.objectContextMenuItems,onIsEngineReady:t=>this.onEngineReady(t),onWorkspacesChange:t=>this.workspaces=t.detail}),e("kritzel-controls",{key:"beef7d08c44673a50184722a8201a12bf4635ce8",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>this.controlsRef=t,controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,onIsControlsReady:()=>this.isControlsReady=true}))}static get watchers(){return{isEngineReady:["onIsEngineReady"],isControlsReady:["onIsControlsReady"],workspaces:["onWorkspacesChange"]}}};J.style=Z;var Q={exports:{}};
1
+ import{r as t,h as e,H as i,c as n,g as r}from"./p-SGde3HXB.js";import{T as o,G as s,L as a,U as c,M as l,R as u,I as h,S as f,J as d,Q as v,V as p,W as b,X as g,Y as k,Z as y,_ as w,F as m,K as x,E as z,$ as C,a0 as M,a1 as j,P as I,a2 as S,a3 as _,a4 as T}from"./p-ClW1W-X4.js";var A=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};const E=":host{display:flex}.checkerboard-bg{background:repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;position:relative;overflow:hidden}.color-circle{width:24px;height:24px;border-radius:50%;box-sizing:border-box;display:block}.color-circle.white{border:1px solid var(--kritzel-color-palette-circle-border-color, #dddcdc)}";const $=class{constructor(e){t(this,e)}value;size=24;isLightColor(t){if(!t)return false;let e=0,i=0,n=0;let r=t.startsWith("#")?t.slice(1):t;if(r.length===3){e=parseInt(r[0]+r[0],16);i=parseInt(r[1]+r[1],16);n=parseInt(r[2]+r[2],16)}else if(r.length===6){e=parseInt(r.substring(0,2),16);i=parseInt(r.substring(2,4),16);n=parseInt(r.substring(4,6),16)}else{return false}if(isNaN(e)||isNaN(i)||isNaN(n)){return false}const o=.299*e+.587*i+.114*n;return o>220}render(){const t=this.isLightColor(this.value);return e(i,{key:"000e54c604c8ceca2c44365e95ec1f5bfb1b729a"},e("div",{key:"77b2abeae70e4a80714e1364eb4e11e67f16d066",class:"checkerboard-bg",style:{width:`${this.size}px`,height:`${this.size}px`,borderRadius:"50%",display:"inline-block",position:"relative"}},e("div",{key:"df71720cf51d845a36598499adb900a30770c503",class:{"color-circle":true,white:t},style:{backgroundColor:this.value,width:`${this.size}px`,height:`${this.size}px`,borderRadius:"50%",position:"absolute",top:"0",left:"0",display:"inline-block"}})))}};$.style=E;const O=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;width:100%;box-sizing:border-box}.color-grid{width:100%;display:grid;grid-template-columns:repeat(6, 32px);gap:8px;justify-items:center;overflow:hidden;height:40px;transition:height 0.1s ease-in-out}.color-grid.expanded{height:500px}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.color-container:focus-visible{outline:var(--kritzel-color-palette-focus-outline, 2px auto #e3e3e3)}.color-container:hover{background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.color-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-color-palette-selected-background-color)}";const R=class{constructor(e){t(this,e);this.colorChange=n(this,"colorChange")}colors=[];selectedColor=null;isExpanded=false;isOpaque=false;colorChange;handleColorClick(t){this.selectedColor=t;this.colorChange.emit(t)}calculateHeight(){const t=6;const e=32;const i=8;const n=Math.ceil(this.colors.length/t);return`${n*e+(n-1)*i}px`}render(){const t=this.isExpanded?this.colors:this.colors.slice(0,6);const n=this.isExpanded?this.calculateHeight():"32px";return e(i,{key:"d533725a8ab2019ae963959727283fbbf833c56a"},e("div",{key:"7fb50c16d79e9b7330100b0f4e116f8f07b20827",class:{"color-grid":true,expanded:this.isExpanded},style:{height:n}},t.map((t=>e("div",{tabIndex:0,class:{"color-container":true,selected:this.selectedColor===t},onClick:()=>this.handleColorClick(t)},e("kritzel-color",{value:t}))))))}};R.style=O;const W=":host{display:block}.menu-container{display:flex;flex-direction:column;background-color:var(--kritzel-context-menu-background-color, #ffffff);border-radius:var(--kritzel-context-menu-border-radius, 12px);box-shadow:var(--kritzel-context-menu-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12));border:var(--kritzel-context-menu-border, 1px solid #ebebeb);padding:var(--kritzel-context-menu-padding,4px)}.menu-item{display:flex;align-items:center;gap:var(--kritzel-context-menu-item-gap, 8px);background:none;border:none;text-align:left;padding:var(--kritzel-context-menu-item-padding, 8px);border-radius:var(--kritzel-context-menu-item-border-radius, 12px);cursor:pointer;font-size:var(--kritzel-context-menu-item-font-size, 14px);color:var(--kritzel-context-menu-item-color, #333333);white-space:nowrap;-webkit-tap-highlight-color:transparent}.menu-item:not(.disabled):hover{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item:not(.disabled):active{background-color:var(--kritzel-context-menu-item-active-background-color, hsl(0, 0%, 0%, 8.6%))}.menu-item.disabled{color:var(--kritzel-context-menu-item-disabled-color, #aaaaaa);cursor:default}.menu-item kritzel-icon{opacity:0.8;flex-shrink:0}.menu-item.disabled kritzel-icon{opacity:0.4}.label{flex-grow:1}";const F=class{constructor(e){t(this,e);this.actionSelected=n(this,"actionSelected");this.close=n(this,"close")}get host(){return r(this)}items;onItemsChanged(){this.updateMenuItems()}objects;actionSelected;close;processedItems=[];handleOutsideClick(t){const e=t.composedPath();if(!e.includes(this.host)){this.close.emit()}}componentWillLoad(){this.updateMenuItems()}handleItemClick(t,e){if(!e){this.actionSelected.emit(t)}}async updateMenuItems(){const t=[];for(const e of this.items){const i=await this.evaluateProperty(e.visible,true);if(i){const i=await this.evaluateProperty(e.disabled,false);t.push({item:e,isDisabled:i})}}this.processedItems=t}async evaluateProperty(t,e){if(typeof t==="boolean"){return t}if(typeof t==="function"){return await Promise.resolve(t(null,this.objects))}return e}render(){return e(i,{key:"45b9652285f9c3fe7568cbe222667d23c151622f"},e("div",{key:"9aecc01027f297fa4d991780efaaf51b8d4542dc",class:"menu-container"},this.processedItems.map((({item:t,isDisabled:i},n)=>e("button",{key:`${t.label}-${n}`,class:{"menu-item":true,disabled:i},onClick:()=>this.handleItemClick(t,i),disabled:i},t.icon&&e("kritzel-icon",{name:t.icon,size:16}),e("span",{class:"label"},t.label))))))}static get watchers(){return{items:["onItemsChanged"]}}};F.style=W;const D=":host{display:flex;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:focus-visible{outline:var(--kritzel-color-palette-focus-outline, 2px auto #e3e3e3)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";const B=class{constructor(e){t(this,e);this.toolChange=n(this,"toolChange")}tool;handleToolChange(t){this.palette=t.palettes[t.type]}isExpanded=false;toolChange;palette=[];componentWillLoad(){this.palette=this.tool.palettes[this.tool.type]}handleToggleExpand(){this.isExpanded=!this.isExpanded}handleTypeChange(t){this.palette=this.tool.palettes[t.detail];this.tool.type=t.detail;this.tool.color=this.palette[0];this.toolChange.emit(this.tool)}handleColorChange(t){this.tool.color=t.detail;this.toolChange.emit(this.tool)}handleSizeChange(t){this.tool.size=t.detail;this.toolChange.emit(this.tool)}render(){return e(i,{key:"4b060826312e6d5a2117f5ba9522553af9b02d6f"},e("div",{key:"0975a250184d5bb2d38cc60263bd718157230d8c",style:{display:"flex",flexDirection:"row",alignItems:this.isExpanded?"flex-start":"center",justifyContent:"flex-start",width:"100%",gap:"8px"}},e("kritzel-color-palette",{key:"df84a6fdda01bc7bf3aff42e3b88c4bd9dca500f",colors:this.palette,selectedColor:this.tool.color,isExpanded:this.isExpanded,isOpaque:true,onColorChange:t=>this.handleColorChange(t)}),e("button",{key:"e43c19612807fc4f9cd1bf04f4fb79a048cfd62b",class:"expand-toggle",onClick:()=>this.handleToggleExpand(),title:this.isExpanded?"Collapse":"Expand",style:this.palette.length>6?{visibillity:"visible"}:{visibility:"hidden"}},e("kritzel-icon",{key:"915cce6c4744ad175f3836c946330882de840880",name:this.isExpanded?"chevron-up":"chevron-down"}))),e("kritzel-stroke-size",{key:"c07eebae3ba1785e2644c6b5a22d23f76be950fb",selectedSize:this.tool.size,onSizeChange:t=>this.handleSizeChange(t)}))}static get watchers(){return{tool:["handleToolChange"]}}};B.style=D;const P=":host{display:block;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";const L=class{constructor(e){t(this,e);this.toolChange=n(this,"toolChange")}tool;isExpanded=false;toolChange;handleToggleExpand(){this.isExpanded=!this.isExpanded}handleFamilyChange(t){this.tool.fontFamily=t.detail;this.toolChange.emit(this.tool)}handleColorChange(t){this.tool.fontColor=t.detail;this.toolChange.emit(this.tool)}handleSizeChange(t){this.tool.fontSize=t.detail;this.toolChange.emit(this.tool)}render(){return e(i,{key:"82e611092700f057bd36823e7f7503fe7a0423ed"},e("div",{key:"37ed39adeeeb58981a917918cd185e96d589e973",style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",width:"100%",gap:"8px"}},e("kritzel-font-family",{key:"cd8afc5c4a1eee087610cd3d5a6c05210cfda6b3",selectedFontFamily:this.tool.fontFamily,onFontFamilyChange:t=>this.handleFamilyChange(t)}),e("button",{key:"085f1bba060bde27a7b64dc5477bb51305b76235",class:"expand-toggle",onClick:()=>this.handleToggleExpand(),title:this.isExpanded?"Collapse":"Expand"},e("kritzel-icon",{key:"3ff8fec207120e67f43315c6dace72fc2f6bd0f1",name:this.isExpanded?"chevron-up":"chevron-down"}))),e("kritzel-color-palette",{key:"2e29d01a6b5c0e4a8ec347e63b6a2698c282db40",colors:this.tool.palette,selectedColor:this.tool.fontColor,isExpanded:this.isExpanded,onColorChange:t=>this.handleColorChange(t)}),e("kritzel-font-size",{key:"c972068f1251d66e756b8de72fbdd1b6002d1daa",selectedSize:this.tool.fontSize,fontFamily:this.tool.fontFamily,onSizeChange:t=>this.handleSizeChange(t)}))}};L.style=P;const V=":host{display:flex;flex-direction:column;user-select:none}:host(.mobile){--kritzel-controls-control-hover-background-color:transparent;--kritzel-controls-control-active-background-color:transparent}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 16px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid #ebebeb);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 12px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:focus,.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #007AFF) !important;color:var(--kritzel-controls-control-selected-color, #ffffff) !important}.kritzel-control.selected:focus{background-color:var(--kritzel-controls-control-selected-background-color, #007bffe3) !important}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer;border-radius:50%}.kritzel-config:focus{outline:var(--kritzel-menu-focus-outline, 2px solid #e3e3e3)}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #ebebeb)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:56px;left:50%;transform:translateX(-50%);z-index:10001}";const U=class{constructor(e){t(this,e);this.isControlsReady=n(this,"isControlsReady")}get host(){return r(this)}controls=[];activeControl=null;isUtilityPanelVisible=true;isControlsReady;firstConfig=null;isTooltipVisible=false;isTouchDevice=o.isTouchDevice();handleDocumentClick(t){const e=t.target;if(!this.kritzelEngine||e.closest(".kritzel-tooltip")){return}this.isTooltipVisible=false}handleKeyDown(t){if(t.key==="Escape"){t.preventDefault();this.closeTooltip();this.kritzelEngine?.enable()}}async handleActiveToolChange(t){this.activeControl=this.controls.find((e=>e.tool===t.detail))||null}async closeTooltip(){this.isTooltipVisible=false}kritzelEngine=null;tooltipRef=null;get activeToolAsTextTool(){return this.activeControl?.tool}get activeToolAsBrushTool(){return this.activeControl?.tool}async componentWillLoad(){await this.initializeEngine();await this.initializeTools();this.isControlsReady.emit()}async initializeEngine(){await customElements.whenDefined("kritzel-engine");this.kritzelEngine=this.host.parentElement.querySelector("kritzel-engine");if(!this.kritzelEngine){throw new Error("kritzel-engine not found in parent element.")}}async initializeTools(){for(const t of this.controls){if(t.type==="tool"&&t.tool){t.tool=await this.kritzelEngine.registerTool(t.name,t.tool,t.config)}if(t.type==="tool"&&t.isDefault&&t.tool){await this.kritzelEngine.changeActiveTool(t.tool);this.activeControl=t}if(t.type==="config"){if(this.firstConfig===null){this.firstConfig=t}else{console.warn("Only one config control is allowed. The first one will be used.")}}}}async handleControlClick(t){this.activeControl=t;if(this.activeControl.type==="tool"){await this.kritzelEngine.changeActiveTool(this.activeControl.tool)}}handleConfigClick(t){t.stopPropagation();this.isTooltipVisible=!this.isTooltipVisible;if(this.isTooltipVisible){this.kritzelEngine?.disable()}else{this.kritzelEngine?.enable()}setTimeout((()=>{this.tooltipRef?.focusContent()}),100)}async handleToolChange(t){this.activeControl={...this.activeControl,tool:t.detail};await this.kritzelEngine.changeActiveTool(this.activeControl.tool)}handleTooltipClosed(){this.isTooltipVisible=false;this.kritzelEngine?.enable()}render(){const t=this.activeControl?.config===undefined||this.activeControl?.config===null;return e(i,{key:"ab3e5f078d6d197c6e10c9dee180c04ef85281bf",class:{mobile:this.isTouchDevice}},this.isUtilityPanelVisible&&e("kritzel-utility-panel",{key:"290ceb6f2c46eb7e869a4741dd6600bc7c47bbb4",style:{position:"absolute",bottom:"56px",left:"12px"},onUndo:()=>this.kritzelEngine?.undo(),onRedo:()=>this.kritzelEngine?.redo(),onDelete:()=>this.kritzelEngine?.delete()}),e("div",{key:"d2590bc56b709e77910e7159296741c8859158d7",class:"kritzel-controls"},this.controls.map((i=>{if(i.type==="tool"){return e("button",{class:{"kritzel-control":true,selected:this.activeControl?.name===i?.name},key:i.name,onClick:t=>this.handleControlClick?.(i)},e("kritzel-icon",{name:i.icon}))}if(i.type==="divider"){return e("div",{class:"kritzel-divider",key:i.name})}if(i.type==="config"&&i.name===this.firstConfig?.name&&this.activeControl){return e("div",{class:"kritzel-config-container",key:i.name},e("kritzel-tooltip",{ref:t=>this.tooltipRef=t,isVisible:this.isTooltipVisible,anchorElement:this.host.shadowRoot?.querySelector(".kritzel-config-container"),onTooltipClosed:()=>this.handleTooltipClosed()},e("div",{style:{width:"294px",height:"100%"}},this.activeControl.name==="brush"&&e("kritzel-control-brush-config",{tool:this.activeToolAsBrushTool,onToolChange:t=>this.handleToolChange?.(t)}),this.activeControl.name==="text"&&e("kritzel-control-text-config",{tool:this.activeToolAsTextTool,onToolChange:t=>this.handleToolChange?.(t)}))),e("div",{tabIndex:0,class:"kritzel-config",onClick:t=>this.handleConfigClick?.(t),onKeyDown:t=>{if(t.key==="Enter"){this.handleConfigClick?.(t)}},style:{cursor:this.activeControl.config?"pointer":"default",pointerEvents:t?"none":"auto"}},this.activeControl.tool instanceof s&&e("div",{class:"color-container"},e("kritzel-color",{value:this.activeToolAsBrushTool?.color,size:this.activeToolAsBrushTool?.size,style:{borderRadius:"50%",border:"none"}})),this.activeControl.tool instanceof a&&e("div",{class:"font-container"},e("kritzel-font",{fontFamily:this.activeToolAsTextTool?.fontFamily,size:this.activeToolAsTextTool?.fontSize,color:this.activeToolAsTextTool?.fontColor})),t&&e("div",{class:"no-config"})))}}))))}static get assetsDirs(){return["../assets"]}};U.style=V;const K=":host{display:block;position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:9000}";const H=class{constructor(e){t(this,e)}core;cursorTrailPoints=[];isLeftButtonDown=false;handleMouseDown(t){if(t.pointerType==="mouse"){if(t.button===c.Left){this.isLeftButtonDown=true;this.cursorTrailPoints=[]}}if(t.pointerType==="touch"){if(this.core.store.state.pointers.size===1){this.isLeftButtonDown=true;this.cursorTrailPoints=[]}}}handlePointerMove(t){if(!this.isLeftButtonDown){return}const e={x:t.clientX,y:t.clientY,timestamp:Date.now()};const i=[e,...this.cursorTrailPoints];if(i.length>this.MAX_TRAIL_POINTS){this.cursorTrailPoints=i.slice(0,this.MAX_TRAIL_POINTS)}else{this.cursorTrailPoints=i}}handlePointerUp(t){if(t.pointerType==="mouse"){if(t.button===c.Left){this.isLeftButtonDown=false;this.cursorTrailPoints=[]}}if(t.pointerType==="touch"){if(this.core.store.state.pointers.size===0){this.isLeftButtonDown=false;this.cursorTrailPoints=[]}}}trailCleanupIntervalId;TRAIL_DURATION_MS=100;MAX_TRAIL_POINTS=50;componentDidLoad(){this.trailCleanupIntervalId=window.setInterval((()=>{const t=Date.now();const e=this.cursorTrailPoints.filter((e=>t-e.timestamp<this.TRAIL_DURATION_MS));if(e.length!==this.cursorTrailPoints.length){this.cursorTrailPoints=e}}),50)}disconnectedCallback(){if(this.trailCleanupIntervalId){window.clearInterval(this.trailCleanupIntervalId)}}render(){return e(i,{key:"10ef620f19d72a8a5c3a12d0d98686bc69308a30"},this.cursorTrailPoints.length>1&&e("svg",{key:"d03403051e53422aaa28d6360aaa9c0391e3ef6a",class:"cursor-trail-svg",xmlns:"http://www.w3.org/2000/svg",style:{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",pointerEvents:"none",opacity:"var(--kritzel-cursor-trail-opacity, 0.6)",zIndex:"9000"}},this.cursorTrailPoints.slice(1).map(((t,i)=>{const n=this.cursorTrailPoints[i];const r=Date.now();const o=r-t.timestamp;const s=Math.max(0,Math.min(1,o/this.TRAIL_DURATION_MS));if(s>=1)return null;const a=Math.max(2,15*(1-s));return e("line",{key:`trail-segment-${t.timestamp}`,x1:n.x.toString(),y1:n.y.toString(),x2:t.x.toString(),y2:t.y.toString(),stroke:"var(--kritzel-cursor-trail-color, rgb(228, 228, 228))","stroke-width":a.toString(),"stroke-linecap":"round"})}))))}};H.style=K;const Y=':host{display:inline-flex;vertical-align:middle;width:100%;}.dropdown-wrapper{display:flex;align-items:center;border:1px solid #333333;border-radius:var(--kritzel-controls-control-border-radius, 12px);overflow:hidden;height:32px;width:100%}.custom-select{padding:0 8px;padding-right:30px;height:100%;width:100%;box-sizing:border-box;border-radius:0;border:none;background-color:#fff;cursor:pointer;outline:none;font-size:inherit;color:var(--kritzel-controls-text-color, #333333);-webkit-tap-highlight-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>\');background-size:16px 16px;background-repeat:no-repeat;background-position:right 8px center}.custom-select.has-suffix-border{border-right:1px solid #333333}.custom-select.has-prefix-border{border-left:1px solid #333333}::slotted(*){height:100%;box-sizing:border-box}';const N=class{constructor(e){t(this,e);this.valueChanged=n(this,"valueChanged")}options=[];optionsChanged(){this.updateInternalValue(this.internalValue,true)}value;externalValueChanged(t){if(t!==this.internalValue){this.updateInternalValue(t,false)}}width;selectStyles={};internalValue;hasSuffixContent=false;hasPrefixContent=false;valueChanged;suffixSlotElement;prefixSlotElement;componentWillLoad(){this.updateInternalValue(this.value,false);this.evaluateSuffixContent();this.evaluatePrefixContent()}updateInternalValue(t,e){let i=t;if(this.options&&this.options.length>0){const t=this.options.some((t=>t.value===i));if(!i||!t){i=this.options[0].value}}else{i=undefined}if(this.internalValue!==i){this.internalValue=i;if(e||t!==i&&t!==undefined){this.valueChanged.emit(this.internalValue)}}}handleSelectChange=t=>{const e=t.target.value;if(this.internalValue!==e){this.internalValue=e;this.valueChanged.emit(this.internalValue)}};evaluateSuffixContent=()=>{if(this.suffixSlotElement){const t=this.suffixSlotElement.assignedNodes({flatten:true}).length>0;if(this.hasSuffixContent!==t){this.hasSuffixContent=t}}else{if(this.hasSuffixContent!==false){this.hasSuffixContent=false}}};evaluatePrefixContent=()=>{if(this.prefixSlotElement){const t=this.prefixSlotElement.assignedNodes({flatten:true}).length>0;if(this.hasPrefixContent!==t){this.hasPrefixContent=t}}else{if(this.hasPrefixContent!==false){this.hasPrefixContent=false}}};render(){const t={"custom-select":true,"has-suffix-border":this.hasSuffixContent,"has-prefix-border":this.hasPrefixContent};return e(i,{key:"f24911715685ced571843ba7be6631248c8519b7"},e("div",{key:"520fdb74afdef8bd5228f76074e51981f44b910d",class:"dropdown-wrapper"},e("slot",{key:"cf6628437946b57ad0b27c066639e0b64b5a28f8",name:"prefix",ref:t=>this.prefixSlotElement=t,onSlotchange:this.evaluatePrefixContent}),e("select",{key:"3203ccd5b9c8b84e8f41bddfcb07786e879f0035",class:t,style:{...this.selectStyles,width:this.width},onInput:this.handleSelectChange},this.options.map((t=>e("option",{value:t.value,style:t.style,selected:t.value===this.internalValue},t.label)))),e("slot",{key:"d0abb52e082db81860c09d2c48b7c065adb406f3",name:"suffix",ref:t=>this.suffixSlotElement=t,onSlotchange:this.evaluateSuffixContent})))}static get watchers(){return{options:["optionsChanged"],value:["externalValueChanged"]}}};N.style=Y;class X{static registry=new Map;static register(t,e){if(this.registry.has(t)){console.warn(`[IconRegistry] Icon "${t}" is already registered. It will be overwritten.`)}this.registry.set(t,e)}static get(t){return this.registry.get(t)}static registerIcons(t){for(const e in t){if(Object.prototype.hasOwnProperty.call(t,e)){this.register(e,t[e])}}}static has(t){return this.registry.has(t)}}X.registerIcons({cursor:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',pen:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',highlighter:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',eraser:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',type:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',image:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',"chevron-down":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',"chevron-up":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',copy:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',paste:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',cut:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',delete:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',"bring-to-front":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',"send-to-back":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',"select-all":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',download:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',undo:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',redo:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>',plus:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus-icon lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>',"ellipsis-vertical":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis-vertical-icon lucide-ellipsis-vertical"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>',x:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>'});const q=1e3;const G=1e-4;const Z="kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-workspace-manager{position:absolute;top:var(--kritzel-editor-workspace-manager-top, 14px);left:var(--kritzel-editor-workspace-manager-left, 14px)}kritzel-controls{position:absolute;bottom:var(--kritzel-editor-controls-bottom, 14px);transition:transform var(--kritzel-editor-controls-transition-duration, 0.1s) var(--kritzel-editor-controls-transition, ease-in-out)}kritzel-controls.keyboard-open{transform:var(--kritzel-editor-controls-transform, translateY(300%))}";const J=class{constructor(e){t(this,e);this.isReady=n(this,"isReady")}get host(){return r(this)}scaleMax=q;scaleMin=G;controls=[{name:"selection",type:"tool",isDefault:true,tool:l,icon:"cursor"},{name:"brush",type:"tool",tool:s,icon:"pen",config:u},{name:"eraser",type:"tool",tool:h,icon:"eraser"},{name:"text",type:"tool",tool:a,icon:"type",config:f},{name:"image",type:"tool",tool:d,icon:"image"},{name:"divider",type:"divider"},{name:"config",type:"config"}];globalContextMenuItems=[{label:"Paste",icon:"paste",disabled:async()=>(await this.engineRef.getCopiedObjects()).length===0,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Select All",icon:"select-all",action:()=>this.selectAllObjectsInViewport()}];objectContextMenuItems=[{label:"Copy",icon:"copy",action:()=>this.engineRef.copy()},{label:"Paste",icon:"paste",disabled:async()=>(await this.engineRef.getCopiedObjects()).length===0,action:(t,e)=>this.engineRef.paste(t.x,t.y)},{label:"Delete",icon:"delete",action:()=>this.engineRef.delete()},{label:"Bring to Front",icon:"bring-to-front",action:()=>this.engineRef.bringToFront()},{label:"Send to Back",icon:"send-to-back",action:()=>this.engineRef.sendToBack()}];customSvgIcons={};isControlsVisible=true;isUtilityPanelVisible=true;syncConfig;isReady;isEngineReady=false;isControlsReady=false;isWorkspaceManagerReady=false;workspaces=[];activeWorkspace;isVirtualKeyboardOpen=false;onIsEngineReady(t){if(t&&this.isControlsReady){this.checkIsReady()}}onIsControlsReady(t){if(t&&this.isEngineReady){this.checkIsReady()}}onWorkspacesChange(t){if(this.activeWorkspace){const e=t.find((t=>t.id===this.activeWorkspace.id));if(e&&e!==this.activeWorkspace){this.activeWorkspace=e}}}handleTouchStart(t){if(t.cancelable){t.preventDefault()}}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async getSelectedObjects(){return this.engineRef.getSelectedObjects()}async selectObjects(t){return this.engineRef.selectObjects(t)}async selectAllObjectsInViewport(){return this.engineRef.selectAllObjectsInViewport()}async clearSelection(){this.engineRef.clearSelection()}async centerObjectInViewport(t){return this.engineRef.centerObjectInViewport(t)}async createWorkspace(t,e){const i=new v(`workspace-${Date.now()}`,t,e);return this.engineRef.createWorkspace(i)}async updateWorkspace(t){return this.engineRef.updateWorkspace(t)}async deleteWorkspace(t){return this.engineRef.deleteWorkspace(t)}async getWorkspaces(){return this.engineRef.getWorkspaces()}async getActiveWorkspace(){return this.engineRef.getActiveWorkspace()}engineRef;controlsRef;splitButtonRef;componentDidLoad(){this.registerCustomSvgIcons();this.listenForMobileKeyboard();this.setOsSpecificCssVariables()}async checkIsReady(){await customElements.whenDefined("kritzel-editor");await customElements.whenDefined("kritzel-workspace-manager");await customElements.whenDefined("kritzel-controls");await customElements.whenDefined("kritzel-engine");if(!this.isEngineReady||!this.isControlsReady||!this.isWorkspaceManagerReady){return}this.isReady.emit(this.host)}onEngineReady(t){this.isEngineReady=true;this.activeWorkspace=t.detail.activeWorkspace;this.workspaces=t.detail.workspaces}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons)){X.register(t,e)}}listenForMobileKeyboard(){p.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){const t=o.detectOS();switch(t){case"iOS":this.host.style.setProperty("--kritzel-editor-workspace-manager-top","14px");this.host.style.setProperty("--kritzel-editor-workspace-manager-left","14px");this.host.style.setProperty("--kritzel-editor-controls-bottom","14px");this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)");this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)");this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;case"Android":this.host.style.setProperty("--kritzel-editor-workspace-manager-top","14px");this.host.style.setProperty("--kritzel-editor-workspace-manager-left","14px");this.host.style.setProperty("--kritzel-editor-controls-bottom","24px");break;default:this.host.style.setProperty("--kritzel-editor-workspace-manager-top","14px");this.host.style.setProperty("--kritzel-editor-workspace-manager-left","14px");this.host.style.setProperty("--kritzel-editor-controls-bottom","14px");break}}render(){return e(i,{key:"97ab11381c7ba448814b6b463a3bd9135e5d328f"},e("kritzel-workspace-manager",{key:"2eb9bb27e0e613537a2ceea4144a7753313d1c78",workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=true}),e("kritzel-engine",{key:"4c3b68eec1c2e2ac879a6fb34edcefcefdf2cea7",ref:t=>this.engineRef=t,workspace:this.activeWorkspace,syncConfig:this.syncConfig,scaleMax:this.scaleMax,scaleMin:this.scaleMin,globalContextMenuItems:this.globalContextMenuItems,objectContextMenuItems:this.objectContextMenuItems,onIsEngineReady:t=>this.onEngineReady(t),onWorkspacesChange:t=>this.workspaces=t.detail}),e("kritzel-controls",{key:"beef7d08c44673a50184722a8201a12bf4635ce8",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>this.controlsRef=t,controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,onIsControlsReady:()=>this.isControlsReady=true}))}static get watchers(){return{isEngineReady:["onIsEngineReady"],isControlsReady:["onIsControlsReady"],workspaces:["onWorkspacesChange"]}}};J.style=Z;var Q={exports:{}};
2
2
  /**
3
3
  * @license
4
4
  * Lodash <https://lodash.com/>
@@ -6,5 +6,5 @@ import{r as t,h as e,H as i,c as n,g as r}from"./p-SGde3HXB.js";import{T as o,G
6
6
  * Released under MIT license <https://lodash.com/license>
7
7
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
8
8
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
9
- */var tt=Q.exports;var et;function it(){if(et)return Q.exports;et=1;(function(t,e){(function(){var i;var n="4.17.21";var r=200;var o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`";var c="__lodash_hash_undefined__";var l=500;var u="__lodash_placeholder__";var h=1,f=2,d=4;var v=1,p=2;var b=1,g=2,k=4,y=8,w=16,m=32,x=64,z=128,C=256,M=512;var j=30,I="...";var S=800,_=16;var T=1,$=2,E=3;var O=1/0,R=9007199254740991,W=17976931348623157e292,F=0/0;var D=4294967295,B=D-1,P=D>>>1;var L=[["ary",z],["bind",b],["bindKey",g],["curry",y],["curryRight",w],["flip",M],["partial",m],["partialRight",x],["rearg",C]];var V="[object Arguments]",U="[object Array]",K="[object AsyncFunction]",H="[object Boolean]",Y="[object Date]",N="[object DOMException]",X="[object Error]",q="[object Function]",G="[object GeneratorFunction]",Z="[object Map]",J="[object Number]",Q="[object Null]",tt="[object Object]",et="[object Promise]",it="[object Proxy]",nt="[object RegExp]",rt="[object Set]",ot="[object String]",st="[object Symbol]",at="[object Undefined]",ct="[object WeakMap]",lt="[object WeakSet]";var ut="[object ArrayBuffer]",ht="[object DataView]",ft="[object Float32Array]",dt="[object Float64Array]",vt="[object Int8Array]",pt="[object Int16Array]",bt="[object Int32Array]",gt="[object Uint8Array]",kt="[object Uint8ClampedArray]",yt="[object Uint16Array]",wt="[object Uint32Array]";var mt=/\b__p \+= '';/g,xt=/\b(__p \+=) '' \+/g,zt=/(__e\(.*?\)|\b__t\)) \+\n'';/g;var Ct=/&(?:amp|lt|gt|quot|#39);/g,Mt=/[&<>"']/g,jt=RegExp(Ct.source),It=RegExp(Mt.source);var St=/<%-([\s\S]+?)%>/g,_t=/<%([\s\S]+?)%>/g,Tt=/<%=([\s\S]+?)%>/g;var At=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$t=/^\w*$/,Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;var Ot=/[\\^$.*+?()[\]{}|]/g,Rt=RegExp(Ot.source);var Wt=/^\s+/;var Ft=/\s/;var Dt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bt=/\{\n\/\* \[wrapped with (.+)\] \*/,Pt=/,? & /;var Lt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;var Vt=/[()=,{}\[\]\/\s]/;var Ut=/\\(\\)?/g;var Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;var Ht=/\w*$/;var Yt=/^[-+]0x[0-9a-f]+$/i;var Nt=/^0b[01]+$/i;var Xt=/^\[object .+?Constructor\]$/;var qt=/^0o[0-7]+$/i;var Gt=/^(?:0|[1-9]\d*)$/;var Zt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;var Jt=/($^)/;var Qt=/['\n\r\u2028\u2029\\]/g;var te="\\ud800-\\udfff",ee="\\u0300-\\u036f",ie="\\ufe20-\\ufe2f",ne="\\u20d0-\\u20ff",re=ee+ie+ne,oe="\\u2700-\\u27bf",se="a-z\\xdf-\\xf6\\xf8-\\xff",ae="\\xac\\xb1\\xd7\\xf7",ce="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",le="\\u2000-\\u206f",ue=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",he="A-Z\\xc0-\\xd6\\xd8-\\xde",fe="\\ufe0e\\ufe0f",de=ae+ce+le+ue;var ve="['’]",pe="["+te+"]",be="["+de+"]",ge="["+re+"]",ke="\\d+",ye="["+oe+"]",we="["+se+"]",me="[^"+te+de+ke+oe+se+he+"]",xe="\\ud83c[\\udffb-\\udfff]",ze="(?:"+ge+"|"+xe+")",Ce="[^"+te+"]",Me="(?:\\ud83c[\\udde6-\\uddff]){2}",je="[\\ud800-\\udbff][\\udc00-\\udfff]",Ie="["+he+"]",Se="\\u200d";var _e="(?:"+we+"|"+me+")",Te="(?:"+Ie+"|"+me+")",Ae="(?:"+ve+"(?:d|ll|m|re|s|t|ve))?",$e="(?:"+ve+"(?:D|LL|M|RE|S|T|VE))?",Ee=ze+"?",Oe="["+fe+"]?",Re="(?:"+Se+"(?:"+[Ce,Me,je].join("|")+")"+Oe+Ee+")*",We="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Fe="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",De=Oe+Ee+Re,Be="(?:"+[ye,Me,je].join("|")+")"+De,Pe="(?:"+[Ce+ge+"?",ge,Me,je,pe].join("|")+")";var Le=RegExp(ve,"g");var Ve=RegExp(ge,"g");var Ue=RegExp(xe+"(?="+xe+")|"+Pe+De,"g");var Ke=RegExp([Ie+"?"+we+"+"+Ae+"(?="+[be,Ie,"$"].join("|")+")",Te+"+"+$e+"(?="+[be,Ie+_e,"$"].join("|")+")",Ie+"?"+_e+"+"+Ae,Ie+"+"+$e,Fe,We,ke,Be].join("|"),"g");var He=RegExp("["+Se+te+re+fe+"]");var Ye=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;var Ne=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"];var Xe=-1;var qe={};qe[ft]=qe[dt]=qe[vt]=qe[pt]=qe[bt]=qe[gt]=qe[kt]=qe[yt]=qe[wt]=true;qe[V]=qe[U]=qe[ut]=qe[H]=qe[ht]=qe[Y]=qe[X]=qe[q]=qe[Z]=qe[J]=qe[tt]=qe[nt]=qe[rt]=qe[ot]=qe[ct]=false;var Ge={};Ge[V]=Ge[U]=Ge[ut]=Ge[ht]=Ge[H]=Ge[Y]=Ge[ft]=Ge[dt]=Ge[vt]=Ge[pt]=Ge[bt]=Ge[Z]=Ge[J]=Ge[tt]=Ge[nt]=Ge[rt]=Ge[ot]=Ge[st]=Ge[gt]=Ge[kt]=Ge[yt]=Ge[wt]=true;Ge[X]=Ge[q]=Ge[ct]=false;var Ze={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"};var Je={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};var Qe={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"};var ti={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};var ei=parseFloat,ii=parseInt;var ni=typeof A=="object"&&A&&A.Object===Object&&A;var ri=typeof self=="object"&&self&&self.Object===Object&&self;var oi=ni||ri||Function("return this")();var si=e&&!e.nodeType&&e;var ai=si&&"object"=="object"&&t&&!t.nodeType&&t;var ci=ai&&ai.exports===si;var li=ci&&ni.process;var ui=function(){try{var t=ai&&ai.require&&ai.require("util").types;if(t){return t}return li&&li.binding&&li.binding("util")}catch(t){}}();var hi=ui&&ui.isArrayBuffer,fi=ui&&ui.isDate,di=ui&&ui.isMap,vi=ui&&ui.isRegExp,pi=ui&&ui.isSet,bi=ui&&ui.isTypedArray;function gi(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}function ki(t,e,i,n){var r=-1,o=t==null?0:t.length;while(++r<o){var s=t[r];e(n,s,i(s),t)}return n}function yi(t,e){var i=-1,n=t==null?0:t.length;while(++i<n){if(e(t[i],i,t)===false){break}}return t}function wi(t,e){var i=t==null?0:t.length;while(i--){if(e(t[i],i,t)===false){break}}return t}function mi(t,e){var i=-1,n=t==null?0:t.length;while(++i<n){if(!e(t[i],i,t)){return false}}return true}function xi(t,e){var i=-1,n=t==null?0:t.length,r=0,o=[];while(++i<n){var s=t[i];if(e(s,i,t)){o[r++]=s}}return o}function zi(t,e){var i=t==null?0:t.length;return!!i&&Ri(t,e,0)>-1}function Ci(t,e,i){var n=-1,r=t==null?0:t.length;while(++n<r){if(i(e,t[n])){return true}}return false}function Mi(t,e){var i=-1,n=t==null?0:t.length,r=Array(n);while(++i<n){r[i]=e(t[i],i,t)}return r}function ji(t,e){var i=-1,n=e.length,r=t.length;while(++i<n){t[r+i]=e[i]}return t}function Ii(t,e,i,n){var r=-1,o=t==null?0:t.length;if(n&&o){i=t[++r]}while(++r<o){i=e(i,t[r],r,t)}return i}function Si(t,e,i,n){var r=t==null?0:t.length;if(n&&r){i=t[--r]}while(r--){i=e(i,t[r],r,t)}return i}function _i(t,e){var i=-1,n=t==null?0:t.length;while(++i<n){if(e(t[i],i,t)){return true}}return false}var Ti=Bi("length");function Ai(t){return t.split("")}function $i(t){return t.match(Lt)||[]}function Ei(t,e,i){var n;i(t,(function(t,i,r){if(e(t,i,r)){n=i;return false}}));return n}function Oi(t,e,i,n){var r=t.length,o=i+(n?1:-1);while(n?o--:++o<r){if(e(t[o],o,t)){return o}}return-1}function Ri(t,e,i){return e===e?fn(t,e,i):Oi(t,Fi,i)}function Wi(t,e,i,n){var r=i-1,o=t.length;while(++r<o){if(n(t[r],e)){return r}}return-1}function Fi(t){return t!==t}function Di(t,e){var i=t==null?0:t.length;return i?Ui(t,e)/i:F}function Bi(t){return function(e){return e==null?i:e[t]}}function Pi(t){return function(e){return t==null?i:t[e]}}function Li(t,e,i,n,r){r(t,(function(t,r,o){i=n?(n=false,t):e(i,t,r,o)}));return i}function Vi(t,e){var i=t.length;t.sort(e);while(i--){t[i]=t[i].value}return t}function Ui(t,e){var n,r=-1,o=t.length;while(++r<o){var s=e(t[r]);if(s!==i){n=n===i?s:n+s}}return n}function Ki(t,e){var i=-1,n=Array(t);while(++i<t){n[i]=e(i)}return n}function Hi(t,e){return Mi(e,(function(e){return[e,t[e]]}))}function Yi(t){return t?t.slice(0,bn(t)+1).replace(Wt,""):t}function Ni(t){return function(e){return t(e)}}function Xi(t,e){return Mi(e,(function(e){return t[e]}))}function qi(t,e){return t.has(e)}function Gi(t,e){var i=-1,n=t.length;while(++i<n&&Ri(e,t[i],0)>-1){}return i}function Zi(t,e){var i=t.length;while(i--&&Ri(e,t[i],0)>-1){}return i}function Ji(t,e){var i=t.length,n=0;while(i--){if(t[i]===e){++n}}return n}var Qi=Pi(Ze);var tn=Pi(Je);function en(t){return"\\"+ti[t]}function nn(t,e){return t==null?i:t[e]}function rn(t){return He.test(t)}function on(t){return Ye.test(t)}function sn(t){var e,i=[];while(!(e=t.next()).done){i.push(e.value)}return i}function an(t){var e=-1,i=Array(t.size);t.forEach((function(t,n){i[++e]=[n,t]}));return i}function cn(t,e){return function(i){return t(e(i))}}function ln(t,e){var i=-1,n=t.length,r=0,o=[];while(++i<n){var s=t[i];if(s===e||s===u){t[i]=u;o[r++]=i}}return o}function un(t){var e=-1,i=Array(t.size);t.forEach((function(t){i[++e]=t}));return i}function hn(t){var e=-1,i=Array(t.size);t.forEach((function(t){i[++e]=[t,t]}));return i}function fn(t,e,i){var n=i-1,r=t.length;while(++n<r){if(t[n]===e){return n}}return-1}function dn(t,e,i){var n=i+1;while(n--){if(t[n]===e){return n}}return n}function vn(t){return rn(t)?kn(t):Ti(t)}function pn(t){return rn(t)?yn(t):Ai(t)}function bn(t){var e=t.length;while(e--&&Ft.test(t.charAt(e))){}return e}var gn=Pi(Qe);function kn(t){var e=Ue.lastIndex=0;while(Ue.test(t)){++e}return e}function yn(t){return t.match(Ue)||[]}function wn(t){return t.match(Ke)||[]}var mn=function t(e){e=e==null?oi:xn.defaults(oi.Object(),e,xn.pick(oi,Ne));var A=e.Array,Ft=e.Date,Lt=e.Error,te=e.Function,ee=e.Math,ie=e.Object,ne=e.RegExp,re=e.String,oe=e.TypeError;var se=A.prototype,ae=te.prototype,ce=ie.prototype;var le=e["__core-js_shared__"];var ue=ae.toString;var he=ce.hasOwnProperty;var fe=0;var de=function(){var t=/[^.]+$/.exec(le&&le.keys&&le.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();var ve=ce.toString;var pe=ue.call(ie);var be=oi._;var ge=ne("^"+ue.call(he).replace(Ot,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var ke=ci?e.Buffer:i,ye=e.Symbol,we=e.Uint8Array,me=ke?ke.allocUnsafe:i,xe=cn(ie.getPrototypeOf,ie),ze=ie.create,Ce=ce.propertyIsEnumerable,Me=se.splice,je=ye?ye.isConcatSpreadable:i,Ie=ye?ye.iterator:i,Se=ye?ye.toStringTag:i;var _e=function(){try{var t=Ns(ie,"defineProperty");t({},"",{});return t}catch(t){}}();var Te=e.clearTimeout!==oi.clearTimeout&&e.clearTimeout,Ae=Ft&&Ft.now!==oi.Date.now&&Ft.now,$e=e.setTimeout!==oi.setTimeout&&e.setTimeout;var Ee=ee.ceil,Oe=ee.floor,Re=ie.getOwnPropertySymbols,We=ke?ke.isBuffer:i,Fe=e.isFinite,De=se.join,Be=cn(ie.keys,ie),Pe=ee.max,Ue=ee.min,Ke=Ft.now,He=e.parseInt,Ye=ee.random,Ze=se.reverse;var Je=Ns(e,"DataView"),Qe=Ns(e,"Map"),ti=Ns(e,"Promise"),ni=Ns(e,"Set"),ri=Ns(e,"WeakMap"),si=Ns(ie,"create");var ai=ri&&new ri;var li={};var ui=$a(Je),Ti=$a(Qe),Ai=$a(ti),Pi=$a(ni),fn=$a(ri);var kn=ye?ye.prototype:i,yn=kn?kn.valueOf:i,mn=kn?kn.toString:i;function zn(t){if(Mu(t)&&!cu(t)&&!(t instanceof In)){if(t instanceof jn){return t}if(he.call(t,"__wrapped__")){return Oa(t)}}return new jn(t)}var Cn=function(){function t(){}return function(e){if(!Cu(e)){return{}}if(ze){return ze(e)}t.prototype=e;var n=new t;t.prototype=i;return n}}();function Mn(){}function jn(t,e){this.__wrapped__=t;this.__actions__=[];this.__chain__=!!e;this.__index__=0;this.__values__=i}zn.templateSettings={escape:St,evaluate:_t,interpolate:Tt,variable:"",imports:{_:zn}};zn.prototype=Mn.prototype;zn.prototype.constructor=zn;jn.prototype=Cn(Mn.prototype);jn.prototype.constructor=jn;function In(t){this.__wrapped__=t;this.__actions__=[];this.__dir__=1;this.__filtered__=false;this.__iteratees__=[];this.__takeCount__=D;this.__views__=[]}function Sn(){var t=new In(this.__wrapped__);t.__actions__=rs(this.__actions__);t.__dir__=this.__dir__;t.__filtered__=this.__filtered__;t.__iteratees__=rs(this.__iteratees__);t.__takeCount__=this.__takeCount__;t.__views__=rs(this.__views__);return t}function _n(){if(this.__filtered__){var t=new In(this);t.__dir__=-1;t.__filtered__=true}else{t=this.clone();t.__dir__*=-1}return t}function Tn(){var t=this.__wrapped__.value(),e=this.__dir__,i=cu(t),n=e<0,r=i?t.length:0,o=Js(0,r,this.__views__),s=o.start,a=o.end,c=a-s,l=n?a:s-1,u=this.__iteratees__,h=u.length,f=0,d=Ue(c,this.__takeCount__);if(!i||!n&&r==c&&d==c){return Bo(t,this.__actions__)}var v=[];t:while(c--&&f<d){l+=e;var p=-1,b=t[l];while(++p<h){var g=u[p],k=g.iteratee,y=g.type,w=k(b);if(y==$){b=w}else if(!w){if(y==T){continue t}else{break t}}}v[f++]=b}return v}In.prototype=Cn(Mn.prototype);In.prototype.constructor=In;function An(t){var e=-1,i=t==null?0:t.length;this.clear();while(++e<i){var n=t[e];this.set(n[0],n[1])}}function $n(){this.__data__=si?si(null):{};this.size=0}function En(t){var e=this.has(t)&&delete this.__data__[t];this.size-=e?1:0;return e}function On(t){var e=this.__data__;if(si){var n=e[t];return n===c?i:n}return he.call(e,t)?e[t]:i}function Rn(t){var e=this.__data__;return si?e[t]!==i:he.call(e,t)}function Wn(t,e){var n=this.__data__;this.size+=this.has(t)?0:1;n[t]=si&&e===i?c:e;return this}An.prototype.clear=$n;An.prototype["delete"]=En;An.prototype.get=On;An.prototype.has=Rn;An.prototype.set=Wn;function Fn(t){var e=-1,i=t==null?0:t.length;this.clear();while(++e<i){var n=t[e];this.set(n[0],n[1])}}function Dn(){this.__data__=[];this.size=0}function Bn(t){var e=this.__data__,i=ur(e,t);if(i<0){return false}var n=e.length-1;if(i==n){e.pop()}else{Me.call(e,i,1)}--this.size;return true}function Pn(t){var e=this.__data__,n=ur(e,t);return n<0?i:e[n][1]}function Ln(t){return ur(this.__data__,t)>-1}function Vn(t,e){var i=this.__data__,n=ur(i,t);if(n<0){++this.size;i.push([t,e])}else{i[n][1]=e}return this}Fn.prototype.clear=Dn;Fn.prototype["delete"]=Bn;Fn.prototype.get=Pn;Fn.prototype.has=Ln;Fn.prototype.set=Vn;function Un(t){var e=-1,i=t==null?0:t.length;this.clear();while(++e<i){var n=t[e];this.set(n[0],n[1])}}function Kn(){this.size=0;this.__data__={hash:new An,map:new(Qe||Fn),string:new An}}function Hn(t){var e=Hs(this,t)["delete"](t);this.size-=e?1:0;return e}function Yn(t){return Hs(this,t).get(t)}function Nn(t){return Hs(this,t).has(t)}function Xn(t,e){var i=Hs(this,t),n=i.size;i.set(t,e);this.size+=i.size==n?0:1;return this}Un.prototype.clear=Kn;Un.prototype["delete"]=Hn;Un.prototype.get=Yn;Un.prototype.has=Nn;Un.prototype.set=Xn;function qn(t){var e=-1,i=t==null?0:t.length;this.__data__=new Un;while(++e<i){this.add(t[e])}}function Gn(t){this.__data__.set(t,c);return this}function Zn(t){return this.__data__.has(t)}qn.prototype.add=qn.prototype.push=Gn;qn.prototype.has=Zn;function Jn(t){var e=this.__data__=new Fn(t);this.size=e.size}function Qn(){this.__data__=new Fn;this.size=0}function tr(t){var e=this.__data__,i=e["delete"](t);this.size=e.size;return i}function er(t){return this.__data__.get(t)}function ir(t){return this.__data__.has(t)}function nr(t,e){var i=this.__data__;if(i instanceof Fn){var n=i.__data__;if(!Qe||n.length<r-1){n.push([t,e]);this.size=++i.size;return this}i=this.__data__=new Un(n)}i.set(t,e);this.size=i.size;return this}Jn.prototype.clear=Qn;Jn.prototype["delete"]=tr;Jn.prototype.get=er;Jn.prototype.has=ir;Jn.prototype.set=nr;function rr(t,e){var i=cu(t),n=!i&&au(t),r=!i&&!n&&du(t),o=!i&&!n&&!r&&Pu(t),s=i||n||r||o,a=s?Ki(t.length,re):[],c=a.length;for(var l in t){if((e||he.call(t,l))&&!(s&&(l=="length"||r&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||sa(l,c)))){a.push(l)}}return a}function or(t){var e=t.length;return e?t[ko(0,e-1)]:i}function sr(t,e){return _a(rs(t),br(e,0,t.length))}function ar(t){return _a(rs(t))}function cr(t,e,n){if(n!==i&&!ru(t[e],n)||n===i&&!(e in t)){vr(t,e,n)}}function lr(t,e,n){var r=t[e];if(!(he.call(t,e)&&ru(r,n))||n===i&&!(e in t)){vr(t,e,n)}}function ur(t,e){var i=t.length;while(i--){if(ru(t[i][0],e)){return i}}return-1}function hr(t,e,i,n){xr(t,(function(t,r,o){e(n,t,i(t),o)}));return n}function fr(t,e){return t&&os(e,xh(e),t)}function dr(t,e){return t&&os(e,zh(e),t)}function vr(t,e,i){if(e=="__proto__"&&_e){_e(t,e,{configurable:true,enumerable:true,value:i,writable:true})}else{t[e]=i}}function pr(t,e){var n=-1,r=e.length,o=A(r),s=t==null;while(++n<r){o[n]=s?i:bh(t,e[n])}return o}function br(t,e,n){if(t===t){if(n!==i){t=t<=n?t:n}if(e!==i){t=t>=e?t:e}}return t}function gr(t,e,n,r,o,s){var a,c=e&h,l=e&f,u=e&d;if(n){a=o?n(t,r,o,s):n(t)}if(a!==i){return a}if(!Cu(t)){return t}var v=cu(t);if(v){a=ea(t);if(!c){return rs(t,a)}}else{var p=Zs(t),b=p==q||p==G;if(du(t)){return Xo(t,c)}if(p==tt||p==V||b&&!o){a=l||b?{}:ia(t);if(!c){return l?as(t,dr(a,t)):ss(t,fr(a,t))}}else{if(!Ge[p]){return o?t:{}}a=na(t,p,c)}}s||(s=new Jn);var g=s.get(t);if(g){return g}s.set(t,a);if(Fu(t)){t.forEach((function(i){a.add(gr(i,e,n,i,t,s))}))}else if(ju(t)){t.forEach((function(i,r){a.set(r,gr(i,e,n,r,t,s))}))}var k=u?l?Ps:Bs:l?zh:xh;var y=v?i:k(t);yi(y||t,(function(i,r){if(y){r=i;i=t[r]}lr(a,r,gr(i,e,n,r,t,s))}));return a}function kr(t){var e=xh(t);return function(i){return yr(i,t,e)}}function yr(t,e,n){var r=n.length;if(t==null){return!r}t=ie(t);while(r--){var o=n[r],s=e[o],a=t[o];if(a===i&&!(o in t)||!s(a)){return false}}return true}function wr(t,e,n){if(typeof t!="function"){throw new oe(s)}return Ma((function(){t.apply(i,n)}),e)}function mr(t,e,i,n){var o=-1,s=zi,a=true,c=t.length,l=[],u=e.length;if(!c){return l}if(i){e=Mi(e,Ni(i))}if(n){s=Ci;a=false}else if(e.length>=r){s=qi;a=false;e=new qn(e)}t:while(++o<c){var h=t[o],f=i==null?h:i(h);h=n||h!==0?h:0;if(a&&f===f){var d=u;while(d--){if(e[d]===f){continue t}}l.push(h)}else if(!s(e,f,n)){l.push(h)}}return l}var xr=us(Ar);var zr=us($r,true);function Cr(t,e){var i=true;xr(t,(function(t,n,r){i=!!e(t,n,r);return i}));return i}function Mr(t,e,n){var r=-1,o=t.length;while(++r<o){var s=t[r],a=e(s);if(a!=null&&(c===i?a===a&&!Bu(a):n(a,c))){var c=a,l=s}}return l}function jr(t,e,n,r){var o=t.length;n=Xu(n);if(n<0){n=-n>o?0:o+n}r=r===i||r>o?o:Xu(r);if(r<0){r+=o}r=n>r?0:qu(r);while(n<r){t[n++]=e}return t}function Ir(t,e){var i=[];xr(t,(function(t,n,r){if(e(t,n,r)){i.push(t)}}));return i}function Sr(t,e,i,n,r){var o=-1,s=t.length;i||(i=oa);r||(r=[]);while(++o<s){var a=t[o];if(e>0&&i(a)){if(e>1){Sr(a,e-1,i,n,r)}else{ji(r,a)}}else if(!n){r[r.length]=a}}return r}var _r=hs();var Tr=hs(true);function Ar(t,e){return t&&_r(t,e,xh)}function $r(t,e){return t&&Tr(t,e,xh)}function Er(t,e){return xi(e,(function(e){return mu(t[e])}))}function Or(t,e){e=Ko(e,t);var n=0,r=e.length;while(t!=null&&n<r){t=t[Aa(e[n++])]}return n&&n==r?t:i}function Rr(t,e,i){var n=e(t);return cu(t)?n:ji(n,i(t))}function Wr(t){if(t==null){return t===i?at:Q}return Se&&Se in ie(t)?Xs(t):ya(t)}function Fr(t,e){return t>e}function Dr(t,e){return t!=null&&he.call(t,e)}function Br(t,e){return t!=null&&e in ie(t)}function Pr(t,e,i){return t>=Ue(e,i)&&t<Pe(e,i)}function Lr(t,e,n){var r=n?Ci:zi,o=t[0].length,s=t.length,a=s,c=A(s),l=Infinity,u=[];while(a--){var h=t[a];if(a&&e){h=Mi(h,Ni(e))}l=Ue(h.length,l);c[a]=!n&&(e||o>=120&&h.length>=120)?new qn(a&&h):i}h=t[0];var f=-1,d=c[0];t:while(++f<o&&u.length<l){var v=h[f],p=e?e(v):v;v=n||v!==0?v:0;if(!(d?qi(d,p):r(u,p,n))){a=s;while(--a){var b=c[a];if(!(b?qi(b,p):r(t[a],p,n))){continue t}}if(d){d.push(p)}u.push(v)}}return u}function Vr(t,e,i,n){Ar(t,(function(t,r,o){e(n,i(t),r,o)}));return n}function Ur(t,e,n){e=Ko(e,t);t=ma(t,e);var r=t==null?t:t[Aa(oc(e))];return r==null?i:gi(r,t,n)}function Kr(t){return Mu(t)&&Wr(t)==V}function Hr(t){return Mu(t)&&Wr(t)==ut}function Yr(t){return Mu(t)&&Wr(t)==Y}function Nr(t,e,i,n,r){if(t===e){return true}if(t==null||e==null||!Mu(t)&&!Mu(e)){return t!==t&&e!==e}return Xr(t,e,i,n,Nr,r)}function Xr(t,e,i,n,r,o){var s=cu(t),a=cu(e),c=s?U:Zs(t),l=a?U:Zs(e);c=c==V?tt:c;l=l==V?tt:l;var u=c==tt,h=l==tt,f=c==l;if(f&&du(t)){if(!du(e)){return false}s=true;u=false}if(f&&!u){o||(o=new Jn);return s||Pu(t)?Rs(t,e,i,n,r,o):Ws(t,e,c,i,n,r,o)}if(!(i&v)){var d=u&&he.call(t,"__wrapped__"),p=h&&he.call(e,"__wrapped__");if(d||p){var b=d?t.value():t,g=p?e.value():e;o||(o=new Jn);return r(b,g,i,n,o)}}if(!f){return false}o||(o=new Jn);return Fs(t,e,i,n,r,o)}function qr(t){return Mu(t)&&Zs(t)==Z}function Gr(t,e,n,r){var o=n.length,s=o,a=!r;if(t==null){return!s}t=ie(t);while(o--){var c=n[o];if(a&&c[2]?c[1]!==t[c[0]]:!(c[0]in t)){return false}}while(++o<s){c=n[o];var l=c[0],u=t[l],h=c[1];if(a&&c[2]){if(u===i&&!(l in t)){return false}}else{var f=new Jn;if(r){var d=r(u,h,l,t,e,f)}if(!(d===i?Nr(h,u,v|p,r,f):d)){return false}}}return true}function Zr(t){if(!Cu(t)||ha(t)){return false}var e=mu(t)?ge:Xt;return e.test($a(t))}function Jr(t){return Mu(t)&&Wr(t)==nt}function Qr(t){return Mu(t)&&Zs(t)==rt}function to(t){return Mu(t)&&zu(t.length)&&!!qe[Wr(t)]}function eo(t){if(typeof t=="function"){return t}if(t==null){return Af}if(typeof t=="object"){return cu(t)?ao(t[0],t[1]):so(t)}return Kf(t)}function io(t){if(!da(t)){return Be(t)}var e=[];for(var i in ie(t)){if(he.call(t,i)&&i!="constructor"){e.push(i)}}return e}function no(t){if(!Cu(t)){return ka(t)}var e=da(t),i=[];for(var n in t){if(!(n=="constructor"&&(e||!he.call(t,n)))){i.push(n)}}return i}function ro(t,e){return t<e}function oo(t,e){var i=-1,n=uu(t)?A(t.length):[];xr(t,(function(t,r,o){n[++i]=e(t,r,o)}));return n}function so(t){var e=Ys(t);if(e.length==1&&e[0][2]){return pa(e[0][0],e[0][1])}return function(i){return i===t||Gr(i,t,e)}}function ao(t,e){if(ca(t)&&va(e)){return pa(Aa(t),e)}return function(n){var r=bh(n,t);return r===i&&r===e?kh(n,t):Nr(e,r,v|p)}}function co(t,e,n,r,o){if(t===e){return}_r(e,(function(s,a){o||(o=new Jn);if(Cu(s)){lo(t,e,a,n,co,r,o)}else{var c=r?r(za(t,a),s,a+"",t,e,o):i;if(c===i){c=s}cr(t,a,c)}}),zh)}function lo(t,e,n,r,o,s,a){var c=za(t,n),l=za(e,n),u=a.get(l);if(u){cr(t,n,u);return}var h=s?s(c,l,n+"",t,e,a):i;var f=h===i;if(f){var d=cu(l),v=!d&&du(l),p=!d&&!v&&Pu(l);h=l;if(d||v||p){if(cu(c)){h=c}else if(hu(c)){h=rs(c)}else if(v){f=false;h=Xo(l,true)}else if(p){f=false;h=Qo(l,true)}else{h=[]}}else if(Ou(l)||au(l)){h=c;if(au(c)){h=Zu(c)}else if(!Cu(c)||mu(c)){h=ia(l)}}else{f=false}}if(f){a.set(l,h);o(h,l,r,s,a);a["delete"](l)}cr(t,n,h)}function uo(t,e){var n=t.length;if(!n){return}e+=e<0?n:0;return sa(e,n)?t[e]:i}function ho(t,e,i){if(e.length){e=Mi(e,(function(t){if(cu(t)){return function(e){return Or(e,t.length===1?t[0]:t)}}return t}))}else{e=[Af]}var n=-1;e=Mi(e,Ni(Ks()));var r=oo(t,(function(t,i,r){var o=Mi(e,(function(e){return e(t)}));return{criteria:o,index:++n,value:t}}));return Vi(r,(function(t,e){return es(t,e,i)}))}function fo(t,e){return vo(t,e,(function(e,i){return kh(t,i)}))}function vo(t,e,i){var n=-1,r=e.length,o={};while(++n<r){var s=e[n],a=Or(t,s);if(i(a,s)){Co(o,Ko(s,t),a)}}return o}function po(t){return function(e){return Or(e,t)}}function bo(t,e,i,n){var r=n?Wi:Ri,o=-1,s=e.length,a=t;if(t===e){e=rs(e)}if(i){a=Mi(t,Ni(i))}while(++o<s){var c=0,l=e[o],u=i?i(l):l;while((c=r(a,u,c,n))>-1){if(a!==t){Me.call(a,c,1)}Me.call(t,c,1)}}return t}function go(t,e){var i=t?e.length:0,n=i-1;while(i--){var r=e[i];if(i==n||r!==o){var o=r;if(sa(r)){Me.call(t,r,1)}else{Wo(t,r)}}}return t}function ko(t,e){return t+Oe(Ye()*(e-t+1))}function yo(t,e,i,n){var r=-1,o=Pe(Ee((e-t)/(i||1)),0),s=A(o);while(o--){s[n?o:++r]=t;t+=i}return s}function wo(t,e){var i="";if(!t||e<1||e>R){return i}do{if(e%2){i+=t}e=Oe(e/2);if(e){t+=t}}while(e);return i}function mo(t,e){return ja(wa(t,e,Af),t+"")}function xo(t){return or(Lh(t))}function zo(t,e){var i=Lh(t);return _a(i,br(e,0,i.length))}function Co(t,e,n,r){if(!Cu(t)){return t}e=Ko(e,t);var o=-1,s=e.length,a=s-1,c=t;while(c!=null&&++o<s){var l=Aa(e[o]),u=n;if(l==="__proto__"||l==="constructor"||l==="prototype"){return t}if(o!=a){var h=c[l];u=r?r(h,l,c):i;if(u===i){u=Cu(h)?h:sa(e[o+1])?[]:{}}}lr(c,l,u);c=c[l]}return t}var Mo=!ai?Af:function(t,e){ai.set(t,e);return t};var jo=!_e?Af:function(t,e){return _e(t,"toString",{configurable:true,enumerable:false,value:If(e),writable:true})};function Io(t){return _a(Lh(t))}function So(t,e,i){var n=-1,r=t.length;if(e<0){e=-e>r?0:r+e}i=i>r?r:i;if(i<0){i+=r}r=e>i?0:i-e>>>0;e>>>=0;var o=A(r);while(++n<r){o[n]=t[n+e]}return o}function _o(t,e){var i;xr(t,(function(t,n,r){i=e(t,n,r);return!i}));return!!i}function To(t,e,i){var n=0,r=t==null?n:t.length;if(typeof e=="number"&&e===e&&r<=P){while(n<r){var o=n+r>>>1,s=t[o];if(s!==null&&!Bu(s)&&(i?s<=e:s<e)){n=o+1}else{r=o}}return r}return Ao(t,e,Af,i)}function Ao(t,e,n,r){var o=0,s=t==null?0:t.length;if(s===0){return 0}e=n(e);var a=e!==e,c=e===null,l=Bu(e),u=e===i;while(o<s){var h=Oe((o+s)/2),f=n(t[h]),d=f!==i,v=f===null,p=f===f,b=Bu(f);if(a){var g=r||p}else if(u){g=p&&(r||d)}else if(c){g=p&&d&&(r||!v)}else if(l){g=p&&d&&!v&&(r||!b)}else if(v||b){g=false}else{g=r?f<=e:f<e}if(g){o=h+1}else{s=h}}return Ue(s,B)}function $o(t,e){var i=-1,n=t.length,r=0,o=[];while(++i<n){var s=t[i],a=e?e(s):s;if(!i||!ru(a,c)){var c=a;o[r++]=s===0?0:s}}return o}function Eo(t){if(typeof t=="number"){return t}if(Bu(t)){return F}return+t}function Oo(t){if(typeof t=="string"){return t}if(cu(t)){return Mi(t,Oo)+""}if(Bu(t)){return mn?mn.call(t):""}var e=t+"";return e=="0"&&1/t==-Infinity?"-0":e}function Ro(t,e,i){var n=-1,o=zi,s=t.length,a=true,c=[],l=c;if(i){a=false;o=Ci}else if(s>=r){var u=e?null:_s(t);if(u){return un(u)}a=false;o=qi;l=new qn}else{l=e?[]:c}t:while(++n<s){var h=t[n],f=e?e(h):h;h=i||h!==0?h:0;if(a&&f===f){var d=l.length;while(d--){if(l[d]===f){continue t}}if(e){l.push(f)}c.push(h)}else if(!o(l,f,i)){if(l!==c){l.push(f)}c.push(h)}}return c}function Wo(t,e){e=Ko(e,t);t=ma(t,e);return t==null||delete t[Aa(oc(e))]}function Fo(t,e,i,n){return Co(t,e,i(Or(t,e)),n)}function Do(t,e,i,n){var r=t.length,o=n?r:-1;while((n?o--:++o<r)&&e(t[o],o,t)){}return i?So(t,n?0:o,n?o+1:r):So(t,n?o+1:0,n?r:o)}function Bo(t,e){var i=t;if(i instanceof In){i=i.value()}return Ii(e,(function(t,e){return e.func.apply(e.thisArg,ji([t],e.args))}),i)}function Po(t,e,i){var n=t.length;if(n<2){return n?Ro(t[0]):[]}var r=-1,o=A(n);while(++r<n){var s=t[r],a=-1;while(++a<n){if(a!=r){o[r]=mr(o[r]||s,t[a],e,i)}}}return Ro(Sr(o,1),e,i)}function Lo(t,e,n){var r=-1,o=t.length,s=e.length,a={};while(++r<o){var c=r<s?e[r]:i;n(a,t[r],c)}return a}function Vo(t){return hu(t)?t:[]}function Uo(t){return typeof t=="function"?t:Af}function Ko(t,e){if(cu(t)){return t}return ca(t,e)?[t]:Ta(Qu(t))}var Ho=mo;function Yo(t,e,n){var r=t.length;n=n===i?r:n;return!e&&n>=r?t:So(t,e,n)}var No=Te||function(t){return oi.clearTimeout(t)};function Xo(t,e){if(e){return t.slice()}var i=t.length,n=me?me(i):new t.constructor(i);t.copy(n);return n}function qo(t){var e=new t.constructor(t.byteLength);new we(e).set(new we(t));return e}function Go(t,e){var i=e?qo(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}function Zo(t){var e=new t.constructor(t.source,Ht.exec(t));e.lastIndex=t.lastIndex;return e}function Jo(t){return yn?ie(yn.call(t)):{}}function Qo(t,e){var i=e?qo(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}function ts(t,e){if(t!==e){var n=t!==i,r=t===null,o=t===t,s=Bu(t);var a=e!==i,c=e===null,l=e===e,u=Bu(e);if(!c&&!u&&!s&&t>e||s&&a&&l&&!c&&!u||r&&a&&l||!n&&l||!o){return 1}if(!r&&!s&&!u&&t<e||u&&n&&o&&!r&&!s||c&&n&&o||!a&&o||!l){return-1}}return 0}function es(t,e,i){var n=-1,r=t.criteria,o=e.criteria,s=r.length,a=i.length;while(++n<s){var c=ts(r[n],o[n]);if(c){if(n>=a){return c}var l=i[n];return c*(l=="desc"?-1:1)}}return t.index-e.index}function is(t,e,i,n){var r=-1,o=t.length,s=i.length,a=-1,c=e.length,l=Pe(o-s,0),u=A(c+l),h=!n;while(++a<c){u[a]=e[a]}while(++r<s){if(h||r<o){u[i[r]]=t[r]}}while(l--){u[a++]=t[r++]}return u}function ns(t,e,i,n){var r=-1,o=t.length,s=-1,a=i.length,c=-1,l=e.length,u=Pe(o-a,0),h=A(u+l),f=!n;while(++r<u){h[r]=t[r]}var d=r;while(++c<l){h[d+c]=e[c]}while(++s<a){if(f||r<o){h[d+i[s]]=t[r++]}}return h}function rs(t,e){var i=-1,n=t.length;e||(e=A(n));while(++i<n){e[i]=t[i]}return e}function os(t,e,n,r){var o=!n;n||(n={});var s=-1,a=e.length;while(++s<a){var c=e[s];var l=r?r(n[c],t[c],c,n,t):i;if(l===i){l=t[c]}if(o){vr(n,c,l)}else{lr(n,c,l)}}return n}function ss(t,e){return os(t,qs(t),e)}function as(t,e){return os(t,Gs(t),e)}function cs(t,e){return function(i,n){var r=cu(i)?ki:hr,o=e?e():{};return r(i,t,Ks(n,2),o)}}function ls(t){return mo((function(e,n){var r=-1,o=n.length,s=o>1?n[o-1]:i,a=o>2?n[2]:i;s=t.length>3&&typeof s=="function"?(o--,s):i;if(a&&aa(n[0],n[1],a)){s=o<3?i:s;o=1}e=ie(e);while(++r<o){var c=n[r];if(c){t(e,c,r,s)}}return e}))}function us(t,e){return function(i,n){if(i==null){return i}if(!uu(i)){return t(i,n)}var r=i.length,o=e?r:-1,s=ie(i);while(e?o--:++o<r){if(n(s[o],o,s)===false){break}}return i}}function hs(t){return function(e,i,n){var r=-1,o=ie(e),s=n(e),a=s.length;while(a--){var c=s[t?a:++r];if(i(o[c],c,o)===false){break}}return e}}function fs(t,e,i){var n=e&b,r=ps(t);function o(){var e=this&&this!==oi&&this instanceof o?r:t;return e.apply(n?i:this,arguments)}return o}function ds(t){return function(e){e=Qu(e);var n=rn(e)?pn(e):i;var r=n?n[0]:e.charAt(0);var o=n?Yo(n,1).join(""):e.slice(1);return r[t]()+o}}function vs(t){return function(e){return Ii(xf(Xh(e).replace(Le,"")),t,"")}}function ps(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var i=Cn(t.prototype),n=t.apply(i,e);return Cu(n)?n:i}}function bs(t,e,n){var r=ps(t);function o(){var s=arguments.length,a=A(s),c=s,l=Us(o);while(c--){a[c]=arguments[c]}var u=s<3&&a[0]!==l&&a[s-1]!==l?[]:ln(a,l);s-=u.length;if(s<n){return Is(t,e,ys,o.placeholder,i,a,u,i,i,n-s)}var h=this&&this!==oi&&this instanceof o?r:t;return gi(h,this,a)}return o}function gs(t){return function(e,n,r){var o=ie(e);if(!uu(e)){var s=Ks(n,3);e=xh(e);n=function(t){return s(o[t],t,o)}}var a=t(e,n,r);return a>-1?o[s?e[a]:a]:i}}function ks(t){return Ds((function(e){var n=e.length,r=n,o=jn.prototype.thru;if(t){e.reverse()}while(r--){var a=e[r];if(typeof a!="function"){throw new oe(s)}if(o&&!c&&Vs(a)=="wrapper"){var c=new jn([],true)}}r=c?r:n;while(++r<n){a=e[r];var l=Vs(a),u=l=="wrapper"?Ls(a):i;if(u&&ua(u[0])&&u[1]==(z|y|m|C)&&!u[4].length&&u[9]==1){c=c[Vs(u[0])].apply(c,u[3])}else{c=a.length==1&&ua(a)?c[l]():c.thru(a)}}return function(){var t=arguments,i=t[0];if(c&&t.length==1&&cu(i)){return c.plant(i).value()}var r=0,o=n?e[r].apply(this,t):i;while(++r<n){o=e[r].call(this,o)}return o}}))}function ys(t,e,n,r,o,s,a,c,l,u){var h=e&z,f=e&b,d=e&g,v=e&(y|w),p=e&M,k=d?i:ps(t);function m(){var i=arguments.length,b=A(i),g=i;while(g--){b[g]=arguments[g]}if(v){var y=Us(m),w=Ji(b,y)}if(r){b=is(b,r,o,v)}if(s){b=ns(b,s,a,v)}i-=w;if(v&&i<u){var x=ln(b,y);return Is(t,e,ys,m.placeholder,n,b,x,c,l,u-i)}var z=f?n:this,C=d?z[t]:t;i=b.length;if(c){b=xa(b,c)}else if(p&&i>1){b.reverse()}if(h&&l<i){b.length=l}if(this&&this!==oi&&this instanceof m){C=k||ps(C)}return C.apply(z,b)}return m}function ws(t,e){return function(i,n){return Vr(i,t,e(n),{})}}function ms(t,e){return function(n,r){var o;if(n===i&&r===i){return e}if(n!==i){o=n}if(r!==i){if(o===i){return r}if(typeof n=="string"||typeof r=="string"){n=Oo(n);r=Oo(r)}else{n=Eo(n);r=Eo(r)}o=t(n,r)}return o}}function xs(t){return Ds((function(e){e=Mi(e,Ni(Ks()));return mo((function(i){var n=this;return t(e,(function(t){return gi(t,n,i)}))}))}))}function zs(t,e){e=e===i?" ":Oo(e);var n=e.length;if(n<2){return n?wo(e,t):e}var r=wo(e,Ee(t/vn(e)));return rn(e)?Yo(pn(r),0,t).join(""):r.slice(0,t)}function Cs(t,e,i,n){var r=e&b,o=ps(t);function s(){var e=-1,a=arguments.length,c=-1,l=n.length,u=A(l+a),h=this&&this!==oi&&this instanceof s?o:t;while(++c<l){u[c]=n[c]}while(a--){u[c++]=arguments[++e]}return gi(h,r?i:this,u)}return s}function Ms(t){return function(e,n,r){if(r&&typeof r!="number"&&aa(e,n,r)){n=r=i}e=Nu(e);if(n===i){n=e;e=0}else{n=Nu(n)}r=r===i?e<n?1:-1:Nu(r);return yo(e,n,r,t)}}function js(t){return function(e,i){if(!(typeof e=="string"&&typeof i=="string")){e=Gu(e);i=Gu(i)}return t(e,i)}}function Is(t,e,n,r,o,s,a,c,l,u){var h=e&y,f=h?a:i,d=h?i:a,v=h?s:i,p=h?i:s;e|=h?m:x;e&=~(h?x:m);if(!(e&k)){e&=-4}var b=[t,e,o,v,f,p,d,c,l,u];var g=n.apply(i,b);if(ua(t)){Ca(g,b)}g.placeholder=r;return Ia(g,t,e)}function Ss(t){var e=ee[t];return function(t,i){t=Gu(t);i=i==null?0:Ue(Xu(i),292);if(i&&Fe(t)){var n=(Qu(t)+"e").split("e"),r=e(n[0]+"e"+(+n[1]+i));n=(Qu(r)+"e").split("e");return+(n[0]+"e"+(+n[1]-i))}return e(t)}}var _s=!(ni&&1/un(new ni([,-0]))[1]==O)?Bf:function(t){return new ni(t)};function Ts(t){return function(e){var i=Zs(e);if(i==Z){return an(e)}if(i==rt){return hn(e)}return Hi(e,t(e))}}function As(t,e,n,r,o,a,c,l){var u=e&g;if(!u&&typeof t!="function"){throw new oe(s)}var h=r?r.length:0;if(!h){e&=-97;r=o=i}c=c===i?c:Pe(Xu(c),0);l=l===i?l:Xu(l);h-=o?o.length:0;if(e&x){var f=r,d=o;r=o=i}var v=u?i:Ls(t);var p=[t,e,n,r,o,f,d,a,c,l];if(v){ga(p,v)}t=p[0];e=p[1];n=p[2];r=p[3];o=p[4];l=p[9]=p[9]===i?u?0:t.length:Pe(p[9]-h,0);if(!l&&e&(y|w)){e&=-25}if(!e||e==b){var k=fs(t,e,n)}else if(e==y||e==w){k=bs(t,e,l)}else if((e==m||e==(b|m))&&!o.length){k=Cs(t,e,n,r)}else{k=ys.apply(i,p)}var z=v?Mo:Ca;return Ia(z(k,p),t,e)}function $s(t,e,n,r){if(t===i||ru(t,ce[n])&&!he.call(r,n)){return e}return t}function Es(t,e,n,r,o,s){if(Cu(t)&&Cu(e)){s.set(e,t);co(t,e,i,Es,s);s["delete"](e)}return t}function Os(t){return Ou(t)?i:t}function Rs(t,e,n,r,o,s){var a=n&v,c=t.length,l=e.length;if(c!=l&&!(a&&l>c)){return false}var u=s.get(t);var h=s.get(e);if(u&&h){return u==e&&h==t}var f=-1,d=true,b=n&p?new qn:i;s.set(t,e);s.set(e,t);while(++f<c){var g=t[f],k=e[f];if(r){var y=a?r(k,g,f,e,t,s):r(g,k,f,t,e,s)}if(y!==i){if(y){continue}d=false;break}if(b){if(!_i(e,(function(t,e){if(!qi(b,e)&&(g===t||o(g,t,n,r,s))){return b.push(e)}}))){d=false;break}}else if(!(g===k||o(g,k,n,r,s))){d=false;break}}s["delete"](t);s["delete"](e);return d}function Ws(t,e,i,n,r,o,s){switch(i){case ht:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset){return false}t=t.buffer;e=e.buffer;case ut:if(t.byteLength!=e.byteLength||!o(new we(t),new we(e))){return false}return true;case H:case Y:case J:return ru(+t,+e);case X:return t.name==e.name&&t.message==e.message;case nt:case ot:return t==e+"";case Z:var a=an;case rt:var c=n&v;a||(a=un);if(t.size!=e.size&&!c){return false}var l=s.get(t);if(l){return l==e}n|=p;s.set(t,e);var u=Rs(a(t),a(e),n,r,o,s);s["delete"](t);return u;case st:if(yn){return yn.call(t)==yn.call(e)}}return false}function Fs(t,e,n,r,o,s){var a=n&v,c=Bs(t),l=c.length,u=Bs(e),h=u.length;if(l!=h&&!a){return false}var f=l;while(f--){var d=c[f];if(!(a?d in e:he.call(e,d))){return false}}var p=s.get(t);var b=s.get(e);if(p&&b){return p==e&&b==t}var g=true;s.set(t,e);s.set(e,t);var k=a;while(++f<l){d=c[f];var y=t[d],w=e[d];if(r){var m=a?r(w,y,d,e,t,s):r(y,w,d,t,e,s)}if(!(m===i?y===w||o(y,w,n,r,s):m)){g=false;break}k||(k=d=="constructor")}if(g&&!k){var x=t.constructor,z=e.constructor;if(x!=z&&("constructor"in t&&"constructor"in e)&&!(typeof x=="function"&&x instanceof x&&typeof z=="function"&&z instanceof z)){g=false}}s["delete"](t);s["delete"](e);return g}function Ds(t){return ja(wa(t,i,Xa),t+"")}function Bs(t){return Rr(t,xh,qs)}function Ps(t){return Rr(t,zh,Gs)}var Ls=!ai?Bf:function(t){return ai.get(t)};function Vs(t){var e=t.name+"",i=li[e],n=he.call(li,e)?i.length:0;while(n--){var r=i[n],o=r.func;if(o==null||o==t){return r.name}}return e}function Us(t){var e=he.call(zn,"placeholder")?zn:t;return e.placeholder}function Ks(){var t=zn.iteratee||$f;t=t===$f?eo:t;return arguments.length?t(arguments[0],arguments[1]):t}function Hs(t,e){var i=t.__data__;return la(e)?i[typeof e=="string"?"string":"hash"]:i.map}function Ys(t){var e=xh(t),i=e.length;while(i--){var n=e[i],r=t[n];e[i]=[n,r,va(r)]}return e}function Ns(t,e){var n=nn(t,e);return Zr(n)?n:i}function Xs(t){var e=he.call(t,Se),n=t[Se];try{t[Se]=i;var r=true}catch(t){}var o=ve.call(t);if(r){if(e){t[Se]=n}else{delete t[Se]}}return o}var qs=!Re?Xf:function(t){if(t==null){return[]}t=ie(t);return xi(Re(t),(function(e){return Ce.call(t,e)}))};var Gs=!Re?Xf:function(t){var e=[];while(t){ji(e,qs(t));t=xe(t)}return e};var Zs=Wr;if(Je&&Zs(new Je(new ArrayBuffer(1)))!=ht||Qe&&Zs(new Qe)!=Z||ti&&Zs(ti.resolve())!=et||ni&&Zs(new ni)!=rt||ri&&Zs(new ri)!=ct){Zs=function(t){var e=Wr(t),n=e==tt?t.constructor:i,r=n?$a(n):"";if(r){switch(r){case ui:return ht;case Ti:return Z;case Ai:return et;case Pi:return rt;case fn:return ct}}return e}}function Js(t,e,i){var n=-1,r=i.length;while(++n<r){var o=i[n],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=Ue(e,t+s);break;case"takeRight":t=Pe(t,e-s);break}}return{start:t,end:e}}function Qs(t){var e=t.match(Bt);return e?e[1].split(Pt):[]}function ta(t,e,i){e=Ko(e,t);var n=-1,r=e.length,o=false;while(++n<r){var s=Aa(e[n]);if(!(o=t!=null&&i(t,s))){break}t=t[s]}if(o||++n!=r){return o}r=t==null?0:t.length;return!!r&&zu(r)&&sa(s,r)&&(cu(t)||au(t))}function ea(t){var e=t.length,i=new t.constructor(e);if(e&&typeof t[0]=="string"&&he.call(t,"index")){i.index=t.index;i.input=t.input}return i}function ia(t){return typeof t.constructor=="function"&&!da(t)?Cn(xe(t)):{}}function na(t,e,i){var n=t.constructor;switch(e){case ut:return qo(t);case H:case Y:return new n(+t);case ht:return Go(t,i);case ft:case dt:case vt:case pt:case bt:case gt:case kt:case yt:case wt:return Qo(t,i);case Z:return new n;case J:case ot:return new n(t);case nt:return Zo(t);case rt:return new n;case st:return Jo(t)}}function ra(t,e){var i=e.length;if(!i){return t}var n=i-1;e[n]=(i>1?"& ":"")+e[n];e=e.join(i>2?", ":" ");return t.replace(Dt,"{\n/* [wrapped with "+e+"] */\n")}function oa(t){return cu(t)||au(t)||!!(je&&t&&t[je])}function sa(t,e){var i=typeof t;e=e==null?R:e;return!!e&&(i=="number"||i!="symbol"&&Gt.test(t))&&(t>-1&&t%1==0&&t<e)}function aa(t,e,i){if(!Cu(i)){return false}var n=typeof e;if(n=="number"?uu(i)&&sa(e,i.length):n=="string"&&e in i){return ru(i[e],t)}return false}function ca(t,e){if(cu(t)){return false}var i=typeof t;if(i=="number"||i=="symbol"||i=="boolean"||t==null||Bu(t)){return true}return $t.test(t)||!At.test(t)||e!=null&&t in ie(e)}function la(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function ua(t){var e=Vs(t),i=zn[e];if(typeof i!="function"||!(e in In.prototype)){return false}if(t===i){return true}var n=Ls(i);return!!n&&t===n[0]}function ha(t){return!!de&&de in t}var fa=le?mu:qf;function da(t){var e=t&&t.constructor,i=typeof e=="function"&&e.prototype||ce;return t===i}function va(t){return t===t&&!Cu(t)}function pa(t,e){return function(n){if(n==null){return false}return n[t]===e&&(e!==i||t in ie(n))}}function ba(t){var e=Pl(t,(function(t){if(i.size===l){i.clear()}return t}));var i=e.cache;return e}function ga(t,e){var i=t[1],n=e[1],r=i|n,o=r<(b|g|z);var s=n==z&&i==y||n==z&&i==C&&t[7].length<=e[8]||n==(z|C)&&e[7].length<=e[8]&&i==y;if(!(o||s)){return t}if(n&b){t[2]=e[2];r|=i&b?0:k}var a=e[3];if(a){var c=t[3];t[3]=c?is(c,a,e[4]):a;t[4]=c?ln(t[3],u):e[4]}a=e[5];if(a){c=t[5];t[5]=c?ns(c,a,e[6]):a;t[6]=c?ln(t[5],u):e[6]}a=e[7];if(a){t[7]=a}if(n&z){t[8]=t[8]==null?e[8]:Ue(t[8],e[8])}if(t[9]==null){t[9]=e[9]}t[0]=e[0];t[1]=r;return t}function ka(t){var e=[];if(t!=null){for(var i in ie(t)){e.push(i)}}return e}function ya(t){return ve.call(t)}function wa(t,e,n){e=Pe(e===i?t.length-1:e,0);return function(){var i=arguments,r=-1,o=Pe(i.length-e,0),s=A(o);while(++r<o){s[r]=i[e+r]}r=-1;var a=A(e+1);while(++r<e){a[r]=i[r]}a[e]=n(s);return gi(t,this,a)}}function ma(t,e){return e.length<2?t:Or(t,So(e,0,-1))}function xa(t,e){var n=t.length,r=Ue(e.length,n),o=rs(t);while(r--){var s=e[r];t[r]=sa(s,n)?o[s]:i}return t}function za(t,e){if(e==="constructor"&&typeof t[e]==="function"){return}if(e=="__proto__"){return}return t[e]}var Ca=Sa(Mo);var Ma=$e||function(t,e){return oi.setTimeout(t,e)};var ja=Sa(jo);function Ia(t,e,i){var n=e+"";return ja(t,ra(n,Ea(Qs(n),i)))}function Sa(t){var e=0,n=0;return function(){var r=Ke(),o=_-(r-n);n=r;if(o>0){if(++e>=S){return arguments[0]}}else{e=0}return t.apply(i,arguments)}}function _a(t,e){var n=-1,r=t.length,o=r-1;e=e===i?r:e;while(++n<e){var s=ko(n,o),a=t[s];t[s]=t[n];t[n]=a}t.length=e;return t}var Ta=ba((function(t){var e=[];if(t.charCodeAt(0)===46){e.push("")}t.replace(Et,(function(t,i,n,r){e.push(n?r.replace(Ut,"$1"):i||t)}));return e}));function Aa(t){if(typeof t=="string"||Bu(t)){return t}var e=t+"";return e=="0"&&1/t==-Infinity?"-0":e}function $a(t){if(t!=null){try{return ue.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Ea(t,e){yi(L,(function(i){var n="_."+i[0];if(e&i[1]&&!zi(t,n)){t.push(n)}}));return t.sort()}function Oa(t){if(t instanceof In){return t.clone()}var e=new jn(t.__wrapped__,t.__chain__);e.__actions__=rs(t.__actions__);e.__index__=t.__index__;e.__values__=t.__values__;return e}function Ra(t,e,n){if(n?aa(t,e,n):e===i){e=1}else{e=Pe(Xu(e),0)}var r=t==null?0:t.length;if(!r||e<1){return[]}var o=0,s=0,a=A(Ee(r/e));while(o<r){a[s++]=So(t,o,o+=e)}return a}function Wa(t){var e=-1,i=t==null?0:t.length,n=0,r=[];while(++e<i){var o=t[e];if(o){r[n++]=o}}return r}function Fa(){var t=arguments.length;if(!t){return[]}var e=A(t-1),i=arguments[0],n=t;while(n--){e[n-1]=arguments[n]}return ji(cu(i)?rs(i):[i],Sr(e,1))}var Da=mo((function(t,e){return hu(t)?mr(t,Sr(e,1,hu,true)):[]}));var Ba=mo((function(t,e){var n=oc(e);if(hu(n)){n=i}return hu(t)?mr(t,Sr(e,1,hu,true),Ks(n,2)):[]}));var Pa=mo((function(t,e){var n=oc(e);if(hu(n)){n=i}return hu(t)?mr(t,Sr(e,1,hu,true),i,n):[]}));function La(t,e,n){var r=t==null?0:t.length;if(!r){return[]}e=n||e===i?1:Xu(e);return So(t,e<0?0:e,r)}function Va(t,e,n){var r=t==null?0:t.length;if(!r){return[]}e=n||e===i?1:Xu(e);e=r-e;return So(t,0,e<0?0:e)}function Ua(t,e){return t&&t.length?Do(t,Ks(e,3),true,true):[]}function Ka(t,e){return t&&t.length?Do(t,Ks(e,3),true):[]}function Ha(t,e,i,n){var r=t==null?0:t.length;if(!r){return[]}if(i&&typeof i!="number"&&aa(t,e,i)){i=0;n=r}return jr(t,e,i,n)}function Ya(t,e,i){var n=t==null?0:t.length;if(!n){return-1}var r=i==null?0:Xu(i);if(r<0){r=Pe(n+r,0)}return Oi(t,Ks(e,3),r)}function Na(t,e,n){var r=t==null?0:t.length;if(!r){return-1}var o=r-1;if(n!==i){o=Xu(n);o=n<0?Pe(r+o,0):Ue(o,r-1)}return Oi(t,Ks(e,3),o,true)}function Xa(t){var e=t==null?0:t.length;return e?Sr(t,1):[]}function qa(t){var e=t==null?0:t.length;return e?Sr(t,O):[]}function Ga(t,e){var n=t==null?0:t.length;if(!n){return[]}e=e===i?1:Xu(e);return Sr(t,e)}function Za(t){var e=-1,i=t==null?0:t.length,n={};while(++e<i){var r=t[e];n[r[0]]=r[1]}return n}function Ja(t){return t&&t.length?t[0]:i}function Qa(t,e,i){var n=t==null?0:t.length;if(!n){return-1}var r=i==null?0:Xu(i);if(r<0){r=Pe(n+r,0)}return Ri(t,e,r)}function tc(t){var e=t==null?0:t.length;return e?So(t,0,-1):[]}var ec=mo((function(t){var e=Mi(t,Vo);return e.length&&e[0]===t[0]?Lr(e):[]}));var ic=mo((function(t){var e=oc(t),n=Mi(t,Vo);if(e===oc(n)){e=i}else{n.pop()}return n.length&&n[0]===t[0]?Lr(n,Ks(e,2)):[]}));var nc=mo((function(t){var e=oc(t),n=Mi(t,Vo);e=typeof e=="function"?e:i;if(e){n.pop()}return n.length&&n[0]===t[0]?Lr(n,i,e):[]}));function rc(t,e){return t==null?"":De.call(t,e)}function oc(t){var e=t==null?0:t.length;return e?t[e-1]:i}function sc(t,e,n){var r=t==null?0:t.length;if(!r){return-1}var o=r;if(n!==i){o=Xu(n);o=o<0?Pe(r+o,0):Ue(o,r-1)}return e===e?dn(t,e,o):Oi(t,Fi,o,true)}function ac(t,e){return t&&t.length?uo(t,Xu(e)):i}var cc=mo(lc);function lc(t,e){return t&&t.length&&e&&e.length?bo(t,e):t}function uc(t,e,i){return t&&t.length&&e&&e.length?bo(t,e,Ks(i,2)):t}function hc(t,e,n){return t&&t.length&&e&&e.length?bo(t,e,i,n):t}var fc=Ds((function(t,e){var i=t==null?0:t.length,n=pr(t,e);go(t,Mi(e,(function(t){return sa(t,i)?+t:t})).sort(ts));return n}));function dc(t,e){var i=[];if(!(t&&t.length)){return i}var n=-1,r=[],o=t.length;e=Ks(e,3);while(++n<o){var s=t[n];if(e(s,n,t)){i.push(s);r.push(n)}}go(t,r);return i}function vc(t){return t==null?t:Ze.call(t)}function pc(t,e,n){var r=t==null?0:t.length;if(!r){return[]}if(n&&typeof n!="number"&&aa(t,e,n)){e=0;n=r}else{e=e==null?0:Xu(e);n=n===i?r:Xu(n)}return So(t,e,n)}function bc(t,e){return To(t,e)}function gc(t,e,i){return Ao(t,e,Ks(i,2))}function kc(t,e){var i=t==null?0:t.length;if(i){var n=To(t,e);if(n<i&&ru(t[n],e)){return n}}return-1}function yc(t,e){return To(t,e,true)}function wc(t,e,i){return Ao(t,e,Ks(i,2),true)}function mc(t,e){var i=t==null?0:t.length;if(i){var n=To(t,e,true)-1;if(ru(t[n],e)){return n}}return-1}function xc(t){return t&&t.length?$o(t):[]}function zc(t,e){return t&&t.length?$o(t,Ks(e,2)):[]}function Cc(t){var e=t==null?0:t.length;return e?So(t,1,e):[]}function Mc(t,e,n){if(!(t&&t.length)){return[]}e=n||e===i?1:Xu(e);return So(t,0,e<0?0:e)}function jc(t,e,n){var r=t==null?0:t.length;if(!r){return[]}e=n||e===i?1:Xu(e);e=r-e;return So(t,e<0?0:e,r)}function Ic(t,e){return t&&t.length?Do(t,Ks(e,3),false,true):[]}function Sc(t,e){return t&&t.length?Do(t,Ks(e,3)):[]}var _c=mo((function(t){return Ro(Sr(t,1,hu,true))}));var Tc=mo((function(t){var e=oc(t);if(hu(e)){e=i}return Ro(Sr(t,1,hu,true),Ks(e,2))}));var Ac=mo((function(t){var e=oc(t);e=typeof e=="function"?e:i;return Ro(Sr(t,1,hu,true),i,e)}));function $c(t){return t&&t.length?Ro(t):[]}function Ec(t,e){return t&&t.length?Ro(t,Ks(e,2)):[]}function Oc(t,e){e=typeof e=="function"?e:i;return t&&t.length?Ro(t,i,e):[]}function Rc(t){if(!(t&&t.length)){return[]}var e=0;t=xi(t,(function(t){if(hu(t)){e=Pe(t.length,e);return true}}));return Ki(e,(function(e){return Mi(t,Bi(e))}))}function Wc(t,e){if(!(t&&t.length)){return[]}var n=Rc(t);if(e==null){return n}return Mi(n,(function(t){return gi(e,i,t)}))}var Fc=mo((function(t,e){return hu(t)?mr(t,e):[]}));var Dc=mo((function(t){return Po(xi(t,hu))}));var Bc=mo((function(t){var e=oc(t);if(hu(e)){e=i}return Po(xi(t,hu),Ks(e,2))}));var Pc=mo((function(t){var e=oc(t);e=typeof e=="function"?e:i;return Po(xi(t,hu),i,e)}));var Lc=mo(Rc);function Vc(t,e){return Lo(t||[],e||[],lr)}function Uc(t,e){return Lo(t||[],e||[],Co)}var Kc=mo((function(t){var e=t.length,n=e>1?t[e-1]:i;n=typeof n=="function"?(t.pop(),n):i;return Wc(t,n)}));function Hc(t){var e=zn(t);e.__chain__=true;return e}function Yc(t,e){e(t);return t}function Nc(t,e){return e(t)}var Xc=Ds((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,o=function(e){return pr(e,t)};if(e>1||this.__actions__.length||!(r instanceof In)||!sa(n)){return this.thru(o)}r=r.slice(n,+n+(e?1:0));r.__actions__.push({func:Nc,args:[o],thisArg:i});return new jn(r,this.__chain__).thru((function(t){if(e&&!t.length){t.push(i)}return t}))}));function qc(){return Hc(this)}function Gc(){return new jn(this.value(),this.__chain__)}function Zc(){if(this.__values__===i){this.__values__=Yu(this.value())}var t=this.__index__>=this.__values__.length,e=t?i:this.__values__[this.__index__++];return{done:t,value:e}}function Jc(){return this}function Qc(t){var e,n=this;while(n instanceof Mn){var r=Oa(n);r.__index__=0;r.__values__=i;if(e){o.__wrapped__=r}else{e=r}var o=r;n=n.__wrapped__}o.__wrapped__=t;return e}function tl(){var t=this.__wrapped__;if(t instanceof In){var e=t;if(this.__actions__.length){e=new In(this)}e=e.reverse();e.__actions__.push({func:Nc,args:[vc],thisArg:i});return new jn(e,this.__chain__)}return this.thru(vc)}function el(){return Bo(this.__wrapped__,this.__actions__)}var il=cs((function(t,e,i){if(he.call(t,i)){++t[i]}else{vr(t,i,1)}}));function nl(t,e,n){var r=cu(t)?mi:Cr;if(n&&aa(t,e,n)){e=i}return r(t,Ks(e,3))}function rl(t,e){var i=cu(t)?xi:Ir;return i(t,Ks(e,3))}var ol=gs(Ya);var sl=gs(Na);function al(t,e){return Sr(bl(t,e),1)}function cl(t,e){return Sr(bl(t,e),O)}function ll(t,e,n){n=n===i?1:Xu(n);return Sr(bl(t,e),n)}function ul(t,e){var i=cu(t)?yi:xr;return i(t,Ks(e,3))}function hl(t,e){var i=cu(t)?wi:zr;return i(t,Ks(e,3))}var fl=cs((function(t,e,i){if(he.call(t,i)){t[i].push(e)}else{vr(t,i,[e])}}));function dl(t,e,i,n){t=uu(t)?t:Lh(t);i=i&&!n?Xu(i):0;var r=t.length;if(i<0){i=Pe(r+i,0)}return Du(t)?i<=r&&t.indexOf(e,i)>-1:!!r&&Ri(t,e,i)>-1}var vl=mo((function(t,e,i){var n=-1,r=typeof e=="function",o=uu(t)?A(t.length):[];xr(t,(function(t){o[++n]=r?gi(e,t,i):Ur(t,e,i)}));return o}));var pl=cs((function(t,e,i){vr(t,i,e)}));function bl(t,e){var i=cu(t)?Mi:oo;return i(t,Ks(e,3))}function gl(t,e,n,r){if(t==null){return[]}if(!cu(e)){e=e==null?[]:[e]}n=r?i:n;if(!cu(n)){n=n==null?[]:[n]}return ho(t,e,n)}var kl=cs((function(t,e,i){t[i?0:1].push(e)}),(function(){return[[],[]]}));function yl(t,e,i){var n=cu(t)?Ii:Li,r=arguments.length<3;return n(t,Ks(e,4),i,r,xr)}function wl(t,e,i){var n=cu(t)?Si:Li,r=arguments.length<3;return n(t,Ks(e,4),i,r,zr)}function ml(t,e){var i=cu(t)?xi:Ir;return i(t,Ll(Ks(e,3)))}function xl(t){var e=cu(t)?or:xo;return e(t)}function zl(t,e,n){if(n?aa(t,e,n):e===i){e=1}else{e=Xu(e)}var r=cu(t)?sr:zo;return r(t,e)}function Cl(t){var e=cu(t)?ar:Io;return e(t)}function Ml(t){if(t==null){return 0}if(uu(t)){return Du(t)?vn(t):t.length}var e=Zs(t);if(e==Z||e==rt){return t.size}return io(t).length}function jl(t,e,n){var r=cu(t)?_i:_o;if(n&&aa(t,e,n)){e=i}return r(t,Ks(e,3))}var Il=mo((function(t,e){if(t==null){return[]}var i=e.length;if(i>1&&aa(t,e[0],e[1])){e=[]}else if(i>2&&aa(e[0],e[1],e[2])){e=[e[0]]}return ho(t,Sr(e,1),[])}));var Sl=Ae||function(){return oi.Date.now()};function _l(t,e){if(typeof e!="function"){throw new oe(s)}t=Xu(t);return function(){if(--t<1){return e.apply(this,arguments)}}}function Tl(t,e,n){e=n?i:e;e=t&&e==null?t.length:e;return As(t,z,i,i,i,i,e)}function Al(t,e){var n;if(typeof e!="function"){throw new oe(s)}t=Xu(t);return function(){if(--t>0){n=e.apply(this,arguments)}if(t<=1){e=i}return n}}var $l=mo((function(t,e,i){var n=b;if(i.length){var r=ln(i,Us($l));n|=m}return As(t,n,e,i,r)}));var El=mo((function(t,e,i){var n=b|g;if(i.length){var r=ln(i,Us(El));n|=m}return As(e,n,t,i,r)}));function Ol(t,e,n){e=n?i:e;var r=As(t,y,i,i,i,i,i,e);r.placeholder=Ol.placeholder;return r}function Rl(t,e,n){e=n?i:e;var r=As(t,w,i,i,i,i,i,e);r.placeholder=Rl.placeholder;return r}function Wl(t,e,n){var r,o,a,c,l,u,h=0,f=false,d=false,v=true;if(typeof t!="function"){throw new oe(s)}e=Gu(e)||0;if(Cu(n)){f=!!n.leading;d="maxWait"in n;a=d?Pe(Gu(n.maxWait)||0,e):a;v="trailing"in n?!!n.trailing:v}function p(e){var n=r,s=o;r=o=i;h=e;c=t.apply(s,n);return c}function b(t){h=t;l=Ma(y,e);return f?p(t):c}function g(t){var i=t-u,n=t-h,r=e-i;return d?Ue(r,a-n):r}function k(t){var n=t-u,r=t-h;return u===i||n>=e||n<0||d&&r>=a}function y(){var t=Sl();if(k(t)){return w(t)}l=Ma(y,g(t))}function w(t){l=i;if(v&&r){return p(t)}r=o=i;return c}function m(){if(l!==i){No(l)}h=0;r=u=o=l=i}function x(){return l===i?c:w(Sl())}function z(){var t=Sl(),n=k(t);r=arguments;o=this;u=t;if(n){if(l===i){return b(u)}if(d){No(l);l=Ma(y,e);return p(u)}}if(l===i){l=Ma(y,e)}return c}z.cancel=m;z.flush=x;return z}var Fl=mo((function(t,e){return wr(t,1,e)}));var Dl=mo((function(t,e,i){return wr(t,Gu(e)||0,i)}));function Bl(t){return As(t,M)}function Pl(t,e){if(typeof t!="function"||e!=null&&typeof e!="function"){throw new oe(s)}var i=function(){var n=arguments,r=e?e.apply(this,n):n[0],o=i.cache;if(o.has(r)){return o.get(r)}var s=t.apply(this,n);i.cache=o.set(r,s)||o;return s};i.cache=new(Pl.Cache||Un);return i}Pl.Cache=Un;function Ll(t){if(typeof t!="function"){throw new oe(s)}return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Vl(t){return Al(2,t)}var Ul=Ho((function(t,e){e=e.length==1&&cu(e[0])?Mi(e[0],Ni(Ks())):Mi(Sr(e,1),Ni(Ks()));var i=e.length;return mo((function(n){var r=-1,o=Ue(n.length,i);while(++r<o){n[r]=e[r].call(this,n[r])}return gi(t,this,n)}))}));var Kl=mo((function(t,e){var n=ln(e,Us(Kl));return As(t,m,i,e,n)}));var Hl=mo((function(t,e){var n=ln(e,Us(Hl));return As(t,x,i,e,n)}));var Yl=Ds((function(t,e){return As(t,C,i,i,i,e)}));function Nl(t,e){if(typeof t!="function"){throw new oe(s)}e=e===i?e:Xu(e);return mo(t,e)}function Xl(t,e){if(typeof t!="function"){throw new oe(s)}e=e==null?0:Pe(Xu(e),0);return mo((function(i){var n=i[e],r=Yo(i,0,e);if(n){ji(r,n)}return gi(t,this,r)}))}function ql(t,e,i){var n=true,r=true;if(typeof t!="function"){throw new oe(s)}if(Cu(i)){n="leading"in i?!!i.leading:n;r="trailing"in i?!!i.trailing:r}return Wl(t,e,{leading:n,maxWait:e,trailing:r})}function Gl(t){return Tl(t,1)}function Zl(t,e){return Kl(Uo(e),t)}function Jl(){if(!arguments.length){return[]}var t=arguments[0];return cu(t)?t:[t]}function Ql(t){return gr(t,d)}function tu(t,e){e=typeof e=="function"?e:i;return gr(t,d,e)}function eu(t){return gr(t,h|d)}function iu(t,e){e=typeof e=="function"?e:i;return gr(t,h|d,e)}function nu(t,e){return e==null||yr(t,e,xh(e))}function ru(t,e){return t===e||t!==t&&e!==e}var ou=js(Fr);var su=js((function(t,e){return t>=e}));var au=Kr(function(){return arguments}())?Kr:function(t){return Mu(t)&&he.call(t,"callee")&&!Ce.call(t,"callee")};var cu=A.isArray;var lu=hi?Ni(hi):Hr;function uu(t){return t!=null&&zu(t.length)&&!mu(t)}function hu(t){return Mu(t)&&uu(t)}function fu(t){return t===true||t===false||Mu(t)&&Wr(t)==H}var du=We||qf;var vu=fi?Ni(fi):Yr;function pu(t){return Mu(t)&&t.nodeType===1&&!Ou(t)}function bu(t){if(t==null){return true}if(uu(t)&&(cu(t)||typeof t=="string"||typeof t.splice=="function"||du(t)||Pu(t)||au(t))){return!t.length}var e=Zs(t);if(e==Z||e==rt){return!t.size}if(da(t)){return!io(t).length}for(var i in t){if(he.call(t,i)){return false}}return true}function gu(t,e){return Nr(t,e)}function ku(t,e,n){n=typeof n=="function"?n:i;var r=n?n(t,e):i;return r===i?Nr(t,e,i,n):!!r}function yu(t){if(!Mu(t)){return false}var e=Wr(t);return e==X||e==N||typeof t.message=="string"&&typeof t.name=="string"&&!Ou(t)}function wu(t){return typeof t=="number"&&Fe(t)}function mu(t){if(!Cu(t)){return false}var e=Wr(t);return e==q||e==G||e==K||e==it}function xu(t){return typeof t=="number"&&t==Xu(t)}function zu(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=R}function Cu(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function Mu(t){return t!=null&&typeof t=="object"}var ju=di?Ni(di):qr;function Iu(t,e){return t===e||Gr(t,e,Ys(e))}function Su(t,e,n){n=typeof n=="function"?n:i;return Gr(t,e,Ys(e),n)}function _u(t){return Eu(t)&&t!=+t}function Tu(t){if(fa(t)){throw new Lt(o)}return Zr(t)}function Au(t){return t===null}function $u(t){return t==null}function Eu(t){return typeof t=="number"||Mu(t)&&Wr(t)==J}function Ou(t){if(!Mu(t)||Wr(t)!=tt){return false}var e=xe(t);if(e===null){return true}var i=he.call(e,"constructor")&&e.constructor;return typeof i=="function"&&i instanceof i&&ue.call(i)==pe}var Ru=vi?Ni(vi):Jr;function Wu(t){return xu(t)&&t>=-9007199254740991&&t<=R}var Fu=pi?Ni(pi):Qr;function Du(t){return typeof t=="string"||!cu(t)&&Mu(t)&&Wr(t)==ot}function Bu(t){return typeof t=="symbol"||Mu(t)&&Wr(t)==st}var Pu=bi?Ni(bi):to;function Lu(t){return t===i}function Vu(t){return Mu(t)&&Zs(t)==ct}function Uu(t){return Mu(t)&&Wr(t)==lt}var Ku=js(ro);var Hu=js((function(t,e){return t<=e}));function Yu(t){if(!t){return[]}if(uu(t)){return Du(t)?pn(t):rs(t)}if(Ie&&t[Ie]){return sn(t[Ie]())}var e=Zs(t),i=e==Z?an:e==rt?un:Lh;return i(t)}function Nu(t){if(!t){return t===0?t:0}t=Gu(t);if(t===O||t===-Infinity){var e=t<0?-1:1;return e*W}return t===t?t:0}function Xu(t){var e=Nu(t),i=e%1;return e===e?i?e-i:e:0}function qu(t){return t?br(Xu(t),0,D):0}function Gu(t){if(typeof t=="number"){return t}if(Bu(t)){return F}if(Cu(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Cu(e)?e+"":e}if(typeof t!="string"){return t===0?t:+t}t=Yi(t);var i=Nt.test(t);return i||qt.test(t)?ii(t.slice(2),i?2:8):Yt.test(t)?F:+t}function Zu(t){return os(t,zh(t))}function Ju(t){return t?br(Xu(t),-9007199254740991,R):t===0?t:0}function Qu(t){return t==null?"":Oo(t)}var th=ls((function(t,e){if(da(e)||uu(e)){os(e,xh(e),t);return}for(var i in e){if(he.call(e,i)){lr(t,i,e[i])}}}));var eh=ls((function(t,e){os(e,zh(e),t)}));var ih=ls((function(t,e,i,n){os(e,zh(e),t,n)}));var nh=ls((function(t,e,i,n){os(e,xh(e),t,n)}));var rh=Ds(pr);function oh(t,e){var i=Cn(t);return e==null?i:fr(i,e)}var sh=mo((function(t,e){t=ie(t);var n=-1;var r=e.length;var o=r>2?e[2]:i;if(o&&aa(e[0],e[1],o)){r=1}while(++n<r){var s=e[n];var a=zh(s);var c=-1;var l=a.length;while(++c<l){var u=a[c];var h=t[u];if(h===i||ru(h,ce[u])&&!he.call(t,u)){t[u]=s[u]}}}return t}));var ah=mo((function(t){t.push(i,Es);return gi(Ih,i,t)}));function ch(t,e){return Ei(t,Ks(e,3),Ar)}function lh(t,e){return Ei(t,Ks(e,3),$r)}function uh(t,e){return t==null?t:_r(t,Ks(e,3),zh)}function hh(t,e){return t==null?t:Tr(t,Ks(e,3),zh)}function fh(t,e){return t&&Ar(t,Ks(e,3))}function dh(t,e){return t&&$r(t,Ks(e,3))}function vh(t){return t==null?[]:Er(t,xh(t))}function ph(t){return t==null?[]:Er(t,zh(t))}function bh(t,e,n){var r=t==null?i:Or(t,e);return r===i?n:r}function gh(t,e){return t!=null&&ta(t,e,Dr)}function kh(t,e){return t!=null&&ta(t,e,Br)}var yh=ws((function(t,e,i){if(e!=null&&typeof e.toString!="function"){e=ve.call(e)}t[e]=i}),If(Af));var wh=ws((function(t,e,i){if(e!=null&&typeof e.toString!="function"){e=ve.call(e)}if(he.call(t,e)){t[e].push(i)}else{t[e]=[i]}}),Ks);var mh=mo(Ur);function xh(t){return uu(t)?rr(t):io(t)}function zh(t){return uu(t)?rr(t,true):no(t)}function Ch(t,e){var i={};e=Ks(e,3);Ar(t,(function(t,n,r){vr(i,e(t,n,r),t)}));return i}function Mh(t,e){var i={};e=Ks(e,3);Ar(t,(function(t,n,r){vr(i,n,e(t,n,r))}));return i}var jh=ls((function(t,e,i){co(t,e,i)}));var Ih=ls((function(t,e,i,n){co(t,e,i,n)}));var Sh=Ds((function(t,e){var i={};if(t==null){return i}var n=false;e=Mi(e,(function(e){e=Ko(e,t);n||(n=e.length>1);return e}));os(t,Ps(t),i);if(n){i=gr(i,h|f|d,Os)}var r=e.length;while(r--){Wo(i,e[r])}return i}));function _h(t,e){return Ah(t,Ll(Ks(e)))}var Th=Ds((function(t,e){return t==null?{}:fo(t,e)}));function Ah(t,e){if(t==null){return{}}var i=Mi(Ps(t),(function(t){return[t]}));e=Ks(e);return vo(t,i,(function(t,i){return e(t,i[0])}))}function $h(t,e,n){e=Ko(e,t);var r=-1,o=e.length;if(!o){o=1;t=i}while(++r<o){var s=t==null?i:t[Aa(e[r])];if(s===i){r=o;s=n}t=mu(s)?s.call(t):s}return t}function Eh(t,e,i){return t==null?t:Co(t,e,i)}function Oh(t,e,n,r){r=typeof r=="function"?r:i;return t==null?t:Co(t,e,n,r)}var Rh=Ts(xh);var Wh=Ts(zh);function Fh(t,e,i){var n=cu(t),r=n||du(t)||Pu(t);e=Ks(e,4);if(i==null){var o=t&&t.constructor;if(r){i=n?new o:[]}else if(Cu(t)){i=mu(o)?Cn(xe(t)):{}}else{i={}}}(r?yi:Ar)(t,(function(t,n,r){return e(i,t,n,r)}));return i}function Dh(t,e){return t==null?true:Wo(t,e)}function Bh(t,e,i){return t==null?t:Fo(t,e,Uo(i))}function Ph(t,e,n,r){r=typeof r=="function"?r:i;return t==null?t:Fo(t,e,Uo(n),r)}function Lh(t){return t==null?[]:Xi(t,xh(t))}function Vh(t){return t==null?[]:Xi(t,zh(t))}function Uh(t,e,n){if(n===i){n=e;e=i}if(n!==i){n=Gu(n);n=n===n?n:0}if(e!==i){e=Gu(e);e=e===e?e:0}return br(Gu(t),e,n)}function Kh(t,e,n){e=Nu(e);if(n===i){n=e;e=0}else{n=Nu(n)}t=Gu(t);return Pr(t,e,n)}function Hh(t,e,n){if(n&&typeof n!="boolean"&&aa(t,e,n)){e=n=i}if(n===i){if(typeof e=="boolean"){n=e;e=i}else if(typeof t=="boolean"){n=t;t=i}}if(t===i&&e===i){t=0;e=1}else{t=Nu(t);if(e===i){e=t;t=0}else{e=Nu(e)}}if(t>e){var r=t;t=e;e=r}if(n||t%1||e%1){var o=Ye();return Ue(t+o*(e-t+ei("1e-"+((o+"").length-1))),e)}return ko(t,e)}var Yh=vs((function(t,e,i){e=e.toLowerCase();return t+(i?Nh(e):e)}));function Nh(t){return mf(Qu(t).toLowerCase())}function Xh(t){t=Qu(t);return t&&t.replace(Zt,Qi).replace(Ve,"")}function qh(t,e,n){t=Qu(t);e=Oo(e);var r=t.length;n=n===i?r:br(Xu(n),0,r);var o=n;n-=e.length;return n>=0&&t.slice(n,o)==e}function Gh(t){t=Qu(t);return t&&It.test(t)?t.replace(Mt,tn):t}function Zh(t){t=Qu(t);return t&&Rt.test(t)?t.replace(Ot,"\\$&"):t}var Jh=vs((function(t,e,i){return t+(i?"-":"")+e.toLowerCase()}));var Qh=vs((function(t,e,i){return t+(i?" ":"")+e.toLowerCase()}));var tf=ds("toLowerCase");function ef(t,e,i){t=Qu(t);e=Xu(e);var n=e?vn(t):0;if(!e||n>=e){return t}var r=(e-n)/2;return zs(Oe(r),i)+t+zs(Ee(r),i)}function nf(t,e,i){t=Qu(t);e=Xu(e);var n=e?vn(t):0;return e&&n<e?t+zs(e-n,i):t}function rf(t,e,i){t=Qu(t);e=Xu(e);var n=e?vn(t):0;return e&&n<e?zs(e-n,i)+t:t}function of(t,e,i){if(i||e==null){e=0}else if(e){e=+e}return He(Qu(t).replace(Wt,""),e||0)}function sf(t,e,n){if(n?aa(t,e,n):e===i){e=1}else{e=Xu(e)}return wo(Qu(t),e)}function af(){var t=arguments,e=Qu(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var cf=vs((function(t,e,i){return t+(i?"_":"")+e.toLowerCase()}));function lf(t,e,n){if(n&&typeof n!="number"&&aa(t,e,n)){e=n=i}n=n===i?D:n>>>0;if(!n){return[]}t=Qu(t);if(t&&(typeof e=="string"||e!=null&&!Ru(e))){e=Oo(e);if(!e&&rn(t)){return Yo(pn(t),0,n)}}return t.split(e,n)}var uf=vs((function(t,e,i){return t+(i?" ":"")+mf(e)}));function hf(t,e,i){t=Qu(t);i=i==null?0:br(Xu(i),0,t.length);e=Oo(e);return t.slice(i,i+e.length)==e}function ff(t,e,n){var r=zn.templateSettings;if(n&&aa(t,e,n)){e=i}t=Qu(t);e=ih({},e,r,$s);var o=ih({},e.imports,r.imports,$s),s=xh(o),c=Xi(o,s);var l,u,h=0,f=e.interpolate||Jt,d="__p += '";var v=ne((e.escape||Jt).source+"|"+f.source+"|"+(f===Tt?Kt:Jt).source+"|"+(e.evaluate||Jt).source+"|$","g");var p="//# sourceURL="+(he.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Xe+"]")+"\n";t.replace(v,(function(e,i,n,r,o,s){n||(n=r);d+=t.slice(h,s).replace(Qt,en);if(i){l=true;d+="' +\n__e("+i+") +\n'"}if(o){u=true;d+="';\n"+o+";\n__p += '"}if(n){d+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"}h=s+e.length;return e}));d+="';\n";var b=he.call(e,"variable")&&e.variable;if(!b){d="with (obj) {\n"+d+"\n}\n"}else if(Vt.test(b)){throw new Lt(a)}d=(u?d.replace(mt,""):d).replace(xt,"$1").replace(zt,"$1;");d="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(l?", __e = _.escape":"")+(u?", __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=zf((function(){return te(s,p+"return "+d).apply(i,c)}));g.source=d;if(yu(g)){throw g}return g}function df(t){return Qu(t).toLowerCase()}function vf(t){return Qu(t).toUpperCase()}function pf(t,e,n){t=Qu(t);if(t&&(n||e===i)){return Yi(t)}if(!t||!(e=Oo(e))){return t}var r=pn(t),o=pn(e),s=Gi(r,o),a=Zi(r,o)+1;return Yo(r,s,a).join("")}function bf(t,e,n){t=Qu(t);if(t&&(n||e===i)){return t.slice(0,bn(t)+1)}if(!t||!(e=Oo(e))){return t}var r=pn(t),o=Zi(r,pn(e))+1;return Yo(r,0,o).join("")}function gf(t,e,n){t=Qu(t);if(t&&(n||e===i)){return t.replace(Wt,"")}if(!t||!(e=Oo(e))){return t}var r=pn(t),o=Gi(r,pn(e));return Yo(r,o).join("")}function kf(t,e){var n=j,r=I;if(Cu(e)){var o="separator"in e?e.separator:o;n="length"in e?Xu(e.length):n;r="omission"in e?Oo(e.omission):r}t=Qu(t);var s=t.length;if(rn(t)){var a=pn(t);s=a.length}if(n>=s){return t}var c=n-vn(r);if(c<1){return r}var l=a?Yo(a,0,c).join(""):t.slice(0,c);if(o===i){return l+r}if(a){c+=l.length-c}if(Ru(o)){if(t.slice(c).search(o)){var u,h=l;if(!o.global){o=ne(o.source,Qu(Ht.exec(o))+"g")}o.lastIndex=0;while(u=o.exec(h)){var f=u.index}l=l.slice(0,f===i?c:f)}}else if(t.indexOf(Oo(o),c)!=c){var d=l.lastIndexOf(o);if(d>-1){l=l.slice(0,d)}}return l+r}function yf(t){t=Qu(t);return t&&jt.test(t)?t.replace(Ct,gn):t}var wf=vs((function(t,e,i){return t+(i?" ":"")+e.toUpperCase()}));var mf=ds("toUpperCase");function xf(t,e,n){t=Qu(t);e=n?i:e;if(e===i){return on(t)?wn(t):$i(t)}return t.match(e)||[]}var zf=mo((function(t,e){try{return gi(t,i,e)}catch(t){return yu(t)?t:new Lt(t)}}));var Cf=Ds((function(t,e){yi(e,(function(e){e=Aa(e);vr(t,e,$l(t[e],t))}));return t}));function Mf(t){var e=t==null?0:t.length,i=Ks();t=!e?[]:Mi(t,(function(t){if(typeof t[1]!="function"){throw new oe(s)}return[i(t[0]),t[1]]}));return mo((function(i){var n=-1;while(++n<e){var r=t[n];if(gi(r[0],this,i)){return gi(r[1],this,i)}}}))}function jf(t){return kr(gr(t,h))}function If(t){return function(){return t}}function Sf(t,e){return t==null||t!==t?e:t}var _f=ks();var Tf=ks(true);function Af(t){return t}function $f(t){return eo(typeof t=="function"?t:gr(t,h))}function Ef(t){return so(gr(t,h))}function Of(t,e){return ao(t,gr(e,h))}var Rf=mo((function(t,e){return function(i){return Ur(i,t,e)}}));var Wf=mo((function(t,e){return function(i){return Ur(t,i,e)}}));function Ff(t,e,i){var n=xh(e),r=Er(e,n);if(i==null&&!(Cu(e)&&(r.length||!n.length))){i=e;e=t;t=this;r=Er(e,xh(e))}var o=!(Cu(i)&&"chain"in i)||!!i.chain,s=mu(t);yi(r,(function(i){var n=e[i];t[i]=n;if(s){t.prototype[i]=function(){var e=this.__chain__;if(o||e){var i=t(this.__wrapped__),r=i.__actions__=rs(this.__actions__);r.push({func:n,args:arguments,thisArg:t});i.__chain__=e;return i}return n.apply(t,ji([this.value()],arguments))}}}));return t}function Df(){if(oi._===this){oi._=be}return this}function Bf(){}function Pf(t){t=Xu(t);return mo((function(e){return uo(e,t)}))}var Lf=xs(Mi);var Vf=xs(mi);var Uf=xs(_i);function Kf(t){return ca(t)?Bi(Aa(t)):po(t)}function Hf(t){return function(e){return t==null?i:Or(t,e)}}var Yf=Ms();var Nf=Ms(true);function Xf(){return[]}function qf(){return false}function Gf(){return{}}function Zf(){return""}function Jf(){return true}function Qf(t,e){t=Xu(t);if(t<1||t>R){return[]}var i=D,n=Ue(t,D);e=Ks(e);t-=D;var r=Ki(n,e);while(++i<t){e(i)}return r}function td(t){if(cu(t)){return Mi(t,Aa)}return Bu(t)?[t]:rs(Ta(Qu(t)))}function ed(t){var e=++fe;return Qu(t)+e}var id=ms((function(t,e){return t+e}),0);var nd=Ss("ceil");var rd=ms((function(t,e){return t/e}),1);var od=Ss("floor");function sd(t){return t&&t.length?Mr(t,Af,Fr):i}function ad(t,e){return t&&t.length?Mr(t,Ks(e,2),Fr):i}function cd(t){return Di(t,Af)}function ld(t,e){return Di(t,Ks(e,2))}function ud(t){return t&&t.length?Mr(t,Af,ro):i}function hd(t,e){return t&&t.length?Mr(t,Ks(e,2),ro):i}var fd=ms((function(t,e){return t*e}),1);var dd=Ss("round");var vd=ms((function(t,e){return t-e}),0);function pd(t){return t&&t.length?Ui(t,Af):0}function bd(t,e){return t&&t.length?Ui(t,Ks(e,2)):0}zn.after=_l;zn.ary=Tl;zn.assign=th;zn.assignIn=eh;zn.assignInWith=ih;zn.assignWith=nh;zn.at=rh;zn.before=Al;zn.bind=$l;zn.bindAll=Cf;zn.bindKey=El;zn.castArray=Jl;zn.chain=Hc;zn.chunk=Ra;zn.compact=Wa;zn.concat=Fa;zn.cond=Mf;zn.conforms=jf;zn.constant=If;zn.countBy=il;zn.create=oh;zn.curry=Ol;zn.curryRight=Rl;zn.debounce=Wl;zn.defaults=sh;zn.defaultsDeep=ah;zn.defer=Fl;zn.delay=Dl;zn.difference=Da;zn.differenceBy=Ba;zn.differenceWith=Pa;zn.drop=La;zn.dropRight=Va;zn.dropRightWhile=Ua;zn.dropWhile=Ka;zn.fill=Ha;zn.filter=rl;zn.flatMap=al;zn.flatMapDeep=cl;zn.flatMapDepth=ll;zn.flatten=Xa;zn.flattenDeep=qa;zn.flattenDepth=Ga;zn.flip=Bl;zn.flow=_f;zn.flowRight=Tf;zn.fromPairs=Za;zn.functions=vh;zn.functionsIn=ph;zn.groupBy=fl;zn.initial=tc;zn.intersection=ec;zn.intersectionBy=ic;zn.intersectionWith=nc;zn.invert=yh;zn.invertBy=wh;zn.invokeMap=vl;zn.iteratee=$f;zn.keyBy=pl;zn.keys=xh;zn.keysIn=zh;zn.map=bl;zn.mapKeys=Ch;zn.mapValues=Mh;zn.matches=Ef;zn.matchesProperty=Of;zn.memoize=Pl;zn.merge=jh;zn.mergeWith=Ih;zn.method=Rf;zn.methodOf=Wf;zn.mixin=Ff;zn.negate=Ll;zn.nthArg=Pf;zn.omit=Sh;zn.omitBy=_h;zn.once=Vl;zn.orderBy=gl;zn.over=Lf;zn.overArgs=Ul;zn.overEvery=Vf;zn.overSome=Uf;zn.partial=Kl;zn.partialRight=Hl;zn.partition=kl;zn.pick=Th;zn.pickBy=Ah;zn.property=Kf;zn.propertyOf=Hf;zn.pull=cc;zn.pullAll=lc;zn.pullAllBy=uc;zn.pullAllWith=hc;zn.pullAt=fc;zn.range=Yf;zn.rangeRight=Nf;zn.rearg=Yl;zn.reject=ml;zn.remove=dc;zn.rest=Nl;zn.reverse=vc;zn.sampleSize=zl;zn.set=Eh;zn.setWith=Oh;zn.shuffle=Cl;zn.slice=pc;zn.sortBy=Il;zn.sortedUniq=xc;zn.sortedUniqBy=zc;zn.split=lf;zn.spread=Xl;zn.tail=Cc;zn.take=Mc;zn.takeRight=jc;zn.takeRightWhile=Ic;zn.takeWhile=Sc;zn.tap=Yc;zn.throttle=ql;zn.thru=Nc;zn.toArray=Yu;zn.toPairs=Rh;zn.toPairsIn=Wh;zn.toPath=td;zn.toPlainObject=Zu;zn.transform=Fh;zn.unary=Gl;zn.union=_c;zn.unionBy=Tc;zn.unionWith=Ac;zn.uniq=$c;zn.uniqBy=Ec;zn.uniqWith=Oc;zn.unset=Dh;zn.unzip=Rc;zn.unzipWith=Wc;zn.update=Bh;zn.updateWith=Ph;zn.values=Lh;zn.valuesIn=Vh;zn.without=Fc;zn.words=xf;zn.wrap=Zl;zn.xor=Dc;zn.xorBy=Bc;zn.xorWith=Pc;zn.zip=Lc;zn.zipObject=Vc;zn.zipObjectDeep=Uc;zn.zipWith=Kc;zn.entries=Rh;zn.entriesIn=Wh;zn.extend=eh;zn.extendWith=ih;Ff(zn,zn);zn.add=id;zn.attempt=zf;zn.camelCase=Yh;zn.capitalize=Nh;zn.ceil=nd;zn.clamp=Uh;zn.clone=Ql;zn.cloneDeep=eu;zn.cloneDeepWith=iu;zn.cloneWith=tu;zn.conformsTo=nu;zn.deburr=Xh;zn.defaultTo=Sf;zn.divide=rd;zn.endsWith=qh;zn.eq=ru;zn.escape=Gh;zn.escapeRegExp=Zh;zn.every=nl;zn.find=ol;zn.findIndex=Ya;zn.findKey=ch;zn.findLast=sl;zn.findLastIndex=Na;zn.findLastKey=lh;zn.floor=od;zn.forEach=ul;zn.forEachRight=hl;zn.forIn=uh;zn.forInRight=hh;zn.forOwn=fh;zn.forOwnRight=dh;zn.get=bh;zn.gt=ou;zn.gte=su;zn.has=gh;zn.hasIn=kh;zn.head=Ja;zn.identity=Af;zn.includes=dl;zn.indexOf=Qa;zn.inRange=Kh;zn.invoke=mh;zn.isArguments=au;zn.isArray=cu;zn.isArrayBuffer=lu;zn.isArrayLike=uu;zn.isArrayLikeObject=hu;zn.isBoolean=fu;zn.isBuffer=du;zn.isDate=vu;zn.isElement=pu;zn.isEmpty=bu;zn.isEqual=gu;zn.isEqualWith=ku;zn.isError=yu;zn.isFinite=wu;zn.isFunction=mu;zn.isInteger=xu;zn.isLength=zu;zn.isMap=ju;zn.isMatch=Iu;zn.isMatchWith=Su;zn.isNaN=_u;zn.isNative=Tu;zn.isNil=$u;zn.isNull=Au;zn.isNumber=Eu;zn.isObject=Cu;zn.isObjectLike=Mu;zn.isPlainObject=Ou;zn.isRegExp=Ru;zn.isSafeInteger=Wu;zn.isSet=Fu;zn.isString=Du;zn.isSymbol=Bu;zn.isTypedArray=Pu;zn.isUndefined=Lu;zn.isWeakMap=Vu;zn.isWeakSet=Uu;zn.join=rc;zn.kebabCase=Jh;zn.last=oc;zn.lastIndexOf=sc;zn.lowerCase=Qh;zn.lowerFirst=tf;zn.lt=Ku;zn.lte=Hu;zn.max=sd;zn.maxBy=ad;zn.mean=cd;zn.meanBy=ld;zn.min=ud;zn.minBy=hd;zn.stubArray=Xf;zn.stubFalse=qf;zn.stubObject=Gf;zn.stubString=Zf;zn.stubTrue=Jf;zn.multiply=fd;zn.nth=ac;zn.noConflict=Df;zn.noop=Bf;zn.now=Sl;zn.pad=ef;zn.padEnd=nf;zn.padStart=rf;zn.parseInt=of;zn.random=Hh;zn.reduce=yl;zn.reduceRight=wl;zn.repeat=sf;zn.replace=af;zn.result=$h;zn.round=dd;zn.runInContext=t;zn.sample=xl;zn.size=Ml;zn.snakeCase=cf;zn.some=jl;zn.sortedIndex=bc;zn.sortedIndexBy=gc;zn.sortedIndexOf=kc;zn.sortedLastIndex=yc;zn.sortedLastIndexBy=wc;zn.sortedLastIndexOf=mc;zn.startCase=uf;zn.startsWith=hf;zn.subtract=vd;zn.sum=pd;zn.sumBy=bd;zn.template=ff;zn.times=Qf;zn.toFinite=Nu;zn.toInteger=Xu;zn.toLength=qu;zn.toLower=df;zn.toNumber=Gu;zn.toSafeInteger=Ju;zn.toString=Qu;zn.toUpper=vf;zn.trim=pf;zn.trimEnd=bf;zn.trimStart=gf;zn.truncate=kf;zn.unescape=yf;zn.uniqueId=ed;zn.upperCase=wf;zn.upperFirst=mf;zn.each=ul;zn.eachRight=hl;zn.first=Ja;Ff(zn,function(){var t={};Ar(zn,(function(e,i){if(!he.call(zn.prototype,i)){t[i]=e}}));return t}(),{chain:false});zn.VERSION=n;yi(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){zn[t].placeholder=zn}));yi(["drop","take"],(function(t,e){In.prototype[t]=function(n){n=n===i?1:Pe(Xu(n),0);var r=this.__filtered__&&!e?new In(this):this.clone();if(r.__filtered__){r.__takeCount__=Ue(n,r.__takeCount__)}else{r.__views__.push({size:Ue(n,D),type:t+(r.__dir__<0?"Right":"")})}return r};In.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}));yi(["filter","map","takeWhile"],(function(t,e){var i=e+1,n=i==T||i==E;In.prototype[t]=function(t){var e=this.clone();e.__iteratees__.push({iteratee:Ks(t,3),type:i});e.__filtered__=e.__filtered__||n;return e}}));yi(["head","last"],(function(t,e){var i="take"+(e?"Right":"");In.prototype[t]=function(){return this[i](1).value()[0]}}));yi(["initial","tail"],(function(t,e){var i="drop"+(e?"":"Right");In.prototype[t]=function(){return this.__filtered__?new In(this):this[i](1)}}));In.prototype.compact=function(){return this.filter(Af)};In.prototype.find=function(t){return this.filter(t).head()};In.prototype.findLast=function(t){return this.reverse().find(t)};In.prototype.invokeMap=mo((function(t,e){if(typeof t=="function"){return new In(this)}return this.map((function(i){return Ur(i,t,e)}))}));In.prototype.reject=function(t){return this.filter(Ll(Ks(t)))};In.prototype.slice=function(t,e){t=Xu(t);var n=this;if(n.__filtered__&&(t>0||e<0)){return new In(n)}if(t<0){n=n.takeRight(-t)}else if(t){n=n.drop(t)}if(e!==i){e=Xu(e);n=e<0?n.dropRight(-e):n.take(e-t)}return n};In.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()};In.prototype.toArray=function(){return this.take(D)};Ar(In.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),o=zn[r?"take"+(e=="last"?"Right":""):e],s=r||/^find/.test(e);if(!o){return}zn.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,c=e instanceof In,l=a[0],u=c||cu(e);var h=function(t){var e=o.apply(zn,ji([t],a));return r&&f?e[0]:e};if(u&&n&&typeof l=="function"&&l.length!=1){c=u=false}var f=this.__chain__,d=!!this.__actions__.length,v=s&&!f,p=c&&!d;if(!s&&u){e=p?e:new In(this);var b=t.apply(e,a);b.__actions__.push({func:Nc,args:[h],thisArg:i});return new jn(b,f)}if(v&&p){return t.apply(this,a)}b=this.thru(h);return v?r?b.value()[0]:b.value():b}}));yi(["pop","push","shift","sort","splice","unshift"],(function(t){var e=se[t],i=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);zn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var r=this.value();return e.apply(cu(r)?r:[],t)}return this[i]((function(i){return e.apply(cu(i)?i:[],t)}))}}));Ar(In.prototype,(function(t,e){var i=zn[e];if(i){var n=i.name+"";if(!he.call(li,n)){li[n]=[]}li[n].push({name:e,func:i})}}));li[ys(i,g).name]=[{name:"wrapper",func:i}];In.prototype.clone=Sn;In.prototype.reverse=_n;In.prototype.value=Tn;zn.prototype.at=Xc;zn.prototype.chain=qc;zn.prototype.commit=Gc;zn.prototype.next=Zc;zn.prototype.plant=Qc;zn.prototype.reverse=tl;zn.prototype.toJSON=zn.prototype.valueOf=zn.prototype.value=el;zn.prototype.first=zn.prototype.head;if(Ie){zn.prototype[Ie]=Jc}return zn};var xn=mn();if(ai){(ai.exports=xn)._=xn;si._=xn}else{oi._=xn}}).call(tt)})(Q,Q.exports);return Q.exports}var nt=it();class rt{_core;_debounceUpdate;initialTouchDistance=0;startX=0;startY=0;constructor(t,e){this._core=t;this._core.store.state.host=e;this._core.store.state.viewportWidth=e.clientWidth;this._core.store.state.viewportHeight=e.clientHeight;this._core.store.state.startX=0;this._core.store.state.startY=0;this._core.store.state.translateX=0;this._core.store.state.translateY=0;this._debounceUpdate=nt.debounce((()=>{this._core.updateWorkspaceViewport(this._core.store.state.translateX,this._core.store.state.translateY,this._core.store.state.scale)}),300)}handleResize(){this._core.store.state.viewportWidth=this._core.store.state.host.clientWidth;this._core.store.state.viewportHeight=this._core.store.state.host.clientHeight;this._core.store.state.hasViewportChanged=true;this._core.rerender()}handlePointerDown(t){if(t.pointerType==="mouse"){const e=t.clientX-this._core.store.offsetX;const i=t.clientY-this._core.store.offsetY;if(t.button===c.Right){this._core.store.state.isPanning=true;this._core.store.state.startX=e;this._core.store.state.startY=i}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===2){const e=this._core.store.currentPath;if(e){this._core.store.state.objectsMap.remove((t=>t.id===e.id))}this._core.store.state.isScaling=true;const i=t[0].clientX-this._core.store.offsetX;const n=t[0].clientY-this._core.store.offsetY;const r=t[1].clientX-this._core.store.offsetX;const o=t[1].clientY-this._core.store.offsetY;this.initialTouchDistance=Math.sqrt(Math.pow(i-r,2)+Math.pow(n-o,2));this.startX=(i+r)/2;this.startY=(n+o)/2;this._core.rerender()}}}handlePointerMove(t){if(t.pointerType==="mouse"){const e=this._core.store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;this._core.store.state.pointerX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this._core.store.state.pointerY=(n-this._core.store.state.translateY)/this._core.store.state.scale;if(this._core.store.state.isPanning){const t=i-this._core.store.state.startX;const e=n-this._core.store.state.startY;this._core.store.state.translateX+=t;this._core.store.state.translateY+=e;this._core.store.state.startX=i;this._core.store.state.startY=n;this._core.store.state.hasViewportChanged=true;this._core.store.state.skipContextMenu=true;this._core.rerender();this._debounceUpdate()}}if(t.pointerType==="touch"){const e=this._core.store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;this._core.store.state.pointerX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this._core.store.state.pointerY=(n-this._core.store.state.translateY)/this._core.store.state.scale;const r=Array.from(this._core.store.state.pointers.values());if(r.length===2){const t=r[0].clientX-this._core.store.offsetX;const e=r[0].clientY-this._core.store.offsetY;const i=r[1].clientX-this._core.store.offsetX;const n=r[1].clientY-this._core.store.offsetY;const o=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-n,2));const s=(t+i)/2;const a=(e+n)/2;const c=o/this.initialTouchDistance;const l=this._core.store.state.scale*c;if(l>this._core.store.state.scaleMax||l<this._core.store.state.scaleMin){this._core.store.state.translateX=this._core.store.state.translateX+s-this.startX;this._core.store.state.translateY=this._core.store.state.translateY+a-this.startY}else{const t=(s-this._core.store.state.translateX)*(c-1);const e=(a-this._core.store.state.translateY)*(c-1);this._core.store.state.translateX=this._core.store.state.translateX+s-this.startX-t;this._core.store.state.translateY=this._core.store.state.translateY+a-this.startY-e;this._core.store.state.scale=l;this.initialTouchDistance=o}this.startX=s;this.startY=a;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate()}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isPanning){this._core.store.state.isPanning=false;this._core.rerender()}}if(t.pointerType==="touch"){if(this._core.store.state.pointers.size===0){setTimeout((()=>{this._core.store.state.isScaling=false;this._core.rerender()}),300)}}}handleWheel(t){t.preventDefault();if(t.ctrlKey===true&&Math.abs(t.deltaY)>0&&Math.abs(t.deltaX)===0){this.handleZoom(t)}if(!t.ctrlKey){this.handlePan(t)}}centerInViewport(t){const{scale:e,viewportWidth:i,viewportHeight:n}=this._core.store.state;const{x:r,y:o,width:s,height:a}=t.rotatedBoundingBox;const c=r+s/2;const l=o+a/2;this._core.store.state.translateX=i/2-c*e;this._core.store.state.translateY=n/2-l*e;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate()}centerFitInViewport(t){const e=this._core.store.state.viewportWidth/(t.rotatedBoundingBox.width*1.1);const i=this._core.store.state.viewportHeight/(t.rotatedBoundingBox.height*1.1);const n=Math.min(e,i,this._core.store.state.scaleMax);const r=Math.max(n,this._core.store.state.scaleMin);this._core.store.state.scale=r;this.centerInViewport(t)}handleZoom(t){this._core.store.state.isScaling=true;const e=this._core.store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;this._core.store.state.pointerX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this._core.store.state.pointerY=(n-this._core.store.state.translateY)/this._core.store.state.scale;const r=t.deltaY>0?-this._core.store.state.scaleStep*this._core.store.state.scale:this._core.store.state.scaleStep*this._core.store.state.scale;const o=Math.min(this._core.store.state.scaleMax,Math.max(this._core.store.state.scaleMin,this._core.store.state.scale+r));const s=o/this._core.store.state.scale;const a=(i-this._core.store.state.translateX)*(s-1);const c=(n-this._core.store.state.translateY)*(s-1);this._core.store.state.scale=o;this._core.store.state.translateX=this._core.store.state.translateX-a;this._core.store.state.translateY=this._core.store.state.translateY-c;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate();setTimeout((()=>{this._core.store.state.isScaling=false}),300)}handlePan(t){const e=.8;this._core.store.state.translateX=this._core.store.state.translateX-t.deltaX*e;this._core.store.state.translateY=this._core.store.state.translateY-t.deltaY*e;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate()}}class ot extends b{shortcuts=[{key:"Escape",condition:t=>!!t.store.selectionGroup,action:t=>t.clearSelection()},{key:"Delete",condition:t=>!!t.store.selectionGroup,action:t=>t.delete()},{key:"z",ctrl:true,action:t=>t.undo()},{key:"y",ctrl:true,action:t=>t.redo()},{key:"s",ctrl:true,action:()=>this.switchTool("selection")},{key:"b",ctrl:true,action:()=>this.switchTool("brush")},{key:"e",ctrl:true,action:()=>this.switchTool("eraser")},{key:"i",ctrl:true,action:()=>this.switchTool("image")},{key:"x",ctrl:true,action:()=>this.switchTool("text")},{key:"c",ctrl:true,condition:t=>!!t.store.selectionGroup,action:t=>{t.copy();t.rerender()}},{key:"v",ctrl:true,condition:t=>!!t.store.state.copiedObjects&&!t.store.activeText,action:t=>t.paste()},{key:"+",ctrl:true,condition:t=>!!t.store.selectionGroup,action:t=>t.bringForward()},{key:"-",ctrl:true,condition:t=>!!t.store.selectionGroup,action:t=>t.sendBackward()},{key:"*",shift:true,condition:t=>!!t.store.selectionGroup,action:t=>t.bringToFront()},{key:"_",shift:true,condition:t=>!!t.store.selectionGroup,action:t=>t.sendToBack()}];constructor(t){super(t)}switchTool(t){const e=g.getTool(t);this._core.store.setState("activeTool",e);this._core.deselectAllObjects();e.onActivate()}handleKeyDown(t){this._core.store.state.isCtrlKeyPressed=t.ctrlKey;const e=this.shortcuts.find((e=>e.key===t.key&&!!e.ctrl===t.ctrlKey&&!!e.shift===t.shiftKey&&(!e.condition||e.condition(this._core))));if(e){t.preventDefault();e.action(this._core)}}handleKeyUp(t){this._core.store.state.isCtrlKeyPressed=t.ctrlKey}}class st extends b{globalContextMenuItems=[];objectContextMenuItems=[];constructor(t,e,i){super(t);this.globalContextMenuItems=e;this.objectContextMenuItems=i}handleContextMenu(t){if(!(this._core.store.state.activeTool instanceof l)){return}if(this._core.store.state.skipContextMenu){this._core.store.state.skipContextMenu=false;return}const e=this._core.store.state.activeTool;e?.moveHandler?.cancelPendingDrag();if(this._core.store.selectionBox){this._core.store.state.objectsMap.remove((t=>t instanceof k));this._core.store.state.isSelecting=false}const i=this._core.getObjectFromPointerEvent(t,".object");if(i&&!(i instanceof y)&&!(i instanceof k)){const t=y.create(this._core);t.addOrRemove(i);t.isSelected=true;t.rotation=i.rotation;this._core.store.state.isSelecting=false;const e=this._core.store.selectionGroup;if(e){this._core.removeSelectionGroup()}this._core.addSelectionGroup(t);this._core.rerender()}this._core.store.state.contextMenuItems=this._core.store.selectionGroup?this.objectContextMenuItems:this.globalContextMenuItems;let n=t.clientX-this._core.store.offsetX;let r=t.clientY-this._core.store.offsetY;const o=150;const s=200;const a=10;if(n+o>window.innerWidth-a){n=window.innerWidth-o-a}if(r+s>window.innerHeight-a){r=window.innerHeight-s-a}n=Math.max(a,n);r=Math.max(a,r);this._core.store.state.contextMenuX=n;this._core.store.state.contextMenuY=r;this._core.store.state.isContextMenuVisible=true;this._core.store.state.isEnabled=false;this._core.rerender()}}class at{static isInstanceOf(t,e){return!!t&&t.__class__===e}}const ct={activeWorkspace:null,activeTool:null,copiedObjects:null,objectsMap:null,resizeHandleType:null,hasViewportChanged:false,hasObjectsChanged:false,isReady:false,isEnabled:true,isScaling:false,isPanning:false,isSelecting:false,isResizing:false,isResizeHandleSelected:false,isRotating:false,isRotationHandleSelected:false,isDragging:false,isDrawing:false,isErasing:false,isWriting:false,isCtrlKeyPressed:false,isContextMenuVisible:false,contextMenuItems:[],contextMenuX:0,contextMenuY:0,skipContextMenu:false,debugInfo:{showObjectInfo:false,showViewportInfo:false},host:null,pointerX:0,pointerY:0,scale:1,scaleMax:1,scaleMin:1,scaleStep:.075,startX:0,startY:0,translateX:0,translateXMax:400,translateXMin:0,translateY:0,translateYMax:400,translateYMin:0,viewportWidth:0,viewportHeight:0,longTouchTimeout:null,longTouchDelay:300,pointers:new Map,workspaces:[]};class lt extends w{__class__="KritzelCustomElement";element;isInteractive=true;constructor(t){super();if(t){this.translateX=t.translateX||0;this.translateY=t.translateY||0;this.scale=t.scale||1;this.element=t.element;this.height=t.height||0;this.width=t.width||0}}static create(t,e){const i=new lt(e);i._core=t;i.id=i.generateId();i.workspaceId=t.store.state.activeWorkspace.id;return i}mount(t){if(t===null){return}if(this.isMounted&&this.elementRef===t&&this.element.parentElement===t){return}this.elementRef=t;this.isMounted=true;this.elementRef.innerHTML="";this.elementRef.appendChild(this.element)}resize(t,e,i,n){if(i<=1||n<=1){return}this.width=i;this.height=n;this.translateX=t;this.translateY=e;if(this.element){this.element.style.width=`${i}px`;this.element.style.height=`${n}px`}this._core.store.state.objectsMap.update(this)}copy(){const t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this);t.id=this.generateId();t.isMounted=false;t.element=this.element.cloneNode(true);return t}}class ut{_core;constructor(t){this._core=t}revive(t){if(t&&typeof t==="object"){if(t.__class__){let e;switch(t.__class__){case"KritzelPath":e=z.create(this._core).deserialize(t);break;case"KritzelText":e=x.create(this._core,t.fontSize,t.fontFamily).deserialize(t);break;case"KritzelImage":e=m.create(this._core).deserialize(t);break;case"KritzelCustomElement":e=lt.create(this._core).deserialize(t);break;case"KritzelSelectionGroup":e=y.create(this._core).deserialize(t);break;case"KritzelWorkspace":e=v.create(this._core,t).deserialize(t);break;case"KritzelBrushTool":e=new s(this._core);break;case"KritzelEraserTool":e=new h(this._core);break;case"KritzelImageTool":e=new d(this._core);break;case"KritzelSelectionTool":e=new l(this._core);break;case"KritzelTextTool":e=new a(this._core);break;default:e=t}return e}const e=Array.isArray(t)?[]:{};for(const i in t){if(Object.prototype.hasOwnProperty.call(t,i)){e[i]=this.revive(t[i])}}return e}return t}}class ht{map;_ydoc=null;_objectsMap=null;_providers=[];_undoManager=null;_reviver=null;_core=null;_workspaceId=null;_isReady=false;_temporaryItemsCount=0;get isReady(){return this._isReady}get undoManager(){return this._undoManager}get workspaceId(){return this._workspaceId}constructor(){this.map=new Map}async initialize(t,e,i){this._core=t;this._workspaceId=e;this._reviver=new ut(t);this._ydoc=new C;this._objectsMap=this._ydoc.getMap("objects");const n=`kritzel-workspace-${e}`;const r=i??M;for(const t of r.providers){let e;if(typeof t==="function"){e=new t(n,this._ydoc)}else{e=t.create(n,this._ydoc)}this._providers.push(e)}this._undoManager=new j([this._objectsMap],{captureTimeout:200,trackedOrigins:new Set(["local","temporary"]),ignoreRemoteMapChanges:true});this._undoManager.on("stack-item-added",(t=>{if(t.type==="undo"){if(t.origin==="temporary"){this._temporaryItemsCount++}}}));this._undoManager.on("stack-item-popped",(t=>{if(t.type==="undo"){if(t.origin==="temporary"&&this._temporaryItemsCount>0){this._temporaryItemsCount--}}}));this._objectsMap.observe((t=>{this.handleObjectsChange(t)}));await Promise.all(this._providers.map((t=>t.connect())));this._isReady=true;this.loadFromYjs()}handleObjectsChange(t){if(t.transaction.origin==="local"||t.transaction.origin==="temporary"){this._core?.rerender();return}const e=Array.from(t.keysChanged);const i=[];const n=[];const r=[];e.forEach((e=>{const o=t.changes.keys.get(e);if(o&&o.action==="delete"){r.push(e)}else{const t=this._objectsMap.get(e);if(t){const e=this._reviver.revive(t);if(e instanceof y){n.push(e)}else{i.push(e)}}}}));r.forEach((t=>{this.map.delete(t)}));i.forEach((t=>{this.map.set(t.id,t)}));n.forEach((t=>{this.map.set(t.id,t)}));this._core?.rerender()}transaction(t){if(this._ydoc){this._ydoc.transact(t,"local")}}loadFromYjs(){if(!this._objectsMap||!this._reviver){return}this.map.clear();this._objectsMap.forEach(((t,e)=>{const i=this._reviver.revive(t);this.map.set(e,i)}))}reset(){this.map.clear();this._ydoc.transact((()=>{this._objectsMap.clear()}),"local")}insert(t){if(!t.id){return false}this.map.set(t.id,t);if(this._objectsMap&&this.isPersistable(t)){const e=t.serialize();this._ydoc.transact((()=>{this._objectsMap.set(t.id,e)}),"local")}return true}update(t,e={}){if(!t.id||!this.map.has(t.id)){return false}this.map.set(t.id,t);if(this._objectsMap&&this.isPersistable(t)){const i=t.serialize();const n=e.temporary?"temporary":"local";this._ydoc.transact((()=>{this._objectsMap.set(t.id,i)}),n)}return true}remove(t){for(const[e,i]of this.map){if(t(i)){this.map.delete(e);if(this._objectsMap&&this.isPersistable(i)){this._ydoc.transact((()=>{this._objectsMap.delete(e)}),"local")}}}}filter(t){const e=[];for(const i of this.map.values()){if(t(i)){e.push(i)}}return e}allObjects(){return Array.from(this.map.values())}isPersistable(t){if(t instanceof k){return false}return true}undo(){if(this._undoManager&&this._undoManager.canUndo()){this._undoManager.undo()}}redo(){if(this._undoManager&&this._undoManager.canRedo()){this._undoManager.redo()}}canUndo(){return this._undoManager?this._undoManager.canUndo():false}canRedo(){return this._undoManager?this._undoManager.canRedo():false}clearHistory(){if(this._undoManager){this._undoManager.clear();this._temporaryItemsCount=0}}consolidateTemporaryItems(){if(!this._undoManager||this._temporaryItemsCount===0){return}const t=this._undoManager.undoStack.length;if(t===0){this._temporaryItemsCount=0;return}this._undoManager.stopCapturing();const e=Math.min(this._temporaryItemsCount,t);if(e>1){for(let t=0;t<e;t++){if(this._undoManager.canUndo()){this._undoManager.undo()}}this._ydoc.transact((()=>{for(let t=e-1;t>=0;t--){if(this._undoManager.canRedo()){this._undoManager.redo()}}}),"local")}this._temporaryItemsCount=0}clearTemporaryItems(){if(!this._undoManager||this._temporaryItemsCount===0){return}const t=this._undoManager.undoStack.length;const e=Math.min(this._temporaryItemsCount,t);for(let t=0;t<e;t++){if(this._undoManager.undoStack.length>0){this._undoManager.undoStack.pop()}}this._temporaryItemsCount=0}destroy(){this._providers.forEach((t=>t.destroy()));this._providers=[];if(this._ydoc){this._ydoc.destroy()}this.map.clear()}}class ft{_state;_listeners=new Map;get state(){return this._state}get currentZIndex(){return Math.max(0,...this._state.objectsMap.filter((t=>!(t instanceof y)&&!(t instanceof k))).map((t=>t.zIndex)))+1}get allObjects(){return this._state.objectsMap.allObjects()}get allNonSelectionObjects(){return this._state.objectsMap.allObjects().filter((t=>!(t instanceof y)&&!(t instanceof k)))}get selectedObjects(){return this.allObjects.filter((t=>!(t instanceof y))).filter((t=>t.isSelected))}get selectionBox(){const t=this._state.objectsMap.filter((t=>t instanceof k));return t.length>0?t[0]:null}get selectionGroup(){const t=this._state.objectsMap.filter((t=>t instanceof y));return t.length>0?t[0]:null}get activeText(){const t=this._state.objectsMap.filter((t=>t instanceof x&&t.isEditing));return t.length>0?t[0]:null}get currentPath(){const t=this._state.objectsMap.filter((t=>t instanceof z&&t.isCompleted===false));return t.length>0?t[0]:null}get offsetX(){return this._state.host.getBoundingClientRect().left}get offsetY(){return this._state.host.getBoundingClientRect().top}get isDisabled(){return this._state.isEnabled===false||this._state.isReady===false||this._state.activeWorkspace===null}constructor(t){this._state=t;this._state.objectsMap=new ht}onStateChange(t,e){if(!this._listeners.has(t)){this._listeners.set(t,new Set)}this._listeners.get(t).add(e)}getState(t){return this._state[t]}setState(t,e){const i=this._state[t];if(i!==e){this._state[t]=e;if(this._listeners.has(t)){this._listeners.get(t).forEach((n=>n(e,i,String(t))))}}}}class dt{_kritzelEngine;_store;_syncConfig;_appStateMap;get engine(){return this._kritzelEngine}get store(){return this._store}get appStateMap(){return this._appStateMap}constructor(t){this._kritzelEngine=t;this._store=new ft(ct);this._appStateMap=new I}setSyncConfig(t){this._syncConfig=t}async initializeYjs(){await this._appStateMap.initialize(this,this._syncConfig)}loadWorkspacesFromAppState(){return this._appStateMap.allWorkspaces()}saveWorkspaceToAppState(t){if(this._appStateMap.has(t.id)){this._appStateMap.update(t)}else{this._appStateMap.insert(t)}}deleteWorkspaceFromAppState(t){this._appStateMap.remove((e=>e.id===t))}async initializeWorkspace(t){const e=this.loadWorkspacesFromAppState();const i=e.length>0?[...e].sort(((t,e)=>e.updatedAt.getTime()-t.updatedAt.getTime()))[0]:null;let n;if(t){n=t;const i=e.find((e=>e.id===t.id));if(!i){n._core=this;this.saveWorkspaceToAppState(n)}}else if(i){n=i}else{n=new v(S.generateUUID(),"New Workspace");n._core=this;this.saveWorkspaceToAppState(n)}if(this._store.state.objectsMap&&this._store.state.objectsMap.isReady){this._store.state.objectsMap.destroy()}this._store.state.activeWorkspace=n;this._store.state.workspaces=this.loadWorkspacesFromAppState();const r=n.viewport??{translateX:0,translateY:0,scale:1};this._store.state.translateX=r.translateX??0;this._store.state.translateY=r.translateY??0;this._store.state.scale=r.scale??1;const o=new ht;await o.initialize(this,n.id,this._syncConfig);this._store.state.objectsMap=o;this.rerender()}rerender(){if(this._kritzelEngine){this._kritzelEngine.forceUpdate++}}findObjectById(t){for(const e of this._store.allObjects){if(e.id===t){return e}}return null}getWorkspaces(){return this.loadWorkspacesFromAppState()}createWorkspace(t){t._core=this;t.createdAt=new Date;t.updatedAt=new Date;this.saveWorkspaceToAppState(t);this._store.state.workspaces=this.loadWorkspacesFromAppState()}updateWorkspace(t){t.updatedAt=new Date;this.saveWorkspaceToAppState(t);const e=this._store.state.workspaces;const i=e.findIndex((e=>e.id===t.id));if(i!==-1){e[i]=t;this._store.state.workspaces=e}}deleteWorkspace(t){if(this._store.state.activeWorkspace?.id===t.id){this._store.state.objectsMap?.destroy()}this.deleteWorkspaceFromAppState(t.id);this._store.state.workspaces=this.loadWorkspacesFromAppState();const e=`kritzel-workspace-${t.id}`;window.indexedDB.deleteDatabase(e)}updateWorkspaceViewport(t,e,i){const n=this._store.state.activeWorkspace;if(!n){return}n.viewport={translateX:t,translateY:e,scale:i};n.updatedAt=new Date;this.saveWorkspaceToAppState(n)}addObject(t){this._store.state.objectsMap.insert(t)}removeObject(t){t.isMounted=false;this._store.state.objectsMap.remove((e=>e.id===t.id))}updateObject(t,e){for(const i in e){if(e.hasOwnProperty(i)){t[i]=e[i]}}this._store.state.objectsMap.update(t)}addSelectionGroup(t){this.removeSelectionGroup();this.removeSelectionBox();this._store.state.objectsMap.insert(t)}removeSelectionGroup(){const t=this._store.selectionGroup;if(t){this._store.state.objectsMap.remove((e=>e.id===t.id))}}removeSelectionBox(){const t=this._store.selectionBox;if(t){this._store.state.objectsMap.remove((e=>e.id===t.id))}}deselectAllObjects(){this.removeSelectionGroup();this.rerender()}delete(){const t=this._store.selectionGroup;if(!t){return}t.objects.forEach((t=>this.removeObject(t)));this.removeSelectionGroup();this.rerender()}undo(){this._store.state.objectsMap?.undo()}redo(){this._store.state.objectsMap?.redo()}deleteObject(t){const e=this.findObjectById(t);if(e){this.removeObject(e);this.rerender()}}copy(){const t=this._store.selectionGroup;if(t){this._store.state.copiedObjects=t.objects.sort(((t,e)=>t.zIndex-e.zIndex)).map((t=>t.copy()))}}paste(t,e){const i=this._store.state.copiedObjects;if(!i||i.length===0){return}const n=this._store.state.activeWorkspace;const r=i.some((t=>t.workspaceId!==n.id));const o=Math.min(...i.map((t=>t.translateX)));const s=Math.min(...i.map((t=>t.translateY)));let a;let c;if(t!==undefined&&e!==undefined){a=t;c=e}else if(r){a=o;c=s}else{a=o+25/this._store.state.scale;c=s+25/this._store.state.scale}const l=a-o;const u=c-s;this.removeSelectionGroup();this.removeSelectionBox();const h=y.create(this);i.forEach(((t,e)=>{if(t.workspaceId!==n.id){t.workspaceId=n.id}t.updatePosition(t.translateX+l,t.translateY+u);t.zIndex=this._store.currentZIndex+e;this.addObject(t);h.addOrRemove(t)}));h.isSelected=true;if(i.length===1){h.rotation=i[0].rotation}this.addSelectionGroup(h);if(r){if(t!==undefined&&e!==undefined){h.updatePosition(t,e)}else{h.centerInViewport()}this.engine.viewport.centerFitInViewport(h)}this._store.state.isSelecting=false;const f=this._store.selectionGroup;if(f){this._store.state.copiedObjects=f.objects.sort(((t,e)=>t.zIndex-e.zIndex)).map((t=>t.copy()))}this._store.setState("activeTool",g.getTool("selection"));this.rerender()}bringForward(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=n.length>0?Math.max(...n.map((t=>t.zIndex)))+1:0;i.forEach((t=>{if(t.zIndex!==r){this.updateObject(t,{zIndex:t.zIndex+1})}}));this.rerender()}sendBackward(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=n.length>0?Math.min(...n.map((t=>t.zIndex)))-1:0;i.forEach((t=>{if(t.zIndex!==r){this.updateObject(t,{zIndex:t.zIndex-1})}}));this.rerender()}bringToFront(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=Math.max(...n.map((t=>t.zIndex)))+1;i.forEach((t=>{this.updateObject(t,{zIndex:r})}));this.rerender()}sendToBack(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=Math.min(...n.map((t=>t.zIndex)))-1;i.forEach((t=>{this.updateObject(t,{zIndex:r})}));this.rerender()}selectObjects(t){if(t.length===0){return}const e=y.create(this);t.forEach((t=>{t.isSelected=false;e.addOrRemove(t)}));e.isSelected=true;if(t.length===1){e.rotation=e.objects[0].rotation}this.addSelectionGroup(e);this.rerender()}selectAllObjectsInViewport(){const t=this._store.state.objectsMap.filter((t=>t.isInViewport())).filter((t=>!(t instanceof y)&&!(t instanceof k)&&!(t instanceof F)));if(t.length>0){const e=y.create(this);t.forEach((t=>{t.isSelected=false;e.addOrRemove(t)}));e.isSelected=true;this._store.state.isSelecting=false;if(t.length===1){e.rotation=e.objects[0].rotation}this.addSelectionGroup(e);this._store.setState("activeTool",g.getTool("selection"));this.rerender()}}clearSelection(){this.removeSelectionGroup();this._store.state.objectsMap.remove((t=>t instanceof k||t instanceof y));this._store.state.isSelecting=false;this._store.state.isResizeHandleSelected=false;this._store.state.isRotationHandleSelected=false;this.rerender()}resetActiveText(){const t=this._store.activeText;if(t){if(t.isEmpty){this.deleteObject(t.id)}else{t.save()}}}getObjectFromPointerEvent(t,e=".object"){const i=this._store.state.host?.shadowRoot;if(!i)return null;const n=t.clientX;const r=t.clientY;const o=i.elementFromPoint(n,r);if(!o)return null;const s=o.closest(e);if(s){const t=this._store.allObjects.find((t=>s.id===t.id));const e=t?.hitTest(n,r);return e?t:null}return null}getObjectsFromPointerEvent(t,e=".object"){const i=this._store.state.host?.shadowRoot;if(!i)return[];const n=t.clientX;const r=t.clientY;const o=i.elementsFromPoint(n,r);if(!o||o.length===0)return[];const s=new Set;o.forEach((t=>{const i=t.closest(e);if(i&&i.id){s.add(i.id)}}));if(s.size>0){return this._store.allObjects.filter((t=>s.has(t.id))).sort(((t,e)=>e.zIndex-t.zIndex))}return[]}getCanvasPoint(t){if(!this._store.state.host){return{x:0,y:0}}const e=this._store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;const r=i-this._store.state.translateX;const o=n-this._store.state.translateY;const s=r/this._store.state.scale;const a=o/this._store.state.scale;return{x:s,y:a}}beforeWorkspaceChange(){this.resetActiveText();this.clearSelection();this._store.setState("activeTool",g.getTool("selection"))}}const vt=":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}";const pt=class{get host(){return r(this)}workspace;syncConfig;onWorkspaceChange(t){const e=this.core.store.state.activeWorkspace?.id;const i=t?.id;if(e!==i){this.core.beforeWorkspaceChange();this.core.initializeWorkspace(t)}}activeTool;globalContextMenuItems;objectContextMenuItems;scaleMax=q;validateScaleMax(t){if(t>q){console.warn(`scaleMax cannot be greater than ${q}.`);this.scaleMax=q;this.core.store.state.scaleMax=this.scaleMax}else{this.core.store.state.scaleMax=t}}scaleMin=G;validateScaleMin(t){if(t<G){console.warn(`scaleMin cannot be less than ${G}.`);this.scaleMin=G;this.core.store.state.scaleMin=this.scaleMin}else{this.core.store.state.scaleMin=t}}isEngineReady;activeToolChange;workspacesChange;longpress;forceUpdate=0;handleWheel(t){if(this.core.store.isDisabled){return}if(this.core.store.state.isContextMenuVisible){this.hideContextMenu()}this.viewport.handleWheel(t);this.core.store.state?.activeTool?.handleWheel(t)}handlePointerDown(t){if(this.core.store.isDisabled){return}if(o.isTouchDevice()){_.onLongPress(t,(t=>this.longpress.emit(t)))}this.host.setPointerCapture(t.pointerId);this.core.store.state.pointers.set(t.pointerId,t);this.viewport.handlePointerDown(t);this.core.store.state?.activeTool?.handlePointerDown(t)}throttledPointerMoveMulti=nt.throttle((t=>{this.viewport.handlePointerMove(t);this.core.store.state?.activeTool?.handlePointerMove(t)}),16);handlePointerMove(t){if(this.core.store.isDisabled){return}this.core.store.state.pointers.set(t.pointerId,t);if(this.core.store.state.pointers.size>1){this.throttledPointerMoveMulti(t)}this.viewport.handlePointerMove(t);this.core.store.state?.activeTool?.handlePointerMove(t)}handlePointerUp(t){if(this.core.store.isDisabled){return}this.core.store.state.pointers.delete(t.pointerId);this.host.releasePointerCapture(t.pointerId);this.viewport.handlePointerUp(t);this.core.store.state?.activeTool?.handlePointerUp(t)}handlePointerCancel(t){if(this.core.store.isDisabled){return}this.host.releasePointerCapture(t.pointerId);this.core.store.state.pointers.delete(t.pointerId);this.viewport.handlePointerUp(t);this.core.store.state?.activeTool?.handlePointerUp(t)}handleLongPress(t){this.contextMenuHandler.handleContextMenu(t.detail)}handleContextMenu(t){t.preventDefault();if(this.core.store.isDisabled){return}if(t.pointerType==="touch"){return}this.contextMenuHandler.handleContextMenu(t)}handleResize(){this.viewport.handleResize()}handleKeyDown(t){if(this.core.store.isDisabled){return}this.keyHandler.handleKeyDown(t)}handleKeyUp(t){if(this.core.store.isDisabled){return}this.keyHandler.handleKeyUp(t)}preventDoubleTapZoomOnTouchDevices(t){t.preventDefault()}async registerTool(t,e,i){if(typeof e!=="function"||!(e.prototype instanceof T)){console.error(`Failed to register tool "${t}": Tool class must be a constructor function`);return null}const n=g.registerTool(t,e,this.core);if(i){Object.entries(i).forEach((([t,e])=>{n[t]=e}))}return Promise.resolve(n)}async changeActiveTool(t){this.core.store.state.activeTool?.onDeactivate();this.core.store.setState("activeTool",t);this.core.deselectAllObjects();t?.onActivate()}async disable(){this.core.store.state.isEnabled=false;this.core.rerender()}async enable(){this.core.store.state.isEnabled=true;this.core.rerender()}async delete(){this.core.delete()}async copy(){this.core.copy()}async paste(t,e){this.core.paste(t,e)}async bringForward(t){this.core.bringForward(t)}async sendBackward(t){this.core.sendBackward(t)}async bringToFront(t){this.core.bringToFront(t)}async sendToBack(t){this.core.sendToBack(t)}async undo(){this.core.undo()}async redo(){this.core.redo()}async hideContextMenu(){this.core.store.state.pointers.clear();this.core.store.state.isContextMenuVisible=false;this.core.store.state.objectsMap.remove((t=>t instanceof k));this.core.store.state.isSelecting=false;this.core.store.state.isEnabled=true;this.core.rerender()}async getObjectById(t){const e=this.core.store.allObjects.find((e=>e.id===t));return e||null}async addObject(t){this.core.deselectAllObjects();t.id=t.generateId();t._core=this.core;t.scale=t.scale?t.scale:this.core.store.state.scale;t.zIndex=this.core.store.currentZIndex;this.core.addObject(t);this.core.rerender();return t}async updateObject(t,e){this.core.deselectAllObjects();this.core.updateObject(t,e);this.core.rerender();return t}async removeObject(t){this.core.deselectAllObjects();this.core.removeObject(t);this.core.rerender();return t}async getSelectedObjects(){const t=this.core.store.selectionGroup;return t?t.objects:[]}async selectObjects(t){this.core.store.state.activeTool?.onDeactivate();this.core.store.setState("activeTool",g.getTool("selection"));this.core.deselectAllObjects();this.core.selectObjects(t)}async selectAllObjectsInViewport(){this.core.store.state.activeTool?.onDeactivate();this.core.store.setState("activeTool",g.getTool("selection"));this.core.deselectAllObjects();this.core.selectAllObjectsInViewport()}async clearSelection(){this.core.clearSelection()}async centerObjectInViewport(t){t.centerInViewport();this.core.updateObject(t,t);this.core.rerender();return t}async getCopiedObjects(){return this.core.store.state.copiedObjects||[]}async createWorkspace(t){await this.core.createWorkspace(t);this.workspacesChange.emit(this.core.store.state.workspaces);return t}async updateWorkspace(t){await this.core.updateWorkspace(t);this.workspacesChange.emit(this.core.store.state.workspaces)}async deleteWorkspace(t){await this.core.deleteWorkspace(t);this.workspacesChange.emit(this.core.store.state.workspaces)}async getWorkspaces(){return await this.core.getWorkspaces()}async getActiveWorkspace(){return this.core.store.state.activeWorkspace}core;viewport;contextMenuHandler;keyHandler;contextMenuElement=null;get isSelecting(){return this.core.store.state.activeTool instanceof l&&this.core.store.state.isSelecting}get isSelectionActive(){return this.core.store.state.activeTool instanceof l&&this.core.store.selectionGroup!==null}constructor(e){t(this,e);this.isEngineReady=n(this,"isEngineReady");this.activeToolChange=n(this,"activeToolChange");this.workspacesChange=n(this,"workspacesChange");this.longpress=n(this,"longpress");this.core=new dt(this)}disconnectedCallback(){this.throttledPointerMoveMulti.cancel()}componentWillLoad(){this.validateScaleMax(this.scaleMax);this.validateScaleMin(this.scaleMin)}async componentDidLoad(){this.contextMenuHandler=new st(this.core,this.globalContextMenuItems,this.objectContextMenuItems);this.keyHandler=new ot(this.core);this.viewport=new rt(this.core,this.host);if(this.syncConfig){this.core.setSyncConfig(this.syncConfig)}await this.core.initializeYjs();await this.core.initializeWorkspace(this.workspace);this.core.appStateMap.onRemoteChange((()=>{this.workspacesChange.emit(this.core.store.state.workspaces)}));this._registerStateChangeListeners();if(this.core.store.state.isReady===false){this.core.store.state.isReady=true;this.isEngineReady.emit(this.core.store.state)}}_registerStateChangeListeners(){this.core.store.onStateChange("activeTool",this._handleActiveToolChange.bind(this))}_handleActiveToolChange(t){if(!(t instanceof l)){this.core.clearSelection();this.core.store.state.objectsMap.remove((t=>t instanceof k));this.core.store.state.isSelecting=false;this.core.store.state.isResizeHandleSelected=false;this.core.store.state.isRotationHandleSelected=false}this.core.store.state.skipContextMenu=false;this.core.store.state.copiedObjects=null;this.activeToolChange.emit(t);p.forceHideKeyboard();this.core.rerender()}render(){const t=window.getComputedStyle(this.host);const n=t.getPropertyValue("--kritzel-selection-handle-size").trim()||"6px";const r=parseFloat(n);const s=r*2<14?14:r;const a=this.core.store.state.viewportWidth/2+this.core.store.state.translateX;const c=this.core.store.state.viewportHeight/2+this.core.store.state.translateY;return e(i,{key:"3e05ce246b599985a06e54e0d81a63b4765ff506"},e("div",{key:"6169eb0566bb2965c7d1569492a62a1ef1d4b7ef",class:"debug-panel",style:{display:this.core.store.state.debugInfo.showViewportInfo?"block":"none"}},e("div",{key:"598db5c39099553997248086e392c168c583aca9"},"ActiveWorkspaceId: ",this.core.store.state?.activeWorkspace?.id),e("div",{key:"6d5de3390f2e32dbaa7fe52521b8fd9c0e8706de"},"ActiveWorkspaceName: ",this.core.store.state?.activeWorkspace?.name),e("div",{key:"6006c27d020aeea24170a09140e3bc5c2ea459cf"},"TranslateX: ",this.core.store.state?.translateX),e("div",{key:"edfa3cb59d47df747dc9f003ce08345348ba586d"},"TranslateY: ",this.core.store.state?.translateY),e("div",{key:"799f714d6e4b129f59be7cbc52f657e9b21f9879"},"ViewportWidth: ",this.core.store.state?.viewportWidth),e("div",{key:"4a8f545cf72fe496abf18a4907743ac6b46ef889"},"ViewportHeight: ",this.core.store.state?.viewportHeight),e("div",{key:"8e665e3c23424cb4e76b2d4354bb4472a5b3ddbe"},"PointerCount: ",this.core.store.state.pointers.size),e("div",{key:"c168b114e204b90dafaf8736a571171a748047c1"},"Scale: ",this.core.store.state?.scale),e("div",{key:"bee83601a571727a06235c674e7300cdc398dfac"},"ActiveTool: ",this.core.store.state?.activeTool?.name),e("div",{key:"0a2f5f36143c587ddc9b3ae487ce32196cd17232"},"HasViewportChanged: ",this.core.store.state?.hasViewportChanged?"true":"false"),e("div",{key:"515959ec3700ecdc9dd3ca9183bfacd854d173d2"},"IsEnabled: ",this.core.store.state?.isEnabled?"true":"false"),e("div",{key:"5a9ca8f3ba91f10e9d6bec07c6005c1e43713d69"},"IsScaling: ",this.core.store.state?.isScaling?"true":"false"),e("div",{key:"f5d1a5d59828be47be31e794b3b41c1e14c50780"},"IsPanning: ",this.core.store.state?.isPanning?"true":"false"),e("div",{key:"1db8cdad160c131542fd787d104b4b979415ec4c"},"IsSelecting: ",this.isSelecting?"true":"false"),e("div",{key:"baae83187cfb4c21ea07c7834017df92a7340d5b"},"IsSelectionActive: ",this.isSelectionActive?"true":"false"),e("div",{key:"6b248cb6fad7fb4dd5162fb2529dfec821a708fc"},"IsResizeHandleSelected: ",this.core.store.state.isResizeHandleSelected?"true":"false"),e("div",{key:"0eae863f48c27867d0fa0f8c767b50c13be48271"},"IsRotationHandleSelected: ",this.core.store.state.isRotationHandleSelected?"true":"false"),e("div",{key:"a4ca58af5858725d4f1d0e00547e6e42365cb8fe"},"IsDrawing: ",this.core.store.state.isDrawing?"true":"false"),e("div",{key:"8f978714060623d3daa9454e04ef929b1f02b143"},"IsWriting: ",this.core.store.state.isWriting?"true":"false"),e("div",{key:"9b274d7785a9e4a36128c273bcee6b692d815a86"},"PointerX: ",this.core.store.state?.pointerX),e("div",{key:"0c248bc24c164c4c52fb06b17347f107e3f0995f"},"PointerY: ",this.core.store.state?.pointerY),e("div",{key:"21f3664f0978f308d88a976c47b875dd5bb08b95"},"SelectedObjects: ",this.core.store.selectionGroup?.objects.length||0),e("div",{key:"e1161aa45ea02de914e01a93ec159447b5e17e8b"},"ViewportCenter: (",a.toFixed(2),", ",c.toFixed(2),")")),e("div",{key:"87249fcc3f23632739631b8fdbc64371694d6206",id:"origin",class:"origin",style:{transform:`matrix(${this.core.store.state?.scale}, 0, 0, ${this.core.store.state?.scale}, ${this.core.store.state?.translateX}, ${this.core.store.state?.translateY})`}},this.core.store.state.objectsMap.allObjects()?.map((t=>e("div",{key:t.id,style:{display:t.isInViewport()?"block":"none",transform:t?.transformationMatrix,transformOrigin:"top left",zIndex:t.zIndex.toString(),position:"absolute",pointerEvents:this.core.store.state.isScaling?"none":"auto"}},e("svg",{xmlns:"http://www.w3.org/2000/svg",id:t.id,class:"object",style:{height:t?.totalHeight.toString(),width:t?.totalWidth.toString(),left:"0",top:"0",position:"absolute",transform:`rotate(${t.rotationDegrees}deg)`,transformOrigin:`${t.totalWidth/2}px ${t.totalHeight/2}px`,opacity:t.markedForRemoval?"0.5":t.opacity.toString(),pointerEvents:t.markedForRemoval?"none":"auto"}},e("foreignObject",{x:"0",y:"0",width:t.totalWidth.toString(),height:t.totalHeight.toString(),style:{minHeight:"0",minWidth:"0",backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:t.borderWidth+"px",borderStyle:"solid",padding:t.padding+"px",overflow:"visible"}},at.isInstanceOf(t,"KritzelPath")&&e("svg",{ref:e=>t.mount(e),xmlns:"http://www.w3.org/2000/svg",style:{height:t?.height.toString(),width:t?.width.toString(),position:"absolute",overflow:"visible"},viewBox:t?.viewBox},e("path",{d:t?.d,fill:t.fill,stroke:t?.stroke,"shape-rendering":this.core.store.state.isScaling?"optimizeSpeed":"auto"})),at.isInstanceOf(t,"KritzelImage")&&e("img",{ref:e=>t.mount(e),src:t.src,style:{width:"100%",height:"100%",userSelect:"none",pointerEvents:"none",imageRendering:this.core.store.state.isScaling?"pixelated":"auto"},draggable:false,onDragStart:t=>t.preventDefault()}),at.isInstanceOf(t,"KritzelText")&&e("div",{ref:e=>t.mount(e),onPointerDown:e=>t.handlePointerDown(e),onPointerMove:e=>t.handlePointerMove(e),onPointerUp:e=>t.handlePointerUp(e),style:{minWidth:t.initialWidth+"px",minHeight:t.initialHeight+"px",maxWidth:"500px",height:"auto",width:"max-content",transformOrigin:"top left",transform:`scale(${t.scaleFactor})`,backgroundColor:t.backgroundColor,overflow:"visible",textRendering:this.core.store.state.isScaling?"optimizeSpeed":"auto"}}),at.isInstanceOf(t,"KritzelCustomElement")&&e("div",{ref:e=>t.mount(e),style:{width:"100%",height:"100%",pointerEvents:"auto",overflow:"hidden",display:"block"}}),at.isInstanceOf(t,"KritzelSelectionGroup")&&e("div",{ref:e=>t.mount(e),style:{width:"100%",height:"100%"}}),at.isInstanceOf(t,"KritzelSelectionBox")&&e("div",{ref:e=>t.mount(e),style:{width:"100%",height:"100%",backgroundColor:o.isFirefox()?t.backgroundColor:"transparent",borderWidth:o.isFirefox()?t.borderWidth+"px":"0",borderStyle:o.isFirefox()?"solid":"none",borderColor:o.isFirefox()?t.borderColor:"transparent"}})),e("line",{x1:"0",y1:"0",x2:t.totalWidth,y2:"0",style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("line",{x1:"0",y1:"0",x2:"0",y2:t.totalHeight,style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("line",{x1:"0",y1:t.totalHeight,x2:t.totalWidth,y2:t.totalHeight,style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("line",{x1:t.totalWidth,y1:"0",x2:t.totalWidth,y2:t.totalHeight,style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("circle",{class:"resize-handle top-left",cx:"0",cy:"0",r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay top-left",cx:"0",cy:"0",r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle top-right",cx:t.totalWidth,cy:"0",r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay top-right",cx:t.totalWidth,cy:"0",r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle bottom-left",cx:"0",cy:t.totalHeight,r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay bottom-left",cx:"0",cy:t.totalHeight,r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle bottom-right",cx:t.totalWidth,cy:t.totalHeight,r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay bottom-right",cx:t.totalWidth,cy:t.totalHeight,r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("line",{x1:t.totalWidth/2,y1:"0",x2:t.totalWidth/2,y2:-(15*t.scale/this.core.store.state?.scale),style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"rotation-handle",cx:t.totalWidth/2,cy:-(15*t.scale/this.core.store.state?.scale),r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"rotation-handle-overlay",cx:t.totalWidth/2,cy:-(15*t.scale/this.core.store.state?.scale),r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent",cursor:"grab"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("g",{style:{display:this.core.store.state.debugInfo.showObjectInfo?"block":"none",pointerEvents:"none"}},e("foreignObject",{x:t.totalWidth.toString(),y:"0",width:"400px",height:"160px",style:{minHeight:"0",minWidth:"0",display:t.isDebugInfoVisible?"block":"none"}},e("div",{style:{width:"100%",height:"100%"}},e("div",{style:{whitespace:"nowrap"}},"Id: ",t.id),e("div",{style:{whiteSpace:"nowrap"}},"width: ",t.width),e("div",{style:{whiteSpace:"nowrap"}},"height: ",t.height),e("div",{style:{whiteSpace:"nowrap"}},"translateX: ",t.translateX),e("div",{style:{whiteSpace:"nowrap"}},"translateY: ",t.translateY))))))))),this.core.store.state.isContextMenuVisible&&e("kritzel-context-menu",{key:"e99d647c9be209966a4e302773eef855667800e2",class:"context-menu",ref:t=>this.contextMenuElement=t,items:this.core.store.state.contextMenuItems,objects:this.core.store.selectionGroup?.objects||[],style:{position:"fixed",left:`${this.core.store.state.contextMenuX}px`,top:`${this.core.store.state.contextMenuY}px`,zIndex:"10000"},onActionSelected:t=>{t.detail.action({x:(-this.core.store.state.translateX+this.core.store.state.contextMenuX)/this.core.store.state.scale,y:(-this.core.store.state.translateY+this.core.store.state.contextMenuY)/this.core.store.state.scale},this.core.store.selectionGroup?.objects);this.hideContextMenu()},onClose:()=>this.hideContextMenu()}),this.core.store.state?.activeTool instanceof h&&!this.core.store.state.isScaling&&e("kritzel-cursor-trail",{key:"a7301f377705b93d2dd1b0f0e8da2bc40522b0a3",core:this.core}))}static get watchers(){return{workspace:["onWorkspaceChange"],scaleMax:["validateScaleMax"],scaleMin:["validateScaleMin"]}}};pt.style=vt;const bt=":host{display:block}.font-preview{color:var(--kritzel-font-size-text-color, #333333);line-height:1;text-align:center;font-weight:bold}";const gt=class{constructor(e){t(this,e)}fontFamily="Arial, sans-serif";size=24;color="#000000";render(){return e(i,{key:"0a6f1d1326e9dde84a4122d79f75dc1c75ffe0fb"},e("div",{key:"88a342d01c4150cd4fc5dacca23f7b9904edca52",class:"font-preview",style:{fontFamily:this.fontFamily,fontSize:`${this.size}px`,color:this.color}},"A"))}};gt.style=bt;const kt=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.font-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:pointer;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}.font-style-button.italic-text{font-style:italic}";const yt=class{constructor(e){t(this,e);this.fontFamilyChange=n(this,"fontFamilyChange")}fontOptions=[{value:"arial",label:"Arial"},{value:"verdana",label:"Verdana"},{value:"helvetica",label:"Helvetica"},{value:"tahoma",label:"Tahoma"},{value:"trebuchet ms",label:"Trebuchet MS"},{value:"times new roman",label:"Times New Roman"},{value:"georgia",label:"Georgia"},{value:"garamond",label:"Garamond"},{value:"courier new",label:"Courier New"},{value:"brush script mt",label:"Brush Script MT"}];selectedFontFamily;fontFamilyChange;componentWillLoad(){if(this.fontOptions&&this.fontOptions.length>0){const t=this.fontOptions.some((t=>t.value===this.selectedFontFamily));if(!this.selectedFontFamily||!t){this.selectedFontFamily=this.fontOptions[0].value}}}handleDropdownValueChange=t=>{this.fontFamilyChange.emit(t.detail)};render(){const t=this.fontOptions.map((t=>({value:t.value,label:t.label,style:{fontFamily:t.value}})));return e(i,{key:"27d14ddb4a57b9cd7b936047b6ea6a9251a1ab27"},e("kritzel-dropdown",{key:"20ea042c9a907dc1ac5e16a589a8856f87389e36",options:t,value:this.selectedFontFamily,onValueChanged:this.handleDropdownValueChange,selectStyles:{fontFamily:this.selectedFontFamily}},e("button",{key:"f63fed16477a327aadaeb54feefe35df1780e37d",class:"font-style-button",slot:"suffix"},"B"),e("button",{key:"13b3089606c2e83b256ed2cec6513a9911016754",class:"font-style-button italic-text",slot:"suffix"},"I")))}};yt.style=kt;const wt=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:4px;cursor:pointer;border:2px solid transparent;box-sizing:border-box;border-radius:50%}.size-container:hover{background-color:var(--kritzel-font-size-hover-background-color, #ebebeb)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-font-size-selected-background-color, #e0e0e0)}";const mt=class{constructor(e){t(this,e);this.sizeChange=n(this,"sizeChange")}sizes=[8,10,12,16,20,24];selectedSize=null;fontFamily="Arial";sizeChange;handleSizeClick(t){this.selectedSize=t;this.sizeChange.emit(t)}render(){return e(i,{key:"9f3d851d443352f7437116cf91eff8d8de41e322"},this.sizes.map((t=>e("div",{class:{"size-container":true,selected:this.selectedSize===t},onClick:()=>this.handleSizeClick(t)},e("kritzel-font",{fontFamily:this.fontFamily,size:t})))))}};mt.style=wt;const xt=":host{display:inline-flex;justify-content:center;align-items:center;color:var(--kritzel-icon-color, inherited)}span{display:flex;align-items:center;width:100%;height:100%;}span>svg{width:100%;height:100%}";const zt=class{constructor(e){t(this,e)}name;label;size=24;render(){const t=X.get(this.name);if(!t){console.error(`[kritzel-icon] Icon "${this.name}" not found in registry.`);return e("span",{class:"error-icon","aria-label":`Error: Icon ${this.name} not found`},"?")}const n={width:`${this.size}px`,height:`${this.size}px`};return e(i,{style:n},e("span",{"aria-hidden":!this.label,role:this.label?"img":undefined,"aria-label":this.label,innerHTML:t}))}};zt.style=xt;const Ct=":host{position:relative;display:flex;flex-direction:column;background-color:var(--kritzel-menu-background-color, #ffffff);width:var(--kritzel-menu-width, 200px);padding:var(--kritzel-menu-padding, 8px);border-radius:var(--kritzel-menu-border-radius, 12px);box-shadow:var(--kritzel-menu-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-menu-border, 1px solid #ebebeb);z-index:2;gap:var(--kritzel-menu-gap, 4px);overflow-y:auto;scrollbar-color:#ebebeb transparent;scrollbar-width:thin;max-height:300px}:host(:focus-visible){outline:var(--kritzel-menu-focus-outline, 2px solid #e3e3e3)}.has-open-child-overlay{position:absolute;top:0;left:0;right:0;bottom:0;z-index:3}";const Mt=class{constructor(e){t(this,e);this.itemSelect=n(this,"itemSelect");this.itemSave=n(this,"itemSave");this.itemCancel=n(this,"itemCancel");this.itemToggleChildMenu=n(this,"itemToggleChildMenu");this.itemCloseChildMenu=n(this,"itemCloseChildMenu");this.close=n(this,"close")}get host(){return r(this)}items;parent=null;itemSelect;itemSave;itemCancel;itemToggleChildMenu;itemCloseChildMenu;close;selectedIndex=null;async setScrollTop(t){this.host.scrollTop=t;this.host.scrollTo({top:t,behavior:"auto"})}async setFocus(){const t=this.host.shadowRoot.querySelector("kritzel-menu-item");if(t){t.focus()}}get openChildMenuItem(){return this.items.find((t=>t.isChildMenuOpen))}get editingMenuItem(){return this.items.find((t=>t.isEditing))}onOverlayClick=t=>{t.stopPropagation();this.itemCloseChildMenu.emit(this.openChildMenuItem)};handleItemSelect=t=>{t.stopPropagation();this.itemSelect.emit(t.detail)};handleSave=t=>{t.stopPropagation();this.itemSave.emit(t.detail)};handleCancel=t=>{t.stopPropagation();this.itemCancel.emit(t.detail)};handleToggleChildMenu=t=>{t.stopPropagation();this.itemToggleChildMenu.emit(t.detail)};handleCloseChildMenu=t=>{t.stopPropagation();this.itemCloseChildMenu.emit(t.detail)};render(){return e(i,{key:"be122cb0ecff3227d9e69997de76a73940a61860",tabIndex:0,onClick:t=>t.stopPropagation()},this.openChildMenuItem&&e("div",{key:"ae10bec61e5c5e1a29b444cb7378f15c6692f3b6",class:"has-open-child-overlay",onClick:this.onOverlayClick}),this.items.map((t=>e("kritzel-menu-item",{key:t.id,item:t,parent:this.parent,style:{pointerEvents:this.editingMenuItem&&!t.isEditing?"none":"auto"},onItemSelect:this.handleItemSelect,onItemSave:this.handleSave,onItemCancel:this.handleCancel,onItemToggleChildMenu:this.handleToggleChildMenu,onItemCloseChildMenu:this.handleCloseChildMenu}))))}};Mt.style=Ct;const jt=":host{position:relative;display:flex;align-items:center;justify-content:space-between;width:100%;padding:var(--kritzel-menu-item-padding, 8px);box-sizing:border-box;gap:16px;height:var(--kritzel-menu-item-height, 40px);min-height:var(--kritzel-menu-item-min-height, 40px);font-family:sans-serif;font-size:var(--kritzel-menu-item-font-size, 14px);color:var(--kritzel-menu-item-color, #333333);border-radius:var(--kritzel-menu-item-border-radius, 12px);outline:none;cursor:default}:host(:hover) .menu-item-overlay,:host(:focus-within) .menu-item-overlay{background-color:var(--kritzel-menu-item-overlay-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.selected){background-color:var(--kritzel-menu-item-selected-bg, #007aff);color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected) .action-button{color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected.editing){background-color:var(--kritzel-menu-item-selected-bg, #007aff)}:host(.selected) .edit-input{color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected) .action-button kritzel-icon{--kritzel-icon-color:var(--kritzel-menu-item-selected-color, #ffffff)}kritzel-icon{--kritzel-icon-color:var(--kritzel-menu-item-color, #333333)}:host(.selected) .edit-input::selection{background-color:var(--kritzel-menu-item-input-selection-color, rgba(255, 255, 255, 0.16))}:host(.editing){background-color:var(--kritzel-menu-item-editing-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.disabled){opacity:0.5;pointer-events:none !important}:host(.child-open){background-color:var(--kritzel-menu-item-child-open-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.child-open.selected){background-color:var(--kritzel-menu-item-selected-bg, #007aff)}.menu-item-overlay{position:absolute;inset:0;background-color:transparent;z-index:0;pointer-events:none;border-radius:var(--kritzel-menu-item-border-radius, 12px)}.menu-item-content{display:flex;align-items:center;gap:8px;position:relative;z-index:1;height:100%}.left{justify-content:flex-start;flex:1;min-width:0}.left>div{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.right{justify-content:flex-end}.edit-input{flex:1;height:var(--kritzel-menu-item-input-height, 24px);padding:0;background-color:transparent;border-radius:0;border:none;border-bottom:1px solid var(--kritzel-menu-item-input-border, #ccc);font-size:var(--kritzel-context-menu-item-font-size, 14px);width:100%;min-width:0;box-sizing:border-box;outline:none}.edit-input::selection{background-color:var(--kritzel-menu-item-input-selection-color, #007bff);color:var(--kritzel-menu-item-input-selection-text-color, #ffffff)}.action-button{padding:4px;border-radius:8px;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;background-color:transparent;background:transparent;outline:none;-webkit-tap-highlight-color:transparent}.action-button:hover,.action-button:focus{background-color:var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.action-button.disabled{pointer-events:none;opacity:0.5}";const It=class{constructor(e){t(this,e);this.itemSelect=n(this,"itemSelect");this.itemSave=n(this,"itemSave");this.itemCancel=n(this,"itemCancel");this.itemToggleChildMenu=n(this,"itemToggleChildMenu");this.itemCloseChildMenu=n(this,"itemCloseChildMenu")}get host(){return r(this)}item;onItemChange(t,e){if(t!==e){this.isDirty=false}}parent=null;itemSelect;itemSave;itemCancel;itemToggleChildMenu;itemCloseChildMenu;isDirty=false;inputRef;focusInput(){if(this.item.isEditing&&this.inputRef&&!this.isDirty){this.inputRef.focus();if(o.isIOS()){const t=this.inputRef.value.length;this.inputRef.setSelectionRange(t,t)}else{this.inputRef.select()}}}componentDidLoad(){this.setDeviceSpecificStyles();this.focusInput()}componentDidUpdate(){this.focusInput()}setDeviceSpecificStyles=()=>{const t=o.isTouchDevice();if(t){this.host.style.setProperty("--kritzel-menu-item-overlay-background-color","transparent");this.host.style.setProperty("--kritzel-menu-item-button-hover-background-color","transparent")}};handleItemSelect=t=>{t.stopPropagation();this.itemSelect.emit({item:this.item,parent:this.parent})};handleInputChange=t=>{t.stopPropagation();const e=t.target;this.item.label=e.value;this.isDirty=true};handleSave=t=>{t.stopPropagation();this.host.focus();this.itemSave.emit(this.item)};handleCancel=t=>{t.stopPropagation();this.host.focus();this.itemCancel.emit(this.item)};handleMenuToggle=t=>{t.stopPropagation();this.itemToggleChildMenu.emit({item:this.item,childMenuAnchor:t.target})};handleMenuClose=()=>{this.itemCloseChildMenu.emit(this.item)};renderViewMode(){return[e("div",{class:"menu-item-content left"},e("div",null,this.item.label)),e("div",{class:"menu-item-content right"},this.item.children&&this.item.children.length>0&&[e("button",{id:"child-menu-toggle",class:"action-button",onClick:this.handleMenuToggle,disabled:this.item.isDisabled},e("kritzel-icon",{name:"ellipsis-vertical",size:16})),e("kritzel-portal",{anchor:this.item.childMenuAnchor,offsetY:4,onClose:this.handleMenuClose},e("kritzel-menu",{items:this.item.children,parent:this.item,onItemSelect:t=>this.itemSelect.emit(t.detail),onItemSave:t=>this.itemSave.emit(t.detail),onItemCancel:t=>this.itemCancel.emit(t.detail),onClose:this.handleMenuClose}))])]}renderEditMode(){return[e("div",{class:"menu-item-content left"},e("input",{ref:t=>this.inputRef=t,type:"text",class:"edit-input",value:this.item.label,onInput:this.handleInputChange})),e("div",{class:"menu-item-content right"},e("div",{tabIndex:0,class:"action-button",onClick:this.handleCancel},e("kritzel-icon",{name:"x",size:16})),e("div",{tabIndex:!this.isDirty&&!this.item.isNewItem?-1:0,class:{"action-button":true,disabled:!this.isDirty&&!this.item.isNewItem},onClick:this.handleSave},e("kritzel-icon",{name:"check",size:16})))]}render(){return e(i,{key:"9df3acdaff753e3ed910f848c98e8ad73e2b5f5c",tabIndex:this.item.isDisabled?-1:0,class:{selected:this.item.isSelected,editing:this.item.isEditing,disabled:this.item.isDisabled,"child-open":this.item.isChildMenuOpen},onClick:this.handleItemSelect},e("div",{key:"bb73e5c0c3dd87efabcaa0b53d20c7c477b34aa1",class:"menu-item-overlay"}),this.item.isEditing?this.renderEditMode():this.renderViewMode())}static get watchers(){return{item:["onItemChange"]}}};It.style=jt;class St{static getNumericValueFromStyle(t,e){const i=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(i)||0}static getScrollableParent(t){if(!t){return window}const e=t.parentNode?.host??t.parentElement;if(!e||e.tagName==="BODY"){return window}const i=window.getComputedStyle(e);if(i.overflow==="auto"||i.overflowY==="auto"||i.overflow==="scroll"||i.overflowY==="scroll"){return e}return this.getScrollableParent(e)}static isElementInViewport(t){if(!t){return false}const e=this.getScrollableParent(t);const i=t.getBoundingClientRect();if(e===window){const t=window.innerHeight||document.documentElement.clientHeight;const e=window.innerWidth||document.documentElement.clientWidth;return i.top>=0&&i.left>=0&&i.bottom<=t&&i.right<=e}const n=e.getBoundingClientRect();return i.top>=n.top&&i.left>=n.left&&i.bottom<=n.bottom&&i.right<=n.right}static getFocusableElements(t){if(!t)return[];const e=[];const i='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details, [tabindex]:not([tabindex="-1"])';const n=t=>t.offsetParent!==null;const r=t=>{if(t instanceof HTMLElement&&t.matches(i)&&!t.hasAttribute("disabled")&&n(t)){e.push(t)}if(t.shadowRoot){Array.from(t.shadowRoot.children).forEach(r)}if(t.tagName==="SLOT"){t.assignedElements({flatten:true}).forEach(r)}if(!t.shadowRoot){Array.from(t.children).forEach(r)}};r(t);return e}}const _t=class{constructor(e){t(this,e);this.close=n(this,"close")}get host(){return r(this)}anchor;anchorChanged(t){if(t){this.openPortal();this.calculatePosition();if(this.autoFocus){this.focusFirstElement()}}else{this.closePortal()}}offsetX;offsetY;autoFocus=true;close;handleOutsideClick(t){t.stopPropagation();const e=this.lastAddedPortal===this.portal;if(!e)return;const i=t.target;if(!this.host.contains(i)){this.close.emit();this.closePortal()}}handleKeyDown(t){t.stopPropagation();const e=this.lastAddedPortal===this.portal;if(!e)return;if(t.key==="Escape"){this.anchor.focus();this.close.emit();this.closePortal()}if(t.key==="Tab"){this.trapFocus(t)}if(t.key==="Enter"){const e=this.getDeepActiveElement();if(e?.click){t.preventDefault();e.click()}}}handleResize(){this.calculatePosition()}handleWindowScroll(){const t=St.isElementInViewport(this.anchor);if(!t){this.anchor?.blur();this.closePortal();return}this.calculatePosition()}portal;id=`portal-${S.generateUUID()}`;defaultOffset=0;minLeft=0;focusFirstElement(){requestAnimationFrame((()=>{this.firstFocusableElement?.focus?.()}))}getDeepActiveElement(){let t=document.activeElement;while(t?.shadowRoot?.activeElement){t=t.shadowRoot.activeElement}return t}trapFocus(t){const e=St.getFocusableElements(this.host);if(e.length===0)return;const i=e[0];const n=e[e.length-1];const r=this.getDeepActiveElement();if(t.shiftKey){if(r===i){n.focus();t.preventDefault()}}else{if(r===n){i.focus();t.preventDefault()}}}get firstFocusableElement(){const t=this.host.shadowRoot?.querySelector("slot");const e=t?.assignedElements({flatten:true})[0];if(!e)return null;const i=St.getFocusableElements(e);return i[0]??e}get lastAddedPortal(){const t=Array.from(document.querySelectorAll('[id^="portal-"]'));return t.length?t[t.length-1]:null}calculateLeft(){if(!this.anchor||!this.portal)return 0;const t=this.anchor.getBoundingClientRect();const e=this.portal.getBoundingClientRect();const i=this.offsetX??this.defaultOffset;let n=t.left+i;const r=window.innerWidth-e.width-this.minLeft;if(n<this.minLeft)n=this.minLeft;if(n>r)n=r;return Math.round(n+window.scrollX)}calculateTop(){if(!this.anchor||!this.portal)return 0;const t=this.anchor.getBoundingClientRect();const e=this.portal.getBoundingClientRect();const i=this.offsetY??this.defaultOffset;let n=t.bottom+i;if(n+e.height>window.innerHeight){n=t.top-e.height-i}return Math.round(n+window.scrollY)}openPortal(){this.portal=document.createElement("div");this.portal.setAttribute("id",this.id);this.portal.style.zIndex="1";this.portal.style.position="absolute";this.portal.style.top="0px";this.portal.style.left="0px";this.portal.appendChild(this.host);document.body.append(this.portal)}closePortal(){const t=document.getElementById(this.id);if(!t)return;document.body.removeChild(t);this.host.remove()}calculatePosition(){if(!this.anchor||!this.portal)return;const t=this.calculateTop();const e=this.calculateLeft();this.portal.style.top=`${t}px`;this.portal.style.left=`${e}px`}render(){return e(i,{key:"9c5cdf7126ff1148dd2364cce9d2524862e27d13",style:{display:this.anchor?"block":"none"}},e("slot",{key:"209a77246fedcea0c24882605487452ff5cc62ce"}))}static get watchers(){return{anchor:["anchorChanged"]}}};const Tt=":host{position:relative;display:flex;align-items:center;font-family:sans-serif;z-index:1;padding:var(--kritzel-split-button-padding, 4px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-split-button-border, 1px solid #ebebeb);gap:var(--kritzel-split-button-gap, 4px)}:host(.mobile){--kritzel-split-button-hover-background-color:transparent}button{border:none;background-color:transparent;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;text-align:center;display:flex;align-items:center;justify-content:center;pointer-events:all;-webkit-tap-highlight-color:transparent}.split-main-button,.split-menu-button{height:auto;display:flex;align-items:center;padding:var(--kritzel-split-button-padding, 8px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);font-size:var(--kritzel-split-button-font-size, 14px)}.split-main-button:hover,.split-menu-button:hover{background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button:focus,.split-menu-button:focus{outline:none;background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button{gap:var(--kritzel-split-button-gap, 4px)}.split-menu-button{border-left:none;justify-content:center}.split-divider{width:var(--kritzel-split-button-divider-width, 1px);height:24px;background-color:var(--kritzel-split-button-divider-background-color, hsl(0, 0%, 0%, 4.3%))}:disabled{pointer-events:none;opacity:0.5}";const At=class{constructor(e){t(this,e);this.mainButtonClick=n(this,"mainButtonClick");this.itemSelect=n(this,"itemSelect");this.itemSave=n(this,"itemSave");this.itemCancel=n(this,"itemCancel");this.itemToggleChildMenu=n(this,"itemToggleChildMenu");this.itemCloseChildMenu=n(this,"itemCloseChildMenu");this.menuOpen=n(this,"menuOpen");this.menuClose=n(this,"menuClose")}get host(){return r(this)}buttonIcon="plus";dropdownIcon="chevron-down";items=[];mainButtonDisabled=false;menuButtonDisabled=false;mainButtonClick;itemSelect;itemSave;itemCancel;itemToggleChildMenu;itemCloseChildMenu;menuOpen;menuClose;isMenuOpen=false;isTouchDevice=o.isTouchDevice();anchorElement;menuScrollTop=0;splitMenuButtonRef;menuRef;async open(){if(this.isMenuOpen)return;this.isMenuOpen=true;this.anchorElement=this.host;this.menuOpen.emit()}async focusMenu(){if(this.menuRef){await this.menuRef.setFocus()}}handleButtonClick=t=>{t.stopPropagation();this.mainButtonClick.emit()};toggleMenu=t=>{t.stopPropagation();if(this.isMenuOpen){this.closeMenu()}else{this.openMenu(t)}};openMenu=t=>{t.stopPropagation();this.isMenuOpen=true;this.anchorElement=this.host;this.menuOpen.emit();requestAnimationFrame((()=>{this.menuRef?.setScrollTop(this.menuScrollTop)}))};closeMenu=()=>{this.isMenuOpen=false;this.anchorElement=null;this.splitMenuButtonRef?.blur();this.menuClose.emit()};handleItemSelect=t=>{this.itemSelect.emit(t.detail)};handleItemSave=t=>{this.itemSave.emit(t.detail)};handleItemCancel=t=>{this.itemCancel.emit(t.detail)};handleItemToggleChildMenu=t=>{this.itemToggleChildMenu.emit(t.detail)};handleItemCloseChildMenu=t=>{this.itemCloseChildMenu.emit(t.detail)};handleScroll=t=>{this.menuScrollTop=t.target.scrollTop};render(){return e(i,{key:"4ff7809dd62c1dd60600fda592aeac43cd9bc74c",class:{mobile:this.isTouchDevice}},e("button",{key:"db6485fabcffdd75a25d178aca7b653af499a90c",class:"split-main-button",tabIndex:0,onClick:this.handleButtonClick,disabled:this.mainButtonDisabled},this.buttonIcon&&e("kritzel-icon",{key:"4001a4e23ef53bec2a578310de8c8b593d7b266c",name:this.buttonIcon})),e("div",{key:"8ff86d3c01a48b06afca77dd066518efa3589cb1",class:"split-divider"}),e("button",{key:"f1c40edbec3756a7f3681de4e8d0f1981dd312a4",ref:t=>this.splitMenuButtonRef=t,class:"split-menu-button",tabIndex:0,onClick:this.toggleMenu,disabled:this.menuButtonDisabled},e("kritzel-icon",{key:"0ddb89976632ae7454e66504f8bab3fd5072c252",name:this.dropdownIcon})),e("kritzel-portal",{key:"64531ffd6ac847fd1a99e32aceefea9f18088992",anchor:this.anchorElement,offsetY:4,onClose:this.closeMenu},e("kritzel-menu",{key:"f3b86cb71e5ba39e8f98e26b3669416e2cdb4802",ref:t=>this.menuRef=t,items:this.items,onItemSelect:this.handleItemSelect,onItemSave:this.handleItemSave,onItemCancel:this.handleItemCancel,onItemToggleChildMenu:this.handleItemToggleChildMenu,onItemCloseChildMenu:this.handleItemCloseChildMenu,onClose:this.closeMenu,onScroll:this.handleScroll})))}};At.style=Tt;const $t=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.size-container:focus-visible{outline:var(--kritzel-stroke-size-focus-outline, 2px auto #e3e3e3)}.size-container:hover{background-color:var(--kritzel-stroke-size-hover-background-color, #ebebeb)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-stroke-size-selected-background-color, #ebebeb)}";const Et=class{constructor(e){t(this,e);this.sizeChange=n(this,"sizeChange")}sizes=[4,6,8,12,16,24];selectedSize=null;sizeChange;handleSizeClick(t){this.selectedSize=t;this.sizeChange.emit(t)}render(){return e(i,{key:"74579e34c23725e22927afe371c1f7925903720a"},this.sizes.map((t=>e("div",{tabIndex:0,class:{"size-container":true,selected:this.selectedSize===t},onClick:()=>this.handleSizeClick(t)},e("kritzel-color",{value:"#000000",size:t})))))}};Et.style=$t;const Ot=":host{width:auto}.tooltip-content{position:relative;padding:8px 12px;border-radius:4px;width:fit-content;background-color:var(--kritzel-controls-tooltip-background-color, #ffffff);color:var(--kritzel-controls-tooltip-color, #000000);padding:var(--kritzel-controls-tooltip-padding, 8px);border-radius:var(--kritzel-controls-tooltip-border-radius, 16px);white-space:nowrap;box-shadow:var(--kritzel-controls-tooltip-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12))}";const Rt=768;const Wt=class{constructor(e){t(this,e);this.tooltipClosed=n(this,"tooltipClosed")}get host(){return r(this)}isVisible=false;anchorElement;arrowSize=8;offsetY=24;tooltipClosed;positionX=0;arrowOffset="0px";isMobileView=window.innerWidth<Rt;handleOutsideClick(t){if(!this.isVisible)return;const e=t.target;if(!this.host.contains(e)){this.tooltipClosed.emit()}}handleWindowResize(){this.isMobileView=window.innerWidth<Rt;this.calculateAdjustedPosition()}async focusContent(){const t=St.getFocusableElements(this.host);if(t.length>0){t[0].focus()}}componentDidLoad(){this.focusSlottedContent()}componentWillLoad(){this.isMobileView=window.innerWidth<Rt;this.calculateAdjustedPosition()}componentWillUpdate(){this.calculateAdjustedPosition()}focusSlottedContent(){const t=this.host.shadowRoot?.querySelector("slot");const e=t?.assignedElements()||[];if(e.length>0){const t=e[0];t.focus()}}calculateAdjustedPosition(){if(this.isVisible&&this.anchorElement){const t=this.anchorElement.getBoundingClientRect();const e=this.host.shadowRoot?.querySelector(".tooltip-content");if(!this.isMobileView){this.positionX=t.left+t.width/2;this.arrowOffset=`calc(${50}% - ${this.arrowSize}px)`}else{const i=e.getBoundingClientRect();this.positionX=t.left+t.width/2-i.width/2;this.arrowOffset=`${t.left+t.width/2-i.left-this.arrowSize}px`}}}render(){return e(i,{key:"72a6356a43a15a7abc9a46b0d22c3c62217791e8",style:{position:"fixed",zIndex:"9999",transition:"opacity 0.3s ease-in-out, transform 0.3s ease-in-out",visibility:this.isVisible?"visible":"hidden",left:!this.isMobileView?`${this.positionX}px`:"50%",marginBottom:`${this.offsetY+this.arrowSize}px`}},e("div",{key:"75f5350f23ada0eee009279eddd7d25273ad3740",class:"tooltip-content",onClick:t=>t.stopPropagation()},e("slot",{key:"ad999154289e933cac1fdc13392de2aec78811a8"}),e("div",{key:"6be3f5c24d42898920c339be2cd2f3dd8a82fa80",class:"tooltip-arrow-wrapper",style:{position:"fixed",left:this.arrowOffset,bottom:`-${this.arrowSize*2}px`}},e("div",{key:"37397c6245dd6b0def23e2611d118e0c4f5860ef",class:"tooltip-arrow",style:{borderLeft:`${this.arrowSize}px solid transparent`,borderRight:`${this.arrowSize}px solid transparent`,borderTop:`${this.arrowSize}px solid var(--kritzel-controls-tooltip-background-color, #ffffff)`,filter:"drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))"}}),e("div",{key:"dbf009c371d46ef0a36e27771758c66e817d9b22",class:"tooltip-arrow-rect",style:{position:"relative",width:`${this.arrowSize*2}px`,height:`${this.arrowSize}px`,backgroundColor:"var(--kritzel-controls-tooltip-background-color, #ffffff)",bottom:`${this.arrowSize*2}px`}}))))}};Wt.style=Ot;const Ft=":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:12px;border-top-right-radius:12px;background-color:rgb(226, 226, 226);width:fit-content;user-select:none}.utility-button{display:flex;justify-content:center;align-items:center;width:28px;height:28px;padding:8px 4px;border:none;outline:none;background:none;cursor:pointer;color:#333333;-webkit-tap-highlight-color:transparent;border-radius:var(--kritzel-utility-panel-button-border-radius, 8px)}.utility-button:focus{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.utility-separator{width:1px;height:16px;background-color:hsl(0, 0%, 0%, 4.3%)}";const Dt=class{constructor(e){t(this,e);this.undo=n(this,"undo");this.redo=n(this,"redo");this.delete=n(this,"delete")}undo;redo;delete;handleUndo(t){if(t.cancelable){t.preventDefault();t.stopPropagation();this.undo.emit()}}handleRedo(t){t.preventDefault();t.stopPropagation();this.redo.emit()}render(){return e(i,{key:"8e2eb13668d8787827b10cee7c9daf2abdecc2c6"},e("button",{key:"0773e7ef81bc972ba589333f4ac7e85d98737770",class:"utility-button",onClick:t=>this.handleUndo(t)},e("kritzel-icon",{key:"fa69c1a2535d44bfb871a4d719079d0f900cc6c7",name:"undo"})),e("button",{key:"edc28968f3ec92467d6b4aaa095a71770413d657",class:"utility-button",onClick:t=>this.handleRedo(t)},e("kritzel-icon",{key:"d4cf72e2bda411fe9942d473c5e1ceae62a76074",name:"redo"})),e("div",{key:"8927237c6099a147495564657cdef97e7d35d7c1",class:"utility-separator"}),e("button",{key:"e089819f7dd870165130322c3c4a9d754d4ed023",class:"utility-button"},e("kritzel-icon",{key:"a143770d1b3f8fdbe5c5b36c5d7eaab511cd8a4b",name:"delete",onClick:()=>this.delete.emit()})))}};Dt.style=Ft;const Bt=":host{display:flex;flex-direction:column;z-index:1}";const Pt=class{constructor(e){t(this,e);this.isWorkspaceManagerReady=n(this,"isWorkspaceManagerReady");this.workspaceChange=n(this,"workspaceChange")}get host(){return r(this)}activeWorkspace;workspaces=[];isWorkspaceManagerReady;workspaceChange;childMenuAnchor=null;openChildMenuItem=null;newWorkspace=null;editingItemId=null;handleWheel(t){if(t.ctrlKey){t.preventDefault()}}kritzelEngineRef=null;splitButtonRef;get sortedWorkspaces(){return[this.newWorkspace,...this.workspaces].filter((t=>t!=null)).sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}async componentWillLoad(){await this.initializeEngine();this.isWorkspaceManagerReady.emit()}async initializeEngine(){await customElements.whenDefined("kritzel-engine");this.kritzelEngineRef=this.host.parentElement.querySelector("kritzel-engine");if(!this.kritzelEngineRef){throw new Error("kritzel-engine not found in parent element.")}}async select(t,e){if(this.editingItemId){return}if(t.action){t.action(t,e);return}this.workspaceChange.emit(t.value)}async add(){await this.splitButtonRef.open();this.newWorkspace=new v(S.generateUUID(),"New Workspace");this.editingItemId=this.newWorkspace.id}edit(t){this.openChildMenuItem=null;this.childMenuAnchor=null;requestAnimationFrame((()=>{this.editingItemId=t.id}))}async save(t){if(this.newWorkspace){this.newWorkspace.name=t.label;await this.kritzelEngineRef.createWorkspace(this.newWorkspace);this.workspaceChange.emit(this.newWorkspace)}else{const e=t.value;e.name=t.label;await this.kritzelEngineRef.updateWorkspace(e)}this.editingItemId=null;this.newWorkspace=null}cancel(){this.newWorkspace=null;this.editingItemId=null}async delete(t){this.openChildMenuItem=null;this.childMenuAnchor=null;await this.kritzelEngineRef.deleteWorkspace(t.value);if(t.value.id===this.activeWorkspace?.id){this.activeWorkspace=this.sortedWorkspaces.find((e=>e.id!==t.value.id))||null;this.workspaceChange.emit(this.activeWorkspace)}await this.splitButtonRef.focusMenu()}toggleChildMenu(t,e){this.openChildMenuItem=t;this.childMenuAnchor=e}closeChildMenu(){this.openChildMenuItem=null;this.childMenuAnchor=null}handleMenuOpen(){this.kritzelEngineRef.disable()}handleMenuClose(){this.cancel();this.closeChildMenu();this.kritzelEngineRef.enable()}render(){const t=this.sortedWorkspaces.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())).filter((t=>t!==null)).map((t=>({id:t.id,label:t.name,value:t,isEditing:this.editingItemId===t.id,isSelected:this.activeWorkspace?.id===t.id,isNewItem:this.newWorkspace?.id===t.id,isChildMenuOpen:this.openChildMenuItem?.id===t.id,childMenuAnchor:this.openChildMenuItem?.id===t.id?this.childMenuAnchor:null,children:[{id:`${t.id}-rename`,label:"Rename",value:"rename",action:(t,e)=>this.edit(e)},{id:`${t.id}-delete`,label:"Delete",value:"delete",isDisabled:this.sortedWorkspaces.length<=1,action:(t,e)=>this.delete(e)}]})));return e(i,null,e("kritzel-split-button",{ref:t=>this.splitButtonRef=t,items:t,mainButtonDisabled:this.editingItemId!=null,onMainButtonClick:()=>this.add(),onItemSelect:t=>this.select(t.detail.item,t.detail.parent),onItemToggleChildMenu:t=>this.toggleChildMenu(t.detail.item,t.detail.childMenuAnchor),onItemSave:t=>this.save(t.detail),onItemCancel:()=>this.cancel(),onItemCloseChildMenu:()=>this.closeChildMenu(),onMenuOpen:()=>this.handleMenuOpen(),onMenuClose:()=>this.handleMenuClose()}))}};Pt.style=Bt;export{E as kritzel_color,R as kritzel_color_palette,F as kritzel_context_menu,B as kritzel_control_brush_config,L as kritzel_control_text_config,U as kritzel_controls,H as kritzel_cursor_trail,N as kritzel_dropdown,J as kritzel_editor,pt as kritzel_engine,gt as kritzel_font,yt as kritzel_font_family,mt as kritzel_font_size,zt as kritzel_icon,Mt as kritzel_menu,It as kritzel_menu_item,_t as kritzel_portal,At as kritzel_split_button,Et as kritzel_stroke_size,Wt as kritzel_tooltip,Dt as kritzel_utility_panel,Pt as kritzel_workspace_manager};
10
- //# sourceMappingURL=p-7d732b05.entry.js.map
9
+ */var tt=Q.exports;var et;function it(){if(et)return Q.exports;et=1;(function(t,e){(function(){var i;var n="4.17.21";var r=200;var o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`";var c="__lodash_hash_undefined__";var l=500;var u="__lodash_placeholder__";var h=1,f=2,d=4;var v=1,p=2;var b=1,g=2,k=4,y=8,w=16,m=32,x=64,z=128,C=256,M=512;var j=30,I="...";var S=800,_=16;var T=1,E=2,$=3;var O=1/0,R=9007199254740991,W=17976931348623157e292,F=0/0;var D=4294967295,B=D-1,P=D>>>1;var L=[["ary",z],["bind",b],["bindKey",g],["curry",y],["curryRight",w],["flip",M],["partial",m],["partialRight",x],["rearg",C]];var V="[object Arguments]",U="[object Array]",K="[object AsyncFunction]",H="[object Boolean]",Y="[object Date]",N="[object DOMException]",X="[object Error]",q="[object Function]",G="[object GeneratorFunction]",Z="[object Map]",J="[object Number]",Q="[object Null]",tt="[object Object]",et="[object Promise]",it="[object Proxy]",nt="[object RegExp]",rt="[object Set]",ot="[object String]",st="[object Symbol]",at="[object Undefined]",ct="[object WeakMap]",lt="[object WeakSet]";var ut="[object ArrayBuffer]",ht="[object DataView]",ft="[object Float32Array]",dt="[object Float64Array]",vt="[object Int8Array]",pt="[object Int16Array]",bt="[object Int32Array]",gt="[object Uint8Array]",kt="[object Uint8ClampedArray]",yt="[object Uint16Array]",wt="[object Uint32Array]";var mt=/\b__p \+= '';/g,xt=/\b(__p \+=) '' \+/g,zt=/(__e\(.*?\)|\b__t\)) \+\n'';/g;var Ct=/&(?:amp|lt|gt|quot|#39);/g,Mt=/[&<>"']/g,jt=RegExp(Ct.source),It=RegExp(Mt.source);var St=/<%-([\s\S]+?)%>/g,_t=/<%([\s\S]+?)%>/g,Tt=/<%=([\s\S]+?)%>/g;var At=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Et=/^\w*$/,$t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;var Ot=/[\\^$.*+?()[\]{}|]/g,Rt=RegExp(Ot.source);var Wt=/^\s+/;var Ft=/\s/;var Dt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bt=/\{\n\/\* \[wrapped with (.+)\] \*/,Pt=/,? & /;var Lt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;var Vt=/[()=,{}\[\]\/\s]/;var Ut=/\\(\\)?/g;var Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;var Ht=/\w*$/;var Yt=/^[-+]0x[0-9a-f]+$/i;var Nt=/^0b[01]+$/i;var Xt=/^\[object .+?Constructor\]$/;var qt=/^0o[0-7]+$/i;var Gt=/^(?:0|[1-9]\d*)$/;var Zt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;var Jt=/($^)/;var Qt=/['\n\r\u2028\u2029\\]/g;var te="\\ud800-\\udfff",ee="\\u0300-\\u036f",ie="\\ufe20-\\ufe2f",ne="\\u20d0-\\u20ff",re=ee+ie+ne,oe="\\u2700-\\u27bf",se="a-z\\xdf-\\xf6\\xf8-\\xff",ae="\\xac\\xb1\\xd7\\xf7",ce="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",le="\\u2000-\\u206f",ue=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",he="A-Z\\xc0-\\xd6\\xd8-\\xde",fe="\\ufe0e\\ufe0f",de=ae+ce+le+ue;var ve="['’]",pe="["+te+"]",be="["+de+"]",ge="["+re+"]",ke="\\d+",ye="["+oe+"]",we="["+se+"]",me="[^"+te+de+ke+oe+se+he+"]",xe="\\ud83c[\\udffb-\\udfff]",ze="(?:"+ge+"|"+xe+")",Ce="[^"+te+"]",Me="(?:\\ud83c[\\udde6-\\uddff]){2}",je="[\\ud800-\\udbff][\\udc00-\\udfff]",Ie="["+he+"]",Se="\\u200d";var _e="(?:"+we+"|"+me+")",Te="(?:"+Ie+"|"+me+")",Ae="(?:"+ve+"(?:d|ll|m|re|s|t|ve))?",Ee="(?:"+ve+"(?:D|LL|M|RE|S|T|VE))?",$e=ze+"?",Oe="["+fe+"]?",Re="(?:"+Se+"(?:"+[Ce,Me,je].join("|")+")"+Oe+$e+")*",We="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Fe="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",De=Oe+$e+Re,Be="(?:"+[ye,Me,je].join("|")+")"+De,Pe="(?:"+[Ce+ge+"?",ge,Me,je,pe].join("|")+")";var Le=RegExp(ve,"g");var Ve=RegExp(ge,"g");var Ue=RegExp(xe+"(?="+xe+")|"+Pe+De,"g");var Ke=RegExp([Ie+"?"+we+"+"+Ae+"(?="+[be,Ie,"$"].join("|")+")",Te+"+"+Ee+"(?="+[be,Ie+_e,"$"].join("|")+")",Ie+"?"+_e+"+"+Ae,Ie+"+"+Ee,Fe,We,ke,Be].join("|"),"g");var He=RegExp("["+Se+te+re+fe+"]");var Ye=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;var Ne=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"];var Xe=-1;var qe={};qe[ft]=qe[dt]=qe[vt]=qe[pt]=qe[bt]=qe[gt]=qe[kt]=qe[yt]=qe[wt]=true;qe[V]=qe[U]=qe[ut]=qe[H]=qe[ht]=qe[Y]=qe[X]=qe[q]=qe[Z]=qe[J]=qe[tt]=qe[nt]=qe[rt]=qe[ot]=qe[ct]=false;var Ge={};Ge[V]=Ge[U]=Ge[ut]=Ge[ht]=Ge[H]=Ge[Y]=Ge[ft]=Ge[dt]=Ge[vt]=Ge[pt]=Ge[bt]=Ge[Z]=Ge[J]=Ge[tt]=Ge[nt]=Ge[rt]=Ge[ot]=Ge[st]=Ge[gt]=Ge[kt]=Ge[yt]=Ge[wt]=true;Ge[X]=Ge[q]=Ge[ct]=false;var Ze={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"};var Je={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};var Qe={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"};var ti={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};var ei=parseFloat,ii=parseInt;var ni=typeof A=="object"&&A&&A.Object===Object&&A;var ri=typeof self=="object"&&self&&self.Object===Object&&self;var oi=ni||ri||Function("return this")();var si=e&&!e.nodeType&&e;var ai=si&&"object"=="object"&&t&&!t.nodeType&&t;var ci=ai&&ai.exports===si;var li=ci&&ni.process;var ui=function(){try{var t=ai&&ai.require&&ai.require("util").types;if(t){return t}return li&&li.binding&&li.binding("util")}catch(t){}}();var hi=ui&&ui.isArrayBuffer,fi=ui&&ui.isDate,di=ui&&ui.isMap,vi=ui&&ui.isRegExp,pi=ui&&ui.isSet,bi=ui&&ui.isTypedArray;function gi(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}function ki(t,e,i,n){var r=-1,o=t==null?0:t.length;while(++r<o){var s=t[r];e(n,s,i(s),t)}return n}function yi(t,e){var i=-1,n=t==null?0:t.length;while(++i<n){if(e(t[i],i,t)===false){break}}return t}function wi(t,e){var i=t==null?0:t.length;while(i--){if(e(t[i],i,t)===false){break}}return t}function mi(t,e){var i=-1,n=t==null?0:t.length;while(++i<n){if(!e(t[i],i,t)){return false}}return true}function xi(t,e){var i=-1,n=t==null?0:t.length,r=0,o=[];while(++i<n){var s=t[i];if(e(s,i,t)){o[r++]=s}}return o}function zi(t,e){var i=t==null?0:t.length;return!!i&&Ri(t,e,0)>-1}function Ci(t,e,i){var n=-1,r=t==null?0:t.length;while(++n<r){if(i(e,t[n])){return true}}return false}function Mi(t,e){var i=-1,n=t==null?0:t.length,r=Array(n);while(++i<n){r[i]=e(t[i],i,t)}return r}function ji(t,e){var i=-1,n=e.length,r=t.length;while(++i<n){t[r+i]=e[i]}return t}function Ii(t,e,i,n){var r=-1,o=t==null?0:t.length;if(n&&o){i=t[++r]}while(++r<o){i=e(i,t[r],r,t)}return i}function Si(t,e,i,n){var r=t==null?0:t.length;if(n&&r){i=t[--r]}while(r--){i=e(i,t[r],r,t)}return i}function _i(t,e){var i=-1,n=t==null?0:t.length;while(++i<n){if(e(t[i],i,t)){return true}}return false}var Ti=Bi("length");function Ai(t){return t.split("")}function Ei(t){return t.match(Lt)||[]}function $i(t,e,i){var n;i(t,(function(t,i,r){if(e(t,i,r)){n=i;return false}}));return n}function Oi(t,e,i,n){var r=t.length,o=i+(n?1:-1);while(n?o--:++o<r){if(e(t[o],o,t)){return o}}return-1}function Ri(t,e,i){return e===e?fn(t,e,i):Oi(t,Fi,i)}function Wi(t,e,i,n){var r=i-1,o=t.length;while(++r<o){if(n(t[r],e)){return r}}return-1}function Fi(t){return t!==t}function Di(t,e){var i=t==null?0:t.length;return i?Ui(t,e)/i:F}function Bi(t){return function(e){return e==null?i:e[t]}}function Pi(t){return function(e){return t==null?i:t[e]}}function Li(t,e,i,n,r){r(t,(function(t,r,o){i=n?(n=false,t):e(i,t,r,o)}));return i}function Vi(t,e){var i=t.length;t.sort(e);while(i--){t[i]=t[i].value}return t}function Ui(t,e){var n,r=-1,o=t.length;while(++r<o){var s=e(t[r]);if(s!==i){n=n===i?s:n+s}}return n}function Ki(t,e){var i=-1,n=Array(t);while(++i<t){n[i]=e(i)}return n}function Hi(t,e){return Mi(e,(function(e){return[e,t[e]]}))}function Yi(t){return t?t.slice(0,bn(t)+1).replace(Wt,""):t}function Ni(t){return function(e){return t(e)}}function Xi(t,e){return Mi(e,(function(e){return t[e]}))}function qi(t,e){return t.has(e)}function Gi(t,e){var i=-1,n=t.length;while(++i<n&&Ri(e,t[i],0)>-1){}return i}function Zi(t,e){var i=t.length;while(i--&&Ri(e,t[i],0)>-1){}return i}function Ji(t,e){var i=t.length,n=0;while(i--){if(t[i]===e){++n}}return n}var Qi=Pi(Ze);var tn=Pi(Je);function en(t){return"\\"+ti[t]}function nn(t,e){return t==null?i:t[e]}function rn(t){return He.test(t)}function on(t){return Ye.test(t)}function sn(t){var e,i=[];while(!(e=t.next()).done){i.push(e.value)}return i}function an(t){var e=-1,i=Array(t.size);t.forEach((function(t,n){i[++e]=[n,t]}));return i}function cn(t,e){return function(i){return t(e(i))}}function ln(t,e){var i=-1,n=t.length,r=0,o=[];while(++i<n){var s=t[i];if(s===e||s===u){t[i]=u;o[r++]=i}}return o}function un(t){var e=-1,i=Array(t.size);t.forEach((function(t){i[++e]=t}));return i}function hn(t){var e=-1,i=Array(t.size);t.forEach((function(t){i[++e]=[t,t]}));return i}function fn(t,e,i){var n=i-1,r=t.length;while(++n<r){if(t[n]===e){return n}}return-1}function dn(t,e,i){var n=i+1;while(n--){if(t[n]===e){return n}}return n}function vn(t){return rn(t)?kn(t):Ti(t)}function pn(t){return rn(t)?yn(t):Ai(t)}function bn(t){var e=t.length;while(e--&&Ft.test(t.charAt(e))){}return e}var gn=Pi(Qe);function kn(t){var e=Ue.lastIndex=0;while(Ue.test(t)){++e}return e}function yn(t){return t.match(Ue)||[]}function wn(t){return t.match(Ke)||[]}var mn=function t(e){e=e==null?oi:xn.defaults(oi.Object(),e,xn.pick(oi,Ne));var A=e.Array,Ft=e.Date,Lt=e.Error,te=e.Function,ee=e.Math,ie=e.Object,ne=e.RegExp,re=e.String,oe=e.TypeError;var se=A.prototype,ae=te.prototype,ce=ie.prototype;var le=e["__core-js_shared__"];var ue=ae.toString;var he=ce.hasOwnProperty;var fe=0;var de=function(){var t=/[^.]+$/.exec(le&&le.keys&&le.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();var ve=ce.toString;var pe=ue.call(ie);var be=oi._;var ge=ne("^"+ue.call(he).replace(Ot,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var ke=ci?e.Buffer:i,ye=e.Symbol,we=e.Uint8Array,me=ke?ke.allocUnsafe:i,xe=cn(ie.getPrototypeOf,ie),ze=ie.create,Ce=ce.propertyIsEnumerable,Me=se.splice,je=ye?ye.isConcatSpreadable:i,Ie=ye?ye.iterator:i,Se=ye?ye.toStringTag:i;var _e=function(){try{var t=Ns(ie,"defineProperty");t({},"",{});return t}catch(t){}}();var Te=e.clearTimeout!==oi.clearTimeout&&e.clearTimeout,Ae=Ft&&Ft.now!==oi.Date.now&&Ft.now,Ee=e.setTimeout!==oi.setTimeout&&e.setTimeout;var $e=ee.ceil,Oe=ee.floor,Re=ie.getOwnPropertySymbols,We=ke?ke.isBuffer:i,Fe=e.isFinite,De=se.join,Be=cn(ie.keys,ie),Pe=ee.max,Ue=ee.min,Ke=Ft.now,He=e.parseInt,Ye=ee.random,Ze=se.reverse;var Je=Ns(e,"DataView"),Qe=Ns(e,"Map"),ti=Ns(e,"Promise"),ni=Ns(e,"Set"),ri=Ns(e,"WeakMap"),si=Ns(ie,"create");var ai=ri&&new ri;var li={};var ui=Ea(Je),Ti=Ea(Qe),Ai=Ea(ti),Pi=Ea(ni),fn=Ea(ri);var kn=ye?ye.prototype:i,yn=kn?kn.valueOf:i,mn=kn?kn.toString:i;function zn(t){if(Mu(t)&&!cu(t)&&!(t instanceof In)){if(t instanceof jn){return t}if(he.call(t,"__wrapped__")){return Oa(t)}}return new jn(t)}var Cn=function(){function t(){}return function(e){if(!Cu(e)){return{}}if(ze){return ze(e)}t.prototype=e;var n=new t;t.prototype=i;return n}}();function Mn(){}function jn(t,e){this.__wrapped__=t;this.__actions__=[];this.__chain__=!!e;this.__index__=0;this.__values__=i}zn.templateSettings={escape:St,evaluate:_t,interpolate:Tt,variable:"",imports:{_:zn}};zn.prototype=Mn.prototype;zn.prototype.constructor=zn;jn.prototype=Cn(Mn.prototype);jn.prototype.constructor=jn;function In(t){this.__wrapped__=t;this.__actions__=[];this.__dir__=1;this.__filtered__=false;this.__iteratees__=[];this.__takeCount__=D;this.__views__=[]}function Sn(){var t=new In(this.__wrapped__);t.__actions__=rs(this.__actions__);t.__dir__=this.__dir__;t.__filtered__=this.__filtered__;t.__iteratees__=rs(this.__iteratees__);t.__takeCount__=this.__takeCount__;t.__views__=rs(this.__views__);return t}function _n(){if(this.__filtered__){var t=new In(this);t.__dir__=-1;t.__filtered__=true}else{t=this.clone();t.__dir__*=-1}return t}function Tn(){var t=this.__wrapped__.value(),e=this.__dir__,i=cu(t),n=e<0,r=i?t.length:0,o=Js(0,r,this.__views__),s=o.start,a=o.end,c=a-s,l=n?a:s-1,u=this.__iteratees__,h=u.length,f=0,d=Ue(c,this.__takeCount__);if(!i||!n&&r==c&&d==c){return Bo(t,this.__actions__)}var v=[];t:while(c--&&f<d){l+=e;var p=-1,b=t[l];while(++p<h){var g=u[p],k=g.iteratee,y=g.type,w=k(b);if(y==E){b=w}else if(!w){if(y==T){continue t}else{break t}}}v[f++]=b}return v}In.prototype=Cn(Mn.prototype);In.prototype.constructor=In;function An(t){var e=-1,i=t==null?0:t.length;this.clear();while(++e<i){var n=t[e];this.set(n[0],n[1])}}function En(){this.__data__=si?si(null):{};this.size=0}function $n(t){var e=this.has(t)&&delete this.__data__[t];this.size-=e?1:0;return e}function On(t){var e=this.__data__;if(si){var n=e[t];return n===c?i:n}return he.call(e,t)?e[t]:i}function Rn(t){var e=this.__data__;return si?e[t]!==i:he.call(e,t)}function Wn(t,e){var n=this.__data__;this.size+=this.has(t)?0:1;n[t]=si&&e===i?c:e;return this}An.prototype.clear=En;An.prototype["delete"]=$n;An.prototype.get=On;An.prototype.has=Rn;An.prototype.set=Wn;function Fn(t){var e=-1,i=t==null?0:t.length;this.clear();while(++e<i){var n=t[e];this.set(n[0],n[1])}}function Dn(){this.__data__=[];this.size=0}function Bn(t){var e=this.__data__,i=ur(e,t);if(i<0){return false}var n=e.length-1;if(i==n){e.pop()}else{Me.call(e,i,1)}--this.size;return true}function Pn(t){var e=this.__data__,n=ur(e,t);return n<0?i:e[n][1]}function Ln(t){return ur(this.__data__,t)>-1}function Vn(t,e){var i=this.__data__,n=ur(i,t);if(n<0){++this.size;i.push([t,e])}else{i[n][1]=e}return this}Fn.prototype.clear=Dn;Fn.prototype["delete"]=Bn;Fn.prototype.get=Pn;Fn.prototype.has=Ln;Fn.prototype.set=Vn;function Un(t){var e=-1,i=t==null?0:t.length;this.clear();while(++e<i){var n=t[e];this.set(n[0],n[1])}}function Kn(){this.size=0;this.__data__={hash:new An,map:new(Qe||Fn),string:new An}}function Hn(t){var e=Hs(this,t)["delete"](t);this.size-=e?1:0;return e}function Yn(t){return Hs(this,t).get(t)}function Nn(t){return Hs(this,t).has(t)}function Xn(t,e){var i=Hs(this,t),n=i.size;i.set(t,e);this.size+=i.size==n?0:1;return this}Un.prototype.clear=Kn;Un.prototype["delete"]=Hn;Un.prototype.get=Yn;Un.prototype.has=Nn;Un.prototype.set=Xn;function qn(t){var e=-1,i=t==null?0:t.length;this.__data__=new Un;while(++e<i){this.add(t[e])}}function Gn(t){this.__data__.set(t,c);return this}function Zn(t){return this.__data__.has(t)}qn.prototype.add=qn.prototype.push=Gn;qn.prototype.has=Zn;function Jn(t){var e=this.__data__=new Fn(t);this.size=e.size}function Qn(){this.__data__=new Fn;this.size=0}function tr(t){var e=this.__data__,i=e["delete"](t);this.size=e.size;return i}function er(t){return this.__data__.get(t)}function ir(t){return this.__data__.has(t)}function nr(t,e){var i=this.__data__;if(i instanceof Fn){var n=i.__data__;if(!Qe||n.length<r-1){n.push([t,e]);this.size=++i.size;return this}i=this.__data__=new Un(n)}i.set(t,e);this.size=i.size;return this}Jn.prototype.clear=Qn;Jn.prototype["delete"]=tr;Jn.prototype.get=er;Jn.prototype.has=ir;Jn.prototype.set=nr;function rr(t,e){var i=cu(t),n=!i&&au(t),r=!i&&!n&&du(t),o=!i&&!n&&!r&&Pu(t),s=i||n||r||o,a=s?Ki(t.length,re):[],c=a.length;for(var l in t){if((e||he.call(t,l))&&!(s&&(l=="length"||r&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||sa(l,c)))){a.push(l)}}return a}function or(t){var e=t.length;return e?t[ko(0,e-1)]:i}function sr(t,e){return _a(rs(t),br(e,0,t.length))}function ar(t){return _a(rs(t))}function cr(t,e,n){if(n!==i&&!ru(t[e],n)||n===i&&!(e in t)){vr(t,e,n)}}function lr(t,e,n){var r=t[e];if(!(he.call(t,e)&&ru(r,n))||n===i&&!(e in t)){vr(t,e,n)}}function ur(t,e){var i=t.length;while(i--){if(ru(t[i][0],e)){return i}}return-1}function hr(t,e,i,n){xr(t,(function(t,r,o){e(n,t,i(t),o)}));return n}function fr(t,e){return t&&os(e,xh(e),t)}function dr(t,e){return t&&os(e,zh(e),t)}function vr(t,e,i){if(e=="__proto__"&&_e){_e(t,e,{configurable:true,enumerable:true,value:i,writable:true})}else{t[e]=i}}function pr(t,e){var n=-1,r=e.length,o=A(r),s=t==null;while(++n<r){o[n]=s?i:bh(t,e[n])}return o}function br(t,e,n){if(t===t){if(n!==i){t=t<=n?t:n}if(e!==i){t=t>=e?t:e}}return t}function gr(t,e,n,r,o,s){var a,c=e&h,l=e&f,u=e&d;if(n){a=o?n(t,r,o,s):n(t)}if(a!==i){return a}if(!Cu(t)){return t}var v=cu(t);if(v){a=ea(t);if(!c){return rs(t,a)}}else{var p=Zs(t),b=p==q||p==G;if(du(t)){return Xo(t,c)}if(p==tt||p==V||b&&!o){a=l||b?{}:ia(t);if(!c){return l?as(t,dr(a,t)):ss(t,fr(a,t))}}else{if(!Ge[p]){return o?t:{}}a=na(t,p,c)}}s||(s=new Jn);var g=s.get(t);if(g){return g}s.set(t,a);if(Fu(t)){t.forEach((function(i){a.add(gr(i,e,n,i,t,s))}))}else if(ju(t)){t.forEach((function(i,r){a.set(r,gr(i,e,n,r,t,s))}))}var k=u?l?Ps:Bs:l?zh:xh;var y=v?i:k(t);yi(y||t,(function(i,r){if(y){r=i;i=t[r]}lr(a,r,gr(i,e,n,r,t,s))}));return a}function kr(t){var e=xh(t);return function(i){return yr(i,t,e)}}function yr(t,e,n){var r=n.length;if(t==null){return!r}t=ie(t);while(r--){var o=n[r],s=e[o],a=t[o];if(a===i&&!(o in t)||!s(a)){return false}}return true}function wr(t,e,n){if(typeof t!="function"){throw new oe(s)}return Ma((function(){t.apply(i,n)}),e)}function mr(t,e,i,n){var o=-1,s=zi,a=true,c=t.length,l=[],u=e.length;if(!c){return l}if(i){e=Mi(e,Ni(i))}if(n){s=Ci;a=false}else if(e.length>=r){s=qi;a=false;e=new qn(e)}t:while(++o<c){var h=t[o],f=i==null?h:i(h);h=n||h!==0?h:0;if(a&&f===f){var d=u;while(d--){if(e[d]===f){continue t}}l.push(h)}else if(!s(e,f,n)){l.push(h)}}return l}var xr=us(Ar);var zr=us(Er,true);function Cr(t,e){var i=true;xr(t,(function(t,n,r){i=!!e(t,n,r);return i}));return i}function Mr(t,e,n){var r=-1,o=t.length;while(++r<o){var s=t[r],a=e(s);if(a!=null&&(c===i?a===a&&!Bu(a):n(a,c))){var c=a,l=s}}return l}function jr(t,e,n,r){var o=t.length;n=Xu(n);if(n<0){n=-n>o?0:o+n}r=r===i||r>o?o:Xu(r);if(r<0){r+=o}r=n>r?0:qu(r);while(n<r){t[n++]=e}return t}function Ir(t,e){var i=[];xr(t,(function(t,n,r){if(e(t,n,r)){i.push(t)}}));return i}function Sr(t,e,i,n,r){var o=-1,s=t.length;i||(i=oa);r||(r=[]);while(++o<s){var a=t[o];if(e>0&&i(a)){if(e>1){Sr(a,e-1,i,n,r)}else{ji(r,a)}}else if(!n){r[r.length]=a}}return r}var _r=hs();var Tr=hs(true);function Ar(t,e){return t&&_r(t,e,xh)}function Er(t,e){return t&&Tr(t,e,xh)}function $r(t,e){return xi(e,(function(e){return mu(t[e])}))}function Or(t,e){e=Ko(e,t);var n=0,r=e.length;while(t!=null&&n<r){t=t[Aa(e[n++])]}return n&&n==r?t:i}function Rr(t,e,i){var n=e(t);return cu(t)?n:ji(n,i(t))}function Wr(t){if(t==null){return t===i?at:Q}return Se&&Se in ie(t)?Xs(t):ya(t)}function Fr(t,e){return t>e}function Dr(t,e){return t!=null&&he.call(t,e)}function Br(t,e){return t!=null&&e in ie(t)}function Pr(t,e,i){return t>=Ue(e,i)&&t<Pe(e,i)}function Lr(t,e,n){var r=n?Ci:zi,o=t[0].length,s=t.length,a=s,c=A(s),l=Infinity,u=[];while(a--){var h=t[a];if(a&&e){h=Mi(h,Ni(e))}l=Ue(h.length,l);c[a]=!n&&(e||o>=120&&h.length>=120)?new qn(a&&h):i}h=t[0];var f=-1,d=c[0];t:while(++f<o&&u.length<l){var v=h[f],p=e?e(v):v;v=n||v!==0?v:0;if(!(d?qi(d,p):r(u,p,n))){a=s;while(--a){var b=c[a];if(!(b?qi(b,p):r(t[a],p,n))){continue t}}if(d){d.push(p)}u.push(v)}}return u}function Vr(t,e,i,n){Ar(t,(function(t,r,o){e(n,i(t),r,o)}));return n}function Ur(t,e,n){e=Ko(e,t);t=ma(t,e);var r=t==null?t:t[Aa(oc(e))];return r==null?i:gi(r,t,n)}function Kr(t){return Mu(t)&&Wr(t)==V}function Hr(t){return Mu(t)&&Wr(t)==ut}function Yr(t){return Mu(t)&&Wr(t)==Y}function Nr(t,e,i,n,r){if(t===e){return true}if(t==null||e==null||!Mu(t)&&!Mu(e)){return t!==t&&e!==e}return Xr(t,e,i,n,Nr,r)}function Xr(t,e,i,n,r,o){var s=cu(t),a=cu(e),c=s?U:Zs(t),l=a?U:Zs(e);c=c==V?tt:c;l=l==V?tt:l;var u=c==tt,h=l==tt,f=c==l;if(f&&du(t)){if(!du(e)){return false}s=true;u=false}if(f&&!u){o||(o=new Jn);return s||Pu(t)?Rs(t,e,i,n,r,o):Ws(t,e,c,i,n,r,o)}if(!(i&v)){var d=u&&he.call(t,"__wrapped__"),p=h&&he.call(e,"__wrapped__");if(d||p){var b=d?t.value():t,g=p?e.value():e;o||(o=new Jn);return r(b,g,i,n,o)}}if(!f){return false}o||(o=new Jn);return Fs(t,e,i,n,r,o)}function qr(t){return Mu(t)&&Zs(t)==Z}function Gr(t,e,n,r){var o=n.length,s=o,a=!r;if(t==null){return!s}t=ie(t);while(o--){var c=n[o];if(a&&c[2]?c[1]!==t[c[0]]:!(c[0]in t)){return false}}while(++o<s){c=n[o];var l=c[0],u=t[l],h=c[1];if(a&&c[2]){if(u===i&&!(l in t)){return false}}else{var f=new Jn;if(r){var d=r(u,h,l,t,e,f)}if(!(d===i?Nr(h,u,v|p,r,f):d)){return false}}}return true}function Zr(t){if(!Cu(t)||ha(t)){return false}var e=mu(t)?ge:Xt;return e.test(Ea(t))}function Jr(t){return Mu(t)&&Wr(t)==nt}function Qr(t){return Mu(t)&&Zs(t)==rt}function to(t){return Mu(t)&&zu(t.length)&&!!qe[Wr(t)]}function eo(t){if(typeof t=="function"){return t}if(t==null){return Af}if(typeof t=="object"){return cu(t)?ao(t[0],t[1]):so(t)}return Kf(t)}function io(t){if(!da(t)){return Be(t)}var e=[];for(var i in ie(t)){if(he.call(t,i)&&i!="constructor"){e.push(i)}}return e}function no(t){if(!Cu(t)){return ka(t)}var e=da(t),i=[];for(var n in t){if(!(n=="constructor"&&(e||!he.call(t,n)))){i.push(n)}}return i}function ro(t,e){return t<e}function oo(t,e){var i=-1,n=uu(t)?A(t.length):[];xr(t,(function(t,r,o){n[++i]=e(t,r,o)}));return n}function so(t){var e=Ys(t);if(e.length==1&&e[0][2]){return pa(e[0][0],e[0][1])}return function(i){return i===t||Gr(i,t,e)}}function ao(t,e){if(ca(t)&&va(e)){return pa(Aa(t),e)}return function(n){var r=bh(n,t);return r===i&&r===e?kh(n,t):Nr(e,r,v|p)}}function co(t,e,n,r,o){if(t===e){return}_r(e,(function(s,a){o||(o=new Jn);if(Cu(s)){lo(t,e,a,n,co,r,o)}else{var c=r?r(za(t,a),s,a+"",t,e,o):i;if(c===i){c=s}cr(t,a,c)}}),zh)}function lo(t,e,n,r,o,s,a){var c=za(t,n),l=za(e,n),u=a.get(l);if(u){cr(t,n,u);return}var h=s?s(c,l,n+"",t,e,a):i;var f=h===i;if(f){var d=cu(l),v=!d&&du(l),p=!d&&!v&&Pu(l);h=l;if(d||v||p){if(cu(c)){h=c}else if(hu(c)){h=rs(c)}else if(v){f=false;h=Xo(l,true)}else if(p){f=false;h=Qo(l,true)}else{h=[]}}else if(Ou(l)||au(l)){h=c;if(au(c)){h=Zu(c)}else if(!Cu(c)||mu(c)){h=ia(l)}}else{f=false}}if(f){a.set(l,h);o(h,l,r,s,a);a["delete"](l)}cr(t,n,h)}function uo(t,e){var n=t.length;if(!n){return}e+=e<0?n:0;return sa(e,n)?t[e]:i}function ho(t,e,i){if(e.length){e=Mi(e,(function(t){if(cu(t)){return function(e){return Or(e,t.length===1?t[0]:t)}}return t}))}else{e=[Af]}var n=-1;e=Mi(e,Ni(Ks()));var r=oo(t,(function(t,i,r){var o=Mi(e,(function(e){return e(t)}));return{criteria:o,index:++n,value:t}}));return Vi(r,(function(t,e){return es(t,e,i)}))}function fo(t,e){return vo(t,e,(function(e,i){return kh(t,i)}))}function vo(t,e,i){var n=-1,r=e.length,o={};while(++n<r){var s=e[n],a=Or(t,s);if(i(a,s)){Co(o,Ko(s,t),a)}}return o}function po(t){return function(e){return Or(e,t)}}function bo(t,e,i,n){var r=n?Wi:Ri,o=-1,s=e.length,a=t;if(t===e){e=rs(e)}if(i){a=Mi(t,Ni(i))}while(++o<s){var c=0,l=e[o],u=i?i(l):l;while((c=r(a,u,c,n))>-1){if(a!==t){Me.call(a,c,1)}Me.call(t,c,1)}}return t}function go(t,e){var i=t?e.length:0,n=i-1;while(i--){var r=e[i];if(i==n||r!==o){var o=r;if(sa(r)){Me.call(t,r,1)}else{Wo(t,r)}}}return t}function ko(t,e){return t+Oe(Ye()*(e-t+1))}function yo(t,e,i,n){var r=-1,o=Pe($e((e-t)/(i||1)),0),s=A(o);while(o--){s[n?o:++r]=t;t+=i}return s}function wo(t,e){var i="";if(!t||e<1||e>R){return i}do{if(e%2){i+=t}e=Oe(e/2);if(e){t+=t}}while(e);return i}function mo(t,e){return ja(wa(t,e,Af),t+"")}function xo(t){return or(Lh(t))}function zo(t,e){var i=Lh(t);return _a(i,br(e,0,i.length))}function Co(t,e,n,r){if(!Cu(t)){return t}e=Ko(e,t);var o=-1,s=e.length,a=s-1,c=t;while(c!=null&&++o<s){var l=Aa(e[o]),u=n;if(l==="__proto__"||l==="constructor"||l==="prototype"){return t}if(o!=a){var h=c[l];u=r?r(h,l,c):i;if(u===i){u=Cu(h)?h:sa(e[o+1])?[]:{}}}lr(c,l,u);c=c[l]}return t}var Mo=!ai?Af:function(t,e){ai.set(t,e);return t};var jo=!_e?Af:function(t,e){return _e(t,"toString",{configurable:true,enumerable:false,value:If(e),writable:true})};function Io(t){return _a(Lh(t))}function So(t,e,i){var n=-1,r=t.length;if(e<0){e=-e>r?0:r+e}i=i>r?r:i;if(i<0){i+=r}r=e>i?0:i-e>>>0;e>>>=0;var o=A(r);while(++n<r){o[n]=t[n+e]}return o}function _o(t,e){var i;xr(t,(function(t,n,r){i=e(t,n,r);return!i}));return!!i}function To(t,e,i){var n=0,r=t==null?n:t.length;if(typeof e=="number"&&e===e&&r<=P){while(n<r){var o=n+r>>>1,s=t[o];if(s!==null&&!Bu(s)&&(i?s<=e:s<e)){n=o+1}else{r=o}}return r}return Ao(t,e,Af,i)}function Ao(t,e,n,r){var o=0,s=t==null?0:t.length;if(s===0){return 0}e=n(e);var a=e!==e,c=e===null,l=Bu(e),u=e===i;while(o<s){var h=Oe((o+s)/2),f=n(t[h]),d=f!==i,v=f===null,p=f===f,b=Bu(f);if(a){var g=r||p}else if(u){g=p&&(r||d)}else if(c){g=p&&d&&(r||!v)}else if(l){g=p&&d&&!v&&(r||!b)}else if(v||b){g=false}else{g=r?f<=e:f<e}if(g){o=h+1}else{s=h}}return Ue(s,B)}function Eo(t,e){var i=-1,n=t.length,r=0,o=[];while(++i<n){var s=t[i],a=e?e(s):s;if(!i||!ru(a,c)){var c=a;o[r++]=s===0?0:s}}return o}function $o(t){if(typeof t=="number"){return t}if(Bu(t)){return F}return+t}function Oo(t){if(typeof t=="string"){return t}if(cu(t)){return Mi(t,Oo)+""}if(Bu(t)){return mn?mn.call(t):""}var e=t+"";return e=="0"&&1/t==-Infinity?"-0":e}function Ro(t,e,i){var n=-1,o=zi,s=t.length,a=true,c=[],l=c;if(i){a=false;o=Ci}else if(s>=r){var u=e?null:_s(t);if(u){return un(u)}a=false;o=qi;l=new qn}else{l=e?[]:c}t:while(++n<s){var h=t[n],f=e?e(h):h;h=i||h!==0?h:0;if(a&&f===f){var d=l.length;while(d--){if(l[d]===f){continue t}}if(e){l.push(f)}c.push(h)}else if(!o(l,f,i)){if(l!==c){l.push(f)}c.push(h)}}return c}function Wo(t,e){e=Ko(e,t);t=ma(t,e);return t==null||delete t[Aa(oc(e))]}function Fo(t,e,i,n){return Co(t,e,i(Or(t,e)),n)}function Do(t,e,i,n){var r=t.length,o=n?r:-1;while((n?o--:++o<r)&&e(t[o],o,t)){}return i?So(t,n?0:o,n?o+1:r):So(t,n?o+1:0,n?r:o)}function Bo(t,e){var i=t;if(i instanceof In){i=i.value()}return Ii(e,(function(t,e){return e.func.apply(e.thisArg,ji([t],e.args))}),i)}function Po(t,e,i){var n=t.length;if(n<2){return n?Ro(t[0]):[]}var r=-1,o=A(n);while(++r<n){var s=t[r],a=-1;while(++a<n){if(a!=r){o[r]=mr(o[r]||s,t[a],e,i)}}}return Ro(Sr(o,1),e,i)}function Lo(t,e,n){var r=-1,o=t.length,s=e.length,a={};while(++r<o){var c=r<s?e[r]:i;n(a,t[r],c)}return a}function Vo(t){return hu(t)?t:[]}function Uo(t){return typeof t=="function"?t:Af}function Ko(t,e){if(cu(t)){return t}return ca(t,e)?[t]:Ta(Qu(t))}var Ho=mo;function Yo(t,e,n){var r=t.length;n=n===i?r:n;return!e&&n>=r?t:So(t,e,n)}var No=Te||function(t){return oi.clearTimeout(t)};function Xo(t,e){if(e){return t.slice()}var i=t.length,n=me?me(i):new t.constructor(i);t.copy(n);return n}function qo(t){var e=new t.constructor(t.byteLength);new we(e).set(new we(t));return e}function Go(t,e){var i=e?qo(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}function Zo(t){var e=new t.constructor(t.source,Ht.exec(t));e.lastIndex=t.lastIndex;return e}function Jo(t){return yn?ie(yn.call(t)):{}}function Qo(t,e){var i=e?qo(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}function ts(t,e){if(t!==e){var n=t!==i,r=t===null,o=t===t,s=Bu(t);var a=e!==i,c=e===null,l=e===e,u=Bu(e);if(!c&&!u&&!s&&t>e||s&&a&&l&&!c&&!u||r&&a&&l||!n&&l||!o){return 1}if(!r&&!s&&!u&&t<e||u&&n&&o&&!r&&!s||c&&n&&o||!a&&o||!l){return-1}}return 0}function es(t,e,i){var n=-1,r=t.criteria,o=e.criteria,s=r.length,a=i.length;while(++n<s){var c=ts(r[n],o[n]);if(c){if(n>=a){return c}var l=i[n];return c*(l=="desc"?-1:1)}}return t.index-e.index}function is(t,e,i,n){var r=-1,o=t.length,s=i.length,a=-1,c=e.length,l=Pe(o-s,0),u=A(c+l),h=!n;while(++a<c){u[a]=e[a]}while(++r<s){if(h||r<o){u[i[r]]=t[r]}}while(l--){u[a++]=t[r++]}return u}function ns(t,e,i,n){var r=-1,o=t.length,s=-1,a=i.length,c=-1,l=e.length,u=Pe(o-a,0),h=A(u+l),f=!n;while(++r<u){h[r]=t[r]}var d=r;while(++c<l){h[d+c]=e[c]}while(++s<a){if(f||r<o){h[d+i[s]]=t[r++]}}return h}function rs(t,e){var i=-1,n=t.length;e||(e=A(n));while(++i<n){e[i]=t[i]}return e}function os(t,e,n,r){var o=!n;n||(n={});var s=-1,a=e.length;while(++s<a){var c=e[s];var l=r?r(n[c],t[c],c,n,t):i;if(l===i){l=t[c]}if(o){vr(n,c,l)}else{lr(n,c,l)}}return n}function ss(t,e){return os(t,qs(t),e)}function as(t,e){return os(t,Gs(t),e)}function cs(t,e){return function(i,n){var r=cu(i)?ki:hr,o=e?e():{};return r(i,t,Ks(n,2),o)}}function ls(t){return mo((function(e,n){var r=-1,o=n.length,s=o>1?n[o-1]:i,a=o>2?n[2]:i;s=t.length>3&&typeof s=="function"?(o--,s):i;if(a&&aa(n[0],n[1],a)){s=o<3?i:s;o=1}e=ie(e);while(++r<o){var c=n[r];if(c){t(e,c,r,s)}}return e}))}function us(t,e){return function(i,n){if(i==null){return i}if(!uu(i)){return t(i,n)}var r=i.length,o=e?r:-1,s=ie(i);while(e?o--:++o<r){if(n(s[o],o,s)===false){break}}return i}}function hs(t){return function(e,i,n){var r=-1,o=ie(e),s=n(e),a=s.length;while(a--){var c=s[t?a:++r];if(i(o[c],c,o)===false){break}}return e}}function fs(t,e,i){var n=e&b,r=ps(t);function o(){var e=this&&this!==oi&&this instanceof o?r:t;return e.apply(n?i:this,arguments)}return o}function ds(t){return function(e){e=Qu(e);var n=rn(e)?pn(e):i;var r=n?n[0]:e.charAt(0);var o=n?Yo(n,1).join(""):e.slice(1);return r[t]()+o}}function vs(t){return function(e){return Ii(xf(Xh(e).replace(Le,"")),t,"")}}function ps(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var i=Cn(t.prototype),n=t.apply(i,e);return Cu(n)?n:i}}function bs(t,e,n){var r=ps(t);function o(){var s=arguments.length,a=A(s),c=s,l=Us(o);while(c--){a[c]=arguments[c]}var u=s<3&&a[0]!==l&&a[s-1]!==l?[]:ln(a,l);s-=u.length;if(s<n){return Is(t,e,ys,o.placeholder,i,a,u,i,i,n-s)}var h=this&&this!==oi&&this instanceof o?r:t;return gi(h,this,a)}return o}function gs(t){return function(e,n,r){var o=ie(e);if(!uu(e)){var s=Ks(n,3);e=xh(e);n=function(t){return s(o[t],t,o)}}var a=t(e,n,r);return a>-1?o[s?e[a]:a]:i}}function ks(t){return Ds((function(e){var n=e.length,r=n,o=jn.prototype.thru;if(t){e.reverse()}while(r--){var a=e[r];if(typeof a!="function"){throw new oe(s)}if(o&&!c&&Vs(a)=="wrapper"){var c=new jn([],true)}}r=c?r:n;while(++r<n){a=e[r];var l=Vs(a),u=l=="wrapper"?Ls(a):i;if(u&&ua(u[0])&&u[1]==(z|y|m|C)&&!u[4].length&&u[9]==1){c=c[Vs(u[0])].apply(c,u[3])}else{c=a.length==1&&ua(a)?c[l]():c.thru(a)}}return function(){var t=arguments,i=t[0];if(c&&t.length==1&&cu(i)){return c.plant(i).value()}var r=0,o=n?e[r].apply(this,t):i;while(++r<n){o=e[r].call(this,o)}return o}}))}function ys(t,e,n,r,o,s,a,c,l,u){var h=e&z,f=e&b,d=e&g,v=e&(y|w),p=e&M,k=d?i:ps(t);function m(){var i=arguments.length,b=A(i),g=i;while(g--){b[g]=arguments[g]}if(v){var y=Us(m),w=Ji(b,y)}if(r){b=is(b,r,o,v)}if(s){b=ns(b,s,a,v)}i-=w;if(v&&i<u){var x=ln(b,y);return Is(t,e,ys,m.placeholder,n,b,x,c,l,u-i)}var z=f?n:this,C=d?z[t]:t;i=b.length;if(c){b=xa(b,c)}else if(p&&i>1){b.reverse()}if(h&&l<i){b.length=l}if(this&&this!==oi&&this instanceof m){C=k||ps(C)}return C.apply(z,b)}return m}function ws(t,e){return function(i,n){return Vr(i,t,e(n),{})}}function ms(t,e){return function(n,r){var o;if(n===i&&r===i){return e}if(n!==i){o=n}if(r!==i){if(o===i){return r}if(typeof n=="string"||typeof r=="string"){n=Oo(n);r=Oo(r)}else{n=$o(n);r=$o(r)}o=t(n,r)}return o}}function xs(t){return Ds((function(e){e=Mi(e,Ni(Ks()));return mo((function(i){var n=this;return t(e,(function(t){return gi(t,n,i)}))}))}))}function zs(t,e){e=e===i?" ":Oo(e);var n=e.length;if(n<2){return n?wo(e,t):e}var r=wo(e,$e(t/vn(e)));return rn(e)?Yo(pn(r),0,t).join(""):r.slice(0,t)}function Cs(t,e,i,n){var r=e&b,o=ps(t);function s(){var e=-1,a=arguments.length,c=-1,l=n.length,u=A(l+a),h=this&&this!==oi&&this instanceof s?o:t;while(++c<l){u[c]=n[c]}while(a--){u[c++]=arguments[++e]}return gi(h,r?i:this,u)}return s}function Ms(t){return function(e,n,r){if(r&&typeof r!="number"&&aa(e,n,r)){n=r=i}e=Nu(e);if(n===i){n=e;e=0}else{n=Nu(n)}r=r===i?e<n?1:-1:Nu(r);return yo(e,n,r,t)}}function js(t){return function(e,i){if(!(typeof e=="string"&&typeof i=="string")){e=Gu(e);i=Gu(i)}return t(e,i)}}function Is(t,e,n,r,o,s,a,c,l,u){var h=e&y,f=h?a:i,d=h?i:a,v=h?s:i,p=h?i:s;e|=h?m:x;e&=~(h?x:m);if(!(e&k)){e&=-4}var b=[t,e,o,v,f,p,d,c,l,u];var g=n.apply(i,b);if(ua(t)){Ca(g,b)}g.placeholder=r;return Ia(g,t,e)}function Ss(t){var e=ee[t];return function(t,i){t=Gu(t);i=i==null?0:Ue(Xu(i),292);if(i&&Fe(t)){var n=(Qu(t)+"e").split("e"),r=e(n[0]+"e"+(+n[1]+i));n=(Qu(r)+"e").split("e");return+(n[0]+"e"+(+n[1]-i))}return e(t)}}var _s=!(ni&&1/un(new ni([,-0]))[1]==O)?Bf:function(t){return new ni(t)};function Ts(t){return function(e){var i=Zs(e);if(i==Z){return an(e)}if(i==rt){return hn(e)}return Hi(e,t(e))}}function As(t,e,n,r,o,a,c,l){var u=e&g;if(!u&&typeof t!="function"){throw new oe(s)}var h=r?r.length:0;if(!h){e&=-97;r=o=i}c=c===i?c:Pe(Xu(c),0);l=l===i?l:Xu(l);h-=o?o.length:0;if(e&x){var f=r,d=o;r=o=i}var v=u?i:Ls(t);var p=[t,e,n,r,o,f,d,a,c,l];if(v){ga(p,v)}t=p[0];e=p[1];n=p[2];r=p[3];o=p[4];l=p[9]=p[9]===i?u?0:t.length:Pe(p[9]-h,0);if(!l&&e&(y|w)){e&=-25}if(!e||e==b){var k=fs(t,e,n)}else if(e==y||e==w){k=bs(t,e,l)}else if((e==m||e==(b|m))&&!o.length){k=Cs(t,e,n,r)}else{k=ys.apply(i,p)}var z=v?Mo:Ca;return Ia(z(k,p),t,e)}function Es(t,e,n,r){if(t===i||ru(t,ce[n])&&!he.call(r,n)){return e}return t}function $s(t,e,n,r,o,s){if(Cu(t)&&Cu(e)){s.set(e,t);co(t,e,i,$s,s);s["delete"](e)}return t}function Os(t){return Ou(t)?i:t}function Rs(t,e,n,r,o,s){var a=n&v,c=t.length,l=e.length;if(c!=l&&!(a&&l>c)){return false}var u=s.get(t);var h=s.get(e);if(u&&h){return u==e&&h==t}var f=-1,d=true,b=n&p?new qn:i;s.set(t,e);s.set(e,t);while(++f<c){var g=t[f],k=e[f];if(r){var y=a?r(k,g,f,e,t,s):r(g,k,f,t,e,s)}if(y!==i){if(y){continue}d=false;break}if(b){if(!_i(e,(function(t,e){if(!qi(b,e)&&(g===t||o(g,t,n,r,s))){return b.push(e)}}))){d=false;break}}else if(!(g===k||o(g,k,n,r,s))){d=false;break}}s["delete"](t);s["delete"](e);return d}function Ws(t,e,i,n,r,o,s){switch(i){case ht:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset){return false}t=t.buffer;e=e.buffer;case ut:if(t.byteLength!=e.byteLength||!o(new we(t),new we(e))){return false}return true;case H:case Y:case J:return ru(+t,+e);case X:return t.name==e.name&&t.message==e.message;case nt:case ot:return t==e+"";case Z:var a=an;case rt:var c=n&v;a||(a=un);if(t.size!=e.size&&!c){return false}var l=s.get(t);if(l){return l==e}n|=p;s.set(t,e);var u=Rs(a(t),a(e),n,r,o,s);s["delete"](t);return u;case st:if(yn){return yn.call(t)==yn.call(e)}}return false}function Fs(t,e,n,r,o,s){var a=n&v,c=Bs(t),l=c.length,u=Bs(e),h=u.length;if(l!=h&&!a){return false}var f=l;while(f--){var d=c[f];if(!(a?d in e:he.call(e,d))){return false}}var p=s.get(t);var b=s.get(e);if(p&&b){return p==e&&b==t}var g=true;s.set(t,e);s.set(e,t);var k=a;while(++f<l){d=c[f];var y=t[d],w=e[d];if(r){var m=a?r(w,y,d,e,t,s):r(y,w,d,t,e,s)}if(!(m===i?y===w||o(y,w,n,r,s):m)){g=false;break}k||(k=d=="constructor")}if(g&&!k){var x=t.constructor,z=e.constructor;if(x!=z&&("constructor"in t&&"constructor"in e)&&!(typeof x=="function"&&x instanceof x&&typeof z=="function"&&z instanceof z)){g=false}}s["delete"](t);s["delete"](e);return g}function Ds(t){return ja(wa(t,i,Xa),t+"")}function Bs(t){return Rr(t,xh,qs)}function Ps(t){return Rr(t,zh,Gs)}var Ls=!ai?Bf:function(t){return ai.get(t)};function Vs(t){var e=t.name+"",i=li[e],n=he.call(li,e)?i.length:0;while(n--){var r=i[n],o=r.func;if(o==null||o==t){return r.name}}return e}function Us(t){var e=he.call(zn,"placeholder")?zn:t;return e.placeholder}function Ks(){var t=zn.iteratee||Ef;t=t===Ef?eo:t;return arguments.length?t(arguments[0],arguments[1]):t}function Hs(t,e){var i=t.__data__;return la(e)?i[typeof e=="string"?"string":"hash"]:i.map}function Ys(t){var e=xh(t),i=e.length;while(i--){var n=e[i],r=t[n];e[i]=[n,r,va(r)]}return e}function Ns(t,e){var n=nn(t,e);return Zr(n)?n:i}function Xs(t){var e=he.call(t,Se),n=t[Se];try{t[Se]=i;var r=true}catch(t){}var o=ve.call(t);if(r){if(e){t[Se]=n}else{delete t[Se]}}return o}var qs=!Re?Xf:function(t){if(t==null){return[]}t=ie(t);return xi(Re(t),(function(e){return Ce.call(t,e)}))};var Gs=!Re?Xf:function(t){var e=[];while(t){ji(e,qs(t));t=xe(t)}return e};var Zs=Wr;if(Je&&Zs(new Je(new ArrayBuffer(1)))!=ht||Qe&&Zs(new Qe)!=Z||ti&&Zs(ti.resolve())!=et||ni&&Zs(new ni)!=rt||ri&&Zs(new ri)!=ct){Zs=function(t){var e=Wr(t),n=e==tt?t.constructor:i,r=n?Ea(n):"";if(r){switch(r){case ui:return ht;case Ti:return Z;case Ai:return et;case Pi:return rt;case fn:return ct}}return e}}function Js(t,e,i){var n=-1,r=i.length;while(++n<r){var o=i[n],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=Ue(e,t+s);break;case"takeRight":t=Pe(t,e-s);break}}return{start:t,end:e}}function Qs(t){var e=t.match(Bt);return e?e[1].split(Pt):[]}function ta(t,e,i){e=Ko(e,t);var n=-1,r=e.length,o=false;while(++n<r){var s=Aa(e[n]);if(!(o=t!=null&&i(t,s))){break}t=t[s]}if(o||++n!=r){return o}r=t==null?0:t.length;return!!r&&zu(r)&&sa(s,r)&&(cu(t)||au(t))}function ea(t){var e=t.length,i=new t.constructor(e);if(e&&typeof t[0]=="string"&&he.call(t,"index")){i.index=t.index;i.input=t.input}return i}function ia(t){return typeof t.constructor=="function"&&!da(t)?Cn(xe(t)):{}}function na(t,e,i){var n=t.constructor;switch(e){case ut:return qo(t);case H:case Y:return new n(+t);case ht:return Go(t,i);case ft:case dt:case vt:case pt:case bt:case gt:case kt:case yt:case wt:return Qo(t,i);case Z:return new n;case J:case ot:return new n(t);case nt:return Zo(t);case rt:return new n;case st:return Jo(t)}}function ra(t,e){var i=e.length;if(!i){return t}var n=i-1;e[n]=(i>1?"& ":"")+e[n];e=e.join(i>2?", ":" ");return t.replace(Dt,"{\n/* [wrapped with "+e+"] */\n")}function oa(t){return cu(t)||au(t)||!!(je&&t&&t[je])}function sa(t,e){var i=typeof t;e=e==null?R:e;return!!e&&(i=="number"||i!="symbol"&&Gt.test(t))&&(t>-1&&t%1==0&&t<e)}function aa(t,e,i){if(!Cu(i)){return false}var n=typeof e;if(n=="number"?uu(i)&&sa(e,i.length):n=="string"&&e in i){return ru(i[e],t)}return false}function ca(t,e){if(cu(t)){return false}var i=typeof t;if(i=="number"||i=="symbol"||i=="boolean"||t==null||Bu(t)){return true}return Et.test(t)||!At.test(t)||e!=null&&t in ie(e)}function la(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function ua(t){var e=Vs(t),i=zn[e];if(typeof i!="function"||!(e in In.prototype)){return false}if(t===i){return true}var n=Ls(i);return!!n&&t===n[0]}function ha(t){return!!de&&de in t}var fa=le?mu:qf;function da(t){var e=t&&t.constructor,i=typeof e=="function"&&e.prototype||ce;return t===i}function va(t){return t===t&&!Cu(t)}function pa(t,e){return function(n){if(n==null){return false}return n[t]===e&&(e!==i||t in ie(n))}}function ba(t){var e=Pl(t,(function(t){if(i.size===l){i.clear()}return t}));var i=e.cache;return e}function ga(t,e){var i=t[1],n=e[1],r=i|n,o=r<(b|g|z);var s=n==z&&i==y||n==z&&i==C&&t[7].length<=e[8]||n==(z|C)&&e[7].length<=e[8]&&i==y;if(!(o||s)){return t}if(n&b){t[2]=e[2];r|=i&b?0:k}var a=e[3];if(a){var c=t[3];t[3]=c?is(c,a,e[4]):a;t[4]=c?ln(t[3],u):e[4]}a=e[5];if(a){c=t[5];t[5]=c?ns(c,a,e[6]):a;t[6]=c?ln(t[5],u):e[6]}a=e[7];if(a){t[7]=a}if(n&z){t[8]=t[8]==null?e[8]:Ue(t[8],e[8])}if(t[9]==null){t[9]=e[9]}t[0]=e[0];t[1]=r;return t}function ka(t){var e=[];if(t!=null){for(var i in ie(t)){e.push(i)}}return e}function ya(t){return ve.call(t)}function wa(t,e,n){e=Pe(e===i?t.length-1:e,0);return function(){var i=arguments,r=-1,o=Pe(i.length-e,0),s=A(o);while(++r<o){s[r]=i[e+r]}r=-1;var a=A(e+1);while(++r<e){a[r]=i[r]}a[e]=n(s);return gi(t,this,a)}}function ma(t,e){return e.length<2?t:Or(t,So(e,0,-1))}function xa(t,e){var n=t.length,r=Ue(e.length,n),o=rs(t);while(r--){var s=e[r];t[r]=sa(s,n)?o[s]:i}return t}function za(t,e){if(e==="constructor"&&typeof t[e]==="function"){return}if(e=="__proto__"){return}return t[e]}var Ca=Sa(Mo);var Ma=Ee||function(t,e){return oi.setTimeout(t,e)};var ja=Sa(jo);function Ia(t,e,i){var n=e+"";return ja(t,ra(n,$a(Qs(n),i)))}function Sa(t){var e=0,n=0;return function(){var r=Ke(),o=_-(r-n);n=r;if(o>0){if(++e>=S){return arguments[0]}}else{e=0}return t.apply(i,arguments)}}function _a(t,e){var n=-1,r=t.length,o=r-1;e=e===i?r:e;while(++n<e){var s=ko(n,o),a=t[s];t[s]=t[n];t[n]=a}t.length=e;return t}var Ta=ba((function(t){var e=[];if(t.charCodeAt(0)===46){e.push("")}t.replace($t,(function(t,i,n,r){e.push(n?r.replace(Ut,"$1"):i||t)}));return e}));function Aa(t){if(typeof t=="string"||Bu(t)){return t}var e=t+"";return e=="0"&&1/t==-Infinity?"-0":e}function Ea(t){if(t!=null){try{return ue.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function $a(t,e){yi(L,(function(i){var n="_."+i[0];if(e&i[1]&&!zi(t,n)){t.push(n)}}));return t.sort()}function Oa(t){if(t instanceof In){return t.clone()}var e=new jn(t.__wrapped__,t.__chain__);e.__actions__=rs(t.__actions__);e.__index__=t.__index__;e.__values__=t.__values__;return e}function Ra(t,e,n){if(n?aa(t,e,n):e===i){e=1}else{e=Pe(Xu(e),0)}var r=t==null?0:t.length;if(!r||e<1){return[]}var o=0,s=0,a=A($e(r/e));while(o<r){a[s++]=So(t,o,o+=e)}return a}function Wa(t){var e=-1,i=t==null?0:t.length,n=0,r=[];while(++e<i){var o=t[e];if(o){r[n++]=o}}return r}function Fa(){var t=arguments.length;if(!t){return[]}var e=A(t-1),i=arguments[0],n=t;while(n--){e[n-1]=arguments[n]}return ji(cu(i)?rs(i):[i],Sr(e,1))}var Da=mo((function(t,e){return hu(t)?mr(t,Sr(e,1,hu,true)):[]}));var Ba=mo((function(t,e){var n=oc(e);if(hu(n)){n=i}return hu(t)?mr(t,Sr(e,1,hu,true),Ks(n,2)):[]}));var Pa=mo((function(t,e){var n=oc(e);if(hu(n)){n=i}return hu(t)?mr(t,Sr(e,1,hu,true),i,n):[]}));function La(t,e,n){var r=t==null?0:t.length;if(!r){return[]}e=n||e===i?1:Xu(e);return So(t,e<0?0:e,r)}function Va(t,e,n){var r=t==null?0:t.length;if(!r){return[]}e=n||e===i?1:Xu(e);e=r-e;return So(t,0,e<0?0:e)}function Ua(t,e){return t&&t.length?Do(t,Ks(e,3),true,true):[]}function Ka(t,e){return t&&t.length?Do(t,Ks(e,3),true):[]}function Ha(t,e,i,n){var r=t==null?0:t.length;if(!r){return[]}if(i&&typeof i!="number"&&aa(t,e,i)){i=0;n=r}return jr(t,e,i,n)}function Ya(t,e,i){var n=t==null?0:t.length;if(!n){return-1}var r=i==null?0:Xu(i);if(r<0){r=Pe(n+r,0)}return Oi(t,Ks(e,3),r)}function Na(t,e,n){var r=t==null?0:t.length;if(!r){return-1}var o=r-1;if(n!==i){o=Xu(n);o=n<0?Pe(r+o,0):Ue(o,r-1)}return Oi(t,Ks(e,3),o,true)}function Xa(t){var e=t==null?0:t.length;return e?Sr(t,1):[]}function qa(t){var e=t==null?0:t.length;return e?Sr(t,O):[]}function Ga(t,e){var n=t==null?0:t.length;if(!n){return[]}e=e===i?1:Xu(e);return Sr(t,e)}function Za(t){var e=-1,i=t==null?0:t.length,n={};while(++e<i){var r=t[e];n[r[0]]=r[1]}return n}function Ja(t){return t&&t.length?t[0]:i}function Qa(t,e,i){var n=t==null?0:t.length;if(!n){return-1}var r=i==null?0:Xu(i);if(r<0){r=Pe(n+r,0)}return Ri(t,e,r)}function tc(t){var e=t==null?0:t.length;return e?So(t,0,-1):[]}var ec=mo((function(t){var e=Mi(t,Vo);return e.length&&e[0]===t[0]?Lr(e):[]}));var ic=mo((function(t){var e=oc(t),n=Mi(t,Vo);if(e===oc(n)){e=i}else{n.pop()}return n.length&&n[0]===t[0]?Lr(n,Ks(e,2)):[]}));var nc=mo((function(t){var e=oc(t),n=Mi(t,Vo);e=typeof e=="function"?e:i;if(e){n.pop()}return n.length&&n[0]===t[0]?Lr(n,i,e):[]}));function rc(t,e){return t==null?"":De.call(t,e)}function oc(t){var e=t==null?0:t.length;return e?t[e-1]:i}function sc(t,e,n){var r=t==null?0:t.length;if(!r){return-1}var o=r;if(n!==i){o=Xu(n);o=o<0?Pe(r+o,0):Ue(o,r-1)}return e===e?dn(t,e,o):Oi(t,Fi,o,true)}function ac(t,e){return t&&t.length?uo(t,Xu(e)):i}var cc=mo(lc);function lc(t,e){return t&&t.length&&e&&e.length?bo(t,e):t}function uc(t,e,i){return t&&t.length&&e&&e.length?bo(t,e,Ks(i,2)):t}function hc(t,e,n){return t&&t.length&&e&&e.length?bo(t,e,i,n):t}var fc=Ds((function(t,e){var i=t==null?0:t.length,n=pr(t,e);go(t,Mi(e,(function(t){return sa(t,i)?+t:t})).sort(ts));return n}));function dc(t,e){var i=[];if(!(t&&t.length)){return i}var n=-1,r=[],o=t.length;e=Ks(e,3);while(++n<o){var s=t[n];if(e(s,n,t)){i.push(s);r.push(n)}}go(t,r);return i}function vc(t){return t==null?t:Ze.call(t)}function pc(t,e,n){var r=t==null?0:t.length;if(!r){return[]}if(n&&typeof n!="number"&&aa(t,e,n)){e=0;n=r}else{e=e==null?0:Xu(e);n=n===i?r:Xu(n)}return So(t,e,n)}function bc(t,e){return To(t,e)}function gc(t,e,i){return Ao(t,e,Ks(i,2))}function kc(t,e){var i=t==null?0:t.length;if(i){var n=To(t,e);if(n<i&&ru(t[n],e)){return n}}return-1}function yc(t,e){return To(t,e,true)}function wc(t,e,i){return Ao(t,e,Ks(i,2),true)}function mc(t,e){var i=t==null?0:t.length;if(i){var n=To(t,e,true)-1;if(ru(t[n],e)){return n}}return-1}function xc(t){return t&&t.length?Eo(t):[]}function zc(t,e){return t&&t.length?Eo(t,Ks(e,2)):[]}function Cc(t){var e=t==null?0:t.length;return e?So(t,1,e):[]}function Mc(t,e,n){if(!(t&&t.length)){return[]}e=n||e===i?1:Xu(e);return So(t,0,e<0?0:e)}function jc(t,e,n){var r=t==null?0:t.length;if(!r){return[]}e=n||e===i?1:Xu(e);e=r-e;return So(t,e<0?0:e,r)}function Ic(t,e){return t&&t.length?Do(t,Ks(e,3),false,true):[]}function Sc(t,e){return t&&t.length?Do(t,Ks(e,3)):[]}var _c=mo((function(t){return Ro(Sr(t,1,hu,true))}));var Tc=mo((function(t){var e=oc(t);if(hu(e)){e=i}return Ro(Sr(t,1,hu,true),Ks(e,2))}));var Ac=mo((function(t){var e=oc(t);e=typeof e=="function"?e:i;return Ro(Sr(t,1,hu,true),i,e)}));function Ec(t){return t&&t.length?Ro(t):[]}function $c(t,e){return t&&t.length?Ro(t,Ks(e,2)):[]}function Oc(t,e){e=typeof e=="function"?e:i;return t&&t.length?Ro(t,i,e):[]}function Rc(t){if(!(t&&t.length)){return[]}var e=0;t=xi(t,(function(t){if(hu(t)){e=Pe(t.length,e);return true}}));return Ki(e,(function(e){return Mi(t,Bi(e))}))}function Wc(t,e){if(!(t&&t.length)){return[]}var n=Rc(t);if(e==null){return n}return Mi(n,(function(t){return gi(e,i,t)}))}var Fc=mo((function(t,e){return hu(t)?mr(t,e):[]}));var Dc=mo((function(t){return Po(xi(t,hu))}));var Bc=mo((function(t){var e=oc(t);if(hu(e)){e=i}return Po(xi(t,hu),Ks(e,2))}));var Pc=mo((function(t){var e=oc(t);e=typeof e=="function"?e:i;return Po(xi(t,hu),i,e)}));var Lc=mo(Rc);function Vc(t,e){return Lo(t||[],e||[],lr)}function Uc(t,e){return Lo(t||[],e||[],Co)}var Kc=mo((function(t){var e=t.length,n=e>1?t[e-1]:i;n=typeof n=="function"?(t.pop(),n):i;return Wc(t,n)}));function Hc(t){var e=zn(t);e.__chain__=true;return e}function Yc(t,e){e(t);return t}function Nc(t,e){return e(t)}var Xc=Ds((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,o=function(e){return pr(e,t)};if(e>1||this.__actions__.length||!(r instanceof In)||!sa(n)){return this.thru(o)}r=r.slice(n,+n+(e?1:0));r.__actions__.push({func:Nc,args:[o],thisArg:i});return new jn(r,this.__chain__).thru((function(t){if(e&&!t.length){t.push(i)}return t}))}));function qc(){return Hc(this)}function Gc(){return new jn(this.value(),this.__chain__)}function Zc(){if(this.__values__===i){this.__values__=Yu(this.value())}var t=this.__index__>=this.__values__.length,e=t?i:this.__values__[this.__index__++];return{done:t,value:e}}function Jc(){return this}function Qc(t){var e,n=this;while(n instanceof Mn){var r=Oa(n);r.__index__=0;r.__values__=i;if(e){o.__wrapped__=r}else{e=r}var o=r;n=n.__wrapped__}o.__wrapped__=t;return e}function tl(){var t=this.__wrapped__;if(t instanceof In){var e=t;if(this.__actions__.length){e=new In(this)}e=e.reverse();e.__actions__.push({func:Nc,args:[vc],thisArg:i});return new jn(e,this.__chain__)}return this.thru(vc)}function el(){return Bo(this.__wrapped__,this.__actions__)}var il=cs((function(t,e,i){if(he.call(t,i)){++t[i]}else{vr(t,i,1)}}));function nl(t,e,n){var r=cu(t)?mi:Cr;if(n&&aa(t,e,n)){e=i}return r(t,Ks(e,3))}function rl(t,e){var i=cu(t)?xi:Ir;return i(t,Ks(e,3))}var ol=gs(Ya);var sl=gs(Na);function al(t,e){return Sr(bl(t,e),1)}function cl(t,e){return Sr(bl(t,e),O)}function ll(t,e,n){n=n===i?1:Xu(n);return Sr(bl(t,e),n)}function ul(t,e){var i=cu(t)?yi:xr;return i(t,Ks(e,3))}function hl(t,e){var i=cu(t)?wi:zr;return i(t,Ks(e,3))}var fl=cs((function(t,e,i){if(he.call(t,i)){t[i].push(e)}else{vr(t,i,[e])}}));function dl(t,e,i,n){t=uu(t)?t:Lh(t);i=i&&!n?Xu(i):0;var r=t.length;if(i<0){i=Pe(r+i,0)}return Du(t)?i<=r&&t.indexOf(e,i)>-1:!!r&&Ri(t,e,i)>-1}var vl=mo((function(t,e,i){var n=-1,r=typeof e=="function",o=uu(t)?A(t.length):[];xr(t,(function(t){o[++n]=r?gi(e,t,i):Ur(t,e,i)}));return o}));var pl=cs((function(t,e,i){vr(t,i,e)}));function bl(t,e){var i=cu(t)?Mi:oo;return i(t,Ks(e,3))}function gl(t,e,n,r){if(t==null){return[]}if(!cu(e)){e=e==null?[]:[e]}n=r?i:n;if(!cu(n)){n=n==null?[]:[n]}return ho(t,e,n)}var kl=cs((function(t,e,i){t[i?0:1].push(e)}),(function(){return[[],[]]}));function yl(t,e,i){var n=cu(t)?Ii:Li,r=arguments.length<3;return n(t,Ks(e,4),i,r,xr)}function wl(t,e,i){var n=cu(t)?Si:Li,r=arguments.length<3;return n(t,Ks(e,4),i,r,zr)}function ml(t,e){var i=cu(t)?xi:Ir;return i(t,Ll(Ks(e,3)))}function xl(t){var e=cu(t)?or:xo;return e(t)}function zl(t,e,n){if(n?aa(t,e,n):e===i){e=1}else{e=Xu(e)}var r=cu(t)?sr:zo;return r(t,e)}function Cl(t){var e=cu(t)?ar:Io;return e(t)}function Ml(t){if(t==null){return 0}if(uu(t)){return Du(t)?vn(t):t.length}var e=Zs(t);if(e==Z||e==rt){return t.size}return io(t).length}function jl(t,e,n){var r=cu(t)?_i:_o;if(n&&aa(t,e,n)){e=i}return r(t,Ks(e,3))}var Il=mo((function(t,e){if(t==null){return[]}var i=e.length;if(i>1&&aa(t,e[0],e[1])){e=[]}else if(i>2&&aa(e[0],e[1],e[2])){e=[e[0]]}return ho(t,Sr(e,1),[])}));var Sl=Ae||function(){return oi.Date.now()};function _l(t,e){if(typeof e!="function"){throw new oe(s)}t=Xu(t);return function(){if(--t<1){return e.apply(this,arguments)}}}function Tl(t,e,n){e=n?i:e;e=t&&e==null?t.length:e;return As(t,z,i,i,i,i,e)}function Al(t,e){var n;if(typeof e!="function"){throw new oe(s)}t=Xu(t);return function(){if(--t>0){n=e.apply(this,arguments)}if(t<=1){e=i}return n}}var El=mo((function(t,e,i){var n=b;if(i.length){var r=ln(i,Us(El));n|=m}return As(t,n,e,i,r)}));var $l=mo((function(t,e,i){var n=b|g;if(i.length){var r=ln(i,Us($l));n|=m}return As(e,n,t,i,r)}));function Ol(t,e,n){e=n?i:e;var r=As(t,y,i,i,i,i,i,e);r.placeholder=Ol.placeholder;return r}function Rl(t,e,n){e=n?i:e;var r=As(t,w,i,i,i,i,i,e);r.placeholder=Rl.placeholder;return r}function Wl(t,e,n){var r,o,a,c,l,u,h=0,f=false,d=false,v=true;if(typeof t!="function"){throw new oe(s)}e=Gu(e)||0;if(Cu(n)){f=!!n.leading;d="maxWait"in n;a=d?Pe(Gu(n.maxWait)||0,e):a;v="trailing"in n?!!n.trailing:v}function p(e){var n=r,s=o;r=o=i;h=e;c=t.apply(s,n);return c}function b(t){h=t;l=Ma(y,e);return f?p(t):c}function g(t){var i=t-u,n=t-h,r=e-i;return d?Ue(r,a-n):r}function k(t){var n=t-u,r=t-h;return u===i||n>=e||n<0||d&&r>=a}function y(){var t=Sl();if(k(t)){return w(t)}l=Ma(y,g(t))}function w(t){l=i;if(v&&r){return p(t)}r=o=i;return c}function m(){if(l!==i){No(l)}h=0;r=u=o=l=i}function x(){return l===i?c:w(Sl())}function z(){var t=Sl(),n=k(t);r=arguments;o=this;u=t;if(n){if(l===i){return b(u)}if(d){No(l);l=Ma(y,e);return p(u)}}if(l===i){l=Ma(y,e)}return c}z.cancel=m;z.flush=x;return z}var Fl=mo((function(t,e){return wr(t,1,e)}));var Dl=mo((function(t,e,i){return wr(t,Gu(e)||0,i)}));function Bl(t){return As(t,M)}function Pl(t,e){if(typeof t!="function"||e!=null&&typeof e!="function"){throw new oe(s)}var i=function(){var n=arguments,r=e?e.apply(this,n):n[0],o=i.cache;if(o.has(r)){return o.get(r)}var s=t.apply(this,n);i.cache=o.set(r,s)||o;return s};i.cache=new(Pl.Cache||Un);return i}Pl.Cache=Un;function Ll(t){if(typeof t!="function"){throw new oe(s)}return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Vl(t){return Al(2,t)}var Ul=Ho((function(t,e){e=e.length==1&&cu(e[0])?Mi(e[0],Ni(Ks())):Mi(Sr(e,1),Ni(Ks()));var i=e.length;return mo((function(n){var r=-1,o=Ue(n.length,i);while(++r<o){n[r]=e[r].call(this,n[r])}return gi(t,this,n)}))}));var Kl=mo((function(t,e){var n=ln(e,Us(Kl));return As(t,m,i,e,n)}));var Hl=mo((function(t,e){var n=ln(e,Us(Hl));return As(t,x,i,e,n)}));var Yl=Ds((function(t,e){return As(t,C,i,i,i,e)}));function Nl(t,e){if(typeof t!="function"){throw new oe(s)}e=e===i?e:Xu(e);return mo(t,e)}function Xl(t,e){if(typeof t!="function"){throw new oe(s)}e=e==null?0:Pe(Xu(e),0);return mo((function(i){var n=i[e],r=Yo(i,0,e);if(n){ji(r,n)}return gi(t,this,r)}))}function ql(t,e,i){var n=true,r=true;if(typeof t!="function"){throw new oe(s)}if(Cu(i)){n="leading"in i?!!i.leading:n;r="trailing"in i?!!i.trailing:r}return Wl(t,e,{leading:n,maxWait:e,trailing:r})}function Gl(t){return Tl(t,1)}function Zl(t,e){return Kl(Uo(e),t)}function Jl(){if(!arguments.length){return[]}var t=arguments[0];return cu(t)?t:[t]}function Ql(t){return gr(t,d)}function tu(t,e){e=typeof e=="function"?e:i;return gr(t,d,e)}function eu(t){return gr(t,h|d)}function iu(t,e){e=typeof e=="function"?e:i;return gr(t,h|d,e)}function nu(t,e){return e==null||yr(t,e,xh(e))}function ru(t,e){return t===e||t!==t&&e!==e}var ou=js(Fr);var su=js((function(t,e){return t>=e}));var au=Kr(function(){return arguments}())?Kr:function(t){return Mu(t)&&he.call(t,"callee")&&!Ce.call(t,"callee")};var cu=A.isArray;var lu=hi?Ni(hi):Hr;function uu(t){return t!=null&&zu(t.length)&&!mu(t)}function hu(t){return Mu(t)&&uu(t)}function fu(t){return t===true||t===false||Mu(t)&&Wr(t)==H}var du=We||qf;var vu=fi?Ni(fi):Yr;function pu(t){return Mu(t)&&t.nodeType===1&&!Ou(t)}function bu(t){if(t==null){return true}if(uu(t)&&(cu(t)||typeof t=="string"||typeof t.splice=="function"||du(t)||Pu(t)||au(t))){return!t.length}var e=Zs(t);if(e==Z||e==rt){return!t.size}if(da(t)){return!io(t).length}for(var i in t){if(he.call(t,i)){return false}}return true}function gu(t,e){return Nr(t,e)}function ku(t,e,n){n=typeof n=="function"?n:i;var r=n?n(t,e):i;return r===i?Nr(t,e,i,n):!!r}function yu(t){if(!Mu(t)){return false}var e=Wr(t);return e==X||e==N||typeof t.message=="string"&&typeof t.name=="string"&&!Ou(t)}function wu(t){return typeof t=="number"&&Fe(t)}function mu(t){if(!Cu(t)){return false}var e=Wr(t);return e==q||e==G||e==K||e==it}function xu(t){return typeof t=="number"&&t==Xu(t)}function zu(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=R}function Cu(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function Mu(t){return t!=null&&typeof t=="object"}var ju=di?Ni(di):qr;function Iu(t,e){return t===e||Gr(t,e,Ys(e))}function Su(t,e,n){n=typeof n=="function"?n:i;return Gr(t,e,Ys(e),n)}function _u(t){return $u(t)&&t!=+t}function Tu(t){if(fa(t)){throw new Lt(o)}return Zr(t)}function Au(t){return t===null}function Eu(t){return t==null}function $u(t){return typeof t=="number"||Mu(t)&&Wr(t)==J}function Ou(t){if(!Mu(t)||Wr(t)!=tt){return false}var e=xe(t);if(e===null){return true}var i=he.call(e,"constructor")&&e.constructor;return typeof i=="function"&&i instanceof i&&ue.call(i)==pe}var Ru=vi?Ni(vi):Jr;function Wu(t){return xu(t)&&t>=-9007199254740991&&t<=R}var Fu=pi?Ni(pi):Qr;function Du(t){return typeof t=="string"||!cu(t)&&Mu(t)&&Wr(t)==ot}function Bu(t){return typeof t=="symbol"||Mu(t)&&Wr(t)==st}var Pu=bi?Ni(bi):to;function Lu(t){return t===i}function Vu(t){return Mu(t)&&Zs(t)==ct}function Uu(t){return Mu(t)&&Wr(t)==lt}var Ku=js(ro);var Hu=js((function(t,e){return t<=e}));function Yu(t){if(!t){return[]}if(uu(t)){return Du(t)?pn(t):rs(t)}if(Ie&&t[Ie]){return sn(t[Ie]())}var e=Zs(t),i=e==Z?an:e==rt?un:Lh;return i(t)}function Nu(t){if(!t){return t===0?t:0}t=Gu(t);if(t===O||t===-Infinity){var e=t<0?-1:1;return e*W}return t===t?t:0}function Xu(t){var e=Nu(t),i=e%1;return e===e?i?e-i:e:0}function qu(t){return t?br(Xu(t),0,D):0}function Gu(t){if(typeof t=="number"){return t}if(Bu(t)){return F}if(Cu(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Cu(e)?e+"":e}if(typeof t!="string"){return t===0?t:+t}t=Yi(t);var i=Nt.test(t);return i||qt.test(t)?ii(t.slice(2),i?2:8):Yt.test(t)?F:+t}function Zu(t){return os(t,zh(t))}function Ju(t){return t?br(Xu(t),-9007199254740991,R):t===0?t:0}function Qu(t){return t==null?"":Oo(t)}var th=ls((function(t,e){if(da(e)||uu(e)){os(e,xh(e),t);return}for(var i in e){if(he.call(e,i)){lr(t,i,e[i])}}}));var eh=ls((function(t,e){os(e,zh(e),t)}));var ih=ls((function(t,e,i,n){os(e,zh(e),t,n)}));var nh=ls((function(t,e,i,n){os(e,xh(e),t,n)}));var rh=Ds(pr);function oh(t,e){var i=Cn(t);return e==null?i:fr(i,e)}var sh=mo((function(t,e){t=ie(t);var n=-1;var r=e.length;var o=r>2?e[2]:i;if(o&&aa(e[0],e[1],o)){r=1}while(++n<r){var s=e[n];var a=zh(s);var c=-1;var l=a.length;while(++c<l){var u=a[c];var h=t[u];if(h===i||ru(h,ce[u])&&!he.call(t,u)){t[u]=s[u]}}}return t}));var ah=mo((function(t){t.push(i,$s);return gi(Ih,i,t)}));function ch(t,e){return $i(t,Ks(e,3),Ar)}function lh(t,e){return $i(t,Ks(e,3),Er)}function uh(t,e){return t==null?t:_r(t,Ks(e,3),zh)}function hh(t,e){return t==null?t:Tr(t,Ks(e,3),zh)}function fh(t,e){return t&&Ar(t,Ks(e,3))}function dh(t,e){return t&&Er(t,Ks(e,3))}function vh(t){return t==null?[]:$r(t,xh(t))}function ph(t){return t==null?[]:$r(t,zh(t))}function bh(t,e,n){var r=t==null?i:Or(t,e);return r===i?n:r}function gh(t,e){return t!=null&&ta(t,e,Dr)}function kh(t,e){return t!=null&&ta(t,e,Br)}var yh=ws((function(t,e,i){if(e!=null&&typeof e.toString!="function"){e=ve.call(e)}t[e]=i}),If(Af));var wh=ws((function(t,e,i){if(e!=null&&typeof e.toString!="function"){e=ve.call(e)}if(he.call(t,e)){t[e].push(i)}else{t[e]=[i]}}),Ks);var mh=mo(Ur);function xh(t){return uu(t)?rr(t):io(t)}function zh(t){return uu(t)?rr(t,true):no(t)}function Ch(t,e){var i={};e=Ks(e,3);Ar(t,(function(t,n,r){vr(i,e(t,n,r),t)}));return i}function Mh(t,e){var i={};e=Ks(e,3);Ar(t,(function(t,n,r){vr(i,n,e(t,n,r))}));return i}var jh=ls((function(t,e,i){co(t,e,i)}));var Ih=ls((function(t,e,i,n){co(t,e,i,n)}));var Sh=Ds((function(t,e){var i={};if(t==null){return i}var n=false;e=Mi(e,(function(e){e=Ko(e,t);n||(n=e.length>1);return e}));os(t,Ps(t),i);if(n){i=gr(i,h|f|d,Os)}var r=e.length;while(r--){Wo(i,e[r])}return i}));function _h(t,e){return Ah(t,Ll(Ks(e)))}var Th=Ds((function(t,e){return t==null?{}:fo(t,e)}));function Ah(t,e){if(t==null){return{}}var i=Mi(Ps(t),(function(t){return[t]}));e=Ks(e);return vo(t,i,(function(t,i){return e(t,i[0])}))}function Eh(t,e,n){e=Ko(e,t);var r=-1,o=e.length;if(!o){o=1;t=i}while(++r<o){var s=t==null?i:t[Aa(e[r])];if(s===i){r=o;s=n}t=mu(s)?s.call(t):s}return t}function $h(t,e,i){return t==null?t:Co(t,e,i)}function Oh(t,e,n,r){r=typeof r=="function"?r:i;return t==null?t:Co(t,e,n,r)}var Rh=Ts(xh);var Wh=Ts(zh);function Fh(t,e,i){var n=cu(t),r=n||du(t)||Pu(t);e=Ks(e,4);if(i==null){var o=t&&t.constructor;if(r){i=n?new o:[]}else if(Cu(t)){i=mu(o)?Cn(xe(t)):{}}else{i={}}}(r?yi:Ar)(t,(function(t,n,r){return e(i,t,n,r)}));return i}function Dh(t,e){return t==null?true:Wo(t,e)}function Bh(t,e,i){return t==null?t:Fo(t,e,Uo(i))}function Ph(t,e,n,r){r=typeof r=="function"?r:i;return t==null?t:Fo(t,e,Uo(n),r)}function Lh(t){return t==null?[]:Xi(t,xh(t))}function Vh(t){return t==null?[]:Xi(t,zh(t))}function Uh(t,e,n){if(n===i){n=e;e=i}if(n!==i){n=Gu(n);n=n===n?n:0}if(e!==i){e=Gu(e);e=e===e?e:0}return br(Gu(t),e,n)}function Kh(t,e,n){e=Nu(e);if(n===i){n=e;e=0}else{n=Nu(n)}t=Gu(t);return Pr(t,e,n)}function Hh(t,e,n){if(n&&typeof n!="boolean"&&aa(t,e,n)){e=n=i}if(n===i){if(typeof e=="boolean"){n=e;e=i}else if(typeof t=="boolean"){n=t;t=i}}if(t===i&&e===i){t=0;e=1}else{t=Nu(t);if(e===i){e=t;t=0}else{e=Nu(e)}}if(t>e){var r=t;t=e;e=r}if(n||t%1||e%1){var o=Ye();return Ue(t+o*(e-t+ei("1e-"+((o+"").length-1))),e)}return ko(t,e)}var Yh=vs((function(t,e,i){e=e.toLowerCase();return t+(i?Nh(e):e)}));function Nh(t){return mf(Qu(t).toLowerCase())}function Xh(t){t=Qu(t);return t&&t.replace(Zt,Qi).replace(Ve,"")}function qh(t,e,n){t=Qu(t);e=Oo(e);var r=t.length;n=n===i?r:br(Xu(n),0,r);var o=n;n-=e.length;return n>=0&&t.slice(n,o)==e}function Gh(t){t=Qu(t);return t&&It.test(t)?t.replace(Mt,tn):t}function Zh(t){t=Qu(t);return t&&Rt.test(t)?t.replace(Ot,"\\$&"):t}var Jh=vs((function(t,e,i){return t+(i?"-":"")+e.toLowerCase()}));var Qh=vs((function(t,e,i){return t+(i?" ":"")+e.toLowerCase()}));var tf=ds("toLowerCase");function ef(t,e,i){t=Qu(t);e=Xu(e);var n=e?vn(t):0;if(!e||n>=e){return t}var r=(e-n)/2;return zs(Oe(r),i)+t+zs($e(r),i)}function nf(t,e,i){t=Qu(t);e=Xu(e);var n=e?vn(t):0;return e&&n<e?t+zs(e-n,i):t}function rf(t,e,i){t=Qu(t);e=Xu(e);var n=e?vn(t):0;return e&&n<e?zs(e-n,i)+t:t}function of(t,e,i){if(i||e==null){e=0}else if(e){e=+e}return He(Qu(t).replace(Wt,""),e||0)}function sf(t,e,n){if(n?aa(t,e,n):e===i){e=1}else{e=Xu(e)}return wo(Qu(t),e)}function af(){var t=arguments,e=Qu(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var cf=vs((function(t,e,i){return t+(i?"_":"")+e.toLowerCase()}));function lf(t,e,n){if(n&&typeof n!="number"&&aa(t,e,n)){e=n=i}n=n===i?D:n>>>0;if(!n){return[]}t=Qu(t);if(t&&(typeof e=="string"||e!=null&&!Ru(e))){e=Oo(e);if(!e&&rn(t)){return Yo(pn(t),0,n)}}return t.split(e,n)}var uf=vs((function(t,e,i){return t+(i?" ":"")+mf(e)}));function hf(t,e,i){t=Qu(t);i=i==null?0:br(Xu(i),0,t.length);e=Oo(e);return t.slice(i,i+e.length)==e}function ff(t,e,n){var r=zn.templateSettings;if(n&&aa(t,e,n)){e=i}t=Qu(t);e=ih({},e,r,Es);var o=ih({},e.imports,r.imports,Es),s=xh(o),c=Xi(o,s);var l,u,h=0,f=e.interpolate||Jt,d="__p += '";var v=ne((e.escape||Jt).source+"|"+f.source+"|"+(f===Tt?Kt:Jt).source+"|"+(e.evaluate||Jt).source+"|$","g");var p="//# sourceURL="+(he.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Xe+"]")+"\n";t.replace(v,(function(e,i,n,r,o,s){n||(n=r);d+=t.slice(h,s).replace(Qt,en);if(i){l=true;d+="' +\n__e("+i+") +\n'"}if(o){u=true;d+="';\n"+o+";\n__p += '"}if(n){d+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"}h=s+e.length;return e}));d+="';\n";var b=he.call(e,"variable")&&e.variable;if(!b){d="with (obj) {\n"+d+"\n}\n"}else if(Vt.test(b)){throw new Lt(a)}d=(u?d.replace(mt,""):d).replace(xt,"$1").replace(zt,"$1;");d="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(l?", __e = _.escape":"")+(u?", __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=zf((function(){return te(s,p+"return "+d).apply(i,c)}));g.source=d;if(yu(g)){throw g}return g}function df(t){return Qu(t).toLowerCase()}function vf(t){return Qu(t).toUpperCase()}function pf(t,e,n){t=Qu(t);if(t&&(n||e===i)){return Yi(t)}if(!t||!(e=Oo(e))){return t}var r=pn(t),o=pn(e),s=Gi(r,o),a=Zi(r,o)+1;return Yo(r,s,a).join("")}function bf(t,e,n){t=Qu(t);if(t&&(n||e===i)){return t.slice(0,bn(t)+1)}if(!t||!(e=Oo(e))){return t}var r=pn(t),o=Zi(r,pn(e))+1;return Yo(r,0,o).join("")}function gf(t,e,n){t=Qu(t);if(t&&(n||e===i)){return t.replace(Wt,"")}if(!t||!(e=Oo(e))){return t}var r=pn(t),o=Gi(r,pn(e));return Yo(r,o).join("")}function kf(t,e){var n=j,r=I;if(Cu(e)){var o="separator"in e?e.separator:o;n="length"in e?Xu(e.length):n;r="omission"in e?Oo(e.omission):r}t=Qu(t);var s=t.length;if(rn(t)){var a=pn(t);s=a.length}if(n>=s){return t}var c=n-vn(r);if(c<1){return r}var l=a?Yo(a,0,c).join(""):t.slice(0,c);if(o===i){return l+r}if(a){c+=l.length-c}if(Ru(o)){if(t.slice(c).search(o)){var u,h=l;if(!o.global){o=ne(o.source,Qu(Ht.exec(o))+"g")}o.lastIndex=0;while(u=o.exec(h)){var f=u.index}l=l.slice(0,f===i?c:f)}}else if(t.indexOf(Oo(o),c)!=c){var d=l.lastIndexOf(o);if(d>-1){l=l.slice(0,d)}}return l+r}function yf(t){t=Qu(t);return t&&jt.test(t)?t.replace(Ct,gn):t}var wf=vs((function(t,e,i){return t+(i?" ":"")+e.toUpperCase()}));var mf=ds("toUpperCase");function xf(t,e,n){t=Qu(t);e=n?i:e;if(e===i){return on(t)?wn(t):Ei(t)}return t.match(e)||[]}var zf=mo((function(t,e){try{return gi(t,i,e)}catch(t){return yu(t)?t:new Lt(t)}}));var Cf=Ds((function(t,e){yi(e,(function(e){e=Aa(e);vr(t,e,El(t[e],t))}));return t}));function Mf(t){var e=t==null?0:t.length,i=Ks();t=!e?[]:Mi(t,(function(t){if(typeof t[1]!="function"){throw new oe(s)}return[i(t[0]),t[1]]}));return mo((function(i){var n=-1;while(++n<e){var r=t[n];if(gi(r[0],this,i)){return gi(r[1],this,i)}}}))}function jf(t){return kr(gr(t,h))}function If(t){return function(){return t}}function Sf(t,e){return t==null||t!==t?e:t}var _f=ks();var Tf=ks(true);function Af(t){return t}function Ef(t){return eo(typeof t=="function"?t:gr(t,h))}function $f(t){return so(gr(t,h))}function Of(t,e){return ao(t,gr(e,h))}var Rf=mo((function(t,e){return function(i){return Ur(i,t,e)}}));var Wf=mo((function(t,e){return function(i){return Ur(t,i,e)}}));function Ff(t,e,i){var n=xh(e),r=$r(e,n);if(i==null&&!(Cu(e)&&(r.length||!n.length))){i=e;e=t;t=this;r=$r(e,xh(e))}var o=!(Cu(i)&&"chain"in i)||!!i.chain,s=mu(t);yi(r,(function(i){var n=e[i];t[i]=n;if(s){t.prototype[i]=function(){var e=this.__chain__;if(o||e){var i=t(this.__wrapped__),r=i.__actions__=rs(this.__actions__);r.push({func:n,args:arguments,thisArg:t});i.__chain__=e;return i}return n.apply(t,ji([this.value()],arguments))}}}));return t}function Df(){if(oi._===this){oi._=be}return this}function Bf(){}function Pf(t){t=Xu(t);return mo((function(e){return uo(e,t)}))}var Lf=xs(Mi);var Vf=xs(mi);var Uf=xs(_i);function Kf(t){return ca(t)?Bi(Aa(t)):po(t)}function Hf(t){return function(e){return t==null?i:Or(t,e)}}var Yf=Ms();var Nf=Ms(true);function Xf(){return[]}function qf(){return false}function Gf(){return{}}function Zf(){return""}function Jf(){return true}function Qf(t,e){t=Xu(t);if(t<1||t>R){return[]}var i=D,n=Ue(t,D);e=Ks(e);t-=D;var r=Ki(n,e);while(++i<t){e(i)}return r}function td(t){if(cu(t)){return Mi(t,Aa)}return Bu(t)?[t]:rs(Ta(Qu(t)))}function ed(t){var e=++fe;return Qu(t)+e}var id=ms((function(t,e){return t+e}),0);var nd=Ss("ceil");var rd=ms((function(t,e){return t/e}),1);var od=Ss("floor");function sd(t){return t&&t.length?Mr(t,Af,Fr):i}function ad(t,e){return t&&t.length?Mr(t,Ks(e,2),Fr):i}function cd(t){return Di(t,Af)}function ld(t,e){return Di(t,Ks(e,2))}function ud(t){return t&&t.length?Mr(t,Af,ro):i}function hd(t,e){return t&&t.length?Mr(t,Ks(e,2),ro):i}var fd=ms((function(t,e){return t*e}),1);var dd=Ss("round");var vd=ms((function(t,e){return t-e}),0);function pd(t){return t&&t.length?Ui(t,Af):0}function bd(t,e){return t&&t.length?Ui(t,Ks(e,2)):0}zn.after=_l;zn.ary=Tl;zn.assign=th;zn.assignIn=eh;zn.assignInWith=ih;zn.assignWith=nh;zn.at=rh;zn.before=Al;zn.bind=El;zn.bindAll=Cf;zn.bindKey=$l;zn.castArray=Jl;zn.chain=Hc;zn.chunk=Ra;zn.compact=Wa;zn.concat=Fa;zn.cond=Mf;zn.conforms=jf;zn.constant=If;zn.countBy=il;zn.create=oh;zn.curry=Ol;zn.curryRight=Rl;zn.debounce=Wl;zn.defaults=sh;zn.defaultsDeep=ah;zn.defer=Fl;zn.delay=Dl;zn.difference=Da;zn.differenceBy=Ba;zn.differenceWith=Pa;zn.drop=La;zn.dropRight=Va;zn.dropRightWhile=Ua;zn.dropWhile=Ka;zn.fill=Ha;zn.filter=rl;zn.flatMap=al;zn.flatMapDeep=cl;zn.flatMapDepth=ll;zn.flatten=Xa;zn.flattenDeep=qa;zn.flattenDepth=Ga;zn.flip=Bl;zn.flow=_f;zn.flowRight=Tf;zn.fromPairs=Za;zn.functions=vh;zn.functionsIn=ph;zn.groupBy=fl;zn.initial=tc;zn.intersection=ec;zn.intersectionBy=ic;zn.intersectionWith=nc;zn.invert=yh;zn.invertBy=wh;zn.invokeMap=vl;zn.iteratee=Ef;zn.keyBy=pl;zn.keys=xh;zn.keysIn=zh;zn.map=bl;zn.mapKeys=Ch;zn.mapValues=Mh;zn.matches=$f;zn.matchesProperty=Of;zn.memoize=Pl;zn.merge=jh;zn.mergeWith=Ih;zn.method=Rf;zn.methodOf=Wf;zn.mixin=Ff;zn.negate=Ll;zn.nthArg=Pf;zn.omit=Sh;zn.omitBy=_h;zn.once=Vl;zn.orderBy=gl;zn.over=Lf;zn.overArgs=Ul;zn.overEvery=Vf;zn.overSome=Uf;zn.partial=Kl;zn.partialRight=Hl;zn.partition=kl;zn.pick=Th;zn.pickBy=Ah;zn.property=Kf;zn.propertyOf=Hf;zn.pull=cc;zn.pullAll=lc;zn.pullAllBy=uc;zn.pullAllWith=hc;zn.pullAt=fc;zn.range=Yf;zn.rangeRight=Nf;zn.rearg=Yl;zn.reject=ml;zn.remove=dc;zn.rest=Nl;zn.reverse=vc;zn.sampleSize=zl;zn.set=$h;zn.setWith=Oh;zn.shuffle=Cl;zn.slice=pc;zn.sortBy=Il;zn.sortedUniq=xc;zn.sortedUniqBy=zc;zn.split=lf;zn.spread=Xl;zn.tail=Cc;zn.take=Mc;zn.takeRight=jc;zn.takeRightWhile=Ic;zn.takeWhile=Sc;zn.tap=Yc;zn.throttle=ql;zn.thru=Nc;zn.toArray=Yu;zn.toPairs=Rh;zn.toPairsIn=Wh;zn.toPath=td;zn.toPlainObject=Zu;zn.transform=Fh;zn.unary=Gl;zn.union=_c;zn.unionBy=Tc;zn.unionWith=Ac;zn.uniq=Ec;zn.uniqBy=$c;zn.uniqWith=Oc;zn.unset=Dh;zn.unzip=Rc;zn.unzipWith=Wc;zn.update=Bh;zn.updateWith=Ph;zn.values=Lh;zn.valuesIn=Vh;zn.without=Fc;zn.words=xf;zn.wrap=Zl;zn.xor=Dc;zn.xorBy=Bc;zn.xorWith=Pc;zn.zip=Lc;zn.zipObject=Vc;zn.zipObjectDeep=Uc;zn.zipWith=Kc;zn.entries=Rh;zn.entriesIn=Wh;zn.extend=eh;zn.extendWith=ih;Ff(zn,zn);zn.add=id;zn.attempt=zf;zn.camelCase=Yh;zn.capitalize=Nh;zn.ceil=nd;zn.clamp=Uh;zn.clone=Ql;zn.cloneDeep=eu;zn.cloneDeepWith=iu;zn.cloneWith=tu;zn.conformsTo=nu;zn.deburr=Xh;zn.defaultTo=Sf;zn.divide=rd;zn.endsWith=qh;zn.eq=ru;zn.escape=Gh;zn.escapeRegExp=Zh;zn.every=nl;zn.find=ol;zn.findIndex=Ya;zn.findKey=ch;zn.findLast=sl;zn.findLastIndex=Na;zn.findLastKey=lh;zn.floor=od;zn.forEach=ul;zn.forEachRight=hl;zn.forIn=uh;zn.forInRight=hh;zn.forOwn=fh;zn.forOwnRight=dh;zn.get=bh;zn.gt=ou;zn.gte=su;zn.has=gh;zn.hasIn=kh;zn.head=Ja;zn.identity=Af;zn.includes=dl;zn.indexOf=Qa;zn.inRange=Kh;zn.invoke=mh;zn.isArguments=au;zn.isArray=cu;zn.isArrayBuffer=lu;zn.isArrayLike=uu;zn.isArrayLikeObject=hu;zn.isBoolean=fu;zn.isBuffer=du;zn.isDate=vu;zn.isElement=pu;zn.isEmpty=bu;zn.isEqual=gu;zn.isEqualWith=ku;zn.isError=yu;zn.isFinite=wu;zn.isFunction=mu;zn.isInteger=xu;zn.isLength=zu;zn.isMap=ju;zn.isMatch=Iu;zn.isMatchWith=Su;zn.isNaN=_u;zn.isNative=Tu;zn.isNil=Eu;zn.isNull=Au;zn.isNumber=$u;zn.isObject=Cu;zn.isObjectLike=Mu;zn.isPlainObject=Ou;zn.isRegExp=Ru;zn.isSafeInteger=Wu;zn.isSet=Fu;zn.isString=Du;zn.isSymbol=Bu;zn.isTypedArray=Pu;zn.isUndefined=Lu;zn.isWeakMap=Vu;zn.isWeakSet=Uu;zn.join=rc;zn.kebabCase=Jh;zn.last=oc;zn.lastIndexOf=sc;zn.lowerCase=Qh;zn.lowerFirst=tf;zn.lt=Ku;zn.lte=Hu;zn.max=sd;zn.maxBy=ad;zn.mean=cd;zn.meanBy=ld;zn.min=ud;zn.minBy=hd;zn.stubArray=Xf;zn.stubFalse=qf;zn.stubObject=Gf;zn.stubString=Zf;zn.stubTrue=Jf;zn.multiply=fd;zn.nth=ac;zn.noConflict=Df;zn.noop=Bf;zn.now=Sl;zn.pad=ef;zn.padEnd=nf;zn.padStart=rf;zn.parseInt=of;zn.random=Hh;zn.reduce=yl;zn.reduceRight=wl;zn.repeat=sf;zn.replace=af;zn.result=Eh;zn.round=dd;zn.runInContext=t;zn.sample=xl;zn.size=Ml;zn.snakeCase=cf;zn.some=jl;zn.sortedIndex=bc;zn.sortedIndexBy=gc;zn.sortedIndexOf=kc;zn.sortedLastIndex=yc;zn.sortedLastIndexBy=wc;zn.sortedLastIndexOf=mc;zn.startCase=uf;zn.startsWith=hf;zn.subtract=vd;zn.sum=pd;zn.sumBy=bd;zn.template=ff;zn.times=Qf;zn.toFinite=Nu;zn.toInteger=Xu;zn.toLength=qu;zn.toLower=df;zn.toNumber=Gu;zn.toSafeInteger=Ju;zn.toString=Qu;zn.toUpper=vf;zn.trim=pf;zn.trimEnd=bf;zn.trimStart=gf;zn.truncate=kf;zn.unescape=yf;zn.uniqueId=ed;zn.upperCase=wf;zn.upperFirst=mf;zn.each=ul;zn.eachRight=hl;zn.first=Ja;Ff(zn,function(){var t={};Ar(zn,(function(e,i){if(!he.call(zn.prototype,i)){t[i]=e}}));return t}(),{chain:false});zn.VERSION=n;yi(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){zn[t].placeholder=zn}));yi(["drop","take"],(function(t,e){In.prototype[t]=function(n){n=n===i?1:Pe(Xu(n),0);var r=this.__filtered__&&!e?new In(this):this.clone();if(r.__filtered__){r.__takeCount__=Ue(n,r.__takeCount__)}else{r.__views__.push({size:Ue(n,D),type:t+(r.__dir__<0?"Right":"")})}return r};In.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}));yi(["filter","map","takeWhile"],(function(t,e){var i=e+1,n=i==T||i==$;In.prototype[t]=function(t){var e=this.clone();e.__iteratees__.push({iteratee:Ks(t,3),type:i});e.__filtered__=e.__filtered__||n;return e}}));yi(["head","last"],(function(t,e){var i="take"+(e?"Right":"");In.prototype[t]=function(){return this[i](1).value()[0]}}));yi(["initial","tail"],(function(t,e){var i="drop"+(e?"":"Right");In.prototype[t]=function(){return this.__filtered__?new In(this):this[i](1)}}));In.prototype.compact=function(){return this.filter(Af)};In.prototype.find=function(t){return this.filter(t).head()};In.prototype.findLast=function(t){return this.reverse().find(t)};In.prototype.invokeMap=mo((function(t,e){if(typeof t=="function"){return new In(this)}return this.map((function(i){return Ur(i,t,e)}))}));In.prototype.reject=function(t){return this.filter(Ll(Ks(t)))};In.prototype.slice=function(t,e){t=Xu(t);var n=this;if(n.__filtered__&&(t>0||e<0)){return new In(n)}if(t<0){n=n.takeRight(-t)}else if(t){n=n.drop(t)}if(e!==i){e=Xu(e);n=e<0?n.dropRight(-e):n.take(e-t)}return n};In.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()};In.prototype.toArray=function(){return this.take(D)};Ar(In.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),o=zn[r?"take"+(e=="last"?"Right":""):e],s=r||/^find/.test(e);if(!o){return}zn.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,c=e instanceof In,l=a[0],u=c||cu(e);var h=function(t){var e=o.apply(zn,ji([t],a));return r&&f?e[0]:e};if(u&&n&&typeof l=="function"&&l.length!=1){c=u=false}var f=this.__chain__,d=!!this.__actions__.length,v=s&&!f,p=c&&!d;if(!s&&u){e=p?e:new In(this);var b=t.apply(e,a);b.__actions__.push({func:Nc,args:[h],thisArg:i});return new jn(b,f)}if(v&&p){return t.apply(this,a)}b=this.thru(h);return v?r?b.value()[0]:b.value():b}}));yi(["pop","push","shift","sort","splice","unshift"],(function(t){var e=se[t],i=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);zn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var r=this.value();return e.apply(cu(r)?r:[],t)}return this[i]((function(i){return e.apply(cu(i)?i:[],t)}))}}));Ar(In.prototype,(function(t,e){var i=zn[e];if(i){var n=i.name+"";if(!he.call(li,n)){li[n]=[]}li[n].push({name:e,func:i})}}));li[ys(i,g).name]=[{name:"wrapper",func:i}];In.prototype.clone=Sn;In.prototype.reverse=_n;In.prototype.value=Tn;zn.prototype.at=Xc;zn.prototype.chain=qc;zn.prototype.commit=Gc;zn.prototype.next=Zc;zn.prototype.plant=Qc;zn.prototype.reverse=tl;zn.prototype.toJSON=zn.prototype.valueOf=zn.prototype.value=el;zn.prototype.first=zn.prototype.head;if(Ie){zn.prototype[Ie]=Jc}return zn};var xn=mn();if(ai){(ai.exports=xn)._=xn;si._=xn}else{oi._=xn}}).call(tt)})(Q,Q.exports);return Q.exports}var nt=it();class rt{_core;_debounceUpdate;_debounceEndScaling;initialTouchDistance=0;startX=0;startY=0;constructor(t,e){this._core=t;this._core.store.state.host=e;this._core.store.state.viewportWidth=e.clientWidth;this._core.store.state.viewportHeight=e.clientHeight;this._core.store.state.startX=0;this._core.store.state.startY=0;this._core.store.state.translateX=0;this._core.store.state.translateY=0;this._debounceUpdate=nt.debounce((()=>{this._core.updateWorkspaceViewport(this._core.store.state.translateX,this._core.store.state.translateY,this._core.store.state.scale)}),300);this._debounceEndScaling=nt.debounce((()=>{this._core.store.state.isScaling=false;this._core.rerender()}),100)}handleResize(){this._core.store.state.viewportWidth=this._core.store.state.host.clientWidth;this._core.store.state.viewportHeight=this._core.store.state.host.clientHeight;this._core.store.state.hasViewportChanged=true;this._core.rerender()}handlePointerDown(t){if(t.pointerType==="mouse"){const e=t.clientX-this._core.store.offsetX;const i=t.clientY-this._core.store.offsetY;if(t.button===c.Right){this._core.store.state.isPanning=true;this._core.store.state.startX=e;this._core.store.state.startY=i}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===2){const e=this._core.store.currentPath;if(e){this._core.store.state.objectsMap.remove((t=>t.id===e.id))}this._core.store.state.isScaling=true;const i=t[0].clientX-this._core.store.offsetX;const n=t[0].clientY-this._core.store.offsetY;const r=t[1].clientX-this._core.store.offsetX;const o=t[1].clientY-this._core.store.offsetY;this.initialTouchDistance=Math.sqrt(Math.pow(i-r,2)+Math.pow(n-o,2));this.startX=(i+r)/2;this.startY=(n+o)/2;this._core.rerender()}}}handlePointerMove(t){if(t.pointerType==="mouse"){const e=this._core.store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;this._core.store.state.pointerX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this._core.store.state.pointerY=(n-this._core.store.state.translateY)/this._core.store.state.scale;if(this._core.store.state.isPanning){const t=i-this._core.store.state.startX;const e=n-this._core.store.state.startY;this._core.store.state.translateX+=t;this._core.store.state.translateY+=e;this._core.store.state.startX=i;this._core.store.state.startY=n;this._core.store.state.hasViewportChanged=true;this._core.store.state.skipContextMenu=true;this._core.rerender();this._debounceUpdate()}}if(t.pointerType==="touch"){const e=this._core.store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;this._core.store.state.pointerX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this._core.store.state.pointerY=(n-this._core.store.state.translateY)/this._core.store.state.scale;const r=Array.from(this._core.store.state.pointers.values());if(r.length===2){const t=r[0].clientX-this._core.store.offsetX;const e=r[0].clientY-this._core.store.offsetY;const i=r[1].clientX-this._core.store.offsetX;const n=r[1].clientY-this._core.store.offsetY;const o=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-n,2));const s=(t+i)/2;const a=(e+n)/2;const c=o/this.initialTouchDistance;const l=this._core.store.state.scale*c;if(l>this._core.store.state.scaleMax||l<this._core.store.state.scaleMin){this._core.store.state.translateX=this._core.store.state.translateX+s-this.startX;this._core.store.state.translateY=this._core.store.state.translateY+a-this.startY}else{const t=(s-this._core.store.state.translateX)*(c-1);const e=(a-this._core.store.state.translateY)*(c-1);this._core.store.state.translateX=this._core.store.state.translateX+s-this.startX-t;this._core.store.state.translateY=this._core.store.state.translateY+a-this.startY-e;this._core.store.state.scale=l;this.initialTouchDistance=o}this.startX=s;this.startY=a;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate()}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isPanning){this._core.store.state.isPanning=false;this._core.rerender()}}if(t.pointerType==="touch"){if(this._core.store.state.pointers.size===0){this._debounceEndScaling()}}}handleWheel(t){t.preventDefault();if(t.ctrlKey===true&&Math.abs(t.deltaY)>0&&Math.abs(t.deltaX)===0){this.handleZoom(t)}if(!t.ctrlKey){this.handlePan(t)}}centerInViewport(t){const{scale:e,viewportWidth:i,viewportHeight:n}=this._core.store.state;const{x:r,y:o,width:s,height:a}=t.rotatedBoundingBox;const c=r+s/2;const l=o+a/2;this._core.store.state.translateX=i/2-c*e;this._core.store.state.translateY=n/2-l*e;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate()}centerFitInViewport(t){const e=this._core.store.state.viewportWidth/(t.rotatedBoundingBox.width*1.1);const i=this._core.store.state.viewportHeight/(t.rotatedBoundingBox.height*1.1);const n=Math.min(e,i,this._core.store.state.scaleMax);const r=Math.max(n,this._core.store.state.scaleMin);this._core.store.state.scale=r;this.centerInViewport(t)}handleZoom(t){this._core.store.state.isScaling=true;const e=this._core.store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;this._core.store.state.pointerX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this._core.store.state.pointerY=(n-this._core.store.state.translateY)/this._core.store.state.scale;const r=1+t.deltaY*-.012;const o=Math.max(.8,Math.min(1.2,r));const s=Math.min(this._core.store.state.scaleMax,Math.max(this._core.store.state.scaleMin,this._core.store.state.scale*o));const a=s/this._core.store.state.scale;const c=(i-this._core.store.state.translateX)*(a-1);const l=(n-this._core.store.state.translateY)*(a-1);this._core.store.state.scale=s;this._core.store.state.translateX=this._core.store.state.translateX-c;this._core.store.state.translateY=this._core.store.state.translateY-l;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate();this._debounceEndScaling()}handlePan(t){const e=.8;this._core.store.state.translateX=this._core.store.state.translateX-t.deltaX*e;this._core.store.state.translateY=this._core.store.state.translateY-t.deltaY*e;this._core.store.state.hasViewportChanged=true;this._core.rerender();this._debounceUpdate()}}class ot extends b{shortcuts=[{key:"Escape",condition:t=>!!t.store.selectionGroup,action:t=>t.clearSelection()},{key:"Delete",condition:t=>!!t.store.selectionGroup,action:t=>t.delete()},{key:"z",ctrl:true,action:t=>t.undo()},{key:"y",ctrl:true,action:t=>t.redo()},{key:"s",ctrl:true,action:()=>this.switchTool("selection")},{key:"b",ctrl:true,action:()=>this.switchTool("brush")},{key:"e",ctrl:true,action:()=>this.switchTool("eraser")},{key:"i",ctrl:true,action:()=>this.switchTool("image")},{key:"x",ctrl:true,action:()=>this.switchTool("text")},{key:"c",ctrl:true,condition:t=>!!t.store.selectionGroup,action:t=>{t.copy();t.rerender()}},{key:"v",ctrl:true,condition:t=>!!t.store.state.copiedObjects&&!t.store.activeText,action:t=>t.paste()},{key:"+",ctrl:true,condition:t=>!!t.store.selectionGroup,action:t=>t.bringForward()},{key:"-",ctrl:true,condition:t=>!!t.store.selectionGroup,action:t=>t.sendBackward()},{key:"*",shift:true,condition:t=>!!t.store.selectionGroup,action:t=>t.bringToFront()},{key:"_",shift:true,condition:t=>!!t.store.selectionGroup,action:t=>t.sendToBack()}];constructor(t){super(t)}switchTool(t){const e=g.getTool(t);this._core.store.setState("activeTool",e);this._core.deselectAllObjects();e.onActivate()}handleKeyDown(t){this._core.store.state.isCtrlKeyPressed=t.ctrlKey;const e=this.shortcuts.find((e=>e.key===t.key&&!!e.ctrl===t.ctrlKey&&!!e.shift===t.shiftKey&&(!e.condition||e.condition(this._core))));if(e){t.preventDefault();e.action(this._core)}}handleKeyUp(t){this._core.store.state.isCtrlKeyPressed=t.ctrlKey}}class st extends b{globalContextMenuItems=[];objectContextMenuItems=[];constructor(t,e,i){super(t);this.globalContextMenuItems=e;this.objectContextMenuItems=i}handleContextMenu(t){if(!(this._core.store.state.activeTool instanceof l)){return}if(this._core.store.state.skipContextMenu){this._core.store.state.skipContextMenu=false;return}const e=this._core.store.state.activeTool;e?.moveHandler?.cancelPendingDrag();if(this._core.store.selectionBox){this._core.store.state.objectsMap.remove((t=>t instanceof k));this._core.store.state.isSelecting=false}const i=this._core.getObjectFromPointerEvent(t,".object");if(i&&!(i instanceof y)&&!(i instanceof k)){const t=y.create(this._core);t.addOrRemove(i);t.isSelected=true;t.rotation=i.rotation;this._core.store.state.isSelecting=false;const e=this._core.store.selectionGroup;if(e){this._core.removeSelectionGroup()}this._core.addSelectionGroup(t);this._core.rerender()}this._core.store.state.contextMenuItems=this._core.store.selectionGroup?this.objectContextMenuItems:this.globalContextMenuItems;let n=t.clientX-this._core.store.offsetX;let r=t.clientY-this._core.store.offsetY;const o=150;const s=200;const a=10;if(n+o>window.innerWidth-a){n=window.innerWidth-o-a}if(r+s>window.innerHeight-a){r=window.innerHeight-s-a}n=Math.max(a,n);r=Math.max(a,r);this._core.store.state.contextMenuX=n;this._core.store.state.contextMenuY=r;this._core.store.state.isContextMenuVisible=true;this._core.store.state.isEnabled=false;this._core.rerender()}}class at{static isInstanceOf(t,e){return!!t&&t.__class__===e}}const ct={activeWorkspace:null,activeTool:null,copiedObjects:null,objectsMap:null,resizeHandleType:null,hasViewportChanged:false,hasObjectsChanged:false,isReady:false,isEnabled:true,isScaling:false,isPanning:false,isSelecting:false,isResizing:false,isResizeHandleSelected:false,isRotating:false,isRotationHandleSelected:false,isDragging:false,isDrawing:false,isErasing:false,isWriting:false,isCtrlKeyPressed:false,isContextMenuVisible:false,contextMenuItems:[],contextMenuX:0,contextMenuY:0,skipContextMenu:false,debugInfo:{showObjectInfo:false,showViewportInfo:false},host:null,pointerX:0,pointerY:0,scale:1,scaleMax:1,scaleMin:1,startX:0,startY:0,translateX:0,translateXMax:400,translateXMin:0,translateY:0,translateYMax:400,translateYMin:0,viewportWidth:0,viewportHeight:0,longTouchTimeout:null,longTouchDelay:300,pointers:new Map,workspaces:[]};class lt extends w{__class__="KritzelCustomElement";element;isInteractive=true;constructor(t){super();if(t){this.translateX=t.translateX||0;this.translateY=t.translateY||0;this.scale=t.scale||1;this.element=t.element;this.height=t.height||0;this.width=t.width||0}}static create(t,e){const i=new lt(e);i._core=t;i.id=i.generateId();i.workspaceId=t.store.state.activeWorkspace.id;return i}mount(t){if(t===null){return}if(this.isMounted&&this.elementRef===t&&this.element.parentElement===t){return}this.elementRef=t;this.isMounted=true;this.elementRef.innerHTML="";this.elementRef.appendChild(this.element)}resize(t,e,i,n){if(i<=1||n<=1){return}this.width=i;this.height=n;this.translateX=t;this.translateY=e;if(this.element){this.element.style.width=`${i}px`;this.element.style.height=`${n}px`}this._core.store.state.objectsMap.update(this)}copy(){const t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this);t.id=this.generateId();t.isMounted=false;t.element=this.element.cloneNode(true);return t}}class ut{_core;constructor(t){this._core=t}revive(t){if(t&&typeof t==="object"){if(t.__class__){let e;switch(t.__class__){case"KritzelPath":e=z.create(this._core).deserialize(t);break;case"KritzelText":e=x.create(this._core,t.fontSize,t.fontFamily).deserialize(t);break;case"KritzelImage":e=m.create(this._core).deserialize(t);break;case"KritzelCustomElement":e=lt.create(this._core).deserialize(t);break;case"KritzelSelectionGroup":e=y.create(this._core).deserialize(t);break;case"KritzelWorkspace":e=v.create(this._core,t).deserialize(t);break;case"KritzelBrushTool":e=new s(this._core);break;case"KritzelEraserTool":e=new h(this._core);break;case"KritzelImageTool":e=new d(this._core);break;case"KritzelSelectionTool":e=new l(this._core);break;case"KritzelTextTool":e=new a(this._core);break;default:e=t}return e}const e=Array.isArray(t)?[]:{};for(const i in t){if(Object.prototype.hasOwnProperty.call(t,i)){e[i]=this.revive(t[i])}}return e}return t}}class ht{map;_ydoc=null;_objectsMap=null;_providers=[];_undoManager=null;_reviver=null;_core=null;_workspaceId=null;_isReady=false;_temporaryItemsCount=0;get isReady(){return this._isReady}get undoManager(){return this._undoManager}get workspaceId(){return this._workspaceId}constructor(){this.map=new Map}async initialize(t,e,i){this._core=t;this._workspaceId=e;this._reviver=new ut(t);this._ydoc=new C;this._objectsMap=this._ydoc.getMap("objects");const n=`kritzel-workspace-${e}`;const r=i??M;for(const t of r.providers){let e;if(typeof t==="function"){e=new t(n,this._ydoc)}else{e=t.create(n,this._ydoc)}this._providers.push(e)}this._undoManager=new j([this._objectsMap],{captureTimeout:200,trackedOrigins:new Set(["local","temporary"]),ignoreRemoteMapChanges:true});this._undoManager.on("stack-item-added",(t=>{if(t.type==="undo"){if(t.origin==="temporary"){this._temporaryItemsCount++}}}));this._undoManager.on("stack-item-popped",(t=>{if(t.type==="undo"){if(t.origin==="temporary"&&this._temporaryItemsCount>0){this._temporaryItemsCount--}}}));this._objectsMap.observe((t=>{this.handleObjectsChange(t)}));await Promise.all(this._providers.map((t=>t.connect())));this._isReady=true;this.loadFromYjs()}handleObjectsChange(t){if(t.transaction.origin==="local"||t.transaction.origin==="temporary"){this._core?.rerender();return}const e=Array.from(t.keysChanged);const i=[];const n=[];const r=[];e.forEach((e=>{const o=t.changes.keys.get(e);if(o&&o.action==="delete"){r.push(e)}else{const t=this._objectsMap.get(e);if(t){const e=this._reviver.revive(t);if(e instanceof y){n.push(e)}else{i.push(e)}}}}));r.forEach((t=>{this.map.delete(t)}));i.forEach((t=>{this.map.set(t.id,t)}));n.forEach((t=>{this.map.set(t.id,t)}));this._core?.rerender()}transaction(t){if(this._ydoc){this._ydoc.transact(t,"local")}}loadFromYjs(){if(!this._objectsMap||!this._reviver){return}this.map.clear();this._objectsMap.forEach(((t,e)=>{const i=this._reviver.revive(t);this.map.set(e,i)}))}reset(){this.map.clear();this._ydoc.transact((()=>{this._objectsMap.clear()}),"local")}insert(t){if(!t.id){return false}this.map.set(t.id,t);if(this._objectsMap&&this.isPersistable(t)){const e=t.serialize();this._ydoc.transact((()=>{this._objectsMap.set(t.id,e)}),"local")}return true}update(t,e={}){if(!t.id||!this.map.has(t.id)){return false}this.map.set(t.id,t);if(this._objectsMap&&this.isPersistable(t)){const i=t.serialize();const n=e.temporary?"temporary":"local";this._ydoc.transact((()=>{this._objectsMap.set(t.id,i)}),n)}return true}remove(t){for(const[e,i]of this.map){if(t(i)){this.map.delete(e);if(this._objectsMap&&this.isPersistable(i)){this._ydoc.transact((()=>{this._objectsMap.delete(e)}),"local")}}}}filter(t){const e=[];for(const i of this.map.values()){if(t(i)){e.push(i)}}return e}allObjects(){return Array.from(this.map.values())}isPersistable(t){if(t instanceof k){return false}return true}undo(){if(this._undoManager&&this._undoManager.canUndo()){this._undoManager.undo()}}redo(){if(this._undoManager&&this._undoManager.canRedo()){this._undoManager.redo()}}canUndo(){return this._undoManager?this._undoManager.canUndo():false}canRedo(){return this._undoManager?this._undoManager.canRedo():false}clearHistory(){if(this._undoManager){this._undoManager.clear();this._temporaryItemsCount=0}}consolidateTemporaryItems(){if(!this._undoManager||this._temporaryItemsCount===0){return}const t=this._undoManager.undoStack.length;if(t===0){this._temporaryItemsCount=0;return}this._undoManager.stopCapturing();const e=Math.min(this._temporaryItemsCount,t);if(e>1){for(let t=0;t<e;t++){if(this._undoManager.canUndo()){this._undoManager.undo()}}this._ydoc.transact((()=>{for(let t=e-1;t>=0;t--){if(this._undoManager.canRedo()){this._undoManager.redo()}}}),"local")}this._temporaryItemsCount=0}clearTemporaryItems(){if(!this._undoManager||this._temporaryItemsCount===0){return}const t=this._undoManager.undoStack.length;const e=Math.min(this._temporaryItemsCount,t);for(let t=0;t<e;t++){if(this._undoManager.undoStack.length>0){this._undoManager.undoStack.pop()}}this._temporaryItemsCount=0}destroy(){this._providers.forEach((t=>t.destroy()));this._providers=[];if(this._ydoc){this._ydoc.destroy()}this.map.clear()}}class ft{_state;_listeners=new Map;get state(){return this._state}get currentZIndex(){return Math.max(0,...this._state.objectsMap.filter((t=>!(t instanceof y)&&!(t instanceof k))).map((t=>t.zIndex)))+1}get allObjects(){return this._state.objectsMap.allObjects()}get allNonSelectionObjects(){return this._state.objectsMap.allObjects().filter((t=>!(t instanceof y)&&!(t instanceof k)))}get selectedObjects(){return this.allObjects.filter((t=>!(t instanceof y))).filter((t=>t.isSelected))}get selectionBox(){const t=this._state.objectsMap.filter((t=>t instanceof k));return t.length>0?t[0]:null}get selectionGroup(){const t=this._state.objectsMap.filter((t=>t instanceof y));return t.length>0?t[0]:null}get activeText(){const t=this._state.objectsMap.filter((t=>t instanceof x&&t.isEditing));return t.length>0?t[0]:null}get currentPath(){const t=this._state.objectsMap.filter((t=>t instanceof z&&t.isCompleted===false));return t.length>0?t[0]:null}get offsetX(){return this._state.host.getBoundingClientRect().left}get offsetY(){return this._state.host.getBoundingClientRect().top}get isDisabled(){return this._state.isEnabled===false||this._state.isReady===false||this._state.activeWorkspace===null}constructor(t){this._state=t;this._state.objectsMap=new ht}onStateChange(t,e){if(!this._listeners.has(t)){this._listeners.set(t,new Set)}this._listeners.get(t).add(e)}getState(t){return this._state[t]}setState(t,e){const i=this._state[t];if(i!==e){this._state[t]=e;if(this._listeners.has(t)){this._listeners.get(t).forEach((n=>n(e,i,String(t))))}}}}class dt{_kritzelEngine;_store;_syncConfig;_appStateMap;get engine(){return this._kritzelEngine}get store(){return this._store}get appStateMap(){return this._appStateMap}constructor(t){this._kritzelEngine=t;this._store=new ft(ct);this._appStateMap=new I}setSyncConfig(t){this._syncConfig=t}async initializeYjs(){await this._appStateMap.initialize(this,this._syncConfig)}loadWorkspacesFromAppState(){return this._appStateMap.allWorkspaces()}saveWorkspaceToAppState(t){if(this._appStateMap.has(t.id)){this._appStateMap.update(t)}else{this._appStateMap.insert(t)}}deleteWorkspaceFromAppState(t){this._appStateMap.remove((e=>e.id===t))}async initializeWorkspace(t){const e=this.loadWorkspacesFromAppState();const i=e.length>0?[...e].sort(((t,e)=>e.updatedAt.getTime()-t.updatedAt.getTime()))[0]:null;let n;if(t){n=t;const i=e.find((e=>e.id===t.id));if(!i){n._core=this;this.saveWorkspaceToAppState(n)}}else if(i){n=i}else{n=new v(S.generateUUID(),"New Workspace");n._core=this;this.saveWorkspaceToAppState(n)}if(this._store.state.objectsMap&&this._store.state.objectsMap.isReady){this._store.state.objectsMap.destroy()}this._store.state.activeWorkspace=n;this._store.state.workspaces=this.loadWorkspacesFromAppState();const r=n.viewport??{translateX:0,translateY:0,scale:1};this._store.state.translateX=r.translateX??0;this._store.state.translateY=r.translateY??0;this._store.state.scale=r.scale??1;const o=new ht;await o.initialize(this,n.id,this._syncConfig);this._store.state.objectsMap=o;this.rerender()}rerender(){if(this._kritzelEngine){this._kritzelEngine.forceUpdate++}}findObjectById(t){for(const e of this._store.allObjects){if(e.id===t){return e}}return null}getWorkspaces(){return this.loadWorkspacesFromAppState()}createWorkspace(t){t._core=this;t.createdAt=new Date;t.updatedAt=new Date;this.saveWorkspaceToAppState(t);this._store.state.workspaces=this.loadWorkspacesFromAppState()}updateWorkspace(t){t.updatedAt=new Date;this.saveWorkspaceToAppState(t);const e=this._store.state.workspaces;const i=e.findIndex((e=>e.id===t.id));if(i!==-1){e[i]=t;this._store.state.workspaces=e}}deleteWorkspace(t){if(this._store.state.activeWorkspace?.id===t.id){this._store.state.objectsMap?.destroy()}this.deleteWorkspaceFromAppState(t.id);this._store.state.workspaces=this.loadWorkspacesFromAppState();const e=`kritzel-workspace-${t.id}`;window.indexedDB.deleteDatabase(e)}updateWorkspaceViewport(t,e,i){const n=this._store.state.activeWorkspace;if(!n){return}n.viewport={translateX:t,translateY:e,scale:i};n.updatedAt=new Date;this.saveWorkspaceToAppState(n)}addObject(t){this._store.state.objectsMap.insert(t)}removeObject(t){t.isMounted=false;this._store.state.objectsMap.remove((e=>e.id===t.id))}updateObject(t,e){for(const i in e){if(e.hasOwnProperty(i)){t[i]=e[i]}}this._store.state.objectsMap.update(t)}addSelectionGroup(t){this.removeSelectionGroup();this.removeSelectionBox();this._store.state.objectsMap.insert(t)}removeSelectionGroup(){const t=this._store.selectionGroup;if(t){this._store.state.objectsMap.remove((e=>e.id===t.id))}}removeSelectionBox(){const t=this._store.selectionBox;if(t){this._store.state.objectsMap.remove((e=>e.id===t.id))}}deselectAllObjects(){this.removeSelectionGroup();this.rerender()}delete(){const t=this._store.selectionGroup;if(!t){return}t.objects.forEach((t=>this.removeObject(t)));this.removeSelectionGroup();this.rerender()}undo(){this._store.state.objectsMap?.undo()}redo(){this._store.state.objectsMap?.redo()}deleteObject(t){const e=this.findObjectById(t);if(e){this.removeObject(e);this.rerender()}}copy(){const t=this._store.selectionGroup;if(t){this._store.state.copiedObjects=t.objects.sort(((t,e)=>t.zIndex-e.zIndex)).map((t=>t.copy()))}}paste(t,e){const i=this._store.state.copiedObjects;if(!i||i.length===0){return}const n=this._store.state.activeWorkspace;const r=i.some((t=>t.workspaceId!==n.id));const o=Math.min(...i.map((t=>t.translateX)));const s=Math.min(...i.map((t=>t.translateY)));let a;let c;if(t!==undefined&&e!==undefined){a=t;c=e}else if(r){a=o;c=s}else{a=o+25/this._store.state.scale;c=s+25/this._store.state.scale}const l=a-o;const u=c-s;this.removeSelectionGroup();this.removeSelectionBox();const h=y.create(this);i.forEach(((t,e)=>{if(t.workspaceId!==n.id){t.workspaceId=n.id}t.updatePosition(t.translateX+l,t.translateY+u);t.zIndex=this._store.currentZIndex+e;this.addObject(t);h.addOrRemove(t)}));h.isSelected=true;if(i.length===1){h.rotation=i[0].rotation}this.addSelectionGroup(h);if(r){if(t!==undefined&&e!==undefined){h.updatePosition(t,e)}else{h.centerInViewport()}this.engine.viewport.centerFitInViewport(h)}this._store.state.isSelecting=false;const f=this._store.selectionGroup;if(f){this._store.state.copiedObjects=f.objects.sort(((t,e)=>t.zIndex-e.zIndex)).map((t=>t.copy()))}this._store.setState("activeTool",g.getTool("selection"));this.rerender()}bringForward(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=n.length>0?Math.max(...n.map((t=>t.zIndex)))+1:0;i.forEach((t=>{if(t.zIndex!==r){this.updateObject(t,{zIndex:t.zIndex+1})}}));this.rerender()}sendBackward(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=n.length>0?Math.min(...n.map((t=>t.zIndex)))-1:0;i.forEach((t=>{if(t.zIndex!==r){this.updateObject(t,{zIndex:t.zIndex-1})}}));this.rerender()}bringToFront(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=Math.max(...n.map((t=>t.zIndex)))+1;i.forEach((t=>{this.updateObject(t,{zIndex:r})}));this.rerender()}sendToBack(t){const e=this._store.selectionGroup;const i=t?[t]:e?.objects||[];const n=this._store.allNonSelectionObjects.filter((t=>i.findIndex((e=>e.id===t.id))===-1));const r=Math.min(...n.map((t=>t.zIndex)))-1;i.forEach((t=>{this.updateObject(t,{zIndex:r})}));this.rerender()}selectObjects(t){if(t.length===0){return}const e=y.create(this);t.forEach((t=>{t.isSelected=false;e.addOrRemove(t)}));e.isSelected=true;if(t.length===1){e.rotation=e.objects[0].rotation}this.addSelectionGroup(e);this.rerender()}selectAllObjectsInViewport(){const t=this._store.state.objectsMap.filter((t=>t.isInViewport())).filter((t=>!(t instanceof y)&&!(t instanceof k)&&!(t instanceof F)));if(t.length>0){const e=y.create(this);t.forEach((t=>{t.isSelected=false;e.addOrRemove(t)}));e.isSelected=true;this._store.state.isSelecting=false;if(t.length===1){e.rotation=e.objects[0].rotation}this.addSelectionGroup(e);this._store.setState("activeTool",g.getTool("selection"));this.rerender()}}clearSelection(){this.removeSelectionGroup();this._store.state.objectsMap.remove((t=>t instanceof k||t instanceof y));this._store.state.isSelecting=false;this._store.state.isResizeHandleSelected=false;this._store.state.isRotationHandleSelected=false;this.rerender()}resetActiveText(){const t=this._store.activeText;if(t){if(t.isEmpty){this.deleteObject(t.id)}else{t.save()}}}getObjectFromPointerEvent(t,e=".object"){const i=this._store.state.host?.shadowRoot;if(!i)return null;const n=t.clientX;const r=t.clientY;const o=i.elementFromPoint(n,r);if(!o)return null;const s=o.closest(e);if(s){const t=this._store.allObjects.find((t=>s.id===t.id));const e=t?.hitTest(n,r);return e?t:null}return null}getObjectsFromPointerEvent(t,e=".object"){const i=this._store.state.host?.shadowRoot;if(!i)return[];const n=t.clientX;const r=t.clientY;const o=i.elementsFromPoint(n,r);if(!o||o.length===0)return[];const s=new Set;o.forEach((t=>{const i=t.closest(e);if(i&&i.id){s.add(i.id)}}));if(s.size>0){return this._store.allObjects.filter((t=>s.has(t.id))).sort(((t,e)=>e.zIndex-t.zIndex))}return[]}getCanvasPoint(t){if(!this._store.state.host){return{x:0,y:0}}const e=this._store.state.host.getBoundingClientRect();const i=t.clientX-e.left;const n=t.clientY-e.top;const r=i-this._store.state.translateX;const o=n-this._store.state.translateY;const s=r/this._store.state.scale;const a=o/this._store.state.scale;return{x:s,y:a}}beforeWorkspaceChange(){this.resetActiveText();this.clearSelection();this._store.setState("activeTool",g.getTool("selection"))}}const vt=":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}";const pt=class{get host(){return r(this)}workspace;syncConfig;onWorkspaceChange(t){const e=this.core.store.state.activeWorkspace?.id;const i=t?.id;if(e!==i){this.core.beforeWorkspaceChange();this.core.initializeWorkspace(t)}}activeTool;globalContextMenuItems;objectContextMenuItems;scaleMax=q;validateScaleMax(t){if(t>q){console.warn(`scaleMax cannot be greater than ${q}.`);this.scaleMax=q;this.core.store.state.scaleMax=this.scaleMax}else{this.core.store.state.scaleMax=t}}scaleMin=G;validateScaleMin(t){if(t<G){console.warn(`scaleMin cannot be less than ${G}.`);this.scaleMin=G;this.core.store.state.scaleMin=this.scaleMin}else{this.core.store.state.scaleMin=t}}isEngineReady;activeToolChange;workspacesChange;longpress;forceUpdate=0;throttledWheel=nt.throttle((t=>{this.viewport.handleWheel(t);this.core.store.state?.activeTool?.handleWheel(t)}),16);handleWheel(t){if(this.core.store.isDisabled){return}if(this.core.store.state.isContextMenuVisible){this.hideContextMenu()}this.throttledWheel(t)}handlePointerDown(t){if(this.core.store.isDisabled){return}if(o.isTouchDevice()){_.onLongPress(t,(t=>this.longpress.emit(t)))}this.host.setPointerCapture(t.pointerId);this.core.store.state.pointers.set(t.pointerId,t);this.viewport.handlePointerDown(t);this.core.store.state?.activeTool?.handlePointerDown(t)}throttledPointerMoveMulti=nt.throttle((t=>{this.viewport.handlePointerMove(t);this.core.store.state?.activeTool?.handlePointerMove(t)}),16);handlePointerMove(t){if(this.core.store.isDisabled){return}this.core.store.state.pointers.set(t.pointerId,t);if(this.core.store.state.pointers.size>1){this.throttledPointerMoveMulti(t)}this.viewport.handlePointerMove(t);this.core.store.state?.activeTool?.handlePointerMove(t)}handlePointerUp(t){if(this.core.store.isDisabled){return}this.core.store.state.pointers.delete(t.pointerId);this.host.releasePointerCapture(t.pointerId);this.viewport.handlePointerUp(t);this.core.store.state?.activeTool?.handlePointerUp(t)}handlePointerCancel(t){if(this.core.store.isDisabled){return}this.host.releasePointerCapture(t.pointerId);this.core.store.state.pointers.delete(t.pointerId);this.viewport.handlePointerUp(t);this.core.store.state?.activeTool?.handlePointerUp(t)}handleLongPress(t){this.contextMenuHandler.handleContextMenu(t.detail)}handleContextMenu(t){t.preventDefault();if(this.core.store.isDisabled){return}if(t.pointerType==="touch"){return}this.contextMenuHandler.handleContextMenu(t)}handleResize(){this.viewport.handleResize()}handleKeyDown(t){if(this.core.store.isDisabled){return}this.keyHandler.handleKeyDown(t)}handleKeyUp(t){if(this.core.store.isDisabled){return}this.keyHandler.handleKeyUp(t)}preventDoubleTapZoomOnTouchDevices(t){t.preventDefault()}async registerTool(t,e,i){if(typeof e!=="function"||!(e.prototype instanceof T)){console.error(`Failed to register tool "${t}": Tool class must be a constructor function`);return null}const n=g.registerTool(t,e,this.core);if(i){Object.entries(i).forEach((([t,e])=>{n[t]=e}))}return Promise.resolve(n)}async changeActiveTool(t){this.core.store.state.activeTool?.onDeactivate();this.core.store.setState("activeTool",t);this.core.deselectAllObjects();t?.onActivate()}async disable(){this.core.store.state.isEnabled=false;this.core.rerender()}async enable(){this.core.store.state.isEnabled=true;this.core.rerender()}async delete(){this.core.delete()}async copy(){this.core.copy()}async paste(t,e){this.core.paste(t,e)}async bringForward(t){this.core.bringForward(t)}async sendBackward(t){this.core.sendBackward(t)}async bringToFront(t){this.core.bringToFront(t)}async sendToBack(t){this.core.sendToBack(t)}async undo(){this.core.undo()}async redo(){this.core.redo()}async hideContextMenu(){this.core.store.state.pointers.clear();this.core.store.state.isContextMenuVisible=false;this.core.store.state.objectsMap.remove((t=>t instanceof k));this.core.store.state.isSelecting=false;this.core.store.state.isEnabled=true;this.core.rerender()}async getObjectById(t){const e=this.core.store.allObjects.find((e=>e.id===t));return e||null}async addObject(t){this.core.deselectAllObjects();t.id=t.generateId();t._core=this.core;t.scale=t.scale?t.scale:this.core.store.state.scale;t.zIndex=this.core.store.currentZIndex;this.core.addObject(t);this.core.rerender();return t}async updateObject(t,e){this.core.deselectAllObjects();this.core.updateObject(t,e);this.core.rerender();return t}async removeObject(t){this.core.deselectAllObjects();this.core.removeObject(t);this.core.rerender();return t}async getSelectedObjects(){const t=this.core.store.selectionGroup;return t?t.objects:[]}async selectObjects(t){this.core.store.state.activeTool?.onDeactivate();this.core.store.setState("activeTool",g.getTool("selection"));this.core.deselectAllObjects();this.core.selectObjects(t)}async selectAllObjectsInViewport(){this.core.store.state.activeTool?.onDeactivate();this.core.store.setState("activeTool",g.getTool("selection"));this.core.deselectAllObjects();this.core.selectAllObjectsInViewport()}async clearSelection(){this.core.clearSelection()}async centerObjectInViewport(t){t.centerInViewport();this.core.updateObject(t,t);this.core.rerender();return t}async getCopiedObjects(){return this.core.store.state.copiedObjects||[]}async createWorkspace(t){await this.core.createWorkspace(t);this.workspacesChange.emit(this.core.store.state.workspaces);return t}async updateWorkspace(t){await this.core.updateWorkspace(t);this.workspacesChange.emit(this.core.store.state.workspaces)}async deleteWorkspace(t){await this.core.deleteWorkspace(t);this.workspacesChange.emit(this.core.store.state.workspaces)}async getWorkspaces(){return await this.core.getWorkspaces()}async getActiveWorkspace(){return this.core.store.state.activeWorkspace}core;viewport;contextMenuHandler;keyHandler;contextMenuElement=null;get isSelecting(){return this.core.store.state.activeTool instanceof l&&this.core.store.state.isSelecting}get isSelectionActive(){return this.core.store.state.activeTool instanceof l&&this.core.store.selectionGroup!==null}constructor(e){t(this,e);this.isEngineReady=n(this,"isEngineReady");this.activeToolChange=n(this,"activeToolChange");this.workspacesChange=n(this,"workspacesChange");this.longpress=n(this,"longpress");this.core=new dt(this)}disconnectedCallback(){this.throttledWheel.cancel();this.throttledPointerMoveMulti.cancel()}componentWillLoad(){this.validateScaleMax(this.scaleMax);this.validateScaleMin(this.scaleMin)}async componentDidLoad(){this.contextMenuHandler=new st(this.core,this.globalContextMenuItems,this.objectContextMenuItems);this.keyHandler=new ot(this.core);this.viewport=new rt(this.core,this.host);if(this.syncConfig){this.core.setSyncConfig(this.syncConfig)}await this.core.initializeYjs();await this.core.initializeWorkspace(this.workspace);this.core.appStateMap.onRemoteChange((()=>{this.workspacesChange.emit(this.core.store.state.workspaces)}));this._registerStateChangeListeners();if(this.core.store.state.isReady===false){this.core.store.state.isReady=true;this.isEngineReady.emit(this.core.store.state)}}_registerStateChangeListeners(){this.core.store.onStateChange("activeTool",this._handleActiveToolChange.bind(this))}_handleActiveToolChange(t){if(!(t instanceof l)){this.core.clearSelection();this.core.store.state.objectsMap.remove((t=>t instanceof k));this.core.store.state.isSelecting=false;this.core.store.state.isResizeHandleSelected=false;this.core.store.state.isRotationHandleSelected=false}this.core.store.state.skipContextMenu=false;this.core.store.state.copiedObjects=null;this.activeToolChange.emit(t);p.forceHideKeyboard();this.core.rerender()}render(){const t=window.getComputedStyle(this.host);const n=t.getPropertyValue("--kritzel-selection-handle-size").trim()||"6px";const r=parseFloat(n);const s=r*2<14?14:r;const a=this.core.store.state.viewportWidth/2+this.core.store.state.translateX;const c=this.core.store.state.viewportHeight/2+this.core.store.state.translateY;const l=this.core.store.state.objectsMap.allObjects().filter((t=>t.isInViewport()));return e(i,{key:"606a74a14c90cd906800b13ea7b2d3c0f66027f9"},e("div",{key:"16bbc31eb41a73b7bf4a93ee03326f737ae5e913",class:"debug-panel",style:{display:this.core.store.state.debugInfo.showViewportInfo?"block":"none"}},e("div",{key:"fe676e4d3c0819aaba3c11ed59a228d13b07f230"},"ActiveWorkspaceId: ",this.core.store.state?.activeWorkspace?.id),e("div",{key:"509fa7ffadb00292cb1eac48299441f6c02c0b41"},"ActiveWorkspaceName: ",this.core.store.state?.activeWorkspace?.name),e("div",{key:"870d0d25fb058016f246c6d09f8484f2da7268c8"},"TranslateX: ",this.core.store.state?.translateX),e("div",{key:"510f84b9c531847f211c5a30333e26687f9aa0a1"},"TranslateY: ",this.core.store.state?.translateY),e("div",{key:"f8893208caf4ef75c5e4719216e115aebdec7f58"},"ViewportWidth: ",this.core.store.state?.viewportWidth),e("div",{key:"012219bffa89704491c2153e209ba1bf57adbeee"},"ViewportHeight: ",this.core.store.state?.viewportHeight),e("div",{key:"9c899814bf36d3f8862fd7f49689508a1baf39e2"},"PointerCount: ",this.core.store.state.pointers.size),e("div",{key:"4a5dc288955d617186819cce51a7077d8f0a27ee"},"Scale: ",this.core.store.state?.scale),e("div",{key:"f6b3e3db24cc1f6df5cacba49e7cbca3e855a1d5"},"ActiveTool: ",this.core.store.state?.activeTool?.name),e("div",{key:"5159cfb7ba76274acafa9dd52cf035df0a638954"},"HasViewportChanged: ",this.core.store.state?.hasViewportChanged?"true":"false"),e("div",{key:"fb951bba9378e7edaa931c1f71172a1760f493f1"},"IsEnabled: ",this.core.store.state?.isEnabled?"true":"false"),e("div",{key:"31e8257fdf8deca0036181fe08e7312e0f7e06ea"},"IsScaling: ",this.core.store.state?.isScaling?"true":"false"),e("div",{key:"eb9c0276321566c024dce3eb6e5b4c5ac8a2217b"},"IsPanning: ",this.core.store.state?.isPanning?"true":"false"),e("div",{key:"4ccbbe93181ea8bca8008c495a87ecf32e0fc823"},"IsSelecting: ",this.isSelecting?"true":"false"),e("div",{key:"c8bb0d92069b152b3238b806302413c8ef565bfc"},"IsSelectionActive: ",this.isSelectionActive?"true":"false"),e("div",{key:"6a8fa0e36c486f92c66b016efaf718d98876500a"},"IsResizeHandleSelected: ",this.core.store.state.isResizeHandleSelected?"true":"false"),e("div",{key:"a0c090c6de6183b0d217a14e637cc766f1d0ec70"},"IsRotationHandleSelected: ",this.core.store.state.isRotationHandleSelected?"true":"false"),e("div",{key:"54a73257c6e60831e1945548ac90404d53c0c59a"},"IsDrawing: ",this.core.store.state.isDrawing?"true":"false"),e("div",{key:"eb05d42967f2503664da627a06e6428282614873"},"IsWriting: ",this.core.store.state.isWriting?"true":"false"),e("div",{key:"a6a7141369c33eca952f7aea7c9fefeeb4a5b1fa"},"PointerX: ",this.core.store.state?.pointerX),e("div",{key:"ffe702239f80b6ccb9d6623de37c63e3af13703c"},"PointerY: ",this.core.store.state?.pointerY),e("div",{key:"3a48b1e2630298dd480295ba0c845a0eb4adbab5"},"SelectedObjects: ",this.core.store.selectionGroup?.objects.length||0),e("div",{key:"b1dd6b5e2aa1c59d9c2ecd658bd7830ae599e24a"},"ViewportCenter: (",a.toFixed(2),", ",c.toFixed(2),")")),e("div",{key:"ada0f44f8a38cbdf8f90a70402ffbf6383638c0c",id:"origin",class:"origin",style:{transform:`matrix(${this.core.store.state?.scale}, 0, 0, ${this.core.store.state?.scale}, ${this.core.store.state?.translateX}, ${this.core.store.state?.translateY})`}},l?.map((t=>e("div",{key:t.id,style:{transform:t?.transformationMatrix,transformOrigin:"top left",zIndex:t.zIndex.toString(),position:"absolute",pointerEvents:this.core.store.state.isScaling?"none":"auto"}},e("svg",{xmlns:"http://www.w3.org/2000/svg",id:t.id,class:"object",style:{height:t?.totalHeight.toString(),width:t?.totalWidth.toString(),left:"0",top:"0",position:"absolute",transform:`rotate(${t.rotationDegrees}deg)`,transformOrigin:`${t.totalWidth/2}px ${t.totalHeight/2}px`,opacity:t.markedForRemoval?"0.5":t.opacity.toString(),pointerEvents:t.markedForRemoval?"none":"auto"}},e("foreignObject",{x:"0",y:"0",width:t.totalWidth.toString(),height:t.totalHeight.toString(),style:{minHeight:"0",minWidth:"0",backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:t.borderWidth+"px",borderStyle:"solid",padding:t.padding+"px",overflow:"visible"}},at.isInstanceOf(t,"KritzelPath")&&e("svg",{ref:e=>t.mount(e),xmlns:"http://www.w3.org/2000/svg",style:{height:t?.height.toString(),width:t?.width.toString(),position:"absolute",overflow:"visible"},viewBox:t?.viewBox},e("path",{d:t?.d,fill:t.fill,stroke:t?.stroke,"shape-rendering":t.isLowRes()?"optimizeSpeed":"auto"})),at.isInstanceOf(t,"KritzelImage")&&e("img",{ref:e=>t.mount(e),src:t.src,style:{width:"100%",height:"100%",userSelect:"none",pointerEvents:"none",imageRendering:this.core.store.state.isScaling||this.core.store.state.isPanning?"pixelated":"auto"},draggable:false,onDragStart:t=>t.preventDefault()}),at.isInstanceOf(t,"KritzelText")&&e("div",{ref:e=>t.mount(e),onPointerDown:e=>t.handlePointerDown(e),onPointerMove:e=>t.handlePointerMove(e),onPointerUp:e=>t.handlePointerUp(e),style:{minWidth:t.initialWidth+"px",minHeight:t.initialHeight+"px",maxWidth:"500px",height:"auto",width:"max-content",transformOrigin:"top left",transform:`scale(${t.scaleFactor})`,backgroundColor:t.backgroundColor,overflow:"visible",textRendering:this.core.store.state.isScaling||this.core.store.state.isPanning?"optimizeSpeed":"auto"}}),at.isInstanceOf(t,"KritzelCustomElement")&&e("div",{ref:e=>t.mount(e),style:{width:"100%",height:"100%",pointerEvents:"auto",overflow:"hidden",display:"block"}}),at.isInstanceOf(t,"KritzelSelectionGroup")&&e("div",{ref:e=>t.mount(e),style:{width:"100%",height:"100%"}}),at.isInstanceOf(t,"KritzelSelectionBox")&&e("div",{ref:e=>t.mount(e),style:{width:"100%",height:"100%",backgroundColor:o.isFirefox()?t.backgroundColor:"transparent",borderWidth:o.isFirefox()?t.borderWidth+"px":"0",borderStyle:o.isFirefox()?"solid":"none",borderColor:o.isFirefox()?t.borderColor:"transparent"}})),e("line",{x1:"0",y1:"0",x2:t.totalWidth,y2:"0",style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("line",{x1:"0",y1:"0",x2:"0",y2:t.totalHeight,style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("line",{x1:"0",y1:t.totalHeight,x2:t.totalWidth,y2:t.totalHeight,style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("line",{x1:t.totalWidth,y1:"0",x2:t.totalWidth,y2:t.totalHeight,style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`,strokeLinecap:"square"},visibility:t.isSelected?"visible":"hidden"}),e("circle",{class:"resize-handle top-left",cx:"0",cy:"0",r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay top-left",cx:"0",cy:"0",r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle top-right",cx:t.totalWidth,cy:"0",r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay top-right",cx:t.totalWidth,cy:"0",r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle bottom-left",cx:"0",cy:t.totalHeight,r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay bottom-left",cx:"0",cy:t.totalHeight,r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle bottom-right",cx:t.totalWidth,cy:t.totalHeight,r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"resize-handle-overlay bottom-right",cx:t.totalWidth,cy:t.totalHeight,r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("line",{x1:t.totalWidth/2,y1:"0",x2:t.totalWidth/2,y2:-(15*t.scale/this.core.store.state?.scale),style:{stroke:"var(--kritzel-selection-border-color, #007AFF)",strokeWidth:`calc(var(--kritzel-selection-border-width, 2px) * ${t.scale} / ${this.core.store.state?.scale})`},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"rotation-handle",cx:t.totalWidth/2,cy:-(15*t.scale/this.core.store.state?.scale),r:`${r*t.scale/this.core.store.state?.scale}`,style:{fill:"var(--kritzel-selection-handle-color, #000000)"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("circle",{class:"rotation-handle-overlay",cx:t.totalWidth/2,cy:-(15*t.scale/this.core.store.state?.scale),r:`${s*t.scale/this.core.store.state?.scale}`,style:{fill:"transparent",cursor:"grab"},visibility:t.isSelected&&!this.isSelecting?"visible":"hidden"}),e("g",{style:{display:this.core.store.state.debugInfo.showObjectInfo?"block":"none",pointerEvents:"none"}},e("foreignObject",{x:t.totalWidth.toString(),y:"0",width:"400px",height:"160px",style:{minHeight:"0",minWidth:"0",display:t.isDebugInfoVisible?"block":"none"}},e("div",{style:{width:"100%",height:"100%"}},e("div",{style:{whitespace:"nowrap"}},"Id: ",t.id),e("div",{style:{whiteSpace:"nowrap"}},"width: ",t.width),e("div",{style:{whiteSpace:"nowrap"}},"height: ",t.height),e("div",{style:{whiteSpace:"nowrap"}},"translateX: ",t.translateX),e("div",{style:{whiteSpace:"nowrap"}},"translateY: ",t.translateY))))))))),this.core.store.state.isContextMenuVisible&&e("kritzel-context-menu",{key:"0369b6579f87448c6c3c608ef10c47276fd58c92",class:"context-menu",ref:t=>this.contextMenuElement=t,items:this.core.store.state.contextMenuItems,objects:this.core.store.selectionGroup?.objects||[],style:{position:"fixed",left:`${this.core.store.state.contextMenuX}px`,top:`${this.core.store.state.contextMenuY}px`,zIndex:"10000"},onActionSelected:t=>{t.detail.action({x:(-this.core.store.state.translateX+this.core.store.state.contextMenuX)/this.core.store.state.scale,y:(-this.core.store.state.translateY+this.core.store.state.contextMenuY)/this.core.store.state.scale},this.core.store.selectionGroup?.objects);this.hideContextMenu()},onClose:()=>this.hideContextMenu()}),this.core.store.state?.activeTool instanceof h&&!this.core.store.state.isScaling&&e("kritzel-cursor-trail",{key:"3692b5245247d082191144d3672e9733fe6d16fe",core:this.core}))}static get watchers(){return{workspace:["onWorkspaceChange"],scaleMax:["validateScaleMax"],scaleMin:["validateScaleMin"]}}};pt.style=vt;const bt=":host{display:block}.font-preview{color:var(--kritzel-font-size-text-color, #333333);line-height:1;text-align:center;font-weight:bold}";const gt=class{constructor(e){t(this,e)}fontFamily="Arial, sans-serif";size=24;color="#000000";render(){return e(i,{key:"0a6f1d1326e9dde84a4122d79f75dc1c75ffe0fb"},e("div",{key:"88a342d01c4150cd4fc5dacca23f7b9904edca52",class:"font-preview",style:{fontFamily:this.fontFamily,fontSize:`${this.size}px`,color:this.color}},"A"))}};gt.style=bt;const kt=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.font-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:pointer;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}.font-style-button.italic-text{font-style:italic}";const yt=class{constructor(e){t(this,e);this.fontFamilyChange=n(this,"fontFamilyChange")}fontOptions=[{value:"arial",label:"Arial"},{value:"verdana",label:"Verdana"},{value:"helvetica",label:"Helvetica"},{value:"tahoma",label:"Tahoma"},{value:"trebuchet ms",label:"Trebuchet MS"},{value:"times new roman",label:"Times New Roman"},{value:"georgia",label:"Georgia"},{value:"garamond",label:"Garamond"},{value:"courier new",label:"Courier New"},{value:"brush script mt",label:"Brush Script MT"}];selectedFontFamily;fontFamilyChange;componentWillLoad(){if(this.fontOptions&&this.fontOptions.length>0){const t=this.fontOptions.some((t=>t.value===this.selectedFontFamily));if(!this.selectedFontFamily||!t){this.selectedFontFamily=this.fontOptions[0].value}}}handleDropdownValueChange=t=>{this.fontFamilyChange.emit(t.detail)};render(){const t=this.fontOptions.map((t=>({value:t.value,label:t.label,style:{fontFamily:t.value}})));return e(i,{key:"27d14ddb4a57b9cd7b936047b6ea6a9251a1ab27"},e("kritzel-dropdown",{key:"20ea042c9a907dc1ac5e16a589a8856f87389e36",options:t,value:this.selectedFontFamily,onValueChanged:this.handleDropdownValueChange,selectStyles:{fontFamily:this.selectedFontFamily}},e("button",{key:"f63fed16477a327aadaeb54feefe35df1780e37d",class:"font-style-button",slot:"suffix"},"B"),e("button",{key:"13b3089606c2e83b256ed2cec6513a9911016754",class:"font-style-button italic-text",slot:"suffix"},"I")))}};yt.style=kt;const wt=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:4px;cursor:pointer;border:2px solid transparent;box-sizing:border-box;border-radius:50%}.size-container:hover{background-color:var(--kritzel-font-size-hover-background-color, #ebebeb)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-font-size-selected-background-color, #e0e0e0)}";const mt=class{constructor(e){t(this,e);this.sizeChange=n(this,"sizeChange")}sizes=[8,10,12,16,20,24];selectedSize=null;fontFamily="Arial";sizeChange;handleSizeClick(t){this.selectedSize=t;this.sizeChange.emit(t)}render(){return e(i,{key:"9f3d851d443352f7437116cf91eff8d8de41e322"},this.sizes.map((t=>e("div",{class:{"size-container":true,selected:this.selectedSize===t},onClick:()=>this.handleSizeClick(t)},e("kritzel-font",{fontFamily:this.fontFamily,size:t})))))}};mt.style=wt;const xt=":host{display:inline-flex;justify-content:center;align-items:center;color:var(--kritzel-icon-color, inherited)}span{display:flex;align-items:center;width:100%;height:100%;}span>svg{width:100%;height:100%}";const zt=class{constructor(e){t(this,e)}name;label;size=24;render(){const t=X.get(this.name);if(!t){console.error(`[kritzel-icon] Icon "${this.name}" not found in registry.`);return e("span",{class:"error-icon","aria-label":`Error: Icon ${this.name} not found`},"?")}const n={width:`${this.size}px`,height:`${this.size}px`};return e(i,{style:n},e("span",{"aria-hidden":!this.label,role:this.label?"img":undefined,"aria-label":this.label,innerHTML:t}))}};zt.style=xt;const Ct=":host{position:relative;display:flex;flex-direction:column;background-color:var(--kritzel-menu-background-color, #ffffff);width:var(--kritzel-menu-width, 200px);padding:var(--kritzel-menu-padding, 8px);border-radius:var(--kritzel-menu-border-radius, 12px);box-shadow:var(--kritzel-menu-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-menu-border, 1px solid #ebebeb);z-index:2;gap:var(--kritzel-menu-gap, 4px);overflow-y:auto;scrollbar-color:#ebebeb transparent;scrollbar-width:thin;max-height:300px}:host(:focus-visible){outline:var(--kritzel-menu-focus-outline, 2px solid #e3e3e3)}.has-open-child-overlay{position:absolute;top:0;left:0;right:0;bottom:0;z-index:3}";const Mt=class{constructor(e){t(this,e);this.itemSelect=n(this,"itemSelect");this.itemSave=n(this,"itemSave");this.itemCancel=n(this,"itemCancel");this.itemToggleChildMenu=n(this,"itemToggleChildMenu");this.itemCloseChildMenu=n(this,"itemCloseChildMenu");this.close=n(this,"close")}get host(){return r(this)}items;parent=null;itemSelect;itemSave;itemCancel;itemToggleChildMenu;itemCloseChildMenu;close;selectedIndex=null;async setScrollTop(t){this.host.scrollTop=t;this.host.scrollTo({top:t,behavior:"auto"})}async setFocus(){const t=this.host.shadowRoot.querySelector("kritzel-menu-item");if(t){t.focus()}}get openChildMenuItem(){return this.items.find((t=>t.isChildMenuOpen))}get editingMenuItem(){return this.items.find((t=>t.isEditing))}onOverlayClick=t=>{t.stopPropagation();this.itemCloseChildMenu.emit(this.openChildMenuItem)};handleItemSelect=t=>{t.stopPropagation();this.itemSelect.emit(t.detail)};handleSave=t=>{t.stopPropagation();this.itemSave.emit(t.detail)};handleCancel=t=>{t.stopPropagation();this.itemCancel.emit(t.detail)};handleToggleChildMenu=t=>{t.stopPropagation();this.itemToggleChildMenu.emit(t.detail)};handleCloseChildMenu=t=>{t.stopPropagation();this.itemCloseChildMenu.emit(t.detail)};render(){return e(i,{key:"be122cb0ecff3227d9e69997de76a73940a61860",tabIndex:0,onClick:t=>t.stopPropagation()},this.openChildMenuItem&&e("div",{key:"ae10bec61e5c5e1a29b444cb7378f15c6692f3b6",class:"has-open-child-overlay",onClick:this.onOverlayClick}),this.items.map((t=>e("kritzel-menu-item",{key:t.id,item:t,parent:this.parent,style:{pointerEvents:this.editingMenuItem&&!t.isEditing?"none":"auto"},onItemSelect:this.handleItemSelect,onItemSave:this.handleSave,onItemCancel:this.handleCancel,onItemToggleChildMenu:this.handleToggleChildMenu,onItemCloseChildMenu:this.handleCloseChildMenu}))))}};Mt.style=Ct;const jt=":host{position:relative;display:flex;align-items:center;justify-content:space-between;width:100%;padding:var(--kritzel-menu-item-padding, 8px);box-sizing:border-box;gap:16px;height:var(--kritzel-menu-item-height, 40px);min-height:var(--kritzel-menu-item-min-height, 40px);font-family:sans-serif;font-size:var(--kritzel-menu-item-font-size, 14px);color:var(--kritzel-menu-item-color, #333333);border-radius:var(--kritzel-menu-item-border-radius, 12px);outline:none;cursor:default}:host(:hover) .menu-item-overlay,:host(:focus-within) .menu-item-overlay{background-color:var(--kritzel-menu-item-overlay-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.selected){background-color:var(--kritzel-menu-item-selected-bg, #007aff);color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected) .action-button{color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected.editing){background-color:var(--kritzel-menu-item-selected-bg, #007aff)}:host(.selected) .edit-input{color:var(--kritzel-menu-item-selected-color, #ffffff)}:host(.selected) .action-button kritzel-icon{--kritzel-icon-color:var(--kritzel-menu-item-selected-color, #ffffff)}kritzel-icon{--kritzel-icon-color:var(--kritzel-menu-item-color, #333333)}:host(.selected) .edit-input::selection{background-color:var(--kritzel-menu-item-input-selection-color, rgba(255, 255, 255, 0.16))}:host(.editing){background-color:var(--kritzel-menu-item-editing-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.disabled){opacity:0.5;pointer-events:none !important}:host(.child-open){background-color:var(--kritzel-menu-item-child-open-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.child-open.selected){background-color:var(--kritzel-menu-item-selected-bg, #007aff)}.menu-item-overlay{position:absolute;inset:0;background-color:transparent;z-index:0;pointer-events:none;border-radius:var(--kritzel-menu-item-border-radius, 12px)}.menu-item-content{display:flex;align-items:center;gap:8px;position:relative;z-index:1;height:100%}.left{justify-content:flex-start;flex:1;min-width:0}.left>div{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.right{justify-content:flex-end}.edit-input{flex:1;height:var(--kritzel-menu-item-input-height, 24px);padding:0;background-color:transparent;border-radius:0;border:none;border-bottom:1px solid var(--kritzel-menu-item-input-border, #ccc);font-size:var(--kritzel-context-menu-item-font-size, 14px);width:100%;min-width:0;box-sizing:border-box;outline:none}.edit-input::selection{background-color:var(--kritzel-menu-item-input-selection-color, #007bff);color:var(--kritzel-menu-item-input-selection-text-color, #ffffff)}.action-button{padding:4px;border-radius:8px;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;background-color:transparent;background:transparent;outline:none;-webkit-tap-highlight-color:transparent}.action-button:hover,.action-button:focus{background-color:var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.action-button.disabled{pointer-events:none;opacity:0.5}";const It=class{constructor(e){t(this,e);this.itemSelect=n(this,"itemSelect");this.itemSave=n(this,"itemSave");this.itemCancel=n(this,"itemCancel");this.itemToggleChildMenu=n(this,"itemToggleChildMenu");this.itemCloseChildMenu=n(this,"itemCloseChildMenu")}get host(){return r(this)}item;onItemChange(t,e){if(t!==e){this.isDirty=false}}parent=null;itemSelect;itemSave;itemCancel;itemToggleChildMenu;itemCloseChildMenu;isDirty=false;inputRef;focusInput(){if(this.item.isEditing&&this.inputRef&&!this.isDirty){this.inputRef.focus();if(o.isIOS()){const t=this.inputRef.value.length;this.inputRef.setSelectionRange(t,t)}else{this.inputRef.select()}}}componentDidLoad(){this.setDeviceSpecificStyles();this.focusInput()}componentDidUpdate(){this.focusInput()}setDeviceSpecificStyles=()=>{const t=o.isTouchDevice();if(t){this.host.style.setProperty("--kritzel-menu-item-overlay-background-color","transparent");this.host.style.setProperty("--kritzel-menu-item-button-hover-background-color","transparent")}};handleItemSelect=t=>{t.stopPropagation();this.itemSelect.emit({item:this.item,parent:this.parent})};handleInputChange=t=>{t.stopPropagation();const e=t.target;this.item.label=e.value;this.isDirty=true};handleSave=t=>{t.stopPropagation();this.host.focus();this.itemSave.emit(this.item)};handleCancel=t=>{t.stopPropagation();this.host.focus();this.itemCancel.emit(this.item)};handleMenuToggle=t=>{t.stopPropagation();this.itemToggleChildMenu.emit({item:this.item,childMenuAnchor:t.target})};handleMenuClose=()=>{this.itemCloseChildMenu.emit(this.item)};renderViewMode(){return[e("div",{class:"menu-item-content left"},e("div",null,this.item.label)),e("div",{class:"menu-item-content right"},this.item.children&&this.item.children.length>0&&[e("button",{id:"child-menu-toggle",class:"action-button",onClick:this.handleMenuToggle,disabled:this.item.isDisabled},e("kritzel-icon",{name:"ellipsis-vertical",size:16})),e("kritzel-portal",{anchor:this.item.childMenuAnchor,offsetY:4,onClose:this.handleMenuClose},e("kritzel-menu",{items:this.item.children,parent:this.item,onItemSelect:t=>this.itemSelect.emit(t.detail),onItemSave:t=>this.itemSave.emit(t.detail),onItemCancel:t=>this.itemCancel.emit(t.detail),onClose:this.handleMenuClose}))])]}renderEditMode(){return[e("div",{class:"menu-item-content left"},e("input",{ref:t=>this.inputRef=t,type:"text",class:"edit-input",value:this.item.label,onInput:this.handleInputChange})),e("div",{class:"menu-item-content right"},e("div",{tabIndex:0,class:"action-button",onClick:this.handleCancel},e("kritzel-icon",{name:"x",size:16})),e("div",{tabIndex:!this.isDirty&&!this.item.isNewItem?-1:0,class:{"action-button":true,disabled:!this.isDirty&&!this.item.isNewItem},onClick:this.handleSave},e("kritzel-icon",{name:"check",size:16})))]}render(){return e(i,{key:"9df3acdaff753e3ed910f848c98e8ad73e2b5f5c",tabIndex:this.item.isDisabled?-1:0,class:{selected:this.item.isSelected,editing:this.item.isEditing,disabled:this.item.isDisabled,"child-open":this.item.isChildMenuOpen},onClick:this.handleItemSelect},e("div",{key:"bb73e5c0c3dd87efabcaa0b53d20c7c477b34aa1",class:"menu-item-overlay"}),this.item.isEditing?this.renderEditMode():this.renderViewMode())}static get watchers(){return{item:["onItemChange"]}}};It.style=jt;class St{static getNumericValueFromStyle(t,e){const i=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(i)||0}static getScrollableParent(t){if(!t){return window}const e=t.parentNode?.host??t.parentElement;if(!e||e.tagName==="BODY"){return window}const i=window.getComputedStyle(e);if(i.overflow==="auto"||i.overflowY==="auto"||i.overflow==="scroll"||i.overflowY==="scroll"){return e}return this.getScrollableParent(e)}static isElementInViewport(t){if(!t){return false}const e=this.getScrollableParent(t);const i=t.getBoundingClientRect();if(e===window){const t=window.innerHeight||document.documentElement.clientHeight;const e=window.innerWidth||document.documentElement.clientWidth;return i.top>=0&&i.left>=0&&i.bottom<=t&&i.right<=e}const n=e.getBoundingClientRect();return i.top>=n.top&&i.left>=n.left&&i.bottom<=n.bottom&&i.right<=n.right}static getFocusableElements(t){if(!t)return[];const e=[];const i='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details, [tabindex]:not([tabindex="-1"])';const n=t=>t.offsetParent!==null;const r=t=>{if(t instanceof HTMLElement&&t.matches(i)&&!t.hasAttribute("disabled")&&n(t)){e.push(t)}if(t.shadowRoot){Array.from(t.shadowRoot.children).forEach(r)}if(t.tagName==="SLOT"){t.assignedElements({flatten:true}).forEach(r)}if(!t.shadowRoot){Array.from(t.children).forEach(r)}};r(t);return e}}const _t=class{constructor(e){t(this,e);this.close=n(this,"close")}get host(){return r(this)}anchor;anchorChanged(t){if(t){this.openPortal();this.calculatePosition();if(this.autoFocus){this.focusFirstElement()}}else{this.closePortal()}}offsetX;offsetY;autoFocus=true;close;handleOutsideClick(t){t.stopPropagation();const e=this.lastAddedPortal===this.portal;if(!e)return;const i=t.target;if(!this.host.contains(i)){this.close.emit();this.closePortal()}}handleKeyDown(t){t.stopPropagation();const e=this.lastAddedPortal===this.portal;if(!e)return;if(t.key==="Escape"){this.anchor.focus();this.close.emit();this.closePortal()}if(t.key==="Tab"){this.trapFocus(t)}if(t.key==="Enter"){const e=this.getDeepActiveElement();if(e?.click){t.preventDefault();e.click()}}}handleResize(){this.calculatePosition()}handleWindowScroll(){const t=St.isElementInViewport(this.anchor);if(!t){this.anchor?.blur();this.closePortal();return}this.calculatePosition()}portal;id=`portal-${S.generateUUID()}`;defaultOffset=0;minLeft=0;focusFirstElement(){requestAnimationFrame((()=>{this.firstFocusableElement?.focus?.()}))}getDeepActiveElement(){let t=document.activeElement;while(t?.shadowRoot?.activeElement){t=t.shadowRoot.activeElement}return t}trapFocus(t){const e=St.getFocusableElements(this.host);if(e.length===0)return;const i=e[0];const n=e[e.length-1];const r=this.getDeepActiveElement();if(t.shiftKey){if(r===i){n.focus();t.preventDefault()}}else{if(r===n){i.focus();t.preventDefault()}}}get firstFocusableElement(){const t=this.host.shadowRoot?.querySelector("slot");const e=t?.assignedElements({flatten:true})[0];if(!e)return null;const i=St.getFocusableElements(e);return i[0]??e}get lastAddedPortal(){const t=Array.from(document.querySelectorAll('[id^="portal-"]'));return t.length?t[t.length-1]:null}calculateLeft(){if(!this.anchor||!this.portal)return 0;const t=this.anchor.getBoundingClientRect();const e=this.portal.getBoundingClientRect();const i=this.offsetX??this.defaultOffset;let n=t.left+i;const r=window.innerWidth-e.width-this.minLeft;if(n<this.minLeft)n=this.minLeft;if(n>r)n=r;return Math.round(n+window.scrollX)}calculateTop(){if(!this.anchor||!this.portal)return 0;const t=this.anchor.getBoundingClientRect();const e=this.portal.getBoundingClientRect();const i=this.offsetY??this.defaultOffset;let n=t.bottom+i;if(n+e.height>window.innerHeight){n=t.top-e.height-i}return Math.round(n+window.scrollY)}openPortal(){this.portal=document.createElement("div");this.portal.setAttribute("id",this.id);this.portal.style.zIndex="1";this.portal.style.position="absolute";this.portal.style.top="0px";this.portal.style.left="0px";this.portal.appendChild(this.host);document.body.append(this.portal)}closePortal(){const t=document.getElementById(this.id);if(!t)return;document.body.removeChild(t);this.host.remove()}calculatePosition(){if(!this.anchor||!this.portal)return;const t=this.calculateTop();const e=this.calculateLeft();this.portal.style.top=`${t}px`;this.portal.style.left=`${e}px`}render(){return e(i,{key:"9c5cdf7126ff1148dd2364cce9d2524862e27d13",style:{display:this.anchor?"block":"none"}},e("slot",{key:"209a77246fedcea0c24882605487452ff5cc62ce"}))}static get watchers(){return{anchor:["anchorChanged"]}}};const Tt=":host{position:relative;display:flex;align-items:center;font-family:sans-serif;z-index:1;padding:var(--kritzel-split-button-padding, 4px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-split-button-border, 1px solid #ebebeb);gap:var(--kritzel-split-button-gap, 4px)}:host(.mobile){--kritzel-split-button-hover-background-color:transparent}button{border:none;background-color:transparent;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;text-align:center;display:flex;align-items:center;justify-content:center;pointer-events:all;-webkit-tap-highlight-color:transparent}.split-main-button,.split-menu-button{height:auto;display:flex;align-items:center;padding:var(--kritzel-split-button-padding, 8px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);font-size:var(--kritzel-split-button-font-size, 14px)}.split-main-button:hover,.split-menu-button:hover{background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button:focus,.split-menu-button:focus{outline:none;background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button{gap:var(--kritzel-split-button-gap, 4px)}.split-menu-button{border-left:none;justify-content:center}.split-divider{width:var(--kritzel-split-button-divider-width, 1px);height:24px;background-color:var(--kritzel-split-button-divider-background-color, hsl(0, 0%, 0%, 4.3%))}:disabled{pointer-events:none;opacity:0.5}";const At=class{constructor(e){t(this,e);this.mainButtonClick=n(this,"mainButtonClick");this.itemSelect=n(this,"itemSelect");this.itemSave=n(this,"itemSave");this.itemCancel=n(this,"itemCancel");this.itemToggleChildMenu=n(this,"itemToggleChildMenu");this.itemCloseChildMenu=n(this,"itemCloseChildMenu");this.menuOpen=n(this,"menuOpen");this.menuClose=n(this,"menuClose")}get host(){return r(this)}buttonIcon="plus";dropdownIcon="chevron-down";items=[];mainButtonDisabled=false;menuButtonDisabled=false;mainButtonClick;itemSelect;itemSave;itemCancel;itemToggleChildMenu;itemCloseChildMenu;menuOpen;menuClose;isMenuOpen=false;isTouchDevice=o.isTouchDevice();anchorElement;menuScrollTop=0;splitMenuButtonRef;menuRef;async open(){if(this.isMenuOpen)return;this.isMenuOpen=true;this.anchorElement=this.host;this.menuOpen.emit()}async focusMenu(){if(this.menuRef){await this.menuRef.setFocus()}}handleButtonClick=t=>{t.stopPropagation();this.mainButtonClick.emit()};toggleMenu=t=>{t.stopPropagation();if(this.isMenuOpen){this.closeMenu()}else{this.openMenu(t)}};openMenu=t=>{t.stopPropagation();this.isMenuOpen=true;this.anchorElement=this.host;this.menuOpen.emit();requestAnimationFrame((()=>{this.menuRef?.setScrollTop(this.menuScrollTop)}))};closeMenu=()=>{this.isMenuOpen=false;this.anchorElement=null;this.splitMenuButtonRef?.blur();this.menuClose.emit()};handleItemSelect=t=>{this.itemSelect.emit(t.detail)};handleItemSave=t=>{this.itemSave.emit(t.detail)};handleItemCancel=t=>{this.itemCancel.emit(t.detail)};handleItemToggleChildMenu=t=>{this.itemToggleChildMenu.emit(t.detail)};handleItemCloseChildMenu=t=>{this.itemCloseChildMenu.emit(t.detail)};handleScroll=t=>{this.menuScrollTop=t.target.scrollTop};render(){return e(i,{key:"4ff7809dd62c1dd60600fda592aeac43cd9bc74c",class:{mobile:this.isTouchDevice}},e("button",{key:"db6485fabcffdd75a25d178aca7b653af499a90c",class:"split-main-button",tabIndex:0,onClick:this.handleButtonClick,disabled:this.mainButtonDisabled},this.buttonIcon&&e("kritzel-icon",{key:"4001a4e23ef53bec2a578310de8c8b593d7b266c",name:this.buttonIcon})),e("div",{key:"8ff86d3c01a48b06afca77dd066518efa3589cb1",class:"split-divider"}),e("button",{key:"f1c40edbec3756a7f3681de4e8d0f1981dd312a4",ref:t=>this.splitMenuButtonRef=t,class:"split-menu-button",tabIndex:0,onClick:this.toggleMenu,disabled:this.menuButtonDisabled},e("kritzel-icon",{key:"0ddb89976632ae7454e66504f8bab3fd5072c252",name:this.dropdownIcon})),e("kritzel-portal",{key:"64531ffd6ac847fd1a99e32aceefea9f18088992",anchor:this.anchorElement,offsetY:4,onClose:this.closeMenu},e("kritzel-menu",{key:"f3b86cb71e5ba39e8f98e26b3669416e2cdb4802",ref:t=>this.menuRef=t,items:this.items,onItemSelect:this.handleItemSelect,onItemSave:this.handleItemSave,onItemCancel:this.handleItemCancel,onItemToggleChildMenu:this.handleItemToggleChildMenu,onItemCloseChildMenu:this.handleItemCloseChildMenu,onClose:this.closeMenu,onScroll:this.handleScroll})))}};At.style=Tt;const Et=":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.size-container:focus-visible{outline:var(--kritzel-stroke-size-focus-outline, 2px auto #e3e3e3)}.size-container:hover{background-color:var(--kritzel-stroke-size-hover-background-color, #ebebeb)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-stroke-size-selected-background-color, #ebebeb)}";const $t=class{constructor(e){t(this,e);this.sizeChange=n(this,"sizeChange")}sizes=[4,6,8,12,16,24];selectedSize=null;sizeChange;handleSizeClick(t){this.selectedSize=t;this.sizeChange.emit(t)}render(){return e(i,{key:"74579e34c23725e22927afe371c1f7925903720a"},this.sizes.map((t=>e("div",{tabIndex:0,class:{"size-container":true,selected:this.selectedSize===t},onClick:()=>this.handleSizeClick(t)},e("kritzel-color",{value:"#000000",size:t})))))}};$t.style=Et;const Ot=":host{width:auto}.tooltip-content{position:relative;padding:8px 12px;border-radius:4px;width:fit-content;background-color:var(--kritzel-controls-tooltip-background-color, #ffffff);color:var(--kritzel-controls-tooltip-color, #000000);padding:var(--kritzel-controls-tooltip-padding, 8px);border-radius:var(--kritzel-controls-tooltip-border-radius, 16px);white-space:nowrap;box-shadow:var(--kritzel-controls-tooltip-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12))}";const Rt=768;const Wt=class{constructor(e){t(this,e);this.tooltipClosed=n(this,"tooltipClosed")}get host(){return r(this)}isVisible=false;anchorElement;arrowSize=8;offsetY=24;tooltipClosed;positionX=0;arrowOffset="0px";isMobileView=window.innerWidth<Rt;handleOutsideClick(t){if(!this.isVisible)return;const e=t.target;if(!this.host.contains(e)){this.tooltipClosed.emit()}}handleWindowResize(){this.isMobileView=window.innerWidth<Rt;this.calculateAdjustedPosition()}async focusContent(){const t=St.getFocusableElements(this.host);if(t.length>0){t[0].focus()}}componentDidLoad(){this.focusSlottedContent()}componentWillLoad(){this.isMobileView=window.innerWidth<Rt;this.calculateAdjustedPosition()}componentWillUpdate(){this.calculateAdjustedPosition()}focusSlottedContent(){const t=this.host.shadowRoot?.querySelector("slot");const e=t?.assignedElements()||[];if(e.length>0){const t=e[0];t.focus()}}calculateAdjustedPosition(){if(this.isVisible&&this.anchorElement){const t=this.anchorElement.getBoundingClientRect();const e=this.host.shadowRoot?.querySelector(".tooltip-content");if(!this.isMobileView){this.positionX=t.left+t.width/2;this.arrowOffset=`calc(${50}% - ${this.arrowSize}px)`}else{const i=e.getBoundingClientRect();this.positionX=t.left+t.width/2-i.width/2;this.arrowOffset=`${t.left+t.width/2-i.left-this.arrowSize}px`}}}render(){return e(i,{key:"72a6356a43a15a7abc9a46b0d22c3c62217791e8",style:{position:"fixed",zIndex:"9999",transition:"opacity 0.3s ease-in-out, transform 0.3s ease-in-out",visibility:this.isVisible?"visible":"hidden",left:!this.isMobileView?`${this.positionX}px`:"50%",marginBottom:`${this.offsetY+this.arrowSize}px`}},e("div",{key:"75f5350f23ada0eee009279eddd7d25273ad3740",class:"tooltip-content",onClick:t=>t.stopPropagation()},e("slot",{key:"ad999154289e933cac1fdc13392de2aec78811a8"}),e("div",{key:"6be3f5c24d42898920c339be2cd2f3dd8a82fa80",class:"tooltip-arrow-wrapper",style:{position:"fixed",left:this.arrowOffset,bottom:`-${this.arrowSize*2}px`}},e("div",{key:"37397c6245dd6b0def23e2611d118e0c4f5860ef",class:"tooltip-arrow",style:{borderLeft:`${this.arrowSize}px solid transparent`,borderRight:`${this.arrowSize}px solid transparent`,borderTop:`${this.arrowSize}px solid var(--kritzel-controls-tooltip-background-color, #ffffff)`,filter:"drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))"}}),e("div",{key:"dbf009c371d46ef0a36e27771758c66e817d9b22",class:"tooltip-arrow-rect",style:{position:"relative",width:`${this.arrowSize*2}px`,height:`${this.arrowSize}px`,backgroundColor:"var(--kritzel-controls-tooltip-background-color, #ffffff)",bottom:`${this.arrowSize*2}px`}}))))}};Wt.style=Ot;const Ft=":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:12px;border-top-right-radius:12px;background-color:rgb(226, 226, 226);width:fit-content;user-select:none}.utility-button{display:flex;justify-content:center;align-items:center;width:28px;height:28px;padding:8px 4px;border:none;outline:none;background:none;cursor:pointer;color:#333333;-webkit-tap-highlight-color:transparent;border-radius:var(--kritzel-utility-panel-button-border-radius, 8px)}.utility-button:focus{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.utility-separator{width:1px;height:16px;background-color:hsl(0, 0%, 0%, 4.3%)}";const Dt=class{constructor(e){t(this,e);this.undo=n(this,"undo");this.redo=n(this,"redo");this.delete=n(this,"delete")}undo;redo;delete;handleUndo(t){if(t.cancelable){t.preventDefault();t.stopPropagation();this.undo.emit()}}handleRedo(t){t.preventDefault();t.stopPropagation();this.redo.emit()}render(){return e(i,{key:"8e2eb13668d8787827b10cee7c9daf2abdecc2c6"},e("button",{key:"0773e7ef81bc972ba589333f4ac7e85d98737770",class:"utility-button",onClick:t=>this.handleUndo(t)},e("kritzel-icon",{key:"fa69c1a2535d44bfb871a4d719079d0f900cc6c7",name:"undo"})),e("button",{key:"edc28968f3ec92467d6b4aaa095a71770413d657",class:"utility-button",onClick:t=>this.handleRedo(t)},e("kritzel-icon",{key:"d4cf72e2bda411fe9942d473c5e1ceae62a76074",name:"redo"})),e("div",{key:"8927237c6099a147495564657cdef97e7d35d7c1",class:"utility-separator"}),e("button",{key:"e089819f7dd870165130322c3c4a9d754d4ed023",class:"utility-button"},e("kritzel-icon",{key:"a143770d1b3f8fdbe5c5b36c5d7eaab511cd8a4b",name:"delete",onClick:()=>this.delete.emit()})))}};Dt.style=Ft;const Bt=":host{display:flex;flex-direction:column;z-index:1}";const Pt=class{constructor(e){t(this,e);this.isWorkspaceManagerReady=n(this,"isWorkspaceManagerReady");this.workspaceChange=n(this,"workspaceChange")}get host(){return r(this)}activeWorkspace;workspaces=[];isWorkspaceManagerReady;workspaceChange;childMenuAnchor=null;openChildMenuItem=null;newWorkspace=null;editingItemId=null;handleWheel(t){if(t.ctrlKey){t.preventDefault()}}kritzelEngineRef=null;splitButtonRef;get sortedWorkspaces(){return[this.newWorkspace,...this.workspaces].filter((t=>t!=null)).sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}async componentWillLoad(){await this.initializeEngine();this.isWorkspaceManagerReady.emit()}async initializeEngine(){await customElements.whenDefined("kritzel-engine");this.kritzelEngineRef=this.host.parentElement.querySelector("kritzel-engine");if(!this.kritzelEngineRef){throw new Error("kritzel-engine not found in parent element.")}}async select(t,e){if(this.editingItemId){return}if(t.action){t.action(t,e);return}this.workspaceChange.emit(t.value)}async add(){await this.splitButtonRef.open();this.newWorkspace=new v(S.generateUUID(),"New Workspace");this.editingItemId=this.newWorkspace.id}edit(t){this.openChildMenuItem=null;this.childMenuAnchor=null;requestAnimationFrame((()=>{this.editingItemId=t.id}))}async save(t){if(this.newWorkspace){this.newWorkspace.name=t.label;await this.kritzelEngineRef.createWorkspace(this.newWorkspace);this.workspaceChange.emit(this.newWorkspace)}else{const e=t.value;e.name=t.label;await this.kritzelEngineRef.updateWorkspace(e)}this.editingItemId=null;this.newWorkspace=null}cancel(){this.newWorkspace=null;this.editingItemId=null}async delete(t){this.openChildMenuItem=null;this.childMenuAnchor=null;await this.kritzelEngineRef.deleteWorkspace(t.value);if(t.value.id===this.activeWorkspace?.id){this.activeWorkspace=this.sortedWorkspaces.find((e=>e.id!==t.value.id))||null;this.workspaceChange.emit(this.activeWorkspace)}await this.splitButtonRef.focusMenu()}toggleChildMenu(t,e){this.openChildMenuItem=t;this.childMenuAnchor=e}closeChildMenu(){this.openChildMenuItem=null;this.childMenuAnchor=null}handleMenuOpen(){this.kritzelEngineRef.disable()}handleMenuClose(){this.cancel();this.closeChildMenu();this.kritzelEngineRef.enable()}render(){const t=this.sortedWorkspaces.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())).filter((t=>t!==null)).map((t=>({id:t.id,label:t.name,value:t,isEditing:this.editingItemId===t.id,isSelected:this.activeWorkspace?.id===t.id,isNewItem:this.newWorkspace?.id===t.id,isChildMenuOpen:this.openChildMenuItem?.id===t.id,childMenuAnchor:this.openChildMenuItem?.id===t.id?this.childMenuAnchor:null,children:[{id:`${t.id}-rename`,label:"Rename",value:"rename",action:(t,e)=>this.edit(e)},{id:`${t.id}-delete`,label:"Delete",value:"delete",isDisabled:this.sortedWorkspaces.length<=1,action:(t,e)=>this.delete(e)}]})));return e(i,null,e("kritzel-split-button",{ref:t=>this.splitButtonRef=t,items:t,mainButtonDisabled:this.editingItemId!=null,onMainButtonClick:()=>this.add(),onItemSelect:t=>this.select(t.detail.item,t.detail.parent),onItemToggleChildMenu:t=>this.toggleChildMenu(t.detail.item,t.detail.childMenuAnchor),onItemSave:t=>this.save(t.detail),onItemCancel:()=>this.cancel(),onItemCloseChildMenu:()=>this.closeChildMenu(),onMenuOpen:()=>this.handleMenuOpen(),onMenuClose:()=>this.handleMenuClose()}))}};Pt.style=Bt;export{$ as kritzel_color,R as kritzel_color_palette,F as kritzel_context_menu,B as kritzel_control_brush_config,L as kritzel_control_text_config,U as kritzel_controls,H as kritzel_cursor_trail,N as kritzel_dropdown,J as kritzel_editor,pt as kritzel_engine,gt as kritzel_font,yt as kritzel_font_family,mt as kritzel_font_size,zt as kritzel_icon,Mt as kritzel_menu,It as kritzel_menu_item,_t as kritzel_portal,At as kritzel_split_button,$t as kritzel_stroke_size,Wt as kritzel_tooltip,Dt as kritzel_utility_panel,Pt as kritzel_workspace_manager};
10
+ //# sourceMappingURL=p-843d013b.entry.js.map