@uploadcare/file-uploader
Version:
Building blocks for Uploadcare products integration
29 lines • 312 kB
JavaScript
/**
* @license
* MIT License
*
* Copyright (c) 2025 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 ri=Object.defineProperty;var An=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var In=Object.prototype.hasOwnProperty;var s=(i,e)=>ri(i,"name",{value:e,configurable:!0});var kn=(i,e)=>{for(var t in e)ri(i,t,{get:e[t],enumerable:!0})},On=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Sn(e))!In.call(i,o)&&o!==t&&ri(i,o,{get:()=>e[o],enumerable:!(r=An(e,o))||r.enumerable});return i};var Mn=i=>On(ri({},"__esModule",{value:!0}),i);var Kc={};kn(Kc,{ActivityBlock:()=>g,ActivityHeader:()=>Pi,BaseComponent:()=>ge,Block:()=>b,BtnUi:()=>at,CameraSource:()=>Rt,CloudImageEditor:()=>ir,CloudImageEditorActivity:()=>Fi,CloudImageEditorBlock:()=>ue,Config:()=>ut,Copyright:()=>Bi,CropFrame:()=>Pt,Data:()=>T,DropArea:()=>pt,EditorAspectRatioButtonControl:()=>tt,EditorCropButtonControl:()=>it,EditorFilterControl:()=>je,EditorFreeformButtonControl:()=>ze,EditorImageCropper:()=>Dt,EditorImageFader:()=>Di,EditorOperationControl:()=>nt,EditorScroller:()=>Ft,EditorSlider:()=>$t,EditorToolbar:()=>Vt,ExternalSource:()=>jt,ExternalUploadSource:()=>se,FileItem:()=>Gi,FileUploaderInline:()=>ti,FileUploaderMinimal:()=>ii,FileUploaderRegular:()=>bt,FormInput:()=>Wi,Icon:()=>mt,Img:()=>Qi,LineLoaderUi:()=>Nt,Modal:()=>Wt,ModalEvents:()=>U,PACKAGE_NAME:()=>Te,PACKAGE_VERSION:()=>xe,PresenceToggle:()=>Bt,ProgressBar:()=>qt,ProgressBarCommon:()=>Xt,Select:()=>Zt,SimpleBtn:()=>gt,SliderUi:()=>zt,SolutionBlock:()=>ae,SourceBtn:()=>vt,SourceList:()=>Ji,Spinner:()=>Yt,StartFrom:()=>Qt,Thumb:()=>yt,UID:()=>fe,UploadCtxProvider:()=>tr,UploadList:()=>Jt,UploadSource:()=>P,UploaderBlock:()=>O,UrlSource:()=>ei,defineComponents:()=>Ti,defineLocale:()=>Ir,loadFileUploaderFrom:()=>is,toKebabCase:()=>ct});var Ln=Object.defineProperty,Rn=s((i,e,t)=>e in i?Ln(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,"__defNormalProp"),nr=s((i,e,t)=>(Rn(i,typeof e!="symbol"?e+"":e,t),t),"__publicField");function Pn(i){let e=s(t=>{var r;for(let o in t)((r=t[o])==null?void 0:r.constructor)===Object&&(t[o]=e(t[o]));return{...t}},"clone");return e(i)}s(Pn,"cloneObj");var T=class{static{s(this,"Data")}constructor(i){i.constructor===Object?this.store=Pn(i):(this._storeIsProxy=!0,this.store=i),this.callbackMap=Object.create(null)}static warn(i,e){console.warn(`Symbiote Data: cannot ${i}. Prop name: `+e)}read(i){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(T.warn("read",i),null):this.store[i]}has(i){return this._storeIsProxy?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this._storeIsProxy&&!this.store.hasOwnProperty(i)){T.warn("publish",i);return}this.store[i]=e,this.notify(i)}multiPub(i){for(let e in i)this.pub(e,i[e])}notify(i){this.callbackMap[i]&&this.callbackMap[i].forEach(e=>{e(this.store[i])})}sub(i,e,t=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(T.warn("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.store[i]),{remove:s(()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},"remove"),callback:e})}static registerCtx(i,e=Symbol()){let t=T.globalStore.get(e);return t?console.warn('State: context UID "'+e+'" already in use'):(t=new T(i),T.globalStore.set(e,t)),t}static deleteCtx(i){T.globalStore.delete(i)}static getCtx(i,e=!0){return T.globalStore.get(i)||(e&&console.warn('State: wrong context UID - "'+i+'"'),null)}};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"}),po="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Un=po.length-1,fe=class{static{s(this,"UID")}static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:po.charAt(Math.random()*Un);return e}};function ho(i,e,t){let r=!0,o,n=e.split(".");return n.forEach((a,l)=>{l<n.length-1?i=i[a]:o=a}),i?i[o]=t:r=!1,r}s(ho,"setNestedProp");function $n(i){return i.split("-").map((e,t)=>e&&t?e[0].toUpperCase()+e.slice(1):e).join("").split("_").map((e,t)=>e&&t?e.toUpperCase():e).join("")}s($n,"kebabToCamel");function Dn(i,e){[...i.querySelectorAll(`[${E.REPEAT_ATTR}]`)].forEach(t=>{let r=t.getAttribute(E.REPEAT_ITEM_TAG_ATTR),o;if(r&&(o=window.customElements.get(r)),!o){o=class extends e.BaseComponent{static{s(this,"itemClass")}constructor(){super(),r||(this.style.display="contents")}};let a=t.innerHTML;o.template=a,o.reg(r)}for(;t.firstChild;)t.firstChild.remove();let n=t.getAttribute(E.REPEAT_ATTR);e.sub(n,a=>{if(!a){for(;t.firstChild;)t.firstChild.remove();return}let l=[...t.children],c,d=s(u=>{u.forEach((h,f)=>{if(l[f])if(l[f].set$)setTimeout(()=>{l[f].set$(h)});else for(let m in h)l[f][m]=h[m];else{c||(c=new DocumentFragment);let m=new o;Object.assign(m.init$,h),c.appendChild(m)}}),c&&t.appendChild(c);let p=l.slice(u.length,l.length);for(let h of p)h.remove()},"fillItems");if(a.constructor===Array)d(a);else if(a.constructor===Object){let u=[];for(let p in a){let h=a[p];Object.defineProperty(h,"_KEY_",{value:p,enumerable:!0}),u.push(h)}d(u)}else console.warn("Symbiote repeat data type error:"),console.log(a)}),t.removeAttribute(E.REPEAT_ATTR),t.removeAttribute(E.REPEAT_ITEM_TAG_ATTR)})}s(Dn,"repeatProcessor");var co="__default__";function Fn(i,e){if(e.shadowRoot)return;let t=[...i.querySelectorAll("slot")];if(!t.length)return;let r={};t.forEach(o=>{let n=o.getAttribute("name")||co;r[n]={slot:o,fr:document.createDocumentFragment()}}),e.initChildren.forEach(o=>{var n;let a=co;o instanceof Element&&o.hasAttribute("slot")&&(a=o.getAttribute("slot"),o.removeAttribute("slot")),(n=r[a])==null||n.fr.appendChild(o)}),Object.values(r).forEach(o=>{if(o.fr.childNodes.length)o.slot.parentNode.replaceChild(o.fr,o.slot);else if(o.slot.childNodes.length){let n=document.createDocumentFragment();n.append(...o.slot.childNodes),o.slot.parentNode.replaceChild(n,o.slot)}else o.slot.remove()})}s(Fn,"slotProcessor");function Vn(i,e){[...i.querySelectorAll(`[${E.EL_REF_ATTR}]`)].forEach(t=>{let r=t.getAttribute(E.EL_REF_ATTR);e.ref[r]=t,t.removeAttribute(E.EL_REF_ATTR)})}s(Vn,"refProcessor");function Nn(i,e){[...i.querySelectorAll(`[${E.BIND_ATTR}]`)].forEach(t=>{let o=t.getAttribute(E.BIND_ATTR).split(";");[...t.attributes].forEach(n=>{if(n.name.startsWith("-")&&n.value){let a=$n(n.name.replace("-",""));o.push(a+":"+n.value),t.removeAttribute(n.name)}}),o.forEach(n=>{if(!n)return;let a=n.split(":").map(u=>u.trim()),l=a[0],c;l.indexOf(E.ATTR_BIND_PRFX)===0&&(c=!0,l=l.replace(E.ATTR_BIND_PRFX,""));let d=a[1].split(",").map(u=>u.trim());for(let u of d){let p;u.startsWith("!!")?(p="double",u=u.replace("!!","")):u.startsWith("!")&&(p="single",u=u.replace("!","")),e.sub(u,h=>{p==="double"?h=!!h:p==="single"&&(h=!h),c?h?.constructor===Boolean?h?t.setAttribute(l,""):t.removeAttribute(l):t.setAttribute(l,h):ho(t,l,h)||(t[E.SET_LATER_KEY]||(t[E.SET_LATER_KEY]=Object.create(null)),t[E.SET_LATER_KEY][l]=h)})}}),t.removeAttribute(E.BIND_ATTR)})}s(Nn,"domSetProcessor");var oi="{{",_t="}}",Bn="skip-text";function zn(i){let e,t=[],r=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode:s(o=>{var n;return!((n=o.parentElement)!=null&&n.hasAttribute(Bn))&&o.textContent.includes(oi)&&o.textContent.includes(_t)&&1},"acceptNode")});for(;e=r.nextNode();)t.push(e);return t}s(zn,"getTextNodesWithTokens");var Hn=s(function(i,e){zn(i).forEach(r=>{let o=[],n;for(;r.textContent.includes(_t);)r.textContent.startsWith(oi)?(n=r.textContent.indexOf(_t)+_t.length,r.splitText(n),o.push(r)):(n=r.textContent.indexOf(oi),r.splitText(n)),r=r.nextSibling;o.forEach(a=>{let l=a.textContent.replace(oi,"").replace(_t,"");a.textContent="",e.sub(l,c=>{a.textContent=c})})})},"txtNodesProcessor"),jn=[Dn,Fn,Vn,Nn,Hn],si="'",Ge='"',Kn=/\\([0-9a-fA-F]{1,6} ?)/g;function Gn(i){return(i[0]===Ge||i[0]===si)&&(i[i.length-1]===Ge||i[i.length-1]===si)}s(Gn,"hasLeadingTrailingQuotes");function Wn(i){return(i[0]===Ge||i[0]===si)&&(i=i.slice(1)),(i[i.length-1]===Ge||i[i.length-1]===si)&&(i=i.slice(0,-1)),i}s(Wn,"trimQuotes");function qn(i){let e="",t="";for(var r=0;r<i.length;r++){let o=i[r+1];i[r]==="\\"&&o==='"'?(e+='\\"',r++):i[r]==='"'&&t!=="\\"?e+='\\"':e+=i[r],t=i[r]}return e}s(qn,"escapeQuotes");function Xn(i){let e=i;Gn(i)&&(e=Wn(e),e=e.replace(Kn,(t,r)=>String.fromCodePoint(parseInt(r.trim(),16))),e=e.replaceAll(`\\
`,"\\n"),e=qn(e),e=Ge+e+Ge);try{return JSON.parse(e)}catch{throw new Error(`Failed to parse CSS property value: ${e}. Original input: ${i}`)}}s(Xn,"parseCssPropertyValue");var uo=0,Ke=null,me=null,Ae=class extends HTMLElement{static{s(this,"_BaseComponent")}constructor(){super(),nr(this,"updateCssData",()=>{var i;this.dropCssDataCache(),(i=this.__boundCssProps)==null||i.forEach(e=>{let t=this.getCssData(this.__extractCssName(e),!0);t!==null&&this.$[e]!==t&&(this.$[e]=t)})}),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 Ae}initCallback(){}__initCallback(){var i;this.__initialized||(this.__initialized=!0,(i=this.initCallback)==null||i.call(this))}render(i,e=this.renderShadow){let t;if((e||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let o=this.getAttribute(E.USE_TPL);if(o){let n=this.getRootNode(),a=n?.querySelector(o)||document.querySelector(o);a?i=a.content.cloneNode(!0):console.warn(`Symbiote template "${o}" is not found...`)}}if(this.processInnerHtml)for(let o of this.tplProcessors)o(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?.constructor===DocumentFragment)t=i;else if(i?.constructor===String){let o=document.createElement("template");o.innerHTML=i,t=o.content.cloneNode(!0)}else this.constructor.__tpl&&(t=this.constructor.__tpl.content.cloneNode(!0));for(let o of this.tplProcessors)o(t,this)}let r=s(()=>{t&&(e&&this.shadowRoot.appendChild(t)||this.appendChild(t)),this.__initCallback()},"addFr");if(this.constructor.__shadowStylesUrl){e=!0;let o=document.createElement("link");o.rel="stylesheet",o.href=this.constructor.__shadowStylesUrl,o.onload=r,this.shadowRoot.prepend(o)}else r()}addTemplateProcessor(i){this.tplProcessors.add(i)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=fe.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 i;let e=((i=this.getAttribute(E.CTX_NAME_ATTR))==null?void 0:i.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(i,e){let t,r;if(i.startsWith(E.EXT_DATA_CTX_PRFX))t=e.nodeCtx,r=i.replace(E.EXT_DATA_CTX_PRFX,"");else if(i.includes(E.NAMED_DATA_CTX_SPLTR)){let o=i.split(E.NAMED_DATA_CTX_SPLTR);t=T.getCtx(o[0]),r=o[1]}else t=e.localCtx,r=i;return{ctx:t,name:r}}sub(i,e,t=!0){let r=s(n=>{this.isConnected&&e(n)},"subCb"),o=Ae.__parseProp(i,this);o.ctx.has(o.name)?this.allSubs.add(o.ctx.sub(o.name,r,t)):window.setTimeout(()=>{this.allSubs.add(o.ctx.sub(o.name,r,t))})}notify(i){let e=Ae.__parseProp(i,this);e.ctx.notify(e.name)}has(i){let e=Ae.__parseProp(i,this);return e.ctx.has(e.name)}add(i,e,t=!1){let r=Ae.__parseProp(i,this);r.ctx.add(r.name,e,t)}add$(i,e=!1){for(let t in i)this.add(t,i[t],e)}get $(){if(!this.__stateProxy){let i=Object.create(null);this.__stateProxy=new Proxy(i,{set:s((e,t,r)=>{let o=Ae.__parseProp(t,this);return o.ctx.pub(o.name,r),!0},"set"),get:s((e,t)=>{let r=Ae.__parseProp(t,this);return r.ctx.read(r.name)},"get")})}return this.__stateProxy}set$(i,e=!1){for(let t in i){let r=i[t];e||![String,Number,Boolean].includes(r?.constructor)?this.$[t]=r:this.$[t]!==r&&(this.$[t]=r)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(E.CTX_OWNER_ATTR)&&this.getAttribute(E.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let i=this.constructor.__attrDesc;if(i)for(let e of Object.values(i))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 t=e.split(E.NAMED_DATA_CTX_SPLTR),r=t[0].trim(),o=t[1].trim();if(r&&o){let n=T.getCtx(r,!1);n||(n=T.registerCtx({},r)),n.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 i;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let e=(i=this.getAttribute(E.CTX_NAME_ATTR))==null?void 0:i.trim();if(e&&this.style.setProperty(E.CSS_CTX_PROP,`'${e}'`),this.__initDataCtx(),this[E.SET_LATER_KEY]){for(let t in this[E.SET_LATER_KEY])ho(this,t,this[E.SET_LATER_KEY][t]);delete this[E.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let t of jn)this.addTemplateProcessor(t);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let t=this.getRootNode();if(!t)return;if(t?.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()},t.nodeType===Node.DOCUMENT_NODE?t.head.appendChild(o):t.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 i of this.allSubs)i.remove(),this.allSubs.delete(i);for(let i of this.tplProcessors)this.tplProcessors.delete(i);me?.delete(this.updateCssData),me?.size||(Ke?.disconnect(),Ke=null,me=null)},100)))}static reg(i,e=!1){i||(uo++,i=`${E.AUTO_TAG_PRFX}-${uo}`),this.__tag=i;let t=window.customElements.get(i);if(t){!e&&t!==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,e?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,e,t){var r;if(e===t)return;let o=(r=this.constructor.__attrDesc)==null?void 0:r[i];o?this.__dataCtxInitialized?this.$[o]=t:this.init$[o]=t:this[i]=t}getCssData(i,e=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(i)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let t=this.__computedStyle.getPropertyValue(i).trim();try{this.__cssDataCache[i]=Xn(t)}catch{!e&&console.warn(`CSS Data error: ${i}`),this.__cssDataCache[i]=null}}return this.__cssDataCache[i]}__extractCssName(i){return i.split("--").map((e,t)=>t===0?"":e).join("--")}__initStyleAttrObserver(){me||(me=new Set),me.add(this.updateCssData),Ke||(Ke=new MutationObserver(i=>{i[0].type==="attributes"&&me.forEach(e=>{e()})}),Ke.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(i,e=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(i);let t=this.getCssData(this.__extractCssName(i),!0);t===null&&(t=e),this.add(i,t),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(i,e,t){let r="__"+i;this[r]=this[i],Object.defineProperty(this,i,{set:s(o=>{this[r]=o,t?window.setTimeout(()=>{e?.(o)}):e?.(o)},"set"),get:s(()=>this[r],"get")}),this[i]=this[r]}static set shadowStyles(i){let e=new Blob([i],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(e)}static set rootStyles(i){if(!this.__rootStylesLink){let e=new Blob([i],{type:"text/css"}),t=URL.createObjectURL(e),r=document.createElement("link");r.href=t,r.rel="stylesheet",this.__rootStylesLink=r}}},ge=Ae;nr(ge,"template");var sr=class{static{s(this,"AppRouter")}static _print(i){console.warn(i)}static setDefaultTitle(i){this.defaultTitle=i}static setRoutingMap(i){Object.assign(this.appMap,i);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(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(t=>{if(t.includes("?"))i.route=t.replace("?","");else if(t.includes("=")){let r=t.split("=");i.options[r[0]]=decodeURI(r[1])}else i.options[t]=!0}),i}static notify(){let i=this.readAddressBar(),e=this.appMap[i.route];if(e&&e.title&&(document.title=e.title),i.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 "${i.route}" not found...`);return}let t=new CustomEvent(sr.routingEventName,{detail:{route:i.route,options:Object.assign(e||{},i.options)}});window.dispatchEvent(t)}static reflect(i,e={}){let t=this.appMap[i];if(!t){this._print("Wrong route: "+i);return}let r="?"+i;for(let n in e)e[n]===!0?r+=this.separator+n:r+=this.separator+n+`=${e[n]}`;let o=t.title||this.defaultTitle||"";window.history.pushState(null,o,r),document.title=o}static applyRoute(i,e={}){this.reflect(i,e),this.notify()}static setSeparator(i){this._separator=i}static get separator(){return this._separator||"&"}static createRouterData(i,e){this.setRoutingMap(e);let t=T.registerCtx({route:null,options:null,title:null},i);return window.addEventListener(this.routingEventName,r=>{var o;t.multiPub({route:r.detail.route,options:r.detail.options,title:((o=r.detail.options)==null?void 0:o.title)||this.defaultTitle||""})}),sr.notify(),this.initPopstateListener(),t}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};sr.appMap=Object.create(null);function wt(i,e){for(let t in e)t.includes("-")?i.style.setProperty(t,e[t]):i.style[t]=e[t]}s(wt,"applyStyles");function Zn(i,e){for(let t in e)e[t].constructor===Boolean?e[t]?i.setAttribute(t,""):i.removeAttribute(t):i.setAttribute(t,e[t])}s(Zn,"applyAttributes");function ar(i={tag:"div"}){let e=document.createElement(i.tag);if(i.attributes&&Zn(e,i.attributes),i.styles&&wt(e,i.styles),i.properties)for(let t in i.properties)e[t]=i.properties[t];return i.processors&&i.processors.forEach(t=>{t(e)}),i.children&&i.children.forEach(t=>{let r=ar(t);e.appendChild(r)}),e}s(ar,"create");var mo="idb-store-ready",Yn="symbiote-db",Qn="symbiote-idb-update_",Jn=class{static{s(this,"DbInstance")}_notifyWhenReady(i=null){window.dispatchEvent(new CustomEvent(mo,{detail:{dbName:this.name,storeName:this.storeName,event:i}}))}get _updEventName(){return Qn+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,e){this.name=i,this.storeName=e,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=t=>{this.db=t.target.result,this.objStore=this.db.createObjectStore(e,{keyPath:"_key"}),this.objStore.transaction.oncomplete=r=>{this._notifyWhenReady(r)}},this.request.onsuccess=t=>{this.db=t.target.result,this._notifyWhenReady(t)},this.request.onerror=t=>{console.error(t)},this._subscriptionsMap={},this._updateHandler=t=>{t.key===this.name&&this._subscriptionsMap[t.newValue]&&this._subscriptionsMap[t.newValue].forEach(async o=>{o(await this.read(t.newValue))})},this._localUpdateHandler=t=>{this._updateHandler(t.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(i){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(i);return new Promise((r,o)=>{t.onsuccess=n=>{var a;(a=n.target.result)!=null&&a._value?r(n.target.result._value):(r(null),console.warn(`IDB: cannot read "${i}"`))},t.onerror=n=>{o(n)}})}write(i,e,t=!1){let r={_key:i,_value:e},n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(r);return new Promise((a,l)=>{n.onsuccess=c=>{t||this._notifySubscribers(i),a(c.target.result)},n.onerror=c=>{l(c)}})}delete(i,e=!1){let r=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(i);return new Promise((o,n)=>{r.onsuccess=a=>{e||this._notifySubscribers(i),o(a)},r.onerror=a=>{n(a)}})}getAll(){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((t,r)=>{e.onsuccess=o=>{let n=o.target.result;t(n.map(a=>a._value))},e.onerror=o=>{r(o)}})}subscribe(i,e){this._subscriptionsMap[i]||(this._subscriptionsMap[i]=new Set);let t=this._subscriptionsMap[i];return t.add(e),{remove:s(()=>{t.delete(e),t.size||delete this._subscriptionsMap[i]},"remove")}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,fo.clear(this.name)}},fo=class{static{s(this,"IDB")}static get readyEventName(){return mo}static open(i=Yn,e="store"){let t=i+"/"+e;return this._reg[t]||(this._reg[t]=new Jn(i,e)),this._reg[t]}static clear(i){window.indexedDB.deleteDatabase(i);for(let e in this._reg)e.split("/")[0]===i&&delete this._reg[e]}};nr(fo,"_reg",Object.create(null));var ve=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config"}),_=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",...ve}),ni=class{static{s(this,"EventEmitter")}_timeoutStore=new Map;_targets=new Set;_debugPrint=null;constructor(e){this._debugPrint=e}bindTarget(e){this._targets.add(e)}unbindTarget(e){this._targets.delete(e)}_dispatch(e,t){for(let r of this._targets)r.dispatchEvent(new CustomEvent(e,{detail:t}));this._debugPrint?.(()=>{let r=t&&typeof t=="object"?{...t}:t;return[`event "${e}"`,r]})}emit(e,t,r={}){let{debounce:o}=r;if(typeof o!="number"&&!o){this._dispatch(e,typeof t=="function"?t():t);return}this._timeoutStore.has(e)&&window.clearTimeout(this._timeoutStore.get(e));let n=typeof o=="number"?o:20,a=window.setTimeout(()=>{this._dispatch(e,typeof t=="function"?t():t),this._timeoutStore.delete(e)},n);this._timeoutStore.set(e,a)}};function M(i,e){let t,r=s(((...o)=>{t&&clearTimeout(t),t=setTimeout(()=>i(...o),e)}),"debounced");return r.cancel=()=>{t&&clearTimeout(t)},r}s(M,"debounce");var q=s(i=>i?i.split(",").map(e=>e.trim()).filter(Boolean):[],"deserializeCsv"),ye=s(i=>i.join(","),"serializeCsv");var go=s(i=>{if(typeof i!="string"||!i)return"";let e=i.trim();return e.startsWith("-/")?e=e.slice(2):e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,e.length-1)),e},"normalizeCdnOperation"),ai=s((...i)=>i.filter(e=>typeof e=="string"&&!!e).map(e=>go(e)).join("/-/"),"joinCdnOperations"),H=s((...i)=>{let e=ai(...i);return e?`-/${e}/`:""},"createCdnUrlModifiers");function li(i){let e=new URL(i),t=e.pathname+e.search+e.hash,r=t.lastIndexOf("http"),o=t.lastIndexOf("/"),n="";return r>=0?n=t.slice(r):o>=0&&(n=t.slice(o+1)),n}s(li,"extractFilename");function ci(i){let e=new URL(i),{pathname:t}=e,r=t.indexOf("/"),o=t.indexOf("/",r+1);return t.substring(r+1,o)}s(ci,"extractUuid");function lr(i){let e=vo(i),t=new URL(e),r=t.pathname.indexOf("/-/");return r===-1?"":t.pathname.substring(r).slice(1)}s(lr,"extractCdnUrlModifiers");function cr(i){return lr(i).split("/-/").filter(Boolean).map(t=>go(t))}s(cr,"extractOperations");function vo(i){let e=new URL(i),t=li(i),r=yo(t)?bo(t).pathname:t;return e.pathname=e.pathname.replace(r,""),e.search="",e.hash="",e.toString()}s(vo,"trimFilename");function yo(i){return i.startsWith("http")}s(yo,"isFileUrl");function bo(i){let e=new URL(i);return{pathname:`${e.origin}${e.pathname??""}`,search:e.search??"",hash:e.hash??""}}s(bo,"splitFileUrl");var $=s((i,e,t)=>{let r=new URL(vo(i)),o=t??li(i),n=e??"";if(r.pathname.startsWith("//")&&(r.pathname=r.pathname.replace("//","/")),o&&yo(o)){let a=bo(o);r.pathname=`${r.pathname}${n}${a.pathname||""}`,r.search=a.search,r.hash=a.hash}else r.pathname=`${r.pathname}${n}${o||""}`;return r.toString()},"createCdnUrl"),Se=s((i,e)=>{let t=new URL(i);return t.pathname=`${e}/`,t.toString()},"createOriginalUrl");var D=s((i,e=",")=>i.trim().split(e).map(t=>t.trim()).filter(t=>t.length>0),"stringToArray");var Ct=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}),wo=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function ea(i,e){if(typeof e=="number"){let t=e;return Ct[i]!==t?`${i}/${t}`:""}if(typeof e=="boolean"){let t=e;return Ct[i]!==t?`${i}`:""}if(i==="filter"&&e){let{name:t,amount:r}=e;return Ct.filter===r?"":`${i}/${t}/${r}`}if(i==="crop"&&e){let{dimensions:t,coords:r}=e;return`${i}/${t.join("x")}/${r.join(",")}`}return""}s(ea,"transformationToStr");function Ie(i){return ai(...wo.filter(e=>typeof i[e]<"u"&&i[e]!==null).map(e=>{let t=i[e];return ea(e,t)}).filter(e=>!!e))}s(Ie,"transformationsToOperations");var di=ai("format/auto","progressive/yes"),be=s(([i])=>typeof i<"u"?Number(i):void 0,"asNumber"),_o=s(()=>!0,"asBoolean"),ta=s(([i,e])=>({name:i,amount:typeof e<"u"?Number(e):100}),"asFilter"),ia=s(([i,e])=>{if(!/\d+x\d+/.test(i)||!/\d+,\d+/.test(e))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:D(i,"x").map(Number),coords:D(e).map(Number)}},"asCrop"),ra=Object.freeze({enhance:be,brightness:be,exposure:be,gamma:be,contrast:be,saturation:be,vibrance:be,warmth:be,filter:ta,mirror:_o,flip:_o,rotate:be,crop:s(i=>{let[e,t]=i,{dimensions:r,coords:o}=ia([e,t]);return{dimensions:r,coords:o}},"crop")});function dr(i){let e={};for(let t of i){let[r,...o]=t.split("/");if(!r||!wo.includes(r))continue;let n=r,a=ra[n];try{let l=a(o);e[n]=l}catch(l){console.warn([`Failed to parse URL operation "${t}". 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 e}s(dr,"operationsToTransformations");var L=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),X=Object.freeze([L.CROP,L.TUNING,L.FILTERS]),Co=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Eo=Object.freeze(["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"]),To=Object.freeze(["rotate","mirror","flip"]),_e=Ct,re=Object.freeze({brightness:{zero:_e.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:_e.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:_e.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:_e.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:_e.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:_e.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:_e.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:_e.enhance,range:[0,100],keypointsNumber:1},filter:{zero:_e.filter,range:[0,100],keypointsNumber:1}});var Et="https://ucarecdn.com",oa="https://upload.uploadcare.com",sa="https://social.uploadcare.com",na="https://ucarecd.net",aa={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",topLevelOrigin:"",cloudImageEditorTabs:ye(X),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Et,cdnCnamePrefixed:na,baseUrl:oa,socialBaseUrl:sa,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,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:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},Y=Object.freeze(aa);var xo=s(i=>{let e=new Intl.Locale(i),t="ltr",r=e.getTextInfo?.().direction;return r?t=r:e.textInfo?.direction&&(t=e.textInfo.direction),t},"getLocaleDirection");var ui=s((i,e)=>new Intl.PluralRules(i).select(e),"getPluralForm");var la=s(i=>i,"DEFAULT_TRANSFORMER"),ur="{{",So="}}",Ao="plural:";function Tt(i,e={},t={}){let{openToken:r=ur,closeToken:o=So,transform:n=la}=t;for(let a in e){let l=e[a],c=l?.toString(),d=typeof c=="string"?n(c):String(c);i=i.replaceAll(r+a+o,d)}return i}s(Tt,"applyTemplateData");function Io(i){let e=[],t=i.indexOf(ur);for(;t!==-1;){let r=i.indexOf(So,t);if(r===-1)break;let o=i.substring(t+2,r);if(o.startsWith(Ao)){let n=i.substring(t+2,r).replace(Ao,""),a=n.substring(0,n.indexOf("(")),l=n.substring(n.indexOf("(")+1,n.indexOf(")"));e.push({variable:o,pluralKey:a,countVariable:l})}t=i.indexOf(ur,r)}return e}s(Io,"getPluralObjects");var ko="--uploadcare-blocks-window-height",xt=class i{static{s(this,"WindowHeightTracker")}static clientsRegistry=new Set;static flush=M(()=>{document.documentElement.style.setProperty(ko,`${window.innerHeight}px`)},100);static registerClient(e){i.clientsRegistry.size===0&&i.attachTracker(),i.clientsRegistry.add(e)}static unregisterClient(e){i.clientsRegistry.delete(e),i.clientsRegistry.size===0&&i.detachTracker()}static attachTracker(){window.addEventListener("resize",i.flush,{passive:!0,capture:!0}),i.flush()}static detachTracker(){window.removeEventListener("resize",i.flush,{capture:!0}),document.documentElement.style.removeProperty(ko)}};var Oo=s(({element:i,attribute:e,onSuccess:t,onTimeout:r,timeout:o=300})=>{let n=i.getAttribute(e);if(n!==null){t(n);return}let a=new MutationObserver(d=>{let u=d[d.length-1];u&&c(u)});a.observe(i,{attributes:!0,attributeFilter:[e]});let l=window.setTimeout(()=>{a.disconnect(),r()},o),c=s(d=>{let u=i.getAttribute(e);d.type==="attributes"&&d.attributeName===e&&u!==null&&(window.clearTimeout(l),a.disconnect(),t(u))},"handleMutation")},"waitForAttribute");function Mo(i){return Object.prototype.toString.call(i)==="[object Object]"}s(Mo,"isObject");var ca=/\W|_/g;function da(i){return i.split(ca).map((e,t)=>e.charAt(0)[t>0?"toUpperCase":"toLowerCase"]()+e.slice(1)).join("")}s(da,"camelizeString");function Lo(i,{ignoreKeys:e}={ignoreKeys:[]}){return Array.isArray(i)?i.map(t=>Ee(t,{ignoreKeys:e})):i}s(Lo,"camelizeArrayItems");function Ee(i,{ignoreKeys:e}={ignoreKeys:[]}){if(Array.isArray(i))return Lo(i,{ignoreKeys:e});if(!Mo(i))return i;let t={};for(let r of Object.keys(i)){let o=i[r];if(e.includes(r)){t[r]=o;continue}Mo(o)?o=Ee(o,{ignoreKeys:e}):Array.isArray(o)&&(o=Lo(o,{ignoreKeys:e})),t[da(r)]=o}return t}s(Ee,"camelizeKeys");var ua=s(i=>new Promise(e=>setTimeout(e,i)),"delay");function yr({libraryName:i,libraryVersion:e,userAgent:t,publicKey:r="",integration:o=""}){let n="JavaScript";if(typeof t=="string")return t;if(typeof t=="function")return t({publicKey:r,libraryName:i,libraryVersion:e,languageName:n,integration:o});let a=[i,e,r].filter(Boolean).join("/"),l=[n,o].filter(Boolean).join("; ");return`${a} (${l})`}s(yr,"getUserAgent$1");var pa={factor:2,time:100};function ha(i,e=pa){let t=0;function r(o){let n=Math.round(e.time*e.factor**t);return o({attempt:t,retry:s(l=>ua(l??n).then(()=>(t+=1,r(o))),"retry")})}return s(r,"runAttempt"),r(i)}s(ha,"retrier");var De=class extends Error{static{s(this,"UploadcareError")}},We=class i extends De{static{s(this,"NetworkError")}originalProgressEvent;constructor(e){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,i.prototype),this.originalProgressEvent=e}},pi=s((i,e)=>{i&&(i.aborted?Promise.resolve().then(e):i.addEventListener("abort",()=>e(),{once:!0}))},"onCancel"),ke=class i extends De{static{s(this,"CancelError")}isCancel=!0;constructor(e="Request canceled"){super(e),this.name="CancelError",Object.setPrototypeOf(this,i.prototype)}},ma=500,Po=s(({check:i,interval:e=ma,timeout:t,signal:r})=>new Promise((o,n)=>{let a,l;pi(r,()=>{a&&clearTimeout(a),n(new ke("Poll cancelled"))}),t&&(l=setTimeout(()=>{a&&clearTimeout(a),n(new ke("Timed out"))},t));let c=s(()=>{try{Promise.resolve(i(r)).then(d=>{d?(l&&clearTimeout(l),o(d)):a=setTimeout(c,e)}).catch(d=>{l&&clearTimeout(l),n(d)})}catch(d){l&&clearTimeout(l),n(d)}},"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"},hi="application/octet-stream",Uo="original",Me=s(({method:i,url:e,data:t,headers:r={},signal:o,onProgress:n})=>new Promise((a,l)=>{let c=new XMLHttpRequest,d=i?.toUpperCase()||"GET",u=!1;c.open(d,e,!0),r&&Object.entries(r).forEach(p=>{let[h,f]=p;typeof f<"u"&&!Array.isArray(f)&&c.setRequestHeader(h,f)}),c.responseType="text",pi(o,()=>{u=!0,c.abort(),l(new ke)}),c.onload=()=>{if(c.status!=200)l(new Error(`Error ${c.status}: ${c.statusText}`));else{let p={method:d,url:e,data:t,headers:r||void 0,signal:o,onProgress:n},h=c.getAllResponseHeaders().trim().split(/[\r\n]+/),f={};h.forEach(function(y){let S=y.split(": "),x=S.shift(),A=S.join(": ");x&&typeof x<"u"&&(f[x]=A)});let m=c.response,v=c.status;a({request:p,data:m,headers:f,status:v})}},c.onerror=p=>{u||l(new We(p))},n&&typeof n=="function"&&(c.upload.onprogress=p=>{p.lengthComputable?n({isComputable:!0,value:p.loaded/p.total}):n({isComputable:!1})}),t?c.send(t):c.send()}),"request");function fa(i,...e){return i}s(fa,"identity");var ga=s(({name:i})=>i?[i]:[],"getFileOptions"),va=fa,ya=s(()=>new FormData,"getFormData"),$o=s(i=>!1,"isBuffer"),mi=s(i=>typeof Blob<"u"&&i instanceof Blob,"isBlob"),fi=s(i=>typeof File<"u"&&i instanceof File,"isFile"),gi=s(i=>!!i&&typeof i=="object"&&!Array.isArray(i)&&"uri"in i&&typeof i.uri=="string","isReactNativeAsset"),qe=s(i=>mi(i)||fi(i)||$o()||gi(i),"isFileData"),ba=s(i=>typeof i=="string"||typeof i=="number"||typeof i>"u","isSimpleValue"),_a=s(i=>!!i&&typeof i=="object"&&!Array.isArray(i),"isObjectValue"),wa=s(i=>!!i&&typeof i=="object"&&"data"in i&&qe(i.data),"isFileValue");function Do(i,e,t){if(Array.isArray(t))for(let r of t)Do(i,`${e}[]`,r);else if(wa(t)){let{name:r,contentType:o}=t,n=va(t.data,r,o??hi),a=ga({name:r,contentType:o});i.push([e,n,...a])}else if(_a(t))for(let[r,o]of Object.entries(t))typeof o<"u"&&i.push([`${e}[${r}]`,String(o)]);else ba(t)&&t&&i.push([e,t.toString()])}s(Do,"collectParams");function Ca(i){let e=[];for(let[t,r]of Object.entries(i))Do(e,t,r);return e}s(Ca,"getFormDataParams");function vi(i){let e=ya(),t=Ca(i);for(let r of t){let[o,n,...a]=r;e.append(o,n,...a)}return e}s(vi,"buildFormData");var j=class i extends De{static{s(this,"UploadError")}code;request;response;headers;constructor(e,t,r,o,n){super(),this.name="UploadError",this.message=e,this.code=t,this.request=r,this.response=o,this.headers=n,Object.setPrototypeOf(this,i.prototype)}},Ea=s(i=>{let e=new URLSearchParams;for(let[t,r]of Object.entries(i))r&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).filter(o=>o[1]??!1).forEach(o=>e.set(`${t}[${o[0]}]`,String(o[1]))):Array.isArray(r)?r.forEach(o=>{e.append(`${t}[]`,o)}):typeof r=="string"&&r?e.set(t,r):typeof r=="number"&&e.set(t,r.toString());return e.toString()},"buildSearchParams"),we=s((i,e,t)=>{let r=new URL(i);return r.pathname=(r.pathname+e).replace("//","/"),t&&(r.search=Ea(t)),r.toString()},"getUrl"),Ta="6.18.0",xa="UploadcareUploadClient",Aa=Ta;function Fe(i){return yr({libraryName:xa,libraryVersion:Aa,...i})}s(Fe,"getUserAgent");var Sa="RequestThrottledError",Ro=15e3,Ia=1e3;function ka(i){let{headers:e}=i||{};if(!e||typeof e["retry-after"]!="string")return Ro;let t=parseInt(e["retry-after"],10);return Number.isFinite(t)?t*1e3:Ro}s(ka,"getTimeoutFromThrottledRequest");function Le(i,e){let{retryThrottledRequestMaxTimes:t,retryNetworkErrorMaxTimes:r}=e;return ha(({attempt:o,retry:n})=>i().catch(a=>{if("response"in a&&a?.code===Sa&&o<t)return n(ka(a));if(a instanceof We&&o<r)return n((o+1)*Ia);throw a}))}s(Le,"retryIfFailed");var Fo=s(i=>{let e="";return(mi(i)||fi(i)||gi(i))&&(e=i.type),e||hi},"getContentType"),Vo=s(i=>{let e="";return fi(i)&&i.name?e=i.name:mi(i)||$o()?e="":gi(i)&&i.name&&(e=i.name),e||Uo},"getFileName");function br(i){return typeof i>"u"||i==="auto"?"auto":i?"1":"0"}s(br,"getStoreValue");function Oa(i,{publicKey:e,fileName:t,contentType:r,baseURL:o=I.baseURL,secureSignature:n,secureExpire:a,store:l,signal:c,onProgress:d,source:u="local",integration:p,userAgent:h,retryThrottledRequestMaxTimes:f=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=I.retryNetworkErrorMaxTimes,metadata:v}){return Le(()=>Me({method:"POST",url:we(o,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Fe({publicKey:e,integration:p,userAgent:h})},data:vi({file:{data:i,name:t||Vo(i),contentType:r||Fo(i)},UPLOADCARE_PUB_KEY:e,UPLOADCARE_STORE:br(l),signature:n,expire:a,source:u,metadata:v}),signal:c,onProgress:d}).then(({data:y,headers:S,request:x})=>{let A=Ee(JSON.parse(y));if("error"in A)throw new j(A.error.content,A.error.errorCode,x,A,S);return A}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}s(Oa,"base");var mr;(function(i){i.Token="token",i.FileInfo="file_info"})(mr||(mr={}));function Ma(i,{publicKey:e,baseURL:t=I.baseURL,store:r,fileName:o,checkForUrlDuplicates:n,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,source:d="url",signal:u,integration:p,userAgent:h,retryThrottledRequestMaxTimes:f=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=I.retryNetworkErrorMaxTimes,metadata:v}){return Le(()=>Me({method:"POST",headers:{"X-UC-User-Agent":Fe({publicKey:e,integration:p,userAgent:h})},url:we(t,"/from_url/",{jsonerrors:1,pub_key:e,source_url:i,store:br(r),filename:o,check_URL_duplicates:n?1:void 0,save_URL_duplicates:a?1:void 0,signature:l,expire:c,source:d,metadata:v}),signal:u}).then(({data:y,headers:S,request:x})=>{let A=Ee(JSON.parse(y));if("error"in A)throw new j(A.error.content,A.error.errorCode,x,A,S);return A}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}s(Ma,"fromUrl");var Z;(function(i){i.Unknown="unknown",i.Waiting="waiting",i.Progress="progress",i.Error="error",i.Success="success"})(Z||(Z={}));var La=s(i=>"status"in i&&i.status===Z.Error,"isErrorResponse");function Ra(i,{publicKey:e,baseURL:t=I.baseURL,signal:r,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=I.retryNetworkErrorMaxTimes}={}){return Le(()=>Me({method:"GET",headers:e?{"X-UC-User-Agent":Fe({publicKey:e,integration:o,userAgent:n})}:void 0,url:we(t,"/from_url/status/",{jsonerrors:1,token:i}),signal:r}).then(({data:c,headers:d,request:u})=>{let p=Ee(JSON.parse(c));if("error"in p&&!La(p))throw new j(p.error.content,p.error.errorCode,u,p,d);return p}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:a})}s(Ra,"fromUrlStatus");function Pa(i,{publicKey:e,baseURL:t=I.baseURL,jsonpCallback:r,secureSignature:o,secureExpire:n,signal:a,source:l,integration:c,userAgent:d,retryThrottledRequestMaxTimes:u=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=I.retryNetworkErrorMaxTimes}){return Le(()=>Me({method:"POST",headers:{"X-UC-User-Agent":Fe({publicKey:e,integration:c,userAgent:d})},url:we(t,"/group/",{jsonerrors:1}),data:vi({files:i,callback:r,pub_key:e,signature:o,expire:n,source:l}),signal:a}).then(({data:h,headers:f,request:m})=>{let v=Ee(JSON.parse(h));if("error"in v)throw new j(v.error.content,v.error.errorCode,m,v,f);return v}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:u})}s(Pa,"group");function No(i,{publicKey:e,baseURL:t=I.baseURL,signal:r,source:o,integration:n,userAgent:a,retryThrottledRequestMaxTimes:l=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=I.retryNetworkErrorMaxTimes}){return Le(()=>Me({method:"GET",headers:{"X-UC-User-Agent":Fe({publicKey:e,integration:n,userAgent:a})},url:we(t,"/info/",{jsonerrors:1,pub_key:e,file_id:i,source:o}),signal:r}).then(({data:d,headers:u,request:p})=>{let h=Ee(JSON.parse(d));if("error"in h)throw new j(h.error.content,h.error.errorCode,p,h,u);return h}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}s(No,"info");function Ua(i,{publicKey:e,contentType:t,fileName:r,multipartChunkSize:o=I.multipartChunkSize,baseURL:n="",secureSignature:a,secureExpire:l,store:c,signal:d,source:u="local",integration:p,userAgent:h,retryThrottledRequestMaxTimes:f=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=I.retryNetworkErrorMaxTimes,metadata:v}){return Le(()=>Me({method:"POST",url:we(n,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Fe({publicKey:e,integration:p,userAgent:h})},data:vi({filename:r||Uo,size:i,content_type:t||hi,part_size:o,UPLOADCARE_STORE:br(c),UPLOADCARE_PUB_KEY:e,signature:a,expire:l,source:u,metadata:v}),signal:d}).then(({data:y,headers:S,request:x})=>{let A=Ee(JSON.parse(y));if("error"in A)throw new j(A.error.content,A.error.errorCode,x,A,S);return A.parts=Object.keys(A.parts).map(Q=>A.parts[Number(Q)]),A}),{retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})}s(Ua,"multipartStart");function $a(i,e,{contentType:t,signal:r,onProgress:o,retryThrottledRequestMaxTimes:n=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=I.retryNetworkErrorMaxTimes}){return Le(()=>Me({method:"PUT",url:e,data:i,onProgress:o,signal:r,headers:{"Content-Type":t||hi}}).then(l=>(o&&o({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a})}s($a,"multipartUpload");function Da(i,{publicKey:e,baseURL:t=I.baseURL,source:r="local",signal:o,integration:n,userAgent:a,retryThrottledRequestMaxTimes:l=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=I.retryNetworkErrorMaxTimes}){return Le(()=>Me({method:"POST",url:we(t,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Fe({publicKey:e,integration:n,userAgent:a})},data:vi({uuid:i,UPLOADCARE_PUB_KEY:e,source:r}),signal:o}).then(({data:d,headers:u,request:p})=>{let h=Ee(JSON.parse(d));if("error"in h)throw new j(h.error.content,h.error.errorCode,p,h,u);return h}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}s(Da,"multipartComplete");function _r(i,{publicKey:e,baseURL:t,source:r,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l,signal:c,onProgress:d}){return Po({check:s(u=>No(i,{publicKey:e,baseURL:t,signal:u,source:r,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}).then(p=>p.isReady?p:(d&&d({isComputable:!0,value:1}),!1)),"check"),signal:c})}s(_r,"isReadyPoll");function Fa(i){return"defaultEffects"in i}s(Fa,"isGroupFileInfo");var Ce=class{static{s(this,"UploadcareFile")}uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(e,{baseCDN:t=I.baseCDN,fileName:r}={}){let{uuid:o,s3Bucket:n}=e,a=we(t,`${o}/`),l=n?we(`https://${n}.s3.amazonaws.com/`,`${o}/${e.filename}`):null;this.uuid=o,this.name=r||e.filename,this.size=e.size,this.isStored=e.isStored,this.isImage=e.isImage,this.mimeType=e.mimeType,this.cdnUrl=a,this.originalFilename=e.originalFilename,this.imageInfo=e.imageInfo,this.videoInfo=e.videoInfo,this.contentInfo=e.contentInfo,this.metadata=e.metadata||null,this.s3Bucket=n||null,this.s3Url=l,Fa(e)&&(this.defaultEffects=e.defaultEffects)}},Va=s((i,{publicKey:e,fileName:t,baseURL:r,secureSignature:o,secureExpire:n,store:a,contentType:l,signal:c,onProgress:d,source:u,integration:p,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:v,metadata:y})=>Oa(i,{publicKey:e,fileName:t,contentType:l,baseURL:r,secureSignature:o,secureExpire:n,store:a,signal:c,onProgress:d,source:u,integration:p,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,metadata:y}).then(({file:S})=>_r(S,{publicKey:e,baseURL:r,source:u,integration:p,userAgent:h,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,onProgress:d,signal:c})).then(S=>new Ce(S,{baseCDN:v})),"uploadDirect"),Na=s((i,{publicKey:e,fileName:t,baseURL:r,signal:o,onProgress:n,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u,baseCDN:p})=>No(i,{publicKey:e,baseURL:r,signal:o,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u}).then(h=>new Ce(h,{baseCDN:p,fileName:t})).then(h=>(n&&n({isComputable:!0,value:1}),h)),"uploadFromUploaded"),Ba=s((i,{signal:e}={})=>{let t=null,r=null,o=i.map(()=>new AbortController),n=s(a=>()=>{r=a,o.forEach((l,c)=>c!==a&&l.abort())},"createStopRaceCallback");return pi(e,()=>{o.forEach(a=>a.abort())}),Promise.all(i.map((a,l)=>{let c=n(l);return Promise.resolve().then(()=>a({stopRace:c,signal:o[l].signal})).then(d=>(c(),d)).catch(d=>(t=d,null))})).then(a=>{if(r===null)throw t;return a[r]})},"race"),za=window.WebSocket,fr=class{static{s(this,"Events")}events=Object.create({});emit(e,t){this.events[e]?.forEach(r=>r(t))}on(e,t){this.events[e]=this.events[e]||[],this.events[e].push(t)}off(e,t){t?this.events[e]=this.events[e].filter(r=>r!==t):this.events[e]=[]}},Ha=s((i,e)=>i==="success"?{status:Z.Success,...e}:i==="progress"?{status:Z.Progress,...e}:{status:Z.Error,...e},"response"),gr=class{static{s(this,"Pusher")}key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new fr;disconnectTimeoutId=null;constructor(e,t=3e4){this.key=e,this.disconnectTime=t}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.