UNPKG

@uploadcare/file-uploader

Version:

Building blocks for Uploadcare products integration

29 lines 295 kB
/** * @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. * */ "use strict";var UC=(()=>{var $t=Object.defineProperty;var Sa=Object.getOwnPropertyDescriptor;var Ia=Object.getOwnPropertyNames;var Oa=Object.getPrototypeOf,$a=Object.prototype.hasOwnProperty;var ka=Reflect.get;var Ma=(r,t,e)=>t in r?$t(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var n=(r,t)=>$t(r,"name",{value:t,configurable:!0});var La=(r,t)=>{for(var e in t)$t(r,e,{get:t[e],enumerable:!0})},Pa=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ia(t))!$a.call(r,s)&&s!==e&&$t(r,s,{get:()=>t[s],enumerable:!(i=Sa(t,s))||i.enumerable});return r};var Ua=r=>Pa($t({},"__esModule",{value:!0}),r);var d=(r,t,e)=>Ma(r,typeof t!="symbol"?t+"":t,e);var q=(r,t,e)=>ka(Oa(r),e,t);var Pu={};La(Pu,{ActivityBlock:()=>b,ActivityHeader:()=>ps,BaseComponent:()=>be,Block:()=>y,BtnUi:()=>xt,CameraSource:()=>Yt,CloudImageEditor:()=>_s,CloudImageEditorActivity:()=>us,CloudImageEditorBlock:()=>pe,Config:()=>jn,Copyright:()=>fs,CropFrame:()=>ei,Data:()=>T,DropArea:()=>ft,EditorCropButtonControl:()=>yt,EditorFilterControl:()=>Ge,EditorImageCropper:()=>ri,EditorImageFader:()=>ls,EditorOperationControl:()=>wt,EditorScroller:()=>oi,EditorSlider:()=>ii,EditorToolbar:()=>ni,ExternalSource:()=>ui,ExternalUploadSource:()=>Ne,FileItem:()=>vt,FileUploaderInline:()=>fi,FileUploaderMinimal:()=>pi,FileUploaderRegular:()=>Tt,FormInput:()=>hs,Icon:()=>lt,Img:()=>ts,LineLoaderUi:()=>ai,Modal:()=>qt,ModalEvents:()=>D,PACKAGE_NAME:()=>De,PACKAGE_VERSION:()=>Fe,PresenceToggle:()=>li,ProgressBar:()=>Qt,ProgressBarCommon:()=>Jt,Select:()=>di,SimpleBtn:()=>dt,SliderUi:()=>ci,SolutionBlock:()=>le,SourceBtn:()=>mt,SourceList:()=>is,Spinner:()=>hi,StartFrom:()=>Wt,Thumb:()=>At,UID:()=>Pe,UploadCtxProvider:()=>pa,UploadList:()=>Zt,UploadSource:()=>L,UploaderBlock:()=>$,UrlSource:()=>Kt,defineComponents:()=>vs,defineLocale:()=>qs,loadFileUploaderFrom:()=>Ea,toKebabCase:()=>nt});var Ra=Object.defineProperty,Da=n((r,t,e)=>t in r?Ra(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,"__defNormalProp"),Cs=n((r,t,e)=>(Da(r,typeof t!="symbol"?t+"":t,e),e),"__publicField");function Fa(r){let t=n(e=>{var i;for(let s in e)((i=e[s])==null?void 0:i.constructor)===Object&&(e[s]=t(e[s]));return{...e}},"clone");return t(r)}n(Fa,"cloneObj");var Xe,T=(Xe=class{constructor(t){t.constructor===Object?this.store=Fa(t):(this._storeIsProxy=!0,this.store=t),this.callbackMap=Object.create(null)}static warn(t,e){console.warn(`Symbiote Data: cannot ${t}. Prop name: `+e)}read(t){return!this._storeIsProxy&&!this.store.hasOwnProperty(t)?(T.warn("read",t),null):this.store[t]}has(t){return this._storeIsProxy?this.store[t]!==void 0:this.store.hasOwnProperty(t)}add(t,e,i=!1){!i&&Object.keys(this.store).includes(t)||(this.store[t]=e,this.notify(t))}pub(t,e){if(!this._storeIsProxy&&!this.store.hasOwnProperty(t)){T.warn("publish",t);return}this.store[t]=e,this.notify(t)}multiPub(t){for(let e in t)this.pub(e,t[e])}notify(t){this.callbackMap[t]&&this.callbackMap[t].forEach(e=>{e(this.store[t])})}sub(t,e,i=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(t)?(T.warn("subscribe",t),null):(this.callbackMap[t]||(this.callbackMap[t]=new Set),this.callbackMap[t].add(e),i&&e(this.store[t]),{remove:n(()=>{this.callbackMap[t].delete(e),this.callbackMap[t].size||delete this.callbackMap[t]},"remove"),callback:e})}static registerCtx(t,e=Symbol()){let i=T.globalStore.get(e);return i?console.warn('State: context UID "'+e+'" already in use'):(i=new T(t),T.globalStore.set(e,i)),i}static deleteCtx(t){T.globalStore.delete(t)}static getCtx(t,e=!0){return T.globalStore.get(t)||(e&&console.warn('State: wrong context UID - "'+t+'"'),null)}},n(Xe,"Data"),Xe);T.globalStore=new Map;var E=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"}),yo="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Na=yo.length-1,qe,Pe=(qe=class{static generate(t="XXXXXXXXX-XXX"){let e="";for(let i=0;i<t.length;i++)e+=t[i]==="-"?t[i]:yo.charAt(Math.random()*Na);return e}},n(qe,"UID"),qe);function wo(r,t,e){let i=!0,s,o=t.split(".");return o.forEach((a,l)=>{l<o.length-1?r=r[a]:s=a}),r?r[s]=e:i=!1,i}n(wo,"setNestedProp");function Va(r){return r.split("-").map((t,e)=>t&&e?t[0].toUpperCase()+t.slice(1):t).join("").split("_").map((t,e)=>t&&e?t.toUpperCase():t).join("")}n(Va,"kebabToCamel");function za(r,t){[...r.querySelectorAll(`[${E.REPEAT_ATTR}]`)].forEach(e=>{var a;let i=e.getAttribute(E.REPEAT_ITEM_TAG_ATTR),s;if(i&&(s=window.customElements.get(i)),!s){s=(a=class extends t.BaseComponent{constructor(){super(),i||(this.style.display="contents")}},n(a,"itemClass"),a);let l=e.innerHTML;s.template=l,s.reg(i)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(E.REPEAT_ATTR);t.sub(o,l=>{if(!l){for(;e.firstChild;)e.firstChild.remove();return}let c=[...e.children],u,p=n(h=>{h.forEach((m,g)=>{if(c[g])if(c[g].set$)setTimeout(()=>{c[g].set$(m)});else for(let _ in m)c[g][_]=m[_];else{u||(u=new DocumentFragment);let _=new s;Object.assign(_.init$,m),u.appendChild(_)}}),u&&e.appendChild(u);let f=c.slice(h.length,c.length);for(let m of f)m.remove()},"fillItems");if(l.constructor===Array)p(l);else if(l.constructor===Object){let h=[];for(let f in l){let m=l[f];Object.defineProperty(m,"_KEY_",{value:f,enumerable:!0}),h.push(m)}p(h)}else console.warn("Symbiote repeat data type error:"),console.log(l)}),e.removeAttribute(E.REPEAT_ATTR),e.removeAttribute(E.REPEAT_ITEM_TAG_ATTR)})}n(za,"repeatProcessor");var _o="__default__";function Ba(r,t){if(t.shadowRoot)return;let e=[...r.querySelectorAll("slot")];if(!e.length)return;let i={};e.forEach(s=>{let o=s.getAttribute("name")||_o;i[o]={slot:s,fr:document.createDocumentFragment()}}),t.initChildren.forEach(s=>{var o;let a=_o;s instanceof Element&&s.hasAttribute("slot")&&(a=s.getAttribute("slot"),s.removeAttribute("slot")),(o=i[a])==null||o.fr.appendChild(s)}),Object.values(i).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()})}n(Ba,"slotProcessor");function Ha(r,t){[...r.querySelectorAll(`[${E.EL_REF_ATTR}]`)].forEach(e=>{let i=e.getAttribute(E.EL_REF_ATTR);t.ref[i]=e,e.removeAttribute(E.EL_REF_ATTR)})}n(Ha,"refProcessor");function ja(r,t){[...r.querySelectorAll(`[${E.BIND_ATTR}]`)].forEach(e=>{let s=e.getAttribute(E.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let a=Va(o.name.replace("-",""));s.push(a+":"+o.value),e.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let a=o.split(":").map(p=>p.trim()),l=a[0],c;l.indexOf(E.ATTR_BIND_PRFX)===0&&(c=!0,l=l.replace(E.ATTR_BIND_PRFX,""));let u=a[1].split(",").map(p=>p.trim());for(let p of u){let h;p.startsWith("!!")?(h="double",p=p.replace("!!","")):p.startsWith("!")&&(h="single",p=p.replace("!","")),t.sub(p,f=>{h==="double"?f=!!f:h==="single"&&(f=!f),c?(f==null?void 0:f.constructor)===Boolean?f?e.setAttribute(l,""):e.removeAttribute(l):e.setAttribute(l,f):wo(e,l,f)||(e[E.SET_LATER_KEY]||(e[E.SET_LATER_KEY]=Object.create(null)),e[E.SET_LATER_KEY][l]=f)})}}),e.removeAttribute(E.BIND_ATTR)})}n(ja,"domSetProcessor");var mi="{{",kt="}}",Ga="skip-text";function Wa(r){let t,e=[],i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:n(s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(Ga))&&s.textContent.includes(mi)&&s.textContent.includes(kt)&&1},"acceptNode")});for(;t=i.nextNode();)e.push(t);return e}n(Wa,"getTextNodesWithTokens");var Xa=n(function(r,t){Wa(r).forEach(i=>{let s=[],o;for(;i.textContent.includes(kt);)i.textContent.startsWith(mi)?(o=i.textContent.indexOf(kt)+kt.length,i.splitText(o),s.push(i)):(o=i.textContent.indexOf(mi),i.splitText(o)),i=i.nextSibling;s.forEach(a=>{let l=a.textContent.replace(mi,"").replace(kt,"");a.textContent="",t.sub(l,c=>{a.textContent=c})})})},"txtNodesProcessor"),qa=[za,Ba,Ha,ja,Xa],gi="'",Qe='"',Za=/\\([0-9a-fA-F]{1,6} ?)/g;function Ka(r){return(r[0]===Qe||r[0]===gi)&&(r[r.length-1]===Qe||r[r.length-1]===gi)}n(Ka,"hasLeadingTrailingQuotes");function Ya(r){return(r[0]===Qe||r[0]===gi)&&(r=r.slice(1)),(r[r.length-1]===Qe||r[r.length-1]===gi)&&(r=r.slice(0,-1)),r}n(Ya,"trimQuotes");function Ja(r){let t="",e="";for(var i=0;i<r.length;i++){let s=r[i+1];r[i]==="\\"&&s==='"'?(t+='\\"',i++):r[i]==='"'&&e!=="\\"?t+='\\"':t+=r[i],e=r[i]}return t}n(Ja,"escapeQuotes");function Qa(r){let t=r;Ka(r)&&(t=Ya(t),t=t.replace(Za,(e,i)=>String.fromCodePoint(parseInt(i.trim(),16))),t=t.replaceAll(`\\ `,"\\n"),t=Ja(t),t=Qe+t+Qe);try{return JSON.parse(t)}catch{throw new Error(`Failed to parse CSS property value: ${t}. Original input: ${r}`)}}n(Qa,"parseCssPropertyValue");var vo=0,We=null,ge=null,Ze,Ee=(Ze=class extends HTMLElement{constructor(){super(),Cs(this,"updateCssData",()=>{var t;this.dropCssDataCache(),(t=this.__boundCssProps)==null||t.forEach(e=>{let i=this.getCssData(this.__extractCssName(e),!0);i!==null&&this.$[e]!==i&&(this.$[e]=i)})}),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 Ee}initCallback(){}__initCallback(){var t;this.__initialized||(this.__initialized=!0,(t=this.initCallback)==null||t.call(this))}render(t,e=this.renderShadow){let i;if((e||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let o=this.getAttribute(E.USE_TPL);if(o){let a=this.getRootNode(),l=(a==null?void 0:a.querySelector(o))||document.querySelector(o);l?t=l.content.cloneNode(!0):console.warn(`Symbiote template "${o}" is not found...`)}}if(this.processInnerHtml)for(let o of this.tplProcessors)o(this,this);if(t||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(t==null?void 0:t.constructor)===DocumentFragment)i=t;else if((t==null?void 0:t.constructor)===String){let o=document.createElement("template");o.innerHTML=t,i=o.content.cloneNode(!0)}else this.constructor.__tpl&&(i=this.constructor.__tpl.content.cloneNode(!0));for(let o of this.tplProcessors)o(i,this)}let s=n(()=>{i&&(e&&this.shadowRoot.appendChild(i)||this.appendChild(i)),this.__initCallback()},"addFr");if(this.constructor.__shadowStylesUrl){e=!0;let o=document.createElement("link");o.rel="stylesheet",o.href=this.constructor.__shadowStylesUrl,o.onload=s,this.shadowRoot.prepend(o)}else s()}addTemplateProcessor(t){this.tplProcessors.add(t)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=Pe.generate(),this.style.setProperty(E.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(E.CSS_CTX_PROP,!0)}get ctxName(){var t;let e=((t=this.getAttribute(E.CTX_NAME_ATTR))==null?void 0:t.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=e,e}get localCtx(){return this.__localCtx||(this.__localCtx=T.registerCtx({},this)),this.__localCtx}get nodeCtx(){return T.getCtx(this.ctxName,!1)||T.registerCtx({},this.ctxName)}static __parseProp(t,e){let i,s;if(t.startsWith(E.EXT_DATA_CTX_PRFX))i=e.nodeCtx,s=t.replace(E.EXT_DATA_CTX_PRFX,"");else if(t.includes(E.NAMED_DATA_CTX_SPLTR)){let o=t.split(E.NAMED_DATA_CTX_SPLTR);i=T.getCtx(o[0]),s=o[1]}else i=e.localCtx,s=t;return{ctx:i,name:s}}sub(t,e,i=!0){let s=n(a=>{this.isConnected&&e(a)},"subCb"),o=Ee.__parseProp(t,this);o.ctx.has(o.name)?this.allSubs.add(o.ctx.sub(o.name,s,i)):window.setTimeout(()=>{this.allSubs.add(o.ctx.sub(o.name,s,i))})}notify(t){let e=Ee.__parseProp(t,this);e.ctx.notify(e.name)}has(t){let e=Ee.__parseProp(t,this);return e.ctx.has(e.name)}add(t,e,i=!1){let s=Ee.__parseProp(t,this);s.ctx.add(s.name,e,i)}add$(t,e=!1){for(let i in t)this.add(i,t[i],e)}get $(){if(!this.__stateProxy){let t=Object.create(null);this.__stateProxy=new Proxy(t,{set:n((e,i,s)=>{let o=Ee.__parseProp(i,this);return o.ctx.pub(o.name,s),!0},"set"),get:n((e,i)=>{let s=Ee.__parseProp(i,this);return s.ctx.read(s.name)},"get")})}return this.__stateProxy}set$(t,e=!1){for(let i in t){let s=t[i];e||![String,Number,Boolean].includes(s==null?void 0:s.constructor)?this.$[i]=s:this.$[i]!==s&&(this.$[i]=s)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(E.CTX_OWNER_ATTR)&&this.getAttribute(E.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let t=this.constructor.__attrDesc;if(t)for(let e of Object.values(t))Object.keys(this.init$).includes(e)||(this.init$[e]="");for(let e in this.init$)if(e.startsWith(E.EXT_DATA_CTX_PRFX))this.nodeCtx.add(e.replace(E.EXT_DATA_CTX_PRFX,""),this.init$[e],this.__ctxOwner);else if(e.includes(E.NAMED_DATA_CTX_SPLTR)){let i=e.split(E.NAMED_DATA_CTX_SPLTR),s=i[0].trim(),o=i[1].trim();if(s&&o){let a=T.getCtx(s,!1);a||(a=T.registerCtx({},s)),a.add(o,this.init$[e])}}else this.localCtx.add(e,this.init$[e]);for(let e in this.cssInit$)this.bindCssData(e,this.cssInit$[e]);this.__dataCtxInitialized=!0}connectedCallback(){var t;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let e=(t=this.getAttribute(E.CTX_NAME_ATTR))==null?void 0:t.trim();if(e&&this.style.setProperty(E.CSS_CTX_PROP,`'${e}'`),this.__initDataCtx(),this[E.SET_LATER_KEY]){for(let i in this[E.SET_LATER_KEY])wo(this,i,this[E.SET_LATER_KEY][i]);delete this[E.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let i of qa)this.addTemplateProcessor(i);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let i=this.getRootNode();if(!i)return;if(i==null?void 0:i.querySelector(`link[${E.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let o=this.constructor.__rootStylesLink.cloneNode(!0);o.setAttribute(E.ROOT_STYLE_ATTR_NAME,this.constructor.is),o.onload=()=>{this.render()},i.nodeType===Node.DOCUMENT_NODE?i.head.appendChild(o):i.prepend(o)}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 t of this.allSubs)t.remove(),this.allSubs.delete(t);for(let t of this.tplProcessors)this.tplProcessors.delete(t);ge==null||ge.delete(this.updateCssData),ge!=null&&ge.size||(We==null||We.disconnect(),We=null,ge=null)},100)))}static reg(t,e=!1){t||(vo++,t=`${E.AUTO_TAG_PRFX}-${vo}`),this.__tag=t;let i=window.customElements.get(t);if(i){!e&&i!==this&&console.warn([`Element with tag name "${t}" 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(t,e?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(t){this.observedAttributes=Object.keys(t),this.__attrDesc=t}attributeChangedCallback(t,e,i){var s;if(e===i)return;let o=(s=this.constructor.__attrDesc)==null?void 0:s[t];o?this.__dataCtxInitialized?this.$[o]=i:this.init$[o]=i:this[t]=i}getCssData(t,e=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(t)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let i=this.__computedStyle.getPropertyValue(t).trim();try{this.__cssDataCache[t]=Qa(i)}catch{!e&&console.warn(`CSS Data error: ${t}`),this.__cssDataCache[t]=null}}return this.__cssDataCache[t]}__extractCssName(t){return t.split("--").map((e,i)=>i===0?"":e).join("--")}__initStyleAttrObserver(){ge||(ge=new Set),ge.add(this.updateCssData),We||(We=new MutationObserver(t=>{t[0].type==="attributes"&&ge.forEach(e=>{e()})}),We.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(t,e=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(t);let i=this.getCssData(this.__extractCssName(t),!0);i===null&&(i=e),this.add(t,i),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(t,e,i){let s="__"+t;this[s]=this[t],Object.defineProperty(this,t,{set:n(o=>{this[s]=o,i?window.setTimeout(()=>{e==null||e(o)}):e==null||e(o)},"set"),get:n(()=>this[s],"get")}),this[t]=this[s]}static set shadowStyles(t){let e=new Blob([t],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(e)}static set rootStyles(t){if(!this.__rootStylesLink){let e=new Blob([t],{type:"text/css"}),i=URL.createObjectURL(e),s=document.createElement("link");s.href=i,s.rel="stylesheet",this.__rootStylesLink=s}}},n(Ze,"_BaseComponent"),Ze),be=Ee;Cs(be,"template");var Ke,ws=(Ke=class{static _print(t){console.warn(t)}static setDefaultTitle(t){this.defaultTitle=t}static setRoutingMap(t){Object.assign(this.appMap,t);for(let e in this.appMap)!this.defaultRoute&&this.appMap[e].default===!0?this.defaultRoute=e:!this.errorRoute&&this.appMap[e].error===!0&&(this.errorRoute=e)}static set routingEventName(t){this.__routingEventName=t}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let t={route:null,options:{}};return window.location.search.split(this.separator).forEach(i=>{if(i.includes("?"))t.route=i.replace("?","");else if(i.includes("=")){let s=i.split("=");t.options[s[0]]=decodeURI(s[1])}else t.options[i]=!0}),t}static notify(){let t=this.readAddressBar(),e=this.appMap[t.route];if(e&&e.title&&(document.title=e.title),t.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!e&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e){this._print(`Route "${t.route}" not found...`);return}let i=new CustomEvent(ws.routingEventName,{detail:{route:t.route,options:Object.assign(e||{},t.options)}});window.dispatchEvent(i)}static reflect(t,e={}){let i=this.appMap[t];if(!i){this._print("Wrong route: "+t);return}let s="?"+t;for(let a in e)e[a]===!0?s+=this.separator+a:s+=this.separator+a+`=${e[a]}`;let o=i.title||this.defaultTitle||"";window.history.pushState(null,o,s),document.title=o}static applyRoute(t,e={}){this.reflect(t,e),this.notify()}static setSeparator(t){this._separator=t}static get separator(){return this._separator||"&"}static createRouterData(t,e){this.setRoutingMap(e);let i=T.registerCtx({route:null,options:null,title:null},t);return window.addEventListener(this.routingEventName,s=>{var o;i.multiPub({route:s.detail.route,options:s.detail.options,title:((o=s.detail.options)==null?void 0:o.title)||this.defaultTitle||""})}),ws.notify(),this.initPopstateListener(),i}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}},n(Ke,"AppRouter"),Ke);ws.appMap=Object.create(null);function Mt(r,t){for(let e in t)e.includes("-")?r.style.setProperty(e,t[e]):r.style[e]=t[e]}n(Mt,"applyStyles");function el(r,t){for(let e in t)t[e].constructor===Boolean?t[e]?r.setAttribute(e,""):r.removeAttribute(e):r.setAttribute(e,t[e])}n(el,"applyAttributes");function xs(r={tag:"div"}){let t=document.createElement(r.tag);if(r.attributes&&el(t,r.attributes),r.styles&&Mt(t,r.styles),r.properties)for(let e in r.properties)t[e]=r.properties[e];return r.processors&&r.processors.forEach(e=>{e(t)}),r.children&&r.children.forEach(e=>{let i=xs(e);t.appendChild(i)}),t}n(xs,"create");var Co="idb-store-ready",tl="symbiote-db",il="symbiote-idb-update_",Ye,sl=(Ye=class{_notifyWhenReady(t=null){window.dispatchEvent(new CustomEvent(Co,{detail:{dbName:this.name,storeName:this.storeName,event:t}}))}get _updEventName(){return il+this.name}_getUpdateEvent(t){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:t}})}_notifySubscribers(t){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,t),window.dispatchEvent(this._getUpdateEvent(t))}constructor(t,e){this.name=t,this.storeName=e,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=i=>{this.db=i.target.result,this.objStore=this.db.createObjectStore(e,{keyPath:"_key"}),this.objStore.transaction.oncomplete=s=>{this._notifyWhenReady(s)}},this.request.onsuccess=i=>{this.db=i.target.result,this._notifyWhenReady(i)},this.request.onerror=i=>{console.error(i)},this._subscriptionsMap={},this._updateHandler=i=>{i.key===this.name&&this._subscriptionsMap[i.newValue]&&this._subscriptionsMap[i.newValue].forEach(async o=>{o(await this.read(i.newValue))})},this._localUpdateHandler=i=>{this._updateHandler(i.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(t){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(t);return new Promise((s,o)=>{i.onsuccess=a=>{var l;(l=a.target.result)!=null&&l._value?s(a.target.result._value):(s(null),console.warn(`IDB: cannot read "${t}"`))},i.onerror=a=>{o(a)}})}write(t,e,i=!1){let s={_key:t,_value:e},a=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(s);return new Promise((l,c)=>{a.onsuccess=u=>{i||this._notifySubscribers(t),l(u.target.result)},a.onerror=u=>{c(u)}})}delete(t,e=!1){let s=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(t);return new Promise((o,a)=>{s.onsuccess=l=>{e||this._notifySubscribers(t),o(l)},s.onerror=l=>{a(l)}})}getAll(){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((i,s)=>{e.onsuccess=o=>{let a=o.target.result;i(a.map(l=>l._value))},e.onerror=o=>{s(o)}})}subscribe(t,e){this._subscriptionsMap[t]||(this._subscriptionsMap[t]=new Set);let i=this._subscriptionsMap[t];return i.add(e),{remove:n(()=>{i.delete(e),i.size||delete this._subscriptionsMap[t]},"remove")}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,xo.clear(this.name)}},n(Ye,"DbInstance"),Ye),Je,xo=(Je=class{static get readyEventName(){return Co}static open(t=tl,e="store"){let i=t+"/"+e;return this._reg[i]||(this._reg[i]=new sl(t,e)),this._reg[i]}static clear(t){window.indexedDB.deleteDatabase(t);for(let e in this._reg)e.split("/")[0]===t&&delete this._reg[e]}},n(Je,"IDB"),Je);Cs(xo,"_reg",Object.create(null));var Ao=n(r=>{if(typeof r!="string"||!r)return"";let t=r.trim();return t.startsWith("-/")?t=t.slice(2):t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,t.length-1)),t},"normalizeCdnOperation"),bi=n((...r)=>r.filter(t=>typeof t=="string"&&t).map(t=>Ao(t)).join("/-/"),"joinCdnOperations"),B=n((...r)=>{let t=bi(...r);return t?`-/${t}/`:""},"createCdnUrlModifiers");function _i(r){let t=new URL(r),e=t.pathname+t.search+t.hash,i=e.lastIndexOf("http"),s=e.lastIndexOf("/"),o="";return i>=0?o=e.slice(i):s>=0&&(o=e.slice(s+1)),o}n(_i,"extractFilename");function vi(r){let t=new URL(r),{pathname:e}=t,i=e.indexOf("/"),s=e.indexOf("/",i+1);return e.substring(i+1,s)}n(vi,"extractUuid");function As(r){let t=To(r),e=new URL(t),i=e.pathname.indexOf("/-/");return i===-1?"":e.pathname.substring(i).slice(1)}n(As,"extractCdnUrlModifiers");function Eo(r){return As(r).split("/-/").filter(Boolean).map(e=>Ao(e))}n(Eo,"extractOperations");function To(r){let t=new URL(r),e=_i(r),i=So(e)?Io(e).pathname:e;return t.pathname=t.pathname.replace(i,""),t.search="",t.hash="",t.toString()}n(To,"trimFilename");function So(r){return r.startsWith("http")}n(So,"isFileUrl");function Io(r){let t=new URL(r);return{pathname:t.origin+t.pathname||"",search:t.search||"",hash:t.hash||""}}n(Io,"splitFileUrl");var F=n((r,t,e)=>{let i=new URL(To(r));if(e=e||_i(r),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),So(e)){let s=Io(e);i.pathname=i.pathname+(t||"")+(s.pathname||""),i.search=s.search,i.hash=s.hash}else i.pathname=i.pathname+(t||"")+(e||"");return i.toString()},"createCdnUrl"),Te=n((r,t)=>{let e=new URL(r);return e.pathname=t+"/",e.toString()},"createOriginalUrl");var V=n((r,t=",")=>r.trim().split(t).map(e=>e.trim()).filter(e=>e.length>0),"stringToArray");var J=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}),$o=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function rl(r,t){if(typeof t=="number"){let e=t;return J[r]!==e?`${r}/${e}`:""}if(typeof t=="boolean"){let e=t;return J[r]!==e?`${r}`:""}if(r==="filter"&&t){let{name:e,amount:i}=t;return J.filter===i?"":`${r}/${e}/${i}`}if(r==="crop"&&t){let{dimensions:e,coords:i}=t;return`${r}/${e.join("x")}/${i.join(",")}`}return""}n(rl,"transformationToStr");function Se(r){return bi(...$o.filter(t=>typeof r[t]!="undefined"&&r[t]!==null).map(t=>{let e=r[t];return rl(t,e)}).filter(t=>!!t))}n(Se,"transformationsToOperations");var yi=bi("format/auto","progressive/yes"),_e=n(([r])=>typeof r!="undefined"?Number(r):void 0,"asNumber"),Oo=n(()=>!0,"asBoolean"),ol=n(([r,t])=>({name:r,amount:typeof t!="undefined"?Number(t):100}),"asFilter"),nl=n(([r,t])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(t))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:V(r,"x").map(Number),coords:V(t).map(Number)}},"asCrop"),al=Object.freeze({enhance:_e,brightness:_e,exposure:_e,gamma:_e,contrast:_e,saturation:_e,vibrance:_e,warmth:_e,filter:ol,mirror:Oo,flip:Oo,rotate:_e,crop:nl});function ko(r){let t={};for(let e of r){let[i,...s]=e.split("/");if(!$o.includes(i))continue;let o=i,a=al[o];try{let l=a(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}n(ko,"operationsToTransformations");var P=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),Z=[P.CROP,P.TUNING,P.FILTERS],Mo=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],Lo=["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"],Po=["rotate","mirror","flip"],ae=Object.freeze({brightness:{zero:J.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:J.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:J.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:J.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:J.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:J.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:J.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:J.enhance,range:[0,100],keypointsNumber:1},filter:{zero:J.filter,range:[0,100],keypointsNumber:1}});var K=n(r=>r?r.split(",").map(t=>t.trim()).filter(Boolean):[],"deserializeCsv"),ve=n(r=>r?r.join(","):"","serializeCsv");var ll="https://ucarecdn.com",cl="https://upload.uploadcare.com",ul="https://social.uploadcare.com",re={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",cloudImageEditorTabs:ve(Z),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:ll,baseUrl:cl,socialBaseUrl:ul,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,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:[],cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null};var k=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"}),Es=class Es{constructor(t){d(this,"_timeoutStore",new Map);d(this,"_targets",new Set);d(this,"_debugPrint",null);this._debugPrint=t}bindTarget(t){this._targets.add(t)}unbindTarget(t){this._targets.delete(t)}_dispatch(t,e){var i;for(let s of this._targets)s.dispatchEvent(new CustomEvent(t,{detail:e}));(i=this._debugPrint)==null||i.call(this,()=>{let s=e&&typeof e=="object"?{...e}:e;return[`event "${t}"`,s]})}emit(t,e,{debounce:i}={}){if(typeof i!="number"&&!i){this._dispatch(t,typeof e=="function"?e():e);return}this._timeoutStore.has(t)&&window.clearTimeout(this._timeoutStore.get(t));let s=typeof i=="number"?i:20,o=window.setTimeout(()=>{this._dispatch(t,typeof e=="function"?e():e),this._timeoutStore.delete(t)},s);this._timeoutStore.set(t,o)}};n(Es,"EventEmitter");var wi=Es;function M(r,t){let e,i=n((...s)=>{clearTimeout(e),e=setTimeout(()=>r(...s),t)},"debounced");return i.cancel=()=>{clearTimeout(e)},i}n(M,"debounce");var Uo="--uploadcare-blocks-window-height",Lt=class Lt{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(Uo)}};n(Lt,"WindowHeightTracker"),d(Lt,"clientsRegistry",new Set),d(Lt,"flush",M(()=>{document.documentElement.style.setProperty(Uo,`${window.innerHeight}px`)},100));var Pt=Lt;var Ro=n(r=>{var i;let t=new Intl.Locale(r),e="ltr";return typeof t.getTextInfo=="function"&&t.getTextInfo().direction?e=t.getTextInfo().direction:"textInfo"in t&&((i=t.textInfo)!=null&&i.direction)&&(e=t.textInfo.direction),e},"getLocaleDirection");var Ci=n((r,t)=>new Intl.PluralRules(r).select(t),"getPluralForm");var dl=n(r=>r,"DEFAULT_TRANSFORMER"),Ts="{{",Fo="}}",Do="plural:";function Ut(r,t,e={}){var a;let{openToken:i=Ts,closeToken:s=Fo,transform:o=dl}=e;for(let l in t){let c=(a=t[l])==null?void 0:a.toString();r=r.replaceAll(i+l+s,typeof c=="string"?o(c):c)}return r}n(Ut,"applyTemplateData");function No(r){let t=[],e=r.indexOf(Ts);for(;e!==-1;){let i=r.indexOf(Fo,e),s=r.substring(e+2,i);if(s.startsWith(Do)){let o=r.substring(e+2,i).replace(Do,""),a=o.substring(0,o.indexOf("(")),l=o.substring(o.indexOf("(")+1,o.indexOf(")"));t.push({variable:s,pluralKey:a,countVariable:l})}e=r.indexOf(Ts,i)}return t}n(No,"getPluralObjects");var Vo=n(({element:r,attribute:t,onSuccess:e,onTimeout:i,timeout:s=300})=>{let o=r.getAttribute(t);if(o!==null){e(o);return}let a=new MutationObserver(u=>{let p=u[u.length-1];c(p)});a.observe(r,{attributes:!0,attributeFilter:[t]});let l=setTimeout(()=>{a.disconnect(),i()},s),c=n(u=>{let p=r.getAttribute(t);u.type==="attributes"&&u.attributeName===t&&p!==null&&(clearTimeout(l),a.disconnect(),e(p))},"handleMutation")},"waitForAttribute");function zo(r){return Object.prototype.toString.call(r)==="[object Object]"}n(zo,"isObject");var hl=/\W|_/g;function pl(r){return r.split(hl).map((t,e)=>t.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+t.slice(1)).join("")}n(pl,"camelizeString");function Bo(r,{ignoreKeys:t}={ignoreKeys:[]}){return Array.isArray(r)?r.map(e=>Ce(e,{ignoreKeys:t})):r}n(Bo,"camelizeArrayItems");function Ce(r,{ignoreKeys:t}={ignoreKeys:[]}){if(Array.isArray(r))return Bo(r,{ignoreKeys:t});if(!zo(r))return r;let e={};for(let i of Object.keys(r)){let s=r[i];if(t.includes(i)){e[i]=s;continue}zo(s)?s=Ce(s,{ignoreKeys:t}):Array.isArray(s)&&(s=Bo(s,{ignoreKeys:t})),e[pl(i)]=s}return e}n(Ce,"camelizeKeys");var fl=n(r=>new Promise(t=>setTimeout(t,r)),"delay");function Ls({libraryName:r,libraryVersion:t,userAgent:e,publicKey:i="",integration:s=""}){let o="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:i,libraryName:r,libraryVersion:t,languageName:o,integration:s});let a=[r,t,i].filter(Boolean).join("/"),l=[o,s].filter(Boolean).join("; ");return`${a} (${l})`}n(Ls,"getUserAgent$1");var ml={factor:2,time:100};function gl(r,t=ml){let e=0;function i(s){let o=Math.round(t.time*t.factor**e);return s({attempt:e,retry:n(l=>fl(l!=null?l:o).then(()=>(e+=1,i(s))),"retry")})}return n(i,"runAttempt"),i(r)}n(gl,"retrier");var Ns=class Ns extends Error{};n(Ns,"UploadcareError");var Ue=Ns,Ai=class Ai extends Ue{constructor(e){super();d(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,Ai.prototype),this.originalProgressEvent=e}};n(Ai,"NetworkError");var et=Ai,Si=n((r,t)=>{r&&(r.aborted?Promise.resolve().then(t):r.addEventListener("abort",()=>t(),{once:!0}))},"onCancel"),Ei=class Ei extends Ue{constructor(e="Request canceled"){super(e);d(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,Ei.prototype)}};n(Ei,"CancelError");var Ie=Ei,bl=500,jo=n(({check:r,interval:t=bl,timeout:e,signal:i})=>new Promise((s,o)=>{let a,l;Si(i,()=>{a&&clearTimeout(a),o(new Ie("Poll cancelled"))}),e&&(l=setTimeout(()=>{a&&clearTimeout(a),o(new Ie("Timed out"))},e));let c=n(()=>{try{Promise.resolve(r(i)).then(u=>{u?(l&&clearTimeout(l),s(u)):a=setTimeout(c,t)}).catch(u=>{l&&clearTimeout(l),o(u)})}catch(u){l&&clearTimeout(l),o(u)}},"tick");a=setTimeout(c,0)}),"poll"),I={baseCDN:"https://ucarecdn.com",baseURL:"https://upload.uploadcare.com",maxContentLength:50*1024*1024,retryThrottledRequestMaxTimes:1,retryNetworkErrorMaxTimes:3,multipartMinFileSize:25*1024*1024,multipartChunkSize:5*1024*1024,multipartMinLastPartSize:1024*1024,maxConcurrentRequests:4,pollingTimeoutMilliseconds:1e4,pusherKey:"79ae88bd931ea68464d9"},Ii="application/octet-stream",Go="original",Oe=n(({method:r,url:t,data:e,headers:i={},signal:s,onProgress:o})=>new Promise((a,l)=>{let c=new XMLHttpRequest,u=(r==null?void 0:r.toUpperCase())||"GET",p=!1;c.open(u,t,!0),i&&Object.entries(i).forEach(h=>{let[f,m]=h;typeof m!="undefined"&&!Array.isArray(m)&&c.setRequestHeader(f,m)}),c.responseType="text",Si(s,()=>{p=!0,c.abort(),l(new Ie)}),c.onload=()=>{if(c.status!=200)l(new Error(`Error ${c.status}: ${c.statusText}`));else{let h={method:u,url:t,data:e,headers:i||void 0,signal:s,onProgress:o},f=c.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};f.forEach(function(x){let C=x.split(": "),v=C.shift(),w=C.join(": ");v&&typeof v!="undefined"&&(m[v]=w)});let g=c.response,_=c.status;a({request:h,data:g,headers:m,status:_})}},c.onerror=h=>{p||l(new et(h))},o&&typeof o=="function"&&(c.upload.onprogress=h=>{h.lengthComputable?o({isComputable:!0,value:h.loaded/h.total}):o({isComputable:!1})}),e?c.send(e):c.send()}),"request");function _l(r,...t){return r}n(_l,"identity");var vl=n(({name:r})=>r?[r]:[],"getFileOptions"),yl=_l,wl=n(()=>new FormData,"getFormData"),Wo=n(r=>!1,"isBuffer"),Oi=n(r=>typeof Blob!="undefined"&&r instanceof Blob,"isBlob"),$i=n(r=>typeof File!="undefined"&&r instanceof File,"isFile"),ki=n(r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&"uri"in r&&typeof r.uri=="string","isReactNativeAsset"),tt=n(r=>Oi(r)||$i(r)||Wo()||ki(r),"isFileData"),Cl=n(r=>typeof r=="string"||typeof r=="number"||typeof r=="undefined","isSimpleValue"),xl=n(r=>!!r&&typeof r=="object"&&!Array.isArray(r),"isObjectValue"),Al=n(r=>!!r&&typeof r=="object"&&"data"in r&&tt(r.data),"isFileValue");function Xo(r,t,e){if(Array.isArray(e))for(let i of e)Xo(r,`${t}[]`,i);else if(Al(e)){let{name:i,contentType:s}=e,o=yl(e.data,i,s!=null?s:Ii),a=vl({name:i,contentType:s});r.push([t,o,...a])}else if(xl(e))for(let[i,s]of Object.entries(e))typeof s!="undefined"&&r.push([`${t}[${i}]`,String(s)]);else Cl(e)&&e&&r.push([t,e.toString()])}n(Xo,"collectParams");function El(r){let t=[];for(let[e,i]of Object.entries(r))Xo(t,e,i);return t}n(El,"getFormDataParams");function Mi(r){let t=wl(),e=El(r);for(let i of e){let[s,o,...a]=i;t.append(s,o,...a)}return t}n(Mi,"buildFormData");var Ti=class Ti extends Ue{constructor(e,i,s,o,a){super();d(this,"code");d(this,"request");d(this,"response");d(this,"headers");this.name="UploadError",this.message=e,this.code=i,this.request=s,this.response=o,this.headers=a,Object.setPrototypeOf(this,Ti.prototype)}};n(Ti,"UploadError");var H=Ti,Tl=n(r=>{let t=new URLSearchParams;for(let[e,i]of Object.entries(r))i&&typeof i=="object"&&!Array.isArray(i)?Object.entries(i).filter(s=>{var o;return(o=s[1])!=null?o:!1}).forEach(s=>t.set(`${e}[${s[0]}]`,String(s[1]))):Array.isArray(i)?i.forEach(s=>{t.append(`${e}[]`,s)}):typeof i=="string"&&i?t.set(e,i):typeof i=="number"&&t.set(e,i.toString());return t.toString()},"buildSearchParams"),ye=n((r,t,e)=>{let i=new URL(r);return i.pathname=(i.pathname+t).replace("//","/"),e&&(i.search=Tl(e)),i.toString()},"getUrl"),Sl="6.14.1",Il="UploadcareUploadClient",Ol=Sl;function Re(r){return Ls({libraryName:Il,libraryVersion:Ol,...r})}n(Re,"getUserAgent");var $l="RequestThrottledError",Ho=15e3,kl=1e3;function Ml(r){let{headers:t}=r||{};if(!t||typeof t["retry-after"]!="string")return Ho;let e=parseInt(t["retry-after"],10);return Number.isFinite(e)?e*1e3:Ho}n(Ml,"getTimeoutFromThrottledRequest");function $e(r,t){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:i}=t;return gl(({attempt:s,retry:o})=>r().catch(a=>{if("response"in a&&(a==null?void 0:a.code)===$l&&s<e)return o(Ml(a));if(a instanceof et&&s<i)return o((s+1)*kl);throw a}))}n($e,"retryIfFailed");var qo=n(r=>{let t="";return(Oi(r)||$i(r)||ki(r))&&(t=r.type),t||Ii},"getContentType"),Zo=n(r=>{let t="";return $i(r)&&r.name?t=r.name:Oi(r)||Wo()?t="":ki(r)&&r.name&&(t=r.name),t||Go},"getFileName");function Ps(r){return typeof r=="undefined"||r==="auto"?"auto":r?"1":"0"}n(Ps,"getStoreValue");function Ll(r,{publicKey:t,fileName:e,contentType:i,baseURL:s=I.baseURL,secureSignature:o,secureExpire:a,store:l,signal:c,onProgress:u,source:p="local",integration:h,userAgent:f,retryThrottledRequestMaxTimes:m=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=I.retryNetworkErrorMaxTimes,metadata:_}){return $e(()=>Oe({method:"POST",url:ye(s,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Re({publicKey:t,integration:h,userAgent:f})},data:Mi({file:{data:r,name:e||Zo(r),contentType:i||qo(r)},UPLOADCARE_PUB_KEY:t,UPLOADCARE_STORE:Ps(l),signature:o,expire:a,source:p,metadata:_}),signal:c,onProgress:u}).then(({data:x,headers:C,request:v})=>{let w=Ce(JSON.parse(x));if("error"in w)throw new H(w.error.content,w.error.errorCode,v,w,C);return w}),{retryNetworkErrorMaxTimes:g,retryThrottledRequestMaxTimes:m})}n(Ll,"base");var Os;(function(r){r.Token="token",r.FileInfo="file_info"})(Os||(Os={}));function Pl(r,{publicKey:t,baseURL:e=I.baseURL,store:i,fileName:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,source:u="url",signal:p,integration:h,userAgent:f,retryThrottledRequestMaxTimes:m=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=I.retryNetworkErrorMaxTimes,metadata:_}){return $e(()=>Oe({method:"POST",headers:{"X-UC-User-Agent":Re({publicKey:t,integration:h,userAgent:f})},url:ye(e,"/from_url/",{jsonerrors:1,pub_key:t,source_url:r,store:Ps(i),filename:s,check_URL_duplicates:o?1:void 0,save_URL_duplicates:a?1:void 0,signature:l,expire:c,source:u,metadata:_}),signal:p}).then(({data:x,headers:C,request:v})=>{let w=Ce(JSON.parse(x));if("error"in w)throw new H(w.error.content,w.error.errorCode,v,w,C);return w}),{retryNetworkErrorMaxTimes:g,retryThrottledRequestMaxTimes:m})}n(Pl,"fromUrl");var Y;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(Y||(Y={}));var Ul=n(r=>"status"in r&&r.status===Y.Error,"isErrorResponse");function Rl(r,{publicKey:t,baseURL:e=I.baseURL,signal:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:a=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=I.retryNetworkErrorMaxTimes}={}){return $e(()=>Oe({method:"GET",headers:t?{"X-UC-User-Agent":Re({publicKey:t,integration:s,userAgent:o})}:void 0,url:ye(e,"/from_url/status/",{jsonerrors:1,token:r}),signal:i}).then(({data:c,headers:u,request:p})=>{let h=Ce(JSON.parse(c));if("error"in h&&!Ul(h))throw new H(h.error.content,h.error.errorCode,p,h,u);return h}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:a})}n(Rl,"fromUrlStatus");function Dl(r,{publicKey:t,baseURL:e=I.baseURL,jsonpCallback:i,secureSignature:s,secureExpire:o,signal:a,source:l,integration:c,userAgent:u,retryThrottledRequestMaxTimes:p=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"POST",headers:{"X-UC-User-Agent":Re({publicKey:t,integration:c,userAgent:u})},url:ye(e,"/group/",{jsonerrors:1}),data:Mi({files:r,callback:i,pub_key:t,signature:s,expire:o,source:l}),signal:a}).then(({data:f,headers:m,request:g})=>{let _=Ce(JSON.parse(f));if("error"in _)throw new H(_.error.content,_.error.errorCode,g,_,m);return _}),{retryNetworkErrorMaxTimes:h,retryThrottledRequestMaxTimes:p})}n(Dl,"group");function Ko(r,{publicKey:t,baseURL:e=I.baseURL,signal:i,source:s,integration:o,userAgent:a,retryThrottledRequestMaxTimes:l=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"GET",headers:{"X-UC-User-Agent":Re({publicKey:t,integration:o,userAgent:a})},url:ye(e,"/info/",{jsonerrors:1,pub_key:t,file_id:r,source:s}),signal:i}).then(({data:u,headers:p,request:h})=>{let f=Ce(JSON.parse(u));if("error"in f)throw new H(f.error.content,f.error.errorCode,h,f,p);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}n(Ko,"info");function Fl(r,{publicKey:t,contentType:e,fileName:i,multipartChunkSize:s=I.multipartChunkSize,baseURL:o="",secureSignature:a,secureExpire:l,store:c,signal:u,source:p="local",integration:h,userAgent:f,retryThrottledRequestMaxTimes:m=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=I.retryNetworkErrorMaxTimes,metadata:_}){return $e(()=>Oe({method:"POST",url:ye(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Re({publicKey:t,integration:h,userAgent:f})},data:Mi({filename:i||Go,size:r,content_type:e||Ii,part_size:s,UPLOADCARE_STORE:Ps(c),UPLOADCARE_PUB_KEY:t,signature:a,expire:l,source:p,metadata:_}),signal:u}).then(({data:x,headers:C,request:v})=>{let w=Ce(JSON.parse(x));if("error"in w)throw new H(w.error.content,w.error.errorCode,v,w,C);return w.parts=Object.keys(w.parts).map(R=>w.parts[Number(R)]),w}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:g})}n(Fl,"multipartStart");function Nl(r,t,{contentType:e,signal:i,onProgress:s,retryThrottledRequestMaxTimes:o=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"PUT",url:t,data:r,onProgress:s,signal:i,headers:{"Content-Type":e||Ii}}).then(l=>(s&&s({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:a})}n(Nl,"multipartUpload");function Vl(r,{publicKey:t,baseURL:e=I.baseURL,source:i="local",signal:s,integration:o,userAgent:a,retryThrottledRequestMaxTimes:l=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"POST",url:ye(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Re({publicKey:t,integration:o,userAgent:a})},data:Mi({uuid:r,UPLOADCARE_PUB_KEY:t,source:i}),signal:s}).then(({data:u,headers:p,request:h})=>{let f=Ce(JSON.parse(u));if("error"in f)throw new H(f.error.content,f.error.errorCode,h,f,p);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}n(Vl,"multipartComplete");function Us(r,{publicKey:t,baseURL:e,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l,signal:c,onProgress:u}){return jo({check:n(p=>Ko(r,{publicKey:t,baseURL:e,signal:p,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}).then(h=>h.isReady?h:(u&&u({isComputable:!0,value:1}),!1)),"check"),signal:c})}n(Us,"isReadyPoll");function zl(r){return"defaultEffects"in r}n(zl,"isGroupFileInfo");var Vs=class Vs{constructor(t,{baseCDN:e=I.baseCDN,fileName:i}={}){d(this,"uuid");d(this,"name",null);d(this,"size",null);d(this,"isStored",null);d(this,"isImage",null);d(this,"mimeType",null);d(this,"cdnUrl",null);d(this,"s3Url",null);d(this,"originalFilename",null);d(this,"imageInfo",null);d(this,"videoInfo",null);d(this,"contentInfo",null);d(this,"metadata",null);d(this,"s3Bucket",null);d(this,"defaultEffects",null);let{uuid:s,s3Bucket:o}=t,a=ye(e,`${s}/`),l=o?ye(`https://${o}.s3.amazonaws.com/`,`${s}/${t.filename}`):null;this.uuid=s,this.name=i||t.filename,this.size=t.size,this.isStored=t.isStored,this.isImage=t.isImage,this.mimeType=t.mimeType,this.cdnUrl=a,this.originalFilename=t.originalFilename,this.imageInfo=t.imageInfo,this.videoInfo=t.videoInfo,this.contentInfo=t.contentInfo,this.metadata=t.metadata||null,this.s3Bucket=o||null,this.s3Url=l,zl(t)&&(this.defaultEffects=t.defaultEffects)}};n(Vs,"UploadcareFile");var we=Vs,Bl=n((r,{publicKey:t,fileName:e,baseURL:i,secureSignature:s,secureExpire:o,store:a,contentType:l,signal:c,onProgress:u,source:p,integration:h,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:g,baseCDN:_,metadata:x})=>Ll(r,{publicKey:t,fileName:e,contentType:l,baseURL:i,secureSignature:s,secureExpire:o,store:a,signal:c,onProgress:u,source:p,integration:h,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:g,metadata:x}).then(({file:C})=>Us(C,{publicKey:t,baseURL:i,source:p,integration:h,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:g,onProgress:u,signal:c})).then(C=>new we(C,{baseCDN:_})),"uploadDirect"),Hl=n((r,{publicKey:t,fileName:e,baseURL:i,signal:s,onProgress:o,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:u,retryNetworkErrorMaxTimes:p,baseCDN:h})=>Ko(r,{publicKey:t,baseURL:i,signal:s,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:u,retryNetworkErrorMaxTimes:p}).then(f=>new we(f,{baseCDN:h,fileName:e})).then(f=>(o&&o({isComputable:!0,value:1}),f)),"uploadFromUploaded"),jl=n((r,{signal:t}={})=>{let e=null,i=null,s=r.map(()=>new AbortController),o=n(a=>()=>{i=a,s.forEach((l,c)=>c!==a&&l.abort())},"createStopRaceCallback");return Si(t,()=>{s.forEach(a=>a.abort())}),Promise.all(r.map((a,l)=>{let c=o(l);return Promise.resolve().then(()=>a({stopRace:c,signal:s[l].signal})).then(u=>(c(),u)).catch(u=>(e=u,null))})).then(a=>{if(i===null)throw e;return a[i]})},"race"),Gl=window.WebSocket,zs=class zs{constructor(){d(this,"events",Object.create({}))}emit(t,e){var i;(i=this.events[t])==null||i.forEach(s=>s(e))}on(t,e){this.events[t]=this.events[t]||[],this.events[t].push(e)}off(t,e){e?this.events[t]=t