@uploadcare/file-uploader 1.24.4 → 1.24.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/env.js +1 -1
- package/dist/index.css +471 -525
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -7
- package/dist/index.layered.css +2719 -0
- package/dist/index.ssr.js +10 -4
- package/dist/locales/file-uploader/nl.js +1 -1
- package/package.json +8 -3
- package/web/file-uploader.iife.min.d.ts +2 -0
- package/web/file-uploader.iife.min.js +1 -1
- package/web/file-uploader.min.d.ts +2 -0
- package/web/file-uploader.min.js +1 -1
- package/web/uc-basic.layered.min.css +26 -0
- package/web/uc-basic.min.css +2 -3
- package/web/uc-cloud-image-editor.layered.min.css +26 -0
- package/web/uc-cloud-image-editor.min.css +1 -2
- package/web/uc-cloud-image-editor.min.d.ts +2 -0
- package/web/uc-cloud-image-editor.min.js +1 -1
- package/web/uc-file-uploader-inline.layered.min.css +26 -0
- package/web/uc-file-uploader-inline.min.css +2 -3
- package/web/uc-file-uploader-inline.min.d.ts +2 -0
- package/web/uc-file-uploader-inline.min.js +1 -1
- package/web/uc-file-uploader-minimal.layered.min.css +26 -0
- package/web/uc-file-uploader-minimal.min.css +2 -3
- package/web/uc-file-uploader-minimal.min.d.ts +2 -0
- package/web/uc-file-uploader-minimal.min.js +1 -1
- package/web/uc-file-uploader-regular.layered.min.css +26 -0
- package/web/uc-file-uploader-regular.min.css +2 -3
- package/web/uc-file-uploader-regular.min.d.ts +2 -0
- package/web/uc-file-uploader-regular.min.js +1 -1
- package/web/uc-img.min.js +1 -1
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
var _n=Object.defineProperty,wn=(i,e,t)=>e in i?_n(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Gi=(i,e,t)=>(wn(i,typeof e!="symbol"?e+"":e,t),t);function Cn(i){let e=t=>{var r;for(let o in t)((r=t[o])==null?void 0:r.constructor)===Object&&(t[o]=e(t[o]));return{...t}};return e(i)}var E=class{constructor(i){i.constructor===Object?this.store=Cn(i):(this._storeIsProxy=!0,this.store=i),this.callbackMap=Object.create(null)}static warn(i,e){console.warn(`Symbiote Data: cannot ${i}. Prop name: `+e)}read(i){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(E.warn("read",i),null):this.store[i]}has(i){return this._storeIsProxy?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this._storeIsProxy&&!this.store.hasOwnProperty(i)){E.warn("publish",i);return}this.store[i]=e,this.notify(i)}multiPub(i){for(let e in i)this.pub(e,i[e])}notify(i){this.callbackMap[i]&&this.callbackMap[i].forEach(e=>{e(this.store[i])})}sub(i,e,t=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(E.warn("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.store[i]),{remove:()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},callback:e})}static registerCtx(i,e=Symbol()){let t=E.globalStore.get(e);return t?console.warn('State: context UID "'+e+'" already in use'):(t=new E(i),E.globalStore.set(e,t)),t}static deleteCtx(i){E.globalStore.delete(i)}static getCtx(i,e=!0){return E.globalStore.get(i)||(e&&console.warn('State: wrong context UID - "'+i+'"'),null)}};E.globalStore=new Map;var w=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"}),no="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",En=no.length-1,ne=class{static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:no.charAt(Math.random()*En);return e}};function ao(i,e,t){let r=!0,o,s=e.split(".");return s.forEach((n,a)=>{a<s.length-1?i=i[n]:o=n}),i?i[o]=t:r=!1,r}function Tn(i){return i.split("-").map((e,t)=>e&&t?e[0].toUpperCase()+e.slice(1):e).join("").split("_").map((e,t)=>e&&t?e.toUpperCase():e).join("")}function xn(i,e){[...i.querySelectorAll(`[${w.REPEAT_ATTR}]`)].forEach(t=>{let r=t.getAttribute(w.REPEAT_ITEM_TAG_ATTR),o;if(r&&(o=window.customElements.get(r)),!o){o=class extends e.BaseComponent{constructor(){super(),r||(this.style.display="contents")}};let n=t.innerHTML;o.template=n,o.reg(r)}for(;t.firstChild;)t.firstChild.remove();let s=t.getAttribute(w.REPEAT_ATTR);e.sub(s,n=>{if(!n){for(;t.firstChild;)t.firstChild.remove();return}let a=[...t.children],l,c=d=>{d.forEach((p,m)=>{if(a[m])if(a[m].set$)setTimeout(()=>{a[m].set$(p)});else for(let h in p)a[m][h]=p[h];else{l||(l=new DocumentFragment);let h=new o;Object.assign(h.init$,p),l.appendChild(h)}}),l&&t.appendChild(l);let u=a.slice(d.length,a.length);for(let p of u)p.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let d=[];for(let u in n){let p=n[u];Object.defineProperty(p,"_KEY_",{value:u,enumerable:!0}),d.push(p)}c(d)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),t.removeAttribute(w.REPEAT_ATTR),t.removeAttribute(w.REPEAT_ITEM_TAG_ATTR)})}var oo="__default__";function An(i,e){if(e.shadowRoot)return;let t=[...i.querySelectorAll("slot")];if(!t.length)return;let r={};t.forEach(o=>{let s=o.getAttribute("name")||oo;r[s]={slot:o,fr:document.createDocumentFragment()}}),e.initChildren.forEach(o=>{var s;let n=oo;o instanceof Element&&o.hasAttribute("slot")&&(n=o.getAttribute("slot"),o.removeAttribute("slot")),(s=r[n])==null||s.fr.appendChild(o)}),Object.values(r).forEach(o=>{if(o.fr.childNodes.length)o.slot.parentNode.replaceChild(o.fr,o.slot);else if(o.slot.childNodes.length){let s=document.createDocumentFragment();s.append(...o.slot.childNodes),o.slot.parentNode.replaceChild(s,o.slot)}else o.slot.remove()})}function Sn(i,e){[...i.querySelectorAll(`[${w.EL_REF_ATTR}]`)].forEach(t=>{let r=t.getAttribute(w.EL_REF_ATTR);e.ref[r]=t,t.removeAttribute(w.EL_REF_ATTR)})}function In(i,e){[...i.querySelectorAll(`[${w.BIND_ATTR}]`)].forEach(t=>{let o=t.getAttribute(w.BIND_ATTR).split(";");[...t.attributes].forEach(s=>{if(s.name.startsWith("-")&&s.value){let n=Tn(s.name.replace("-",""));o.push(n+":"+s.value),t.removeAttribute(s.name)}}),o.forEach(s=>{if(!s)return;let n=s.split(":").map(d=>d.trim()),a=n[0],l;a.indexOf(w.ATTR_BIND_PRFX)===0&&(l=!0,a=a.replace(w.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(d=>d.trim());for(let d of c){let u;d.startsWith("!!")?(u="double",d=d.replace("!!","")):d.startsWith("!")&&(u="single",d=d.replace("!","")),e.sub(d,p=>{u==="double"?p=!!p:u==="single"&&(p=!p),l?p?.constructor===Boolean?p?t.setAttribute(a,""):t.removeAttribute(a):t.setAttribute(a,p):ao(t,a,p)||(t[w.SET_LATER_KEY]||(t[w.SET_LATER_KEY]=Object.create(null)),t[w.SET_LATER_KEY][a]=p)})}}),t.removeAttribute(w.BIND_ATTR)})}var Ut="{{",nt="}}",kn="skip-text";function On(i){let e,t=[],r=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode:o=>{var s;return!((s=o.parentElement)!=null&&s.hasAttribute(kn))&&o.textContent.includes(Ut)&&o.textContent.includes(nt)&&1}});for(;e=r.nextNode();)t.push(e);return t}var Mn=function(i,e){On(i).forEach(r=>{let o=[],s;for(;r.textContent.includes(nt);)r.textContent.startsWith(Ut)?(s=r.textContent.indexOf(nt)+nt.length,r.splitText(s),o.push(r)):(s=r.textContent.indexOf(Ut),r.splitText(s)),r=r.nextSibling;o.forEach(n=>{let a=n.textContent.replace(Ut,"").replace(nt,"");n.textContent="",e.sub(a,l=>{n.textContent=l})})})},Ln=[xn,An,Sn,In,Mn],$t="'",He='"',Rn=/\\([0-9a-fA-F]{1,6} ?)/g;function Pn(i){return(i[0]===He||i[0]===$t)&&(i[i.length-1]===He||i[i.length-1]===$t)}function Un(i){return(i[0]===He||i[0]===$t)&&(i=i.slice(1)),(i[i.length-1]===He||i[i.length-1]===$t)&&(i=i.slice(0,-1)),i}function $n(i){let e="",t="";for(var r=0;r<i.length;r++){let o=i[r+1];i[r]==="\\"&&o==='"'?(e+='\\"',r++):i[r]==='"'&&t!=="\\"?e+='\\"':e+=i[r],t=i[r]}return e}function Dn(i){let e=i;Pn(i)&&(e=Un(e),e=e.replace(Rn,(t,r)=>String.fromCodePoint(parseInt(r.trim(),16))),e=e.replaceAll(`\\
|
|
27
27
|
`,"\\n"),e=$n(e),e=He+e+He);try{return JSON.parse(e)}catch{throw new Error(`Failed to parse CSS property value: ${e}. Original input: ${i}`)}}var so=0,ze=null,he=null,Ce=class extends HTMLElement{constructor(){super(),Gi(this,"updateCssData",()=>{var i;this.dropCssDataCache(),(i=this.__boundCssProps)==null||i.forEach(e=>{let t=this.getCssData(this.__extractCssName(e),!0);t!==null&&this.$[e]!==t&&(this.$[e]=t)})}),this.init$=Object.create(null),this.cssInit$=Object.create(null),this.tplProcessors=new Set,this.ref=Object.create(null),this.allSubs=new Set,this.pauseRender=!1,this.renderShadow=!1,this.readyToDestroy=!0,this.processInnerHtml=!1,this.allowCustomTemplate=!1,this.ctxOwner=!1}get BaseComponent(){return Ce}initCallback(){}__initCallback(){var i;this.__initialized||(this.__initialized=!0,(i=this.initCallback)==null||i.call(this))}render(i,e=this.renderShadow){let t;if((e||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let o=this.getAttribute(w.USE_TPL);if(o){let s=this.getRootNode(),n=s?.querySelector(o)||document.querySelector(o);n?i=n.content.cloneNode(!0):console.warn(`Symbiote template "${o}" is not found...`)}}if(this.processInnerHtml)for(let o of this.tplProcessors)o(this,this);if(i||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),i?.constructor===DocumentFragment)t=i;else if(i?.constructor===String){let o=document.createElement("template");o.innerHTML=i,t=o.content.cloneNode(!0)}else this.constructor.__tpl&&(t=this.constructor.__tpl.content.cloneNode(!0));for(let o of this.tplProcessors)o(t,this)}let r=()=>{t&&(e&&this.shadowRoot.appendChild(t)||this.appendChild(t)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){e=!0;let o=document.createElement("link");o.rel="stylesheet",o.href=this.constructor.__shadowStylesUrl,o.onload=r,this.shadowRoot.prepend(o)}else r()}addTemplateProcessor(i){this.tplProcessors.add(i)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=ne.generate(),this.style.setProperty(w.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(w.CSS_CTX_PROP,!0)}get ctxName(){var i;let e=((i=this.getAttribute(w.CTX_NAME_ATTR))==null?void 0:i.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=e,e}get localCtx(){return this.__localCtx||(this.__localCtx=E.registerCtx({},this)),this.__localCtx}get nodeCtx(){return E.getCtx(this.ctxName,!1)||E.registerCtx({},this.ctxName)}static __parseProp(i,e){let t,r;if(i.startsWith(w.EXT_DATA_CTX_PRFX))t=e.nodeCtx,r=i.replace(w.EXT_DATA_CTX_PRFX,"");else if(i.includes(w.NAMED_DATA_CTX_SPLTR)){let o=i.split(w.NAMED_DATA_CTX_SPLTR);t=E.getCtx(o[0]),r=o[1]}else t=e.localCtx,r=i;return{ctx:t,name:r}}sub(i,e,t=!0){let r=s=>{this.isConnected&&e(s)},o=Ce.__parseProp(i,this);o.ctx.has(o.name)?this.allSubs.add(o.ctx.sub(o.name,r,t)):window.setTimeout(()=>{this.allSubs.add(o.ctx.sub(o.name,r,t))})}notify(i){let e=Ce.__parseProp(i,this);e.ctx.notify(e.name)}has(i){let e=Ce.__parseProp(i,this);return e.ctx.has(e.name)}add(i,e,t=!1){let r=Ce.__parseProp(i,this);r.ctx.add(r.name,e,t)}add$(i,e=!1){for(let t in i)this.add(t,i[t],e)}get $(){if(!this.__stateProxy){let i=Object.create(null);this.__stateProxy=new Proxy(i,{set:(e,t,r)=>{let o=Ce.__parseProp(t,this);return o.ctx.pub(o.name,r),!0},get:(e,t)=>{let r=Ce.__parseProp(t,this);return r.ctx.read(r.name)}})}return this.__stateProxy}set$(i,e=!1){for(let t in i){let r=i[t];e||![String,Number,Boolean].includes(r?.constructor)?this.$[t]=r:this.$[t]!==r&&(this.$[t]=r)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(w.CTX_OWNER_ATTR)&&this.getAttribute(w.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let i=this.constructor.__attrDesc;if(i)for(let e of Object.values(i))Object.keys(this.init$).includes(e)||(this.init$[e]="");for(let e in this.init$)if(e.startsWith(w.EXT_DATA_CTX_PRFX))this.nodeCtx.add(e.replace(w.EXT_DATA_CTX_PRFX,""),this.init$[e],this.__ctxOwner);else if(e.includes(w.NAMED_DATA_CTX_SPLTR)){let t=e.split(w.NAMED_DATA_CTX_SPLTR),r=t[0].trim(),o=t[1].trim();if(r&&o){let s=E.getCtx(r,!1);s||(s=E.registerCtx({},r)),s.add(o,this.init$[e])}}else this.localCtx.add(e,this.init$[e]);for(let e in this.cssInit$)this.bindCssData(e,this.cssInit$[e]);this.__dataCtxInitialized=!0}connectedCallback(){var i;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let e=(i=this.getAttribute(w.CTX_NAME_ATTR))==null?void 0:i.trim();if(e&&this.style.setProperty(w.CSS_CTX_PROP,`'${e}'`),this.__initDataCtx(),this[w.SET_LATER_KEY]){for(let t in this[w.SET_LATER_KEY])ao(this,t,this[w.SET_LATER_KEY][t]);delete this[w.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let t of Ln)this.addTemplateProcessor(t);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let t=this.getRootNode();if(!t)return;if(t?.querySelector(`link[${w.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let o=this.constructor.__rootStylesLink.cloneNode(!0);o.setAttribute(w.ROOT_STYLE_ATTR_NAME,this.constructor.is),o.onload=()=>{this.render()},t.nodeType===Node.DOCUMENT_NODE?t.head.appendChild(o):t.prepend(o)}else this.render()}this.connectedOnce=!0}}destroyCallback(){}disconnectedCallback(){this.connectedOnce&&(this.dropCssDataCache(),this.readyToDestroy&&(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),this.__disconnectTimeout=window.setTimeout(()=>{this.destroyCallback();for(let i of this.allSubs)i.remove(),this.allSubs.delete(i);for(let i of this.tplProcessors)this.tplProcessors.delete(i);he?.delete(this.updateCssData),he?.size||(ze?.disconnect(),ze=null,he=null)},100)))}static reg(i,e=!1){i||(so++,i=`${w.AUTO_TAG_PRFX}-${so}`),this.__tag=i;let t=window.customElements.get(i);if(t){!e&&t!==this&&console.warn([`Element with tag name "${i}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
|
|
28
28
|
`));return}window.customElements.define(i,e?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(i){this.observedAttributes=Object.keys(i),this.__attrDesc=i}attributeChangedCallback(i,e,t){var r;if(e===t)return;let o=(r=this.constructor.__attrDesc)==null?void 0:r[i];o?this.__dataCtxInitialized?this.$[o]=t:this.init$[o]=t:this[i]=t}getCssData(i,e=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(i)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let t=this.__computedStyle.getPropertyValue(i).trim();try{this.__cssDataCache[i]=Dn(t)}catch{!e&&console.warn(`CSS Data error: ${i}`),this.__cssDataCache[i]=null}}return this.__cssDataCache[i]}__extractCssName(i){return i.split("--").map((e,t)=>t===0?"":e).join("--")}__initStyleAttrObserver(){he||(he=new Set),he.add(this.updateCssData),ze||(ze=new MutationObserver(i=>{i[0].type==="attributes"&&he.forEach(e=>{e()})}),ze.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(i,e=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(i);let t=this.getCssData(this.__extractCssName(i),!0);t===null&&(t=e),this.add(i,t),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(i,e,t){let r="__"+i;this[r]=this[i],Object.defineProperty(this,i,{set:o=>{this[r]=o,t?window.setTimeout(()=>{e?.(o)}):e?.(o)},get:()=>this[r]}),this[i]=this[r]}static set shadowStyles(i){let e=new Blob([i],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(e)}static set rootStyles(i){if(!this.__rootStylesLink){let e=new Blob([i],{type:"text/css"}),t=URL.createObjectURL(e),r=document.createElement("link");r.href=t,r.rel="stylesheet",this.__rootStylesLink=r}}},Ee=Ce;Gi(Ee,"template");var Ki=class{static _print(i){console.warn(i)}static setDefaultTitle(i){this.defaultTitle=i}static setRoutingMap(i){Object.assign(this.appMap,i);for(let e in this.appMap)!this.defaultRoute&&this.appMap[e].default===!0?this.defaultRoute=e:!this.errorRoute&&this.appMap[e].error===!0&&(this.errorRoute=e)}static set routingEventName(i){this.__routingEventName=i}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let i={route:null,options:{}};return window.location.search.split(this.separator).forEach(t=>{if(t.includes("?"))i.route=t.replace("?","");else if(t.includes("=")){let r=t.split("=");i.options[r[0]]=decodeURI(r[1])}else i.options[t]=!0}),i}static notify(){let i=this.readAddressBar(),e=this.appMap[i.route];if(e&&e.title&&(document.title=e.title),i.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!e&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e){this._print(`Route "${i.route}" not found...`);return}let t=new CustomEvent(Ki.routingEventName,{detail:{route:i.route,options:Object.assign(e||{},i.options)}});window.dispatchEvent(t)}static reflect(i,e={}){let t=this.appMap[i];if(!t){this._print("Wrong route: "+i);return}let r="?"+i;for(let s in e)e[s]===!0?r+=this.separator+s:r+=this.separator+s+`=${e[s]}`;let o=t.title||this.defaultTitle||"";window.history.pushState(null,o,r),document.title=o}static applyRoute(i,e={}){this.reflect(i,e),this.notify()}static setSeparator(i){this._separator=i}static get separator(){return this._separator||"&"}static createRouterData(i,e){this.setRoutingMap(e);let t=E.registerCtx({route:null,options:null,title:null},i);return window.addEventListener(this.routingEventName,r=>{var o;t.multiPub({route:r.detail.route,options:r.detail.options,title:((o=r.detail.options)==null?void 0:o.title)||this.defaultTitle||""})}),Ki.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}};Ki.appMap=Object.create(null);function at(i,e){for(let t in e)t.includes("-")?i.style.setProperty(t,e[t]):i.style[t]=e[t]}function Fn(i,e){for(let t in e)e[t].constructor===Boolean?e[t]?i.setAttribute(t,""):i.removeAttribute(t):i.setAttribute(t,e[t])}function Wi(i={tag:"div"}){let e=document.createElement(i.tag);if(i.attributes&&Fn(e,i.attributes),i.styles&&at(e,i.styles),i.properties)for(let t in i.properties)e[t]=i.properties[t];return i.processors&&i.processors.forEach(t=>{t(e)}),i.children&&i.children.forEach(t=>{let r=Wi(t);e.appendChild(r)}),e}var lo="idb-store-ready",Vn="symbiote-db",Nn="symbiote-idb-update_",Bn=class{_notifyWhenReady(i=null){window.dispatchEvent(new CustomEvent(lo,{detail:{dbName:this.name,storeName:this.storeName,event:i}}))}get _updEventName(){return Nn+this.name}_getUpdateEvent(i){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:i}})}_notifySubscribers(i){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,i),window.dispatchEvent(this._getUpdateEvent(i))}constructor(i,e){this.name=i,this.storeName=e,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=t=>{this.db=t.target.result,this.objStore=this.db.createObjectStore(e,{keyPath:"_key"}),this.objStore.transaction.oncomplete=r=>{this._notifyWhenReady(r)}},this.request.onsuccess=t=>{this.db=t.target.result,this._notifyWhenReady(t)},this.request.onerror=t=>{console.error(t)},this._subscriptionsMap={},this._updateHandler=t=>{t.key===this.name&&this._subscriptionsMap[t.newValue]&&this._subscriptionsMap[t.newValue].forEach(async o=>{o(await this.read(t.newValue))})},this._localUpdateHandler=t=>{this._updateHandler(t.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(i){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(i);return new Promise((r,o)=>{t.onsuccess=s=>{var n;(n=s.target.result)!=null&&n._value?r(s.target.result._value):(r(null),console.warn(`IDB: cannot read "${i}"`))},t.onerror=s=>{o(s)}})}write(i,e,t=!1){let r={_key:i,_value:e},s=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(r);return new Promise((n,a)=>{s.onsuccess=l=>{t||this._notifySubscribers(i),n(l.target.result)},s.onerror=l=>{a(l)}})}delete(i,e=!1){let r=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(i);return new Promise((o,s)=>{r.onsuccess=n=>{e||this._notifySubscribers(i),o(n)},r.onerror=n=>{s(n)}})}getAll(){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((t,r)=>{e.onsuccess=o=>{let s=o.target.result;t(s.map(n=>n._value))},e.onerror=o=>{r(o)}})}subscribe(i,e){this._subscriptionsMap[i]||(this._subscriptionsMap[i]=new Set);let t=this._subscriptionsMap[i];return t.add(e),{remove:()=>{t.delete(e),t.size||delete this._subscriptionsMap[i]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,co.clear(this.name)}},co=class{static get readyEventName(){return lo}static open(i=Vn,e="store"){let t=i+"/"+e;return this._reg[t]||(this._reg[t]=new Bn(i,e)),this._reg[t]}static clear(i){window.indexedDB.deleteDatabase(i);for(let e in this._reg)e.split("/")[0]===i&&delete this._reg[e]}};Gi(co,"_reg",Object.create(null));var k=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),T=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"}),Dt=class{_timeoutStore=new Map;_targets=new Set;_debugPrint=null;constructor(e){this._debugPrint=e}bindTarget(e){this._targets.add(e)}unbindTarget(e){this._targets.delete(e)}_dispatch(e,t){for(let r of this._targets)r.dispatchEvent(new CustomEvent(e,{detail:t}));this._debugPrint?.(()=>{let r=t&&typeof t=="object"?{...t}:t;return[`event "${e}"`,r]})}emit(e,t,r={}){let{debounce:o}=r;if(typeof o!="number"&&!o){this._dispatch(e,typeof t=="function"?t():t);return}this._timeoutStore.has(e)&&window.clearTimeout(this._timeoutStore.get(e));let s=typeof o=="number"?o:20,n=window.setTimeout(()=>{this._dispatch(e,typeof t=="function"?t():t),this._timeoutStore.delete(e)},s);this._timeoutStore.set(e,n)}};function M(i,e){let t,r=((...o)=>{t&&clearTimeout(t),t=setTimeout(()=>i(...o),e)});return r.cancel=()=>{t&&clearTimeout(t)},r}var q=i=>i?i.split(",").map(e=>e.trim()).filter(Boolean):[],me=i=>i.join(",");var uo=i=>{if(typeof i!="string"||!i)return"";let e=i.trim();return e.startsWith("-/")?e=e.slice(2):e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,e.length-1)),e},Ft=(...i)=>i.filter(e=>typeof e=="string"&&!!e).map(e=>uo(e)).join("/-/"),H=(...i)=>{let e=Ft(...i);return e?`-/${e}/`:""};function Vt(i){let e=new URL(i),t=e.pathname+e.search+e.hash,r=t.lastIndexOf("http"),o=t.lastIndexOf("/"),s="";return r>=0?s=t.slice(r):o>=0&&(s=t.slice(o+1)),s}function Nt(i){let e=new URL(i),{pathname:t}=e,r=t.indexOf("/"),o=t.indexOf("/",r+1);return t.substring(r+1,o)}function qi(i){let e=po(i),t=new URL(e),r=t.pathname.indexOf("/-/");return r===-1?"":t.pathname.substring(r).slice(1)}function Xi(i){return qi(i).split("/-/").filter(Boolean).map(t=>uo(t))}function po(i){let e=new URL(i),t=Vt(i),r=ho(t)?mo(t).pathname:t;return e.pathname=e.pathname.replace(r,""),e.search="",e.hash="",e.toString()}function ho(i){return i.startsWith("http")}function mo(i){let e=new URL(i);return{pathname:`${e.origin}${e.pathname??""}`,search:e.search??"",hash:e.hash??""}}var U=(i,e,t)=>{let r=new URL(po(i)),o=t??Vt(i),s=e??"";if(r.pathname.startsWith("//")&&(r.pathname=r.pathname.replace("//","/")),o&&ho(o)){let n=mo(o);r.pathname=`${r.pathname}${s}${n.pathname||""}`,r.search=n.search,r.hash=n.hash}else r.pathname=`${r.pathname}${s}${o||""}`;return r.toString()},Te=(i,e)=>{let t=new URL(i);return t.pathname=`${e}/`,t.toString()};var $=(i,e=",")=>i.trim().split(e).map(t=>t.trim()).filter(t=>t.length>0);var lt=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}),go=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function zn(i,e){if(typeof e=="number"){let t=e;return lt[i]!==t?`${i}/${t}`:""}if(typeof e=="boolean"){let t=e;return lt[i]!==t?`${i}`:""}if(i==="filter"&&e){let{name:t,amount:r}=e;return lt.filter===r?"":`${i}/${t}/${r}`}if(i==="crop"&&e){let{dimensions:t,coords:r}=e;return`${i}/${t.join("x")}/${r.join(",")}`}return""}function xe(i){return Ft(...go.filter(e=>typeof i[e]<"u"&&i[e]!==null).map(e=>{let t=i[e];return zn(e,t)}).filter(e=>!!e))}var Bt=Ft("format/auto","progressive/yes"),fe=([i])=>typeof i<"u"?Number(i):void 0,fo=()=>!0,Hn=([i,e])=>({name:i,amount:typeof e<"u"?Number(e):100}),jn=([i,e])=>{if(!/\d+x\d+/.test(i)||!/\d+,\d+/.test(e))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:$(i,"x").map(Number),coords:$(e).map(Number)}},Kn=Object.freeze({enhance:fe,brightness:fe,exposure:fe,gamma:fe,contrast:fe,saturation:fe,vibrance:fe,warmth:fe,filter:Hn,mirror:fo,flip:fo,rotate:fe,crop:i=>{let[e,t]=i,{dimensions:r,coords:o}=jn([e,t]);return{dimensions:r,coords:o}}});function Zi(i){let e={};for(let t of i){let[r,...o]=t.split("/");if(!r||!go.includes(r))continue;let s=r,n=Kn[s];try{let a=n(o);e[s]=a}catch(a){console.warn([`Failed to parse URL operation "${t}". It will be ignored.`,a instanceof Error?`Error message: "${a.message}"`:a,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
|
|
29
|
-
`))}}return e}var L=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),X=Object.freeze([L.CROP,L.TUNING,L.FILTERS]),vo=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),yo=Object.freeze(["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"]),bo=Object.freeze(["rotate","mirror","flip"]),ge=lt,re=Object.freeze({brightness:{zero:ge.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:ge.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:ge.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:ge.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:ge.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:ge.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:ge.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:ge.enhance,range:[0,100],keypointsNumber:1},filter:{zero:ge.filter,range:[0,100],keypointsNumber:1}});var ct="https://ucarecdn.com",Gn="https://upload.uploadcare.com",Wn="https://social.uploadcare.com",qn="https://ucarecd.net",Xn={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:me(X),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:ct,cdnCnamePrefixed:qn,baseUrl:Gn,socialBaseUrl:Wn,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},Y=Object.freeze(Xn);var _o=i=>{let e=new Intl.Locale(i),t="ltr",r=e.getTextInfo?.().direction;return r?t=r:e.textInfo?.direction&&(t=e.textInfo.direction),t};var zt=(i,e)=>new Intl.PluralRules(i).select(e);var Zn=i=>i;var wo="plural:";function dt(i,e={},t={}){let{openToken:r="{{",closeToken:o="}}",transform:s=Zn}=t;for(let n in e){let a=e[n],l=a?.toString(),c=typeof l=="string"?s(l):String(l);i=i.replaceAll(r+n+o,c)}return i}function Co(i){let e=[],t=i.indexOf("{{");for(;t!==-1;){let r=i.indexOf("}}",t);if(r===-1)break;let o=i.substring(t+2,r);if(o.startsWith(wo)){let s=i.substring(t+2,r).replace(wo,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));e.push({variable:o,pluralKey:n,countVariable:a})}t=i.indexOf("{{",r)}return e}var Eo="--uploadcare-blocks-window-height",ut=class i{static clientsRegistry=new Set;static flush=M(()=>{document.documentElement.style.setProperty(Eo,`${window.innerHeight}px`)},100);static registerClient(e){i.clientsRegistry.size===0&&i.attachTracker(),i.clientsRegistry.add(e)}static unregisterClient(e){i.clientsRegistry.delete(e),i.clientsRegistry.size===0&&i.detachTracker()}static attachTracker(){window.addEventListener("resize",i.flush,{passive:!0,capture:!0}),i.flush()}static detachTracker(){window.removeEventListener("resize",i.flush,{capture:!0}),document.documentElement.style.removeProperty(Eo)}};var To=({element:i,attribute:e,onSuccess:t,onTimeout:r,timeout:o=300})=>{let s=i.getAttribute(e);if(s!==null){t(s);return}let n=new MutationObserver(c=>{let d=c[c.length-1];d&&l(d)});n.observe(i,{attributes:!0,attributeFilter:[e]});let a=window.setTimeout(()=>{n.disconnect(),r()},o),l=c=>{let d=i.getAttribute(e);c.type==="attributes"&&c.attributeName===e&&d!==null&&(window.clearTimeout(a),n.disconnect(),t(d))}};function xo(i){return Object.prototype.toString.call(i)==="[object Object]"}var Yn=/\W|_/g;function Qn(i){return i.split(Yn).map((e,t)=>e.charAt(0)[t>0?"toUpperCase":"toLowerCase"]()+e.slice(1)).join("")}function Ao(i,{ignoreKeys:e}={ignoreKeys:[]}){return Array.isArray(i)?i.map(t=>be(t,{ignoreKeys:e})):i}function be(i,{ignoreKeys:e}={ignoreKeys:[]}){if(Array.isArray(i))return Ao(i,{ignoreKeys:e});if(!xo(i))return i;let t={};for(let r of Object.keys(i)){let o=i[r];if(e.includes(r)){t[r]=o;continue}xo(o)?o=be(o,{ignoreKeys:e}):Array.isArray(o)&&(o=Ao(o,{ignoreKeys:e})),t[Qn(r)]=o}return t}var Jn=i=>new Promise(e=>setTimeout(e,i));function rr({libraryName:i,libraryVersion:e,userAgent:t,publicKey:r="",integration:o=""}){let s="JavaScript";if(typeof t=="string")return t;if(typeof t=="function")return t({publicKey:r,libraryName:i,libraryVersion:e,languageName:s,integration:o});let n=[i,e,r].filter(Boolean).join("/"),a=[s,o].filter(Boolean).join("; ");return`${n} (${a})`}var ea={factor:2,time:100};function ta(i,e=ea){let t=0;function r(o){let s=Math.round(e.time*e.factor**t);return o({attempt:t,retry:a=>Jn(a??s).then(()=>(t+=1,r(o)))})}return r(i)}var $e=class extends Error{},je=class i extends $e{originalProgressEvent;constructor(e){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,i.prototype),this.originalProgressEvent=e}},Ht=(i,e)=>{i&&(i.aborted?Promise.resolve().then(e):i.addEventListener("abort",()=>e(),{once:!0}))},Ae=class i extends $e{isCancel=!0;constructor(e="Request canceled"){super(e),this.name="CancelError",Object.setPrototypeOf(this,i.prototype)}},ia=500,Io=({check:i,interval:e=ia,timeout:t,signal:r})=>new Promise((o,s)=>{let n,a;Ht(r,()=>{n&&clearTimeout(n),s(new Ae("Poll cancelled"))}),t&&(a=setTimeout(()=>{n&&clearTimeout(n),s(new Ae("Timed out"))},t));let l=()=>{try{Promise.resolve(i(r)).then(c=>{c?(a&&clearTimeout(a),o(c)):n=setTimeout(l,e)}).catch(c=>{a&&clearTimeout(a),s(c)})}catch(c){a&&clearTimeout(a),s(c)}};n=setTimeout(l,0)}),S={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"},jt="application/octet-stream",ko="original",Ie=({method:i,url:e,data:t,headers:r={},signal:o,onProgress:s})=>new Promise((n,a)=>{let l=new XMLHttpRequest,c=i?.toUpperCase()||"GET",d=!1;l.open(c,e,!0),r&&Object.entries(r).forEach(u=>{let[p,m]=u;typeof m<"u"&&!Array.isArray(m)&&l.setRequestHeader(p,m)}),l.responseType="text",Ht(o,()=>{d=!0,l.abort(),a(new Ae)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let u={method:c,url:e,data:t,headers:r||void 0,signal:o,onProgress:s},p=l.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};p.forEach(function(v){let A=v.split(": "),C=A.shift(),x=A.join(": ");C&&typeof C<"u"&&(m[C]=x)});let h=l.response,g=l.status;n({request:u,data:h,headers:m,status:g})}},l.onerror=u=>{d||a(new je(u))},s&&typeof s=="function"&&(l.upload.onprogress=u=>{u.lengthComputable?s({isComputable:!0,value:u.loaded/u.total}):s({isComputable:!1})}),t?l.send(t):l.send()});function ra(i,...e){return i}var oa=({name:i})=>i?[i]:[],sa=ra,na=()=>new FormData,Oo=i=>!1,Kt=i=>typeof Blob<"u"&&i instanceof Blob,Gt=i=>typeof File<"u"&&i instanceof File,Wt=i=>!!i&&typeof i=="object"&&!Array.isArray(i)&&"uri"in i&&typeof i.uri=="string",Ke=i=>Kt(i)||Gt(i)||Oo()||Wt(i),aa=i=>typeof i=="string"||typeof i=="number"||typeof i>"u",la=i=>!!i&&typeof i=="object"&&!Array.isArray(i),ca=i=>!!i&&typeof i=="object"&&"data"in i&&Ke(i.data);function Mo(i,e,t){if(Array.isArray(t))for(let r of t)Mo(i,`${e}[]`,r);else if(ca(t)){let{name:r,contentType:o}=t,s=sa(t.data,r,o??jt),n=oa({name:r,contentType:o});i.push([e,s,...n])}else if(la(t))for(let[r,o]of Object.entries(t))typeof o<"u"&&i.push([`${e}[${r}]`,String(o)]);else aa(t)&&t&&i.push([e,t.toString()])}function da(i){let e=[];for(let[t,r]of Object.entries(i))Mo(e,t,r);return e}function qt(i){let e=na(),t=da(i);for(let r of t){let[o,s,...n]=r;e.append(o,s,...n)}return e}var j=class i extends $e{code;request;response;headers;constructor(e,t,r,o,s){super(),this.name="UploadError",this.message=e,this.code=t,this.request=r,this.response=o,this.headers=s,Object.setPrototypeOf(this,i.prototype)}},ua=i=>{let e=new URLSearchParams;for(let[t,r]of Object.entries(i))r&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).filter(o=>o[1]??!1).forEach(o=>e.set(`${t}[${o[0]}]`,String(o[1]))):Array.isArray(r)?r.forEach(o=>{e.append(`${t}[]`,o)}):typeof r=="string"&&r?e.set(t,r):typeof r=="number"&&e.set(t,r.toString());return e.toString()},ve=(i,e,t)=>{let r=new URL(i);return r.pathname=(r.pathname+e).replace("//","/"),t&&(r.search=ua(t)),r.toString()},pa="6.18.2",ha="UploadcareUploadClient",ma=pa;function De(i){return rr({libraryName:ha,libraryVersion:ma,...i})}var fa="RequestThrottledError",So=15e3,ga=1e3;function va(i){let{headers:e}=i||{};if(!e||typeof e["retry-after"]!="string")return So;let t=parseInt(e["retry-after"],10);return Number.isFinite(t)?t*1e3:So}function ke(i,e){let{retryThrottledRequestMaxTimes:t,retryNetworkErrorMaxTimes:r}=e;return ta(({attempt:o,retry:s})=>i().catch(n=>{if("response"in n&&n?.code===fa&&o<t)return s(va(n));if(n instanceof je&&o<r)return s((o+1)*ga);throw n}))}var Lo=i=>{let e="";return(Kt(i)||Gt(i)||Wt(i))&&(e=i.type),e||jt},Ro=i=>{let e="";return Gt(i)&&i.name?e=i.name:Kt(i)||Oo()?e="":Wt(i)&&i.name&&(e=i.name),e||ko};function or(i){return typeof i>"u"||i==="auto"?"auto":i?"1":"0"}function ya(i,{publicKey:e,fileName:t,contentType:r,baseURL:o=S.baseURL,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:c,source:d="local",integration:u,userAgent:p,retryThrottledRequestMaxTimes:m=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=S.retryNetworkErrorMaxTimes,metadata:g}){return ke(()=>Ie({method:"POST",url:ve(o,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":De({publicKey:e,integration:u,userAgent:p})},data:qt({file:{data:i,name:t||Ro(i),contentType:r||Lo(i)},UPLOADCARE_PUB_KEY:e,UPLOADCARE_STORE:or(a),signature:s,expire:n,source:d,metadata:g}),signal:l,onProgress:c}).then(({data:v,headers:A,request:C})=>{let x=be(JSON.parse(v));if("error"in x)throw new j(x.error.content,x.error.errorCode,C,x,A);return x}),{retryNetworkErrorMaxTimes:h,retryThrottledRequestMaxTimes:m})}var Ji;(function(i){i.Token="token",i.FileInfo="file_info"})(Ji||(Ji={}));function ba(i,{publicKey:e,baseURL:t=S.baseURL,store:r,fileName:o,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:c="url",signal:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=S.retryNetworkErrorMaxTimes,metadata:g}){return ke(()=>Ie({method:"POST",headers:{"X-UC-User-Agent":De({publicKey:e,integration:u,userAgent:p})},url:ve(t,"/from_url/",{jsonerrors:1,pub_key:e,source_url:i,store:or(r),filename:o,check_URL_duplicates:s?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:c,metadata:g}),signal:d}).then(({data:v,headers:A,request:C})=>{let x=be(JSON.parse(v));if("error"in x)throw new j(x.error.content,x.error.errorCode,C,x,A);return x}),{retryNetworkErrorMaxTimes:h,retryThrottledRequestMaxTimes:m})}var Z;(function(i){i.Unknown="unknown",i.Waiting="waiting",i.Progress="progress",i.Error="error",i.Success="success"})(Z||(Z={}));var _a=i=>"status"in i&&i.status===Z.Error;function wa(i,{publicKey:e,baseURL:t=S.baseURL,signal:r,integration:o,userAgent:s,retryThrottledRequestMaxTimes:n=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=S.retryNetworkErrorMaxTimes}={}){return ke(()=>Ie({method:"GET",headers:e?{"X-UC-User-Agent":De({publicKey:e,integration:o,userAgent:s})}:void 0,url:ve(t,"/from_url/status/",{jsonerrors:1,token:i}),signal:r}).then(({data:l,headers:c,request:d})=>{let u=be(JSON.parse(l));if("error"in u&&!_a(u))throw new j(u.error.content,u.error.errorCode,d,u,c);return u}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function Ca(i,{publicKey:e,baseURL:t=S.baseURL,jsonpCallback:r,secureSignature:o,secureExpire:s,signal:n,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:u=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"POST",headers:{"X-UC-User-Agent":De({publicKey:e,integration:l,userAgent:c})},url:ve(t,"/group/",{jsonerrors:1}),data:qt({files:i,callback:r,pub_key:e,signature:o,expire:s,source:a}),signal:n}).then(({data:p,headers:m,request:h})=>{let g=be(JSON.parse(p));if("error"in g)throw new j(g.error.content,g.error.errorCode,h,g,m);return g}),{retryNetworkErrorMaxTimes:u,retryThrottledRequestMaxTimes:d})}function Po(i,{publicKey:e,baseURL:t=S.baseURL,signal:r,source:o,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"GET",headers:{"X-UC-User-Agent":De({publicKey:e,integration:s,userAgent:n})},url:ve(t,"/info/",{jsonerrors:1,pub_key:e,file_id:i,source:o}),signal:r}).then(({data:c,headers:d,request:u})=>{let p=be(JSON.parse(c));if("error"in p)throw new j(p.error.content,p.error.errorCode,u,p,d);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function Ea(i,{publicKey:e,contentType:t,fileName:r,multipartChunkSize:o=S.multipartChunkSize,baseURL:s="",secureSignature:n,secureExpire:a,store:l,signal:c,source:d="local",integration:u,userAgent:p,retryThrottledRequestMaxTimes:m=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=S.retryNetworkErrorMaxTimes,metadata:g}){return ke(()=>Ie({method:"POST",url:ve(s,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":De({publicKey:e,integration:u,userAgent:p})},data:qt({filename:r||ko,size:i,content_type:t||jt,part_size:o,UPLOADCARE_STORE:or(l),UPLOADCARE_PUB_KEY:e,signature:n,expire:a,source:d,metadata:g}),signal:c}).then(({data:v,headers:A,request:C})=>{let x=be(JSON.parse(v));if("error"in x)throw new j(x.error.content,x.error.errorCode,C,x,A);return x.parts=Object.keys(x.parts).map(Q=>x.parts[Number(Q)]),x}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h})}function Ta(i,e,{contentType:t,signal:r,onProgress:o,retryThrottledRequestMaxTimes:s=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"PUT",url:e,data:i,onProgress:o,signal:r,headers:{"Content-Type":t||jt}}).then(a=>(o&&o({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n})}function xa(i,{publicKey:e,baseURL:t=S.baseURL,source:r="local",signal:o,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"POST",url:ve(t,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":De({publicKey:e,integration:s,userAgent:n})},data:qt({uuid:i,UPLOADCARE_PUB_KEY:e,source:r}),signal:o}).then(({data:c,headers:d,request:u})=>{let p=be(JSON.parse(c));if("error"in p)throw new j(p.error.content,p.error.errorCode,u,p,d);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function sr(i,{publicKey:e,baseURL:t,source:r,integration:o,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:c}){return Io({check:d=>Po(i,{publicKey:e,baseURL:t,signal:d,source:r,integration:o,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(u=>u.isReady?u:(c&&c({isComputable:!0,value:1}),!1)),signal:l})}function Aa(i){return"defaultEffects"in i}var ye=class{uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(e,{baseCDN:t=S.baseCDN,fileName:r}={}){let{uuid:o,s3Bucket:s}=e,n=ve(t,`${o}/`),a=s?ve(`https://${s}.s3.amazonaws.com/`,`${o}/${e.filename}`):null;this.uuid=o,this.name=r||e.filename,this.size=e.size,this.isStored=e.isStored,this.isImage=e.isImage,this.mimeType=e.mimeType,this.cdnUrl=n,this.originalFilename=e.originalFilename,this.imageInfo=e.imageInfo,this.videoInfo=e.videoInfo,this.contentInfo=e.contentInfo,this.metadata=e.metadata||null,this.s3Bucket=s||null,this.s3Url=a,Aa(e)&&(this.defaultEffects=e.defaultEffects)}},Sa=(i,{publicKey:e,fileName:t,baseURL:r,secureSignature:o,secureExpire:s,store:n,contentType:a,signal:l,onProgress:c,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,baseCDN:g,metadata:v})=>ya(i,{publicKey:e,fileName:t,contentType:a,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:l,onProgress:c,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,metadata:v}).then(({file:A})=>sr(A,{publicKey:e,baseURL:r,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,onProgress:c,signal:l})).then(A=>new ye(A,{baseCDN:g})),Ia=(i,{publicKey:e,fileName:t,baseURL:r,signal:o,onProgress:s,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d,baseCDN:u})=>Po(i,{publicKey:e,baseURL:r,signal:o,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d}).then(p=>new ye(p,{baseCDN:u,fileName:t})).then(p=>(s&&s({isComputable:!0,value:1}),p)),ka=(i,{signal:e}={})=>{let t=null,r=null,o=i.map(()=>new AbortController),s=n=>()=>{r=n,o.forEach((a,l)=>l!==n&&a.abort())};return Ht(e,()=>{o.forEach(n=>n.abort())}),Promise.all(i.map((n,a)=>{let l=s(a);return Promise.resolve().then(()=>n({stopRace:l,signal:o[a].signal})).then(c=>(l(),c)).catch(c=>(t=c,null))})).then(n=>{if(r===null)throw t;return n[r]})},Oa=window.WebSocket,er=class{events=Object.create({});emit(e,t){this.events[e]?.forEach(r=>r(t))}on(e,t){this.events[e]=this.events[e]||[],this.events[e].push(t)}off(e,t){t?this.events[e]=this.events[e].filter(r=>r!==t):this.events[e]=[]}},Ma=(i,e)=>i==="success"?{status:Z.Success,...e}:i==="progress"?{status:Z.Progress,...e}:{status:Z.Error,...e},tr=class{key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new er;disconnectTimeoutId=null;constructor(e,t=3e4){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 Oa(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 r=JSON.parse(t.data.toString());switch(r.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(r.channel,Ma(r.event,JSON.parse(r.data)))}})}}disconnect(){let e=()=>{this.ws?.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{e()},this.disconnectTime):e()}send(e,t){let r=JSON.stringify({event:e,data:t});this.ws?.send(r)}subscribe(e,t){this.subscribers+=1,this.connect();let r=`task-status-${e}`,o={event:"pusher:subscribe",data:{channel:r}};this.emmitter.on(r,t),this.isConnected?this.send(o.event,o.data):this.queue.push(o)}unsubscribe(e){this.subscribers-=1;let t=`task-status-${e}`,r={event:"pusher:unsubscribe",data:{channel:t}};this.emmitter.off(t),this.isConnected?this.send(r.event,r.data):this.queue=this.queue.filter(o=>o.data.channel!==t),this.subscribers===0&&this.disconnect()}onError(e){return this.emmitter.on("error",e),()=>this.emmitter.off("error",e)}},Yi=null,nr=i=>{if(!Yi){let e=typeof window>"u"?0:3e4;Yi=new tr(i,e)}return Yi},La=i=>{nr(i).connect()};function Ra({token:i,publicKey:e,baseURL:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Io({check:c=>wa(i,{publicKey:e,baseURL:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,signal:c}).then(d=>{switch(d.status){case Z.Error:return new j(d.error,d.errorCode);case Z.Waiting:return!1;case Z.Unknown:return new j(`Token "${i}" was not found.`);case Z.Progress:return a&&(d.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:d.done/d.total})),!1;case Z.Success:return a&&a({isComputable:!0,value:d.done/d.total}),d;default:throw new Error("Unknown status")}}),signal:l})}var Pa=({token:i,pusherKey:e,signal:t,onProgress:r})=>new Promise((o,s)=>{let n=nr(e),a=n.onError(s),l=()=>{a(),n.unsubscribe(i)};Ht(t,()=>{l(),s(new Ae("pusher cancelled"))}),n.subscribe(i,c=>{switch(c.status){case Z.Progress:{r&&(c.total==="unknown"?r({isComputable:!1}):r({isComputable:!0,value:c.done/c.total}));break}case Z.Success:{l(),r&&r({isComputable:!0,value:c.done/c.total}),o(c);break}case Z.Error:l(),s(new j(c.msg,c.error_code))}})}),Ua=(i,{publicKey:e,fileName:t,baseURL:r,baseCDN:o,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,onProgress:u,source:p,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,pusherKey:v=S.pusherKey,metadata:A})=>Promise.resolve(La(v)).then(()=>ba(i,{publicKey:e,fileName:t,baseURL:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,source:p,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,metadata:A})).catch(C=>(nr(v)?.disconnect(),Promise.reject(C))).then(C=>C.type===Ji.FileInfo?C:ka([({signal:x})=>Ra({token:C.token,publicKey:e,baseURL:r,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,onProgress:u,signal:x}),({signal:x})=>Pa({token:C.token,pusherKey:v,signal:x,onProgress:u})],{signal:d})).then(C=>{if(C instanceof j)throw C;return C}).then(C=>sr(C.uuid,{publicKey:e,baseURL:r,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,onProgress:u,signal:d})).then(C=>new ye(C,{baseCDN:o})),Qi=new WeakMap,$a=async i=>{if(Qi.has(i))return Qi.get(i);let e=await fetch(i.uri).then(t=>t.blob());return Qi.set(i,e),e},Uo=async i=>{if(Gt(i)||Kt(i))return i.size;if(Wt(i))return(await $a(i)).size;throw new Error("Unknown file type. Cannot determine file size.")},Da=(i,e=S.multipartMinFileSize)=>i>=e,$o=i=>{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!Ke(i)&&t.test(i)},ar=i=>{let e="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",t=new RegExp(e);return!Ke(i)&&t.test(i)},Fa=(i,e)=>new Promise((t,r)=>{let o=[],s=!1,n=e.length,a=[...e],l=()=>{let c=e.length-a.length,d=a.shift();d&&d().then(u=>{s||(o[c]=u,n-=1,n?l():t(o))}).catch(u=>{s=!0,r(u)})};for(let c=0;c<i;c++)l()}),Va=(i,e,t,r)=>{let o=r*e,s=Math.min(o+r,t);return i.slice(o,s)},Na=async(i,e,t)=>r=>Va(i,r,e,t),Ba=(i,e,{publicKey:t,contentType:r,onProgress:o,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>Ta(i,e,{publicKey:t,contentType:r,onProgress:o,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),za=async(i,{publicKey:e,fileName:t,fileSize:r,baseURL:o,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:c,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,contentType:g,multipartChunkSize:v=S.multipartChunkSize,maxConcurrentRequests:A=S.maxConcurrentRequests,baseCDN:C,metadata:x})=>{let Q=r??await Uo(i),J,Ue=(V,W)=>{if(!c)return;J||(J=Array(V).fill(0));let ie=se=>se.reduce((pe,ji)=>pe+ji,0);return se=>{se.isComputable&&(J[W]=se.value,c({isComputable:!0,value:ie(J)/V}))}};return g||=Lo(i),Ea(Q,{publicKey:e,contentType:g,fileName:t||Ro(i),baseURL:o,secureSignature:s,secureExpire:n,store:a,signal:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,metadata:x,multipartChunkSize:v}).then(async({uuid:V,parts:W})=>{let ie=await Na(i,Q,v);return Promise.all([V,Fa(A,W.map((se,pe)=>()=>Ba(ie(pe),se,{publicKey:e,contentType:g,onProgress:Ue(W.length,pe),signal:l,integration:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h})))])}).then(([V])=>xa(V,{publicKey:e,baseURL:o,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h})).then(V=>V.isReady?V:sr(V.uuid,{publicKey:e,baseURL:o,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,onProgress:c,signal:l})).then(V=>new ye(V,{baseCDN:C}))};async function lr(i,{publicKey:e,fileName:t,baseURL:r=S.baseURL,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:h,multipartMinFileSize:g,multipartChunkSize:v,maxConcurrentRequests:A,baseCDN:C=S.baseCDN,checkForUrlDuplicates:x,saveUrlForRecurrentUploads:Q,pusherKey:J,metadata:Ue}){if(Ke(i)){let V=await Uo(i);return Da(V,g)?za(i,{publicKey:e,contentType:h,multipartChunkSize:v,fileSize:V,fileName:t,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,maxConcurrentRequests:A,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:C,metadata:Ue}):Sa(i,{publicKey:e,fileName:t,contentType:h,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:C,metadata:Ue})}if(ar(i))return Ua(i,{publicKey:e,fileName:t,baseURL:r,baseCDN:C,checkForUrlDuplicates:x,saveUrlForRecurrentUploads:Q,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,pusherKey:J,metadata:Ue});if($o(i))return Ia(i,{publicKey:e,fileName:t,baseURL:r,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:C});throw new TypeError(`File uploading from "${i}" is not supported`)}var ir=class{uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(e,{baseCDN:t=S.baseCDN}={}){this.uuid=e.id,this.filesCount=e.filesCount;let r=e.files.filter(Boolean);this.totalSize=Object.values(r).reduce((o,s)=>o+s.size,0),this.isStored=!!e.datetimeStored,this.isImage=!!Object.values(r).filter(o=>o.isImage).length,this.cdnUrl=e.cdnUrl,this.files=r.map(o=>new ye(o,{baseCDN:t})),this.createdAt=e.datetimeCreated,this.storedAt=e.datetimeStored}},Ha=i=>{for(let e of i)if(!Ke(e))return!1;return!0},ja=i=>{for(let e of i)if(!$o(e))return!1;return!0},Ka=i=>{for(let e of i)if(!ar(e))return!1;return!0};function Do(i,{publicKey:e,fileName:t,baseURL:r=S.baseURL,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:h,multipartChunkSize:g=S.multipartChunkSize,baseCDN:v=S.baseCDN,checkForUrlDuplicates:A,saveUrlForRecurrentUploads:C,jsonpCallback:x}){if(!Ha(i)&&!Ka(i)&&!ja(i))throw new TypeError(`Group uploading from "${i}" is not supported`);let Q,J=!0,Ue=i.length,V=(W,ie)=>{if(!l)return;Q||(Q=Array(W).fill(0));let se=pe=>pe.reduce((ji,bn)=>ji+bn)/W;return pe=>{if(!pe.isComputable||!J){J=!1,l({isComputable:!1});return}Q[ie]=pe.value,l({isComputable:!0,value:se(Q)})}};return Promise.all(i.map((W,ie)=>Ke(W)||ar(W)?lr(W,{publicKey:e,fileName:t,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:V(Ue,ie),source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:h,multipartChunkSize:g,baseCDN:v,checkForUrlDuplicates:A,saveUrlForRecurrentUploads:C}).then(se=>se.uuid):W)).then(W=>Ca(W,{publicKey:e,baseURL:r,jsonpCallback:x,secureSignature:o,secureExpire:s,signal:a,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m}).then(ie=>new ir(ie,{baseCDN:v})).then(ie=>(l&&l({isComputable:!0,value:1}),ie)))}var Se=class{_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(e){this._concurrency=e}run(){let e=this._concurrency-this._running;for(let t=0;t<e;t++){let r=this._pending.shift();if(!r)return;let o=this._resolvers.get(r),s=this._rejectors.get(r);if(!o||!s)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,r().finally(()=>{this._resolvers.delete(r),this._rejectors.delete(r),this._running-=1,this.run()}).then(n=>o(n)).catch(n=>s(n))}}add(e,{autoRun:t}={autoRun:!0}){return new Promise((r,o)=>{this._resolvers.set(e,r),this._rejectors.set(e,o),this._pending.push(e),t&&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 cr=()=>({}),dr=i=>({...cr(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{i.modalManager?.close(i.$["*currentActivity"]),i.set$({"*currentActivity":null})}}),ur=i=>({...dr(i),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new Se(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),Fo=i=>({...ur(i),"*solution":null});var pt={"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":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","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-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","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 occurred. 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","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var Xt=new Map,pr=new Map,Vo=(i,e)=>{Xt.has(i)&&console.log(`Locale ${i} is already defined. Overwriting...`),Xt.set(i,{...pt,...e})},Ga=(i,e)=>{pr.set(i,e)},No=(i,e)=>{typeof e=="function"?Ga(i,e):Vo(i,e)},Bo=async i=>{if(!Xt.has(i)){if(!pr.has(i))throw new Error(`Locale ${i} is not defined`);let t=await pr.get(i)();Vo(i,t)}return Xt.get(i)};No("en",pt);var oe=i=>`*l10n/${i}`,Wa="en",Zt=class{_blockInstance=null;_localeName="";_callbacks=new Set;_boundBlocks=new Map;constructor(e){this._blockInstance=e;for(let[t,r]of Object.entries(pt)){let o=this._blockInstance.has(oe(t))?!this._blockInstance.$[oe(t)]:!0;this._blockInstance.add(oe(t),r,o)}setTimeout(()=>{e.subConfigValue("localeName",async t=>{if(!this._blockInstance||!t)return;this._localeName=t;let r=await Bo(t);if(t!==Wa&&this._localeName!==t)return;let o=this._blockInstance.cfg.localeDefinitionOverride?.[t];for(let[s,n]of Object.entries(r)){let a=o?.[s];this._blockInstance.add(oe(s),a??n,!0);for(let l of this._callbacks)l()}}),e.subConfigValue("localeDefinitionOverride",t=>{if(!t)return;let r=t[this._localeName];if(r)for(let[o,s]of Object.entries(r)){this._blockInstance?.add(oe(o),s,!0);for(let n of this._callbacks)n()}})})}onLocaleChange(e){let t=M(e,0);return this._callbacks.add(t),()=>{this._callbacks.delete(t)}}bindL10n(e,t,r){e.$[t]=r(),this._boundBlocks.has(e)||this._boundBlocks.set(e,new Map),this._boundBlocks.get(e)?.get(t)?.();let o=this.onLocaleChange(()=>{e.$[t]=r()});this._boundBlocks.get(e)?.set(t,o)}destroyL10nBindings(e){let t=this._boundBlocks.get(e);if(t){for(let r of t.values())r();this._boundBlocks.delete(e)}}destroy(){this._callbacks.clear()}};function zo(i,e){[...i.querySelectorAll("[l10n]")].forEach(t=>{let r=t.getAttribute("l10n");if(!r)return;let o=r.split(";");for(let s of o)s&&qa(t,s,e)})}var qa=(i,e,t)=>{let r="textContent",o=!1;if(e.includes(":")){let a=e.split(":");if(a.length!==2){console.warn(`l10n attribute value should be in format "property:key" or "key". Found: ${e}`);return}let l=a;r=l[0],e=l[1],r.startsWith("@")&&(r=r.slice(1),o=!0)}let s=e;t.has(s)&&t.sub(s,a=>{if(!a)return;t.l10nProcessorSubs.has(s)||t.l10nProcessorSubs.set(s,new Set);let l=t.l10nProcessorSubs.get(s);l?.forEach(u=>{u.remove(),l.delete(u),t.allSubs.delete(u)});let c=oe(a).replace("*","");t.nodeCtx.has(c)||t.nodeCtx.add(c,a);let d=t.nodeCtx.sub(c,()=>{i[r]=t.l10n(a)});l?.add(d),t.allSubs.add(d),i.removeAttribute("l10n")});let n=oe(e);t.has(n)||t.add(n,""),t.sub(n,()=>{o?i.setAttribute(r,t.l10n(e)):i[r]=t.l10n(e)}),i.removeAttribute("l10n")};var Xa={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function ht(i,e){e.tabIndex=0,e.focus(),i.tabIndex=-1}function hr(i){let e=i.role||i.type||i.tagName;if(!e)return null;let t=Xa[e.toLowerCase()];if(!t)return null;for(let r of t){let o=i.closest(`[role=${r}]`);if(o)return o}}function mr(i,e){return e.role==="toolbar"?Za(e):e.querySelectorAll(`[role=${i.role}]`)}function Za(i){return[...i.querySelectorAll("*")].filter(t=>t.role==="button"||t.type==="button"||t.role==="checkbox"||t.type==="checkbox")}function Ya(i){let e=i.getAttribute("aria-orientation");if(e==="vertical")return!1;if(e==="horizontal")return!0;let t=i.role;return t==="menubar"||t==="tablist"||t==="toolbar"}function Ho(i){return e=>{let t=!1,r=i?.searchDelayMs||300,o=0,s="";function n(u){let p=hr(u.target);if(!p){a();return}let m=mr(u.target,p),h=Array.from(m).indexOf(u.target),g="ArrowDown",v="ArrowUp";if(Ya(p)&&(e.document.dir==="rtl"?(g="ArrowLeft",v="ArrowRight"):(g="ArrowRight",v="ArrowLeft")),u.key===g)u.preventDefault(),ht(u.target,m[h+1]||m[0]);else if(u.key===v)u.preventDefault(),ht(u.target,m[h-1]||m[m.length-1]);else if(u.key==="Home")u.preventDefault(),ht(u.target,m[0]);else if(u.key==="End")u.preventDefault(),ht(u.target,m[m.length-1]);else if(u.key.length===1&&p.role!=="tablist"){let A=Date.now();A-o<=r?s+=u.key.toLowerCase():s=u.key.toLowerCase(),o=A;let C=Array.from(m).find(x=>x.textContent?.trim()?.toLowerCase()?.startsWith(s));C&&(u.preventDefault(),ht(u.target,C))}}function a(){t=!1,e.removeEventListener("keydown",n)}function l(u){let p=hr(u.target);if(p){t||(t=!0,e.addEventListener("keydown",n));let m=mr(u.target,p);for(let h of m)h!==u.target&&h.setAttribute("tabindex",-1)}else t&&a()}function c(u){(!u.relatedTarget||u.relatedTarget===e.document)&&a()}function d(u){let p=hr(u.target);if(p){let m=mr(u.target,p);for(let h of m)h!==u.target&&h.setAttribute("tabindex",-1);u.target.setAttribute("tabindex",0)}}return e.addEventListener("click",d),e.addEventListener("focusin",l),e.addEventListener("focusout",c),()=>{a(),e.removeEventListener("click",d),e.removeEventListener("focusin",l),e.removeEventListener("focusout",c)}}}function jo(){return i=>{let e,t;function r(s){if(s.target.getAttribute("aria-hidden")==="true"){e=s.target,e.setAttribute("aria-hidden","false"),t=e.hidden,t&&(e.hidden=!1);let n=s.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function o(s){e&&e.contains(s.target)&&(!s.relatedTarget||!e.contains(s.relatedTarget))&&(s.target.tabIndex=-1,e.setAttribute("aria-hidden","true"),t&&(e.hidden=!0),e=null)}return i.addEventListener("keyuxJump",r),i.addEventListener("focusout",o),()=>{i.removeEventListener("keyuxJump",r),i.removeEventListener("focusout",o)}}}function Ko(){return i=>{let e=[];function t(l){let c=i.document.activeElement;c&&c!==i.document.body&&e.push(new WeakRef(c)),l.focus({focusVisible:!0})}function r(){let l=e.pop();if(!l){i.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():r()}let o=0,s;function n(l){clearInterval(s);let c=l.getAttribute("aria-controls");s=setInterval(()=>{if(o++>50){clearInterval(s);return}let d=i.document.getElementById(c);if(d){let u=d.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');u&&(clearInterval(s),d.dispatchEvent(new i.CustomEvent("keyuxJump",{bubbles:!0})),t(u))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&r()}return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}}}function Go(i){let e,t=i.split(" "),r;function o(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(s(),a.target.classList.add(...t),e=a.target,r=a.target)}function s(){e&&e.classList.remove(...t),r=null}function n(a){a.clientX===0&&a.clientY===0&&r!==a.target&&(s(),a.target.classList.add(...t),e=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",o),a.addEventListener("keyup",s),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",o),a.removeEventListener("keyup",s)})}function Wo(i,e){let t=e.map(r=>r(i));return()=>{t.forEach(r=>r())}}var fr=class{_listeners=new Map;_scope=[];addEventListener(e,t){let r=o=>{let s=o.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&t(o)};this._listeners.set(t,r),window.addEventListener(e,r)}removeEventListener(e,t){let r=this._listeners.get(t);r&&window.removeEventListener(e,r),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=[];for(let e of this._listeners.values())window.removeEventListener("keydown",e),window.removeEventListener("keyup",e);this._listeners.clear()}},Yt=class{_destroyKeyUX;_scopedWindow;constructor(){this._scopedWindow=new fr,this._destroyKeyUX=Wo(this._scopedWindow,[Ho(),Go("is-pressed"),Ko(),jo()])}registerBlock(e){this._scopedWindow.registerScope(e)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var D=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Qt=class{_modals=new Map;_activeModals=new Set;_subscribers=new Map;_block;constructor(e){this._block=e}_debugPrint(...e){this._block.debugPrint("[modal-manager]",...e)}registerModal(e,t){this._modals.set(e,t),this._notify(D.ADD,{id:e,modal:t})}deleteModal(e){if(!this._modals.has(e))return!1;let t=this._modals.get(e);return this._modals.delete(e),this._activeModals.delete(e),this._notify(D.DELETE,{id:e,modal:t}),!0}open(e){if(!this._modals.has(e))return this._debugPrint(`Modal with ID "${e}" not found`),!1;let t=this._modals.get(e);return this._activeModals.add(e),this._notify(D.OPEN,{modal:t,id:e}),!0}close(e){if(!this._modals.has(e)||!this._activeModals.has(e))return this._debugPrint(`Modal with ID "${e}" not found or not active`),!1;let t=this._modals.get(e);return this._activeModals.delete(e),this._notify(D.CLOSE,{id:e,modal:t}),!0}toggle(e){return this._modals.has(e)?this._activeModals.has(e)?this.close(e):this.open(e):(this._debugPrint(`Modal with ID "${e}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let e=Array.from(this._activeModals).pop();return e?this.close(e):!1}closeAll(){let e=this._activeModals.size;return this._activeModals.clear(),this._notify(D.CLOSE_ALL,{}),e}subscribe(e,t){return this._subscribers.has(e)||this._subscribers.set(e,new Set),this._subscribers.get(e)?.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){this._subscribers.has(e)&&this._subscribers.get(e)?.delete(t)}_notify(e,t){if(this._subscribers.has(e))for(let r of this._subscribers.get(e)??new Set)try{r(t)}catch(o){this._block.telemetryManager.sendEventError(o,"modal subscriber"),this._debugPrint("Error in modal subscriber:",o)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(D.DESTROY,{})}};function Qa(i){return i.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`).replace(/__/g,"_")}function vr(i){return Array.isArray(i)?i.map(e=>typeof e=="object"&&e!==null?vr(e):e):typeof i!="object"||i===null?i:Object.fromEntries(Object.entries(i).map(([e,t])=>{let r=Qa(e);return typeof t=="object"&&t!==null?[r,vr(t)]:[r,t]}))}function Ja(i){return{ok:!0,value:i}}function gr(i){return{ok:!1,error:i}}var el="https://tlm.uploadcare.com/api/",yr=class{constructor(e=el){this.baseUrl=e}async base(e,t={}){let r=`${this.baseUrl}${e}`;try{let o=await fetch(r,t);if(!o.ok)return gr(new Error(`Got non-200 response from "${r}". Status: ${o.status.toString()}`));try{let s=await o.json();return Ja(s)}catch(s){return gr(new Error(`Error parsing JSON from "${r}". Error: ${s}`))}}catch(o){return gr(new Error(`Error fetching data from "${r}". Error: ${o}`))}}async post(e,t,r={}){return await this.base(e,{...r,method:"POST",body:JSON.stringify(vr(t)),headers:{"Content-Type":"application/json",...r.headers||{}}})}async get(e,t={}){return await this.base(e,{method:"GET",...t})}},tl=async(i,e)=>({success:!0,data:e}),Jt=class extends yr{constructor(){super()}async sendEvent(e,t){let r=await tl(void 0,e);if(!r.success)throw console.error("TelemetryAPIService: events: body is invalid",r.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",e,t)}};var qo="1.24.4";var Oe="blocks",Me=qo;var ei=class{_sessionId=crypto.randomUUID();_telemetryInstance;_block;_config=structuredClone(Y);_initialized=!1;_lastPayload=null;_queue;constructor(e){this._block=e,this._telemetryInstance=new Jt,this._queue=new Se(10);for(let t of Object.keys(this._config))this._block.subConfigValue(t,r=>{this._initialized&&this._config[t]!==r&&this.sendEvent({eventType:k.CHANGE_CONFIG}),this._setConfig(t,r)})}_init(e){e===k.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(e,t){this._config[e]!==t&&(this._config[e]=t)}_formattingPayload(e){let t=e.payload?{...e.payload}:{};t.activity&&(t.activity=void 0);let r={...e};return(e.eventType===k.INIT_SOLUTION||e.eventType===k.CHANGE_CONFIG)&&(r.config=this._config),{...r,appVersion:Me,appName:Oe,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:r.eventType??"",eventTimestamp:this._timestamp,payload:{...t}}}_excludedEvents(e){return!!(e&&[T.CHANGE,T.COMMON_UPLOAD_PROGRESS,T.FILE_ADDED,T.FILE_REMOVED,T.FILE_UPLOAD_START,T.FILE_UPLOAD_PROGRESS,T.FILE_UPLOAD_SUCCESS,T.FILE_UPLOAD_FAILED].includes(e))}sendEvent(e){let t=this._formattingPayload({eventType:e.eventType,payload:e.payload,config:e.config});this._init(e.eventType),!(this._excludedEvents(e.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,t))&&this._queue.add(async()=>{this._lastPayload=t,await this._telemetryInstance.sendEvent(t)})}sendEventError(e,t="unknown"){this.sendEvent({eventType:k.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${t}`,error:e.message}}})}sendEventCloudImageEditor(e,t,r={}){this.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{tabId:t,node:e.currentTarget?.tagName,event:e.type,...r}}})}_checkObj(e,t){if(JSON.stringify(e)===JSON.stringify(t))return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let s of r)if(!Object.hasOwn(t,s)||!this._checkObj(e[s],t[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let e=this._block.$["*solution"];return e?e.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}};var B=i=>`*cfg/${i}`;function Xo(i,e){let t=i.querySelectorAll("[data-testid]");if(t.length===0)return;let r=new WeakMap;for(let o of t){let s=o.getAttribute("data-testid");s&&r.set(o,s)}e.subConfigValue("testMode",o=>{if(!o){for(let n of t)n.removeAttribute("data-testid");return}let s=e.testId;for(let n of t){let a=r.get(n);a&&n.setAttribute("data-testid",`${s}--${a}`)}})}var rl="uc-",y=class extends Ee{__cfgProxy;l10nProcessorSubs=new Map;static StateConsumerScope=null;static styleAttrs=[];requireCtxName=!1;activityType=null;init$=cr();l10n(e,t={}){if(!e)return"";let r=this.$[oe(e)]||e,o=Co(r);for(let n of o)t[n.variable]=this.pluralize(n.pluralKey,Number(t[n.countVariable]));return dt(r,t)}pluralize(e,t){let r=this.l10n("locale-id")||"en",o=zt(r,t);return this.l10n(`${e}__${o}`)}bindL10n(e,t){this.localeManager?.bindL10n(this,e,t)}constructor(){super(),this.addTemplateProcessor(zo),this.addTemplateProcessor(Xo)}emit(e,t,r){let o=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;o&&(o.emit(e,t,r),this.telemetryManager.sendEvent({eventType:e,payload:typeof t=="function"?t():t}))}hasBlockInCtx(e){for(let t of this.blocksRegistry)if(e(t))return!0;return!1}setOrAddState(e,t){this.add$({[e]:t},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(t=>{this.setAttribute(t,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?To({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),ut.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),ut.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Dt(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new Zt(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new ei(this)),this.has("*a11y")||this.add("*a11y",new Yt),this.has("*modalManager")||this.add("*modalManager",new Qt(this)),this.sub(oe("locale-id"),t=>{let r=_o(t);this.style.direction=r==="ltr"?"":r}),this.subConfigValue("testMode",t=>{if(!t||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId)})}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this.has("*modalManager")?this.$["*modalManager"]:void 0}get telemetryManager(){return this.cfg.qualityInsights?this.has("*telemetryManager")&&this.$["*telemetryManager"]:{sendEvent:()=>{},sendEventCloudImageEditor:()=>{},sendEventError:()=>{}}}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}destroyCallback(){super.destroyCallback();let e=this.blocksRegistry;e?.delete(this),this.localeManager?.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,E.deleteCtx(this),e?.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){E.deleteCtx(this.ctxName),this.localeManager?.destroy(),this.modalManager?.destroy()}async proxyUrl(e){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(e,{uuid:Nt(e),cdnUrlModifiers:qi(e),fileName:Vt(e)})}catch(t){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",t),this.telemetryManager.sendEventError(t,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?dt(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:t=>window.encodeURIComponent(t)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(t,r,o)=>{if(typeof r!="string")return!1;let s=B(r);return this.has(s)||this.add(s,Y[r]),this.$[s]=o,!0},get:(t,r)=>{let o=B(r);return this.has(o)||this.add(o,Y[r]),this.$[B(r)]}})}return this.__cfgProxy}subConfigValue(e,t){let r=B(e);this.has(r)||this.add(r,Y[e]),this.sub(r,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof e?.[0]=="function"){let r=e[0];t=r()}console.log(`[${this.ctxName}]`,...t)}static reg(e){if(!e){super.reg();return}e.startsWith(rl)&&super.reg(e)}};var Zo="active",Ge="___ACTIVITY_IS_ACTIVE___",f=class i extends y{historyTracked=!1;[Ge];init$=dr(this);_debouncedHistoryFlush=M(this._historyFlush.bind(this),10);_deactivate(){let e=i._activityCallbacks.get(this);this[Ge]=!1,this.removeAttribute(Zo),e?.deactivateCallback?.()}_activate(){let e=i._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[Ge]=!0,this.setAttribute(Zo,""),e?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(T.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{try{this.activityType!==e&&this[Ge]?this._deactivate():this.activityType===e&&!this[Ge]&&this._activate()}catch(t){this.telemetryManager.sendEventError(t,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,t),this.$["*currentActivity"]=this.$["*history"][this.$["*history"].length-1]??null}e||(this.$["*history"]=[])}))}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e)}_isActivityRegistered(){return!!this.activityType&&i._activityCallbacks.has(this)}static _activityCallbacks=new Map;static activities;get isActivityActive(){return!!this[Ge]}get couldOpenActivity(){return!0}registerActivity(e,t={}){let{onActivate:r,onDeactivate:o}=t;i._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),i._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];!![...this.blocksRegistry].find(r=>r instanceof i&&r.activityType===e)||(this.$["*currentActivity"]=null,this.modalManager?.closeAll())}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(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let r=!!t;t&&(r=[...this.blocksRegistry].find(s=>s.activityType===t)?.couldOpenActivity??!1),t=r?t:void 0,t&&this.modalManager?.open(t),this.$["*currentActivity"]=t,this.$["*history"]=e,t||this.modalManager?.closeAll()}}};f.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"});function br(i){for(let e in i){let t=[...e].reduce((r,o)=>(o.toUpperCase()===o&&(o=`-${o.toLowerCase()}`),r+=o,r),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("uc-")||(t=`uc-${t}`),i[e].reg&&i[e].reg(t)}}var _r="UC";function ol(i,e=!1){return new Promise((t,r)=>{if(typeof document!="object"){t(null);return}if(typeof window=="object"&&window[_r]){t(window[_r]);return}let o=document.createElement("script");o.async=!0,o.src=i,o.onerror=()=>{r()},o.onload=()=>{let s=window[_r];e&&br(s),t(s)},document.head.appendChild(o)})}var Yo="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-photo-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-ngdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var _e=class extends y{static styleAttrs=["uc-wgt-common"];requireCtxName=!0;init$=Fo(this);static _template="";initCallback(){super.initCallback(),this.a11y?.registerBlock(this)}static set template(e){this._template=`${Yo+e}<slot></slot>`}static get template(){return this._template}};var mt=33.333333333333336,b=1,wr=24,Qo=6;function Le(i,e){for(let[t,r]of Object.entries(e))i.setAttributeNS(null,t,r.toString())}function K(i,e={}){let t=document.createElementNS("http://www.w3.org/2000/svg",i);return Le(t,e),t}function Jo(i,e,t){let{x:r,y:o,width:s,height:n}=i,a=e.includes("w")?0:1,l=e.includes("n")?0:1,c=a===0?-1:1,d=l===0?-1:1,u=[r+a*s+1.5*c,o+l*n+1.5*d-24*t*d],p=[r+a*s+1.5*c,o+l*n+1.5*d],m=[r+a*s-24*t*c+1.5*c,o+l*n+1.5*d],h=`M ${u[0]} ${u[1]} L ${p[0]} ${p[1]} L ${m[0]} ${m[1]}`,g=[p[0],p[1]];return{d:h,center:g}}function es(i,e,t){let{x:r,y:o,width:s,height:n}=i,a=e==="n"||e==="s",l=e==="w"||e==="e",c=a?.5:e==="w"?0:1,d=l?.5:e==="n"?0:1,u=e==="w"?-1:e==="e"?1:0,p=e==="n"?-1:e==="s"?1:0,m,h;a?(m=[r+c*s-34*t/2,o+d*n+1.5*p],h=[r+c*s+34*t/2,o+d*n+1.5*p]):(m=[r+c*s+1.5*u,o+d*n-34*t/2],h=[r+c*s+1.5*u,o+d*n+34*t/2]);let g=`M ${m[0]} ${m[1]} L ${h[0]} ${h[1]}`,v=[(m[0]+h[0])/2,(m[1]+h[1])/2];return{d:g,center:v}}function ts(i){return i===""?"move":["e","w"].includes(i)?"ew-resize":["n","s"].includes(i)?"ns-resize":["nw","se"].includes(i)?"nwse-resize":"nesw-resize"}function is({rect:i,delta:[e,t],imageBox:r}){return qe({...i,x:i.x+e,y:i.y+t},r)}function qe(i,e){let{x:t}=i,{y:r}=i;return i.x<e.x?t=e.x:i.x+i.width>e.x+e.width&&(t=e.x+e.width-i.width),i.y<e.y?r=e.y:i.y+i.height>e.y+e.height&&(r=e.y+e.height-i.height),{...i,x:t,y:r}}function sl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[,o]=e,{y:s,width:n,height:a}=i;s+=o,a-=o,t&&(n=a*t);let l=i.x+i.width/2-n/2;return s<=r.y&&(s=r.y,a=i.y+i.height-s,t&&(n=a*t,l=i.x+i.width/2-n/2)),l<=r.x&&(l=r.x,s=i.y+i.height-a),l+n>=r.x+r.width&&(l=Math.max(r.x,r.x+r.width-n),n=r.x+r.width-l,t&&(a=n/t),s=i.y+i.height-a),a<b&&(a=b,t&&(n=a*t,l=i.x+i.width/2-n/2),s=i.y+i.height-a),n<b&&(n=b,t&&(a=n/t,l=i.x+i.width/2-n/2),s=i.y+i.height-a),{x:l,y:s,width:n,height:a}}function nl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o]=e,{x:s,width:n,height:a}=i;s+=o,n-=o,t&&(a=n/t);let l=i.y+i.height/2-a/2;return s<=r.x&&(s=r.x,n=i.x+i.width-s,t&&(a=n/t,l=i.y+i.height/2-a/2)),l<=r.y&&(l=r.y,s=i.x+i.width-n),l+a>=r.y+r.height&&(l=Math.max(r.y,r.y+r.height-a),a=r.y+r.height-l,t&&(n=a*t),s=i.x+i.width-n),a<b&&(a=b,t&&(n=a*t),l=i.y+i.height/2-a/2,s=i.x+i.width-n),n<b&&(n=b,t&&(a=n/t),l=i.y+i.height/2-a/2,s=i.x+i.width-n),{x:s,y:l,width:n,height:a}}function al({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[,o]=e,{y:s,width:n,height:a}=i;a+=o,t&&(n=a*t);let l=i.x+i.width/2-n/2;return s+a>=r.y+r.height&&(a=r.y+r.height-s,t&&(n=a*t),l=i.x+i.width/2-n/2),l<=r.x&&(l=r.x,s=i.y),l+n>=r.x+r.width&&(l=Math.max(r.x,r.x+r.width-n),n=r.x+r.width-l,t&&(a=n/t),s=i.y),a<b&&(a=b,t&&(n=a*t),l=i.x+i.width/2-n/2),n<b&&(n=b,t&&(a=n/t),l=i.x+i.width/2-n/2),{x:l,y:s,width:n,height:a}}function ll({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o]=e,{x:s,width:n,height:a}=i;n+=o,t&&(a=n/t);let l=i.y+i.height/2-a/2;return s+n>=r.x+r.width&&(n=r.x+r.width-s,t&&(a=n/t),l=i.y+i.height/2-a/2),l<=r.y&&(l=r.y,s=i.x),l+a>=r.y+r.height&&(l=Math.max(r.y,r.y+r.height-a),a=r.y+r.height-l,t&&(n=a*t),s=i.x),a<b&&(a=b,t&&(n=a*t),l=i.y+i.height/2-a/2),n<b&&(n=b,t&&(a=n/t),l=i.y+i.height/2-a/2),{x:s,y:l,width:n,height:a}}function cl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+o<r.x&&(o=r.x-n),a+s<r.y&&(s=r.y-a),n+=o,l-=o,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=r.y&&(c=c-(r.y-a),l=c*t,n=i.x+i.width-l,a=r.y)):t&&(o=c*t-l,l=l+o,n-=o,n<=r.x&&(l=l-(r.x-n),c=l/t,n=r.x,a=i.y+i.height-c)),c<b&&(c=b,t&&(l=c*t),n=i.x+i.width-l,a=i.y+i.height-c),l<b&&(l=b,t&&(c=l/t),n=i.x+i.width-l,a=i.y+i.height-c),{x:n,y:a,width:l,height:c}}function dl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+l+o>r.x+r.width&&(o=r.x+r.width-n-l),a+s<r.y&&(s=r.y-a),l+=o,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=r.y&&(c=c-(r.y-a),l=c*t,n=i.x,a=r.y)):t&&(o=c*t-l,l+=o,n+l>=r.x+r.width&&(l=r.x+r.width-n,c=l/t,n=r.x+r.width-l,a=i.y+i.height-c)),c<b&&(c=b,t&&(l=c*t),a=i.y+i.height-c),l<b&&(l=b,t&&(c=l/t),a=i.y+i.height-c),{x:n,y:a,width:l,height:c}}function ul({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+o<r.x&&(o=r.x-n),a+c+s>r.y+r.height&&(s=r.y+r.height-a-c),n+=o,l-=o,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=r.y+r.height&&(c=r.y+r.height-a,l=c*t,n=i.x+i.width-l,a=r.y+r.height-c)):t&&(o=c*t-l,l+=o,n-=o,n<=r.x&&(l=l-(r.x-n),c=l/t,n=r.x,a=i.y)),c<b&&(c=b,t&&(l=c*t),n=i.x+i.width-l),l<b&&(l=b,t&&(c=l/t),n=i.x+i.width-l),{x:n,y:a,width:l,height:c}}function pl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+l+o>r.x+r.width&&(o=r.x+r.width-n-l),a+c+s>r.y+r.height&&(s=r.y+r.height-a-c),l+=o,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=r.y+r.height&&(c=r.y+r.height-a,l=c*t,n=i.x,a=r.y+r.height-c)):t&&(o=c*t-l,l+=o,n+l>=r.x+r.width&&(l=r.x+r.width-n,c=l/t,n=r.x+r.width-l,a=i.y)),c<b&&(c=b,t&&(l=c*t)),l<b&&(l=b,t&&(c=l/t)),{x:n,y:a,width:l,height:c}}function rs({direction:i,...e}){switch(i){case"n":return sl(e);case"w":return nl(e);case"s":return al(e);case"e":return ll(e);case"nw":return cl(e);case"ne":return dl(e);case"sw":return ul(e);case"se":return pl(e);default:return e.rect}}function os(i,[e,t]){return i.x<=e&&e<=i.x+i.width&&i.y<=t&&t<=i.y+i.height}function ss(i,e){return i.x>=e.x&&i.y>=e.y&&i.x+i.width<=e.x+e.width&&i.y+i.height<=e.y+e.height}function ns(i,e){return Math.abs(i.width/i.height-e)<.1}function Xe({width:i,height:e},t){let r=t/90%2!==0;return{width:r?e:i,height:r?i:e}}function as(i,e,t){let r=i/e,o,s;r>t?(o=Math.round(e*t),s=e):(o=i,s=Math.round(i/t));let n=Math.round((i-o)/2),a=Math.round((e-s)/2);return n+o>i&&(o=i-n),a+s>e&&(s=e-a),{x:n,y:a,width:o,height:s}}function Ze(i){return{x:Math.round(i.x),y:Math.round(i.y),width:Math.round(i.width),height:Math.round(i.height)}}function Re(i,e,t){return Math.min(Math.max(i,e),t)}var ft=["free"],ii=i=>{let e=$(i);if(!e||e.length===0)return[];let t=[];for(let r of e){let o=r.trim();if(!o)continue;let s=o.indexOf(":");if(s===-1&&!ft.includes(o)){console.warn(`Invalid crop preset: ${o}`);continue}let n=Number(o.slice(0,s)),a=Number(o.slice(s+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!ft.includes(o)){console.warn(`Invalid crop preset: ${o}`);continue}t.push({id:ne.generate(),type:"aspect-ratio",width:ft.includes(o)?0:n,height:ft.includes(o)?0:a,hasFreeform:ft.includes(o)})}return t},ls=(i,e,t,r=.1)=>{let o=i/e,s=null,n=1/0;for(let a of t){let[l,c]=[a.width,a.height],d=l/c,u=Math.abs(o-d);u<n&&(n=u,s=a)}if(s){let[a,l]=[s.width,s.height],c=a/l;if(Math.abs(o-c)/c>r)return null}return s};var le=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Cr=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),P=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Cr,...le});function cs(i){return rr({...i,libraryName:Oe,libraryVersion:Me})}var ds=i=>typeof i!="number"?0:Math.floor(i/1e3),us=(i,{threshold:e})=>{let{secureExpire:t}=i,r=ds(Date.now()),o=Number(t),s=ds(e);return r+s>=o};var ri=class{_block;_secureToken=null;constructor(e){this._block=e}_debugPrint(...e){this._block.debugPrint("[secure-uploads]",...e)}async getSecureToken(){let{secureSignature:e,secureExpire:t,secureUploadsSignatureResolver:r}=this._block.cfg;if((e||t)&&r&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),r){if(!this._secureToken||us(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 o=await r();o?!o.secureSignature||!o.secureExpire?console.error("Secure signature resolver returned an invalid result:",o):(this._debugPrint("Secure signature resolved:",o),this._debugPrint("Secure signature will expire in",new Date(Number(o.secureExpire)*1e3).toISOString()),this._secureToken=o):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(o){console.error("Secure signature resolving failed. Falling back to the previous one.",o),this._block.telemetryManager.sendEventError(o,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.")}}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 Er=(i,e)=>{if(i.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:e.l10n("some-files-were-not-uploaded")}};var Tr=(i,e)=>{let t=i.totalCount,r=e.cfg.multiple?e.cfg.multipleMin:0,o=e.cfg.multiple?e.cfg.multipleMax:1;if(r&&t<r)return{type:"TOO_FEW_FILES",message:e.l10n("files-count-limit-error-too-few",{min:r,max:o,total:t}),payload:{total:t,min:r,max:o}};if(o&&t>o)return{type:"TOO_MANY_FILES",message:e.l10n("files-count-limit-error-too-many",{min:r,max:o,total:t}),payload:{total:t,min:r,max:o}}};var hl=()=>{let i=navigator.userAgent;return/Macintosh|Windows/.test(i)&&/Version\/[\d.]+.*Safari/.test(i)&&!/Chrome|Chromium|Edg|OPR/.test(i)},ml=()=>"capture"in document.createElement("input"),fl=()=>({safariDesktop:hl()}),gl=()=>({htmlMediaCapture:ml()}),ps=fl(),Fe=gl();var gt="image/*",xr="video/*",vl=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],yl=()=>ps.safariDesktop?[gt]:[gt,...vl],vt=yl(),oi=i=>i?i.filter(e=>typeof e=="string").flatMap(e=>$(e)):[],Ar=(i,e)=>e.some(t=>{if(t.endsWith("*")){let r=t.replace("*","");return i.startsWith(r)}return i===t}),hs=(i,e)=>e.some(t=>t.startsWith(".")?i.toLowerCase().endsWith(t.toLowerCase()):!1),ms=i=>{let e=i?.type;return e?Ar(e,vt):!1};var Sr=(i,e)=>{let t=e.cfg.imgOnly,r=e.cfg.accept,o=oi([...t?vt:[],r]);if(!o.length)return;let s=i.mimeType,n=i.name;if(!s||!n)return;let a=Ar(s,o),l=hs(n,o);if(!a&&!l)return{type:"FORBIDDEN_FILE_TYPE",message:e.l10n("file-type-not-allowed"),payload:{entry:i}}};var Ir=(i,e)=>{let t=e.cfg.imgOnly,r=i.isImage;if(!(!t||r)&&!(!i.fileInfo&&i.externalUrl)&&!(!i.fileInfo&&!i.mimeType))return{type:"NOT_AN_IMAGE",message:e.l10n("images-only-accepted"),payload:{entry:i}}};var ce=1e3,Ve=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),yt=i=>Math.ceil(i*100)/100,fs=(i,e=Ve.AUTO)=>{let t=e===Ve.AUTO;if(e===Ve.BYTE||t&&i<ce**1){let o=zt("en-US",i)==="one"?"byte":"bytes";return`${i} ${o}`}return e===Ve.KB||t&&i<ce**2?`${yt(i/ce**1)} KB`:e===Ve.MB||t&&i<ce**3?`${yt(i/ce**2)} MB`:e===Ve.GB||t&&i<ce**4?`${yt(i/ce**3)} GB`:e===Ve.TB||t&&i<ce**5?`${yt(i/ce**4)} TB`:`${yt(i/ce**5)} PB`};var kr=(i,e)=>{let t=e.cfg.maxLocalFileSizeBytes,r=i.size;if(t&&r&&r>t)return{type:"FILE_SIZE_EXCEEDED",message:e.l10n("files-max-size-limit-error",{maxFileSize:fs(t)}),payload:{entry:i}}};var Or=(i,e)=>{let{internalId:t}=i,o=e._uploadCollection.read(t)?.getValue("uploadError");if(!o)return;if(o instanceof j)return{type:"UPLOAD_ERROR",message:o.message,payload:{entry:i,error:o}};if(o instanceof je)return{type:"NETWORK_ERROR",message:o.message,payload:{entry:i,error:o}};let s=o instanceof Error?o:new Error("Unknown error",{cause:o});return{type:"UNKNOWN_ERROR",message:s.message,payload:{entry:i,error:s}}};var gs=()=>{let i=()=>{},e=()=>{};return{promise:new Promise((r,o)=>{i=r,e=o}),resolve:i,reject:e}};var Ye={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},bl=i=>typeof i=="function"?{runOn:"change",validator:i}:i,si=class{_blockInstance;_uploadCollection;_commonFileValidators=[Ir,Sr,kr,Or];_commonCollectionValidators=[Tr,Er];_queue=new Se(20);_runQueueDebounced=M(()=>{this._queue.run()},500);_entryValidationState=new Map;constructor(e){this._blockInstance=e,this._uploadCollection=this._blockInstance.uploadCollection;let t=()=>{this.runFileValidators("change"),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),this._blockInstance.subConfigValue("validationConcurrency",r=>{this._queue.concurrency=r})}runFileValidators(e,t){let r=t??this._uploadCollection.items();for(let o of r){let s=this._uploadCollection.read(o);s&&this._runFileValidatorsForEntry(s,e)}}runCollectionValidators(){let e=this._blockInstance.api.getOutputCollectionState(),t=[];for(let r of[...this._commonCollectionValidators,...this._blockInstance.cfg.collectionValidators])try{let o=r(e,this._blockInstance.api);if(!o)continue;o&&(t.push(this._addCustomTypeToValidationError(o)),o.message||console.warn(Ye.MISSING_ERROR_MESSAGE))}catch(o){console.warn(Ye.COLLECTION_VALIDATION_FAILED,o)}this._blockInstance.$["*collectionErrors"]=t,t.length>0&&this._blockInstance.emit(T.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}cleanupValidationForEntry(e){let t=this._entryValidationState.get(e.uid);t&&(t.abortController?.abort(),this._entryValidationState.delete(e.uid))}async _runFileValidatorsForEntry(e,t){let r=this._getValidatorDescriptorsForEntry(e,t);if(r.length===0)return;e.setMultipleValues({isQueuedForValidation:!0,isValidationPending:!0});let o=this._blockInstance.api.getOutputItem(e.uid),s=this._getEntryValidationState(e);s.promise&&await s.promise;let{promise:n,resolve:a}=gs();s.promise=n;let l=new AbortController;s.abortController=l;let c=this._blockInstance.cfg.validationTimeout,d=this._getValidatorDescriptors(),u=new Set(r.map(h=>h.validator)),p=[];for(let h of d)if(!u.has(h.validator)){let g=s.lastErrorThrownByValidator.get(h.validator);g&&p.push(g)}let m=r.map(h=>async()=>{if(!this._blockInstance.isConnected)return;let g=setTimeout(()=>{s.skippedValidators.add(h.validator),l.abort(),console.warn(Ye.FILE_VALIDATION_TIMEOUT)},c);try{let v=await h.validator(o,this._blockInstance.api,{signal:l.signal});if(!v||l.signal.aborted){s.lastErrorThrownByValidator.set(h.validator,void 0);return}let A=this._addCustomTypeToValidationError(v);s.lastErrorThrownByValidator.set(h.validator,A),p.push(A),v.message||console.warn(Ye.MISSING_ERROR_MESSAGE)}catch(v){l.signal.aborted||(s.skippedValidators.add(h.validator),console.warn(Ye.FILE_VALIDATION_FAILED,v),this._blockInstance.telemetryManager.sendEventError(v,`file validator. ${Ye.FILE_VALIDATION_FAILED}`))}finally{clearTimeout(g),h.runOn!=="change"&&s.skippedValidators.add(h.validator)}});if(this._runQueueDebounced(),await this._queue.add(async()=>{e.setValue("isQueuedForValidation",!1),await Promise.all(m.map(h=>h())).catch(()=>{})},{autoRun:!1}),l.signal.aborted){e.setMultipleValues({isQueuedForValidation:!1,isValidationPending:!1}),a();return}e.setMultipleValues({isValidationPending:!1,isQueuedForValidation:!1,errors:p}),a()}_addCustomTypeToValidationError(e){return{...e,type:e.type??"CUSTOM_ERROR"}}_getEntryValidationState(e){let t=this._entryValidationState.get(e.uid);if(t)return t;let r={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(e.uid,r),r}_getValidatorDescriptors(){return[...this._commonFileValidators,...this._blockInstance.cfg.fileValidators].map(bl)}_getValidatorDescriptorsForEntry(e,t){let r=this._getEntryValidationState(e);return this._getValidatorDescriptors().filter(o=>!r.skippedValidators.has(o.validator)).filter(o=>o.runOn===t)}};var vs="[Typed State] Wrong property name: ",_l="[Typed State] Wrong property type: ",ni=class{__typedSchema;__ctxId;__schema;__data;constructor(e,t){this.__typedSchema=e,this.__ctxId=t||ne.generate(),this.__schema=Object.keys(e).reduce((r,o)=>(e[o]&&(r[o]=e[o].value),r),{}),this.__data=E.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(e,t){if(!Object.hasOwn(this.__typedSchema,e)||!this.__typedSchema[e]){console.warn(vs+e);return}let r=this.__typedSchema[e],o=t?.constructor===r.type,s=t instanceof r.type,n=r.nullable&&t===null;if(o||s||n){this.__data.pub(e,t);return}console.warn(_l+e)}setMultipleValues(e){for(let[t,r]of Object.entries(e))this.setValue(t,r)}getValue(e){return Object.hasOwn(this.__typedSchema,e)||console.warn(vs+e),this.__data.read(e)}subscribe(e,t){return this.__data.sub(e,t)}remove(){E.deleteCtx(this.__ctxId)}};var ai=class{__typedSchema;__ctxId;__data;__watchList;__subsMap=Object.create(null);__propertyObservers=new Set;__collectionObservers=new Set;__items=new Set;__removed=new Set;__added=new Set;__observeTimeout;__notifyTimeout;__notifyObservers;constructor(e){this.__typedSchema=e.typedSchema,this.__ctxId=e.ctxName||ne.generate(),this.__data=E.registerCtx({},this.__ctxId),this.__watchList=e.watchList||[];let t=Object.create(null);this.__notifyObservers=(r,o)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),t[r]||(t[r]=new Set),t[r].add(o),this.__observeTimeout=window.setTimeout(()=>{Object.keys(t).length!==0&&(this.__propertyObservers.forEach(s=>{s({...t})}),t=Object.create(null))})},e.handler&&this.observeCollection(e.handler)}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 r of this.__collectionObservers)r?.([...this.__items],e,t)})}observeCollection(e){return this.__collectionObservers.add(e),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(e)}}unobserveCollection(e){this.__collectionObservers.delete(e)}add(e){let t=new ni(this.__typedSchema);for(let[r,o]of Object.entries(e))o!==void 0&&t.setValue(r,o);return this.__items.add(t.uid),this.notify(),this.__data.add(t.uid,t),this.__added.add(t),this.__watchList.forEach(r=>{this.__subsMap[t.uid]||(this.__subsMap[t.uid]=[]),this.__subsMap[t.uid]?.push(t.subscribe(r,()=>{this.__notifyObservers(r,t.uid)}))}),t.uid}read(e){return this.__data.read(e)}readProp(e,t){let r=this.read(e);return r?r.getValue(t):(console.warn(`Item with id ${e} not found`),null)}publishProp(e,t,r){let o=this.read(e);if(!o){console.warn(`Item with id ${e} not found`);return}o.setValue(t,r)}remove(e){let t=this.read(e);t&&this.__removed.add(t),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){this.__propertyObservers.delete(e)}findItems(e){let t=[];return this.__items.forEach(r=>{let o=this.read(r);o&&e(o)&&t.push(r)}),t}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){E.deleteCtx(this.__ctxId),this.__propertyObservers=new Set,this.__collectionObservers=new Set;for(let e in this.__subsMap)this.__subsMap[e]?.forEach(t=>{t.remove()}),delete this.__subsMap[e]}};var _=Object.freeze({PHOTO:"photo",VIDEO:"video"}),ee=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Mr=i=>({isVideoRecordingEnabled:q(i.cameraModes).includes(_.VIDEO),isPhotoEnabled:q(i.cameraModes).includes(_.PHOTO)});var wl=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,Cl=new RegExp(`^/?(${wl.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),ys=({url:i,cdnBase:e})=>{let t=new URL(e),r=new URL(ct),o=new URL(i);if(t.host!==o.host&&r.host!==o.host)return null;let s=Cl.exec(o.pathname);if(!s)return null;let[,n,a,l]=s;return n?{uuid:n,cdnUrlModifiers:a||"",filename:l||null}:null};function bs(i){let e=new Map;return(...r)=>{let o=JSON.stringify(r);if(e.has(o))return e.get(o);let s=i(...r);return e.set(o,s),s}}var _s=new Set;function li(i){_s.has(i)||(_s.add(i),console.warn(i))}function El(i){let e=!1;return setTimeout(()=>{e=!0},0),r=>((...o)=>(e&&li(i),r(...o)))}function ws(i){let e={},t={progress:()=>i.$["*commonProgress"],errors:()=>i.$["*collectionErrors"],group:()=>i.$["*groupInfo"],totalCount:()=>i.uploadCollection.size,failedCount:()=>e.failedEntries.length,successCount:()=>e.successEntries.length,uploadingCount:()=>e.uploadingEntries.length,status:()=>e.isFailed?"failed":e.isUploading?"uploading":e.isSuccess?"success":"idle",isSuccess:()=>e.allEntries.length>0&&e.errors.length===0&&e.successEntries.length===e.allEntries.length,isUploading:()=>e.allEntries.some(o=>o.status==="uploading"),isFailed:()=>e.errors.length>0||e.failedEntries.length>0,allEntries:()=>i.getOutputData(),successEntries:()=>e.allEntries.filter(o=>o.status==="success"),failedEntries:()=>e.allEntries.filter(o=>o.status==="failed"),uploadingEntries:()=>e.allEntries.filter(o=>o.status==="uploading"),idleEntries:()=>e.allEntries.filter(o=>o.status==="idle")},r=El("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[o,s]of Object.entries(t)){let n=o,l=bs(r(s));Object.defineProperty(e,n,{get:l,enumerable:!0})}return e}var ci=class{_ctx;constructor(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)}addFileFromUrl=(e,{silent:t,fileName:r,source:o}={})=>{let s=this._uploadCollection.add({externalUrl:e,fileName:r??null,silent:t??!1,source:o??P.API});return this.getOutputItem(s)};addFileFromUuid=(e,{silent:t,fileName:r,source:o}={})=>{let s=this._uploadCollection.add({uuid:e,fileName:r??null,silent:t??!1,source:o??P.API});return this.getOutputItem(s)};addFileFromCdnUrl=(e,{silent:t,fileName:r,source:o}={})=>{let s=ys({url:e,cdnBase:this.cfg.cdnCname});if(!s)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:s.uuid,cdnUrl:e,cdnUrlModifiers:s.cdnUrlModifiers,fileName:r??s.filename??null,silent:t??!1,source:o??P.API});return this.getOutputItem(n)};addFileFromObject=(e,{silent:t,fileName:r,source:o,fullPath:s}={})=>{let n=this._uploadCollection.add({file:e,isImage:ms(e),mimeType:e.type,fileName:r??e.name,fileSize:e.size,silent:t??!1,source:o??P.API,fullPath:s??null});return this.getOutputItem(n)};removeFileByInternalId=e=>{if(!this._uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this._uploadCollection.remove(e)};removeAllFiles(){this._uploadCollection.clearAll()}uploadAll=()=>{let e=this._uploadCollection.items().filter(t=>{let r=this._uploadCollection.read(t);return r?!r.getValue("isRemoved")&&!r.getValue("isUploading")&&!r.getValue("fileInfo")&&r.getValue("errors").length===0&&!r.getValue("isValidationPending")&&!r.getValue("isQueuedForValidation"):!1});e.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(e),this._ctx.emit(T.COMMON_UPLOAD_START,this.getOutputCollectionState()))};openSystemDialog=(e={})=>{let t=me(oi([this.cfg.accept??"",...this.cfg.imgOnly?vt:[]])),r="uploadcare-file-input",o=document.createElement("input");if(o.setAttribute(r,""),at(o,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),o.type="file",o.multiple=this.cfg.multiple,e.captureCamera){o.capture=this.cfg.cameraCapture;let{isPhotoEnabled:s,isVideoRecordingEnabled:n}=Mr(this.cfg);e.modeCamera===_.PHOTO&&s?o.accept=gt:e.modeCamera===_.VIDEO&&n?o.accept=xr:o.accept=[gt,n&&xr].filter(Boolean).join(",")}else o.accept=t;o.addEventListener("change",()=>{o.files&&([...o.files].forEach(s=>{this.addFileFromObject(s,{source:e.captureCamera?P.CAMERA:P.LOCAL})}),this._ctx.modalManager?.open(f.activities.UPLOAD_LIST),this._ctx.$["*currentActivity"]=f.activities.UPLOAD_LIST,o.remove())},{once:!0}),document.querySelectorAll(`[${r}]`).forEach(s=>{s.remove()}),document.body.appendChild(o),o.dispatchEvent(new MouseEvent("click"))};getOutputItem(e){let t=E.getCtx(e).store,r=t.fileInfo,o=t.isRemoved?"removed":t.errors.length>0?"failed":t.fileInfo?"success":t.isUploading?"uploading":"idle";return{uuid:r?.uuid??t.uuid??null,internalId:e,name:r?.originalFilename??t.fileName,size:r?.size??t.fileSize,isImage:r?.isImage??t.isImage,mimeType:r?.mimeType??t.mimeType,file:t.file,externalUrl:t.externalUrl,cdnUrlModifiers:t.cdnUrlModifiers,cdnUrl:t.cdnUrl??r?.cdnUrl??null,fullPath:t.fullPath,uploadProgress:t.uploadProgress,fileInfo:r??null,metadata:t.metadata??r?.metadata??null,isSuccess:o==="success",isUploading:o==="uploading",isFailed:o==="failed",isRemoved:o==="removed",isValidationPending:t.isValidationPending,errors:t.errors,status:o,source:t?.source}}getOutputCollectionState(){return ws(this._ctx)}initFlow=(e=!1)=>{if(this._uploadCollection.size>0&&!e)this._ctx.modalManager?.open(f.activities.UPLOAD_LIST),this._ctx.set$({"*currentActivity":f.activities.UPLOAD_LIST});else if(this._sourceList?.length===1){let t=this._sourceList[0];if(t==="local"){this._ctx.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.openSystemDialog();return}if(t==="camera"&&Fe.htmlMediaCapture){let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=Mr(this.cfg);if(n&&a){this._ctx.set$({"*currentActivity":f.activities.START_FROM});return}else if(n||a){this.openSystemDialog({captureCamera:!0,modeCamera:n?_.PHOTO:_.VIDEO});return}else this.openSystemDialog({captureCamera:!0,modeCamera:_.PHOTO})}let r=this._ctx.$["*blocksRegistry"],o=n=>"type"in n&&n.type===t;[...r].find(o)?.activate(),this._ctx.$["*currentActivity"]&&this._ctx.modalManager?.open(this._ctx.$["*currentActivity"])}else this._ctx.modalManager?.open(f.activities.START_FROM),this._ctx.set$({"*currentActivity":f.activities.START_FROM})};doneFlow=()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.modalManager?.closeAll()};setCurrentActivity=(e,...t)=>{if(this._ctx.hasBlockInCtx(r=>r.activityType===e)){this._ctx.set$({"*currentActivityParams":t??{},"*currentActivity":e});return}console.warn(`Activity type "${e}" not found in the context`)};getCurrentActivity=()=>this._ctx.$["*currentActivity"];setModalState=e=>{if(e&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}e?this._ctx.modalManager?.open(this._ctx.$["*currentActivity"]):(this._ctx.modalManager?.close(this._ctx.$["*currentActivity"]),this._ctx.$["*currentActivity"]=null)};get _sourceList(){let e=[];return this.cfg.sourceList&&(e=$(this.cfg.sourceList)),e}};var Cs=Object.freeze({file:Object.freeze({type:File,value:null,nullable:!0}),externalUrl:Object.freeze({type:String,value:null,nullable:!0}),fileName:Object.freeze({type:String,value:null,nullable:!0}),fileSize:Object.freeze({type:Number,value:null,nullable:!0}),lastModified:Object.freeze({type:Number,value:Date.now()}),uploadProgress:Object.freeze({type:Number,value:0}),uuid:Object.freeze({type:String,value:null,nullable:!0}),isImage:Object.freeze({type:Boolean,value:!1}),mimeType:Object.freeze({type:String,value:null,nullable:!0}),ctxName:Object.freeze({type:String,value:null,nullable:!0}),cdnUrl:Object.freeze({type:String,value:null,nullable:!0}),cdnUrlModifiers:Object.freeze({type:String,value:null,nullable:!0}),fileInfo:Object.freeze({type:ye,value:null,nullable:!0}),isUploading:Object.freeze({type:Boolean,value:!1}),abortController:Object.freeze({type:AbortController,value:null,nullable:!0}),thumbUrl:Object.freeze({type:String,value:null,nullable:!0}),silent:Object.freeze({type:Boolean,value:!1}),source:Object.freeze({type:String,value:null,nullable:!0}),fullPath:Object.freeze({type:String,value:null,nullable:!0}),metadata:Object.freeze({type:Object,value:null,nullable:!0}),errors:Object.freeze({type:Array,value:[]}),uploadError:Object.freeze({type:Error,value:null,nullable:!0}),isRemoved:Object.freeze({type:Boolean,value:!1}),isQueuedForUploading:Object.freeze({type:Boolean,value:!1}),isValidationPending:Object.freeze({type:Boolean,value:!1}),isQueuedForValidation:Object.freeze({type:Boolean,value:!1})});var O=class i extends f{static extSrcList;static sourceTypes;couldBeCtxOwner=!1;isCtxOwner=!1;_unobserveCollection;_unobserveCollectionProperties;init$=ur(this);get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof i?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new ai({typedSchema:Cs,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new ci(this)),this.has("*validationManager")||this.add("*validationManager",new si(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(){this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}disconnectedCallback(){super.disconnectedCallback(),this.isCtxOwner&&this._unobserveUploadCollection()}connectedCallback(){super.connectedCallback(),this.isCtxOwner&&this._observeUploadCollection()}destroyCallback(){super.destroyCallback(),this._flushOutputItems.cancel()}_initCtxOwner(){this.isCtxOwner=!0,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new ri(this))}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate)}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0}async _createGroup(e){let t=await this.getUploadClientOptions(),r=e.allEntries.map(a=>a.uuid+(a.cdnUrlModifiers?`/${a.cdnUrlModifiers}`:"")),o=new AbortController,s=await Do(r,{...t,signal:o.signal});if(this.$["*collectionState"]!==e){o.abort();return}this.$["*groupInfo"]=s;let n=this.api.getOutputCollectionState();this.emit(T.GROUP_CREATED,n),this.emit(T.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=n}_flushOutputItems=M(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(T.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300);_handleCollectionUpdate=(e,t,r)=>{(t.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...t].map(o=>o.uid));for(let o of t)o.getValue("silent")||this.emit(T.FILE_ADDED,this.api.getOutputItem(o.uid));this.validationManager.runCollectionValidators();for(let o of r){this.$["*uploadTrigger"].delete(o.uid),this.validationManager.cleanupValidationForEntry(o),o.getValue("abortController")?.abort(),o.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0});let s=o?.getValue("thumbUrl");s&&URL.revokeObjectURL(s),this.emit(T.FILE_REMOVED,this.api.getOutputItem(o.uid))}this.$["*uploadList"]=e.map(o=>({uid:o})),this._flushCommonUploadProgress(),this._flushOutputItems()};_handleCollectionPropertiesUpdate=e=>{this._flushOutputItems();let t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([o])=>["uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(o)).flatMap(([,o])=>[...o]))];if(r.length>0&&setTimeout(()=>{let o=r.filter(s=>e.fileInfo?.has(s)&&!!E.getCtx(s).store.fileInfo);o.length>0&&this.validationManager.runFileValidators("upload",o),this.validationManager.runFileValidators("change",r)}),e.uploadProgress){for(let o of e.uploadProgress){let{isUploading:s,silent:n}=E.getCtx(o).store;s&&!n&&this.emit(T.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(e.isUploading)for(let o of e.isUploading){let{isUploading:s,silent:n}=E.getCtx(o).store;s&&!n&&this.emit(T.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(e.fileInfo){for(let o of e.fileInfo){let{fileInfo:s,silent:n}=E.getCtx(o).store;s&&!n&&this.emit(T.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this.openCloudImageEditor()}if(e.errors){this.validationManager.runCollectionValidators();for(let n of e.errors){let{errors:a}=E.getCtx(n).store;a.length>0&&(this.emit(T.FILE_UPLOAD_FAILED,this.api.getOutputItem(n)),this.emit(T.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=t.findItems(n=>!!n.getValue("fileInfo")),s=t.findItems(n=>n.getValue("errors").length>0);t.size>0&&s.length===0&&t.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(T.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}e.cdnUrl&&([...e.cdnUrl].filter(s=>!!this.uploadCollection.read(s)?.getValue("cdnUrl")).forEach(s=>{this.emit(T.FILE_URL_CHANGED,this.api.getOutputItem(s))}),this.$["*groupInfo"]=null)};_flushCommonUploadProgress=()=>{let e=0,r=[...this.$["*uploadTrigger"]].filter(s=>!!this.uploadCollection.read(s));r.forEach(s=>{let n=this.uploadCollection.readProp(s,"uploadProgress");typeof n=="number"&&(e+=n)});let o=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(T.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))};openCloudImageEditor(){let[e]=this.uploadCollection.findItems(t=>!!t.getValue("fileInfo")&&t.getValue("isImage")).map(t=>this.uploadCollection.read(t));e&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(t=>t.activityType===f.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:e.uid},this.$["*currentActivity"]=f.activities.CLOUD_IMG_EDIT,this.modalManager?.open(f.activities.CLOUD_IMG_EDIT))}setInitialCrop(){let e=ii(this.cfg.cropPreset);if(e){let[t]=e,r=this.uploadCollection.findItems(o=>!!o.getValue("fileInfo")&&o.getValue("isImage")&&!o.getValue("cdnUrlModifiers")?.includes("/crop/")).map(o=>this.uploadCollection.read(o)).filter(Boolean);for(let o of r){let s=o.getValue("fileInfo");if(!s||!s.imageInfo){console.warn("Failed to get image info for entry",o.uid);continue}let{width:n,height:a}=s.imageInfo,l=typeof t?.width=="number"&&typeof t?.height=="number"&&t.width>0&&t.height>0?t.width/t.height:1,c=as(n,a,l),d=H(`crop/${c.width}x${c.height}/${c.x},${c.y}`,"preview"),u=o.getValue("cdnUrl");if(!u){console.warn("Failed to get cdnUrl for entry",o.uid);continue}o.setMultipleValues({cdnUrlModifiers:d,cdnUrl:U(u,d)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(p=>p.activityType===f.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=f.activities.CLOUD_IMG_EDIT,this.modalManager?.open(f.activities.CLOUD_IMG_EDIT))}}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let r=this.api.getOutputItem(e);return await t(r)}return t}async getUploadClientOptions(){let t=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:cs,integration:this.cfg.userAgentIntegration,secureSignature:t?.secureSignature,secureExpire:t?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,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(r=>this.api.getOutputItem(r))}};O.extSrcList=Object.freeze({...le});O.sourceTypes=Object.freeze({...P});var Lr=class extends f{};var Es=()=>typeof navigator.permissions<"u";var Tl={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},Ts=["camera","microphone"];function di(i){let e=Math.floor(i/60).toString().padStart(2,"0"),t=Math.floor(i%60).toString().padStart(2,"0");return`${e}:${t}`}var xs="image/jpeg",As="video/webm",ui=class extends O{couldBeCtxOwner=!0;activityType=f.activities.CAMERA;_unsubPermissions=null;_capturing=!1;_chunks=[];_mediaRecorder=null;_stream=null;_selectedAudioId=null;_selectedCameraId=null;_activeTab=null;_options={};_canvas=null;_ctx=null;_cameraDevices=[];_audioDevices=[];_permissionResponses={};constructor(){super(),this.init$={...this.init$,video:null,videoTransformCss:null,videoHidden:!0,messageHidden:!0,requestBtnHidden:Es(),cameraSelectOptions:null,cameraSelectHidden:!0,l10nMessage:"",switcher:null,panels:null,timer:null,timerHidden:!0,cameraHidden:!0,cameraActionsHidden:!0,audioSelectOptions:null,audioSelectHidden:!0,audioSelectDisabled:!0,audioToggleMicrophoneHidden:!0,tabCameraHidden:!0,tabVideoHidden:!0,currentIcon:"camera-full",currentTimelineIcon:"play",toggleMicrophoneIcon:"microphone",_startTime:0,_elapsedTime:0,_animationFrameId:null,mutableClassButton:"uc-shot-btn uc-camera-action",onCameraSelectChange:e=>{let t=e.target;t&&(this._selectedCameraId=t.value,this._capture())},onAudioSelectChange:e=>{let t=e.target;t&&(this._selectedAudioId=t.value,this._capture())},onCancel:()=>{this.historyBack()},onShot:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this._activeTab}}}),this._shot()},onRequestPermissions:()=>this._capture(),onStartCamera:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this._activeTab}}}),this._chooseActionWithCamera()},onStartRecording:()=>this._startRecording(),onStopRecording:()=>this._stopRecording(),onToggleRecording:()=>this._toggleRecording(),onToggleAudio:()=>this._toggleEnableAudio(),onRetake:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this._activeTab}}}),this._retake()},onAccept:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this._activeTab}}}),this._accept()},onClickTab:e=>{let r=e.currentTarget?.getAttribute("data-id");r&&this._handleActiveTab(r)}}}_chooseActionWithCamera=()=>{if(this._activeTab===_.PHOTO&&this._shot(),this._activeTab===_.VIDEO){if(this._mediaRecorder?.state==="recording"){this._stopRecording();return}this._startRecording()}};_updateTimer=()=>{let e=Math.floor((performance.now()-this.$._startTime+this.$._elapsedTime)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){let o=this.ref.timer;o&&(o.textContent=di(t)),this._stopRecording();return}let r=this.ref.timer;r&&(r.textContent=di(t))}else{let t=this.ref.timer;t&&(t.textContent=di(e))}this._animationFrameId=requestAnimationFrame(this._updateTimer)};_startTimer=()=>{this.$._startTime=performance.now(),this.$._elapsedTime=0,this._updateTimer()};_stopTimer=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)};_startTimeline=()=>{let e=this.ref.video;if(!e)return;let t=e.currentTime,r=e.duration||1,o=this.ref.line;o&&(o.style.transform=`scaleX(${t/r})`);let s=this.ref.timer;s&&(s.textContent=di(t)),this._animationFrameId=requestAnimationFrame(this._startTimeline)};_stopTimeline=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)};_animationFrameId=null;_startRecording=()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(As)?this._options.mimeType=As:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(ee.PLAY))}catch(e){console.error("Failed to start recording",e),this.telemetryManager.sendEventError(e,"camera recording. Failed to start recording")}};_stopRecording=()=>{this._mediaRecorder?.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(ee.STOP)}),this._mediaRecorder?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this._activeTab}}})};_toggleRecording=()=>{this._mediaRecorder?.state!=="recording"&&(!this.ref.video.paused&&!this.ref.video.ended&&this.ref.video.readyState>2?this.ref.video.pause():this.ref.video.paused&&this.ref.video.play())};_toggleEnableAudio=()=>{this._stream?.getAudioTracks().forEach(e=>{e.enabled=!e.enabled,this.$.toggleMicrophoneIcon=e.enabled?"microphone":"microphone-mute",this.$.audioSelectDisabled=!e.enabled})};_previewVideo=()=>{try{let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=URL.createObjectURL(e),r=this.ref.video;if(!r)return;r.muted=!1,r.volume=1,this.$.video=null,r.src=t,r.addEventListener("play",()=>{this._startTimeline(),this.set$({currentTimelineIcon:"pause"})}),r.addEventListener("pause",()=>{this.set$({currentTimelineIcon:"play"}),this._stopTimeline()})}catch(e){console.error("Failed to preview video",e),this.telemetryManager.sendEventError(e,"camera previewing. Failed to preview video")}};_retake=()=>{if(this._setCameraState(ee.RETAKE),this._activeTab===_.VIDEO){this.$.video=this._stream;let e=this.ref.video;e&&(e.muted=!0)}this.ref.video?.play?.()};_accept=()=>{if(this._setCameraState(ee.ACCEPT),this._activeTab===_.PHOTO){this._canvas?.toBlob(o=>{if(!o)return;let s=this._createFile("camera","jpeg",xs,o);this._toSend(s)},xs);return}let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=this._guessExtensionByMime(this._mediaRecorder?.mimeType),r=this._createFile("video",t,`video/${t}`,e);this._toSend(r),this._chunks=[]};_handlePhoto=e=>{e===ee.SHOT&&this.set$({tabVideoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,cameraActionsHidden:!1,cameraSelectHidden:!0}),(e===ee.RETAKE||e===ee.ACCEPT)&&this.set$({tabVideoHidden:!this._cameraModes.includes(_.VIDEO),tabCameraHidden:!this._cameraModes.includes(_.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,cameraSelectHidden:this._cameraDevices.length<=1})};_handleVideo=e=>{e===ee.PLAY&&this.set$({timerHidden:!1,tabCameraHidden:!0,cameraSelectHidden:!0,audioSelectHidden:!0,currentTimelineIcon:"pause",currentIcon:"square",mutableClassButton:"uc-shot-btn uc-camera-action uc-stop-record"}),e===ee.STOP&&this.set$({timerHidden:!1,cameraHidden:!0,audioToggleMicrophoneHidden:!0,cameraActionsHidden:!1}),(e===ee.RETAKE||e===ee.ACCEPT)&&this.set$({timerHidden:!0,tabVideoHidden:!this._cameraModes.includes(_.VIDEO),tabCameraHidden:!this._cameraModes.includes(_.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording,currentIcon:"video-camera-full",mutableClassButton:"uc-shot-btn uc-camera-action",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,cameraSelectHidden:this._cameraDevices.length<=1})};_setCameraState=e=>{this._activeTab===_.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===_.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e)};_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");this._canvas.height=this.ref.video.videoHeight,this._canvas.width=this.ref.video.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(this.ref.video,0,0),this.ref.video.pause()}_handleActiveTab=e=>{this.ref.switcher?.querySelectorAll("button").forEach(r=>{r.classList.toggle("uc-active",r.getAttribute("data-id")===e)}),e===_.PHOTO&&this.set$({currentIcon:"camera-full",audioSelectHidden:!0,audioToggleMicrophoneHidden:!0}),e===_.VIDEO&&this.set$({currentTimelineIcon:"play",currentIcon:"video-camera-full",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording}),this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:e}}}),this._activeTab=e};_createFile=(e,t,r,o)=>{let s=Date.now(),n=`${e}-${s}.${t}`;return new File([o],n,{lastModified:s,type:r})};_guessExtensionByMime(e){let t={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return"webm";if(e){let r=e.split("/");if(r?.[0]==="video"){let s=r.slice(1).join("/")?.split(";")[0];if(s&&t[s])return t[s]}}return"avi"}_toSend=e=>{this.api.addFileFromObject(e,{source:P.CAMERA}),this.set$({"*currentActivity":f.activities.UPLOAD_LIST}),this.modalManager?.open(f.activities.UPLOAD_LIST)};get _cameraModes(){return $(this.cfg.cameraModes).filter(e=>e===_.PHOTO||e===_.VIDEO)}_setPermissionsState=M(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===_.VIDEO&&this.cfg.enableAudioRecording,r=this._activeTab===_.PHOTO?"camera-full":"video-camera-full";e==="granted"?this.set$({videoHidden:!1,cameraHidden:!1,tabCameraHidden:!this._cameraModes.includes(_.PHOTO),tabVideoHidden:!this._cameraModes.includes(_.VIDEO),messageHidden:!0,timerHidden:!0,currentIcon:r,audioToggleMicrophoneHidden:!t,audioSelectHidden:!t}):e==="prompt"?(this.$.l10nMessage="camera-permissions-prompt",this.set$({videoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,messageHidden:!1}),this._stopCapture()):(this.$.l10nMessage="camera-permissions-denied",this.set$({videoHidden:!0,messageHidden:!1,tabCameraHidden:!this._cameraModes.includes(_.PHOTO),tabVideoHidden:!this._cameraModes.includes(_.VIDEO),cameraActionsHidden:!0,mutableClassButton:"uc-shot-btn uc-camera-action"}),this._stopCapture())},300);_makeStreamInactive=()=>{if(!this._stream)return!1;let e=this._stream?.getAudioTracks(),t=this._stream?.getVideoTracks();return e.forEach(r=>{r.stop()}),t.forEach(r=>{r.stop()}),!0};_stopCapture=()=>{this._capturing&&(this.ref.video.volume=0,this.$.video?.getTracks?.()?.[0]?.stop(),this.$.video=null,this._makeStreamInactive(),this._stopTimer(),this._capturing=!1)};_capture=async()=>{let e={video:{...Tl},audio:this.cfg.enableAudioRecording?{}:!1};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this.ref.video&&(this.ref.video.volume=0);try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied")}),this.$.video=this._stream,this._capturing=!0,this._setPermissionsState("granted")}catch(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t),this.telemetryManager.sendEventError(t,"camera capturing. Failed to capture camera")}};_handlePermissionsChange=()=>{this._capture()};_permissionAccess=async()=>{try{for(let e of Ts){let t=await navigator.permissions.query({name:e});this._permissionResponses[e]=t,t.addEventListener("change",this._handlePermissionsChange)}}catch(e){console.log("Failed to use permissions API. Fallback to manual request mode.",e),this.telemetryManager.sendEventError(e,"camera permissions. Failed to use permissions API"),this._capture()}};_getPermission=()=>{};_requestDeviceAccess=async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices)}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get user media"),console.log("Failed to get user media",e)}};_getDevices=async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=e.filter(t=>t.kind==="videoinput").map((t,r)=>({text:t.label.trim()||`${this.l10n("caption-camera")} ${r+1}`,value:t.deviceId})),this._audioDevices=this.cfg.enableAudioRecording?e.filter(t=>t.kind==="audioinput").map(t=>({text:t.label.trim(),value:t.deviceId})):[],this._cameraDevices.length>1&&this.set$({cameraSelectOptions:this._cameraDevices,cameraSelectHidden:!1}),this._selectedCameraId=this._cameraDevices[0]?.value??null,this._audioDevices.length>1&&this.set$({audioSelectOptions:this._audioDevices,audioSelectHidden:!1}),this._selectedAudioId=this._audioDevices[0]?.value??null}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get devices"),console.log("Failed to get devices",e)}};_onActivate=async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes)};_onDeactivate=async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()};_handleCameraModes=e=>{this.$.tabVideoHidden=!e.includes(_.VIDEO),this.$.tabCameraHidden=!e.includes(_.PHOTO);let t=e[0];t&&(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t)};initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:this._onActivate,onDeactivate:this._onDeactivate}),this.subConfigValue("cameraMirror",e=>{this.$.videoTransformCss=e?"scaleX(-1)":null}),this.subConfigValue("enableAudioRecording",e=>{this.$.audioToggleMicrophoneHidden=!e,this.$.audioSelectDisabled=!e}),this.subConfigValue("cameraModes",e=>{if(!this.isActivityActive)return;let t=q(e);this._handleCameraModes(t.filter(r=>r===_.PHOTO||r===_.VIDEO))})}_destroy(){for(let e of Ts)this._permissionResponses[e]?.removeEventListener("change",this._handlePermissionsChange);navigator.mediaDevices?.removeEventListener("devicechange",this._getDevices)}async destroyCallback(){super.destroyCallback(),this._destroy()}};ui.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back" ><uc-icon name="back"></uc-icon></button><div set="@hidden: !cameraSelectHidden"><uc-icon name="camera"></uc-icon><span l10n="caption-camera"></span></div><uc-select class="uc-camera-select" set="$.options: cameraSelectOptions; @hidden: cameraSelectHidden; onchange: onCameraSelectChange" ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline set="srcObject: video; style.transform: videoTransformCss; @hidden: videoHidden" ref="video" ></video><div class="uc-message-box" set="@hidden: messageHidden"><span l10n="l10nMessage"></span><button type="button" set="onclick: onRequestPermissions; @hidden: requestBtnHidden" l10n="camera-permissions-request" ></button></div></div><div class="uc-controls"><div ref="switcher" class="uc-switcher" set="@hidden:!timerHidden"><button data-id="photo" type="button" class="uc-switch uc-mini-btn" set="onclick: onClickTab; @hidden: tabCameraHidden" ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class="uc-switch uc-mini-btn" set="onclick: onClickTab; @hidden: tabVideoHidden" ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" set="@hidden:timerHidden; onclick: onToggleRecording" ><uc-icon set="@name: currentTimelineIcon"></uc-icon><span ref="timer"> 00:00 </span><span ref="line" class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" set="@hidden: cameraActionsHidden" ><button type="button" class="uc-secondary-btn" set="onclick: onRetake"> Retake </button><button type="button" class="uc-primary-btn" set="onclick: onAccept" data-testid="accept" > Accept </button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" set="onclick: onStartCamera; @class: mutableClassButton; @hidden: cameraHidden;" ><uc-icon set="@name: currentIcon"></uc-icon></button><div class="uc-select"><button class="uc-mini-btn uc-btn-microphone" set="onclick: onToggleAudio; @hidden: audioToggleMicrophoneHidden;" ><uc-icon set="@name:toggleMicrophoneIcon"></uc-icon></button><uc-select class="uc-audio-select" set="$.options: audioSelectOptions; onchange: onAudioSelectChange; @hidden: audioSelectHidden; @disabled: audioSelectDisabled" ></uc-select></div></div>`;var de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function Ss(...i){return i.reduce((e,t)=>{if(typeof t=="string")return e[t]=!0,e;for(let r of Object.keys(t))e[r]=t[r];return e},{})}function N(...i){let e=Ss(...i);return Object.keys(e).reduce((t,r)=>(e[r]&&t.push(r),t),[]).join(" ")}function Is(i,...e){let t=Ss(...e);for(let r of Object.keys(t))i.classList.toggle(r,!!t[r])}var xl=i=>X.includes(i),ks=i=>{if(!i)return X;let e=q(i).filter(xl);return e.length===0?X:e};function Os(i){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":X,"*tabId":L.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:de,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:me([...X]),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let e=i.querySelectorAll("img");for(let t of e){let r=t.src;t.src=de,t.src=r}i.$["*networkProblems"]=!1},"*on.apply":e=>{if(!e)return;let t=i.$["*originalUrl"],r=H(xe(e),"preview"),o=U(t,r),s={originalUrl:t,cdnUrlModifiers:r,cdnUrl:o,transformations:e};i.dispatchEvent(new CustomEvent("apply",{detail:s,bubbles:!0,composed:!0})),i.remove()},"*on.cancel":()=>{i.remove(),i.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Ms="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='ruc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#uuc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#uuc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#uuc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#uuc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#uuc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#uuc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#uuc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>";var Ls=`${Ms} <div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" set="visible: presence.networkProblems;"><div class="uc-network_problems_content"><div class="uc-network_problems_icon"><uc-icon name="sad"></uc-icon></div><div class="uc-network_problems_text">Network error</div></div><div class="uc-network_problems_footer"><uc-btn-ui theme="primary" text="Retry" set="onclick: *on.retryNetwork"></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">{{fileType}}</div></div><div class="uc-image_container" ref="img-container-el"><img src="${de}" class="uc-image uc-image_visible_from_editor" ref="img-el" /><uc-editor-image-cropper ref="cropper-el"></uc-editor-image-cropper><uc-editor-image-fader ref="fader-el"></uc-editor-image-fader></div><div class="uc-info_pan">{{msg}}</div></div><div class="uc-toolbar"><uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor"><uc-editor-toolbar></uc-editor-toolbar></div></div></div>`;var we=class extends y{ctxOwner=!0;static styleAttrs=["uc-cloud-image-editor"];_debouncedShowLoader=M(this._showLoader.bind(this),300);constructor(){super(),this.init$={...this.init$,...Os(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((t,r)=>{let o=window.setTimeout(()=>{r(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),s=new ResizeObserver(n=>{let[a]=n;a&&a.contentRect.width>0&&a.contentRect.height>0&&(window.clearTimeout(o),s.disconnect(),window.setTimeout(()=>t(),0))});s.observe(this)})}initCallback(){super.initCallback(),this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.$.cdnUrl){let e=this.$.cdnUrl,t=Nt(e),r=Te(e,t);if(r===this.$["*originalUrl"])return;this.$["*originalUrl"]=r;let o=Xi(e),s=Zi(o);this.$["*editorTransformations"]=s}else if(this.$.uuid){let e=Te(this.cfg.cdnCname,this.$.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===L.CROP?this.$["*cropperEl"]?.deactivate({reset:!0}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(U(e,H("json"))),r=await fetch(t).then(n=>n.json()),{width:o,height:s}=r;this.$["*imageSize"]={width:o,height:s},this.$["*tabId"]===L.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:e})}catch(e){e&&(this.telemetryManager.sendEventError(e,"cloud editor image. Failed to load image info"),console.error("Failed to load image info",e))}}}async initEditor(){try{await this._waitForSize()}catch(e){this.isConnected&&console.error(e.message);return}this.ref["img-el"].addEventListener("load",()=>{this._debouncedShowLoader(!1),this.$.src!==de&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let t=this.ref["img-el"];t.src!==e&&(t.src=e||de)}),this.sub("tabs",e=>{this.$["*tabList"]=ks(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=N("uc-image",{"uc-image_hidden_to_cropper":e===L.CROP,"uc-image_hidden_effects":e!==L.CROP})}),this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{this.$["presence.networkProblems"]=e,this.$["presence.modalCaption"]=!e}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],r=H(xe(e),"preview"),o=U(t,r),s={originalUrl:t,cdnUrlModifiers:r,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:s,bubbles:!0,composed:!0}))},!1),this.sub("uuid",e=>e&&this.updateImage()),this.sub("cdnUrl",e=>e&&this.updateImage()),this.sub("cropPreset",e=>{let t=ii(e),r=null;if(this.$.cdnUrl){let o=Xi(this.$.cdnUrl),s=Zi(o);if(Array.isArray(s?.crop?.dimensions)){let[n,a]=s.crop.dimensions;r=ls(n,a,t,.1)}}this.$["*cropPresetList"]=t,this.$["*currentAspectRatio"]=r??t?.[0]??null})}};we.template=Ls;we.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var pi=class extends y{_handlePointerUp;_handlePointerMove;_handleSvgPointerMove;_backdropMaskId=`backdrop-mask-${ne.generate()}`;_backdropMask;_backdropMaskInner;_frameThumbs;_frameGuides;_draggingThumb;_hoverThumb;_dragStartPoint;_dragStartCrop;_frameImage;_guidesHidden=!1;constructor(){super(),this.init$={...this.init$,dragging:!1},this._handlePointerUp=this._handlePointerUp_.bind(this),this._handlePointerMove=this._handlePointerMove_.bind(this),this._handleSvgPointerMove=this._handleSvgPointerMove_.bind(this)}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return!1;if(e===""&&t.height<=b&&t.width<=b)return!0;let r=t.height<=b&&(e.includes("n")||e.includes("s")),o=t.width<=b&&(e.includes("e")||e.includes("w"));return r||o}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:o,height:s}=e,n=this.ref["svg-el"],a=K("mask",{id:this._backdropMaskId}),l=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=K("rect",{x:t,y:r,width:o,height:s,fill:"black"});a.appendChild(l),a.appendChild(c);let d=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:`url(#${this._backdropMaskId})`});n.appendChild(d),n.appendChild(a),this._backdropMask=a,this._backdropMaskInner=c}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block")}))}_updateBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:o,height:s}=e;this._backdropMaskInner&&Le(this._backdropMaskInner,{x:t,y:r,width:o,height:s})}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:r,pathNode:o,interactionNode:s,groupNode:n}=t,a=r==="",l=r.length===2,{x:c,y:d,width:u,height:p}=e;if(a)Le(s,{x:c,y:d,width:u,height:p});else{let h=Re(Math.min(u,p)/82/2,0,1),g=l?Jo(e,r,h):es(e,r,h),v=g.center;if(!v)continue;let A=Math.max(wr*Re(Math.min(u,p)/wr/3,0,1),Qo);Le(s,{x:v[0]-A,y:v[1]-A,width:A*2,height:A*2}),Le(o,{d:g.d})}let m=this._shouldThumbBeDisabled(r);n.setAttribute("class",N("uc-thumb",{"uc-thumb--hidden":m,"uc-thumb--visible":!m}))}Le(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1})}}_createThumb(e,t){let r=K("g");r.classList.add("uc-thumb"),r.setAttribute("with-effects","");let o=K("rect",{fill:"transparent"}),s=K("path",{stroke:"currentColor",fill:"none","stroke-width":3});r.appendChild(s),r.appendChild(o),e[t]={direction:t,pathNode:s,interactionNode:o,groupNode:r},t===""&&(r.style.cursor="move"),o.addEventListener("pointerdown",this._handlePointerDown.bind(this,t))}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let r=0;r<3;r++){let o=`${["n","","s"][t]}${["w","","e"][r]}`;o!==""&&this._createThumb(e,o)}return this._createThumb(e,""),e}_createGuides(){let e=K("svg"),t=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let r=1;r<=2;r++){let o=K("line",{x1:`${mt*r}%`,y1:"0%",x2:`${mt*r}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}for(let r=1;r<=2;r++){let o=K("line",{x1:"0%",y1:`${mt*r}%`,x2:"100%",y2:`${mt*r}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}return e.classList.add("uc-guides","uc-guides--semi-hidden"),e}_createFrame(){let e=this.ref["svg-el"],t=document.createDocumentFragment(),r=this._createGuides();t.appendChild(r);let o=this._createThumbs();for(let{groupNode:s}of Object.values(o))t.appendChild(s);e.appendChild(t),this._frameThumbs=o,this._frameGuides=r}_handlePointerDown(e,t){if(!this._frameThumbs)return;let r=this._frameThumbs[e];if(!r||this._shouldThumbBeDisabled(e))return;let o=this.$["*cropBox"],s=this.ref["svg-el"],{x:n,y:a}=s.getBoundingClientRect(),l=t.x-n,c=t.y-a;this.$.dragging=!0,this._draggingThumb=r,this._dragStartPoint=[l,c],this._dragStartCrop={...o}}_handlePointerUp_(e){this._updateCursor(),this.$.dragging&&(e.stopPropagation(),e.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(e){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this.ref["svg-el"],{x:r,y:o}=t.getBoundingClientRect(),s=e.x-r,n=e.y-o,a=s-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,d=this._calcCropBox(c,[a,l]);d&&(this.$["*cropBox"]=d)}_calcCropBox(e,t){let[r,o]=t,s=this.$["*imageBox"],n=this._dragStartCrop??this.$["*cropBox"],a=this.$["*currentAspectRatio"],l=a?a.width/a.height:void 0;if(e===""?n=is({rect:n,delta:[r,o],imageBox:s}):n=rs({rect:n,delta:[r,o],direction:e,aspectRatio:l,imageBox:s}),!Object.values(n).every(c=>Number.isFinite(c)&&c>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return qe(Ze(n),s)}_handleSvgPointerMove_(e){if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(r=>{if(!r||this._shouldThumbBeDisabled(r.direction))return!1;let s=r.interactionNode.getBoundingClientRect(),n={x:s.x,y:s.y,width:s.width,height:s.height};return os(n,[e.x,e.y])});this._hoverThumb=t,this._updateCursor()}_updateCursor(){let e=this._hoverThumb,t=this.ref["svg-el"];t.style.cursor=e?ts(e.direction):"initial"}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this.ref["svg-el"],r=document.createDocumentFragment(),o=K("image",{href:e});o.setAttribute("class","uc-cloud-mask"),r.appendChild(o),t.appendChild(r),this._frameImage=o}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:r,width:o,height:s}=e;Le(this._frameImage,{x:t,y:r,height:s,width:o})}_render(){this._updateBackdrop(),this._updateFrame(),this._updateMask()}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:r}=t;r.setAttribute("class",N("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}))}}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",()=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",t=>{t&&(this._guidesHidden=t.height<=b||t.width<=b,window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this._createMask(t)}),this.sub("dragging",t=>{this._frameGuides&&this._frameGuides.setAttribute("class",N({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&t,"uc-guides--semi-hidden":!this._guidesHidden&&!t}))}),this.ref["svg-el"].addEventListener("pointermove",this._handleSvgPointerMove,!0),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}destroyCallback(){super.destroyCallback(),this.ref["svg-el"].removeEventListener("pointermove",this._handleSvgPointerMove,!0),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}};pi.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var te=class extends y{_titleEl;constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"","on.click":null,"title-prop":""}}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this.sub("title",e=>{let t=this._titleEl;t&&(t.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=N({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e??null})}};te.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><uc-icon ref="icon-el" set="@name: icon;"></uc-icon><div class="uc-title" ref="title-el">{{title}}</div></button>`;var hi=12,Rs=16,Sl=i=>{let e=12,t=12;return i.width/i.height>=1?(e=hi,t=Math.round(hi*i.height/i.width)):(t=hi,e=Math.round(hi*i.width/i.height)),{width:e,height:t}},Qe=class extends te{initCallback(){super.initCallback(),this.$.icon="arrow-dropdown",this.$["on.click"]=this.handleClick.bind(this),this.sub("*currentAspectRatio",e=>{this.$.title=e.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}),this.bindL10n("title-prop",()=>this.$.title)})}handleClick(){this.$["*showListAspectRatio"]=!0}};Qe.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><div class="uc-title" ref="title-el">{{title}}</div><uc-icon ref="icon-el" set="@name: icon;"></uc-icon></button>`;var bt=class extends te{constructor(){super(),this.init$={...this.init$,active:!1,once:!1}}initCallback(){super.initCallback(),this.defineAccessor("aspectRatio",e=>{if(!e)return;let t=!!e.hasFreeform;this.$.title=t?this.l10n("custom"):`${e.width}:${e.height}`,t||this._renderRectBasedOnAspectRatio(e),t&&this.setAttribute("uc-aspect-ratio-freeform",""),this._aspectRatio=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:t?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}).toLowerCase(),value:""}))}),this.sub("*currentAspectRatio",e=>{this.$.active=e&&e.id===this._aspectRatio?.id||e?.width===this._aspectRatio?.width&&e?.height===this._aspectRatio?.height}),this.$["on.click"]=this.handleClick.bind(this)}handleClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio)}_renderRectBasedOnAspectRatio(e){let{width:t,height:r}=Sl(e),o=K("rect",{"stroke-linejoin":"round",fill:"none",stroke:"currentColor","stroke-width":1.2,"fill-rule":"evenodd",x:(Rs-t)/2,y:(Rs-r)/2,rx:2,width:t,height:r}),s=this.ref["icon-el"]?.ref?.svg;s&&(s.innerHTML="",s.appendChild(o))}_aspectRatio};function Il(i){let e=i+90;return e=e>=360?0:e,e}function kl(i,e){if(i==="rotate")return Il(typeof e=="number"?e:0);if(i==="mirror"||i==="flip")return!e;throw new Error(`Unsupported operation: ${i}`)}var _t=class extends te{_operation=void 0;initCallback(){super.initCallback(),this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(e).toLowerCase()})))}),this.$["on.click"]=e=>{if(!this._operation)return;let t=this.$["*cropperEl"],r=t.getValue(this._operation),o=kl(this._operation,r);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this._operation,next:o,prev:r}),t.setValue(this._operation,o)}}};function Be(i){let e=new Image;return{promise:new Promise((o,s)=>{e.src=i,e.onload=()=>o(),e.onerror=n=>s(n)}),image:e,cancel:()=>{e.naturalWidth===0&&(e.src=de)}}}function wt(i){let e=[];for(let s of i){let n=Be(s);e.push(n)}let t=e.map(s=>s.image);return{promise:Promise.allSettled(e.map(s=>s.promise)),images:t,cancel:()=>{e.forEach(s=>{s.cancel()})}}}var ue="original",mi=class extends y{_operation="filter";_filter;_originalUrl="";constructor(){super(),this.init$={...this.init$,disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0,"on.input":e=>{this.$["*faderEl"]?.set(e),this.$.value=e}}}setOperation(e,t){this._operation=e,this._filter=t,this._initializeValues();let r=this.$["*faderEl"],o=this._originalUrl||this.$["*originalUrl"];r&&o&&r.activate({url:o,operation:this._operation,value:this._filter===ue?void 0:this.$.value,filter:this._filter===ue?void 0:this._filter,fromViewer:!1})}_initializeValues(){let e=this._operation,{range:t,zero:r}=re[e],[o,s]=t;this.$.min=o,this.$.max=s,this.$.zero=r;let a=this.$["*editorTransformations"][e];if(e==="filter"){let c=Number(s),d=a;if(d){let{name:u,amount:p}=d;c=u===this._filter?p:s}this.$.value=c,this.$.defaultValue=c;return}let l=typeof a<"u"?a:r;this.$.value=l,this.$.defaultValue=l}apply(){let t={...this.$["*editorTransformations"]};this._operation==="filter"?!this._filter||this._filter===ue?delete t.filter:t.filter={name:this._filter,amount:this.$.value}:t[this._operation]=this.$.value,this.$["*editorTransformations"]=t}cancel(){this.$["*faderEl"]?.deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{this._originalUrl=e}),this.sub("value",e=>{let t=`${this._filter??this._operation} ${e}`;this.$["*operationTooltip"]=t})}};mi.template=`<uc-slider-ui ref="slider-el" set="disabled: disabled; min: min; max: max; defaultValue: defaultValue; zero: zero; onInput: on.input;" ></uc-slider-ui>`;function Je(i){let e=i.match(/^([A-Za-z]+)\s+(\d+)$/);if(!e)return null;let[,t,r]=e;return!t||typeof r>"u"?null:{filter:t,value:Number(r)}}var et=class extends te{_operation="";_filter="";_originalUrl="";_observer;_cancelPreload;constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=window.devicePixelRatio,r=Math.ceil(t*e),o=t>=2?"lightest":"normal",s=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==ue?{name:this._filter,amount:s}:void 0,U(this._originalUrl,H(Bt,xe(n),`quality/${o}`,`scale_crop/${r}x${r}/center`))}async _observerCallback(e,t){if(e[0]?.isIntersecting){let o=await this.proxyUrl(this._previewSrc()),s=this.ref["preview-el"],{promise:n,cancel:a}=Be(o);this._cancelPreload=a,n.catch(l=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:l})}).finally(()=>{s.style.backgroundImage=`url(${o})`,s.setAttribute("loaded",""),t.unobserve(this)})}else this._cancelPreload?.()}initCallback(){super.initCallback(),this.$["on.click"]=t=>{if(this.$.active)this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0);else{let r=this.$["*sliderEl"];r.setOperation(this._operation,this._filter),r.apply()}this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:Je(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",t=>{this._operation="filter",this._filter=t,this.$.isOriginal=t===ue,this.$.icon=this.$.isOriginal?"original":"slider",this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-filter",{name:t.toLowerCase()}))}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let e=this.$["*originalUrl"];this._originalUrl=e,this.$.isOriginal?this.ref["icon-el"].classList.add("uc-original-icon"):this._observer.observe(this),this.sub("*currentFilter",t=>{this.$.active=t&&t===this._filter}),this.sub("isOriginal",t=>{this.$.iconSize=t?40:20}),this.sub("active",t=>{if(this.$.isOriginal)return;let r=this.ref["icon-el"];r.style.opacity=t?"1":"0";let o=this.ref["preview-el"];t?o.style.opacity="0":o.style.backgroundImage&&(o.style.opacity="1")}),this.sub("*networkProblems",async t=>{if(!t){let r=await this.proxyUrl(this._previewSrc()),o=this.ref["preview-el"];o.style.backgroundImage&&(o.style.backgroundImage="none",o.style.backgroundImage=`url(${r})`)}})}destroyCallback(){super.destroyCallback(),this._observer?.disconnect(),this._cancelPreload?.()}};et.template=`<button type="button" role="option" l10n="@title:title-prop;@aria-label:title-prop"><div class="uc-preview" ref="preview-el"></div><uc-icon ref="icon-el" set="@name: icon; @size: iconSize;"></uc-icon></button>`;var tt=(i,e)=>{let t=!1,r,o=0,s=((...n)=>{t?(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-o>=e&&(i(...n),o=Date.now())},Math.max(e-(Date.now()-o),0))):(i(...n),o=Date.now(),t=!0)});return Object.defineProperty(s,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{r&&clearTimeout(r)}}),s};function Ps(i,e){let t={};for(let r of e){let o=i[r];(Object.hasOwn(i,r)||o!==void 0)&&(t[r]=o)}return t}function it(i,e,t){let o=window.devicePixelRatio,s=Math.min(Math.ceil(e*o),3e3),n=o>=2?"lightest":"normal";return U(i,H(Bt,xe(t),`quality/${n}`,`stretch/off/-/resize/${s}x`,`@clib/${Oe}/${Me}/uc-cloud-image-editor/`))}function Ol(i){return i?[({dimensions:t,coords:r})=>[...t,...r].every(o=>Number.isInteger(o)&&Number.isFinite(o)),({dimensions:t,coords:r})=>t.every(o=>o>0)&&r.every(o=>o>=0)].every(t=>t(i)):!0}var fi=class extends y{ctxOwner=!0;_commitDebounced;_handleResizeThrottled;_imageSize={width:0,height:0};_canvas;_ctx=null;_isActive=!1;_observer;_cancelPreload;constructor(){super(),this.init$={...this.init$,image:null,"*padding":20,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=M(this._commit.bind(this),300),this._handleResizeThrottled=tt(this._handleResize.bind(this),100)}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let e=this.$["*editorTransformations"],t=Ps(e,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...t};this.$["*operations"]=r}_initCanvas(){let e=this.ref["canvas-el"],t=e.getContext("2d"),r=this.offsetWidth,o=this.offsetHeight,s=window.devicePixelRatio;e.style.width=`${r}px`,e.style.height=`${o}px`,e.width=r*s,e.height=o*s,t?.scale(s,s),this._canvas=e,this._ctx=t}_alignImage(){if(!this._isActive||!this.$.image)return;let e=this.$.image,t=this.$["*padding"],r=this.$["*operations"],{rotate:o}=r,s={width:this.offsetWidth,height:this.offsetHeight},n=Xe({width:e.naturalWidth,height:e.naturalHeight},o),a;if(n.width>s.width-t*2||n.height>s.height-t*2){let l=n.width/n.height,c=s.width/s.height;if(l>c){let d=s.width-t*2,u=d/l,p=0+t,m=t+(s.height-t*2)/2-u/2;a={x:p,y:m,width:d,height:u}}else{let d=s.height-t*2,u=d*l,p=t+(s.width-t*2)/2-u/2,m=0+t;a={x:p,y:m,width:u,height:d}}}else{let{width:l,height:c}=n,d=t+(s.width-t*2)/2-l/2,u=t+(s.height-t*2)/2-c/2;a={x:d,y:u,width:l,height:c}}this.$["*imageBox"]=Ze(a)}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,s=this.$["*editorTransformations"].crop,{width:n,x:a,y:l}=t;if(s){let{dimensions:[u,p],coords:[m,h]}=s,{width:g}=Xe(this._imageSize,o),v=n/g;e=qe(Ze({x:a+m*v,y:l+h*v,width:u*v,height:p*v}),t)}let c=this.$["*currentAspectRatio"],d=c?c.width/c.height:void 0;if(!ss(e,t)||d&&!ns(e,d)){let u=t.width/t.height,p=t.width,m=t.height;d&&(u>d?p=Math.min(t.height*d,t.width):m=Math.min(t.width/d,t.height)),e={x:t.x+t.width/2-p/2,y:t.y+t.height/2-m/2,width:p,height:m}}this.$["*cropBox"]=qe(Ze(e),t)}_drawImage(){let e=this._ctx;if(!e)return;let t=this.$.image,r=this.$["*imageBox"],o=this.$["*operations"],{mirror:s,flip:n,rotate:a}=o,l=Xe({width:r.width,height:r.height},a);e.save(),e.translate(r.x+r.width/2,r.y+r.height/2),e.rotate(a*Math.PI*-1/180),e.scale(s?-1:1,n?-1:1),e.drawImage(t,-l.width/2,-l.height/2,l.width,l.height),e.restore()}_draw(){if(!this._isActive||!this.$.image||!this._canvas||!this._ctx)return;let e=this._canvas;this._ctx.clearRect(0,0,e.width,e.height),this._drawImage()}_animateIn({fromViewer:e}){this.$.image&&(this.ref["frame-el"].toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=N({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:s,height:n}=t,{width:a,height:l}=Xe(this._imageSize,o),{width:c,height:d}=e,u=s/a,p=n/l;return[Re(Math.round(c/u),1,a),Re(Math.round(d/p),1,l)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:s,height:n,x:a,y:l}=t,{width:c,height:d}=Xe(this._imageSize,o),{x:u,y:p}=e,m=s/c,h=n/d,g=this._getCropDimensions(),v={dimensions:g,coords:[Re(Math.round((u-a)/m),0,c-g[0]),Re(Math.round((p-l)/h),0,d-g[1])]};if(!Ol(v)){console.error("Cropper is trying to create invalid crop object",{payload:v});return}if(!(g[0]===c&&g[1]===d))return v}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:r,flip:o}=e,s=this._getCropTransformation(),a={...this.$["*editorTransformations"],crop:s,rotate:t,mirror:r,flip:o};this.$["*editorTransformations"]=a}setValue(e,t){this.$["*operations"]={...this.$["*operations"],[e]:t},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:t}={}){if(!this._isActive){this._isActive=!0,this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{let r=this.$["*originalUrl"],o=this.$["*editorTransformations"];this.$.image=await this._waitForImage(r,o),this._syncTransformations(),this._animateIn({fromViewer:t})}catch(r){console.error("Failed to activate cropper",{error:r}),this.telemetryManager.sendEventError(r,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(r=>{let[o]=r;if(!o)return;o.contentRect.width>0&&o.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=N({"uc-active_from_viewer":!1,"uc-active_from_editor":!1,"uc-inactive_to_editor":!0}),this.ref["frame-el"].toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),this._observer?.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],r=Math.min(this.offsetWidth,e[0])/t.width,o=Math.min(this.offsetHeight,e[1])/t.height,s=Math.min(r,o),n=t.x+t.width/2,a=t.y+t.height/2;this.style.transform=`scale(${s}) translate(${(this.offsetWidth/2-n)/s}px, ${(this.offsetHeight/2-a)/s}px)`,this.style.transformOrigin=`${n}px ${a}px`}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,r=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${r}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(e,t){let r=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(it(e,r,t)),{promise:s,cancel:n,image:a}=Be(o),l=this._handleImageLoading(o);return a.addEventListener("load",l,{once:!0}),a.addEventListener("error",l,{once:!0}),this._cancelPreload?.(),this._cancelPreload=n,s.then(()=>a).catch(c=>(console.error("Failed to load image",{error:c}),this.$["*networkProblems"]=!0,a))}_handleImageLoading(e){let t="crop",r=this.$["*loadingOperations"],o=r.get(t);return o||(o=new Map,r.set(t,o)),o.get(e)||(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let s=r.get(t);s?.has(e)&&(s.delete(e),this.$["*loadingOperations"]=r)}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw()}),this.sub("*cropBox",()=>{this.$.image&&this._commitDebounced()}),this.sub("*currentAspectRatio",()=>{this._alignCrop()}),setTimeout(()=>{this.sub("*networkProblems",e=>{e||this._isActive&&this.activate(this._imageSize,{fromViewer:!1})})},0)}destroyCallback(){super.destroyCallback(),this._observer?.disconnect()}};fi.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Rr(i,e,t){let r=t,o=t-1,s=new Array(r);for(let n=o;n>=0;n-=1)s[n]=Math.ceil((n*e+(o-n)*i)/o);return s}function Ml(i){return typeof i=="string"&&i in re}function Ll(i){let e=[];for(let t=0;t<i.length-1;t+=1){let r=i[t],o=i[t+1];typeof r=="number"&&typeof o=="number"&&e.push([r,o])}return e}function Rl(i,e,t){let r=Ll(i).find(([n,a])=>n<=e&&e<=a);if(!r)return i.map(()=>0);let[o,s]=r;return i.map(n=>{let a=Math.abs(o-s)||1,l=Math.abs(e-o)/a;return o===n?e>t?1:1-l:s===n?e>=t?l:1:0})}function Pl(i,e){return i.map((t,r)=>t<e?i.length-r:r)}function Us(i,e){let t=re[i].keypointsNumber,{range:r,zero:o}=re[i];return[...new Set([...Rr(r[0],o,t+1),...Rr(o,r[1],t+1),o,e])].sort((s,n)=>s-n)}var Pr=class extends y{_isActive=!1;_hidden=!0;_operation="initial";_filter;_value;_transformations={};_keypoints=[];_container;_previewImage;_cancelLastImages;_cancelBatchPreload;_url;_fromViewer;_raf=0;_addKeypointDebounced=M(this._addKeypoint.bind(this),600);constructor(){super(),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(e){let t=this._operation,r=this.$["*loadingOperations"];r.has(t)||r.set(t,new Map);let o=r.get(t);return o&&!o.get(e)&&(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let s=r.get(t);s?.has(e)&&(s.delete(e),this.$["*loadingOperations"]=r)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let e of this._keypoints){let{image:t}=e;t&&(t.style.opacity=e.opacity.toString(),t.style.zIndex=e.zIndex.toString())}})}_imageSrc({url:e=this._url,filter:t=this._filter??void 0,operation:r,value:o}={}){if(!e)throw new Error("URL is not defined");let s={...this._transformations};r&&(r==="filter"?t&&typeof o=="number"&&(s.filter={name:t,amount:o}):typeof o=="number"&&(s[r]=o));let n=this.offsetWidth;return this.proxyUrl(it(e,n,s))}async _constructKeypoint(e,t){return{src:await this._imageSrc({operation:e,value:t}),image:void 0,opacity:0,zIndex:0,value:t}}_isSame(e,t){return this._operation===e&&this._filter===t}async _addKeypoint(e,t,r){let o=()=>!this._isSame(e,t)||this._value!==r||!!this._keypoints.find(l=>l.value===r);if(o())return;let s=await this._constructKeypoint(e,r),n=new Image;n.src=s.src;let a=this._handleImageLoading(s.src);n.addEventListener("load",a,{once:!0}),n.addEventListener("error",a,{once:!0}),s.image=n,n.classList.add("uc-fader-image"),n.addEventListener("load",()=>{if(o())return;let l=this._keypoints,c=l.findIndex(m=>m.value>r);c===-1&&(c=l.length);let u=l[c]?.image,p=this._container;!p||u&&!p.contains(u)||(l.splice(c,0,s),u&&p.insertBefore(n,u),this._update(e,r))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(e){let t=typeof e=="string"?parseInt(e,10):e;!Ml(this._operation)||!Number.isFinite(t)||(this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t))}_update(e,t){this._operation=e,this._value=t;let{zero:r}=re[e],o=this._keypoints.map(a=>a.value),s=Rl(o,t,r),n=Pl(o,r);this._keypoints.forEach((a,l)=>{let c=s[l],d=n[l];typeof c=="number"&&(a.opacity=c),typeof d=="number"&&(a.zIndex=d)}),this._flush()}_createPreviewImage(){let e=new Image;return e.classList.add("uc-fader-image","uc-fader-image--preview"),e.style.opacity="0",e}async _initNodes(){let e=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage();let t=this._previewImage;this.contains(t)||e.appendChild(t);let r=document.createElement("div");e.appendChild(r);let o=this._keypoints.map(d=>d.src),{images:s,promise:n,cancel:a}=wt(o);s.forEach(d=>{let u=this._handleImageLoading(d.src);d.addEventListener("load",u),d.addEventListener("error",u)}),this._cancelLastImages=()=>{a(),this._cancelLastImages=void 0};let l=this._operation,c=this._filter;await n,this._isActive&&this._isSame(l,c)&&(this._container?.remove(),this._container=r,this._keypoints.forEach((d,u)=>{let p=s[u];p&&(p.classList.add("uc-fader-image"),d.image=p,this._container?.appendChild(p))}),this.appendChild(e),this._flush())}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),r=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",r,{once:!0}),this._previewImage.addEventListener("error",r,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:e,filter:t,operation:r,value:o}){if(!r||typeof o!="number")return;this._cancelBatchPreload?.();let s=Us(r,o),n=await Promise.all(s.map(l=>this._imageSrc({url:e,filter:t,operation:r,value:l}))),{cancel:a}=wt(n);this._cancelBatchPreload=a}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this.contains(t)||this.appendChild(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=N({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}t.style.opacity="0";let r=this._handleImageLoading(e);t.addEventListener("error",r,{once:!0}),t.src=e,t.addEventListener("load",()=>{r(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=N({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),t.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:e,operation:t,value:r,filter:o,fromViewer:s}){if(this._isActive=!0,this._hidden=!1,this._url=e,this._operation=t??"initial",this._value=r,this._filter=o,this._fromViewer=s,typeof r!="number"&&!o){let a=await this._imageSrc({operation:t,value:r});this._setOriginalSrc(a),this._container?.remove();return}!t||typeof r!="number"||(this._keypoints=await Promise.all(Us(t,r).map(a=>this._constructKeypoint(t,a))),this._update(t,r),this._initNodes())}deactivate({hide:e=!0}={}){this._isActive=!1,this._cancelLastImages?.(),this._cancelBatchPreload?.(),e&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=N({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._container?.remove()},{once:!0})):this._container?.remove()}};var Ct=class extends te{_operation="";initCallback(){super.initCallback(),this.$["on.click"]=e=>{this.$["*sliderEl"].setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation,this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:Je(this.$["*operationTooltip"])})},this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()})),this.bindL10n("title",()=>this.l10n(e)))}),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=re[this._operation],r=e[this._operation],o=typeof r<"u"?r!==t:!1;this.$.active=o})}};var Ul=1,gi=class extends y{initCallback(){super.initCallback(),this.addEventListener("wheel",e=>{e.preventDefault();let{deltaY:t,deltaX:r}=e;Math.abs(r)>Ul?this.scrollLeft+=r:this.scrollLeft+=t},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};gi.template=" <slot></slot> ";function $l(i){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${i}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${i}" data-id="${i}" icon="${i}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${i}; title-prop: a11y-editor-tab-${i}" ></uc-btn-ui></uc-presence-toggle>`}function Dl(i){return`<uc-presence-toggle id="tab_${i}" class="uc-tab-content" set="visible: presence.tabContent.${i}; styles: presence.tabContentStyles" ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner" ref="controls-list-${i}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var vi=class extends y{_debouncedShowLoader;_cancelPreload;_updateInfoTooltip;constructor(){super(),this.init$={...this.init$,"*sliderEl":null,"*listAspectRatioEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*showListAspectRatio":!1,hideSliderOrList:!1,"*currentFilter":ue,"*currentOperation":null,showLoader:!1,filters:yo,colorOperations:vo,cropOperations:bo,"*operationTooltip":null,"presence.mainToolbar":!0,"presence.subToolbar":!1,"presence.tabToggles":!0,"presence.tabContent.crop":!1,"presence.tabContent.tuning":!1,"presence.tabContent.filters":!1,"presence.tabToggle.crop":!0,"presence.tabToggle.tuning":!0,"presence.tabToggle.filters":!0,"presence.subTopToolbarStyles":{hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"},"presence.subBottomToolbarStyles":{hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"},"presence.tabContentStyles":{hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"},"presence.tabToggleStyles":{hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"},"presence.tabTogglesStyles":{hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"},"on.cancel":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t()},"on.apply":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t(this.$["*editorTransformations"])},"on.applySlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:Je(this.$["*operationTooltip"])}),this.ref["slider-el"].apply(),this._onSliderClose()},"on.cancelSlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this.ref["slider-el"].cancel(),this._onSliderClose()},"on.clickTab":e=>{let r=e.currentTarget?.getAttribute("data-id");r&&(this.telemetryManager.sendEventCloudImageEditor(e,r),this._activateTab(r,{fromViewer:!1}))},tab_role:"tab",[`tab_${L.TUNING}`]:`tab_${L.TUNING}`,[`tab_${L.CROP}`]:`tab_${L.CROP}`,[`tab_${L.FILTERS}`]:`tab_${L.FILTERS}`,cancel:"cancel",apply:"apply","a11y-editor-tab-filters":"a11y-editor-tab-filters","a11y-editor-tab-tuning":"a11y-editor-tab-tuning","a11y-editor-tab-crop":"a11y-editor-tab-crop"},this._debouncedShowLoader=M(this._showLoader.bind(this),500),this._updateInfoTooltip=M(this._updateInfoTooltipHandler.bind(this),0)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===L.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===L.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let t=new Ct;return t.operation=e,t}_createFilterControl(e){let t=new et;return t.filter=e,t}_createToggleControl(e){let t=new _t;return t.operation=e,t}_createAspectRatioControl(e){let t=new bt;return t.aspectRatio=e,t}_createFreeformControl(){return new Qe}_clearListAspectRatio(){let e=this.$["*listAspectRatioEl"];e&&(e.innerHTML="")}_renderControlsList(e){let t=this.ref[`controls-list-${e}`],r=document.createDocumentFragment();if(this._clearListAspectRatio(),e===L.CROP){let o=this.$["*cropPresetList"],s=o.length>=3;if(s){let n=this._createFreeformControl();r.appendChild(n)}for(let n of o){let a=this._createAspectRatioControl(n);r.appendChild(a),s&&this.$["*listAspectRatioEl"]?.appendChild(a)}for(let n of this.$.cropOperations){let a=this._createToggleControl(n);r.appendChild(a)}}else if(e===L.FILTERS){let o=this.$.filters;[ue,...o].forEach(s=>{let n=this._createFilterControl(s);r.appendChild(n)})}else if(e===L.TUNING)for(let o of this.$.colorOperations){let s=this._createOperationControl(o);r.appendChild(s)}[...r.children].forEach((o,s)=>{s===r.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),t.innerHTML="",t.appendChild(r)}_activateTab(e,{fromViewer:t}={}){this.$["*tabId"]=e;let r=this.$["*faderEl"],o=this.$["*cropperEl"];e===L.CROP?(r?.deactivate(),o?.activate(this.$["*imageSize"],{fromViewer:t})):(r?.activate({url:this.$["*originalUrl"],fromViewer:t}),o?.deactivate());for(let s of X){let n=s===e,a=this.ref[`tab-toggle-${s}`];a.active=n,n?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(s),this.$[`presence.tabContent.${s}`]=n}}_unmountTabControls(e){let t=this.ref[`controls-list-${e}`];t&&(t.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],t=this.ref["tabs-indicator"];t.style.transform=`translateX(${e.offsetLeft}px)`}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(it(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:r}=wt([t]);this._cancelPreload=()=>{r(),this._cancelPreload=void 0}}}_showLoader(e){this.$.showLoader=e}_updateInfoTooltipHandler(){let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],r="",o=!1;if(this.$["*tabId"]===L.FILTERS)if(o=!0,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let s=e?.filter?.amount||100;r=`${this.$["*currentFilter"]} ${s}`}else r=this.l10n(ue);else if(this.$["*tabId"]===L.TUNING&&t){o=!0;let s=e?.[t]||re[t].zero;r=`${this.l10n(t)} ${s}`}o&&(this.$["*operationTooltip"]=r),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)}initCallback(){super.initCallback(),this.$["*sliderEl"]=this.ref["slider-el"],this.$["*listAspectRatioEl"]=this.ref["list-el"],this.sub("*imageSize",e=>{e&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",e=>{let t=e?.filter?.name;this.$["*currentFilter"]!==t&&(this.$["*currentFilter"]=t)}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",()=>{this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(e)}),this.sub("*loadingOperations",e=>{let t=!1;for(let[,r]of e.entries()){if(t)break;for(let[,o]of r.entries())if(o){t=!0;break}}this._debouncedShowLoader(t)}),this.sub("*showSlider",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e,this.$.hideSliderOrList=!0}),this.sub("*showListAspectRatio",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e,this.$.hideSliderOrList=!1}),this.sub("*tabList",e=>{this.$["presence.tabToggles"]=e.length>1;for(let t of X){this.$[`presence.tabToggle.${t}`]=e.includes(t);let r=this.ref[`tab-toggle-${t}`];r.style.gridColumn=`${e.indexOf(t)+1}`}if(!e.includes(this.$["*tabId"])&&e.length>0){let[t]=e;t&&this._activateTab(t,{fromViewer:!1})}}),this._updateInfoTooltip()}destroyCallback(){this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}};vi.template=`<uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div ref="tooltip-el" class="uc-info-tooltip uc-info-tooltip_hidden">{{*operationTooltip}}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles" ><div class="uc-tab-content-row">${X.map(Dl).join("")}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" set="visible: presence.tabToggles; styles: presence.tabTogglesStyles" ><div ref="tabs-indicator" class="uc-tab-toggles_indicator"></div> ${X.map($l).join("")} </uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" set="onclick: on.cancel; title-prop:cancel"></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" set="onclick: on.apply; title-prop:apply"></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles" ><div class="uc-slider" set="@hidden:!hideSliderOrList"><uc-editor-slider ref="slider-el"></uc-editor-slider></div><div set="@hidden:hideSliderOrList" class="uc-list-aspect-ratio-container"><div class="uc-list-aspect-ratio" ref="list-el"></div></div><div class="uc-controls-row"><uc-btn-ui theme="secondary" set="onclick: on.cancelSlider" l10n="@text:cancel"></uc-btn-ui><uc-btn-ui theme="primary" set="onclick: on.applySlider" l10n="@text:apply"></uc-btn-ui></div></uc-presence-toggle></div>`;var Et=class extends y{_iconReversed=!1;_iconSingle=!1;_iconHidden=!1;constructor(){super(),this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null,"aria-role":"","aria-controls":"","title-prop":""},this.defineAccessor("active",e=>{e?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return N("uc-icon",{"uc-icon_left":!this._iconReversed,"uc-icon_right":this._iconReversed,"uc-icon_hidden":this._iconHidden,"uc-icon_single":this._iconSingle})}initCallback(){super.initCallback(),this.sub("icon",e=>{this._iconSingle=!this.$.text,this._iconHidden=!e,this.$.iconCss=this._iconCss()}),this.sub("theme",e=>{e&&e!=="custom"&&(this.className=`uc-${e}`)}),this.sub("text",()=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",e=>{this.$["aria-role"]=e||""}),this.defineAccessor("aria-controls",e=>{this.$["aria-controls"]=e||""}),this.defineAccessor("title-prop",e=>{this.$["title-prop"]=e||""})}set reverse(e){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection="")}};Et.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});Et.template=`<button type="button" set="@role:aria-role; @aria-controls: aria-controls; @aria-label:title-prop" l10n="@title:title-prop;" ><uc-icon set="className: iconCss; @name: icon; @hidden: !icon"></uc-icon><div class="uc-text">{{text}}</div></button>`;var yi=class extends y{_active=!1;_handleTransitionEndRight=()=>{let e=this.ref["line-el"];e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)",this._active&&this._start()};initCallback(){super.initCallback(),this.defineAccessor("active",e=>{typeof e=="boolean"&&(e?this._start():this._stop())})}_start(){this._active=!0;let{width:e}=this.getBoundingClientRect(),t=this.ref["line-el"];t.style.transition="transform 1s",t.style.opacity="1",t.style.transform=`translateX(${e}px)`,t.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};yi.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var rt={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},bi=class extends y{_visible=!1;_visibleStyle=rt.visible;_hiddenStyle=rt.hidden;_externalTransitions=!1;constructor(){super(),this.defineAccessor("styles",e=>{e&&(this._externalTransitions=!0,this._visibleStyle=e.visible??rt.visible,this._hiddenStyle=e.hidden??rt.hidden)}),this.defineAccessor("visible",e=>{typeof e=="boolean"&&(this._visible=e,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",Is(this,{[rt.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.setAttribute("aria-hidden",this._visible?"false":"true")}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",!0),this._externalTransitions||this.classList.add(rt.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};bi.template="<slot></slot> ";var _i=class extends y{_observer;_thumbSize=0;_zero=0;_zeroDotEl;_stepsCount;constructor(){super(),this.init$={...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:0,"on.sliderInput":()=>{let e=Number.parseInt(this._inputEl().value,10);this._updateValue(e),this.$.onInput?.(e)},"on.sliderChange":()=>{let e=Number.parseInt(this._inputEl().value,10);this.$.onChange?.(e)}},this.setAttribute("with-effects","")}initCallback(){super.initCallback(),this.defineAccessor("disabled",t=>{this.$.disabled=t}),this.defineAccessor("min",t=>{this.$.min=t}),this.defineAccessor("max",t=>{this.$.max=t}),this.defineAccessor("defaultValue",t=>{this.$.defaultValue=t;let r=this._inputEl();r.value=String(t),this._updateValue(t)}),this.defineAccessor("zero",t=>{this._zero=t}),this.defineAccessor("onInput",t=>{t&&(this.$.onInput=t)}),this.defineAccessor("onChange",t=>{t&&(this.$.onChange=t)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let t=Number.parseInt(this._inputEl().value,10);this._updateValue(t)}),this._observer.observe(this),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let t=Number.parseInt(this._inputEl().value,10);this._updateValue(t)},0),this.sub("disabled",t=>{let r=this._inputEl();t?r.setAttribute("disabled","disabled"):r.removeAttribute("disabled")});let e=this._inputEl();e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_inputEl(){return this.ref["input-el"]}_thumbEl(){return this.ref["thumb-el"]}_stepsEl(){return this.ref["steps-el"]}_updateValue(e){this._updateZeroDot(e);let{width:t}=this.getBoundingClientRect(),s=100/(this.$.max-this.$.min)*(e-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._thumbEl().style.transform=`translateX(${s}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;this._zeroDotEl.style.opacity=e===this._zero?"0":"1";let{width:t}=this.getBoundingClientRect(),s=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${s}px)`)})}_updateSteps(){let t=this._stepsEl(),{width:r}=t.getBoundingClientRect(),o=Math.ceil(r/2),s=Math.ceil(o/15)-2;if(this._stepsCount===s)return;let n=document.createDocumentFragment(),a=document.createElement("div"),l=document.createElement("div");a.className="uc-minor-step",l.className="uc-border-step",n.appendChild(l);for(let d=0;d<s;d+=1)n.appendChild(a.cloneNode());n.appendChild(l.cloneNode());for(let d=0;d<s;d+=1)n.appendChild(a.cloneNode());n.appendChild(l.cloneNode());let c=document.createElement("div");c.className="uc-zero-dot",n.appendChild(c),this._zeroDotEl=c,t.innerHTML="",t.appendChild(n),this._stepsCount=s}destroyCallback(){super.destroyCallback(),this._observer?.disconnect()}};_i.template=`<div class="uc-steps" ref="steps-el"></div><div ref="thumb-el" class="uc-thumb"></div><input class="uc-input" type="range" ref="input-el" set="oninput: on.sliderInput; onchange: on.sliderChange; @min: min; @max: max; @value: defaultValue;" />`;var Ur=class extends O{couldBeCtxOwner=!0;activityType=f.activities.CLOUD_IMG_EDIT;_entry;_instance;get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.mountEditor(),onDeactivate:()=>this.unmountEditor()}),this.subConfigValue("cropPreset",e=>{this._instance&&this._instance.getAttribute("crop-preset")!==e&&this._instance.setAttribute("crop-preset",e)}),this.subConfigValue("cloudImageEditorTabs",e=>{this._instance&&this._instance.getAttribute("tabs")!==e&&this._instance.setAttribute("tabs",e)})}handleApply(e){if(!this._entry)return;let t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager?.close(f.activities.CLOUD_IMG_EDIT),this.historyBack()}handleCancel(){this.modalManager?.close(f.activities.CLOUD_IMG_EDIT),this.historyBack()}mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);let o=new we,s=this.cfg.cropPreset,n=this.cfg.cloudImageEditorTabs;o.setAttribute("ctx-name",this.ctxName),o.setAttribute("cdn-url",r),s&&o.setAttribute("crop-preset",s),n&&o.setAttribute("tabs",n),o.addEventListener("apply",a=>{let l=a;this.handleApply(l),this.debugPrint('editor event "apply"',l.detail)}),o.addEventListener("cancel",a=>{let l=a;this.handleCancel(),this.debugPrint('editor event "cancel"',l.detail)}),o.addEventListener("change",a=>{let l=a;this.debugPrint('editor event "change"',l.detail)}),this.innerHTML="",this.appendChild(o),this._instance=o}unmountEditor(){this._instance=void 0,this._entry=void 0,this.innerHTML=""}};var Tt=i=>i.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(e=>e.toLowerCase()).join("-");var Fl=[{test:i=>!!i.accept&&!!i.imgOnly,message:"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."},{test:i=>i.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:i=>i.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],$s=M(i=>{for(let{test:e,message:t}of Fl)e(i)&&li(t)},0);var Ds=(i,e)=>{let t=new URL(e);return t.hostname=`${i}.${t.hostname}`,t.toString().replace(/\/$/,"")},Vl="0123456789abcdefghijklmnopqrstuvwxyz",Fs=i=>{if(i<=0n)return"0";let e="";for(;i>0n;){let t=i%36n;e=Vl[Number(t)]+e,i=i/36n}return e},$r=(i,e)=>{try{let t=new URL(i),r=new URL(e);return t.hostname.endsWith(r.hostname)}catch{return!1}};var Nl=async i=>{let e=new TextEncoder().encode(i),t=await window.crypto.subtle.digest("SHA-256",e),r=Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join("");return BigInt(`0x${r}`)},Bl=10,zl=async i=>{let e=await Nl(i);return Fs(e).slice(0,Bl)},Vs=async(i,e)=>{let t=await zl(i);return Ds(t,e)};var Ns=i=>i instanceof Promise||!!(i&&typeof i=="object"&&"then"in i&&typeof i.then=="function");var Dr=i=>i,Hl=[Dr({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:i,enableVideoRecording:e})=>{if(e===null)return i;let t=q(i);return e&&!t.includes("video")?t=t.concat("video"):e||(t=t.filter(r=>r!=="video")),me(t)}}),Dr({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:i,defaultCameraMode:e})=>{if(e===null)return i;let t=q(i);return t=t.sort((r,o)=>r===e?-1:o===e?1:0),me(t)}}),Dr({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:i,cdnCname:e,cdnCnamePrefixed:t})=>i&&(e===ct||$r(e,t))?Vs(i,t):e})],Bs=({key:i,setValue:e,getValue:t,computationControllers:r})=>{for(let o of Hl)if(o.deps.includes(i)){let s={[o.key]:t(o.key)};for(let l of o.deps)s[l]=t(l);let n=new AbortController;r.get(o.key)?.abort(),r.set(o.key,n);let a;try{a=o.fn(s,{signal:n.signal})}catch(l){r.get(o.key)===n&&r.delete(o.key),console.error(`Failed to compute value for "${o.key}"`,l);return}Ns(a)?a.then(l=>{n.signal.aborted||e(o.key,l)}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${o.key}"`,l)}).finally(()=>{r.get(o.key)===n&&r.delete(o.key)}):e(o.key,a)}};var R=i=>String(i),z=i=>{let e=Number(i);if(Number.isNaN(e))throw new Error(`Invalid number: "${i}"`);return e},I=i=>{if(typeof i>"u"||i===null)return!1;if(typeof i=="boolean")return i;if(i==="true"||i==="")return!0;if(i==="false")return!1;throw new Error(`Invalid boolean: "${i}"`)},zs=i=>i==="auto"?i:I(i),Hs=i=>{let e=R(i);if(e!=="user"&&e!=="environment"&&e!=="")throw new Error(`Invalid value: "${e}"`);return e},js=i=>{let e=R(i);if(!Object.values(_).includes(e))throw new Error(`Invalid value: "${e}"`);return e},Ks=i=>{let e=R(i),t=q(e);if(t.some(r=>!Object.values(_).includes(r)))throw new Error(`Invalid value: "${JSON.stringify(t)}"`);return e},Gs=i=>{if(typeof i=="object"&&!Array.isArray(i)||typeof i=="function")return i;throw new Error("Invalid metadata value. Must be an object or function.")},Fr=i=>{if(typeof i=="object")return i;throw new Error("Invalid value. Must be an object.")},wi=i=>{if(typeof i=="function")return i;throw new Error("Invalid value. Must be a function.")},Vr=i=>{if(Array.isArray(i))return i;throw new Error("Must be an array.")},Ws=i=>{let e=R(i);if(["grid","list"].includes(e))return e;throw new Error(`Invalid value: "${e}"`)};var jl={pubkey:R,multiple:I,multipleMin:z,multipleMax:z,confirmUpload:I,imgOnly:I,accept:R,externalSourcesPreferredTypes:R,externalSourcesEmbedCss:R,store:zs,cameraMirror:I,cameraCapture:Hs,sourceList:R,topLevelOrigin:R,maxLocalFileSizeBytes:z,thumbSize:z,showEmptyList:I,useLocalImageEditor:I,useCloudImageEditor:I,cloudImageEditorTabs:R,removeCopyright:I,cropPreset:R,imageShrink:R,modalScrollLock:I,modalBackdropStrokes:I,sourceListWrap:I,remoteTabSessionKey:R,cdnCname:R,cdnCnamePrefixed:R,baseUrl:R,socialBaseUrl:R,secureSignature:R,secureExpire:R,secureDeliveryProxy:R,retryThrottledRequestMaxTimes:z,retryNetworkErrorMaxTimes:z,multipartMinFileSize:z,multipartChunkSize:z,maxConcurrentRequests:z,multipartMaxConcurrentRequests:z,multipartMaxAttempts:z,checkForUrlDuplicates:I,saveUrlForRecurrentUploads:I,groupOutput:I,userAgentIntegration:R,debug:I,localeName:R,metadata:Gs,secureUploadsExpireThreshold:z,localeDefinitionOverride:i=>Fr(i),secureUploadsSignatureResolver:i=>wi(i),secureDeliveryProxyUrlResolver:i=>wi(i),iconHrefResolver:i=>wi(i),fileValidators:Vr,collectionValidators:Vr,validationTimeout:z,validationConcurrency:z,cameraModes:Ks,defaultCameraMode:js,enableAudioRecording:I,enableVideoRecording:I,mediaRecorderOptions:Fr,maxVideoRecordingDuration:z,filesViewMode:Ws,gridShowFileNames:I,cloudImageEditorAutoOpen:I,cloudImageEditorMaskHref:R,testMode:I,qualityInsights:I},qs=(i,e)=>{if(!(typeof e>"u"||e===null))try{return jl[i](e)}catch(t){return console.error(`Invalid value for config key "${i}".`,t),Y[i]}};var Ci=[...new Set(["debug",...Object.keys(Y)])],Kl=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],Zs=i=>Kl.includes(i),xt=Ci.filter(i=>!Zs(i)),Gl={...Object.fromEntries(xt.map(i=>[Tt(i),i])),...Object.fromEntries(xt.map(i=>[i.toLowerCase(),i]))},Wl={...Object.fromEntries(xt.map(i=>[Tt(i),B(i)])),...Object.fromEntries(xt.map(i=>[i.toLowerCase(),B(i)]))},Xs=i=>`__${i}`,At=class extends y{requireCtxName=!0;constructor(){super(),this.init$={...this.init$,...Object.fromEntries(Object.entries(Y).map(([e,t])=>[B(e),t])),computationControllers:new Map}}_flushValueToAttribute(e,t){if(!Zs(e)){let r=[...new Set([Tt(e),e.toLowerCase()])];for(let o of r)typeof t>"u"||t===null?this.removeAttribute(o):this.getAttribute(o)!==t.toString()&&this.setAttribute(o,t.toString())}}_flushValueToState(e,t){this.$[B(e)]!==t&&(typeof t>"u"||t===null?this.$[B(e)]=Y[e]:this.$[B(e)]=t)}_setValue(e,t){let r=this,o=qs(e,t),s=Xs(e);r[s]!==o&&(this._assertSameValueDifferentReference(e,r[s],o),r[s]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),$s(this.cfg))}_getValue(e){let t=this,r=Xs(e);return t[r]??this.$[B(e)]}_assertSameValueDifferentReference(e,t,r){this.cfg.debug&&r!==t&&typeof r=="object"&&typeof t=="object"&&JSON.stringify(r)===JSON.stringify(t)&&(console.warn(`[uc-config] Option "${e}" 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] "${e}" previous value:`,t),console.warn(`[uc-config] "${e}" new value:`,r))}initCallback(){super.initCallback();let e=this;for(let t of xt)this.sub(B(t),r=>{this._setValue(t,r)},!1);for(let t of Ci){let r=e[t]??this.$[B(t)];r!==Y[t]&&this._setValue(t,r),Object.defineProperty(this,t,{set:o=>{this._setValue(t,o)},get:()=>this._getValue(t)})}for(let t of Ci)this.sub(B(t),()=>{Bs({key:t,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this.computationControllers})})}attributeChangedCallback(e,t,r){if(t===r)return;let o=this,s=Gl[e];s&&(o[s]=r)}get computationControllers(){return this.$.computationControllers}};At.bindAttributes(Wl);for(let i of Ci)At.prototype[i]=void 0;var Nr=class extends y{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",e=>{this.toggleAttribute("hidden",!!e)})}static template=`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`};function ql(i){return new Promise(e=>{typeof window.FileReader!="function"&&e(!1);try{let t=new FileReader;t.onerror=()=>{e(!0)};let r=o=>{o.type!=="loadend"&&t.abort(),e(!1)};t.onloadend=r,t.onprogress=r,t.readAsDataURL(i)}catch{e(!1)}})}function Xl(i,e){return new Promise(t=>{let r=0,o=[],s=a=>{if(!a){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),t(null);return}a.isFile?(r++,a.file(l=>{r--;let c=new File([l],l.name,{type:l.type||e});o.push({type:"file",file:c,fullPath:a.fullPath}),r===0&&t(o)})):a.isDirectory&&n(a.createReader())},n=a=>{r++,a.readEntries(l=>{r--;for(let c of l)s(c);r===0&&t(o)})};s(i)})}function Ys(i){let e=[],t=[];for(let r=0;r<i.items.length;r++){let o=i.items[r];if(o)if(o.kind==="file"){let s=o.type,n=o;if(typeof n.webkitGetAsEntry=="function"||typeof n.getAsEntry=="function"){let l=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():n.getAsEntry?.();l&&t.push(Xl(l,s).then(c=>{c&&e.push(...c)}));continue}let a=o.getAsFile();a&&t.push(ql(a).then(l=>{l||e.push({type:"file",file:a})}))}else o.kind==="string"&&/^text\/uri-list/.test(o.type)&&t.push(new Promise(s=>{o.getAsString(n=>{e.push({type:"url",url:n}),s()})}))}return Promise.all(t).then(()=>e)}var G=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),Qs=["focus"],Zl=100,Br=new Map;function Yl(i,e){let t=Math.max(Math.min(i[0],e.x+e.width),e.x),r=Math.max(Math.min(i[1],e.y+e.height),e.y);return Math.sqrt((i[0]-t)*(i[0]-t)+(i[1]-r)*(i[1]-r))}function zr(i){let e=0,t=document.body,r=new Set,o=h=>{r.add(h)},s=G.INACTIVE,n=h=>{i.shouldIgnore()&&h!==G.INACTIVE||(s!==h&&r.forEach(g=>{g(h)}),s=h)},a=()=>e>0;o(h=>i.onChange(h));let l=()=>{e=0,n(G.INACTIVE)},c=()=>{e+=1,s===G.INACTIVE&&n(G.ACTIVE)},d=()=>{e-=1,a()||n(G.INACTIVE)},u=h=>{h.preventDefault(),e=0,n(G.INACTIVE)},p=h=>{if(i.shouldIgnore())return;a()||(e+=1);let g=[h.x,h.y],v=i.element.getBoundingClientRect(),A=Math.floor(Yl(g,v)),C=A<Zl,x=h.composedPath().includes(i.element);Br.set(i.element,A);let J=Math.min(...Br.values())===A;x&&J?(h.preventDefault(),n(G.OVER)):n(C&&J?G.NEAR:G.ACTIVE)},m=async h=>{if(i.shouldIgnore())return;h.preventDefault();let{dataTransfer:g}=h;if(!g)return;let v=await Ys(g);i.onItems(v),n(G.INACTIVE)};return t.addEventListener("drop",u),t.addEventListener("dragleave",d),t.addEventListener("dragenter",c),t.addEventListener("dragover",p),i.element.addEventListener("drop",m),Qs.forEach(h=>{window.addEventListener(h,l)}),()=>{Br.delete(i.element),t.removeEventListener("drop",u),t.removeEventListener("dragleave",d),t.removeEventListener("dragenter",c),t.removeEventListener("dragover",p),i.element.removeEventListener("drop",m),Qs.forEach(h=>{window.removeEventListener(h,l)})}}var Js="uc-drop-area",Ei=`${Js}/registry`,St=class extends O{static styleAttrs=[...super.styleAttrs,"uc-drop-area"];_destroyDropzone=null;_destroyContentWrapperDropzone=null;_onAreaClicked=null;constructor(){super(),this.init$={...this.init$,state:G.INACTIVE,withIcon:!1,isClickable:!1,isFullscreen:!1,isEnabled:!0,isVisible:!0,isInitFlow:!1,text:"",[Ei]:new Set}}isActive(){if(!this.$.isEnabled)return!1;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),o=window.getComputedStyle(this),s=o.visibility!=="hidden"&&o.display!=="none";return t&&s&&r}initCallback(){super.initCallback(),this.bindL10n("text",()=>this.l10n("drop-files-here")),this.$[Ei].add(this),this.defineAccessor("disabled",r=>{this.set$({isEnabled:!I(r)})}),this.defineAccessor("clickable",r=>{this.set$({isClickable:I(r)})}),this.defineAccessor("initflow",r=>{this.set$({isInitFlow:I(r)})}),this.defineAccessor("with-icon",r=>{this.set$({withIcon:I(r)})}),this.defineAccessor("fullscreen",r=>{this.set$({isFullscreen:I(r)})}),this.defineAccessor("text",r=>{typeof r=="string"?this.bindL10n("text",()=>this.l10n(r)||r):this.bindL10n("text",()=>this.l10n("drop-files-here"))}),this._destroyDropzone=zr({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:r=>{this.$.state=r},onItems:r=>{r.length&&(r.forEach(o=>{o.type==="url"?this.api.addFileFromUrl(o.url,{source:P.DROP_AREA}):o.type==="file"&&this.api.addFileFromObject(o.file,{source:P.DROP_AREA,fullPath:o.fullPath})}),this.uploadCollection.size&&(this.modalManager?.open(f.activities.UPLOAD_LIST),this.set$({"*currentActivity":f.activities.UPLOAD_LIST})))}});let t=this.ref["content-wrapper"];if(t&&(this._destroyContentWrapperDropzone=zr({element:t,onChange:r=>{let o=Object.entries(G).find(([,s])=>s===r)?.[0].toLowerCase();o&&t.setAttribute("drag-state",o)},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()})),this.sub("state",r=>{let o=Object.entries(G).find(([,s])=>s===r)?.[0].toLowerCase();o&&this.setAttribute("drag-state",o)}),this.subConfigValue("sourceList",r=>{let o=$(r);this.$.isEnabled=o.includes(P.LOCAL),this.$.isVisible=this.$.isEnabled||!this.querySelector("[data-default-slot]")}),this.sub("isVisible",r=>{this.toggleAttribute("hidden",!r)}),this.sub("isClickable",r=>{this.toggleAttribute("clickable",r)}),this.$.isClickable){let r=o=>{if(o instanceof KeyboardEvent){if(o.code==="Space"||o.code==="Enter"){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}}else if(o instanceof MouseEvent){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}};this._onAreaClicked=r,this.addEventListener("keydown",r),this.addEventListener("click",r)}}_shouldIgnore(){if(!this.$.isEnabled||!this._couldHandleFiles())return!0;if(!this.$.isFullscreen)return!1;let e=this.$[Ei];return e.size===0?!1:[...e].filter(o=>o!==this).filter(o=>o.isActive()).length>0}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,r=this.uploadCollection.size;return!(e&&t&&r>=t||!e&&r>0)}destroyCallback(){super.destroyCallback();let e=this.$[Ei];e.delete(this),e.size===0&&E.deleteCtx(Js),this._destroyDropzone?.(),this._destroyContentWrapperDropzone?.(),this._onAreaClicked&&(this.removeEventListener("keydown",this._onAreaClicked),this.removeEventListener("click",this._onAreaClicked),this._onAreaClicked=null)}};St.template=`<slot><div data-default-slot hidden></div><div ref="content-wrapper" class="uc-content-wrapper" set="@hidden: !isVisible"><div class="uc-icon-container" set="@hidden: !withIcon"><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">{{text}}</span></div></slot>`;St.bindAttributes({"with-icon":null,clickable:null,text:null,fullscreen:null,disabled:null,initflow:null});var en=()=>{let i=globalThis.top??globalThis.parent??globalThis.self;try{return i.location.origin}catch(e){return console.warn("Unable to access top-level window location:",e),globalThis.location.origin}};var Ql=i=>i.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),tn=(i,e="i")=>{let t=i.split("*").map(Ql);return new RegExp(`^${t.join(".+")}$`,e)};var Jl=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],ec=(i,e)=>window.getComputedStyle(i).getPropertyValue(e).trim(),rn=i=>{let e={};for(let t of Jl){let r=ec(i,t);r&&(e[t]=r)}return e};var tc=["selected-files-change","toolbar-state-change"],ic=i=>{if(!i||typeof i!="object"||!("type"in i))return!1;let e=i.type;return!(typeof e!="string"||!tc.includes(e))},Ti=class{_handlerMap=new Map;_context;_getTargetOrigin;constructor(e,t){this._context=e,this._getTargetOrigin=t,window.addEventListener("message",this._handleMessage)}_handleMessage=e=>{if(e.source!==this._context)return;let t=e.data;if(!ic(t))return;let r=this._handlerMap.get(t.type);if(r)for(let o of r)o(t)};on(e,t){let r=this._handlerMap.get(e)??new Set;this._handlerMap.has(e)||this._handlerMap.set(e,r),r.add(t)}send(e){let t=this._getTargetOrigin();this._context.postMessage(e,t)}destroy(){window.removeEventListener("message",this._handleMessage)}};function on(i){let e=[];for(let[t,r]of Object.entries(i))r==null||typeof r=="string"&&r.length===0||e.push(`${t}=${encodeURIComponent(r)}`);return e.join("&")}var rc={[le.GDRIVE]:"ngdrive"},xi=class extends O{couldBeCtxOwner=!0;activityType=f.activities.EXTERNAL;_messageBridge;constructor(){super(),this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],total:0,isSelectionReady:!1,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1,showDoneBtn:!1,counterText:"",doneBtnTextClass:"uc-hidden",toolbarVisible:!0,onDone:()=>{for(let e of this.$.selectedList){let t=this.extractUrlFromSelectedFile(e),{filename:r}=e,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(t,{fileName:r,source:o})}this.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.modalManager?.open(f.activities.UPLOAD_LIST)},onCancel:()=>{this.historyBack()},onSelectAll:()=>{this._messageBridge?.send({type:"select-all"})},onDeselectAll:()=>{this._messageBridge?.send({type:"deselect-all"})}}}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:e}=this.activityParams;if(!e){this.modalManager?.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.set$({activityCaption:`${e[0]?.toUpperCase()}${e?.slice(1)}`,activityIcon:e}),this.mountIframe()}}),this.sub("*currentActivityParams",e=>{this.isActivityActive&&(this.unmountIframe(),this.mountIframe())}),this.sub("*currentActivity",e=>{e!==this.activityType&&this.unmountIframe()}),this.subConfigValue("multiple",e=>{this.$.showSelectionStatus=e}),this.subConfigValue("localeName",e=>{this.setupL10n()}),this.subConfigValue("externalSourcesEmbedCss",e=>{this.applyEmbedCss(e)})}extractUrlFromSelectedFile(e){if(e.alternatives){let t=$(this.cfg.externalSourcesPreferredTypes);for(let r of t){let o=tn(r);for(let[s,n]of Object.entries(e.alternatives))if(o.test(s))return n}}return e.url}handleToolbarStateChange(e){this.set$({toolbarVisible:e.isVisible})}async handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this.bindL10n("counterText",()=>this.l10n("selected-count",{count:e.selectedCount,total:e.total})),this.set$({doneBtnTextClass:e.isReady?"":"uc-hidden",isSelectionReady:e.isReady,isDoneBtnEnabled:e.isReady&&e.selectedFiles.length>0,showSelectionStatus:e.isMultipleMode&&e.total>0,couldSelectAll:e.selectedCount<e.total,couldDeselectAll:e.selectedCount===e.total,selectedList:e.selectedFiles,showDoneBtn:e.total>0})}handleIframeLoad(){this.applyEmbedCss(this.cfg.externalSourcesEmbedCss),this.applyTheme(),this.setupL10n()}applyTheme(){this._messageBridge?.send({type:"set-theme-definition",theme:rn(this)})}applyEmbedCss(e){this._messageBridge?.send({type:"set-embed-css",css:e})}setupL10n(){this._messageBridge?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:r,multiple:o}=this.cfg,{externalSourceType:s}=this.activityParams,n=rc[s]??s,l={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:!0,multiple:o.toString(),origin:this.cfg.topLevelOrigin||en(),debug:this.cfg.debug},c=new URL(`/window4/${n}`,r);return c.search=on(l),c.toString()}mountIframe(){let e=Wi({tag:"iframe",attributes:{src:this.remoteUrl(),marginheight:0,marginwidth:0,frameborder:0,allowTransparency:!0}});e.addEventListener("load",this.handleIframeLoad.bind(this)),this.ref.iframeWrapper.innerHTML="",this.ref.iframeWrapper.appendChild(e),e.contentWindow&&(this._messageBridge?.destroy(),this._messageBridge=new Ti(e.contentWindow,()=>this.cfg.socialBaseUrl),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this.handleToolbarStateChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){this._messageBridge?.destroy(),this._messageBridge=void 0,this.ref.iframeWrapper.innerHTML="",this.resetSelectionStatus()}resetSelectionStatus(){this.set$({selectedList:[],total:0,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1,showDoneBtn:!1})}};xi.template=`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *historyBack" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ref="iframeWrapper" class="uc-iframe-wrapper"></div><div class="uc-toolbar" set="@hidden: !toolbarVisible"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel" l10n="cancel"></button><div set="@hidden: !showSelectionStatus" class="uc-selection-status-box"><span>{{counterText}}</span><button type="button" set="onclick: onSelectAll; @hidden: !couldSelectAll" l10n="select-all"></button><button type="button" set="onclick: onDeselectAll; @hidden: !couldDeselectAll" l10n="deselect-all"></button></div><button type="button" class="uc-done-btn uc-primary-btn" set="onclick: onDone; @disabled: !isDoneBtnEnabled; @hidden: !showDoneBtn" ><uc-spinner set="@hidden: isSelectionReady"></uc-spinner><span l10n="done" set="@class: doneBtnTextClass"></span></button></div></div>`;var Si=()=>{let i=[];return{stack:i,promiseReadJpegChunks:t=>new Promise((r,o)=>{let s=2,n=(c,d)=>{let u=new FileReader;u.addEventListener("load",()=>{d(new DataView(u.result))}),u.addEventListener("error",p=>{o(`Reader error: ${p}`)}),u.readAsArrayBuffer(c)},a=()=>n(t.slice(s,s+128),c=>{let d,u,p;for(d=u=0,p=c.byteLength;p>=0?u<p:u>p;d=p>=0?++u:--u)if(c.getUint8(d)===255){s+=d;break}l()}),l=()=>{let c=s;return n(t.slice(s,s+=4),d=>{if(d.byteLength!==4||d.getUint8(0)!==255){o("Corrupted");return}let u=d.getUint8(1);if(u===218){r(!0);return}let p=d.getUint16(2)-2;return n(t.slice(s,s+=p),m=>{if(m.byteLength!==p){o("Corrupted");return}i.push({startPos:c,length:p,marker:u,view:m}),a()})})};FileReader&&DataView||o("Not Support"),n(t.slice(0,2),c=>{c.getUint16(0)!==65496&&o("Not jpeg"),a()})})}},oc=async i=>{let e=[],{promiseReadJpegChunks:t,stack:r}=Si();return await t(i),r.forEach(({marker:o,view:s})=>{o===226&&s.getUint32(0)===1229144927&&s.getUint32(4)===1347571526&&s.getUint32(8)===1229735168&&e.push(s)}),e},nn=async(i,e,t)=>{{let r=[],o=[],{promiseReadJpegChunks:s,stack:n}=Si();await s(i),n.forEach(c=>{if(c.marker===e)return r.push(c.startPos),o.push(c.length)});let a=[i.slice(0,2)];for(let c of t){let d=new DataView(new ArrayBuffer(4));d.setUint16(0,65280+e),d.setUint16(2,c.byteLength+2),a.push(d.buffer),a.push(c)}let l=2;for(let c=0;c<r.length;c++)r[c]>l&&a.push(i.slice(l,r[c])),l=r[c]+o[c]+4;return a.push(i.slice(l,i.size)),new Blob(a,{type:i.type})}};var an=(i,e)=>nn(i,226,e.map(t=>t.buffer)),sc=async i=>{try{return await an(i,[])}catch(e){throw new Error(`Failed to strip ICC profile: ${e}`)}},nc=(i,e,t)=>new Promise((r,o)=>{let s=n=>{if(!n){o("Failed to convert canvas to blob");return}r(n)};i.toBlob(s,e,t),i.width=i.height=1}),It=()=>{let i=document.createElement("canvas"),e=i.getContext("2d");return{canvas:i,ctx:e}},ac=i=>{let{ctx:t,canvas:r}=It();r.width=r.height=50,t.drawImage(i,0,0,50,50);let o=t.getImageData(0,0,50,50).data;r.width=r.height=1;for(let s=3;s<o.length;s+=4)if(o[s]<254)return!0;return!1},lc=async i=>{let e=null,{promiseReadJpegChunks:t,stack:r}=Si();return await t(i),r.forEach(({marker:o,view:s})=>{if(!e&&o===225&&s.byteLength>=14&&s.getUint32(0)===1165519206&&s.getUint16(4)===0){e=s;return}}),e},cc="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",Ai,dc=()=>new Promise(i=>{if(Ai!==void 0)i(Ai);else{let e=new Image;e.addEventListener("load",()=>{Ai=e.naturalWidth<e.naturalHeight,e.src="//:0",i(Ai)}),e.src=cc}}),uc=(i,e)=>{let t,r,o,s;if(!i||i.byteLength<14||i.getUint32(0)!==1165519206||i.getUint16(4)!==0)return;if(i.getUint16(6)===18761)r=!0;else if(i.getUint16(6)===19789)r=!1;else return;if(i.getUint16(8,r)!==42)return;o=8+i.getUint32(10,r);let n=i.getUint16(o-2,r);for(t=0,s=n;s>=0?t<s:t>s;s>=0?++t:--t){if(i.byteLength<o+10)return;i.getUint16(o,r)===274&&e(o+8,r),o+=12}},pc=(i,e)=>{uc(i,(t,r)=>i.setUint16(t,e,r))},hc=async(i,e,t)=>(t&&pc(e,1),nn(i,225,[e.buffer])),mc=(i,e)=>new Promise((t,r)=>{e&&(i.src=e),i.complete?t(i):(i.addEventListener("load",()=>{t(i)}),i.addEventListener("error",()=>{r(new Error("Failed to load image. Probably not an image."))}))}),fc=i=>mc(new Image,i),gc=[1,3],vc=[192,193,194,195,197,198,199,201,202,203,205,206,207],sn={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},yc=async i=>{let e=!1,{promiseReadJpegChunks:t,stack:r}=Si();return await t(i).then(()=>(r.forEach(({marker:o,view:s})=>{if(!e&&vc.indexOf(o)>=0){let n=s.getUint8(5);gc.indexOf(n)<0&&(e=!0)}}),e)).catch(()=>e)},ln=(i,e)=>{let t={};return(...r)=>{let o=e(r,t);return o in t?t[o]:t[o]=i(...r)}},cn=(i,e)=>{let[t]=i,r=Object.keys(e).map(o=>parseInt(o,10)).sort((o,s)=>o-s);for(let o=0;o<r.length;o++){let s=r[o],n=!!e[s];if(s>t&&n||s<t&&!n)return s}return t},Pe={R:55,G:110,B:165,A:255},bc=`rgba(${Pe.R}, ${Pe.G}, ${Pe.B}, ${Pe.A/255})`,dn=(i,e)=>{try{let t=[i-1,e-1,1,1],{canvas:r,ctx:o}=It();r.width=1,r.height=1;let{canvas:s,ctx:n}=It();s.width=i,s.height=e,n&&(n.fillStyle=bc,n.fillRect(...t),o.drawImage(s,i-1,e-1,1,1,0,0,1,1));let a=o&&o.getImageData(0,0,1,1).data,l=!1;return a&&(l=a[0]===Pe.R&&a[1]===Pe.G&&a[2]===Pe.B&&a[3]===Pe.A),s.width=s.height=1,l}catch{return console.error(`Failed to test for max canvas size of ${i}x${e}.`),!1}};function un(i){return(...e)=>new Promise(t=>{setTimeout(()=>{let r=i(...e);t(r)},0)})}var _c=un(ln(dn,cn)),wc=un(ln(dn,cn)),pn=async(i,e)=>{let t=sn.squareSide.find(n=>n*n>=i*e),r=sn.dimension.find(n=>n>=i&&n>=e);if(!t||!r)throw new Error("Not supported");let[o,s]=await Promise.all([_c(t,t),wc(r,1)]);if(o&&s)return!0;throw new Error("Not supported")},hn=async(i,e,t)=>{try{let{ctx:r,canvas:o}=It();return o.width=e,o.height=t,r.imageSmoothingQuality="high",r.drawImage(i,0,0,e,t),i instanceof HTMLImageElement&&(i.src="//:0"),i instanceof HTMLCanvasElement&&(i.width=i.height=1),o}catch(r){throw new Error("Canvas resize error",{cause:r})}},Cc=({img:i,targetW:e,targetH:t})=>hn(i,e,t),Ec=function({sourceW:i,targetW:e,targetH:t,step:r}){let o=[],s=e,n=t;do o.push([s,n]),s=Math.round(s/r),n=Math.round(n/r);while(s<i*r);return o.reverse()},Tc=({img:i,sourceW:e,targetW:t,targetH:r,step:o})=>{let s=Ec({sourceW:e,targetW:t,targetH:r,step:o});return s.reduce((n,[a,l],c)=>n.then(d=>pn(a,l).then(()=>hn(d,a,l)).catch(()=>{if(c===s.length-1)throw new Error("Not supported");return d})),Promise.resolve(i))},xc=()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Ac=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Hr=.71,Sc=(i,e)=>{if(i.width*Hr*i.height*Hr<e.size)throw new Error("Not required");let t=i.width,r=i.height,o=t/r,s=Math.floor(Math.sqrt(e.size*o)),n=Math.floor(e.size/Math.sqrt(e.size*o));return pn(s,n).then(()=>{let{ctx:a}=It();return"imageSmoothingQuality"in a&&!xc()&&!Ac?Cc({img:i,targetW:s,targetH:n}):Tc({img:i,sourceW:t,targetW:s,targetH:n,step:Hr})}).catch(()=>Promise.reject("Not supported"))},mn=async(i,e)=>{try{if(await yc(i))throw new Error("Should skipped");let r=await Promise.allSettled([lc(i),dc(),oc(i)]),s=!r.some(g=>g.status==="rejected"),[n,a,l]=r,c=await sc(i).catch(()=>i),d=await fc(URL.createObjectURL(c));URL.revokeObjectURL(d.src);let u=await Sc(d,e),p="image/jpeg",m=e?.quality||.8;!s&&ac(u)&&(p="image/png",m=void 0);let h=await nc(u,p,m);if(s&&n.status==="fulfilled"&&n.value){let g=n.value,v=a.status==="fulfilled"?a.value:!1;h=await hc(h,g,v)}return s&&l.status==="fulfilled"&&l.value.length>0&&(h=await an(h,l.value)),h}catch(t){let r;throw t instanceof Error&&(r=t.message),typeof t=="string"&&(r=t),new Error(`Failed to shrink image. ${r?`Message: "${r}".`:""}`,{cause:t})}};var Ic=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,fn=i=>{if(typeof i!="string")return!1;let e=Ic.exec(i.toLocaleLowerCase())??[];if(e.length===0)return!1;let t=Number(e[1])*Number(e[2]),r=16384*16384;return t>r?(console.warn(`Shrinked size can not be larger than ${Math.floor(r/1e3/1e3)}MP. You have set ${e[1]}x${e[2]} (${Math.ceil(t/1e3/100)/10}MP).`),!1):{quality:e[3]?Number(e[3])/100:void 0,size:t}};var ot=class extends O{_entrySubs=new Set;_entry=null;_withEntry(e){return(...t)=>{let r=this._entry;if(!r){console.warn("No entry found");return}return e(r,...t)}}_subEntry(e,t){this._withEntry((r,o,s)=>{let n=r.subscribe(o,a=>{this.isConnected&&s(a)});this._entrySubs.add(n)})(e,t)}_reset(){for(let e of this._entrySubs)e.remove();this._entrySubs=new Set,this._entry=null}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set}};var F=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),jr=class i extends ot{couldBeCtxOwner=!0;pauseRender=!0;_renderedOnce=!1;_observer;_isIntersecting=!1;_thumbRect;constructor(){super(),this.init$={...this.init$,uid:"",itemName:"",errorText:"",hint:"",thumbUrl:"",progressValue:0,progressVisible:!1,badgeIcon:"",isFinished:!1,isFailed:!1,isUploading:!1,isFocused:!1,isEditable:!1,showFileNames:!1,state:F.IDLE,ariaLabelStatusFile:"",onEdit:this._withEntry(e=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"edit-file",node:this.tagName}}}),this.$["*currentActivityParams"]={internalId:e.uid},this.modalManager?.open(f.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=f.activities.CLOUD_IMG_EDIT}),onRemove:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uploadCollection.remove(this.$.uid)},onUpload:()=>{this.upload()}}}_calculateState=this._withEntry(e=>{let t=F.IDLE;e.getValue("errors").length>0?t=F.FAILED:e.getValue("isQueuedForUploading")?t=F.QUEUED_UPLOADING:e.getValue("isQueuedForValidation")?t=F.QUEUED_VALIDATION:e.getValue("isValidationPending")?t=F.VALIDATION:e.getValue("isUploading")?t=F.UPLOADING:e.getValue("fileInfo")&&(t=F.FINISHED),this.$.state=t});_debouncedCalculateState=M(this._calculateState.bind(this),100);_updateHintAndProgress=this._withEntry(tt((e,t)=>{let r=e.getValue("errors")?.[0]?.message,o=e.getValue("source"),s=e.getValue("externalUrl"),n=t===F.FINISHED,a=t===F.UPLOADING,l=t===F.QUEUED_UPLOADING,c=t===F.QUEUED_VALIDATION,d=t===F.VALIDATION,u=e.getValue("fileName"),p="";r?p="":!n&&s&&o&&Object.values(le).includes(o)&&(p=this.l10n("waiting-for",{source:this.l10n(`src-type-${o}`)})),this.set$({hint:p,errorText:r,progressVisible:a||l||c||d,progressValue:c||d?0:e.getValue("uploadProgress"),ariaLabelStatusFile:u&&this.l10n("a11y-file-item-status",{fileName:u,status:this.l10n(t?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()})})},100));_handleState=this._withEntry((e,t)=>{t===F.FAILED?this.$.badgeIcon="badge-error":t===F.FINISHED&&(this.$.badgeIcon="badge-success"),t===F.UPLOADING&&(this.$.isFocused=!1),this.set$({isFailed:t===F.FAILED,isUploading:t===F.UPLOADING,isFinished:t===F.FINISHED,isEditable:this.cfg.useCloudImageEditor&&e.getValue("isImage")&&e.getValue("cdnUrl")}),this._updateHintAndProgress(t)});_reset(){super._reset(),this._debouncedCalculateState.cancel()}_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,this._thumbRect=t.boundingClientRect,t.isIntersecting&&!this._renderedOnce&&(this.render(),this._renderedOnce=!0))}_handleEntryId(e){this._reset();let t=this.uploadCollection?.read(e);this._entry=t,t&&(this._subEntry("isQueuedForValidation",()=>{this._debouncedCalculateState()}),this._subEntry("isValidationPending",()=>{this._debouncedCalculateState()}),this._subEntry("uploadProgress",()=>{this._debouncedCalculateState()}),this._subEntry("isQueuedForUploading",()=>{this._debouncedCalculateState()}),this._subEntry("fileName",r=>{this.$.itemName=r||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",r=>{this.$.itemName=t.getValue("fileName")||r||this.l10n("file-no-name")}),this._subEntry("fileInfo",()=>{this._debouncedCalculateState()}),this._subEntry("errors",()=>this._debouncedCalculateState()),this._subEntry("isUploading",()=>this._debouncedCalculateState()),this._subEntry("fileSize",()=>this._debouncedCalculateState()),this._subEntry("mimeType",()=>this._debouncedCalculateState()),this._subEntry("isImage",()=>this._debouncedCalculateState()))}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this.$.showFileNames=!0;return}this.$.showFileNames=e}initCallback(){super.initCallback(),this.sub("uid",e=>{this._handleEntryId(e)}),this.sub("state",e=>{this._handleState(e)}),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.subConfigValue("filesViewMode",e=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",e)}),this.subConfigValue("gridShowFileNames",e=>{this._updateShowFileNames(e)}),this.onclick=()=>{i.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{this._entry&&!e.has(this._entry.uid)||setTimeout(()=>this.isConnected&&this.upload())}),i.activeInstances.add(this)}destroyCallback(){super.destroyCallback(),i.activeInstances.delete(this),this._reset()}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect()}_settingsOfShrink(){return fn(this.cfg.imageShrink)}async _processShrink(e){let t=this._settingsOfShrink();return t?await mn(e,t):(console.warn("Image shrink settings are invalid, skipping shrinking"),e)}upload=this._withEntry(async e=>{if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0||e.getValue("isValidationPending"))return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){e.setMultipleValues({isUploading:!0,errors:[],isQueuedForUploading:!0}),this._debouncedCalculateState();try{let r=new AbortController;e.setValue("abortController",r);let o=async()=>{e.setValue("isQueuedForUploading",!1);let n=e.getValue("file");if(n instanceof File&&this.cfg.imageShrink)try{n=await this._processShrink(n)}catch{}let a=n||e.getValue("externalUrl")||e.getValue("uuid");if(!a)throw new Error("No file input");let c={...await this.getUploadClientOptions(),fileName:e.getValue("fileName")??void 0,source:e.getValue("source")??void 0,onProgress:d=>{if(d.isComputable){let u=d.value*100;e.setValue("uploadProgress",u)}},signal:r.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",a,c),lr(a,c)},s=await this.$["*uploadQueue"].add(o);e.setMultipleValues({fileInfo:s,isQueuedForUploading:!1,isUploading:!1,fileName:s.originalFilename,fileSize:s.size,isImage:s.isImage??!1,mimeType:s.contentInfo?.mime?.mime??s.mimeType,uuid:s.uuid,cdnUrl:e.getValue("cdnUrl")??s.cdnUrl,cdnUrlModifiers:e.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:e.getValue("source")??null}),e===this._entry&&this._debouncedCalculateState()}catch(r){this.telemetryManager.sendEventError(r,"file upload. Failed to upload file"),r instanceof Ae&&r.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):r instanceof $e?e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:r}):(console.error("Unknown upload error",r),e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:r})})),e===this._entry&&this._debouncedCalculateState()}}});static template=`<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused"><uc-thumb set="uid:uid;badgeIcon:badgeIcon"></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;"><span class="uc-file-name" set="@hidden: !showFileNames">{{itemName}}</span><span class="uc-file-error" set="@hidden: !errorText;">{{errorText}}</span><span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span></div><div class="uc-file-actions"><button type="button" l10n="@title:file-item-edit-button;@aria-label:file-item-edit-button" class="uc-edit-btn uc-mini-btn" set="onclick: onEdit; @hidden: !isEditable" ><uc-icon name="edit-file"></uc-icon></button><button type="button" l10n="@title:file-item-remove-button;@aria-label:file-item-remove-button" class="uc-remove-btn uc-mini-btn" set="onclick: onRemove;" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" set="onclick: onUpload;"><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" set="value: progressValue; visible: progressVisible; @hasFileName: showFileNames;" ></uc-progress-bar></div>`;static activeInstances=new Set};var Kr=class extends O{requireCtxName=!0;_validationInputElement=null;_dynamicInputsContainer=null;_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,at(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{{if(!this._dynamicInputsContainer){let s=document.createElement("div");this.appendChild(s),this._dynamicInputsContainer=s}if(!this._validationInputElement){let s=this._createValidationInput();this.appendChild(s),this._validationInputElement=s}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let s=e.errors[0]?.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(s??"");return}let t=e.group?e.group:null;if(t){this._validationInputElement.value=t.cdnUrl??"",this._validationInputElement.setCustomValidity("");return}let r=e.allEntries.map(s=>s.cdnUrl).filter(s=>typeof s=="string");if(!this.cfg.multiple&&r.length===1&&r[0]){this._validationInputElement.value=r[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let o=new DocumentFragment;for(let s of r){let n=document.createElement("input");n.type="hidden",n.name=`${this.ctxName}[]`,n.value=s,o.appendChild(n)}this._dynamicInputsContainer.replaceChildren(o)}},!1)}};var kt=class extends y{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",e=>{if(!e)return;let t=`#uc-icon-${e}`;this.subConfigValue("iconHrefResolver",r=>{r&&(t=r(e)??t),this.$.href=t})}),this.setAttribute("aria-hidden","true")}};kt.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;kt.bindAttributes({name:"name"});var gn=i=>[...new Set(i)];var st="--uc-img-",Gr="unresolved";var Wr=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),qr=3e3,Xr=5e3,Zr=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var kc="https://ucarecdn.com",Ot=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:kc},"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 vn=Object.create(null);for(let i in Ot)vn[st+i]=Ot[i]?.default||"";var Ii=class extends Ee{cssInit$=vn;$$(e){return this.$[st+e]}set$$(e){for(let t in e)this.$[st+t]=e[t]}sub$$(e,t){this.sub(st+e,r=>{r===null||r===""||t(r)})}analyticsParams(){return`-/@clib/${Oe}/${Me}/uc-img/`}initAttributes(e){[...this.attributes].forEach(t=>{Ot[t.name]||e.setAttribute(t.name,t.value)})}initIntersection(e,t){let r={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(s=>{s.isIntersecting&&(t(),this._isnObserver.unobserve(e))})},r),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e)}destroyCallback(){super.destroyCallback(),this._isnObserver&&(this._observed.forEach(e=>{this._isnObserver.unobserve(e)}),this._isnObserver=null),E.deleteCtx(this)}static get observedAttributes(){return Object.keys(Ot)}attributeChangedCallback(e,t,r){window.setTimeout(()=>{this.$[st+e]=r})}};var yn=i=>Object.entries(i).filter(([e,t])=>t!==void 0&&t!=="").map(([e,t])=>e==="cdn-operations"||e==="analytics"?t:`${e}/${t}`);var Mi=class extends Ii{_img=new Image;_imgPreview=new Image;_fmtAbs(e){return!e.includes("//")&&!Wr&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if(e?.trim()!==""){let t=e.match(/\d+/)[0],r=e.match(/[a-zA-Z]+/)[0],o=parseInt(t,10);if(Number(o)>Xr&&this.hasFormatJPG)return Xr+r;if(Number(o)>qr&&!this.hasFormatJPG)return qr+r}return e}_getCdnModifiers(e,t){let r={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return H(...yn(r))}_getUrlBase(e="",t=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(Wr&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let r=this._getCdnModifiers(e,t);if(this.$$("src").startsWith(this.$$("cdn-cname")))return U(this.$$("src"),r);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(U(Te(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("uuid"))return this._proxyUrl(U(Te(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("proxy-cname"))return this._proxyUrl(U(this.$$("proxy-cname"),r,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(U(`https://${this.$$("pubkey")}.ucr.io/`,r,this._fmtAbs(this.$$("src"))))}_proxyUrl(e){return this.$$("secure-delivery-proxy")?dt(this.$$("secure-delivery-proxy"),{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}_getElSize(e,t=1,r=!0){let o=e.getBoundingClientRect(),s=t*Math.round(o.width),n=r?"":t*Math.round(o.height);return s||n?`${s||""}x${n||""}`:null}_setupEventProxy(e){let t=o=>{o.stopPropagation();let s=new Event(o.type,o);this.dispatchEvent(s)},r=["load","error"];for(let o of r)e.addEventListener(o,t)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:Zr.PREVIEW,img:this._imgPreview}:{type:Zr.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){if(this.$$("breakpoints")){let e=$(this.$$("breakpoints"));return gn(e.map(t=>parseInt(t,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let r=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",r),e.style.setProperty("background-image","-webkit-"+r)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(t=>{e.add(this._getUrlBase(t+"x")+` ${this._validateSize(t+"w")}`),this.$$("hi-res-support")&&e.add(this._getUrlBase(t*2+"x")+` ${this._validateSize(t*2+"w")}`),this.$$("ultra-res-support")&&e.add(this._getUrlBase(t*3+"x")+` ${this._validateSize(t*3+"w")}`)}):(e.add(this._getUrlBase(this._getElSize(this.currentImg.img))+" 1x"),this.$$("hi-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,2))+" 2x"),this.$$("ultra-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,3))+" 3x")),[...e].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){[...document.querySelectorAll(this.bgSelector)].forEach(e=>{this.$$("intersection")?this.initIntersection(e,()=>{this.renderBg(e)}):this.renderBg(e)})}_appendURL({elNode:e,src:t,srcset:r}){t&&(e.src=t),r&&(e.srcset=r)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:t,elNode:r}){return new Promise((o,s)=>{this._setupConfigForImage({elNode:r}),r.setAttribute(Gr,""),r.addEventListener("load",()=>{r.removeAttribute(Gr),o(r)}),r.addEventListener("error",()=>{s(!1)}),this._appendURL({elNode:r,src:e,srcset:t})})}async renderImage(){if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{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 this._imgPreview?.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 this._imgPreview?.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var Yr=class extends Mi{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 Qr=null,Li=class extends y{static styleAttrs=[...super.styleAttrs,"uc-modal"];static StateConsumerScope="modal";_mouseDownTarget;handleModalOpen;handleModalClose;handleModalCloseAll;constructor(){super(),this.init$={...this.init$,closeClicked:this._handleDialogClose}}_handleBackdropClick=()=>{this._closeDialog()};_closeDialog=()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="")};_handleDialogClose=()=>{this._closeDialog()};_handleDialogMouseDown=e=>{this._mouseDownTarget=e.target};_handleDialogMouseUp=e=>{let t=e.target;t===this.ref.dialog&&t===this._mouseDownTarget&&this._closeDialog()};show(){let e=this.ref.dialog;typeof e.showModal=="function"?(this.setAttribute("aria-modal","true"),e.showModal()):e.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden")}hide(){let e=this.ref.dialog;typeof e.close=="function"?(this.setAttribute("aria-modal","false"),e.close()):e.removeAttribute("open")}_handleModalOpen({id:e}){e===this.id?(Qr=e,this.show(),this.emit(T.MODAL_OPEN,{modalId:e},{debounce:!0})):this.hide()}_handleModalClose({id:e}){e===this.id&&(this.hide(),this.emit(T.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0}))}_handleModalCloseAll(e){this.hide(),Qr===this.id&&this.emit(T.MODAL_CLOSE,{modalId:Qr,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0})}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this);let e=this.ref.dialog;e.addEventListener("close",this._handleDialogClose),e.addEventListener("mousedown",this._handleDialogMouseDown),e.addEventListener("mouseup",this._handleDialogMouseUp),this.subConfigValue("modalBackdropStrokes",t=>{t?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.handleModalCloseAll=this._handleModalCloseAll.bind(this),this.modalManager?.subscribe(D.OPEN,this.handleModalOpen),this.modalManager?.subscribe(D.CLOSE,this.handleModalClose),this.modalManager?.subscribe(D.CLOSE_ALL,this.handleModalCloseAll)}destroyCallback(){super.destroyCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0;let e=this.ref.dialog;e.removeEventListener("close",this._handleDialogClose),e.removeEventListener("mousedown",this._handleDialogMouseDown),e.removeEventListener("mouseup",this._handleDialogMouseUp),this.modalManager?.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(D.CLOSE,this.handleModalClose),this.modalManager?.unsubscribe(D.CLOSE_ALL,this.handleModalCloseAll)}};Li.template=`<dialog ref="dialog"><slot></slot></dialog>`;var Ri=class extends y{_value=0;_visible=!0;constructor(){super(),this.init$={...this.init$,width:0,opacity:0}}initCallback(){super.initCallback();let e=()=>{let t=this.ref.fakeProgressLine;if(!this._visible){t.classList.add("uc-fake-progress--hidden");return}this._value>0&&t.classList.add("uc-fake-progress--hidden")};this.ref.fakeProgressLine.addEventListener("animationiteration",e),this.defineAccessor("value",t=>{t!=null&&(this._value=t,this._visible&&this.style.setProperty("--l-progress-value",this._value.toString()))}),this.defineAccessor("visible",t=>{this._visible=t,this.classList.toggle("uc-progress-bar--hidden",!t)})}};Ri.template=`<div ref="fakeProgressLine" class="uc-fake-progress"></div><div ref="realProgressLine" class="uc-progress"></div>`;var Pi=class extends O{_unobserveCollectionCb;constructor(){super(),this.init$={...this.init$,visible:!1,value:0,"*commonProgress":0}}initCallback(){super.initCallback(),this._unobserveCollectionCb=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(t=>this.uploadCollection.read(t)?.getValue("isUploading")??!1);this.$.visible=e}),this.sub("visible",e=>{e?this.setAttribute("active",""):this.removeAttribute("active")}),this.sub("*commonProgress",e=>{this.$.value=e})}destroyCallback(){super.destroyCallback(),this._unobserveCollectionCb?.(),this._unobserveCollectionCb=void 0}};Pi.template='<uc-progress-bar set="visible: visible; value: value"></uc-progress-bar>';var Ui=class extends y{constructor(){super(),this.init$={...this.init$,currentText:"",options:[],selectHtml:"",onSelect:e=>{e.preventDefault(),e.stopPropagation();let t=this.ref.select;this.value=t.value,this.$.currentText=this.$.options.find(r=>r.value===this.value)?.text||"",this.dispatchEvent(new Event("change"))}}}initCallback(){super.initCallback(),this.sub("options",e=>{this.$.currentText=e?.[0]?.text||"";let t="";e?.forEach(r=>{t+=`<option value="${r.value}">${r.text}</option>`}),this.$.selectHtml=t})}};Ui.template='<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>';var Mt=class extends O{static styleAttrs=[...super.styleAttrs,"uc-simple-btn"];couldBeCtxOwner=!0;constructor(){super(),this.init$={...this.init$,withDropZone:!0,onClick:()=>{this.api.initFlow()},"button-text":""}}initCallback(){super.initCallback(),this.defineAccessor("dropzone",e=>{typeof e>"u"||(this.$.withDropZone=I(e))}),this.subConfigValue("multiple",e=>{this.$["button-text"]=e?"upload-files":"upload-file"})}};Mt.template=`<uc-drop-area set="@disabled: !withDropZone"><button type="button" set="onclick: onClick"><uc-icon name="upload"></uc-icon><span l10n="button-text"></span><slot></slot><div class="uc-visual-drop-area" l10n="drop-files-here"></div></button></uc-drop-area>`;Mt.bindAttributes({dropzone:null});var Oc="src-type-",Lt=class extends O{couldBeCtxOwner=!0;type=void 0;_registeredTypes={};constructor(){super(),this.init$={...this.init$,iconName:"default","src-type":""}}initTypes(){this.registerType({type:P.LOCAL,activate:()=>(this.api.openSystemDialog(),!1)}),this.registerType({type:P.URL,activity:f.activities.URL,textKey:"from-url"}),this.registerType({type:P.CAMERA,activity:f.activities.CAMERA,activate:()=>{let e=Fe.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:!0}),!e}}),this.registerType({type:"draw",activity:f.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(Cr))this.registerType({type:e,activity:f.activities.CAMERA,activate:()=>{let t=Fe.htmlMediaCapture;return t&&this.api.openSystemDialog({captureCamera:!0,modeCamera:e==="mobile-photo-camera"?_.PHOTO:_.VIDEO}),!t}});for(let e of Object.values(le))this.registerType({type:e,activity:f.activities.EXTERNAL,activityParams:{externalSourceType:e}})}initCallback(){super.initCallback(),this.initTypes(),this.defineAccessor("type",e=>{e&&this.applyType(e)})}registerType(e){this._registeredTypes[e.type]=e}getType(e){return this._registeredTypes[e]}activate(){if(!this.type)return;let e=this._registeredTypes[this.type];if(!e)return;let{activity:t,activate:r,activityParams:o={}}=e;(r?r():!!t)&&t&&(this.modalManager?.open(t),this.set$({"*currentActivityParams":o,"*currentActivity":t}))}applyType(e){let t=this._registeredTypes[e];if(!t){console.warn(`Unsupported source type: ${e}`);return}let{textKey:r=e,icon:o=e}=t;this.$["src-type"]=`${Oc}${r}`,this.$.iconName=o,this.onclick=()=>{this.activate()}}};Lt.template=`<button type="button"><uc-icon set="@name: iconName"></uc-icon><div class="uc-txt" l10n="src-type"></div></button>`;Lt.bindAttributes({type:null});var Jr=class extends y{initCallback(){super.initCallback(),this.subConfigValue("sourceList",e=>{let t=$(e),r="";t.forEach(o=>{if(o==="instagram"){console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here:https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US");return}if(o==="camera"&&Fe.htmlMediaCapture){this.subConfigValue("cameraModes",s=>{let n=q(s);n.forEach(a=>{r+=`<uc-source-btn role="listitem" type="mobile-${a}-camera"></uc-source-btn>`}),n.length===0&&(r+='<uc-source-btn role="listitem" type="mobile-photo-camera"></uc-source-btn>')});return}r+=`<uc-source-btn role="listitem" type="${o}"></uc-source-btn>`}),this.cfg.sourceListWrap?this.innerHTML=r:this.outerHTML=r})}};var $i=class extends Ee{};$i.template='<div class="uc-spinner"></div>';var Di=class extends f{historyTracked=!0;activityType=f.activities.START_FROM;initCallback(){super.initCallback(),this.registerActivity(this.activityType??"")}};Di.template='<div class="uc-content"><slot></slot></div>';function eo(i,e=40){if(i.type==="image/svg+xml")return URL.createObjectURL(i);let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return Promise.reject(new Error("Canvas context not supported"));let o=new Image,s=new Promise((n,a)=>{o.onload=()=>{let l=o.height/o.width;l>1?(t.width=e,t.height=e*l):(t.height=e,t.width=e/l),r.fillStyle="rgb(240, 240, 240)",r.fillRect(0,0,t.width,t.height),r.drawImage(o,0,0,t.width,t.height),t.toBlob(c=>{if(!c){a();return}let d=URL.createObjectURL(c);n(d)})},o.onerror=l=>{a(l)}});return o.src=URL.createObjectURL(i),s}function Mc(i){let e=new Blob([i],{type:"image/svg+xml"});return URL.createObjectURL(e)}function Fi(i="hsl(209, 21%, 65%)",e=32,t=32){return Mc(`<svg width="${e}" height="${t}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${i}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}var Lc=3e3,Rt=class extends ot{_renderedGridOnce=!1;_thumbRect=null;_isIntersecting=!1;_firstViewMode=this.cfg.filesViewMode;_observer;constructor(){super(),this.init$={...this.init$,thumbUrl:"",badgeIcon:"",uid:""}}_calculateThumbSize(e=!1){e&&(this._thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(this?._thumbRect?.height||0),10),parseInt(String(this?._thumbRect?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,Lc)}_generateThumbnail=this._withEntry(async(e,t=!1)=>{let r=e.getValue("fileInfo"),o=e.getValue("isImage"),s=e.getValue("uuid"),n=e.getValue("thumbUrl"),a=this._calculateThumbSize(t);if(r&&o&&s){let c=await this.proxyUrl(U(Te(this.cfg.cdnCname,s),H(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${a}x${a}/center`)));if(n===c)return;let{promise:d}=Be(c);d.then(()=>{e.setValue("thumbUrl",c),n?.startsWith("blob:")&&URL.revokeObjectURL(n)}).catch(async()=>{if(!n?.startsWith("blob:"))try{let u=e.getValue("file");if(!u)return;let p=await eo(u,a);e.setValue("thumbUrl",p)}catch(u){this.telemetryManager.sendEventError(u,"thumbnail generation. Failed to generate thumb from file");let p=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Fi(p))}});return}if(e.getValue("thumbUrl"))return;let l=e.getValue("file");if(l?.type.includes("image"))try{let c=await eo(l,a);e.setValue("thumbUrl",c)}catch(c){this.telemetryManager.sendEventError(c,"thumbnail generation. Failed to generate thumb from file");let d=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Fi(d))}else{let c=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Fi(c))}});_debouncedGenerateThumb=M(this._generateThumbnail.bind(this),100);_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,t.isIntersecting&&(this._thumbRect=t.boundingClientRect,this._debouncedGenerateThumb(),this._observer?.disconnect()),t.intersectionRatio===0&&this._debouncedGenerateThumb.cancel())}_reset(){super._reset(),this._debouncedGenerateThumb.cancel()}_handleEntryId(e){this._reset();let t=this.uploadCollection?.read(e);this._entry=t,t&&(this._subEntry("fileInfo",r=>{r?.isImage&&this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("thumbUrl",r=>{this.$.thumbUrl=r?`url(${r})`:""}),this._subEntry("cdnUrlModifiers",()=>{this._isIntersecting&&this._debouncedGenerateThumb()}),this._isIntersecting&&this._debouncedGenerateThumb())}initCallback(){super.initCallback(),this.defineAccessor("badgeIcon",e=>{this.$.badgeIcon=e}),this.defineAccessor("uid",e=>{this.set$({uid:e})}),this.sub("uid",e=>{this._handleEntryId(e)}),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this._renderedGridOnce&&(this._firstViewMode==="list"&&this._debouncedGenerateThumb(!0),this._renderedGridOnce=!0)}),this.setAttribute("role","img")}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this._observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set,this._debouncedGenerateThumb.cancel(),this._observer?.disconnect()}};Rt.template=`<div class="uc-thumb" set="style.backgroundImage: thumbUrl"><div class="uc-badge"><uc-icon set="@name: badgeIcon"></uc-icon></div></div>`;Rt.bindAttributes({badgeIcon:null,uid:null});var to=class extends O{static styleAttrs=["uc-wgt-common"];static EventType=T;requireCtxName=!0;initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}destroyCallback(){super.destroyCallback(),this.$["*eventEmitter"].unbindTarget(this)}};var Vi=class extends O{couldBeCtxOwner=!0;historyTracked=!0;activityType=f.activities.UPLOAD_LIST;constructor(){super(),this.init$={...this.init$,doneBtnVisible:!1,doneBtnEnabled:!1,uploadBtnVisible:!1,addMoreBtnVisible:!1,addMoreBtnEnabled:!1,headerText:"",commonErrorMessage:"",hasFiles:!1,onAdd:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(!0)},onUpload:()=>{this.emit(T.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},onDone:()=>{this.emit(T.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()},onCancel:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll()}}}_throttledHandleCollectionUpdate=tt(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll())},300);_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount,validatingBeforeUploading:e.idleEntries.filter(p=>p.isValidationPending).length},r=!e.errors.some(p=>p.type==="TOO_MANY_FILES"||p.type==="TOO_FEW_FILES"),o=e.errors.some(p=>p.type==="TOO_MANY_FILES"),s=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),n=e.allEntries.some(p=>p.isValidationPending),a=t.failed===0&&e.errors.length===0&&!n,l=!1,c=!1,d=!1;if(t.total-t.succeed-t.uploading-t.failed>0&&r&&a)l=!0;else{c=!0;let p=this.cfg.groupOutput?!!e.group:!0;d=t.total===t.succeed&&r&&a&&p}this.set$({doneBtnVisible:c,doneBtnEnabled:d,uploadBtnVisible:l,addMoreBtnEnabled:t.total===0||!o&&!s,addMoreBtnVisible:!s||this.cfg.multiple,hasFiles:t.total>0}),this.bindL10n("headerText",()=>this._getHeaderText(t))}_getHeaderText(e){let t=r=>{let o=e[r];return r==="uploading"&&(o+=e.validatingBeforeUploading),this.l10n(`header-${r}`,{count:o})};return e.uploading>0||e.validatingBeforeUploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",e=>{e&&this._throttledHandleCollectionUpdate()}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e)}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity)}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this.sub("*collectionErrors",e=>{let t=e.filter(r=>r.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this.set$({commonErrorMessage:null});return}this.set$({commonErrorMessage:t.message})})}destroyCallback(){super.destroyCallback(),this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.unobserveCollection(this._throttledHandleCollectionUpdate)}};Vi.template=`<uc-activity-header><span aria-live="polite" class="uc-header-text">{{headerText}}</span><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" set="@hidden: hasFiles"><slot name="empty"><span l10n="no-files"></span></slot></div><div class="uc-files"><div class="uc-files-wrapper" repeat="*uploadList" repeat-item-tag="uc-file-item"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" set="onclick: onAdd; @disabled: !addMoreBtnEnabled; @hidden: !addMoreBtnVisible" ><uc-icon name="add"></uc-icon><span l10n="add-more"></span></button></div><div class="uc-common-error" set="@hidden: !commonErrorMessage; textContent: commonErrorMessage;"></div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel;" l10n="clear"></button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" set="onclick: onAdd; @disabled: !addMoreBtnEnabled; @hidden: !addMoreBtnVisible" ><uc-icon name="add"></uc-icon><span l10n="add-more"></span></button><button type="button" class="uc-upload-btn uc-primary-btn" set="@hidden: !uploadBtnVisible; onclick: onUpload;" l10n="upload" ></button><button type="button" class="uc-done-btn uc-primary-btn" set="@hidden: !doneBtnVisible; onclick: onDone; @disabled: !doneBtnEnabled" l10n="done" ></button></div><uc-drop-area ghost></uc-drop-area>`;var Ni=class extends O{couldBeCtxOwner=!0;activityType=f.activities.URL;constructor(){super(),this.init$={...this.init$,importDisabled:!0,onUpload:e=>{e.preventDefault(),this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let t=this.ref.input.value;this.api.addFileFromUrl(t,{source:P.URL}),this.modalManager?.open(f.activities.UPLOAD_LIST),this.$["*currentActivity"]=f.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()},onInput:e=>{let t=e.target?.value??"";this.set$({importDisabled:!t})}}}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"",{onActivate:()=>{let e=this.ref.input;e.value="",e.focus()}})}};Ni.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back;@aria-label:back"><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span l10n="caption-from-url"></span></div><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content"><label><input placeholder="https://" class="uc-url-input" type="text" ref="input" set="oninput: onInput" /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" set="onclick: onUpload; @disabled: importDisabled" l10n="upload-url" ></button></form>`;var io=class extends we{static styleAttrs=[...super.styleAttrs,"uc-wgt-common"];constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION}),this.a11y?.registerBlock(this)}};var Bi=class extends _e{static styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"];constructor(){super(),this.init$={...this.init$,couldCancel:!1,"*solution":this.tagName,cancel:()=>{if(this.couldHistoryBack){let e=this.$["*historyBack"];e?.();return}this.couldShowList&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST)}}}get couldHistoryBack(){let e=this.$["*history"];return!e||e.length<=1?!1:e[e.length-1]!==f.activities.START_FROM}get couldShowList(){let e=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(e)&&e.length>0}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION});let e=this.ref.uBlock;e&&(this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e.initActivity||f.activities.START_FROM)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0&&this.$["*currentActivity"]===(e.initActivity||f.activities.START_FROM)&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList}))}};Bi.template=`<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-cancel-btn uc-secondary-btn" set="onclick: cancel; @hidden: !couldCancel" ></button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list ref="uBlock"></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`;var ro="active",zi="",Hi=class extends _e{static styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"];handleModalOpen;handleModalClose;constructor(){super(),this.init$={...this.init$,singleUpload:!1,isHiddenStartFrom:!1,classUploadList:zi,classStartFrom:zi,"*solution":this.tagName}}_handleModalOpen(e){e.id===f.activities.CLOUD_IMG_EDIT&&this.set$({classUploadList:ro}),this.$["*currentActivity"]===f.activities.UPLOAD_LIST&&this.set$({classUploadList:ro,isHiddenStartFrom:!0});let t=this.$["*uploadList"];(!t||t.length<=0)&&this.set$({classStartFrom:ro})}_handleModalClose(e){e.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.set$({isHiddenStartFrom:!1})),e.id===f.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST)}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION});let e=this.ref.uBlock;e&&(this.sub("*currentActivity",t=>{t===f.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),t||(this.$["*currentActivity"]=e.initActivity||f.activities.START_FROM)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0?(this.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.set$({classStartFrom:zi})):(this.set$({classUploadList:zi,isHiddenStartFrom:!1}),this.$["*currentActivity"]=e.initActivity||f.activities.START_FROM)}),this.subConfigValue("confirmUpload",t=>{t!==!1&&(this.cfg.confirmUpload=!1)}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t),this.subConfigValue("multiple",r=>{t==="grid"?(r?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.$.singleUpload=!r):(this.style.removeProperty("--uc-grid-col"),this.$.singleUpload=!1)})}),this.handleModalOpen=t=>{this._handleModalOpen(t)},this.handleModalClose=t=>{this._handleModalClose(t)},this.modalManager?.subscribe(D.OPEN,this.handleModalOpen),this.modalManager?.subscribe(D.CLOSE,this.handleModalClose))}destroyCallback(){super.destroyCallback(),this.modalManager?.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(D.CLOSE,this.handleModalClose)}};Hi.template=`<uc-start-from set="@hidden: isHiddenStartFrom; @class:classStartFrom"><uc-drop-area set="@single:singleUpload;" initflow clickable tabindex="0" l10n="choose-file"></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list set="@class:classUploadList" ref="uBlock"></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;var Pt=class extends _e{static styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"];constructor(){super();let e={...this.init$,isHidden:!1,"*solution":this.tagName};this.init$=e}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION}),this.defineAccessor("headless",e=>{this.set$({isHidden:I(e)})})}};Pt.template=`<uc-simple-btn set="@hidden: isHidden"></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;Pt.bindAttributes({headless:null});export{f as ActivityBlock,Lr as ActivityHeader,Ee as BaseComponent,y as Block,Et as BtnUi,ui as CameraSource,io as CloudImageEditor,Ur as CloudImageEditorActivity,we as CloudImageEditorBlock,At as Config,Nr as Copyright,pi as CropFrame,E as Data,St as DropArea,bt as EditorAspectRatioButtonControl,_t as EditorCropButtonControl,et as EditorFilterControl,Qe as EditorFreeformButtonControl,fi as EditorImageCropper,Pr as EditorImageFader,Ct as EditorOperationControl,gi as EditorScroller,mi as EditorSlider,vi as EditorToolbar,xi as ExternalSource,le as ExternalUploadSource,jr as FileItem,Bi as FileUploaderInline,Hi as FileUploaderMinimal,Pt as FileUploaderRegular,Kr as FormInput,kt as Icon,Yr as Img,yi as LineLoaderUi,Li as Modal,D as ModalEvents,Oe as PACKAGE_NAME,Me as PACKAGE_VERSION,bi as PresenceToggle,Ri as ProgressBar,Pi as ProgressBarCommon,Ui as Select,Mt as SimpleBtn,_i as SliderUi,_e as SolutionBlock,Lt as SourceBtn,Jr as SourceList,$i as Spinner,Di as StartFrom,Rt as Thumb,ne as UID,to as UploadCtxProvider,Vi as UploadList,P as UploadSource,O as UploaderBlock,Ni as UrlSource,br as defineComponents,No as defineLocale,ol as loadFileUploaderFrom,Tt as toKebabCase};
|
|
29
|
+
`))}}return e}var L=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),X=Object.freeze([L.CROP,L.TUNING,L.FILTERS]),vo=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),yo=Object.freeze(["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"]),bo=Object.freeze(["rotate","mirror","flip"]),ge=lt,re=Object.freeze({brightness:{zero:ge.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:ge.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:ge.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:ge.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:ge.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:ge.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:ge.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:ge.enhance,range:[0,100],keypointsNumber:1},filter:{zero:ge.filter,range:[0,100],keypointsNumber:1}});var ct="https://ucarecdn.com",Gn="https://upload.uploadcare.com",Wn="https://social.uploadcare.com",qn="https://ucarecd.net",Xn={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:me(X),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:ct,cdnCnamePrefixed:qn,baseUrl:Gn,socialBaseUrl:Wn,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:3,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},Y=Object.freeze(Xn);var _o=i=>{let e=new Intl.Locale(i),t="ltr",r=e.getTextInfo?.().direction;return r?t=r:e.textInfo?.direction&&(t=e.textInfo.direction),t};var zt=(i,e)=>new Intl.PluralRules(i).select(e);var Zn=i=>i;var wo="plural:";function dt(i,e={},t={}){let{openToken:r="{{",closeToken:o="}}",transform:s=Zn}=t;for(let n in e){let a=e[n],l=a?.toString(),c=typeof l=="string"?s(l):String(l);i=i.replaceAll(r+n+o,c)}return i}function Co(i){let e=[],t=i.indexOf("{{");for(;t!==-1;){let r=i.indexOf("}}",t);if(r===-1)break;let o=i.substring(t+2,r);if(o.startsWith(wo)){let s=i.substring(t+2,r).replace(wo,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));e.push({variable:o,pluralKey:n,countVariable:a})}t=i.indexOf("{{",r)}return e}var Eo="--uploadcare-blocks-window-height",ut=class i{static clientsRegistry=new Set;static flush=M(()=>{document.documentElement.style.setProperty(Eo,`${window.innerHeight}px`)},100);static registerClient(e){i.clientsRegistry.size===0&&i.attachTracker(),i.clientsRegistry.add(e)}static unregisterClient(e){i.clientsRegistry.delete(e),i.clientsRegistry.size===0&&i.detachTracker()}static attachTracker(){window.addEventListener("resize",i.flush,{passive:!0,capture:!0}),i.flush()}static detachTracker(){window.removeEventListener("resize",i.flush,{capture:!0}),document.documentElement.style.removeProperty(Eo)}};var To=({element:i,attribute:e,onSuccess:t,onTimeout:r,timeout:o=300})=>{let s=i.getAttribute(e);if(s!==null){t(s);return}let n=new MutationObserver(c=>{let d=c[c.length-1];d&&l(d)});n.observe(i,{attributes:!0,attributeFilter:[e]});let a=window.setTimeout(()=>{n.disconnect(),r()},o),l=c=>{let d=i.getAttribute(e);c.type==="attributes"&&c.attributeName===e&&d!==null&&(window.clearTimeout(a),n.disconnect(),t(d))}};function xo(i){return Object.prototype.toString.call(i)==="[object Object]"}var Yn=/\W|_/g;function Qn(i){return i.split(Yn).map((e,t)=>e.charAt(0)[t>0?"toUpperCase":"toLowerCase"]()+e.slice(1)).join("")}function Ao(i,{ignoreKeys:e}={ignoreKeys:[]}){return Array.isArray(i)?i.map(t=>be(t,{ignoreKeys:e})):i}function be(i,{ignoreKeys:e}={ignoreKeys:[]}){if(Array.isArray(i))return Ao(i,{ignoreKeys:e});if(!xo(i))return i;let t={};for(let r of Object.keys(i)){let o=i[r];if(e.includes(r)){t[r]=o;continue}xo(o)?o=be(o,{ignoreKeys:e}):Array.isArray(o)&&(o=Ao(o,{ignoreKeys:e})),t[Qn(r)]=o}return t}var Jn=i=>new Promise(e=>setTimeout(e,i));function rr({libraryName:i,libraryVersion:e,userAgent:t,publicKey:r="",integration:o=""}){let s="JavaScript";if(typeof t=="string")return t;if(typeof t=="function")return t({publicKey:r,libraryName:i,libraryVersion:e,languageName:s,integration:o});let n=[i,e,r].filter(Boolean).join("/"),a=[s,o].filter(Boolean).join("; ");return`${n} (${a})`}var ea={factor:2,time:100};function ta(i,e=ea){let t=0;function r(o){let s=Math.round(e.time*e.factor**t);return o({attempt:t,retry:a=>Jn(a??s).then(()=>(t+=1,r(o)))})}return r(i)}var $e=class extends Error{},je=class i extends $e{originalProgressEvent;constructor(e){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,i.prototype),this.originalProgressEvent=e}},Ht=(i,e)=>{i&&(i.aborted?Promise.resolve().then(e):i.addEventListener("abort",()=>e(),{once:!0}))},Ae=class i extends $e{isCancel=!0;constructor(e="Request canceled"){super(e),this.name="CancelError",Object.setPrototypeOf(this,i.prototype)}},ia=500,Io=({check:i,interval:e=ia,timeout:t,signal:r})=>new Promise((o,s)=>{let n,a;Ht(r,()=>{n&&clearTimeout(n),s(new Ae("Poll cancelled"))}),t&&(a=setTimeout(()=>{n&&clearTimeout(n),s(new Ae("Timed out"))},t));let l=()=>{try{Promise.resolve(i(r)).then(c=>{c?(a&&clearTimeout(a),o(c)):n=setTimeout(l,e)}).catch(c=>{a&&clearTimeout(a),s(c)})}catch(c){a&&clearTimeout(a),s(c)}};n=setTimeout(l,0)}),S={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"},jt="application/octet-stream",ko="original",Ie=({method:i,url:e,data:t,headers:r={},signal:o,onProgress:s})=>new Promise((n,a)=>{let l=new XMLHttpRequest,c=i?.toUpperCase()||"GET",d=!1;l.open(c,e,!0),r&&Object.entries(r).forEach(u=>{let[p,m]=u;typeof m<"u"&&!Array.isArray(m)&&l.setRequestHeader(p,m)}),l.responseType="text",Ht(o,()=>{d=!0,l.abort(),a(new Ae)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let u={method:c,url:e,data:t,headers:r||void 0,signal:o,onProgress:s},p=l.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};p.forEach(function(v){let A=v.split(": "),C=A.shift(),x=A.join(": ");C&&typeof C<"u"&&(m[C]=x)});let h=l.response,g=l.status;n({request:u,data:h,headers:m,status:g})}},l.onerror=u=>{d||a(new je(u))},s&&typeof s=="function"&&(l.upload.onprogress=u=>{u.lengthComputable?s({isComputable:!0,value:u.loaded/u.total}):s({isComputable:!1})}),t?l.send(t):l.send()});function ra(i,...e){return i}var oa=({name:i})=>i?[i]:[],sa=ra,na=()=>new FormData,Oo=i=>!1,Kt=i=>typeof Blob<"u"&&i instanceof Blob,Gt=i=>typeof File<"u"&&i instanceof File,Wt=i=>!!i&&typeof i=="object"&&!Array.isArray(i)&&"uri"in i&&typeof i.uri=="string",Ke=i=>Kt(i)||Gt(i)||Oo()||Wt(i),aa=i=>typeof i=="string"||typeof i=="number"||typeof i>"u",la=i=>!!i&&typeof i=="object"&&!Array.isArray(i),ca=i=>!!i&&typeof i=="object"&&"data"in i&&Ke(i.data);function Mo(i,e,t){if(Array.isArray(t))for(let r of t)Mo(i,`${e}[]`,r);else if(ca(t)){let{name:r,contentType:o}=t,s=sa(t.data,r,o??jt),n=oa({name:r,contentType:o});i.push([e,s,...n])}else if(la(t))for(let[r,o]of Object.entries(t))typeof o<"u"&&i.push([`${e}[${r}]`,String(o)]);else aa(t)&&t&&i.push([e,t.toString()])}function da(i){let e=[];for(let[t,r]of Object.entries(i))Mo(e,t,r);return e}function qt(i){let e=na(),t=da(i);for(let r of t){let[o,s,...n]=r;e.append(o,s,...n)}return e}var j=class i extends $e{code;request;response;headers;constructor(e,t,r,o,s){super(),this.name="UploadError",this.message=e,this.code=t,this.request=r,this.response=o,this.headers=s,Object.setPrototypeOf(this,i.prototype)}},ua=i=>{let e=new URLSearchParams;for(let[t,r]of Object.entries(i))r&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).filter(o=>o[1]??!1).forEach(o=>e.set(`${t}[${o[0]}]`,String(o[1]))):Array.isArray(r)?r.forEach(o=>{e.append(`${t}[]`,o)}):typeof r=="string"&&r?e.set(t,r):typeof r=="number"&&e.set(t,r.toString());return e.toString()},ve=(i,e,t)=>{let r=new URL(i);return r.pathname=(r.pathname+e).replace("//","/"),t&&(r.search=ua(t)),r.toString()},pa="6.18.2",ha="UploadcareUploadClient",ma=pa;function De(i){return rr({libraryName:ha,libraryVersion:ma,...i})}var fa="RequestThrottledError",So=15e3,ga=1e3;function va(i){let{headers:e}=i||{};if(!e||typeof e["retry-after"]!="string")return So;let t=parseInt(e["retry-after"],10);return Number.isFinite(t)?t*1e3:So}function ke(i,e){let{retryThrottledRequestMaxTimes:t,retryNetworkErrorMaxTimes:r}=e;return ta(({attempt:o,retry:s})=>i().catch(n=>{if("response"in n&&n?.code===fa&&o<t)return s(va(n));if(n instanceof je&&o<r)return s((o+1)*ga);throw n}))}var Lo=i=>{let e="";return(Kt(i)||Gt(i)||Wt(i))&&(e=i.type),e||jt},Ro=i=>{let e="";return Gt(i)&&i.name?e=i.name:Kt(i)||Oo()?e="":Wt(i)&&i.name&&(e=i.name),e||ko};function or(i){return typeof i>"u"||i==="auto"?"auto":i?"1":"0"}function ya(i,{publicKey:e,fileName:t,contentType:r,baseURL:o=S.baseURL,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:c,source:d="local",integration:u,userAgent:p,retryThrottledRequestMaxTimes:m=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=S.retryNetworkErrorMaxTimes,metadata:g}){return ke(()=>Ie({method:"POST",url:ve(o,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":De({publicKey:e,integration:u,userAgent:p})},data:qt({file:{data:i,name:t||Ro(i),contentType:r||Lo(i)},UPLOADCARE_PUB_KEY:e,UPLOADCARE_STORE:or(a),signature:s,expire:n,source:d,metadata:g}),signal:l,onProgress:c}).then(({data:v,headers:A,request:C})=>{let x=be(JSON.parse(v));if("error"in x)throw new j(x.error.content,x.error.errorCode,C,x,A);return x}),{retryNetworkErrorMaxTimes:h,retryThrottledRequestMaxTimes:m})}var Ji;(function(i){i.Token="token",i.FileInfo="file_info"})(Ji||(Ji={}));function ba(i,{publicKey:e,baseURL:t=S.baseURL,store:r,fileName:o,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:c="url",signal:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=S.retryNetworkErrorMaxTimes,metadata:g}){return ke(()=>Ie({method:"POST",headers:{"X-UC-User-Agent":De({publicKey:e,integration:u,userAgent:p})},url:ve(t,"/from_url/",{jsonerrors:1,pub_key:e,source_url:i,store:or(r),filename:o,check_URL_duplicates:s?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:c,metadata:g}),signal:d}).then(({data:v,headers:A,request:C})=>{let x=be(JSON.parse(v));if("error"in x)throw new j(x.error.content,x.error.errorCode,C,x,A);return x}),{retryNetworkErrorMaxTimes:h,retryThrottledRequestMaxTimes:m})}var Z;(function(i){i.Unknown="unknown",i.Waiting="waiting",i.Progress="progress",i.Error="error",i.Success="success"})(Z||(Z={}));var _a=i=>"status"in i&&i.status===Z.Error;function wa(i,{publicKey:e,baseURL:t=S.baseURL,signal:r,integration:o,userAgent:s,retryThrottledRequestMaxTimes:n=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=S.retryNetworkErrorMaxTimes}={}){return ke(()=>Ie({method:"GET",headers:e?{"X-UC-User-Agent":De({publicKey:e,integration:o,userAgent:s})}:void 0,url:ve(t,"/from_url/status/",{jsonerrors:1,token:i}),signal:r}).then(({data:l,headers:c,request:d})=>{let u=be(JSON.parse(l));if("error"in u&&!_a(u))throw new j(u.error.content,u.error.errorCode,d,u,c);return u}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function Ca(i,{publicKey:e,baseURL:t=S.baseURL,jsonpCallback:r,secureSignature:o,secureExpire:s,signal:n,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:u=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"POST",headers:{"X-UC-User-Agent":De({publicKey:e,integration:l,userAgent:c})},url:ve(t,"/group/",{jsonerrors:1}),data:qt({files:i,callback:r,pub_key:e,signature:o,expire:s,source:a}),signal:n}).then(({data:p,headers:m,request:h})=>{let g=be(JSON.parse(p));if("error"in g)throw new j(g.error.content,g.error.errorCode,h,g,m);return g}),{retryNetworkErrorMaxTimes:u,retryThrottledRequestMaxTimes:d})}function Po(i,{publicKey:e,baseURL:t=S.baseURL,signal:r,source:o,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"GET",headers:{"X-UC-User-Agent":De({publicKey:e,integration:s,userAgent:n})},url:ve(t,"/info/",{jsonerrors:1,pub_key:e,file_id:i,source:o}),signal:r}).then(({data:c,headers:d,request:u})=>{let p=be(JSON.parse(c));if("error"in p)throw new j(p.error.content,p.error.errorCode,u,p,d);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function Ea(i,{publicKey:e,contentType:t,fileName:r,multipartChunkSize:o=S.multipartChunkSize,baseURL:s="",secureSignature:n,secureExpire:a,store:l,signal:c,source:d="local",integration:u,userAgent:p,retryThrottledRequestMaxTimes:m=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=S.retryNetworkErrorMaxTimes,metadata:g}){return ke(()=>Ie({method:"POST",url:ve(s,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":De({publicKey:e,integration:u,userAgent:p})},data:qt({filename:r||ko,size:i,content_type:t||jt,part_size:o,UPLOADCARE_STORE:or(l),UPLOADCARE_PUB_KEY:e,signature:n,expire:a,source:d,metadata:g}),signal:c}).then(({data:v,headers:A,request:C})=>{let x=be(JSON.parse(v));if("error"in x)throw new j(x.error.content,x.error.errorCode,C,x,A);return x.parts=Object.keys(x.parts).map(Q=>x.parts[Number(Q)]),x}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h})}function Ta(i,e,{contentType:t,signal:r,onProgress:o,retryThrottledRequestMaxTimes:s=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"PUT",url:e,data:i,onProgress:o,signal:r,headers:{"Content-Type":t||jt}}).then(a=>(o&&o({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n})}function xa(i,{publicKey:e,baseURL:t=S.baseURL,source:r="local",signal:o,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=S.retryNetworkErrorMaxTimes}){return ke(()=>Ie({method:"POST",url:ve(t,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":De({publicKey:e,integration:s,userAgent:n})},data:qt({uuid:i,UPLOADCARE_PUB_KEY:e,source:r}),signal:o}).then(({data:c,headers:d,request:u})=>{let p=be(JSON.parse(c));if("error"in p)throw new j(p.error.content,p.error.errorCode,u,p,d);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function sr(i,{publicKey:e,baseURL:t,source:r,integration:o,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:c}){return Io({check:d=>Po(i,{publicKey:e,baseURL:t,signal:d,source:r,integration:o,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(u=>u.isReady?u:(c&&c({isComputable:!0,value:1}),!1)),signal:l})}function Aa(i){return"defaultEffects"in i}var ye=class{uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(e,{baseCDN:t=S.baseCDN,fileName:r}={}){let{uuid:o,s3Bucket:s}=e,n=ve(t,`${o}/`),a=s?ve(`https://${s}.s3.amazonaws.com/`,`${o}/${e.filename}`):null;this.uuid=o,this.name=r||e.filename,this.size=e.size,this.isStored=e.isStored,this.isImage=e.isImage,this.mimeType=e.mimeType,this.cdnUrl=n,this.originalFilename=e.originalFilename,this.imageInfo=e.imageInfo,this.videoInfo=e.videoInfo,this.contentInfo=e.contentInfo,this.metadata=e.metadata||null,this.s3Bucket=s||null,this.s3Url=a,Aa(e)&&(this.defaultEffects=e.defaultEffects)}},Sa=(i,{publicKey:e,fileName:t,baseURL:r,secureSignature:o,secureExpire:s,store:n,contentType:a,signal:l,onProgress:c,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,baseCDN:g,metadata:v})=>ya(i,{publicKey:e,fileName:t,contentType:a,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:l,onProgress:c,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,metadata:v}).then(({file:A})=>sr(A,{publicKey:e,baseURL:r,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,onProgress:c,signal:l})).then(A=>new ye(A,{baseCDN:g})),Ia=(i,{publicKey:e,fileName:t,baseURL:r,signal:o,onProgress:s,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d,baseCDN:u})=>Po(i,{publicKey:e,baseURL:r,signal:o,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d}).then(p=>new ye(p,{baseCDN:u,fileName:t})).then(p=>(s&&s({isComputable:!0,value:1}),p)),ka=(i,{signal:e}={})=>{let t=null,r=null,o=i.map(()=>new AbortController),s=n=>()=>{r=n,o.forEach((a,l)=>l!==n&&a.abort())};return Ht(e,()=>{o.forEach(n=>n.abort())}),Promise.all(i.map((n,a)=>{let l=s(a);return Promise.resolve().then(()=>n({stopRace:l,signal:o[a].signal})).then(c=>(l(),c)).catch(c=>(t=c,null))})).then(n=>{if(r===null)throw t;return n[r]})},Oa=window.WebSocket,er=class{events=Object.create({});emit(e,t){this.events[e]?.forEach(r=>r(t))}on(e,t){this.events[e]=this.events[e]||[],this.events[e].push(t)}off(e,t){t?this.events[e]=this.events[e].filter(r=>r!==t):this.events[e]=[]}},Ma=(i,e)=>i==="success"?{status:Z.Success,...e}:i==="progress"?{status:Z.Progress,...e}:{status:Z.Error,...e},tr=class{key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new er;disconnectTimeoutId=null;constructor(e,t=3e4){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 Oa(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 r=JSON.parse(t.data.toString());switch(r.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(r.channel,Ma(r.event,JSON.parse(r.data)))}})}}disconnect(){let e=()=>{this.ws?.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{e()},this.disconnectTime):e()}send(e,t){let r=JSON.stringify({event:e,data:t});this.ws?.send(r)}subscribe(e,t){this.subscribers+=1,this.connect();let r=`task-status-${e}`,o={event:"pusher:subscribe",data:{channel:r}};this.emmitter.on(r,t),this.isConnected?this.send(o.event,o.data):this.queue.push(o)}unsubscribe(e){this.subscribers-=1;let t=`task-status-${e}`,r={event:"pusher:unsubscribe",data:{channel:t}};this.emmitter.off(t),this.isConnected?this.send(r.event,r.data):this.queue=this.queue.filter(o=>o.data.channel!==t),this.subscribers===0&&this.disconnect()}onError(e){return this.emmitter.on("error",e),()=>this.emmitter.off("error",e)}},Yi=null,nr=i=>{if(!Yi){let e=typeof window>"u"?0:3e4;Yi=new tr(i,e)}return Yi},La=i=>{nr(i).connect()};function Ra({token:i,publicKey:e,baseURL:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Io({check:c=>wa(i,{publicKey:e,baseURL:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,signal:c}).then(d=>{switch(d.status){case Z.Error:return new j(d.error,d.errorCode);case Z.Waiting:return!1;case Z.Unknown:return new j(`Token "${i}" was not found.`);case Z.Progress:return a&&(d.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:d.done/d.total})),!1;case Z.Success:return a&&a({isComputable:!0,value:d.done/d.total}),d;default:throw new Error("Unknown status")}}),signal:l})}var Pa=({token:i,pusherKey:e,signal:t,onProgress:r})=>new Promise((o,s)=>{let n=nr(e),a=n.onError(s),l=()=>{a(),n.unsubscribe(i)};Ht(t,()=>{l(),s(new Ae("pusher cancelled"))}),n.subscribe(i,c=>{switch(c.status){case Z.Progress:{r&&(c.total==="unknown"?r({isComputable:!1}):r({isComputable:!0,value:c.done/c.total}));break}case Z.Success:{l(),r&&r({isComputable:!0,value:c.done/c.total}),o(c);break}case Z.Error:l(),s(new j(c.msg,c.error_code))}})}),Ua=(i,{publicKey:e,fileName:t,baseURL:r,baseCDN:o,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,onProgress:u,source:p,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,pusherKey:v=S.pusherKey,metadata:A})=>Promise.resolve(La(v)).then(()=>ba(i,{publicKey:e,fileName:t,baseURL:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,source:p,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,metadata:A})).catch(C=>(nr(v)?.disconnect(),Promise.reject(C))).then(C=>C.type===Ji.FileInfo?C:ka([({signal:x})=>Ra({token:C.token,publicKey:e,baseURL:r,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,onProgress:u,signal:x}),({signal:x})=>Pa({token:C.token,pusherKey:v,signal:x,onProgress:u})],{signal:d})).then(C=>{if(C instanceof j)throw C;return C}).then(C=>sr(C.uuid,{publicKey:e,baseURL:r,integration:m,userAgent:h,retryThrottledRequestMaxTimes:g,onProgress:u,signal:d})).then(C=>new ye(C,{baseCDN:o})),Qi=new WeakMap,$a=async i=>{if(Qi.has(i))return Qi.get(i);let e=await fetch(i.uri).then(t=>t.blob());return Qi.set(i,e),e},Uo=async i=>{if(Gt(i)||Kt(i))return i.size;if(Wt(i))return(await $a(i)).size;throw new Error("Unknown file type. Cannot determine file size.")},Da=(i,e=S.multipartMinFileSize)=>i>=e,$o=i=>{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!Ke(i)&&t.test(i)},ar=i=>{let e="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",t=new RegExp(e);return!Ke(i)&&t.test(i)},Fa=(i,e)=>new Promise((t,r)=>{let o=[],s=!1,n=e.length,a=[...e],l=()=>{let c=e.length-a.length,d=a.shift();d&&d().then(u=>{s||(o[c]=u,n-=1,n?l():t(o))}).catch(u=>{s=!0,r(u)})};for(let c=0;c<i;c++)l()}),Va=(i,e,t,r)=>{let o=r*e,s=Math.min(o+r,t);return i.slice(o,s)},Na=async(i,e,t)=>r=>Va(i,r,e,t),Ba=(i,e,{publicKey:t,contentType:r,onProgress:o,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>Ta(i,e,{publicKey:t,contentType:r,onProgress:o,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),za=async(i,{publicKey:e,fileName:t,fileSize:r,baseURL:o,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:c,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,contentType:g,multipartChunkSize:v=S.multipartChunkSize,maxConcurrentRequests:A=S.maxConcurrentRequests,baseCDN:C,metadata:x})=>{let Q=r??await Uo(i),J,Ue=(V,W)=>{if(!c)return;J||(J=Array(V).fill(0));let ie=se=>se.reduce((pe,ji)=>pe+ji,0);return se=>{se.isComputable&&(J[W]=se.value,c({isComputable:!0,value:ie(J)/V}))}};return g||=Lo(i),Ea(Q,{publicKey:e,contentType:g,fileName:t||Ro(i),baseURL:o,secureSignature:s,secureExpire:n,store:a,signal:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,metadata:x,multipartChunkSize:v}).then(async({uuid:V,parts:W})=>{let ie=await Na(i,Q,v);return Promise.all([V,Fa(A,W.map((se,pe)=>()=>Ba(ie(pe),se,{publicKey:e,contentType:g,onProgress:Ue(W.length,pe),signal:l,integration:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h})))])}).then(([V])=>xa(V,{publicKey:e,baseURL:o,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h})).then(V=>V.isReady?V:sr(V.uuid,{publicKey:e,baseURL:o,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:h,onProgress:c,signal:l})).then(V=>new ye(V,{baseCDN:C}))};async function lr(i,{publicKey:e,fileName:t,baseURL:r=S.baseURL,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:h,multipartMinFileSize:g,multipartChunkSize:v,maxConcurrentRequests:A,baseCDN:C=S.baseCDN,checkForUrlDuplicates:x,saveUrlForRecurrentUploads:Q,pusherKey:J,metadata:Ue}){if(Ke(i)){let V=await Uo(i);return Da(V,g)?za(i,{publicKey:e,contentType:h,multipartChunkSize:v,fileSize:V,fileName:t,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,maxConcurrentRequests:A,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:C,metadata:Ue}):Sa(i,{publicKey:e,fileName:t,contentType:h,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:C,metadata:Ue})}if(ar(i))return Ua(i,{publicKey:e,fileName:t,baseURL:r,baseCDN:C,checkForUrlDuplicates:x,saveUrlForRecurrentUploads:Q,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,pusherKey:J,metadata:Ue});if($o(i))return Ia(i,{publicKey:e,fileName:t,baseURL:r,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:C});throw new TypeError(`File uploading from "${i}" is not supported`)}var ir=class{uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(e,{baseCDN:t=S.baseCDN}={}){this.uuid=e.id,this.filesCount=e.filesCount;let r=e.files.filter(Boolean);this.totalSize=Object.values(r).reduce((o,s)=>o+s.size,0),this.isStored=!!e.datetimeStored,this.isImage=!!Object.values(r).filter(o=>o.isImage).length,this.cdnUrl=e.cdnUrl,this.files=r.map(o=>new ye(o,{baseCDN:t})),this.createdAt=e.datetimeCreated,this.storedAt=e.datetimeStored}},Ha=i=>{for(let e of i)if(!Ke(e))return!1;return!0},ja=i=>{for(let e of i)if(!$o(e))return!1;return!0},Ka=i=>{for(let e of i)if(!ar(e))return!1;return!0};function Do(i,{publicKey:e,fileName:t,baseURL:r=S.baseURL,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:h,multipartChunkSize:g=S.multipartChunkSize,baseCDN:v=S.baseCDN,checkForUrlDuplicates:A,saveUrlForRecurrentUploads:C,jsonpCallback:x}){if(!Ha(i)&&!Ka(i)&&!ja(i))throw new TypeError(`Group uploading from "${i}" is not supported`);let Q,J=!0,Ue=i.length,V=(W,ie)=>{if(!l)return;Q||(Q=Array(W).fill(0));let se=pe=>pe.reduce((ji,bn)=>ji+bn)/W;return pe=>{if(!pe.isComputable||!J){J=!1,l({isComputable:!1});return}Q[ie]=pe.value,l({isComputable:!0,value:se(Q)})}};return Promise.all(i.map((W,ie)=>Ke(W)||ar(W)?lr(W,{publicKey:e,fileName:t,baseURL:r,secureSignature:o,secureExpire:s,store:n,signal:a,onProgress:V(Ue,ie),source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:h,multipartChunkSize:g,baseCDN:v,checkForUrlDuplicates:A,saveUrlForRecurrentUploads:C}).then(se=>se.uuid):W)).then(W=>Ca(W,{publicKey:e,baseURL:r,jsonpCallback:x,secureSignature:o,secureExpire:s,signal:a,source:c,integration:d,userAgent:u,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m}).then(ie=>new ir(ie,{baseCDN:v})).then(ie=>(l&&l({isComputable:!0,value:1}),ie)))}var Se=class{_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(e){this._concurrency=e}run(){let e=this._concurrency-this._running;for(let t=0;t<e;t++){let r=this._pending.shift();if(!r)return;let o=this._resolvers.get(r),s=this._rejectors.get(r);if(!o||!s)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,r().finally(()=>{this._resolvers.delete(r),this._rejectors.delete(r),this._running-=1,this.run()}).then(n=>o(n)).catch(n=>s(n))}}add(e,{autoRun:t}={autoRun:!0}){return new Promise((r,o)=>{this._resolvers.set(e,r),this._rejectors.set(e,o),this._pending.push(e),t&&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 cr=()=>({}),dr=i=>({...cr(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{i.modalManager?.close(i.$["*currentActivity"]),i.set$({"*currentActivity":null})}}),ur=i=>({...dr(i),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new Se(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),Fo=i=>({...ur(i),"*solution":null});var pt={"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":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","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-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","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 occurred. 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","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var Xt=new Map,pr=new Map,Vo=(i,e)=>{Xt.has(i)&&console.log(`Locale ${i} is already defined. Overwriting...`),Xt.set(i,{...pt,...e})},Ga=(i,e)=>{pr.set(i,e)},No=(i,e)=>{typeof e=="function"?Ga(i,e):Vo(i,e)},Bo=async i=>{if(!Xt.has(i)){if(!pr.has(i))throw new Error(`Locale ${i} is not defined`);let t=await pr.get(i)();Vo(i,t)}return Xt.get(i)};No("en",pt);var oe=i=>`*l10n/${i}`,Wa="en",Zt=class{_blockInstance=null;_localeName="";_callbacks=new Set;_boundBlocks=new Map;constructor(e){this._blockInstance=e;for(let[t,r]of Object.entries(pt)){let o=this._blockInstance.has(oe(t))?!this._blockInstance.$[oe(t)]:!0;this._blockInstance.add(oe(t),r,o)}setTimeout(()=>{e.subConfigValue("localeName",async t=>{if(!this._blockInstance||!t)return;this._localeName=t;let r=await Bo(t);if(t!==Wa&&this._localeName!==t)return;let o=this._blockInstance.cfg.localeDefinitionOverride?.[t];for(let[s,n]of Object.entries(r)){let a=o?.[s];this._blockInstance.add(oe(s),a??n,!0);for(let l of this._callbacks)l()}}),e.subConfigValue("localeDefinitionOverride",t=>{if(!t)return;let r=t[this._localeName];if(r)for(let[o,s]of Object.entries(r)){this._blockInstance?.add(oe(o),s,!0);for(let n of this._callbacks)n()}})})}onLocaleChange(e){let t=M(e,0);return this._callbacks.add(t),()=>{this._callbacks.delete(t)}}bindL10n(e,t,r){e.$[t]=r(),this._boundBlocks.has(e)||this._boundBlocks.set(e,new Map),this._boundBlocks.get(e)?.get(t)?.();let o=this.onLocaleChange(()=>{e.$[t]=r()});this._boundBlocks.get(e)?.set(t,o)}destroyL10nBindings(e){let t=this._boundBlocks.get(e);if(t){for(let r of t.values())r();this._boundBlocks.delete(e)}}destroy(){this._callbacks.clear()}};function zo(i,e){[...i.querySelectorAll("[l10n]")].forEach(t=>{let r=t.getAttribute("l10n");if(!r)return;let o=r.split(";");for(let s of o)s&&qa(t,s,e)})}var qa=(i,e,t)=>{let r="textContent",o=!1;if(e.includes(":")){let a=e.split(":");if(a.length!==2){console.warn(`l10n attribute value should be in format "property:key" or "key". Found: ${e}`);return}let l=a;r=l[0],e=l[1],r.startsWith("@")&&(r=r.slice(1),o=!0)}let s=e;t.has(s)&&t.sub(s,a=>{if(!a)return;t.l10nProcessorSubs.has(s)||t.l10nProcessorSubs.set(s,new Set);let l=t.l10nProcessorSubs.get(s);l?.forEach(u=>{u.remove(),l.delete(u),t.allSubs.delete(u)});let c=oe(a).replace("*","");t.nodeCtx.has(c)||t.nodeCtx.add(c,a);let d=t.nodeCtx.sub(c,()=>{i[r]=t.l10n(a)});l?.add(d),t.allSubs.add(d),i.removeAttribute("l10n")});let n=oe(e);t.has(n)||t.add(n,""),t.sub(n,()=>{o?i.setAttribute(r,t.l10n(e)):i[r]=t.l10n(e)}),i.removeAttribute("l10n")};var Xa={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function ht(i,e){e.tabIndex=0,e.focus(),i.tabIndex=-1}function hr(i){let e=i.role||i.type||i.tagName;if(!e)return null;let t=Xa[e.toLowerCase()];if(!t)return null;for(let r of t){let o=i.closest(`[role=${r}]`);if(o)return o}}function mr(i,e){return e.role==="toolbar"?Za(e):e.querySelectorAll(`[role=${i.role}]`)}function Za(i){return[...i.querySelectorAll("*")].filter(t=>t.role==="button"||t.type==="button"||t.role==="checkbox"||t.type==="checkbox")}function Ya(i){let e=i.getAttribute("aria-orientation");if(e==="vertical")return!1;if(e==="horizontal")return!0;let t=i.role;return t==="menubar"||t==="tablist"||t==="toolbar"}function Ho(i){return e=>{let t=!1,r=i?.searchDelayMs||300,o=0,s="";function n(u){let p=hr(u.target);if(!p){a();return}let m=mr(u.target,p),h=Array.from(m).indexOf(u.target),g="ArrowDown",v="ArrowUp";if(Ya(p)&&(e.document.dir==="rtl"?(g="ArrowLeft",v="ArrowRight"):(g="ArrowRight",v="ArrowLeft")),u.key===g)u.preventDefault(),ht(u.target,m[h+1]||m[0]);else if(u.key===v)u.preventDefault(),ht(u.target,m[h-1]||m[m.length-1]);else if(u.key==="Home")u.preventDefault(),ht(u.target,m[0]);else if(u.key==="End")u.preventDefault(),ht(u.target,m[m.length-1]);else if(u.key.length===1&&p.role!=="tablist"){let A=Date.now();A-o<=r?s+=u.key.toLowerCase():s=u.key.toLowerCase(),o=A;let C=Array.from(m).find(x=>x.textContent?.trim()?.toLowerCase()?.startsWith(s));C&&(u.preventDefault(),ht(u.target,C))}}function a(){t=!1,e.removeEventListener("keydown",n)}function l(u){let p=hr(u.target);if(p){t||(t=!0,e.addEventListener("keydown",n));let m=mr(u.target,p);for(let h of m)h!==u.target&&h.setAttribute("tabindex",-1)}else t&&a()}function c(u){(!u.relatedTarget||u.relatedTarget===e.document)&&a()}function d(u){let p=hr(u.target);if(p){let m=mr(u.target,p);for(let h of m)h!==u.target&&h.setAttribute("tabindex",-1);u.target.setAttribute("tabindex",0)}}return e.addEventListener("click",d),e.addEventListener("focusin",l),e.addEventListener("focusout",c),()=>{a(),e.removeEventListener("click",d),e.removeEventListener("focusin",l),e.removeEventListener("focusout",c)}}}function jo(){return i=>{let e,t;function r(s){if(s.target.getAttribute("aria-hidden")==="true"){e=s.target,e.setAttribute("aria-hidden","false"),t=e.hidden,t&&(e.hidden=!1);let n=s.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function o(s){e&&e.contains(s.target)&&(!s.relatedTarget||!e.contains(s.relatedTarget))&&(s.target.tabIndex=-1,e.setAttribute("aria-hidden","true"),t&&(e.hidden=!0),e=null)}return i.addEventListener("keyuxJump",r),i.addEventListener("focusout",o),()=>{i.removeEventListener("keyuxJump",r),i.removeEventListener("focusout",o)}}}function Ko(){return i=>{let e=[];function t(l){let c=i.document.activeElement;c&&c!==i.document.body&&e.push(new WeakRef(c)),l.focus({focusVisible:!0})}function r(){let l=e.pop();if(!l){i.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():r()}let o=0,s;function n(l){clearInterval(s);let c=l.getAttribute("aria-controls");s=setInterval(()=>{if(o++>50){clearInterval(s);return}let d=i.document.getElementById(c);if(d){let u=d.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');u&&(clearInterval(s),d.dispatchEvent(new i.CustomEvent("keyuxJump",{bubbles:!0})),t(u))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&r()}return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}}}function Go(i){let e,t=i.split(" "),r;function o(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(s(),a.target.classList.add(...t),e=a.target,r=a.target)}function s(){e&&e.classList.remove(...t),r=null}function n(a){a.clientX===0&&a.clientY===0&&r!==a.target&&(s(),a.target.classList.add(...t),e=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",o),a.addEventListener("keyup",s),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",o),a.removeEventListener("keyup",s)})}function Wo(i,e){let t=e.map(r=>r(i));return()=>{t.forEach(r=>r())}}var fr=class{_listeners=new Map;_scope=[];addEventListener(e,t){let r=o=>{let s=o.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&t(o)};this._listeners.set(t,r),window.addEventListener(e,r)}removeEventListener(e,t){let r=this._listeners.get(t);r&&window.removeEventListener(e,r),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=[];for(let e of this._listeners.values())window.removeEventListener("keydown",e),window.removeEventListener("keyup",e);this._listeners.clear()}},Yt=class{_destroyKeyUX;_scopedWindow;constructor(){this._scopedWindow=new fr,this._destroyKeyUX=Wo(this._scopedWindow,[Ho(),Go("is-pressed"),Ko(),jo()])}registerBlock(e){this._scopedWindow.registerScope(e)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var D=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Qt=class{_modals=new Map;_activeModals=new Set;_subscribers=new Map;_block;constructor(e){this._block=e}_debugPrint(...e){this._block.debugPrint("[modal-manager]",...e)}registerModal(e,t){this._modals.set(e,t),this._notify(D.ADD,{id:e,modal:t})}deleteModal(e){if(!this._modals.has(e))return!1;let t=this._modals.get(e);return this._modals.delete(e),this._activeModals.delete(e),this._notify(D.DELETE,{id:e,modal:t}),!0}open(e){if(!this._modals.has(e))return this._debugPrint(`Modal with ID "${e}" not found`),!1;let t=this._modals.get(e);return this._activeModals.add(e),this._notify(D.OPEN,{modal:t,id:e}),!0}close(e){if(!this._modals.has(e)||!this._activeModals.has(e))return this._debugPrint(`Modal with ID "${e}" not found or not active`),!1;let t=this._modals.get(e);return this._activeModals.delete(e),this._notify(D.CLOSE,{id:e,modal:t}),!0}toggle(e){return this._modals.has(e)?this._activeModals.has(e)?this.close(e):this.open(e):(this._debugPrint(`Modal with ID "${e}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let e=Array.from(this._activeModals).pop();return e?this.close(e):!1}closeAll(){let e=this._activeModals.size;return this._activeModals.clear(),this._notify(D.CLOSE_ALL,{}),e}subscribe(e,t){return this._subscribers.has(e)||this._subscribers.set(e,new Set),this._subscribers.get(e)?.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){this._subscribers.has(e)&&this._subscribers.get(e)?.delete(t)}_notify(e,t){if(this._subscribers.has(e))for(let r of this._subscribers.get(e)??new Set)try{r(t)}catch(o){this._block.telemetryManager.sendEventError(o,"modal subscriber"),this._debugPrint("Error in modal subscriber:",o)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(D.DESTROY,{})}};function Qa(i){return i.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`).replace(/__/g,"_")}function vr(i){return Array.isArray(i)?i.map(e=>typeof e=="object"&&e!==null?vr(e):e):typeof i!="object"||i===null?i:Object.fromEntries(Object.entries(i).map(([e,t])=>{let r=Qa(e);return typeof t=="object"&&t!==null?[r,vr(t)]:[r,t]}))}function Ja(i){return{ok:!0,value:i}}function gr(i){return{ok:!1,error:i}}var el="https://tlm.uploadcare.com/api/",yr=class{constructor(e=el){this.baseUrl=e}async base(e,t={}){let r=`${this.baseUrl}${e}`;try{let o=await fetch(r,t);if(!o.ok)return gr(new Error(`Got non-200 response from "${r}". Status: ${o.status.toString()}`));try{let s=await o.json();return Ja(s)}catch(s){return gr(new Error(`Error parsing JSON from "${r}". Error: ${s}`))}}catch(o){return gr(new Error(`Error fetching data from "${r}". Error: ${o}`))}}async post(e,t,r={}){return await this.base(e,{...r,method:"POST",body:JSON.stringify(vr(t)),headers:{"Content-Type":"application/json",...r.headers||{}}})}async get(e,t={}){return await this.base(e,{method:"GET",...t})}},tl=async(i,e)=>({success:!0,data:e}),Jt=class extends yr{constructor(){super()}async sendEvent(e,t){let r=await tl(void 0,e);if(!r.success)throw console.error("TelemetryAPIService: events: body is invalid",r.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",e,t)}};var qo="1.24.6";var Oe="blocks",Me=qo;var ei=class{_sessionId=crypto.randomUUID();_telemetryInstance;_block;_config=structuredClone(Y);_initialized=!1;_lastPayload=null;_queue;constructor(e){this._block=e,this._telemetryInstance=new Jt,this._queue=new Se(10);for(let t of Object.keys(this._config))this._block.subConfigValue(t,r=>{this._initialized&&this._config[t]!==r&&this.sendEvent({eventType:k.CHANGE_CONFIG}),this._setConfig(t,r)})}_init(e){e===k.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(e,t){this._config[e]!==t&&(this._config[e]=t)}_formattingPayload(e){let t=e.payload?{...e.payload}:{};t.activity&&(t.activity=void 0);let r={...e};return(e.eventType===k.INIT_SOLUTION||e.eventType===k.CHANGE_CONFIG)&&(r.config=this._config),{...r,appVersion:Me,appName:Oe,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:r.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...t}}}_excludedEvents(e){return!!(e&&[T.CHANGE,T.COMMON_UPLOAD_PROGRESS,T.FILE_ADDED,T.FILE_REMOVED,T.FILE_UPLOAD_START,T.FILE_UPLOAD_PROGRESS,T.FILE_UPLOAD_SUCCESS,T.FILE_UPLOAD_FAILED].includes(e))}sendEvent(e){let t=this._formattingPayload({eventType:e.eventType,payload:e.payload,config:e.config});this._init(e.eventType),!(this._excludedEvents(e.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,t))&&this._queue.add(async()=>{this._lastPayload=t,await this._telemetryInstance.sendEvent(t)})}sendEventError(e,t="unknown"){this.sendEvent({eventType:k.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${t}`,error:e.message}}})}sendEventCloudImageEditor(e,t,r={}){this.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{tabId:t,node:e.currentTarget?.tagName,event:e.type,...r}}})}_checkObj(e,t){if(JSON.stringify(e)===JSON.stringify(t))return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let s of r)if(!Object.hasOwn(t,s)||!this._checkObj(e[s],t[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let e=this._block.$["*solution"];return e?e.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var B=i=>`*cfg/${i}`;function Xo(i,e){let t=i.querySelectorAll("[data-testid]");if(t.length===0)return;let r=new WeakMap;for(let o of t){let s=o.getAttribute("data-testid");s&&r.set(o,s)}e.subConfigValue("testMode",o=>{if(!o){for(let n of t)n.removeAttribute("data-testid");return}let s=e.testId;for(let n of t){let a=r.get(n);a&&n.setAttribute("data-testid",`${s}--${a}`)}})}var rl="uc-",y=class extends Ee{__cfgProxy;l10nProcessorSubs=new Map;static StateConsumerScope=null;static styleAttrs=[];requireCtxName=!1;activityType=null;init$=cr();l10n(e,t={}){if(!e)return"";let r=this.$[oe(e)]||e,o=Co(r);for(let n of o)t[n.variable]=this.pluralize(n.pluralKey,Number(t[n.countVariable]));return dt(r,t)}pluralize(e,t){let r=this.l10n("locale-id")||"en",o=zt(r,t);return this.l10n(`${e}__${o}`)}bindL10n(e,t){this.localeManager?.bindL10n(this,e,t)}constructor(){super(),this.addTemplateProcessor(zo),this.addTemplateProcessor(Xo)}emit(e,t,r){let o=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;o&&(o.emit(e,t,r),this.telemetryManager.sendEvent({eventType:e,payload:typeof t=="function"?t():t}))}hasBlockInCtx(e){for(let t of this.blocksRegistry)if(e(t))return!0;return!1}setOrAddState(e,t){this.add$({[e]:t},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(t=>{this.setAttribute(t,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?To({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),ut.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),ut.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Dt(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new Zt(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new ei(this)),this.has("*a11y")||this.add("*a11y",new Yt),this.has("*modalManager")||this.add("*modalManager",new Qt(this)),this.sub(oe("locale-id"),t=>{let r=_o(t);this.style.direction=r==="ltr"?"":r}),this.subConfigValue("testMode",t=>{if(!t||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId)})}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this.has("*modalManager")?this.$["*modalManager"]:void 0}get telemetryManager(){return this.cfg.qualityInsights?this.has("*telemetryManager")&&this.$["*telemetryManager"]:{sendEvent:()=>{},sendEventCloudImageEditor:()=>{},sendEventError:()=>{}}}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}destroyCallback(){super.destroyCallback();let e=this.blocksRegistry;e?.delete(this),this.localeManager?.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,E.deleteCtx(this),e?.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){E.deleteCtx(this.ctxName),this.localeManager?.destroy(),this.modalManager?.destroy()}async proxyUrl(e){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(e,{uuid:Nt(e),cdnUrlModifiers:qi(e),fileName:Vt(e)})}catch(t){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",t),this.telemetryManager.sendEventError(t,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?dt(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:t=>window.encodeURIComponent(t)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(t,r,o)=>{if(typeof r!="string")return!1;let s=B(r);return this.has(s)||this.add(s,Y[r]),this.$[s]=o,!0},get:(t,r)=>{let o=B(r);return this.has(o)||this.add(o,Y[r]),this.$[B(r)]}})}return this.__cfgProxy}subConfigValue(e,t){let r=B(e);this.has(r)||this.add(r,Y[e]),this.sub(r,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof e?.[0]=="function"){let r=e[0];t=r()}console.log(`[${this.ctxName}]`,...t)}static reg(e){if(!e){super.reg();return}e.startsWith(rl)&&super.reg(e)}};var Zo="active",Ge="___ACTIVITY_IS_ACTIVE___",f=class i extends y{historyTracked=!1;[Ge];init$=dr(this);_debouncedHistoryFlush=M(this._historyFlush.bind(this),10);_deactivate(){let e=i._activityCallbacks.get(this);this[Ge]=!1,this.removeAttribute(Zo),e?.deactivateCallback?.()}_activate(){let e=i._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[Ge]=!0,this.setAttribute(Zo,""),e?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(T.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{try{this.activityType!==e&&this[Ge]?this._deactivate():this.activityType===e&&!this[Ge]&&this._activate()}catch(t){this.telemetryManager.sendEventError(t,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,t),this.$["*currentActivity"]=this.$["*history"][this.$["*history"].length-1]??null}e||(this.$["*history"]=[])}))}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e)}_isActivityRegistered(){return!!this.activityType&&i._activityCallbacks.has(this)}static _activityCallbacks=new Map;static activities;get isActivityActive(){return!!this[Ge]}get couldOpenActivity(){return!0}registerActivity(e,t={}){let{onActivate:r,onDeactivate:o}=t;i._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),i._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];!![...this.blocksRegistry].find(r=>r instanceof i&&r.activityType===e)||(this.$["*currentActivity"]=null,this.modalManager?.closeAll())}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(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let r=!!t;t&&(r=[...this.blocksRegistry].find(s=>s.activityType===t)?.couldOpenActivity??!1),t=r?t:void 0,t&&this.modalManager?.open(t),this.$["*currentActivity"]=t,this.$["*history"]=e,t||this.modalManager?.closeAll()}}};f.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"});function br(i){for(let e in i){let t=[...e].reduce((r,o)=>(o.toUpperCase()===o&&(o=`-${o.toLowerCase()}`),r+=o,r),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("uc-")||(t=`uc-${t}`),i[e].reg&&i[e].reg(t)}}var _r="UC";function ol(i,e=!1){return new Promise((t,r)=>{if(typeof document!="object"){t(null);return}if(typeof window=="object"&&window[_r]){t(window[_r]);return}let o=document.createElement("script");o.async=!0,o.src=i,o.onerror=()=>{r()},o.onload=()=>{let s=window[_r];e&&br(s),t(s)},document.head.appendChild(o)})}var Yo="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-photo-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-ngdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var _e=class extends y{static styleAttrs=["uc-wgt-common"];requireCtxName=!0;init$=Fo(this);static _template="";initCallback(){super.initCallback(),this.a11y?.registerBlock(this)}static set template(e){this._template=`${Yo+e}<slot></slot>`}static get template(){return this._template}};var mt=33.333333333333336,b=1,wr=24,Qo=6;function Le(i,e){for(let[t,r]of Object.entries(e))i.setAttributeNS(null,t,r.toString())}function K(i,e={}){let t=document.createElementNS("http://www.w3.org/2000/svg",i);return Le(t,e),t}function Jo(i,e,t){let{x:r,y:o,width:s,height:n}=i,a=e.includes("w")?0:1,l=e.includes("n")?0:1,c=a===0?-1:1,d=l===0?-1:1,u=[r+a*s+1.5*c,o+l*n+1.5*d-24*t*d],p=[r+a*s+1.5*c,o+l*n+1.5*d],m=[r+a*s-24*t*c+1.5*c,o+l*n+1.5*d],h=`M ${u[0]} ${u[1]} L ${p[0]} ${p[1]} L ${m[0]} ${m[1]}`,g=[p[0],p[1]];return{d:h,center:g}}function es(i,e,t){let{x:r,y:o,width:s,height:n}=i,a=e==="n"||e==="s",l=e==="w"||e==="e",c=a?.5:e==="w"?0:1,d=l?.5:e==="n"?0:1,u=e==="w"?-1:e==="e"?1:0,p=e==="n"?-1:e==="s"?1:0,m,h;a?(m=[r+c*s-34*t/2,o+d*n+1.5*p],h=[r+c*s+34*t/2,o+d*n+1.5*p]):(m=[r+c*s+1.5*u,o+d*n-34*t/2],h=[r+c*s+1.5*u,o+d*n+34*t/2]);let g=`M ${m[0]} ${m[1]} L ${h[0]} ${h[1]}`,v=[(m[0]+h[0])/2,(m[1]+h[1])/2];return{d:g,center:v}}function ts(i){return i===""?"move":["e","w"].includes(i)?"ew-resize":["n","s"].includes(i)?"ns-resize":["nw","se"].includes(i)?"nwse-resize":"nesw-resize"}function is({rect:i,delta:[e,t],imageBox:r}){return qe({...i,x:i.x+e,y:i.y+t},r)}function qe(i,e){let{x:t}=i,{y:r}=i;return i.x<e.x?t=e.x:i.x+i.width>e.x+e.width&&(t=e.x+e.width-i.width),i.y<e.y?r=e.y:i.y+i.height>e.y+e.height&&(r=e.y+e.height-i.height),{...i,x:t,y:r}}function sl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[,o]=e,{y:s,width:n,height:a}=i;s+=o,a-=o,t&&(n=a*t);let l=i.x+i.width/2-n/2;return s<=r.y&&(s=r.y,a=i.y+i.height-s,t&&(n=a*t,l=i.x+i.width/2-n/2)),l<=r.x&&(l=r.x,s=i.y+i.height-a),l+n>=r.x+r.width&&(l=Math.max(r.x,r.x+r.width-n),n=r.x+r.width-l,t&&(a=n/t),s=i.y+i.height-a),a<b&&(a=b,t&&(n=a*t,l=i.x+i.width/2-n/2),s=i.y+i.height-a),n<b&&(n=b,t&&(a=n/t,l=i.x+i.width/2-n/2),s=i.y+i.height-a),{x:l,y:s,width:n,height:a}}function nl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o]=e,{x:s,width:n,height:a}=i;s+=o,n-=o,t&&(a=n/t);let l=i.y+i.height/2-a/2;return s<=r.x&&(s=r.x,n=i.x+i.width-s,t&&(a=n/t,l=i.y+i.height/2-a/2)),l<=r.y&&(l=r.y,s=i.x+i.width-n),l+a>=r.y+r.height&&(l=Math.max(r.y,r.y+r.height-a),a=r.y+r.height-l,t&&(n=a*t),s=i.x+i.width-n),a<b&&(a=b,t&&(n=a*t),l=i.y+i.height/2-a/2,s=i.x+i.width-n),n<b&&(n=b,t&&(a=n/t),l=i.y+i.height/2-a/2,s=i.x+i.width-n),{x:s,y:l,width:n,height:a}}function al({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[,o]=e,{y:s,width:n,height:a}=i;a+=o,t&&(n=a*t);let l=i.x+i.width/2-n/2;return s+a>=r.y+r.height&&(a=r.y+r.height-s,t&&(n=a*t),l=i.x+i.width/2-n/2),l<=r.x&&(l=r.x,s=i.y),l+n>=r.x+r.width&&(l=Math.max(r.x,r.x+r.width-n),n=r.x+r.width-l,t&&(a=n/t),s=i.y),a<b&&(a=b,t&&(n=a*t),l=i.x+i.width/2-n/2),n<b&&(n=b,t&&(a=n/t),l=i.x+i.width/2-n/2),{x:l,y:s,width:n,height:a}}function ll({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o]=e,{x:s,width:n,height:a}=i;n+=o,t&&(a=n/t);let l=i.y+i.height/2-a/2;return s+n>=r.x+r.width&&(n=r.x+r.width-s,t&&(a=n/t),l=i.y+i.height/2-a/2),l<=r.y&&(l=r.y,s=i.x),l+a>=r.y+r.height&&(l=Math.max(r.y,r.y+r.height-a),a=r.y+r.height-l,t&&(n=a*t),s=i.x),a<b&&(a=b,t&&(n=a*t),l=i.y+i.height/2-a/2),n<b&&(n=b,t&&(a=n/t),l=i.y+i.height/2-a/2),{x:s,y:l,width:n,height:a}}function cl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+o<r.x&&(o=r.x-n),a+s<r.y&&(s=r.y-a),n+=o,l-=o,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=r.y&&(c=c-(r.y-a),l=c*t,n=i.x+i.width-l,a=r.y)):t&&(o=c*t-l,l=l+o,n-=o,n<=r.x&&(l=l-(r.x-n),c=l/t,n=r.x,a=i.y+i.height-c)),c<b&&(c=b,t&&(l=c*t),n=i.x+i.width-l,a=i.y+i.height-c),l<b&&(l=b,t&&(c=l/t),n=i.x+i.width-l,a=i.y+i.height-c),{x:n,y:a,width:l,height:c}}function dl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+l+o>r.x+r.width&&(o=r.x+r.width-n-l),a+s<r.y&&(s=r.y-a),l+=o,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=r.y&&(c=c-(r.y-a),l=c*t,n=i.x,a=r.y)):t&&(o=c*t-l,l+=o,n+l>=r.x+r.width&&(l=r.x+r.width-n,c=l/t,n=r.x+r.width-l,a=i.y+i.height-c)),c<b&&(c=b,t&&(l=c*t),a=i.y+i.height-c),l<b&&(l=b,t&&(c=l/t),a=i.y+i.height-c),{x:n,y:a,width:l,height:c}}function ul({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+o<r.x&&(o=r.x-n),a+c+s>r.y+r.height&&(s=r.y+r.height-a-c),n+=o,l-=o,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=r.y+r.height&&(c=r.y+r.height-a,l=c*t,n=i.x+i.width-l,a=r.y+r.height-c)):t&&(o=c*t-l,l+=o,n-=o,n<=r.x&&(l=l-(r.x-n),c=l/t,n=r.x,a=i.y)),c<b&&(c=b,t&&(l=c*t),n=i.x+i.width-l),l<b&&(l=b,t&&(c=l/t),n=i.x+i.width-l),{x:n,y:a,width:l,height:c}}function pl({rect:i,delta:e,aspectRatio:t,imageBox:r}){let[o,s]=e,{x:n,y:a,width:l,height:c}=i;return n+l+o>r.x+r.width&&(o=r.x+r.width-n-l),a+c+s>r.y+r.height&&(s=r.y+r.height-a-c),l+=o,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=r.y+r.height&&(c=r.y+r.height-a,l=c*t,n=i.x,a=r.y+r.height-c)):t&&(o=c*t-l,l+=o,n+l>=r.x+r.width&&(l=r.x+r.width-n,c=l/t,n=r.x+r.width-l,a=i.y)),c<b&&(c=b,t&&(l=c*t)),l<b&&(l=b,t&&(c=l/t)),{x:n,y:a,width:l,height:c}}function rs({direction:i,...e}){switch(i){case"n":return sl(e);case"w":return nl(e);case"s":return al(e);case"e":return ll(e);case"nw":return cl(e);case"ne":return dl(e);case"sw":return ul(e);case"se":return pl(e);default:return e.rect}}function os(i,[e,t]){return i.x<=e&&e<=i.x+i.width&&i.y<=t&&t<=i.y+i.height}function ss(i,e){return i.x>=e.x&&i.y>=e.y&&i.x+i.width<=e.x+e.width&&i.y+i.height<=e.y+e.height}function ns(i,e){return Math.abs(i.width/i.height-e)<.1}function Xe({width:i,height:e},t){let r=t/90%2!==0;return{width:r?e:i,height:r?i:e}}function as(i,e,t){let r=i/e,o,s;r>t?(o=Math.round(e*t),s=e):(o=i,s=Math.round(i/t));let n=Math.round((i-o)/2),a=Math.round((e-s)/2);return n+o>i&&(o=i-n),a+s>e&&(s=e-a),{x:n,y:a,width:o,height:s}}function Ze(i){return{x:Math.round(i.x),y:Math.round(i.y),width:Math.round(i.width),height:Math.round(i.height)}}function Re(i,e,t){return Math.min(Math.max(i,e),t)}var ft=["free"],ii=i=>{let e=$(i);if(!e||e.length===0)return[];let t=[];for(let r of e){let o=r.trim();if(!o)continue;let s=o.indexOf(":");if(s===-1&&!ft.includes(o)){console.warn(`Invalid crop preset: ${o}`);continue}let n=Number(o.slice(0,s)),a=Number(o.slice(s+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!ft.includes(o)){console.warn(`Invalid crop preset: ${o}`);continue}t.push({id:ne.generate(),type:"aspect-ratio",width:ft.includes(o)?0:n,height:ft.includes(o)?0:a,hasFreeform:ft.includes(o)})}return t},ls=(i,e,t,r=.1)=>{let o=i/e,s=null,n=1/0;for(let a of t){let[l,c]=[a.width,a.height],d=l/c,u=Math.abs(o-d);u<n&&(n=u,s=a)}if(s){let[a,l]=[s.width,s.height],c=a/l;if(Math.abs(o-c)/c>r)return null}return s};var le=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Cr=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),P=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Cr,...le});function cs(i){return rr({...i,libraryName:Oe,libraryVersion:Me})}var ds=i=>typeof i!="number"?0:Math.floor(i/1e3),us=(i,{threshold:e})=>{let{secureExpire:t}=i,r=ds(Date.now()),o=Number(t),s=ds(e);return r+s>=o};var ri=class{_block;_secureToken=null;constructor(e){this._block=e}_debugPrint(...e){this._block.debugPrint("[secure-uploads]",...e)}async getSecureToken(){let{secureSignature:e,secureExpire:t,secureUploadsSignatureResolver:r}=this._block.cfg;if((e||t)&&r&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),r){if(!this._secureToken||us(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 o=await r();o?!o.secureSignature||!o.secureExpire?console.error("Secure signature resolver returned an invalid result:",o):(this._debugPrint("Secure signature resolved:",o),this._debugPrint("Secure signature will expire in",new Date(Number(o.secureExpire)*1e3).toISOString()),this._secureToken=o):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(o){console.error("Secure signature resolving failed. Falling back to the previous one.",o),this._block.telemetryManager.sendEventError(o,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.")}}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 Er=(i,e)=>{if(i.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:e.l10n("some-files-were-not-uploaded")}};var Tr=(i,e)=>{let t=i.totalCount,r=e.cfg.multiple?e.cfg.multipleMin:0,o=e.cfg.multiple?e.cfg.multipleMax:1;if(r&&t<r)return{type:"TOO_FEW_FILES",message:e.l10n("files-count-limit-error-too-few",{min:r,max:o,total:t}),payload:{total:t,min:r,max:o}};if(o&&t>o)return{type:"TOO_MANY_FILES",message:e.l10n("files-count-limit-error-too-many",{min:r,max:o,total:t}),payload:{total:t,min:r,max:o}}};var hl=()=>{let i=navigator.userAgent;return/Macintosh|Windows/.test(i)&&/Version\/[\d.]+.*Safari/.test(i)&&!/Chrome|Chromium|Edg|OPR/.test(i)},ml=()=>"capture"in document.createElement("input"),fl=()=>({safariDesktop:hl()}),gl=()=>({htmlMediaCapture:ml()}),ps=fl(),Fe=gl();var gt="image/*",xr="video/*",vl=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],yl=()=>ps.safariDesktop?[gt]:[gt,...vl],vt=yl(),oi=i=>i?i.filter(e=>typeof e=="string").flatMap(e=>$(e)):[],Ar=(i,e)=>e.some(t=>{if(t.endsWith("*")){let r=t.replace("*","");return i.startsWith(r)}return i===t}),hs=(i,e)=>e.some(t=>t.startsWith(".")?i.toLowerCase().endsWith(t.toLowerCase()):!1),ms=i=>{let e=i?.type;return e?Ar(e,vt):!1};var Sr=(i,e)=>{let t=e.cfg.imgOnly,r=e.cfg.accept,o=oi([...t?vt:[],r]);if(!o.length)return;let s=i.mimeType,n=i.name;if(!s||!n)return;let a=Ar(s,o),l=hs(n,o);if(!a&&!l)return{type:"FORBIDDEN_FILE_TYPE",message:e.l10n("file-type-not-allowed"),payload:{entry:i}}};var Ir=(i,e)=>{let t=e.cfg.imgOnly,r=i.isImage;if(!(!t||r)&&!(!i.fileInfo&&i.externalUrl)&&!(!i.fileInfo&&!i.mimeType))return{type:"NOT_AN_IMAGE",message:e.l10n("images-only-accepted"),payload:{entry:i}}};var ce=1e3,Ve=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),yt=i=>Math.ceil(i*100)/100,fs=(i,e=Ve.AUTO)=>{let t=e===Ve.AUTO;if(e===Ve.BYTE||t&&i<ce**1){let o=zt("en-US",i)==="one"?"byte":"bytes";return`${i} ${o}`}return e===Ve.KB||t&&i<ce**2?`${yt(i/ce**1)} KB`:e===Ve.MB||t&&i<ce**3?`${yt(i/ce**2)} MB`:e===Ve.GB||t&&i<ce**4?`${yt(i/ce**3)} GB`:e===Ve.TB||t&&i<ce**5?`${yt(i/ce**4)} TB`:`${yt(i/ce**5)} PB`};var kr=(i,e)=>{let t=e.cfg.maxLocalFileSizeBytes,r=i.size;if(t&&r&&r>t)return{type:"FILE_SIZE_EXCEEDED",message:e.l10n("files-max-size-limit-error",{maxFileSize:fs(t)}),payload:{entry:i}}};var Or=(i,e)=>{let{internalId:t}=i,o=e._uploadCollection.read(t)?.getValue("uploadError");if(!o)return;if(o instanceof j)return{type:"UPLOAD_ERROR",message:o.message,payload:{entry:i,error:o}};if(o instanceof je)return{type:"NETWORK_ERROR",message:o.message,payload:{entry:i,error:o}};let s=o instanceof Error?o:new Error("Unknown error",{cause:o});return{type:"UNKNOWN_ERROR",message:s.message,payload:{entry:i,error:s}}};var gs=()=>{let i=()=>{},e=()=>{};return{promise:new Promise((r,o)=>{i=r,e=o}),resolve:i,reject:e}};var Ye={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},bl=i=>typeof i=="function"?{runOn:"change",validator:i}:i,si=class{_blockInstance;_uploadCollection;_commonFileValidators=[Ir,Sr,kr,Or];_commonCollectionValidators=[Tr,Er];_queue=new Se(20);_runQueueDebounced=M(()=>{this._queue.run()},500);_entryValidationState=new Map;constructor(e){this._blockInstance=e,this._uploadCollection=this._blockInstance.uploadCollection;let t=()=>{this.runFileValidators("change"),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),this._blockInstance.subConfigValue("validationConcurrency",r=>{this._queue.concurrency=r})}runFileValidators(e,t){let r=t??this._uploadCollection.items();for(let o of r){let s=this._uploadCollection.read(o);s&&this._runFileValidatorsForEntry(s,e)}}runCollectionValidators(){let e=this._blockInstance.api.getOutputCollectionState(),t=[];for(let r of[...this._commonCollectionValidators,...this._blockInstance.cfg.collectionValidators])try{let o=r(e,this._blockInstance.api);if(!o)continue;o&&(t.push(this._addCustomTypeToValidationError(o)),o.message||console.warn(Ye.MISSING_ERROR_MESSAGE))}catch(o){console.warn(Ye.COLLECTION_VALIDATION_FAILED,o)}this._blockInstance.$["*collectionErrors"]=t,t.length>0&&this._blockInstance.emit(T.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}cleanupValidationForEntry(e){let t=this._entryValidationState.get(e.uid);t&&(t.abortController?.abort(),this._entryValidationState.delete(e.uid))}async _runFileValidatorsForEntry(e,t){let r=this._getValidatorDescriptorsForEntry(e,t);if(r.length===0)return;e.setMultipleValues({isQueuedForValidation:!0,isValidationPending:!0});let o=this._blockInstance.api.getOutputItem(e.uid),s=this._getEntryValidationState(e);s.promise&&await s.promise;let{promise:n,resolve:a}=gs();s.promise=n;let l=new AbortController;s.abortController=l;let c=this._blockInstance.cfg.validationTimeout,d=this._getValidatorDescriptors(),u=new Set(r.map(h=>h.validator)),p=[];for(let h of d)if(!u.has(h.validator)){let g=s.lastErrorThrownByValidator.get(h.validator);g&&p.push(g)}let m=r.map(h=>async()=>{if(!this._blockInstance.isConnected)return;let g=setTimeout(()=>{s.skippedValidators.add(h.validator),l.abort(),console.warn(Ye.FILE_VALIDATION_TIMEOUT)},c);try{let v=await h.validator(o,this._blockInstance.api,{signal:l.signal});if(!v||l.signal.aborted){s.lastErrorThrownByValidator.set(h.validator,void 0);return}let A=this._addCustomTypeToValidationError(v);s.lastErrorThrownByValidator.set(h.validator,A),p.push(A),v.message||console.warn(Ye.MISSING_ERROR_MESSAGE)}catch(v){l.signal.aborted||(s.skippedValidators.add(h.validator),console.warn(Ye.FILE_VALIDATION_FAILED,v),this._blockInstance.telemetryManager.sendEventError(v,`file validator. ${Ye.FILE_VALIDATION_FAILED}`))}finally{clearTimeout(g),h.runOn!=="change"&&s.skippedValidators.add(h.validator)}});if(this._runQueueDebounced(),await this._queue.add(async()=>{e.setValue("isQueuedForValidation",!1),await Promise.all(m.map(h=>h())).catch(()=>{})},{autoRun:!1}),l.signal.aborted){e.setMultipleValues({isQueuedForValidation:!1,isValidationPending:!1}),a();return}e.setMultipleValues({isValidationPending:!1,isQueuedForValidation:!1,errors:p}),a()}_addCustomTypeToValidationError(e){return{...e,type:e.type??"CUSTOM_ERROR"}}_getEntryValidationState(e){let t=this._entryValidationState.get(e.uid);if(t)return t;let r={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(e.uid,r),r}_getValidatorDescriptors(){return[...this._commonFileValidators,...this._blockInstance.cfg.fileValidators].map(bl)}_getValidatorDescriptorsForEntry(e,t){let r=this._getEntryValidationState(e);return this._getValidatorDescriptors().filter(o=>!r.skippedValidators.has(o.validator)).filter(o=>o.runOn===t)}};var vs="[Typed State] Wrong property name: ",_l="[Typed State] Wrong property type: ",ni=class{__typedSchema;__ctxId;__schema;__data;constructor(e,t){this.__typedSchema=e,this.__ctxId=t||ne.generate(),this.__schema=Object.keys(e).reduce((r,o)=>(e[o]&&(r[o]=e[o].value),r),{}),this.__data=E.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(e,t){if(!Object.hasOwn(this.__typedSchema,e)||!this.__typedSchema[e]){console.warn(vs+e);return}let r=this.__typedSchema[e],o=t?.constructor===r.type,s=t instanceof r.type,n=r.nullable&&t===null;if(o||s||n){this.__data.pub(e,t);return}console.warn(_l+e)}setMultipleValues(e){for(let[t,r]of Object.entries(e))this.setValue(t,r)}getValue(e){return Object.hasOwn(this.__typedSchema,e)||console.warn(vs+e),this.__data.read(e)}subscribe(e,t){return this.__data.sub(e,t)}remove(){E.deleteCtx(this.__ctxId)}};var ai=class{__typedSchema;__ctxId;__data;__watchList;__subsMap=Object.create(null);__propertyObservers=new Set;__collectionObservers=new Set;__items=new Set;__removed=new Set;__added=new Set;__observeTimeout;__notifyTimeout;__notifyObservers;constructor(e){this.__typedSchema=e.typedSchema,this.__ctxId=e.ctxName||ne.generate(),this.__data=E.registerCtx({},this.__ctxId),this.__watchList=e.watchList||[];let t=Object.create(null);this.__notifyObservers=(r,o)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),t[r]||(t[r]=new Set),t[r].add(o),this.__observeTimeout=window.setTimeout(()=>{Object.keys(t).length!==0&&(this.__propertyObservers.forEach(s=>{s({...t})}),t=Object.create(null))})},e.handler&&this.observeCollection(e.handler)}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 r of this.__collectionObservers)r?.([...this.__items],e,t)})}observeCollection(e){return this.__collectionObservers.add(e),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(e)}}unobserveCollection(e){this.__collectionObservers.delete(e)}add(e){let t=new ni(this.__typedSchema);for(let[r,o]of Object.entries(e))o!==void 0&&t.setValue(r,o);return this.__items.add(t.uid),this.notify(),this.__data.add(t.uid,t),this.__added.add(t),this.__watchList.forEach(r=>{this.__subsMap[t.uid]||(this.__subsMap[t.uid]=[]),this.__subsMap[t.uid]?.push(t.subscribe(r,()=>{this.__notifyObservers(r,t.uid)}))}),t.uid}read(e){return this.__data.read(e)}readProp(e,t){let r=this.read(e);return r?r.getValue(t):(console.warn(`Item with id ${e} not found`),null)}publishProp(e,t,r){let o=this.read(e);if(!o){console.warn(`Item with id ${e} not found`);return}o.setValue(t,r)}remove(e){let t=this.read(e);t&&this.__removed.add(t),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){this.__propertyObservers.delete(e)}findItems(e){let t=[];return this.__items.forEach(r=>{let o=this.read(r);o&&e(o)&&t.push(r)}),t}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){E.deleteCtx(this.__ctxId),this.__propertyObservers=new Set,this.__collectionObservers=new Set;for(let e in this.__subsMap)this.__subsMap[e]?.forEach(t=>{t.remove()}),delete this.__subsMap[e]}};var _=Object.freeze({PHOTO:"photo",VIDEO:"video"}),ee=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Mr=i=>({isVideoRecordingEnabled:q(i.cameraModes).includes(_.VIDEO),isPhotoEnabled:q(i.cameraModes).includes(_.PHOTO)});var wl=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,Cl=new RegExp(`^/?(${wl.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),ys=({url:i,cdnBase:e})=>{let t=new URL(e),r=new URL(ct),o=new URL(i);if(t.host!==o.host&&r.host!==o.host)return null;let s=Cl.exec(o.pathname);if(!s)return null;let[,n,a,l]=s;return n?{uuid:n,cdnUrlModifiers:a||"",filename:l||null}:null};function bs(i){let e=new Map;return(...r)=>{let o=JSON.stringify(r);if(e.has(o))return e.get(o);let s=i(...r);return e.set(o,s),s}}var _s=new Set;function li(i){_s.has(i)||(_s.add(i),console.warn(i))}function El(i){let e=!1;return setTimeout(()=>{e=!0},0),r=>((...o)=>(e&&li(i),r(...o)))}function ws(i){let e={},t={progress:()=>i.$["*commonProgress"],errors:()=>i.$["*collectionErrors"],group:()=>i.$["*groupInfo"],totalCount:()=>i.uploadCollection.size,failedCount:()=>e.failedEntries.length,successCount:()=>e.successEntries.length,uploadingCount:()=>e.uploadingEntries.length,status:()=>e.isFailed?"failed":e.isUploading?"uploading":e.isSuccess?"success":"idle",isSuccess:()=>e.allEntries.length>0&&e.errors.length===0&&e.successEntries.length===e.allEntries.length,isUploading:()=>e.allEntries.some(o=>o.status==="uploading"),isFailed:()=>e.errors.length>0||e.failedEntries.length>0,allEntries:()=>i.getOutputData(),successEntries:()=>e.allEntries.filter(o=>o.status==="success"),failedEntries:()=>e.allEntries.filter(o=>o.status==="failed"),uploadingEntries:()=>e.allEntries.filter(o=>o.status==="uploading"),idleEntries:()=>e.allEntries.filter(o=>o.status==="idle")},r=El("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[o,s]of Object.entries(t)){let n=o,l=bs(r(s));Object.defineProperty(e,n,{get:l,enumerable:!0})}return e}var ci=class{_ctx;constructor(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)}addFileFromUrl=(e,{silent:t,fileName:r,source:o}={})=>{let s=this._uploadCollection.add({externalUrl:e,fileName:r??null,silent:t??!1,source:o??P.API});return this.getOutputItem(s)};addFileFromUuid=(e,{silent:t,fileName:r,source:o}={})=>{let s=this._uploadCollection.add({uuid:e,fileName:r??null,silent:t??!1,source:o??P.API});return this.getOutputItem(s)};addFileFromCdnUrl=(e,{silent:t,fileName:r,source:o}={})=>{let s=ys({url:e,cdnBase:this.cfg.cdnCname});if(!s)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:s.uuid,cdnUrl:e,cdnUrlModifiers:s.cdnUrlModifiers,fileName:r??s.filename??null,silent:t??!1,source:o??P.API});return this.getOutputItem(n)};addFileFromObject=(e,{silent:t,fileName:r,source:o,fullPath:s}={})=>{let n=this._uploadCollection.add({file:e,isImage:ms(e),mimeType:e.type,fileName:r??e.name,fileSize:e.size,silent:t??!1,source:o??P.API,fullPath:s??null});return this.getOutputItem(n)};removeFileByInternalId=e=>{if(!this._uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this._uploadCollection.remove(e)};removeAllFiles(){this._uploadCollection.clearAll()}uploadAll=()=>{let e=this._uploadCollection.items().filter(t=>{let r=this._uploadCollection.read(t);return r?!r.getValue("isRemoved")&&!r.getValue("isUploading")&&!r.getValue("fileInfo")&&r.getValue("errors").length===0&&!r.getValue("isValidationPending")&&!r.getValue("isQueuedForValidation"):!1});e.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(e),this._ctx.emit(T.COMMON_UPLOAD_START,this.getOutputCollectionState()))};openSystemDialog=(e={})=>{let t=me(oi([this.cfg.accept??"",...this.cfg.imgOnly?vt:[]])),r="uploadcare-file-input",o=document.createElement("input");if(o.setAttribute(r,""),at(o,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),o.type="file",o.multiple=this.cfg.multiple,e.captureCamera){o.capture=this.cfg.cameraCapture;let{isPhotoEnabled:s,isVideoRecordingEnabled:n}=Mr(this.cfg);e.modeCamera===_.PHOTO&&s?o.accept=gt:e.modeCamera===_.VIDEO&&n?o.accept=xr:o.accept=[gt,n&&xr].filter(Boolean).join(",")}else o.accept=t;o.addEventListener("change",()=>{o.files&&([...o.files].forEach(s=>{this.addFileFromObject(s,{source:e.captureCamera?P.CAMERA:P.LOCAL})}),this._ctx.modalManager?.open(f.activities.UPLOAD_LIST),this._ctx.$["*currentActivity"]=f.activities.UPLOAD_LIST,o.remove())},{once:!0}),document.querySelectorAll(`[${r}]`).forEach(s=>{s.remove()}),document.body.appendChild(o),o.dispatchEvent(new MouseEvent("click"))};getOutputItem(e){let t=E.getCtx(e).store,r=t.fileInfo,o=t.isRemoved?"removed":t.errors.length>0?"failed":t.fileInfo?"success":t.isUploading?"uploading":"idle";return{uuid:r?.uuid??t.uuid??null,internalId:e,name:r?.originalFilename??t.fileName,size:r?.size??t.fileSize,isImage:r?.isImage??t.isImage,mimeType:r?.mimeType??t.mimeType,file:t.file,externalUrl:t.externalUrl,cdnUrlModifiers:t.cdnUrlModifiers,cdnUrl:t.cdnUrl??r?.cdnUrl??null,fullPath:t.fullPath,uploadProgress:t.uploadProgress,fileInfo:r??null,metadata:t.metadata??r?.metadata??null,isSuccess:o==="success",isUploading:o==="uploading",isFailed:o==="failed",isRemoved:o==="removed",isValidationPending:t.isValidationPending,errors:t.errors,status:o,source:t?.source}}getOutputCollectionState(){return ws(this._ctx)}initFlow=(e=!1)=>{if(this._uploadCollection.size>0&&!e)this._ctx.modalManager?.open(f.activities.UPLOAD_LIST),this._ctx.set$({"*currentActivity":f.activities.UPLOAD_LIST});else if(this._sourceList?.length===1){let t=this._sourceList[0];if(t==="local"){this._ctx.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.openSystemDialog();return}if(t==="camera"&&Fe.htmlMediaCapture){let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=Mr(this.cfg);if(n&&a){this._ctx.set$({"*currentActivity":f.activities.START_FROM});return}else if(n||a){this.openSystemDialog({captureCamera:!0,modeCamera:n?_.PHOTO:_.VIDEO});return}else this.openSystemDialog({captureCamera:!0,modeCamera:_.PHOTO})}let r=this._ctx.$["*blocksRegistry"],o=n=>"type"in n&&n.type===t;[...r].find(o)?.activate(),this._ctx.$["*currentActivity"]&&this._ctx.modalManager?.open(this._ctx.$["*currentActivity"])}else this._ctx.modalManager?.open(f.activities.START_FROM),this._ctx.set$({"*currentActivity":f.activities.START_FROM})};doneFlow=()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.modalManager?.closeAll()};setCurrentActivity=(e,...t)=>{if(this._ctx.hasBlockInCtx(r=>r.activityType===e)){this._ctx.set$({"*currentActivityParams":t??{},"*currentActivity":e});return}console.warn(`Activity type "${e}" not found in the context`)};getCurrentActivity=()=>this._ctx.$["*currentActivity"];setModalState=e=>{if(e&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}e?this._ctx.modalManager?.open(this._ctx.$["*currentActivity"]):(this._ctx.modalManager?.close(this._ctx.$["*currentActivity"]),this._ctx.$["*currentActivity"]=null)};get _sourceList(){let e=[];return this.cfg.sourceList&&(e=$(this.cfg.sourceList)),e}};var Cs=Object.freeze({file:Object.freeze({type:File,value:null,nullable:!0}),externalUrl:Object.freeze({type:String,value:null,nullable:!0}),fileName:Object.freeze({type:String,value:null,nullable:!0}),fileSize:Object.freeze({type:Number,value:null,nullable:!0}),lastModified:Object.freeze({type:Number,value:Date.now()}),uploadProgress:Object.freeze({type:Number,value:0}),uuid:Object.freeze({type:String,value:null,nullable:!0}),isImage:Object.freeze({type:Boolean,value:!1}),mimeType:Object.freeze({type:String,value:null,nullable:!0}),ctxName:Object.freeze({type:String,value:null,nullable:!0}),cdnUrl:Object.freeze({type:String,value:null,nullable:!0}),cdnUrlModifiers:Object.freeze({type:String,value:null,nullable:!0}),fileInfo:Object.freeze({type:ye,value:null,nullable:!0}),isUploading:Object.freeze({type:Boolean,value:!1}),abortController:Object.freeze({type:AbortController,value:null,nullable:!0}),thumbUrl:Object.freeze({type:String,value:null,nullable:!0}),silent:Object.freeze({type:Boolean,value:!1}),source:Object.freeze({type:String,value:null,nullable:!0}),fullPath:Object.freeze({type:String,value:null,nullable:!0}),metadata:Object.freeze({type:Object,value:null,nullable:!0}),errors:Object.freeze({type:Array,value:[]}),uploadError:Object.freeze({type:Error,value:null,nullable:!0}),isRemoved:Object.freeze({type:Boolean,value:!1}),isQueuedForUploading:Object.freeze({type:Boolean,value:!1}),isValidationPending:Object.freeze({type:Boolean,value:!1}),isQueuedForValidation:Object.freeze({type:Boolean,value:!1})});var O=class i extends f{static extSrcList;static sourceTypes;couldBeCtxOwner=!1;isCtxOwner=!1;_unobserveCollection;_unobserveCollectionProperties;init$=ur(this);get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof i?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new ai({typedSchema:Cs,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new ci(this)),this.has("*validationManager")||this.add("*validationManager",new si(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(){this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}disconnectedCallback(){super.disconnectedCallback(),this.isCtxOwner&&this._unobserveUploadCollection()}connectedCallback(){super.connectedCallback(),this.isCtxOwner&&this._observeUploadCollection()}destroyCallback(){super.destroyCallback(),this._flushOutputItems.cancel()}_initCtxOwner(){this.isCtxOwner=!0,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new ri(this))}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate)}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0}async _createGroup(e){let t=await this.getUploadClientOptions(),r=e.allEntries.map(a=>a.uuid+(a.cdnUrlModifiers?`/${a.cdnUrlModifiers}`:"")),o=new AbortController,s=await Do(r,{...t,signal:o.signal});if(this.$["*collectionState"]!==e){o.abort();return}this.$["*groupInfo"]=s;let n=this.api.getOutputCollectionState();this.emit(T.GROUP_CREATED,n),this.emit(T.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=n}_flushOutputItems=M(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(T.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300);_handleCollectionUpdate=(e,t,r)=>{(t.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...t].map(o=>o.uid));for(let o of t)o.getValue("silent")||this.emit(T.FILE_ADDED,this.api.getOutputItem(o.uid));this.validationManager.runCollectionValidators();for(let o of r){this.$["*uploadTrigger"].delete(o.uid),this.validationManager.cleanupValidationForEntry(o),o.getValue("abortController")?.abort(),o.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0});let s=o?.getValue("thumbUrl");s&&URL.revokeObjectURL(s),this.emit(T.FILE_REMOVED,this.api.getOutputItem(o.uid))}this.$["*uploadList"]=e.map(o=>({uid:o})),this._flushCommonUploadProgress(),this._flushOutputItems()};_handleCollectionPropertiesUpdate=e=>{this._flushOutputItems();let t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([o])=>["uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(o)).flatMap(([,o])=>[...o]))];if(r.length>0&&setTimeout(()=>{let o=r.filter(s=>e.fileInfo?.has(s)&&!!E.getCtx(s).store.fileInfo);o.length>0&&this.validationManager.runFileValidators("upload",o),this.validationManager.runFileValidators("change",r)}),e.uploadProgress){for(let o of e.uploadProgress){let{isUploading:s,silent:n}=E.getCtx(o).store;s&&!n&&this.emit(T.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(e.isUploading)for(let o of e.isUploading){let{isUploading:s,silent:n}=E.getCtx(o).store;s&&!n&&this.emit(T.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(e.fileInfo){for(let o of e.fileInfo){let{fileInfo:s,silent:n}=E.getCtx(o).store;s&&!n&&this.emit(T.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this.openCloudImageEditor()}if(e.errors){this.validationManager.runCollectionValidators();for(let n of e.errors){let{errors:a}=E.getCtx(n).store;a.length>0&&(this.emit(T.FILE_UPLOAD_FAILED,this.api.getOutputItem(n)),this.emit(T.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=t.findItems(n=>!!n.getValue("fileInfo")),s=t.findItems(n=>n.getValue("errors").length>0);t.size>0&&s.length===0&&t.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(T.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}e.cdnUrl&&([...e.cdnUrl].filter(s=>!!this.uploadCollection.read(s)?.getValue("cdnUrl")).forEach(s=>{this.emit(T.FILE_URL_CHANGED,this.api.getOutputItem(s))}),this.$["*groupInfo"]=null)};_flushCommonUploadProgress=()=>{let e=0,r=[...this.$["*uploadTrigger"]].filter(s=>!!this.uploadCollection.read(s));r.forEach(s=>{let n=this.uploadCollection.readProp(s,"uploadProgress");typeof n=="number"&&(e+=n)});let o=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(T.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))};openCloudImageEditor(){let[e]=this.uploadCollection.findItems(t=>!!t.getValue("fileInfo")&&t.getValue("isImage")).map(t=>this.uploadCollection.read(t));e&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(t=>t.activityType===f.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:e.uid},this.$["*currentActivity"]=f.activities.CLOUD_IMG_EDIT,this.modalManager?.open(f.activities.CLOUD_IMG_EDIT))}setInitialCrop(){let e=ii(this.cfg.cropPreset);if(e){let[t]=e,r=this.uploadCollection.findItems(o=>!!o.getValue("fileInfo")&&o.getValue("isImage")&&!o.getValue("cdnUrlModifiers")?.includes("/crop/")).map(o=>this.uploadCollection.read(o)).filter(Boolean);for(let o of r){let s=o.getValue("fileInfo");if(!s||!s.imageInfo){console.warn("Failed to get image info for entry",o.uid);continue}let{width:n,height:a}=s.imageInfo,l=typeof t?.width=="number"&&typeof t?.height=="number"&&t.width>0&&t.height>0?t.width/t.height:1,c=as(n,a,l),d=H(`crop/${c.width}x${c.height}/${c.x},${c.y}`,"preview"),u=o.getValue("cdnUrl");if(!u){console.warn("Failed to get cdnUrl for entry",o.uid);continue}o.setMultipleValues({cdnUrlModifiers:d,cdnUrl:U(u,d)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(p=>p.activityType===f.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=f.activities.CLOUD_IMG_EDIT,this.modalManager?.open(f.activities.CLOUD_IMG_EDIT))}}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let r=this.api.getOutputItem(e);return await t(r)}return t}async getUploadClientOptions(){let t=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:cs,integration:this.cfg.userAgentIntegration,secureSignature:t?.secureSignature,secureExpire:t?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,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(r=>this.api.getOutputItem(r))}};O.extSrcList=Object.freeze({...le});O.sourceTypes=Object.freeze({...P});var Lr=class extends f{};var Es=()=>typeof navigator.permissions<"u";var Tl={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},Ts=["camera","microphone"];function di(i){let e=Math.floor(i/60).toString().padStart(2,"0"),t=Math.floor(i%60).toString().padStart(2,"0");return`${e}:${t}`}var xs="image/jpeg",As="video/webm",ui=class extends O{couldBeCtxOwner=!0;activityType=f.activities.CAMERA;_unsubPermissions=null;_capturing=!1;_chunks=[];_mediaRecorder=null;_stream=null;_selectedAudioId=null;_selectedCameraId=null;_activeTab=null;_options={};_canvas=null;_ctx=null;_cameraDevices=[];_audioDevices=[];_permissionResponses={};constructor(){super(),this.init$={...this.init$,video:null,videoTransformCss:null,videoHidden:!0,messageHidden:!0,requestBtnHidden:Es(),cameraSelectOptions:null,cameraSelectHidden:!0,l10nMessage:"",switcher:null,panels:null,timer:null,timerHidden:!0,cameraHidden:!0,cameraActionsHidden:!0,audioSelectOptions:null,audioSelectHidden:!0,audioSelectDisabled:!0,audioToggleMicrophoneHidden:!0,tabCameraHidden:!0,tabVideoHidden:!0,currentIcon:"camera-full",currentTimelineIcon:"play",toggleMicrophoneIcon:"microphone",_startTime:0,_elapsedTime:0,_animationFrameId:null,mutableClassButton:"uc-shot-btn uc-camera-action",onCameraSelectChange:e=>{let t=e.target;t&&(this._selectedCameraId=t.value,this._capture())},onAudioSelectChange:e=>{let t=e.target;t&&(this._selectedAudioId=t.value,this._capture())},onCancel:()=>{this.historyBack()},onShot:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this._activeTab}}}),this._shot()},onRequestPermissions:()=>this._capture(),onStartCamera:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this._activeTab}}}),this._chooseActionWithCamera()},onStartRecording:()=>this._startRecording(),onStopRecording:()=>this._stopRecording(),onToggleRecording:()=>this._toggleRecording(),onToggleAudio:()=>this._toggleEnableAudio(),onRetake:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this._activeTab}}}),this._retake()},onAccept:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this._activeTab}}}),this._accept()},onClickTab:e=>{let r=e.currentTarget?.getAttribute("data-id");r&&this._handleActiveTab(r)}}}_chooseActionWithCamera=()=>{if(this._activeTab===_.PHOTO&&this._shot(),this._activeTab===_.VIDEO){if(this._mediaRecorder?.state==="recording"){this._stopRecording();return}this._startRecording()}};_updateTimer=()=>{let e=Math.floor((performance.now()-this.$._startTime+this.$._elapsedTime)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){let o=this.ref.timer;o&&(o.textContent=di(t)),this._stopRecording();return}let r=this.ref.timer;r&&(r.textContent=di(t))}else{let t=this.ref.timer;t&&(t.textContent=di(e))}this._animationFrameId=requestAnimationFrame(this._updateTimer)};_startTimer=()=>{this.$._startTime=performance.now(),this.$._elapsedTime=0,this._updateTimer()};_stopTimer=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)};_startTimeline=()=>{let e=this.ref.video;if(!e)return;let t=e.currentTime,r=e.duration||1,o=this.ref.line;o&&(o.style.transform=`scaleX(${t/r})`);let s=this.ref.timer;s&&(s.textContent=di(t)),this._animationFrameId=requestAnimationFrame(this._startTimeline)};_stopTimeline=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)};_animationFrameId=null;_startRecording=()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(As)?this._options.mimeType=As:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(ee.PLAY))}catch(e){console.error("Failed to start recording",e),this.telemetryManager.sendEventError(e,"camera recording. Failed to start recording")}};_stopRecording=()=>{this._mediaRecorder?.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(ee.STOP)}),this._mediaRecorder?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this._activeTab}}})};_toggleRecording=()=>{this._mediaRecorder?.state!=="recording"&&(!this.ref.video.paused&&!this.ref.video.ended&&this.ref.video.readyState>2?this.ref.video.pause():this.ref.video.paused&&this.ref.video.play())};_toggleEnableAudio=()=>{this._stream?.getAudioTracks().forEach(e=>{e.enabled=!e.enabled,this.$.toggleMicrophoneIcon=e.enabled?"microphone":"microphone-mute",this.$.audioSelectDisabled=!e.enabled})};_previewVideo=()=>{try{let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=URL.createObjectURL(e),r=this.ref.video;if(!r)return;r.muted=!1,r.volume=1,this.$.video=null,r.src=t,r.addEventListener("play",()=>{this._startTimeline(),this.set$({currentTimelineIcon:"pause"})}),r.addEventListener("pause",()=>{this.set$({currentTimelineIcon:"play"}),this._stopTimeline()})}catch(e){console.error("Failed to preview video",e),this.telemetryManager.sendEventError(e,"camera previewing. Failed to preview video")}};_retake=()=>{if(this._setCameraState(ee.RETAKE),this._activeTab===_.VIDEO){this.$.video=this._stream;let e=this.ref.video;e&&(e.muted=!0)}this.ref.video?.play?.()};_accept=()=>{if(this._setCameraState(ee.ACCEPT),this._activeTab===_.PHOTO){this._canvas?.toBlob(o=>{if(!o)return;let s=this._createFile("camera","jpeg",xs,o);this._toSend(s)},xs);return}let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=this._guessExtensionByMime(this._mediaRecorder?.mimeType),r=this._createFile("video",t,`video/${t}`,e);this._toSend(r),this._chunks=[]};_handlePhoto=e=>{e===ee.SHOT&&this.set$({tabVideoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,cameraActionsHidden:!1,cameraSelectHidden:!0}),(e===ee.RETAKE||e===ee.ACCEPT)&&this.set$({tabVideoHidden:!this._cameraModes.includes(_.VIDEO),tabCameraHidden:!this._cameraModes.includes(_.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,cameraSelectHidden:this._cameraDevices.length<=1})};_handleVideo=e=>{e===ee.PLAY&&this.set$({timerHidden:!1,tabCameraHidden:!0,cameraSelectHidden:!0,audioSelectHidden:!0,currentTimelineIcon:"pause",currentIcon:"square",mutableClassButton:"uc-shot-btn uc-camera-action uc-stop-record"}),e===ee.STOP&&this.set$({timerHidden:!1,cameraHidden:!0,audioToggleMicrophoneHidden:!0,cameraActionsHidden:!1}),(e===ee.RETAKE||e===ee.ACCEPT)&&this.set$({timerHidden:!0,tabVideoHidden:!this._cameraModes.includes(_.VIDEO),tabCameraHidden:!this._cameraModes.includes(_.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording,currentIcon:"video-camera-full",mutableClassButton:"uc-shot-btn uc-camera-action",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,cameraSelectHidden:this._cameraDevices.length<=1})};_setCameraState=e=>{this._activeTab===_.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===_.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e)};_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");this._canvas.height=this.ref.video.videoHeight,this._canvas.width=this.ref.video.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(this.ref.video,0,0),this.ref.video.pause()}_handleActiveTab=e=>{this.ref.switcher?.querySelectorAll("button").forEach(r=>{r.classList.toggle("uc-active",r.getAttribute("data-id")===e)}),e===_.PHOTO&&this.set$({currentIcon:"camera-full",audioSelectHidden:!0,audioToggleMicrophoneHidden:!0}),e===_.VIDEO&&this.set$({currentTimelineIcon:"play",currentIcon:"video-camera-full",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording}),this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:e}}}),this._activeTab=e};_createFile=(e,t,r,o)=>{let s=Date.now(),n=`${e}-${s}.${t}`;return new File([o],n,{lastModified:s,type:r})};_guessExtensionByMime(e){let t={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return"webm";if(e){let r=e.split("/");if(r?.[0]==="video"){let s=r.slice(1).join("/")?.split(";")[0];if(s&&t[s])return t[s]}}return"avi"}_toSend=e=>{this.api.addFileFromObject(e,{source:P.CAMERA}),this.set$({"*currentActivity":f.activities.UPLOAD_LIST}),this.modalManager?.open(f.activities.UPLOAD_LIST)};get _cameraModes(){return $(this.cfg.cameraModes).filter(e=>e===_.PHOTO||e===_.VIDEO)}_setPermissionsState=M(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===_.VIDEO&&this.cfg.enableAudioRecording,r=this._activeTab===_.PHOTO?"camera-full":"video-camera-full";e==="granted"?this.set$({videoHidden:!1,cameraHidden:!1,tabCameraHidden:!this._cameraModes.includes(_.PHOTO),tabVideoHidden:!this._cameraModes.includes(_.VIDEO),messageHidden:!0,timerHidden:!0,currentIcon:r,audioToggleMicrophoneHidden:!t,audioSelectHidden:!t}):e==="prompt"?(this.$.l10nMessage="camera-permissions-prompt",this.set$({videoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,messageHidden:!1}),this._stopCapture()):(this.$.l10nMessage="camera-permissions-denied",this.set$({videoHidden:!0,messageHidden:!1,tabCameraHidden:!this._cameraModes.includes(_.PHOTO),tabVideoHidden:!this._cameraModes.includes(_.VIDEO),cameraActionsHidden:!0,mutableClassButton:"uc-shot-btn uc-camera-action"}),this._stopCapture())},300);_makeStreamInactive=()=>{if(!this._stream)return!1;let e=this._stream?.getAudioTracks(),t=this._stream?.getVideoTracks();return e.forEach(r=>{r.stop()}),t.forEach(r=>{r.stop()}),!0};_stopCapture=()=>{this._capturing&&(this.ref.video.volume=0,this.$.video?.getTracks?.()?.[0]?.stop(),this.$.video=null,this._makeStreamInactive(),this._stopTimer(),this._capturing=!1)};_capture=async()=>{let e={video:{...Tl},audio:this.cfg.enableAudioRecording?{}:!1};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this.ref.video&&(this.ref.video.volume=0);try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied")}),this.$.video=this._stream,this._capturing=!0,this._setPermissionsState("granted")}catch(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t),this.telemetryManager.sendEventError(t,"camera capturing. Failed to capture camera")}};_handlePermissionsChange=()=>{this._capture()};_permissionAccess=async()=>{try{for(let e of Ts){let t=await navigator.permissions.query({name:e});this._permissionResponses[e]=t,t.addEventListener("change",this._handlePermissionsChange)}}catch(e){console.log("Failed to use permissions API. Fallback to manual request mode.",e),this.telemetryManager.sendEventError(e,"camera permissions. Failed to use permissions API"),this._capture()}};_getPermission=()=>{};_requestDeviceAccess=async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices)}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get user media"),console.log("Failed to get user media",e)}};_getDevices=async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=e.filter(t=>t.kind==="videoinput").map((t,r)=>({text:t.label.trim()||`${this.l10n("caption-camera")} ${r+1}`,value:t.deviceId})),this._audioDevices=this.cfg.enableAudioRecording?e.filter(t=>t.kind==="audioinput").map(t=>({text:t.label.trim(),value:t.deviceId})):[],this._cameraDevices.length>1&&this.set$({cameraSelectOptions:this._cameraDevices,cameraSelectHidden:!1}),this._selectedCameraId=this._cameraDevices[0]?.value??null,this._audioDevices.length>1&&this.set$({audioSelectOptions:this._audioDevices,audioSelectHidden:!1}),this._selectedAudioId=this._audioDevices[0]?.value??null}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get devices"),console.log("Failed to get devices",e)}};_onActivate=async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes)};_onDeactivate=async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()};_handleCameraModes=e=>{this.$.tabVideoHidden=!e.includes(_.VIDEO),this.$.tabCameraHidden=!e.includes(_.PHOTO);let t=e[0];t&&(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t)};initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:this._onActivate,onDeactivate:this._onDeactivate}),this.subConfigValue("cameraMirror",e=>{this.$.videoTransformCss=e?"scaleX(-1)":null}),this.subConfigValue("enableAudioRecording",e=>{this.$.audioToggleMicrophoneHidden=!e,this.$.audioSelectDisabled=!e}),this.subConfigValue("cameraModes",e=>{if(!this.isActivityActive)return;let t=q(e);this._handleCameraModes(t.filter(r=>r===_.PHOTO||r===_.VIDEO))})}_destroy(){for(let e of Ts)this._permissionResponses[e]?.removeEventListener("change",this._handlePermissionsChange);navigator.mediaDevices?.removeEventListener("devicechange",this._getDevices)}async destroyCallback(){super.destroyCallback(),this._destroy()}};ui.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back" ><uc-icon name="back"></uc-icon></button><div set="@hidden: !cameraSelectHidden"><uc-icon name="camera"></uc-icon><span l10n="caption-camera"></span></div><uc-select class="uc-camera-select" set="$.options: cameraSelectOptions; @hidden: cameraSelectHidden; onchange: onCameraSelectChange" ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline set="srcObject: video; style.transform: videoTransformCss; @hidden: videoHidden" ref="video" ></video><div class="uc-message-box" set="@hidden: messageHidden"><span l10n="l10nMessage"></span><button type="button" set="onclick: onRequestPermissions; @hidden: requestBtnHidden" l10n="camera-permissions-request" ></button></div></div><div class="uc-controls"><div ref="switcher" class="uc-switcher" set="@hidden:!timerHidden"><button data-id="photo" type="button" class="uc-switch uc-mini-btn" set="onclick: onClickTab; @hidden: tabCameraHidden" data-testid="tab-photo" ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class="uc-switch uc-mini-btn" set="onclick: onClickTab; @hidden: tabVideoHidden" data-testid="tab-video" ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" set="@hidden:timerHidden; onclick: onToggleRecording" data-testid="recording-timer" ><uc-icon set="@name: currentTimelineIcon"></uc-icon><span ref="timer"> 00:00 </span><span ref="line" class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" set="@hidden: cameraActionsHidden" ><button type="button" class="uc-secondary-btn" set="onclick: onRetake" data-testid="retake"> Retake </button><button type="button" class="uc-primary-btn" set="onclick: onAccept" data-testid="accept" > Accept </button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" set="onclick: onStartCamera; @class: mutableClassButton; @hidden: cameraHidden;" ><uc-icon set="@name: currentIcon"></uc-icon></button><div class="uc-select"><button class="uc-mini-btn uc-btn-microphone" set="onclick: onToggleAudio; @hidden: audioToggleMicrophoneHidden;" data-testid="toggle-microphone" ><uc-icon set="@name:toggleMicrophoneIcon"></uc-icon></button><uc-select class="uc-audio-select" set="$.options: audioSelectOptions; onchange: onAudioSelectChange; @hidden: audioSelectHidden; @disabled: audioSelectDisabled" data-testid="audio-select" ></uc-select></div></div>`;var de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function Ss(...i){return i.reduce((e,t)=>{if(typeof t=="string")return e[t]=!0,e;for(let r of Object.keys(t))e[r]=t[r];return e},{})}function N(...i){let e=Ss(...i);return Object.keys(e).reduce((t,r)=>(e[r]&&t.push(r),t),[]).join(" ")}function Is(i,...e){let t=Ss(...e);for(let r of Object.keys(t))i.classList.toggle(r,!!t[r])}var xl=i=>X.includes(i),ks=i=>{if(!i)return X;let e=q(i).filter(xl);return e.length===0?X:e};function Os(i){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":X,"*tabId":L.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:de,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:me([...X]),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let e=i.querySelectorAll("img");for(let t of e){let r=t.src;t.src=de,t.src=r}i.$["*networkProblems"]=!1},"*on.apply":e=>{if(!e)return;let t=i.$["*originalUrl"],r=H(xe(e),"preview"),o=U(t,r),s={originalUrl:t,cdnUrlModifiers:r,cdnUrl:o,transformations:e};i.dispatchEvent(new CustomEvent("apply",{detail:s,bubbles:!0,composed:!0})),i.remove()},"*on.cancel":()=>{i.remove(),i.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Ms="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='ruc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#uuc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#uuc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#uuc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#uuc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#uuc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#uuc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#uuc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>";var Ls=`${Ms} <div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" set="visible: presence.networkProblems;"><div class="uc-network_problems_content"><div class="uc-network_problems_icon"><uc-icon name="sad"></uc-icon></div><div class="uc-network_problems_text">Network error</div></div><div class="uc-network_problems_footer"><uc-btn-ui theme="primary" text="Retry" set="onclick: *on.retryNetwork"></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">{{fileType}}</div></div><div class="uc-image_container" ref="img-container-el"><img src="${de}" class="uc-image uc-image_visible_from_editor" ref="img-el" /><uc-editor-image-cropper ref="cropper-el"></uc-editor-image-cropper><uc-editor-image-fader ref="fader-el"></uc-editor-image-fader></div><div class="uc-info_pan">{{msg}}</div></div><div class="uc-toolbar"><uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor"><uc-editor-toolbar></uc-editor-toolbar></div></div></div>`;var we=class extends y{ctxOwner=!0;static styleAttrs=["uc-cloud-image-editor"];_debouncedShowLoader=M(this._showLoader.bind(this),300);constructor(){super(),this.init$={...this.init$,...Os(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((t,r)=>{let o=window.setTimeout(()=>{r(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),s=new ResizeObserver(n=>{let[a]=n;a&&a.contentRect.width>0&&a.contentRect.height>0&&(window.clearTimeout(o),s.disconnect(),window.setTimeout(()=>t(),0))});s.observe(this)})}initCallback(){super.initCallback(),this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.$.cdnUrl){let e=this.$.cdnUrl,t=Nt(e),r=Te(e,t);if(r===this.$["*originalUrl"])return;this.$["*originalUrl"]=r;let o=Xi(e),s=Zi(o);this.$["*editorTransformations"]=s}else if(this.$.uuid){let e=Te(this.cfg.cdnCname,this.$.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===L.CROP?this.$["*cropperEl"]?.deactivate({reset:!0}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(U(e,H("json"))),r=await fetch(t).then(n=>n.json()),{width:o,height:s}=r;this.$["*imageSize"]={width:o,height:s},this.$["*tabId"]===L.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:e})}catch(e){e&&(this.telemetryManager.sendEventError(e,"cloud editor image. Failed to load image info"),console.error("Failed to load image info",e))}}}async initEditor(){try{await this._waitForSize()}catch(e){this.isConnected&&console.error(e.message);return}this.ref["img-el"].addEventListener("load",()=>{this._debouncedShowLoader(!1),this.$.src!==de&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let t=this.ref["img-el"];t.src!==e&&(t.src=e||de)}),this.sub("tabs",e=>{this.$["*tabList"]=ks(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=N("uc-image",{"uc-image_hidden_to_cropper":e===L.CROP,"uc-image_hidden_effects":e!==L.CROP})}),this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{this.$["presence.networkProblems"]=e,this.$["presence.modalCaption"]=!e}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],r=H(xe(e),"preview"),o=U(t,r),s={originalUrl:t,cdnUrlModifiers:r,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:s,bubbles:!0,composed:!0}))},!1),this.sub("uuid",e=>e&&this.updateImage()),this.sub("cdnUrl",e=>e&&this.updateImage()),this.sub("cropPreset",e=>{let t=ii(e),r=null;if(this.$.cdnUrl){let o=Xi(this.$.cdnUrl),s=Zi(o);if(Array.isArray(s?.crop?.dimensions)){let[n,a]=s.crop.dimensions;r=ls(n,a,t,.1)}}this.$["*cropPresetList"]=t,this.$["*currentAspectRatio"]=r??t?.[0]??null})}};we.template=Ls;we.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var pi=class extends y{_handlePointerUp;_handlePointerMove;_handleSvgPointerMove;_backdropMaskId=`backdrop-mask-${ne.generate()}`;_backdropMask;_backdropMaskInner;_frameThumbs;_frameGuides;_draggingThumb;_hoverThumb;_dragStartPoint;_dragStartCrop;_frameImage;_guidesHidden=!1;constructor(){super(),this.init$={...this.init$,dragging:!1},this._handlePointerUp=this._handlePointerUp_.bind(this),this._handlePointerMove=this._handlePointerMove_.bind(this),this._handleSvgPointerMove=this._handleSvgPointerMove_.bind(this)}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return!1;if(e===""&&t.height<=b&&t.width<=b)return!0;let r=t.height<=b&&(e.includes("n")||e.includes("s")),o=t.width<=b&&(e.includes("e")||e.includes("w"));return r||o}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:o,height:s}=e,n=this.ref["svg-el"],a=K("mask",{id:this._backdropMaskId}),l=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=K("rect",{x:t,y:r,width:o,height:s,fill:"black"});a.appendChild(l),a.appendChild(c);let d=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:`url(#${this._backdropMaskId})`});n.appendChild(d),n.appendChild(a),this._backdropMask=a,this._backdropMaskInner=c}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block")}))}_updateBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:o,height:s}=e;this._backdropMaskInner&&Le(this._backdropMaskInner,{x:t,y:r,width:o,height:s})}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:r,pathNode:o,interactionNode:s,groupNode:n}=t,a=r==="",l=r.length===2,{x:c,y:d,width:u,height:p}=e;if(a)Le(s,{x:c,y:d,width:u,height:p});else{let h=Re(Math.min(u,p)/82/2,0,1),g=l?Jo(e,r,h):es(e,r,h),v=g.center;if(!v)continue;let A=Math.max(wr*Re(Math.min(u,p)/wr/3,0,1),Qo);Le(s,{x:v[0]-A,y:v[1]-A,width:A*2,height:A*2}),Le(o,{d:g.d})}let m=this._shouldThumbBeDisabled(r);n.setAttribute("class",N("uc-thumb",{"uc-thumb--hidden":m,"uc-thumb--visible":!m}))}Le(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1})}}_createThumb(e,t){let r=K("g");r.classList.add("uc-thumb"),r.setAttribute("with-effects","");let o=K("rect",{fill:"transparent"}),s=K("path",{stroke:"currentColor",fill:"none","stroke-width":3});r.appendChild(s),r.appendChild(o),e[t]={direction:t,pathNode:s,interactionNode:o,groupNode:r},t===""&&(r.style.cursor="move"),o.addEventListener("pointerdown",this._handlePointerDown.bind(this,t))}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let r=0;r<3;r++){let o=`${["n","","s"][t]}${["w","","e"][r]}`;o!==""&&this._createThumb(e,o)}return this._createThumb(e,""),e}_createGuides(){let e=K("svg"),t=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let r=1;r<=2;r++){let o=K("line",{x1:`${mt*r}%`,y1:"0%",x2:`${mt*r}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}for(let r=1;r<=2;r++){let o=K("line",{x1:"0%",y1:`${mt*r}%`,x2:"100%",y2:`${mt*r}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}return e.classList.add("uc-guides","uc-guides--semi-hidden"),e}_createFrame(){let e=this.ref["svg-el"],t=document.createDocumentFragment(),r=this._createGuides();t.appendChild(r);let o=this._createThumbs();for(let{groupNode:s}of Object.values(o))t.appendChild(s);e.appendChild(t),this._frameThumbs=o,this._frameGuides=r}_handlePointerDown(e,t){if(!this._frameThumbs)return;let r=this._frameThumbs[e];if(!r||this._shouldThumbBeDisabled(e))return;let o=this.$["*cropBox"],s=this.ref["svg-el"],{x:n,y:a}=s.getBoundingClientRect(),l=t.x-n,c=t.y-a;this.$.dragging=!0,this._draggingThumb=r,this._dragStartPoint=[l,c],this._dragStartCrop={...o}}_handlePointerUp_(e){this._updateCursor(),this.$.dragging&&(e.stopPropagation(),e.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(e){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this.ref["svg-el"],{x:r,y:o}=t.getBoundingClientRect(),s=e.x-r,n=e.y-o,a=s-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,d=this._calcCropBox(c,[a,l]);d&&(this.$["*cropBox"]=d)}_calcCropBox(e,t){let[r,o]=t,s=this.$["*imageBox"],n=this._dragStartCrop??this.$["*cropBox"],a=this.$["*currentAspectRatio"],l=a?a.width/a.height:void 0;if(e===""?n=is({rect:n,delta:[r,o],imageBox:s}):n=rs({rect:n,delta:[r,o],direction:e,aspectRatio:l,imageBox:s}),!Object.values(n).every(c=>Number.isFinite(c)&&c>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return qe(Ze(n),s)}_handleSvgPointerMove_(e){if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(r=>{if(!r||this._shouldThumbBeDisabled(r.direction))return!1;let s=r.interactionNode.getBoundingClientRect(),n={x:s.x,y:s.y,width:s.width,height:s.height};return os(n,[e.x,e.y])});this._hoverThumb=t,this._updateCursor()}_updateCursor(){let e=this._hoverThumb,t=this.ref["svg-el"];t.style.cursor=e?ts(e.direction):"initial"}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this.ref["svg-el"],r=document.createDocumentFragment(),o=K("image",{href:e});o.setAttribute("class","uc-cloud-mask"),r.appendChild(o),t.appendChild(r),this._frameImage=o}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:r,width:o,height:s}=e;Le(this._frameImage,{x:t,y:r,height:s,width:o})}_render(){this._updateBackdrop(),this._updateFrame(),this._updateMask()}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:r}=t;r.setAttribute("class",N("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}))}}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",()=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",t=>{t&&(this._guidesHidden=t.height<=b||t.width<=b,window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this._createMask(t)}),this.sub("dragging",t=>{this._frameGuides&&this._frameGuides.setAttribute("class",N({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&t,"uc-guides--semi-hidden":!this._guidesHidden&&!t}))}),this.ref["svg-el"].addEventListener("pointermove",this._handleSvgPointerMove,!0),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}destroyCallback(){super.destroyCallback(),this.ref["svg-el"].removeEventListener("pointermove",this._handleSvgPointerMove,!0),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}};pi.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var te=class extends y{_titleEl;constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"","on.click":null,"title-prop":""}}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this.sub("title",e=>{let t=this._titleEl;t&&(t.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=N({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e??null})}};te.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><uc-icon ref="icon-el" set="@name: icon;"></uc-icon><div class="uc-title" ref="title-el">{{title}}</div></button>`;var hi=12,Rs=16,Sl=i=>{let e=12,t=12;return i.width/i.height>=1?(e=hi,t=Math.round(hi*i.height/i.width)):(t=hi,e=Math.round(hi*i.width/i.height)),{width:e,height:t}},Qe=class extends te{initCallback(){super.initCallback(),this.$.icon="arrow-dropdown",this.$["on.click"]=this.handleClick.bind(this),this.sub("*currentAspectRatio",e=>{this.$.title=e.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}),this.bindL10n("title-prop",()=>this.$.title)})}handleClick(){this.$["*showListAspectRatio"]=!0}};Qe.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><div class="uc-title" ref="title-el">{{title}}</div><uc-icon ref="icon-el" set="@name: icon;"></uc-icon></button>`;var bt=class extends te{constructor(){super(),this.init$={...this.init$,active:!1,once:!1}}initCallback(){super.initCallback(),this.defineAccessor("aspectRatio",e=>{if(!e)return;let t=!!e.hasFreeform;this.$.title=t?this.l10n("custom"):`${e.width}:${e.height}`,t||this._renderRectBasedOnAspectRatio(e),t&&this.setAttribute("uc-aspect-ratio-freeform",""),this._aspectRatio=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:t?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}).toLowerCase(),value:""}))}),this.sub("*currentAspectRatio",e=>{this.$.active=e&&e.id===this._aspectRatio?.id||e?.width===this._aspectRatio?.width&&e?.height===this._aspectRatio?.height}),this.$["on.click"]=this.handleClick.bind(this)}handleClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio)}_renderRectBasedOnAspectRatio(e){let{width:t,height:r}=Sl(e),o=K("rect",{"stroke-linejoin":"round",fill:"none",stroke:"currentColor","stroke-width":1.2,"fill-rule":"evenodd",x:(Rs-t)/2,y:(Rs-r)/2,rx:2,width:t,height:r}),s=this.ref["icon-el"]?.ref?.svg;s&&(s.innerHTML="",s.appendChild(o))}_aspectRatio};function Il(i){let e=i+90;return e=e>=360?0:e,e}function kl(i,e){if(i==="rotate")return Il(typeof e=="number"?e:0);if(i==="mirror"||i==="flip")return!e;throw new Error(`Unsupported operation: ${i}`)}var _t=class extends te{_operation=void 0;initCallback(){super.initCallback(),this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(e).toLowerCase()})))}),this.$["on.click"]=e=>{if(!this._operation)return;let t=this.$["*cropperEl"],r=t.getValue(this._operation),o=kl(this._operation,r);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this._operation,next:o,prev:r}),t.setValue(this._operation,o)}}};function Be(i){let e=new Image;return{promise:new Promise((o,s)=>{e.src=i,e.onload=()=>o(),e.onerror=n=>s(n)}),image:e,cancel:()=>{e.naturalWidth===0&&(e.src=de)}}}function wt(i){let e=[];for(let s of i){let n=Be(s);e.push(n)}let t=e.map(s=>s.image);return{promise:Promise.allSettled(e.map(s=>s.promise)),images:t,cancel:()=>{e.forEach(s=>{s.cancel()})}}}var ue="original",mi=class extends y{_operation="filter";_filter;_originalUrl="";constructor(){super(),this.init$={...this.init$,disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0,"on.input":e=>{this.$["*faderEl"]?.set(e),this.$.value=e}}}setOperation(e,t){this._operation=e,this._filter=t,this._initializeValues();let r=this.$["*faderEl"],o=this._originalUrl||this.$["*originalUrl"];r&&o&&r.activate({url:o,operation:this._operation,value:this._filter===ue?void 0:this.$.value,filter:this._filter===ue?void 0:this._filter,fromViewer:!1})}_initializeValues(){let e=this._operation,{range:t,zero:r}=re[e],[o,s]=t;this.$.min=o,this.$.max=s,this.$.zero=r;let a=this.$["*editorTransformations"][e];if(e==="filter"){let c=Number(s),d=a;if(d){let{name:u,amount:p}=d;c=u===this._filter?p:s}this.$.value=c,this.$.defaultValue=c;return}let l=typeof a<"u"?a:r;this.$.value=l,this.$.defaultValue=l}apply(){let t={...this.$["*editorTransformations"]};this._operation==="filter"?!this._filter||this._filter===ue?delete t.filter:t.filter={name:this._filter,amount:this.$.value}:t[this._operation]=this.$.value,this.$["*editorTransformations"]=t}cancel(){this.$["*faderEl"]?.deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{this._originalUrl=e}),this.sub("value",e=>{let t=`${this._filter??this._operation} ${e}`;this.$["*operationTooltip"]=t})}};mi.template=`<uc-slider-ui ref="slider-el" set="disabled: disabled; min: min; max: max; defaultValue: defaultValue; zero: zero; onInput: on.input;" ></uc-slider-ui>`;function Je(i){let e=i.match(/^([A-Za-z]+)\s+(\d+)$/);if(!e)return null;let[,t,r]=e;return!t||typeof r>"u"?null:{filter:t,value:Number(r)}}var et=class extends te{_operation="";_filter="";_originalUrl="";_observer;_cancelPreload;constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=window.devicePixelRatio,r=Math.ceil(t*e),o=t>=2?"lightest":"normal",s=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==ue?{name:this._filter,amount:s}:void 0,U(this._originalUrl,H(Bt,xe(n),`quality/${o}`,`scale_crop/${r}x${r}/center`))}async _observerCallback(e,t){if(e[0]?.isIntersecting){let o=await this.proxyUrl(this._previewSrc()),s=this.ref["preview-el"],{promise:n,cancel:a}=Be(o);this._cancelPreload=a,n.catch(l=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:l})}).finally(()=>{s.style.backgroundImage=`url(${o})`,s.setAttribute("loaded",""),t.unobserve(this)})}else this._cancelPreload?.()}initCallback(){super.initCallback(),this.$["on.click"]=t=>{if(this.$.active)this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0);else{let r=this.$["*sliderEl"];r.setOperation(this._operation,this._filter),r.apply()}this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:Je(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",t=>{this._operation="filter",this._filter=t,this.$.isOriginal=t===ue,this.$.icon=this.$.isOriginal?"original":"slider",this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-filter",{name:t.toLowerCase()}))}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let e=this.$["*originalUrl"];this._originalUrl=e,this.$.isOriginal?this.ref["icon-el"].classList.add("uc-original-icon"):this._observer.observe(this),this.sub("*currentFilter",t=>{this.$.active=t&&t===this._filter}),this.sub("isOriginal",t=>{this.$.iconSize=t?40:20}),this.sub("active",t=>{if(this.$.isOriginal)return;let r=this.ref["icon-el"];r.style.opacity=t?"1":"0";let o=this.ref["preview-el"];t?o.style.opacity="0":o.style.backgroundImage&&(o.style.opacity="1")}),this.sub("*networkProblems",async t=>{if(!t){let r=await this.proxyUrl(this._previewSrc()),o=this.ref["preview-el"];o.style.backgroundImage&&(o.style.backgroundImage="none",o.style.backgroundImage=`url(${r})`)}})}destroyCallback(){super.destroyCallback(),this._observer?.disconnect(),this._cancelPreload?.()}};et.template=`<button type="button" role="option" l10n="@title:title-prop;@aria-label:title-prop"><div class="uc-preview" ref="preview-el"></div><uc-icon ref="icon-el" set="@name: icon; @size: iconSize;"></uc-icon></button>`;var tt=(i,e)=>{let t=!1,r,o=0,s=((...n)=>{t?(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-o>=e&&(i(...n),o=Date.now())},Math.max(e-(Date.now()-o),0))):(i(...n),o=Date.now(),t=!0)});return Object.defineProperty(s,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{r&&clearTimeout(r)}}),s};function Ps(i,e){let t={};for(let r of e){let o=i[r];(Object.hasOwn(i,r)||o!==void 0)&&(t[r]=o)}return t}function it(i,e,t){let o=window.devicePixelRatio,s=Math.min(Math.ceil(e*o),3e3),n=o>=2?"lightest":"normal";return U(i,H(Bt,xe(t),`quality/${n}`,`stretch/off/-/resize/${s}x`,`@clib/${Oe}/${Me}/uc-cloud-image-editor/`))}function Ol(i){return i?[({dimensions:t,coords:r})=>[...t,...r].every(o=>Number.isInteger(o)&&Number.isFinite(o)),({dimensions:t,coords:r})=>t.every(o=>o>0)&&r.every(o=>o>=0)].every(t=>t(i)):!0}var fi=class extends y{ctxOwner=!0;_commitDebounced;_handleResizeThrottled;_imageSize={width:0,height:0};_canvas;_ctx=null;_isActive=!1;_observer;_cancelPreload;constructor(){super(),this.init$={...this.init$,image:null,"*padding":20,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=M(this._commit.bind(this),300),this._handleResizeThrottled=tt(this._handleResize.bind(this),100)}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let e=this.$["*editorTransformations"],t=Ps(e,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...t};this.$["*operations"]=r}_initCanvas(){let e=this.ref["canvas-el"],t=e.getContext("2d"),r=this.offsetWidth,o=this.offsetHeight,s=window.devicePixelRatio;e.style.width=`${r}px`,e.style.height=`${o}px`,e.width=r*s,e.height=o*s,t?.scale(s,s),this._canvas=e,this._ctx=t}_alignImage(){if(!this._isActive||!this.$.image)return;let e=this.$.image,t=this.$["*padding"],r=this.$["*operations"],{rotate:o}=r,s={width:this.offsetWidth,height:this.offsetHeight},n=Xe({width:e.naturalWidth,height:e.naturalHeight},o),a;if(n.width>s.width-t*2||n.height>s.height-t*2){let l=n.width/n.height,c=s.width/s.height;if(l>c){let d=s.width-t*2,u=d/l,p=0+t,m=t+(s.height-t*2)/2-u/2;a={x:p,y:m,width:d,height:u}}else{let d=s.height-t*2,u=d*l,p=t+(s.width-t*2)/2-u/2,m=0+t;a={x:p,y:m,width:u,height:d}}}else{let{width:l,height:c}=n,d=t+(s.width-t*2)/2-l/2,u=t+(s.height-t*2)/2-c/2;a={x:d,y:u,width:l,height:c}}this.$["*imageBox"]=Ze(a)}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,s=this.$["*editorTransformations"].crop,{width:n,x:a,y:l}=t;if(s){let{dimensions:[u,p],coords:[m,h]}=s,{width:g}=Xe(this._imageSize,o),v=n/g;e=qe(Ze({x:a+m*v,y:l+h*v,width:u*v,height:p*v}),t)}let c=this.$["*currentAspectRatio"],d=c?c.width/c.height:void 0;if(!ss(e,t)||d&&!ns(e,d)){let u=t.width/t.height,p=t.width,m=t.height;d&&(u>d?p=Math.min(t.height*d,t.width):m=Math.min(t.width/d,t.height)),e={x:t.x+t.width/2-p/2,y:t.y+t.height/2-m/2,width:p,height:m}}this.$["*cropBox"]=qe(Ze(e),t)}_drawImage(){let e=this._ctx;if(!e)return;let t=this.$.image,r=this.$["*imageBox"],o=this.$["*operations"],{mirror:s,flip:n,rotate:a}=o,l=Xe({width:r.width,height:r.height},a);e.save(),e.translate(r.x+r.width/2,r.y+r.height/2),e.rotate(a*Math.PI*-1/180),e.scale(s?-1:1,n?-1:1),e.drawImage(t,-l.width/2,-l.height/2,l.width,l.height),e.restore()}_draw(){if(!this._isActive||!this.$.image||!this._canvas||!this._ctx)return;let e=this._canvas;this._ctx.clearRect(0,0,e.width,e.height),this._drawImage()}_animateIn({fromViewer:e}){this.$.image&&(this.ref["frame-el"].toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=N({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:s,height:n}=t,{width:a,height:l}=Xe(this._imageSize,o),{width:c,height:d}=e,u=s/a,p=n/l;return[Re(Math.round(c/u),1,a),Re(Math.round(d/p),1,l)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:s,height:n,x:a,y:l}=t,{width:c,height:d}=Xe(this._imageSize,o),{x:u,y:p}=e,m=s/c,h=n/d,g=this._getCropDimensions(),v={dimensions:g,coords:[Re(Math.round((u-a)/m),0,c-g[0]),Re(Math.round((p-l)/h),0,d-g[1])]};if(!Ol(v)){console.error("Cropper is trying to create invalid crop object",{payload:v});return}if(!(g[0]===c&&g[1]===d))return v}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:r,flip:o}=e,s=this._getCropTransformation(),a={...this.$["*editorTransformations"],crop:s,rotate:t,mirror:r,flip:o};this.$["*editorTransformations"]=a}setValue(e,t){this.$["*operations"]={...this.$["*operations"],[e]:t},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:t}={}){if(!this._isActive){this._isActive=!0,this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{let r=this.$["*originalUrl"],o=this.$["*editorTransformations"];this.$.image=await this._waitForImage(r,o),this._syncTransformations(),this._animateIn({fromViewer:t})}catch(r){console.error("Failed to activate cropper",{error:r}),this.telemetryManager.sendEventError(r,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(r=>{let[o]=r;if(!o)return;o.contentRect.width>0&&o.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=N({"uc-active_from_viewer":!1,"uc-active_from_editor":!1,"uc-inactive_to_editor":!0}),this.ref["frame-el"].toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),this._observer?.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],r=Math.min(this.offsetWidth,e[0])/t.width,o=Math.min(this.offsetHeight,e[1])/t.height,s=Math.min(r,o),n=t.x+t.width/2,a=t.y+t.height/2;this.style.transform=`scale(${s}) translate(${(this.offsetWidth/2-n)/s}px, ${(this.offsetHeight/2-a)/s}px)`,this.style.transformOrigin=`${n}px ${a}px`}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,r=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${r}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(e,t){let r=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(it(e,r,t)),{promise:s,cancel:n,image:a}=Be(o),l=this._handleImageLoading(o);return a.addEventListener("load",l,{once:!0}),a.addEventListener("error",l,{once:!0}),this._cancelPreload?.(),this._cancelPreload=n,s.then(()=>a).catch(c=>(console.error("Failed to load image",{error:c}),this.$["*networkProblems"]=!0,a))}_handleImageLoading(e){let t="crop",r=this.$["*loadingOperations"],o=r.get(t);return o||(o=new Map,r.set(t,o)),o.get(e)||(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let s=r.get(t);s?.has(e)&&(s.delete(e),this.$["*loadingOperations"]=r)}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw()}),this.sub("*cropBox",()=>{this.$.image&&this._commitDebounced()}),this.sub("*currentAspectRatio",()=>{this._alignCrop()}),setTimeout(()=>{this.sub("*networkProblems",e=>{e||this._isActive&&this.activate(this._imageSize,{fromViewer:!1})})},0)}destroyCallback(){super.destroyCallback(),this._observer?.disconnect()}};fi.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Rr(i,e,t){let r=t,o=t-1,s=new Array(r);for(let n=o;n>=0;n-=1)s[n]=Math.ceil((n*e+(o-n)*i)/o);return s}function Ml(i){return typeof i=="string"&&i in re}function Ll(i){let e=[];for(let t=0;t<i.length-1;t+=1){let r=i[t],o=i[t+1];typeof r=="number"&&typeof o=="number"&&e.push([r,o])}return e}function Rl(i,e,t){let r=Ll(i).find(([n,a])=>n<=e&&e<=a);if(!r)return i.map(()=>0);let[o,s]=r;return i.map(n=>{let a=Math.abs(o-s)||1,l=Math.abs(e-o)/a;return o===n?e>t?1:1-l:s===n?e>=t?l:1:0})}function Pl(i,e){return i.map((t,r)=>t<e?i.length-r:r)}function Us(i,e){let t=re[i].keypointsNumber,{range:r,zero:o}=re[i];return[...new Set([...Rr(r[0],o,t+1),...Rr(o,r[1],t+1),o,e])].sort((s,n)=>s-n)}var Pr=class extends y{_isActive=!1;_hidden=!0;_operation="initial";_filter;_value;_transformations={};_keypoints=[];_container;_previewImage;_cancelLastImages;_cancelBatchPreload;_url;_fromViewer;_raf=0;_addKeypointDebounced=M(this._addKeypoint.bind(this),600);constructor(){super(),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(e){let t=this._operation,r=this.$["*loadingOperations"];r.has(t)||r.set(t,new Map);let o=r.get(t);return o&&!o.get(e)&&(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let s=r.get(t);s?.has(e)&&(s.delete(e),this.$["*loadingOperations"]=r)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let e of this._keypoints){let{image:t}=e;t&&(t.style.opacity=e.opacity.toString(),t.style.zIndex=e.zIndex.toString())}})}_imageSrc({url:e=this._url,filter:t=this._filter??void 0,operation:r,value:o}={}){if(!e)throw new Error("URL is not defined");let s={...this._transformations};r&&(r==="filter"?t&&typeof o=="number"&&(s.filter={name:t,amount:o}):typeof o=="number"&&(s[r]=o));let n=this.offsetWidth;return this.proxyUrl(it(e,n,s))}async _constructKeypoint(e,t){return{src:await this._imageSrc({operation:e,value:t}),image:void 0,opacity:0,zIndex:0,value:t}}_isSame(e,t){return this._operation===e&&this._filter===t}async _addKeypoint(e,t,r){let o=()=>!this._isSame(e,t)||this._value!==r||!!this._keypoints.find(l=>l.value===r);if(o())return;let s=await this._constructKeypoint(e,r),n=new Image;n.src=s.src;let a=this._handleImageLoading(s.src);n.addEventListener("load",a,{once:!0}),n.addEventListener("error",a,{once:!0}),s.image=n,n.classList.add("uc-fader-image"),n.addEventListener("load",()=>{if(o())return;let l=this._keypoints,c=l.findIndex(m=>m.value>r);c===-1&&(c=l.length);let u=l[c]?.image,p=this._container;!p||u&&!p.contains(u)||(l.splice(c,0,s),u&&p.insertBefore(n,u),this._update(e,r))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(e){let t=typeof e=="string"?parseInt(e,10):e;!Ml(this._operation)||!Number.isFinite(t)||(this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t))}_update(e,t){this._operation=e,this._value=t;let{zero:r}=re[e],o=this._keypoints.map(a=>a.value),s=Rl(o,t,r),n=Pl(o,r);this._keypoints.forEach((a,l)=>{let c=s[l],d=n[l];typeof c=="number"&&(a.opacity=c),typeof d=="number"&&(a.zIndex=d)}),this._flush()}_createPreviewImage(){let e=new Image;return e.classList.add("uc-fader-image","uc-fader-image--preview"),e.style.opacity="0",e}async _initNodes(){let e=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage();let t=this._previewImage;this.contains(t)||e.appendChild(t);let r=document.createElement("div");e.appendChild(r);let o=this._keypoints.map(d=>d.src),{images:s,promise:n,cancel:a}=wt(o);s.forEach(d=>{let u=this._handleImageLoading(d.src);d.addEventListener("load",u),d.addEventListener("error",u)}),this._cancelLastImages=()=>{a(),this._cancelLastImages=void 0};let l=this._operation,c=this._filter;await n,this._isActive&&this._isSame(l,c)&&(this._container?.remove(),this._container=r,this._keypoints.forEach((d,u)=>{let p=s[u];p&&(p.classList.add("uc-fader-image"),d.image=p,this._container?.appendChild(p))}),this.appendChild(e),this._flush())}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),r=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",r,{once:!0}),this._previewImage.addEventListener("error",r,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:e,filter:t,operation:r,value:o}){if(!r||typeof o!="number")return;this._cancelBatchPreload?.();let s=Us(r,o),n=await Promise.all(s.map(l=>this._imageSrc({url:e,filter:t,operation:r,value:l}))),{cancel:a}=wt(n);this._cancelBatchPreload=a}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this.contains(t)||this.appendChild(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=N({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}t.style.opacity="0";let r=this._handleImageLoading(e);t.addEventListener("error",r,{once:!0}),t.src=e,t.addEventListener("load",()=>{r(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=N({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),t.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:e,operation:t,value:r,filter:o,fromViewer:s}){if(this._isActive=!0,this._hidden=!1,this._url=e,this._operation=t??"initial",this._value=r,this._filter=o,this._fromViewer=s,typeof r!="number"&&!o){let a=await this._imageSrc({operation:t,value:r});this._setOriginalSrc(a),this._container?.remove();return}!t||typeof r!="number"||(this._keypoints=await Promise.all(Us(t,r).map(a=>this._constructKeypoint(t,a))),this._update(t,r),this._initNodes())}deactivate({hide:e=!0}={}){this._isActive=!1,this._cancelLastImages?.(),this._cancelBatchPreload?.(),e&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=N({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._container?.remove()},{once:!0})):this._container?.remove()}};var Ct=class extends te{_operation="";initCallback(){super.initCallback(),this.$["on.click"]=e=>{this.$["*sliderEl"].setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation,this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:Je(this.$["*operationTooltip"])})},this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()})),this.bindL10n("title",()=>this.l10n(e)))}),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=re[this._operation],r=e[this._operation],o=typeof r<"u"?r!==t:!1;this.$.active=o})}};var Ul=1,gi=class extends y{initCallback(){super.initCallback(),this.addEventListener("wheel",e=>{e.preventDefault();let{deltaY:t,deltaX:r}=e;Math.abs(r)>Ul?this.scrollLeft+=r:this.scrollLeft+=t},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};gi.template=" <slot></slot> ";function $l(i){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${i}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${i}" data-id="${i}" icon="${i}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${i}; title-prop: a11y-editor-tab-${i}" ></uc-btn-ui></uc-presence-toggle>`}function Dl(i){return`<uc-presence-toggle id="tab_${i}" class="uc-tab-content" set="visible: presence.tabContent.${i}; styles: presence.tabContentStyles" ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner" ref="controls-list-${i}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var vi=class extends y{_debouncedShowLoader;_cancelPreload;_updateInfoTooltip;constructor(){super(),this.init$={...this.init$,"*sliderEl":null,"*listAspectRatioEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*showListAspectRatio":!1,hideSliderOrList:!1,"*currentFilter":ue,"*currentOperation":null,showLoader:!1,filters:yo,colorOperations:vo,cropOperations:bo,"*operationTooltip":null,"presence.mainToolbar":!0,"presence.subToolbar":!1,"presence.tabToggles":!0,"presence.tabContent.crop":!1,"presence.tabContent.tuning":!1,"presence.tabContent.filters":!1,"presence.tabToggle.crop":!0,"presence.tabToggle.tuning":!0,"presence.tabToggle.filters":!0,"presence.subTopToolbarStyles":{hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"},"presence.subBottomToolbarStyles":{hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"},"presence.tabContentStyles":{hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"},"presence.tabToggleStyles":{hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"},"presence.tabTogglesStyles":{hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"},"on.cancel":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t()},"on.apply":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t(this.$["*editorTransformations"])},"on.applySlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:Je(this.$["*operationTooltip"])}),this.ref["slider-el"].apply(),this._onSliderClose()},"on.cancelSlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this.ref["slider-el"].cancel(),this._onSliderClose()},"on.clickTab":e=>{let r=e.currentTarget?.getAttribute("data-id");r&&(this.telemetryManager.sendEventCloudImageEditor(e,r),this._activateTab(r,{fromViewer:!1}))},tab_role:"tab",[`tab_${L.TUNING}`]:`tab_${L.TUNING}`,[`tab_${L.CROP}`]:`tab_${L.CROP}`,[`tab_${L.FILTERS}`]:`tab_${L.FILTERS}`,cancel:"cancel",apply:"apply","a11y-editor-tab-filters":"a11y-editor-tab-filters","a11y-editor-tab-tuning":"a11y-editor-tab-tuning","a11y-editor-tab-crop":"a11y-editor-tab-crop"},this._debouncedShowLoader=M(this._showLoader.bind(this),500),this._updateInfoTooltip=M(this._updateInfoTooltipHandler.bind(this),0)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===L.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===L.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let t=new Ct;return t.operation=e,t}_createFilterControl(e){let t=new et;return t.filter=e,t}_createToggleControl(e){let t=new _t;return t.operation=e,t}_createAspectRatioControl(e){let t=new bt;return t.aspectRatio=e,t}_createFreeformControl(){return new Qe}_clearListAspectRatio(){let e=this.$["*listAspectRatioEl"];e&&(e.innerHTML="")}_renderControlsList(e){let t=this.ref[`controls-list-${e}`],r=document.createDocumentFragment();if(this._clearListAspectRatio(),e===L.CROP){let o=this.$["*cropPresetList"],s=o.length>=3;if(s){let n=this._createFreeformControl();r.appendChild(n)}for(let n of o){let a=this._createAspectRatioControl(n);r.appendChild(a),s&&this.$["*listAspectRatioEl"]?.appendChild(a)}for(let n of this.$.cropOperations){let a=this._createToggleControl(n);r.appendChild(a)}}else if(e===L.FILTERS){let o=this.$.filters;[ue,...o].forEach(s=>{let n=this._createFilterControl(s);r.appendChild(n)})}else if(e===L.TUNING)for(let o of this.$.colorOperations){let s=this._createOperationControl(o);r.appendChild(s)}[...r.children].forEach((o,s)=>{s===r.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),t.innerHTML="",t.appendChild(r)}_activateTab(e,{fromViewer:t}={}){this.$["*tabId"]=e;let r=this.$["*faderEl"],o=this.$["*cropperEl"];e===L.CROP?(r?.deactivate(),o?.activate(this.$["*imageSize"],{fromViewer:t})):(r?.activate({url:this.$["*originalUrl"],fromViewer:t}),o?.deactivate());for(let s of X){let n=s===e,a=this.ref[`tab-toggle-${s}`];a.active=n,n?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(s),this.$[`presence.tabContent.${s}`]=n}}_unmountTabControls(e){let t=this.ref[`controls-list-${e}`];t&&(t.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],t=this.ref["tabs-indicator"];t.style.transform=`translateX(${e.offsetLeft}px)`}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(it(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:r}=wt([t]);this._cancelPreload=()=>{r(),this._cancelPreload=void 0}}}_showLoader(e){this.$.showLoader=e}_updateInfoTooltipHandler(){let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],r="",o=!1;if(this.$["*tabId"]===L.FILTERS)if(o=!0,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let s=e?.filter?.amount||100;r=`${this.$["*currentFilter"]} ${s}`}else r=this.l10n(ue);else if(this.$["*tabId"]===L.TUNING&&t){o=!0;let s=e?.[t]||re[t].zero;r=`${this.l10n(t)} ${s}`}o&&(this.$["*operationTooltip"]=r),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)}initCallback(){super.initCallback(),this.$["*sliderEl"]=this.ref["slider-el"],this.$["*listAspectRatioEl"]=this.ref["list-el"],this.sub("*imageSize",e=>{e&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",e=>{let t=e?.filter?.name;this.$["*currentFilter"]!==t&&(this.$["*currentFilter"]=t)}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",()=>{this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(e)}),this.sub("*loadingOperations",e=>{let t=!1;for(let[,r]of e.entries()){if(t)break;for(let[,o]of r.entries())if(o){t=!0;break}}this._debouncedShowLoader(t)}),this.sub("*showSlider",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e,this.$.hideSliderOrList=!0}),this.sub("*showListAspectRatio",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e,this.$.hideSliderOrList=!1}),this.sub("*tabList",e=>{this.$["presence.tabToggles"]=e.length>1;for(let t of X){this.$[`presence.tabToggle.${t}`]=e.includes(t);let r=this.ref[`tab-toggle-${t}`];r.style.gridColumn=`${e.indexOf(t)+1}`}if(!e.includes(this.$["*tabId"])&&e.length>0){let[t]=e;t&&this._activateTab(t,{fromViewer:!1})}}),this._updateInfoTooltip()}destroyCallback(){this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}};vi.template=`<uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div ref="tooltip-el" class="uc-info-tooltip uc-info-tooltip_hidden">{{*operationTooltip}}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles" ><div class="uc-tab-content-row">${X.map(Dl).join("")}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" set="visible: presence.tabToggles; styles: presence.tabTogglesStyles" ><div ref="tabs-indicator" class="uc-tab-toggles_indicator"></div> ${X.map($l).join("")} </uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" set="onclick: on.cancel; title-prop:cancel"></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" set="onclick: on.apply; title-prop:apply"></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles" ><div class="uc-slider" set="@hidden:!hideSliderOrList"><uc-editor-slider ref="slider-el"></uc-editor-slider></div><div set="@hidden:hideSliderOrList" class="uc-list-aspect-ratio-container"><div class="uc-list-aspect-ratio" ref="list-el"></div></div><div class="uc-controls-row"><uc-btn-ui theme="secondary" set="onclick: on.cancelSlider; title-prop:cancel" l10n="@text:cancel"></uc-btn-ui><uc-btn-ui theme="primary" set="onclick: on.applySlider; title-prop:apply" l10n="@text:apply"></uc-btn-ui></div></uc-presence-toggle></div>`;var Et=class extends y{_iconReversed=!1;_iconSingle=!1;_iconHidden=!1;constructor(){super(),this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null,"aria-role":"","aria-controls":"","title-prop":""},this.defineAccessor("active",e=>{e?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return N("uc-icon",{"uc-icon_left":!this._iconReversed,"uc-icon_right":this._iconReversed,"uc-icon_hidden":this._iconHidden,"uc-icon_single":this._iconSingle})}initCallback(){super.initCallback(),this.sub("icon",e=>{this._iconSingle=!this.$.text,this._iconHidden=!e,this.$.iconCss=this._iconCss()}),this.sub("theme",e=>{e&&e!=="custom"&&(this.className=`uc-${e}`)}),this.sub("text",()=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",e=>{this.$["aria-role"]=e||""}),this.defineAccessor("aria-controls",e=>{this.$["aria-controls"]=e||""}),this.defineAccessor("title-prop",e=>{this.$["title-prop"]=e||""})}set reverse(e){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection="")}};Et.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});Et.template=`<button type="button" set="@role:aria-role; @aria-controls: aria-controls; @aria-label:title-prop" l10n="@title:title-prop;" ><uc-icon set="className: iconCss; @name: icon; @hidden: !icon"></uc-icon><div class="uc-text">{{text}}</div></button>`;var yi=class extends y{_active=!1;_handleTransitionEndRight=()=>{let e=this.ref["line-el"];e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)",this._active&&this._start()};initCallback(){super.initCallback(),this.defineAccessor("active",e=>{typeof e=="boolean"&&(e?this._start():this._stop())})}_start(){this._active=!0;let{width:e}=this.getBoundingClientRect(),t=this.ref["line-el"];t.style.transition="transform 1s",t.style.opacity="1",t.style.transform=`translateX(${e}px)`,t.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};yi.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var rt={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},bi=class extends y{_visible=!1;_visibleStyle=rt.visible;_hiddenStyle=rt.hidden;_externalTransitions=!1;constructor(){super(),this.defineAccessor("styles",e=>{e&&(this._externalTransitions=!0,this._visibleStyle=e.visible??rt.visible,this._hiddenStyle=e.hidden??rt.hidden)}),this.defineAccessor("visible",e=>{typeof e=="boolean"&&(this._visible=e,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",Is(this,{[rt.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.setAttribute("aria-hidden",this._visible?"false":"true")}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",!0),this._externalTransitions||this.classList.add(rt.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};bi.template="<slot></slot> ";var _i=class extends y{_observer;_thumbSize=0;_zero=0;_zeroDotEl;_stepsCount;constructor(){super(),this.init$={...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:0,"on.sliderInput":()=>{let e=Number.parseInt(this._inputEl().value,10);this._updateValue(e),this.$.onInput?.(e)},"on.sliderChange":()=>{let e=Number.parseInt(this._inputEl().value,10);this.$.onChange?.(e)}},this.setAttribute("with-effects","")}initCallback(){super.initCallback(),this.defineAccessor("disabled",t=>{this.$.disabled=t}),this.defineAccessor("min",t=>{this.$.min=t}),this.defineAccessor("max",t=>{this.$.max=t}),this.defineAccessor("defaultValue",t=>{this.$.defaultValue=t;let r=this._inputEl();r.value=String(t),this._updateValue(t)}),this.defineAccessor("zero",t=>{this._zero=t}),this.defineAccessor("onInput",t=>{t&&(this.$.onInput=t)}),this.defineAccessor("onChange",t=>{t&&(this.$.onChange=t)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let t=Number.parseInt(this._inputEl().value,10);this._updateValue(t)}),this._observer.observe(this),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let t=Number.parseInt(this._inputEl().value,10);this._updateValue(t)},0),this.sub("disabled",t=>{let r=this._inputEl();t?r.setAttribute("disabled","disabled"):r.removeAttribute("disabled")});let e=this._inputEl();e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_inputEl(){return this.ref["input-el"]}_thumbEl(){return this.ref["thumb-el"]}_stepsEl(){return this.ref["steps-el"]}_updateValue(e){this._updateZeroDot(e);let{width:t}=this.getBoundingClientRect(),s=100/(this.$.max-this.$.min)*(e-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._thumbEl().style.transform=`translateX(${s}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;this._zeroDotEl.style.opacity=e===this._zero?"0":"1";let{width:t}=this.getBoundingClientRect(),s=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${s}px)`)})}_updateSteps(){let t=this._stepsEl(),{width:r}=t.getBoundingClientRect(),o=Math.ceil(r/2),s=Math.ceil(o/15)-2;if(this._stepsCount===s)return;let n=document.createDocumentFragment(),a=document.createElement("div"),l=document.createElement("div");a.className="uc-minor-step",l.className="uc-border-step",n.appendChild(l);for(let d=0;d<s;d+=1)n.appendChild(a.cloneNode());n.appendChild(l.cloneNode());for(let d=0;d<s;d+=1)n.appendChild(a.cloneNode());n.appendChild(l.cloneNode());let c=document.createElement("div");c.className="uc-zero-dot",n.appendChild(c),this._zeroDotEl=c,t.innerHTML="",t.appendChild(n),this._stepsCount=s}destroyCallback(){super.destroyCallback(),this._observer?.disconnect()}};_i.template=`<div class="uc-steps" ref="steps-el"></div><div ref="thumb-el" class="uc-thumb"></div><input class="uc-input" type="range" ref="input-el" set="oninput: on.sliderInput; onchange: on.sliderChange; @min: min; @max: max; @value: defaultValue;" />`;var Ur=class extends O{couldBeCtxOwner=!0;activityType=f.activities.CLOUD_IMG_EDIT;_entry;_instance;get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.mountEditor(),onDeactivate:()=>this.unmountEditor()}),this.subConfigValue("cropPreset",e=>{this._instance&&this._instance.getAttribute("crop-preset")!==e&&this._instance.setAttribute("crop-preset",e)}),this.subConfigValue("cloudImageEditorTabs",e=>{this._instance&&this._instance.getAttribute("tabs")!==e&&this._instance.setAttribute("tabs",e)})}handleApply(e){if(!this._entry)return;let t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager?.close(f.activities.CLOUD_IMG_EDIT),this.historyBack()}handleCancel(){this.modalManager?.close(f.activities.CLOUD_IMG_EDIT),this.historyBack()}mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);let o=new we,s=this.cfg.cropPreset,n=this.cfg.cloudImageEditorTabs;o.setAttribute("ctx-name",this.ctxName),o.setAttribute("cdn-url",r),s&&o.setAttribute("crop-preset",s),n&&o.setAttribute("tabs",n),o.addEventListener("apply",a=>{let l=a;this.handleApply(l),this.debugPrint('editor event "apply"',l.detail)}),o.addEventListener("cancel",a=>{let l=a;this.handleCancel(),this.debugPrint('editor event "cancel"',l.detail)}),o.addEventListener("change",a=>{let l=a;this.debugPrint('editor event "change"',l.detail)}),this.innerHTML="",this.appendChild(o),this._instance=o}unmountEditor(){this._instance=void 0,this._entry=void 0,this.innerHTML=""}};var Tt=i=>i.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(e=>e.toLowerCase()).join("-");var Fl=[{test:i=>!!i.accept&&!!i.imgOnly,message:"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."},{test:i=>i.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:i=>i.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],$s=M(i=>{for(let{test:e,message:t}of Fl)e(i)&&li(t)},0);var Ds=(i,e)=>{let t=new URL(e);return t.hostname=`${i}.${t.hostname}`,t.toString().replace(/\/$/,"")},Vl="0123456789abcdefghijklmnopqrstuvwxyz",Fs=i=>{if(i<=0n)return"0";let e="";for(;i>0n;){let t=i%36n;e=Vl[Number(t)]+e,i=i/36n}return e},$r=(i,e)=>{try{let t=new URL(i),r=new URL(e);return t.hostname.endsWith(r.hostname)}catch{return!1}};var Nl=async i=>{let e=new TextEncoder().encode(i),t=await window.crypto.subtle.digest("SHA-256",e),r=Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join("");return BigInt(`0x${r}`)},Bl=10,zl=async i=>{let e=await Nl(i);return Fs(e).slice(0,Bl)},Vs=async(i,e)=>{let t=await zl(i);return Ds(t,e)};var Ns=i=>i instanceof Promise||!!(i&&typeof i=="object"&&"then"in i&&typeof i.then=="function");var Dr=i=>i,Hl=[Dr({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:i,enableVideoRecording:e})=>{if(e===null)return i;let t=q(i);return e&&!t.includes("video")?t=t.concat("video"):e||(t=t.filter(r=>r!=="video")),me(t)}}),Dr({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:i,defaultCameraMode:e})=>{if(e===null)return i;let t=q(i);return t=t.sort((r,o)=>r===e?-1:o===e?1:0),me(t)}}),Dr({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:i,cdnCname:e,cdnCnamePrefixed:t})=>i&&(e===ct||$r(e,t))?Vs(i,t):e})],Bs=({key:i,setValue:e,getValue:t,computationControllers:r})=>{for(let o of Hl)if(o.deps.includes(i)){let s={[o.key]:t(o.key)};for(let l of o.deps)s[l]=t(l);let n=new AbortController;r.get(o.key)?.abort(),r.set(o.key,n);let a;try{a=o.fn(s,{signal:n.signal})}catch(l){r.get(o.key)===n&&r.delete(o.key),console.error(`Failed to compute value for "${o.key}"`,l);return}Ns(a)?a.then(l=>{n.signal.aborted||e(o.key,l)}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${o.key}"`,l)}).finally(()=>{r.get(o.key)===n&&r.delete(o.key)}):e(o.key,a)}};var R=i=>String(i),z=i=>{let e=Number(i);if(Number.isNaN(e))throw new Error(`Invalid number: "${i}"`);return e},I=i=>{if(typeof i>"u"||i===null)return!1;if(typeof i=="boolean")return i;if(i==="true"||i==="")return!0;if(i==="false")return!1;throw new Error(`Invalid boolean: "${i}"`)},zs=i=>i==="auto"?i:I(i),Hs=i=>{let e=R(i);if(e!=="user"&&e!=="environment"&&e!=="")throw new Error(`Invalid value: "${e}"`);return e},js=i=>{let e=R(i);if(!Object.values(_).includes(e))throw new Error(`Invalid value: "${e}"`);return e},Ks=i=>{let e=R(i),t=q(e);if(t.some(r=>!Object.values(_).includes(r)))throw new Error(`Invalid value: "${JSON.stringify(t)}"`);return e},Gs=i=>{if(typeof i=="object"&&!Array.isArray(i)||typeof i=="function")return i;throw new Error("Invalid metadata value. Must be an object or function.")},Fr=i=>{if(typeof i=="object")return i;throw new Error("Invalid value. Must be an object.")},wi=i=>{if(typeof i=="function")return i;throw new Error("Invalid value. Must be a function.")},Vr=i=>{if(Array.isArray(i))return i;throw new Error("Must be an array.")},Ws=i=>{let e=R(i);if(["grid","list"].includes(e))return e;throw new Error(`Invalid value: "${e}"`)};var jl={pubkey:R,multiple:I,multipleMin:z,multipleMax:z,confirmUpload:I,imgOnly:I,accept:R,externalSourcesPreferredTypes:R,externalSourcesEmbedCss:R,store:zs,cameraMirror:I,cameraCapture:Hs,sourceList:R,topLevelOrigin:R,maxLocalFileSizeBytes:z,thumbSize:z,showEmptyList:I,useLocalImageEditor:I,useCloudImageEditor:I,cloudImageEditorTabs:R,removeCopyright:I,cropPreset:R,imageShrink:R,modalScrollLock:I,modalBackdropStrokes:I,sourceListWrap:I,remoteTabSessionKey:R,cdnCname:R,cdnCnamePrefixed:R,baseUrl:R,socialBaseUrl:R,secureSignature:R,secureExpire:R,secureDeliveryProxy:R,retryThrottledRequestMaxTimes:z,retryNetworkErrorMaxTimes:z,multipartMinFileSize:z,multipartChunkSize:z,maxConcurrentRequests:z,multipartMaxConcurrentRequests:z,multipartMaxAttempts:z,checkForUrlDuplicates:I,saveUrlForRecurrentUploads:I,groupOutput:I,userAgentIntegration:R,debug:I,localeName:R,metadata:Gs,secureUploadsExpireThreshold:z,localeDefinitionOverride:i=>Fr(i),secureUploadsSignatureResolver:i=>wi(i),secureDeliveryProxyUrlResolver:i=>wi(i),iconHrefResolver:i=>wi(i),fileValidators:Vr,collectionValidators:Vr,validationTimeout:z,validationConcurrency:z,cameraModes:Ks,defaultCameraMode:js,enableAudioRecording:I,enableVideoRecording:I,mediaRecorderOptions:Fr,maxVideoRecordingDuration:z,filesViewMode:Ws,gridShowFileNames:I,cloudImageEditorAutoOpen:I,cloudImageEditorMaskHref:R,testMode:I,qualityInsights:I},qs=(i,e)=>{if(!(typeof e>"u"||e===null))try{return jl[i](e)}catch(t){return console.error(`Invalid value for config key "${i}".`,t),Y[i]}};var Ci=[...new Set(["debug",...Object.keys(Y)])],Kl=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],Zs=i=>Kl.includes(i),xt=Ci.filter(i=>!Zs(i)),Gl={...Object.fromEntries(xt.map(i=>[Tt(i),i])),...Object.fromEntries(xt.map(i=>[i.toLowerCase(),i]))},Wl={...Object.fromEntries(xt.map(i=>[Tt(i),B(i)])),...Object.fromEntries(xt.map(i=>[i.toLowerCase(),B(i)]))},Xs=i=>`__${i}`,At=class extends y{requireCtxName=!0;constructor(){super(),this.init$={...this.init$,...Object.fromEntries(Object.entries(Y).map(([e,t])=>[B(e),t])),computationControllers:new Map}}_flushValueToAttribute(e,t){if(!Zs(e)){let r=[...new Set([Tt(e),e.toLowerCase()])];for(let o of r)typeof t>"u"||t===null?this.removeAttribute(o):this.getAttribute(o)!==t.toString()&&this.setAttribute(o,t.toString())}}_flushValueToState(e,t){this.$[B(e)]!==t&&(typeof t>"u"||t===null?this.$[B(e)]=Y[e]:this.$[B(e)]=t)}_setValue(e,t){let r=this,o=qs(e,t),s=Xs(e);r[s]!==o&&(this._assertSameValueDifferentReference(e,r[s],o),r[s]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),$s(this.cfg))}_getValue(e){let t=this,r=Xs(e);return t[r]??this.$[B(e)]}_assertSameValueDifferentReference(e,t,r){this.cfg.debug&&r!==t&&typeof r=="object"&&typeof t=="object"&&JSON.stringify(r)===JSON.stringify(t)&&(console.warn(`[uc-config] Option "${e}" 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] "${e}" previous value:`,t),console.warn(`[uc-config] "${e}" new value:`,r))}initCallback(){super.initCallback();let e=this;for(let t of xt)this.sub(B(t),r=>{this._setValue(t,r)},!1);for(let t of Ci){let r=e[t]??this.$[B(t)];r!==Y[t]&&this._setValue(t,r),Object.defineProperty(this,t,{set:o=>{this._setValue(t,o)},get:()=>this._getValue(t)})}for(let t of Ci)this.sub(B(t),()=>{Bs({key:t,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this.computationControllers})})}attributeChangedCallback(e,t,r){if(t===r)return;let o=this,s=Gl[e];s&&(o[s]=r)}get computationControllers(){return this.$.computationControllers}};At.bindAttributes(Wl);for(let i of Ci)At.prototype[i]=void 0;var Nr=class extends y{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",e=>{this.toggleAttribute("hidden",!!e)})}static template=`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`};function ql(i){return new Promise(e=>{typeof window.FileReader!="function"&&e(!1);try{let t=new FileReader;t.onerror=()=>{e(!0)};let r=o=>{o.type!=="loadend"&&t.abort(),e(!1)};t.onloadend=r,t.onprogress=r,t.readAsDataURL(i)}catch{e(!1)}})}function Xl(i,e){return new Promise(t=>{let r=0,o=[],s=a=>{if(!a){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),t(null);return}a.isFile?(r++,a.file(l=>{r--;let c=new File([l],l.name,{type:l.type||e});o.push({type:"file",file:c,fullPath:a.fullPath}),r===0&&t(o)})):a.isDirectory&&n(a.createReader())},n=a=>{r++,a.readEntries(l=>{r--;for(let c of l)s(c);r===0&&t(o)})};s(i)})}function Ys(i){let e=[],t=[];for(let r=0;r<i.items.length;r++){let o=i.items[r];if(o)if(o.kind==="file"){let s=o.type,n=o;if(typeof n.webkitGetAsEntry=="function"||typeof n.getAsEntry=="function"){let l=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():n.getAsEntry?.();l&&t.push(Xl(l,s).then(c=>{c&&e.push(...c)}));continue}let a=o.getAsFile();a&&t.push(ql(a).then(l=>{l||e.push({type:"file",file:a})}))}else o.kind==="string"&&/^text\/uri-list/.test(o.type)&&t.push(new Promise(s=>{o.getAsString(n=>{e.push({type:"url",url:n}),s()})}))}return Promise.all(t).then(()=>e)}var G=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),Qs=["focus"],Zl=100,Br=new Map;function Yl(i,e){let t=Math.max(Math.min(i[0],e.x+e.width),e.x),r=Math.max(Math.min(i[1],e.y+e.height),e.y);return Math.sqrt((i[0]-t)*(i[0]-t)+(i[1]-r)*(i[1]-r))}function zr(i){let e=0,t=document.body,r=new Set,o=h=>{r.add(h)},s=G.INACTIVE,n=h=>{i.shouldIgnore()&&h!==G.INACTIVE||(s!==h&&r.forEach(g=>{g(h)}),s=h)},a=()=>e>0;o(h=>i.onChange(h));let l=()=>{e=0,n(G.INACTIVE)},c=()=>{e+=1,s===G.INACTIVE&&n(G.ACTIVE)},d=()=>{e-=1,a()||n(G.INACTIVE)},u=h=>{h.preventDefault(),e=0,n(G.INACTIVE)},p=h=>{if(i.shouldIgnore())return;a()||(e+=1);let g=[h.x,h.y],v=i.element.getBoundingClientRect(),A=Math.floor(Yl(g,v)),C=A<Zl,x=h.composedPath().includes(i.element);Br.set(i.element,A);let J=Math.min(...Br.values())===A;x&&J?(h.preventDefault(),n(G.OVER)):n(C&&J?G.NEAR:G.ACTIVE)},m=async h=>{if(i.shouldIgnore())return;h.preventDefault();let{dataTransfer:g}=h;if(!g)return;let v=await Ys(g);i.onItems(v),n(G.INACTIVE)};return t.addEventListener("drop",u),t.addEventListener("dragleave",d),t.addEventListener("dragenter",c),t.addEventListener("dragover",p),i.element.addEventListener("drop",m),Qs.forEach(h=>{window.addEventListener(h,l)}),()=>{Br.delete(i.element),t.removeEventListener("drop",u),t.removeEventListener("dragleave",d),t.removeEventListener("dragenter",c),t.removeEventListener("dragover",p),i.element.removeEventListener("drop",m),Qs.forEach(h=>{window.removeEventListener(h,l)})}}var Js="uc-drop-area",Ei=`${Js}/registry`,St=class extends O{static styleAttrs=[...super.styleAttrs,"uc-drop-area"];_destroyDropzone=null;_destroyContentWrapperDropzone=null;_onAreaClicked=null;constructor(){super(),this.init$={...this.init$,state:G.INACTIVE,withIcon:!1,isClickable:!1,isFullscreen:!1,isEnabled:!0,isVisible:!0,isInitFlow:!1,text:"",[Ei]:new Set}}isActive(){if(!this.$.isEnabled)return!1;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),o=window.getComputedStyle(this),s=o.visibility!=="hidden"&&o.display!=="none";return t&&s&&r}initCallback(){super.initCallback(),this.bindL10n("text",()=>this.l10n("drop-files-here")),this.$[Ei].add(this),this.defineAccessor("disabled",r=>{this.set$({isEnabled:!I(r)})}),this.defineAccessor("clickable",r=>{this.set$({isClickable:I(r)})}),this.defineAccessor("initflow",r=>{this.set$({isInitFlow:I(r)})}),this.defineAccessor("with-icon",r=>{this.set$({withIcon:I(r)})}),this.defineAccessor("fullscreen",r=>{this.set$({isFullscreen:I(r)})}),this.defineAccessor("text",r=>{typeof r=="string"?this.bindL10n("text",()=>this.l10n(r)||r):this.bindL10n("text",()=>this.l10n("drop-files-here"))}),this._destroyDropzone=zr({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:r=>{this.$.state=r},onItems:r=>{r.length&&(r.forEach(o=>{o.type==="url"?this.api.addFileFromUrl(o.url,{source:P.DROP_AREA}):o.type==="file"&&this.api.addFileFromObject(o.file,{source:P.DROP_AREA,fullPath:o.fullPath})}),this.uploadCollection.size&&(this.modalManager?.open(f.activities.UPLOAD_LIST),this.set$({"*currentActivity":f.activities.UPLOAD_LIST})))}});let t=this.ref["content-wrapper"];if(t&&(this._destroyContentWrapperDropzone=zr({element:t,onChange:r=>{let o=Object.entries(G).find(([,s])=>s===r)?.[0].toLowerCase();o&&t.setAttribute("drag-state",o)},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()})),this.sub("state",r=>{let o=Object.entries(G).find(([,s])=>s===r)?.[0].toLowerCase();o&&this.setAttribute("drag-state",o)}),this.subConfigValue("sourceList",r=>{let o=$(r);this.$.isEnabled=o.includes(P.LOCAL),this.$.isVisible=this.$.isEnabled||!this.querySelector("[data-default-slot]")}),this.sub("isVisible",r=>{this.toggleAttribute("hidden",!r)}),this.sub("isClickable",r=>{this.toggleAttribute("clickable",r)}),this.$.isClickable){let r=o=>{if(o instanceof KeyboardEvent){if(o.code==="Space"||o.code==="Enter"){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}}else if(o instanceof MouseEvent){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}};this._onAreaClicked=r,this.addEventListener("keydown",r),this.addEventListener("click",r)}}_shouldIgnore(){if(!this.$.isEnabled||!this._couldHandleFiles())return!0;if(!this.$.isFullscreen)return!1;let e=this.$[Ei];return e.size===0?!1:[...e].filter(o=>o!==this).filter(o=>o.isActive()).length>0}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,r=this.uploadCollection.size;return!(e&&t&&r>=t||!e&&r>0)}destroyCallback(){super.destroyCallback();let e=this.$[Ei];e.delete(this),e.size===0&&E.deleteCtx(Js),this._destroyDropzone?.(),this._destroyContentWrapperDropzone?.(),this._onAreaClicked&&(this.removeEventListener("keydown",this._onAreaClicked),this.removeEventListener("click",this._onAreaClicked),this._onAreaClicked=null)}};St.template=`<slot><div data-default-slot hidden></div><div ref="content-wrapper" class="uc-content-wrapper" set="@hidden: !isVisible"><div class="uc-icon-container" set="@hidden: !withIcon"><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">{{text}}</span></div></slot>`;St.bindAttributes({"with-icon":null,clickable:null,text:null,fullscreen:null,disabled:null,initflow:null});var en=()=>{let i=globalThis.top??globalThis.parent??globalThis.self;try{return i.location.origin}catch(e){return console.warn("Unable to access top-level window location:",e),globalThis.location.origin}};var Ql=i=>i.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),tn=(i,e="i")=>{let t=i.split("*").map(Ql);return new RegExp(`^${t.join(".+")}$`,e)};var Jl=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],ec=(i,e)=>window.getComputedStyle(i).getPropertyValue(e).trim(),rn=i=>{let e={};for(let t of Jl){let r=ec(i,t);r&&(e[t]=r)}return e};var tc=["selected-files-change","toolbar-state-change"],ic=i=>{if(!i||typeof i!="object"||!("type"in i))return!1;let e=i.type;return!(typeof e!="string"||!tc.includes(e))},Ti=class{_handlerMap=new Map;_context;_getTargetOrigin;constructor(e,t){this._context=e,this._getTargetOrigin=t,window.addEventListener("message",this._handleMessage)}_handleMessage=e=>{if(e.source!==this._context)return;let t=e.data;if(!ic(t))return;let r=this._handlerMap.get(t.type);if(r)for(let o of r)o(t)};on(e,t){let r=this._handlerMap.get(e)??new Set;this._handlerMap.has(e)||this._handlerMap.set(e,r),r.add(t)}send(e){let t=this._getTargetOrigin();this._context.postMessage(e,t)}destroy(){window.removeEventListener("message",this._handleMessage)}};function on(i){let e=[];for(let[t,r]of Object.entries(i))r==null||typeof r=="string"&&r.length===0||e.push(`${t}=${encodeURIComponent(r)}`);return e.join("&")}var rc={[le.GDRIVE]:"ngdrive"},xi=class extends O{couldBeCtxOwner=!0;activityType=f.activities.EXTERNAL;_messageBridge;constructor(){super(),this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],total:0,isSelectionReady:!1,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1,showDoneBtn:!1,counterText:"",doneBtnTextClass:"uc-hidden",toolbarVisible:!0,onDone:()=>{for(let e of this.$.selectedList){let t=this.extractUrlFromSelectedFile(e),{filename:r}=e,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(t,{fileName:r,source:o})}this.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.modalManager?.open(f.activities.UPLOAD_LIST)},onCancel:()=>{this.historyBack()},onSelectAll:()=>{this._messageBridge?.send({type:"select-all"})},onDeselectAll:()=>{this._messageBridge?.send({type:"deselect-all"})}}}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:e}=this.activityParams;if(!e){this.modalManager?.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.set$({activityCaption:`${e[0]?.toUpperCase()}${e?.slice(1)}`,activityIcon:e}),this.mountIframe()}}),this.sub("*currentActivityParams",e=>{this.isActivityActive&&(this.unmountIframe(),this.mountIframe())}),this.sub("*currentActivity",e=>{e!==this.activityType&&this.unmountIframe()}),this.subConfigValue("multiple",e=>{this.$.showSelectionStatus=e}),this.subConfigValue("localeName",e=>{this.setupL10n()}),this.subConfigValue("externalSourcesEmbedCss",e=>{this.applyEmbedCss(e)})}extractUrlFromSelectedFile(e){if(e.alternatives){let t=$(this.cfg.externalSourcesPreferredTypes);for(let r of t){let o=tn(r);for(let[s,n]of Object.entries(e.alternatives))if(o.test(s))return n}}return e.url}handleToolbarStateChange(e){this.set$({toolbarVisible:e.isVisible})}async handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this.bindL10n("counterText",()=>this.l10n("selected-count",{count:e.selectedCount,total:e.total})),this.set$({doneBtnTextClass:e.isReady?"":"uc-hidden",isSelectionReady:e.isReady,isDoneBtnEnabled:e.isReady&&e.selectedFiles.length>0,showSelectionStatus:e.isMultipleMode&&e.total>0,couldSelectAll:e.selectedCount<e.total,couldDeselectAll:e.selectedCount===e.total,selectedList:e.selectedFiles,showDoneBtn:e.total>0})}handleIframeLoad(){this.applyEmbedCss(this.cfg.externalSourcesEmbedCss),this.applyTheme(),this.setupL10n()}applyTheme(){this._messageBridge?.send({type:"set-theme-definition",theme:rn(this)})}applyEmbedCss(e){this._messageBridge?.send({type:"set-embed-css",css:e})}setupL10n(){this._messageBridge?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:r,multiple:o}=this.cfg,{externalSourceType:s}=this.activityParams,n=rc[s]??s,l={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:!0,multiple:o.toString(),origin:this.cfg.topLevelOrigin||en(),debug:this.cfg.debug},c=new URL(`/window4/${n}`,r);return c.search=on(l),c.toString()}mountIframe(){let e=Wi({tag:"iframe",attributes:{src:this.remoteUrl(),marginheight:0,marginwidth:0,frameborder:0,allowTransparency:!0}});e.addEventListener("load",this.handleIframeLoad.bind(this)),this.ref.iframeWrapper.innerHTML="",this.ref.iframeWrapper.appendChild(e),e.contentWindow&&(this._messageBridge?.destroy(),this._messageBridge=new Ti(e.contentWindow,()=>this.cfg.socialBaseUrl),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this.handleToolbarStateChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){this._messageBridge?.destroy(),this._messageBridge=void 0,this.ref.iframeWrapper.innerHTML="",this.resetSelectionStatus()}resetSelectionStatus(){this.set$({selectedList:[],total:0,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1,showDoneBtn:!1})}};xi.template=`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *historyBack" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ref="iframeWrapper" class="uc-iframe-wrapper"></div><div class="uc-toolbar" set="@hidden: !toolbarVisible"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel" l10n="cancel"></button><div set="@hidden: !showSelectionStatus" class="uc-selection-status-box"><span>{{counterText}}</span><button type="button" set="onclick: onSelectAll; @hidden: !couldSelectAll" l10n="select-all"></button><button type="button" set="onclick: onDeselectAll; @hidden: !couldDeselectAll" l10n="deselect-all"></button></div><button type="button" class="uc-done-btn uc-primary-btn" set="onclick: onDone; @disabled: !isDoneBtnEnabled; @hidden: !showDoneBtn" ><uc-spinner set="@hidden: isSelectionReady"></uc-spinner><span l10n="done" set="@class: doneBtnTextClass"></span></button></div></div>`;var Si=()=>{let i=[];return{stack:i,promiseReadJpegChunks:t=>new Promise((r,o)=>{let s=2,n=(c,d)=>{let u=new FileReader;u.addEventListener("load",()=>{d(new DataView(u.result))}),u.addEventListener("error",p=>{o(`Reader error: ${p}`)}),u.readAsArrayBuffer(c)},a=()=>n(t.slice(s,s+128),c=>{let d,u,p;for(d=u=0,p=c.byteLength;p>=0?u<p:u>p;d=p>=0?++u:--u)if(c.getUint8(d)===255){s+=d;break}l()}),l=()=>{let c=s;return n(t.slice(s,s+=4),d=>{if(d.byteLength!==4||d.getUint8(0)!==255){o("Corrupted");return}let u=d.getUint8(1);if(u===218){r(!0);return}let p=d.getUint16(2)-2;return n(t.slice(s,s+=p),m=>{if(m.byteLength!==p){o("Corrupted");return}i.push({startPos:c,length:p,marker:u,view:m}),a()})})};FileReader&&DataView||o("Not Support"),n(t.slice(0,2),c=>{c.getUint16(0)!==65496&&o("Not jpeg"),a()})})}},oc=async i=>{let e=[],{promiseReadJpegChunks:t,stack:r}=Si();return await t(i),r.forEach(({marker:o,view:s})=>{o===226&&s.getUint32(0)===1229144927&&s.getUint32(4)===1347571526&&s.getUint32(8)===1229735168&&e.push(s)}),e},nn=async(i,e,t)=>{{let r=[],o=[],{promiseReadJpegChunks:s,stack:n}=Si();await s(i),n.forEach(c=>{if(c.marker===e)return r.push(c.startPos),o.push(c.length)});let a=[i.slice(0,2)];for(let c of t){let d=new DataView(new ArrayBuffer(4));d.setUint16(0,65280+e),d.setUint16(2,c.byteLength+2),a.push(d.buffer),a.push(c)}let l=2;for(let c=0;c<r.length;c++)r[c]>l&&a.push(i.slice(l,r[c])),l=r[c]+o[c]+4;return a.push(i.slice(l,i.size)),new Blob(a,{type:i.type})}};var an=(i,e)=>nn(i,226,e.map(t=>t.buffer)),sc=async i=>{try{return await an(i,[])}catch(e){throw new Error(`Failed to strip ICC profile: ${e}`)}},nc=(i,e,t)=>new Promise((r,o)=>{let s=n=>{if(!n){o("Failed to convert canvas to blob");return}r(n)};i.toBlob(s,e,t),i.width=i.height=1}),It=()=>{let i=document.createElement("canvas"),e=i.getContext("2d");return{canvas:i,ctx:e}},ac=i=>{let{ctx:t,canvas:r}=It();r.width=r.height=50,t.drawImage(i,0,0,50,50);let o=t.getImageData(0,0,50,50).data;r.width=r.height=1;for(let s=3;s<o.length;s+=4)if(o[s]<254)return!0;return!1},lc=async i=>{let e=null,{promiseReadJpegChunks:t,stack:r}=Si();return await t(i),r.forEach(({marker:o,view:s})=>{if(!e&&o===225&&s.byteLength>=14&&s.getUint32(0)===1165519206&&s.getUint16(4)===0){e=s;return}}),e},cc="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",Ai,dc=()=>new Promise(i=>{if(Ai!==void 0)i(Ai);else{let e=new Image;e.addEventListener("load",()=>{Ai=e.naturalWidth<e.naturalHeight,e.src="//:0",i(Ai)}),e.src=cc}}),uc=(i,e)=>{let t,r,o,s;if(!i||i.byteLength<14||i.getUint32(0)!==1165519206||i.getUint16(4)!==0)return;if(i.getUint16(6)===18761)r=!0;else if(i.getUint16(6)===19789)r=!1;else return;if(i.getUint16(8,r)!==42)return;o=8+i.getUint32(10,r);let n=i.getUint16(o-2,r);for(t=0,s=n;s>=0?t<s:t>s;s>=0?++t:--t){if(i.byteLength<o+10)return;i.getUint16(o,r)===274&&e(o+8,r),o+=12}},pc=(i,e)=>{uc(i,(t,r)=>i.setUint16(t,e,r))},hc=async(i,e,t)=>(t&&pc(e,1),nn(i,225,[e.buffer])),mc=(i,e)=>new Promise((t,r)=>{e&&(i.src=e),i.complete?t(i):(i.addEventListener("load",()=>{t(i)}),i.addEventListener("error",()=>{r(new Error("Failed to load image. Probably not an image."))}))}),fc=i=>mc(new Image,i),gc=[1,3],vc=[192,193,194,195,197,198,199,201,202,203,205,206,207],sn={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},yc=async i=>{let e=!1,{promiseReadJpegChunks:t,stack:r}=Si();return await t(i).then(()=>(r.forEach(({marker:o,view:s})=>{if(!e&&vc.indexOf(o)>=0){let n=s.getUint8(5);gc.indexOf(n)<0&&(e=!0)}}),e)).catch(()=>e)},ln=(i,e)=>{let t={};return(...r)=>{let o=e(r,t);return o in t?t[o]:t[o]=i(...r)}},cn=(i,e)=>{let[t]=i,r=Object.keys(e).map(o=>parseInt(o,10)).sort((o,s)=>o-s);for(let o=0;o<r.length;o++){let s=r[o],n=!!e[s];if(s>t&&n||s<t&&!n)return s}return t},Pe={R:55,G:110,B:165,A:255},bc=`rgba(${Pe.R}, ${Pe.G}, ${Pe.B}, ${Pe.A/255})`,dn=(i,e)=>{try{let t=[i-1,e-1,1,1],{canvas:r,ctx:o}=It();r.width=1,r.height=1;let{canvas:s,ctx:n}=It();s.width=i,s.height=e,n&&(n.fillStyle=bc,n.fillRect(...t),o.drawImage(s,i-1,e-1,1,1,0,0,1,1));let a=o&&o.getImageData(0,0,1,1).data,l=!1;return a&&(l=a[0]===Pe.R&&a[1]===Pe.G&&a[2]===Pe.B&&a[3]===Pe.A),s.width=s.height=1,l}catch{return console.error(`Failed to test for max canvas size of ${i}x${e}.`),!1}};function un(i){return(...e)=>new Promise(t=>{setTimeout(()=>{let r=i(...e);t(r)},0)})}var _c=un(ln(dn,cn)),wc=un(ln(dn,cn)),pn=async(i,e)=>{let t=sn.squareSide.find(n=>n*n>=i*e),r=sn.dimension.find(n=>n>=i&&n>=e);if(!t||!r)throw new Error("Not supported");let[o,s]=await Promise.all([_c(t,t),wc(r,1)]);if(o&&s)return!0;throw new Error("Not supported")},hn=async(i,e,t)=>{try{let{ctx:r,canvas:o}=It();return o.width=e,o.height=t,r.imageSmoothingQuality="high",r.drawImage(i,0,0,e,t),i instanceof HTMLImageElement&&(i.src="//:0"),i instanceof HTMLCanvasElement&&(i.width=i.height=1),o}catch(r){throw new Error("Canvas resize error",{cause:r})}},Cc=({img:i,targetW:e,targetH:t})=>hn(i,e,t),Ec=function({sourceW:i,targetW:e,targetH:t,step:r}){let o=[],s=e,n=t;do o.push([s,n]),s=Math.round(s/r),n=Math.round(n/r);while(s<i*r);return o.reverse()},Tc=({img:i,sourceW:e,targetW:t,targetH:r,step:o})=>{let s=Ec({sourceW:e,targetW:t,targetH:r,step:o});return s.reduce((n,[a,l],c)=>n.then(d=>pn(a,l).then(()=>hn(d,a,l)).catch(()=>{if(c===s.length-1)throw new Error("Not supported");return d})),Promise.resolve(i))},xc=()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Ac=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Hr=.71,Sc=(i,e)=>{if(i.width*Hr*i.height*Hr<e.size)throw new Error("Not required");let t=i.width,r=i.height,o=t/r,s=Math.floor(Math.sqrt(e.size*o)),n=Math.floor(e.size/Math.sqrt(e.size*o));return pn(s,n).then(()=>{let{ctx:a}=It();return"imageSmoothingQuality"in a&&!xc()&&!Ac?Cc({img:i,targetW:s,targetH:n}):Tc({img:i,sourceW:t,targetW:s,targetH:n,step:Hr})}).catch(()=>Promise.reject("Not supported"))},mn=async(i,e)=>{try{if(await yc(i))throw new Error("Should skipped");let r=await Promise.allSettled([lc(i),dc(),oc(i)]),s=!r.some(g=>g.status==="rejected"),[n,a,l]=r,c=await sc(i).catch(()=>i),d=await fc(URL.createObjectURL(c));URL.revokeObjectURL(d.src);let u=await Sc(d,e),p="image/jpeg",m=e?.quality||.8;!s&&ac(u)&&(p="image/png",m=void 0);let h=await nc(u,p,m);if(s&&n.status==="fulfilled"&&n.value){let g=n.value,v=a.status==="fulfilled"?a.value:!1;h=await hc(h,g,v)}return s&&l.status==="fulfilled"&&l.value.length>0&&(h=await an(h,l.value)),h}catch(t){let r;throw t instanceof Error&&(r=t.message),typeof t=="string"&&(r=t),new Error(`Failed to shrink image. ${r?`Message: "${r}".`:""}`,{cause:t})}};var Ic=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,fn=i=>{if(typeof i!="string")return!1;let e=Ic.exec(i.toLocaleLowerCase())??[];if(e.length===0)return!1;let t=Number(e[1])*Number(e[2]),r=16384*16384;return t>r?(console.warn(`Shrinked size can not be larger than ${Math.floor(r/1e3/1e3)}MP. You have set ${e[1]}x${e[2]} (${Math.ceil(t/1e3/100)/10}MP).`),!1):{quality:e[3]?Number(e[3])/100:void 0,size:t}};var ot=class extends O{_entrySubs=new Set;_entry=null;_withEntry(e){return(...t)=>{let r=this._entry;if(!r){console.warn("No entry found");return}return e(r,...t)}}_subEntry(e,t){this._withEntry((r,o,s)=>{let n=r.subscribe(o,a=>{this.isConnected&&s(a)});this._entrySubs.add(n)})(e,t)}_reset(){for(let e of this._entrySubs)e.remove();this._entrySubs=new Set,this._entry=null}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set}};var F=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),jr=class i extends ot{couldBeCtxOwner=!0;pauseRender=!0;_renderedOnce=!1;_observer;_isIntersecting=!1;_thumbRect;constructor(){super(),this.init$={...this.init$,uid:"",itemName:"",errorText:"",hint:"",thumbUrl:"",progressValue:0,progressVisible:!1,badgeIcon:"",isFinished:!1,isFailed:!1,isUploading:!1,isFocused:!1,isEditable:!1,showFileNames:!1,state:F.IDLE,ariaLabelStatusFile:"",onEdit:this._withEntry(e=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"edit-file",node:this.tagName}}}),this.$["*currentActivityParams"]={internalId:e.uid},this.modalManager?.open(f.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=f.activities.CLOUD_IMG_EDIT}),onRemove:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uploadCollection.remove(this.$.uid)},onUpload:()=>{this.upload()}}}_calculateState=this._withEntry(e=>{let t=F.IDLE;e.getValue("errors").length>0?t=F.FAILED:e.getValue("isQueuedForUploading")?t=F.QUEUED_UPLOADING:e.getValue("isQueuedForValidation")?t=F.QUEUED_VALIDATION:e.getValue("isValidationPending")?t=F.VALIDATION:e.getValue("isUploading")?t=F.UPLOADING:e.getValue("fileInfo")&&(t=F.FINISHED),this.$.state=t});_debouncedCalculateState=M(this._calculateState.bind(this),100);_updateHintAndProgress=this._withEntry(tt((e,t)=>{let r=e.getValue("errors")?.[0]?.message,o=e.getValue("source"),s=e.getValue("externalUrl"),n=t===F.FINISHED,a=t===F.UPLOADING,l=t===F.QUEUED_UPLOADING,c=t===F.QUEUED_VALIDATION,d=t===F.VALIDATION,u=e.getValue("fileName"),p="";r?p="":!n&&s&&o&&Object.values(le).includes(o)&&(p=this.l10n("waiting-for",{source:this.l10n(`src-type-${o}`)}));let m=e.getValue("uploadProgress"),h=m===100?100:c||d?0:m,g=a||l||c||d;this.set$({hint:p,errorText:r,progressVisible:g,progressValue:h,ariaLabelStatusFile:u&&this.l10n("a11y-file-item-status",{fileName:u,status:this.l10n(t?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()})})},100));_handleState=this._withEntry((e,t)=>{t===F.FAILED?this.$.badgeIcon="badge-error":t===F.FINISHED&&(this.$.badgeIcon="badge-success"),t===F.UPLOADING&&(this.$.isFocused=!1),this.set$({isFailed:t===F.FAILED,isUploading:t===F.UPLOADING,isFinished:t===F.FINISHED,isEditable:this.cfg.useCloudImageEditor&&e.getValue("isImage")&&e.getValue("cdnUrl")}),this._updateHintAndProgress(t)});_reset(){super._reset(),this._debouncedCalculateState.cancel()}_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,this._thumbRect=t.boundingClientRect,t.isIntersecting&&!this._renderedOnce&&(this.render(),this._renderedOnce=!0))}_handleEntryId(e){this._reset();let t=this.uploadCollection?.read(e);this._entry=t,t&&(this._subEntry("isQueuedForValidation",()=>{this._debouncedCalculateState()}),this._subEntry("isValidationPending",()=>{this._debouncedCalculateState()}),this._subEntry("uploadProgress",()=>{this._debouncedCalculateState()}),this._subEntry("isQueuedForUploading",()=>{this._debouncedCalculateState()}),this._subEntry("fileName",r=>{this.$.itemName=r||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",r=>{this.$.itemName=t.getValue("fileName")||r||this.l10n("file-no-name")}),this._subEntry("fileInfo",()=>{this._debouncedCalculateState()}),this._subEntry("errors",()=>this._debouncedCalculateState()),this._subEntry("isUploading",()=>this._debouncedCalculateState()),this._subEntry("fileSize",()=>this._debouncedCalculateState()),this._subEntry("mimeType",()=>this._debouncedCalculateState()),this._subEntry("isImage",()=>this._debouncedCalculateState()))}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this.$.showFileNames=!0;return}this.$.showFileNames=e}initCallback(){super.initCallback(),this.sub("uid",e=>{this._handleEntryId(e)}),this.sub("state",e=>{this._handleState(e)}),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.subConfigValue("filesViewMode",e=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",e)}),this.subConfigValue("gridShowFileNames",e=>{this._updateShowFileNames(e)}),this.onclick=()=>{i.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{this._entry&&!e.has(this._entry.uid)||setTimeout(()=>this.isConnected&&this.upload())}),i.activeInstances.add(this)}destroyCallback(){super.destroyCallback(),i.activeInstances.delete(this),this._reset()}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect()}_settingsOfShrink(){return fn(this.cfg.imageShrink)}async _processShrink(e){let t=this._settingsOfShrink();return t?await mn(e,t):(console.warn("Image shrink settings are invalid, skipping shrinking"),e)}upload=this._withEntry(async e=>{if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0||e.getValue("isValidationPending"))return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){e.setMultipleValues({isUploading:!0,errors:[],isQueuedForUploading:!0}),this._debouncedCalculateState();try{let r=new AbortController;e.setValue("abortController",r);let o=async()=>{e.setValue("isQueuedForUploading",!1);let n=e.getValue("file");if(n instanceof File&&this.cfg.imageShrink)try{n=await this._processShrink(n)}catch{}let a=n||e.getValue("externalUrl")||e.getValue("uuid");if(!a)throw new Error("No file input");let c={...await this.getUploadClientOptions(),fileName:e.getValue("fileName")??void 0,source:e.getValue("source")??void 0,onProgress:d=>{if(d.isComputable){let u=d.value*100;e.setValue("uploadProgress",u)}},signal:r.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",a,c),lr(a,c)},s=await this.$["*uploadQueue"].add(o);e.setMultipleValues({fileInfo:s,isQueuedForUploading:!1,isUploading:!1,fileName:s.originalFilename,fileSize:s.size,isImage:s.isImage??!1,mimeType:s.contentInfo?.mime?.mime??s.mimeType,uuid:s.uuid,cdnUrl:e.getValue("cdnUrl")??s.cdnUrl,cdnUrlModifiers:e.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:e.getValue("source")??null}),e===this._entry&&this._debouncedCalculateState()}catch(r){this.telemetryManager.sendEventError(r,"file upload. Failed to upload file"),r instanceof Ae&&r.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):r instanceof $e?e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:r}):(console.error("Unknown upload error",r),e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:r})})),e===this._entry&&this._debouncedCalculateState()}}});static template=`<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused"><uc-thumb set="uid:uid;badgeIcon:badgeIcon"></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;"><span class="uc-file-name" set="@hidden: !showFileNames">{{itemName}}</span><span class="uc-file-error" set="@hidden: !errorText;">{{errorText}}</span><span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span></div><div class="uc-file-actions"><button type="button" l10n="@title:file-item-edit-button;@aria-label:file-item-edit-button" class="uc-edit-btn uc-mini-btn" set="onclick: onEdit; @hidden: !isEditable" data-testid="edit" ><uc-icon name="edit-file"></uc-icon></button><button type="button" l10n="@title:file-item-remove-button;@aria-label:file-item-remove-button" class="uc-remove-btn uc-mini-btn" set="onclick: onRemove;" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" set="onclick: onUpload;"><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" set="value: progressValue; visible: progressVisible; @hasFileName: showFileNames;" ></uc-progress-bar></div>`;static activeInstances=new Set};var Kr=class extends O{requireCtxName=!0;_validationInputElement=null;_dynamicInputsContainer=null;_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,at(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{{if(!this._dynamicInputsContainer){let s=document.createElement("div");this.appendChild(s),this._dynamicInputsContainer=s}if(!this._validationInputElement){let s=this._createValidationInput();this.appendChild(s),this._validationInputElement=s}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let s=e.errors[0]?.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(s??"");return}let t=e.group?e.group:null;if(t){this._validationInputElement.value=t.cdnUrl??"",this._validationInputElement.setCustomValidity("");return}let r=e.allEntries.map(s=>s.cdnUrl).filter(s=>typeof s=="string");if(!this.cfg.multiple&&r.length===1&&r[0]){this._validationInputElement.value=r[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let o=new DocumentFragment;for(let s of r){let n=document.createElement("input");n.type="hidden",n.name=`${this.ctxName}[]`,n.value=s,o.appendChild(n)}this._dynamicInputsContainer.replaceChildren(o)}},!1)}};var kt=class extends y{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",e=>{if(!e)return;let t=`#uc-icon-${e}`;this.subConfigValue("iconHrefResolver",r=>{r&&(t=r(e)??t),this.$.href=t})}),this.setAttribute("aria-hidden","true")}};kt.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;kt.bindAttributes({name:"name"});var gn=i=>[...new Set(i)];var st="--uc-img-",Gr="unresolved";var Wr=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),qr=3e3,Xr=5e3,Zr=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var kc="https://ucarecdn.com",Ot=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:kc},"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 vn=Object.create(null);for(let i in Ot)vn[st+i]=Ot[i]?.default||"";var Ii=class extends Ee{cssInit$=vn;$$(e){return this.$[st+e]}set$$(e){for(let t in e)this.$[st+t]=e[t]}sub$$(e,t){this.sub(st+e,r=>{r===null||r===""||t(r)})}analyticsParams(){return`-/@clib/${Oe}/${Me}/uc-img/`}initAttributes(e){[...this.attributes].forEach(t=>{Ot[t.name]||e.setAttribute(t.name,t.value)})}initIntersection(e,t){let r={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(s=>{s.isIntersecting&&(t(),this._isnObserver.unobserve(e))})},r),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e)}destroyCallback(){super.destroyCallback(),this._isnObserver&&(this._observed.forEach(e=>{this._isnObserver.unobserve(e)}),this._isnObserver=null),E.deleteCtx(this)}static get observedAttributes(){return Object.keys(Ot)}attributeChangedCallback(e,t,r){window.setTimeout(()=>{this.$[st+e]=r})}};var yn=i=>Object.entries(i).filter(([e,t])=>t!==void 0&&t!=="").map(([e,t])=>e==="cdn-operations"||e==="analytics"?t:`${e}/${t}`);var Mi=class extends Ii{_img=new Image;_imgPreview=new Image;_fmtAbs(e){return!e.includes("//")&&!Wr&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if(e?.trim()!==""){let t=e.match(/\d+/)[0],r=e.match(/[a-zA-Z]+/)[0],o=parseInt(t,10);if(Number(o)>Xr&&this.hasFormatJPG)return Xr+r;if(Number(o)>qr&&!this.hasFormatJPG)return qr+r}return e}_getCdnModifiers(e,t){let r={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return H(...yn(r))}_getUrlBase(e="",t=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(Wr&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let r=this._getCdnModifiers(e,t);if(this.$$("src").startsWith(this.$$("cdn-cname")))return U(this.$$("src"),r);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(U(Te(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("uuid"))return this._proxyUrl(U(Te(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("proxy-cname"))return this._proxyUrl(U(this.$$("proxy-cname"),r,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(U(`https://${this.$$("pubkey")}.ucr.io/`,r,this._fmtAbs(this.$$("src"))))}_proxyUrl(e){return this.$$("secure-delivery-proxy")?dt(this.$$("secure-delivery-proxy"),{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}_getElSize(e,t=1,r=!0){let o=e.getBoundingClientRect(),s=t*Math.round(o.width),n=r?"":t*Math.round(o.height);return s||n?`${s||""}x${n||""}`:null}_setupEventProxy(e){let t=o=>{o.stopPropagation();let s=new Event(o.type,o);this.dispatchEvent(s)},r=["load","error"];for(let o of r)e.addEventListener(o,t)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:Zr.PREVIEW,img:this._imgPreview}:{type:Zr.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){if(this.$$("breakpoints")){let e=$(this.$$("breakpoints"));return gn(e.map(t=>parseInt(t,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let r=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",r),e.style.setProperty("background-image","-webkit-"+r)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(t=>{e.add(this._getUrlBase(t+"x")+` ${this._validateSize(t+"w")}`),this.$$("hi-res-support")&&e.add(this._getUrlBase(t*2+"x")+` ${this._validateSize(t*2+"w")}`),this.$$("ultra-res-support")&&e.add(this._getUrlBase(t*3+"x")+` ${this._validateSize(t*3+"w")}`)}):(e.add(this._getUrlBase(this._getElSize(this.currentImg.img))+" 1x"),this.$$("hi-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,2))+" 2x"),this.$$("ultra-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,3))+" 3x")),[...e].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){[...document.querySelectorAll(this.bgSelector)].forEach(e=>{this.$$("intersection")?this.initIntersection(e,()=>{this.renderBg(e)}):this.renderBg(e)})}_appendURL({elNode:e,src:t,srcset:r}){t&&(e.src=t),r&&(e.srcset=r)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:t,elNode:r}){return new Promise((o,s)=>{this._setupConfigForImage({elNode:r}),r.setAttribute(Gr,""),r.addEventListener("load",()=>{r.removeAttribute(Gr),o(r)}),r.addEventListener("error",()=>{s(!1)}),this._appendURL({elNode:r,src:e,srcset:t})})}async renderImage(){if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{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 this._imgPreview?.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 this._imgPreview?.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var Yr=class extends Mi{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 Qr=null,Li=class extends y{static styleAttrs=[...super.styleAttrs,"uc-modal"];static StateConsumerScope="modal";_mouseDownTarget;handleModalOpen;handleModalClose;handleModalCloseAll;constructor(){super(),this.init$={...this.init$,closeClicked:this._handleDialogClose}}_handleBackdropClick=()=>{this._closeDialog()};_closeDialog=()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="")};_handleDialogClose=()=>{this._closeDialog()};_handleDialogMouseDown=e=>{this._mouseDownTarget=e.target};_handleDialogMouseUp=e=>{let t=e.target;t===this.ref.dialog&&t===this._mouseDownTarget&&this._closeDialog()};show(){let e=this.ref.dialog;typeof e.showModal=="function"?(this.setAttribute("aria-modal","true"),e.showModal()):e.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden")}hide(){let e=this.ref.dialog;typeof e.close=="function"?(this.setAttribute("aria-modal","false"),e.close()):e.removeAttribute("open")}_handleModalOpen({id:e}){e===this.id?(Qr=e,this.show(),this.emit(T.MODAL_OPEN,{modalId:e},{debounce:!0})):this.hide()}_handleModalClose({id:e}){e===this.id&&(this.hide(),this.emit(T.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0}))}_handleModalCloseAll(e){this.hide(),Qr===this.id&&this.emit(T.MODAL_CLOSE,{modalId:Qr,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0})}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this);let e=this.ref.dialog;e.addEventListener("close",this._handleDialogClose),e.addEventListener("mousedown",this._handleDialogMouseDown),e.addEventListener("mouseup",this._handleDialogMouseUp),this.subConfigValue("modalBackdropStrokes",t=>{t?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.handleModalCloseAll=this._handleModalCloseAll.bind(this),this.modalManager?.subscribe(D.OPEN,this.handleModalOpen),this.modalManager?.subscribe(D.CLOSE,this.handleModalClose),this.modalManager?.subscribe(D.CLOSE_ALL,this.handleModalCloseAll)}destroyCallback(){super.destroyCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0;let e=this.ref.dialog;e.removeEventListener("close",this._handleDialogClose),e.removeEventListener("mousedown",this._handleDialogMouseDown),e.removeEventListener("mouseup",this._handleDialogMouseUp),this.modalManager?.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(D.CLOSE,this.handleModalClose),this.modalManager?.unsubscribe(D.CLOSE_ALL,this.handleModalCloseAll)}};Li.template=`<dialog ref="dialog"><slot></slot></dialog>`;var Ri=class extends y{_value=0;_visible=!0;constructor(){super(),this.init$={...this.init$,width:0,opacity:0}}initCallback(){super.initCallback();let e=()=>{let t=this.ref.fakeProgressLine;if(!this._visible){t.classList.add("uc-fake-progress--hidden");return}this._value>0&&t.classList.add("uc-fake-progress--hidden")};this.ref.fakeProgressLine.addEventListener("animationiteration",e),this.defineAccessor("value",t=>{t!=null&&(this._value=t,this._visible&&this.style.setProperty("--l-progress-value",this._value.toString()))}),this.defineAccessor("visible",t=>{this._visible=t,this.classList.toggle("uc-progress-bar--hidden",!t)})}};Ri.template=`<div ref="fakeProgressLine" class="uc-fake-progress"></div><div ref="realProgressLine" class="uc-progress"></div>`;var Pi=class extends O{_unobserveCollectionCb;constructor(){super(),this.init$={...this.init$,visible:!1,value:0,"*commonProgress":0}}initCallback(){super.initCallback(),this._unobserveCollectionCb=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(t=>this.uploadCollection.read(t)?.getValue("isUploading")??!1);this.$.visible=e}),this.sub("visible",e=>{e?this.setAttribute("active",""):this.removeAttribute("active")}),this.sub("*commonProgress",e=>{this.$.value=e})}destroyCallback(){super.destroyCallback(),this._unobserveCollectionCb?.(),this._unobserveCollectionCb=void 0}};Pi.template='<uc-progress-bar set="visible: visible; value: value"></uc-progress-bar>';var Ui=class extends y{constructor(){super(),this.init$={...this.init$,currentText:"",options:[],selectHtml:"",onSelect:e=>{e.preventDefault(),e.stopPropagation();let t=this.ref.select;this.value=t.value,this.$.currentText=this.$.options.find(r=>r.value===this.value)?.text||"",this.dispatchEvent(new Event("change"))}}}initCallback(){super.initCallback(),this.sub("options",e=>{this.$.currentText=e?.[0]?.text||"";let t="";e?.forEach(r=>{t+=`<option value="${r.value}">${r.text}</option>`}),this.$.selectHtml=t})}};Ui.template='<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>';var Mt=class extends O{static styleAttrs=[...super.styleAttrs,"uc-simple-btn"];couldBeCtxOwner=!0;constructor(){super(),this.init$={...this.init$,withDropZone:!0,onClick:()=>{this.api.initFlow()},"button-text":""}}initCallback(){super.initCallback(),this.defineAccessor("dropzone",e=>{typeof e>"u"||(this.$.withDropZone=I(e))}),this.subConfigValue("multiple",e=>{this.$["button-text"]=e?"upload-files":"upload-file"})}};Mt.template=`<uc-drop-area set="@disabled: !withDropZone"><button type="button" set="onclick: onClick"><uc-icon name="upload"></uc-icon><span l10n="button-text"></span><slot></slot><div class="uc-visual-drop-area" l10n="drop-files-here"></div></button></uc-drop-area>`;Mt.bindAttributes({dropzone:null});var Oc="src-type-",Lt=class extends O{couldBeCtxOwner=!0;type=void 0;_registeredTypes={};constructor(){super(),this.init$={...this.init$,iconName:"default","src-type":""}}initTypes(){this.registerType({type:P.LOCAL,activate:()=>(this.api.openSystemDialog(),!1)}),this.registerType({type:P.URL,activity:f.activities.URL,textKey:"from-url"}),this.registerType({type:P.CAMERA,activity:f.activities.CAMERA,activate:()=>{let e=Fe.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:!0}),!e}}),this.registerType({type:"draw",activity:f.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(Cr))this.registerType({type:e,activity:f.activities.CAMERA,activate:()=>{let t=Fe.htmlMediaCapture;return t&&this.api.openSystemDialog({captureCamera:!0,modeCamera:e==="mobile-photo-camera"?_.PHOTO:_.VIDEO}),!t}});for(let e of Object.values(le))this.registerType({type:e,activity:f.activities.EXTERNAL,activityParams:{externalSourceType:e}})}initCallback(){super.initCallback(),this.initTypes(),this.defineAccessor("type",e=>{e&&this.applyType(e)})}registerType(e){this._registeredTypes[e.type]=e}getType(e){return this._registeredTypes[e]}activate(){if(!this.type)return;let e=this._registeredTypes[this.type];if(!e)return;let{activity:t,activate:r,activityParams:o={}}=e;(r?r():!!t)&&t&&(this.modalManager?.open(t),this.set$({"*currentActivityParams":o,"*currentActivity":t}))}applyType(e){let t=this._registeredTypes[e];if(!t){console.warn(`Unsupported source type: ${e}`);return}let{textKey:r=e,icon:o=e}=t;this.$["src-type"]=`${Oc}${r}`,this.$.iconName=o,this.onclick=()=>{this.activate()}}};Lt.template=`<button type="button"><uc-icon set="@name: iconName"></uc-icon><div class="uc-txt" l10n="src-type"></div></button>`;Lt.bindAttributes({type:null});var Jr=class extends y{initCallback(){super.initCallback(),this.subConfigValue("sourceList",e=>{let t=$(e),r="";t.forEach(o=>{if(o==="instagram"){console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here:https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US");return}if(o==="camera"&&Fe.htmlMediaCapture){this.subConfigValue("cameraModes",s=>{let n=q(s);n.forEach(a=>{r+=`<uc-source-btn role="listitem" type="mobile-${a}-camera"></uc-source-btn>`}),n.length===0&&(r+='<uc-source-btn role="listitem" type="mobile-photo-camera"></uc-source-btn>')});return}r+=`<uc-source-btn role="listitem" type="${o}"></uc-source-btn>`}),this.cfg.sourceListWrap?this.innerHTML=r:this.outerHTML=r})}};var $i=class extends Ee{};$i.template='<div class="uc-spinner"></div>';var Di=class extends f{historyTracked=!0;activityType=f.activities.START_FROM;initCallback(){super.initCallback(),this.registerActivity(this.activityType??"")}};Di.template='<div class="uc-content"><slot></slot></div>';function eo(i,e=40){if(i.type==="image/svg+xml")return URL.createObjectURL(i);let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return Promise.reject(new Error("Canvas context not supported"));let o=new Image,s=new Promise((n,a)=>{o.onload=()=>{let l=o.height/o.width;l>1?(t.width=e,t.height=e*l):(t.height=e,t.width=e/l),r.fillStyle="rgb(240, 240, 240)",r.fillRect(0,0,t.width,t.height),r.drawImage(o,0,0,t.width,t.height),t.toBlob(c=>{if(!c){a();return}let d=URL.createObjectURL(c);n(d)})},o.onerror=l=>{a(l)}});return o.src=URL.createObjectURL(i),s}function Mc(i){let e=new Blob([i],{type:"image/svg+xml"});return URL.createObjectURL(e)}function Fi(i="hsl(209, 21%, 65%)",e=32,t=32){return Mc(`<svg width="${e}" height="${t}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${i}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}var Lc=3e3,Rt=class extends ot{_renderedGridOnce=!1;_thumbRect=null;_isIntersecting=!1;_firstViewMode=this.cfg.filesViewMode;_observer;constructor(){super(),this.init$={...this.init$,thumbUrl:"",badgeIcon:"",uid:""}}_calculateThumbSize(e=!1){e&&(this._thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(this?._thumbRect?.height||0),10),parseInt(String(this?._thumbRect?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,Lc)}_generateThumbnail=this._withEntry(async(e,t=!1)=>{let r=e.getValue("fileInfo"),o=e.getValue("isImage"),s=e.getValue("uuid"),n=e.getValue("thumbUrl"),a=this._calculateThumbSize(t);if(r&&o&&s){let c=await this.proxyUrl(U(Te(this.cfg.cdnCname,s),H(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${a}x${a}/center`)));if(n===c)return;let{promise:d}=Be(c);d.then(()=>{e.setValue("thumbUrl",c),n?.startsWith("blob:")&&URL.revokeObjectURL(n)}).catch(async()=>{if(!n?.startsWith("blob:"))try{let u=e.getValue("file");if(!u)return;let p=await eo(u,a);e.setValue("thumbUrl",p)}catch(u){this.telemetryManager.sendEventError(u,"thumbnail generation. Failed to generate thumb from file");let p=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Fi(p))}});return}if(e.getValue("thumbUrl"))return;let l=e.getValue("file");if(l?.type.includes("image"))try{let c=await eo(l,a);e.setValue("thumbUrl",c)}catch(c){this.telemetryManager.sendEventError(c,"thumbnail generation. Failed to generate thumb from file");let d=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Fi(d))}else{let c=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Fi(c))}});_debouncedGenerateThumb=M(this._generateThumbnail.bind(this),100);_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,t.isIntersecting&&(this._thumbRect=t.boundingClientRect,this._debouncedGenerateThumb(),this._observer?.disconnect()),t.intersectionRatio===0&&this._debouncedGenerateThumb.cancel())}_reset(){super._reset(),this._debouncedGenerateThumb.cancel()}_handleEntryId(e){this._reset();let t=this.uploadCollection?.read(e);this._entry=t,t&&(this._subEntry("fileInfo",r=>{r?.isImage&&this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("thumbUrl",r=>{this.$.thumbUrl=r?`url(${r})`:""}),this._subEntry("cdnUrlModifiers",()=>{this._isIntersecting&&this._debouncedGenerateThumb()}),this._isIntersecting&&this._debouncedGenerateThumb())}initCallback(){super.initCallback(),this.defineAccessor("badgeIcon",e=>{this.$.badgeIcon=e}),this.defineAccessor("uid",e=>{this.set$({uid:e})}),this.sub("uid",e=>{this._handleEntryId(e)}),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this._renderedGridOnce&&(this._firstViewMode==="list"&&this._debouncedGenerateThumb(!0),this._renderedGridOnce=!0)}),this.setAttribute("role","img")}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this._observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set,this._debouncedGenerateThumb.cancel(),this._observer?.disconnect()}};Rt.template=`<div class="uc-thumb" set="style.backgroundImage: thumbUrl"><div class="uc-badge"><uc-icon set="@name: badgeIcon"></uc-icon></div></div>`;Rt.bindAttributes({badgeIcon:null,uid:null});var to=class extends O{static styleAttrs=["uc-wgt-common"];static EventType=T;requireCtxName=!0;initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}destroyCallback(){super.destroyCallback(),this.$["*eventEmitter"].unbindTarget(this)}};var Vi=class extends O{couldBeCtxOwner=!0;historyTracked=!0;activityType=f.activities.UPLOAD_LIST;constructor(){super(),this.init$={...this.init$,doneBtnVisible:!1,doneBtnEnabled:!1,uploadBtnVisible:!1,addMoreBtnVisible:!1,addMoreBtnEnabled:!1,headerText:"",commonErrorMessage:"",hasFiles:!1,onAdd:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(!0)},onUpload:()=>{this.emit(T.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},onDone:()=>{this.emit(T.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()},onCancel:()=>{this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll()}}}_throttledHandleCollectionUpdate=tt(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll())},300);_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount,validatingBeforeUploading:e.idleEntries.filter(p=>p.isValidationPending).length},r=!e.errors.some(p=>p.type==="TOO_MANY_FILES"||p.type==="TOO_FEW_FILES"),o=e.errors.some(p=>p.type==="TOO_MANY_FILES"),s=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),n=e.allEntries.some(p=>p.isValidationPending),a=t.failed===0&&e.errors.length===0&&!n,l=!1,c=!1,d=!1;if(t.total-t.succeed-t.uploading-t.failed>0&&r&&a)l=!0;else{c=!0;let p=this.cfg.groupOutput?!!e.group:!0;d=t.total===t.succeed&&r&&a&&p}this.set$({doneBtnVisible:c,doneBtnEnabled:d,uploadBtnVisible:l,addMoreBtnEnabled:t.total===0||!o&&!s,addMoreBtnVisible:!s||this.cfg.multiple,hasFiles:t.total>0}),this.bindL10n("headerText",()=>this._getHeaderText(t))}_getHeaderText(e){let t=r=>{let o=e[r];return r==="uploading"&&(o+=e.validatingBeforeUploading),this.l10n(`header-${r}`,{count:o})};return e.uploading>0||e.validatingBeforeUploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",e=>{e&&this._throttledHandleCollectionUpdate()}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e)}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity)}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this.sub("*collectionErrors",e=>{let t=e.filter(r=>r.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this.set$({commonErrorMessage:null});return}this.set$({commonErrorMessage:t.message})})}destroyCallback(){super.destroyCallback(),this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.unobserveCollection(this._throttledHandleCollectionUpdate)}};Vi.template=`<uc-activity-header><span aria-live="polite" class="uc-header-text">{{headerText}}</span><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" set="@hidden: hasFiles"><slot name="empty"><span l10n="no-files"></span></slot></div><div class="uc-files"><div class="uc-files-wrapper" repeat="*uploadList" repeat-item-tag="uc-file-item"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" set="onclick: onAdd; @disabled: !addMoreBtnEnabled; @hidden: !addMoreBtnVisible" ><uc-icon name="add"></uc-icon><span l10n="add-more"></span></button></div><div class="uc-common-error" set="@hidden: !commonErrorMessage; textContent: commonErrorMessage;"></div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel;" l10n="clear"></button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" set="onclick: onAdd; @disabled: !addMoreBtnEnabled; @hidden: !addMoreBtnVisible" ><uc-icon name="add"></uc-icon><span l10n="add-more"></span></button><button type="button" class="uc-upload-btn uc-primary-btn" set="@hidden: !uploadBtnVisible; onclick: onUpload;" l10n="upload" ></button><button type="button" class="uc-done-btn uc-primary-btn" set="@hidden: !doneBtnVisible; onclick: onDone; @disabled: !doneBtnEnabled" l10n="done" ></button></div><uc-drop-area ghost></uc-drop-area>`;var Ni=class extends O{couldBeCtxOwner=!0;activityType=f.activities.URL;constructor(){super(),this.init$={...this.init$,importDisabled:!0,onUpload:e=>{e.preventDefault(),this.telemetryManager.sendEvent({eventType:k.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let t=this.ref.input.value;this.api.addFileFromUrl(t,{source:P.URL}),this.modalManager?.open(f.activities.UPLOAD_LIST),this.$["*currentActivity"]=f.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()},onInput:e=>{let t=e.target?.value??"";this.set$({importDisabled:!t})}}}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"",{onActivate:()=>{let e=this.ref.input;e.value="",e.focus()}})}};Ni.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back;@aria-label:back"><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span l10n="caption-from-url"></span></div><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close;@aria-label:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content"><label><input placeholder="https://" class="uc-url-input" type="text" ref="input" set="oninput: onInput" /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" set="onclick: onUpload; @disabled: importDisabled" l10n="upload-url" ></button></form>`;var io=class extends we{static styleAttrs=[...super.styleAttrs,"uc-wgt-common"];constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION}),this.a11y?.registerBlock(this)}};var Bi=class extends _e{static styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"];constructor(){super(),this.init$={...this.init$,couldCancel:!1,"*solution":this.tagName,cancel:()=>{if(this.couldHistoryBack){let e=this.$["*historyBack"];e?.();return}this.couldShowList&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST)}}}get couldHistoryBack(){let e=this.$["*history"];return!e||e.length<=1?!1:e[e.length-1]!==f.activities.START_FROM}get couldShowList(){let e=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(e)&&e.length>0}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION});let e=this.ref.uBlock;e&&(this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e.initActivity||f.activities.START_FROM)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0&&this.$["*currentActivity"]===(e.initActivity||f.activities.START_FROM)&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList}))}};Bi.template=`<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-cancel-btn uc-secondary-btn" set="onclick: cancel; @hidden: !couldCancel" ></button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list ref="uBlock"></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`;var ro="active",zi="",Hi=class extends _e{static styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"];handleModalOpen;handleModalClose;constructor(){super(),this.init$={...this.init$,singleUpload:!1,isHiddenStartFrom:!1,classUploadList:zi,classStartFrom:zi,"*solution":this.tagName}}_handleModalOpen(e){e.id===f.activities.CLOUD_IMG_EDIT&&this.set$({classUploadList:ro}),this.$["*currentActivity"]===f.activities.UPLOAD_LIST&&this.set$({classUploadList:ro,isHiddenStartFrom:!0});let t=this.$["*uploadList"];(!t||t.length<=0)&&this.set$({classStartFrom:ro})}_handleModalClose(e){e.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.set$({isHiddenStartFrom:!1})),e.id===f.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=f.activities.UPLOAD_LIST)}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION});let e=this.ref.uBlock;e&&(this.sub("*currentActivity",t=>{t===f.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),t||(this.$["*currentActivity"]=e.initActivity||f.activities.START_FROM)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0?(this.$["*currentActivity"]=f.activities.UPLOAD_LIST,this.set$({classStartFrom:zi})):(this.set$({classUploadList:zi,isHiddenStartFrom:!1}),this.$["*currentActivity"]=e.initActivity||f.activities.START_FROM)}),this.subConfigValue("confirmUpload",t=>{t!==!1&&(this.cfg.confirmUpload=!1)}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t),this.subConfigValue("multiple",r=>{t==="grid"?(r?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.$.singleUpload=!r):(this.style.removeProperty("--uc-grid-col"),this.$.singleUpload=!1)})}),this.handleModalOpen=t=>{this._handleModalOpen(t)},this.handleModalClose=t=>{this._handleModalClose(t)},this.modalManager?.subscribe(D.OPEN,this.handleModalOpen),this.modalManager?.subscribe(D.CLOSE,this.handleModalClose))}destroyCallback(){super.destroyCallback(),this.modalManager?.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(D.CLOSE,this.handleModalClose)}};Hi.template=`<uc-start-from set="@hidden: isHiddenStartFrom; @class:classStartFrom"><uc-drop-area set="@single:singleUpload;" initflow clickable tabindex="0" l10n="choose-file"></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list set="@class:classUploadList" ref="uBlock"></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;var Pt=class extends _e{static styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"];constructor(){super();let e={...this.init$,isHidden:!1,"*solution":this.tagName};this.init$=e}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:k.INIT_SOLUTION}),this.defineAccessor("headless",e=>{this.set$({isHidden:I(e)})})}};Pt.template=`<uc-simple-btn set="@hidden: isHidden"></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;Pt.bindAttributes({headless:null});export{f as ActivityBlock,Lr as ActivityHeader,Ee as BaseComponent,y as Block,Et as BtnUi,ui as CameraSource,io as CloudImageEditor,Ur as CloudImageEditorActivity,we as CloudImageEditorBlock,At as Config,Nr as Copyright,pi as CropFrame,E as Data,St as DropArea,bt as EditorAspectRatioButtonControl,_t as EditorCropButtonControl,et as EditorFilterControl,Qe as EditorFreeformButtonControl,fi as EditorImageCropper,Pr as EditorImageFader,Ct as EditorOperationControl,gi as EditorScroller,mi as EditorSlider,vi as EditorToolbar,xi as ExternalSource,le as ExternalUploadSource,jr as FileItem,Bi as FileUploaderInline,Hi as FileUploaderMinimal,Pt as FileUploaderRegular,Kr as FormInput,kt as Icon,Yr as Img,yi as LineLoaderUi,Li as Modal,D as ModalEvents,Oe as PACKAGE_NAME,Me as PACKAGE_VERSION,bi as PresenceToggle,Ri as ProgressBar,Pi as ProgressBarCommon,Ui as Select,Mt as SimpleBtn,_i as SliderUi,_e as SolutionBlock,Lt as SourceBtn,Jr as SourceList,$i as Spinner,Di as StartFrom,Rt as Thumb,ne as UID,to as UploadCtxProvider,Vi as UploadList,P as UploadSource,O as UploaderBlock,Ni as UrlSource,br as defineComponents,No as defineLocale,ol as loadFileUploaderFrom,Tt as toKebabCase};
|