`;var Ce=class extends C{setCurrentTab(i){if(!i)return;[...this.ref.context.querySelectorAll("[tab-ctx]")].forEach(e=>{e.getAttribute("tab-ctx")===i?e.removeAttribute("hidden"):e.setAttribute("hidden","")});for(let e in this._tabMap)e===i?this._tabMap[e].setAttribute("current",""):this._tabMap[e].removeAttribute("current")}initCallback(){super.initCallback(),this._tabMap={},this.defineAccessor("tab-list",i=>{if(!i)return;M(i).forEach(e=>{let r=Jt({tag:"div",attributes:{class:"tab"},properties:{onclick:()=>{this.setCurrentTab(e)}}});r.textContent=this.l10n(e),this.ref.row.appendChild(r),this._tabMap[e]=r})}),this.defineAccessor("default",i=>{this.setCurrentTab(i)}),this.hasAttribute("default")||this.setCurrentTab(Object.keys(this._tabMap)[0])}};Ce.bindAttributes({"tab-list":null,default:null});Ce.template=`
`;we.bindAttributes({video:"video",src:"src"});var ja="css-src";function wi(s){return class extends s{constructor(){super(...arguments);h(this,"renderShadow",!0);h(this,"pauseRender",!0);h(this,"requireCtxName",!0)}shadowReadyCallback(){}async _waitForShadowStylesLoad(){if(!this.shadowRoot)return;let t=this.constructor.__shadowStylesUrl,e=this.shadowRoot.querySelector(`link[href="${t}"]`);e&&await new Promise((r,n)=>{e.addEventListener("load",r),e.addEventListener("error",n)})}initCallback(){super.initCallback(),this.setAttribute("hidden",""),$e({element:this,attribute:ja,onSuccess:t=>{this.attachShadow({mode:"open"});let e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href=t,e.onload=()=>{window.requestAnimationFrame(async()=>{this.render(),await this._waitForShadowStylesLoad(),window.setTimeout(()=>{this.removeAttribute("hidden"),this.shadowReadyCallback()})})},this.shadowRoot.prepend(e)},onTimeout:()=>{console.error("Attribute `css-src` is required and it is not set. See migration guide: https://uploadcare.com/docs/file-uploader/migration-to-0.25.0/")}})}}}var Ee=class extends wi(C){};var Ei=class extends C{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i)})}};h(Ei,"template",`Powered by Uploadcare`);var Tt=class extends Ee{constructor(){super(...arguments);h(this,"requireCtxName",!0);h(this,"init$",Me(this));h(this,"_template",null)}static set template(t){this._template=t+""}static get template(){return this._template}};var Ai=class extends Tt{shadowReadyCallback(){super.shadowReadyCallback(),this.sub("*modalActive",i=>{this._lastModalActive!==i&&this.emit(i?$.MODAL_OPEN:$.MODAL_CLOSE,void 0,{debounce:!0}),this._lastModalActive=i},!1)}};Ai.template=``;var xi=class extends Tt{constructor(){super(...arguments);h(this,"pauseRender",!0)}shadowReadyCallback(){let t=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=t.initActivity||g.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0?this.$["*currentActivity"]=g.activities.UPLOAD_LIST:this.$["*currentActivity"]=t.initActivity||g.activities.START_FROM}),this.subConfigValue("sourceList",e=>{e!=="local"&&(this.cfg.sourceList="local")}),this.subConfigValue("confirmUpload",e=>{e!==!1&&(this.cfg.confirmUpload=!1)})}};xi.template=``;var Ti=class extends Tt{constructor(){super(),this.init$={...this.init$,couldCancel:!1,cancel:()=>{this.couldHistoryBack?this.$["*historyBack"]():this.couldShowList&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}}}get couldHistoryBack(){let i=this.$["*history"];return i.length>1&&i[i.length-1]!==g.activities.START_FROM}get couldShowList(){return this.cfg.showEmptyList||this.$["*uploadList"].length>0}shadowReadyCallback(){let i=this.ref.uBlock;this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=i.initActivity||g.activities.START_FROM)}),this.sub("*uploadList",t=>{(t==null?void 0:t.length)>0&&this.$["*currentActivity"]===(i.initActivity||g.activities.START_FROM)&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList})}};Ti.template=``;var ps=class extends wi(nt){shadowReadyCallback(){this.__shadowReady=!0,this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async initEditor(){this.__shadowReady&&await super.initEditor()}};function fs(s){for(let i in s){let t=[...i].reduce((e,r)=>(r.toUpperCase()===r&&(r="-"+r.toLowerCase()),e+=r),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("lr-")||(t="lr-"+t),s[i].reg&&s[i].reg(t)}}var ms="LR";async function Ha(s,i=!1){return new Promise((t,e)=>{if(typeof document!="object"){t(null);return}if(typeof window=="object"&&window[ms]){t(window[ms]);return}let r=document.createElement("script");r.async=!0,r.src=s,r.onerror=()=>{e()},r.onload=()=>{let n=window[ms];i&&fs(n),t(n)},document.head.appendChild(r)})}export{g as ActivityBlock,ds as ActivityHeader,Nt as BaseComponent,C as Block,ni as CameraSource,ps as CloudImageEditor,hs as CloudImageEditorActivity,nt as CloudImageEditorBlock,Zo as Config,li as ConfirmationDialog,Ei as Copyright,ui as CropFrame,E as Data,le as DropArea,me as EditorCropButtonControl,Xt as EditorFilterControl,pi as EditorImageCropper,cs as EditorImageFader,ye as EditorOperationControl,fi as EditorScroller,di as EditorSlider,mi as EditorToolbar,vi as ExternalSource,de as FileItem,fe as FilePreview,Ti as FileUploaderInline,xi as FileUploaderMinimal,Ai as FileUploaderRegular,us as FormInput,ne as Icon,es as Img,gi as LineLoaderUi,ve as LrBtnUi,pe as Modal,Fe as PACKAGE_NAME,Be as PACKAGE_VERSION,bi as PresenceToggle,hi as ProgressBar,ci as ProgressBarCommon,Ci as Select,Ee as ShadowWrapper,ae as SimpleBtn,yi as SliderUi,ce as SourceBtn,rs as SourceList,Qe as StartFrom,Ce as Tabs,ka as UploadCtxProvider,ai as UploadDetails,si as UploadList,A as UploaderBlock,ri as UrlSource,we as Video,Ha as connectBlocksFrom,fs as registerBlocks,wi as shadowed,ht as toKebabCase};
\ No newline at end of file
diff --git a/pyuploadcare/dj/static/uploadcare/file-uploader.min.js b/pyuploadcare/dj/static/uploadcare/file-uploader.min.js
new file mode 100644
index 00000000..c0b018d4
--- /dev/null
+++ b/pyuploadcare/dj/static/uploadcare/file-uploader.min.js
@@ -0,0 +1,29 @@
+/**
+ * @license
+ * MIT License
+ *
+ * Copyright (c) 2022 Uploadcare (hello@uploadcare.com). All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+var Uo=Object.defineProperty;var Mo=Object.getPrototypeOf;var Po=Reflect.get;var Ro=(r,e,t)=>e in r?Uo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>(Ro(r,typeof e!="symbol"?e+"":e,t),t);var j=(r,e,t)=>Po(Mo(r),t,e);var Fo=Object.defineProperty,Do=(r,e,t)=>e in r?Fo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Pi=(r,e,t)=>(Do(r,typeof e!="symbol"?e+"":e,t),t);function No(r){let e=t=>{var i;for(let s in t)((i=t[s])==null?void 0:i.constructor)===Object&&(t[s]=e(t[s]));return{...t}};return e(r)}var E=class{constructor(r){r.constructor===Object?this.store=No(r):(this._storeIsProxy=!0,this.store=r),this.callbackMap=Object.create(null)}static warn(r,e){console.warn(`Symbiote Data: cannot ${r}. Prop name: `+e)}read(r){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("read",r),null):this.store[r]}has(r){return this._storeIsProxy?this.store[r]!==void 0:this.store.hasOwnProperty(r)}add(r,e,t=!1){!t&&Object.keys(this.store).includes(r)||(this.store[r]=e,this.notify(r))}pub(r,e){if(!this._storeIsProxy&&!this.store.hasOwnProperty(r)){E.warn("publish",r);return}this.store[r]=e,this.notify(r)}multiPub(r){for(let e in r)this.pub(e,r[e])}notify(r){this.callbackMap[r]&&this.callbackMap[r].forEach(e=>{e(this.store[r])})}sub(r,e,t=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("subscribe",r),null):(this.callbackMap[r]||(this.callbackMap[r]=new Set),this.callbackMap[r].add(e),t&&e(this.store[r]),{remove:()=>{this.callbackMap[r].delete(e),this.callbackMap[r].size||delete this.callbackMap[r]},callback:e})}static registerCtx(r,e=Symbol()){let t=E.globalStore.get(e);return t?console.warn('State: context UID "'+e+'" already in use'):(t=new E(r),E.globalStore.set(e,t)),t}static deleteCtx(r){E.globalStore.delete(r)}static getCtx(r,e=!0){return E.globalStore.get(r)||(e&&console.warn('State: wrong context UID - "'+r+'"'),null)}};E.globalStore=new Map;var A=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"}),Pr="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Bo=Pr.length-1,Mt=class{static generate(r="XXXXXXXXX-XXX"){let e="";for(let t=0;t{le&&t?e[0].toUpperCase()+e.slice(1):e).join("").split("_").map((e,t)=>e&&t?e.toUpperCase():e).join("")}function Vo(r,e){[...r.querySelectorAll(`[${A.REPEAT_ATTR}]`)].forEach(t=>{let i=t.getAttribute(A.REPEAT_ITEM_TAG_ATTR),s;if(i&&(s=window.customElements.get(i)),!s){s=class extends e.BaseComponent{constructor(){super(),i||(this.style.display="contents")}};let n=t.innerHTML;s.template=n,s.reg(i)}for(;t.firstChild;)t.firstChild.remove();let o=t.getAttribute(A.REPEAT_ATTR);e.sub(o,n=>{if(!n){for(;t.firstChild;)t.firstChild.remove();return}let l=[...t.children],a,c=h=>{h.forEach((p,m)=>{if(l[m])if(l[m].set$)setTimeout(()=>{l[m].set$(p)});else for(let f in p)l[m][f]=p[f];else{a||(a=new DocumentFragment);let f=new s;Object.assign(f.init$,p),a.appendChild(f)}}),a&&t.appendChild(a);let d=l.slice(h.length,l.length);for(let p of d)p.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let h=[];for(let d in n){let p=n[d];Object.defineProperty(p,"_KEY_",{value:d,enumerable:!0}),h.push(p)}c(h)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),t.removeAttribute(A.REPEAT_ATTR),t.removeAttribute(A.REPEAT_ITEM_TAG_ATTR)})}var Ur="__default__";function jo(r,e){if(e.shadowRoot)return;let t=[...r.querySelectorAll("slot")];if(!t.length)return;let i={};t.forEach(s=>{let o=s.getAttribute("name")||Ur;i[o]={slot:s,fr:document.createDocumentFragment()}}),e.initChildren.forEach(s=>{var o;let n=Ur;s instanceof Element&&s.hasAttribute("slot")&&(n=s.getAttribute("slot"),s.removeAttribute("slot")),(o=i[n])==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()})}function Ho(r,e){[...r.querySelectorAll(`[${A.EL_REF_ATTR}]`)].forEach(t=>{let i=t.getAttribute(A.EL_REF_ATTR);e.ref[i]=t,t.removeAttribute(A.EL_REF_ATTR)})}function Go(r,e){[...r.querySelectorAll(`[${A.BIND_ATTR}]`)].forEach(t=>{let s=t.getAttribute(A.BIND_ATTR).split(";");[...t.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=zo(o.name.replace("-",""));s.push(n+":"+o.value),t.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let n=o.split(":").map(h=>h.trim()),l=n[0],a;l.indexOf(A.ATTR_BIND_PRFX)===0&&(a=!0,l=l.replace(A.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(h=>h.trim());for(let h of c){let d;h.startsWith("!!")?(d="double",h=h.replace("!!","")):h.startsWith("!")&&(d="single",h=h.replace("!","")),e.sub(h,p=>{d==="double"?p=!!p:d==="single"&&(p=!p),a?(p==null?void 0:p.constructor)===Boolean?p?t.setAttribute(l,""):t.removeAttribute(l):t.setAttribute(l,p):Rr(t,l,p)||(t[A.SET_LATER_KEY]||(t[A.SET_LATER_KEY]=Object.create(null)),t[A.SET_LATER_KEY][l]=p)})}}),t.removeAttribute(A.BIND_ATTR)})}var Ie="{{",Jt="}}",Wo="skip-text";function Xo(r){let e,t=[],i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(Wo))&&s.textContent.includes(Ie)&&s.textContent.includes(Jt)&&1}});for(;e=i.nextNode();)t.push(e);return t}var qo=function(r,e){Xo(r).forEach(i=>{let s=[],o;for(;i.textContent.includes(Jt);)i.textContent.startsWith(Ie)?(o=i.textContent.indexOf(Jt)+Jt.length,i.splitText(o),s.push(i)):(o=i.textContent.indexOf(Ie),i.splitText(o)),i=i.nextSibling;s.forEach(n=>{let l=n.textContent.replace(Ie,"").replace(Jt,"");n.textContent="",e.sub(l,a=>{n.textContent=a})})})},Ko=[Vo,jo,Ho,Go,qo],Oe="'",Ut='"',Zo=/\\([0-9a-fA-F]{1,6} ?)/g;function Yo(r){return(r[0]===Ut||r[0]===Oe)&&(r[r.length-1]===Ut||r[r.length-1]===Oe)}function Jo(r){return(r[0]===Ut||r[0]===Oe)&&(r=r.slice(1)),(r[r.length-1]===Ut||r[r.length-1]===Oe)&&(r=r.slice(0,-1)),r}function Qo(r){let e="",t="";for(var i=0;iString.fromCodePoint(parseInt(i.trim(),16))),e=e.replaceAll(`\\
+`,"\\n"),e=Qo(e),e=Ut+e+Ut);try{return JSON.parse(e)}catch{throw new Error(`Failed to parse CSS property value: ${e}. Original input: ${r}`)}}var Mr=0,Lt=null,ut=null,_t=class extends HTMLElement{constructor(){super(),Pi(this,"updateCssData",()=>{var r;this.dropCssDataCache(),(r=this.__boundCssProps)==null||r.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 _t}initCallback(){}__initCallback(){var r;this.__initialized||(this.__initialized=!0,(r=this.initCallback)==null||r.call(this))}render(r,e=this.renderShadow){let t;if((e||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let s=this.getAttribute(A.USE_TPL);if(s){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(s))||document.querySelector(s);n?r=n.content.cloneNode(!0):console.warn(`Symbiote template "${s}" is not found...`)}}if(this.processInnerHtml)for(let s of this.tplProcessors)s(this,this);if(r||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(r==null?void 0:r.constructor)===DocumentFragment)t=r;else if((r==null?void 0:r.constructor)===String){let s=document.createElement("template");s.innerHTML=r,t=s.content.cloneNode(!0)}else this.constructor.__tpl&&(t=this.constructor.__tpl.content.cloneNode(!0));for(let s of this.tplProcessors)s(t,this)}let i=()=>{t&&(e&&this.shadowRoot.appendChild(t)||this.appendChild(t)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){e=!0;let s=document.createElement("link");s.rel="stylesheet",s.href=this.constructor.__shadowStylesUrl,s.onload=i,this.shadowRoot.prepend(s)}else i()}addTemplateProcessor(r){this.tplProcessors.add(r)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=Mt.generate(),this.style.setProperty(A.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(A.CSS_CTX_PROP,!0)}get ctxName(){var r;let e=((r=this.getAttribute(A.CTX_NAME_ATTR))==null?void 0:r.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=e,e}get localCtx(){return this.__localCtx||(this.__localCtx=E.registerCtx({},this)),this.__localCtx}get nodeCtx(){return E.getCtx(this.ctxName,!1)||E.registerCtx({},this.ctxName)}static __parseProp(r,e){let t,i;if(r.startsWith(A.EXT_DATA_CTX_PRFX))t=e.nodeCtx,i=r.replace(A.EXT_DATA_CTX_PRFX,"");else if(r.includes(A.NAMED_DATA_CTX_SPLTR)){let s=r.split(A.NAMED_DATA_CTX_SPLTR);t=E.getCtx(s[0]),i=s[1]}else t=e.localCtx,i=r;return{ctx:t,name:i}}sub(r,e,t=!0){let i=o=>{this.isConnected&&e(o)},s=_t.__parseProp(r,this);s.ctx.has(s.name)?this.allSubs.add(s.ctx.sub(s.name,i,t)):window.setTimeout(()=>{this.allSubs.add(s.ctx.sub(s.name,i,t))})}notify(r){let e=_t.__parseProp(r,this);e.ctx.notify(e.name)}has(r){let e=_t.__parseProp(r,this);return e.ctx.has(e.name)}add(r,e,t=!1){let i=_t.__parseProp(r,this);i.ctx.add(i.name,e,t)}add$(r,e=!1){for(let t in r)this.add(t,r[t],e)}get $(){if(!this.__stateProxy){let r=Object.create(null);this.__stateProxy=new Proxy(r,{set:(e,t,i)=>{let s=_t.__parseProp(t,this);return s.ctx.pub(s.name,i),!0},get:(e,t)=>{let i=_t.__parseProp(t,this);return i.ctx.read(i.name)}})}return this.__stateProxy}set$(r,e=!1){for(let t in r){let i=r[t];e||![String,Number,Boolean].includes(i==null?void 0:i.constructor)?this.$[t]=i:this.$[t]!==i&&(this.$[t]=i)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(A.CTX_OWNER_ATTR)&&this.getAttribute(A.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let r=this.constructor.__attrDesc;if(r)for(let e of Object.values(r))Object.keys(this.init$).includes(e)||(this.init$[e]="");for(let e in this.init$)if(e.startsWith(A.EXT_DATA_CTX_PRFX))this.nodeCtx.add(e.replace(A.EXT_DATA_CTX_PRFX,""),this.init$[e],this.__ctxOwner);else if(e.includes(A.NAMED_DATA_CTX_SPLTR)){let t=e.split(A.NAMED_DATA_CTX_SPLTR),i=t[0].trim(),s=t[1].trim();if(i&&s){let o=E.getCtx(i,!1);o||(o=E.registerCtx({},i)),o.add(s,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 r;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let e=(r=this.getAttribute(A.CTX_NAME_ATTR))==null?void 0:r.trim();if(e&&this.style.setProperty(A.CSS_CTX_PROP,`'${e}'`),this.__initDataCtx(),this[A.SET_LATER_KEY]){for(let t in this[A.SET_LATER_KEY])Rr(this,t,this[A.SET_LATER_KEY][t]);delete this[A.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let t of Ko)this.addTemplateProcessor(t);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let t=this.getRootNode();if(!t)return;if(t==null?void 0:t.querySelector(`link[${A.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let s=this.constructor.__rootStylesLink.cloneNode(!0);s.setAttribute(A.ROOT_STYLE_ATTR_NAME,this.constructor.is),s.onload=()=>{this.render()},t.nodeType===Node.DOCUMENT_NODE?t.head.appendChild(s):t.prepend(s)}else this.render()}this.connectedOnce=!0}}destroyCallback(){}disconnectedCallback(){this.connectedOnce&&(this.dropCssDataCache(),this.readyToDestroy&&(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),this.__disconnectTimeout=window.setTimeout(()=>{this.destroyCallback();for(let r of this.allSubs)r.remove(),this.allSubs.delete(r);for(let r of this.tplProcessors)this.tplProcessors.delete(r);ut==null||ut.delete(this.updateCssData),ut!=null&&ut.size||(Lt==null||Lt.disconnect(),Lt=null,ut=null)},100)))}static reg(r,e=!1){r||(Mr++,r=`${A.AUTO_TAG_PRFX}-${Mr}`),this.__tag=r;let t=window.customElements.get(r);if(t){!e&&t!==this&&console.warn([`Element with tag name "${r}" 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(r,e?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(r){this.observedAttributes=Object.keys(r),this.__attrDesc=r}attributeChangedCallback(r,e,t){var i;if(e===t)return;let s=(i=this.constructor.__attrDesc)==null?void 0:i[r];s?this.__dataCtxInitialized?this.$[s]=t:this.init$[s]=t:this[r]=t}getCssData(r,e=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(r)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let t=this.__computedStyle.getPropertyValue(r).trim();try{this.__cssDataCache[r]=tn(t)}catch{!e&&console.warn(`CSS Data error: ${r}`),this.__cssDataCache[r]=null}}return this.__cssDataCache[r]}__extractCssName(r){return r.split("--").map((e,t)=>t===0?"":e).join("--")}__initStyleAttrObserver(){ut||(ut=new Set),ut.add(this.updateCssData),Lt||(Lt=new MutationObserver(r=>{r[0].type==="attributes"&&ut.forEach(e=>{e()})}),Lt.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(r,e=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(r);let t=this.getCssData(this.__extractCssName(r),!0);t===null&&(t=e),this.add(r,t),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(r,e,t){let i="__"+r;this[i]=this[r],Object.defineProperty(this,r,{set:s=>{this[i]=s,t?window.setTimeout(()=>{e==null||e(s)}):e==null||e(s)},get:()=>this[i]}),this[r]=this[i]}static set shadowStyles(r){let e=new Blob([r],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(e)}static set rootStyles(r){if(!this.__rootStylesLink){let e=new Blob([r],{type:"text/css"}),t=URL.createObjectURL(e),i=document.createElement("link");i.href=t,i.rel="stylesheet",this.__rootStylesLink=i}}},Pt=_t;Pi(Pt,"template");var Mi=class{static _print(r){console.warn(r)}static setDefaultTitle(r){this.defaultTitle=r}static setRoutingMap(r){Object.assign(this.appMap,r);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(r){this.__routingEventName=r}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let r={route:null,options:{}};return window.location.search.split(this.separator).forEach(t=>{if(t.includes("?"))r.route=t.replace("?","");else if(t.includes("=")){let i=t.split("=");r.options[i[0]]=decodeURI(i[1])}else r.options[t]=!0}),r}static notify(){let r=this.readAddressBar(),e=this.appMap[r.route];if(e&&e.title&&(document.title=e.title),r.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 "${r.route}" not found...`);return}let t=new CustomEvent(Mi.routingEventName,{detail:{route:r.route,options:Object.assign(e||{},r.options)}});window.dispatchEvent(t)}static reflect(r,e={}){let t=this.appMap[r];if(!t){this._print("Wrong route: "+r);return}let i="?"+r;for(let o in e)e[o]===!0?i+=this.separator+o:i+=this.separator+o+`=${e[o]}`;let s=t.title||this.defaultTitle||"";window.history.pushState(null,s,i),document.title=s}static applyRoute(r,e={}){this.reflect(r,e),this.notify()}static setSeparator(r){this._separator=r}static get separator(){return this._separator||"&"}static createRouterData(r,e){this.setRoutingMap(e);let t=E.registerCtx({route:null,options:null,title:null},r);return window.addEventListener(this.routingEventName,i=>{var s;t.multiPub({route:i.detail.route,options:i.detail.options,title:((s=i.detail.options)==null?void 0:s.title)||this.defaultTitle||""})}),Mi.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}};Mi.appMap=Object.create(null);function Qt(r,e){for(let t in e)t.includes("-")?r.style.setProperty(t,e[t]):r.style[t]=e[t]}function en(r,e){for(let t in e)e[t].constructor===Boolean?e[t]?r.setAttribute(t,""):r.removeAttribute(t):r.setAttribute(t,e[t])}function Ri(r={tag:"div"}){let e=document.createElement(r.tag);if(r.attributes&&en(e,r.attributes),r.styles&&Qt(e,r.styles),r.properties)for(let t in r.properties)e[t]=r.properties[t];return r.processors&&r.processors.forEach(t=>{t(e)}),r.children&&r.children.forEach(t=>{let i=Ri(t);e.appendChild(i)}),e}var Fr="idb-store-ready",rn="symbiote-db",sn="symbiote-idb-update_",on=class{_notifyWhenReady(r=null){window.dispatchEvent(new CustomEvent(Fr,{detail:{dbName:this.name,storeName:this.storeName,event:r}}))}get _updEventName(){return sn+this.name}_getUpdateEvent(r){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:r}})}_notifySubscribers(r){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,r),window.dispatchEvent(this._getUpdateEvent(r))}constructor(r,e){this.name=r,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=i=>{this._notifyWhenReady(i)}},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 s=>{s(await this.read(t.newValue))})},this._localUpdateHandler=t=>{this._updateHandler(t.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(r){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(r);return new Promise((i,s)=>{t.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?i(o.target.result._value):(i(null),console.warn(`IDB: cannot read "${r}"`))},t.onerror=o=>{s(o)}})}write(r,e,t=!1){let i={_key:r,_value:e},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(i);return new Promise((n,l)=>{o.onsuccess=a=>{t||this._notifySubscribers(r),n(a.target.result)},o.onerror=a=>{l(a)}})}delete(r,e=!1){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(r);return new Promise((s,o)=>{i.onsuccess=n=>{e||this._notifySubscribers(r),s(n)},i.onerror=n=>{o(n)}})}getAll(){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((t,i)=>{e.onsuccess=s=>{let o=s.target.result;t(o.map(n=>n._value))},e.onerror=s=>{i(s)}})}subscribe(r,e){this._subscriptionsMap[r]||(this._subscriptionsMap[r]=new Set);let t=this._subscriptionsMap[r];return t.add(e),{remove:()=>{t.delete(e),t.size||delete this._subscriptionsMap[r]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,Dr.clear(this.name)}},Dr=class{static get readyEventName(){return Fr}static open(r=rn,e="store"){let t=r+"/"+e;return this._reg[t]||(this._reg[t]=new on(r,e)),this._reg[t]}static clear(r){window.indexedDB.deleteDatabase(r);for(let e in this._reg)e.split("/")[0]===r&&delete this._reg[e]}};Pi(Dr,"_reg",Object.create(null));var Nr=r=>{if(typeof r!="string"||!r)return"";let e=r.trim();return e.startsWith("-/")?e=e.slice(2):e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,e.length-1)),e},Le=(...r)=>r.filter(e=>typeof e=="string"&&e).map(e=>Nr(e)).join("/-/"),D=(...r)=>{let e=Le(...r);return e?`-/${e}/`:""};function Ue(r){let e=new URL(r),t=e.pathname+e.search+e.hash,i=t.lastIndexOf("http"),s=t.lastIndexOf("/"),o="";return i>=0?o=t.slice(i):s>=0&&(o=t.slice(s+1)),o}function Me(r){let e=new URL(r),{pathname:t}=e,i=t.indexOf("/"),s=t.indexOf("/",i+1);return t.substring(i+1,s)}function Fi(r){let e=zr(r),t=new URL(e),i=t.pathname.indexOf("/-/");return i===-1?"":t.pathname.substring(i).slice(1)}function Br(r){return Fi(r).split("/-/").filter(Boolean).map(t=>Nr(t))}function zr(r){let e=new URL(r),t=Ue(r),i=Vr(t)?jr(t).pathname:t;return e.pathname=e.pathname.replace(i,""),e.search="",e.hash="",e.toString()}function Vr(r){return r.startsWith("http")}function jr(r){let e=new URL(r);return{pathname:e.origin+e.pathname||"",search:e.search||"",hash:e.hash||""}}var U=(r,e,t)=>{let i=new URL(zr(r));if(t=t||Ue(r),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),Vr(t)){let s=jr(t);i.pathname=i.pathname+(e||"")+(s.pathname||""),i.search=s.search,i.hash=s.hash}else i.pathname=i.pathname+(e||"")+(t||"");return i.toString()},yt=(r,e)=>{let t=new URL(r);return t.pathname=e+"/",t.toString()};var N=(r,e=",")=>r.trim().split(e).map(t=>t.trim()).filter(t=>t.length>0);var X=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}),Gr=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function nn(r,e){if(typeof e=="number"){let t=e;return X[r]!==t?`${r}/${t}`:""}if(typeof e=="boolean"){let t=e;return X[r]!==t?`${r}`:""}if(r==="filter"&&e){let{name:t,amount:i}=e;return X.filter===i?"":`${r}/${t}/${i}`}if(r==="crop"&&e){let{dimensions:t,coords:i}=e;return`${r}/${t.join("x")}/${i.join(",")}`}return""}function vt(r){return Le(...Gr.filter(e=>typeof r[e]!="undefined"&&r[e]!==null).map(e=>{let t=r[e];return nn(e,t)}).filter(e=>!!e))}var Pe=Le("format/auto","progressive/yes"),ht=([r])=>typeof r!="undefined"?Number(r):void 0,Hr=()=>!0,ln=([r,e])=>({name:r,amount:typeof e!="undefined"?Number(e):100}),an=([r,e])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(e))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:N(r,"x").map(Number),coords:N(e).map(Number)}},cn=Object.freeze({enhance:ht,brightness:ht,exposure:ht,gamma:ht,contrast:ht,saturation:ht,vibrance:ht,warmth:ht,filter:ln,mirror:Hr,flip:Hr,rotate:ht,crop:an});function Wr(r){let e={};for(let t of r){let[i,...s]=t.split("/");if(!Gr.includes(i))continue;let o=i,n=cn[o];try{let l=n(s);e[o]=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}var I=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),H=[I.CROP,I.TUNING,I.FILTERS],Xr=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],qr=["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"],Kr=["rotate","mirror","flip"],it=Object.freeze({brightness:{zero:X.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:X.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:X.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:X.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:X.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:X.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:X.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:X.enhance,range:[0,100],keypointsNumber:1},filter:{zero:X.filter,range:[0,100],keypointsNumber:1}});var Zr=r=>r?r.split(",").map(e=>e.trim()):[],Rt=r=>r?r.join(","):"";var un="https://ucarecdn.com",hn="https://upload.uploadcare.com",dn="https://social.uploadcare.com",J={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",cloudImageEditorTabs:Rt(H),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:un,baseUrl:hn,socialBaseUrl:dn,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:1,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[]};var 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"}),Re=class{constructor(e){u(this,"_timeoutStore",new Map);u(this,"_targets",new Set);u(this,"_debugPrint",null);this._debugPrint=e}bindTarget(e){this._targets.add(e)}unbindTarget(e){this._targets.delete(e)}_dispatch(e,t){var i;for(let s of this._targets)s.dispatchEvent(new CustomEvent(e,{detail:t}));(i=this._debugPrint)==null||i.call(this,()=>{let s=t&&typeof t=="object"?{...t}:t;return[`event "${e}"`,s]})}emit(e,t,{debounce:i}={}){if(typeof i!="number"&&!i){this._dispatch(e,typeof t=="function"?t():t);return}this._timeoutStore.has(e)&&window.clearTimeout(this._timeoutStore.get(e));let s=typeof i=="number"?i:20,o=window.setTimeout(()=>{this._dispatch(e,typeof t=="function"?t():t),this._timeoutStore.delete(e)},s);this._timeoutStore.set(e,o)}};function O(r,e){let t,i=(...s)=>{clearTimeout(t),t=setTimeout(()=>r(...s),e)};return i.cancel=()=>{clearTimeout(t)},i}var Yr="--uploadcare-blocks-window-height",St=class{static registerClient(e){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(e)}static unregisterClient(e){this.clientsRegistry.delete(e),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(Yr)}};u(St,"clientsRegistry",new Set),u(St,"flush",O(()=>{document.documentElement.style.setProperty(Yr,`${window.innerHeight}px`)},100));var Jr=r=>{var i;let e=new Intl.Locale(r),t="ltr";return typeof e.getTextInfo=="function"&&e.getTextInfo().direction?t=e.getTextInfo().direction:"textInfo"in e&&((i=e.textInfo)!=null&&i.direction)&&(t=e.textInfo.direction),t};var Fe=(r,e)=>new Intl.PluralRules(r).select(e);var pn=r=>r,Di="{{",ts="}}",Qr="plural:";function te(r,e,t={}){var n;let{openToken:i=Di,closeToken:s=ts,transform:o=pn}=t;for(let l in e){let a=(n=e[l])==null?void 0:n.toString();r=r.replaceAll(i+l+s,typeof a=="string"?o(a):a)}return r}function es(r){let e=[],t=r.indexOf(Di);for(;t!==-1;){let i=r.indexOf(ts,t),s=r.substring(t+2,i);if(s.startsWith(Qr)){let o=r.substring(t+2,i).replace(Qr,""),n=o.substring(0,o.indexOf("(")),l=o.substring(o.indexOf("(")+1,o.indexOf(")"));e.push({variable:s,pluralKey:n,countVariable:l})}t=r.indexOf(Di,i)}return e}var is=({element:r,attribute:e,onSuccess:t,onTimeout:i,timeout:s=300})=>{let o=r.getAttribute(e);if(o!==null){t(o);return}let n=new MutationObserver(c=>{let h=c[c.length-1];a(h)});n.observe(r,{attributes:!0,attributeFilter:[e]});let l=setTimeout(()=>{n.disconnect(),i()},s),a=c=>{let h=r.getAttribute(e);c.type==="attributes"&&c.attributeName===e&&h!==null&&(clearTimeout(l),n.disconnect(),t(h))}};function rs(r){return Object.prototype.toString.call(r)==="[object Object]"}var fn=/\W|_/g;function mn(r){return r.split(fn).map((e,t)=>e.charAt(0)[t>0?"toUpperCase":"toLowerCase"]()+e.slice(1)).join("")}function ss(r,{ignoreKeys:e}={ignoreKeys:[]}){return Array.isArray(r)?r.map(t=>ft(t,{ignoreKeys:e})):r}function ft(r,{ignoreKeys:e}={ignoreKeys:[]}){if(Array.isArray(r))return ss(r,{ignoreKeys:e});if(!rs(r))return r;let t={};for(let i of Object.keys(r)){let s=r[i];if(e.includes(i)){t[i]=s;continue}rs(s)?s=ft(s,{ignoreKeys:e}):Array.isArray(s)&&(s=ss(s,{ignoreKeys:e})),t[mn(i)]=s}return t}var gn=r=>new Promise(e=>setTimeout(e,r));function Gi({libraryName:r,libraryVersion:e,userAgent:t,publicKey:i="",integration:s=""}){let o="JavaScript";if(typeof t=="string")return t;if(typeof t=="function")return t({publicKey:i,libraryName:r,libraryVersion:e,languageName:o,integration:s});let n=[r,e,i].filter(Boolean).join("/"),l=[o,s].filter(Boolean).join("; ");return`${n} (${l})`}var bn={factor:2,time:100};function _n(r,e=bn){let t=0;function i(s){let o=Math.round(e.time*e.factor**t);return s({attempt:t,retry:l=>gn(l!=null?l:o).then(()=>(t+=1,i(s)))})}return i(r)}var ee=class extends Error{},Ft=class r extends ee{constructor(t){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,r.prototype),this.originalProgressEvent=t}},Ne=(r,e)=>{r&&(r.aborted?Promise.resolve().then(e):r.addEventListener("abort",()=>e(),{once:!0}))},wt=class r extends ee{constructor(t="Request canceled"){super(t);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,r.prototype)}},yn=500,ns=({check:r,interval:e=yn,timeout:t,signal:i})=>new Promise((s,o)=>{let n,l;Ne(i,()=>{n&&clearTimeout(n),o(new wt("Poll cancelled"))}),t&&(l=setTimeout(()=>{n&&clearTimeout(n),o(new wt("Timed out"))},t));let a=()=>{try{Promise.resolve(r(i)).then(c=>{c?(l&&clearTimeout(l),s(c)):n=setTimeout(a,e)}).catch(c=>{l&&clearTimeout(l),o(c)})}catch(c){l&&clearTimeout(l),o(c)}};n=setTimeout(a,0)}),T={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"},Be="application/octet-stream",ls="original",Ct=({method:r,url:e,data:t,headers:i={},signal:s,onProgress:o})=>new Promise((n,l)=>{let a=new XMLHttpRequest,c=(r==null?void 0:r.toUpperCase())||"GET",h=!1;a.open(c,e,!0),i&&Object.entries(i).forEach(d=>{let[p,m]=d;typeof m!="undefined"&&!Array.isArray(m)&&a.setRequestHeader(p,m)}),a.responseType="text",Ne(s,()=>{h=!0,a.abort(),l(new wt)}),a.onload=()=>{if(a.status!=200)l(new Error(`Error ${a.status}: ${a.statusText}`));else{let d={method:c,url:e,data:t,headers:i||void 0,signal:s,onProgress:o},p=a.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};p.forEach(function(v){let w=v.split(": "),y=w.shift(),C=w.join(": ");y&&typeof y!="undefined"&&(m[y]=C)});let f=a.response,g=a.status;n({request:d,data:f,headers:m,status:g})}},a.onerror=d=>{h||l(new Ft(d))},o&&typeof o=="function"&&(a.upload.onprogress=d=>{d.lengthComputable?o({isComputable:!0,value:d.loaded/d.total}):o({isComputable:!1})}),t?a.send(t):a.send()});function vn(r,...e){return r}var wn=({name:r})=>r?[r]:[],Cn=vn,xn=()=>new FormData,as=r=>!1,ze=r=>typeof Blob!="undefined"&&r instanceof Blob,Ve=r=>typeof File!="undefined"&&r instanceof File,je=r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&"uri"in r&&typeof r.uri=="string",Dt=r=>ze(r)||Ve(r)||as()||je(r),An=r=>typeof r=="string"||typeof r=="number"||typeof r=="undefined",En=r=>!!r&&typeof r=="object"&&!Array.isArray(r),Tn=r=>!!r&&typeof r=="object"&&"data"in r&&Dt(r.data);function cs(r,e,t){if(Array.isArray(t))for(let i of t)cs(r,`${e}[]`,i);else if(Tn(t)){let{name:i,contentType:s}=t,o=Cn(t.data,i,s!=null?s:Be),n=wn({name:i,contentType:s});r.push([e,o,...n])}else if(En(t))for(let[i,s]of Object.entries(t))typeof s!="undefined"&&r.push([`${e}[${i}]`,String(s)]);else An(t)&&t&&r.push([e,t.toString()])}function Sn(r){let e=[];for(let[t,i]of Object.entries(r))cs(e,t,i);return e}function He(r){let e=xn(),t=Sn(r);for(let i of t){let[s,o,...n]=i;e.append(s,o,...n)}return e}var B=class r extends ee{constructor(t,i,s,o,n){super();u(this,"code");u(this,"request");u(this,"response");u(this,"headers");this.name="UploadError",this.message=t,this.code=i,this.request=s,this.response=o,this.headers=n,Object.setPrototypeOf(this,r.prototype)}},kn=r=>{let e=new URLSearchParams;for(let[t,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=>e.set(`${t}[${s[0]}]`,String(s[1]))):Array.isArray(i)?i.forEach(s=>{e.append(`${t}[]`,s)}):typeof i=="string"&&i?e.set(t,i):typeof i=="number"&&e.set(t,i.toString());return e.toString()},dt=(r,e,t)=>{let i=new URL(r);return i.pathname=(i.pathname+e).replace("//","/"),t&&(i.search=kn(t)),i.toString()},$n="6.14.1",In="UploadcareUploadClient",On=$n;function kt(r){return Gi({libraryName:In,libraryVersion:On,...r})}var Ln="RequestThrottledError",os=15e3,Un=1e3;function Mn(r){let{headers:e}=r||{};if(!e||typeof e["retry-after"]!="string")return os;let t=parseInt(e["retry-after"],10);return Number.isFinite(t)?t*1e3:os}function xt(r,e){let{retryThrottledRequestMaxTimes:t,retryNetworkErrorMaxTimes:i}=e;return _n(({attempt:s,retry:o})=>r().catch(n=>{if("response"in n&&(n==null?void 0:n.code)===Ln&&s{let e="";return(ze(r)||Ve(r)||je(r))&&(e=r.type),e||Be},hs=r=>{let e="";return Ve(r)&&r.name?e=r.name:ze(r)||as()?e="":je(r)&&r.name&&(e=r.name),e||ls};function Wi(r){return typeof r=="undefined"||r==="auto"?"auto":r?"1":"0"}function Pn(r,{publicKey:e,fileName:t,contentType:i,baseURL:s=T.baseURL,secureSignature:o,secureExpire:n,store:l,signal:a,onProgress:c,source:h="local",integration:d,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xt(()=>Ct({method:"POST",url:dt(s,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":kt({publicKey:e,integration:d,userAgent:p})},data:He({file:{data:r,name:t||hs(r),contentType:i||us(r)},UPLOADCARE_PUB_KEY:e,UPLOADCARE_STORE:Wi(l),signature:o,expire:n,source:h,metadata:g}),signal:a,onProgress:c}).then(({data:v,headers:w,request:y})=>{let C=ft(JSON.parse(v));if("error"in C)throw new B(C.error.content,C.error.errorCode,y,C,w);return C}),{retryNetworkErrorMaxTimes:f,retryThrottledRequestMaxTimes:m})}var zi;(function(r){r.Token="token",r.FileInfo="file_info"})(zi||(zi={}));function Rn(r,{publicKey:e,baseURL:t=T.baseURL,store:i,fileName:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:l,secureExpire:a,source:c="url",signal:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xt(()=>Ct({method:"POST",headers:{"X-UC-User-Agent":kt({publicKey:e,integration:d,userAgent:p})},url:dt(t,"/from_url/",{jsonerrors:1,pub_key:e,source_url:r,store:Wi(i),filename:s,check_URL_duplicates:o?1:void 0,save_URL_duplicates:n?1:void 0,signature:l,expire:a,source:c,metadata:g}),signal:h}).then(({data:v,headers:w,request:y})=>{let C=ft(JSON.parse(v));if("error"in C)throw new B(C.error.content,C.error.errorCode,y,C,w);return C}),{retryNetworkErrorMaxTimes:f,retryThrottledRequestMaxTimes:m})}var G;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(G||(G={}));var Fn=r=>"status"in r&&r.status===G.Error;function Dn(r,{publicKey:e,baseURL:t=T.baseURL,signal:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=T.retryNetworkErrorMaxTimes}={}){return xt(()=>Ct({method:"GET",headers:e?{"X-UC-User-Agent":kt({publicKey:e,integration:s,userAgent:o})}:void 0,url:dt(t,"/from_url/status/",{jsonerrors:1,token:r}),signal:i}).then(({data:a,headers:c,request:h})=>{let d=ft(JSON.parse(a));if("error"in d&&!Fn(d))throw new B(d.error.content,d.error.errorCode,h,d,c);return d}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:n})}function Nn(r,{publicKey:e,baseURL:t=T.baseURL,jsonpCallback:i,secureSignature:s,secureExpire:o,signal:n,source:l,integration:a,userAgent:c,retryThrottledRequestMaxTimes:h=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:d=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"POST",headers:{"X-UC-User-Agent":kt({publicKey:e,integration:a,userAgent:c})},url:dt(t,"/group/",{jsonerrors:1}),data:He({files:r,callback:i,pub_key:e,signature:s,expire:o,source:l}),signal:n}).then(({data:p,headers:m,request:f})=>{let g=ft(JSON.parse(p));if("error"in g)throw new B(g.error.content,g.error.errorCode,f,g,m);return g}),{retryNetworkErrorMaxTimes:d,retryThrottledRequestMaxTimes:h})}function ds(r,{publicKey:e,baseURL:t=T.baseURL,signal:i,source:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:l=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"GET",headers:{"X-UC-User-Agent":kt({publicKey:e,integration:o,userAgent:n})},url:dt(t,"/info/",{jsonerrors:1,pub_key:e,file_id:r,source:s}),signal:i}).then(({data:c,headers:h,request:d})=>{let p=ft(JSON.parse(c));if("error"in p)throw new B(p.error.content,p.error.errorCode,d,p,h);return p}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Bn(r,{publicKey:e,contentType:t,fileName:i,multipartChunkSize:s=T.multipartChunkSize,baseURL:o="",secureSignature:n,secureExpire:l,store:a,signal:c,source:h="local",integration:d,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xt(()=>Ct({method:"POST",url:dt(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":kt({publicKey:e,integration:d,userAgent:p})},data:He({filename:i||ls,size:r,content_type:t||Be,part_size:s,UPLOADCARE_STORE:Wi(a),UPLOADCARE_PUB_KEY:e,signature:n,expire:l,source:h,metadata:g}),signal:c}).then(({data:v,headers:w,request:y})=>{let C=ft(JSON.parse(v));if("error"in C)throw new B(C.error.content,C.error.errorCode,y,C,w);return C.parts=Object.keys(C.parts).map(M=>C.parts[Number(M)]),C}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})}function zn(r,e,{contentType:t,signal:i,onProgress:s,retryThrottledRequestMaxTimes:o=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"PUT",url:e,data:r,onProgress:s,signal:i,headers:{"Content-Type":t||Be}}).then(l=>(s&&s({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n})}function Vn(r,{publicKey:e,baseURL:t=T.baseURL,source:i="local",signal:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:l=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"POST",url:dt(t,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":kt({publicKey:e,integration:o,userAgent:n})},data:He({uuid:r,UPLOADCARE_PUB_KEY:e,source:i}),signal:s}).then(({data:c,headers:h,request:d})=>{let p=ft(JSON.parse(c));if("error"in p)throw new B(p.error.content,p.error.errorCode,d,p,h);return p}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Xi(r,{publicKey:e,baseURL:t,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:l,signal:a,onProgress:c}){return ns({check:h=>ds(r,{publicKey:e,baseURL:t,signal:h,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:l}).then(d=>d.isReady?d:(c&&c({isComputable:!0,value:1}),!1)),signal:a})}function jn(r){return"defaultEffects"in r}var pt=class{constructor(e,{baseCDN:t=T.baseCDN,fileName:i}={}){u(this,"uuid");u(this,"name",null);u(this,"size",null);u(this,"isStored",null);u(this,"isImage",null);u(this,"mimeType",null);u(this,"cdnUrl",null);u(this,"s3Url",null);u(this,"originalFilename",null);u(this,"imageInfo",null);u(this,"videoInfo",null);u(this,"contentInfo",null);u(this,"metadata",null);u(this,"s3Bucket",null);u(this,"defaultEffects",null);let{uuid:s,s3Bucket:o}=e,n=dt(t,`${s}/`),l=o?dt(`https://${o}.s3.amazonaws.com/`,`${s}/${e.filename}`):null;this.uuid=s,this.name=i||e.filename,this.size=e.size,this.isStored=e.isStored,this.isImage=e.isImage,this.mimeType=e.mimeType,this.cdnUrl=n,this.originalFilename=e.originalFilename,this.imageInfo=e.imageInfo,this.videoInfo=e.videoInfo,this.contentInfo=e.contentInfo,this.metadata=e.metadata||null,this.s3Bucket=o||null,this.s3Url=l,jn(e)&&(this.defaultEffects=e.defaultEffects)}},Hn=(r,{publicKey:e,fileName:t,baseURL:i,secureSignature:s,secureExpire:o,store:n,contentType:l,signal:a,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:g,metadata:v})=>Pn(r,{publicKey:e,fileName:t,contentType:l,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,metadata:v}).then(({file:w})=>Xi(w,{publicKey:e,baseURL:i,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,onProgress:c,signal:a})).then(w=>new pt(w,{baseCDN:g})),Gn=(r,{publicKey:e,fileName:t,baseURL:i,signal:s,onProgress:o,source:n,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h,baseCDN:d})=>ds(r,{publicKey:e,baseURL:i,signal:s,source:n,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h}).then(p=>new pt(p,{baseCDN:d,fileName:t})).then(p=>(o&&o({isComputable:!0,value:1}),p)),Wn=(r,{signal:e}={})=>{let t=null,i=null,s=r.map(()=>new AbortController),o=n=>()=>{i=n,s.forEach((l,a)=>a!==n&&l.abort())};return Ne(e,()=>{s.forEach(n=>n.abort())}),Promise.all(r.map((n,l)=>{let a=o(l);return Promise.resolve().then(()=>n({stopRace:a,signal:s[l].signal})).then(c=>(a(),c)).catch(c=>(t=c,null))})).then(n=>{if(i===null)throw t;return n[i]})},Xn=window.WebSocket,Vi=class{constructor(){u(this,"events",Object.create({}))}emit(e,t){var i;(i=this.events[e])==null||i.forEach(s=>s(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(i=>i!==t):this.events[e]=[]}},qn=(r,e)=>r==="success"?{status:G.Success,...e}:r==="progress"?{status:G.Progress,...e}:{status:G.Error,...e},ji=class{constructor(e,t=3e4){u(this,"key");u(this,"disconnectTime");u(this,"ws");u(this,"queue",[]);u(this,"isConnected",!1);u(this,"subscribers",0);u(this,"emmitter",new Vi);u(this,"disconnectTimeoutId",null);this.key=e,this.disconnectTime=t}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let e=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new Xn(e),this.ws.addEventListener("error",t=>{this.emmitter.emit("error",new Error(t.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(t=>this.send(t.event,t.data)),this.queue=[]}),this.ws.addEventListener("message",t=>{let i=JSON.parse(t.data.toString());switch(i.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(i.channel,qn(i.event,JSON.parse(i.data)))}})}}disconnect(){let e=()=>{var t;(t=this.ws)==null||t.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{e()},this.disconnectTime):e()}send(e,t){var s;let i=JSON.stringify({event:e,data:t});(s=this.ws)==null||s.send(i)}subscribe(e,t){this.subscribers+=1,this.connect();let i=`task-status-${e}`,s={event:"pusher:subscribe",data:{channel:i}};this.emmitter.on(i,t),this.isConnected?this.send(s.event,s.data):this.queue.push(s)}unsubscribe(e){this.subscribers-=1;let t=`task-status-${e}`,i={event:"pusher:unsubscribe",data:{channel:t}};this.emmitter.off(t),this.isConnected?this.send(i.event,i.data):this.queue=this.queue.filter(s=>s.data.channel!==t),this.subscribers===0&&this.disconnect()}onError(e){return this.emmitter.on("error",e),()=>this.emmitter.off("error",e)}},Ni=null,qi=r=>{if(!Ni){let e=typeof window=="undefined"?0:3e4;Ni=new ji(r,e)}return Ni},Kn=r=>{qi(r).connect()};function Zn({token:r,publicKey:e,baseURL:t,integration:i,userAgent:s,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,onProgress:l,signal:a}){return ns({check:c=>Dn(r,{publicKey:e,baseURL:t,integration:i,userAgent:s,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,signal:c}).then(h=>{switch(h.status){case G.Error:return new B(h.error,h.errorCode);case G.Waiting:return!1;case G.Unknown:return new B(`Token "${r}" was not found.`);case G.Progress:return l&&(h.total==="unknown"?l({isComputable:!1}):l({isComputable:!0,value:h.done/h.total})),!1;case G.Success:return l&&l({isComputable:!0,value:h.done/h.total}),h;default:throw new Error("Unknown status")}}),signal:a})}var Yn=({token:r,pusherKey:e,signal:t,onProgress:i})=>new Promise((s,o)=>{let n=qi(e),l=n.onError(o),a=()=>{l(),n.unsubscribe(r)};Ne(t,()=>{a(),o(new wt("pusher cancelled"))}),n.subscribe(r,c=>{switch(c.status){case G.Progress:{i&&(c.total==="unknown"?i({isComputable:!1}):i({isComputable:!0,value:c.done/c.total}));break}case G.Success:{a(),i&&i({isComputable:!0,value:c.done/c.total}),s(c);break}case G.Error:a(),o(new B(c.msg,c.error_code))}})}),Jn=(r,{publicKey:e,fileName:t,baseURL:i,baseCDN:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:l,secureExpire:a,store:c,signal:h,onProgress:d,source:p,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,pusherKey:v=T.pusherKey,metadata:w})=>Promise.resolve(Kn(v)).then(()=>Rn(r,{publicKey:e,fileName:t,baseURL:i,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:l,secureExpire:a,store:c,signal:h,source:p,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,metadata:w})).catch(y=>{let C=qi(v);return C==null||C.disconnect(),Promise.reject(y)}).then(y=>y.type===zi.FileInfo?y:Wn([({signal:C})=>Zn({token:y.token,publicKey:e,baseURL:i,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,onProgress:d,signal:C}),({signal:C})=>Yn({token:y.token,pusherKey:v,signal:C,onProgress:d})],{signal:h})).then(y=>{if(y instanceof B)throw y;return y}).then(y=>Xi(y.uuid,{publicKey:e,baseURL:i,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,onProgress:d,signal:h})).then(y=>new pt(y,{baseCDN:s})),Bi=new WeakMap,Qn=async r=>{if(Bi.has(r))return Bi.get(r);let e=await fetch(r.uri).then(t=>t.blob());return Bi.set(r,e),e},ps=async r=>{if(Ve(r)||ze(r))return r.size;if(je(r))return(await Qn(r)).size;throw new Error("Unknown file type. Cannot determine file size.")},tl=(r,e=T.multipartMinFileSize)=>r>=e,fs=r=>{let e="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",t=new RegExp(e);return!Dt(r)&&t.test(r)},Ki=r=>{let e="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",t=new RegExp(e);return!Dt(r)&&t.test(r)},el=(r,e)=>new Promise((t,i)=>{let s=[],o=!1,n=e.length,l=[...e],a=()=>{let c=e.length-l.length,h=l.shift();h&&h().then(d=>{o||(s[c]=d,n-=1,n?a():t(s))}).catch(d=>{o=!0,i(d)})};for(let c=0;c{let s=i*e,o=Math.min(s+i,t);return r.slice(s,o)},rl=async(r,e,t)=>i=>il(r,i,e,t),sl=(r,e,{publicKey:t,contentType:i,onProgress:s,signal:o,integration:n,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})=>zn(r,e,{publicKey:t,contentType:i,onProgress:s,signal:o,integration:n,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a}),ol=async(r,{publicKey:e,fileName:t,fileSize:i,baseURL:s,secureSignature:o,secureExpire:n,store:l,signal:a,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartChunkSize:v=T.multipartChunkSize,maxConcurrentRequests:w=T.maxConcurrentRequests,baseCDN:y,metadata:C})=>{let M=i!=null?i:await ps(r),q,tt=(P,V)=>{if(!c)return;q||(q=Array(P).fill(0));let Y=et=>et.reduce((ct,Ui)=>ct+Ui,0);return et=>{et.isComputable&&(q[V]=et.value,c({isComputable:!0,value:Y(q)/P}))}};return g||(g=us(r)),Bn(M,{publicKey:e,contentType:g,fileName:t||hs(r),baseURL:s,secureSignature:o,secureExpire:n,store:l,signal:a,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,metadata:C}).then(async({uuid:P,parts:V})=>{let Y=await rl(r,M,v);return Promise.all([P,el(w,V.map((et,ct)=>()=>sl(Y(ct),et,{publicKey:e,contentType:g,onProgress:tt(V.length,ct),signal:a,integration:d,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})))])}).then(([P])=>Vn(P,{publicKey:e,baseURL:s,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})).then(P=>P.isReady?P:Xi(P.uuid,{publicKey:e,baseURL:s,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,onProgress:c,signal:a})).then(P=>new pt(P,{baseCDN:y}))};async function Zi(r,{publicKey:e,fileName:t,baseURL:i=T.baseURL,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartMinFileSize:g,multipartChunkSize:v,maxConcurrentRequests:w,baseCDN:y=T.baseCDN,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:M,pusherKey:q,metadata:tt}){if(Dt(r)){let P=await ps(r);return tl(P,g)?ol(r,{publicKey:e,contentType:f,multipartChunkSize:v,fileSize:P,fileName:t,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:h,userAgent:d,maxConcurrentRequests:w,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y,metadata:tt}):Hn(r,{publicKey:e,fileName:t,contentType:f,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y,metadata:tt})}if(Ki(r))return Jn(r,{publicKey:e,fileName:t,baseURL:i,baseCDN:y,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:M,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,pusherKey:q,metadata:tt});if(fs(r))return Gn(r,{publicKey:e,fileName:t,baseURL:i,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y});throw new TypeError(`File uploading from "${r}" is not supported`)}var Hi=class{constructor(e,{baseCDN:t=T.baseCDN}={}){u(this,"uuid");u(this,"filesCount");u(this,"totalSize");u(this,"isStored");u(this,"isImage");u(this,"cdnUrl");u(this,"files");u(this,"createdAt");u(this,"storedAt",null);this.uuid=e.id,this.filesCount=e.filesCount;let i=e.files.filter(Boolean);this.totalSize=Object.values(i).reduce((s,o)=>s+o.size,0),this.isStored=!!e.datetimeStored,this.isImage=!!Object.values(i).filter(s=>s.isImage).length,this.cdnUrl=e.cdnUrl,this.files=i.map(s=>new pt(s,{baseCDN:t})),this.createdAt=e.datetimeCreated,this.storedAt=e.datetimeStored}},nl=r=>{for(let e of r)if(!Dt(e))return!1;return!0},ll=r=>{for(let e of r)if(!fs(e))return!1;return!0},al=r=>{for(let e of r)if(!Ki(e))return!1;return!0};function ms(r,{publicKey:e,fileName:t,baseURL:i=T.baseURL,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartChunkSize:g=T.multipartChunkSize,baseCDN:v=T.baseCDN,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:y,jsonpCallback:C}){if(!nl(r)&&!al(r)&&!ll(r))throw new TypeError(`Group uploading from "${r}" is not supported`);let M,q=!0,tt=r.length,P=(V,Y)=>{if(!a)return;M||(M=Array(V).fill(0));let et=ct=>ct.reduce((Ui,Lo)=>Ui+Lo)/V;return ct=>{if(!ct.isComputable||!q){q=!1,a({isComputable:!1});return}M[Y]=ct.value,a({isComputable:!0,value:et(M)})}};return Promise.all(r.map((V,Y)=>Dt(V)||Ki(V)?Zi(V,{publicKey:e,fileName:t,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:P(tt,Y),source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartChunkSize:g,baseCDN:v,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:y}).then(et=>et.uuid):V)).then(V=>Nn(V,{publicKey:e,baseURL:i,jsonpCallback:C,secureSignature:s,secureExpire:o,signal:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m}).then(Y=>new Hi(Y,{baseCDN:v})).then(Y=>(a&&a({isComputable:!0,value:1}),Y)))}var De=class{constructor(e){u(this,"_concurrency",1);u(this,"_pending",[]);u(this,"_running",0);u(this,"_resolvers",new Map);u(this,"_rejectors",new Map);this._concurrency=e}_run(){let e=this._concurrency-this._running;for(let t=0;t{this._resolvers.delete(i),this._rejectors.delete(i),this._running-=1,this._run()}).then(n=>s(n)).catch(n=>o(n))}}add(e){return new Promise((t,i)=>{this._resolvers.set(e,t),this._rejectors.set(e,i),this._pending.push(e),this._run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(e){this._concurrency=e,this._run()}get concurrency(){return this._concurrency}};var Yi=()=>({}),Ji=r=>({...Yi(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{r.set$({"*currentActivity":null,"*modalActive":!1})}}),Ge=r=>({...Ji(r),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new De(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null});var ie={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"Selected:","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-instagram":"Instagram","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"Onedrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error ocurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}"};var We=new Map,Qi=new Map,gs=(r,e)=>{We.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`),We.set(r,{...ie,...e})},cl=(r,e)=>{Qi.set(r,e)},bs=(r,e)=>{typeof e=="function"?cl(r,e):gs(r,e)},_s=async r=>{if(!We.has(r)){if(!Qi.has(r))throw new Error(`Locale ${r} is not defined`);let t=await Qi.get(r)();gs(r,t)}return We.get(r)};bs("en",ie);var mt=r=>`*l10n/${r}`,ul="en",Xe=class{constructor(e){u(this,"_blockInstance",null);u(this,"_localeName","");u(this,"_callbacks",new Set);u(this,"_boundBlocks",new Map);this._blockInstance=e;for(let[t,i]of Object.entries(ie))this._blockInstance.add(mt(t),i,!1);setTimeout(()=>{e.subConfigValue("localeName",async t=>{var o;if(!this._blockInstance||!t)return;this._localeName=t;let i=await _s(t);if(t!==ul&&this._localeName!==t)return;let s=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[t];for(let[n,l]of Object.entries(i)){let a=s==null?void 0:s[n];this._blockInstance.add(mt(n),a!=null?a:l,!0);for(let c of this._callbacks)c()}}),e.subConfigValue("localeDefinitionOverride",t=>{var s;if(!t)return;let i=t[this._localeName];if(i)for(let[o,n]of Object.entries(i)){(s=this._blockInstance)==null||s.add(mt(o),n,!0);for(let l of this._callbacks)l()}})})}onLocaleChange(e){let t=O(e,0);return this._callbacks.add(t),()=>{this._callbacks.delete(t)}}bindL10n(e,t,i){var o,n,l;e.$[t]=i(),this._boundBlocks.has(e)||this._boundBlocks.set(e,new Map),(n=(o=this._boundBlocks.get(e))==null?void 0:o.get(t))==null||n();let s=this.onLocaleChange(()=>{e.$[t]=i()});(l=this._boundBlocks.get(e))==null||l.set(t,s)}destroyL10nBindings(e){let t=this._boundBlocks.get(e);if(t){for(let i of t.values())i();this._boundBlocks.delete(e)}}destroy(){this._callbacks.clear()}};function ys(r,e){[...r.querySelectorAll("[l10n]")].forEach(t=>{let i=t.getAttribute("l10n");if(!i)return;let s="textContent",o=!1;if(i.includes(":")){let a=i.split(":");s=a[0],i=a[1],s.startsWith("@")&&(s=s.slice(1),o=!0)}let n=i;e.has(n)&&e.sub(n,a=>{if(!a)return;e.l10nProcessorSubs.has(n)||e.l10nProcessorSubs.set(n,new Set);let c=e.l10nProcessorSubs.get(n);c==null||c.forEach(p=>{p.remove(),c.delete(p),e.allSubs.delete(p)});let h=mt(a).replace("*","");e.nodeCtx.has(h)||e.nodeCtx.add(h,a);let d=e.nodeCtx.sub(h,()=>{t[s]=e.l10n(a)});c==null||c.add(d),e.allSubs.add(d),t.removeAttribute("l10n")});let l=mt(i);e.has(l)||e.add(l,""),e.sub(l,()=>{i=i,o?t.setAttribute(s,e.l10n(i)):t[s]=e.l10n(i)}),t.removeAttribute("l10n")})}var W=r=>`*cfg/${r}`;var hl={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function re(r,e){e.tabIndex=0,e.focus(),r.tabIndex=-1}function tr(r){let e=r.role||r.type||r.tagName;if(!e)return null;let t=hl[e.toLowerCase()];if(!t)return null;for(let i of t){let s=r.closest(`[role=${i}]`);if(s)return s}}function er(r,e){return e.role==="toolbar"?dl(e):e.querySelectorAll(`[role=${r.role}]`)}function dl(r){return[...r.querySelectorAll("*")].filter(t=>t.role==="button"||t.type==="button"||t.role==="checkbox"||t.type==="checkbox")}function pl(r){let e=r.getAttribute("aria-orientation");if(e==="vertical")return!1;if(e==="horizontal")return!0;let t=r.role;return t==="menubar"||t==="tablist"||t==="toolbar"}function vs(r){return e=>{let t=!1,i=(r==null?void 0:r.searchDelayMs)||300,s=0,o="";function n(d){let p=tr(d.target);if(!p){l();return}let m=er(d.target,p),f=Array.from(m).indexOf(d.target),g="ArrowDown",v="ArrowUp";if(pl(p)&&(e.document.dir==="rtl"?(g="ArrowLeft",v="ArrowRight"):(g="ArrowRight",v="ArrowLeft")),d.key===g)d.preventDefault(),re(d.target,m[f+1]||m[0]);else if(d.key===v)d.preventDefault(),re(d.target,m[f-1]||m[m.length-1]);else if(d.key==="Home")d.preventDefault(),re(d.target,m[0]);else if(d.key==="End")d.preventDefault(),re(d.target,m[m.length-1]);else if(d.key.length===1&&p.role!=="tablist"){let w=Date.now();w-s<=i?o+=d.key.toLowerCase():o=d.key.toLowerCase(),s=w;let y=Array.from(m).find(C=>{var M,q,tt;return(tt=(q=(M=C.textContent)==null?void 0:M.trim())==null?void 0:q.toLowerCase())==null?void 0:tt.startsWith(o)});y&&(d.preventDefault(),re(d.target,y))}}function l(){t=!1,e.removeEventListener("keydown",n)}function a(d){let p=tr(d.target);if(p){t||(t=!0,e.addEventListener("keydown",n));let m=er(d.target,p);for(let f of m)f!==d.target&&f.setAttribute("tabindex",-1)}else t&&l()}function c(d){(!d.relatedTarget||d.relatedTarget===e.document)&&l()}function h(d){let p=tr(d.target);if(p){let m=er(d.target,p);for(let f of m)f!==d.target&&f.setAttribute("tabindex",-1);d.target.setAttribute("tabindex",0)}}return e.addEventListener("click",h),e.addEventListener("focusin",a),e.addEventListener("focusout",c),()=>{l(),e.removeEventListener("click",h),e.removeEventListener("focusin",a),e.removeEventListener("focusout",c)}}}function ws(){return r=>{let e,t;function i(o){if(o.target.getAttribute("aria-hidden")==="true"){e=o.target,e.setAttribute("aria-hidden","false"),t=e.hidden,t&&(e.hidden=!1);let n=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function s(o){e&&e.contains(o.target)&&(!o.relatedTarget||!e.contains(o.relatedTarget))&&(o.target.tabIndex=-1,e.setAttribute("aria-hidden","true"),t&&(e.hidden=!0),e=null)}return r.addEventListener("keyuxJump",i),r.addEventListener("focusout",s),()=>{r.removeEventListener("keyuxJump",i),r.removeEventListener("focusout",s)}}}function Cs(){return r=>{let e=[];function t(c){let h=r.document.activeElement;h&&h!==r.document.body&&e.push(new WeakRef(h)),c.focus({focusVisible:!0})}function i(){let c=e.pop();if(!c){r.document.activeElement.blur();return}let h=c.deref();h&&h.isConnected?h.focus():i()}let s=0,o;function n(c){clearInterval(o);let h=c.getAttribute("aria-controls");h&&(o=setInterval(()=>{if(s++>50){clearInterval(o);return}let d=r.document.getElementById(h);if(d){let p=d.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');p&&(clearInterval(o),d.dispatchEvent(new r.CustomEvent("keyuxJump",{bubbles:!0})),t(p))}},50))}function l(c){c.clientX===0&&c.clientY===0&&n(c.target)}function a(c){c.target.tagName==="INPUT"&&c.key==="Enter"&&n(c.target),c.key==="Escape"&&i()}return r.addEventListener("click",l),r.addEventListener("keydown",a),()=>{r.removeEventListener("click",l),r.removeEventListener("keydown",a)}}}function xs(r){let e,t=r.split(" ");function i(){e&&e.classList.remove(...t)}function s(o){o.clientX===0&&o.clientY===0&&(i(),o.target.classList.add(...t),e=o.target)}return o=>(o.addEventListener("keyup",i),o.addEventListener("click",s),()=>{o.removeEventListener("keyup",i),o.removeEventListener("click",s)})}function As(r,e){let t=e.map(i=>i(r));return()=>{t.forEach(i=>i())}}var ir=class{constructor(){u(this,"_listeners",new Map);u(this,"_scope",[])}addEventListener(e,t){let i=s=>{let o=s.target;o&&this._scope.some(n=>n===s.target||n.contains(o))&&t(s)};this._listeners.set(t,i),window.addEventListener(e,i)}removeEventListener(e,t){let i=this._listeners.get(t);i&&window.removeEventListener(e,i),this._listeners.delete(t)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(e){this._scope.push(e)}destroy(){this._scope=[],this._listeners.forEach((e,t)=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",e),this._listeners.delete(t)})}},qe=class{constructor(){u(this,"_destroyKeyUX");u(this,"_scopedWindow");this._scopedWindow=new ir,this._destroyKeyUX=As(this._scopedWindow,[vs(),xs("is-pressed"),Cs(),ws()])}registerBlock(e){this._scopedWindow.registerScope(e)}destroy(){var e;(e=this._destroyKeyUX)==null||e.call(this),this._scopedWindow.destroy()}};var fl="uc-",_=class extends Pt{constructor(){super();u(this,"requireCtxName",!1);u(this,"activityType",null);u(this,"init$",Yi());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(ys)}l10n(t,i={}){if(!t)return"";let s=this.$[mt(t)]||t,o=es(s);for(let l of o)i[l.variable]=this.pluralize(l.pluralKey,Number(i[l.countVariable]));return te(s,i)}pluralize(t,i){let s=this.l10n("locale-id")||"en",o=Fe(s,i);return this.l10n(`${t}__${o}`)}bindL10n(t,i){var s;(s=this.localeManager)==null||s.bindL10n(this,t,i)}emit(t,i,s){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&o.emit(t,i,s)}hasBlockInCtx(t){for(let i of this.blocksRegistry)if(t(i))return!0;return!1}setOrAddState(t,i){this.add$({[t]:i},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(i=>{this.setAttribute(i,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?is({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),St.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),St.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Re(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new Xe(this)),this.has("*a11y")||this.add("*a11y",new qe),this.sub(mt("locale-id"),i=>{let s=Jr(i);this.style.direction=s==="ltr"?"":s})}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}destroyCallback(){var i;super.destroyCallback();let t=this.blocksRegistry;t==null||t.delete(this),(i=this.localeManager)==null||i.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,E.deleteCtx(this),(t==null?void 0:t.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var t;E.deleteCtx(this.ctxName),(t=this.localeManager)==null||t.destroy()}async proxyUrl(t){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(t,{uuid:Me(t),cdnUrlModifiers:Fi(t),fileName:Ue(t)})}catch(i){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",i),t}return this.cfg.secureDeliveryProxy?te(this.cfg.secureDeliveryProxy,{previewUrl:t},{transform:i=>window.encodeURIComponent(i)}):t}get cfg(){if(!this.__cfgProxy){let t=Object.create(null);this.__cfgProxy=new Proxy(t,{set:(i,s,o)=>{if(typeof s!="string")return!1;let n=W(s);return this.has(n)||this.add(n,J[s]),this.$[n]=o,!0},get:(i,s)=>{let o=W(s);return this.has(o)||this.add(o,J[s]),this.$[W(s)]}})}return this.__cfgProxy}subConfigValue(t,i){let s=W(t);this.has(s)||this.add(s,J[t]),this.sub(s,i)}debugPrint(...t){if(!this.cfg.debug)return;let i=t;if(typeof(t==null?void 0:t[0])=="function"){let s=t[0];i=s()}console.log(`[${this.ctxName}]`,...i)}static reg(t){if(!t){super.reg();return}t.startsWith(fl)&&super.reg(t)}};u(_,"StateConsumerScope",null),u(_,"styleAttrs",[]);var Es="";var rt=class extends _{constructor(){super(...arguments);u(this,"requireCtxName",!0);u(this,"init$",Ge(this));u(this,"_template",null)}initCallback(){var t;super.initCallback(),(t=this.a11y)==null||t.registerBlock(this)}static set template(t){this._template=Es+t+""}static get template(){return this._template}};u(rt,"styleAttrs",["uc-wgt-common"]);var Ts="active",se="___ACTIVITY_IS_ACTIVE___",gt=class gt extends _{constructor(){super(...arguments);u(this,"historyTracked",!1);u(this,"init$",Ji(this));u(this,"_debouncedHistoryFlush",O(this._historyFlush.bind(this),10))}_deactivate(){var i;let t=gt._activityCallbacks.get(this);this[se]=!1,this.removeAttribute(Ts),(i=t==null?void 0:t.deactivateCallback)==null||i.call(t)}_activate(){var i;let t=gt._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[se]=!0,this.setAttribute(Ts,""),(i=t==null?void 0:t.activateCallback)==null||i.call(t),this._debouncedHistoryFlush(),this.emit(k.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.hasAttribute("current-activity")&&this.sub("*currentActivity",t=>{this.setAttribute("current-activity",t)}),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",t=>{var i;try{this.activityType!==t&&this[se]?this._deactivate():this.activityType===t&&!this[se]&&this._activate()}catch(s){console.error(`Error in activity "${this.activityType}". `,s),this.$["*currentActivity"]=(i=this.$["*history"][this.$["*history"].length-1])!=null?i:null}t||(this.$["*history"]=[])}),this.has("*modalActive")&&this.sub("*modalActive",t=>{!t&&this.activityType===this.$["*currentActivity"]&&(this.$["*currentActivity"]=null)}))}_historyFlush(){let t=this.$["*history"];t&&(t.length>10&&(t=t.slice(t.length-11,t.length-1)),this.historyTracked&&t[t.length-1]!==this.activityType&&t.push(this.activityType),this.$["*history"]=t)}_isActivityRegistered(){return this.activityType&>._activityCallbacks.has(this)}get isActivityActive(){return this[se]}get couldOpenActivity(){return!0}registerActivity(t,i={}){let{onActivate:s,onDeactivate:o}=i;gt._activityCallbacks.set(this,{activateCallback:s,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),gt._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();let t=this.$["*currentActivity"];!![...this.blocksRegistry].find(s=>s instanceof gt&&s.activityType===t)||(this.$["*currentActivity"]=null,this.setOrAddState("*modalActive",!1))}get activityKey(){return this.ctxName+this.activityType}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")}get doneActivity(){return this.getCssData("--cfg-done-activity")}historyBack(){var i;let t=this.$["*history"];if(t){let s=t.pop();for(;s===this.activityType;)s=t.pop();let o=!!s;if(s){let n=[...this.blocksRegistry].find(l=>l.activityType===s);o=(i=n==null?void 0:n.couldOpenActivity)!=null?i:!1}s=o?s:void 0,this.$["*currentActivity"]=s,this.$["*history"]=t,s||this.setOrAddState("*modalActive",!1)}}};u(gt,"_activityCallbacks",new Map);var b=gt;b.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var oe=33.333333333333336,x=1,rr=24,Ss=6;function $t(r,e){for(let t in e)r.setAttributeNS(null,t,e[t].toString())}function K(r,e={}){let t=document.createElementNS("http://www.w3.org/2000/svg",r);return $t(t,e),t}function ks(r,e,t){let{x:i,y:s,width:o,height:n}=r,l=e.includes("w")?0:1,a=e.includes("n")?0:1,c=[-1,1][l],h=[-1,1][a],d=[i+l*o+1.5*c,s+a*n+1.5*h-24*t*h],p=[i+l*o+1.5*c,s+a*n+1.5*h],m=[i+l*o-24*t*c+1.5*c,s+a*n+1.5*h];return{d:`M ${d[0]} ${d[1]} L ${p[0]} ${p[1]} L ${m[0]} ${m[1]}`,center:p}}function $s(r,e,t){let{x:i,y:s,width:o,height:n}=r,l=["n","s"].includes(e)?.5:{w:0,e:1}[e],a=["w","e"].includes(e)?.5:{n:0,s:1}[e],c=[-1,1][l],h=[-1,1][a],d,p;["n","s"].includes(e)?(d=[i+l*o-34*t/2,s+a*n+1.5*h],p=[i+l*o+34*t/2,s+a*n+1.5*h]):(d=[i+l*o+1.5*c,s+a*n-34*t/2],p=[i+l*o+1.5*c,s+a*n+34*t/2]);let m=`M ${d[0]} ${d[1]} L ${p[0]} ${p[1]}`,f=[p[0]-(p[0]-d[0])/2,p[1]-(p[1]-d[1])/2];return{d:m,center:f}}function Is(r){return r===""?"move":["e","w"].includes(r)?"ew-resize":["n","s"].includes(r)?"ns-resize":["nw","se"].includes(r)?"nwse-resize":"nesw-resize"}function Os({rect:r,delta:[e,t],imageBox:i}){return Bt({...r,x:r.x+e,y:r.y+t},i)}function Bt(r,e){let{x:t}=r,{y:i}=r;return r.xe.x+e.width&&(t=e.x+e.width-r.width),r.ye.y+e.height&&(i=e.y+e.height-r.height),{...r,x:t,y:i}}function ml({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[,s]=e,{y:o,width:n,height:l}=r;o+=s,l-=s,t&&(n=l*t);let a=r.x+r.width/2-n/2;return o<=i.y&&(o=i.y,l=r.y+r.height-o,t&&(n=l*t,a=r.x+r.width/2-n/2)),a<=i.x&&(a=i.x,o=r.y+r.height-l),a+n>=i.x+i.width&&(a=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-a,t&&(l=n/t),o=r.y+r.height-l),l=i.y+i.height&&(a=Math.max(i.y,i.y+i.height-l),l=i.y+i.height-a,t&&(n=l*t),o=r.x+r.width-n),l=i.y+i.height&&(l=i.y+i.height-o,t&&(n=l*t),a=r.x+r.width/2-n/2),a<=i.x&&(a=i.x,o=r.y),a+n>=i.x+i.width&&(a=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-a,t&&(l=n/t),o=r.y),l=i.x+i.width&&(n=i.x+i.width-o,t&&(l=n/t),a=r.y+r.height/2-l/2),a<=i.y&&(a=i.y,o=r.x),a+l>=i.y+i.height&&(a=Math.max(i.y,i.y+i.height-l),l=i.y+i.height-a,t&&(n=l*t),o=r.x),lt?(o=a/t-c,c+=o,l-=o,l<=i.y&&(c=c-(i.y-l),a=c*t,n=r.x+r.width-a,l=i.y)):t&&(s=c*t-a,a=a+s,n-=s,n<=i.x&&(a=a-(i.x-n),c=a/t,n=i.x,l=r.y+r.height-c)),ci.x+i.width&&(s=i.x+i.width-n-a),l+ot?(o=a/t-c,c+=o,l-=o,l<=i.y&&(c=c-(i.y-l),a=c*t,n=r.x,l=i.y)):t&&(s=c*t-a,a+=s,n+a>=i.x+i.width&&(a=i.x+i.width-n,c=a/t,n=i.x+i.width-a,l=r.y+r.height-c)),ci.y+i.height&&(o=i.y+i.height-l-c),n+=s,a-=s,c+=o,t&&Math.abs(a/c)>t?(o=a/t-c,c+=o,l+c>=i.y+i.height&&(c=i.y+i.height-l,a=c*t,n=r.x+r.width-a,l=i.y+i.height-c)):t&&(s=c*t-a,a+=s,n-=s,n<=i.x&&(a=a-(i.x-n),c=a/t,n=i.x,l=r.y)),ci.x+i.width&&(s=i.x+i.width-n-a),l+c+o>i.y+i.height&&(o=i.y+i.height-l-c),a+=s,c+=o,t&&Math.abs(a/c)>t?(o=a/t-c,c+=o,l+c>=i.y+i.height&&(c=i.y+i.height-l,a=c*t,n=r.x,l=i.y+i.height-c)):t&&(s=c*t-a,a+=s,n+a>=i.x+i.width&&(a=i.x+i.width-n,c=a/t,n=i.x+i.width-a,l=r.y)),c=e.x&&r.y>=e.y&&r.x+r.width<=e.x+e.width&&r.y+r.height<=e.y+e.height}function Ps(r,e){return Math.abs(r.width/r.height-e)<.1}function zt({width:r,height:e},t){let i=t/90%2!==0;return{width:i?e:r,height:i?r:e}}function Rs(r,e,t){let i=r/e,s,o;i>t?(s=Math.round(e*t),o=e):(s=r,o=Math.round(r/t));let n=Math.round((r-s)/2),l=Math.round((e-o)/2);return n+s>r&&(s=r-n),l+o>e&&(o=e-l),{x:n,y:l,width:s,height:o}}function Vt(r){return{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}}function At(r,e,t){return Math.min(Math.max(r,e),t)}var Ze=r=>{if(!r)return[];let[e,t]=r.split(":").map(Number);if(!Number.isFinite(e)||!Number.isFinite(t)){console.error(`Invalid crop preset: ${r}`);return}return[{type:"aspect-ratio",width:e,height:t}]};var jt="blocks",Ht="1.6.0";function Fs(r){return Gi({...r,libraryName:jt,libraryVersion:Ht})}var Ds=r=>Math.floor(r/1e3),Ns=(r,{threshold:e})=>{let{secureExpire:t}=r,i=Ds(Date.now()),s=Number(t),o=Ds(e);return i+o>=s};var Ye=class{constructor(e){u(this,"_block");u(this,"_secureToken",null);this._block=e}_debugPrint(...e){this._block.debugPrint("[secure-uploads]",...e)}async getSecureToken(){let{secureSignature:e,secureExpire:t,secureUploadsSignatureResolver:i}=this._block.cfg;if((e||t)&&i&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),i){if(!this._secureToken||Ns(this._secureToken,{threshold:this._block.cfg.secureUploadsExpireThreshold})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let s=await i();s?!s.secureSignature||!s.secureExpire?console.error("Secure signature resolver returned an invalid result:",s):(this._debugPrint("Secure signature resolved:",s),this._debugPrint("Secure signature will expire in",new Date(Number(s.secureExpire)*1e3).toISOString()),this._secureToken=s):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(s){console.error("Secure signature resolving failed. Falling back to the previous one.",s)}}return this._secureToken}return e&&t?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:e,secureExpire:t}),{secureSignature:e,secureExpire:t}):null}};var Bs="[Typed State] Wrong property name: ",xl="[Typed State] Wrong property type: ",Je=class{constructor(e,t){this.__typedSchema=e,this.__ctxId=t||Mt.generate(),this.__schema=Object.keys(e).reduce((i,s)=>(i[s]=e[s].value,i),{}),this.__data=E.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(e,t){if(!this.__typedSchema.hasOwnProperty(e)){console.warn(Bs+e);return}let i=this.__typedSchema[e];if((t==null?void 0:t.constructor)===i.type||t instanceof i.type||i.nullable&&t===null){this.__data.pub(e,t);return}console.warn(xl+e)}setMultipleValues(e){for(let t in e)this.setValue(t,e[t])}getValue(e){if(!this.__typedSchema.hasOwnProperty(e)){console.warn(Bs+e);return}return this.__data.read(e)}subscribe(e,t){return this.__data.sub(e,t)}remove(){E.deleteCtx(this.__ctxId)}};var Qe=class{constructor(e){this.__typedSchema=e.typedSchema,this.__ctxId=e.ctxName||Mt.generate(),this.__data=E.registerCtx({},this.__ctxId),this.__watchList=e.watchList||[],this.__subsMap=Object.create(null),this.__propertyObservers=new Set,this.__collectionObservers=new Set,this.__items=new Set,this.__removed=new Set,this.__added=new Set;let t=Object.create(null);this.__notifyObservers=(i,s)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),t[i]||(t[i]=new Set),t[i].add(s),this.__observeTimeout=window.setTimeout(()=>{Object.keys(t).length!==0&&(this.__propertyObservers.forEach(o=>{o({...t})}),t=Object.create(null))})}}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let e=new Set(this.__added),t=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(let i of this.__collectionObservers)i==null||i([...this.__items],e,t)})}observeCollection(e){return this.__collectionObservers.add(e),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(e)}}unobserveCollection(e){var t;(t=this.__collectionObservers)==null||t.delete(e)}add(e){let t=new Je(this.__typedSchema);for(let i in e)t.setValue(i,e[i]);return this.__items.add(t.uid),this.notify(),this.__data.add(t.uid,t),this.__added.add(t),this.__watchList.forEach(i=>{this.__subsMap[t.uid]||(this.__subsMap[t.uid]=[]),this.__subsMap[t.uid].push(t.subscribe(i,()=>{this.__notifyObservers(i,t.uid)}))}),t.uid}read(e){return this.__data.read(e)}readProp(e,t){return this.read(e).getValue(t)}publishProp(e,t,i){this.read(e).setValue(t,i)}remove(e){this.__removed.add(this.__data.read(e)),this.__items.delete(e),this.notify(),this.__data.pub(e,null),delete this.__subsMap[e]}clearAll(){this.__items.forEach(e=>{this.remove(e)})}observeProperties(e){return this.__propertyObservers.add(e),()=>{this.unobserveProperties(e)}}unobserveProperties(e){var t;(t=this.__propertyObservers)==null||t.delete(e)}findItems(e){let t=[];return this.__items.forEach(i=>{let s=this.read(i);e(s)&&t.push(i)}),t}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){E.deleteCtx(this.__ctxId),this.__propertyObservers=null,this.__collectionObservers=null;for(let e in this.__subsMap)this.__subsMap[e].forEach(t=>{t.remove()}),delete this.__subsMap[e]}};var Gt=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",INSTAGRAM:"instagram",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),L=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Gt});var ne=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],ti=r=>r?r.filter(e=>typeof e=="string").map(e=>N(e)).flat():[],sr=(r,e)=>e.some(t=>t.endsWith("*")?(t=t.replace("*",""),r.startsWith(t)):r===t),zs=(r,e)=>e.some(t=>t.startsWith(".")?r.toLowerCase().endsWith(t.toLowerCase()):!1),Vs=r=>{let e=r==null?void 0:r.type;return e?sr(e,ne):!1};var Al=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,El=new RegExp(`^/?(${Al.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),js=({url:r,cdnBase:e})=>{let t=new URL(e),i=new URL(r);if(t.host!==i.host)return null;let[,s,o,n]=El.exec(i.pathname);return{uuid:s,cdnUrlModifiers:o||"",filename:n||null}};var Hs=r=>{let e=new Map;return(...t)=>{let i=JSON.stringify(t);if(e.has(i))return e.get(i);let s=r(...t);return e.set(i,s),s}};var Gs=new Set;function Ws(r){Gs.has(r)||(Gs.add(r),console.warn(r))}function Tl(r){let e=!1;return setTimeout(()=>{e=!0},0),i=>(...s)=>(e&&Ws(r),i(...s))}function Xs(r){let e={progress:()=>r.$["*commonProgress"],errors:()=>r.$["*collectionErrors"],group:()=>r.$["*groupInfo"],totalCount:()=>r.uploadCollection.size,failedCount:()=>t.failedEntries.length,successCount:()=>t.successEntries.length,uploadingCount:()=>t.uploadingEntries.length,status:()=>t.isFailed?"failed":t.isUploading?"uploading":t.isSuccess?"success":"idle",isSuccess:()=>t.allEntries.length>0&&t.errors.length===0&&t.successEntries.length===t.allEntries.length,isUploading:()=>t.allEntries.some(s=>s.status==="uploading"),isFailed:()=>t.errors.length>0||t.failedEntries.length>0,allEntries:()=>r.getOutputData(),successEntries:()=>t.allEntries.filter(s=>s.status==="success"),failedEntries:()=>t.allEntries.filter(s=>s.status==="failed"),uploadingEntries:()=>t.allEntries.filter(s=>s.status==="uploading"),idleEntries:()=>t.allEntries.filter(s=>s.status==="idle")},t={},i=Tl("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[s,o]of Object.entries(e)){let n=s,a=Hs(i(o));Object.defineProperty(t,n,{get:a,enumerable:!0})}return t}var ei=class{constructor(e){u(this,"_ctx");u(this,"addFileFromUrl",(e,{silent:t,fileName:i,source:s}={})=>{let o=this._uploadCollection.add({externalUrl:e,fileName:i!=null?i:null,silent:t!=null?t:!1,source:s!=null?s:L.API});return this.getOutputItem(o)});u(this,"addFileFromUuid",(e,{silent:t,fileName:i,source:s}={})=>{let o=this._uploadCollection.add({uuid:e,fileName:i!=null?i:null,silent:t!=null?t:!1,source:s!=null?s:L.API});return this.getOutputItem(o)});u(this,"addFileFromCdnUrl",(e,{silent:t,fileName:i,source:s}={})=>{var l;let o=js({url:e,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:o.uuid,cdnUrl:e,cdnUrlModifiers:o.cdnUrlModifiers,fileName:(l=i!=null?i:o.filename)!=null?l:null,silent:t!=null?t:!1,source:s!=null?s:L.API});return this.getOutputItem(n)});u(this,"addFileFromObject",(e,{silent:t,fileName:i,source:s,fullPath:o}={})=>{let n=this._uploadCollection.add({file:e,isImage:Vs(e),mimeType:e.type,fileName:i!=null?i:e.name,fileSize:e.size,silent:t!=null?t:!1,source:s!=null?s:L.API,fullPath:o!=null?o:null});return this.getOutputItem(n)});u(this,"removeFileByInternalId",e=>{if(!this._uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this._uploadCollection.remove(e)});u(this,"uploadAll",()=>{let e=this._uploadCollection.items().filter(t=>{let i=this._uploadCollection.read(t);return!i.getValue("isRemoved")&&!i.getValue("isUploading")&&!i.getValue("fileInfo")});e.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(e),this._ctx.emit(k.COMMON_UPLOAD_START,this.getOutputCollectionState()))});u(this,"openSystemDialog",(e={})=>{var o;let t=Rt(ti([(o=this.cfg.accept)!=null?o:"",...this.cfg.imgOnly?ne:[]]));this.cfg.accept&&this.cfg.imgOnly&&console.warn("There could be a mistake.\nBoth `accept` and `imgOnly` parameters are set.\nThe value of `accept` will be concatenated with the internal image mime types list.");let i="uploadcare-file-input",s=document.createElement("input");s.setAttribute(i,""),Qt(s,{opacity:0,height:0,width:0,visibility:"hidden"}),s.type="file",s.multiple=this.cfg.multiple,e.captureCamera?(s.capture=this.cfg.cameraCapture,s.accept="image/*"):s.accept=t,s.addEventListener("change",()=>{s.files&&([...s.files].forEach(n=>this.addFileFromObject(n,{source:e.captureCamera?L.CAMERA:L.LOCAL})),this._ctx.$["*currentActivity"]=b.activities.UPLOAD_LIST,this._ctx.setOrAddState("*modalActive",!0),s.remove())},{once:!0}),document.querySelectorAll(`[${i}]`).forEach(n=>n.remove()),document.body.appendChild(s),s.dispatchEvent(new MouseEvent("click"))});u(this,"getOutputItem",e=>{var n,l,a,c,h,d,p,m,f,g;let t=E.getCtx(e).store,i=t.fileInfo,s=t.isRemoved?"removed":t.errors.length>0?"failed":t.fileInfo?"success":t.isUploading?"uploading":"idle";return{uuid:(l=(n=i==null?void 0:i.uuid)!=null?n:t.uuid)!=null?l:null,internalId:e,name:(a=i==null?void 0:i.originalFilename)!=null?a:t.fileName,size:(c=i==null?void 0:i.size)!=null?c:t.fileSize,isImage:(h=i==null?void 0:i.isImage)!=null?h:t.isImage,mimeType:(d=i==null?void 0:i.mimeType)!=null?d:t.mimeType,file:t.file,externalUrl:t.externalUrl,cdnUrlModifiers:t.cdnUrlModifiers,cdnUrl:(m=(p=t.cdnUrl)!=null?p:i==null?void 0:i.cdnUrl)!=null?m:null,fullPath:t.fullPath,uploadProgress:t.uploadProgress,fileInfo:i!=null?i:null,metadata:(g=(f=t.metadata)!=null?f:i==null?void 0:i.metadata)!=null?g:null,isSuccess:s==="success",isUploading:s==="uploading",isFailed:s==="failed",isRemoved:s==="removed",errors:t.errors,status:s,source:t==null?void 0:t.source}});u(this,"getOutputCollectionState",()=>Xs(this._ctx));u(this,"initFlow",(e=!1)=>{var t;if(this._uploadCollection.size>0&&!e)this._ctx.set$({"*currentActivity":b.activities.UPLOAD_LIST}),this._ctx.setOrAddState("*modalActive",!0);else if(((t=this._sourceList)==null?void 0:t.length)===1){let i=this._sourceList[0];if(i==="local"){this._ctx.$["*currentActivity"]=b.activities.UPLOAD_LIST,this.openSystemDialog();return}let s=this._ctx.$["*blocksRegistry"],o=l=>"type"in l&&l.type===i,n=[...s].find(o);n==null||n.activate(),this._ctx.$["*currentActivity"]&&this._ctx.setOrAddState("*modalActive",!0)}else this._ctx.set$({"*currentActivity":b.activities.START_FROM}),this._ctx.setOrAddState("*modalActive",!0)});u(this,"doneFlow",()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.setOrAddState("*modalActive",!1)});u(this,"setCurrentActivity",(e,t=void 0)=>{if(this._ctx.hasBlockInCtx(i=>i.activityType===e)){this._ctx.set$({"*currentActivityParams":t!=null?t:{},"*currentActivity":e});return}console.warn(`Activity type "${e}" not found in the context`)});u(this,"getCurrentActivity",()=>this._ctx.$["*currentActivity"]);u(this,"setModalState",e=>{if(e&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}this._ctx.setOrAddState("*modalActive",e)});this._ctx=e}get _uploadCollection(){return this._ctx.uploadCollection}get cfg(){return this._ctx.cfg}get l10n(){return this._ctx.l10n.bind(this._ctx)}removeAllFiles(){this._uploadCollection.clearAll()}get _sourceList(){let e=[];return this.cfg.sourceList&&(e=N(this.cfg.sourceList)),e}};var or=(r,e)=>{let t=e.cfg.imgOnly,i=r.isImage;if(!(!t||i)&&!(!r.fileInfo&&r.externalUrl)&&!(!r.fileInfo&&!r.mimeType))return{type:"NOT_AN_IMAGE",message:e.l10n("images-only-accepted"),payload:{entry:r}}};var nr=(r,e)=>{let t=e.cfg.imgOnly,i=e.cfg.accept,s=ti([...t?ne:[],i]);if(!s.length)return;let o=r.mimeType,n=r.name;if(!o||!n)return;let l=sr(o,s),a=zs(n,s);if(!l&&!a)return{type:"FORBIDDEN_FILE_TYPE",message:e.l10n("file-type-not-allowed"),payload:{entry:r}}};var ot=1e3,It=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),le=r=>Math.ceil(r*100)/100,qs=(r,e=It.AUTO)=>{let t=e===It.AUTO;if(e===It.BYTE||t&&r{let t=e.cfg.maxLocalFileSizeBytes,i=r.size;if(t&&i&&i>t)return{type:"FILE_SIZE_EXCEEDED",message:e.l10n("files-max-size-limit-error",{maxFileSize:qs(t)}),payload:{entry:r}}};var ar=(r,e)=>{let{internalId:t}=r,i=e._uploadCollection.read(t),s=i==null?void 0:i.getValue("uploadError");if(!s)return;if(s instanceof B)return{type:"UPLOAD_ERROR",message:s.message,payload:{entry:r,error:s}};if(s instanceof Ft)return{type:"NETWORK_ERROR",message:s.message,payload:{entry:r,error:s}};let o=s instanceof Error?s:new Error("Unknown error",{cause:s});return{type:"UNKNOWN_ERROR",message:o.message,payload:{entry:r,error:o}}};var cr=(r,e)=>{if(r.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:e.l10n("some-files-were-not-uploaded")}};var ur=(r,e)=>{let t=r.totalCount,i=e.cfg.multiple?e.cfg.multipleMin:0,s=e.cfg.multiple?e.cfg.multipleMax:1;if(i&&ts)return{type:"TOO_MANY_FILES",message:e.l10n("files-count-limit-error-too-many",{min:i,max:s,total:t}),payload:{total:t,min:i,max:s}}};var ii={file:"File validator execution has failed",collection:"Collection validator execution has failed",message:"Missing message. We recommend adding message: value."},ri=class{constructor(e){u(this,"_blockInstance");u(this,"_fileValidators",[or,nr,lr,ar]);u(this,"_collectionValidators",[ur,cr]);this._blockInstance=e,this._uploadCollection=this._blockInstance.uploadCollection;let t=()=>{this.runFileValidators(),this.runCollectionValidators()};this._blockInstance.subConfigValue("maxLocalFileSizeBytes",t),this._blockInstance.subConfigValue("multipleMin",t),this._blockInstance.subConfigValue("multipleMax",t),this._blockInstance.subConfigValue("multiple",t),this._blockInstance.subConfigValue("imgOnly",t),this._blockInstance.subConfigValue("accept",t)}runFileValidators(e){let t=e!=null?e:this._uploadCollection.items();for(let i of t){let s=this._uploadCollection.read(i);s&&this._runFileValidatorsForEntry(s)}}runCollectionValidators(){let e=this._blockInstance.api.getOutputCollectionState(),t=[];for(let i of[...this._collectionValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.collectionValidators)])try{let s=i(e,this._blockInstance.api);if(!s)continue;s&&(t.push(s),s.message||console.warn(ii.message))}catch(s){console.warn(ii.collection,s)}this._blockInstance.$["*collectionErrors"]=t,t.length>0&&this._blockInstance.emit(k.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}_runFileValidatorsForEntry(e){let t=this._blockInstance.api.getOutputItem(e.uid),i=[];for(let s of[...this._fileValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.fileValidators)])try{let o=s(t,this._blockInstance.api);if(!o)continue;o&&(i.push(o),o.message||console.warn(ii.message))}catch(o){console.warn(ii.file,o)}e.setValue("errors",i)}_addCustomTypeToValidators(e){return e.map(t=>(...i)=>{let s=t(...i);return s?{...s,type:"CUSTOM_ERROR"}:void 0})}};var Ks=Object.freeze({file:{type:File,value:null},externalUrl:{type:String,value:null},fileName:{type:String,value:null,nullable:!0},fileSize:{type:Number,value:null,nullable:!0},lastModified:{type:Number,value:Date.now()},uploadProgress:{type:Number,value:0},uuid:{type:String,value:null},isImage:{type:Boolean,value:!1},mimeType:{type:String,value:null,nullable:!0},ctxName:{type:String,value:null},cdnUrl:{type:String,value:null},cdnUrlModifiers:{type:String,value:null},fileInfo:{type:pt,value:null},isUploading:{type:Boolean,value:!1},abortController:{type:AbortController,value:null,nullable:!0},thumbUrl:{type:String,value:null,nullable:!0},silent:{type:Boolean,value:!1},source:{type:String,value:!1,nullable:!0},fullPath:{type:String,value:null,nullable:!0},metadata:{type:Object,value:null,nullable:!0},errors:{type:Array,value:[]},uploadError:{type:Error,value:null,nullable:!0},isRemoved:{type:Boolean,value:!1}});var S=class r extends b{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!1);u(this,"isCtxOwner",!1);u(this,"init$",Ge(this));u(this,"_flushOutputItems",O(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let i=this.api.getOutputCollectionState();this.$["*collectionState"]=i,this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&i.totalCount>0&&i.status==="success"&&this._createGroup(i)},300));u(this,"_handleCollectionUpdate",(t,i,s)=>{var o;(i.size||s.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators(),this.validationManager.runCollectionValidators();for(let n of i)n.getValue("silent")||this.emit(k.FILE_ADDED,this.api.getOutputItem(n.uid));for(let n of s)this.$["*uploadTrigger"].delete(n.uid),(o=n.getValue("abortController"))==null||o.abort(),n.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0}),URL.revokeObjectURL(n==null?void 0:n.getValue("thumbUrl")),this.emit(k.FILE_REMOVED,this.api.getOutputItem(n.uid));this.$["*uploadList"]=t.map(n=>({uid:n})),this._flushCommonUploadProgress(),this._flushOutputItems()});u(this,"_handleCollectionPropertiesUpdate",t=>{this._flushOutputItems();let i=this.uploadCollection,s=[...new Set(Object.entries(t).filter(([o])=>["uploadError","fileInfo"].includes(o)).map(([,o])=>[...o]).flat())];if(s.length>0&&setTimeout(()=>{this.validationManager.runFileValidators(s)}),t.uploadProgress){for(let o of t.uploadProgress){let{isUploading:n,silent:l}=E.getCtx(o).store;n&&!l&&this.emit(k.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(t.isUploading)for(let o of t.isUploading){let{isUploading:n,silent:l}=E.getCtx(o).store;n&&!l&&this.emit(k.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(t.fileInfo){for(let o of t.fileInfo){let{fileInfo:n,silent:l}=E.getCtx(o).store;n&&!l&&this.emit(k.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop()}if(t.errors){for(let l of t.errors){let{errors:a}=E.getCtx(l).store;a.length>0&&(this.emit(k.FILE_UPLOAD_FAILED,this.api.getOutputItem(l)),this.emit(k.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=i.findItems(l=>!!l.getValue("fileInfo")),n=i.findItems(l=>l.getValue("errors").length>0);i.size>0&&n.length===0&&i.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(k.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}t.cdnUrl&&([...t.cdnUrl].filter(n=>{var l;return!!((l=this.uploadCollection.read(n))!=null&&l.getValue("cdnUrl"))}).forEach(n=>{this.emit(k.FILE_URL_CHANGED,this.api.getOutputItem(n))}),this.$["*groupInfo"]=null)});u(this,"_flushCommonUploadProgress",()=>{let t=0,s=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));s.forEach(n=>{let l=this.uploadCollection.readProp(n,"uploadProgress");t+=l});let o=s.length?Math.round(t/s.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(k.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))})}get hasCtxOwner(){return this.hasBlockInCtx(t=>t instanceof r?t.isCtxOwner&&t.isConnected&&t!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let t=new Qe({typedSchema:Ks,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading"]});this.add("*uploadCollection",t)}this.has("*publicApi")||this.add("*publicApi",new ei(this)),this.has("*validationManager")||this.add("*validationManager",new ri(this)),!this.hasCtxOwner&&this.couldBeCtxOwner&&this.initCtxOwner()}get validationManager(){if(!this.has("*validationManager"))throw new Error("Unexpected error: ValidationManager is not initialized");return this.$["*validationManager"]}get api(){if(!this.has("*publicApi"))throw new Error("Unexpected error: UploaderPublicApi is not initialized");return this.$["*publicApi"]}getAPI(){return this.api}get uploadCollection(){if(!this.has("*uploadCollection"))throw new Error("Unexpected error: TypedCollection is not initialized");return this.$["*uploadCollection"]}destroyCtxCallback(){var t,i;(t=this._unobserveCollectionProperties)==null||t.call(this),(i=this._unobserveCollection)==null||i.call(this),this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}initCtxOwner(){this.isCtxOwner=!0,this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate),this.subConfigValue("maxConcurrentRequests",t=>{this.$["*uploadQueue"].concurrency=Number(t)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new Ye(this)),this.has("*modalActive")&&this.sub("*modalActive",t=>{t&&!this.$["*currentActivity"]&&(this.$["*modalActive"]=!1)})}async _createGroup(t){let i=await this.getUploadClientOptions(),s=t.allEntries.map(a=>a.uuid+(a.cdnUrlModifiers?`/${a.cdnUrlModifiers}`:"")),o=new AbortController,n=await ms(s,{...i,signal:o.signal});if(this.$["*collectionState"]!==t){o.abort();return}this.$["*groupInfo"]=n;let l=this.api.getOutputCollectionState();this.emit(k.GROUP_CREATED,l),this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=l}setInitialCrop(){let t=Ze(this.cfg.cropPreset);if(t){let[i]=t,s=this.uploadCollection.findItems(o=>{var n;return o.getValue("fileInfo")&&o.getValue("isImage")&&!((n=o.getValue("cdnUrlModifiers"))!=null&&n.includes("/crop/"))}).map(o=>this.uploadCollection.read(o));for(let o of s){let n=o.getValue("fileInfo"),{width:l,height:a}=n.imageInfo,c=i.width/i.height,h=Rs(l,a,c),d=D(`crop/${h.width}x${h.height}/${h.x},${h.y}`,"preview");o.setMultipleValues({cdnUrlModifiers:d,cdnUrl:U(o.getValue("cdnUrl"),d)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(p=>p.activityType===b.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=b.activities.CLOUD_IMG_EDIT)}}}async getMetadataFor(t){let i=this.cfg.metadata||void 0;if(typeof i=="function"){let s=this.api.getOutputItem(t);return await i(s)}return i}async getUploadClientOptions(){let i=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:Fs,integration:this.cfg.userAgentIntegration,secureSignature:i==null?void 0:i.secureSignature,secureExpire:i==null?void 0:i.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return this.uploadCollection.items().map(s=>this.api.getOutputItem(s))}};S.extSrcList=Object.freeze({...Gt});S.sourceTypes=Object.freeze({...L});var ae=r=>{var e;return(e=r.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:e.map(t=>t.toLowerCase()).join("-")};var R=r=>String(r),Q=r=>{let e=Number(r);if(Number.isNaN(e))throw new Error(`Invalid number: "${r}"`);return e},$=r=>{if(typeof r=="undefined"||r===null)return!1;if(typeof r=="boolean")return r;if(r==="true"||r==="")return!0;if(r==="false")return!1;throw new Error(`Invalid boolean: "${r}"`)},Sl=r=>r==="auto"?r:$(r),kl=r=>{let e=R(r);if(e!=="user"&&e!=="environment"&&e!=="")throw new Error(`Invalid "cameraCapture" value: "${e}"`);return e},$l=r=>{if(typeof r=="object"&&!Array.isArray(r)||typeof r=="function")return r;throw new Error("Invalid metadata value. Must be an object or function.")},Il=r=>{if(typeof r=="object")return r;throw new Error("Invalid value. Must be an object.")},hr=r=>{if(typeof r=="function")return r;throw new Error("Invalid value. Must be a function.")},Zs=r=>{if(Array.isArray(r))return r;throw new Error("Must be an array.")},Ol={pubkey:R,multiple:$,multipleMin:Q,multipleMax:Q,confirmUpload:$,imgOnly:$,accept:R,externalSourcesPreferredTypes:R,store:Sl,cameraMirror:$,cameraCapture:kl,sourceList:R,maxLocalFileSizeBytes:Q,thumbSize:Q,showEmptyList:$,useLocalImageEditor:$,useCloudImageEditor:$,cloudImageEditorTabs:R,removeCopyright:$,cropPreset:R,imageShrink:R,modalScrollLock:$,modalBackdropStrokes:$,sourceListWrap:$,remoteTabSessionKey:R,cdnCname:R,baseUrl:R,socialBaseUrl:R,secureSignature:R,secureExpire:R,secureDeliveryProxy:R,retryThrottledRequestMaxTimes:Q,multipartMinFileSize:Q,multipartChunkSize:Q,maxConcurrentRequests:Q,multipartMaxConcurrentRequests:Q,multipartMaxAttempts:Q,checkForUrlDuplicates:$,saveUrlForRecurrentUploads:$,groupOutput:$,userAgentIntegration:R,debug:$,localeName:R,metadata:$l,secureUploadsExpireThreshold:Q,localeDefinitionOverride:Il,secureUploadsSignatureResolver:hr,secureDeliveryProxyUrlResolver:hr,iconHrefResolver:hr,fileValidators:Zs,collectionValidators:Zs},Ys=(r,e)=>{if(!(typeof e=="undefined"||e===null))try{return Ol[r](e)}catch(t){return console.error(`Invalid value for config key "${r}".`,t),J[r]}};var dr=[...new Set(["debug",...Object.keys(J)])],Ll=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators"],Ul=r=>Ll.includes(r),Wt=dr.filter(r=>!Ul(r)),Ml={...Object.fromEntries(Wt.map(r=>[ae(r),r])),...Object.fromEntries(Wt.map(r=>[r.toLowerCase(),r]))},Pl={...Object.fromEntries(Wt.map(r=>[ae(r),W(r)])),...Object.fromEntries(Wt.map(r=>[r.toLowerCase(),W(r)]))},Js=r=>"__"+r,ce=class extends _{constructor(){super();u(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(J).map(([t,i])=>[W(t),i]))}}_flushValueToAttribute(t,i){if(Wt.includes(t)){let s=[...new Set([ae(t),t.toLowerCase()])];for(let o of s)typeof i=="undefined"||i===null?this.removeAttribute(o):this.getAttribute(o)!==i.toString()&&this.setAttribute(o,i.toString())}}_flushValueToState(t,i){this.$[W(t)]!==i&&(typeof i=="undefined"||i===null?this.$[W(t)]=J[t]:this.$[W(t)]=i)}_setValue(t,i){let s=this,o=Ys(t,i),n=Js(t);s[n]!==o&&(this._assertSameValueDifferentReference(t,s[n],o),s[n]=o,this._flushValueToAttribute(t,o),this._flushValueToState(t,o),this.debugPrint(`[uc-config] "${t}"`,o))}_getValue(t){let i=this,s=Js(t);return i[s]}_assertSameValueDifferentReference(t,i,s){this.cfg.debug&&s!==i&&typeof s=="object"&&typeof i=="object"&&JSON.stringify(s)===JSON.stringify(i)&&(console.warn(`[uc-config] Option "${t}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${t}" previous value:`,i),console.warn(`[uc-config] "${t}" new value:`,s))}initCallback(){var i;super.initCallback();let t=this;for(let s of Wt)this.sub(W(s),o=>{this._setValue(s,o)},!1);for(let s of dr){let o=(i=t[s])!=null?i:this.$[W(s)];o!==J[s]&&this._setValue(s,o),Object.defineProperty(this,s,{set:n=>{this._setValue(s,n)},get:()=>this._getValue(s)})}}attributeChangedCallback(t,i,s){if(i===s)return;let o=this,n=Ml[t];o[n]=s}};ce.bindAttributes(Pl);for(let r of dr)ce.prototype[r]=void 0;var Rl=ce;var ue=class extends _{constructor(){super(),this.init$={...this.init$,name:"",href:"",title:""}}initCallback(){super.initCallback(),this.sub("name",e=>{if(!e)return;let t=`#uc-icon-${e}`;this.subConfigValue("iconHrefResolver",i=>{if(i){let s=i(e);t=s!=null?s:t}this.$.href=t})})}};ue.template=``;ue.bindAttributes({name:"name",title:"title"});var Qs=r=>[...new Set(r)];var to=r=>Object.entries(r).filter(([e,t])=>t!==void 0&&t!=="").map(([e,t])=>e==="cdn-operations"||e==="analytics"?t:`${e}/${t}`);var Fl="https://ucarecdn.com",he=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Fl},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Xt="--uc-img-",pr="unresolved";var fr=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),mr=3e3,gr=5e3,br=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var io=Object.create(null),eo;for(let r in he)io[Xt+r]=((eo=he[r])==null?void 0:eo.default)||"";var si=class extends Pt{constructor(){super(...arguments);u(this,"cssInit$",io)}$$(t){return this.$[Xt+t]}set$$(t){for(let i in t)this.$[Xt+i]=t[i]}sub$$(t,i){this.sub(Xt+t,s=>{s===null||s===""||i(s)})}analyticsParams(){return`-/@clib/${jt}/${Ht}/uc-img/`}initAttributes(t){[...this.attributes].forEach(i=>{he[i.name]||t.setAttribute(i.name,i.value)})}initIntersection(t,i){let s={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(n=>{n.isIntersecting&&(i(),this._isnObserver.unobserve(t))})},s),this._isnObserver.observe(t),this._observed||(this._observed=new Set),this._observed.add(t)}destroyCallback(){super.destroyCallback(),this._isnObserver&&(this._observed.forEach(t=>{this._isnObserver.unobserve(t)}),this._isnObserver=null),E.deleteCtx(this)}static get observedAttributes(){return Object.keys(he)}attributeChangedCallback(t,i,s){window.setTimeout(()=>{this.$[Xt+t]=s})}};var li=class extends si{constructor(){super(...arguments);u(this,"_img",new Image);u(this,"_imgPreview",new Image)}_fmtAbs(t){return!t.includes("//")&&!fr&&(t=new URL(t,document.baseURI).href),t}_validateSize(t){if((t==null?void 0:t.trim())!==""){let i=t.match(/\d+/)[0],s=t.match(/[a-zA-Z]+/)[0],o=parseInt(i,10);if(Number(o)>gr&&this.hasFormatJPG)return gr+s;if(Number(o)>mr&&!this.hasFormatJPG)return mr+s}return t}_getCdnModifiers(t,i){let s={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(t),blur:i,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return D(...to(s))}_getUrlBase(t="",i=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(fr&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let s=this._getCdnModifiers(t,i);if(this.$$("src").startsWith(this.$$("cdn-cname")))return U(this.$$("src"),s);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(U(yt(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("uuid"))return this._proxyUrl(U(yt(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("proxy-cname"))return this._proxyUrl(U(this.$$("proxy-cname"),s,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(U(`https://${this.$$("pubkey")}.ucr.io/`,s,this._fmtAbs(this.$$("src"))))}_proxyUrl(t){return this.$$("secure-delivery-proxy")?te(this.$$("secure-delivery-proxy"),{previewUrl:t},{transform:s=>window.encodeURIComponent(s)}):t}_getElSize(t,i=1,s=!0){let o=t.getBoundingClientRect(),n=i*Math.round(o.width),l=s?"":i*Math.round(o.height);return n||l?`${n||""}x${l||""}`:null}_setupEventProxy(t){let i=o=>{o.stopPropagation();let n=new Event(o.type,o);this.dispatchEvent(n)},s=["load","error"];for(let o of s)t.addEventListener(o,i)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:br.PREVIEW,img:this._imgPreview}:{type:br.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){if(this.$$("breakpoints")){let t=N(this.$$("breakpoints"));return Qs(t.map(i=>parseInt(i,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(t){let i=new Set;i.add(`url("${this._getUrlBase(this._getElSize(t))}") 1x`),this.$$("hi-res-support")&&i.add(`url("${this._getUrlBase(this._getElSize(t,2))}") ${2}x`),this.$$("ultra-res-support")&&i.add(`url("${this._getUrlBase(this._getElSize(t,3))}") ${3}x`);let s=`image-set(${[...i].join(", ")})`;t.style.setProperty("background-image",s),t.style.setProperty("background-image","-webkit-"+s)}getSrcset(){let t=new Set;return this.breakpoints?this.breakpoints.forEach(i=>{t.add(this._getUrlBase(i+"x")+` ${this._validateSize(i+"w")}`),this.$$("hi-res-support")&&t.add(this._getUrlBase(i*2+"x")+` ${this._validateSize(i*2+"w")}`),this.$$("ultra-res-support")&&t.add(this._getUrlBase(i*3+"x")+` ${this._validateSize(i*3+"w")}`)}):(t.add(this._getUrlBase(this._getElSize(this.currentImg.img))+" 1x"),this.$$("hi-res-support")&&t.add(this._getUrlBase(this._getElSize(this.currentImg.img,2))+" 2x"),this.$$("ultra-res-support")&&t.add(this._getUrlBase(this._getElSize(this.currentImg.img,3))+" 3x")),[...t].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){[...document.querySelectorAll(this.bgSelector)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this.renderBg(t)}):this.renderBg(t)})}_appendURL({elNode:t,src:i,srcset:s}){i&&(t.src=i),s&&(t.srcset=s)}_setupConfigForImage({elNode:t}){this._setupEventProxy(t),this.initAttributes(t)}loaderImage({src:t,srcset:i,elNode:s}){return new Promise((o,n)=>{this._setupConfigForImage({elNode:s}),s.setAttribute(pr,""),s.addEventListener("load",()=>{s.removeAttribute(pr),o(s)}),s.addEventListener("error",()=>{n(!1)}),this._appendURL({elNode:s,src:t,srcset:i})})}async renderImage(){var t,i;if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{var s;this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((s=this._imgPreview)==null?void 0:s.remove()),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await((t=this._imgPreview)==null?void 0:t.remove()),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((i=this._imgPreview)==null?void 0:i.remove()),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var _r=class extends li{initCallback(){super.initCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",e=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=e?"lazy":"eager")})}};var de=class de extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);this.init$={...this.init$,withDropZone:!0,onClick:()=>{this.api.initFlow()},"button-text":""}}initCallback(){super.initCallback(),this.defineAccessor("dropzone",t=>{typeof t!="undefined"&&(this.$.withDropZone=$(t))}),this.subConfigValue("multiple",t=>{this.$["button-text"]=t?"upload-files":"upload-file"})}};u(de,"styleAttrs",[...j(de,de,"styleAttrs"),"uc-simple-btn"]);var pe=de;pe.template=``;pe.bindAttributes({dropzone:null});var ai=class extends b{constructor(){super(...arguments);u(this,"historyTracked",!0);u(this,"activityType","start-from")}initCallback(){super.initCallback(),this.registerActivity(this.activityType)}};ai.template='