kritzel-stencil 0.0.132 → 0.0.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-ouFX0OVi.js → index-DILpAbYp.js} +97 -75
- package/dist/cjs/index-DILpAbYp.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +70 -82
- package/dist/collection/classes/commands/add-selection-group.command.js +6 -3
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +13 -0
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +8 -0
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +5 -3
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-object.command.js +2 -0
- package/dist/collection/classes/commands/update-object.command.js.map +1 -1
- package/dist/collection/classes/core/core.class.js +7 -9
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/core/history.class.js +1 -0
- package/dist/collection/classes/core/history.class.js.map +1 -1
- package/dist/collection/classes/core/viewport.class.js +0 -6
- package/dist/collection/classes/core/viewport.class.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +7 -2
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +42 -58
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +24 -19
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +10 -12
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +14 -22
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +11 -3
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +3 -4
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +13 -4
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -2
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/helpers/object.helper.js +0 -14
- package/dist/collection/helpers/object.helper.js.map +1 -1
- package/dist/collection/interfaces/clonable.interface.js +2 -0
- package/dist/collection/interfaces/clonable.interface.js.map +1 -0
- package/dist/collection/interfaces/shortcut.interface.js +2 -0
- package/dist/collection/interfaces/shortcut.interface.js.map +1 -0
- package/dist/components/index.js +2 -2
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +8 -8
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/p-B0kd2rUI.js +16 -0
- package/dist/components/p-B0kd2rUI.js.map +1 -0
- package/dist/components/{p-BiCgeOiJ.js → p-B3LGnqFz.js} +3 -3
- package/dist/components/{p-BiCgeOiJ.js.map → p-B3LGnqFz.js.map} +1 -1
- package/dist/components/{p-C1-nvBx9.js → p-BKvOO7NT.js} +6 -6
- package/dist/components/{p-C1-nvBx9.js.map → p-BKvOO7NT.js.map} +1 -1
- package/dist/components/{p-CvmWmUK9.js → p-CM8KdFZI.js} +4 -4
- package/dist/components/{p-CvmWmUK9.js.map → p-CM8KdFZI.js.map} +1 -1
- package/dist/components/{p-B3VQubt_.js → p-CNTK3JOp.js} +16 -6
- package/dist/components/p-CNTK3JOp.js.map +1 -0
- package/dist/components/{p-Davd1R_4.js → p-CZzYv_iN.js} +155 -140
- package/dist/components/p-CZzYv_iN.js.map +1 -0
- package/dist/components/{p-BGdsAz54.js → p-DOPuq6gn.js} +3 -4
- package/dist/components/p-DOPuq6gn.js.map +1 -0
- package/dist/components/{p-D_907-Wd.js → p-Dw4n-4zp.js} +3 -3
- package/dist/components/{p-D_907-Wd.js.map → p-Dw4n-4zp.js.map} +1 -1
- package/dist/components/{p-CTvJDYFQ.js → p-NP1Htol7.js} +3 -3
- package/dist/components/{p-CTvJDYFQ.js.map → p-NP1Htol7.js.map} +1 -1
- package/dist/esm/{index-C_uHp-ur.js → index-BrCE-Ctm.js} +97 -75
- package/dist/esm/index-BrCE-Ctm.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +70 -82
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-092c9a05.entry.js +2 -0
- package/dist/stencil/p-092c9a05.entry.js.map +1 -0
- package/dist/stencil/p-BrCE-Ctm.js +2 -0
- package/dist/stencil/p-BrCE-Ctm.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/commands/add-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/rotate-selection-group.command.d.ts +1 -1
- package/dist/types/classes/handlers/key.handler.d.ts +2 -0
- package/dist/types/classes/handlers/move.handler.d.ts +2 -0
- package/dist/types/classes/handlers/resize.handler.d.ts +1 -0
- package/dist/types/classes/handlers/rotation.handler.d.ts +4 -0
- package/dist/types/classes/objects/base-object.class.d.ts +3 -1
- package/dist/types/helpers/object.helper.d.ts +0 -2
- package/dist/types/interfaces/clonable.interface.d.ts +3 -0
- package/dist/types/interfaces/shortcut.interface.d.ts +8 -0
- package/package.json +64 -64
- package/dist/cjs/index-ouFX0OVi.js.map +0 -1
- package/dist/components/p-B3VQubt_.js.map +0 -1
- package/dist/components/p-BGdsAz54.js.map +0 -1
- package/dist/components/p-Davd1R_4.js.map +0 -1
- package/dist/components/p-EXPChOF6.js +0 -30
- package/dist/components/p-EXPChOF6.js.map +0 -1
- package/dist/esm/index-C_uHp-ur.js.map +0 -1
- package/dist/stencil/p-C_uHp-ur.js +0 -2
- package/dist/stencil/p-C_uHp-ur.js.map +0 -1
- package/dist/stencil/p-a6f8283e.entry.js +0 -2
- package/dist/stencil/p-a6f8283e.entry.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class t{_core;initiator;skipHistory;constructor(t,i,s=false){this._core=t;this.initiator=i?.constructor?.name??"Unknown";this.skipHistory=s}execute(){throw new Error("Method not implemented.")}undo(){throw new Error("Method not implemented.")}}class i extends t{object;updatedProperties;previousProperties;constructor(t,i,s,e,n=false){super(t,i,n);this.object=s;this.updatedProperties=e;this.previousProperties={};for(const t in e){if(e.hasOwnProperty(t)){this.previousProperties[t]=this.object[t]}}}execute(){for(const t in this.updatedProperties){if(this.updatedProperties.hasOwnProperty(t)){this.object[t]=this.updatedProperties[t]}}this._core.store.state.objectsMap.update(this.object);this._core.updateObjectInDatabase(this.object)}undo(){for(const t in this.previousProperties){if(this.previousProperties.hasOwnProperty(t)){this.object[t]=this.previousProperties[t]}}this._core.store.state.objectsMap.update(this.object);this._core.updateObjectInDatabase(this.object)}}class s{static registry={};static registerTool(t,i,s){const e=new i(s);e.name=t;this.registry[t]=e;return e}static getTool(t){const i=this.registry[t];if(!i){console.warn(`Unknown tool: ${t}`);return null}return i}}class e{__class__=this.constructor.name;name="base-tool";_core;constructor(t){this._core=t}onActivate(){}onDeactivate(){}handlePointerDown(t){}handlePointerMove(t){}handlePointerUp(t){}handleWheel(t){}serialize(){return{__class__:this.__class__,name:this.name}}deserialize(t){Object.assign(this,t);return this}}class n extends t{object;constructor(t,i,s,e=false){super(t,i,e);this.object=s}execute(){this._core.store.state.objectsMap.insert(this.object);this._core.addObjectToDatabase(this.object)}undo(){this._core.store.state.objectsMap.remove((t=>t.id===this.object.id));this._core.deleteObjectFromDatabase(this.object.id)}}var r;(function(t){t[t["Left"]=0]="Left";t[t["Middle"]=1]="Middle";t[t["Right"]=2]="Right"})(r||(r={}));class o{static isRightClick(t){return t.button===r.Right}static isLeftClick(t){return t.button===r.Left}static isMainMouseWheel(t){return Math.abs(t.deltaY)>0&&Math.abs(t.deltaX)===0&&Number.isInteger(t.deltaY)}static isPointerEventOnContextMenu(t){const i=t.composedPath();const s=i.find((t=>t.classList&&t.classList.contains("context-menu")));return!!s}static onLongPress(t,i,s){const e=400;const n=10;const r=t.clientX;const o=t.clientY;const h=t.target;const c=setTimeout((()=>{d();i(t)}),e);const a=()=>{clearTimeout(c);d();s?.()};const f=t=>{if(Math.abs(t.clientX-r)>n||Math.abs(t.clientY-o)>n){a()}};const u=()=>{a()};const l=()=>{a()};const d=()=>{h.removeEventListener("pointermove",f);h.removeEventListener("pointerup",u);h.removeEventListener("pointercancel",l)};h.addEventListener("pointermove",f,{passive:true});h.addEventListener("pointerup",u,{once:true});h.addEventListener("pointercancel",l,{once:true});return a}}class h{static forceHideKeyboard(){if(document.activeElement instanceof HTMLElement){document.activeElement.blur()}}static enableInteractiveWidget(){const t=document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');if(t){let i=t.getAttribute("content");if(!i.includes("interactive-widget=resizes-content")){i+=", interactive-widget=resizes-content"}t.setAttribute("content",i)}}static disableInteractiveWidget(){const t=document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');if(t){let i=t.getAttribute("content");let s=i.replace(/\s*interactive-widget=resizes-content\s*[,;]?/g,"");s=s.replace(/,(\s*,)+/g,",").replace(/^,/,"").replace(/,$/,"").trim();t.setAttribute("content",s)}}static onKeyboardVisibleChanged(t){if("visualViewport"in window){const i=.75;const s=s=>{const e=s.target;const n=e.height*e.scale/window.screen.height<i;t(n)};window.visualViewport.addEventListener("resize",s);return()=>window.visualViewport.removeEventListener("resize",s)}else{console.warn("Listening for keyboard visibility changes is not reliably supported in this browser.");return()=>{}}}}class c extends e{fontFamily="Arial";fontSize=16;fontColor="#000000";palette=["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#808000","#800080"];constructor(t){super(t)}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){const i=t.composedPath().slice(1);const e=i.find((t=>t.classList&&t.classList.contains("object")));const r=this._core.findObjectById(e?.id);if(this._core.store.state.activeText===null&&r&&r instanceof l){this._core.store.setState("activeText",r);r.focus();return}if(this._core.store.state.activeText!==null&&r instanceof l){r.focus();return}if(this._core.store.state.activeText!==null){this._core.resetActiveText();this._core.store.setState("activeTool",s.getTool("selection"));return}if(o.isLeftClick(t)===false){return}const h=t.clientX-this._core.store.offsetX;const c=t.clientY-this._core.store.offsetY;const a=l.create(this._core,this.fontSize,this.fontFamily);a.fontColor=this.fontColor;a.translateX=(h-this._core.store.state.translateX)/this._core.store.state.scale;a.translateY=(c-this._core.store.state.translateY)/this._core.store.state.scale;a.zIndex=this._core.store.currentZIndex;this._core.store.setState("activeText",a);this._core.history.executeCommand(new n(this._core,this,a))}if(t.pointerType==="touch"){const i=Array.from(this._core.store.state.pointers.values());const e=t.composedPath().slice(1);const r=e.find((t=>t.classList&&t.classList.contains("object")));const o=this._core.findObjectById(r?.id);if(this._core.store.state.activeText===null&&o&&o instanceof l){this._core.store.setState("activeText",o);o.focus();return}if(this._core.store.state.activeText!==null&&o instanceof l){o.focus();return}if(this._core.store.state.activeText!==null){this._core.resetActiveText();this._core.store.setState("activeTool",s.getTool("selection"));return}if(i.length>1){return}h.disableInteractiveWidget();const c=Math.round(i[0].clientX-this._core.store.offsetX);const a=Math.round(i[0].clientY-this._core.store.offsetY);const f=l.create(this._core,this.fontSize,this.fontFamily);f.fontColor=this.fontColor;f.translateX=(c-this._core.store.state.translateX)/this._core.store.state.scale;f.translateY=(a-this._core.store.state.translateY)/this._core.store.state.scale;f.zIndex=this._core.store.currentZIndex;this._core.store.setState("activeText",f);this._core.history.executeCommand(new n(this._core,this,f))}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){this._core.store.state.activeText?.updateTextareaDimensions();this._core.store.state.activeText?.focus()}if(t.pointerType==="touch"){this._core.store.state.activeText?.updateTextareaDimensions();this._core.store.state.activeText?.focus();h.enableInteractiveWidget()}}}class a{static generateUUID(){return Math.random().toString(36).substr(2,9)}static isEmpty(t){if(t===null||t===undefined){return true}return Object?.keys(t).length===0&&t?.constructor===Object}}class f{static doPolygonsIntersect(t,i){const s=[t.bottomLeft,t.bottomRight,t.topRight,t.topLeft];const e=[i.bottomLeft,i.bottomRight,i.topRight,i.topLeft];for(const t of s){if(this.isPointInPolygon(t,e)){return true}}for(const t of e){if(this.isPointInPolygon(t,s)){return true}}for(let t=0;t<s.length;t++){const i=s[t];const n=s[(t+1)%s.length];for(let t=0;t<e.length;t++){const s=e[t];const r=e[(t+1)%e.length];if(this.intersectLines(i,n,s,r)){return true}}}return false}static isPointInPolygon(t,i){let s=false;for(let e=0,n=i.length-1;e<i.length;n=e++){const r=i[e].x,o=i[e].y;const h=i[n].x,c=i[n].y;const a=o>t.y!==c>t.y&&t.x<(h-r)*(t.y-o)/(c-o)+r;if(a)s=!s}return s}static intersectLines(t,i,s,e){const n=(i.x-t.x)*(e.y-s.y)-(i.y-t.y)*(e.x-s.x);if(n===0){return false}const r=((s.x-t.x)*(e.y-s.y)-(s.y-t.y)*(e.x-s.x))/n;const o=-((t.x-s.x)*(i.y-t.y)-(t.y-s.y)*(i.x-t.x))/n;return r>=0&&r<=1&&o>=0&&o<=1}}class u{__class__="KritzelBaseObject";_core;_elementRef;id;workspaceId;x;y;translateX;translateY;height;width;backgroundColor;borderColor;borderWidth=0;opacity=1;padding=0;scale;resizing=false;rotation=0;markedForRemoval=false;zIndex=0;isVisible=true;isSelected=false;isHovered=false;isMounted=false;isEditable=false;isInteractive=false;isDebugInfoVisible=false;get totalWidth(){return this.width+this.padding*2}get totalHeight(){return this.height+this.padding*2}set elementRef(t){this._elementRef=t}get elementRef(){return this._elementRef}get boundingBox(){return{x:this.translateX,y:this.translateY,z:this.scale,width:this.totalWidth/this.scale,height:this.totalHeight/this.scale,depth:0}}get rotatedBoundingBox(){return{x:this.minXRotated,y:this.minYRotated,z:this.scale,width:this.maxXRotated-this.minXRotated,height:this.maxYRotated-this.minYRotated,depth:0}}get rotatedPolygon(){const t=this.translateX+this.totalWidth/2/this.scale;const i=this.translateY+this.totalHeight/2/this.scale;const s=this.rotation;const e=this.totalWidth/this.scale;const n=this.totalHeight/this.scale;const r={topLeft:{x:this.translateX,y:this.translateY},topRight:{x:this.translateX+e,y:this.translateY},bottomRight:{x:this.translateX+e,y:this.translateY+n},bottomLeft:{x:this.translateX,y:this.translateY+n}};const o=Object.keys(r).reduce(((e,n)=>{const o=r[n];const h=Math.cos(s)*(o.x-t)-Math.sin(s)*(o.y-i)+t;const c=Math.sin(s)*(o.x-t)+Math.cos(s)*(o.y-i)+i;e[n]={x:h,y:c};return e}),{});return o}get minXRotated(){const t=[this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x];return Math.min(...t)}get minYRotated(){const t=[this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y];return Math.min(...t)}get maxXRotated(){const t=[this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x];return Math.max(...t)}get maxYRotated(){const t=[this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y];return Math.max(...t)}get transformationMatrix(){const t=1/this.scale;const i=this.translateX;const s=this.translateY;return`matrix(${t}, 0, 0, ${t}, ${i}, ${s})`}get rotationDegrees(){return this.rotation*(180/Math.PI)}get centerX(){return this.translateX+this.totalWidth/2}get centerY(){return this.translateY+this.totalHeight/2}constructor(){this.id=this.generateId()}static create(t){const i=new u;i._core=t;i.zIndex=t.store.currentZIndex;i.workspaceId=t.store.state.activeWorkspace.id;return i}mount(t){if(this.isMounted){return}this.elementRef=t;this.isMounted=true}unmount(){if(!this.isMounted){return}this.isMounted=false}remount(){if(!this.isMounted){return}this.isMounted=false}generateId(){return a.generateUUID()}isInViewport(){const t={x:-this._core.store.state.translateX/this._core.store.state.scale,y:-this._core.store.state.translateY/this._core.store.state.scale,width:this._core.store.state.viewportWidth/this._core.store.state.scale,height:this._core.store.state.viewportHeight/this._core.store.state.scale};return this.boundingBox.x<t.x+t.width&&this.boundingBox.x+this.boundingBox.width>t.x&&this.boundingBox.y<t.y+t.height&&this.boundingBox.y+this.boundingBox.height>t.y}centerInViewport(){const t=this._core.store.state.scale;this.translateX=(this._core.store.state.viewportWidth/2-this.totalWidth/2-this._core.store.state.translateX)/t;this.translateY=(this._core.store.state.viewportHeight/2-this.totalHeight/2-this._core.store.state.translateY)/t}move(t,i,s,e){const n=(t-s)/this._core.store.state.scale;const r=(i-e)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r}resize(t,i,s,e){if(s<=1||e<=1){return}this.width=s;this.height=e;this.translateX=t;this.translateY=i}rotate(t){this.rotation=t}clone(){const t=new u;Object.assign(t,this);return t}copy(){const t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this);t.id=this.generateId();t.isMounted=false;return t}onSelectedClick(){}serialize(){const{_core:t,_elementRef:i,element:s,totalWidth:e,totalHeight:n,...r}=this;const o=structuredClone(r);if(s&&typeof s==="object"&&"nodeType"in s&&s.nodeType===1){o.element=s.cloneNode(true)}return o}deserialize(t){Object.assign(this,t);return this}isClass(t){return this.__class__===t}edit(){}hitTest(t,i){return true}hitTestPolygon(t){const i=this.rotatedPolygon;return f.doPolygonsIntersect(i,t)}updatePosition(t,i){this.translateX=t;this.translateY=i;this._core.store.state.objectsMap.update(this)}}class l extends u{__class__="KritzelText";value="";fontFamily="Arial";fontSize=8;fontColor="#000000";initialWidth=3;isNew=true;isDebugInfoVisible=true;isEditable=true;rows=1;get isReadonly(){return!(this._core.store.state.activeTool instanceof c)}constructor(t){super();if(t){this.value=t.value||" ";this.translateX=t.translateX||0;this.translateY=t.translateY||0;this.fontSize=t.fontSize||8;this.fontFamily=t.fontFamily||"Arial";this.fontColor=t.fontColor||"#000000";this.height=t.height||this.fontSize*1.2;this.width=t.width||0;this.scale=t.scale||1}}static create(t,i,s){const e=new l;e._core=t;e.id=e.generateId();e.workspaceId=t.store.state.activeWorkspace.id;e.fontSize=i;e.fontFamily=s;e.translateX=0;e.translateY=0;e.width=e.initialWidth/(e._core.store.state.scale<0?e._core.store.state.scale:1);e.height=e.fontSize*1.2/(e._core.store.state.scale<0?e._core.store.state.scale:1);e.padding=5;e.backgroundColor="transparent";e.scale=e._core.store.state.scale;e.value=" ";e.zIndex=t.store.currentZIndex;return e}mount(t){if(this.isMounted&&this.elementRef===t||this.isInViewport()===false){return}this.elementRef=t;this.isMounted=true}resize(t,i,s,e){if(s<=1||e<=1){return}const n=e/this.height;this.fontSize=this.fontSize*n;this.width=this.width*n;this.height=e;this.translateX=t;this.translateY=i}handleKeyDown(t){if(this.isReadonly){t.preventDefault();t.stopPropagation()}}handleInput(t){const i=t.target;if(i.value===""){this.value=" ";i.value=" ";i.selectionStart=i.selectionEnd=i.value.length}else{this.value=i.value.trim()}this.updateTextareaDimensions()}updateTextareaDimensions(){if(this.elementRef){const t=document.createElement("span");t.style.position="absolute";t.style.whiteSpace="pre-wrap";t.style.visibility="hidden";t.style.fontSize=window.getComputedStyle(this.elementRef).fontSize;t.style.fontFamily=window.getComputedStyle(this.elementRef).fontFamily;t.innerHTML=this.elementRef.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")+"<br>";document.body.appendChild(t);const s=t.offsetWidth;const e=t.offsetHeight;document.body.removeChild(t);this.width=s;this.height=e;this._core.history.executeCommand(new i(this._core,this,this,{...this}))}}focus(){if(this.elementRef){this.elementRef.focus()}}selectAll(){if(this.elementRef){this.elementRef.select()}}insertFromClipboard(){if(this.elementRef){this.elementRef.focus();try{navigator.clipboard.readText().then((t=>{const i=this.elementRef.selectionStart;const s=this.elementRef.selectionEnd;const e=this.elementRef.value;this.elementRef.value=e.substring(0,i)+t+e.substring(s);this.elementRef.selectionStart=this.elementRef.selectionEnd=i+t.length;this.value=this.elementRef.value;this.updateTextareaDimensions()}))}catch(t){console.error("Failed to read clipboard contents:",t)}}}edit(){this._core.store.setState("activeTool",s.getTool("text"));this._core.store.setState("selectionGroup",null);this._core.store.setState("selectionBox",null);this._core.store.setState("activeText",this);setTimeout((()=>{this.focus()}),300)}}var d={};var v;function w(){if(v)return d;v=1;(function(t){var i=Object.defineProperty;var s=t=>i(t,"__esModule",{value:true});var e=(t,e)=>{s(t);for(var n in e)i(t,n,{get:e[n],enumerable:true})};e(t,{default:()=>T,getStroke:()=>P,getStrokeOutlinePoints:()=>U,getStrokePoints:()=>F});function n(t,i,s,e=t=>t){return t*e(.5-i*(.5-s))}function r(t){return[-t[0],-t[1]]}function o(t,i){return[t[0]+i[0],t[1]+i[1]]}function h(t,i){return[t[0]-i[0],t[1]-i[1]]}function c(t,i){return[t[0]*i,t[1]*i]}function a(t,i){return[t[0]/i,t[1]/i]}function f(t){return[t[1],-t[0]]}function u(t,i){return t[0]*i[0]+t[1]*i[1]}function l(t,i){return t[0]===i[0]&&t[1]===i[1]}function d(t){return Math.hypot(t[0],t[1])}function v(t){return t[0]*t[0]+t[1]*t[1]}function w(t,i){return v(h(t,i))}function p(t){return a(t,d(t))}function A(t,i){return Math.hypot(t[1]-i[1],t[0]-i[0])}function g(t,i,s){let e=Math.sin(s),n=Math.cos(s),r=t[0]-i[0],o=t[1]-i[1],h=r*n-o*e,c=r*e+o*n;return[h+i[0],c+i[1]]}function m(t,i,s){return o(t,c(h(i,t),s))}function y(t,i,s){return o(t,c(i,s))}var{min:b,PI:M}=Math,x=.275,E=M+1e-4;function U(t,i={}){let{size:s=16,smoothing:e=.5,thinning:a=.5,simulatePressure:l=true,easing:d=t=>t,start:v={},end:A={},last:M=false}=i,{cap:U=true,easing:F=t=>t*(2-t)}=v,{cap:P=true,easing:T=t=>--t*t*t+1}=A;if(t.length===0||s<=0)return[];let S=t[t.length-1].runningLength,k=v.taper===false?0:v.taper===true?Math.max(s,S):v.taper,B=A.taper===false?0:A.taper===true?Math.max(s,S):A.taper,z=Math.pow(s*e,2),_=[],I=[],C=t.slice(0,10).reduce(((t,i)=>{let e=i.pressure;if(l){let n=b(1,i.distance/s),r=b(1,1-n);e=b(1,t+(r-t)*(n*x))}return(t+e)/2}),t[0].pressure),j=n(s,a,t[t.length-1].pressure,d),R,D=t[0].vector,O=t[0].point,Q=O,G=O,H=Q,K=false;for(let i=0;i<t.length;i++){let{pressure:e}=t[i],{point:r,vector:v,distance:p,runningLength:A}=t[i];if(i<t.length-1&&S-A<3)continue;if(a){if(l){let t=b(1,p/s),i=b(1,1-t);e=b(1,C+(i-C)*(t*x))}j=n(s,a,e,d)}else j=s/2;R===void 0&&(R=j);let y=A<k?F(A/k):1,M=S-A<B?T((S-A)/B):1;j=Math.max(.01,j*Math.min(y,M));let U=(i<t.length-1?t[i+1]:t[i]).vector,P=i<t.length-1?u(v,U):1,X=u(v,D)<0&&!K,W=P!==null&&P<0;if(X||W){let t=c(f(D),j);for(let i=1/13,s=0;s<=1;s+=i)G=g(h(r,t),r,E*s),_.push(G),H=g(o(r,t),r,E*-s),I.push(H);O=G,Q=H,W&&(K=true);continue}if(K=false,i===t.length-1){let t=c(f(v),j);_.push(h(r,t)),I.push(o(r,t));continue}let L=c(f(m(U,v,P)),j);G=h(r,L),(i<=1||w(O,G)>z)&&(_.push(G),O=G),H=o(r,L),(i<=1||w(Q,H)>z)&&(I.push(H),Q=H),C=e,D=v}let X=t[0].point.slice(0,2),W=t.length>1?t[t.length-1].point.slice(0,2):o(t[0].point,[1,1]),L=[],Y=[];if(t.length===1){if(!(k||B)||M){let t=y(X,p(f(h(X,W))),-(R||j)),i=[];for(let s=1/13,e=s;e<=1;e+=s)i.push(g(t,X,E*2*e));return i}}else{if(!(k||B&&t.length===1))if(U)for(let t=1/13,i=t;i<=1;i+=t){let t=g(I[0],X,E*i);L.push(t)}else{let t=h(_[0],I[0]),i=c(t,.5),s=c(t,.51);L.push(h(X,i),h(X,s),o(X,s),o(X,i))}let i=f(r(t[t.length-1].vector));if(B||k&&t.length===1)Y.push(W);else if(P){let t=y(W,i,j);for(let i=1/29,s=i;s<1;s+=i)Y.push(g(t,W,E*3*s))}else Y.push(o(W,c(i,j)),o(W,c(i,j*.99)),h(W,c(i,j*.99)),h(W,c(i,j)))}return _.concat(Y,I.reverse(),L)}function F(t,i={}){var s;let{streamline:e=.5,size:n=16,last:r=false}=i;if(t.length===0)return[];let c=.15+(1-e)*.85,a=Array.isArray(t[0])?t:t.map((({x:t,y:i,pressure:s=.5})=>[t,i,s]));if(a.length===2){let t=a[1];a=a.slice(0,-1);for(let i=1;i<5;i++)a.push(m(a[0],t,i/4))}a.length===1&&(a=[...a,[...o(a[0],[1,1]),...a[0].slice(2)]]);let f=[{point:[a[0][0],a[0][1]],pressure:a[0][2]>=0?a[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],u=false,d=0,v=f[0],w=a.length-1;for(let t=1;t<a.length;t++){let i=r&&t===w?a[t].slice(0,2):m(v.point,a[t],c);if(l(v.point,i))continue;let s=A(i,v.point);if(d+=s,t<w&&!u){if(d<n)continue;u=true}v={point:i,pressure:a[t][2]>=0?a[t][2]:.5,vector:p(h(v.point,i)),distance:s,runningLength:d},f.push(v)}return f[0].vector=((s=f[1])==null?void 0:s.vector)||[0,0],f}function P(t,i={}){return U(F(t,i),i)}var T=P})(d);return d}var p=w();class A{static average(t,i){return(t+i)/2}}class g extends u{__class__="KritzelPath";points;d;stroke="none";strokeWidth;lineSlack=.5;fill;x=0;y=0;height=0;width=0;scale=1;options;isVisible=true;isDebugInfoVisible=true;_adjustedPoints=null;get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super();this.options=t;this.points=t?.points??[];this.translateX=t?.translateX??0;this.translateY=t?.translateY??0;this.scale=t?.scale??1;this.strokeWidth=t?.strokeWidth??8;this.fill=t?.fill??"#000000";this.d=this.generateSvgPath();this.updateDimensions()}static create(t,i){const s=new g;s._core=t;s.id=s.generateId();s.workspaceId=t.store.state.activeWorkspace.id;s.options=i;s.points=i?.points??[];s.translateX=i?.translateX??0;s.translateY=i?.translateY??0;s.scale=i?.scale??1;s.strokeWidth=i?.strokeWidth??8;s.fill=i?.fill??"#000000";s.zIndex=t.store.currentZIndex;s.d=s.generateSvgPath();s.updateDimensions();return s}resize(t,i,s,e){if(s<=1||e<=1){return}const n=s/this.width;const r=e/this.height;this.width=s;this.height=e;this.points=this.points.map((([t,i])=>[t*n,i*r]));this.d=this.generateSvgPath();this.width=Math.max(...this.points.map((t=>t[0])))-Math.min(...this.points.map((t=>t[0])))+this.strokeWidth;this.height=Math.max(...this.points.map((t=>t[1])))-Math.min(...this.points.map((t=>t[1])))+this.strokeWidth;this.x=Math.min(...this.points.map((t=>t[0])))-this.strokeWidth/2;this.y=Math.min(...this.points.map((t=>t[1])))-this.strokeWidth/2;this.translateX=t;this.translateY=i;this._adjustedPoints=null}rotate(t){this.rotation=t;this._adjustedPoints=null}move(t,i,s,e){const n=(t-s)/this._core.store.state.scale;const r=(i-e)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r;this._adjustedPoints=null}hitTest(t,i){const s=this.strokeWidth/this.scale/2;if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}if(this._adjustedPoints.length===1){const e=this._adjustedPoints[0];const n=this.pointToLineSegmentDistance(t,i,e[0],e[1],e[0],e[1]);return n<=s}for(let e=0;e<this._adjustedPoints.length-1;e++){const n=this._adjustedPoints[e];const r=this._adjustedPoints[e+1];const o=this.pointToLineSegmentDistance(t,i,n[0],n[1],r[0],r[1]);if(o<=s){return true}}return false}hitTestPolygon(t){const i=this.strokeWidth/this.scale/2;if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}const s=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}];for(const[t,i]of this._adjustedPoints){if(f.isPointInPolygon({x:t,y:i},s)){return true}}for(const t of s){if(this.hitTest(t.x,t.y)){return true}}for(let t=0;t<this._adjustedPoints.length-1;t++){const i={x:this._adjustedPoints[t][0],y:this._adjustedPoints[t][1]};const e={x:this._adjustedPoints[t+1][0],y:this._adjustedPoints[t+1][1]};for(let t=0;t<s.length;t++){const n=s[t];const r=s[(t+1)%s.length];if(f.intersectLines(i,e,n,r)){return true}}}for(let t=0;t<this._adjustedPoints.length-1;t++){const e=this._adjustedPoints[t];const n=this._adjustedPoints[t+1];for(let t=0;t<s.length;t++){const r=s[t];const o=s[(t+1)%s.length];const h=this.pointToLineSegmentDistance(r.x,r.y,e[0],e[1],n[0],n[1]);const c=this.pointToLineSegmentDistance(o.x,o.y,e[0],e[1],n[0],n[1]);const a=this.pointToLineSegmentDistance(e[0],e[1],r.x,r.y,o.x,o.y);const f=this.pointToLineSegmentDistance(n[0],n[1],r.x,r.y,o.x,o.y);const u=Math.min(h,c,a,f);if(u<=i){return true}}}return false}updatePosition(t,i){this.translateX=t;this.translateY=i;this._adjustedPoints=null;this._core.store.state.objectsMap.update(this)}computeAdjustedPoints(){if(!this.points?.length){return[]}const t=this.rotation;const i=Math.cos(t);const s=Math.sin(t);const e=this.points.map((t=>t[0]));const n=this.points.map((t=>t[1]));const r={x:(Math.min(...e)+Math.max(...e))/2,y:(Math.min(...n)+Math.max(...n))/2};const{x:o,y:h}=r;const c=this.points.map((([t,e])=>{const n=t-o;const r=e-h;return[o+n*i-r*s,h+n*s+r*i]}));return c.map((([t,i])=>[Math.abs(t-this.x)/this.scale+this.translateX,Math.abs(i-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,i,s,e,n,r){const o=t-s;const h=i-e;const c=n-s;const a=r-e;const f=o*c+h*a;const u=c*c+a*a;let l=-1;if(u!==0){l=f/u}let d,v;if(l<0){d=s;v=e}else if(l>1){d=n;v=r}else{d=s+l*c;v=e+l*a}const w=t-d;const p=i-v;return Math.sqrt(w*w+p*p)}updateDimensions(){const t=this.points.map((([t,i])=>{const s=t*Math.cos(this.rotation)-i*Math.sin(this.rotation);const e=t*Math.sin(this.rotation)+i*Math.cos(this.rotation);return[s,e]}));const i=Math.min(...t.map((t=>t[0]-this.strokeWidth/2)));const s=Math.min(...t.map((t=>t[1]-this.strokeWidth/2)));const e=Math.max(...t.map((t=>t[0]+this.strokeWidth/2)));const n=Math.max(...t.map((t=>t[1]+this.strokeWidth/2)));this.width=e-i+this.lineSlack;this.height=n-s+this.lineSlack;this.x=i;this.y=s;this.translateX=(this.x+this.translateX)/this.scale;this.translateY=(this.y+this.translateY)/this.scale}generateSvgPath(){const t=this.getStrokeFromPoints(this.points,this.strokeWidth);return this.getSvgPathFromStroke(t)}getStrokeFromPoints(t,i){return p.getStroke(t,{size:i,thinning:.5,smoothing:.5,streamline:.5,easing:t=>t,simulatePressure:true,last:true,start:{cap:true,taper:0,easing:t=>t},end:{cap:true,taper:0,easing:t=>t}})}getSvgPathFromStroke(t,i=true){const s=t.length;if(s<4){return``}let e=t[0];let n=t[1];const r=t[2];let o=`M${e[0].toFixed(2)},${e[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${A.average(n[0],r[0]).toFixed(2)},${A.average(n[1],r[1]).toFixed(2)} T`;for(let i=2,r=s-1;i<r;i++){e=t[i];n=t[i+1];o+=`${A.average(e[0],n[0]).toFixed(2)},${A.average(e[1],n[1]).toFixed(2)} `}if(i){o+="Z"}return o}}class m extends u{__class__="KritzelImage";src="";maxWidth=300;maxHeight=300;maxCompressionSize=300;isDebugInfoVisible=true;constructor(t){super();this.src=t?.src||"";this.x=t?.x||0;this.y=t?.y||0;this.translateX=t?.translateX||0;this.translateY=t?.translateY||0;this.scale=t?.scale||1}static create(t){const i=new m;i._core=t;i.id=i.generateId();i.workspaceId=t.store.state.activeWorkspace.id;i.x=0;i.y=0;i.translateX=0;i.translateY=0;i.scale=i._core.store.state.scale;i.zIndex=t.store.currentZIndex;return i}resize(t,i,s,e){if(s<=1||e<=1){return}const n=e/this.height;this.width=this.width*n;this.height=this.height*n;this.translateX=t;this.translateY=i}calculateScaledDimensions(t){let i=t.width;let s=t.height;if(t.width>this.maxWidth||t.height>this.maxHeight){const e=this.maxWidth/t.width;const n=this.maxHeight/t.height;const r=Math.min(e,n);i=t.width*r;s=t.height*r}return{scaledWidth:i,scaledHeight:s}}}class y extends e{type="pen";color="#000000";size=6;palettes={pen:["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#808000","#800080"],highlighter:["#ffff00","#ffb347","#b4ffb4"]};constructor(t){super(t)}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(o.isLeftClick(t)){this._core.store.setState("isDrawing",true);const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.setState("currentPath",g.create(this._core,{points:[[i,s]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size}))}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===1){const i=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);this._core.store.setState("isDrawing",true);this._core.store.setState("currentPath",g.create(this._core,{points:[[i,s]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size}));this._core.rerender()}}}handlePointerMove(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._core.store.state.isDrawing){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.setState("currentPath",g.create(this._core,{points:[...this._core.store.state.currentPath.points,[i,s]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size}));this._core.rerender()}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===1){const i=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);this._core.store.setState("currentPath",g.create(this._core,{points:[...this._core.store.state.currentPath.points,[i,s]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size}));this._core.rerender()}}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._core.store.state.isDrawing){this._core.store.setState("isDrawing",false);if(this._core.store.state.currentPath){const t=this._core.store.state.currentPath;t.zIndex=this._core.store.currentZIndex;this._core.store.setState("currentPath",t);this._core.history.executeCommand(new n(this._core,this,this._core.store.state.currentPath))}this._core.store.setState("currentPath",undefined)}}if(t.pointerType==="touch"){if(this._core.store.state.isDrawing){this._core.store.setState("isDrawing",false);if(this._core.store.state.currentPath){const t=this._core.store.state.currentPath;t.zIndex=this._core.store.currentZIndex;this._core.store.setState("currentPath",t);this._core.history.executeCommand(new n(this._core,this,t))}this._core.store.setState("currentPath",undefined);this._core.rerender()}}}}class b extends t{commands;constructor(t,i,s,e=false){super(t,i,e);this.commands=s}execute(){this.commands.forEach((t=>t.execute()))}undo(){this.commands.forEach((t=>t.undo()))}}class M extends u{__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,i){const s=new M(i);s._core=t;s.id=s.generateId();s.workspaceId=t.store.state.activeWorkspace.id;return s}mount(t){if(this.isMounted){return}this.elementRef=t;this.isMounted=true;this.elementRef.appendChild(this.element)}resize(t,i,s,e){if(s<=1||e<=1){return}this.width=s;this.height=e;this.translateX=t;this.translateY=i;if(this.element){this.element.style.width=`${s}px`;this.element.style.height=`${e}px`}}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 x extends t{object;constructor(t,i,s,e=false){super(t,i,e);this.object=s}execute(){this._core.store.state.objectsMap.remove((t=>t.id===this.object.id));this._core.store.state.objectsMap.filter((t=>t instanceof M)).forEach((t=>t.remount()));this._core.deleteObjectFromDatabase(this.object.id)}undo(){this._core.store.state.objectsMap.insert(this.object);this._core.store.state.objectsMap.filter((t=>t instanceof M)).forEach((t=>t.remount()));this._core.addObjectToDatabase(this.object)}}class E extends e{touchStartTimeout=null;constructor(t){super(t)}handlePointerDown(t){if(t.pointerType==="mouse"){if(o.isLeftClick(t)){this._core.store.setState("isErasing",true)}}if(t.pointerType==="touch"){this.touchStartTimeout=setTimeout((()=>{if(this._core.store.state.pointers.size===1&&!this._core.store.state.isScaling){this._core.store.setState("isErasing",true)}}),80)}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._core.store.state.isErasing){const i=this._core.getObjectsFromPointerEvent(t,".object");if(i.length===0)return;const s=this._core.store.state.pointerX;const e=this._core.store.state.pointerY;i.forEach((t=>{t.markedForRemoval=t.hitTest(s,e)}));this._core.rerender()}}if(t.pointerType==="touch"){if(this._core.store.state.pointers.size===1&&this._core.store.state.isErasing){const i=this._core.store.state.host?.shadowRoot;if(!i)return;const s=this._core.getObjectsFromPointerEvent(t,".object");if(s.length===0)return;const e=this._core.store.state.pointerX;const n=this._core.store.state.pointerY;s.forEach((t=>{t.markedForRemoval=t.hitTest(e,n)}));this._core.rerender()}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isErasing){const t=this._core.store.allObjects.filter((t=>t.markedForRemoval)).map((t=>{t.markedForRemoval=false;return new x(this._core,this,t)}));if(t.length>0){this._core.history.executeCommand(new b(this._core,this,t))}this._core.store.setState("isErasing",false)}}if(t.pointerType==="touch"){clearTimeout(this.touchStartTimeout);if(this._core.store.state.isErasing){const t=this._core.store.allObjects.filter((t=>t.markedForRemoval)).map((t=>{t.markedForRemoval=false;return new x(this._core,this,t)}));if(t.length>0){this._core.history.executeCommand(new b(this._core,this,t))}this._core.store.setState("isErasing",false)}}}}class U extends t{previousSelectionGroup;constructor(t,i,s=false){super(t,i,s);this.previousSelectionGroup=this._core.store.state.selectionGroup}execute(){this._core.store.state.objectsMap.remove((t=>t.id===this.previousSelectionGroup?.id));this._core.store.setState("selectionGroup",null)}undo(){if(this.previousSelectionGroup){this._core.store.state.objectsMap.insert(this.previousSelectionGroup);this._core.store.setState("selectionGroup",this.previousSelectionGroup)}}}class F extends t{selectionGroup;startX;startY;endX;endY;skipExecution;constructor(t,i,s,e,n,r,o=false,h=false){super(t,i,h);this.startX=s;this.startY=e;this.endX=n;this.endY=r;this.skipExecution=o;this.selectionGroup=this._core.store.state.selectionGroup}execute(){if(this.skipExecution){this.skipExecution=false;this._core.store.state.selectionGroup.objects.forEach((t=>{this._core.store.state.objectsMap.update(t);this._core.updateObjectInDatabase(t)}));return}this._core.store.setState("selectionGroup",this.selectionGroup);this._core.store.state.selectionGroup.move(this.startX,this.startY,this.endX,this.endY);this._core.store.state.selectionGroup.objects.forEach((t=>{this._core.store.state.objectsMap.update(t);this._core.updateObjectInDatabase(t)}))}undo(){this._core.store.setState("selectionGroup",this.selectionGroup);this._core.store.state.selectionGroup.move(this.endX,this.endY,this.startX,this.startY);this._core.store.state.selectionGroup.objects.forEach((t=>{this._core.store.state.objectsMap.update(t);this._core.updateObjectInDatabase(t)}))}}class P{_core;constructor(t){this._core=t}}class T extends P{dragStartX;dragStartY;startX;startY;endX;endY;hasMoved=false;constructor(t){super(t)}reset(){this.dragStartX=0;this.dragStartY=0;this.startX=0;this.startY=0;this.endX=0;this.endY=0;this.hasMoved=false}handlePointerDown(t){if(t.pointerType==="mouse"){if(o.isLeftClick(t)){if(this._core.store.state.selectionGroup?.isSelected&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.setState("isDragging",true);this.dragStartX=i;this.dragStartY=s;this.startX=this.dragStartX;this.startY=this.dragStartY}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(this._core.store.state.pointers.size===1){if(this._core.store.state.selectionGroup?.isSelected&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected){const i=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);this.dragStartX=i;this.dragStartY=s;this.startX=i;this.startY=s}}}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._core.store.state.isDragging&&this._core.store.state.selectionGroup){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this.endX=i;this.endY=s;this._core.store.state.selectionGroup.move(i,s,this.dragStartX,this.dragStartY);this.dragStartX=i;this.dragStartY=s;this.hasMoved=true}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(this._core.store.state.pointers.size===1&&this._core.store.state.selectionGroup&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected){const i=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);this._core.store.setState("isDragging",true);this.endX=i;this.endY=s;this.hasMoved=true;const e=Math.abs(i-this.startX);const n=Math.abs(s-this.startY);const r=5;if(e>r||n>r){clearTimeout(this._core.store.state.longTouchTimeout);this._core.store.state.selectionGroup.move(i,s,this.dragStartX,this.dragStartY);this.dragStartX=i;this.dragStartY=s}}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isDragging){this._core.store.setState("isDragging",false);if(this.hasMoved){this._core.history.executeCommand(new F(this._core,this,this.endX,this.endY,this.startX,this.startY,true))}this.reset()}}if(t.pointerType==="touch"){if(this._core.store.state.isDragging){this._core.store.setState("isDragging",false);if(this.hasMoved){this._core.history.executeCommand(new F(this._core,this,this.endX,this.endY,this.startX,this.startY,true))}this.reset()}}}}var S;(function(t){t["TopLeft"]="top-left";t["TopRight"]="top-right";t["BottomLeft"]="bottom-left";t["BottomRight"]="bottom-right"})(S||(S={}));class k extends t{newSize;previousSize;selectionGroup;constructor(t,i,s,e,n=false){super(t,i,n);this.previousSize=s;this.newSize=e;this.selectionGroup=this._core.store.state.selectionGroup}execute(){this._core.store.setState("selectionGroup",this.selectionGroup);this._core.store.state.selectionGroup.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height);this._core.store.state.selectionGroup.objects.forEach((t=>{this._core.store.state.objectsMap.update(t);this._core.updateObjectInDatabase(t)}))}undo(){this._core.store.setState("selectionGroup",this.selectionGroup);this._core.store.state.selectionGroup.resize(this.previousSize.x,this.previousSize.y,this.previousSize.width,this.previousSize.height);this._core.store.state.selectionGroup.objects.forEach((t=>{this._core.store.state.objectsMap.update(t);this._core.updateObjectInDatabase(t)}))}}class B extends P{initialMouseX=0;initialMouseY=0;initialSize={x:0,y:0,width:0,height:0};newSize={x:0,y:0,width:0,height:0};constructor(t){super(t)}reset(){this.initialMouseX=0;this.initialMouseY=0;this.initialSize={x:0,y:0,width:0,height:0};this.newSize={x:0,y:0,width:0,height:0}}handlePointerDown(t){if(t.pointerType==="mouse"){if(o.isLeftClick(t)){if(this._core.store.state.selectionGroup&&this._core.store.state.isResizeHandleSelected){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.setState("isResizing",true);this.initialMouseX=i;this.initialMouseY=s;this.initialSize.width=this._core.store.state.selectionGroup.width;this.initialSize.height=this._core.store.state.selectionGroup.height;this.initialSize.x=this._core.store.state.selectionGroup.translateX;this.initialSize.y=this._core.store.state.selectionGroup.translateY}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const i=t[0];if(!i){return}if(t.length===1){if(this._core.store.state.selectionGroup&&this._core.store.state.isResizeHandleSelected){const t=Math.round(i.clientX-this._core.store.offsetX);const s=Math.round(i.clientY-this._core.store.offsetY);this._core.store.setState("isResizing",true);this.initialMouseX=t;this.initialMouseY=s;this.initialSize.width=this._core.store.state.selectionGroup.width;this.initialSize.height=this._core.store.state.selectionGroup.height;this.initialSize.x=this._core.store.state.selectionGroup.translateX;this.initialSize.y=this._core.store.state.selectionGroup.translateY;clearTimeout(this._core.store.state.longTouchTimeout)}}}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._core.store.state.isResizing&&this._core.store.state.selectionGroup){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;const e=i-this.initialMouseX;const n=s-this.initialMouseY;switch(this._core.store.state.resizeHandleType){case S.TopLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height-n;this.newSize.x=e/this._core.store.state.scale+this.initialSize.x;this.newSize.y=n/this._core.store.state.scale+this.initialSize.y;break;case S.TopRight:this.newSize.width=this.initialSize.width+e;this.newSize.height=this.initialSize.height-n;this.newSize.x=this.initialSize.x;this.newSize.y=n/this._core.store.state.scale+this.initialSize.y;break;case S.BottomLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height+n;this.newSize.x=e/this._core.store.state.scale+this.initialSize.x;this.newSize.y=this.initialSize.y;break;case S.BottomRight:this.newSize.width=this.initialSize.width+e;this.newSize.height=this.initialSize.height+n;this.newSize.x=this.initialSize.x;this.newSize.y=this.initialSize.y;break}this._core.store.state.selectionGroup.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const i=t[0];if(!i){return}if(this._core.store.state.isResizing&&this._core.store.state.selectionGroup){const t=Math.round(i.clientX-this._core.store.offsetX);const s=Math.round(i.clientY-this._core.store.offsetY);const e=t-this.initialMouseX;const n=s-this.initialMouseY;switch(this._core.store.state.resizeHandleType){case S.TopLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height-n;this.newSize.x=e/this._core.store.state.scale+this.initialSize.x;this.newSize.y=n/this._core.store.state.scale+this.initialSize.y;break;case S.TopRight:this.newSize.width=this.initialSize.width+e;this.newSize.height=this.initialSize.height-n;this.newSize.x=this.initialSize.x;this.newSize.y=n/this._core.store.state.scale+this.initialSize.y;break;case S.BottomLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height+n;this.newSize.x=e/this._core.store.state.scale+this.initialSize.x;this.newSize.y=this.initialSize.y;break;case S.BottomRight:this.newSize.width=this.initialSize.width+e;this.newSize.height=this.initialSize.height+n;this.newSize.x=this.initialSize.x;this.newSize.y=this.initialSize.y;break}this._core.store.state.selectionGroup.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height);clearTimeout(this._core.store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isResizing){this._core.history.executeCommand(new k(this._core,this,structuredClone(this.initialSize),structuredClone(this.newSize)));this._core.store.setState("isResizing",false);this.reset()}}if(t.pointerType==="touch"){if(this._core.store.state.isResizing){this._core.history.executeCommand(new k(this._core,this,structuredClone(this.initialSize),structuredClone(this.newSize)));this._core.store.setState("isResizing",false);this.reset();clearTimeout(this._core.store.state.longTouchTimeout)}}}}class z extends t{rotation;initialRotation;selectionGroup;constructor(t,i,s,e,n=false){super(t,i,n);this.rotation=s;this.initialRotation=e;this.selectionGroup=this._core.store.state.selectionGroup}execute(){this._core.store.setState("selectionGroup",this.selectionGroup);this._core.store.state.selectionGroup.rotate(this.rotation);this._core.store.state.selectionGroup.objects.forEach((t=>{this._core.store.state.objectsMap.update(t);this._core.updateObjectInDatabase(t)}))}undo(){this._core.store.setState("selectionGroup",this.selectionGroup);this._core.store.state.selectionGroup.rotate(this.initialRotation);this._core.store.state.selectionGroup.objects.forEach((t=>{this._core.store.state.objectsMap.update(t);this._core.updateObjectInDatabase(t)}))}}class _ extends P{initialRotation=0;rotation=0;unchangedObjects=[];initialSelectionGroupRotation=0;constructor(t){super(t)}reset(){this.initialRotation=0;this.rotation=0;this.unchangedObjects=[]}handlePointerDown(t){if(t.pointerType==="mouse"){if(o.isLeftClick(t)){if(this._core.store.state.selectionGroup&&this._core.store.state.isRotationHandleSelected){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.setState("isRotating",true);const e=this._core.store.state.selectionGroup.translateX+this._core.store.state.selectionGroup.width/2/this._core.store.state.scale;const n=this._core.store.state.selectionGroup.translateY+this._core.store.state.selectionGroup.height/2/this._core.store.state.scale;const r=(i-this._core.store.state.translateX)/this._core.store.state.scale;const o=(s-this._core.store.state.translateY)/this._core.store.state.scale;this.initialSelectionGroupRotation=this._core.store.state.selectionGroup.rotation;this.initialRotation=Math.atan2(n-o,e-r)-this._core.store.state.selectionGroup.rotation;this.unchangedObjects=this._core.store.state.selectionGroup.objects.map((t=>t.clone()))}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const i=t[0];if(!i){return}if(t.length===1){if(this._core.store.state.selectionGroup&&this._core.store.state.isRotationHandleSelected){const t=Math.round(i.clientX-this._core.store.offsetX);const s=Math.round(i.clientY-this._core.store.offsetY);this._core.store.setState("isRotating",true);const e=this._core.store.state.selectionGroup.translateX+this._core.store.state.selectionGroup.width/2/this._core.store.state.scale;const n=this._core.store.state.selectionGroup.translateY+this._core.store.state.selectionGroup.height/2/this._core.store.state.scale;const r=(t-this._core.store.state.translateX)/this._core.store.state.scale;const o=(s-this._core.store.state.translateY)/this._core.store.state.scale;this.initialRotation=Math.atan2(n-o,e-r)-this._core.store.state.selectionGroup.rotation;this.unchangedObjects=this._core.store.state.selectionGroup.objects.map((t=>t.clone()));clearTimeout(this._core.store.state.longTouchTimeout)}}}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._core.store.state.isRotating&&this._core.store.state.selectionGroup){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;const e=this._core.store.state.selectionGroup.translateX+this._core.store.state.selectionGroup.width/2/this._core.store.state.scale;const n=this._core.store.state.selectionGroup.translateY+this._core.store.state.selectionGroup.height/2/this._core.store.state.scale;const r=(i-this._core.store.state.translateX)/this._core.store.state.scale;const o=(s-this._core.store.state.translateY)/this._core.store.state.scale;const h=Math.atan2(n-o,e-r);this.rotation=h-this.initialRotation;this._core.store.state.selectionGroup.rotate(this.rotation)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const i=t[0];if(!i){return}if(this._core.store.state.isRotating&&this._core.store.state.selectionGroup){const t=Math.round(i.clientX-this._core.store.offsetX);const s=Math.round(i.clientY-this._core.store.offsetY);const e=this._core.store.state.selectionGroup.translateX+this._core.store.state.selectionGroup.width/2/this._core.store.state.scale;const n=this._core.store.state.selectionGroup.translateY+this._core.store.state.selectionGroup.height/2/this._core.store.state.scale;const r=(t-this._core.store.state.translateX)/this._core.store.state.scale;const o=(s-this._core.store.state.translateY)/this._core.store.state.scale;const h=Math.atan2(n-o,e-r);this.rotation=h-this.initialRotation;this._core.store.state.selectionGroup.rotate(this.rotation);clearTimeout(this._core.store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isRotating){this._core.history.executeCommand(new z(this._core,this,this.rotation,this.initialSelectionGroupRotation));this._core.store.setState("isRotating",false);this.reset()}}if(t.pointerType==="touch"){if(this._core.store.state.isRotating){this._core.history.executeCommand(new z(this._core,this,this.rotation,this.initialSelectionGroupRotation));this._core.store.setState("isRotating",false);this.reset();clearTimeout(this._core.store.state.longTouchTimeout)}}}}class I extends u{__class__="KrtizelSelectionBox";objects=[];static create(t){const i=new I;i._core=t;i.id=i.generateId();i.workspaceId=t.store.state.activeWorkspace.id;i.scale=t.store.state.scale;i.zIndex=99999;i.backgroundColor="var(--kritzel-selection-box-background-color, rgba(0, 122, 255, 0.2))";i.borderColor="var(--kritzel-selection-box-border-color, rgba(0, 122, 255, 0.5))";i.borderWidth=2;i.height=0;i.width=0;return i}}class C extends t{selectionGroup;previousSelectionGroup;constructor(t,i,s,e,n=false){super(t,i,n);this.selectionGroup=s;this.previousSelectionGroup=e||null}execute(){this._core.store.state.objectsMap.remove((t=>t instanceof I||t instanceof K));this._core.store.state.objectsMap.insert(this.selectionGroup);this._core.store.setState("selectionGroup",this.selectionGroup);this._core.store.setState("selectionBox",null)}undo(){this._core.store.state.objectsMap.remove((t=>t.id===this.selectionGroup.id));this._core.store.setState("selectionGroup",this.previousSelectionGroup);this._core.store.setState("selectionBox",null)}}class j extends P{startX;startY;touchStartX=0;touchStartY=0;touchStartTimeout=null;get isSelectionClick(){return this._core.store.state.selectionBox&&this._core.store.state.selectionBox.width===0&&this._core.store.state.selectionBox.height===0}get isSelectionDrag(){return this._core.store.state.selectionBox&&(this._core.store.state.selectionBox.width>0||this._core.store.state.selectionBox.height>0)}constructor(t){super(t)}handlePointerDown(t){if(t.pointerType==="mouse"){if(o.isLeftClick(t)&&!this._core.store.state.selectionGroup){this.startMouseSelection(t)}}if(t.pointerType==="touch"){this.touchStartTimeout=setTimeout((()=>{if(this._core.store.state.pointers.size===1&&!this._core.store.state.isScaling&&!this._core.store.state.selectionGroup){this.startTouchSelection();this.updateTouchSelection()}}),80)}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._core.store.state.isSelecting){this.updateMouseSelection(t)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const i=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);const e=Math.abs(i-this.touchStartX);const n=Math.abs(s-this.touchStartY);const r=5;if((e>r||n>r)&&this._core.store.state.isSelecting){this.updateTouchSelection();clearTimeout(this._core.store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(o.isLeftClick(t)&&this._core.store.state.isSelecting){if(this.isSelectionClick){const i=this._core.store.state.pointerX;const s=this._core.store.state.pointerY;const e=this._core.getObjectsFromPointerEvent(t,".object").find((t=>t.hitTest(i,s)));this.addObjectToSelectionGroup(e);this.removeSelectionBox()}if(this.isSelectionDrag){this.updateMouseSelection(t);this.addSelectedObjectsToSelectionGroup();this.removeSelectionBox()}}}if(t.pointerType==="touch"){clearTimeout(this.touchStartTimeout);if(this._core.store.state.isSelecting){if(this.isSelectionClick){const i=this._core.store.state.pointerX;const s=this._core.store.state.pointerY;const e=this._core.getObjectsFromPointerEvent(t,".object").find((t=>t.hitTest(i,s)));this.addObjectToSelectionGroup(e);this.removeSelectionBox()}if(this.isSelectionDrag){this.updateTouchSelection();this.addSelectedObjectsToSelectionGroup();this.removeSelectionBox()}this._core.store.setState("skipContextMenu",false)}}}removeSelectionBox(){this._core.store.setState("selectionBox",null);this._core.store.setState("isSelecting",false);this._core.store.state.objectsMap.remove((t=>t instanceof I))}startMouseSelection(t){let i,s;i=t.clientX-this._core.store.offsetX;s=t.clientY-this._core.store.offsetY;const e=I.create(this._core);this.startX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this.startY=(s-this._core.store.state.translateY)/this._core.store.state.scale;e.translateX=this.startX;e.translateY=this.startY;this._core.store.setState("selectionGroup",null);this._core.store.setState("selectionBox",e);this._core.store.setState("isSelecting",true);this._core.store.state.objectsMap.remove((t=>t instanceof I||t instanceof K));this._core.store.state.objectsMap.insert(e)}startTouchSelection(){const t=Array.from(this._core.store.state.pointers.values());const i=t[0];if(!i){return}let s,e;s=Math.round(i.clientX-this._core.store.offsetX);e=Math.round(i.clientY-this._core.store.offsetY);this.touchStartX=s;this.touchStartY=e;const n=I.create(this._core);this.startX=(s-this._core.store.state.translateX)/this._core.store.state.scale;this.startY=(e-this._core.store.state.translateY)/this._core.store.state.scale;n.translateX=this.startX;n.translateY=this.startY;this._core.store.setState("selectionGroup",null);this._core.store.setState("selectionBox",n);this._core.store.setState("isSelecting",true);this._core.store.state.objectsMap.remove((t=>t instanceof I||t instanceof K));this._core.store.state.objectsMap.insert(n)}updateMouseSelection(t){let i,s;i=t.clientX-this._core.store.offsetX;s=t.clientY-this._core.store.offsetY;const e=this._core.store.state.selectionBox;if(e){const t=(i-this._core.store.state.translateX)/e.scale;const n=(s-this._core.store.state.translateY)/e.scale;e.width=Math.abs(t-this.startX)*e.scale;e.height=Math.abs(n-this.startY)*e.scale;e.translateX=Math.min(t,this.startX);e.translateY=Math.min(n,this.startY);this.updateSelectedObjects()}}updateTouchSelection(){const t=Array.from(this._core.store.state.pointers.values());const i=t[0];if(!i){return}let s,e;s=Math.round(i.clientX-this._core.store.offsetX);e=Math.round(i.clientY-this._core.store.offsetY);const n=this._core.store.state.selectionBox;if(n){const t=(s-this._core.store.state.translateX)/n.scale;const i=(e-this._core.store.state.translateY)/n.scale;n.width=Math.abs(t-this.startX)*n.scale;n.height=Math.abs(i-this.startY)*n.scale;n.translateX=Math.min(t,this.startX);n.translateY=Math.min(i,this.startY);this.updateSelectedObjects()}}updateSelectedObjects(){this._core.store.allObjects.filter((t=>!(t instanceof I))).forEach((t=>t.isSelected=t.hitTestPolygon(this._core.store.state.selectionBox.rotatedPolygon)))}addObjectToSelectionGroup(t){if(!t){return}const i=K.create(this._core);i.addOrRemove(t);i.isSelected=true;i.rotation=t.rotation;this._core.store.setState("selectionGroup",i);this._core.history.executeCommand(new C(this._core,this,this._core.store.state.selectionGroup))}addSelectedObjectsToSelectionGroup(){const t=this._core.store.selectedObjects;if(t.length===0){return}this._core.store.setState("selectionGroup",K.create(this._core));t.forEach((t=>{t.isSelected=false;this._core.store.state.selectionGroup.addOrRemove(t)}));const i=this._core.store.state.selectionGroup;i.isSelected=true;if(i.length===1){i.rotation=i.objects[0].rotation}this._core.store.setState("selectionGroup",i);this._core.history.executeCommand(new C(this._core,this,this._core.store.state.selectionGroup))}}class R extends P{constructor(t){super(t)}handlePointerMove(t){if(t.pointerType==="mouse"){const i=this._core.getObjectFromPointerEvent(t,".object");if(!i)return;const s=this._core.store.state.pointerX;const e=this._core.store.state.pointerY;i.isHovered=i.hitTest(s,e)}}}class D extends e{selectionHandler;moveHandler;hoverHandler;resizeHandler;rotationHandler;constructor(t){super(t);this.selectionHandler=new j(this._core);this.moveHandler=new T(this._core);this.hoverHandler=new R(this._core);this.resizeHandler=new B(this._core);this.rotationHandler=new _(this._core)}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(o.isLeftClick(t)){this._core.store.setState("isResizeHandleSelected",this.isHandleSelected(t));this._core.store.setState("isRotationHandleSelected",this.isRotationHandleSelected(t));this._core.store.setState("resizeHandleType",this.getHandleType(t));const i=this.getSelectedObject(t);const s=i&&this._core.store.state.selectionGroup&&i.id!==this._core.store.state.selectionGroup.id;if((i===null||s)&&this._core.store.state.selectionGroup&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected){this._core.history.executeCommand(new U(this._core,this._core.store.state.selectionGroup))}if(i&&i.isSelected===false&&i?.objects.length===1&&i.objects[0].isInteractive){return}}this.moveHandler.handlePointerDown(t);this.selectionHandler.handlePointerDown(t);this.resizeHandler.handlePointerDown(t);this.rotationHandler.handlePointerDown(t);this._core.rerender()}if(t.pointerType==="touch"){if(this._core.store.state.isScaling===true){return}if(this._core.store.state.pointers.size===1){this._core.store.setState("isResizeHandleSelected",this.isHandleSelected(t));this._core.store.setState("isRotationHandleSelected",this.isRotationHandleSelected(t));this._core.store.setState("resizeHandleType",this.getHandleType(t));const i=this.getSelectedObject(t);const s=i&&this._core.store.state.selectionGroup&&i.id!==this._core.store.state.selectionGroup.id;if(!this._core.store.state.selectionGroup&&i){this._core.store.setState("skipContextMenu",true)}if((i===null||s)&&this._core.store.state.selectionGroup&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected){this._core.history.executeCommand(new U(this._core,this._core.store.state.selectionGroup))}}this.rotationHandler.handlePointerDown(t);this.resizeHandler.handlePointerDown(t);this.moveHandler.handlePointerDown(t);this.selectionHandler.handlePointerDown(t);this._core.rerender()}}handlePointerMove(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){this.moveHandler.handlePointerMove(t);this.hoverHandler.handlePointerMove(t);this.selectionHandler.handlePointerMove(t);this.resizeHandler.handlePointerMove(t);this.rotationHandler.handlePointerMove(t);this._core.rerender()}if(t.pointerType==="touch"){if(this._core.store.state.isScaling===true){return}this.rotationHandler.handlePointerMove(t);this.resizeHandler.handlePointerMove(t);this.moveHandler.handlePointerMove(t);this.selectionHandler.handlePointerMove(t);this._core.rerender()}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){this.moveHandler.handlePointerUp(t);this.selectionHandler.handlePointerUp(t);this.resizeHandler.handlePointerUp(t);this.rotationHandler.handlePointerUp(t);this._core.rerender()}if(t.pointerType==="touch"){if(this._core.store.state.isScaling===true){return}this.rotationHandler.handlePointerUp(t);this.resizeHandler.handlePointerUp(t);this.moveHandler.handlePointerUp(t);this.selectionHandler.handlePointerUp(t);this._core.rerender()}}getSelectedObject(t){const i=t.composedPath().slice(1);const s=i.find((t=>t.classList&&t.classList.contains("object")));const e=this._core.findObjectById(s?.id);if(!e){return null}if(e instanceof K){return e}else{const t=K.create(this._core);t.translateX=0;t.translateY=0;t.addOrRemove(e);return t}}getHandleType(t){const i=this._core.store.state.host?.shadowRoot;if(!i)return;const s=i.elementFromPoint(t.clientX,t.clientY);const e=s?.closest(".resize-handle-overlay");return e?.classList[1]}isHandleSelected(t){const i=this._core.store.state.host?.shadowRoot;if(!i)return false;const s=i.elementFromPoint(t.clientX,t.clientY);return!!s?.classList.contains("resize-handle-overlay")}isRotationHandleSelected(t){const i=t.composedPath();return!!i.find((t=>t.classList&&t.classList.contains("rotation-handle-overlay")))}}const O={type:"pen",color:"#000000",size:16,palettes:{pen:["#000000","#ff5252","#ffbc00","#00c853","#0000FF","#d500f9","#fafafa","#a52714","#ee8100","#558b2f","#01579b","#8e24aa","#90a4ae","#ff4081","#ff6e40","#aeea00","#304ffe","#7c4dff","#cfd8dc","#f8bbd0","#ffccbc","#f0f4c3","#9fa8da","#d1c4e9"],highlighter:["#0000006e","#ff52526e","#ffbb006e","#00c8536e","#0000FF6e","#d500f96e","#fafafa6e","#a527146e","#ee81006e","#558b2f6e","#01579b6e","#8e24aa6e","#90a4ae6e","#ff40816e","#ff6e406e","#aeea006e","#304ffe6e","#7c4dff6e","#cfd8dc6e","#f8bbd06e","#ffccbc6e","#f0f4c36e","#9fa8da6e","#d1c4e96e"]}};const Q={color:"#000000",size:8,fontFamily:"Arial",palette:["#000000","#ff5252","#ffbc00","#00c853","#0000FF","#d500f9","#fafafa","#a52714","#ee8100","#558b2f","#01579b","#8e24aa","#90a4ae","#ff4081","#ff6e40","#aeea00","#304ffe","#7c4dff","#cfd8dc","#f8bbd0","#ffccbc","#f0f4c3","#9fa8da","#d1c4e9"]};class G{__class__="KritzelWorkspace";id;name;createdAt;updatedAt;viewport;_core;constructor(t,i,s={translateX:0,translateY:0,scale:1}){this.id=t;this.name=i;this.createdAt=new Date;this.updatedAt=new Date;this.viewport=s}static create(t,i){const s=new G(i.id,i.name,i.viewport);s._core=t;Object.assign(s,i);return s}addObject(t){this._core.engine.addObject(t)}serialize(){return{__class__:this.__class__,id:this.id,name:this.name,createdAt:this.createdAt,updatedAt:this.updatedAt,viewport:this.viewport}}deserialize(t){Object.assign(this,t);this.createdAt=new Date(t.createdAt);this.updatedAt=new Date(t.updatedAt);return this}}class H{_core;constructor(t){this._core=t}revive(t){if(t&&typeof t==="object"){if(t.__class__){let i;switch(t.__class__){case"KritzelPath":i=g.create(this._core).deserialize(t);break;case"KritzelText":i=l.create(this._core,t.fontSize,t.fontFamily).deserialize(t);break;case"KritzelImage":i=m.create(this._core).deserialize(t);break;case"KritzelCustomElement":i=M.create(this._core).deserialize(t);break;case"KritzelSelectionGroup":i=K.create(this._core).deserialize(t);break;case"KritzelWorkspace":i=G.create(this._core,t).deserialize(t);break;case"KritzelBrushTool":i=new y(this._core);break;case"KritzelEraserTool":i=new E(this._core);break;case"KritzelImageTool":i=new Ut(this._core);break;case"KritzelSelectionTool":i=new D(this._core);break;case"KritzelTextTool":i=new c(this._core);break;default:i=t}return i}const i=Array.isArray(t)?[]:{};for(const s in t){if(Object.prototype.hasOwnProperty.call(t,s)){i[s]=this.revive(t[s])}}return i}return t}}class K extends u{__class__="KritzelSelectionGroup";objects=[];unchangedObjects=[];minX;maxX;minY;maxY;get length(){return this.objects.length}static create(t){const i=new K;i._core=t;i.id=i.generateId();i.workspaceId=t.store.state.activeWorkspace.id;i.scale=t.store.state.scale;i.zIndex=99999;return i}addOrRemove(t){const i=this.objects.findIndex((i=>i.id===t.id));if(i===-1){this.objects.push(t)}else{this.objects.splice(i,1)}this.unchangedObjects=this.objects.map((t=>t.clone()));this.refreshObjectDimensions()}deselectAllChildren(){this.objects.forEach((t=>t.isSelected=false))}updatePosition(t,i){this.objects.forEach((s=>{const e=s.translateX-this.translateX;const n=s.translateY-this.translateY;s.updatePosition(t+e,i+n)}));this.unchangedObjects.forEach((s=>{const e=s.translateX-this.translateX;const n=s.translateY-this.translateY;s.translateX=t+e;s.translateY=i+n}));this.translateX=t;this.translateY=i;this._core.store.state.objectsMap.update(this)}move(t,i,s,e){const n=(t-s)/this._core.store.state.scale;const r=(i-e)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r;this._core.store.state.objectsMap.update(this);this.objects.forEach((n=>{n.move(t,i,s,e);this._core.store.state.objectsMap.update(n)}));this.unchangedObjects.forEach((t=>{t.translateX+=n;t.translateY+=r}))}resize(t,i,s,e){const n=s/this.width;const r=e/this.height;const o=t-this.translateX;const h=i-this.translateY;this.objects.forEach((t=>{const i=t.width*n;const s=t.height*r;const e=t.translateX+o+(t.translateX-this.translateX)*(n-1);const c=t.translateY+h+(t.translateY-this.translateY)*(r-1);t.resize(e,c,i,s);this._core.store.state.objectsMap.update(t)}));this.refreshObjectDimensions();this.unchangedObjects=this.objects.map((t=>t.clone()))}rotate(t){this.rotation=t;const i=this.translateX+this.totalWidth/2/this.scale;const s=this.translateY+this.totalHeight/2/this.scale;const e=t;const n=Math.cos(e);const r=Math.sin(e);this.objects.forEach((e=>{const o=this.getUnchangedObject(e.id);const h=this.getOffsetXToCenter(o);const c=this.getOffsetYToCenter(o);const a=n*h-r*c;const f=r*h+n*c;e.translateX=i+a-e.totalWidth/2/e.scale;e.translateY=s+f-e.totalHeight/2/e.scale;e.rotate(this.objects.length===1?t:t+o.rotation);this._core.store.state.objectsMap.update(e)}))}copy(){const t=K.create(this._core);let i=this._core.store.currentZIndex;this.objects.sort(((t,i)=>t.zIndex-i.zIndex)).forEach((s=>{const e=s.copy();e.zIndex=i;t.addOrRemove(e);i++}));t.unchangedObjects=t.objects.map((t=>t.clone()));if(this.objects.length===1){t.rotation=this.objects[0].rotation}return t}refreshObjectDimensions(){if(this.objects.length===1){const t=this.objects[0];this.minX=t.boundingBox.x/this.scale;this.maxX=t.boundingBox.x/this.scale+t.boundingBox.width;this.minY=t.boundingBox.y/this.scale;this.maxY=t.boundingBox.y/this.scale+t.boundingBox.height;this.translateX=(this.minX-this.padding)*this.scale;this.translateY=(this.minY-this.padding)*this.scale;this.width=(this.maxX-this.minX-this.padding)*this.scale;this.height=(this.maxY-this.minY-this.padding)*this.scale}else{this.minX=Math.min(...this.objects.map((t=>t.minXRotated)));this.maxX=Math.max(...this.objects.map((t=>t.maxXRotated)));this.minY=Math.min(...this.objects.map((t=>t.minYRotated)));this.maxY=Math.max(...this.objects.map((t=>t.maxYRotated)));this.translateX=this.minX-this.padding;this.translateY=this.minY-this.padding;this.width=(this.maxX-this.minX-this.padding)*this.scale;this.height=(this.maxY-this.minY-this.padding)*this.scale}this._core.store.state.objectsMap.update(this)}getOffsetXToCenter(t){const i=t.translateX+t.totalWidth/t.scale/2;const s=this.translateX+this.totalWidth/this.scale/2;return i-s}getOffsetYToCenter(t){const i=t.translateY+t.totalHeight/t.scale/2;const s=this.translateY+this.totalHeight/this.scale/2;return i-s}getUnchangedObject(t){const i=this.unchangedObjects.find((i=>i.id===t));const s=new H(this._core);return s.revive(i)}}function X(t,i){return i.forEach((function(i){i&&"string"!=typeof i&&!Array.isArray(i)&&Object.keys(i).forEach((function(s){if("default"!==s&&!(s in t)){var e=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(t,s,e.get?e:{enumerable:true,get:function(){return i[s]}})}}))})),Object.freeze(t)}function W(t,i){return new Promise((function(s,e){let n;return L(t).then((function(t){try{return n=t,s(new Blob([i.slice(0,2),n,i.slice(2)],{type:"image/jpeg"}))}catch(t){return e(t)}}),e)}))}const L=t=>new Promise(((i,s)=>{const e=new FileReader;e.addEventListener("load",(({target:{result:t}})=>{const e=new DataView(t);let n=0;if(65496!==e.getUint16(n))return s("not a valid JPEG");for(n+=2;;){const r=e.getUint16(n);if(65498===r)break;const o=e.getUint16(n+2);if(65505===r&&1165519206===e.getUint32(n+4)){const r=n+10;let h;switch(e.getUint16(r)){case 18761:h=true;break;case 19789:h=false;break;default:return s("TIFF header contains invalid endian")}if(42!==e.getUint16(r+2,h))return s("TIFF header contains invalid version");const c=e.getUint32(r+4,h),a=r+c+2+12*e.getUint16(r+c,h);for(let t=r+c+2;t<a;t+=12){if(274==e.getUint16(t,h)){if(3!==e.getUint16(t+2,h))return s("Orientation data type is invalid");if(1!==e.getUint32(t+4,h))return s("Orientation data count is invalid");e.setUint16(t+8,1,h);break}}return i(t.slice(n,n+2+o))}n+=2+o}return i(new Blob)})),e.readAsArrayBuffer(t)}));var Y={},$={get exports(){return Y},set exports(t){Y=t}};!function(t){var i,s,e={};$.exports=e,e.parse=function(t,i){for(var s=e.bin.readUshort,n=e.bin.readUint,r=0,o={},h=new Uint8Array(t),c=h.length-4;101010256!=n(h,c);)c--;r=c;r+=4;var a=s(h,r+=4);s(h,r+=2);var f=n(h,r+=2),u=n(h,r+=4);r+=4,r=u;for(var l=0;l<a;l++){n(h,r),r+=4,r+=4,r+=4,n(h,r+=4);f=n(h,r+=4);var d=n(h,r+=4),v=s(h,r+=4),w=s(h,r+2),p=s(h,r+4);r+=6;var A=n(h,r+=8);r+=4,r+=v+w+p,e._readLocal(h,A,o,f,d,i)}return o},e._readLocal=function(t,i,s,n,r,o){var h=e.bin.readUshort,c=e.bin.readUint;c(t,i),h(t,i+=4),h(t,i+=2);var a=h(t,i+=2);c(t,i+=2),c(t,i+=4),i+=4;var f=h(t,i+=8),u=h(t,i+=2);i+=2;var l=e.bin.readUTF8(t,i,f);if(i+=f,i+=u,o)s[l]={size:r,csize:n};else{var d=new Uint8Array(t.buffer,i);if(0==a)s[l]=new Uint8Array(d.buffer.slice(i,i+n));else{if(8!=a)throw"unknown compression method: "+a;var v=new Uint8Array(r);e.inflateRaw(d,v),s[l]=v}}},e.inflateRaw=function(t,i){return e.F.inflate(t,i)},e.inflate=function(t,i){return e.inflateRaw(new Uint8Array(t.buffer,t.byteOffset+2,t.length-6),i)},e.deflate=function(t,i){null==i&&(i={level:6});var s=0,n=new Uint8Array(50+Math.floor(1.1*t.length));n[s]=120,n[s+1]=156,s+=2,s=e.F.deflateRaw(t,n,s,i.level);var r=e.adler(t,0,t.length);return n[s+0]=r>>>24&255,n[s+1]=r>>>16&255,n[s+2]=r>>>8&255,n[s+3]=r>>>0&255,new Uint8Array(n.buffer,0,s+4)},e.deflateRaw=function(t,i){null==i&&(i={level:6});var s=new Uint8Array(50+Math.floor(1.1*t.length)),n=e.F.deflateRaw(t,s,n,i.level);return new Uint8Array(s.buffer,0,n)},e.encode=function(t,i){null==i&&(i=false);var s=0,n=e.bin.writeUint,r=e.bin.writeUshort,o={};for(var h in t){var c=!e._noNeed(h)&&!i,a=t[h],f=e.crc.crc(a,0,a.length);o[h]={cpr:c,usize:a.length,crc:f,file:c?e.deflateRaw(a):a}}for(var h in o)s+=o[h].file.length+30+46+2*e.bin.sizeUTF8(h);s+=22;var u=new Uint8Array(s),l=0,d=[];for(var h in o){var v=o[h];d.push(l),l=e._writeHeader(u,l,h,v,0)}var w=0,p=l;for(var h in o){v=o[h];d.push(l),l=e._writeHeader(u,l,h,v,1,d[w++])}var A=l-p;return n(u,l,101010256),l+=4,r(u,l+=4,w),r(u,l+=2,w),n(u,l+=2,A),n(u,l+=4,p),l+=4,l+=2,u.buffer},e._noNeed=function(t){var i=t.split(".").pop().toLowerCase();return-1!="png,jpg,jpeg,zip".indexOf(i)},e._writeHeader=function(t,i,s,n,r,o){var h=e.bin.writeUint,c=e.bin.writeUshort,a=n.file;return h(t,i,0==r?67324752:33639248),i+=4,1==r&&(i+=2),c(t,i,20),c(t,i+=2,0),c(t,i+=2,n.cpr?8:0),h(t,i+=2,0),h(t,i+=4,n.crc),h(t,i+=4,a.length),h(t,i+=4,n.usize),c(t,i+=4,e.bin.sizeUTF8(s)),c(t,i+=2,0),i+=2,1==r&&(i+=2,i+=2,h(t,i+=6,o),i+=4),i+=e.bin.writeUTF8(t,i,s),0==r&&(t.set(a,i),i+=a.length),i},e.crc={table:function(){for(var t=new Uint32Array(256),i=0;i<256;i++){for(var s=i,e=0;e<8;e++)1&s?s=3988292384^s>>>1:s>>>=1;t[i]=s}return t}(),update:function(t,i,s,n){for(var r=0;r<n;r++)t=e.crc.table[255&(t^i[s+r])]^t>>>8;return t},crc:function(t,i,s){return 4294967295^e.crc.update(4294967295,t,i,s)}},e.adler=function(t,i,s){for(var e=1,n=0,r=i,o=i+s;r<o;){for(var h=Math.min(r+5552,o);r<h;)n+=e+=t[r++];e%=65521,n%=65521}return n<<16|e},e.bin={readUshort:function(t,i){return t[i]|t[i+1]<<8},writeUshort:function(t,i,s){t[i]=255&s,t[i+1]=s>>8&255},readUint:function(t,i){return 16777216*t[i+3]+(t[i+2]<<16|t[i+1]<<8|t[i])},writeUint:function(t,i,s){t[i]=255&s,t[i+1]=s>>8&255,t[i+2]=s>>16&255,t[i+3]=s>>24&255},readASCII:function(t,i,s){for(var e="",n=0;n<s;n++)e+=String.fromCharCode(t[i+n]);return e},writeASCII:function(t,i,s){for(var e=0;e<s.length;e++)t[i+e]=s.charCodeAt(e)},pad:function(t){return t.length<2?"0"+t:t},readUTF8:function(t,i,s){for(var n,r="",o=0;o<s;o++)r+="%"+e.bin.pad(t[i+o].toString(16));try{n=decodeURIComponent(r)}catch(n){return e.bin.readASCII(t,i,s)}return n},writeUTF8:function(t,i,s){for(var e=s.length,n=0,r=0;r<e;r++){var o=s.charCodeAt(r);if(0==(4294967168&o))t[i+n]=o,n++;else if(0==(4294965248&o))t[i+n]=192|o>>6,t[i+n+1]=128|o>>0&63,n+=2;else if(0==(4294901760&o))t[i+n]=224|o>>12,t[i+n+1]=128|o>>6&63,t[i+n+2]=128|o>>0&63,n+=3;else{if(0!=(4292870144&o))throw"e";t[i+n]=240|o>>18,t[i+n+1]=128|o>>12&63,t[i+n+2]=128|o>>6&63,t[i+n+3]=128|o>>0&63,n+=4}}return n},sizeUTF8:function(t){for(var i=t.length,s=0,e=0;e<i;e++){var n=t.charCodeAt(e);if(0==(4294967168&n))s++;else if(0==(4294965248&n))s+=2;else if(0==(4294901760&n))s+=3;else{if(0!=(4292870144&n))throw"e";s+=4}}return s}},e.F={},e.F.deflateRaw=function(t,i,s,n){var r=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][n],o=e.F.U,h=e.F._goodIndex;var c=e.F._putsE,a=0,f=s<<3,u=0,l=t.length;if(0==n){for(;a<l;){c(i,f,a+(E=Math.min(65535,l-a))==l?1:0),f=e.F._copyExact(t,a,E,i,f+8),a+=E}return f>>>3}var d=o.lits,v=o.strt,w=o.prev,p=0,A=0,g=0,m=0,y=0,b=0;for(l>2&&(v[b=e.F._hash(t,0)]=0),a=0;a<l;a++){if(y=b,a+1<l-2){b=e.F._hash(t,a+1);var M=a+1&32767;w[M]=v[b],v[b]=M}if(u<=a){(p>14e3||A>26697)&&l-a>100&&(u<a&&(d[p]=a-u,p+=2,u=a),f=e.F._writeBlock(a==l-1||u==l?1:0,d,p,m,t,g,a-g,i,f),p=A=m=0,g=a);var x=0;a<l-2&&(x=e.F._bestMatch(t,a,w,y,Math.min(r[2],l-a),r[3]));var E=x>>>16,U=65535&x;if(0!=x){U=65535&x;var F=h(E=x>>>16,o.of0);o.lhst[257+F]++;var P=h(U,o.df0);o.dhst[P]++,m+=o.exb[F]+o.dxb[P],d[p]=E<<23|a-u,d[p+1]=U<<16|F<<8|P,p+=2,u=a+E}else o.lhst[t[a]]++;A++}}for(g==a&&0!=t.length||(u<a&&(d[p]=a-u,p+=2,u=a),f=e.F._writeBlock(1,d,p,m,t,g,a-g,i,f),p=0,A=0,p=A=m=0,g=a);0!=(7&f);)f++;return f>>>3},e.F._bestMatch=function(t,i,s,n,r,o){var h=32767&i,c=s[h],a=h-c+32768&32767;if(c==h||n!=e.F._hash(t,i-a))return 0;for(var f=0,u=0,l=Math.min(32767,i);a<=l&&0!=--o&&c!=h;){if(0==f||t[i+f]==t[i+f-a]){var d=e.F._howLong(t,i,a);if(d>f){if(u=a,(f=d)>=r)break;a+2<d&&(d=a+2);for(var v=0,w=0;w<d-2;w++){var p=i-a+w+32768&32767,A=p-s[p]+32768&32767;A>v&&(v=A,c=p)}}}a+=(h=c)-(c=s[h])+32768&32767}return f<<16|u},e.F._howLong=function(t,i,s){if(t[i]!=t[i-s]||t[i+1]!=t[i+1-s]||t[i+2]!=t[i+2-s])return 0;var e=i,n=Math.min(t.length,i+258);for(i+=3;i<n&&t[i]==t[i-s];)i++;return i-e},e.F._hash=function(t,i){return(t[i]<<8|t[i+1])+(t[i+2]<<4)&65535},e.saved=0,e.F._writeBlock=function(t,i,s,n,r,o,h,c,a){var f,u,l,d,v,w,p,A,g,m=e.F.U,y=e.F._putsF,b=e.F._putsE;m.lhst[256]++,u=(f=e.F.getTrees())[0],l=f[1],d=f[2],v=f[3],w=f[4],p=f[5],A=f[6],g=f[7];var M=32+(0==(a+3&7)?0:8-(a+3&7))+(h<<3),x=n+e.F.contSize(m.fltree,m.lhst)+e.F.contSize(m.fdtree,m.dhst),E=n+e.F.contSize(m.ltree,m.lhst)+e.F.contSize(m.dtree,m.dhst);E+=14+3*p+e.F.contSize(m.itree,m.ihst)+(2*m.ihst[16]+3*m.ihst[17]+7*m.ihst[18]);for(var U=0;U<286;U++)m.lhst[U]=0;for(U=0;U<30;U++)m.dhst[U]=0;for(U=0;U<19;U++)m.ihst[U]=0;var F=M<x&&M<E?0:x<E?1:2;if(y(c,a,t),y(c,a+1,F),a+=3,0==F){for(;0!=(7&a);)a++;a=e.F._copyExact(r,o,h,c,a)}else{var P,T;if(1==F&&(P=m.fltree,T=m.fdtree),2==F){e.F.makeCodes(m.ltree,u),e.F.revCodes(m.ltree,u),e.F.makeCodes(m.dtree,l),e.F.revCodes(m.dtree,l),e.F.makeCodes(m.itree,d),e.F.revCodes(m.itree,d),P=m.ltree,T=m.dtree,b(c,a,v-257),b(c,a+=5,w-1),b(c,a+=5,p-4),a+=4;for(var S=0;S<p;S++)b(c,a+3*S,m.itree[1+(m.ordr[S]<<1)]);a+=3*p,a=e.F._codeTiny(A,m.itree,c,a),a=e.F._codeTiny(g,m.itree,c,a)}for(var k=o,B=0;B<s;B+=2){for(var z=i[B],_=z>>>23,I=k+(8388607&z);k<I;)a=e.F._writeLit(r[k++],P,c,a);if(0!=_){var C=i[B+1],j=C>>16,R=C>>8&255,D=255&C;b(c,a=e.F._writeLit(257+R,P,c,a),_-m.of0[R]),a+=m.exb[R],y(c,a=e.F._writeLit(D,T,c,a),j-m.df0[D]),a+=m.dxb[D],k+=_}}a=e.F._writeLit(256,P,c,a)}return a},e.F._copyExact=function(t,i,s,e,n){var r=n>>>3;return e[r]=s,e[r+1]=s>>>8,e[r+2]=255-e[r],e[r+3]=255-e[r+1],r+=4,e.set(new Uint8Array(t.buffer,i,s),r),n+(s+4<<3)},e.F.getTrees=function(){for(var t=e.F.U,i=e.F._hufTree(t.lhst,t.ltree,15),s=e.F._hufTree(t.dhst,t.dtree,15),n=[],r=e.F._lenCodes(t.ltree,n),o=[],h=e.F._lenCodes(t.dtree,o),c=0;c<n.length;c+=2)t.ihst[n[c]]++;for(c=0;c<o.length;c+=2)t.ihst[o[c]]++;for(var a=e.F._hufTree(t.ihst,t.itree,7),f=19;f>4&&0==t.itree[1+(t.ordr[f-1]<<1)];)f--;return[i,s,a,r,h,f,n,o]},e.F.getSecond=function(t){for(var i=[],s=0;s<t.length;s+=2)i.push(t[s+1]);return i},e.F.nonZero=function(t){for(var i="",s=0;s<t.length;s+=2)0!=t[s+1]&&(i+=(s>>1)+",");return i},e.F.contSize=function(t,i){for(var s=0,e=0;e<i.length;e++)s+=i[e]*t[1+(e<<1)];return s},e.F._codeTiny=function(t,i,s,n){for(var r=0;r<t.length;r+=2){var o=t[r],h=t[r+1];n=e.F._writeLit(o,i,s,n);var c=16==o?2:17==o?3:7;o>15&&(e.F._putsE(s,n,h,c),n+=c)}return n},e.F._lenCodes=function(t,i){for(var s=t.length;2!=s&&0==t[s-1];)s-=2;for(var e=0;e<s;e+=2){var n=t[e+1],r=e+3<s?t[e+3]:-1,o=e+5<s?t[e+5]:-1,h=0==e?-1:t[e-1];if(0==n&&r==n&&o==n){for(var c=e+5;c+2<s&&t[c+2]==n;)c+=2;(a=Math.min(c+1-e>>>1,138))<11?i.push(17,a-3):i.push(18,a-11),e+=2*a-2}else if(n==h&&r==n&&o==n){for(c=e+5;c+2<s&&t[c+2]==n;)c+=2;var a=Math.min(c+1-e>>>1,6);i.push(16,a-3),e+=2*a-2}else i.push(n,0)}return s>>>1},e.F._hufTree=function(t,i,s){var n=[],r=t.length,o=i.length,h=0;for(h=0;h<o;h+=2)i[h]=0,i[h+1]=0;for(h=0;h<r;h++)0!=t[h]&&n.push({lit:h,f:t[h]});var c=n.length,a=n.slice(0);if(0==c)return 0;if(1==c){var f=n[0].lit;a=0==f?1:0;return i[1+(f<<1)]=1,i[1+(a<<1)]=1,1}n.sort((function(t,i){return t.f-i.f}));var u=n[0],l=n[1],d=0,v=1,w=2;for(n[0]={lit:-1,f:u.f+l.f,l:u,r:l,d:0};v!=c-1;)u=d!=v&&(w==c||n[d].f<n[w].f)?n[d++]:n[w++],l=d!=v&&(w==c||n[d].f<n[w].f)?n[d++]:n[w++],n[v++]={lit:-1,f:u.f+l.f,l:u,r:l};var p=e.F.setDepth(n[v-1],0);for(p>s&&(e.F.restrictDepth(a,s,p),p=s),h=0;h<c;h++)i[1+(a[h].lit<<1)]=a[h].d;return p},e.F.setDepth=function(t,i){return-1!=t.lit?(t.d=i,i):Math.max(e.F.setDepth(t.l,i+1),e.F.setDepth(t.r,i+1))},e.F.restrictDepth=function(t,i,s){var e=0,n=1<<s-i,r=0;for(t.sort((function(t,i){return i.d==t.d?t.f-i.f:i.d-t.d})),e=0;e<t.length&&t[e].d>i;e++){var o=t[e].d;t[e].d=i,r+=n-(1<<s-o)}for(r>>>=s-i;r>0;){(o=t[e].d)<i?(t[e].d++,r-=1<<i-o-1):e++}for(;e>=0;e--)t[e].d==i&&r<0&&(t[e].d--,r++);0!=r&&console.log("debt left")},e.F._goodIndex=function(t,i){var s=0;return i[16|s]<=t&&(s|=16),i[8|s]<=t&&(s|=8),i[4|s]<=t&&(s|=4),i[2|s]<=t&&(s|=2),i[1|s]<=t&&(s|=1),s},e.F._writeLit=function(t,i,s,n){return e.F._putsF(s,n,i[t<<1]),n+i[1+(t<<1)]},e.F.inflate=function(t,i){var s=Uint8Array;if(3==t[0]&&0==t[1])return i||new s(0);var n=e.F,r=n._bitsF,o=n._bitsE,h=n._decodeTiny,c=n.makeCodes,a=n.codes2map,f=n._get17,u=n.U,l=null==i;l&&(i=new s(t.length>>>2<<3));for(var d,v,w=0,p=0,A=0,g=0,m=0,y=0,b=0,M=0,x=0;0==w;)if(w=r(t,x,1),p=r(t,x+1,2),x+=3,0!=p){if(l&&(i=e.F._check(i,M+(1<<17))),1==p&&(d=u.flmap,v=u.fdmap,y=511,b=31),2==p){A=o(t,x,5)+257,g=o(t,x+5,5)+1,m=o(t,x+10,4)+4,x+=14;for(var E=0;E<38;E+=2)u.itree[E]=0,u.itree[E+1]=0;var U=1;for(E=0;E<m;E++){var F=o(t,x+3*E,3);u.itree[1+(u.ordr[E]<<1)]=F,F>U&&(U=F)}x+=3*m,c(u.itree,U),a(u.itree,U,u.imap),d=u.lmap,v=u.dmap,x=h(u.imap,(1<<U)-1,A+g,t,x,u.ttree);var P=n._copyOut(u.ttree,0,A,u.ltree);y=(1<<P)-1;var T=n._copyOut(u.ttree,A,g,u.dtree);b=(1<<T)-1,c(u.ltree,P),a(u.ltree,P,d),c(u.dtree,T),a(u.dtree,T,v)}for(;;){var S=d[f(t,x)&y];x+=15&S;var k=S>>>4;if(k>>>8==0)i[M++]=k;else{if(256==k)break;var B=M+k-254;if(k>264){var z=u.ldef[k-257];B=M+(z>>>3)+o(t,x,7&z),x+=7&z}var _=v[f(t,x)&b];x+=15&_;var I=_>>>4,C=u.ddef[I],j=(C>>>4)+r(t,x,15&C);for(x+=15&C,l&&(i=e.F._check(i,M+(1<<17)));M<B;)i[M]=i[M++-j],i[M]=i[M++-j],i[M]=i[M++-j],i[M]=i[M++-j];M=B}}}else{0!=(7&x)&&(x+=8-(7&x));var R=4+(x>>>3),D=t[R-4]|t[R-3]<<8;l&&(i=e.F._check(i,M+D)),i.set(new s(t.buffer,t.byteOffset+R,D),M),x=R+D<<3,M+=D}return i.length==M?i:i.slice(0,M)},e.F._check=function(t,i){var s=t.length;if(i<=s)return t;var e=new Uint8Array(Math.max(s<<1,i));return e.set(t,0),e},e.F._decodeTiny=function(t,i,s,n,r,o){for(var h=e.F._bitsE,c=e.F._get17,a=0;a<s;){var f=t[c(n,r)&i];r+=15&f;var u=f>>>4;if(u<=15)o[a]=u,a++;else{var l=0,d=0;16==u?(d=3+h(n,r,2),r+=2,l=o[a-1]):17==u?(d=3+h(n,r,3),r+=3):18==u&&(d=11+h(n,r,7),r+=7);for(var v=a+d;a<v;)o[a]=l,a++}}return r},e.F._copyOut=function(t,i,s,e){for(var n=0,r=0,o=e.length>>>1;r<s;){var h=t[r+i];e[r<<1]=0,e[1+(r<<1)]=h,h>n&&(n=h),r++}for(;r<o;)e[r<<1]=0,e[1+(r<<1)]=0,r++;return n},e.F.makeCodes=function(t,i){for(var s,n,r,o,h=e.F.U,c=t.length,a=h.bl_count,f=0;f<=i;f++)a[f]=0;for(f=1;f<c;f+=2)a[t[f]]++;var u=h.next_code;for(s=0,a[0]=0,n=1;n<=i;n++)s=s+a[n-1]<<1,u[n]=s;for(r=0;r<c;r+=2)0!=(o=t[r+1])&&(t[r]=u[o],u[o]++)},e.F.codes2map=function(t,i,s){for(var n=t.length,r=e.F.U.rev15,o=0;o<n;o+=2)if(0!=t[o+1])for(var h=o>>1,c=t[o+1],a=h<<4|c,f=i-c,u=t[o]<<f,l=u+(1<<f);u!=l;){s[r[u]>>>15-i]=a,u++}},e.F.revCodes=function(t,i){for(var s=e.F.U.rev15,n=15-i,r=0;r<t.length;r+=2){var o=t[r]<<i-t[r+1];t[r]=s[o]>>>n}},e.F._putsE=function(t,i,s){s<<=7&i;var e=i>>>3;t[e]|=s,t[e+1]|=s>>>8},e.F._putsF=function(t,i,s){s<<=7&i;var e=i>>>3;t[e]|=s,t[e+1]|=s>>>8,t[e+2]|=s>>>16},e.F._bitsE=function(t,i,s){return(t[i>>>3]|t[1+(i>>>3)]<<8)>>>(7&i)&(1<<s)-1},e.F._bitsF=function(t,i,s){return(t[i>>>3]|t[1+(i>>>3)]<<8|t[2+(i>>>3)]<<16)>>>(7&i)&(1<<s)-1},e.F._get17=function(t,i){return(t[i>>>3]|t[1+(i>>>3)]<<8|t[2+(i>>>3)]<<16)>>>(7&i)},e.F._get25=function(t,i){return(t[i>>>3]|t[1+(i>>>3)]<<8|t[2+(i>>>3)]<<16|t[3+(i>>>3)]<<24)>>>(7&i)},e.F.U=(i=Uint16Array,s=Uint32Array,{next_code:new i(16),bl_count:new i(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new i(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new s(32),flmap:new i(512),fltree:[],fdmap:new i(32),fdtree:[],lmap:new i(32768),ltree:[],ttree:[],dmap:new i(32768),dtree:[],imap:new i(512),itree:[],rev15:new i(32768),lhst:new s(286),dhst:new s(30),ihst:new s(19),lits:new s(15e3),strt:new i(65536),prev:new i(32768)}),function(){for(var t=e.F.U,i=0;i<32768;i++){var s=i;s=(4278255360&(s=(4042322160&(s=(3435973836&(s=(2863311530&s)>>>1|(1431655765&s)<<1))>>>2|(858993459&s)<<2))>>>4|(252645135&s)<<4))>>>8|(16711935&s)<<8,t.rev15[i]=(s>>>16|s<<16)>>>17}function n(t,i,s){for(;0!=i--;)t.push(0,s)}for(i=0;i<32;i++)t.ldef[i]=t.of0[i]<<3|t.exb[i],t.ddef[i]=t.df0[i]<<4|t.dxb[i];n(t.fltree,144,8),n(t.fltree,112,9),n(t.fltree,24,7),n(t.fltree,8,8),e.F.makeCodes(t.fltree,9),e.F.codes2map(t.fltree,9,t.flmap),e.F.revCodes(t.fltree,9),n(t.fdtree,32,5),e.F.makeCodes(t.fdtree,5),e.F.codes2map(t.fdtree,5,t.fdmap),e.F.revCodes(t.fdtree,5),n(t.itree,19,0),n(t.ltree,286,0),n(t.dtree,30,0),n(t.ttree,320,0)}()}();var V=X({__proto__:null,default:Y},[Y]);const N=function(){var t={nextZero(t,i){for(;0!=t[i];)i++;return i},readUshort:(t,i)=>t[i]<<8|t[i+1],writeUshort(t,i,s){t[i]=s>>8&255,t[i+1]=255&s},readUint:(t,i)=>16777216*t[i]+(t[i+1]<<16|t[i+2]<<8|t[i+3]),writeUint(t,i,s){t[i]=s>>24&255,t[i+1]=s>>16&255,t[i+2]=s>>8&255,t[i+3]=255&s},readASCII(t,i,s){let e="";for(let n=0;n<s;n++)e+=String.fromCharCode(t[i+n]);return e},writeASCII(t,i,s){for(let e=0;e<s.length;e++)t[i+e]=s.charCodeAt(e)},readBytes(t,i,s){const e=[];for(let n=0;n<s;n++)e.push(t[i+n]);return e},pad:t=>t.length<2?`0${t}`:t,readUTF8(i,s,e){let n,r="";for(let n=0;n<e;n++)r+=`%${t.pad(i[s+n].toString(16))}`;try{n=decodeURIComponent(r)}catch(n){return t.readASCII(i,s,e)}return n}};function i(i,s,e,n){const o=s*e,h=r(n),c=Math.ceil(s*h/8),a=new Uint8Array(4*o),f=new Uint32Array(a.buffer),{ctype:u}=n,{depth:l}=n,d=t.readUshort;if(6==u){const t=o<<2;if(8==l)for(var v=0;v<t;v+=4)a[v]=i[v],a[v+1]=i[v+1],a[v+2]=i[v+2],a[v+3]=i[v+3];if(16==l)for(v=0;v<t;v++)a[v]=i[v<<1]}else if(2==u){const t=n.tabs.tRNS;if(null==t){if(8==l)for(v=0;v<o;v++){var w=3*v;f[v]=255<<24|i[w+2]<<16|i[w+1]<<8|i[w]}if(16==l)for(v=0;v<o;v++){w=6*v;f[v]=255<<24|i[w+4]<<16|i[w+2]<<8|i[w]}}else{var p=t[0];const s=t[1],e=t[2];if(8==l)for(v=0;v<o;v++){var A=v<<2;w=3*v;f[v]=255<<24|i[w+2]<<16|i[w+1]<<8|i[w],i[w]==p&&i[w+1]==s&&i[w+2]==e&&(a[A+3]=0)}if(16==l)for(v=0;v<o;v++){A=v<<2,w=6*v;f[v]=255<<24|i[w+4]<<16|i[w+2]<<8|i[w],d(i,w)==p&&d(i,w+2)==s&&d(i,w+4)==e&&(a[A+3]=0)}}}else if(3==u){const t=n.tabs.PLTE,r=n.tabs.tRNS,h=r?r.length:0;if(1==l)for(var g=0;g<e;g++){var m=g*c,y=g*s;for(v=0;v<s;v++){A=y+v<<2;var b=3*(M=i[m+(v>>3)]>>7-((7&v)<<0)&1);a[A]=t[b],a[A+1]=t[b+1],a[A+2]=t[b+2],a[A+3]=M<h?r[M]:255}}if(2==l)for(g=0;g<e;g++)for(m=g*c,y=g*s,v=0;v<s;v++){A=y+v<<2,b=3*(M=i[m+(v>>2)]>>6-((3&v)<<1)&3);a[A]=t[b],a[A+1]=t[b+1],a[A+2]=t[b+2],a[A+3]=M<h?r[M]:255}if(4==l)for(g=0;g<e;g++)for(m=g*c,y=g*s,v=0;v<s;v++){A=y+v<<2,b=3*(M=i[m+(v>>1)]>>4-((1&v)<<2)&15);a[A]=t[b],a[A+1]=t[b+1],a[A+2]=t[b+2],a[A+3]=M<h?r[M]:255}if(8==l)for(v=0;v<o;v++){var M;A=v<<2,b=3*(M=i[v]);a[A]=t[b],a[A+1]=t[b+1],a[A+2]=t[b+2],a[A+3]=M<h?r[M]:255}}else if(4==u){if(8==l)for(v=0;v<o;v++){A=v<<2;var x=i[E=v<<1];a[A]=x,a[A+1]=x,a[A+2]=x,a[A+3]=i[E+1]}if(16==l)for(v=0;v<o;v++){var E;A=v<<2,x=i[E=v<<2];a[A]=x,a[A+1]=x,a[A+2]=x,a[A+3]=i[E+2]}}else if(0==u)for(p=n.tabs.tRNS?n.tabs.tRNS:-1,g=0;g<e;g++){const t=g*c,e=g*s;if(1==l)for(var U=0;U<s;U++){var F=(x=255*(i[t+(U>>>3)]>>>7-(7&U)&1))==255*p?0:255;f[e+U]=F<<24|x<<16|x<<8|x}else if(2==l)for(U=0;U<s;U++){F=(x=85*(i[t+(U>>>2)]>>>6-((3&U)<<1)&3))==85*p?0:255;f[e+U]=F<<24|x<<16|x<<8|x}else if(4==l)for(U=0;U<s;U++){F=(x=17*(i[t+(U>>>1)]>>>4-((1&U)<<2)&15))==17*p?0:255;f[e+U]=F<<24|x<<16|x<<8|x}else if(8==l)for(U=0;U<s;U++){F=(x=i[t+U])==p?0:255;f[e+U]=F<<24|x<<16|x<<8|x}else if(16==l)for(U=0;U<s;U++){x=i[t+(U<<1)],F=d(i,t+(U<<1))==p?0:255;f[e+U]=F<<24|x<<16|x<<8|x}}return a}function s(t,i,s,h){const c=r(t),a=Math.ceil(s*c/8),f=new Uint8Array((a+1+t.interlace)*h);return i=t.tabs.CgBI?n(i,f):e(i,f),0==t.interlace?i=o(i,t,0,s,h):1==t.interlace&&(i=function t(i,s){const e=s.width,n=s.height,h=r(s),c=h>>3,a=Math.ceil(e*h/8),f=new Uint8Array(n*a);let u=0;const l=[0,0,4,0,2,0,1],d=[0,4,0,2,0,1,0],v=[8,8,8,4,4,2,2],w=[8,8,4,4,2,2,1];let p=0;for(;p<7;){const t=v[p],r=w[p];let g=0,m=0,y=l[p];for(;y<n;)y+=t,m++;let b=d[p];for(;b<e;)b+=r,g++;const M=Math.ceil(g*h/8);o(i,s,u,g,m);let x=0,E=l[p];for(;E<n;){let s=d[p],n=u+x*M<<3;for(;s<e;){var A;if(1==h)A=(A=i[n>>3])>>7-(7&n)&1,f[E*a+(s>>3)]|=A<<7-((7&s)<<0);if(2==h)A=(A=i[n>>3])>>6-(7&n)&3,f[E*a+(s>>2)]|=A<<6-((3&s)<<1);if(4==h)A=(A=i[n>>3])>>4-(7&n)&15,f[E*a+(s>>1)]|=A<<4-((1&s)<<2);if(h>=8){const t=E*a+s*c;for(let s=0;s<c;s++)f[t+s]=i[(n>>3)+s]}n+=h,s+=r}x++,E+=t}g*m!=0&&(u+=m*(1+M)),p+=1}return f}(i,t)),i}function e(t,i){return n(new Uint8Array(t.buffer,2,t.length-6),i)}var n=function(){const t={H:{}};return t.H.N=function(i,s){const e=Uint8Array;let n,r,o=0,h=0,c=0,a=0,f=0,u=0,l=0,d=0,v=0;if(3==i[0]&&0==i[1])return s||new e(0);const w=t.H,p=w.b,A=w.e,g=w.R,m=w.n,y=w.A,b=w.Z,M=w.m,x=null==s;for(x&&(s=new e(i.length>>>2<<5));0==o;)if(o=p(i,v,1),h=p(i,v+1,2),v+=3,0!=h){if(x&&(s=t.H.W(s,d+(1<<17))),1==h&&(n=M.J,r=M.h,u=511,l=31),2==h){c=A(i,v,5)+257,a=A(i,v+5,5)+1,f=A(i,v+10,4)+4,v+=14;let t=1;for(var E=0;E<38;E+=2)M.Q[E]=0,M.Q[E+1]=0;for(E=0;E<f;E++){const s=A(i,v+3*E,3);M.Q[1+(M.X[E]<<1)]=s,s>t&&(t=s)}v+=3*f,m(M.Q,t),y(M.Q,t,M.u),n=M.w,r=M.d,v=g(M.u,(1<<t)-1,c+a,i,v,M.v);const s=w.V(M.v,0,c,M.C);u=(1<<s)-1;const e=w.V(M.v,c,a,M.D);l=(1<<e)-1,m(M.C,s),y(M.C,s,n),m(M.D,e),y(M.D,e,r)}for(;;){const t=n[b(i,v)&u];v+=15&t;const e=t>>>4;if(e>>>8==0)s[d++]=e;else{if(256==e)break;{let t=d+e-254;if(e>264){const s=M.q[e-257];t=d+(s>>>3)+A(i,v,7&s),v+=7&s}const n=r[b(i,v)&l];v+=15&n;const o=n>>>4,h=M.c[o],c=(h>>>4)+p(i,v,15&h);for(v+=15&h;d<t;)s[d]=s[d++-c],s[d]=s[d++-c],s[d]=s[d++-c],s[d]=s[d++-c];d=t}}}}else{0!=(7&v)&&(v+=8-(7&v));const n=4+(v>>>3),r=i[n-4]|i[n-3]<<8;x&&(s=t.H.W(s,d+r)),s.set(new e(i.buffer,i.byteOffset+n,r),d),v=n+r<<3,d+=r}return s.length==d?s:s.slice(0,d)},t.H.W=function(t,i){const s=t.length;if(i<=s)return t;const e=new Uint8Array(s<<1);return e.set(t,0),e},t.H.R=function(i,s,e,n,r,o){const h=t.H.e,c=t.H.Z;let a=0;for(;a<e;){const t=i[c(n,r)&s];r+=15&t;const e=t>>>4;if(e<=15)o[a]=e,a++;else{let t=0,i=0;16==e?(i=3+h(n,r,2),r+=2,t=o[a-1]):17==e?(i=3+h(n,r,3),r+=3):18==e&&(i=11+h(n,r,7),r+=7);const s=a+i;for(;a<s;)o[a]=t,a++}}return r},t.H.V=function(t,i,s,e){let n=0,r=0;const o=e.length>>>1;for(;r<s;){const s=t[r+i];e[r<<1]=0,e[1+(r<<1)]=s,s>n&&(n=s),r++}for(;r<o;)e[r<<1]=0,e[1+(r<<1)]=0,r++;return n},t.H.n=function(i,s){const e=t.H.m,n=i.length;let r,o,h;let c;const a=e.j;for(var f=0;f<=s;f++)a[f]=0;for(f=1;f<n;f+=2)a[i[f]]++;const u=e.K;for(r=0,a[0]=0,o=1;o<=s;o++)r=r+a[o-1]<<1,u[o]=r;for(h=0;h<n;h+=2)c=i[h+1],0!=c&&(i[h]=u[c],u[c]++)},t.H.A=function(i,s,e){const n=i.length,r=t.H.m.r;for(let t=0;t<n;t+=2)if(0!=i[t+1]){const n=t>>1,o=i[t+1],h=n<<4|o,c=s-o;let a=i[t]<<c;const f=a+(1<<c);for(;a!=f;){e[r[a]>>>15-s]=h,a++}}},t.H.l=function(i,s){const e=t.H.m.r,n=15-s;for(let t=0;t<i.length;t+=2){const r=i[t]<<s-i[t+1];i[t]=e[r]>>>n}},t.H.M=function(t,i,s){s<<=7&i;const e=i>>>3;t[e]|=s,t[e+1]|=s>>>8},t.H.I=function(t,i,s){s<<=7&i;const e=i>>>3;t[e]|=s,t[e+1]|=s>>>8,t[e+2]|=s>>>16},t.H.e=function(t,i,s){return(t[i>>>3]|t[1+(i>>>3)]<<8)>>>(7&i)&(1<<s)-1},t.H.b=function(t,i,s){return(t[i>>>3]|t[1+(i>>>3)]<<8|t[2+(i>>>3)]<<16)>>>(7&i)&(1<<s)-1},t.H.Z=function(t,i){return(t[i>>>3]|t[1+(i>>>3)]<<8|t[2+(i>>>3)]<<16)>>>(7&i)},t.H.i=function(t,i){return(t[i>>>3]|t[1+(i>>>3)]<<8|t[2+(i>>>3)]<<16|t[3+(i>>>3)]<<24)>>>(7&i)},t.H.m=function(){const t=Uint16Array,i=Uint32Array;return{K:new t(16),j:new t(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new t(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new i(32),J:new t(512),_:[],h:new t(32),$:[],w:new t(32768),C:[],v:[],d:new t(32768),D:[],u:new t(512),Q:[],r:new t(32768),s:new i(286),Y:new i(30),a:new i(19),t:new i(15e3),k:new t(65536),g:new t(32768)}}(),function(){const i=t.H.m;for(var s=0;s<32768;s++){let t=s;t=(2863311530&t)>>>1|(1431655765&t)<<1,t=(3435973836&t)>>>2|(858993459&t)<<2,t=(4042322160&t)>>>4|(252645135&t)<<4,t=(4278255360&t)>>>8|(16711935&t)<<8,i.r[s]=(t>>>16|t<<16)>>>17}function e(t,i,s){for(;0!=i--;)t.push(0,s)}for(s=0;s<32;s++)i.q[s]=i.S[s]<<3|i.T[s],i.c[s]=i.p[s]<<4|i.z[s];e(i._,144,8),e(i._,112,9),e(i._,24,7),e(i._,8,8),t.H.n(i._,9),t.H.A(i._,9,i.J),t.H.l(i._,9),e(i.$,32,5),t.H.n(i.$,5),t.H.A(i.$,5,i.h),t.H.l(i.$,5),e(i.Q,19,0),e(i.C,286,0),e(i.D,30,0),e(i.v,320,0)}(),t.H.N}();function r(t){return[1,null,3,1,2,null,4][t.ctype]*t.depth}function o(t,i,s,e,n){let o=r(i);const c=Math.ceil(e*o/8);let a,f;o=Math.ceil(o/8);let u=t[s],l=0;if(u>1&&(t[s]=[0,0,1][u-2]),3==u)for(l=o;l<c;l++)t[l+1]=t[l+1]+(t[l+1-o]>>>1)&255;for(let i=0;i<n;i++)if(a=s+i*c,f=a+i+1,u=t[f-1],l=0,0==u)for(;l<c;l++)t[a+l]=t[f+l];else if(1==u){for(;l<o;l++)t[a+l]=t[f+l];for(;l<c;l++)t[a+l]=t[f+l]+t[a+l-o]}else if(2==u)for(;l<c;l++)t[a+l]=t[f+l]+t[a+l-c];else if(3==u){for(;l<o;l++)t[a+l]=t[f+l]+(t[a+l-c]>>>1);for(;l<c;l++)t[a+l]=t[f+l]+(t[a+l-c]+t[a+l-o]>>>1)}else{for(;l<o;l++)t[a+l]=t[f+l]+h(0,t[a+l-c],0);for(;l<c;l++)t[a+l]=t[f+l]+h(t[a+l-o],t[a+l-c],t[a+l-o-c])}return t}function h(t,i,s){const e=t+i-s,n=e-t,r=e-i,o=e-s;return n*n<=r*r&&n*n<=o*o?t:r*r<=o*o?i:s}function c(i,s,e){e.width=t.readUint(i,s),s+=4,e.height=t.readUint(i,s),s+=4,e.depth=i[s],s++,e.ctype=i[s],s++,e.compress=i[s],s++,e.filter=i[s],s++,e.interlace=i[s],s++}function a(t,i,s,e,n,r,o,h,c){const a=Math.min(i,n),f=Math.min(s,r);let u=0,l=0;for(let s=0;s<f;s++)for(let r=0;r<a;r++)if(o>=0&&h>=0?(u=s*i+r<<2,l=(h+s)*n+o+r<<2):(u=(-h+s)*i-o+r<<2,l=s*n+r<<2),0==c)e[l]=t[u],e[l+1]=t[u+1],e[l+2]=t[u+2],e[l+3]=t[u+3];else if(1==c){var d=t[u+3]*(1/255),v=t[u]*d,w=t[u+1]*d,p=t[u+2]*d,A=e[l+3]*(1/255),g=e[l]*A,m=e[l+1]*A,y=e[l+2]*A;const i=1-d,s=d+A*i,n=0==s?0:1/s;e[l+3]=255*s,e[l+0]=(v+g*i)*n,e[l+1]=(w+m*i)*n,e[l+2]=(p+y*i)*n}else if(2==c){d=t[u+3],v=t[u],w=t[u+1],p=t[u+2],A=e[l+3],g=e[l],m=e[l+1],y=e[l+2];d==A&&v==g&&w==m&&p==y?(e[l]=0,e[l+1]=0,e[l+2]=0,e[l+3]=0):(e[l]=v,e[l+1]=w,e[l+2]=p,e[l+3]=d)}else if(3==c){d=t[u+3],v=t[u],w=t[u+1],p=t[u+2],A=e[l+3],g=e[l],m=e[l+1],y=e[l+2];if(d==A&&v==g&&w==m&&p==y)continue;if(d<220&&A>20)return false}return true}return{decode:function i(r){const o=new Uint8Array(r);let h=8;const a=t,f=a.readUshort,u=a.readUint,l={tabs:{},frames:[]},d=new Uint8Array(o.length);let v,w=0,p=0;const A=[137,80,78,71,13,10,26,10];for(var g=0;g<8;g++)if(o[g]!=A[g])throw"The input is not a PNG file!";for(;h<o.length;){const t=a.readUint(o,h);h+=4;const i=a.readASCII(o,h,4);if(h+=4,"IHDR"==i)c(o,h,l);else if("iCCP"==i){for(var m=h;0!=o[m];)m++;a.readASCII(o,h,m-h);const s=o.slice(m+2,h+t);let r=null;try{r=e(s)}catch(t){r=n(s)}l.tabs[i]=r}else if("CgBI"==i)l.tabs[i]=o.slice(h,h+4);else if("IDAT"==i){for(g=0;g<t;g++)d[w+g]=o[h+g];w+=t}else if("acTL"==i)l.tabs[i]={num_frames:u(o,h),num_plays:u(o,h+4)},v=new Uint8Array(o.length);else if("fcTL"==i){if(0!=p)(U=l.frames[l.frames.length-1]).data=s(l,v.slice(0,p),U.rect.width,U.rect.height),p=0;const t={x:u(o,h+12),y:u(o,h+16),width:u(o,h+4),height:u(o,h+8)};let i=f(o,h+22);i=f(o,h+20)/(0==i?100:i);const e={rect:t,delay:Math.round(1e3*i),dispose:o[h+24],blend:o[h+25]};l.frames.push(e)}else if("fdAT"==i){for(g=0;g<t-4;g++)v[p+g]=o[h+g+4];p+=t-4}else if("pHYs"==i)l.tabs[i]=[a.readUint(o,h),a.readUint(o,h+4),o[h+8]];else if("cHRM"==i){l.tabs[i]=[];for(g=0;g<8;g++)l.tabs[i].push(a.readUint(o,h+4*g))}else if("tEXt"==i||"zTXt"==i){null==l.tabs[i]&&(l.tabs[i]={});var y=a.nextZero(o,h),b=a.readASCII(o,h,y-h),M=h+t-y-1;if("tEXt"==i)E=a.readASCII(o,y+1,M);else{var x=e(o.slice(y+2,y+2+M));E=a.readUTF8(x,0,x.length)}l.tabs[i][b]=E}else if("iTXt"==i){null==l.tabs[i]&&(l.tabs[i]={});y=0,m=h;y=a.nextZero(o,m);b=a.readASCII(o,m,y-m);const s=o[m=y+1];var E;m+=2,y=a.nextZero(o,m),a.readASCII(o,m,y-m),m=y+1,y=a.nextZero(o,m),a.readUTF8(o,m,y-m);M=t-((m=y+1)-h);if(0==s)E=a.readUTF8(o,m,M);else{x=e(o.slice(m,m+M));E=a.readUTF8(x,0,x.length)}l.tabs[i][b]=E}else if("PLTE"==i)l.tabs[i]=a.readBytes(o,h,t);else if("hIST"==i){const t=l.tabs.PLTE.length/3;l.tabs[i]=[];for(g=0;g<t;g++)l.tabs[i].push(f(o,h+2*g))}else if("tRNS"==i)3==l.ctype?l.tabs[i]=a.readBytes(o,h,t):0==l.ctype?l.tabs[i]=f(o,h):2==l.ctype&&(l.tabs[i]=[f(o,h),f(o,h+2),f(o,h+4)]);else if("gAMA"==i)l.tabs[i]=a.readUint(o,h)/1e5;else if("sRGB"==i)l.tabs[i]=o[h];else if("bKGD"==i)0==l.ctype||4==l.ctype?l.tabs[i]=[f(o,h)]:2==l.ctype||6==l.ctype?l.tabs[i]=[f(o,h),f(o,h+2),f(o,h+4)]:3==l.ctype&&(l.tabs[i]=o[h]);else if("IEND"==i)break;h+=t,a.readUint(o,h),h+=4}var U;return 0!=p&&((U=l.frames[l.frames.length-1]).data=s(l,v.slice(0,p),U.rect.width,U.rect.height)),l.data=s(l,d,l.width,l.height),delete l.compress,delete l.interlace,delete l.filter,l},toRGBA8:function t(s){const e=s.width,n=s.height;if(null==s.tabs.acTL)return[i(s.data,e,n,s).buffer];const r=[];null==s.frames[0].data&&(s.frames[0].data=s.data);const o=e*n*4,h=new Uint8Array(o),c=new Uint8Array(o),f=new Uint8Array(o);for(let t=0;t<s.frames.length;t++){const l=s.frames[t],d=l.rect.x,v=l.rect.y,w=l.rect.width,p=l.rect.height,A=i(l.data,w,p,s);if(0!=t)for(var u=0;u<o;u++)f[u]=h[u];if(0==l.blend?a(A,w,p,h,e,n,d,v,0):1==l.blend&&a(A,w,p,h,e,n,d,v,1),r.push(h.buffer.slice(0)),0==l.dispose);else if(1==l.dispose)a(c,w,p,h,e,n,d,v,0);else if(2==l.dispose)for(u=0;u<o;u++)h[u]=f[u]}return r},_paeth:h,_copyTile:a,_bin:t}}();!function(){const{_copyTile:t}=N,{_bin:i}=N,s=N._paeth;var e={table:function(){const t=new Uint32Array(256);for(let i=0;i<256;i++){let s=i;for(let t=0;t<8;t++)1&s?s=3988292384^s>>>1:s>>>=1;t[i]=s}return t}(),update(t,i,s,n){for(let r=0;r<n;r++)t=e.table[255&(t^i[s+r])]^t>>>8;return t},crc:(t,i,s)=>4294967295^e.update(4294967295,t,i,s)};function n(t,i,s,e){i[s]+=t[0]*e>>4,i[s+1]+=t[1]*e>>4,i[s+2]+=t[2]*e>>4,i[s+3]+=t[3]*e>>4}function r(t){return Math.max(0,Math.min(255,t))}function o(t,i){const s=t[0]-i[0],e=t[1]-i[1],n=t[2]-i[2],r=t[3]-i[3];return s*s+e*e+n*n+r*r}function h(t,i,s,e,h,c,a){null==a&&(a=1);const f=e.length,u=[];for(var l=0;l<f;l++){const t=e[l];u.push([t>>>0&255,t>>>8&255,t>>>16&255,t>>>24&255])}for(l=0;l<f;l++){let t=4294967295;for(var d=0,v=0;v<f;v++){var w=o(u[l],u[v]);v!=l&&w<t&&(t=w,d=v)}}const p=new Uint32Array(h.buffer),A=new Int16Array(i*s*4),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(l=0;l<g.length;l++)g[l]=255*((g[l]+.5)/16-.5);for(let h=0;h<s;h++)for(let y=0;y<i;y++){var m;l=4*(h*i+y);if(2!=a)m=[r(t[l]+A[l]),r(t[l+1]+A[l+1]),r(t[l+2]+A[l+2]),r(t[l+3]+A[l+3])];else{w=g[4*(3&h)+(3&y)];m=[r(t[l]+w),r(t[l+1]+w),r(t[l+2]+w),r(t[l+3]+w)]}d=0;let b=16777215;for(v=0;v<f;v++){const t=o(m,u[v]);t<b&&(b=t,d=v)}const M=u[d],x=[m[0]-M[0],m[1]-M[1],m[2]-M[2],m[3]-M[3]];1==a&&(y!=i-1&&n(x,A,l+4,7),h!=s-1&&(0!=y&&n(x,A,l+4*i-4,3),n(x,A,l+4*i,5),y!=i-1&&n(x,A,l+4*i+4,1))),c[l>>2]=d,p[l>>2]=e[d]}}function c(t,s,n,r,o){null==o&&(o={});const{crc:h}=e,c=i.writeUint,a=i.writeUshort,f=i.writeASCII;let u=8;const l=t.frames.length>1;let d,v=false,w=33+(l?20:0);if(null!=o.sRGB&&(w+=13),null!=o.pHYs&&(w+=21),null!=o.iCCP&&(d=pako.deflate(o.iCCP),w+=21+d.length+4),3==t.ctype){for(var p=t.plte.length,A=0;A<p;A++)t.plte[A]>>>24!=255&&(v=true);w+=8+3*p+4+(v?8+1*p+4:0)}for(var g=0;g<t.frames.length;g++){l&&(w+=38),w+=(M=t.frames[g]).cimg.length+12,0!=g&&(w+=4)}w+=12;const m=new Uint8Array(w),y=[137,80,78,71,13,10,26,10];for(A=0;A<8;A++)m[A]=y[A];if(c(m,u,13),u+=4,f(m,u,"IHDR"),u+=4,c(m,u,s),u+=4,c(m,u,n),u+=4,m[u]=t.depth,u++,m[u]=t.ctype,u++,m[u]=0,u++,m[u]=0,u++,m[u]=0,u++,c(m,u,h(m,u-17,17)),u+=4,null!=o.sRGB&&(c(m,u,1),u+=4,f(m,u,"sRGB"),u+=4,m[u]=o.sRGB,u++,c(m,u,h(m,u-5,5)),u+=4),null!=o.iCCP){const t=13+d.length;c(m,u,t),u+=4,f(m,u,"iCCP"),u+=4,f(m,u,"ICC profile"),u+=11,u+=2,m.set(d,u),u+=d.length,c(m,u,h(m,u-(t+4),t+4)),u+=4}if(null!=o.pHYs&&(c(m,u,9),u+=4,f(m,u,"pHYs"),u+=4,c(m,u,o.pHYs[0]),u+=4,c(m,u,o.pHYs[1]),u+=4,m[u]=o.pHYs[2],u++,c(m,u,h(m,u-13,13)),u+=4),l&&(c(m,u,8),u+=4,f(m,u,"acTL"),u+=4,c(m,u,t.frames.length),u+=4,c(m,u,null!=o.loop?o.loop:0),u+=4,c(m,u,h(m,u-12,12)),u+=4),3==t.ctype){c(m,u,3*(p=t.plte.length)),u+=4,f(m,u,"PLTE"),u+=4;for(A=0;A<p;A++){const i=3*A,s=t.plte[A],e=255&s,n=s>>>8&255,r=s>>>16&255;m[u+i+0]=e,m[u+i+1]=n,m[u+i+2]=r}if(u+=3*p,c(m,u,h(m,u-3*p-4,3*p+4)),u+=4,v){c(m,u,p),u+=4,f(m,u,"tRNS"),u+=4;for(A=0;A<p;A++)m[u+A]=t.plte[A]>>>24&255;u+=p,c(m,u,h(m,u-p-4,p+4)),u+=4}}let b=0;for(g=0;g<t.frames.length;g++){var M=t.frames[g];l&&(c(m,u,26),u+=4,f(m,u,"fcTL"),u+=4,c(m,u,b++),u+=4,c(m,u,M.rect.width),u+=4,c(m,u,M.rect.height),u+=4,c(m,u,M.rect.x),u+=4,c(m,u,M.rect.y),u+=4,a(m,u,r[g]),u+=2,a(m,u,1e3),u+=2,m[u]=M.dispose,u++,m[u]=M.blend,u++,c(m,u,h(m,u-30,30)),u+=4);const i=M.cimg;c(m,u,(p=i.length)+(0==g?0:4)),u+=4;const s=u;f(m,u,0==g?"IDAT":"fdAT"),u+=4,0!=g&&(c(m,u,b++),u+=4),m.set(i,u),u+=p,c(m,u,h(m,s,u-s)),u+=4}return c(m,u,0),u+=4,f(m,u,"IEND"),u+=4,c(m,u,h(m,u-4,4)),u+=4,m.buffer}function a(t,i,s){for(let e=0;e<t.frames.length;e++){const n=t.frames[e];const r=n.rect.height,o=new Uint8Array(r*n.bpl+r);n.cimg=d(n.img,r,n.bpp,n.bpl,o,i,s)}}function f(i,s,e,n,r){const o=r[0],c=r[1],a=r[2],f=r[3],d=r[4],v=r[5];let p=6,A=8,g=255;for(var m=0;m<i.length;m++){const t=new Uint8Array(i[m]);for(var y=t.length,b=0;b<y;b+=4)g&=t[b+3]}const M=255!=g,x=function i(s,e,n,r,o,h){const c=[];for(var a=0;a<s.length;a++){const i=new Uint8Array(s[a]),u=new Uint32Array(i.buffer);var f;let v=0,p=0,A=e,g=n,m=r?1:0;if(0!=a){const y=h||r||1==a||0!=c[a-2].dispose?1:2;let b=0,M=1e9;for(let t=0;t<y;t++){var d=new Uint8Array(s[a-1-t]);const i=new Uint32Array(s[a-1-t]);let r=e,h=n,c=-1,f=-1;for(let t=0;t<n;t++)for(let s=0;s<e;s++){u[w=t*e+s]!=i[w]&&(s<r&&(r=s),s>c&&(c=s),t<h&&(h=t),t>f&&(f=t))}-1==c&&(r=h=c=f=0),o&&(1==(1&r)&&r--,1==(1&h)&&h--);const l=(c-r+1)*(f-h+1);l<M&&(M=l,b=t,v=r,p=h,A=c-r+1,g=f-h+1)}d=new Uint8Array(s[a-1-b]);1==b&&(c[a-1].dispose=2),f=new Uint8Array(A*g*4),t(d,e,n,f,A,g,-v,-p,0),m=t(i,e,n,f,A,g,-v,-p,3)?1:0,1==m?l(i,e,n,f,{x:v,y:p,width:A,height:g}):t(i,e,n,f,A,g,-v,-p,0)}else f=i.slice(0);c.push({rect:{x:v,y:p,width:A,height:g},img:f,blend:m,dispose:0})}if(r)for(a=0;a<c.length;a++){if(1==(p=c[a]).blend)continue;const t=p.rect,i=c[a-1].rect,r=Math.min(t.x,i.x),h=Math.min(t.y,i.y),f={x:r,y:h,width:Math.max(t.x+t.width,i.x+i.width)-r,height:Math.max(t.y+t.height,i.y+i.height)-h};c[a-1].dispose=1,a-1!=0&&u(s,e,n,c,a-1,f,o),u(s,e,n,c,a,f,o)}let v=0;if(1!=s.length)for(var w=0;w<c.length;w++){var p;v+=(p=c[w]).rect.width*p.rect.height}return c}(i,s,e,o,c,a),E={},U=[],F=[];if(0!=n){const t=[];for(b=0;b<x.length;b++)t.push(x[b].img.buffer);const i=function t(i){let s=0;for(var e=0;e<i.length;e++)s+=i[e].byteLength;const n=new Uint8Array(s);let r=0;for(e=0;e<i.length;e++){const t=new Uint8Array(i[e]),s=t.length;for(let i=0;i<s;i+=4){let s=t[i],e=t[i+1],o=t[i+2];const h=t[i+3];0==h&&(s=e=o=0),n[r+i]=s,n[r+i+1]=e,n[r+i+2]=o,n[r+i+3]=h}r+=s}return n.buffer}(t),s=w(i,n);for(b=0;b<s.plte.length;b++)U.push(s.plte[b].est.rgba);let e=0;for(b=0;b<x.length;b++){const t=(T=x[b]).img.length;var P=new Uint8Array(s.inds.buffer,e>>2,t>>2);F.push(P);const i=new Uint8Array(s.abuf,e,t);v&&h(T.img,T.rect.width,T.rect.height,U,i,P),T.img.set(i),e+=t}}else for(m=0;m<x.length;m++){var T=x[m];const t=new Uint32Array(T.img.buffer);var S=T.rect.width;y=t.length,P=new Uint8Array(y);F.push(P);for(b=0;b<y;b++){const i=t[b];if(0!=b&&i==t[b-1])P[b]=P[b-1];else if(b>S&&i==t[b-S])P[b]=P[b-S];else{let t=E[i];if(null==t&&(E[i]=t=U.length,U.push(i),U.length>=300))break;P[b]=t}}}const k=U.length;k<=256&&0==d&&(A=k<=2?1:k<=4?2:k<=16?4:8,A=Math.max(A,f));for(m=0;m<x.length;m++){(T=x[m]).rect.x;S=T.rect.width;const t=T.rect.height;let i=T.img;let s=4*S,e=4;if(k<=256&&0==d){s=Math.ceil(A*S/8);var B=new Uint8Array(s*t);const n=F[m];for(let i=0;i<t;i++){b=i*s;const t=i*S;if(8==A)for(var z=0;z<S;z++)B[b+z]=n[t+z];else if(4==A)for(z=0;z<S;z++)B[b+(z>>1)]|=n[t+z]<<4-4*(1&z);else if(2==A)for(z=0;z<S;z++)B[b+(z>>2)]|=n[t+z]<<6-2*(3&z);else if(1==A)for(z=0;z<S;z++)B[b+(z>>3)]|=n[t+z]<<7-1*(7&z)}i=B,p=3,e=1}else if(0==M&&1==x.length){B=new Uint8Array(S*t*3);const n=S*t;for(b=0;b<n;b++){const t=3*b,s=4*b;B[t]=i[s],B[t+1]=i[s+1],B[t+2]=i[s+2]}i=B,p=2,e=3,s=3*S}T.img=i,T.bpl=s,T.bpp=e}return{ctype:p,depth:A,plte:U,frames:x}}function u(i,s,e,n,r,o,h){const c=Uint8Array,a=Uint32Array,f=new c(i[r-1]),u=new a(i[r-1]),d=r+1<i.length?new c(i[r+1]):null,v=new c(i[r]),w=new a(v.buffer);let p=s,A=e,g=-1,m=-1;for(let t=0;t<o.height;t++)for(let i=0;i<o.width;i++){const e=o.x+i,h=o.y+t,c=h*s+e,a=w[c];0==a||0==n[r-1].dispose&&u[c]==a&&(null==d||0!=d[4*c+3])||(e<p&&(p=e),e>g&&(g=e),h<A&&(A=h),h>m&&(m=h))}-1==g&&(p=A=g=m=0),h&&(1==(1&p)&&p--,1==(1&A)&&A--),o={x:p,y:A,width:g-p+1,height:m-A+1};const y=n[r];y.rect=o,y.blend=1,y.img=new Uint8Array(o.width*o.height*4),0==n[r-1].dispose?(t(f,s,e,y.img,o.width,o.height,-o.x,-o.y,0),l(v,s,e,y.img,o)):t(v,s,e,y.img,o.width,o.height,-o.x,-o.y,0)}function l(i,s,e,n,r){t(i,s,e,n,r.width,r.height,-r.x,-r.y,2)}function d(t,i,s,e,n,r,o){const h=[];let c,a=[0,1,2,3,4];-1!=r?a=[r]:(i*e>5e5||1==s)&&(a=[0]),o&&(c={level:0});const f=V;for(var u=0;u<a.length;u++){for(let r=0;r<i;r++)v(n,t,r,e,s,a[u]);h.push(f.deflate(n,c))}let l,d=1e9;for(u=0;u<h.length;u++)h[u].length<d&&(l=u,d=h[u].length);return h[l]}function v(t,i,e,n,r,o){const h=e*n;let c=h+e;if(t[c]=o,c++,0==o)if(n<500)for(var a=0;a<n;a++)t[c+a]=i[h+a];else t.set(new Uint8Array(i.buffer,h,n),c);else if(1==o){for(a=0;a<r;a++)t[c+a]=i[h+a];for(a=r;a<n;a++)t[c+a]=i[h+a]-i[h+a-r]+256&255}else if(0==e){for(a=0;a<r;a++)t[c+a]=i[h+a];if(2==o)for(a=r;a<n;a++)t[c+a]=i[h+a];if(3==o)for(a=r;a<n;a++)t[c+a]=i[h+a]-(i[h+a-r]>>1)+256&255;if(4==o)for(a=r;a<n;a++)t[c+a]=i[h+a]-s(i[h+a-r],0,0)+256&255}else{if(2==o)for(a=0;a<n;a++)t[c+a]=i[h+a]+256-i[h+a-n]&255;if(3==o){for(a=0;a<r;a++)t[c+a]=i[h+a]+256-(i[h+a-n]>>1)&255;for(a=r;a<n;a++)t[c+a]=i[h+a]+256-(i[h+a-n]+i[h+a-r]>>1)&255}if(4==o){for(a=0;a<r;a++)t[c+a]=i[h+a]+256-s(0,i[h+a-n],0)&255;for(a=r;a<n;a++)t[c+a]=i[h+a]+256-s(i[h+a-r],i[h+a-n],i[h+a-r-n])&255}}}function w(t,i){const s=new Uint8Array(t),e=s.slice(0),n=new Uint32Array(e.buffer),r=p(e,i),o=r[0],h=r[1],c=s.length,a=new Uint8Array(c>>2);let f;if(s.length<2e7)for(var u=0;u<c;u+=4){f=A(o,l=s[u]*(1/255),d=s[u+1]*(1/255),v=s[u+2]*(1/255),w=s[u+3]*(1/255)),a[u>>2]=f.ind,n[u>>2]=f.est.rgba}else for(u=0;u<c;u+=4){var l=s[u]*(1/255),d=s[u+1]*(1/255),v=s[u+2]*(1/255),w=s[u+3]*(1/255);for(f=o;f.left;)f=g(f.est,l,d,v,w)<=0?f.left:f.right;a[u>>2]=f.ind,n[u>>2]=f.est.rgba}return{abuf:e.buffer,inds:a,plte:h}}function p(t,i,s){null==s&&(s=1e-4);const e=new Uint32Array(t.buffer),n={i0:0,i1:t.length,bst:null,est:null,tdst:0,left:null,right:null};n.bst=b(t,n.i0,n.i1),n.est=M(n.bst);const r=[n];for(;r.length<i;){let i=0,n=0;for(var o=0;o<r.length;o++)r[o].est.L>i&&(i=r[o].est.L,n=o);if(i<s)break;const h=r[n],c=m(t,e,h.i0,h.i1,h.est.e,h.est.eMq255);if(h.i0>=c||h.i1<=c){h.est.L=0;continue}const a={i0:h.i0,i1:c,bst:null,est:null,tdst:0,left:null,right:null};a.bst=b(t,a.i0,a.i1),a.est=M(a.bst);const f={i0:c,i1:h.i1,bst:null,est:null,tdst:0,left:null,right:null};f.bst={R:[],m:[],N:h.bst.N-a.bst.N};for(o=0;o<16;o++)f.bst.R[o]=h.bst.R[o]-a.bst.R[o];for(o=0;o<4;o++)f.bst.m[o]=h.bst.m[o]-a.bst.m[o];f.est=M(f.bst),h.left=a,h.right=f,r[n]=a,r.push(f)}r.sort(((t,i)=>i.bst.N-t.bst.N));for(o=0;o<r.length;o++)r[o].ind=o;return[n,r]}function A(t,i,s,e,n){if(null==t.left)return t.tdst=function t(i,s,e,n,r){const o=s-i[0],h=e-i[1],c=n-i[2],a=r-i[3];return o*o+h*h+c*c+a*a}(t.est.q,i,s,e,n),t;const r=g(t.est,i,s,e,n);let o=t.left,h=t.right;r>0&&(o=t.right,h=t.left);const c=A(o,i,s,e,n);if(c.tdst<=r*r)return c;const a=A(h,i,s,e,n);return a.tdst<c.tdst?a:c}function g(t,i,s,e,n){const{e:r}=t;return r[0]*i+r[1]*s+r[2]*e+r[3]*n-t.eMq}function m(t,i,s,e,n,r){for(e-=4;s<e;){for(;y(t,s,n)<=r;)s+=4;for(;y(t,e,n)>r;)e-=4;if(s>=e)break;const o=i[s>>2];i[s>>2]=i[e>>2],i[e>>2]=o,s+=4,e-=4}for(;y(t,s,n)>r;)s-=4;return s+4}function y(t,i,s){return t[i]*s[0]+t[i+1]*s[1]+t[i+2]*s[2]+t[i+3]*s[3]}function b(t,i,s){const e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=[0,0,0,0],r=s-i>>2;for(let r=i;r<s;r+=4){const i=t[r]*(1/255),s=t[r+1]*(1/255),o=t[r+2]*(1/255),h=t[r+3]*(1/255);n[0]+=i,n[1]+=s,n[2]+=o,n[3]+=h,e[0]+=i*i,e[1]+=i*s,e[2]+=i*o,e[3]+=i*h,e[5]+=s*s,e[6]+=s*o,e[7]+=s*h,e[10]+=o*o,e[11]+=o*h,e[15]+=h*h}return e[4]=e[1],e[8]=e[2],e[9]=e[6],e[12]=e[3],e[13]=e[7],e[14]=e[11],{R:e,m:n,N:r}}function M(t){const{R:i}=t,{m:s}=t,{N:e}=t,n=s[0],r=s[1],o=s[2],h=s[3],c=0==e?0:1/e,a=[i[0]-n*n*c,i[1]-n*r*c,i[2]-n*o*c,i[3]-n*h*c,i[4]-r*n*c,i[5]-r*r*c,i[6]-r*o*c,i[7]-r*h*c,i[8]-o*n*c,i[9]-o*r*c,i[10]-o*o*c,i[11]-o*h*c,i[12]-h*n*c,i[13]-h*r*c,i[14]-h*o*c,i[15]-h*h*c],f=a,u=x;let l=[Math.random(),Math.random(),Math.random(),Math.random()],d=0,v=0;if(0!=e)for(let t=0;t<16&&(l=u.multVec(f,l),v=Math.sqrt(u.dot(l,l)),l=u.sml(1/v,l),!(0!=t&&Math.abs(v-d)<1e-9));t++)d=v;const w=[n*c,r*c,o*c,h*c];return{Cov:a,q:w,e:l,L:d,eMq255:u.dot(u.sml(255,w),l),eMq:u.dot(l,w),rgba:(Math.round(255*w[3])<<24|Math.round(255*w[2])<<16|Math.round(255*w[1])<<8|Math.round(255*w[0])<<0)>>>0}}var x={multVec:(t,i)=>[t[0]*i[0]+t[1]*i[1]+t[2]*i[2]+t[3]*i[3],t[4]*i[0]+t[5]*i[1]+t[6]*i[2]+t[7]*i[3],t[8]*i[0]+t[9]*i[1]+t[10]*i[2]+t[11]*i[3],t[12]*i[0]+t[13]*i[1]+t[14]*i[2]+t[15]*i[3]],dot:(t,i)=>t[0]*i[0]+t[1]*i[1]+t[2]*i[2]+t[3]*i[3],sml:(t,i)=>[t*i[0],t*i[1],t*i[2],t*i[3]]};N.encode=function t(i,s,e,n,r,o,h){null==n&&(n=0),null==h&&(h=false);const u=f(i,s,e,n,[false,false,false,0,h,false]);return a(u,-1),c(u,s,e,r,o)},N.encodeLL=function t(i,s,e,n,r,o,h,f){const u={ctype:0+(1==n?0:2)+(0==r?0:4),depth:o,frames:[]},l=(n+r)*o,d=l*s;for(let t=0;t<i.length;t++)u.frames.push({rect:{x:0,y:0,width:s,height:e},img:new Uint8Array(i[t]),blend:0,dispose:1,bpp:Math.ceil(l/8),bpl:Math.ceil(d/8)});return a(u,0,true),c(u,s,e,h,f)},N.encode.compress=f,N.encode.dither=h,N.quantize=w,N.quantize.getKDtree=p,N.quantize.getNearest=A}();const q={toArrayBuffer(t,i){const s=t.width,e=t.height,n=s<<2,r=t.getContext("2d").getImageData(0,0,s,e),o=new Uint32Array(r.data.buffer),h=(32*s+31)/32<<2,c=h*e,a=122+c,f=new ArrayBuffer(a),u=new DataView(f),l=1<<20;let d,v,w,p,A=l,g=0,m=0,y=0;function b(t){u.setUint16(m,t,true),m+=2}function M(t){u.setUint32(m,t,true),m+=4}function x(t){m+=t}b(19778),M(a),x(4),M(122),M(108),M(s),M(-e>>>0),b(1),b(32),M(3),M(c),M(2835),M(2835),x(8),M(16711680),M(65280),M(255),M(4278190080),M(1466527264),function t(){for(;g<e&&A>0;){for(p=122+g*h,d=0;d<n;)A--,v=o[y++],w=v>>>24,u.setUint32(p+d,v<<8|w),d+=4;g++}y<o.length?(A=l,setTimeout(t,q._dly)):i(f)}()},toBlob(t,i){this.toArrayBuffer(t,(t=>{i(new Blob([t],{type:"image/bmp"}))}))},_dly:9};var Z={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},J={[Z.CHROME]:16384,[Z.FIREFOX]:11180,[Z.DESKTOP_SAFARI]:16384,[Z.IE]:8192,[Z.IOS]:4096,[Z.ETC]:8192};const tt="undefined"!=typeof window,it="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,st=tt&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),et=(tt||it)&&(st&&st.getOriginalSymbol(window,"File")||"undefined"!=typeof File&&File),nt=(tt||it)&&(st&&st.getOriginalSymbol(window,"FileReader")||"undefined"!=typeof FileReader&&FileReader);function rt(t,i,s=Date.now()){return new Promise((e=>{const n=t.split(","),r=n[0].match(/:(.*?);/)[1],o=globalThis.atob(n[1]);let h=o.length;const c=new Uint8Array(h);for(;h--;)c[h]=o.charCodeAt(h);const a=new Blob([c],{type:r});a.name=i,a.lastModified=s,e(a)}))}function ot(t){return new Promise(((i,s)=>{const e=new nt;e.onload=()=>i(e.result),e.onerror=t=>s(t),e.readAsDataURL(t)}))}function ht(t){return new Promise(((i,s)=>{const e=new Image;e.onload=()=>i(e),e.onerror=t=>s(t),e.src=t}))}function ct(){if(void 0!==ct.cachedResult)return ct.cachedResult;let t=Z.ETC;const{userAgent:i}=navigator;return/Chrom(e|ium)/i.test(i)?t=Z.CHROME:/iP(ad|od|hone)/i.test(i)&&/WebKit/i.test(i)?t=Z.IOS:/Safari/i.test(i)?t=Z.DESKTOP_SAFARI:/Firefox/i.test(i)?t=Z.FIREFOX:(/MSIE/i.test(i)||true==!!document.documentMode)&&(t=Z.IE),ct.cachedResult=t,ct.cachedResult}function at(t,i){const s=ct(),e=J[s];let n=t,r=i,o=n*r;const h=n>r?r/n:n/r;for(;o>e*e;){const t=(e+n)/2,i=(e+r)/2;t<i?(r=i,n=i*h):(r=t*h,n=t),o=n*r}return{width:n,height:r}}function ft(t,i){let s,e;try{if(s=new OffscreenCanvas(t,i),e=s.getContext("2d"),null===e)throw new Error("getContext of OffscreenCanvas returns null")}catch(t){s=document.createElement("canvas"),e=s.getContext("2d")}return s.width=t,s.height=i,[s,e]}function ut(t,i){const{width:s,height:e}=at(t.width,t.height),[n,r]=ft(s,e);return i&&/jpe?g/.test(i)&&(r.fillStyle="white",r.fillRect(0,0,n.width,n.height)),r.drawImage(t,0,0,n.width,n.height),n}function lt(){return void 0!==lt.cachedResult||(lt.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"undefined"!=typeof document&&"ontouchend"in document),lt.cachedResult}function dt(t,i={}){return new Promise((function(s,e){let n,r;var o=function(){try{return r=ut(n,i.fileType||t.type),s([n,r])}catch(t){return e(t)}},h=function(i){try{var s=function(t){try{throw t}catch(t){return e(t)}};try{let i;return ot(t).then((function(t){try{return i=t,ht(i).then((function(t){try{return n=t,function(){try{return o()}catch(t){return e(t)}}()}catch(t){return s(t)}}),s)}catch(t){return s(t)}}),s)}catch(t){s(t)}}catch(t){return e(t)}};try{if(lt()||[Z.DESKTOP_SAFARI,Z.MOBILE_SAFARI].includes(ct()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(t).then((function(t){try{return n=t,o()}catch(t){return h()}}),h)}catch(t){h()}}))}function vt(t,i,s,e,n=1){return new Promise((function(r,o){let h;if("image/png"===i){let a,f,u;return a=t.getContext("2d"),({data:f}=a.getImageData(0,0,t.width,t.height)),u=N.encode([f.buffer],t.width,t.height,4096*n),h=new Blob([u],{type:i}),h.name=s,h.lastModified=e,c.call(this)}{if("image/bmp"===i)return new Promise((i=>q.toBlob(t,i))).then(function(t){try{return h=t,h.name=s,h.lastModified=e,l.call(this)}catch(t){return o(t)}}.bind(this),o);{if("function"==typeof OffscreenCanvas&&t instanceof OffscreenCanvas)return t.convertToBlob({type:i,quality:n}).then(function(t){try{return h=t,h.name=s,h.lastModified=e,d.call(this)}catch(t){return o(t)}}.bind(this),o);{let v;return v=t.toDataURL(i,n),rt(v,s,e).then(function(t){try{return h=t,d.call(this)}catch(t){return o(t)}}.bind(this),o)}function d(){return l.call(this)}}function l(){return c.call(this)}}function c(){return r(h)}}))}function wt(t){t.width=0,t.height=0}function pt(){return new Promise((function(t,i){let s,e,n,r;return void 0!==pt.cachedResult?t(pt.cachedResult):rt("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(o){try{return s=o,dt(s).then((function(o){try{return e=o[1],vt(e,s.type,s.name,s.lastModified).then((function(s){try{return n=s,wt(e),dt(n).then((function(s){try{return r=s[0],pt.cachedResult=1===r.width&&2===r.height,t(pt.cachedResult)}catch(t){return i(t)}}),i)}catch(t){return i(t)}}),i)}catch(t){return i(t)}}),i)}catch(t){return i(t)}}),i)}))}function At(t){return new Promise(((i,s)=>{const e=new nt;e.onload=t=>{const s=new DataView(t.target.result);if(65496!=s.getUint16(0,false))return i(-2);const e=s.byteLength;let n=2;for(;n<e;){if(s.getUint16(n+2,false)<=8)return i(-1);const t=s.getUint16(n,false);if(n+=2,65505==t){if(1165519206!=s.getUint32(n+=2,false))return i(-1);const t=18761==s.getUint16(n+=6,false);n+=s.getUint32(n+4,t);const e=s.getUint16(n,t);n+=2;for(let r=0;r<e;r++)if(274==s.getUint16(n+12*r,t))return i(s.getUint16(n+12*r+8,t))}else{if(65280!=(65280&t))break;n+=s.getUint16(n,false)}}return i(-1)},e.onerror=t=>s(t),e.readAsArrayBuffer(t)}))}function gt(t,i){const{width:s}=t,{height:e}=t,{maxWidthOrHeight:n}=i;let r,o=t;return isFinite(n)&&(s>n||e>n)&&([o,r]=ft(s,e),s>e?(o.width=n,o.height=e/s*n):(o.width=s/e*n,o.height=n),r.drawImage(t,0,0,o.width,o.height),wt(t)),o}function mt(t,i){const{width:s}=t,{height:e}=t,[n,r]=ft(s,e);switch(i>4&&i<9?(n.width=e,n.height=s):(n.width=s,n.height=e),i){case 2:r.transform(-1,0,0,1,s,0);break;case 3:r.transform(-1,0,0,-1,s,e);break;case 4:r.transform(1,0,0,-1,0,e);break;case 5:r.transform(0,1,1,0,0,0);break;case 6:r.transform(0,1,-1,0,e,0);break;case 7:r.transform(0,-1,-1,0,e,s);break;case 8:r.transform(0,-1,1,0,0,s)}return r.drawImage(t,0,0,s,e),wt(t),n}function yt(t,i,s=0){return new Promise((function(e,n){let r,o,h,c,a,f,u,l,d,v,w,p,A,g,m,y,b,M,x,E;function U(t=5){if(i.signal&&i.signal.aborted)throw i.signal.reason;r+=t,i.onProgress(Math.min(r,100))}function F(t){if(i.signal&&i.signal.aborted)throw i.signal.reason;r=Math.min(Math.max(t,r),100),i.onProgress(r)}return r=s,o=i.maxIteration||10,h=1024*i.maxSizeMB*1024,U(),dt(t,i).then(function(s){try{return[,c]=s,U(),a=gt(c,i),U(),new Promise((function(s,e){var n;if(!(n=i.exifOrientation))return At(t).then(function(t){try{return n=t,r.call(this)}catch(t){return e(t)}}.bind(this),e);function r(){return s(n)}return r.call(this)})).then(function(s){try{return f=s,U(),pt().then(function(s){try{return u=s?a:mt(a,f),U(),l=i.initialQuality||1,d=i.fileType||t.type,vt(u,d,t.name,t.lastModified,l).then(function(s){try{{if(v=s,U(),w=v.size>h,p=v.size>t.size,!w&&!p)return F(100),e(v);var r;function f(){if(o--&&(m>h||m>A)){let i,s;return i=E?.95*x.width:x.width,s=E?.95*x.height:x.height,[b,M]=ft(i,s),M.drawImage(x,0,0,i,s),l*="image/png"===d?.85:.95,vt(b,d,t.name,t.lastModified,l).then((function(t){try{return y=t,wt(x),x=b,m=y.size,F(Math.min(99,Math.floor((g-m)/(g-h)*100))),f}catch(t){return n(t)}}),n)}return[1]}return A=t.size,g=v.size,m=g,x=u,E=!i.alwaysKeepResolution&&w,(r=function(t){for(;t;){if(t.then)return void t.then(r,n);try{if(t.pop){if(t.length)return t.pop()?P.call(this):t;t=f}else t=t.call(this)}catch(t){return n(t)}}}.bind(this))(f);function P(){return wt(x),wt(b),wt(a),wt(u),wt(c),F(100),e(y)}}}catch(T){return n(T)}}.bind(this),n)}catch(t){return n(t)}}.bind(this),n)}catch(t){return n(t)}}.bind(this),n)}catch(t){return n(t)}}.bind(this),n)}))}const bt="\nlet scriptImported = false\nself.addEventListener('message', async (e) => {\n const { file, id, imageCompressionLibUrl, options } = e.data\n options.onProgress = (progress) => self.postMessage({ progress, id })\n try {\n if (!scriptImported) {\n // console.log('[worker] importScripts', imageCompressionLibUrl)\n self.importScripts(imageCompressionLibUrl)\n scriptImported = true\n }\n // console.log('[worker] self', self)\n const compressedFile = await imageCompression(file, options)\n self.postMessage({ file: compressedFile, id })\n } catch (e) {\n // console.error('[worker] error', e)\n self.postMessage({ error: e.message + '\\n' + e.stack, id })\n }\n})\n";let Mt;function xt(t,i){return new Promise(((s,e)=>{Mt||(Mt=function t(i){const s=[];return s.push(i),URL.createObjectURL(new Blob(s))}(bt));const n=new Worker(Mt);n.addEventListener("message",(function t(r){if(i.signal&&i.signal.aborted)n.terminate();else if(void 0===r.data.progress){if(r.data.error)return e(new Error(r.data.error)),void n.terminate();s(r.data.file),n.terminate()}else i.onProgress(r.data.progress)})),n.addEventListener("error",e),i.signal&&i.signal.addEventListener("abort",(()=>{e(i.signal.reason),n.terminate()})),n.postMessage({file:t,imageCompressionLibUrl:i.libURL,options:{...i,onProgress:void 0,signal:void 0}})}))}function Et(t,i){return new Promise((function(s,e){let n,r,o,h,c,a;if(n={...i},o=0,({onProgress:h}=n),n.maxSizeMB=n.maxSizeMB||Number.POSITIVE_INFINITY,c="boolean"!=typeof n.useWebWorker||n.useWebWorker,delete n.useWebWorker,n.onProgress=t=>{o=t,"function"==typeof h&&h(o)},!(t instanceof Blob||t instanceof et))return e(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(t.type))return e(new Error("The file given is not an image"));if(a="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,!c||"function"!=typeof Worker||a)return yt(t,n).then(function(t){try{return r=t,l.call(this)}catch(t){return e(t)}}.bind(this),e);var f=function(){try{return l.call(this)}catch(t){return e(t)}}.bind(this),u=function(i){try{return yt(t,n).then((function(t){try{return r=t,f()}catch(t){return e(t)}}),e)}catch(t){return e(t)}};try{return n.libURL=n.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",xt(t,n).then((function(t){try{return r=t,f()}catch(t){return u()}}),u)}catch(t){u()}function l(){try{r.name=t.name,r.lastModified=t.lastModified}catch(t){}try{n.preserveExif&&"image/jpeg"===t.type&&(!n.fileType||n.fileType&&n.fileType===t.type)&&(r=W(t,r))}catch(t){}return s(r)}}))}Et.getDataUrlFromFile=ot,Et.getFilefromDataUrl=rt,Et.loadImage=ht,Et.drawImageInCanvas=ut,Et.drawFileInCanvas=dt,Et.canvasToFile=vt,Et.getExifOrientation=At,Et.handleMaxWidthOrHeight=gt,Et.followExifOrientation=mt,Et.cleanupCanvasMemory=wt,Et.isAutoOrientationInBrowser=pt,Et.approximateBelowMaximumCanvasSizeOfBrowser=at,Et.copyExifWithoutOrientation=W,Et.getBrowserName=ct,Et.version="2.0.2";class Ut extends e{fileInput=null;maxCompressionSize=300;constructor(t){super(t);this.setupFileInput()}onActivate(){this.openFilePicker()}openFilePicker(){if(this._core.store.isDisabled){return}this.fileInput.click()}setupFileInput(){this.fileInput=document.createElement("input");this.fileInput.type="file";this.fileInput.accept="image/*";this.fileInput.style.display="none";this.fileInput.addEventListener("change",this.handleFileSelect.bind(this));this.fileInput.addEventListener("cancel",this.handleCancel.bind(this));document.body.appendChild(this.fileInput)}handleFileSelect(t){const i=t.target;if(i.files&&i.files[0]){const t=i.files[0];Et(t,{maxWidthOrHeight:this.maxCompressionSize}).then((t=>{this.readFile(t)})).catch((t=>{console.error("Error during image compression or processing:",t);this.handleCancel()}))}else{console.info("File selection cancelled by user.");this.handleCancel()}if(i){i.value=""}}readFile(t){const i=new FileReader;i.onload=t=>{const i=new Image;i.src=t.target?.result;i.onload=()=>this.createKritzelImage(i)};i.readAsDataURL(t)}createKritzelImage(t){const i=m.create(this._core);const{scaledWidth:s,scaledHeight:e}=i.calculateScaledDimensions(t);i.src=t.src;i.width=s;i.height=e;i.zIndex=this._core.store.currentZIndex;i.centerInViewport();this.addImageToStore(i);return i}addImageToStore(t){const i=K.create(this._core);i.addOrRemove(t);i.isSelected=true;const e=new n(this._core,this,t);const r=new C(this._core,this,i);this._core.history.executeCommand(new b(this._core,this,[e,r]));this._core.store.setState("activeTool",s.getTool("selection"))}handleCancel(){this._core.store.setState("activeTool",s.getTool("selection"))}}export{C as A,b as B,O as D,y as K,a as O,U as R,i as U,c as a,r as b,D as c,E as d,Q as e,Ut as f,G as g,h,o as i,P as j,s as k,K as l,t as m,I as n,H as o,x as p,n as q,e as r,l as s,g as t,m as u};
|
|
2
|
+
//# sourceMappingURL=p-BrCE-Ctm.js.map
|