@uploadcare/file-uploader
Version:
Building blocks for Uploadcare products integration
28 lines • 167 kB
JavaScript
/**
* @license
* MIT License
*
* Copyright (c) 2022 Uploadcare (hello@uploadcare.com). All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var Ii=Object.defineProperty;var ki=Object.getPrototypeOf;var Li=Reflect.get;var Mi=(r,e,t)=>e in r?Ii(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>(Mi(r,typeof e!="symbol"?e+"":e,t),t);var Mt=(r,e,t)=>Li(ki(r),t,e);function Pi(r){for(let e in r){let t=[...e].reduce((i,s)=>(s.toUpperCase()===s&&(s="-"+s.toLowerCase()),i+=s),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("uc-")||(t="uc-"+t),r[e].reg&&r[e].reg(t)}}var yt={"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 Pt=new Map,ye=new Map,ir=(r,e)=>{Pt.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`),Pt.set(r,{...yt,...e})},Ri=(r,e)=>{ye.set(r,e)},sr=(r,e)=>{typeof e=="function"?Ri(r,e):ir(r,e)},or=async r=>{if(!Pt.has(r)){if(!ye.has(r))throw new Error(`Locale ${r} is not defined`);let t=await ye.get(r)();ir(r,t)}return Pt.get(r)};sr("en",yt);function z(r,e){let t,i=(...s)=>{clearTimeout(t),t=setTimeout(()=>r(...s),e)};return i.cancel=()=>{clearTimeout(t)},i}var x=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"}),Rt=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)}};var Fi=Object.defineProperty,Di=(r,e,t)=>e in r?Fi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_e=(r,e,t)=>(Di(r,typeof e!="symbol"?e+"":e,t),t);function $i(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 v=class{constructor(r){r.constructor===Object?this.store=$i(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)?(v.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)){v.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)?(v.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=v.globalStore.get(e);return t?console.warn('State: context UID "'+e+'" already in use'):(t=new v(r),v.globalStore.set(e,t)),t}static deleteCtx(r){v.globalStore.delete(r)}static getCtx(r,e=!0){return v.globalStore.get(r)||(e&&console.warn('State: wrong context UID - "'+r+'"'),null)}};v.globalStore=new Map;var _=Object.freeze({BIND_ATTR:"set",ATTR_BIND_PRFX:"@",EXT_DATA_CTX_PRFX:"*",NAMED_DATA_CTX_SPLTR:"/",CTX_NAME_ATTR:"ctx-name",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx-name",EL_REF_ATTR:"ref",AUTO_TAG_PRFX:"sym",REPEAT_ATTR:"repeat",REPEAT_ITEM_TAG_ATTR:"repeat-item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL:"use-template",ROOT_STYLE_ATTR_NAME:"sym-component"}),ar="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Ni=ar.length-1,_t=class{static generate(r="XXXXXXXXX-XXX"){let e="";for(let t=0;t<r.length;t++)e+=r[t]==="-"?r[t]:ar.charAt(Math.random()*Ni);return e}};function cr(r,e,t){let i=!0,s,o=e.split(".");return o.forEach((n,l)=>{l<o.length-1?r=r[n]:s=n}),r?r[s]=t:i=!1,i}function Vi(r){return r.split("-").map((e,t)=>e&&t?e[0].toUpperCase()+e.slice(1):e).join("").split("_").map((e,t)=>e&&t?e.toUpperCase():e).join("")}function zi(r,e){[...r.querySelectorAll(`[${_.REPEAT_ATTR}]`)].forEach(t=>{let i=t.getAttribute(_.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(_.REPEAT_ATTR);e.sub(o,n=>{if(!n){for(;t.firstChild;)t.firstChild.remove();return}let l=[...t.children],a,c=h=>{h.forEach((f,m)=>{if(l[m])if(l[m].set$)setTimeout(()=>{l[m].set$(f)});else for(let p in f)l[m][p]=f[p];else{a||(a=new DocumentFragment);let p=new s;Object.assign(p.init$,f),a.appendChild(p)}}),a&&t.appendChild(a);let d=l.slice(h.length,l.length);for(let f of d)f.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let h=[];for(let d in n){let f=n[d];Object.defineProperty(f,"_KEY_",{value:d,enumerable:!0}),h.push(f)}c(h)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),t.removeAttribute(_.REPEAT_ATTR),t.removeAttribute(_.REPEAT_ITEM_TAG_ATTR)})}var nr="__default__";function ji(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")||nr;i[o]={slot:s,fr:document.createDocumentFragment()}}),e.initChildren.forEach(s=>{var o;let n=nr;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 Bi(r,e){[...r.querySelectorAll(`[${_.EL_REF_ATTR}]`)].forEach(t=>{let i=t.getAttribute(_.EL_REF_ATTR);e.ref[i]=t,t.removeAttribute(_.EL_REF_ATTR)})}function Hi(r,e){[...r.querySelectorAll(`[${_.BIND_ATTR}]`)].forEach(t=>{let s=t.getAttribute(_.BIND_ATTR).split(";");[...t.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=Vi(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(_.ATTR_BIND_PRFX)===0&&(a=!0,l=l.replace(_.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,f=>{d==="double"?f=!!f:d==="single"&&(f=!f),a?(f==null?void 0:f.constructor)===Boolean?f?t.setAttribute(l,""):t.removeAttribute(l):t.setAttribute(l,f):cr(t,l,f)||(t[_.SET_LATER_KEY]||(t[_.SET_LATER_KEY]=Object.create(null)),t[_.SET_LATER_KEY][l]=f)})}}),t.removeAttribute(_.BIND_ATTR)})}var Ft="{{",bt="}}",Gi="skip-text";function Xi(r){let e,t=[],i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(Gi))&&s.textContent.includes(Ft)&&s.textContent.includes(bt)&&1}});for(;e=i.nextNode();)t.push(e);return t}var qi=function(r,e){Xi(r).forEach(i=>{let s=[],o;for(;i.textContent.includes(bt);)i.textContent.startsWith(Ft)?(o=i.textContent.indexOf(bt)+bt.length,i.splitText(o),s.push(i)):(o=i.textContent.indexOf(Ft),i.splitText(o)),i=i.nextSibling;s.forEach(n=>{let l=n.textContent.replace(Ft,"").replace(bt,"");n.textContent="",e.sub(l,a=>{n.textContent=a})})})},Wi=[zi,ji,Bi,Hi,qi],Dt="'",ht='"',Ki=/\\([0-9a-fA-F]{1,6} ?)/g;function Zi(r){return(r[0]===ht||r[0]===Dt)&&(r[r.length-1]===ht||r[r.length-1]===Dt)}function Yi(r){return(r[0]===ht||r[0]===Dt)&&(r=r.slice(1)),(r[r.length-1]===ht||r[r.length-1]===Dt)&&(r=r.slice(0,-1)),r}function Ji(r){let e="",t="";for(var i=0;i<r.length;i++){let s=r[i+1];r[i]==="\\"&&s==='"'?(e+='\\"',i++):r[i]==='"'&&t!=="\\"?e+='\\"':e+=r[i],t=r[i]}return e}function Qi(r){let e=r;Zi(r)&&(e=Yi(e),e=e.replace(Ki,(t,i)=>String.fromCodePoint(parseInt(i.trim(),16))),e=e.replaceAll(`\\
`,"\\n"),e=Ji(e),e=ht+e+ht);try{return JSON.parse(e)}catch{throw new Error(`Failed to parse CSS property value: ${e}. Original input: ${r}`)}}var lr=0,dt=null,K=null,it=class extends HTMLElement{constructor(){super(),_e(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 it}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(_.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=_t.generate(),this.style.setProperty(_.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(_.CSS_CTX_PROP,!0)}get ctxName(){var r;let e=((r=this.getAttribute(_.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=v.registerCtx({},this)),this.__localCtx}get nodeCtx(){return v.getCtx(this.ctxName,!1)||v.registerCtx({},this.ctxName)}static __parseProp(r,e){let t,i;if(r.startsWith(_.EXT_DATA_CTX_PRFX))t=e.nodeCtx,i=r.replace(_.EXT_DATA_CTX_PRFX,"");else if(r.includes(_.NAMED_DATA_CTX_SPLTR)){let s=r.split(_.NAMED_DATA_CTX_SPLTR);t=v.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=it.__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=it.__parseProp(r,this);e.ctx.notify(e.name)}has(r){let e=it.__parseProp(r,this);return e.ctx.has(e.name)}add(r,e,t=!1){let i=it.__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=it.__parseProp(t,this);return s.ctx.pub(s.name,i),!0},get:(e,t)=>{let i=it.__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(_.CTX_OWNER_ATTR)&&this.getAttribute(_.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(_.EXT_DATA_CTX_PRFX))this.nodeCtx.add(e.replace(_.EXT_DATA_CTX_PRFX,""),this.init$[e],this.__ctxOwner);else if(e.includes(_.NAMED_DATA_CTX_SPLTR)){let t=e.split(_.NAMED_DATA_CTX_SPLTR),i=t[0].trim(),s=t[1].trim();if(i&&s){let o=v.getCtx(i,!1);o||(o=v.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(_.CTX_NAME_ATTR))==null?void 0:r.trim();if(e&&this.style.setProperty(_.CSS_CTX_PROP,`'${e}'`),this.__initDataCtx(),this[_.SET_LATER_KEY]){for(let t in this[_.SET_LATER_KEY])cr(this,t,this[_.SET_LATER_KEY][t]);delete this[_.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let t of Wi)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[${_.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let s=this.constructor.__rootStylesLink.cloneNode(!0);s.setAttribute(_.ROOT_STYLE_ATTR_NAME,this.constructor.is),s.onload=()=>{this.render()},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);K==null||K.delete(this.updateCssData),K!=null&&K.size||(dt==null||dt.disconnect(),dt=null,K=null)},100)))}static reg(r,e=!1){r||(lr++,r=`${_.AUTO_TAG_PRFX}-${lr}`),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]=Qi(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(){K||(K=new Set),K.add(this.updateCssData),dt||(dt=new MutationObserver(r=>{r[0].type==="attributes"&&K.forEach(e=>{e()})}),dt.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}}},ve=it;_e(ve,"template");var be=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(be.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=v.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||""})}),be.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}};be.appMap=Object.create(null);function $t(r,e){for(let t in e)t.includes("-")?r.style.setProperty(t,e[t]):r.style[t]=e[t]}var ur="idb-store-ready",ts="symbiote-db",es="symbiote-idb-update_",rs=class{_notifyWhenReady(r=null){window.dispatchEvent(new CustomEvent(ur,{detail:{dbName:this.name,storeName:this.storeName,event:r}}))}get _updEventName(){return es+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 ur}static open(r=ts,e="store"){let t=r+"/"+e;return this._reg[t]||(this._reg[t]=new rs(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]}};_e(dr,"_reg",Object.create(null));var is=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},we=(...r)=>r.filter(e=>typeof e=="string"&&e).map(e=>is(e)).join("/-/"),Nt=(...r)=>{let e=we(...r);return e?`-/${e}/`:""};function Vt(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 hr(r){let e=new URL(r),{pathname:t}=e,i=t.indexOf("/"),s=t.indexOf("/",i+1);return t.substring(i+1,s)}function fr(r){let e=pr(r),t=new URL(e),i=t.pathname.indexOf("/-/");return i===-1?"":t.pathname.substring(i).slice(1)}function pr(r){let e=new URL(r),t=Vt(r),i=mr(t)?gr(t).pathname:t;return e.pathname=e.pathname.replace(i,""),e.search="",e.hash="",e.toString()}function mr(r){return r.startsWith("http")}function gr(r){let e=new URL(r);return{pathname:e.origin+e.pathname||"",search:e.search||"",hash:e.hash||""}}var zt=(r,e,t)=>{let i=new URL(pr(r));if(t=t||Vt(r),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),mr(t)){let s=gr(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()},yr=(r,e)=>{let t=new URL(r);return t.pathname=e+"/",t.toString()};var Z=(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});var xn=we("format/auto","progressive/yes"),Y=([r])=>typeof r!="undefined"?Number(r):void 0,br=()=>!0,ss=([r,e])=>({name:r,amount:typeof e!="undefined"?Number(e):100}),os=([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:Z(r,"x").map(Number),coords:Z(e).map(Number)}},En=Object.freeze({enhance:Y,brightness:Y,exposure:Y,gamma:Y,contrast:Y,saturation:Y,vibrance:Y,warmth:Y,filter:ss,mirror:br,flip:br,rotate:Y,crop:os});var Ce=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),_r=[Ce.CROP,Ce.TUNING,Ce.FILTERS];var On=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 jt=r=>r?r.join(","):"";var ns="https://ucarecdn.com",ls="https://upload.uploadcare.com",as="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:jt(_r),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:ns,baseUrl:ls,socialBaseUrl:as,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 vr="--uploadcare-blocks-window-height",at=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(vr)}};u(at,"clientsRegistry",new Set),u(at,"flush",z(()=>{document.documentElement.style.setProperty(vr,`${window.innerHeight}px`)},100));var wr=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 Bt=(r,e)=>new Intl.PluralRules(r).select(e);var cs=r=>r,Ae="{{",Ar="}}",Cr="plural:";function xe(r,e,t={}){var n;let{openToken:i=Ae,closeToken:s=Ar,transform:o=cs}=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 xr(r){let e=[],t=r.indexOf(Ae);for(;t!==-1;){let i=r.indexOf(Ar,t),s=r.substring(t+2,i);if(s.startsWith(Cr)){let o=r.substring(t+2,i).replace(Cr,""),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(Ae,i)}return e}var Er=({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 Sr(r){return Object.prototype.toString.call(r)==="[object Object]"}var us=/\W|_/g;function ds(r){return r.split(us).map((e,t)=>e.charAt(0)[t>0?"toUpperCase":"toLowerCase"]()+e.slice(1)).join("")}function Tr(r,{ignoreKeys:e}={ignoreKeys:[]}){return Array.isArray(r)?r.map(t=>tt(t,{ignoreKeys:e})):r}function tt(r,{ignoreKeys:e}={ignoreKeys:[]}){if(Array.isArray(r))return Tr(r,{ignoreKeys:e});if(!Sr(r))return r;let t={};for(let i of Object.keys(r)){let s=r[i];if(e.includes(i)){t[i]=s;continue}Sr(s)?s=tt(s,{ignoreKeys:e}):Array.isArray(s)&&(s=Tr(s,{ignoreKeys:e})),t[ds(i)]=s}return t}var hs=r=>new Promise(e=>setTimeout(e,r));function ke({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 fs={factor:2,time:100};function ps(r,e=fs){let t=0;function i(s){let o=Math.round(e.time*e.factor**t);return s({attempt:t,retry:l=>hs(l!=null?l:o).then(()=>(t+=1,i(s)))})}return i(r)}var vt=class extends Error{},ft=class r extends vt{constructor(t){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,r.prototype),this.originalProgressEvent=t}},Gt=(r,e)=>{r&&(r.aborted?Promise.resolve().then(e):r.addEventListener("abort",()=>e(),{once:!0}))},st=class r extends vt{constructor(t="Request canceled"){super(t);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,r.prototype)}},ms=500,Ur=({check:r,interval:e=ms,timeout:t,signal:i})=>new Promise((s,o)=>{let n,l;Gt(i,()=>{n&&clearTimeout(n),o(new st("Poll cancelled"))}),t&&(l=setTimeout(()=>{n&&clearTimeout(n),o(new st("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)}),w={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"},Xt="application/octet-stream",Ir="original",ot=({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[f,m]=d;typeof m!="undefined"&&!Array.isArray(m)&&a.setRequestHeader(f,m)}),a.responseType="text",Gt(s,()=>{h=!0,a.abort(),l(new st)}),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},f=a.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};f.forEach(function(C){let A=C.split(": "),y=A.shift(),b=A.join(": ");y&&typeof y!="undefined"&&(m[y]=b)});let p=a.response,g=a.status;n({request:d,data:p,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 gs(r,...e){return r}var ys=({name:r})=>r?[r]:[],bs=gs,_s=()=>new FormData,kr=r=>!1,qt=r=>typeof Blob!="undefined"&&r instanceof Blob,Wt=r=>typeof File!="undefined"&&r instanceof File,Kt=r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&"uri"in r&&typeof r.uri=="string",pt=r=>qt(r)||Wt(r)||kr()||Kt(r),vs=r=>typeof r=="string"||typeof r=="number"||typeof r=="undefined",ws=r=>!!r&&typeof r=="object"&&!Array.isArray(r),Cs=r=>!!r&&typeof r=="object"&&"data"in r&&pt(r.data);function Lr(r,e,t){if(Array.isArray(t))for(let i of t)Lr(r,`${e}[]`,i);else if(Cs(t)){let{name:i,contentType:s}=t,o=bs(t.data,i,s!=null?s:Xt),n=ys({name:i,contentType:s});r.push([e,o,...n])}else if(ws(t))for(let[i,s]of Object.entries(t))typeof s!="undefined"&&r.push([`${e}[${i}]`,String(s)]);else vs(t)&&t&&r.push([e,t.toString()])}function As(r){let e=[];for(let[t,i]of Object.entries(r))Lr(e,t,i);return e}function Zt(r){let e=_s(),t=As(r);for(let i of t){let[s,o,...n]=i;e.append(s,o,...n)}return e}var k=class r extends vt{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)}},xs=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()},J=(r,e,t)=>{let i=new URL(r);return i.pathname=(i.pathname+e).replace("//","/"),t&&(i.search=xs(t)),i.toString()},Es="6.14.1",Ss="UploadcareUploadClient",Ts=Es;function ct(r){return ke({libraryName:Ss,libraryVersion:Ts,...r})}var Os="RequestThrottledError",Or=15e3,Us=1e3;function Is(r){let{headers:e}=r||{};if(!e||typeof e["retry-after"]!="string")return Or;let t=parseInt(e["retry-after"],10);return Number.isFinite(t)?t*1e3:Or}function nt(r,e){let{retryThrottledRequestMaxTimes:t,retryNetworkErrorMaxTimes:i}=e;return ps(({attempt:s,retry:o})=>r().catch(n=>{if("response"in n&&(n==null?void 0:n.code)===Os&&s<t)return o(Is(n));if(n instanceof ft&&s<i)return o((s+1)*Us);throw n}))}var Mr=r=>{let e="";return(qt(r)||Wt(r)||Kt(r))&&(e=r.type),e||Xt},Pr=r=>{let e="";return Wt(r)&&r.name?e=r.name:qt(r)||kr()?e="":Kt(r)&&r.name&&(e=r.name),e||Ir};function Le(r){return typeof r=="undefined"||r==="auto"?"auto":r?"1":"0"}function ks(r,{publicKey:e,fileName:t,contentType:i,baseURL:s=w.baseURL,secureSignature:o,secureExpire:n,store:l,signal:a,onProgress:c,source:h="local",integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=w.retryNetworkErrorMaxTimes,metadata:g}){return nt(()=>ot({method:"POST",url:J(s,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":ct({publicKey:e,integration:d,userAgent:f})},data:Zt({file:{data:r,name:t||Pr(r),contentType:i||Mr(r)},UPLOADCARE_PUB_KEY:e,UPLOADCARE_STORE:Le(l),signature:o,expire:n,source:h,metadata:g}),signal:a,onProgress:c}).then(({data:C,headers:A,request:y})=>{let b=tt(JSON.parse(C));if("error"in b)throw new k(b.error.content,b.error.errorCode,y,b,A);return b}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:m})}var Te;(function(r){r.Token="token",r.FileInfo="file_info"})(Te||(Te={}));function Ls(r,{publicKey:e,baseURL:t=w.baseURL,store:i,fileName:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:l,secureExpire:a,source:c="url",signal:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=w.retryNetworkErrorMaxTimes,metadata:g}){return nt(()=>ot({method:"POST",headers:{"X-UC-User-Agent":ct({publicKey:e,integration:d,userAgent:f})},url:J(t,"/from_url/",{jsonerrors:1,pub_key:e,source_url:r,store:Le(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:C,headers:A,request:y})=>{let b=tt(JSON.parse(C));if("error"in b)throw new k(b.error.content,b.error.errorCode,y,b,A);return b}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:m})}var P;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(P||(P={}));var Ms=r=>"status"in r&&r.status===P.Error;function Ps(r,{publicKey:e,baseURL:t=w.baseURL,signal:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=w.retryNetworkErrorMaxTimes}={}){return nt(()=>ot({method:"GET",headers:e?{"X-UC-User-Agent":ct({publicKey:e,integration:s,userAgent:o})}:void 0,url:J(t,"/from_url/status/",{jsonerrors:1,token:r}),signal:i}).then(({data:a,headers:c,request:h})=>{let d=tt(JSON.parse(a));if("error"in d&&!Ms(d))throw new k(d.error.content,d.error.errorCode,h,d,c);return d}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:n})}function Rs(r,{publicKey:e,baseURL:t=w.baseURL,jsonpCallback:i,secureSignature:s,secureExpire:o,signal:n,source:l,integration:a,userAgent:c,retryThrottledRequestMaxTimes:h=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:d=w.retryNetworkErrorMaxTimes}){return nt(()=>ot({method:"POST",headers:{"X-UC-User-Agent":ct({publicKey:e,integration:a,userAgent:c})},url:J(t,"/group/",{jsonerrors:1}),data:Zt({files:r,callback:i,pub_key:e,signature:s,expire:o,source:l}),signal:n}).then(({data:f,headers:m,request:p})=>{let g=tt(JSON.parse(f));if("error"in g)throw new k(g.error.content,g.error.errorCode,p,g,m);return g}),{retryNetworkErrorMaxTimes:d,retryThrottledRequestMaxTimes:h})}function Rr(r,{publicKey:e,baseURL:t=w.baseURL,signal:i,source:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:l=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=w.retryNetworkErrorMaxTimes}){return nt(()=>ot({method:"GET",headers:{"X-UC-User-Agent":ct({publicKey:e,integration:o,userAgent:n})},url:J(t,"/info/",{jsonerrors:1,pub_key:e,file_id:r,source:s}),signal:i}).then(({data:c,headers:h,request:d})=>{let f=tt(JSON.parse(c));if("error"in f)throw new k(f.error.content,f.error.errorCode,d,f,h);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Fs(r,{publicKey:e,contentType:t,fileName:i,multipartChunkSize:s=w.multipartChunkSize,baseURL:o="",secureSignature:n,secureExpire:l,store:a,signal:c,source:h="local",integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=w.retryNetworkErrorMaxTimes,metadata:g}){return nt(()=>ot({method:"POST",url:J(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":ct({publicKey:e,integration:d,userAgent:f})},data:Zt({filename:i||Ir,size:r,content_type:t||Xt,part_size:s,UPLOADCARE_STORE:Le(a),UPLOADCARE_PUB_KEY:e,signature:n,expire:l,source:h,metadata:g}),signal:c}).then(({data:C,headers:A,request:y})=>{let b=tt(JSON.parse(C));if("error"in b)throw new k(b.error.content,b.error.errorCode,y,b,A);return b.parts=Object.keys(b.parts).map(T=>b.parts[Number(T)]),b}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p})}function Ds(r,e,{contentType:t,signal:i,onProgress:s,retryThrottledRequestMaxTimes:o=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=w.retryNetworkErrorMaxTimes}){return nt(()=>ot({method:"PUT",url:e,data:r,onProgress:s,signal:i,headers:{"Content-Type":t||Xt}}).then(l=>(s&&s({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n})}function $s(r,{publicKey:e,baseURL:t=w.baseURL,source:i="local",signal:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:l=w.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=w.retryNetworkErrorMaxTimes}){return nt(()=>ot({method:"POST",url:J(t,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":ct({publicKey:e,integration:o,userAgent:n})},data:Zt({uuid:r,UPLOADCARE_PUB_KEY:e,source:i}),signal:s}).then(({data:c,headers:h,request:d})=>{let f=tt(JSON.parse(c));if("error"in f)throw new k(f.error.content,f.error.errorCode,d,f,h);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Me(r,{publicKey:e,baseURL:t,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:l,signal:a,onProgress:c}){return Ur({check:h=>Rr(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 Ns(r){return"defaultEffects"in r}var Q=class{constructor(e,{baseCDN:t=w.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=J(t,`${s}/`),l=o?J(`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,Ns(e)&&(this.defaultEffects=e.defaultEffects)}},Vs=(r,{publicKey:e,fileName:t,baseURL:i,secureSignature:s,secureExpire:o,store:n,contentType:l,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,baseCDN:g,metadata:C})=>ks(r,{publicKey:e,fileName:t,contentType:l,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,metadata:C}).then(({file:A})=>Me(A,{publicKey:e,baseURL:i,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,onProgress:c,signal:a})).then(A=>new Q(A,{baseCDN:g})),zs=(r,{publicKey:e,fileName:t,baseURL:i,signal:s,onProgress:o,source:n,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h,baseCDN:d})=>Rr(r,{publicKey:e,baseURL:i,signal:s,source:n,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h}).then(f=>new Q(f,{baseCDN:d,fileName:t})).then(f=>(o&&o({isComputable:!0,value:1}),f)),js=(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 Gt(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]})},Bs=window.WebSocket,Oe=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]=[]}},Hs=(r,e)=>r==="success"?{status:P.Success,...e}:r==="progress"?{status:P.Progress,...e}:{status:P.Error,...e},Ue=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 Oe);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 Bs(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,Hs(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)}},Ee=null,Pe=r=>{if(!Ee){let e=typeof window=="undefined"?0:3e4;Ee=new Ue(r,e)}return Ee},Gs=r=>{Pe(r).connect()};function Xs({token:r,publicKey:e,baseURL:t,integration:i,userAgent:s,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,onProgress:l,signal:a}){return Ur({check:c=>Ps(r,{publicKey:e,baseURL:t,integration:i,userAgent: