1import{p as ke,F as Ft,k as xe}from"../base-Ci7vLHE_.js";import{p as Oe}from"../internals--3vI9LC5.js";import"../preload-helper-BVLnHgTN.js";var Pe=Object.defineProperty,Se=l=>{throw TypeError(l)},We=(l,t,e)=>t in l?Pe(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,At=(l,t,e)=>We(l,typeof t!="symbol"?t+"":t,e),Ot=(l,t,e)=>t.has(l)||Se("Cannot "+e),d=(l,t,e)=>(Ot(l,t,"read from private field"),e?e.call(l):t.get(l)),z=(l,t,e)=>t.has(l)?Se("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(l):t.set(l,e),S=(l,t,e,i)=>(Ot(l,t,"write to private field"),t.set(l,e),e),D=(l,t,e)=>(Ot(l,t,"access private method"),e);const St=typeof window<"u"&&typeof window.document<"u",Y=St?window:{},Pt=St?"ontouchstart"in Y.document.documentElement:!1,Wt=St?"PointerEvent"in Y:!1,V="cropper",it=`${V}-canvas`,Ne=`${V}-crosshair`,Xe=`${V}-grid`,Ye=`${V}-handle`,G=`${V}-image`,j=`${V}-selection`,je=`${V}-shade`,qe=`${V}-viewer`,vt="select",Ae="move",tt="scale",Tt="rotate",wt="transform",U="none",Vt="n-resize",Qt="e-resize",Zt="s-resize",Jt="w-resize",st="ne-resize",nt="nw-resize",at="se-resize",ot="sw-resize",Be="action",He=Pt?"touchend touchcancel":"mouseup",Ue=Pt?"touchmove":"mousemove",Ke=Pt?"touchstart":"mousedown",_t=Wt?"pointerdown":Ke,Gt=Wt?"pointermove":Ue,te=Wt?"pointerup pointercancel":He,ee="error",ie="keydown",_="load",se="wheel",et="action",Z="actionend",Fe="actionmove",J="actionstart",F="change",zt="transform";function pt(l){return typeof l=="string"}const Ee=Number.isNaN||Y.isNaN;function $(l){return typeof l=="number"&&!Ee(l)}function R(l){return $(l)&&l>0&&l<1/0}function Ve(l){return typeof l>"u"}function Me(l){return typeof l=="object"&&l!==null}const{hasOwnProperty:Qe}=Object.prototype;function Ct(l){if(!Me(l))return!1;try{const{constructor:t}=l,{prototype:e}=t;return t&&e&&Qe.call(e,"isPrototypeOf")}catch{return!1}}function Nt(l){return typeof l=="function"}function ht(l){return typeof l=="object"&&l!==null&&l.nodeType===1}const Ze=/([a-z\d])([A-Z])/g;function ne(l){return String(l).replace(Ze,"$1-$2").toLowerCase()}const Je=/-[A-z\d]/g;function ae(l){return l.replace(Je,t=>t.slice(1).toUpperCase())}const Te=/\s\s*/;function y(l,t,e,i){t.trim().split(Te).forEach(s=>{l.removeEventListener(s,e,i)})}function k(l,t,e,i){t.trim().split(Te).forEach(s=>{l.addEventListener(s,e,i)})}function oe(l,t,e,i){k(l,t,e,Object.assign(Object.assign({},i),{once:!0}))}const _e={bubbles:!0,cancelable:!0,composed:!0};function Ge(l,t,e,i){return l.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign(Object.assign({},_e),{detail:e}),i)))}const re=Promise.resolve();function ti(l,t){return t?re.then(l?t.bind(l):t):re}function he(l){const{documentElement:t}=l.ownerDocument,e=l.getBoundingClientRect();return{left:e.left+(Y.pageXOffset-t.clientLeft),top:e.top+(Y.pageYOffset-t.clientTop)}}const ei=/deg|g?rad|turn$/i;function Et(l){const t=parseFloat(l)||0;if(t!==0){const[e="rad"]=String(l).match(ei)||[];switch(e.toLowerCase()){case"deg":return t/360*(Math.PI*2);case"grad":return t/400*(Math.PI*2);case"turn":return t*(Math.PI*2)}}return t}const ce="contain",ii="cover";function ut(l,t=ce){const{aspectRatio:e}=l;let{width:i,height:s}=l;const n=R(i),o=R(s);if(n&&o){const a=s*e;t===ce&&a>i||t===ii&&a<i?s=i/e:i=s*e}else n?s=i/e:o&&(i=s*e);return{width:i,height:s}}function ze(l,...t){if(t.length===0)return l;const[e,i,s,n,o,a]=l,[c,h,r,p,u,m]=t[0];return l=[e*c+s*h,i*c+n*h,e*r+s*p,i*r+n*p,e*u+s*m+o,i*u+n*m+a],ze(l,...t.slice(1))}var si=":host([hidden]){display:none!important}";const ni=/left|top|width|height/i,le="open",lt=new WeakMap,dt=new WeakMap,de=new Map,pe=Y.document&&Array.isArray(Y.document.adoptedStyleSheets)&&"replaceSync"in Y.CSSStyleSheet.prototype;class H extends HTMLElement{get $sharedStyle(){return`${this.themeColor?`:host{--theme-color: ${this.themeColor};}`:""}${si}`}constructor(){var t,e;super(),this.shadowRootMode=le,this.slottable=!0;const i=(e=(t=Object.getPrototypeOf(this))===null||t===void 0?void 0:t.constructor)===null||e===void 0?void 0:e.$name;i&&de.set(i,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(t,e,i){if(Object.is(i,e))return;const s=ae(t),n=this[s];let o=i;switch(typeof n){case"boolean":o=i!==null&&i!=="false";break;case"number":o=Number(i);break}switch(this[s]=o,t){case"theme-color":{const a=dt.get(this),c=this.$sharedStyle;a&&c&&(pe?a.replaceSync(c):a.textContent=c);break}}}$propertyChangedCallback(t,e,i){if(!Object.is(i,e))switch(t=ne(t),typeof i){case"boolean":i===!0?this.hasAttribute(t)||this.setAttribute(t,""):this.removeAttribute(t);break;case"number":Ee(i)?i="":i=String(i);default:i?this.getAttribute(t)!==i&&this.setAttribute(t,i):this.removeAttribute(t)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEac
1h(e=>{const i=ae(e);let s=this[i];Ve(s)||this.$propertyChangedCallback(i,void 0,s),Object.defineProperty(this,i,{enumerable:!0,configurable:!0,get(){return s},set(n){const o=s;s=n,this.$propertyChangedCallback(i,o,n)}})});const t=this.attachShadow({mode:this.shadowRootMode||le});if(this.shadowRoot||lt.set(this,t),dt.set(this,this.$addStyles(this.$sharedStyle)),this.$style&&this.$addStyles(this.$style),this.$template){const e=document.createElement("template");e.innerHTML=this.$template,t.appendChild(e.content)}if(this.slottable){const e=document.createElement("slot");t.appendChild(e)}}disconnectedCallback(){dt.has(this)&&dt.delete(this),lt.has(this)&<.delete(this)}$getTagNameOf(t){var e;return(e=de.get(t))!==null&&e!==void 0?e:t}$setStyles(t){return Object.keys(t).forEach(e=>{let i=t[e];$(i)&&(i!==0&&ni.test(e)?i=`${i}px`:i=String(i)),this.style[e]=i}),this}$getShadowRoot(){return this.shadowRoot||lt.get(this)}$addStyles(t){let e;const i=this.$getShadowRoot();return pe?(e=new CSSStyleSheet,e.replaceSync(t),i.adoptedStyleSheets=i.adoptedStyleSheets.concat(e)):(e=document.createElement("style"),e.textContent=t,i.appendChild(e)),e}$emit(t,e,i){return Ge(this,t,e,i)}$nextTick(t){return ti(this,t)}static $define(t,e){Me(t)&&(e=t,t=""),t||(t=this.$name||this.name),t=ne(t),St&&Y.customElements&&!Y.customElements.get(t)&&customElements.define(t,this,e)}}H.$version="2.0.0";var ai=':host{display:block;min-height:100px;
1min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}';class Xt extends H{constructor(){super(...arguments),this.$onPointerDown=null,this.$onPointerMove=null,this.$onPointerUp=null,this.$onWheel=null,this.$wheeling=!1,this.$pointers=new Map,this.$style=ai,this.$action=U,this.background=!1,this.disabled=!1,this.scaleStep=.1,this.themeColor="#39f"}static get observedAttributes(){return super.observedAttributes.concat(["background","disabled","scale-step"])}connectedCallback(){super.connectedCallback(),this.disabled||this.$bind()}disconnectedCallback(){this.disabled||this.$unbind(),super.disconnectedCallback()}$propertyChangedCallback(t,e,i){if(!Object.is(i,e))switch(super.$propertyChangedCallback(t,e,i),t){case"disabled":i?this.$unbind():this.$bind();break}}$bind(){this.$onPointerDown||(this.$onPointerDown=this.$handlePointerDown.bind(this),k(this,_t,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),k(this.ownerDocument,Gt,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),k(this.ownerDocument,te,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),k(this,se,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(y(this,_t,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(y(this.ownerDocument,Gt,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(y(this.ownerDocument,te,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(y(this,se,this.$onWheel,{capture:!0}),this.$onWheel=null)}$handlePointerDown(t){const{buttons:e,button:i,type:s}=t;if(this.disabled||(s==="pointerdown"&&t.pointerType==="mouse"||s==="mousedown")&&($(e)&&e!==1||$(i)&&i!==0||t.ctrlKey))return;const{$pointers:n}=this;let o="";if(t.changedTouches)Array.from(t.changedTouches).forEach(({identifier:a,pageX:c,pageY:h})=>{n.set(a,{startX:c,startY:h,endX:c,endY:h})});else{const{pointerId:a=0,pageX:c,pageY:h}=t;n.set(a,{startX:c,startY:h,endX:c,endY:h})}n.size>1?o=wt:ht(t.target)&&(o=t.target.action||t.target.getAttribute(Be)||""),this.$emit(J,{action:o,relatedEvent:t})!==!1&&(t.preventDefault(),this.$action=o,this.style.willChange="transform")}$handlePointerMove(t){const{$action:e,$pointers:i}=this;if(this.disabled||e===U||i.size===0||this.$emit(Fe,{action:e,relatedEvent:t})===!1)return;if(t.preventDefault(),t.changedTouches)Array.from(t.changedTouches).forEach(({identifier:n,pageX:o,pageY:a})=>{const c=i.get(n);c&&Object.assign(c,{endX:o,endY:a})});else{const{pointerId:n=0,pageX:o,pageY:a}=t,c=i.get(n);c&&Object.assign(c,{endX:o,endY:a})}const s={action:e,relatedEvent:t};if(e===wt){const n=new Map(i);let o=0,a=0,c=0,h=0,r=t.pageX,p=t.pageY;
1i.forEach((g,E)=>{n.delete(E),n.forEach(x=>{let b=x.startX-g.startX,C=x.startY-g.startY,v=x.endX-g.endX,w=x.endY-g.endY,A=0,M=0,I=0,L=0;if(b===0?C<0?I=Math.PI*2:C>0&&(I=Math.PI):b>0?I=Math.PI/2+Math.atan(C/b):b<0&&(I=Math.PI*1.5+Math.atan(C/b)),v===0?w<0?L=Math.PI*2:w>0&&(L=Math.PI):v>0?L=Math.PI/2+Math.atan(w/v):v<0&&(L=Math.PI*1.5+Math.atan(w/v)),L>0||I>0){const W=L-I,N=Math.abs(W);N>o&&(o=N,c=W,r=(g.startX+x.startX)/2,p=(g.startY+x.startY)/2)}if(b=Math.abs(b),C=Math.abs(C),v=Math.abs(v),w=Math.abs(w),b>0&&C>0?A=Math.sqrt(b*b+C*C):b>0?A=b:C>0&&(A=C),v>0&&w>0?M=Math.sqrt(v*v+w*w):v>0?M=v:w>0&&(M=w),A>0&&M>0){const W=(M-A)/A,N=Math.abs(W);N>a&&(a=N,h=W,r=(g.startX+x.startX)/2,p=(g.startY+x.startY)/2)}})});const u=o>0,m=a>0;u&&m?(s.rotate=c,s.scale=h,s.centerX=r,s.centerY=p):u?(s.action=Tt,s.rotate=c,s.centerX=r,s.centerY=p):m?(s.action=tt,s.scale=h,s.centerX=r,s.centerY=p):s.action=U}else{const[n]=Array.from(i.values());Object.assign(s,n)}i.forEach(n=>{n.startX=n.endX,n.startY=n.endY}),s.action!==U&&this.$emit(et,s,{cancelable:!1})}$handlePointerUp(t){const{$action:e,$pointers:i}=this;if(!(this.disabled||e===U)&&this.$emit(Z,{action:e,relatedEvent:t})!==!1){if(t.preventDefault(),t.changedTouches)Array.from(t.changedTouches).forEach(({identifier:s})=>{i.delete(s)});else{const{pointerId:s=0}=t;i.delete(s)}i.size===0&&(this.style.willChange="",this.$action=U)}}$handleWheel(t){if(this.disabled||(t.preventDefault(),this.$wheeling))return;this.$wheeling=!0,setTimeout(()=>{this.$wheeling=!1},50);const e=(t.deltaY>0?-1:1)*this.scaleStep;this.$emit(et,{action:tt,scale:e,relatedEvent:t},{cancelable:!1})}$setAction(t){return pt(t)&&(this.$action=t),this}$toCanvas(t){return new Promise((e,i)=>{if(!this.isConnected){i(new Error("The current element is not connected to the DOM."));return}const s=document.createElement("canvas");let n=this.offsetWidth,o=this.offsetHeight,a=1;Ct(t)&&(R(t.width)||R(t.height))&&({width:n,height:o}=ut({aspectRatio:n/o,width:t.width,height:t.height}),a=n/this.offsetWidth),s.width=n,s.height=o;const c=this.querySelector(this.$getTagNameOf(G));if(!c){e(s);return}c.$ready().then(h=>{const r=s.getContext("2d");if(r){const[p,u,m,g,E,x]=c.$getTransform();let b=E,C=x,v=h.naturalWidth,w=h.naturalHeight;a!==1&&(b*=a,C*=a,v*=a,w*=a);const A=v/2,M=w/2;r.fillStyle="transparent",r.fillRect(0,0,n,o),Ct(t)&&Nt(t.beforeDraw)&&t.beforeDraw.call(this,r,s),r.save(),r.translate(A,M),r.transform(p,u,m,g,b,C),r.translate(-A,-M),r.drawImage(h,0,0,v,w),r.restore()}e(s)}).catch(i)})}}Xt.$name=it;Xt.$version="2.0.0";var oi=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}";const ue=new WeakMap,ge=["alt","crossorigin","decoding","importance","loading","referrerpolicy","sizes","src","srcset"];class Yt extends H{constructor(){super(...arguments),this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=oi,this.$image=new Image,this.initialCenterSize="contain",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1}set $canvas(t){ue.set(this,t)}get $canvas(){return ue.get(this)}static get observedAttributes(){return super.observedAttributes.concat(ge,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(t,e,i){Object.is(i,e)||(super.attributeChangedCallback(t,e,i),ge.includes(t)&&this.$image.setAttribute(t,i))}$propertyChangedCallback(t,e,i){if(!Object.is(i,e))switch(super.$propertyChangedCallback(t,e,i),t){case"initialCenterSize":this.$nextTick(()=>{this.$center(i)});break}}connectedCallback(){super.connectedCallback();const{$image:t}=this,e=this.closest(this.$getTagNameOf(it));e&&(this.$canvas=e,this.$setStyles({display:"block",position:"absolute"}),this.$onCanvasActionStart=i=>{var s,n;this.$actionStartTarget=(n=(s=i.detail)===null||s===void 0?void 0:s.relatedEvent)===null||n===void 0?void 0:n.target},this.$onCanvasActionEnd=()=>{this.$actionStartTarget=null},this.$onCanvasAction=this.$handleAction.bind(this),k(e,J,this.$onCanvasActionStart),k(e,Z,this.$onCanvasActionEnd),k(e,et,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),k(t,_,this.$onLoad),this.$getShadowRoot().appendChild(t)}disconnectedCallback(){const{$image:t,$canvas:e}=this;e&&(this.$onCanvasActionStart&&(y(e,J,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(y(e,Z,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(y(e,et,this.$onCanvasAction),this.$onCanvasAction=null)),t&&this.$onLoad&&(y(t,_,this.$onLoad),this.$onLoad=null),this.$getShadowRoot().removeChild(t),super.disconnectedCallback()}$handleLoad(){const{$image:t}=this;
1this.$setStyles({width:t.naturalWidth,height:t.naturalHeight}),this.$canvas&&this.$center(this.initialCenterSize)}$handleAction(t){if(this.hidden||!(this.rotatable||this.scalable||this.translatable))return;const{$canvas:e}=this,{detail:i}=t;if(i){const{relatedEvent:s}=i;let{action:n}=i;switch(n===wt&&(!this.rotatable||!this.scalable)&&(this.rotatable?n=Tt:this.scalable?n=tt:n=U),n){case Ae:if(this.translatable){let o=null;s&&(o=s.target.closest(this.$getTagNameOf(j))),o||(o=e.querySelector(this.$getTagNameOf(j))),o&&o.multiple&&!o.active&&(o=e.querySelector(`${this.$getTagNameOf(j)}[active]`)),(!o||o.hidden||!o.movable||o.dynamic||!(this.$actionStartTarget&&o.contains(this.$actionStartTarget)))&&this.$move(i.endX-i.startX,i.endY-i.startY)}break;case Tt:if(this.rotatable)if(s){const{x:o,y:a}=this.getBoundingClientRect();this.$rotate(i.rotate,s.clientX-o,s.clientY-a)}else this.$rotate(i.rotate);break;case tt:if(this.scalable)if(s){const o=s.target.closest(this.$getTagNameOf(j));if(!o||!o.zoomable||o.zoomable&&o.dynamic){const{x:a,y:c}=this.getBoundingClientRect();this.$zoom(i.scale,s.clientX-a,s.clientY-c)}}else this.$zoom(i.scale);break;case wt:if(this.rotatable&&this.scalable){const{rotate:o}=i;let{scale:a}=i;a<0?a=1/(1-a):a+=1;const c=Math.cos(o),h=Math.sin(o),[r,p,u,m]=[c*a,h*a,-h*a,c*a];if(s){const g=this.getBoundingClientRect(),E=s.clientX-g.x,x=s.clientY-g.y,[b,C,v,w]=this.$matrix,A=g.width/2,M=g.height/2,I=E-A,L=x-M,W=(I*w-v*L)/(b*w-v*C),N=(L*b-C*I)/(b*w-v*C);this.$transform(r,p,u,m,W*(1-r)+N*u,N*(1-m)+W*p)}else this.$transform(r,p,u,m,0,0)}break}}}$ready(t){const{$image:e}=this,i=new Promise((s,n)=>{const o=new Error("Failed to load the image source");if(e.complete)e.naturalWidth>0&&e.naturalHeight>0?s(e):n(o);else{const a=()=>{y(e,ee,c),s(e)},c=()=>{y(e,_,a),n(o)};oe(e,_,a),oe(e,ee,c)}});return Nt(t)&&i.then(s=>(t(s),s)),i}$center(t){const{parentElement:e}=this;if(!e)return this;const i=e.getBoundingClientRect(),s=i.width,n=i.height,{x:o,y:a,width:c,height:h}=this.getBoundingClientRect(),r=o+c/2,p=a+h/2,u=i.x+s/2,m=i.y+n/2;if(this.$move(u-r,m-p),t&&(c!==s||h!==n)){const g=s/c,E=n/h;switch(t){case"cover":this.$scale(Math.max(g,E));break;case"contain":this.$scale(Math.min(g,E));break}}return this}$move(t,e=t){if(this.translatable&&$(t)&&$(e)){const[i,s,n,o]=this.$matrix,a=(t*o-n*e)/(i*o-n*s),c=(e*i-s*t)/(i*o-n*s);this.$translate(a,c)}return this}$moveTo(t,e=t){if(this.translatable&&$(t)&&$(e)){const[i,s,n,o]=this.$matrix,a=(t*o-n*e)/(i*o-n*s),c=(e*i-s*t)/(i*o-n*s);this.$setTransform(i,s,n,o,a,c)}return this}$rotate(t,e,i){if(this.rotatable){const s=Et(t),n=Math.cos(s),o=Math.sin(s),[a,c,h,r]=[n,o,-o,n];if($(e)&&$(i)){const[p,u,m,g]=this.$matrix,{width:E,height:x}=this.getBoundingClientRect(),b=E/2,C=x/2,v=e-b,w=i-C,A=(v*g-m*w)/(p*g-m*u),M=(w*p-u*v)/(p*g-m*u);this.$transform(a,c,h,r,A*(1-a)-M*h,M*(1-r)-A*c)}else this.$transform(a,c,h,r,0,0)}return this}$zoom(t,e,i){if(!this.scalable||t===0)return this;if(t<0?t=1/(1-t):t+=1,$(e)&&$(i)){const[s,n,o,a]=this.$matrix,{width:c,height:h}=this.getBoundingClientRect(),r=c/2,p=h/2,u=e-r,m=i-p,g=(u*a-o*m)/(s*a-o*n),E=(m*s-n*u)/(s*a-o*n);this.$transform(t,0,0,t,g*(1-t),E*(1-t))}else this.$scale(t);return this}$scale(t,e=t){return this.scalable&&this.$transform(t,0,0,e,0,0),this}$skew(t,e=0){if(this.skewable){const i=Et(t),s=Et(e);this.$transform(1,Math.tan(s),Math.tan(i),1,0,0)}return this}$translate(t,e=t){return this.translatable&&$(t)&&$(e)&&this.$transform(1,0,0,1,t,e),this}$transform(t,e,i,s,n,o){return $(t)&&$(e)&&$(i)&&$(s)&&$(n)&&$(o)?this.$setTransform(ze(this.$matrix,[t,e,i,s,n,o])):this}$setTransform(t,e,i,s,n,o){if((this.rotatable||this.scalable||this.skewable||this.translatable)&&(Array.isArray(t)&&([t,e,i,s,n,o]=t),$(t)&&$(e)&&$(i)&&$(s)&&$(n)&&$(o))){const a=[...this.$matrix],c=[t,e,i,s,n,o];if(this.$emit(zt,{matrix:c,oldMatrix:a})===!1)return this;this.$matrix=c,this.style.transform=`matrix(${c.join(", ")})`}return this}$getTransform(){return this.$matrix.slice()}$resetTransform(){return this.$setTransform([1,0,0,1,0,0])}}Yt.$name=G;Yt.$version="2.0.0";var ri=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}";const me=new WeakMap;
1class jt extends H{constructor(){super(...arguments),this.$onCanvasChange=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$style=ri,this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(t){me.set(this,t)}get $canvas(){return me.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const t=this.closest(this.$getTagNameOf(it));if(t){this.$canvas=t,this.style.position="absolute";const e=t.querySelector(this.$getTagNameOf(j));e&&(this.$onCanvasActionStart=i=>{e.hidden&&i.detail.action===vt&&(this.hidden=!1)},this.$onCanvasActionEnd=i=>{e.hidden&&i.detail.action===vt&&(this.hidden=!0)},this.$onCanvasChange=i=>{const{x:s,y:n,width:o,height:a}=i.detail;this.$change(s,n,o,a),(e.hidden||s===0&&n===0&&o===0&&a===0)&&(this.hidden=!0)},k(t,J,this.$onCanvasActionStart),k(t,Z,this.$onCanvasActionEnd),k(t,F,this.$onCanvasChange))}this.$render()}disconnectedCallback(){const{$canvas:t}=this;t&&(this.$onCanvasActionStart&&(y(t,J,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(y(t,Z,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasChange&&(y(t,F,this.$onCanvasChange),this.$onCanvasChange=null)),super.disconnectedCallback()}$change(t,e,i=this.width,s=this.height){return!$(t)||!$(e)||!$(i)||!$(s)||t===this.x&&e===this.y&&i===this.width&&s===this.height?this:(this.hidden&&(this.hidden=!1),this.x=t,this.y=e,this.width=i,this.height=s,this.$render())}$reset(){return this.$change(0,0,0,0)}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height,outlineWidth:Y.innerWidth})}}jt.$name=je;jt.$version="2.0.0";var hi=':host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}';class qt extends H{constructor(){super(...arguments),this.$onCanvasCropEnd=null,this.$onCanvasCropStart=null,this.$style=hi,this.action=U,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}qt.$name=Ye;qt.$version="2.0.0";var ci=':host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}';const $e=new WeakMap;class Bt extends H{constructor(){super(...arguments),this.$onCanvasAction=null,this.$onCanvasActionStart=null,this.$onCanvasActionEnd=null,this.$onDocumentKeyDown=null,this.$action="",this.$actionStartTarget=null,this.$changing=!1,this.$style=ci,this.$initialSelection={x:0,y:0,width:0,height:0},this.x=0,this.y=0,this.width=0,this.height=0,this.aspectRatio=NaN,this.initialAspectRatio=NaN,this.initialCoverage=NaN,this.active=!1,this.linked=!1,this.dynamic=!1,this.movable=!1,this.resizable=!1,this.zoomable=!1,this.multiple=!1,this.keyboard=!1,this.outlined=!1,this.precise=!1}set $canvas(t){$e.set(this,t)}get $canvas(){return $e.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["active","aspect-ratio","dynamic","height","initial-aspect-ratio","initial-coverage","keyboard","linked","movable","multiple","outlined","precise","resizable","width","x","y","zoomable"])}$propertyChangedCallback(t,e,i){if(!Object.is(i,e))switch(super.$propertyChangedCallback(t,e,i),t){case"x":case"y":case"width":case"height":this.$changing||this.$nextTick(()=>{this.$change(this.x,this.y,this.width,this.height,this.aspectRatio,!0)});break;case"aspectRatio":case"initialAspectRatio":this.$nextTick(()=>{this.$initSelection()});break;case"initialCoverage":this.$nextTick(()=>{R(i)&&i<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(i?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),k(this.ownerDocument,ie,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(y(this.ownerDocument,ie,this.$onDocumentKeyDown),this.$onDocumentKeyDown=null))});break;case"multiple":this.$nextTick(()=>
1{if(this.$canvas){const s=this.$getSelections();i?(s.forEach(n=>{n.active=!1}),this.active=!0,this.$emit(F,{x:this.x,y:this.y,width:this.width,height:this.height})):(this.active=!1,s.slice(1).forEach(n=>{this.$removeSelection(n)}))}});break;case"precise":this.$nextTick(()=>{this.$change(this.x,this.y)});break;case"linked":i&&(this.dynamic=!0);break}}connectedCallback(){super.connectedCallback();const t=this.closest(this.$getTagNameOf(it));t?(this.$canvas=t,this.$setStyles({position:"absolute",transform:`translate(${this.x}px, ${this.y}px)`}),this.hidden||this.$render(),this.$initSelection(!0),this.$onCanvasActionStart=this.$handleActionStart.bind(this),this.$onCanvasActionEnd=this.$handleActionEnd.bind(this),this.$onCanvasAction=this.$handleAction.bind(this),k(t,J,this.$onCanvasActionStart),k(t,Z,this.$onCanvasActionEnd),k(t,et,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:t}=this;t&&(this.$onCanvasActionStart&&(y(t,J,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(y(t,Z,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(y(t,et,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let t=[];return this.parentElement&&(t=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(j)))),t}$initSelection(t=!1,e=!1){const{initialCoverage:i,parentElement:s}=this;if(R(i)&&s){const n=this.aspectRatio||this.initialAspectRatio;let o=(e?0:this.width)||s.offsetWidth*i,a=(e?0:this.height)||s.offsetHeight*i;R(n)&&({width:o,height:a}=ut({aspectRatio:n,width:o,height:a})),this.$change(this.x,this.y,o,a),t&&this.$center(),this.$initialSelection={x:this.x,y:this.y,width:this.width,height:this.height}}}$createSelection(){const t=this.cloneNode(!0);return this.hasAttribute("id")&&t.removeAttribute("id"),t.initialCoverage=NaN,this.active=!1,this.parentElement&&this.parentElement.insertBefore(t,this.nextSibling),t}$removeSelection(t=this){if(this.parentElement){const e=this.$getSelections();if(e.length>1){const i=e.indexOf(t),s=e[i+1]||e[i-1];s&&(t.active=!1,this.parentElement.removeChild(t),s.active=!0,s.$emit(F,{x:s.x,y:s.y,width:s.width,height:s.height}))}else this.$clear()}}$handleActionStart(t){var e,i;const s=(i=(e=t.detail)===null||e===void 0?void 0:e.relatedEvent)===null||i===void 0?void 0:i.target;this.$action="",this.$actionStartTarget=s,!this.hidden&&this.multiple&&!this.active&&s===this&&this.parentElement&&(this.$getSelections().forEach(n=>{n.active=!1}),this.active=!0,this.$emit(F,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(t){const{currentTarget:e,detail:i}=t;if(!e||!i)return;const{relatedEvent:s}=i;let{action:n}=i;if(!n&&this.multiple&&(n=this.$action||(s==null?void 0:s.target.action),this.$action=n),!n||this.hidden&&n!==vt||this.multiple&&!this.active&&n!==tt)return;const o=i.endX-i.startX,a=i.endY-i.startY,{width:c,height:h}=this;let{aspectRatio:r}=this;switch(!R(r)&&s.shiftKey&&(r=R(c)&&R(h)?c/h:1),n){case vt:if(o!==0&&a!==0){const{$canvas:p}=this,u=he(e);(this.multiple&&!this.hidden?this.$createSelection():this).$change(i.startX-u.left,i.startY-u.top,Math.abs(o),Math.abs(a),r),o<0?a<0?n=nt:a>0&&(n=ot):o>0&&(a<0?n=st:a>0&&(n=at)),p&&(p.$action=n)}break;case Ae:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(o,a);break;case tt:if(s&&this.zoomable&&(this.dynamic||this.contains(s.target))){const p=he(e);this.$zoom(i.scale,s.pageX-p.left,s.pageY-p.top)}break;default:this.$resize(n,o,a,r)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(t){if(this.hidden||!this.keyboard||this.multiple&&!this.active||t.defaultPrevented)return;const{activeElement:e}=document;if(!(e&&(["INPUT","TEXTAREA"].includes(e.tagName)||["true","plaintext-only"].includes(e.contentEditable))))switch(t.key){case"Backspace":t.metaKey&&(t.preventDefault(),this.$removeSelection());break;case"Delete":t.preventDefault(),this.$removeSelection();break;case"ArrowLeft":t.preventDefault(),this.$move(-1,0);break;case"ArrowRight":t.preventDefault(),this.$move(1,0);break;case"ArrowUp":t.preventDefault(),this.$move(0,-1);break;case"ArrowDown":t.preventDefault(),this.$move(0,1);break;case"+":t.preventDefault(),this.$zoom(.1);break;case"-":t.preventDefault(),this.$zoom(-.1);break}}$center(){const{parentElement:t}=this;if(!t)return this;const e=(t.offsetWidth-this.width)/2,i=(t.offsetHeight-this.height)/2;return this.$change(e,i)}$move(t,e=t){return this.$moveTo(this.x+t,this.y+e)}$moveTo(t,e=t){return this.movable?this.$change(t,e):this}$resize(t,e=0,i=0,s=this.aspectRatio){if(!this.resizable)return this;const n=R(s),{$canvas:o}=this;let{x:a,y:c,width:h,height:r}=this;switch(t){case Vt:c+=i,r-=i,r<0&&(t=Zt,r=-r,c-=r),n&&(e=i*s,a+=e/2,h-=e,h<0&&(h=-h,a-=h));break;case Qt:h+=e,h<0&&(t=Jt,h=-h,a-=h),n&&(i=e/s,c-=i/2,r+=i,r<0&&(r=-r,c-=r));break;case Zt:r+=i,r<0&&(t=Vt,r=-r,c-=r),n&&(e=i*s,a-=e/2,h+=e,h<0&&(h=-h,a-=h));break;case Jt:a+=e,h-=e,h<0&&(t=Qt,h=-h,a-=h),n&&(i=e/s,c+=i/2,r-=i,r<0&&(r=-r,c-=r));break;case st:n&&(i=-e/s),c+=i,r-=i,h+=e,h<0&&r<0?(t=ot,h=-h,r=-r,a-=h,c-=r):h<0?(t=nt,h=-h,a-=h):r<0&&(t=at,r=-r,c-=r);break;case nt:n&&(i=e/s),a+=e,c+=i,h-=e,r-=i,h<0&&r<0?(t=at,h=-h,r=-r,a-=h,c-=r):h<0?(t=st,h=-h,a-=h):r<0&&(t=ot,r=-r,c-=r);break;case at:n&&(i=e/s),h+=e,r+=i,h<0&&r<0?(t=nt,h=-h,r=-r,a-=h,c-=r):h<0?(t=ot,h=-h,a-=h):r<0&&(t=st,r=-r,c-=r);break;case ot:n&&(i=-e/s),a+=e,h-=e,r+=i,h<0&&r<0?(t=st,h=-h,r=-r,a-=h,c-=r):h<0?(t=at,h=-h,a-=h):r<0&&(t=nt,r=-r,c-=r);break}return o&&o.$setAction(t),this.$change(a,c,h,r)}$zoom(t,e,i){if(!this.zoomable||t===0)return this;t<0?t=1/(1-t):t+=1;const{width:s,height:n}=this,o=s*t,a=n*t;let c=this.x,h=this.y;return $(e)&&$(i)?(c-=(o-s)*((e-this.x)/s),h-=(a-n)*((i-this.y)/n)):(c-=(o-s)/2,h-=(a-n)/2),this.$change(c,h,o,a)}$change(t,e,i=this.width,s=this.height,n=this.aspectRatio,o=!1){return this.$changing||!$(t)||!$(e)||!$(i)||!$(s)||i<0||s<0?this:(R(n)&&({width:i,height:s}=ut({aspectRatio:n,width:i,height:s},"cover")),this.precise||(t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s)),t===this.x&&e===this.y&&i===this.width&&s===this.height&&Object.is(n,this.aspectRatio)&&!o?this:(this.hidden&&(this.hidden=!1),this.$emit(F,{x:t,y:e,width:i,height:s})===!1?this:(this.$changing=!0,this.x=t,this.y=e,this.width=i,this.height=s,this.$changing=!1,this.$render())))}$reset(){const{x:t,y:e,width:i,height:s}=this.$initialSelection;return this.$change(t,e,i,s)}$clear(){return this.$change(0,0,0,0,NaN,!0),this.hidden=!0,this}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height})}$toCanvas(t){return new Promise((e,i)=>{if(!this.isConnected){i(new Error("The current element is not connected to the DOM."));return}const s=document.createElement("canvas");let{width:n,height:o}=this,a=1;if(Ct(t)&&(R(t.width)||R(t.height))&&({width:n,height:o}=ut({aspectRatio:n/o,width:t.width,height:t.height}),a=n/this.width),s.width=n,s.height=o,!this.$canvas){e(s);return}const c=this.$canvas.querySelector(this.$getTagNameOf(G));if(!c){e(s);return}c.$ready().then(h=>{const r=s.getContext("2d");if(r){const[p,u,m,g,E,x]=c.$getTransform(),b=-this.x,C=-this.y,v=(b*g-m*C)/(p*g-m*u),w=(C*p-u*b)/(p*g-m*u);
1let A=p*v+m*w+E,M=u*v+g*w+x,I=h.naturalWidth,L=h.naturalHeight;a!==1&&(A*=a,M*=a,I*=a,L*=a);const W=I/2,N=L/2;r.fillStyle="transparent",r.fillRect(0,0,n,o),Ct(t)&&Nt(t.beforeDraw)&&t.beforeDraw.call(this,r,s),r.save(),r.translate(W,N),r.transform(p,u,m,g,A,M),r.translate(-W,-N),r.drawImage(h,0,0,I,L),r.restore()}e(s)}).catch(i)})}}Bt.$name=j;Bt.$version="2.0.0";var li=":host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}";class Ht extends H{constructor(){super(...arguments),this.$style=li,this.bordered=!1,this.columns=3,this.covered=!1,this.rows=3,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["bordered","columns","covered","rows"])}$propertyChangedCallback(t,e,i){Object.is(i,e)||(super.$propertyChangedCallback(t,e,i),(t==="rows"||t==="columns")&&this.$nextTick(()=>{this.$render()}))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const t=this.$getShadowRoot(),e=document.createDocumentFragment();for(let i=0;i<this.rows;i+=1){const s=document.createElement("span");s.setAttribute("role","row");for(let n=0;n<this.columns;n+=1){const o=document.createElement("span");o.setAttribute("role","gridcell"),s.appendChild(o)}e.appendChild(s)}t&&(t.innerHTML="",t.appendChild(e))}}Ht.$name=Xe;Ht.$version="2.0.0";var di=':host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}';class Ut extends H{constructor(){super(...arguments),this.$style=di,this.centered=!1,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["centered"])}}Ut.$name=Ne;Ut.$version="2.0.0";var pi=":host{display:block;height:100%;overflow:hidden;position:relative;width:100%}";const be=new WeakMap,fe=new WeakMap,ve=new WeakMap,we=new WeakMap,ui="both",gi="horizontal",Ce="vertical",mi="none";class Kt extends H{constructor(){super(...arguments),this.$onSelectionChange=null,this.$onSourceImageLoad=null,this.$onSourceImageTransform=null,this.$scale=1,this.$style=pi,this.resize=Ce,this.selection="",this.slottable=!1}set $image(t){fe.set(this,t)}get $image(){return fe.get(this)}set $sourceImage(t){we.set(this,t)}get $sourceImage(){return we.get(this)}set $canvas(t){be.set(this,t)}get $canvas(){return be.get(this)}set $selection(t){ve.set(this,t)}get $selection(){return ve.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){super.connectedCallback();let t=null;if(this.selection?t=this.ownerDocument.querySelector(this.selection):t=this.closest(this.$getTagNameOf(j)),ht(t)){this.$selection=t,this.$onSelectionChange=this.$handleSelectionChange.bind(this),k(t,F,this.$onSelectionChange);const e=t.closest(this.$getTagNameOf(it));if(e){this.$canvas=e;const i=e.querySelector(this.$getTagNameOf(G));i&&(this.$sourceImage=i,this.$image=i.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),k(i.$image,_,this.$onSourceImageLoad),k(i,zt,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:t,$sourceImage:e}=this;t&&this.$onSelectionChange&&(y(t,F,this.$onSelectionChange),this.$onSelectionChange=null),e&&this.$onSourceImageLoad&&(y(e.$image,_,this.$onSourceImageLoad),this.$onSourceImageLoad=null),e&&this.$onSourceImageTransform&&(y(e,zt,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(t){this.$render(t.detail)}$handleSourceImageLoad(){const{$image:t,$sourceImage:e}=this,i=t.getAttribute("src"),s=e.getAttribute("src");s&&s!==i&&(t.setAttribute("src",s),t.$ready(()=>{setTimeout(()=>{this.$render()},50)}))}$handleSourceImageTransform(t){this.$render(void 0,t.detail.matrix)}$render(t,e){const{$canvas:i,$selection:s}=this;!t&&!s.hidden&&(t=s),(!t||t.x===0&&t.y===0&&t.width===0&&t.height===0)&&(t={x:0,y:0,width:i.offsetWidth,height:i.offsetHeight});const{x:n,y:o,width:a,height:c}=t,h={},{clientWidth:r,clientHeight:p}=this;let u=r,m=p,g=NaN;switch(this.resize){case ui:g=1,u=a,m=c,h.width=a,h.height=c;break;case gi:g=c>0?p/c:0,u=a*g,h.width=u;break;case Ce:g=a>0?r/a:0,m=c*g,h.height=m;break;case mi:default:r>0?g=a>0?r/a:0:p>0&&(g=c>0?p/c:0)}this.$scale=g,this.$setStyles(h),this.$sourceImage&&this.$transformImageByOffset(e??this.$sourceImage.$getTransform(),-n,-o)}$transformImageByOffset(t,e,i){const{$image:s,$scale:n,$sourceImage:o}=this;if(o&&s&&n>=0){const[a,c,h,r,p,u]=t,m=(e*r-h*i)/(a*r-h*c),g=(i*a-c*e)/(a*r-h*c),E=a*m+h*g+p,x=c*m+r*g+u;s.$ready(b=>
1{this.$setStyles.call(s,{width:b.naturalWidth*n,height:b.naturalHeight*n})}),s.$setTransform(a,c,h,r,E*n,x*n)}}}Kt.$name=qe;Kt.$version="2.0.0";/*! Cropper.js v2.0.0 | (c) 2015-present Chen Fengyuan | MIT */var $i='<cropper-canvas background><cropper-image rotatable scalable skewable translatable></cropper-image><cropper-shade hidden></cropper-shade><cropper-handle action="select" plain></cropper-handle><cropper-selection initial-coverage="0.5" movable resizable><cropper-grid role="grid" bordered covered></cropper-grid><cropper-crosshair centered></cropper-crosshair><cropper-handle action="move" theme-color="rgba(255, 255, 255, 0.35)"></cropper-handle><cropper-handle action="n-resize"></cropper-handle><cropper-handle action="e-resize"></cropper-handle><cropper-handle action="s-resize"></cropper-handle><cropper-handle action="w-resize"></cropper-handle><cropper-handle action="ne-resize"></cropper-handle><cropper-handle action="nw-resize"></cropper-handle><cropper-handle action="se-resize"></cropper-handle><cropper-handle action="sw-resize"></cropper-handle></cropper-selection></cropper-canvas>';const bi=/^img|canvas$/,fi=/<(\/?(?:script|style)[^>]*)>/gi,ye={template:$i};Xt.$define();Ut.$define();Ht.$define();qt.$define();Yt.$define();Bt.$define();jt.$define();Kt.$define();class De{constructor(t,e){if(this.options=ye,pt(t)&&(t=document.querySelector(t)),!ht(t)||!bi.test(t.localName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,e=Object.assign(Object.assign({},ye),e),this.options=e;const{ownerDocument:i}=t;let{container:s}=e;if(s&&(pt(s)&&(s=i.querySelector(s)),!ht(s)))throw new Error("The `container` option must be an element or a valid selector.");ht(s)||(t.parentElement?s=t.parentElement:s=i.body),this.container=s;const n=t.localName;let o="";n==="img"?{src:o}=t:n==="canvas"&&window.HTMLCanvasElement&&(o=t.toDataURL());const{template:a}=e;if(a&&pt(a)){const c=document.createElement("template"),h=document.createDocumentFragment();c.innerHTML=a.replace(fi,"<$1>"),h.appendChild(c.content),Array.from(h.querySelectorAll(G)).forEach(r=>{r.setAttribute("src",o),r.setAttribute("alt",t.alt||"The image to crop")}),t.parentElement?(t.style.display="none",s.insertBefore(h,t.nextSibling)):s.appendChild(h)}}getCropperCanvas(){return this.container.querySelector(it)}getCropperImage(){return this.container.querySelector(G)}getCropperSelection(){return this.container.querySelector(j)}getCropperSelections(){return this.container.querySelectorAll(j)}}De.version="2.0.0";const Mt={"image/png":!0,"image/jpeg":!0,"image/gif":!0,"image/webp":!0,"image/svg+xml":!1};function vi(l,t){return l.x>=t.x&&l.y>=t.y&&l.x+l.width<=t.x+t.width&&l.y+l.height<=t.y+t.height}var f,q,rt,gt,X,Q,Dt,mt,Re,Rt;class wi{constructor(t,e=null){z(this,Q),z(this,f),z(this,q),z(this,rt),z(this,gt,!1),z(this,X,null),z(this,mt,i=>{i.stopPropagation();const s=d(this,f).getCropperCanvas(),n=d(this,f).getCropperImage();S(this,X,D(this,Q,Rt).call(this));const o=s.getBoundingClientRect(),a=n.getBoundingClientRect(),c={x:a.left-o.left,y:a.top-o.top,width:a.width,height:a.height};vi(i.detail,c)||i.preventDefault()}),S(this,f,t),S(this,q,e),S(this,rt,new ResizeObserver(i=>D(this,Q,Re).call(this,i)))}enableCrop(){D(this,Q,Dt).call(this);const t=d(this,f).getCropperCanvas(),e=d(this,f).getCropperSelection(),i=d(this,f).getCropperImage();this.clearCrop(),t.disabled=!1,i.$ready(()=>{const s=i.getBoundingClientRect();if(d(this,q)===null)this.selectCrop(s.width*.5,s.height*.5);else if(d(this,q)<1){const n=s.height*.3;this.selectCrop(n*d(this,q),n)}else if(d(this,q)>1){const n=s.width*.3;this.selectCrop(n,n/d(this,q))}else this.selectCrop(s.width*.3,s.width*.3);d(this,rt).observe(t)}),e.addEventListener("change",d(this,mt))}disableCrop(){D(this,Q,Dt).call(this),S(this,X,null);const t=d(this,f).getCropperCanvas();t.disabled=!0,d(this,f).getCropperSelection().removeEventListener("change",d(this,mt)),d(this,rt).unobserve(t),this.clearCrop()}toggleCrop(){const t=this.cropping;return t?this.disableCrop():this.enableCrop(),!t}get cropping(){return!d(this,f).getCropperCanvas().disabled}selectCrop(t,e){const i=d(this,f).getCropperCanvas(),s=d(this,f).getCropperImage(),n=d(this,f).getCropperSelection(),o=s.getBoundingClientRect(),a=i.getBoundingClientRect(),c=o.left-a.left,h=o.top-a.top,r=c+(o.width-t)/2,p=h+(o.height-e)/2;n.x=r,n.y=p,n.width=t,n.height=e,n.$render()}clearCrop(){const t=d(this,f).getCropperSelection();t.width=0,t.height=0,t.x=0,t.y=0,t.$render(),S(this,X,null)}rotate(t){d(this,f).getCropperImage().$rotate(t),this.clearCrop(),this.disableCrop()}async asBlob({min:t,max:e}){let i,s=new Promise(m=>i=m),n=!1;const o=d(this,f).getCropperSelection(),a=d(this,f).getCropperImage(),c=a.getBoundingClientRect();o.width===0&&(this.selectCrop(c.width,c.height),n=!0);let h=Math.min(e.width??1/0,Math.max(t.width??-1/0,a.$image.clientWidth)),r=Math.min(e.height??1/0,Math.max(t.height??-1/0,a.$image.clientHeight));const p=await o.$toCanvas({width:h,height:r});p==null||p.toBlob(m=>i(m));const u=await s;return n&&this.clearCrop(),u}}
1f=new WeakMap,q=new WeakMap,rt=new WeakMap,gt=new WeakMap,X=new WeakMap,Q=new WeakSet,Dt=function(){var l;if(d(this,gt))return;const t=d(this,f).getCropperCanvas(),e=d(this,f).getCropperSelection(),i=d(this,f).getCropperImage();(l=t.querySelector("cropper-shade"))==null||l.remove(),t.background=!1,t.scaleStep=0,i.initialCenterSize="contain",i.scalable=!0,i.skewable=!1,i.setAttribute("crossorigin","anonymous"),e.aspectRatio=d(this,q)||NaN,e.zoomable=!1,e.initialCoverage=0,S(this,gt,!0)},mt=new WeakMap,Re=function(){if(d(this,X)===null)return;const l=d(this,f).getCropperCanvas(),t=d(this,f).getCropperImage(),e=d(this,f).getCropperSelection();t.$center("contain");const i=t.getBoundingClientRect(),s=l.getBoundingClientRect(),n={x:i.left-s.left,y:i.top-s.top};e.x=n.x+d(this,X).x*i.width,e.y=n.y+d(this,X).y*i.height,e.width=d(this,X).width*i.width,e.height=d(this,X).height*i.height,e.$render(),S(this,X,D(this,Q,Rt).call(this))},Rt=function(){const l=d(this,f).getCropperCanvas(),t=d(this,f).getCropperImage(),e=d(this,f).getCropperSelection(),i=t.getBoundingClientRect(),s=l.getBoundingClientRect(),n={x:i.left-s.left,y:i.top-s.top};return{x:(e.x-n.x)/i.width,y:(e.y-n.y)/i.height,width:e.width/i.width,height:e.height/i.height}};var K,yt,$t,ct,B,T,P,bt,O,Ie,kt,xt,It,Lt;const ft=class Le extends ke{constructor(){super(),z(this,O),z(this,K),z(this,yt,!1),z(this,$t,Object.keys(Mt).join(",")),z(this,ct,null),z(this,B),z(this,T,null),z(this,P,null),z(this,bt,{min:{width:null,max:null},max:{width:null,max:null}}),S(this,K,HTMLElement.prototype.attachInternals?this.attachInternals():new Oe(this)),S(this,B,Ft().newTranslator());const t=this.ownerDocument.createElement("dialog"),e=this.ownerDocument.createElement("div");e.classList.add("container"),t.appendChild(e),t.addEventListener("close",async()=>{const u=await d(this,T).asBlob(d(this,bt));u&&d(this,P)&&await D(this,O,xt).call(this,new xe(u,d(this,P).name,d(this,P).mime))});const i=this.ownerDocument.createElement("menu"),s=this.ownerDocument.createElement("button"),n=this.ownerDocument.createElement("button"),o=this.ownerDocument.createElement("button");i.classList.add("actions"),s.classList.add("rotate"),s.textContent=d(this,B).lookup("rotate"),s.addEventListener("click",()=>d(this,T).rotate("90deg")||o.classList.toggle("active",d(this,T).cropping)),n.classList.add("save"),n.textContent=d(this,B).lookup("save"),n.addEventListener("click",()=>t.close()),o.classList.add("crop"),o.textContent=d(this,B).lookup("crop"),o.addEventListener("click",()=>o.classList.toggle("active",d(this,T).toggleCrop())),i.appendChild(s),i.appendChild(o),i.appendChild(n),t.appendChild(i);const a=this.ownerDocument.createElement("div");a.classList.add("attachment");const c=this.ownerDocument.createElement("span");c.classList.add("filename"),c.tabindex=1;const h=this.ownerDocument.createElement("div");h.classList.add("wrapper");const r=this.ownerDocument.createElement("button");r.type="button",r.classList="pick",r.textContent=d(this,B).lookup("upload"),r.addEventListener("click",async()=>{const u=await Ft().filePicker(h,d(this,$t));await this.loadAttachment(u),Mt[d(this,P).mime]&&(D(this,O,Lt).call(this),D(this,O,It).call(this,t))}),c.addEventListener("click",()=>{Mt[d(this,P).mime]?(D(this,O,Lt).call(this),D(this,O,It).call(this,t)):r.click()});const p=this.ownerDocument.createElement("button");p.type="button",p.classList.add("delete"),p.textContent=d(this,B).lookup("delete"),p.addEventListener("click",()=>this.clearAttachment()),h.appendChild(r),h.appendChild(a),h.appendChild(t),a.appendChild(c),a.appendChild(p),this.shadowRoot.appendChild(h)}connectedCallback(){if(this.hasAttribute("accept")&&S(this,$t,this.getAttribute("accept")),this.hasAttribute("required")&&S(this,yt,this.getAttribute("required")),this.hasAttribute("aspect-ratio")){const t=this.getAttribute("aspect-ratio").split("/",2).map(e=>parseFloat(e.trim()));t.length===2&&S(this,ct,t[0]/t[1])}for(const t of["min","max"])if(this.hasAttribute(t)){const e=this.getAttribute(t).split("x",2).map(i=>parseInt(i.trim()));e.length===2&&(d(this,bt)[t]={width:e[0],height:e[1]})}if(this.hasAttribute("value")&&this.getAttribute("value")){const t=new URL(this.getAttribute("value")),e=this.hasAttribute("filename")?this.getAttribute("filename"):t.pathname.split("/").filter(
1Boolean).pop();D(this,O,Ie).call(this,t,e)}D(this,O,kt).call(this)}checkValidity(){return d(this,K).checkValidity()}reportValidity(){return d(this,K).reportValidity()}setValidity(t,e=""){d(this,K).setValidity(t,e)}clearAttachment(){var t;(t=d(this,T))==null||t.disableCrop(),S(this,T,null),S(this,P,null),this.shadowRoot.querySelector("span.filename").textContent="",this.shadowRoot.querySelectorAll("dialog .container *").forEach(e=>e.remove()),D(this,O,kt).call(this),this.dispatchEvent(new Event("change"))}get attachment(){return d(this,P)}async loadAttachment(t){var e;(e=d(this,T))==null||e.disableCrop(),S(this,T,null),await D(this,O,xt).call(this,t),this.shadowRoot.querySelectorAll("dialog .container *").forEach(i=>i.remove())}manipulate(){return d(this,T)}static register(){customElements.get("g2ui-input-image")||customElements.define("g2ui-input-image",Le)}};K=new WeakMap,yt=new WeakMap,$t=new WeakMap,ct=new WeakMap,B=new WeakMap,T=new WeakMap,P=new WeakMap,bt=new WeakMap,O=new WeakSet,Ie=async function(l,t){await D(this,O,xt).call(this,await xe.fromUrl(l,t))},kt=function(){d(this,yt)&&d(this,K).setValidity({valueMissing:d(this,P)===null},d(this,B).lookup("image_missing"),this.shadowRoot.querySelector("button.pick"))},xt=async function(l){this.shadowRoot.querySelector("span.filename").textContent=l.name,d(this,K).setFormValue(new File([await l.blob()],l.name,{type:l.mime})),S(this,P,l),D(this,O,kt).call(this),this.dispatchEvent(new Event("change"))},It=function(l){if(d(this,T))return;const t=this.ownerDocument.createElement("img");t.setAttribute("crossorigin","anonymous"),t.src=d(this,P).url,l.querySelector(".container").appendChild(t),S(this,T,new wi(new De(t),d(this,ct))),d(this,ct)?d(this,T).enableCrop():d(this,T).disableCrop(),this.shadowRoot.querySelector("button.crop").classList.toggle("active",d(this,T).cropping)},Lt=function(){this.shadowRoot.querySelector("dialog").showModal()},At(ft,"formAssociated",!0),At(ft,"shadowRootOptions",{...ke.shadowRootOptions,delegatesFocus:!0}),At(ft,"adopt",[new URL("/apps/framework/build/css/g2ui-input-image-BALNyEXZ.css",import.meta.url)]);let xi=ft;export{xi as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.