@uploadcare/file-uploader
Version:
Building blocks for Uploadcare products integration
29 lines • 114 kB
JavaScript
/**
* @license
* MIT License
*
* Copyright (c) 2022 Uploadcare (hello@uploadcare.com). All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var mi=Object.defineProperty;var _i=Object.getPrototypeOf;var gi=Reflect.get;var bi=(i,t,e)=>t in i?mi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>(bi(i,typeof t!="symbol"?t+"":t,e),e);var at=(i,t,e)=>gi(_i(i),e,t);var yi=Object.defineProperty,vi=(i,t,e)=>t in i?yi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Ve=(i,t,e)=>(vi(i,typeof t!="symbol"?t+"":t,e),e);function wi(i){let t=e=>{var r;for(let s in e)((r=e[s])==null?void 0:r.constructor)===Object&&(e[s]=t(e[s]));return{...e}};return t(i)}var v=class{constructor(i){i.constructor===Object?this.store=wi(i):(this._storeIsProxy=!0,this.store=i),this.callbackMap=Object.create(null)}static warn(i,t){console.warn(`Symbiote Data: cannot ${i}. Prop name: `+t)}read(i){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(v.warn("read",i),null):this.store[i]}has(i){return this._storeIsProxy?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,t,e=!1){!e&&Object.keys(this.store).includes(i)||(this.store[i]=t,this.notify(i))}pub(i,t){if(!this._storeIsProxy&&!this.store.hasOwnProperty(i)){v.warn("publish",i);return}this.store[i]=t,this.notify(i)}multiPub(i){for(let t in i)this.pub(t,i[t])}notify(i){this.callbackMap[i]&&this.callbackMap[i].forEach(t=>{t(this.store[i])})}sub(i,t,e=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(v.warn("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(t),e&&t(this.store[i]),{remove:()=>{this.callbackMap[i].delete(t),this.callbackMap[i].size||delete this.callbackMap[i]},callback:t})}static registerCtx(i,t=Symbol()){let e=v.globalStore.get(t);return e?console.warn('State: context UID "'+t+'" already in use'):(e=new v(i),v.globalStore.set(t,e)),e}static deleteCtx(i){v.globalStore.delete(i)}static getCtx(i,t=!0){return v.globalStore.get(i)||(t&&console.warn('State: wrong context UID - "'+i+'"'),null)}};v.globalStore=new Map;var _=Object.freeze({BIND_ATTR:"set",ATTR_BIND_PRFX:"@",EXT_DATA_CTX_PRFX:"*",NAMED_DATA_CTX_SPLTR:"/",CTX_NAME_ATTR:"ctx-name",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx-name",EL_REF_ATTR:"ref",AUTO_TAG_PRFX:"sym",REPEAT_ATTR:"repeat",REPEAT_ITEM_TAG_ATTR:"repeat-item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL:"use-template",ROOT_STYLE_ATTR_NAME:"sym-component"}),ut="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",xi=ut.length-1,Ei=class{static generate(i="XXXXXXXXX-XXX"){let t="";for(let e=0;e<i.length;e++)t+=i[e]==="-"?i[e]:ut.charAt(Math.random()*xi);return t}};function dt(i,t,e){let r=!0,s,o=t.split(".");return o.forEach((n,l)=>{l<o.length-1?i=i[n]:s=n}),i?i[s]=e:r=!1,r}function Ci(i){return i.split("-").map((t,e)=>t&&e?t[0].toUpperCase()+t.slice(1):t).join("").split("_").map((t,e)=>t&&e?t.toUpperCase():t).join("")}function Ti(i,t){[...i.querySelectorAll(`[${_.REPEAT_ATTR}]`)].forEach(e=>{let r=e.getAttribute(_.REPEAT_ITEM_TAG_ATTR),s;if(r&&(s=window.customElements.get(r)),!s){s=class extends t.BaseComponent{constructor(){super(),r||(this.style.display="contents")}};let n=e.innerHTML;s.template=n,s.reg(r)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(_.REPEAT_ATTR);t.sub(o,n=>{if(!n){for(;e.firstChild;)e.firstChild.remove();return}let l=[...e.children],a,c=u=>{u.forEach((d,m)=>{if(l[m])if(l[m].set$)setTimeout(()=>{l[m].set$(d)});else for(let g in d)l[m][g]=d[g];else{a||(a=new DocumentFragment);let g=new s;Object.assign(g.init$,d),a.appendChild(g)}}),a&&e.appendChild(a);let h=l.slice(u.length,l.length);for(let d of h)d.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let u=[];for(let h in n){let d=n[h];Object.defineProperty(d,"_KEY_",{value:h,enumerable:!0}),u.push(d)}c(u)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),e.removeAttribute(_.REPEAT_ATTR),e.removeAttribute(_.REPEAT_ITEM_TAG_ATTR)})}var ct="__default__";function Ai(i,t){if(t.shadowRoot)return;let e=[...i.querySelectorAll("slot")];if(!e.length)return;let r={};e.forEach(s=>{let o=s.getAttribute("name")||ct;r[o]={slot:s,fr:document.createDocumentFragment()}}),t.initChildren.forEach(s=>{var o;let n=ct;s instanceof Element&&s.hasAttribute("slot")&&(n=s.getAttribute("slot"),s.removeAttribute("slot")),(o=r[n])==null||o.fr.appendChild(s)}),Object.values(r).forEach(s=>{if(s.fr.childNodes.length)s.slot.parentNode.replaceChild(s.fr,s.slot);else if(s.slot.childNodes.length){let o=document.createDocumentFragment();o.append(...s.slot.childNodes),s.slot.parentNode.replaceChild(o,s.slot)}else s.slot.remove()})}function Si(i,t){[...i.querySelectorAll(`[${_.EL_REF_ATTR}]`)].forEach(e=>{let r=e.getAttribute(_.EL_REF_ATTR);t.ref[r]=e,e.removeAttribute(_.EL_REF_ATTR)})}function $i(i,t){[...i.querySelectorAll(`[${_.BIND_ATTR}]`)].forEach(e=>{let s=e.getAttribute(_.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=Ci(o.name.replace("-",""));s.push(n+":"+o.value),e.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let n=o.split(":").map(u=>u.trim()),l=n[0],a;l.indexOf(_.ATTR_BIND_PRFX)===0&&(a=!0,l=l.replace(_.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(u=>u.trim());for(let u of c){let h;u.startsWith("!!")?(h="double",u=u.replace("!!","")):u.startsWith("!")&&(h="single",u=u.replace("!","")),t.sub(u,d=>{h==="double"?d=!!d:h==="single"&&(d=!d),a?(d==null?void 0:d.constructor)===Boolean?d?e.setAttribute(l,""):e.removeAttribute(l):e.setAttribute(l,d):dt(e,l,d)||(e[_.SET_LATER_KEY]||(e[_.SET_LATER_KEY]=Object.create(null)),e[_.SET_LATER_KEY][l]=d)})}}),e.removeAttribute(_.BIND_ATTR)})}var ve="{{",le="}}",ki="skip-text";function Oi(i){let t,e=[],r=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(ki))&&s.textContent.includes(ve)&&s.textContent.includes(le)&&1}});for(;t=r.nextNode();)e.push(t);return e}var Li=function(i,t){Oi(i).forEach(r=>{let s=[],o;for(;r.textContent.includes(le);)r.textContent.startsWith(ve)?(o=r.textContent.indexOf(le)+le.length,r.splitText(o),s.push(r)):(o=r.textContent.indexOf(ve),r.splitText(o)),r=r.nextSibling;s.forEach(n=>{let l=n.textContent.replace(ve,"").replace(le,"");n.textContent="",t.sub(l,a=>{n.textContent=a})})})},Ii=[Ti,Ai,Si,$i,Li],we="'",J='"',Pi=/\\([0-9a-fA-F]{1,6} ?)/g;function Mi(i){return(i[0]===J||i[0]===we)&&(i[i.length-1]===J||i[i.length-1]===we)}function Ri(i){return(i[0]===J||i[0]===we)&&(i=i.slice(1)),(i[i.length-1]===J||i[i.length-1]===we)&&(i=i.slice(0,-1)),i}function Ni(i){let t="",e="";for(var r=0;r<i.length;r++){let s=i[r+1];i[r]==="\\"&&s==='"'?(t+='\\"',r++):i[r]==='"'&&e!=="\\"?t+='\\"':t+=i[r],e=i[r]}return t}function Ui(i){let t=i;Mi(i)&&(t=Ri(t),t=t.replace(Pi,(e,r)=>String.fromCodePoint(parseInt(r.trim(),16))),t=t.replaceAll(`\\
`,"\\n"),t=Ni(t),t=J+t+J);try{return JSON.parse(t)}catch{throw new Error(`Failed to parse CSS property value: ${t}. Original input: ${i}`)}}var ht=0,Q=null,D=null,H=class extends HTMLElement{constructor(){super(),Ve(this,"updateCssData",()=>{var i;this.dropCssDataCache(),(i=this.__boundCssProps)==null||i.forEach(t=>{let e=this.getCssData(this.__extractCssName(t),!0);e!==null&&this.$[t]!==e&&(this.$[t]=e)})}),this.init$=Object.create(null),this.cssInit$=Object.create(null),this.tplProcessors=new Set,this.ref=Object.create(null),this.allSubs=new Set,this.pauseRender=!1,this.renderShadow=!1,this.readyToDestroy=!0,this.processInnerHtml=!1,this.allowCustomTemplate=!1,this.ctxOwner=!1}get BaseComponent(){return H}initCallback(){}__initCallback(){var i;this.__initialized||(this.__initialized=!0,(i=this.initCallback)==null||i.call(this))}render(i,t=this.renderShadow){let e;if((t||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let s=this.getAttribute(_.USE_TPL);if(s){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(s))||document.querySelector(s);n?i=n.content.cloneNode(!0):console.warn(`Symbiote template "${s}" is not found...`)}}if(this.processInnerHtml)for(let s of this.tplProcessors)s(this,this);if(i||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(i==null?void 0:i.constructor)===DocumentFragment)e=i;else if((i==null?void 0:i.constructor)===String){let s=document.createElement("template");s.innerHTML=i,e=s.content.cloneNode(!0)}else this.constructor.__tpl&&(e=this.constructor.__tpl.content.cloneNode(!0));for(let s of this.tplProcessors)s(e,this)}let r=()=>{e&&(t&&this.shadowRoot.appendChild(e)||this.appendChild(e)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){t=!0;let s=document.createElement("link");s.rel="stylesheet",s.href=this.constructor.__shadowStylesUrl,s.onload=r,this.shadowRoot.prepend(s)}else r()}addTemplateProcessor(i){this.tplProcessors.add(i)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=Ei.generate(),this.style.setProperty(_.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(_.CSS_CTX_PROP,!0)}get ctxName(){var i;let t=((i=this.getAttribute(_.CTX_NAME_ATTR))==null?void 0:i.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=t,t}get localCtx(){return this.__localCtx||(this.__localCtx=v.registerCtx({},this)),this.__localCtx}get nodeCtx(){return v.getCtx(this.ctxName,!1)||v.registerCtx({},this.ctxName)}static __parseProp(i,t){let e,r;if(i.startsWith(_.EXT_DATA_CTX_PRFX))e=t.nodeCtx,r=i.replace(_.EXT_DATA_CTX_PRFX,"");else if(i.includes(_.NAMED_DATA_CTX_SPLTR)){let s=i.split(_.NAMED_DATA_CTX_SPLTR);e=v.getCtx(s[0]),r=s[1]}else e=t.localCtx,r=i;return{ctx:e,name:r}}sub(i,t,e=!0){let r=o=>{this.isConnected&&t(o)},s=H.__parseProp(i,this);s.ctx.has(s.name)?this.allSubs.add(s.ctx.sub(s.name,r,e)):window.setTimeout(()=>{this.allSubs.add(s.ctx.sub(s.name,r,e))})}notify(i){let t=H.__parseProp(i,this);t.ctx.notify(t.name)}has(i){let t=H.__parseProp(i,this);return t.ctx.has(t.name)}add(i,t,e=!1){let r=H.__parseProp(i,this);r.ctx.add(r.name,t,e)}add$(i,t=!1){for(let e in i)this.add(e,i[e],t)}get $(){if(!this.__stateProxy){let i=Object.create(null);this.__stateProxy=new Proxy(i,{set:(t,e,r)=>{let s=H.__parseProp(e,this);return s.ctx.pub(s.name,r),!0},get:(t,e)=>{let r=H.__parseProp(e,this);return r.ctx.read(r.name)}})}return this.__stateProxy}set$(i,t=!1){for(let e in i){let r=i[e];t||![String,Number,Boolean].includes(r==null?void 0:r.constructor)?this.$[e]=r:this.$[e]!==r&&(this.$[e]=r)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(_.CTX_OWNER_ATTR)&&this.getAttribute(_.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let i=this.constructor.__attrDesc;if(i)for(let t of Object.values(i))Object.keys(this.init$).includes(t)||(this.init$[t]="");for(let t in this.init$)if(t.startsWith(_.EXT_DATA_CTX_PRFX))this.nodeCtx.add(t.replace(_.EXT_DATA_CTX_PRFX,""),this.init$[t],this.__ctxOwner);else if(t.includes(_.NAMED_DATA_CTX_SPLTR)){let e=t.split(_.NAMED_DATA_CTX_SPLTR),r=e[0].trim(),s=e[1].trim();if(r&&s){let o=v.getCtx(r,!1);o||(o=v.registerCtx({},r)),o.add(s,this.init$[t])}}else this.localCtx.add(t,this.init$[t]);for(let t in this.cssInit$)this.bindCssData(t,this.cssInit$[t]);this.__dataCtxInitialized=!0}connectedCallback(){var i;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let t=(i=this.getAttribute(_.CTX_NAME_ATTR))==null?void 0:i.trim();if(t&&this.style.setProperty(_.CSS_CTX_PROP,`'${t}'`),this.__initDataCtx(),this[_.SET_LATER_KEY]){for(let e in this[_.SET_LATER_KEY])dt(this,e,this[_.SET_LATER_KEY][e]);delete this[_.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let e of Ii)this.addTemplateProcessor(e);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let e=this.getRootNode();if(!e)return;if(e==null?void 0:e.querySelector(`link[${_.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let s=this.constructor.__rootStylesLink.cloneNode(!0);s.setAttribute(_.ROOT_STYLE_ATTR_NAME,this.constructor.is),s.onload=()=>{this.render()},e.nodeType===Node.DOCUMENT_NODE?e.head.appendChild(s):e.prepend(s)}else this.render()}this.connectedOnce=!0}}destroyCallback(){}disconnectedCallback(){this.connectedOnce&&(this.dropCssDataCache(),this.readyToDestroy&&(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),this.__disconnectTimeout=window.setTimeout(()=>{this.destroyCallback();for(let i of this.allSubs)i.remove(),this.allSubs.delete(i);for(let i of this.tplProcessors)this.tplProcessors.delete(i);D==null||D.delete(this.updateCssData),D!=null&&D.size||(Q==null||Q.disconnect(),Q=null,D=null)},100)))}static reg(i,t=!1){i||(ht++,i=`${_.AUTO_TAG_PRFX}-${ht}`),this.__tag=i;let e=window.customElements.get(i);if(e){!t&&e!==this&&console.warn([`Element with tag name "${i}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
`));return}window.customElements.define(i,t?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(i){this.observedAttributes=Object.keys(i),this.__attrDesc=i}attributeChangedCallback(i,t,e){var r;if(t===e)return;let s=(r=this.constructor.__attrDesc)==null?void 0:r[i];s?this.__dataCtxInitialized?this.$[s]=e:this.init$[s]=e:this[i]=e}getCssData(i,t=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(i)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(i).trim();try{this.__cssDataCache[i]=Ui(e)}catch{!t&&console.warn(`CSS Data error: ${i}`),this.__cssDataCache[i]=null}}return this.__cssDataCache[i]}__extractCssName(i){return i.split("--").map((t,e)=>e===0?"":t).join("--")}__initStyleAttrObserver(){D||(D=new Set),D.add(this.updateCssData),Q||(Q=new MutationObserver(i=>{i[0].type==="attributes"&&D.forEach(t=>{t()})}),Q.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(i,t=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(i);let e=this.getCssData(this.__extractCssName(i),!0);e===null&&(e=t),this.add(i,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(i,t,e){let r="__"+i;this[r]=this[i],Object.defineProperty(this,i,{set:s=>{this[r]=s,e?window.setTimeout(()=>{t==null||t(s)}):t==null||t(s)},get:()=>this[r]}),this[i]=this[r]}static set shadowStyles(i){let t=new Blob([i],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(t)}static set rootStyles(i){if(!this.__rootStylesLink){let t=new Blob([i],{type:"text/css"}),e=URL.createObjectURL(t),r=document.createElement("link");r.href=e,r.rel="stylesheet",this.__rootStylesLink=r}}},He=H;Ve(He,"template");var Be=class{static _print(i){console.warn(i)}static setDefaultTitle(i){this.defaultTitle=i}static setRoutingMap(i){Object.assign(this.appMap,i);for(let t in this.appMap)!this.defaultRoute&&this.appMap[t].default===!0?this.defaultRoute=t:!this.errorRoute&&this.appMap[t].error===!0&&(this.errorRoute=t)}static set routingEventName(i){this.__routingEventName=i}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let i={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))i.route=e.replace("?","");else if(e.includes("=")){let r=e.split("=");i.options[r[0]]=decodeURI(r[1])}else i.options[e]=!0}),i}static notify(){let i=this.readAddressBar(),t=this.appMap[i.route];if(t&&t.title&&(document.title=t.title),i.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!t&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t){this._print(`Route "${i.route}" not found...`);return}let e=new CustomEvent(Be.routingEventName,{detail:{route:i.route,options:Object.assign(t||{},i.options)}});window.dispatchEvent(e)}static reflect(i,t={}){let e=this.appMap[i];if(!e){this._print("Wrong route: "+i);return}let r="?"+i;for(let o in t)t[o]===!0?r+=this.separator+o:r+=this.separator+o+`=${t[o]}`;let s=e.title||this.defaultTitle||"";window.history.pushState(null,s,r),document.title=s}static applyRoute(i,t={}){this.reflect(i,t),this.notify()}static setSeparator(i){this._separator=i}static get separator(){return this._separator||"&"}static createRouterData(i,t){this.setRoutingMap(t);let e=v.registerCtx({route:null,options:null,title:null},i);return window.addEventListener(this.routingEventName,r=>{var s;e.multiPub({route:r.detail.route,options:r.detail.options,title:((s=r.detail.options)==null?void 0:s.title)||this.defaultTitle||""})}),Be.notify(),this.initPopstateListener(),e}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};Be.appMap=Object.create(null);var pt="idb-store-ready",Di="symbiote-db",Fi="symbiote-idb-update_",zi=class{_notifyWhenReady(i=null){window.dispatchEvent(new CustomEvent(pt,{detail:{dbName:this.name,storeName:this.storeName,event:i}}))}get _updEventName(){return Fi+this.name}_getUpdateEvent(i){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:i}})}_notifySubscribers(i){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,i),window.dispatchEvent(this._getUpdateEvent(i))}constructor(i,t){this.name=i,this.storeName=t,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=e=>{this.db=e.target.result,this.objStore=this.db.createObjectStore(t,{keyPath:"_key"}),this.objStore.transaction.oncomplete=r=>{this._notifyWhenReady(r)}},this.request.onsuccess=e=>{this.db=e.target.result,this._notifyWhenReady(e)},this.request.onerror=e=>{console.error(e)},this._subscriptionsMap={},this._updateHandler=e=>{e.key===this.name&&this._subscriptionsMap[e.newValue]&&this._subscriptionsMap[e.newValue].forEach(async s=>{s(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(i){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(i);return new Promise((r,s)=>{e.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?r(o.target.result._value):(r(null),console.warn(`IDB: cannot read "${i}"`))},e.onerror=o=>{s(o)}})}write(i,t,e=!1){let r={_key:i,_value:t},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(r);return new Promise((n,l)=>{o.onsuccess=a=>{e||this._notifySubscribers(i),n(a.target.result)},o.onerror=a=>{l(a)}})}delete(i,t=!1){let r=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(i);return new Promise((s,o)=>{r.onsuccess=n=>{t||this._notifySubscribers(i),s(n)},r.onerror=n=>{o(n)}})}getAll(){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,r)=>{t.onsuccess=s=>{let o=s.target.result;e(o.map(n=>n._value))},t.onerror=s=>{r(s)}})}subscribe(i,t){this._subscriptionsMap[i]||(this._subscriptionsMap[i]=new Set);let e=this._subscriptionsMap[i];return e.add(t),{remove:()=>{e.delete(t),e.size||delete this._subscriptionsMap[i]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,ft.clear(this.name)}},ft=class{static get readyEventName(){return pt}static open(i=Di,t="store"){let e=i+"/"+t;return this._reg[e]||(this._reg[e]=new zi(i,t)),this._reg[e]}static clear(i){window.indexedDB.deleteDatabase(i);for(let t in this._reg)t.split("/")[0]===i&&delete this._reg[t]}};Ve(ft,"_reg",Object.create(null));var mt=i=>{if(typeof i!="string"||!i)return"";let t=i.trim();return t.startsWith("-/")?t=t.slice(2):t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,t.length-1)),t},xe=(...i)=>i.filter(t=>typeof t=="string"&&t).map(t=>mt(t)).join("/-/"),F=(...i)=>{let t=xe(...i);return t?`-/${t}/`:""};function Ee(i){let t=new URL(i),e=t.pathname+t.search+t.hash,r=e.lastIndexOf("http"),s=e.lastIndexOf("/"),o="";return r>=0?o=e.slice(r):s>=0&&(o=e.slice(s+1)),o}function Ce(i){let t=new URL(i),{pathname:e}=t,r=e.indexOf("/"),s=e.indexOf("/",r+1);return e.substring(r+1,s)}function Xe(i){let t=gt(i),e=new URL(t),r=e.pathname.indexOf("/-/");return r===-1?"":e.pathname.substring(r).slice(1)}function _t(i){return Xe(i).split("/-/").filter(Boolean).map(e=>mt(e))}function gt(i){let t=new URL(i),e=Ee(i),r=bt(e)?yt(e).pathname:e;return t.pathname=t.pathname.replace(r,""),t.search="",t.hash="",t.toString()}function bt(i){return i.startsWith("http")}function yt(i){let t=new URL(i);return{pathname:t.origin+t.pathname||"",search:t.search||"",hash:t.hash||""}}var z=(i,t,e)=>{let r=new URL(gt(i));if(e=e||Ee(i),r.pathname.startsWith("//")&&(r.pathname=r.pathname.replace("//","/")),bt(e)){let s=yt(e);r.pathname=r.pathname+(t||"")+(s.pathname||""),r.search=s.search,r.hash=s.hash}else r.pathname=r.pathname+(t||"")+(e||"");return r.toString()},Ke=(i,t)=>{let e=new URL(i);return e.pathname=t+"/",e.toString()};var Ge=(i,t=",")=>i.trim().split(t).map(e=>e.trim()).filter(e=>e.length>0);var k=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:!1,flip:!1,crop:void 0}),wt=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function ji(i,t){if(typeof t=="number"){let e=t;return k[i]!==e?`${i}/${e}`:""}if(typeof t=="boolean"){let e=t;return k[i]!==e?`${i}`:""}if(i==="filter"&&t){let{name:e,amount:r}=t;return k.filter===r?"":`${i}/${e}/${r}`}if(i==="crop"&&t){let{dimensions:e,coords:r}=t;return`${i}/${e.join("x")}/${r.join(",")}`}return""}function X(i){return xe(...wt.filter(t=>typeof i[t]!="undefined"&&i[t]!==null).map(t=>{let e=i[t];return ji(t,e)}).filter(t=>!!t))}var Te=xe("format/auto","progressive/yes"),j=([i])=>typeof i!="undefined"?Number(i):void 0,vt=()=>!0,Bi=([i,t])=>({name:i,amount:typeof t!="undefined"?Number(t):100}),Vi=([i,t])=>{if(!/\d+x\d+/.test(i)||!/\d+,\d+/.test(t))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:Ge(i,"x").map(Number),coords:Ge(t).map(Number)}},Hi=Object.freeze({enhance:j,brightness:j,exposure:j,gamma:j,contrast:j,saturation:j,vibrance:j,warmth:j,filter:Bi,mirror:vt,flip:vt,rotate:j,crop:Vi});function xt(i){let t={};for(let e of i){let[r,...s]=e.split("/");if(!wt.includes(r))continue;let o=r,n=Hi[o];try{let l=n(s);t[o]=l}catch(l){console.warn([`Failed to parse URL operation "${e}". It will be ignored.`,l instanceof Error?`Error message: "${l.message}"`:l,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
`))}}return t}var y=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),A=[y.CROP,y.TUNING,y.FILTERS],Et=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],Ct=["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"],Tt=["rotate","mirror","flip"],M=Object.freeze({brightness:{zero:k.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:k.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:k.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:k.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:k.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:k.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:k.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:k.enhance,range:[0,100],keypointsNumber:1},filter:{zero:k.filter,range:[0,100],keypointsNumber:1}});var At=i=>i?i.split(",").map(t=>t.trim()):[],Ae=i=>i?i.join(","):"";var Xi="https://ucarecdn.com",Ki="https://upload.uploadcare.com",Gi="https://social.uploadcare.com",I={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",cloudImageEditorTabs:Ae(A),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Xi,baseUrl:Ki,socialBaseUrl:Gi,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:1,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[]};var Qr=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created"}),Se=class{constructor(t){p(this,"_timeoutStore",new Map);p(this,"_targets",new Set);p(this,"_debugPrint",null);this._debugPrint=t}bindTarget(t){this._targets.add(t)}unbindTarget(t){this._targets.delete(t)}_dispatch(t,e){var r;for(let s of this._targets)s.dispatchEvent(new CustomEvent(t,{detail:e}));(r=this._debugPrint)==null||r.call(this,()=>{let s=e&&typeof e=="object"?{...e}:e;return[`event "${t}"`,s]})}emit(t,e,{debounce:r}={}){if(typeof r!="number"&&!r){this._dispatch(t,typeof e=="function"?e():e);return}this._timeoutStore.has(t)&&window.clearTimeout(this._timeoutStore.get(t));let s=typeof r=="number"?r:20,o=window.setTimeout(()=>{this._dispatch(t,typeof e=="function"?e():e),this._timeoutStore.delete(t)},s);this._timeoutStore.set(t,o)}};function O(i,t){let e,r=(...s)=>{clearTimeout(e),e=setTimeout(()=>i(...s),t)};return r.cancel=()=>{clearTimeout(e)},r}var St="--uploadcare-blocks-window-height",q=class{static registerClient(t){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(t)}static unregisterClient(t){this.clientsRegistry.delete(t),this.clientsRegistry.size===0&&this.detachTracker()}static attachTracker(){window.addEventListener("resize",this.flush,{passive:!0,capture:!0}),this.flush()}static detachTracker(){window.removeEventListener("resize",this.flush,{capture:!0}),document.documentElement.style.removeProperty(St)}};p(q,"clientsRegistry",new Set),p(q,"flush",O(()=>{document.documentElement.style.setProperty(St,`${window.innerHeight}px`)},100));var $t=i=>{var r;let t=new Intl.Locale(i),e="ltr";return typeof t.getTextInfo=="function"&&t.getTextInfo().direction?e=t.getTextInfo().direction:"textInfo"in t&&((r=t.textInfo)!=null&&r.direction)&&(e=t.textInfo.direction),e};var kt=(i,t)=>new Intl.PluralRules(i).select(t);var Wi=i=>i,We="{{",Lt="}}",Ot="plural:";function qe(i,t,e={}){var n;let{openToken:r=We,closeToken:s=Lt,transform:o=Wi}=e;for(let l in t){let a=(n=t[l])==null?void 0:n.toString();i=i.replaceAll(r+l+s,typeof a=="string"?o(a):a)}return i}function It(i){let t=[],e=i.indexOf(We);for(;e!==-1;){let r=i.indexOf(Lt,e),s=i.substring(e+2,r);if(s.startsWith(Ot)){let o=i.substring(e+2,r).replace(Ot,""),n=o.substring(0,o.indexOf("(")),l=o.substring(o.indexOf("(")+1,o.indexOf(")"));t.push({variable:s,pluralKey:n,countVariable:l})}e=i.indexOf(We,r)}return t}var Pt=({element:i,attribute:t,onSuccess:e,onTimeout:r,timeout:s=300})=>{let o=i.getAttribute(t);if(o!==null){e(o);return}let n=new MutationObserver(c=>{let u=c[c.length-1];a(u)});n.observe(i,{attributes:!0,attributeFilter:[t]});let l=setTimeout(()=>{n.disconnect(),r()},s),a=c=>{let u=i.getAttribute(t);c.type==="attributes"&&c.attributeName===t&&u!==null&&(clearTimeout(l),n.disconnect(),e(u))}};var Mt=()=>({});var ae={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"Selected:","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-instagram":"Instagram","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"Onedrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error ocurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}"};var $e=new Map,Ye=new Map,Rt=(i,t)=>{$e.has(i)&&console.log(`Locale ${i} is already defined. Overwriting...`),$e.set(i,{...ae,...t})},qi=(i,t)=>{Ye.set(i,t)},Yi=(i,t)=>{typeof t=="function"?qi(i,t):Rt(i,t)},Nt=async i=>{if(!$e.has(i)){if(!Ye.has(i))throw new Error(`Locale ${i} is not defined`);let e=await Ye.get(i)();Rt(i,e)}return $e.get(i)};Yi("en",ae);var B=i=>`*l10n/${i}`,Zi="en",ke=class{constructor(t){p(this,"_blockInstance",null);p(this,"_localeName","");p(this,"_callbacks",new Set);p(this,"_boundBlocks",new Map);this._blockInstance=t;for(let[e,r]of Object.entries(ae))this._blockInstance.add(B(e),r,!1);setTimeout(()=>{t.subConfigValue("localeName",async e=>{var o;if(!this._blockInstance||!e)return;this._localeName=e;let r=await Nt(e);if(e!==Zi&&this._localeName!==e)return;let s=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[e];for(let[n,l]of Object.entries(r)){let a=s==null?void 0:s[n];this._blockInstance.add(B(n),a!=null?a:l,!0);for(let c of this._callbacks)c()}}),t.subConfigValue("localeDefinitionOverride",e=>{var s;if(!e)return;let r=e[this._localeName];if(r)for(let[o,n]of Object.entries(r)){(s=this._blockInstance)==null||s.add(B(o),n,!0);for(let l of this._callbacks)l()}})})}onLocaleChange(t){let e=O(t,0);return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}bindL10n(t,e,r){var o,n,l;t.$[e]=r(),this._boundBlocks.has(t)||this._boundBlocks.set(t,new Map),(n=(o=this._boundBlocks.get(t))==null?void 0:o.get(e))==null||n();let s=this.onLocaleChange(()=>{t.$[e]=r()});(l=this._boundBlocks.get(t))==null||l.set(e,s)}destroyL10nBindings(t){let e=this._boundBlocks.get(t);if(e){for(let r of e.values())r();this._boundBlocks.delete(t)}}destroy(){this._callbacks.clear()}};function Ut(i,t){[...i.querySelectorAll("[l10n]")].forEach(e=>{let r=e.getAttribute("l10n");if(!r)return;let s="textContent",o=!1;if(r.includes(":")){let a=r.split(":");s=a[0],r=a[1],s.startsWith("@")&&(s=s.slice(1),o=!0)}let n=r;t.has(n)&&t.sub(n,a=>{if(!a)return;t.l10nProcessorSubs.has(n)||t.l10nProcessorSubs.set(n,new Set);let c=t.l10nProcessorSubs.get(n);c==null||c.forEach(d=>{d.remove(),c.delete(d),t.allSubs.delete(d)});let u=B(a).replace("*","");t.nodeCtx.has(u)||t.nodeCtx.add(u,a);let h=t.nodeCtx.sub(u,()=>{e[s]=t.l10n(a)});c==null||c.add(h),t.allSubs.add(h),e.removeAttribute("l10n")});let l=B(r);t.has(l)||t.add(l,""),t.sub(l,()=>{r=r,o?e.setAttribute(s,t.l10n(r)):e[s]=t.l10n(r)}),e.removeAttribute("l10n")})}var S=i=>`*cfg/${i}`;var Qi={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function ce(i,t){t.tabIndex=0,t.focus(),i.tabIndex=-1}function Ze(i){let t=i.role||i.type||i.tagName;if(!t)return null;let e=Qi[t.toLowerCase()];if(!e)return null;for(let r of e){let s=i.closest(`[role=${r}]`);if(s)return s}}function Qe(i,t){return t.role==="toolbar"?Ji(t):t.querySelectorAll(`[role=${i.role}]`)}function Ji(i){return[...i.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function er(i){let t=i.getAttribute("aria-orientation");if(t==="vertical")return!1;if(t==="horizontal")return!0;let e=i.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function Dt(i){return t=>{let e=!1,r=(i==null?void 0:i.searchDelayMs)||300,s=0,o="";function n(h){let d=Ze(h.target);if(!d){l();return}let m=Qe(h.target,d),g=Array.from(m).indexOf(h.target),C="ArrowDown",T="ArrowUp";if(er(d)&&(t.document.dir==="rtl"?(C="ArrowLeft",T="ArrowRight"):(C="ArrowRight",T="ArrowLeft")),h.key===C)h.preventDefault(),ce(h.target,m[g+1]||m[0]);else if(h.key===T)h.preventDefault(),ce(h.target,m[g-1]||m[m.length-1]);else if(h.key==="Home")h.preventDefault(),ce(h.target,m[0]);else if(h.key==="End")h.preventDefault(),ce(h.target,m[m.length-1]);else if(h.key.length===1&&d.role!=="tablist"){let $=Date.now();$-s<=r?o+=h.key.toLowerCase():o=h.key.toLowerCase(),s=$;let W=Array.from(m).find(fi=>{var ot,nt,lt;return(lt=(nt=(ot=fi.textContent)==null?void 0:ot.trim())==null?void 0:nt.toLowerCase())==null?void 0:lt.startsWith(o)});W&&(h.preventDefault(),ce(h.target,W))}}function l(){e=!1,t.removeEventListener("keydown",n)}function a(h){let d=Ze(h.target);if(d){e||(e=!0,t.addEventListener("keydown",n));let m=Qe(h.target,d);for(let g of m)g!==h.target&&g.setAttribute("tabindex",-1)}else e&&l()}function c(h){(!h.relatedTarget||h.relatedTarget===t.document)&&l()}function u(h){let d=Ze(h.target);if(d){let m=Qe(h.target,d);for(let g of m)g!==h.target&&g.setAttribute("tabindex",-1);h.target.setAttribute("tabindex",0)}}return t.addEventListener("click",u),t.addEventListener("focusin",a),t.addEventListener("focusout",c),()=>{l(),t.removeEventListener("click",u),t.removeEventListener("focusin",a),t.removeEventListener("focusout",c)}}}function Ft(){return i=>{let t,e;function r(o){if(o.target.getAttribute("aria-hidden")==="true"){t=o.target,t.setAttribute("aria-hidden","false"),e=t.hidden,e&&(t.hidden=!1);let n=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function s(o){t&&t.contains(o.target)&&(!o.relatedTarget||!t.contains(o.relatedTarget))&&(o.target.tabIndex=-1,t.setAttribute("aria-hidden","true"),e&&(t.hidden=!0),t=null)}return i.addEventListener("keyuxJump",r),i.addEventListener("focusout",s),()=>{i.removeEventListener("keyuxJump",r),i.removeEventListener("focusout",s)}}}function zt(){return i=>{let t=[];function e(c){let u=i.document.activeElement;u&&u!==i.document.body&&t.push(new WeakRef(u)),c.focus({focusVisible:!0})}function r(){let c=t.pop();if(!c){i.document.activeElement.blur();return}let u=c.deref();u&&u.isConnected?u.focus():r()}let s=0,o;function n(c){clearInterval(o);let u=c.getAttribute("aria-controls");u&&(o=setInterval(()=>{if(s++>50){clearInterval(o);return}let h=i.document.getElementById(u);if(h){let d=h.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');d&&(clearInterval(o),h.dispatchEvent(new i.CustomEvent("keyuxJump",{bubbles:!0})),e(d))}},50))}function l(c){c.clientX===0&&c.clientY===0&&n(c.target)}function a(c){c.target.tagName==="INPUT"&&c.key==="Enter"&&n(c.target),c.key==="Escape"&&r()}return i.addEventListener("click",l),i.addEventListener("keydown",a),()=>{i.removeEventListener("click",l),i.removeEventListener("keydown",a)}}}function jt(i){let t,e=i.split(" ");function r(){t&&t.classList.remove(...e)}function s(o){o.clientX===0&&o.clientY===0&&(r(),o.target.classList.add(...e),t=o.target)}return o=>(o.addEventListener("keyup",r),o.addEventListener("click",s),()=>{o.removeEventListener("keyup",r),o.removeEventListener("click",s)})}function Bt(i,t){let e=t.map(r=>r(i));return()=>{e.forEach(r=>r())}}var Je=class{constructor(){p(this,"_listeners",new Map);p(this,"_scope",[])}addEventListener(t,e){let r=s=>{let o=s.target;o&&this._scope.some(n=>n===s.target||n.contains(o))&&e(s)};this._listeners.set(e,r),window.addEventListener(t,r)}removeEventListener(t,e){let r=this._listeners.get(e);r&&window.removeEventListener(t,r),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(t){this._scope.push(t)}destroy(){this._scope=[],this._listeners.forEach((t,e)=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",t),this._listeners.delete(e)})}},Oe=class{constructor(){p(this,"_destroyKeyUX");p(this,"_scopedWindow");this._scopedWindow=new Je,this._destroyKeyUX=Bt(this._scopedWindow,[Dt(),jt("is-pressed"),zt(),Ft()])}registerBlock(t){this._scopedWindow.registerScope(t)}destroy(){var t;(t=this._destroyKeyUX)==null||t.call(this),this._scopedWindow.destroy()}};var tr="uc-",b=class extends He{constructor(){super();p(this,"requireCtxName",!1);p(this,"activityType",null);p(this,"init$",Mt());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(Ut)}l10n(e,r={}){if(!e)return"";let s=this.$[B(e)]||e,o=It(s);for(let l of o)r[l.variable]=this.pluralize(l.pluralKey,Number(r[l.countVariable]));return qe(s,r)}pluralize(e,r){let s=this.l10n("locale-id")||"en",o=kt(s,r);return this.l10n(`${e}__${o}`)}bindL10n(e,r){var s;(s=this.localeManager)==null||s.bindL10n(this,e,r)}emit(e,r,s){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&o.emit(e,r,s)}hasBlockInCtx(e){for(let r of this.blocksRegistry)if(e(r))return!0;return!1}setOrAddState(e,r){this.add$({[e]:r},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(r=>{this.setAttribute(r,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?Pt({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),q.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),q.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Se(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new ke(this)),this.has("*a11y")||this.add("*a11y",new Oe),this.sub(B("locale-id"),r=>{let s=$t(r);this.style.direction=s==="ltr"?"":s})}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}destroyCallback(){var r;super.destroyCallback();let e=this.blocksRegistry;e==null||e.delete(this),(r=this.localeManager)==null||r.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,v.deleteCtx(this),(e==null?void 0:e.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e;v.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.destroy()}async proxyUrl(e){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(e,{uuid:Ce(e),cdnUrlModifiers:Xe(e),fileName:Ee(e)})}catch(r){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",r),e}return this.cfg.secureDeliveryProxy?qe(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(r,s,o)=>{if(typeof s!="string")return!1;let n=S(s);return this.has(n)||this.add(n,I[s]),this.$[n]=o,!0},get:(r,s)=>{let o=S(s);return this.has(o)||this.add(o,I[s]),this.$[S(s)]}})}return this.__cfgProxy}subConfigValue(e,r){let s=S(e);this.has(s)||this.add(s,I[e]),this.sub(s,r)}debugPrint(...e){if(!this.cfg.debug)return;let r=e;if(typeof(e==null?void 0:e[0])=="function"){let s=e[0];r=s()}console.log(`[${this.ctxName}]`,...r)}static reg(e){if(!e){super.reg();return}e.startsWith(tr)&&super.reg(e)}};p(b,"StateConsumerScope",null),p(b,"styleAttrs",[]);var R="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function Vt(...i){return i.reduce((t,e)=>{if(typeof e=="string")return t[e]=!0,t;for(let r of Object.keys(e))t[r]=e[r];return t},{})}function w(...i){let t=Vt(...i);return Object.keys(t).reduce((e,r)=>(t[r]&&e.push(r),e),[]).join(" ")}function Ht(i,...t){let e=Vt(...t);for(let r of Object.keys(e))i.classList.toggle(r,e[r])}var Xt=i=>{if(!i)return[];let[t,e]=i.split(":").map(Number);if(!Number.isFinite(t)||!Number.isFinite(e)){console.error(`Invalid crop preset: ${i}`);return}return[{type:"aspect-ratio",width:t,height:e}]};var Kt=i=>{if(!i)return A;let t=At(i).filter(e=>A.includes(e));return t.length===0?A:t};function Gt(i){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*tabList":A,"*tabId":y.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:R,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:Ae(A),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let t=i.querySelectorAll("img");for(let e of t){let r=e.src;e.src=R,e.src=r}i.$["*networkProblems"]=!1},"*on.apply":t=>{if(!t)return;let e=i.$["*originalUrl"],r=F(X(t),"preview"),s=z(e,r),o={originalUrl:e,cdnUrlModifiers:r,cdnUrl:s,transformations:t};i.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),i.remove()},"*on.cancel":()=>{i.remove(),i.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Wt="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5