!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).CropperGrid=t()}(this,(function(){"use strict";const e="undefined"!=typeof window&&void 0!==window.document,t=e?window:{};e&&t.document.documentElement;const o=Number.isNaN||t.isNaN;const s=/([a-z\d])([A-Z])/g;function n(e){return String(e).replace(s,"$1-$2").toLowerCase()}const r=/-[A-z\d]/g;function i(e){return e.replace(r,(e=>e.slice(1).toUpperCase()))}const a={bubbles:!0,cancelable:!0,composed:!0};const c=Promise.resolve();const l=/left|top|width|height/i,d="open",h=new WeakMap,u=new WeakMap,p=new Map,b=t.document&&Array.isArray(t.document.adoptedStyleSheets)&&"replaceSync"in t.CSSStyleSheet.prototype;class m extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=d,this.slottable=!0;const o=null===(t=null===(e=Object.getPrototypeOf(this))||void 0===e?void 0:e.constructor)||void 0===t?void 0:t.$name;o&&p.set(o,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(e,t,o){if(Object.is(o,t))return;const s=i(e);let n=o;switch(typeof this[s]){case"boolean":n=null!==o&&"false"!==o;break;case"number":n=Number(o)}switch(this[s]=n,e){case"theme-color":{const e=u.get(this),t=this.$sharedStyle;e&&t&&(b?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,s){if(!Object.is(s,t))switch(e=n(e),typeof s){case"boolean":!0===s?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":s=o(s)?"":String(s);default:s?this.getAttribute(e)!==s&&this.setAttribute(e,s):this.removeAttribute(e)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEach((e=>{const t=i(e);let o=this[t];(function(e){return void 0===e})(o)||this.$propertyChangedCallback(t,void 0,o),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>o,set(e){const s=o;o=e,this.$propertyChangedCallback(t,s,e)}})}));const e=this.attachShadow({mode:this.shadowRootMode||d});if(this.shadowRoot||h.set(this,e),u.set(this,this.$addStyles(this.$sharedStyle)),this.$style&&this.$addStyles(this.$style),this.$template){const t=document.createElement("template");t.innerHTML=this.$template,e.appendChild(t.content)}if(this.slottable){const t=document.createElement("slot");e.appendChild(t)}}disconnectedCallback(){u.has(this)&&u.delete(this),h.has(this)&&h.delete(this)}$getTagNameOf(e){var t;return null!==(t=p.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach((t=>{let s=e[t];(function(e){return"number"==typeof e&&!o(e)})(s)&&(s=0!==s&&l.test(t)?`${s}px`:String(s)),this.style[t]=s})),this}$getShadowRoot(){return this.shadowRoot||h.get(this)}$addStyles(e){let t;const o=this.$getShadowRoot();return b?(t=new CSSStyleSheet,t.replaceSync(e),o.adoptedStyleSheets=o.adoptedStyleSheets.concat(t)):(t=document.createElement("style"),t.textContent=e,o.appendChild(t)),t}$emit(e,t,o){return function(e,t,o,s){return e.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign(Object.assign({},a),{detail:o}),s)))}(this,e,t,o)}$nextTick(e){return function(e,t){return t?c.then(e?t.bind(e):t):c}(this,e)}static $define(o,s){var r;"object"==typeof(r=o)&&null!==r&&(s=o,o=""),o||(o=this.$name||this.name),o=n(o),e&&t.customElements&&!t.customElements.get(o)&&customElements.define(o,this,s)}}m.$version="2.0.0-rc.2";class f extends m{constructor(){super(...arguments),this.$style=":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)}",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(e,t,o){Object.is(o,t)||(super.$propertyChangedCallback(e,t,o),"rows"!==e&&"columns"!==e||this.$nextTick((()=>{this.$render()})))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const e=this.$getShadowRoot(),t=document.createDocumentFragment();for(let e=0;e