kritzel-stencil 0.0.123 → 0.0.125

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/{index-UcX3pzju.js → index-CgSgPOBv.js} +8 -11
  2. package/dist/cjs/index-CgSgPOBv.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +13 -14
  5. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  6. package/dist/collection/classes/handlers/hover.handler.js +0 -3
  7. package/dist/collection/classes/handlers/hover.handler.js.map +1 -1
  8. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  9. package/dist/collection/classes/objects/path.class.js +6 -4
  10. package/dist/collection/classes/objects/path.class.js.map +1 -1
  11. package/dist/collection/classes/objects/selection-group.class.js +0 -2
  12. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  13. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +12 -13
  14. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  15. package/dist/components/index.js +2 -2
  16. package/dist/components/kritzel-controls.js +1 -1
  17. package/dist/components/kritzel-editor.js +3 -3
  18. package/dist/components/kritzel-engine.js +1 -1
  19. package/dist/components/{p-Cnc43o9b.js → p-BJOf0PsO.js} +8 -6
  20. package/dist/components/p-BJOf0PsO.js.map +1 -0
  21. package/dist/components/{p-DJaVT2yR.js → p-BjG1zRRI.js} +15 -21
  22. package/dist/components/p-BjG1zRRI.js.map +1 -0
  23. package/dist/components/{p-CneTqrgt.js → p-CBCFr_x3.js} +3 -3
  24. package/dist/components/{p-CneTqrgt.js.map → p-CBCFr_x3.js.map} +1 -1
  25. package/dist/esm/{index-DO2IiM_o.js → index-B_0CRlFw.js} +8 -11
  26. package/dist/esm/index-B_0CRlFw.js.map +1 -0
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/kritzel-brush-style_18.entry.js +13 -14
  29. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  30. package/dist/stencil/index.esm.js +1 -1
  31. package/dist/stencil/{p-c64f6589.entry.js → p-3a2f1d19.entry.js} +2 -2
  32. package/dist/stencil/p-3a2f1d19.entry.js.map +1 -0
  33. package/dist/stencil/p-B_0CRlFw.js +2 -0
  34. package/dist/stencil/p-B_0CRlFw.js.map +1 -0
  35. package/dist/stencil/stencil.esm.js +1 -1
  36. package/dist/types/classes/objects/path.class.d.ts +1 -1
  37. package/package.json +62 -57
  38. package/dist/cjs/index-UcX3pzju.js.map +0 -1
  39. package/dist/components/p-Cnc43o9b.js.map +0 -1
  40. package/dist/components/p-DJaVT2yR.js.map +0 -1
  41. package/dist/esm/index-DO2IiM_o.js.map +0 -1
  42. package/dist/stencil/p-DO2IiM_o.js +0 -2
  43. package/dist/stencil/p-DO2IiM_o.js.map +0 -1
  44. package/dist/stencil/p-c64f6589.entry.js.map +0 -1
@@ -1,2 +0,0 @@
1
- class t{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}}t.registry={};class i{constructor(t){this.__class__=this.constructor.name;this.name="base-tool";this._store=t}onActivate(){}onDeactivate(){}handlePointerDown(t){}handlePointerMove(t){}handlePointerUp(t){}handleWheel(t){}revive(t){Object.assign(this,t);return this}}class s{constructor(t,i){var s,e;this._store=t;this.initiator=(e=(s=i===null||i===void 0?void 0:i.constructor)===null||s===void 0?void 0:s.name)!==null&&e!==void 0?e:"Unknown";this.isUndoable=true}execute(){throw new Error("Method not implemented.")}undo(){throw new Error("Method not implemented.")}}class e extends s{constructor(t,i,s){super(t,i);this.object=s}execute(){this._store.state.objectsOctree.insert(this.object)}undo(){this._store.state.objectsOctree.remove((t=>t.id===this.object.id))}}var n;(function(t){t[t["Left"]=0]="Left";t[t["Middle"]=1]="Middle";t[t["Right"]=2]="Right"})(n||(n={}));class r{static isRightClick(t){return t.button===n.Right}static isLeftClick(t){return t.button===n.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 onLongTouchPress(t,i,s){if(t.pointerType!=="touch"){s===null||s===void 0?void 0:s();return()=>{}}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 f=()=>{clearTimeout(c);d();s===null||s===void 0?void 0:s()};const a=t=>{if(Math.abs(t.clientX-r)>n||Math.abs(t.clientY-o)>n){f()}};const u=()=>{f()};const l=()=>{f()};const d=()=>{h.removeEventListener("pointermove",a);h.removeEventListener("pointerup",u);h.removeEventListener("pointercancel",l)};h.addEventListener("pointermove",a,{passive:true});h.addEventListener("pointerup",u,{once:true});h.addEventListener("pointercancel",l,{once:true});return f}}class o{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)}}}class h extends i{constructor(t){super(t);this.fontFamily="Arial";this.fontSize=16;this.fontColor="#000000";this.palette=["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#808000","#800080"]}handlePointerDown(i){if(i.cancelable){i.preventDefault()}if(i.pointerType==="mouse"){const s=i.composedPath().slice(1);const n=s.find((t=>t.classList&&t.classList.contains("object")));const o=this._store.findObjectById(n===null||n===void 0?void 0:n.id);if(this._store.state.activeText===null&&o&&o instanceof l){this._store.state.activeText=o;o.focus();return}if(this._store.state.activeText!==null&&o instanceof l){o.focus();return}if(this._store.state.activeText!==null){this._store.resetActiveText();this._store.setState("activeTool",t.getTool("selection"));return}if(r.isLeftClick(i)===false){return}const h=i.clientX-this._store.offsetX;const c=i.clientY-this._store.offsetY;const f=l.create(this._store,this.fontSize,this.fontFamily);f.fontColor=this.fontColor;f.translateX=(h-this._store.state.translateX)/this._store.state.scale;f.translateY=(c-this._store.state.translateY)/this._store.state.scale;f.zIndex=this._store.currentZIndex;this._store.state.activeText=f;this._store.history.executeCommand(new e(this._store,this,f))}if(i.pointerType==="touch"){const s=Array.from(this._store.state.pointers.values());const n=i.composedPath().slice(1);const r=n.find((t=>t.classList&&t.classList.contains("object")));const h=this._store.findObjectById(r===null||r===void 0?void 0:r.id);if(this._store.state.activeText===null&&h&&h instanceof l){this._store.state.activeText=h;h.focus();return}if(this._store.state.activeText!==null&&h instanceof l){h.focus();return}if(this._store.state.activeText!==null){this._store.resetActiveText();this._store.setState("activeTool",t.getTool("selection"));return}if(s.length>1){return}o.disableInteractiveWidget();const c=Math.round(s[0].clientX-this._store.offsetX);const f=Math.round(s[0].clientY-this._store.offsetY);const a=l.create(this._store,this.fontSize,this.fontFamily);a.fontColor=this.fontColor;a.translateX=(c-this._store.state.translateX)/this._store.state.scale;a.translateY=(f-this._store.state.translateY)/this._store.state.scale;a.zIndex=this._store.currentZIndex;this._store.state.activeText=a;this._store.history.executeCommand(new e(this._store,this,a))}}handlePointerUp(t){var i,s,e,n;if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){(i=this._store.state.activeText)===null||i===void 0?void 0:i.adjustTextareaSize();(s=this._store.state.activeText)===null||s===void 0?void 0:s.focus()}if(t.pointerType==="touch"){(e=this._store.state.activeText)===null||e===void 0?void 0:e.adjustTextareaSize();(n=this._store.state.activeText)===null||n===void 0?void 0:n.focus();o.enableInteractiveWidget()}}}var c=undefined&&undefined.__rest||function(t,i){var s={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0)s[e]=t[e];if(t!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,e=Object.getOwnPropertySymbols(t);n<e.length;n++){if(i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n]))s[e[n]]=t[e[n]]}return s};class f{static generateUUID(){return Math.random().toString(36).substr(2,9)}static clone(t){const i=t=>{const i=t,{element:s}=i,e=c(i,["_store","_elementRef","totalWidth","totalHeight","element"]);const n=structuredClone(e);if(s&&s instanceof HTMLElement){n.element=s.cloneNode(true)}return n};if(Array.isArray(t)){return t.map(i)}return i(t)}static isEmpty(t){if(t===null||t===undefined){return true}return(Object===null||Object===void 0?void 0:Object.keys(t).length)===0&&(t===null||t===void 0?void 0:t.constructor)===Object}}class a{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 f=o>t.y!==c>t.y&&t.x<(h-r)*(t.y-o)/(c-o)+r;if(f)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{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.__class__="KritzelBaseObject";this.borderWidth=0;this.opacity=1;this.padding=0;this.resizing=false;this.rotation=0;this.markedForRemoval=false;this.zIndex=0;this.isVisible=true;this.isSelected=false;this.isHovered=false;this.isMounted=false;this.isEditable=false;this.isInteractive=false;this.isDebugInfoVisible=false;this.id=this.generateId()}static create(t){const i=new u;i._store=t;i.zIndex=t.currentZIndex;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 f.generateUUID()}isInViewport(){const t={x:-this._store.state.translateX/this._store.state.scale,y:-this._store.state.translateY/this._store.state.scale,width:this._store.state.viewportWidth/this._store.state.scale,height:this._store.state.viewportHeight/this._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._store.state.scale;this.translateX=(this._store.state.viewportWidth/2-this.totalWidth/2-this._store.state.translateX)/t;this.translateY=(this._store.state.viewportHeight/2-this.totalHeight/2-this._store.state.translateY)/t}move(t,i,s,e){const n=(t-s)/this._store.state.scale;const r=(i-e)/this._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}copy(){const t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this);t.id=this.generateId();t.isMounted=false;return t}onSelectedClick(){}revive(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 a.doPolygonsIntersect(i,t)}}class l extends u{get isReadonly(){return!(this._store.state.activeTool instanceof h)}constructor(t){super();this.__class__="KritzelText";this.value="";this.fontFamily="Arial";this.fontSize=8;this.fontColor="#000000";this.initialWidth=3;this.isNew=true;this.isDebugInfoVisible=true;this.isEditable=true;this.rows=1;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._store=t;e.fontSize=i;e.fontFamily=s;e.translateX=0;e.translateY=0;e.width=e.initialWidth/(e._store.state.scale<0?e._store.state.scale:1);e.height=e.fontSize*1.2/(e._store.state.scale<0?e._store.state.scale:1);e.padding=5;e.backgroundColor="transparent";e.scale=e._store.state.scale;e.value=" ";e.zIndex=t.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.adjustTextareaSize()}adjustTextareaSize(){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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")+"<br>";document.body.appendChild(t);const i=t.offsetWidth;const s=t.offsetHeight;document.body.removeChild(t);this.width=i;this.height=s;this._store.rerender()}}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.adjustTextareaSize()}))}catch(t){console.error("Failed to read clipboard contents:",t)}}}edit(){this._store.setState("activeTool",t.getTool("text"));this._store.state.selectionGroup=null;this._store.state.selectionBox=null;this._store.state.activeText=this;setTimeout((()=>{this.focus()}),300)}}var d={};var v;function A(){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:()=>E,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 f(t,i){return[t[0]/i,t[1]/i]}function a(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 A(t,i){return v(h(t,i))}function w(t){return f(t,d(t))}function p(t,i){return Math.hypot(t[1]-i[1],t[0]-i[0])}function m(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 g(t,i,s){return o(t,c(h(i,t),s))}function y(t,i,s){return o(t,c(i,s))}var{min:M,PI:b}=Math,U=.275,x=b+1e-4;function E(t,i={}){let{size:s=16,smoothing:e=.5,thinning:f=.5,simulatePressure:l=true,easing:d=t=>t,start:v={},end:p={},last:b=false}=i,{cap:E=true,easing:F=t=>t*(2-t)}=v,{cap:P=true,easing:T=t=>--t*t*t+1}=p;if(t.length===0||s<=0)return[];let B=t[t.length-1].runningLength,k=v.taper===false?0:v.taper===true?Math.max(s,B):v.taper,S=p.taper===false?0:p.taper===true?Math.max(s,B):p.taper,I=Math.pow(s*e,2),C=[],j=[],O=t.slice(0,10).reduce(((t,i)=>{let e=i.pressure;if(l){let n=M(1,i.distance/s),r=M(1,1-n);e=M(1,t+(r-t)*(n*U))}return(t+e)/2}),t[0].pressure),Q=n(s,f,t[t.length-1].pressure,d),z,R=t[0].vector,D=t[0].point,K=D,L=D,$=K,H=false;for(let i=0;i<t.length;i++){let{pressure:e}=t[i],{point:r,vector:v,distance:w,runningLength:p}=t[i];if(i<t.length-1&&B-p<3)continue;if(f){if(l){let t=M(1,w/s),i=M(1,1-t);e=M(1,O+(i-O)*(t*U))}Q=n(s,f,e,d)}else Q=s/2;z===void 0&&(z=Q);let y=p<k?F(p/k):1,b=B-p<S?T((B-p)/S):1;Q=Math.max(.01,Q*Math.min(y,b));let E=(i<t.length-1?t[i+1]:t[i]).vector,P=i<t.length-1?u(v,E):1,W=u(v,R)<0&&!H,_=P!==null&&P<0;if(W||_){let t=c(a(R),Q);for(let i=1/13,s=0;s<=1;s+=i)L=m(h(r,t),r,x*s),C.push(L),$=m(o(r,t),r,x*-s),j.push($);D=L,K=$,_&&(H=true);continue}if(H=false,i===t.length-1){let t=c(a(v),Q);C.push(h(r,t)),j.push(o(r,t));continue}let X=c(a(g(E,v,P)),Q);L=h(r,X),(i<=1||A(D,L)>I)&&(C.push(L),D=L),$=o(r,X),(i<=1||A(K,$)>I)&&(j.push($),K=$),O=e,R=v}let W=t[0].point.slice(0,2),_=t.length>1?t[t.length-1].point.slice(0,2):o(t[0].point,[1,1]),X=[],G=[];if(t.length===1){if(!(k||S)||b){let t=y(W,w(a(h(W,_))),-(z||Q)),i=[];for(let s=1/13,e=s;e<=1;e+=s)i.push(m(t,W,x*2*e));return i}}else{if(!(k||S&&t.length===1))if(E)for(let t=1/13,i=t;i<=1;i+=t){let t=m(j[0],W,x*i);X.push(t)}else{let t=h(C[0],j[0]),i=c(t,.5),s=c(t,.51);X.push(h(W,i),h(W,s),o(W,s),o(W,i))}let i=a(r(t[t.length-1].vector));if(S||k&&t.length===1)G.push(_);else if(P){let t=y(_,i,Q);for(let i=1/29,s=i;s<1;s+=i)G.push(m(t,_,x*3*s))}else G.push(o(_,c(i,Q)),o(_,c(i,Q*.99)),h(_,c(i,Q*.99)),h(_,c(i,Q)))}return C.concat(G,j.reverse(),X)}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,f=Array.isArray(t[0])?t:t.map((({x:t,y:i,pressure:s=.5})=>[t,i,s]));if(f.length===2){let t=f[1];f=f.slice(0,-1);for(let i=1;i<5;i++)f.push(g(f[0],t,i/4))}f.length===1&&(f=[...f,[...o(f[0],[1,1]),...f[0].slice(2)]]);let a=[{point:[f[0][0],f[0][1]],pressure:f[0][2]>=0?f[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],u=false,d=0,v=a[0],A=f.length-1;for(let t=1;t<f.length;t++){let i=r&&t===A?f[t].slice(0,2):g(v.point,f[t],c);if(l(v.point,i))continue;let s=p(i,v.point);if(d+=s,t<A&&!u){if(d<n)continue;u=true}v={point:i,pressure:f[t][2]>=0?f[t][2]:.5,vector:w(h(v.point,i)),distance:s,runningLength:d},a.push(v)}return a[0].vector=((s=a[1])==null?void 0:s.vector)||[0,0],a}function P(t,i={}){return E(F(t,i),i)}var T=P})(d);return d}var w=A();class p{static average(t,i){return(t+i)/2}}class m extends u{get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){var i,s,e,n,r,o;super();this.__class__="KritzelPath";this.stroke="none";this.lineSlack=.5;this.x=0;this.y=0;this.height=0;this.width=0;this.scale=1;this.isVisible=true;this.isDebugInfoVisible=true;this._adjustedPoints=null;this.options=t;this.points=(i=t===null||t===void 0?void 0:t.points)!==null&&i!==void 0?i:[];this.translateX=(s=t===null||t===void 0?void 0:t.translateX)!==null&&s!==void 0?s:0;this.translateY=(e=t===null||t===void 0?void 0:t.translateY)!==null&&e!==void 0?e:0;this.scale=(n=t===null||t===void 0?void 0:t.scale)!==null&&n!==void 0?n:1;this.strokeWidth=(r=t===null||t===void 0?void 0:t.strokeWidth)!==null&&r!==void 0?r:8;this.fill=(o=t===null||t===void 0?void 0:t.fill)!==null&&o!==void 0?o:"#000000";this.d=this.generateSvgPath();this.updateDimensions()}static create(t,i){var s,e,n,r,o,h;const c=new m;c._store=t;c.id=c.generateId();c.options=i;c.points=(s=i===null||i===void 0?void 0:i.points)!==null&&s!==void 0?s:[];c.translateX=(e=i===null||i===void 0?void 0:i.translateX)!==null&&e!==void 0?e:0;c.translateY=(n=i===null||i===void 0?void 0:i.translateY)!==null&&n!==void 0?n:0;c.scale=(r=i===null||i===void 0?void 0:i.scale)!==null&&r!==void 0?r:1;c.strokeWidth=(o=i===null||i===void 0?void 0:i.strokeWidth)!==null&&o!==void 0?o:8;c.fill=(h=i===null||i===void 0?void 0:i.fill)!==null&&h!==void 0?h:"#000000";c.zIndex=t.currentZIndex;c.d=c.generateSvgPath();c.updateDimensions();return c}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){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(a.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(a.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 f=this.pointToLineSegmentDistance(e[0],e[1],r.x,r.y,o.x,o.y);const a=this.pointToLineSegmentDistance(n[0],n[1],r.x,r.y,o.x,o.y);const u=Math.min(h,c,f,a);if(u<=i){return true}}}return false}computeAdjustedPoints(){var t;if(!((t=this.points)===null||t===void 0?void 0:t.length)){return[]}const i=this.rotation;const s=Math.cos(i);const e=Math.sin(i);const n=this.points.map((t=>t[0]));const r=this.points.map((t=>t[1]));const o={x:(Math.min(...n)+Math.max(...n))/2,y:(Math.min(...r)+Math.max(...r))/2};const{x:h,y:c}=o;const f=this.points.map((([t,i])=>{const n=t-h;const r=i-c;return[h+n*s-r*e,c+n*e+r*s]}));const a=this.x-this.translateX;const u=this.y-this.translateY;return f.map((([t,i])=>[(t+this.options.translateX-a)/this.scale,(i+this.options.translateY-u)/this.scale]))}pointToLineSegmentDistance(t,i,s,e,n,r){const o=t-s;const h=i-e;const c=n-s;const f=r-e;const a=o*c+h*f;const u=c*c+f*f;let l=-1;if(u!==0){l=a/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*f}const A=t-d;const w=i-v;return Math.sqrt(A*A+w*w)}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 w.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)} ${p.average(n[0],r[0]).toFixed(2)},${p.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+=`${p.average(e[0],n[0]).toFixed(2)},${p.average(e[1],n[1]).toFixed(2)} `}if(i){o+="Z"}return o}}class g extends u{constructor(t){super();this.__class__="KritzelImage";this.src="";this.maxWidth=300;this.maxHeight=300;this.maxCompressionSize=300;this.isDebugInfoVisible=true;this.src=(t===null||t===void 0?void 0:t.src)||"";this.x=(t===null||t===void 0?void 0:t.x)||0;this.y=(t===null||t===void 0?void 0:t.y)||0;this.translateX=(t===null||t===void 0?void 0:t.translateX)||0;this.translateY=(t===null||t===void 0?void 0:t.translateY)||0;this.scale=(t===null||t===void 0?void 0:t.scale)||1}static create(t){const i=new g;i._store=t;i.id=i.generateId();i.x=0;i.y=0;i.translateX=0;i.translateY=0;i.scale=i._store.state.scale;i.zIndex=t.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 i{constructor(t){super(t);this.type="pen";this.color="#000000";this.size=6;this.palettes={pen:["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#808000","#800080"],highlighter:["#ffff00","#ffb347","#b4ffb4"]}}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(r.isLeftClick(t)){this._store.state.isDrawing=true;const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;this._store.state.currentPath=m.create(this._store,{points:[[i,s]],translateX:-this._store.state.translateX,translateY:-this._store.state.translateY,scale:this._store.state.scale,fill:this.color,strokeWidth:this.size})}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());if(t.length===1){const i=Math.round(t[0].clientX-this._store.offsetX);const s=Math.round(t[0].clientY-this._store.offsetY);this._store.state.isDrawing=true;this._store.state.currentPath=m.create(this._store,{points:[[i,s]],translateX:-this._store.state.translateX,translateY:-this._store.state.translateY,scale:this._store.state.scale,fill:this.color,strokeWidth:this.size});this._store.rerender()}}}handlePointerMove(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._store.state.isDrawing){const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;this._store.state.currentPath=m.create(this._store,{points:[...this._store.state.currentPath.points,[i,s]],translateX:-this._store.state.translateX,translateY:-this._store.state.translateY,scale:this._store.state.scale,fill:this.color,strokeWidth:this.size});this._store.rerender()}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());if(t.length===1){const i=Math.round(t[0].clientX-this._store.offsetX);const s=Math.round(t[0].clientY-this._store.offsetY);this._store.state.currentPath=m.create(this._store,{points:[...this._store.state.currentPath.points,[i,s]],translateX:-this._store.state.translateX,translateY:-this._store.state.translateY,scale:this._store.state.scale,fill:this.color,strokeWidth:this.size});this._store.rerender()}}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._store.state.isDrawing){this._store.state.isDrawing=false;if(this._store.state.currentPath){this._store.state.currentPath.zIndex=this._store.currentZIndex;this._store.history.executeCommand(new e(this._store,this,this._store.state.currentPath))}this._store.state.currentPath=undefined}}if(t.pointerType==="touch"){if(this._store.state.isDrawing){this._store.state.isDrawing=false;if(this._store.state.currentPath){this._store.state.currentPath.zIndex=this._store.currentZIndex;this._store.history.executeCommand(new e(this._store,this,this._store.state.currentPath))}this._store.state.currentPath=undefined;this._store.rerender()}}}}class M extends s{constructor(t,i,s){super(t,i);this.commands=s}execute(){this.commands.forEach((t=>t.execute()))}undo(){this.commands.forEach((t=>t.undo()))}}class b extends u{constructor(t){super();this.__class__="KritzelCustomElement";this.isInteractive=true;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 b(i);s._store=t;s.id=s.generateId();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 U extends s{constructor(t,i,s){super(t,i);this.object=s}execute(){this._store.state.objectsOctree.remove((t=>t.id===this.object.id));this._store.state.objectsOctree.filter((t=>t instanceof b)).forEach((t=>t.remount()))}undo(){this._store.state.objectsOctree.insert(this.object);this._store.state.objectsOctree.filter((t=>t instanceof b)).forEach((t=>t.remount()))}}class x extends i{constructor(t){super(t);this.touchStartTimeout=null}handlePointerDown(t){if(t.pointerType==="mouse"){if(r.isLeftClick(t)){this._store.state.isErasing=true}}if(t.pointerType==="touch"){this.touchStartTimeout=setTimeout((()=>{if(this._store.state.pointers.size===1&&!this._store.state.isScaling){this._store.state.isErasing=true}}),80)}}handlePointerMove(t){var i;if(t.pointerType==="mouse"){if(this._store.state.isErasing){const i=this._store.getObjectsFromPointerEvent(t,".object");if(i.length===0)return;const s=this._store.state.pointerX;const e=this._store.state.pointerY;i.forEach((t=>{t.markedForRemoval=t.hitTest(s,e)}));this._store.rerender()}}if(t.pointerType==="touch"){if(this._store.state.pointers.size===1&&this._store.state.isErasing){const s=(i=this._store.state.host)===null||i===void 0?void 0:i.shadowRoot;if(!s)return;const e=this._store.getObjectsFromPointerEvent(t,".object");if(e.length===0)return;const n=this._store.state.pointerX;const r=this._store.state.pointerY;e.forEach((t=>{t.markedForRemoval=t.hitTest(n,r)}));this._store.rerender()}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._store.state.isErasing){const t=this._store.allObjects.filter((t=>t.markedForRemoval)).map((t=>{t.markedForRemoval=false;return new U(this._store,this,t)}));if(t.length>0){this._store.history.executeCommand(new M(this._store,this,t))}this._store.state.isErasing=false}}if(t.pointerType==="touch"){clearTimeout(this.touchStartTimeout);if(this._store.state.isErasing){const t=this._store.allObjects.filter((t=>t.markedForRemoval)).map((t=>{t.markedForRemoval=false;return new U(this._store,this,t)}));if(t.length>0){this._store.history.executeCommand(new M(this._store,this,t))}this._store.state.isErasing=false}}}}class E extends s{constructor(t,i){super(t,i);this.previousSelectionGroup=this._store.state.selectionGroup}execute(){this._store.state.objectsOctree.remove((t=>{var i;return t.id===((i=this.previousSelectionGroup)===null||i===void 0?void 0:i.id)}));this._store.state.selectionGroup=null}undo(){if(this.previousSelectionGroup){this._store.state.objectsOctree.insert(this.previousSelectionGroup);this._store.state.selectionGroup=this.previousSelectionGroup}}}class F extends s{constructor(t,i,s,e,n,r,o=false){super(t,i);this.startX=s;this.startY=e;this.endX=n;this.endY=r;this.skipExecution=o;this.selectionGroup=this._store.state.selectionGroup}execute(){if(this.skipExecution){this.skipExecution=false;return}this._store.state.selectionGroup=this.selectionGroup;this._store.state.selectionGroup.move(this.startX,this.startY,this.endX,this.endY)}undo(){this._store.state.selectionGroup=this.selectionGroup;this._store.state.selectionGroup.move(this.endX,this.endY,this.startX,this.startY)}}class P{constructor(t){this._store=t}}class T extends P{constructor(t){super(t)}handlePointerDown(t){var i,s;if(t.pointerType==="mouse"){if(r.isLeftClick(t)){if(((i=this._store.state.selectionGroup)===null||i===void 0?void 0:i.isSelected)&&!this._store.state.isResizeHandleSelected&&!this._store.state.isRotationHandleSelected){const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;this._store.state.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._store.state.pointers.values());if(this._store.state.pointers.size===1){if(((s=this._store.state.selectionGroup)===null||s===void 0?void 0:s.isSelected)&&!this._store.state.isResizeHandleSelected&&!this._store.state.isRotationHandleSelected){const i=Math.round(t[0].clientX-this._store.offsetX);const s=Math.round(t[0].clientY-this._store.offsetY);this.dragStartX=i;this.dragStartY=s;this.startX=i;this.startY=s}}}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._store.state.isDragging&&this._store.state.selectionGroup){const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;this.endX=i;this.endY=s;this._store.state.selectionGroup.move(i,s,this.dragStartX,this.dragStartY);this.dragStartX=i;this.dragStartY=s}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());if(this._store.state.pointers.size===1&&this._store.state.selectionGroup&&!this._store.state.isResizeHandleSelected&&!this._store.state.isRotationHandleSelected){const i=Math.round(t[0].clientX-this._store.offsetX);const s=Math.round(t[0].clientY-this._store.offsetY);this._store.state.isDragging=true;this.endX=i;this.endY=s;const e=Math.abs(i-this.startX);const n=Math.abs(s-this.startY);const r=5;if(e>r||n>r){clearTimeout(this._store.state.longTouchTimeout);this._store.state.selectionGroup.move(i,s,this.dragStartX,this.dragStartY);this.dragStartX=i;this.dragStartY=s}}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._store.state.isDragging){this._store.state.isDragging=false;this._store.history.executeCommand(new F(this._store,this,this.endX,this.endY,this.startX,this.startY,true))}}if(t.pointerType==="touch"){if(this._store.state.isDragging){this._store.state.isDragging=false;this._store.history.executeCommand(new F(this._store,this,this.endX,this.endY,this.startX,this.startY,true))}}}}var B;(function(t){t["TopLeft"]="top-left";t["TopRight"]="top-right";t["BottomLeft"]="bottom-left";t["BottomRight"]="bottom-right"})(B||(B={}));class k extends s{constructor(t,i,s,e){super(t,i);this.previousSize=s;this.newSize=e;this.selectionGroup=this._store.state.selectionGroup}execute(){this._store.state.selectionGroup=this.selectionGroup;this._store.state.selectionGroup.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height)}undo(){this._store.state.selectionGroup=this.selectionGroup;this._store.state.selectionGroup.resize(this.previousSize.x,this.previousSize.y,this.previousSize.width,this.previousSize.height)}}class S extends P{constructor(t){super(t);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(r.isLeftClick(t)){if(this._store.state.selectionGroup&&this._store.state.isResizeHandleSelected){const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;this._store.state.isResizing=true;this.initialMouseX=i;this.initialMouseY=s;this.initialSize.width=this._store.state.selectionGroup.width;this.initialSize.height=this._store.state.selectionGroup.height;this.initialSize.x=this._store.state.selectionGroup.translateX;this.initialSize.y=this._store.state.selectionGroup.translateY}}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());const i=t[0];if(!i){return}if(t.length===1){if(this._store.state.selectionGroup&&this._store.state.isResizeHandleSelected){const t=Math.round(i.clientX-this._store.offsetX);const s=Math.round(i.clientY-this._store.offsetY);this._store.state.isResizing=true;this.initialMouseX=t;this.initialMouseY=s;this.initialSize.width=this._store.state.selectionGroup.width;this.initialSize.height=this._store.state.selectionGroup.height;this.initialSize.x=this._store.state.selectionGroup.translateX;this.initialSize.y=this._store.state.selectionGroup.translateY;clearTimeout(this._store.state.longTouchTimeout)}}}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._store.state.isResizing&&this._store.state.selectionGroup){const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;const e=i-this.initialMouseX;const n=s-this.initialMouseY;switch(this._store.state.resizeHandleType){case B.TopLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height-n;this.newSize.x=e/this._store.state.scale+this.initialSize.x;this.newSize.y=n/this._store.state.scale+this.initialSize.y;break;case B.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._store.state.scale+this.initialSize.y;break;case B.BottomLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height+n;this.newSize.x=e/this._store.state.scale+this.initialSize.x;this.newSize.y=this.initialSize.y;break;case B.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._store.state.selectionGroup.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height);this._store.rerender()}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());const i=t[0];if(!i){return}if(this._store.state.isResizing&&this._store.state.selectionGroup){const t=Math.round(i.clientX-this._store.offsetX);const s=Math.round(i.clientY-this._store.offsetY);const e=t-this.initialMouseX;const n=s-this.initialMouseY;switch(this._store.state.resizeHandleType){case B.TopLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height-n;this.newSize.x=e/this._store.state.scale+this.initialSize.x;this.newSize.y=n/this._store.state.scale+this.initialSize.y;break;case B.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._store.state.scale+this.initialSize.y;break;case B.BottomLeft:this.newSize.width=this.initialSize.width-e;this.newSize.height=this.initialSize.height+n;this.newSize.x=e/this._store.state.scale+this.initialSize.x;this.newSize.y=this.initialSize.y;break;case B.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._store.state.selectionGroup.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height);clearTimeout(this._store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._store.state.isResizing){const t=new k(this._store,this,structuredClone(this.initialSize),structuredClone(this.newSize));this._store.history.executeCommand(t);this._store.state.isResizing=false;this._store.rerender()}}if(t.pointerType==="touch"){if(this._store.state.isResizing){const t=new k(this._store,this,structuredClone(this.initialSize),structuredClone(this.newSize));this._store.history.executeCommand(t);this._store.state.isResizing=false;this._store.rerender();clearTimeout(this._store.state.longTouchTimeout)}}}}class I extends s{constructor(t,i,s){super(t,i);this.rotation=s;this.initialRotation=this._store.state.selectionGroup.rotation;this.selectionGroup=this._store.state.selectionGroup}execute(){this._store.state.selectionGroup=this.selectionGroup;this._store.state.selectionGroup.rotate(this.rotation);this._store.state.selectionGroup.objects.forEach((t=>{this._store.state.objectsOctree.update(t)}))}undo(){this._store.state.selectionGroup=this.selectionGroup;this._store.state.selectionGroup.rotate(this.rotation-this.initialRotation);this._store.state.selectionGroup.objects.forEach((t=>{this._store.state.objectsOctree.update(t)}))}}class C extends P{constructor(t){super(t);this.initialRotation=0;this.rotation=0}handlePointerDown(t){if(t.pointerType==="mouse"){if(r.isLeftClick(t)){if(this._store.state.selectionGroup&&this._store.state.isRotationHandleSelected){const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;this._store.state.isRotating=true;const e=this._store.state.selectionGroup.translateX+this._store.state.selectionGroup.width/2/this._store.state.scale;const n=this._store.state.selectionGroup.translateY+this._store.state.selectionGroup.height/2/this._store.state.scale;const r=(i-this._store.state.translateX)/this._store.state.scale;const o=(s-this._store.state.translateY)/this._store.state.scale;this.initialRotation=Math.atan2(n-o,e-r)-this._store.state.selectionGroup.rotation}}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());const i=t[0];if(!i){return}if(t.length===1){if(this._store.state.selectionGroup&&this._store.state.isRotationHandleSelected){const t=Math.round(i.clientX-this._store.offsetX);const s=Math.round(i.clientY-this._store.offsetY);this._store.state.isRotating=true;const e=this._store.state.selectionGroup.translateX+this._store.state.selectionGroup.width/2/this._store.state.scale;const n=this._store.state.selectionGroup.translateY+this._store.state.selectionGroup.height/2/this._store.state.scale;const r=(t-this._store.state.translateX)/this._store.state.scale;const o=(s-this._store.state.translateY)/this._store.state.scale;this.initialRotation=Math.atan2(n-o,e-r)-this._store.state.selectionGroup.rotation;clearTimeout(this._store.state.longTouchTimeout)}}}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._store.state.isRotating&&this._store.state.selectionGroup){const i=t.clientX-this._store.offsetX;const s=t.clientY-this._store.offsetY;const e=this._store.state.selectionGroup.translateX+this._store.state.selectionGroup.width/2/this._store.state.scale;const n=this._store.state.selectionGroup.translateY+this._store.state.selectionGroup.height/2/this._store.state.scale;const r=(i-this._store.state.translateX)/this._store.state.scale;const o=(s-this._store.state.translateY)/this._store.state.scale;const h=Math.atan2(n-o,e-r);this.rotation=h-this.initialRotation;this._store.state.selectionGroup.rotate(this.rotation);this._store.rerender()}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());const i=t[0];if(!i){return}if(this._store.state.isRotating&&this._store.state.selectionGroup){const t=Math.round(i.clientX-this._store.offsetX);const s=Math.round(i.clientY-this._store.offsetY);const e=this._store.state.selectionGroup.translateX+this._store.state.selectionGroup.width/2/this._store.state.scale;const n=this._store.state.selectionGroup.translateY+this._store.state.selectionGroup.height/2/this._store.state.scale;const r=(t-this._store.state.translateX)/this._store.state.scale;const o=(s-this._store.state.translateY)/this._store.state.scale;const h=Math.atan2(n-o,e-r);this.rotation=h-this.initialRotation;this._store.state.selectionGroup.rotate(this.rotation);this._store.rerender();clearTimeout(this._store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._store.state.isRotating){this._store.history.executeCommand(new I(this._store,this,this.rotation));this._store.state.isRotating=false;this.initialRotation=0;this.rotation=0}}if(t.pointerType==="touch"){if(this._store.state.isRotating){this._store.history.executeCommand(new I(this._store,this,this.rotation));this._store.state.isRotating=false;this.initialRotation=0;this.rotation=0;clearTimeout(this._store.state.longTouchTimeout)}}}}class j extends u{constructor(){super(...arguments);this.__class__="KrtizelSelectionBox";this.objects=[]}static create(t){const i=new j;i._store=t;i.id=i.generateId();i.scale=t.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 O extends s{constructor(t,i,s){super(t,i);this.selectionGroup=s}execute(){this._store.state.objectsOctree.remove((t=>t instanceof j));this._store.state.objectsOctree.insert(this.selectionGroup);this._store.state.selectionGroup=this.selectionGroup;this._store.state.selectionBox=null}undo(){this._store.state.objectsOctree.remove((t=>t.id===this.selectionGroup.id));this._store.state.selectionGroup=null;this._store.state.selectionBox=null}}class Q extends P{get isSelectionClick(){return this._store.state.selectionBox&&this._store.state.selectionBox.width===0&&this._store.state.selectionBox.height===0}get isSelectionDrag(){return this._store.state.selectionBox&&(this._store.state.selectionBox.width>0||this._store.state.selectionBox.height>0)}constructor(t){super(t);this.touchStartX=0;this.touchStartY=0;this.touchStartTimeout=null}handlePointerDown(t){if(t.pointerType==="mouse"){if(r.isLeftClick(t)&&!this._store.state.selectionGroup){this.startMouseSelection(t)}}if(t.pointerType==="touch"){this.touchStartTimeout=setTimeout((()=>{if(this._store.state.pointers.size===1&&!this._store.state.isScaling&&!this._store.state.selectionGroup){this.startTouchSelection();this.updateTouchSelection()}}),80)}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._store.state.isSelecting){this.updateMouseSelection(t)}}if(t.pointerType==="touch"){const t=Array.from(this._store.state.pointers.values());const i=Math.round(t[0].clientX-this._store.offsetX);const s=Math.round(t[0].clientY-this._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._store.state.isSelecting){this.updateTouchSelection();clearTimeout(this._store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(r.isLeftClick(t)&&this._store.state.isSelecting){if(this.isSelectionClick){const i=this._store.state.pointerX;const s=this._store.state.pointerY;const e=this._store.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._store.state.isSelecting){if(this.isSelectionClick){const i=this._store.state.pointerX;const s=this._store.state.pointerY;const e=this._store.getObjectsFromPointerEvent(t,".object").find((t=>t.hitTest(i,s)));this.addObjectToSelectionGroup(e);this.removeSelectionBox()}if(this.isSelectionDrag){this.updateTouchSelection();this.addSelectedObjectsToSelectionGroup();this.removeSelectionBox()}this._store.state.skipContextMenu=false}}}removeSelectionBox(){this._store.state.selectionBox=null;this._store.state.isSelecting=false;this._store.state.objectsOctree.remove((t=>t instanceof j));this._store.rerender()}startMouseSelection(t){let i,s;i=t.clientX-this._store.offsetX;s=t.clientY-this._store.offsetY;const e=j.create(this._store);this.startX=(i-this._store.state.translateX)/this._store.state.scale;this.startY=(s-this._store.state.translateY)/this._store.state.scale;e.translateX=this.startX;e.translateY=this.startY;this._store.state.selectionGroup=null;this._store.state.selectionBox=e;this._store.state.isSelecting=true;this._store.state.objectsOctree.remove((t=>t instanceof j||t instanceof K));this._store.state.objectsOctree.insert(e)}startTouchSelection(){const t=Array.from(this._store.state.pointers.values());const i=t[0];if(!i){return}let s,e;s=Math.round(i.clientX-this._store.offsetX);e=Math.round(i.clientY-this._store.offsetY);this.touchStartX=s;this.touchStartY=e;const n=j.create(this._store);this.startX=(s-this._store.state.translateX)/this._store.state.scale;this.startY=(e-this._store.state.translateY)/this._store.state.scale;n.translateX=this.startX;n.translateY=this.startY;this._store.state.selectionGroup=null;this._store.state.selectionBox=n;this._store.state.isSelecting=true;this._store.state.objectsOctree.remove((t=>t instanceof j||t instanceof K));this._store.state.objectsOctree.insert(n)}updateMouseSelection(t){let i,s;i=t.clientX-this._store.offsetX;s=t.clientY-this._store.offsetY;const e=this._store.state.selectionBox;if(e){const t=(i-this._store.state.translateX)/e.scale;const n=(s-this._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();this._store.rerender()}}updateTouchSelection(){const t=Array.from(this._store.state.pointers.values());const i=t[0];if(!i){return}let s,e;s=Math.round(i.clientX-this._store.offsetX);e=Math.round(i.clientY-this._store.offsetY);const n=this._store.state.selectionBox;if(n){const t=(s-this._store.state.translateX)/n.scale;const i=(e-this._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._store.allObjects.filter((t=>!(t instanceof j))).forEach((t=>t.isSelected=t.hitTestPolygon(this._store.state.selectionBox.rotatedPolygon)))}addObjectToSelectionGroup(t){if(!t){return}this._store.state.selectionGroup=K.create(this._store);this._store.state.selectionGroup.addOrRemove(t);this._store.state.selectionGroup.isSelected=true;this._store.state.selectionGroup.rotation=t.rotation;this._store.history.executeCommand(new O(this._store,this,this._store.state.selectionGroup))}addSelectedObjectsToSelectionGroup(){const t=this._store.selectedObjects;if(t.length===0){return}this._store.state.selectionGroup=K.create(this._store);t.forEach((t=>{t.isSelected=false;this._store.state.selectionGroup.addOrRemove(t)}));this._store.state.selectionGroup.isSelected=true;if(this._store.state.selectionGroup.length===1){this._store.state.selectionGroup.rotation=this._store.state.selectionGroup.objects[0].rotation}this._store.history.executeCommand(new O(this._store,this,this._store.state.selectionGroup))}}class z extends P{constructor(t){super(t)}handlePointerMove(t){if(t.pointerType==="mouse"){const i=this._store.getObjectFromPointerEvent(t,".object");if(!i)return;const s=this._store.state.pointerX;const e=this._store.state.pointerY;i.isHovered=i.hitTest(s,e);if(i.isHovered){console.log(i.id)}}}}class R extends i{constructor(t){super(t);this.selectionHandler=new Q(this._store);this.moveHandler=new T(this._store);this.hoverHandler=new z(this._store);this.resizeHandler=new S(this._store);this.rotationHandler=new C(this._store)}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(r.isLeftClick(t)){this._store.state.isResizeHandleSelected=this.isHandleSelected(t);this._store.state.isRotationHandleSelected=this.isRotationHandleSelected(t);this._store.state.resizeHandleType=this.getHandleType(t);const i=this.getSelectedObject(t);const s=i&&this._store.state.selectionGroup&&i.id!==this._store.state.selectionGroup.id;if((i===null||s)&&this._store.state.selectionGroup&&!this._store.state.isResizeHandleSelected&&!this._store.state.isRotationHandleSelected){this._store.history.executeCommand(new E(this._store,this._store.state.selectionGroup))}if(i&&i.isSelected===false&&(i===null||i===void 0?void 0: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._store.rerender()}if(t.pointerType==="touch"){if(this._store.state.isScaling===true){return}if(this._store.state.pointers.size===1){this._store.state.isResizeHandleSelected=this.isHandleSelected(t);this._store.state.isRotationHandleSelected=this.isRotationHandleSelected(t);this._store.state.resizeHandleType=this.getHandleType(t);const i=this.getSelectedObject(t);const s=i&&this._store.state.selectionGroup&&i.id!==this._store.state.selectionGroup.id;if(!this._store.state.selectionGroup&&i){this._store.state.skipContextMenu=true}if((i===null||s)&&this._store.state.selectionGroup&&!this._store.state.isResizeHandleSelected&&!this._store.state.isRotationHandleSelected){this._store.history.executeCommand(new E(this._store,this._store.state.selectionGroup))}}this.rotationHandler.handlePointerDown(t);this.resizeHandler.handlePointerDown(t);this.moveHandler.handlePointerDown(t);this.selectionHandler.handlePointerDown(t)}}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._store.rerender()}if(t.pointerType==="touch"){if(this._store.state.isScaling===true){return}this.rotationHandler.handlePointerMove(t);this.resizeHandler.handlePointerMove(t);this.moveHandler.handlePointerMove(t);this.selectionHandler.handlePointerMove(t);this._store.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._store.rerender()}if(t.pointerType==="touch"){if(this._store.state.isScaling===true){return}this.rotationHandler.handlePointerUp(t);this.resizeHandler.handlePointerUp(t);this.moveHandler.handlePointerUp(t);this.selectionHandler.handlePointerUp(t)}}getSelectedObject(t){const i=t.composedPath().slice(1);const s=i.find((t=>t.classList&&t.classList.contains("object")));const e=this._store.findObjectById(s===null||s===void 0?void 0:s.id);if(!e){return null}if(e instanceof K){return e}else{const t=K.create(this._store);t.translateX=0;t.translateY=0;t.addOrRemove(e);return t}}getHandleType(t){var i;const s=(i=this._store.state.host)===null||i===void 0?void 0:i.shadowRoot;if(!s)return;const e=s.elementFromPoint(t.clientX,t.clientY);const n=e===null||e===void 0?void 0:e.closest(".resize-handle-overlay");return n===null||n===void 0?void 0:n.classList[1]}isHandleSelected(t){var i;const s=(i=this._store.state.host)===null||i===void 0?void 0:i.shadowRoot;if(!s)return false;const e=s.elementFromPoint(t.clientX,t.clientY);return!!(e===null||e===void 0?void 0:e.classList.contains("resize-handle-overlay"))}isRotationHandleSelected(t){const i=t.composedPath();return!!i.find((t=>t.classList&&t.classList.contains("rotation-handle-overlay")))}}class D{constructor(t){this._store=t}revive(t){if(t&&typeof t==="object"){if(t.__class__){let i;switch(t.__class__){case"KritzelPath":i=m.create(this._store).revive(t);break;case"KritzelText":i=l.create(this._store,t.fontSize,t.fontFamily).revive(t);break;case"KritzelImage":i=g.create(this._store).revive(t);break;case"KritzelCustomElement":i=b.create(this._store).revive(t);break;case"KritzelSelectionGroup":i=K.create(this._store).revive(t);break;case"KritzelBrushTool":i=new y(this._store);break;case"KritzelEraserTool":i=new x(this._store);break;case"KritzelImageTool":i=new bt(this._store);break;case"KritzelSelectionTool":i=new R(this._store);break;case"KritzelTextTool":i=new h(this._store);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{constructor(){super(...arguments);this.__class__="KritzelSelectionGroup";this.objects=[];this.unchangedObjects=[]}get length(){return this.objects.length}static create(t){const i=new K;i._store=t;i.id=i.generateId();i.scale=t.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=f.clone(this.objects);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.translateX=t+e;s.translateY=i+n;this._store.state.objectsOctree.update(s)}));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._store.state.objectsOctree.update(this)}move(t,i,s,e){const n=(t-s)/this._store.state.scale;const r=(i-e)/this._store.state.scale;this.translateX+=n;this.translateY+=r;this._store.state.objectsOctree.update(this);this.objects.forEach((o=>{o.translateX+=n;o.translateY+=r;o.move(t,i,s,e);this._store.state.objectsOctree.update(o)}));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._store.state.objectsOctree.update(t)}));this.refreshObjectDimensions();this.unchangedObjects=f.clone(this.objects)}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 f=n*h-r*c;const a=r*h+n*c;e.translateX=i+f-e.totalWidth/2/e.scale;e.translateY=s+a-e.totalHeight/2/e.scale;e.rotate(this.objects.length===1?t:t+o.rotation);this._store.state.objectsOctree.update(e)}))}copy(){const t=K.create(this._store);let i=this._store.currentZIndex;this.objects.forEach((s=>{const e=s.copy();e.zIndex=i;t.addOrRemove(e);i++}));t.unchangedObjects=f.clone(t.objects);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._store.state.objectsOctree.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 D(this._store);return s.revive(i)}}function L(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 $(t,i){return new Promise((function(s,e){let n;return H(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 H=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),f=r+c+2+12*e.getUint16(r+c,h);for(let t=r+c+2;t<f;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 W={},_={get exports(){return W},set exports(t){W=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 f=s(h,r+=4);s(h,r+=2);var a=n(h,r+=2),u=n(h,r+=4);r+=4,r=u;for(var l=0;l<f;l++){n(h,r),r+=4,r+=4,r+=4,n(h,r+=4);a=n(h,r+=4);var d=n(h,r+=4),v=s(h,r+=4),A=s(h,r+2),w=s(h,r+4);r+=6;var p=n(h,r+=8);r+=4,r+=v+A+w,e._readLocal(h,p,o,a,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 f=h(t,i+=2);c(t,i+=2),c(t,i+=4),i+=4;var a=h(t,i+=8),u=h(t,i+=2);i+=2;var l=e.bin.readUTF8(t,i,a);if(i+=a,i+=u,o)s[l]={size:r,csize:n};else{var d=new Uint8Array(t.buffer,i);if(0==f)s[l]=new Uint8Array(d.buffer.slice(i,i+n));else{if(8!=f)throw"unknown compression method: "+f;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,f=t[h],a=e.crc.crc(f,0,f.length);o[h]={cpr:c,usize:f.length,crc:a,file:c?e.deflateRaw(f):f}}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 A=0,w=l;for(var h in o){v=o[h];d.push(l),l=e._writeHeader(u,l,h,v,1,d[A++])}var p=l-w;return n(u,l,101010256),l+=4,r(u,l+=4,A),r(u,l+=2,A),n(u,l+=2,p),n(u,l+=4,w),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,f=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,f.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(f,i),i+=f.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,f=0,a=s<<3,u=0,l=t.length;if(0==n){for(;f<l;){c(i,a,f+(x=Math.min(65535,l-f))==l?1:0),a=e.F._copyExact(t,f,x,i,a+8),f+=x}return a>>>3}var d=o.lits,v=o.strt,A=o.prev,w=0,p=0,m=0,g=0,y=0,M=0;for(l>2&&(v[M=e.F._hash(t,0)]=0),f=0;f<l;f++){if(y=M,f+1<l-2){M=e.F._hash(t,f+1);var b=f+1&32767;A[b]=v[M],v[M]=b}if(u<=f){(w>14e3||p>26697)&&l-f>100&&(u<f&&(d[w]=f-u,w+=2,u=f),a=e.F._writeBlock(f==l-1||u==l?1:0,d,w,g,t,m,f-m,i,a),w=p=g=0,m=f);var U=0;f<l-2&&(U=e.F._bestMatch(t,f,A,y,Math.min(r[2],l-f),r[3]));var x=U>>>16,E=65535&U;if(0!=U){E=65535&U;var F=h(x=U>>>16,o.of0);o.lhst[257+F]++;var P=h(E,o.df0);o.dhst[P]++,g+=o.exb[F]+o.dxb[P],d[w]=x<<23|f-u,d[w+1]=E<<16|F<<8|P,w+=2,u=f+x}else o.lhst[t[f]]++;p++}}for(m==f&&0!=t.length||(u<f&&(d[w]=f-u,w+=2,u=f),a=e.F._writeBlock(1,d,w,g,t,m,f-m,i,a),w=0,p=0,w=p=g=0,m=f);0!=(7&a);)a++;return a>>>3},e.F._bestMatch=function(t,i,s,n,r,o){var h=32767&i,c=s[h],f=h-c+32768&32767;if(c==h||n!=e.F._hash(t,i-f))return 0;for(var a=0,u=0,l=Math.min(32767,i);f<=l&&0!=--o&&c!=h;){if(0==a||t[i+a]==t[i+a-f]){var d=e.F._howLong(t,i,f);if(d>a){if(u=f,(a=d)>=r)break;f+2<d&&(d=f+2);for(var v=0,A=0;A<d-2;A++){var w=i-f+A+32768&32767,p=w-s[w]+32768&32767;p>v&&(v=p,c=w)}}}f+=(h=c)-(c=s[h])+32768&32767}return a<<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,f){var a,u,l,d,v,A,w,p,m,g=e.F.U,y=e.F._putsF,M=e.F._putsE;g.lhst[256]++,u=(a=e.F.getTrees())[0],l=a[1],d=a[2],v=a[3],A=a[4],w=a[5],p=a[6],m=a[7];var b=32+(0==(f+3&7)?0:8-(f+3&7))+(h<<3),U=n+e.F.contSize(g.fltree,g.lhst)+e.F.contSize(g.fdtree,g.dhst),x=n+e.F.contSize(g.ltree,g.lhst)+e.F.contSize(g.dtree,g.dhst);x+=14+3*w+e.F.contSize(g.itree,g.ihst)+(2*g.ihst[16]+3*g.ihst[17]+7*g.ihst[18]);for(var E=0;E<286;E++)g.lhst[E]=0;for(E=0;E<30;E++)g.dhst[E]=0;for(E=0;E<19;E++)g.ihst[E]=0;var F=b<U&&b<x?0:U<x?1:2;if(y(c,f,t),y(c,f+1,F),f+=3,0==F){for(;0!=(7&f);)f++;f=e.F._copyExact(r,o,h,c,f)}else{var P,T;if(1==F&&(P=g.fltree,T=g.fdtree),2==F){e.F.makeCodes(g.ltree,u),e.F.revCodes(g.ltree,u),e.F.makeCodes(g.dtree,l),e.F.revCodes(g.dtree,l),e.F.makeCodes(g.itree,d),e.F.revCodes(g.itree,d),P=g.ltree,T=g.dtree,M(c,f,v-257),M(c,f+=5,A-1),M(c,f+=5,w-4),f+=4;for(var B=0;B<w;B++)M(c,f+3*B,g.itree[1+(g.ordr[B]<<1)]);f+=3*w,f=e.F._codeTiny(p,g.itree,c,f),f=e.F._codeTiny(m,g.itree,c,f)}for(var k=o,S=0;S<s;S+=2){for(var I=i[S],C=I>>>23,j=k+(8388607&I);k<j;)f=e.F._writeLit(r[k++],P,c,f);if(0!=C){var O=i[S+1],Q=O>>16,z=O>>8&255,R=255&O;M(c,f=e.F._writeLit(257+z,P,c,f),C-g.of0[z]),f+=g.exb[z],y(c,f=e.F._writeLit(R,T,c,f),Q-g.df0[R]),f+=g.dxb[R],k+=C}}f=e.F._writeLit(256,P,c,f)}return f},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 f=e.F._hufTree(t.ihst,t.itree,7),a=19;a>4&&0==t.itree[1+(t.ordr[a-1]<<1)];)a--;return[i,s,f,r,h,a,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;(f=Math.min(c+1-e>>>1,138))<11?i.push(17,f-3):i.push(18,f-11),e+=2*f-2}else if(n==h&&r==n&&o==n){for(c=e+5;c+2<s&&t[c+2]==n;)c+=2;var f=Math.min(c+1-e>>>1,6);i.push(16,f-3),e+=2*f-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,f=n.slice(0);if(0==c)return 0;if(1==c){var a=n[0].lit;f=0==a?1:0;return i[1+(a<<1)]=1,i[1+(f<<1)]=1,1}n.sort((function(t,i){return t.f-i.f}));var u=n[0],l=n[1],d=0,v=1,A=2;for(n[0]={lit:-1,f:u.f+l.f,l:u,r:l,d:0};v!=c-1;)u=d!=v&&(A==c||n[d].f<n[A].f)?n[d++]:n[A++],l=d!=v&&(A==c||n[d].f<n[A].f)?n[d++]:n[A++],n[v++]={lit:-1,f:u.f+l.f,l:u,r:l};var w=e.F.setDepth(n[v-1],0);for(w>s&&(e.F.restrictDepth(f,s,w),w=s),h=0;h<c;h++)i[1+(f[h].lit<<1)]=f[h].d;return w},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,f=n.codes2map,a=n._get17,u=n.U,l=null==i;l&&(i=new s(t.length>>>2<<3));for(var d,v,A=0,w=0,p=0,m=0,g=0,y=0,M=0,b=0,U=0;0==A;)if(A=r(t,U,1),w=r(t,U+1,2),U+=3,0!=w){if(l&&(i=e.F._check(i,b+(1<<17))),1==w&&(d=u.flmap,v=u.fdmap,y=511,M=31),2==w){p=o(t,U,5)+257,m=o(t,U+5,5)+1,g=o(t,U+10,4)+4,U+=14;for(var x=0;x<38;x+=2)u.itree[x]=0,u.itree[x+1]=0;var E=1;for(x=0;x<g;x++){var F=o(t,U+3*x,3);u.itree[1+(u.ordr[x]<<1)]=F,F>E&&(E=F)}U+=3*g,c(u.itree,E),f(u.itree,E,u.imap),d=u.lmap,v=u.dmap,U=h(u.imap,(1<<E)-1,p+m,t,U,u.ttree);var P=n._copyOut(u.ttree,0,p,u.ltree);y=(1<<P)-1;var T=n._copyOut(u.ttree,p,m,u.dtree);M=(1<<T)-1,c(u.ltree,P),f(u.ltree,P,d),c(u.dtree,T),f(u.dtree,T,v)}for(;;){var B=d[a(t,U)&y];U+=15&B;var k=B>>>4;if(k>>>8==0)i[b++]=k;else{if(256==k)break;var S=b+k-254;if(k>264){var I=u.ldef[k-257];S=b+(I>>>3)+o(t,U,7&I),U+=7&I}var C=v[a(t,U)&M];U+=15&C;var j=C>>>4,O=u.ddef[j],Q=(O>>>4)+r(t,U,15&O);for(U+=15&O,l&&(i=e.F._check(i,b+(1<<17)));b<S;)i[b]=i[b++-Q],i[b]=i[b++-Q],i[b]=i[b++-Q],i[b]=i[b++-Q];b=S}}}else{0!=(7&U)&&(U+=8-(7&U));var z=4+(U>>>3),R=t[z-4]|t[z-3]<<8;l&&(i=e.F._check(i,b+R)),i.set(new s(t.buffer,t.byteOffset+z,R),b),U=z+R<<3,b+=R}return i.length==b?i:i.slice(0,b)},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,f=0;f<s;){var a=t[c(n,r)&i];r+=15&a;var u=a>>>4;if(u<=15)o[f]=u,f++;else{var l=0,d=0;16==u?(d=3+h(n,r,2),r+=2,l=o[f-1]):17==u?(d=3+h(n,r,3),r+=3):18==u&&(d=11+h(n,r,7),r+=7);for(var v=f+d;f<v;)o[f]=l,f++}}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,f=h.bl_count,a=0;a<=i;a++)f[a]=0;for(a=1;a<c;a+=2)f[t[a]]++;var u=h.next_code;for(s=0,f[0]=0,n=1;n<=i;n++)s=s+f[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],f=h<<4|c,a=i-c,u=t[o]<<a,l=u+(1<<a);u!=l;){s[r[u]>>>15-i]=f,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 X=L({__proto__:null,default:W},[W]);const G=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),f=new Uint8Array(4*o),a=new Uint32Array(f.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)f[v]=i[v],f[v+1]=i[v+1],f[v+2]=i[v+2],f[v+3]=i[v+3];if(16==l)for(v=0;v<t;v++)f[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 A=3*v;a[v]=255<<24|i[A+2]<<16|i[A+1]<<8|i[A]}if(16==l)for(v=0;v<o;v++){A=6*v;a[v]=255<<24|i[A+4]<<16|i[A+2]<<8|i[A]}}else{var w=t[0];const s=t[1],e=t[2];if(8==l)for(v=0;v<o;v++){var p=v<<2;A=3*v;a[v]=255<<24|i[A+2]<<16|i[A+1]<<8|i[A],i[A]==w&&i[A+1]==s&&i[A+2]==e&&(f[p+3]=0)}if(16==l)for(v=0;v<o;v++){p=v<<2,A=6*v;a[v]=255<<24|i[A+4]<<16|i[A+2]<<8|i[A],d(i,A)==w&&d(i,A+2)==s&&d(i,A+4)==e&&(f[p+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 m=0;m<e;m++){var g=m*c,y=m*s;for(v=0;v<s;v++){p=y+v<<2;var M=3*(b=i[g+(v>>3)]>>7-((7&v)<<0)&1);f[p]=t[M],f[p+1]=t[M+1],f[p+2]=t[M+2],f[p+3]=b<h?r[b]:255}}if(2==l)for(m=0;m<e;m++)for(g=m*c,y=m*s,v=0;v<s;v++){p=y+v<<2,M=3*(b=i[g+(v>>2)]>>6-((3&v)<<1)&3);f[p]=t[M],f[p+1]=t[M+1],f[p+2]=t[M+2],f[p+3]=b<h?r[b]:255}if(4==l)for(m=0;m<e;m++)for(g=m*c,y=m*s,v=0;v<s;v++){p=y+v<<2,M=3*(b=i[g+(v>>1)]>>4-((1&v)<<2)&15);f[p]=t[M],f[p+1]=t[M+1],f[p+2]=t[M+2],f[p+3]=b<h?r[b]:255}if(8==l)for(v=0;v<o;v++){var b;p=v<<2,M=3*(b=i[v]);f[p]=t[M],f[p+1]=t[M+1],f[p+2]=t[M+2],f[p+3]=b<h?r[b]:255}}else if(4==u){if(8==l)for(v=0;v<o;v++){p=v<<2;var U=i[x=v<<1];f[p]=U,f[p+1]=U,f[p+2]=U,f[p+3]=i[x+1]}if(16==l)for(v=0;v<o;v++){var x;p=v<<2,U=i[x=v<<2];f[p]=U,f[p+1]=U,f[p+2]=U,f[p+3]=i[x+2]}}else if(0==u)for(w=n.tabs.tRNS?n.tabs.tRNS:-1,m=0;m<e;m++){const t=m*c,e=m*s;if(1==l)for(var E=0;E<s;E++){var F=(U=255*(i[t+(E>>>3)]>>>7-(7&E)&1))==255*w?0:255;a[e+E]=F<<24|U<<16|U<<8|U}else if(2==l)for(E=0;E<s;E++){F=(U=85*(i[t+(E>>>2)]>>>6-((3&E)<<1)&3))==85*w?0:255;a[e+E]=F<<24|U<<16|U<<8|U}else if(4==l)for(E=0;E<s;E++){F=(U=17*(i[t+(E>>>1)]>>>4-((1&E)<<2)&15))==17*w?0:255;a[e+E]=F<<24|U<<16|U<<8|U}else if(8==l)for(E=0;E<s;E++){F=(U=i[t+E])==w?0:255;a[e+E]=F<<24|U<<16|U<<8|U}else if(16==l)for(E=0;E<s;E++){U=i[t+(E<<1)],F=d(i,t+(E<<1))==w?0:255;a[e+E]=F<<24|U<<16|U<<8|U}}return f}function s(t,i,s,h){const c=r(t),f=Math.ceil(s*c/8),a=new Uint8Array((f+1+t.interlace)*h);return i=t.tabs.CgBI?n(i,a):e(i,a),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,f=Math.ceil(e*h/8),a=new Uint8Array(n*f);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],A=[8,8,4,4,2,2,1];let w=0;for(;w<7;){const t=v[w],r=A[w];let m=0,g=0,y=l[w];for(;y<n;)y+=t,g++;let M=d[w];for(;M<e;)M+=r,m++;const b=Math.ceil(m*h/8);o(i,s,u,m,g);let U=0,x=l[w];for(;x<n;){let s=d[w],n=u+U*b<<3;for(;s<e;){var p;if(1==h)p=(p=i[n>>3])>>7-(7&n)&1,a[x*f+(s>>3)]|=p<<7-((7&s)<<0);if(2==h)p=(p=i[n>>3])>>6-(7&n)&3,a[x*f+(s>>2)]|=p<<6-((3&s)<<1);if(4==h)p=(p=i[n>>3])>>4-(7&n)&15,a[x*f+(s>>1)]|=p<<4-((1&s)<<2);if(h>=8){const t=x*f+s*c;for(let s=0;s<c;s++)a[t+s]=i[(n>>3)+s]}n+=h,s+=r}U++,x+=t}m*g!=0&&(u+=g*(1+b)),w+=1}return a}(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,f=0,a=0,u=0,l=0,d=0,v=0;if(3==i[0]&&0==i[1])return s||new e(0);const A=t.H,w=A.b,p=A.e,m=A.R,g=A.n,y=A.A,M=A.Z,b=A.m,U=null==s;for(U&&(s=new e(i.length>>>2<<5));0==o;)if(o=w(i,v,1),h=w(i,v+1,2),v+=3,0!=h){if(U&&(s=t.H.W(s,d+(1<<17))),1==h&&(n=b.J,r=b.h,u=511,l=31),2==h){c=p(i,v,5)+257,f=p(i,v+5,5)+1,a=p(i,v+10,4)+4,v+=14;let t=1;for(var x=0;x<38;x+=2)b.Q[x]=0,b.Q[x+1]=0;for(x=0;x<a;x++){const s=p(i,v+3*x,3);b.Q[1+(b.X[x]<<1)]=s,s>t&&(t=s)}v+=3*a,g(b.Q,t),y(b.Q,t,b.u),n=b.w,r=b.d,v=m(b.u,(1<<t)-1,c+f,i,v,b.v);const s=A.V(b.v,0,c,b.C);u=(1<<s)-1;const e=A.V(b.v,c,f,b.D);l=(1<<e)-1,g(b.C,s),y(b.C,s,n),g(b.D,e),y(b.D,e,r)}for(;;){const t=n[M(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=b.q[e-257];t=d+(s>>>3)+p(i,v,7&s),v+=7&s}const n=r[M(i,v)&l];v+=15&n;const o=n>>>4,h=b.c[o],c=(h>>>4)+w(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;U&&(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 f=0;for(;f<e;){const t=i[c(n,r)&s];r+=15&t;const e=t>>>4;if(e<=15)o[f]=e,f++;else{let t=0,i=0;16==e?(i=3+h(n,r,2),r+=2,t=o[f-1]):17==e?(i=3+h(n,r,3),r+=3):18==e&&(i=11+h(n,r,7),r+=7);const s=f+i;for(;f<s;)o[f]=t,f++}}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 f=e.j;for(var a=0;a<=s;a++)f[a]=0;for(a=1;a<n;a+=2)f[i[a]]++;const u=e.K;for(r=0,f[0]=0,o=1;o<=s;o++)r=r+f[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 f=i[t]<<c;const a=f+(1<<c);for(;f!=a;){e[r[f]>>>15-s]=h,f++}}},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 f,a;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(f=s+i*c,a=f+i+1,u=t[a-1],l=0,0==u)for(;l<c;l++)t[f+l]=t[a+l];else if(1==u){for(;l<o;l++)t[f+l]=t[a+l];for(;l<c;l++)t[f+l]=t[a+l]+t[f+l-o]}else if(2==u)for(;l<c;l++)t[f+l]=t[a+l]+t[f+l-c];else if(3==u){for(;l<o;l++)t[f+l]=t[a+l]+(t[f+l-c]>>>1);for(;l<c;l++)t[f+l]=t[a+l]+(t[f+l-c]+t[f+l-o]>>>1)}else{for(;l<o;l++)t[f+l]=t[a+l]+h(0,t[f+l-c],0);for(;l<c;l++)t[f+l]=t[a+l]+h(t[f+l-o],t[f+l-c],t[f+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 f(t,i,s,e,n,r,o,h,c){const f=Math.min(i,n),a=Math.min(s,r);let u=0,l=0;for(let s=0;s<a;s++)for(let r=0;r<f;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,A=t[u+1]*d,w=t[u+2]*d,p=e[l+3]*(1/255),m=e[l]*p,g=e[l+1]*p,y=e[l+2]*p;const i=1-d,s=d+p*i,n=0==s?0:1/s;e[l+3]=255*s,e[l+0]=(v+m*i)*n,e[l+1]=(A+g*i)*n,e[l+2]=(w+y*i)*n}else if(2==c){d=t[u+3],v=t[u],A=t[u+1],w=t[u+2],p=e[l+3],m=e[l],g=e[l+1],y=e[l+2];d==p&&v==m&&A==g&&w==y?(e[l]=0,e[l+1]=0,e[l+2]=0,e[l+3]=0):(e[l]=v,e[l+1]=A,e[l+2]=w,e[l+3]=d)}else if(3==c){d=t[u+3],v=t[u],A=t[u+1],w=t[u+2],p=e[l+3],m=e[l],g=e[l+1],y=e[l+2];if(d==p&&v==m&&A==g&&w==y)continue;if(d<220&&p>20)return false}return true}return{decode:function i(r){const o=new Uint8Array(r);let h=8;const f=t,a=f.readUshort,u=f.readUint,l={tabs:{},frames:[]},d=new Uint8Array(o.length);let v,A=0,w=0;const p=[137,80,78,71,13,10,26,10];for(var m=0;m<8;m++)if(o[m]!=p[m])throw"The input is not a PNG file!";for(;h<o.length;){const t=f.readUint(o,h);h+=4;const i=f.readASCII(o,h,4);if(h+=4,"IHDR"==i)c(o,h,l);else if("iCCP"==i){for(var g=h;0!=o[g];)g++;f.readASCII(o,h,g-h);const s=o.slice(g+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(m=0;m<t;m++)d[A+m]=o[h+m];A+=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!=w)(E=l.frames[l.frames.length-1]).data=s(l,v.slice(0,w),E.rect.width,E.rect.height),w=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=a(o,h+22);i=a(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(m=0;m<t-4;m++)v[w+m]=o[h+m+4];w+=t-4}else if("pHYs"==i)l.tabs[i]=[f.readUint(o,h),f.readUint(o,h+4),o[h+8]];else if("cHRM"==i){l.tabs[i]=[];for(m=0;m<8;m++)l.tabs[i].push(f.readUint(o,h+4*m))}else if("tEXt"==i||"zTXt"==i){null==l.tabs[i]&&(l.tabs[i]={});var y=f.nextZero(o,h),M=f.readASCII(o,h,y-h),b=h+t-y-1;if("tEXt"==i)x=f.readASCII(o,y+1,b);else{var U=e(o.slice(y+2,y+2+b));x=f.readUTF8(U,0,U.length)}l.tabs[i][M]=x}else if("iTXt"==i){null==l.tabs[i]&&(l.tabs[i]={});y=0,g=h;y=f.nextZero(o,g);M=f.readASCII(o,g,y-g);const s=o[g=y+1];var x;g+=2,y=f.nextZero(o,g),f.readASCII(o,g,y-g),g=y+1,y=f.nextZero(o,g),f.readUTF8(o,g,y-g);b=t-((g=y+1)-h);if(0==s)x=f.readUTF8(o,g,b);else{U=e(o.slice(g,g+b));x=f.readUTF8(U,0,U.length)}l.tabs[i][M]=x}else if("PLTE"==i)l.tabs[i]=f.readBytes(o,h,t);else if("hIST"==i){const t=l.tabs.PLTE.length/3;l.tabs[i]=[];for(m=0;m<t;m++)l.tabs[i].push(a(o,h+2*m))}else if("tRNS"==i)3==l.ctype?l.tabs[i]=f.readBytes(o,h,t):0==l.ctype?l.tabs[i]=a(o,h):2==l.ctype&&(l.tabs[i]=[a(o,h),a(o,h+2),a(o,h+4)]);else if("gAMA"==i)l.tabs[i]=f.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]=[a(o,h)]:2==l.ctype||6==l.ctype?l.tabs[i]=[a(o,h),a(o,h+2),a(o,h+4)]:3==l.ctype&&(l.tabs[i]=o[h]);else if("IEND"==i)break;h+=t,f.readUint(o,h),h+=4}var E;return 0!=w&&((E=l.frames[l.frames.length-1]).data=s(l,v.slice(0,w),E.rect.width,E.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),a=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,A=l.rect.width,w=l.rect.height,p=i(l.data,A,w,s);if(0!=t)for(var u=0;u<o;u++)a[u]=h[u];if(0==l.blend?f(p,A,w,h,e,n,d,v,0):1==l.blend&&f(p,A,w,h,e,n,d,v,1),r.push(h.buffer.slice(0)),0==l.dispose);else if(1==l.dispose)f(c,A,w,h,e,n,d,v,0);else if(2==l.dispose)for(u=0;u<o;u++)h[u]=a[u]}return r},_paeth:h,_copyTile:f,_bin:t}}();!function(){const{_copyTile:t}=G,{_bin:i}=G,s=G._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,f){null==f&&(f=1);const a=e.length,u=[];for(var l=0;l<a;l++){const t=e[l];u.push([t>>>0&255,t>>>8&255,t>>>16&255,t>>>24&255])}for(l=0;l<a;l++){let t=4294967295;for(var d=0,v=0;v<a;v++){var A=o(u[l],u[v]);v!=l&&A<t&&(t=A,d=v)}}const w=new Uint32Array(h.buffer),p=new Int16Array(i*s*4),m=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(l=0;l<m.length;l++)m[l]=255*((m[l]+.5)/16-.5);for(let h=0;h<s;h++)for(let y=0;y<i;y++){var g;l=4*(h*i+y);if(2!=f)g=[r(t[l]+p[l]),r(t[l+1]+p[l+1]),r(t[l+2]+p[l+2]),r(t[l+3]+p[l+3])];else{A=m[4*(3&h)+(3&y)];g=[r(t[l]+A),r(t[l+1]+A),r(t[l+2]+A),r(t[l+3]+A)]}d=0;let M=16777215;for(v=0;v<a;v++){const t=o(g,u[v]);t<M&&(M=t,d=v)}const b=u[d],U=[g[0]-b[0],g[1]-b[1],g[2]-b[2],g[3]-b[3]];1==f&&(y!=i-1&&n(U,p,l+4,7),h!=s-1&&(0!=y&&n(U,p,l+4*i-4,3),n(U,p,l+4*i,5),y!=i-1&&n(U,p,l+4*i+4,1))),c[l>>2]=d,w[l>>2]=e[d]}}function c(t,s,n,r,o){null==o&&(o={});const{crc:h}=e,c=i.writeUint,f=i.writeUshort,a=i.writeASCII;let u=8;const l=t.frames.length>1;let d,v=false,A=33+(l?20:0);if(null!=o.sRGB&&(A+=13),null!=o.pHYs&&(A+=21),null!=o.iCCP&&(d=pako.deflate(o.iCCP),A+=21+d.length+4),3==t.ctype){for(var w=t.plte.length,p=0;p<w;p++)t.plte[p]>>>24!=255&&(v=true);A+=8+3*w+4+(v?8+1*w+4:0)}for(var m=0;m<t.frames.length;m++){l&&(A+=38),A+=(b=t.frames[m]).cimg.length+12,0!=m&&(A+=4)}A+=12;const g=new Uint8Array(A),y=[137,80,78,71,13,10,26,10];for(p=0;p<8;p++)g[p]=y[p];if(c(g,u,13),u+=4,a(g,u,"IHDR"),u+=4,c(g,u,s),u+=4,c(g,u,n),u+=4,g[u]=t.depth,u++,g[u]=t.ctype,u++,g[u]=0,u++,g[u]=0,u++,g[u]=0,u++,c(g,u,h(g,u-17,17)),u+=4,null!=o.sRGB&&(c(g,u,1),u+=4,a(g,u,"sRGB"),u+=4,g[u]=o.sRGB,u++,c(g,u,h(g,u-5,5)),u+=4),null!=o.iCCP){const t=13+d.length;c(g,u,t),u+=4,a(g,u,"iCCP"),u+=4,a(g,u,"ICC profile"),u+=11,u+=2,g.set(d,u),u+=d.length,c(g,u,h(g,u-(t+4),t+4)),u+=4}if(null!=o.pHYs&&(c(g,u,9),u+=4,a(g,u,"pHYs"),u+=4,c(g,u,o.pHYs[0]),u+=4,c(g,u,o.pHYs[1]),u+=4,g[u]=o.pHYs[2],u++,c(g,u,h(g,u-13,13)),u+=4),l&&(c(g,u,8),u+=4,a(g,u,"acTL"),u+=4,c(g,u,t.frames.length),u+=4,c(g,u,null!=o.loop?o.loop:0),u+=4,c(g,u,h(g,u-12,12)),u+=4),3==t.ctype){c(g,u,3*(w=t.plte.length)),u+=4,a(g,u,"PLTE"),u+=4;for(p=0;p<w;p++){const i=3*p,s=t.plte[p],e=255&s,n=s>>>8&255,r=s>>>16&255;g[u+i+0]=e,g[u+i+1]=n,g[u+i+2]=r}if(u+=3*w,c(g,u,h(g,u-3*w-4,3*w+4)),u+=4,v){c(g,u,w),u+=4,a(g,u,"tRNS"),u+=4;for(p=0;p<w;p++)g[u+p]=t.plte[p]>>>24&255;u+=w,c(g,u,h(g,u-w-4,w+4)),u+=4}}let M=0;for(m=0;m<t.frames.length;m++){var b=t.frames[m];l&&(c(g,u,26),u+=4,a(g,u,"fcTL"),u+=4,c(g,u,M++),u+=4,c(g,u,b.rect.width),u+=4,c(g,u,b.rect.height),u+=4,c(g,u,b.rect.x),u+=4,c(g,u,b.rect.y),u+=4,f(g,u,r[m]),u+=2,f(g,u,1e3),u+=2,g[u]=b.dispose,u++,g[u]=b.blend,u++,c(g,u,h(g,u-30,30)),u+=4);const i=b.cimg;c(g,u,(w=i.length)+(0==m?0:4)),u+=4;const s=u;a(g,u,0==m?"IDAT":"fdAT"),u+=4,0!=m&&(c(g,u,M++),u+=4),g.set(i,u),u+=w,c(g,u,h(g,s,u-s)),u+=4}return c(g,u,0),u+=4,a(g,u,"IEND"),u+=4,c(g,u,h(g,u-4,4)),u+=4,g.buffer}function f(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 a(i,s,e,n,r){const o=r[0],c=r[1],f=r[2],a=r[3],d=r[4],v=r[5];let w=6,p=8,m=255;for(var g=0;g<i.length;g++){const t=new Uint8Array(i[g]);for(var y=t.length,M=0;M<y;M+=4)m&=t[M+3]}const b=255!=m,U=function i(s,e,n,r,o,h){const c=[];for(var f=0;f<s.length;f++){const i=new Uint8Array(s[f]),u=new Uint32Array(i.buffer);var a;let v=0,w=0,p=e,m=n,g=r?1:0;if(0!=f){const y=h||r||1==f||0!=c[f-2].dispose?1:2;let M=0,b=1e9;for(let t=0;t<y;t++){var d=new Uint8Array(s[f-1-t]);const i=new Uint32Array(s[f-1-t]);let r=e,h=n,c=-1,a=-1;for(let t=0;t<n;t++)for(let s=0;s<e;s++){u[A=t*e+s]!=i[A]&&(s<r&&(r=s),s>c&&(c=s),t<h&&(h=t),t>a&&(a=t))}-1==c&&(r=h=c=a=0),o&&(1==(1&r)&&r--,1==(1&h)&&h--);const l=(c-r+1)*(a-h+1);l<b&&(b=l,M=t,v=r,w=h,p=c-r+1,m=a-h+1)}d=new Uint8Array(s[f-1-M]);1==M&&(c[f-1].dispose=2),a=new Uint8Array(p*m*4),t(d,e,n,a,p,m,-v,-w,0),g=t(i,e,n,a,p,m,-v,-w,3)?1:0,1==g?l(i,e,n,a,{x:v,y:w,width:p,height:m}):t(i,e,n,a,p,m,-v,-w,0)}else a=i.slice(0);c.push({rect:{x:v,y:w,width:p,height:m},img:a,blend:g,dispose:0})}if(r)for(f=0;f<c.length;f++){if(1==(w=c[f]).blend)continue;const t=w.rect,i=c[f-1].rect,r=Math.min(t.x,i.x),h=Math.min(t.y,i.y),a={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[f-1].dispose=1,f-1!=0&&u(s,e,n,c,f-1,a,o),u(s,e,n,c,f,a,o)}let v=0;if(1!=s.length)for(var A=0;A<c.length;A++){var w;v+=(w=c[A]).rect.width*w.rect.height}return c}(i,s,e,o,c,f),x={},E=[],F=[];if(0!=n){const t=[];for(M=0;M<U.length;M++)t.push(U[M].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=A(i,n);for(M=0;M<s.plte.length;M++)E.push(s.plte[M].est.rgba);let e=0;for(M=0;M<U.length;M++){const t=(T=U[M]).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,E,i,P),T.img.set(i),e+=t}}else for(g=0;g<U.length;g++){var T=U[g];const t=new Uint32Array(T.img.buffer);var B=T.rect.width;y=t.length,P=new Uint8Array(y);F.push(P);for(M=0;M<y;M++){const i=t[M];if(0!=M&&i==t[M-1])P[M]=P[M-1];else if(M>B&&i==t[M-B])P[M]=P[M-B];else{let t=x[i];if(null==t&&(x[i]=t=E.length,E.push(i),E.length>=300))break;P[M]=t}}}const k=E.length;k<=256&&0==d&&(p=k<=2?1:k<=4?2:k<=16?4:8,p=Math.max(p,a));for(g=0;g<U.length;g++){(T=U[g]).rect.x;B=T.rect.width;const t=T.rect.height;let i=T.img;let s=4*B,e=4;if(k<=256&&0==d){s=Math.ceil(p*B/8);var S=new Uint8Array(s*t);const n=F[g];for(let i=0;i<t;i++){M=i*s;const t=i*B;if(8==p)for(var I=0;I<B;I++)S[M+I]=n[t+I];else if(4==p)for(I=0;I<B;I++)S[M+(I>>1)]|=n[t+I]<<4-4*(1&I);else if(2==p)for(I=0;I<B;I++)S[M+(I>>2)]|=n[t+I]<<6-2*(3&I);else if(1==p)for(I=0;I<B;I++)S[M+(I>>3)]|=n[t+I]<<7-1*(7&I)}i=S,w=3,e=1}else if(0==b&&1==U.length){S=new Uint8Array(B*t*3);const n=B*t;for(M=0;M<n;M++){const t=3*M,s=4*M;S[t]=i[s],S[t+1]=i[s+1],S[t+2]=i[s+2]}i=S,w=2,e=3,s=3*B}T.img=i,T.bpl=s,T.bpp=e}return{ctype:w,depth:p,plte:E,frames:U}}function u(i,s,e,n,r,o,h){const c=Uint8Array,f=Uint32Array,a=new c(i[r-1]),u=new f(i[r-1]),d=r+1<i.length?new c(i[r+1]):null,v=new c(i[r]),A=new f(v.buffer);let w=s,p=e,m=-1,g=-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,f=A[c];0==f||0==n[r-1].dispose&&u[c]==f&&(null==d||0!=d[4*c+3])||(e<w&&(w=e),e>m&&(m=e),h<p&&(p=h),h>g&&(g=h))}-1==m&&(w=p=m=g=0),h&&(1==(1&w)&&w--,1==(1&p)&&p--),o={x:w,y:p,width:m-w+1,height:g-p+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(a,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,f=[0,1,2,3,4];-1!=r?f=[r]:(i*e>5e5||1==s)&&(f=[0]),o&&(c={level:0});const a=X;for(var u=0;u<f.length;u++){for(let r=0;r<i;r++)v(n,t,r,e,s,f[u]);h.push(a.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 f=0;f<n;f++)t[c+f]=i[h+f];else t.set(new Uint8Array(i.buffer,h,n),c);else if(1==o){for(f=0;f<r;f++)t[c+f]=i[h+f];for(f=r;f<n;f++)t[c+f]=i[h+f]-i[h+f-r]+256&255}else if(0==e){for(f=0;f<r;f++)t[c+f]=i[h+f];if(2==o)for(f=r;f<n;f++)t[c+f]=i[h+f];if(3==o)for(f=r;f<n;f++)t[c+f]=i[h+f]-(i[h+f-r]>>1)+256&255;if(4==o)for(f=r;f<n;f++)t[c+f]=i[h+f]-s(i[h+f-r],0,0)+256&255}else{if(2==o)for(f=0;f<n;f++)t[c+f]=i[h+f]+256-i[h+f-n]&255;if(3==o){for(f=0;f<r;f++)t[c+f]=i[h+f]+256-(i[h+f-n]>>1)&255;for(f=r;f<n;f++)t[c+f]=i[h+f]+256-(i[h+f-n]+i[h+f-r]>>1)&255}if(4==o){for(f=0;f<r;f++)t[c+f]=i[h+f]+256-s(0,i[h+f-n],0)&255;for(f=r;f<n;f++)t[c+f]=i[h+f]+256-s(i[h+f-r],i[h+f-n],i[h+f-r-n])&255}}}function A(t,i){const s=new Uint8Array(t),e=s.slice(0),n=new Uint32Array(e.buffer),r=w(e,i),o=r[0],h=r[1],c=s.length,f=new Uint8Array(c>>2);let a;if(s.length<2e7)for(var u=0;u<c;u+=4){a=p(o,l=s[u]*(1/255),d=s[u+1]*(1/255),v=s[u+2]*(1/255),A=s[u+3]*(1/255)),f[u>>2]=a.ind,n[u>>2]=a.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),A=s[u+3]*(1/255);for(a=o;a.left;)a=m(a.est,l,d,v,A)<=0?a.left:a.right;f[u>>2]=a.ind,n[u>>2]=a.est.rgba}return{abuf:e.buffer,inds:f,plte:h}}function w(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=M(t,n.i0,n.i1),n.est=b(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=g(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 f={i0:h.i0,i1:c,bst:null,est:null,tdst:0,left:null,right:null};f.bst=M(t,f.i0,f.i1),f.est=b(f.bst);const a={i0:c,i1:h.i1,bst:null,est:null,tdst:0,left:null,right:null};a.bst={R:[],m:[],N:h.bst.N-f.bst.N};for(o=0;o<16;o++)a.bst.R[o]=h.bst.R[o]-f.bst.R[o];for(o=0;o<4;o++)a.bst.m[o]=h.bst.m[o]-f.bst.m[o];a.est=b(a.bst),h.left=f,h.right=a,r[n]=f,r.push(a)}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 p(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],f=r-i[3];return o*o+h*h+c*c+f*f}(t.est.q,i,s,e,n),t;const r=m(t.est,i,s,e,n);let o=t.left,h=t.right;r>0&&(o=t.right,h=t.left);const c=p(o,i,s,e,n);if(c.tdst<=r*r)return c;const f=p(h,i,s,e,n);return f.tdst<c.tdst?f:c}function m(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 g(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 M(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 b(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,f=[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],a=f,u=U;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(a,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 A=[n*c,r*c,o*c,h*c];return{Cov:f,q:A,e:l,L:d,eMq255:u.dot(u.sml(255,A),l),eMq:u.dot(l,A),rgba:(Math.round(255*A[3])<<24|Math.round(255*A[2])<<16|Math.round(255*A[1])<<8|Math.round(255*A[0])<<0)>>>0}}var U={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]]};G.encode=function t(i,s,e,n,r,o,h){null==n&&(n=0),null==h&&(h=false);const u=a(i,s,e,n,[false,false,false,0,h,false]);return f(u,-1),c(u,s,e,r,o)},G.encodeLL=function t(i,s,e,n,r,o,h,a){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 f(u,0,true),c(u,s,e,h,a)},G.encode.compress=a,G.encode.dither=h,G.quantize=A,G.quantize.getKDtree=w,G.quantize.getNearest=p}();const Y={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,f=122+c,a=new ArrayBuffer(f),u=new DataView(a),l=1<<20;let d,v,A,w,p=l,m=0,g=0,y=0;function M(t){u.setUint16(g,t,true),g+=2}function b(t){u.setUint32(g,t,true),g+=4}function U(t){g+=t}M(19778),b(f),U(4),b(122),b(108),b(s),b(-e>>>0),M(1),M(32),b(3),b(c),b(2835),b(2835),U(8),b(16711680),b(65280),b(255),b(4278190080),b(1466527264),function t(){for(;m<e&&p>0;){for(w=122+m*h,d=0;d<n;)p--,v=o[y++],A=v>>>24,u.setUint32(w+d,v<<8|A),d+=4;m++}y<o.length?(p=l,setTimeout(t,Y._dly)):i(a)}()},toBlob(t,i){this.toArrayBuffer(t,(t=>{i(new Blob([t],{type:"image/bmp"}))}))},_dly:9};var N={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},q={[N.CHROME]:16384,[N.FIREFOX]:11180,[N.DESKTOP_SAFARI]:16384,[N.IE]:8192,[N.IOS]:4096,[N.ETC]:8192};const V="undefined"!=typeof window,Z="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,J=V&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),tt=(V||Z)&&(J&&J.getOriginalSymbol(window,"File")||"undefined"!=typeof File&&File),it=(V||Z)&&(J&&J.getOriginalSymbol(window,"FileReader")||"undefined"!=typeof FileReader&&FileReader);function st(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 f=new Blob([c],{type:r});f.name=i,f.lastModified=s,e(f)}))}function et(t){return new Promise(((i,s)=>{const e=new it;e.onload=()=>i(e.result),e.onerror=t=>s(t),e.readAsDataURL(t)}))}function nt(t){return new Promise(((i,s)=>{const e=new Image;e.onload=()=>i(e),e.onerror=t=>s(t),e.src=t}))}function rt(){if(void 0!==rt.cachedResult)return rt.cachedResult;let t=N.ETC;const{userAgent:i}=navigator;return/Chrom(e|ium)/i.test(i)?t=N.CHROME:/iP(ad|od|hone)/i.test(i)&&/WebKit/i.test(i)?t=N.IOS:/Safari/i.test(i)?t=N.DESKTOP_SAFARI:/Firefox/i.test(i)?t=N.FIREFOX:(/MSIE/i.test(i)||true==!!document.documentMode)&&(t=N.IE),rt.cachedResult=t,rt.cachedResult}function ot(t,i){const s=rt(),e=q[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 ht(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 ct(t,i){const{width:s,height:e}=ot(t.width,t.height),[n,r]=ht(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 ft(){return void 0!==ft.cachedResult||(ft.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"undefined"!=typeof document&&"ontouchend"in document),ft.cachedResult}function at(t,i={}){return new Promise((function(s,e){let n,r;var o=function(){try{return r=ct(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 et(t).then((function(t){try{return i=t,nt(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(ft()||[N.DESKTOP_SAFARI,N.MOBILE_SAFARI].includes(rt()))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 ut(t,i,s,e,n=1){return new Promise((function(r,o){let h;if("image/png"===i){let f,a,u;return f=t.getContext("2d"),({data:a}=f.getImageData(0,0,t.width,t.height)),u=G.encode([a.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=>Y.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),st(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 lt(t){t.width=0,t.height=0}function dt(){return new Promise((function(t,i){let s,e,n,r;return void 0!==dt.cachedResult?t(dt.cachedResult):st("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(o){try{return s=o,at(s).then((function(o){try{return e=o[1],ut(e,s.type,s.name,s.lastModified).then((function(s){try{return n=s,lt(e),at(n).then((function(s){try{return r=s[0],dt.cachedResult=1===r.width&&2===r.height,t(dt.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 vt(t){return new Promise(((i,s)=>{const e=new it;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 At(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]=ht(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),lt(t)),o}function wt(t,i){const{width:s}=t,{height:e}=t,[n,r]=ht(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),lt(t),n}function pt(t,i,s=0){return new Promise((function(e,n){let r,o,h,c,f,a,u,l,d,v,A,w,p,m,g,y,M,b,U,x;function E(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,E(),at(t,i).then(function(s){try{return[,c]=s,E(),f=At(c,i),E(),new Promise((function(s,e){var n;if(!(n=i.exifOrientation))return vt(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 a=s,E(),dt().then(function(s){try{return u=s?f:wt(f,a),E(),l=i.initialQuality||1,d=i.fileType||t.type,ut(u,d,t.name,t.lastModified,l).then(function(s){try{{if(v=s,E(),A=v.size>h,w=v.size>t.size,!A&&!w)return F(100),e(v);var r;function a(){if(o--&&(g>h||g>p)){let i,s;return i=x?.95*U.width:U.width,s=x?.95*U.height:U.height,[M,b]=ht(i,s),b.drawImage(U,0,0,i,s),l*="image/png"===d?.85:.95,ut(M,d,t.name,t.lastModified,l).then((function(t){try{return y=t,lt(U),U=M,g=y.size,F(Math.min(99,Math.floor((m-g)/(m-h)*100))),a}catch(t){return n(t)}}),n)}return[1]}return p=t.size,m=v.size,g=m,U=u,x=!i.alwaysKeepResolution&&A,(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=a}else t=t.call(this)}catch(t){return n(t)}}}.bind(this))(a);function P(){return lt(U),lt(M),lt(f),lt(u),lt(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 mt="\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 gt;function yt(t,i){return new Promise(((s,e)=>{gt||(gt=function t(i){const s=[];return s.push(i),URL.createObjectURL(new Blob(s))}(mt));const n=new Worker(gt);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 Mt(t,i){return new Promise((function(s,e){let n,r,o,h,c,f;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 tt))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(f="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,!c||"function"!=typeof Worker||f)return pt(t,n).then(function(t){try{return r=t,l.call(this)}catch(t){return e(t)}}.bind(this),e);var a=function(){try{return l.call(this)}catch(t){return e(t)}}.bind(this),u=function(i){try{return pt(t,n).then((function(t){try{return r=t,a()}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",yt(t,n).then((function(t){try{return r=t,a()}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=$(t,r))}catch(t){}return s(r)}}))}Mt.getDataUrlFromFile=et,Mt.getFilefromDataUrl=st,Mt.loadImage=nt,Mt.drawImageInCanvas=ct,Mt.drawFileInCanvas=at,Mt.canvasToFile=ut,Mt.getExifOrientation=vt,Mt.handleMaxWidthOrHeight=At,Mt.followExifOrientation=wt,Mt.cleanupCanvasMemory=lt,Mt.isAutoOrientationInBrowser=dt,Mt.approximateBelowMaximumCanvasSizeOfBrowser=ot,Mt.copyExifWithoutOrientation=$,Mt.getBrowserName=rt,Mt.version="2.0.2";class bt extends i{constructor(t){super(t);this.fileInput=null;this.maxCompressionSize=300;this.setupFileInput()}onActivate(){this.openFilePicker()}openFilePicker(){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];Mt(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=>{var i;const s=new Image;s.src=(i=t.target)===null||i===void 0?void 0:i.result;s.onload=()=>this.createKritzelImage(s)};i.readAsDataURL(t)}createKritzelImage(t){const i=g.create(this._store);const{scaledWidth:s,scaledHeight:e}=i.calculateScaledDimensions(t);i.src=t.src;i.width=s;i.height=e;i.zIndex=this._store.currentZIndex;i.centerInViewport();this.addImageToStore(i);return i}addImageToStore(i){const s=K.create(this._store);s.addOrRemove(i);s.isSelected=true;const n=new e(this._store,this,i);const r=new O(this._store,this,s);this._store.history.executeCommand(new M(this._store,this,[n,r]));this._store.setState("activeTool",t.getTool("selection"))}handleCancel(){this._store.setState("activeTool",t.getTool("selection"))}}const Ut={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 xt={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"]};export{e as A,M as B,Ut as D,y as K,E as R,h as a,n as b,R as c,x as d,xt as e,bt as f,r as g,s as h,K as i,j,U as k,O as l,t as m,P as n,i as o,o as p,l as q,m as r,g as s};
2
- //# sourceMappingURL=p-DO2IiM_o.js.map