@uploadcare/file-uploader 1.21.0 → 1.22.0
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/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts +3 -0
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.js +20 -10
- package/blocks/CloudImageEditor/src/css/common.css +30 -0
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts +1 -1
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/svg-sprite.js +1 -1
- package/blocks/themes/uc-basic/svg-sprite.d.ts +1 -1
- package/blocks/themes/uc-basic/svg-sprite.d.ts.map +1 -1
- package/blocks/themes/uc-basic/svg-sprite.js +1 -1
- package/env.d.ts +1 -1
- package/env.js +1 -1
- package/index.ssr.d.ts +1 -1
- package/index.ssr.js +3 -3
- package/locales/file-uploader/ar.d.ts +1 -1
- package/locales/file-uploader/ar.js +2 -3
- package/locales/file-uploader/az.d.ts +1 -1
- package/locales/file-uploader/az.js +2 -2
- package/locales/file-uploader/ca.d.ts +1 -1
- package/locales/file-uploader/ca.js +2 -2
- package/locales/file-uploader/cs.d.ts +1 -1
- package/locales/file-uploader/cs.js +2 -2
- package/locales/file-uploader/da.d.ts +1 -1
- package/locales/file-uploader/da.js +2 -2
- package/locales/file-uploader/de.d.ts +1 -1
- package/locales/file-uploader/de.js +2 -2
- package/locales/file-uploader/el.d.ts +1 -1
- package/locales/file-uploader/el.js +2 -2
- package/locales/file-uploader/en.d.ts +1 -1
- package/locales/file-uploader/en.js +2 -3
- package/locales/file-uploader/es.d.ts +1 -1
- package/locales/file-uploader/es.js +2 -2
- package/locales/file-uploader/et.d.ts +1 -1
- package/locales/file-uploader/et.js +2 -2
- package/locales/file-uploader/fi.d.ts +1 -1
- package/locales/file-uploader/fi.js +2 -2
- package/locales/file-uploader/fr.d.ts +1 -1
- package/locales/file-uploader/fr.js +2 -2
- package/locales/file-uploader/he.d.ts +1 -1
- package/locales/file-uploader/he.js +2 -2
- package/locales/file-uploader/hy.d.ts +1 -1
- package/locales/file-uploader/hy.js +2 -2
- package/locales/file-uploader/is.d.ts +1 -1
- package/locales/file-uploader/is.js +2 -2
- package/locales/file-uploader/it.d.ts +1 -1
- package/locales/file-uploader/it.js +2 -2
- package/locales/file-uploader/ja.d.ts +1 -1
- package/locales/file-uploader/ja.js +2 -2
- package/locales/file-uploader/ka.d.ts +1 -1
- package/locales/file-uploader/ka.js +2 -2
- package/locales/file-uploader/kk.d.ts +1 -1
- package/locales/file-uploader/kk.js +2 -2
- package/locales/file-uploader/ko.d.ts +1 -1
- package/locales/file-uploader/ko.js +2 -2
- package/locales/file-uploader/lv.d.ts +1 -1
- package/locales/file-uploader/lv.js +2 -2
- package/locales/file-uploader/nb.d.ts +1 -1
- package/locales/file-uploader/nb.js +2 -2
- package/locales/file-uploader/nl.d.ts +1 -1
- package/locales/file-uploader/nl.js +2 -2
- package/locales/file-uploader/pl.d.ts +1 -1
- package/locales/file-uploader/pl.js +2 -2
- package/locales/file-uploader/pt.d.ts +1 -1
- package/locales/file-uploader/pt.js +2 -2
- package/locales/file-uploader/ro.d.ts +1 -1
- package/locales/file-uploader/ro.js +2 -2
- package/locales/file-uploader/ru.d.ts +1 -1
- package/locales/file-uploader/ru.js +2 -4
- package/locales/file-uploader/sk.d.ts +1 -1
- package/locales/file-uploader/sk.js +2 -2
- package/locales/file-uploader/sr.d.ts +1 -1
- package/locales/file-uploader/sr.js +2 -2
- package/locales/file-uploader/sv.d.ts +1 -1
- package/locales/file-uploader/sv.js +2 -2
- package/locales/file-uploader/tr.d.ts +1 -1
- package/locales/file-uploader/tr.js +2 -2
- package/locales/file-uploader/uk.d.ts +1 -1
- package/locales/file-uploader/uk.js +2 -2
- package/locales/file-uploader/vi.d.ts +1 -1
- package/locales/file-uploader/vi.js +2 -2
- package/locales/file-uploader/zh-TW.d.ts +1 -1
- package/locales/file-uploader/zh-TW.js +2 -2
- package/locales/file-uploader/zh.d.ts +1 -1
- package/locales/file-uploader/zh.js +2 -4
- package/package.json +1 -1
- package/web/file-uploader.iife.min.js +4 -4
- package/web/file-uploader.min.js +3 -3
- package/web/uc-basic.min.css +1 -1
- package/web/uc-cloud-image-editor.min.css +1 -1
- package/web/uc-cloud-image-editor.min.js +3 -3
- package/web/uc-file-uploader-inline.min.css +1 -1
- package/web/uc-file-uploader-inline.min.js +3 -3
- package/web/uc-file-uploader-minimal.min.css +1 -1
- package/web/uc-file-uploader-minimal.min.js +3 -3
- package/web/uc-file-uploader-regular.min.css +1 -1
- package/web/uc-file-uploader-regular.min.js +3 -3
- package/web/uc-img.min.js +1 -1
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
var er=Object.defineProperty;var tr=Object.getPrototypeOf;var ir=Reflect.get;var rr=(r,t,e)=>t in r?er(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var f=(r,t,e)=>rr(r,typeof t!="symbol"?t+"":t,e);var Mt=(r,t,e)=>ir(tr(r),e,t);var sr=Object.defineProperty,or=(r,t,e)=>t in r?sr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,st=(r,t,e)=>(or(r,typeof t!="symbol"?t+"":t,e),e);function nr(r){let t=e=>{var i;for(let s in e)((i=e[s])==null?void 0:i.constructor)===Object&&(e[s]=t(e[s]));return{...e}};return t(r)}var E=class{constructor(r){r.constructor===Object?this.store=nr(r):(this._storeIsProxy=!0,this.store=r),this.callbackMap=Object.create(null)}static warn(r,t){console.warn(`Symbiote Data: cannot ${r}. Prop name: `+t)}read(r){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("read",r),null):this.store[r]}has(r){return this._storeIsProxy?this.store[r]!==void 0:this.store.hasOwnProperty(r)}add(r,t,e=!1){!e&&Object.keys(this.store).includes(r)||(this.store[r]=t,this.notify(r))}pub(r,t){if(!this._storeIsProxy&&!this.store.hasOwnProperty(r)){E.warn("publish",r);return}this.store[r]=t,this.notify(r)}multiPub(r){for(let t in r)this.pub(t,r[t])}notify(r){this.callbackMap[r]&&this.callbackMap[r].forEach(t=>{t(this.store[r])})}sub(r,t,e=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("subscribe",r),null):(this.callbackMap[r]||(this.callbackMap[r]=new Set),this.callbackMap[r].add(t),e&&t(this.store[r]),{remove:()=>{this.callbackMap[r].delete(t),this.callbackMap[r].size||delete this.callbackMap[r]},callback:t})}static registerCtx(r,t=Symbol()){let e=E.globalStore.get(t);return e?console.warn('State: context UID "'+t+'" already in use'):(e=new E(r),E.globalStore.set(t,e)),e}static deleteCtx(r){E.globalStore.delete(r)}static getCtx(r,t=!0){return E.globalStore.get(r)||(t&&console.warn('State: wrong context UID - "'+r+'"'),null)}};E.globalStore=new Map;var _=Object.freeze({BIND_ATTR:"set",ATTR_BIND_PRFX:"@",EXT_DATA_CTX_PRFX:"*",NAMED_DATA_CTX_SPLTR:"/",CTX_NAME_ATTR:"ctx-name",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx-name",EL_REF_ATTR:"ref",AUTO_TAG_PRFX:"sym",REPEAT_ATTR:"repeat",REPEAT_ITEM_TAG_ATTR:"repeat-item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL:"use-template",ROOT_STYLE_ATTR_NAME:"sym-component"}),Dt="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",ar=Dt.length-1,ot=class{static generate(r="XXXXXXXXX-XXX"){let t="";for(let e=0;e<r.length;e++)t+=r[e]==="-"?r[e]:Dt.charAt(Math.random()*ar);return t}};function Ft(r,t,e){let i=!0,s,o=t.split(".");return o.forEach((n,a)=>{a<o.length-1?r=r[n]:s=n}),r?r[s]=e:i=!1,i}function lr(r){return r.split("-").map((t,e)=>t&&e?t[0].toUpperCase()+t.slice(1):t).join("").split("_").map((t,e)=>t&&e?t.toUpperCase():t).join("")}function cr(r,t){[...r.querySelectorAll(`[${_.REPEAT_ATTR}]`)].forEach(e=>{let i=e.getAttribute(_.REPEAT_ITEM_TAG_ATTR),s;if(i&&(s=window.customElements.get(i)),!s){s=class extends t.BaseComponent{constructor(){super(),i||(this.style.display="contents")}};let n=e.innerHTML;s.template=n,s.reg(i)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(_.REPEAT_ATTR);t.sub(o,n=>{if(!n){for(;e.firstChild;)e.firstChild.remove();return}let a=[...e.children],l,c=u=>{u.forEach((d,p)=>{if(a[p])if(a[p].set$)setTimeout(()=>{a[p].set$(d)});else for(let g in d)a[p][g]=d[g];else{l||(l=new DocumentFragment);let g=new s;Object.assign(g.init$,d),l.appendChild(g)}}),l&&e.appendChild(l);let h=a.slice(u.length,a.length);for(let d of h)d.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let u=[];for(let h in n){let d=n[h];Object.defineProperty(d,"_KEY_",{value:h,enumerable:!0}),u.push(d)}c(u)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),e.removeAttribute(_.REPEAT_ATTR),e.removeAttribute(_.REPEAT_ITEM_TAG_ATTR)})}var Nt="__default__";function hr(r,t){if(t.shadowRoot)return;let e=[...r.querySelectorAll("slot")];if(!e.length)return;let i={};e.forEach(s=>{let o=s.getAttribute("name")||Nt;i[o]={slot:s,fr:document.createDocumentFragment()}}),t.initChildren.forEach(s=>{var o;let n=Nt;s instanceof Element&&s.hasAttribute("slot")&&(n=s.getAttribute("slot"),s.removeAttribute("slot")),(o=i[n])==null||o.fr.appendChild(s)}),Object.values(i).forEach(s=>{if(s.fr.childNodes.length)s.slot.parentNode.replaceChild(s.fr,s.slot);else if(s.slot.childNodes.length){let o=document.createDocumentFragment();o.append(...s.slot.childNodes),s.slot.parentNode.replaceChild(o,s.slot)}else s.slot.remove()})}function ur(r,t){[...r.querySelectorAll(`[${_.EL_REF_ATTR}]`)].forEach(e=>{let i=e.getAttribute(_.EL_REF_ATTR);t.ref[i]=e,e.removeAttribute(_.EL_REF_ATTR)})}function dr(r,t){[...r.querySelectorAll(`[${_.BIND_ATTR}]`)].forEach(e=>{let s=e.getAttribute(_.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=lr(o.name.replace("-",""));s.push(n+":"+o.value),e.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let n=o.split(":").map(u=>u.trim()),a=n[0],l;a.indexOf(_.ATTR_BIND_PRFX)===0&&(l=!0,a=a.replace(_.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(u=>u.trim());for(let u of c){let h;u.startsWith("!!")?(h="double",u=u.replace("!!","")):u.startsWith("!")&&(h="single",u=u.replace("!","")),t.sub(u,d=>{h==="double"?d=!!d:h==="single"&&(d=!d),l?(d==null?void 0:d.constructor)===Boolean?d?e.setAttribute(a,""):e.removeAttribute(a):e.setAttribute(a,d):Ft(e,a,d)||(e[_.SET_LATER_KEY]||(e[_.SET_LATER_KEY]=Object.create(null)),e[_.SET_LATER_KEY][a]=d)})}}),e.removeAttribute(_.BIND_ATTR)})}var $e="{{",
|
|
26
|
+
var er=Object.defineProperty;var tr=Object.getPrototypeOf;var ir=Reflect.get;var rr=(r,t,e)=>t in r?er(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var f=(r,t,e)=>rr(r,typeof t!="symbol"?t+"":t,e);var Mt=(r,t,e)=>ir(tr(r),e,t);var sr=Object.defineProperty,or=(r,t,e)=>t in r?sr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,st=(r,t,e)=>(or(r,typeof t!="symbol"?t+"":t,e),e);function nr(r){let t=e=>{var i;for(let s in e)((i=e[s])==null?void 0:i.constructor)===Object&&(e[s]=t(e[s]));return{...e}};return t(r)}var E=class{constructor(r){r.constructor===Object?this.store=nr(r):(this._storeIsProxy=!0,this.store=r),this.callbackMap=Object.create(null)}static warn(r,t){console.warn(`Symbiote Data: cannot ${r}. Prop name: `+t)}read(r){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("read",r),null):this.store[r]}has(r){return this._storeIsProxy?this.store[r]!==void 0:this.store.hasOwnProperty(r)}add(r,t,e=!1){!e&&Object.keys(this.store).includes(r)||(this.store[r]=t,this.notify(r))}pub(r,t){if(!this._storeIsProxy&&!this.store.hasOwnProperty(r)){E.warn("publish",r);return}this.store[r]=t,this.notify(r)}multiPub(r){for(let t in r)this.pub(t,r[t])}notify(r){this.callbackMap[r]&&this.callbackMap[r].forEach(t=>{t(this.store[r])})}sub(r,t,e=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("subscribe",r),null):(this.callbackMap[r]||(this.callbackMap[r]=new Set),this.callbackMap[r].add(t),e&&t(this.store[r]),{remove:()=>{this.callbackMap[r].delete(t),this.callbackMap[r].size||delete this.callbackMap[r]},callback:t})}static registerCtx(r,t=Symbol()){let e=E.globalStore.get(t);return e?console.warn('State: context UID "'+t+'" already in use'):(e=new E(r),E.globalStore.set(t,e)),e}static deleteCtx(r){E.globalStore.delete(r)}static getCtx(r,t=!0){return E.globalStore.get(r)||(t&&console.warn('State: wrong context UID - "'+r+'"'),null)}};E.globalStore=new Map;var _=Object.freeze({BIND_ATTR:"set",ATTR_BIND_PRFX:"@",EXT_DATA_CTX_PRFX:"*",NAMED_DATA_CTX_SPLTR:"/",CTX_NAME_ATTR:"ctx-name",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx-name",EL_REF_ATTR:"ref",AUTO_TAG_PRFX:"sym",REPEAT_ATTR:"repeat",REPEAT_ITEM_TAG_ATTR:"repeat-item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL:"use-template",ROOT_STYLE_ATTR_NAME:"sym-component"}),Dt="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",ar=Dt.length-1,ot=class{static generate(r="XXXXXXXXX-XXX"){let t="";for(let e=0;e<r.length;e++)t+=r[e]==="-"?r[e]:Dt.charAt(Math.random()*ar);return t}};function Ft(r,t,e){let i=!0,s,o=t.split(".");return o.forEach((n,a)=>{a<o.length-1?r=r[n]:s=n}),r?r[s]=e:i=!1,i}function lr(r){return r.split("-").map((t,e)=>t&&e?t[0].toUpperCase()+t.slice(1):t).join("").split("_").map((t,e)=>t&&e?t.toUpperCase():t).join("")}function cr(r,t){[...r.querySelectorAll(`[${_.REPEAT_ATTR}]`)].forEach(e=>{let i=e.getAttribute(_.REPEAT_ITEM_TAG_ATTR),s;if(i&&(s=window.customElements.get(i)),!s){s=class extends t.BaseComponent{constructor(){super(),i||(this.style.display="contents")}};let n=e.innerHTML;s.template=n,s.reg(i)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(_.REPEAT_ATTR);t.sub(o,n=>{if(!n){for(;e.firstChild;)e.firstChild.remove();return}let a=[...e.children],l,c=u=>{u.forEach((d,p)=>{if(a[p])if(a[p].set$)setTimeout(()=>{a[p].set$(d)});else for(let g in d)a[p][g]=d[g];else{l||(l=new DocumentFragment);let g=new s;Object.assign(g.init$,d),l.appendChild(g)}}),l&&e.appendChild(l);let h=a.slice(u.length,a.length);for(let d of h)d.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let u=[];for(let h in n){let d=n[h];Object.defineProperty(d,"_KEY_",{value:h,enumerable:!0}),u.push(d)}c(u)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),e.removeAttribute(_.REPEAT_ATTR),e.removeAttribute(_.REPEAT_ITEM_TAG_ATTR)})}var Nt="__default__";function hr(r,t){if(t.shadowRoot)return;let e=[...r.querySelectorAll("slot")];if(!e.length)return;let i={};e.forEach(s=>{let o=s.getAttribute("name")||Nt;i[o]={slot:s,fr:document.createDocumentFragment()}}),t.initChildren.forEach(s=>{var o;let n=Nt;s instanceof Element&&s.hasAttribute("slot")&&(n=s.getAttribute("slot"),s.removeAttribute("slot")),(o=i[n])==null||o.fr.appendChild(s)}),Object.values(i).forEach(s=>{if(s.fr.childNodes.length)s.slot.parentNode.replaceChild(s.fr,s.slot);else if(s.slot.childNodes.length){let o=document.createDocumentFragment();o.append(...s.slot.childNodes),s.slot.parentNode.replaceChild(o,s.slot)}else s.slot.remove()})}function ur(r,t){[...r.querySelectorAll(`[${_.EL_REF_ATTR}]`)].forEach(e=>{let i=e.getAttribute(_.EL_REF_ATTR);t.ref[i]=e,e.removeAttribute(_.EL_REF_ATTR)})}function dr(r,t){[...r.querySelectorAll(`[${_.BIND_ATTR}]`)].forEach(e=>{let s=e.getAttribute(_.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=lr(o.name.replace("-",""));s.push(n+":"+o.value),e.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let n=o.split(":").map(u=>u.trim()),a=n[0],l;a.indexOf(_.ATTR_BIND_PRFX)===0&&(l=!0,a=a.replace(_.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(u=>u.trim());for(let u of c){let h;u.startsWith("!!")?(h="double",u=u.replace("!!","")):u.startsWith("!")&&(h="single",u=u.replace("!","")),t.sub(u,d=>{h==="double"?d=!!d:h==="single"&&(d=!d),l?(d==null?void 0:d.constructor)===Boolean?d?e.setAttribute(a,""):e.removeAttribute(a):e.setAttribute(a,d):Ft(e,a,d)||(e[_.SET_LATER_KEY]||(e[_.SET_LATER_KEY]=Object.create(null)),e[_.SET_LATER_KEY][a]=d)})}}),e.removeAttribute(_.BIND_ATTR)})}var $e="{{",de="}}",fr="skip-text";function pr(r){let t,e=[],i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(fr))&&s.textContent.includes($e)&&s.textContent.includes(de)&&1}});for(;t=i.nextNode();)e.push(t);return e}var mr=function(r,t){pr(r).forEach(i=>{let s=[],o;for(;i.textContent.includes(de);)i.textContent.startsWith($e)?(o=i.textContent.indexOf(de)+de.length,i.splitText(o),s.push(i)):(o=i.textContent.indexOf($e),i.splitText(o)),i=i.nextSibling;s.forEach(n=>{let a=n.textContent.replace($e,"").replace(de,"");n.textContent="",t.sub(a,l=>{n.textContent=l})})})},_r=[cr,hr,ur,dr,mr],Oe="'",te='"',gr=/\\([0-9a-fA-F]{1,6} ?)/g;function br(r){return(r[0]===te||r[0]===Oe)&&(r[r.length-1]===te||r[r.length-1]===Oe)}function yr(r){return(r[0]===te||r[0]===Oe)&&(r=r.slice(1)),(r[r.length-1]===te||r[r.length-1]===Oe)&&(r=r.slice(0,-1)),r}function wr(r){let t="",e="";for(var i=0;i<r.length;i++){let s=r[i+1];r[i]==="\\"&&s==='"'?(t+='\\"',i++):r[i]==='"'&&e!=="\\"?t+='\\"':t+=r[i],e=r[i]}return t}function vr(r){let t=r;br(r)&&(t=yr(t),t=t.replace(gr,(e,i)=>String.fromCodePoint(parseInt(i.trim(),16))),t=t.replaceAll(`\\
|
|
27
27
|
`,"\\n"),t=wr(t),t=te+t+te);try{return JSON.parse(t)}catch{throw new Error(`Failed to parse CSS property value: ${t}. Original input: ${r}`)}}var Ut=0,ee=null,j=null,X=class extends HTMLElement{constructor(){super(),st(this,"updateCssData",()=>{var r;this.dropCssDataCache(),(r=this.__boundCssProps)==null||r.forEach(t=>{let e=this.getCssData(this.__extractCssName(t),!0);e!==null&&this.$[t]!==e&&(this.$[t]=e)})}),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 X}initCallback(){}__initCallback(){var r;this.__initialized||(this.__initialized=!0,(r=this.initCallback)==null||r.call(this))}render(r,t=this.renderShadow){let e;if((t||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let s=this.getAttribute(_.USE_TPL);if(s){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(s))||document.querySelector(s);n?r=n.content.cloneNode(!0):console.warn(`Symbiote template "${s}" is not found...`)}}if(this.processInnerHtml)for(let s of this.tplProcessors)s(this,this);if(r||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(r==null?void 0:r.constructor)===DocumentFragment)e=r;else if((r==null?void 0:r.constructor)===String){let s=document.createElement("template");s.innerHTML=r,e=s.content.cloneNode(!0)}else this.constructor.__tpl&&(e=this.constructor.__tpl.content.cloneNode(!0));for(let s of this.tplProcessors)s(e,this)}let i=()=>{e&&(t&&this.shadowRoot.appendChild(e)||this.appendChild(e)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){t=!0;let s=document.createElement("link");s.rel="stylesheet",s.href=this.constructor.__shadowStylesUrl,s.onload=i,this.shadowRoot.prepend(s)}else i()}addTemplateProcessor(r){this.tplProcessors.add(r)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=ot.generate(),this.style.setProperty(_.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(_.CSS_CTX_PROP,!0)}get ctxName(){var r;let t=((r=this.getAttribute(_.CTX_NAME_ATTR))==null?void 0:r.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=t,t}get localCtx(){return this.__localCtx||(this.__localCtx=E.registerCtx({},this)),this.__localCtx}get nodeCtx(){return E.getCtx(this.ctxName,!1)||E.registerCtx({},this.ctxName)}static __parseProp(r,t){let e,i;if(r.startsWith(_.EXT_DATA_CTX_PRFX))e=t.nodeCtx,i=r.replace(_.EXT_DATA_CTX_PRFX,"");else if(r.includes(_.NAMED_DATA_CTX_SPLTR)){let s=r.split(_.NAMED_DATA_CTX_SPLTR);e=E.getCtx(s[0]),i=s[1]}else e=t.localCtx,i=r;return{ctx:e,name:i}}sub(r,t,e=!0){let i=o=>{this.isConnected&&t(o)},s=X.__parseProp(r,this);s.ctx.has(s.name)?this.allSubs.add(s.ctx.sub(s.name,i,e)):window.setTimeout(()=>{this.allSubs.add(s.ctx.sub(s.name,i,e))})}notify(r){let t=X.__parseProp(r,this);t.ctx.notify(t.name)}has(r){let t=X.__parseProp(r,this);return t.ctx.has(t.name)}add(r,t,e=!1){let i=X.__parseProp(r,this);i.ctx.add(i.name,t,e)}add$(r,t=!1){for(let e in r)this.add(e,r[e],t)}get $(){if(!this.__stateProxy){let r=Object.create(null);this.__stateProxy=new Proxy(r,{set:(t,e,i)=>{let s=X.__parseProp(e,this);return s.ctx.pub(s.name,i),!0},get:(t,e)=>{let i=X.__parseProp(e,this);return i.ctx.read(i.name)}})}return this.__stateProxy}set$(r,t=!1){for(let e in r){let i=r[e];t||![String,Number,Boolean].includes(i==null?void 0:i.constructor)?this.$[e]=i:this.$[e]!==i&&(this.$[e]=i)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(_.CTX_OWNER_ATTR)&&this.getAttribute(_.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let r=this.constructor.__attrDesc;if(r)for(let t of Object.values(r))Object.keys(this.init$).includes(t)||(this.init$[t]="");for(let t in this.init$)if(t.startsWith(_.EXT_DATA_CTX_PRFX))this.nodeCtx.add(t.replace(_.EXT_DATA_CTX_PRFX,""),this.init$[t],this.__ctxOwner);else if(t.includes(_.NAMED_DATA_CTX_SPLTR)){let e=t.split(_.NAMED_DATA_CTX_SPLTR),i=e[0].trim(),s=e[1].trim();if(i&&s){let o=E.getCtx(i,!1);o||(o=E.registerCtx({},i)),o.add(s,this.init$[t])}}else this.localCtx.add(t,this.init$[t]);for(let t in this.cssInit$)this.bindCssData(t,this.cssInit$[t]);this.__dataCtxInitialized=!0}connectedCallback(){var r;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let t=(r=this.getAttribute(_.CTX_NAME_ATTR))==null?void 0:r.trim();if(t&&this.style.setProperty(_.CSS_CTX_PROP,`'${t}'`),this.__initDataCtx(),this[_.SET_LATER_KEY]){for(let e in this[_.SET_LATER_KEY])Ft(this,e,this[_.SET_LATER_KEY][e]);delete this[_.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let e of _r)this.addTemplateProcessor(e);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let e=this.getRootNode();if(!e)return;if(e==null?void 0:e.querySelector(`link[${_.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let s=this.constructor.__rootStylesLink.cloneNode(!0);s.setAttribute(_.ROOT_STYLE_ATTR_NAME,this.constructor.is),s.onload=()=>{this.render()},e.nodeType===Node.DOCUMENT_NODE?e.head.appendChild(s):e.prepend(s)}else this.render()}this.connectedOnce=!0}}destroyCallback(){}disconnectedCallback(){this.connectedOnce&&(this.dropCssDataCache(),this.readyToDestroy&&(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),this.__disconnectTimeout=window.setTimeout(()=>{this.destroyCallback();for(let r of this.allSubs)r.remove(),this.allSubs.delete(r);for(let r of this.tplProcessors)this.tplProcessors.delete(r);j==null||j.delete(this.updateCssData),j!=null&&j.size||(ee==null||ee.disconnect(),ee=null,j=null)},100)))}static reg(r,t=!1){r||(Ut++,r=`${_.AUTO_TAG_PRFX}-${Ut}`),this.__tag=r;let e=window.customElements.get(r);if(e){!t&&e!==this&&console.warn([`Element with tag name "${r}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
|
|
28
|
-
`));return}window.customElements.define(r,t?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(r){this.observedAttributes=Object.keys(r),this.__attrDesc=r}attributeChangedCallback(r,t,e){var i;if(t===e)return;let s=(i=this.constructor.__attrDesc)==null?void 0:i[r];s?this.__dataCtxInitialized?this.$[s]=e:this.init$[s]=e:this[r]=e}getCssData(r,t=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(r)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(r).trim();try{this.__cssDataCache[r]=vr(e)}catch{!t&&console.warn(`CSS Data error: ${r}`),this.__cssDataCache[r]=null}}return this.__cssDataCache[r]}__extractCssName(r){return r.split("--").map((t,e)=>e===0?"":t).join("--")}__initStyleAttrObserver(){j||(j=new Set),j.add(this.updateCssData),ee||(ee=new MutationObserver(r=>{r[0].type==="attributes"&&j.forEach(t=>{t()})}),ee.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(r,t=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(r);let e=this.getCssData(this.__extractCssName(r),!0);e===null&&(e=t),this.add(r,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(r,t,e){let i="__"+r;this[i]=this[r],Object.defineProperty(this,r,{set:s=>{this[i]=s,e?window.setTimeout(()=>{t==null||t(s)}):t==null||t(s)},get:()=>this[i]}),this[r]=this[i]}static set shadowStyles(r){let t=new Blob([r],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(t)}static set rootStyles(r){if(!this.__rootStylesLink){let t=new Blob([r],{type:"text/css"}),e=URL.createObjectURL(t),i=document.createElement("link");i.href=e,i.rel="stylesheet",this.__rootStylesLink=i}}},nt=X;st(nt,"template");var rt=class{static _print(r){console.warn(r)}static setDefaultTitle(r){this.defaultTitle=r}static setRoutingMap(r){Object.assign(this.appMap,r);for(let t in this.appMap)!this.defaultRoute&&this.appMap[t].default===!0?this.defaultRoute=t:!this.errorRoute&&this.appMap[t].error===!0&&(this.errorRoute=t)}static set routingEventName(r){this.__routingEventName=r}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let r={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))r.route=e.replace("?","");else if(e.includes("=")){let i=e.split("=");r.options[i[0]]=decodeURI(i[1])}else r.options[e]=!0}),r}static notify(){let r=this.readAddressBar(),t=this.appMap[r.route];if(t&&t.title&&(document.title=t.title),r.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!t&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t){this._print(`Route "${r.route}" not found...`);return}let e=new CustomEvent(rt.routingEventName,{detail:{route:r.route,options:Object.assign(t||{},r.options)}});window.dispatchEvent(e)}static reflect(r,t={}){let e=this.appMap[r];if(!e){this._print("Wrong route: "+r);return}let i="?"+r;for(let o in t)t[o]===!0?i+=this.separator+o:i+=this.separator+o+`=${t[o]}`;let s=e.title||this.defaultTitle||"";window.history.pushState(null,s,i),document.title=s}static applyRoute(r,t={}){this.reflect(r,t),this.notify()}static setSeparator(r){this._separator=r}static get separator(){return this._separator||"&"}static createRouterData(r,t){this.setRoutingMap(t);let e=E.registerCtx({route:null,options:null,title:null},r);return window.addEventListener(this.routingEventName,i=>{var s;e.multiPub({route:i.detail.route,options:i.detail.options,title:((s=i.detail.options)==null?void 0:s.title)||this.defaultTitle||""})}),rt.notify(),this.initPopstateListener(),e}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};rt.appMap=Object.create(null);var zt="idb-store-ready",Er="symbiote-db",Cr="symbiote-idb-update_",Tr=class{_notifyWhenReady(r=null){window.dispatchEvent(new CustomEvent(zt,{detail:{dbName:this.name,storeName:this.storeName,event:r}}))}get _updEventName(){return Cr+this.name}_getUpdateEvent(r){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:r}})}_notifySubscribers(r){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,r),window.dispatchEvent(this._getUpdateEvent(r))}constructor(r,t){this.name=r,this.storeName=t,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=e=>{this.db=e.target.result,this.objStore=this.db.createObjectStore(t,{keyPath:"_key"}),this.objStore.transaction.oncomplete=i=>{this._notifyWhenReady(i)}},this.request.onsuccess=e=>{this.db=e.target.result,this._notifyWhenReady(e)},this.request.onerror=e=>{console.error(e)},this._subscriptionsMap={},this._updateHandler=e=>{e.key===this.name&&this._subscriptionsMap[e.newValue]&&this._subscriptionsMap[e.newValue].forEach(async s=>{s(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(r){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(r);return new Promise((i,s)=>{e.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?i(o.target.result._value):(i(null),console.warn(`IDB: cannot read "${r}"`))},e.onerror=o=>{s(o)}})}write(r,t,e=!1){let i={_key:r,_value:t},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(i);return new Promise((n,a)=>{o.onsuccess=l=>{e||this._notifySubscribers(r),n(l.target.result)},o.onerror=l=>{a(l)}})}delete(r,t=!1){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(r);return new Promise((s,o)=>{i.onsuccess=n=>{t||this._notifySubscribers(r),s(n)},i.onerror=n=>{o(n)}})}getAll(){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,i)=>{t.onsuccess=s=>{let o=s.target.result;e(o.map(n=>n._value))},t.onerror=s=>{i(s)}})}subscribe(r,t){this._subscriptionsMap[r]||(this._subscriptionsMap[r]=new Set);let e=this._subscriptionsMap[r];return e.add(t),{remove:()=>{e.delete(t),e.size||delete this._subscriptionsMap[r]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,jt.clear(this.name)}},jt=class{static get readyEventName(){return zt}static open(r=Er,t="store"){let e=r+"/"+t;return this._reg[e]||(this._reg[e]=new Tr(r,t)),this._reg[e]}static clear(r){window.indexedDB.deleteDatabase(r);for(let t in this._reg)t.split("/")[0]===r&&delete this._reg[t]}};st(jt,"_reg",Object.create(null));var Bt=r=>{if(typeof r!="string"||!r)return"";let t=r.trim();return t.startsWith("-/")?t=t.slice(2):t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,t.length-1)),t},ke=(...r)=>r.filter(t=>typeof t=="string"&&t).map(t=>Bt(t)).join("/-/"),B=(...r)=>{let t=ke(...r);return t?`-/${t}/`:""};function Ie(r){let t=new URL(r),e=t.pathname+t.search+t.hash,i=e.lastIndexOf("http"),s=e.lastIndexOf("/"),o="";return i>=0?o=e.slice(i):s>=0&&(o=e.slice(s+1)),o}function Le(r){let t=new URL(r),{pathname:e}=t,i=e.indexOf("/"),s=e.indexOf("/",i+1);return e.substring(i+1,s)}function at(r){let t=Vt(r),e=new URL(t),i=e.pathname.indexOf("/-/");return i===-1?"":e.pathname.substring(i).slice(1)}function lt(r){return at(r).split("/-/").filter(Boolean).map(e=>Bt(e))}function Vt(r){let t=new URL(r),e=Ie(r),i=Ht(e)?Xt(e).pathname:e;return t.pathname=t.pathname.replace(i,""),t.search="",t.hash="",t.toString()}function Ht(r){return r.startsWith("http")}function Xt(r){let t=new URL(r);return{pathname:t.origin+t.pathname||"",search:t.search||"",hash:t.hash||""}}var V=(r,t,e)=>{let i=new URL(Vt(r));if(e=e||Ie(r),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),Ht(e)){let s=Xt(e);i.pathname=i.pathname+(t||"")+(s.pathname||""),i.search=s.search,i.hash=s.hash}else i.pathname=i.pathname+(t||"")+(e||"");return i.toString()},ct=(r,t)=>{let e=new URL(r);return e.pathname=t+"/",e.toString()};var de=(r,t=",")=>r.trim().split(t).map(e=>e.trim()).filter(e=>e.length>0);var L=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}),Wt=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function xr(r,t){if(typeof t=="number"){let e=t;return L[r]!==e?`${r}/${e}`:""}if(typeof t=="boolean"){let e=t;return L[r]!==e?`${r}`:""}if(r==="filter"&&t){let{name:e,amount:i}=t;return L.filter===i?"":`${r}/${e}/${i}`}if(r==="crop"&&t){let{dimensions:e,coords:i}=t;return`${r}/${e.join("x")}/${i.join(",")}`}return""}function G(r){return ke(...Wt.filter(t=>typeof r[t]!="undefined"&&r[t]!==null).map(t=>{let e=r[t];return xr(t,e)}).filter(t=>!!t))}var Pe=ke("format/auto","progressive/yes"),H=([r])=>typeof r!="undefined"?Number(r):void 0,Gt=()=>!0,Ar=([r,t])=>({name:r,amount:typeof t!="undefined"?Number(t):100}),Sr=([r,t])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(t))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:de(r,"x").map(Number),coords:de(t).map(Number)}},$r=Object.freeze({enhance:H,brightness:H,exposure:H,gamma:H,contrast:H,saturation:H,vibrance:H,warmth:H,filter:Ar,mirror:Gt,flip:Gt,rotate:H,crop:Sr});function ht(r){let t={};for(let e of r){let[i,...s]=e.split("/");if(!Wt.includes(i))continue;let o=i,n=$r[o];try{let a=n(s);t[o]=a}catch(a){console.warn([`Failed to parse URL operation "${e}". 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 t}var y=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),k=[y.CROP,y.TUNING,y.FILTERS],qt=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],Kt=["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"],Yt=["rotate","mirror","flip"],U=Object.freeze({brightness:{zero:L.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:L.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:L.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:L.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:L.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:L.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:L.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:L.enhance,range:[0,100],keypointsNumber:1},filter:{zero:L.filter,range:[0,100],keypointsNumber:1}});var Y=r=>r?r.split(",").map(t=>t.trim()).filter(Boolean):[],Z=r=>r?r.join(","):"";var ut="https://ucarecdn.com",Or="https://upload.uploadcare.com",kr="https://social.uploadcare.com",Ir="https://ucarecd.net",P=Object.freeze({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:Z(k),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:ut,cdnCnamePrefixed:Ir,baseUrl:Or,socialBaseUrl:kr,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:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0});var dt=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config"}),x=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created",...dt}),Re=class{constructor(t){f(this,"_timeoutStore",new Map);f(this,"_targets",new Set);f(this,"_debugPrint",null);this._debugPrint=t}bindTarget(t){this._targets.add(t)}unbindTarget(t){this._targets.delete(t)}_dispatch(t,e){var i;for(let s of this._targets)s.dispatchEvent(new CustomEvent(t,{detail:e}));(i=this._debugPrint)==null||i.call(this,()=>{let s=e&&typeof e=="object"?{...e}:e;return[`event "${t}"`,s]})}emit(t,e,{debounce:i}={}){if(typeof i!="number"&&!i){this._dispatch(t,typeof e=="function"?e():e);return}this._timeoutStore.has(t)&&window.clearTimeout(this._timeoutStore.get(t));let s=typeof i=="number"?i:20,o=window.setTimeout(()=>{this._dispatch(t,typeof e=="function"?e():e),this._timeoutStore.delete(t)},s);this._timeoutStore.set(t,o)}};function A(r,t){let e,i=(...s)=>{clearTimeout(e),e=setTimeout(()=>r(...s),t)};return i.cancel=()=>{clearTimeout(e)},i}var Zt="--uploadcare-blocks-window-height",J=class{static registerClient(t){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(t)}static unregisterClient(t){this.clientsRegistry.delete(t),this.clientsRegistry.size===0&&this.detachTracker()}static attachTracker(){window.addEventListener("resize",this.flush,{passive:!0,capture:!0}),this.flush()}static detachTracker(){window.removeEventListener("resize",this.flush,{capture:!0}),document.documentElement.style.removeProperty(Zt)}};f(J,"clientsRegistry",new Set),f(J,"flush",A(()=>{document.documentElement.style.setProperty(Zt,`${window.innerHeight}px`)},100));var Jt=r=>{var i;let t=new Intl.Locale(r),e="ltr";return typeof t.getTextInfo=="function"&&t.getTextInfo().direction?e=t.getTextInfo().direction:"textInfo"in t&&((i=t.textInfo)!=null&&i.direction)&&(e=t.textInfo.direction),e};var Qt=(r,t)=>new Intl.PluralRules(r).select(t);var Lr=r=>r,ft="{{",ti="}}",ei="plural:";function pt(r,t,e={}){var n;let{openToken:i=ft,closeToken:s=ti,transform:o=Lr}=e;for(let a in t){let l=(n=t[a])==null?void 0:n.toString();r=r.replaceAll(i+a+s,typeof l=="string"?o(l):l)}return r}function ii(r){let t=[],e=r.indexOf(ft);for(;e!==-1;){let i=r.indexOf(ti,e),s=r.substring(e+2,i);if(s.startsWith(ei)){let o=r.substring(e+2,i).replace(ei,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));t.push({variable:s,pluralKey:n,countVariable:a})}e=r.indexOf(ft,i)}return t}var ri=({element:r,attribute:t,onSuccess:e,onTimeout:i,timeout:s=300})=>{let o=r.getAttribute(t);if(o!==null){e(o);return}let n=new MutationObserver(c=>{let u=c[c.length-1];l(u)});n.observe(r,{attributes:!0,attributeFilter:[t]});let a=setTimeout(()=>{n.disconnect(),i()},s),l=c=>{let u=r.getAttribute(t);c.type==="attributes"&&c.attributeName===t&&u!==null&&(clearTimeout(a),n.disconnect(),e(u))}};var eo={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"};var si;(function(r){r.Token="token",r.FileInfo="file_info"})(si||(si={}));var oi;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(oi||(oi={}));var to=window.WebSocket;var Me=class{constructor(t){f(this,"_concurrency",1);f(this,"_pending",[]);f(this,"_running",0);f(this,"_resolvers",new Map);f(this,"_rejectors",new Map);this._concurrency=t}_run(){let t=this._concurrency-this._running;for(let e=0;e<t;e++){let i=this._pending.shift();if(!i)return;let s=this._resolvers.get(i),o=this._rejectors.get(i);if(!s||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,i().finally(()=>{this._resolvers.delete(i),this._rejectors.delete(i),this._running-=1,this._run()}).then(n=>s(n)).catch(n=>o(n))}}add(t){return new Promise((e,i)=>{this._resolvers.set(t,e),this._rejectors.set(t,i),this._pending.push(t),this._run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(t){this._concurrency=t,this._run()}get concurrency(){return this._concurrency}};var ni=()=>({});var fe={"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:"Queued","aspect-ratio":"Aspect ratio","crop-to-shape":"Crop to {{value}}",custom:"Custom"};var Ne=new Map,mt=new Map,ai=(r,t)=>{Ne.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`),Ne.set(r,{...fe,...t})},Pr=(r,t)=>{mt.set(r,t)},Rr=(r,t)=>{typeof t=="function"?Pr(r,t):ai(r,t)},li=async r=>{if(!Ne.has(r)){if(!mt.has(r))throw new Error(`Locale ${r} is not defined`);let e=await mt.get(r)();ai(r,e)}return Ne.get(r)};Rr("en",fe);var M=r=>`*l10n/${r}`,Mr="en",Ue=class{constructor(t){f(this,"_blockInstance",null);f(this,"_localeName","");f(this,"_callbacks",new Set);f(this,"_boundBlocks",new Map);this._blockInstance=t;for(let[e,i]of Object.entries(fe)){let s=this._blockInstance.has(M(e))?!this._blockInstance.$[M(e)]:!0;this._blockInstance.add(M(e),i,s)}setTimeout(()=>{t.subConfigValue("localeName",async e=>{var o;if(!this._blockInstance||!e)return;this._localeName=e;let i=await li(e);if(e!==Mr&&this._localeName!==e)return;let s=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[e];for(let[n,a]of Object.entries(i)){let l=s==null?void 0:s[n];this._blockInstance.add(M(n),l!=null?l:a,!0);for(let c of this._callbacks)c()}}),t.subConfigValue("localeDefinitionOverride",e=>{var s;if(!e)return;let i=e[this._localeName];if(i)for(let[o,n]of Object.entries(i)){(s=this._blockInstance)==null||s.add(M(o),n,!0);for(let a of this._callbacks)a()}})})}onLocaleChange(t){let e=A(t,0);return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}bindL10n(t,e,i){var o,n,a;t.$[e]=i(),this._boundBlocks.has(t)||this._boundBlocks.set(t,new Map),(n=(o=this._boundBlocks.get(t))==null?void 0:o.get(e))==null||n();let s=this.onLocaleChange(()=>{t.$[e]=i()});(a=this._boundBlocks.get(t))==null||a.set(e,s)}destroyL10nBindings(t){let e=this._boundBlocks.get(t);if(e){for(let i of e.values())i();this._boundBlocks.delete(t)}}destroy(){this._callbacks.clear()}};function ci(r,t){[...r.querySelectorAll("[l10n]")].forEach(e=>{let i=e.getAttribute("l10n");if(!i)return;let s=i.split(";");for(let o of s)o&&Nr(e,o,t)})}var Nr=(r,t,e)=>{let i="textContent",s=!1;if(t.includes(":")){let a=t.split(":");i=a[0],t=a[1],i.startsWith("@")&&(i=i.slice(1),s=!0)}let o=t;e.has(o)&&e.sub(o,a=>{if(!a)return;e.l10nProcessorSubs.has(o)||e.l10nProcessorSubs.set(o,new Set);let l=e.l10nProcessorSubs.get(o);l==null||l.forEach(h=>{h.remove(),l.delete(h),e.allSubs.delete(h)});let c=M(a).replace("*","");e.nodeCtx.has(c)||e.nodeCtx.add(c,a);let u=e.nodeCtx.sub(c,()=>{r[i]=e.l10n(a)});l==null||l.add(u),e.allSubs.add(u),r.removeAttribute("l10n")});let n=M(t);e.has(n)||e.add(n,""),e.sub(n,()=>{t=t,s?r.setAttribute(i,e.l10n(t)):r[i]=e.l10n(t)}),r.removeAttribute("l10n")};var S=r=>`*cfg/${r}`;function hi(r,t){let e=r.querySelectorAll("[data-testid]");if(e.length===0)return;let i=new WeakMap;for(let s of e){let o=s.getAttribute("data-testid");o&&i.set(s,o)}t.subConfigValue("testMode",s=>{if(!s){for(let n of e)n.removeAttribute("data-testid");return}let o=t.testId;for(let n of e){let a=i.get(n);a&&n.setAttribute("data-testid",`${o}--${a}`)}})}var Ur={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function pe(r,t){t.tabIndex=0,t.focus(),r.tabIndex=-1}function _t(r){let t=r.role||r.type||r.tagName;if(!t)return null;let e=Ur[t.toLowerCase()];if(!e)return null;for(let i of e){let s=r.closest(`[role=${i}]`);if(s)return s}}function gt(r,t){return t.role==="toolbar"?Dr(t):t.querySelectorAll(`[role=${r.role}]`)}function Dr(r){return[...r.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function Fr(r){let t=r.getAttribute("aria-orientation");if(t==="vertical")return!1;if(t==="horizontal")return!0;let e=r.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function ui(r){return t=>{let e=!1,i=(r==null?void 0:r.searchDelayMs)||300,s=0,o="";function n(h){let d=_t(h.target);if(!d){a();return}let p=gt(h.target,d),g=Array.from(p).indexOf(h.target),N="ArrowDown",O="ArrowUp";if(Fr(d)&&(t.document.dir==="rtl"?(N="ArrowLeft",O="ArrowRight"):(N="ArrowRight",O="ArrowLeft")),h.key===N)h.preventDefault(),pe(h.target,p[g+1]||p[0]);else if(h.key===O)h.preventDefault(),pe(h.target,p[g-1]||p[p.length-1]);else if(h.key==="Home")h.preventDefault(),pe(h.target,p[0]);else if(h.key==="End")h.preventDefault(),pe(h.target,p[p.length-1]);else if(h.key.length===1&&d.role!=="tablist"){let T=Date.now();T-s<=i?o+=h.key.toLowerCase():o=h.key.toLowerCase(),s=T;let It=Array.from(p).find(Qi=>{var Lt,Pt,Rt;return(Rt=(Pt=(Lt=Qi.textContent)==null?void 0:Lt.trim())==null?void 0:Pt.toLowerCase())==null?void 0:Rt.startsWith(o)});It&&(h.preventDefault(),pe(h.target,It))}}function a(){e=!1,t.removeEventListener("keydown",n)}function l(h){let d=_t(h.target);if(d){e||(e=!0,t.addEventListener("keydown",n));let p=gt(h.target,d);for(let g of p)g!==h.target&&g.setAttribute("tabindex",-1)}else e&&a()}function c(h){(!h.relatedTarget||h.relatedTarget===t.document)&&a()}function u(h){let d=_t(h.target);if(d){let p=gt(h.target,d);for(let g of p)g!==h.target&&g.setAttribute("tabindex",-1);h.target.setAttribute("tabindex",0)}}return t.addEventListener("click",u),t.addEventListener("focusin",l),t.addEventListener("focusout",c),()=>{a(),t.removeEventListener("click",u),t.removeEventListener("focusin",l),t.removeEventListener("focusout",c)}}}function di(){return r=>{let t,e;function i(o){if(o.target.getAttribute("aria-hidden")==="true"){t=o.target,t.setAttribute("aria-hidden","false"),e=t.hidden,e&&(t.hidden=!1);let n=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function s(o){t&&t.contains(o.target)&&(!o.relatedTarget||!t.contains(o.relatedTarget))&&(o.target.tabIndex=-1,t.setAttribute("aria-hidden","true"),e&&(t.hidden=!0),t=null)}return r.addEventListener("keyuxJump",i),r.addEventListener("focusout",s),()=>{r.removeEventListener("keyuxJump",i),r.removeEventListener("focusout",s)}}}function fi(){return r=>{let t=[];function e(l){let c=r.document.activeElement;c&&c!==r.document.body&&t.push(new WeakRef(c)),l.focus({focusVisible:!0})}function i(){let l=t.pop();if(!l){r.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():i()}let s=0,o;function n(l){clearInterval(o);let c=l.getAttribute("aria-controls");o=setInterval(()=>{if(s++>50){clearInterval(o);return}let u=r.document.getElementById(c);if(u){let h=u.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');h&&(clearInterval(o),u.dispatchEvent(new r.CustomEvent("keyuxJump",{bubbles:!0})),e(h))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&i()}return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}}}function pi(r){let t,e=r.split(" "),i;function s(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(o(),a.target.classList.add(...e),t=a.target,i=a.target)}function o(){t&&t.classList.remove(...e),i=null}function n(a){a.clientX===0&&a.clientY===0&&i!==a.target&&(o(),a.target.classList.add(...e),t=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",s),a.addEventListener("keyup",o),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",s),a.removeEventListener("keyup",o)})}function mi(r,t){let e=t.map(i=>i(r));return()=>{e.forEach(i=>i())}}var bt=class{constructor(){f(this,"_listeners",new Map);f(this,"_scope",[])}addEventListener(t,e){let i=s=>{let o=s.target;o&&this._scope.some(n=>n===s.target||n.contains(o))&&e(s)};this._listeners.set(e,i),window.addEventListener(t,i)}removeEventListener(t,e){let i=this._listeners.get(e);i&&window.removeEventListener(t,i),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(t){this._scope.push(t)}destroy(){this._scope=[],this._listeners.forEach((t,e)=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",t),this._listeners.delete(e)})}},De=class{constructor(){f(this,"_destroyKeyUX");f(this,"_scopedWindow");this._scopedWindow=new bt,this._destroyKeyUX=mi(this._scopedWindow,[ui(),pi("is-pressed"),fi(),di()])}registerBlock(t){this._scopedWindow.registerScope(t)}destroy(){var t;(t=this._destroyKeyUX)==null||t.call(this),this._scopedWindow.destroy()}};var ie=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Fe=class{constructor(t){f(this,"_modals",new Map);f(this,"_activeModals",new Set);f(this,"_subscribers",new Map);this._block=t}_debugPrint(...t){this._block.debugPrint("[modal-manager]",...t)}registerModal(t,e){this._modals.set(t,e),this._notify(ie.ADD,{id:t,modal:e})}deleteModal(t){if(!this._modals.has(t))return!1;let e=this._modals.get(t);return this._modals.delete(t),this._activeModals.delete(t),this._notify(ie.DELETE,{id:t,modal:e}),!0}open(t){if(!this._modals.has(t))return this._debugPrint(`Modal with ID "${t}" not found`),!1;let e=this._modals.get(t);return this._activeModals.add(t),this._notify(ie.OPEN,{modal:e,id:t}),!0}close(t){if(!this._modals.has(t)||!this._activeModals.has(t))return this._debugPrint(`Modal with ID "${t}" not found or not active`),!1;let e=this._modals.get(t);return this._activeModals.delete(t),this._notify(ie.CLOSE,{id:t,modal:e}),!0}toggle(t){return this._modals.has(t)?this._activeModals.has(t)?this.close(t):this.open(t):(this._debugPrint(`Modal with ID "${t}" 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 t=Array.from(this._activeModals).pop();return this.close(t)}closeAll(){let t=this._activeModals.size;return this._activeModals.clear(),this._notify(ie.CLOSE_ALL,{}),t}subscribe(t,e){var i;return this._subscribers.has(t)||this._subscribers.set(t,new Set),(i=this._subscribers.get(t))==null||i.add(e),()=>this.unsubscribe(t,e)}unsubscribe(t,e){var i;this._subscribers.has(t)&&((i=this._subscribers.get(t))==null||i.delete(e))}_notify(t,e){var i;if(this._subscribers.has(t))for(let s of(i=this._subscribers.get(t))!=null?i:new Set)try{s(e)}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(ie.DESTROY,{})}};function zr(r){return r.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`).replace(/__/g,"_")}function wt(r){return Array.isArray(r)?r.map(t=>typeof t=="object"&&t!==null?wt(t):t):typeof r!="object"||r===null?r:Object.fromEntries(Object.entries(r).map(([t,e])=>{let i=zr(t);return typeof e=="object"&&e!==null?[i,wt(e)]:[i,e]}))}function jr(r){return{ok:!0,value:r}}function yt(r){return{ok:!1,error:r}}var Br="https://tlm.uploadcare.com/api/",vt=class{constructor(t=Br){this.baseUrl=t}async base(t,e={}){let i=`${this.baseUrl}${t}`;try{let s=await fetch(i,e);if(!s.ok)return yt(new Error(`Got non-200 response from "${i}". Status: ${s.status.toString()}`));try{let o=await s.json();return jr(o)}catch(o){return yt(new Error(`Error parsing JSON from "${i}". Error: ${o}`))}}catch(s){return yt(new Error(`Error fetching data from "${i}". Error: ${s}`))}}async post(t,e,i={}){return await this.base(t,{...i,method:"POST",body:JSON.stringify(wt(e)),headers:{"Content-Type":"application/json",...i.headers||{}}})}async get(t,e={}){return await this.base(t,{method:"GET",...e})}},Vr=async(r,t)=>({success:!0,data:t}),ze=class extends vt{constructor(){super()}async sendEvent(t,e){let i=await Vr(void 0,t);if(!i.success)throw console.error("TelemetryAPIService: events: body is invalid",i.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",t,e)}};var je="blocks",Be="1.21.0";var Ve=class{constructor(t){f(this,"_sessionId",crypto.randomUUID());f(this,"_telemetryInstance",null);f(this,"_block",null);f(this,"_config",structuredClone(P));f(this,"_initialized",!1);f(this,"_lastPayload",null);f(this,"_queue",null);this._block=t,this._telemetryInstance=new ze,this._queue=new Me(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,i=>{var s;this._initialized&&this._config[e]!==i&&((s=this._block)==null||s.emit(x.CHANGE_CONFIG,void 0)),this._setConfig(e,i)})}_init(t){t===x.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(t,e){this._config[t]!==e&&(this._config[t]=e)}_formattingPayload(t){var s,o;let e=t.payload?{...t.payload}:{};e.activity&&(e.activity=void 0);let i={...t};return(t.eventType===x.INIT_SOLUTION||t.eventType===x.CHANGE_CONFIG)&&(i.config=this._config),{...i,appVersion:Be,appName:je,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:(s=this._config)==null?void 0:s.pubkey,userAgent:navigator.userAgent,eventType:(o=i.eventType)!=null?o:"",eventTimestamp:this._timestamp,payload:{...e}}}_excludedEvents(t){return!!(t&&[x.CHANGE,x.COMMON_UPLOAD_PROGRESS,x.FILE_ADDED,x.FILE_REMOVED,x.FILE_UPLOAD_START,x.FILE_UPLOAD_PROGRESS,x.FILE_UPLOAD_SUCCESS,x.FILE_UPLOAD_FAILED,x.FILE_URL_CHANGED,x.GROUP_CREATED].includes(t))}sendEvent(t){var o;let e=this._formattingPayload(t);if(this._init(t.eventType),this._excludedEvents(t.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))return null;(o=this._queue)==null||o.add(async()=>{var n;this._lastPayload=e,await((n=this._telemetryInstance)==null?void 0:n.sendEvent(e))})}sendEventError(t,e="unknown"){this.sendEvent({payload:{metadata:{event:"error",text:`Error in ${e}`,error:t.message}}})}sendEventCloudImageEditor(t,e,i={}){var s;this.sendEvent({payload:{metadata:{tabId:e,node:(s=t.currentTarget)==null?void 0:s.tagName,event:t.type,...i}}})}_checkObj(t,e){if(JSON.stringify(t)===JSON.stringify(e))return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;let i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(let o of i)if(!Object.prototype.hasOwnProperty.call(e,o)||!this._checkObj(t[o],e[o]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){var t,e;return(t=this._block)!=null&&t.has("*solution")?(e=this._block)==null?void 0:e.$["*solution"].toLowerCase():null}get _activity(){var t,e;return(t=this._block)!=null&&t.has("*currentActivity")?(e=this._block)==null?void 0:e.$["*currentActivity"]:null}};var Hr="uc-",b=class extends nt{constructor(){super();f(this,"requireCtxName",!1);f(this,"activityType",null);f(this,"init$",ni());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(ci),this.addTemplateProcessor(hi)}l10n(e,i={}){if(!e)return"";let s=this.$[M(e)]||e,o=ii(s);for(let a of o)i[a.variable]=this.pluralize(a.pluralKey,Number(i[a.countVariable]));return pt(s,i)}pluralize(e,i){let s=this.l10n("locale-id")||"en",o=Qt(s,i);return this.l10n(`${e}__${o}`)}bindL10n(e,i){var s;(s=this.localeManager)==null||s.bindL10n(this,e,i)}emit(e,i,s){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&(o.emit(e,i,s),this.telemetryManager.sendEvent({eventType:e,payload:typeof i=="function"?i():i}))}hasBlockInCtx(e){for(let i of this.blocksRegistry)if(e(i))return!0;return!1}setOrAddState(e,i){this.add$({[e]:i},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(i=>{this.setAttribute(i,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?ri({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),J.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),J.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Re(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new Ue(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new Ve(this)),this.has("*a11y")||this.add("*a11y",new De),this.has("*modalManager")||this.add("*modalManager",new Fe(this)),this.sub(M("locale-id"),i=>{let s=Jt(i);this.style.direction=s==="ltr"?"":s}),this.subConfigValue("testMode",i=>{if(!i||!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"]}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(){var i;super.destroyCallback();let e=this.blocksRegistry;e==null||e.delete(this),(i=this.localeManager)==null||i.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,E.deleteCtx(this),(e==null?void 0:e.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e,i;E.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.destroy(),this.modalManager&&((i=this.modalManager)==null||i.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:Le(e),cdnUrlModifiers:at(e),fileName:Ie(e)})}catch(i){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",i),this.telemetryManager.sendEventError(i,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?pt(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:i=>window.encodeURIComponent(i)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(i,s,o)=>{if(typeof s!="string")return!1;let n=S(s);return this.has(n)||this.add(n,P[s]),this.$[n]=o,!0},get:(i,s)=>{let o=S(s);return this.has(o)||this.add(o,P[s]),this.$[S(s)]}})}return this.__cfgProxy}subConfigValue(e,i){let s=S(e);this.has(s)||this.add(s,P[e]),this.sub(s,i)}debugPrint(...e){if(!this.cfg.debug)return;let i=e;if(typeof(e==null?void 0:e[0])=="function"){let s=e[0];i=s()}console.log(`[${this.ctxName}]`,...i)}static reg(e){if(!e){super.reg();return}e.startsWith(Hr)&&super.reg(e)}};f(b,"StateConsumerScope",null),f(b,"styleAttrs",[]);var D="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function _i(...r){return r.reduce((t,e)=>{if(typeof e=="string")return t[e]=!0,t;for(let i of Object.keys(e))t[i]=e[i];return t},{})}function C(...r){let t=_i(...r);return Object.keys(t).reduce((e,i)=>(t[i]&&e.push(i),e),[]).join(" ")}function gi(r,...t){let e=_i(...t);for(let i of Object.keys(e))r.classList.toggle(i,e[i])}var me=["free"],bi=r=>{let t=de(r);if(!(t!=null&&t.length))return[];let e=[];for(let i=0;i<t.length;i++){let s=t[i].trim();if(!s)continue;let o=s.indexOf(":");if(o===-1&&!me.includes(s)){console.warn(`Invalid crop preset: ${s}`);continue}let n=Number(s.slice(0,o)),a=Number(s.slice(o+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!me.includes(s)){console.warn(`Invalid crop preset: ${s}`);continue}e.push({id:ot.generate(),type:"aspect-ratio",width:me.includes(s)?0:n,height:me.includes(s)?0:a,hasFreeform:me.includes(s)})}return e},yi=(r,t,e,i=.1)=>{let s=r/t,o=null,n=1/0;for(let a of e){let[l,c]=[a.width,a.height],u=l/c,h=Math.abs(s-u);h<n&&(n=h,o=a)}if(o){let[a,l]=[o.width,o.height],c=a/l;if(Math.abs(s-c)/c>i)return null}return o};var wi=r=>{if(!r)return k;let t=Y(r).filter(e=>k.includes(e));return t.length===0?k:t};function vi(r){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":k,"*tabId":y.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:D,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:Z(k),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let t=r.querySelectorAll("img");for(let e of t){let i=e.src;e.src=D,e.src=i}r.$["*networkProblems"]=!1},"*on.apply":t=>{if(!t)return;let e=r.$["*originalUrl"],i=B(G(t),"preview"),s=V(e,i),o={originalUrl:e,cdnUrlModifiers:i,cdnUrl:s,transformations:t};r.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),r.remove()},"*on.cancel":()=>{r.remove(),r.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Ei="<svg width='0' height='0' style='position:absolute'><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 fill='none' viewBox='0 0 24 24' id='uc-icon-freeform' xmlns='http://www.w3.org/2000/svg'><path d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25' stroke='currentColor'/></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 Ci=`${Ei} <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="${D}" 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 W=class extends b{constructor(){super();f(this,"ctxOwner",!0);f(this,"_debouncedShowLoader",A(this._showLoader.bind(this),300));this.init$={...this.init$,...vi(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((i,s)=>{let o=setTimeout(()=>{s(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),n=new ResizeObserver(([a])=>{a.contentRect.width>0&&a.contentRect.height>0&&(i(),clearTimeout(o),n.disconnect())});n.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=Le(this.$.cdnUrl),i=ct(this.$.cdnUrl,e);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let s=lt(this.$.cdnUrl),o=ht(s);this.$["*editorTransformations"]=o}else if(this.$.uuid){let e=ct(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"]===y.CROP?this.$["*cropperEl"].deactivate({reset:!0}):this.$["*faderEl"].deactivate();try{let e=await this.proxyUrl(V(this.$["*originalUrl"],B("json"))),i=await fetch(e).then(n=>n.json()),{width:s,height:o}=i;this.$["*imageSize"]={width:s,height:o},this.$["*tabId"]===y.CROP?this.$["*cropperEl"].activate(this.$["*imageSize"]):this.$["*faderEl"].activate({url:this.$["*originalUrl"]})}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._imgLoading=!1,this._debouncedShowLoader(!1),this.$.src!==D&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let i=this.ref["img-el"];i.src!==e&&(this._imgLoading=!0,i.src=e||D)}),this.sub("tabs",e=>{this.$["*tabList"]=wi(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=C("uc-image",{"uc-image_hidden_to_cropper":e===y.CROP,"uc-image_hidden_effects":e!==y.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 i=this.$["*originalUrl"],s=B(G(e),"preview"),o=V(i,s),n={originalUrl:i,cdnUrlModifiers:s,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:!0,composed:!0}))},!1),this.sub("uuid",e=>e&&this.updateImage()),this.sub("cdnUrl",e=>e&&this.updateImage()),this.sub("cropPreset",e=>{var o,n,a;let i=bi(e),s=null;if(this.$.cdnUrl){let l=lt(this.$.cdnUrl),c=ht(l);if(Array.isArray((o=c==null?void 0:c.crop)==null?void 0:o.dimensions)){let[u,h]=(n=c==null?void 0:c.crop)==null?void 0:n.dimensions;s=yi(u,h,i,.1)}}this.$["*cropPresetList"]=i,this.$["*currentAspectRatio"]=(a=s!=null?s:i==null?void 0:i[0])!=null?a:null})}};f(W,"styleAttrs",["uc-cloud-image-editor"]);W.template=Ci;W.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var _e=33.333333333333336,m=1,Et=24,Ti=6;function q(r,t){for(let e in t)r.setAttributeNS(null,e,t[e].toString())}function $(r,t={}){let e=document.createElementNS("http://www.w3.org/2000/svg",r);return q(e,t),e}function xi(r,t,e){let{x:i,y:s,width:o,height:n}=r,a=t.includes("w")?0:1,l=t.includes("n")?0:1,c=[-1,1][a],u=[-1,1][l],h=[i+a*o+1.5*c,s+l*n+1.5*u-24*e*u],d=[i+a*o+1.5*c,s+l*n+1.5*u],p=[i+a*o-24*e*c+1.5*c,s+l*n+1.5*u];return{d:`M ${h[0]} ${h[1]} L ${d[0]} ${d[1]} L ${p[0]} ${p[1]}`,center:d}}function Ai(r,t,e){let{x:i,y:s,width:o,height:n}=r,a=["n","s"].includes(t)?.5:{w:0,e:1}[t],l=["w","e"].includes(t)?.5:{n:0,s:1}[t],c=[-1,1][a],u=[-1,1][l],h,d;["n","s"].includes(t)?(h=[i+a*o-34*e/2,s+l*n+1.5*u],d=[i+a*o+34*e/2,s+l*n+1.5*u]):(h=[i+a*o+1.5*c,s+l*n-34*e/2],d=[i+a*o+1.5*c,s+l*n+34*e/2]);let p=`M ${h[0]} ${h[1]} L ${d[0]} ${d[1]}`,g=[d[0]-(d[0]-h[0])/2,d[1]-(d[1]-h[1])/2];return{d:p,center:g}}function Si(r){return r===""?"move":["e","w"].includes(r)?"ew-resize":["n","s"].includes(r)?"ns-resize":["nw","se"].includes(r)?"nwse-resize":"nesw-resize"}function $i({rect:r,delta:[t,e],imageBox:i}){return se({...r,x:r.x+t,y:r.y+e},i)}function se(r,t){let{x:e}=r,{y:i}=r;return r.x<t.x?e=t.x:r.x+r.width>t.x+t.width&&(e=t.x+t.width-r.width),r.y<t.y?i=t.y:r.y+r.height>t.y+t.height&&(i=t.y+t.height-r.height),{...r,x:e,y:i}}function Xr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[,s]=t,{y:o,width:n,height:a}=r;o+=s,a-=s,e&&(n=a*e);let l=r.x+r.width/2-n/2;return o<=i.y&&(o=i.y,a=r.y+r.height-o,e&&(n=a*e,l=r.x+r.width/2-n/2)),l<=i.x&&(l=i.x,o=r.y+r.height-a),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,e&&(a=n/e),o=r.y+r.height-a),a<m&&(a=m,e&&(n=a*e,l=r.x+r.width/2-n/2),o=r.y+r.height-a),n<m&&(n=m,e&&(a=n/e,l=r.x+r.width/2-n/2),o=r.y+r.height-a),{x:l,y:o,width:n,height:a}}function Gr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s]=t,{x:o,width:n,height:a}=r;o+=s,n-=s,e&&(a=n/e);let l=r.y+r.height/2-a/2;return o<=i.x&&(o=i.x,n=r.x+r.width-o,e&&(a=n/e,l=r.y+r.height/2-a/2)),l<=i.y&&(l=i.y,o=r.x+r.width-n),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,e&&(n=a*e),o=r.x+r.width-n),a<m&&(a=m,e&&(n=a*e),l=r.y+r.height/2-a/2,o=r.x+r.width-n),n<m&&(n=m,e&&(a=n/e),l=r.y+r.height/2-a/2,o=r.x+r.width-n),{x:o,y:l,width:n,height:a}}function Wr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[,s]=t,{y:o,width:n,height:a}=r;a+=s,e&&(n=a*e);let l=r.x+r.width/2-n/2;return o+a>=i.y+i.height&&(a=i.y+i.height-o,e&&(n=a*e),l=r.x+r.width/2-n/2),l<=i.x&&(l=i.x,o=r.y),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,e&&(a=n/e),o=r.y),a<m&&(a=m,e&&(n=a*e),l=r.x+r.width/2-n/2),n<m&&(n=m,e&&(a=n/e),l=r.x+r.width/2-n/2),{x:l,y:o,width:n,height:a}}function qr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s]=t,{x:o,width:n,height:a}=r;n+=s,e&&(a=n/e);let l=r.y+r.height/2-a/2;return o+n>=i.x+i.width&&(n=i.x+i.width-o,e&&(a=n/e),l=r.y+r.height/2-a/2),l<=i.y&&(l=i.y,o=r.x),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,e&&(n=a*e),o=r.x),a<m&&(a=m,e&&(n=a*e),l=r.y+r.height/2-a/2),n<m&&(n=m,e&&(a=n/e),l=r.y+r.height/2-a/2),{x:o,y:l,width:n,height:a}}function Kr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+s<i.x&&(s=i.x-n),a+o<i.y&&(o=i.y-a),n+=s,l-=s,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=i.y&&(c=c-(i.y-a),l=c*e,n=r.x+r.width-l,a=i.y)):e&&(s=c*e-l,l=l+s,n-=s,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=r.y+r.height-c)),c<m&&(c=m,e&&(l=c*e),n=r.x+r.width-l,a=r.y+r.height-c),l<m&&(l=m,e&&(c=l/e),n=r.x+r.width-l,a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Yr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+l+s>i.x+i.width&&(s=i.x+i.width-n-l),a+o<i.y&&(o=i.y-a),l+=s,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=i.y&&(c=c-(i.y-a),l=c*e,n=r.x,a=i.y)):e&&(s=c*e-l,l+=s,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=r.y+r.height-c)),c<m&&(c=m,e&&(l=c*e),a=r.y+r.height-c),l<m&&(l=m,e&&(c=l/e),a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Zr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+s<i.x&&(s=i.x-n),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),n+=s,l-=s,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*e,n=r.x+r.width-l,a=i.y+i.height-c)):e&&(s=c*e-l,l+=s,n-=s,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=r.y)),c<m&&(c=m,e&&(l=c*e),n=r.x+r.width-l),l<m&&(l=m,e&&(c=l/e),n=r.x+r.width-l),{x:n,y:a,width:l,height:c}}function Jr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+l+s>i.x+i.width&&(s=i.x+i.width-n-l),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),l+=s,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*e,n=r.x,a=i.y+i.height-c)):e&&(s=c*e-l,l+=s,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=r.y)),c<m&&(c=m,e&&(l=c*e)),l<m&&(l=m,e&&(c=l/e)),{x:n,y:a,width:l,height:c}}function Oi({direction:r,...t}){switch(r){case"n":return Xr(t);case"w":return Gr(t);case"s":return Wr(t);case"e":return qr(t);case"nw":return Kr(t);case"ne":return Yr(t);case"sw":return Zr(t);case"se":return Jr(t);default:return t.rect}}function ki(r,[t,e]){return r.x<=t&&t<=r.x+r.width&&r.y<=e&&e<=r.y+r.height}function Ii(r,t){return r.x>=t.x&&r.y>=t.y&&r.x+r.width<=t.x+t.width&&r.y+r.height<=t.y+t.height}function Li(r,t){return Math.abs(r.width/r.height-t)<.1}function oe({width:r,height:t},e){let i=e/90%2!==0;return{width:i?t:r,height:i?r:t}}function ne(r){return{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}}function K(r,t,e){return Math.min(Math.max(r,t),e)}var Xe=class extends b{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(t){let e=this.$["*imageBox"];if(!e)return;if(t===""&&e.height<=m&&e.width<=m)return!0;let i=e.height<=m&&(t.includes("n")||t.includes("s")),s=e.width<=m&&(t.includes("e")||t.includes("w"));return i||s}_createBackdrop(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:i,width:s,height:o}=t,n=this.ref["svg-el"],a=$("mask",{id:"backdrop-mask"}),l=$("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=$("rect",{x:e,y:i,width:s,height:o,fill:"black"});a.appendChild(l),a.appendChild(c);let u=$("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});n.appendChild(u),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 t=this.$["*cropBox"];if(!t)return;let{x:e,y:i,width:s,height:o}=t;this._backdropMaskInner&&q(this._backdropMaskInner,{x:e,y:i,width:s,height:o})}_updateFrame(){let t=this.$["*cropBox"];if(!(!t||!this._frameGuides||!this._frameThumbs)){for(let e of Object.values(this._frameThumbs)){let{direction:i,pathNode:s,interactionNode:o,groupNode:n}=e,a=i==="",l=i.length===2,{x:c,y:u,width:h,height:d}=t;if(a)q(o,{x:c,y:u,width:h,height:d});else{let g=K(Math.min(h,d)/(24*2+34)/2,0,1),{d:N,center:O}=l?xi(t,i,g):Ai(t,i,g),T=Math.max(Et*K(Math.min(h,d)/Et/3,0,1),Ti);q(o,{x:O[0]-T,y:O[1]-T,width:T*2,height:T*2}),q(s,{d:N})}let p=this._shouldThumbBeDisabled(i);n.setAttribute("class",C("uc-thumb",{"uc-thumb--hidden":p,"uc-thumb--visible":!p}))}q(this._frameGuides,{x:t.x-1*.5,y:t.y-1*.5,width:t.width+1,height:t.height+1})}}_createThumb(t,e){let i=$("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let s=$("rect",{fill:"transparent"}),o=$("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(o),i.appendChild(s),t[e]={direction:e,pathNode:o,interactionNode:s,groupNode:i},e===""&&(i.style.cursor="move"),s.addEventListener("pointerdown",this._handlePointerDown.bind(this,e))}_createThumbs(){let t={};for(let e=0;e<3;e++)for(let i=0;i<3;i++){let s=`${["n","","s"][e]}${["w","","e"][i]}`;s!==""&&this._createThumb(t,s)}return this._createThumb(t,""),t}_createGuides(){let t=$("svg"),e=$("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});t.appendChild(e);for(let i=1;i<=2;i++){let s=$("line",{x1:`${_e*i}%`,y1:"0%",x2:`${_e*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s)}for(let i=1;i<=2;i++){let s=$("line",{x1:"0%",y1:`${_e*i}%`,x2:"100%",y2:`${_e*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s)}return t.classList.add("uc-guides","uc-guides--semi-hidden"),t}_createFrame(){let t=this.ref["svg-el"],e=document.createDocumentFragment(),i=this._createGuides();e.appendChild(i);let s=this._createThumbs();for(let{groupNode:o}of Object.values(s))e.appendChild(o);t.appendChild(e),this._frameThumbs=s,this._frameGuides=i}_handlePointerDown(t,e){if(!this._frameThumbs)return;let i=this._frameThumbs[t];if(this._shouldThumbBeDisabled(t))return;let s=this.$["*cropBox"],{x:o,y:n}=this.ref["svg-el"].getBoundingClientRect(),a=e.x-o,l=e.y-n;this.$.dragging=!0,this._draggingThumb=i,this._dragStartPoint=[a,l],this._dragStartCrop={...s}}_handlePointerUp_(t){this._updateCursor(),this.$.dragging&&(t.stopPropagation(),t.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(t){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;t.stopPropagation(),t.preventDefault();let e=this.ref["svg-el"],{x:i,y:s}=e.getBoundingClientRect(),o=t.x-i,n=t.y-s,a=o-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,u=this._calcCropBox(c,[a,l]);u&&(this.$["*cropBox"]=u)}_calcCropBox(t,e){var c;let[i,s]=e,o=this.$["*imageBox"],n=(c=this._dragStartCrop)!=null?c:this.$["*cropBox"],a=this.$["*currentAspectRatio"],l=a?a.width/a.height:void 0;if(t===""?n=$i({rect:n,delta:[i,s],imageBox:o}):n=Oi({rect:n,delta:[i,s],direction:t,aspectRatio:l,imageBox:o}),!Object.values(n).every(u=>Number.isFinite(u)&&u>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return se(ne(n),this.$["*imageBox"])}_handleSvgPointerMove_(t){if(!this._frameThumbs)return;let e=Object.values(this._frameThumbs).find(i=>{if(this._shouldThumbBeDisabled(i.direction))return!1;let o=i.interactionNode.getBoundingClientRect(),n={x:o.x,y:o.y,width:o.width,height:o.height};return ki(n,[t.x,t.y])});this._hoverThumb=e,this._updateCursor()}_updateCursor(){let t=this._hoverThumb;this.ref["svg-el"].style.cursor=t?Si(t.direction):"initial"}_createMask(t){if(this._frameImage){this._frameImage.setAttribute("href",t);return}let e=this.ref["svg-el"],i=document.createDocumentFragment(),s=$("image",{href:t});s.setAttribute("class","uc-cloud-mask"),i.appendChild(s),e.appendChild(i),this._frameImage=s}_updateMask(){let t=this.$["*cropBox"];if(!t||!this._frameImage)return;let{x:e,y:i,width:s,height:o}=t;q(this._frameImage,{x:e,y:i,height:o,width:s})}_render(){this._updateBackdrop(),this._updateFrame(),this._updateMask()}toggleThumbs(t){this._frameThumbs&&Object.values(this._frameThumbs).map(({groupNode:e})=>e).forEach(e=>{e.setAttribute("class",C("uc-thumb",{"uc-thumb--hidden":!t,"uc-thumb--visible":t}))})}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",t=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",t=>{t&&(this._guidesHidden=t.height<=m||t.width<=m,window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this._createMask(t)}),this.sub("dragging",t=>{this._frameGuides&&this._frameGuides.setAttribute("class",C({"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(),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}};Xe.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var R=class extends b{constructor(){super(...arguments);f(this,"init$",{...this.init$,active:!1,title:"",icon:"","on.click":null,"title-prop":""})}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this._iconEl=this.ref["icon-el"],this.sub("title",e=>{this._titleEl&&(this._titleEl.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=C({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e})}};R.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>`;function es(r){let t=r+90;return t=t>=360?0:t,t}function ts(r,t){return r==="rotate"?es(t):["mirror","flip"].includes(r)?!t:null}var ge=class extends R{initCallback(){super.initCallback(),this.defineAccessor("operation",t=>{t&&(this._operation=t,this.$.icon=t,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(t).toLowerCase()})))}),this.$["on.click"]=t=>{let e=this.$["*cropperEl"].getValue(this._operation),i=ts(this._operation,e);this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:this._operation,next:i,prev:e}),this.$["*cropperEl"].setValue(this._operation,i)}}};var Ge=12,Pi=16,is=r=>{let t=12,e=12;return r.width/r.height>=1?(t=Ge,e=Math.round(Ge*r.height/r.width)):(e=Ge,t=Math.round(Ge*r.width/r.height)),{width:t,height:e}},be=class extends R{constructor(){super()}initCallback(){super.initCallback(),this.$.icon="freeform",this.$["on.click"]=this.handleClick.bind(this),this.$.active=!!this.$["*currentAspectRatio"],this.sub("*currentAspectRatio",t=>{let e=t.hasFreeform?this.l10n("custom"):`${t.width}:${t.height}`;this.$.title=this.l10n("crop-to-shape",{value:e}),this.bindL10n("title-prop",()=>this.$.title)})}handleClick(){this.$["*showListAspectRatio"]=!0}},ye=class extends R{constructor(){super(),this.init$={...this.init$,active:!1,once:!1}}initCallback(){super.initCallback(),this.defineAccessor("aspectRatio",t=>{if(!t)return;let e=!!t.hasFreeform,i=this.l10n(e?"custom":t.type).toLowerCase();this.$.icon=e?"freeform":t.type,this.$.title=e?this.l10n("custom"):`${t.width}:${t.height}`,e||this._renderRectBasedOnAspectRatio(t),this._aspectRatio=t,this.bindL10n("title-prop",()=>{let s=e?"":`${t.width}:${t.height}`;return this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:i,value:s})})}),this.sub("*currentAspectRatio",t=>{var e,i,s;this.$.active=t&&t.id===((e=this._aspectRatio)==null?void 0:e.id)||(t==null?void 0:t.width)===((i=this._aspectRatio)==null?void 0:i.width)&&(t==null?void 0:t.height)===((s=this._aspectRatio)==null?void 0:s.height)}),this.$["on.click"]=this.handleClick.bind(this)}handleClick(){var t,e;((t=this.$["*currentAspectRatio"])==null?void 0:t.id)!==((e=this._aspectRatio)==null?void 0:e.id)&&(this.$["*currentAspectRatio"]=this._aspectRatio)}_renderRectBasedOnAspectRatio(t){var n,a;let{width:e,height:i}=is(t),s=$("rect",{"stroke-linejoin":"round",fill:"none",stroke:"currentColor","stroke-width":1.2,"fill-rule":"evenodd",x:(Pi-e)/2,y:(Pi-i)/2,width:e,height:i}),o=(a=(n=this.ref["icon-el"])==null?void 0:n.ref)==null?void 0:a.svg;o&&(o.innerHTML="",o.appendChild(s))}};var we={FILTER:"filter",COLOR_OPERATION:"color_operation"},z="original",We=class extends b{constructor(){super(...arguments);f(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,i){this._controlType=e==="filter"?we.FILTER:we.COLOR_OPERATION,this._operation=e,this._iconName=e,this._title=e.toUpperCase(),this._filter=i,this._initializeValues(),this.$["*faderEl"].activate({url:this.$["*originalUrl"],operation:this._operation,value:this._filter===z?void 0:this.$.value,filter:this._filter===z?void 0:this._filter,fromViewer:!1})}_initializeValues(){let{range:e,zero:i}=U[this._operation],[s,o]=e;this.$.min=s,this.$.max=o,this.$.zero=i;let n=this.$["*editorTransformations"][this._operation];if(this._controlType===we.FILTER){let a=o;if(n){let{name:l,amount:c}=n;a=l===this._filter?c:o}this.$.value=a,this.$.defaultValue=a}if(this._controlType===we.COLOR_OPERATION){let a=typeof n!="undefined"?n:i;this.$.value=a,this.$.defaultValue=a}}apply(){let e;this._controlType===we.FILTER?this._filter===z?e=null:e={name:this._filter,amount:this.$.value}:e=this.$.value;let i={...this.$["*editorTransformations"],[this._operation]:e};this.$["*editorTransformations"]=i}cancel(){this.$["*faderEl"].deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{this._originalUrl=e}),this.sub("value",e=>{let i=`${this._filter||this._operation} ${e}`;this.$["*operationTooltip"]=i})}};We.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 ve(r){let t=new Image;return{promise:new Promise((s,o)=>{t.src=r,t.onload=s,t.onerror=o}),image:t,cancel:()=>{t.naturalWidth===0&&(t.src=D)}}}function Ee(r){let t=[];for(let o of r){let n=ve(o);t.push(n)}let e=t.map(o=>o.image);return{promise:Promise.allSettled(t.map(o=>o.promise)),images:e,cancel:()=>{t.forEach(o=>{o.cancel()})}}}function ae(r){let t=r.match(/^(\w+)\s+(\d+)$/);return t?{filter:t[1],value:Number(t[2])}:null}var le=class extends R{constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let t=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),e=window.devicePixelRatio,i=Math.ceil(e*t),s=e>=2?"lightest":"normal",o=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==z?{name:this._filter,amount:o}:void 0,V(this._originalUrl,B(Pe,G(n),`quality/${s}`,`scale_crop/${i}x${i}/center`))}async _observerCallback(t,e){var s;if(t[0].isIntersecting){let o=await this.proxyUrl(this._previewSrc()),n=this.ref["preview-el"],{promise:a,cancel:l}=ve(o);this._cancelPreload=l,a.catch(c=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:c})}).finally(()=>{n.style.backgroundImage=`url(${o})`,n.setAttribute("loaded",""),e.unobserve(this)})}else(s=this._cancelPreload)==null||s.call(this)}initCallback(){super.initCallback(),this.$["on.click"]=e=>{this.$.active?this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0):(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*sliderEl"].apply()),this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:ae(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",e=>{this._operation="filter",this._filter=e,this.$.isOriginal=e===z,this.$.icon=this.$.isOriginal?"original":"slider",this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()}))}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let t=this.$["*originalUrl"];this._originalUrl=t,this.$.isOriginal?this.ref["icon-el"].classList.add("uc-original-icon"):this._observer.observe(this),this.sub("*currentFilter",e=>{this.$.active=e&&e===this._filter}),this.sub("isOriginal",e=>{this.$.iconSize=e?40:20}),this.sub("active",e=>{if(this.$.isOriginal)return;let i=this.ref["icon-el"];i.style.opacity=e?"1":"0";let s=this.ref["preview-el"];e?s.style.opacity="0":s.style.backgroundImage&&(s.style.opacity="1")}),this.sub("*networkProblems",async e=>{if(!e){let i=await this.proxyUrl(this._previewSrc()),s=this.ref["preview-el"];s.style.backgroundImage&&(s.style.backgroundImage="none",s.style.backgroundImage=`url(${i})`)}})}destroyCallback(){var t,e;super.destroyCallback(),(t=this._observer)==null||t.disconnect(),(e=this._cancelPreload)==null||e.call(this)}};le.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 Ce=class extends R{constructor(){super(...arguments);f(this,"_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:ae(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:i}=U[this._operation],s=e[this._operation],o=typeof s!="undefined"?s!==i:!1;this.$.active=o})}};var Ri=(r,t)=>{let e,i,s,o=(...n)=>{e?(clearTimeout(i),i=setTimeout(()=>{Date.now()-s>=t&&(r(...n),s=Date.now())},Math.max(t-(Date.now()-s),0))):(r(...n),s=Date.now(),e=!0)};return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{clearTimeout(i)}}),o};function Mi(r,t){let e={};for(let i of t){let s=r[i];(r.hasOwnProperty(i)||s!==void 0)&&(e[i]=s)}return e}function ce(r,t,e){let s=window.devicePixelRatio,o=Math.min(Math.ceil(t*s),3e3),n=s>=2?"lightest":"normal";return V(r,B(Pe,G(e),`quality/${n}`,`stretch/off/-/resize/${o}x`,`@clib/${je}/${Be}/uc-cloud-image-editor/`))}function rs(r){return r?[({dimensions:e,coords:i})=>[...e,...i].every(s=>Number.isInteger(s)&&Number.isFinite(s)),({dimensions:e,coords:i})=>e.every(s=>s>0)&&i.every(s=>s>=0)].every(e=>e(r)):!0}var qe=class extends b{constructor(){super();f(this,"ctxOwner",!0);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=A(this._commit.bind(this),300),this._handleResizeThrottled=Ri(this._handleResize.bind(this),100),this._imageSize={width:0,height:0}}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let e=this.$["*editorTransformations"],i=Mi(e,Object.keys(this.$["*operations"])),s={...this.$["*operations"],...i};this.$["*operations"]=s}_initCanvas(){let e=this.ref["canvas-el"],i=e.getContext("2d"),s=this.offsetWidth,o=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${s}px`,e.style.height=`${o}px`,e.width=s*n,e.height=o*n,i==null||i.scale(n,n),this._canvas=e,this._ctx=i}_alignImage(){if(!this._isActive||!this.$.image)return;let e=this.$.image,i=this.$["*padding"],s=this.$["*operations"],{rotate:o}=s,n={width:this.offsetWidth,height:this.offsetHeight},a=oe({width:e.naturalWidth,height:e.naturalHeight},o),l;if(a.width>n.width-i*2||a.height>n.height-i*2){let c=a.width/a.height,u=n.width/n.height;if(c>u){let h=n.width-i*2,d=h/c,p=0+i,g=i+(n.height-i*2)/2-d/2;l={x:p,y:g,width:h,height:d}}else{let h=n.height-i*2,d=h*c,p=i+(n.width-i*2)/2-d/2,g=0+i;l={x:p,y:g,width:d,height:h}}}else{let{width:c,height:u}=a,h=i+(n.width-i*2)/2-c/2,d=i+(n.height-i*2)/2-u/2;l={x:h,y:d,width:c,height:u}}this.$["*imageBox"]=ne(l)}_alignCrop(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=this.$["*imageBox"];if(n){let{dimensions:[d,p],coords:[g,N]}=n,{width:O}=oe(this._imageSize,o),T=a/O;e=se(ne({x:l+g*T,y:c+N*T,width:d*T,height:p*T}),this.$["*imageBox"])}let u=this.$["*currentAspectRatio"],h=u?u.width/u.height:void 0;if(!Ii(e,i)||h&&!Li(e,h)){let d=i.width/i.height,p=i.width,g=i.height;h&&(d>h?p=Math.min(i.height*h,i.width):g=Math.min(i.width/h,i.height)),e={x:i.x+i.width/2-p/2,y:i.y+i.height/2-g/2,width:p,height:g}}this.$["*cropBox"]=se(ne(e),this.$["*imageBox"])}_drawImage(){let e=this._ctx;if(!e)return;let i=this.$.image,s=this.$["*imageBox"],o=this.$["*operations"],{mirror:n,flip:a,rotate:l}=o,c=oe({width:s.width,height:s.height},l);e.save(),e.translate(s.x+s.width/2,s.y+s.height/2),e.rotate(l*Math.PI*-1/180),e.scale(n?-1:1,a?-1:1),e.drawImage(i,-c.width/2,-c.height/2,c.width,c.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=C({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a}=i,{width:l,height:c}=oe(this._imageSize,o),{width:u,height:h}=e,d=n/l,p=a/c;return[K(Math.round(u/d),1,l),K(Math.round(h/p),1,c)]}_getCropTransformation(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a,x:l,y:c}=i,{width:u,height:h}=oe(this._imageSize,o),{x:d,y:p}=e,g=n/u,N=a/h,O=this._getCropDimensions(),T={dimensions:O,coords:[K(Math.round((d-l)/g),0,u-O[0]),K(Math.round((p-c)/N),0,h-O[1])]};if(!rs(T)){console.error("Cropper is trying to create invalid crop object",{payload:T});return}if(!(O[0]===u&&O[1]===h))return T}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:i,mirror:s,flip:o}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:i,mirror:s,flip:o};this.$["*editorTransformations"]=l}setValue(e,i){this.$["*operations"]={...this.$["*operations"],[e]:i},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:i}={}){if(!this._isActive){this._isActive=!0,this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{this.$.image=await this._waitForImage(this.$["*originalUrl"],this.$["*editorTransformations"]),this._syncTransformations(),this._animateIn({fromViewer:i})}catch(s){console.error("Failed to activate cropper",{error:s}),this.telemetryManager.sendEventError(s,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(([s])=>{s.contentRect.width>0&&s.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){var i;this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=C({"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}),(i=this._observer)==null||i.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),i=Math.min(this.offsetWidth,e[0])/this.$["*cropBox"].width,s=Math.min(this.offsetHeight,e[1])/this.$["*cropBox"].height,o=Math.min(i,s),n=this.$["*cropBox"].x+this.$["*cropBox"].width/2,a=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform=`scale(${o}) translate(${(this.offsetWidth/2-n)/o}px, ${(this.offsetHeight/2-a)/o}px)`,this.style.transformOrigin=`${n}px ${a}px`}_transitionToImage(){let e=this.$["*cropBox"].x+this.$["*cropBox"].width/2,i=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${e}px ${i}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(e,i){var u;let s=this.offsetWidth;i={...i,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(ce(e,s,i)),{promise:n,cancel:a,image:l}=ve(o),c=this._handleImageLoading(o);return l.addEventListener("load",c,{once:!0}),l.addEventListener("error",c,{once:!0}),(u=this._cancelPreload)==null||u.call(this),this._cancelPreload=a,n.then(()=>l).catch(h=>(console.error("Failed to load image",{error:h}),this.$["*networkProblems"]=!0,Promise.resolve(l)))}_handleImageLoading(e){let i="crop",s=this.$["*loadingOperations"];return s.get(i)||s.set(i,new Map),s.get(i).get(e)||(s.set(i,s.get(i).set(e,!0)),this.$["*loadingOperations"]=s),()=>{var o;(o=s==null?void 0:s.get(i))!=null&&o.has(e)&&(s.get(i).delete(e),this.$["*loadingOperations"]=s)}}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(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};qe.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Ct(r,t,e){let i=Array(e);e--;for(let s=e;s>=0;s--)i[s]=Math.ceil((s*t+(e-s)*r)/e);return i}function ss(r){return r.reduce((t,e,i)=>i<r.length-1?[...t,[e,r[i+1]]]:t,[])}function os(r,t,e){let i=ss(r).find(([s,o])=>s<=t&&t<=o);return r.map(s=>{let o=Math.abs(i[0]-i[1]),n=Math.abs(t-i[0])/o;return i[0]===s?t>e?1:1-n:i[1]===s?t>=e?n:1:0})}function ns(r,t){return r.map((e,i)=>e<t?r.length-i:i)}function Ni(r,t){let e=U[r].keypointsNumber,{range:i,zero:s}=U[r];return[...new Set([...Ct(i[0],s,e+1),...Ct(s,i[1],e+1),s,t])].sort((o,n)=>o-n)}var Tt=class extends b{constructor(){super(),this._isActive=!1,this._hidden=!0,this._addKeypointDebounced=A(this._addKeypoint.bind(this),600),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(t){let e=this._operation,i=this.$["*loadingOperations"];return i.get(e)||i.set(e,new Map),i.get(e).get(t)||(i.set(e,i.get(e).set(t,!0)),this.$["*loadingOperations"]=i),()=>{var s;(s=i==null?void 0:i.get(e))!=null&&s.has(t)&&(i.get(e).delete(t),this.$["*loadingOperations"]=i)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let t of this._keypoints){let{image:e}=t;e&&(e.style.opacity=t.opacity.toString(),e.style.zIndex=t.zIndex.toString())}})}async _imageSrc({url:t=this._url,filter:e=this._filter,operation:i,value:s}={}){let o={...this._transformations};i&&(o[i]=e?{name:e,amount:s}:s);let n=this.offsetWidth;return await this.proxyUrl(ce(t,n,o))}async _constructKeypoint(t,e){return{src:await this._imageSrc({operation:t,value:e}),image:null,opacity:0,zIndex:0,value:e}}_isSame(t,e){return this._operation===t&&this._filter===e}async _addKeypoint(t,e,i){let s=()=>!this._isSame(t,e)||this._value!==i||!!this._keypoints.find(l=>l.value===i);if(s())return;let o=await this._constructKeypoint(t,i),n=new Image;n.src=o.src;let a=this._handleImageLoading(o.src);n.addEventListener("load",a,{once:!0}),n.addEventListener("error",a,{once:!0}),o.image=n,n.classList.add("uc-fader-image"),n.addEventListener("load",()=>{if(s())return;let l=this._keypoints,c=l.findIndex(h=>h.value>i),u=c<l.length?l[c].image:null;!this._container||u&&!this._container.contains(u)||(l.splice(c,0,o),this._container.insertBefore(n,u),this._update(t,i))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(t){t=typeof t=="string"?parseInt(t,10):t,this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t)}_update(t,e){this._operation=t,this._value=e;let{zero:i}=U[t],s=this._keypoints.map(a=>a.value),o=os(s,e,i),n=ns(s,i);for(let[a,l]of Object.entries(this._keypoints))l.opacity=o[a],l.zIndex=n[a];this._flush()}_createPreviewImage(){let t=new Image;return t.classList.add("uc-fader-image","uc-fader-image--preview"),t.style.opacity="0",t}async _initNodes(){let t=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage(),!this.contains(this._previewImage)&&t.appendChild(this._previewImage);let e=document.createElement("div");t.appendChild(e);let i=this._keypoints.map(c=>c.src),{images:s,promise:o,cancel:n}=Ee(i);s.forEach(c=>{let u=this._handleImageLoading(c.src);c.addEventListener("load",u),c.addEventListener("error",u)}),this._cancelLastImages=()=>{n(),this._cancelLastImages=void 0};let a=this._operation,l=this._filter;await o,this._isActive&&this._isSame(a,l)&&(this._container&&this._container.remove(),this._container=e,this._keypoints.forEach((c,u)=>{let h=s[u];h.classList.add("uc-fader-image"),c.image=h,this._container.appendChild(h)}),this.appendChild(t),this._flush())}async setTransformations(t){if(this._transformations=t,this._previewImage){let e=await this._imageSrc(),i=this._handleImageLoading(e);this._previewImage.src=e,this._previewImage.addEventListener("load",i,{once:!0}),this._previewImage.addEventListener("error",i,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:t,filter:e,operation:i,value:s}){this._cancelBatchPreload&&this._cancelBatchPreload();let o=Ni(i,s),n=await Promise.all(o.map(l=>this._imageSrc({url:t,filter:e,operation:i,value:l}))),{cancel:a}=Ee(n);this._cancelBatchPreload=a}_setOriginalSrc(t){let e=this._previewImage||this._createPreviewImage();if(!this.contains(e)&&this.appendChild(e),this._previewImage=e,e.src===t){e.style.opacity="1",e.style.transform="scale(1)",this.className=C({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}e.style.opacity="0";let i=this._handleImageLoading(t);e.addEventListener("error",i,{once:!0}),e.src=t,e.addEventListener("load",()=>{i(),e&&(e.style.opacity="1",e.style.transform="scale(1)",this.className=C({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),e.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:t,operation:e,value:i,filter:s,fromViewer:o}){if(this._isActive=!0,this._hidden=!1,this._url=t,this._operation=e||"initial",this._value=i,this._filter=s,this._fromViewer=o,typeof i!="number"&&!s){let a=await this._imageSrc({operation:e,value:i});this._setOriginalSrc(a),this._container&&this._container.remove();return}this._keypoints=await Promise.all(Ni(e,i).map(a=>this._constructKeypoint(e,a))),this._update(e,i),this._initNodes()}deactivate({hide:t=!0}={}){this._isActive=!1,this._cancelLastImages&&this._cancelLastImages(),this._cancelBatchPreload&&this._cancelBatchPreload(),t&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=C({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._container&&this._container.remove()},{once:!0})):this._container&&this._container.remove()}};var as=1,Ke=class extends b{initCallback(){super.initCallback(),this.addEventListener("wheel",t=>{t.preventDefault();let{deltaY:e,deltaX:i}=t;Math.abs(i)>as?this.scrollLeft+=i:this.scrollLeft+=e},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};Ke.template=" <slot></slot> ";function ls(r){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${r}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${r}" data-id="${r}" icon="${r}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${r}; title-prop: a11y-editor-tab-${r}" ></uc-btn-ui></uc-presence-toggle>`}function cs(r){return`<uc-presence-toggle id="tab_${r}" class="uc-tab-content" set="visible: presence.tabContent.${r}; 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-${r}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var Ye=class extends b{constructor(){super();f(this,"_updateInfoTooltip",A(()=>{var n,a;let e=this.$["*editorTransformations"],i=this.$["*currentOperation"],s="",o=!1;if(this.$["*tabId"]===y.FILTERS)if(o=!0,this.$["*currentFilter"]&&((n=e==null?void 0:e.filter)==null?void 0:n.name)===this.$["*currentFilter"]){let l=((a=e==null?void 0:e.filter)==null?void 0:a.amount)||100;s=this.$["*currentFilter"]+" "+l}else s=this.l10n(z);else if(this.$["*tabId"]===y.TUNING&&i){o=!0;let l=(e==null?void 0:e[i])||U[i].zero;s=this.l10n(i)+" "+l}o&&(this.$["*operationTooltip"]=s),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)},0));this.init$={...this.init$,"*sliderEl":null,"*listAspectRatioEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*showListAspectRatio":!1,hideSliderOrList:!1,"*currentFilter":z,"*currentOperation":null,showLoader:!1,filters:Kt,colorOperations:qt,cropOperations:Yt,"*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=>{var i;this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),(i=this._cancelPreload)==null||i.call(this),this.$["*on.cancel"]()},"on.apply":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"}),this.$["*on.apply"](this.$["*editorTransformations"])},"on.applySlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:ae(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 i=e.currentTarget.getAttribute("data-id");i&&(this.telemetryManager.sendEventCloudImageEditor(e,i),this._activateTab(i,{fromViewer:!1}))},tab_role:"tab",[`tab_${y.TUNING}`]:`tab_${y.TUNING}`,[`tab_${y.CROP}`]:`tab_${y.CROP}`,[`tab_${y.FILTERS}`]:`tab_${y.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=A(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===y.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===y.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let i=new Ce;return i.operation=e,i}_createFilterControl(e){let i=new le;return i.filter=e,i}_createToggleControl(e){let i=new ge;return i.operation=e,i}_createAspectRatioConrol(e){let i=new ye;return i.aspectRatio=e,i}_createFreeformConrol(){return new be}_clearListAspectRatio(){this.$["*listAspectRatioEl"].innerHTML=""}_renderControlsList(e){let i=this.ref[`controls-list-${e}`],s=document.createDocumentFragment();if(this._clearListAspectRatio(),e===y.CROP){let o=this.$["*cropPresetList"].length>=3;if(o){let n=this._createFreeformConrol();s.appendChild(n)}this.$["*cropPresetList"].forEach(n=>{let a=this._createAspectRatioConrol(n);s.appendChild(a),o&&this.$["*listAspectRatioEl"].appendChild(a)}),this.$.cropOperations.forEach(n=>{let a=this._createToggleControl(n);s.appendChild(a)})}else e===y.FILTERS?[z,...this.$.filters].forEach(o=>{let n=this._createFilterControl(o);s.appendChild(n)}):e===y.TUNING&&this.$.colorOperations.forEach(o=>{let n=this._createOperationControl(o);s.appendChild(n)});[...s.children].forEach((o,n)=>{n===s.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),i.innerHTML="",i.appendChild(s)}_activateTab(e,{fromViewer:i}){this.$["*tabId"]=e,e===y.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:i})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:i}),this.$["*cropperEl"].deactivate());for(let s of k){let o=s===e,n=this.ref[`tab-toggle-${s}`];n.active=o,o?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(s),this.$[`presence.tabContent.${s}`]=o}}_unmountTabControls(e){let i=this.ref[`controls-list-${e}`];i&&(i.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],i=this.ref["tabs-indicator"];i.style.transform=`translateX(${e.offsetLeft}px)`}async _preloadEditedImage(){var e;if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let i=this.$["*imgContainerEl"].offsetWidth,s=await this.proxyUrl(ce(this.$["*originalUrl"],i,this.$["*editorTransformations"]));(e=this._cancelPreload)==null||e.call(this);let{cancel:o}=Ee([s]);this._cancelPreload=()=>{o(),this._cancelPreload=void 0}}}_showLoader(e){this.$.showLoader=e}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=>{var s;let i=(s=e==null?void 0:e.filter)==null?void 0:s.name;this.$["*currentFilter"]!==i&&(this.$["*currentFilter"]=i)}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",()=>{this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]&&this.$["*faderEl"].deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]&&this.$["*faderEl"].setTransformations(e)}),this.sub("*loadingOperations",e=>{let i=!1;for(let[,s]of e.entries()){if(i)break;for(let[,o]of s.entries())if(o){i=!0;break}}this._debouncedShowLoader(i)}),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 i of k){this.$[`presence.tabToggle.${i}`]=e.includes(i);let s=this.ref[`tab-toggle-${i}`];s.style.gridColumn=e.indexOf(i)+1}e.includes(this.$["*tabId"])||this._activateTab(e[0],{fromViewer:!1})}),this._updateInfoTooltip()}destroyCallback(){this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}};Ye.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">${k.map(cs).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> ${k.map(ls).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 Te=class extends b{constructor(){super(),this._iconReversed=!1,this._iconSingle=!1,this._iconHidden=!1,this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null,"aria-role":"","aria-controls":"","title-prop":""},this.defineAccessor("active",t=>{t?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return C("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",t=>{this._iconSingle=!this.$.text,this._iconHidden=!t,this.$.iconCss=this._iconCss()}),this.sub("theme",t=>{t!=="custom"&&(this.className=`uc-${t}`)}),this.sub("text",t=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",t=>{this.$["aria-role"]=t||""}),this.defineAccessor("aria-controls",t=>{this.$["aria-controls"]=t||""}),this.defineAccessor("title-prop",t=>{this.$["title-prop"]=t||""})}set reverse(t){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection=null)}};Te.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});Te.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 Ze=class extends b{constructor(){super(),this._active=!1,this._handleTransitionEndRight=()=>{let t=this.ref["line-el"];t.style.transition="initial",t.style.opacity="0",t.style.transform="translateX(-101%)",this._active&&this._start()}}initCallback(){super.initCallback(),this.defineAccessor("active",t=>{typeof t=="boolean"&&(t?this._start():this._stop())})}_start(){this._active=!0;let{width:t}=this.getBoundingClientRect(),e=this.ref["line-el"];e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};Ze.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var Je={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},Qe=class extends b{constructor(){super(),this._visible=!1,this._visibleStyle=Je.visible,this._hiddenStyle=Je.hidden,this._externalTransitions=!1,this.defineAccessor("styles",t=>{t&&(this._externalTransitions=!0,this._visibleStyle=t.visible,this._hiddenStyle=t.hidden)}),this.defineAccessor("visible",t=>{typeof t=="boolean"&&(this._visible=t,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",gi(this,{[Je.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(Je.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};Qe.template="<slot></slot> ";var et=class extends b{constructor(){super();f(this,"init$",{...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:null,"on.sliderInput":()=>{let e=parseInt(this.ref["input-el"].value,10);this._updateValue(e),this.$.onInput&&this.$.onInput(e)},"on.sliderChange":()=>{let e=parseInt(this.ref["input-el"].value,10);this.$.onChange&&this.$.onChange(e)}});this.setAttribute("with-effects","")}initCallback(){super.initCallback(),this.defineAccessor("disabled",i=>{this.$.disabled=i}),this.defineAccessor("min",i=>{this.$.min=i}),this.defineAccessor("max",i=>{this.$.max=i}),this.defineAccessor("defaultValue",i=>{this.$.defaultValue=i,this.ref["input-el"].value=i,this._updateValue(i)}),this.defineAccessor("zero",i=>{this._zero=i}),this.defineAccessor("onInput",i=>{i&&(this.$.onInput=i)}),this.defineAccessor("onChange",i=>{i&&(this.$.onChange=i)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)}),this._observer.observe(this),this._thumbSize=parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)},0),this.sub("disabled",i=>{let s=this.ref["input-el"];i?s.setAttribute("disabled","disabled"):s.removeAttribute("disabled")});let e=this.ref["input-el"];e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_updateValue(e){this._updateZeroDot(e);let{width:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(e-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this.ref["thumb-el"].style.transform=`translateX(${n}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;e===this._zero?this._zeroDotEl.style.opacity="0":this._zeroDotEl.style.opacity="1";let{width:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl.style.transform=`translateX(${n}px)`})}_updateSteps(){let i=this.ref["steps-el"],{width:s}=i.getBoundingClientRect(),o=Math.ceil(s/2),n=Math.ceil(o/15)-2;if(this._stepsCount===n)return;let a=document.createDocumentFragment(),l=document.createElement("div"),c=document.createElement("div");l.className="uc-minor-step",c.className="uc-border-step",a.appendChild(c);for(let h=0;h<n;h++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let h=0;h<n;h++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let u=document.createElement("div");u.className="uc-zero-dot",a.appendChild(u),this._zeroDotEl=u,i.innerHTML="",i.appendChild(a),this._stepsCount=n}destroyCallback(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};et.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 xe=class xe extends W{constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){var t;super.initCallback(),this.emit(dt.INIT_SOLUTION,void 0),(t=this.a11y)==null||t.registerBlock(this)}};f(xe,"styleAttrs",[...Mt(xe,xe,"styleAttrs"),"uc-wgt-common"]);var Ui=xe;var Ae=class extends b{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",t=>{if(!t)return;let e=`#uc-icon-${t}`;this.subConfigValue("iconHrefResolver",i=>{if(i){let s=i(t);e=s!=null?s:e}this.$.href=e})}),this.setAttribute("aria-hidden","true")}};Ae.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;Ae.bindAttributes({name:"name"});function hs(r){for(let t in r){let e=[...t].reduce((i,s)=>(s.toUpperCase()===s&&(s="-"+s.toLowerCase()),i+=s),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e="uc-"+e),r[t].reg&&r[t].reg(e)}}var tt=r=>{var t;return(t=r.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:t.map(e=>e.toLowerCase()).join("-")};var xt=Object.freeze({PHOTO:"photo",VIDEO:"video"}),Xl=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var w=r=>String(r),I=r=>{let t=Number(r);if(Number.isNaN(t))throw new Error(`Invalid number: "${r}"`);return t},v=r=>{if(typeof r=="undefined"||r===null)return!1;if(typeof r=="boolean")return r;if(r==="true"||r==="")return!0;if(r==="false")return!1;throw new Error(`Invalid boolean: "${r}"`)},Di=r=>r==="auto"?r:v(r),Fi=r=>{let t=w(r);if(t!=="user"&&t!=="environment"&&t!=="")throw new Error(`Invalid value: "${t}"`);return t},zi=r=>{let t=w(r);if(!Object.values(xt).includes(t))throw new Error(`Invalid value: "${t}"`);return t},ji=r=>{let t=w(r),e=Y(t);if(e.some(i=>!Object.values(xt).includes(i)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return t},Bi=r=>{if(typeof r=="object"&&!Array.isArray(r)||typeof r=="function")return r;throw new Error("Invalid metadata value. Must be an object or function.")},At=r=>{if(typeof r=="object")return r;throw new Error("Invalid value. Must be an object.")},it=r=>{if(typeof r=="function")return r;throw new Error("Invalid value. Must be a function.")},St=r=>{if(Array.isArray(r))return r;throw new Error("Must be an array.")},Vi=r=>{let t=w(r);if(["grid","list"].includes(t))return t;throw new Error(`Invalid value: "${t}"`)};var us={pubkey:w,multiple:v,multipleMin:I,multipleMax:I,confirmUpload:v,imgOnly:v,accept:w,externalSourcesPreferredTypes:w,externalSourcesEmbedCss:w,store:Di,cameraMirror:v,cameraCapture:Fi,sourceList:w,topLevelOrigin:w,maxLocalFileSizeBytes:I,thumbSize:I,showEmptyList:v,useLocalImageEditor:v,useCloudImageEditor:v,cloudImageEditorTabs:w,removeCopyright:v,cropPreset:w,imageShrink:w,modalScrollLock:v,modalBackdropStrokes:v,sourceListWrap:v,remoteTabSessionKey:w,cdnCname:w,cdnCnamePrefixed:w,baseUrl:w,socialBaseUrl:w,secureSignature:w,secureExpire:w,secureDeliveryProxy:w,retryThrottledRequestMaxTimes:I,retryNetworkErrorMaxTimes:I,multipartMinFileSize:I,multipartChunkSize:I,maxConcurrentRequests:I,multipartMaxConcurrentRequests:I,multipartMaxAttempts:I,checkForUrlDuplicates:v,saveUrlForRecurrentUploads:v,groupOutput:v,userAgentIntegration:w,debug:v,localeName:w,metadata:Bi,secureUploadsExpireThreshold:I,localeDefinitionOverride:At,secureUploadsSignatureResolver:it,secureDeliveryProxyUrlResolver:it,iconHrefResolver:it,fileValidators:St,collectionValidators:St,cameraModes:ji,defaultCameraMode:zi,enableAudioRecording:v,enableVideoRecording:v,mediaRecorderOptions:At,maxVideoRecordingDuration:I,filesViewMode:Vi,gridShowFileNames:v,cloudImageEditorAutoOpen:v,cloudImageEditorMaskHref:w,testMode:v,qualityInsights:v},Hi=(r,t)=>{if(!(typeof t=="undefined"||t===null))try{return us[r](t)}catch(e){return console.error(`Invalid value for config key "${r}".`,e),P[r]}};var Xi=new Set;function Gi(r){Xi.has(r)||(Xi.add(r),console.warn(r))}var ds=[{test:r=>r.accept&&!!r.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:r=>r.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:r=>r.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],Wi=A(r=>{for(let{test:t,message:e}of ds)t(r)&&Gi(e)},0);var qi=(r,t)=>{let e=new URL(t);return e.hostname=`${r}.${e.hostname}`,e.toString().replace(/\/$/,"")},fs="0123456789abcdefghijklmnopqrstuvwxyz",Ki=r=>{if(r<=BigInt(0))return"0";let t="";for(;r>BigInt(0);){let e=r%BigInt(36);t=fs[Number(e)]+t,r=r/BigInt(36)}return t},$t=(r,t)=>{try{let e=new URL(r),i=new URL(t);return e.hostname.endsWith(i.hostname)}catch{return!1}};var ps=async r=>{let t=new TextEncoder().encode(r),e=await window.crypto.subtle.digest("SHA-256",t),i=Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join("");return BigInt(`0x${i}`)},ms=10,_s=async r=>{let t=await ps(r);return Ki(t).slice(0,ms)},Yi=async(r,t)=>{let e=await _s(r);return qi(e,t)};var Zi=r=>r instanceof Promise||!!(r&&typeof r=="object"&&"then"in r&&typeof r.then=="function");var gs=[{key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:r,enableVideoRecording:t})=>{if(t===null)return r;let e=Y(r);return t&&!e.includes("video")?e=e.concat("video"):t||(e=e.filter(i=>i!=="video")),Z(e)}},{key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:r,defaultCameraMode:t})=>{if(t===null)return r;let e=Y(r);return e=e.sort((i,s)=>i===t?-1:s===t?1:0),Z(e)}},{key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:r,cdnCname:t,cdnCnamePrefixed:e})=>r&&(t===ut||$t(t,e))?Yi(r,e):t}],Ot=({key:r,setValue:t,getValue:e})=>{for(let i of gs)if(i.deps.includes(r)){let s={[i.key]:e(i.key),...i.deps.reduce((n,a)=>({...n,[a]:e(a)}),{})},o=i.fn(s);if(Zi(o)){let n=e(i.key);o.then(a=>{e(i.key)===n&&t(i.key,a)}).catch(a=>{console.error(`Failed to compute value for "${i.key}"`,a)})}else t(i.key,o)}};var kt=[...new Set(["debug",...Object.keys(P)])],bs=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],ys=r=>bs.includes(r),he=kt.filter(r=>!ys(r)),ws={...Object.fromEntries(he.map(r=>[tt(r),r])),...Object.fromEntries(he.map(r=>[r.toLowerCase(),r]))},vs={...Object.fromEntries(he.map(r=>[tt(r),S(r)])),...Object.fromEntries(he.map(r=>[r.toLowerCase(),S(r)]))},Ji=r=>"__"+r,Se=class extends b{constructor(){super();f(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(P).map(([e,i])=>[S(e),i]))}}_flushValueToAttribute(e,i){if(he.includes(e)){let s=[...new Set([tt(e),e.toLowerCase()])];for(let o of s)typeof i=="undefined"||i===null?this.removeAttribute(o):this.getAttribute(o)!==i.toString()&&this.setAttribute(o,i.toString())}}_flushValueToState(e,i){this.$[S(e)]!==i&&(typeof i=="undefined"||i===null?this.$[S(e)]=P[e]:this.$[S(e)]=i)}_setValue(e,i){let s=this,o=Hi(e,i),n=Ji(e);s[n]!==o&&(this._assertSameValueDifferentReference(e,s[n],o),s[n]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),Wi(this.cfg),Ot({key:e,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this)}))}_getValue(e){var o;let i=this,s=Ji(e);return(o=i[s])!=null?o:this.$[S(e)]}_assertSameValueDifferentReference(e,i,s){this.cfg.debug&&s!==i&&typeof s=="object"&&typeof i=="object"&&JSON.stringify(s)===JSON.stringify(i)&&(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:`,i),console.warn(`[uc-config] "${e}" new value:`,s))}initCallback(){var i;super.initCallback();let e=this;for(let s of he)this.sub(S(s),o=>{this._setValue(s,o)},!1);for(let s of kt){let o=(i=e[s])!=null?i:this.$[S(s)];o!==P[s]&&this._setValue(s,o),Object.defineProperty(this,s,{set:n=>{this._setValue(s,n)},get:()=>this._getValue(s)}),Ot({key:s,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this)})}}attributeChangedCallback(e,i,s){if(i===s)return;let o=this,n=ws[e];o[n]=s}};Se.bindAttributes(vs);for(let r of kt)Se.prototype[r]=void 0;var Es=Se;export{Te as BtnUi,Ui as CloudImageEditor,W as CloudImageEditorBlock,Es as Config,Xe as CropFrame,ye as EditorAspectRatioButtonControl,ge as EditorCropButtonControl,le as EditorFilterControl,be as EditorFreeformButtonControl,qe as EditorImageCropper,Tt as EditorImageFader,Ce as EditorOperationControl,Ke as EditorScroller,We as EditorSlider,Ye as EditorToolbar,Ae as Icon,Ze as LineLoaderUi,Qe as PresenceToggle,et as SliderUi,hs as defineComponents};
|
|
28
|
+
`));return}window.customElements.define(r,t?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(r){this.observedAttributes=Object.keys(r),this.__attrDesc=r}attributeChangedCallback(r,t,e){var i;if(t===e)return;let s=(i=this.constructor.__attrDesc)==null?void 0:i[r];s?this.__dataCtxInitialized?this.$[s]=e:this.init$[s]=e:this[r]=e}getCssData(r,t=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(r)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(r).trim();try{this.__cssDataCache[r]=vr(e)}catch{!t&&console.warn(`CSS Data error: ${r}`),this.__cssDataCache[r]=null}}return this.__cssDataCache[r]}__extractCssName(r){return r.split("--").map((t,e)=>e===0?"":t).join("--")}__initStyleAttrObserver(){j||(j=new Set),j.add(this.updateCssData),ee||(ee=new MutationObserver(r=>{r[0].type==="attributes"&&j.forEach(t=>{t()})}),ee.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(r,t=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(r);let e=this.getCssData(this.__extractCssName(r),!0);e===null&&(e=t),this.add(r,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(r,t,e){let i="__"+r;this[i]=this[r],Object.defineProperty(this,r,{set:s=>{this[i]=s,e?window.setTimeout(()=>{t==null||t(s)}):t==null||t(s)},get:()=>this[i]}),this[r]=this[i]}static set shadowStyles(r){let t=new Blob([r],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(t)}static set rootStyles(r){if(!this.__rootStylesLink){let t=new Blob([r],{type:"text/css"}),e=URL.createObjectURL(t),i=document.createElement("link");i.href=e,i.rel="stylesheet",this.__rootStylesLink=i}}},nt=X;st(nt,"template");var rt=class{static _print(r){console.warn(r)}static setDefaultTitle(r){this.defaultTitle=r}static setRoutingMap(r){Object.assign(this.appMap,r);for(let t in this.appMap)!this.defaultRoute&&this.appMap[t].default===!0?this.defaultRoute=t:!this.errorRoute&&this.appMap[t].error===!0&&(this.errorRoute=t)}static set routingEventName(r){this.__routingEventName=r}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let r={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))r.route=e.replace("?","");else if(e.includes("=")){let i=e.split("=");r.options[i[0]]=decodeURI(i[1])}else r.options[e]=!0}),r}static notify(){let r=this.readAddressBar(),t=this.appMap[r.route];if(t&&t.title&&(document.title=t.title),r.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!t&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t){this._print(`Route "${r.route}" not found...`);return}let e=new CustomEvent(rt.routingEventName,{detail:{route:r.route,options:Object.assign(t||{},r.options)}});window.dispatchEvent(e)}static reflect(r,t={}){let e=this.appMap[r];if(!e){this._print("Wrong route: "+r);return}let i="?"+r;for(let o in t)t[o]===!0?i+=this.separator+o:i+=this.separator+o+`=${t[o]}`;let s=e.title||this.defaultTitle||"";window.history.pushState(null,s,i),document.title=s}static applyRoute(r,t={}){this.reflect(r,t),this.notify()}static setSeparator(r){this._separator=r}static get separator(){return this._separator||"&"}static createRouterData(r,t){this.setRoutingMap(t);let e=E.registerCtx({route:null,options:null,title:null},r);return window.addEventListener(this.routingEventName,i=>{var s;e.multiPub({route:i.detail.route,options:i.detail.options,title:((s=i.detail.options)==null?void 0:s.title)||this.defaultTitle||""})}),rt.notify(),this.initPopstateListener(),e}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};rt.appMap=Object.create(null);var zt="idb-store-ready",Er="symbiote-db",Cr="symbiote-idb-update_",Tr=class{_notifyWhenReady(r=null){window.dispatchEvent(new CustomEvent(zt,{detail:{dbName:this.name,storeName:this.storeName,event:r}}))}get _updEventName(){return Cr+this.name}_getUpdateEvent(r){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:r}})}_notifySubscribers(r){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,r),window.dispatchEvent(this._getUpdateEvent(r))}constructor(r,t){this.name=r,this.storeName=t,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=e=>{this.db=e.target.result,this.objStore=this.db.createObjectStore(t,{keyPath:"_key"}),this.objStore.transaction.oncomplete=i=>{this._notifyWhenReady(i)}},this.request.onsuccess=e=>{this.db=e.target.result,this._notifyWhenReady(e)},this.request.onerror=e=>{console.error(e)},this._subscriptionsMap={},this._updateHandler=e=>{e.key===this.name&&this._subscriptionsMap[e.newValue]&&this._subscriptionsMap[e.newValue].forEach(async s=>{s(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(r){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(r);return new Promise((i,s)=>{e.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?i(o.target.result._value):(i(null),console.warn(`IDB: cannot read "${r}"`))},e.onerror=o=>{s(o)}})}write(r,t,e=!1){let i={_key:r,_value:t},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(i);return new Promise((n,a)=>{o.onsuccess=l=>{e||this._notifySubscribers(r),n(l.target.result)},o.onerror=l=>{a(l)}})}delete(r,t=!1){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(r);return new Promise((s,o)=>{i.onsuccess=n=>{t||this._notifySubscribers(r),s(n)},i.onerror=n=>{o(n)}})}getAll(){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,i)=>{t.onsuccess=s=>{let o=s.target.result;e(o.map(n=>n._value))},t.onerror=s=>{i(s)}})}subscribe(r,t){this._subscriptionsMap[r]||(this._subscriptionsMap[r]=new Set);let e=this._subscriptionsMap[r];return e.add(t),{remove:()=>{e.delete(t),e.size||delete this._subscriptionsMap[r]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,jt.clear(this.name)}},jt=class{static get readyEventName(){return zt}static open(r=Er,t="store"){let e=r+"/"+t;return this._reg[e]||(this._reg[e]=new Tr(r,t)),this._reg[e]}static clear(r){window.indexedDB.deleteDatabase(r);for(let t in this._reg)t.split("/")[0]===r&&delete this._reg[t]}};st(jt,"_reg",Object.create(null));var Bt=r=>{if(typeof r!="string"||!r)return"";let t=r.trim();return t.startsWith("-/")?t=t.slice(2):t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,t.length-1)),t},ke=(...r)=>r.filter(t=>typeof t=="string"&&t).map(t=>Bt(t)).join("/-/"),B=(...r)=>{let t=ke(...r);return t?`-/${t}/`:""};function Ie(r){let t=new URL(r),e=t.pathname+t.search+t.hash,i=e.lastIndexOf("http"),s=e.lastIndexOf("/"),o="";return i>=0?o=e.slice(i):s>=0&&(o=e.slice(s+1)),o}function Le(r){let t=new URL(r),{pathname:e}=t,i=e.indexOf("/"),s=e.indexOf("/",i+1);return e.substring(i+1,s)}function at(r){let t=Vt(r),e=new URL(t),i=e.pathname.indexOf("/-/");return i===-1?"":e.pathname.substring(i).slice(1)}function lt(r){return at(r).split("/-/").filter(Boolean).map(e=>Bt(e))}function Vt(r){let t=new URL(r),e=Ie(r),i=Ht(e)?Xt(e).pathname:e;return t.pathname=t.pathname.replace(i,""),t.search="",t.hash="",t.toString()}function Ht(r){return r.startsWith("http")}function Xt(r){let t=new URL(r);return{pathname:t.origin+t.pathname||"",search:t.search||"",hash:t.hash||""}}var V=(r,t,e)=>{let i=new URL(Vt(r));if(e=e||Ie(r),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),Ht(e)){let s=Xt(e);i.pathname=i.pathname+(t||"")+(s.pathname||""),i.search=s.search,i.hash=s.hash}else i.pathname=i.pathname+(t||"")+(e||"");return i.toString()},ct=(r,t)=>{let e=new URL(r);return e.pathname=t+"/",e.toString()};var fe=(r,t=",")=>r.trim().split(t).map(e=>e.trim()).filter(e=>e.length>0);var L=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}),Wt=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function xr(r,t){if(typeof t=="number"){let e=t;return L[r]!==e?`${r}/${e}`:""}if(typeof t=="boolean"){let e=t;return L[r]!==e?`${r}`:""}if(r==="filter"&&t){let{name:e,amount:i}=t;return L.filter===i?"":`${r}/${e}/${i}`}if(r==="crop"&&t){let{dimensions:e,coords:i}=t;return`${r}/${e.join("x")}/${i.join(",")}`}return""}function G(r){return ke(...Wt.filter(t=>typeof r[t]!="undefined"&&r[t]!==null).map(t=>{let e=r[t];return xr(t,e)}).filter(t=>!!t))}var Pe=ke("format/auto","progressive/yes"),H=([r])=>typeof r!="undefined"?Number(r):void 0,Gt=()=>!0,Ar=([r,t])=>({name:r,amount:typeof t!="undefined"?Number(t):100}),Sr=([r,t])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(t))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:fe(r,"x").map(Number),coords:fe(t).map(Number)}},$r=Object.freeze({enhance:H,brightness:H,exposure:H,gamma:H,contrast:H,saturation:H,vibrance:H,warmth:H,filter:Ar,mirror:Gt,flip:Gt,rotate:H,crop:Sr});function ht(r){let t={};for(let e of r){let[i,...s]=e.split("/");if(!Wt.includes(i))continue;let o=i,n=$r[o];try{let a=n(s);t[o]=a}catch(a){console.warn([`Failed to parse URL operation "${e}". 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 t}var y=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),k=[y.CROP,y.TUNING,y.FILTERS],qt=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],Kt=["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"],Yt=["rotate","mirror","flip"],U=Object.freeze({brightness:{zero:L.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:L.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:L.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:L.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:L.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:L.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:L.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:L.enhance,range:[0,100],keypointsNumber:1},filter:{zero:L.filter,range:[0,100],keypointsNumber:1}});var Y=r=>r?r.split(",").map(t=>t.trim()).filter(Boolean):[],Z=r=>r?r.join(","):"";var ut="https://ucarecdn.com",Or="https://upload.uploadcare.com",kr="https://social.uploadcare.com",Ir="https://ucarecd.net",P=Object.freeze({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:Z(k),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:ut,cdnCnamePrefixed:Ir,baseUrl:Or,socialBaseUrl:kr,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:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0});var dt=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config"}),x=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created",...dt}),Re=class{constructor(t){f(this,"_timeoutStore",new Map);f(this,"_targets",new Set);f(this,"_debugPrint",null);this._debugPrint=t}bindTarget(t){this._targets.add(t)}unbindTarget(t){this._targets.delete(t)}_dispatch(t,e){var i;for(let s of this._targets)s.dispatchEvent(new CustomEvent(t,{detail:e}));(i=this._debugPrint)==null||i.call(this,()=>{let s=e&&typeof e=="object"?{...e}:e;return[`event "${t}"`,s]})}emit(t,e,{debounce:i}={}){if(typeof i!="number"&&!i){this._dispatch(t,typeof e=="function"?e():e);return}this._timeoutStore.has(t)&&window.clearTimeout(this._timeoutStore.get(t));let s=typeof i=="number"?i:20,o=window.setTimeout(()=>{this._dispatch(t,typeof e=="function"?e():e),this._timeoutStore.delete(t)},s);this._timeoutStore.set(t,o)}};function A(r,t){let e,i=(...s)=>{clearTimeout(e),e=setTimeout(()=>r(...s),t)};return i.cancel=()=>{clearTimeout(e)},i}var Zt="--uploadcare-blocks-window-height",J=class{static registerClient(t){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(t)}static unregisterClient(t){this.clientsRegistry.delete(t),this.clientsRegistry.size===0&&this.detachTracker()}static attachTracker(){window.addEventListener("resize",this.flush,{passive:!0,capture:!0}),this.flush()}static detachTracker(){window.removeEventListener("resize",this.flush,{capture:!0}),document.documentElement.style.removeProperty(Zt)}};f(J,"clientsRegistry",new Set),f(J,"flush",A(()=>{document.documentElement.style.setProperty(Zt,`${window.innerHeight}px`)},100));var Jt=r=>{var i;let t=new Intl.Locale(r),e="ltr";return typeof t.getTextInfo=="function"&&t.getTextInfo().direction?e=t.getTextInfo().direction:"textInfo"in t&&((i=t.textInfo)!=null&&i.direction)&&(e=t.textInfo.direction),e};var Qt=(r,t)=>new Intl.PluralRules(r).select(t);var Lr=r=>r,ft="{{",ti="}}",ei="plural:";function pt(r,t,e={}){var n;let{openToken:i=ft,closeToken:s=ti,transform:o=Lr}=e;for(let a in t){let l=(n=t[a])==null?void 0:n.toString();r=r.replaceAll(i+a+s,typeof l=="string"?o(l):l)}return r}function ii(r){let t=[],e=r.indexOf(ft);for(;e!==-1;){let i=r.indexOf(ti,e),s=r.substring(e+2,i);if(s.startsWith(ei)){let o=r.substring(e+2,i).replace(ei,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));t.push({variable:s,pluralKey:n,countVariable:a})}e=r.indexOf(ft,i)}return t}var ri=({element:r,attribute:t,onSuccess:e,onTimeout:i,timeout:s=300})=>{let o=r.getAttribute(t);if(o!==null){e(o);return}let n=new MutationObserver(c=>{let u=c[c.length-1];l(u)});n.observe(r,{attributes:!0,attributeFilter:[t]});let a=setTimeout(()=>{n.disconnect(),i()},s),l=c=>{let u=r.getAttribute(t);c.type==="attributes"&&c.attributeName===t&&u!==null&&(clearTimeout(a),n.disconnect(),e(u))}};var eo={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"};var si;(function(r){r.Token="token",r.FileInfo="file_info"})(si||(si={}));var oi;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(oi||(oi={}));var to=window.WebSocket;var Me=class{constructor(t){f(this,"_concurrency",1);f(this,"_pending",[]);f(this,"_running",0);f(this,"_resolvers",new Map);f(this,"_rejectors",new Map);this._concurrency=t}_run(){let t=this._concurrency-this._running;for(let e=0;e<t;e++){let i=this._pending.shift();if(!i)return;let s=this._resolvers.get(i),o=this._rejectors.get(i);if(!s||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,i().finally(()=>{this._resolvers.delete(i),this._rejectors.delete(i),this._running-=1,this._run()}).then(n=>s(n)).catch(n=>o(n))}}add(t){return new Promise((e,i)=>{this._resolvers.set(t,e),this._rejectors.set(t,i),this._pending.push(t),this._run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(t){this._concurrency=t,this._run()}get concurrency(){return this._concurrency}};var ni=()=>({});var pe={"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:"Queued","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var Ne=new Map,mt=new Map,ai=(r,t)=>{Ne.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`),Ne.set(r,{...pe,...t})},Pr=(r,t)=>{mt.set(r,t)},Rr=(r,t)=>{typeof t=="function"?Pr(r,t):ai(r,t)},li=async r=>{if(!Ne.has(r)){if(!mt.has(r))throw new Error(`Locale ${r} is not defined`);let e=await mt.get(r)();ai(r,e)}return Ne.get(r)};Rr("en",pe);var M=r=>`*l10n/${r}`,Mr="en",Ue=class{constructor(t){f(this,"_blockInstance",null);f(this,"_localeName","");f(this,"_callbacks",new Set);f(this,"_boundBlocks",new Map);this._blockInstance=t;for(let[e,i]of Object.entries(pe)){let s=this._blockInstance.has(M(e))?!this._blockInstance.$[M(e)]:!0;this._blockInstance.add(M(e),i,s)}setTimeout(()=>{t.subConfigValue("localeName",async e=>{var o;if(!this._blockInstance||!e)return;this._localeName=e;let i=await li(e);if(e!==Mr&&this._localeName!==e)return;let s=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[e];for(let[n,a]of Object.entries(i)){let l=s==null?void 0:s[n];this._blockInstance.add(M(n),l!=null?l:a,!0);for(let c of this._callbacks)c()}}),t.subConfigValue("localeDefinitionOverride",e=>{var s;if(!e)return;let i=e[this._localeName];if(i)for(let[o,n]of Object.entries(i)){(s=this._blockInstance)==null||s.add(M(o),n,!0);for(let a of this._callbacks)a()}})})}onLocaleChange(t){let e=A(t,0);return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}bindL10n(t,e,i){var o,n,a;t.$[e]=i(),this._boundBlocks.has(t)||this._boundBlocks.set(t,new Map),(n=(o=this._boundBlocks.get(t))==null?void 0:o.get(e))==null||n();let s=this.onLocaleChange(()=>{t.$[e]=i()});(a=this._boundBlocks.get(t))==null||a.set(e,s)}destroyL10nBindings(t){let e=this._boundBlocks.get(t);if(e){for(let i of e.values())i();this._boundBlocks.delete(t)}}destroy(){this._callbacks.clear()}};function ci(r,t){[...r.querySelectorAll("[l10n]")].forEach(e=>{let i=e.getAttribute("l10n");if(!i)return;let s=i.split(";");for(let o of s)o&&Nr(e,o,t)})}var Nr=(r,t,e)=>{let i="textContent",s=!1;if(t.includes(":")){let a=t.split(":");i=a[0],t=a[1],i.startsWith("@")&&(i=i.slice(1),s=!0)}let o=t;e.has(o)&&e.sub(o,a=>{if(!a)return;e.l10nProcessorSubs.has(o)||e.l10nProcessorSubs.set(o,new Set);let l=e.l10nProcessorSubs.get(o);l==null||l.forEach(h=>{h.remove(),l.delete(h),e.allSubs.delete(h)});let c=M(a).replace("*","");e.nodeCtx.has(c)||e.nodeCtx.add(c,a);let u=e.nodeCtx.sub(c,()=>{r[i]=e.l10n(a)});l==null||l.add(u),e.allSubs.add(u),r.removeAttribute("l10n")});let n=M(t);e.has(n)||e.add(n,""),e.sub(n,()=>{t=t,s?r.setAttribute(i,e.l10n(t)):r[i]=e.l10n(t)}),r.removeAttribute("l10n")};var S=r=>`*cfg/${r}`;function hi(r,t){let e=r.querySelectorAll("[data-testid]");if(e.length===0)return;let i=new WeakMap;for(let s of e){let o=s.getAttribute("data-testid");o&&i.set(s,o)}t.subConfigValue("testMode",s=>{if(!s){for(let n of e)n.removeAttribute("data-testid");return}let o=t.testId;for(let n of e){let a=i.get(n);a&&n.setAttribute("data-testid",`${o}--${a}`)}})}var Ur={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function me(r,t){t.tabIndex=0,t.focus(),r.tabIndex=-1}function _t(r){let t=r.role||r.type||r.tagName;if(!t)return null;let e=Ur[t.toLowerCase()];if(!e)return null;for(let i of e){let s=r.closest(`[role=${i}]`);if(s)return s}}function gt(r,t){return t.role==="toolbar"?Dr(t):t.querySelectorAll(`[role=${r.role}]`)}function Dr(r){return[...r.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function Fr(r){let t=r.getAttribute("aria-orientation");if(t==="vertical")return!1;if(t==="horizontal")return!0;let e=r.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function ui(r){return t=>{let e=!1,i=(r==null?void 0:r.searchDelayMs)||300,s=0,o="";function n(h){let d=_t(h.target);if(!d){a();return}let p=gt(h.target,d),g=Array.from(p).indexOf(h.target),N="ArrowDown",O="ArrowUp";if(Fr(d)&&(t.document.dir==="rtl"?(N="ArrowLeft",O="ArrowRight"):(N="ArrowRight",O="ArrowLeft")),h.key===N)h.preventDefault(),me(h.target,p[g+1]||p[0]);else if(h.key===O)h.preventDefault(),me(h.target,p[g-1]||p[p.length-1]);else if(h.key==="Home")h.preventDefault(),me(h.target,p[0]);else if(h.key==="End")h.preventDefault(),me(h.target,p[p.length-1]);else if(h.key.length===1&&d.role!=="tablist"){let T=Date.now();T-s<=i?o+=h.key.toLowerCase():o=h.key.toLowerCase(),s=T;let It=Array.from(p).find(Qi=>{var Lt,Pt,Rt;return(Rt=(Pt=(Lt=Qi.textContent)==null?void 0:Lt.trim())==null?void 0:Pt.toLowerCase())==null?void 0:Rt.startsWith(o)});It&&(h.preventDefault(),me(h.target,It))}}function a(){e=!1,t.removeEventListener("keydown",n)}function l(h){let d=_t(h.target);if(d){e||(e=!0,t.addEventListener("keydown",n));let p=gt(h.target,d);for(let g of p)g!==h.target&&g.setAttribute("tabindex",-1)}else e&&a()}function c(h){(!h.relatedTarget||h.relatedTarget===t.document)&&a()}function u(h){let d=_t(h.target);if(d){let p=gt(h.target,d);for(let g of p)g!==h.target&&g.setAttribute("tabindex",-1);h.target.setAttribute("tabindex",0)}}return t.addEventListener("click",u),t.addEventListener("focusin",l),t.addEventListener("focusout",c),()=>{a(),t.removeEventListener("click",u),t.removeEventListener("focusin",l),t.removeEventListener("focusout",c)}}}function di(){return r=>{let t,e;function i(o){if(o.target.getAttribute("aria-hidden")==="true"){t=o.target,t.setAttribute("aria-hidden","false"),e=t.hidden,e&&(t.hidden=!1);let n=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function s(o){t&&t.contains(o.target)&&(!o.relatedTarget||!t.contains(o.relatedTarget))&&(o.target.tabIndex=-1,t.setAttribute("aria-hidden","true"),e&&(t.hidden=!0),t=null)}return r.addEventListener("keyuxJump",i),r.addEventListener("focusout",s),()=>{r.removeEventListener("keyuxJump",i),r.removeEventListener("focusout",s)}}}function fi(){return r=>{let t=[];function e(l){let c=r.document.activeElement;c&&c!==r.document.body&&t.push(new WeakRef(c)),l.focus({focusVisible:!0})}function i(){let l=t.pop();if(!l){r.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():i()}let s=0,o;function n(l){clearInterval(o);let c=l.getAttribute("aria-controls");o=setInterval(()=>{if(s++>50){clearInterval(o);return}let u=r.document.getElementById(c);if(u){let h=u.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');h&&(clearInterval(o),u.dispatchEvent(new r.CustomEvent("keyuxJump",{bubbles:!0})),e(h))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&i()}return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}}}function pi(r){let t,e=r.split(" "),i;function s(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(o(),a.target.classList.add(...e),t=a.target,i=a.target)}function o(){t&&t.classList.remove(...e),i=null}function n(a){a.clientX===0&&a.clientY===0&&i!==a.target&&(o(),a.target.classList.add(...e),t=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",s),a.addEventListener("keyup",o),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",s),a.removeEventListener("keyup",o)})}function mi(r,t){let e=t.map(i=>i(r));return()=>{e.forEach(i=>i())}}var bt=class{constructor(){f(this,"_listeners",new Map);f(this,"_scope",[])}addEventListener(t,e){let i=s=>{let o=s.target;o&&this._scope.some(n=>n===s.target||n.contains(o))&&e(s)};this._listeners.set(e,i),window.addEventListener(t,i)}removeEventListener(t,e){let i=this._listeners.get(e);i&&window.removeEventListener(t,i),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(t){this._scope.push(t)}destroy(){this._scope=[],this._listeners.forEach((t,e)=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",t),this._listeners.delete(e)})}},De=class{constructor(){f(this,"_destroyKeyUX");f(this,"_scopedWindow");this._scopedWindow=new bt,this._destroyKeyUX=mi(this._scopedWindow,[ui(),pi("is-pressed"),fi(),di()])}registerBlock(t){this._scopedWindow.registerScope(t)}destroy(){var t;(t=this._destroyKeyUX)==null||t.call(this),this._scopedWindow.destroy()}};var ie=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Fe=class{constructor(t){f(this,"_modals",new Map);f(this,"_activeModals",new Set);f(this,"_subscribers",new Map);this._block=t}_debugPrint(...t){this._block.debugPrint("[modal-manager]",...t)}registerModal(t,e){this._modals.set(t,e),this._notify(ie.ADD,{id:t,modal:e})}deleteModal(t){if(!this._modals.has(t))return!1;let e=this._modals.get(t);return this._modals.delete(t),this._activeModals.delete(t),this._notify(ie.DELETE,{id:t,modal:e}),!0}open(t){if(!this._modals.has(t))return this._debugPrint(`Modal with ID "${t}" not found`),!1;let e=this._modals.get(t);return this._activeModals.add(t),this._notify(ie.OPEN,{modal:e,id:t}),!0}close(t){if(!this._modals.has(t)||!this._activeModals.has(t))return this._debugPrint(`Modal with ID "${t}" not found or not active`),!1;let e=this._modals.get(t);return this._activeModals.delete(t),this._notify(ie.CLOSE,{id:t,modal:e}),!0}toggle(t){return this._modals.has(t)?this._activeModals.has(t)?this.close(t):this.open(t):(this._debugPrint(`Modal with ID "${t}" 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 t=Array.from(this._activeModals).pop();return this.close(t)}closeAll(){let t=this._activeModals.size;return this._activeModals.clear(),this._notify(ie.CLOSE_ALL,{}),t}subscribe(t,e){var i;return this._subscribers.has(t)||this._subscribers.set(t,new Set),(i=this._subscribers.get(t))==null||i.add(e),()=>this.unsubscribe(t,e)}unsubscribe(t,e){var i;this._subscribers.has(t)&&((i=this._subscribers.get(t))==null||i.delete(e))}_notify(t,e){var i;if(this._subscribers.has(t))for(let s of(i=this._subscribers.get(t))!=null?i:new Set)try{s(e)}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(ie.DESTROY,{})}};function zr(r){return r.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`).replace(/__/g,"_")}function wt(r){return Array.isArray(r)?r.map(t=>typeof t=="object"&&t!==null?wt(t):t):typeof r!="object"||r===null?r:Object.fromEntries(Object.entries(r).map(([t,e])=>{let i=zr(t);return typeof e=="object"&&e!==null?[i,wt(e)]:[i,e]}))}function jr(r){return{ok:!0,value:r}}function yt(r){return{ok:!1,error:r}}var Br="https://tlm.uploadcare.com/api/",vt=class{constructor(t=Br){this.baseUrl=t}async base(t,e={}){let i=`${this.baseUrl}${t}`;try{let s=await fetch(i,e);if(!s.ok)return yt(new Error(`Got non-200 response from "${i}". Status: ${s.status.toString()}`));try{let o=await s.json();return jr(o)}catch(o){return yt(new Error(`Error parsing JSON from "${i}". Error: ${o}`))}}catch(s){return yt(new Error(`Error fetching data from "${i}". Error: ${s}`))}}async post(t,e,i={}){return await this.base(t,{...i,method:"POST",body:JSON.stringify(wt(e)),headers:{"Content-Type":"application/json",...i.headers||{}}})}async get(t,e={}){return await this.base(t,{method:"GET",...e})}},Vr=async(r,t)=>({success:!0,data:t}),ze=class extends vt{constructor(){super()}async sendEvent(t,e){let i=await Vr(void 0,t);if(!i.success)throw console.error("TelemetryAPIService: events: body is invalid",i.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",t,e)}};var je="blocks",Be="1.22.0";var Ve=class{constructor(t){f(this,"_sessionId",crypto.randomUUID());f(this,"_telemetryInstance",null);f(this,"_block",null);f(this,"_config",structuredClone(P));f(this,"_initialized",!1);f(this,"_lastPayload",null);f(this,"_queue",null);this._block=t,this._telemetryInstance=new ze,this._queue=new Me(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,i=>{var s;this._initialized&&this._config[e]!==i&&((s=this._block)==null||s.emit(x.CHANGE_CONFIG,void 0)),this._setConfig(e,i)})}_init(t){t===x.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(t,e){this._config[t]!==e&&(this._config[t]=e)}_formattingPayload(t){var s,o;let e=t.payload?{...t.payload}:{};e.activity&&(e.activity=void 0);let i={...t};return(t.eventType===x.INIT_SOLUTION||t.eventType===x.CHANGE_CONFIG)&&(i.config=this._config),{...i,appVersion:Be,appName:je,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:(s=this._config)==null?void 0:s.pubkey,userAgent:navigator.userAgent,eventType:(o=i.eventType)!=null?o:"",eventTimestamp:this._timestamp,payload:{...e}}}_excludedEvents(t){return!!(t&&[x.CHANGE,x.COMMON_UPLOAD_PROGRESS,x.FILE_ADDED,x.FILE_REMOVED,x.FILE_UPLOAD_START,x.FILE_UPLOAD_PROGRESS,x.FILE_UPLOAD_SUCCESS,x.FILE_UPLOAD_FAILED,x.FILE_URL_CHANGED,x.GROUP_CREATED].includes(t))}sendEvent(t){var o;let e=this._formattingPayload(t);if(this._init(t.eventType),this._excludedEvents(t.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))return null;(o=this._queue)==null||o.add(async()=>{var n;this._lastPayload=e,await((n=this._telemetryInstance)==null?void 0:n.sendEvent(e))})}sendEventError(t,e="unknown"){this.sendEvent({payload:{metadata:{event:"error",text:`Error in ${e}`,error:t.message}}})}sendEventCloudImageEditor(t,e,i={}){var s;this.sendEvent({payload:{metadata:{tabId:e,node:(s=t.currentTarget)==null?void 0:s.tagName,event:t.type,...i}}})}_checkObj(t,e){if(JSON.stringify(t)===JSON.stringify(e))return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;let i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(let o of i)if(!Object.prototype.hasOwnProperty.call(e,o)||!this._checkObj(t[o],e[o]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){var t,e;return(t=this._block)!=null&&t.has("*solution")?(e=this._block)==null?void 0:e.$["*solution"].toLowerCase():null}get _activity(){var t,e;return(t=this._block)!=null&&t.has("*currentActivity")?(e=this._block)==null?void 0:e.$["*currentActivity"]:null}};var Hr="uc-",b=class extends nt{constructor(){super();f(this,"requireCtxName",!1);f(this,"activityType",null);f(this,"init$",ni());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(ci),this.addTemplateProcessor(hi)}l10n(e,i={}){if(!e)return"";let s=this.$[M(e)]||e,o=ii(s);for(let a of o)i[a.variable]=this.pluralize(a.pluralKey,Number(i[a.countVariable]));return pt(s,i)}pluralize(e,i){let s=this.l10n("locale-id")||"en",o=Qt(s,i);return this.l10n(`${e}__${o}`)}bindL10n(e,i){var s;(s=this.localeManager)==null||s.bindL10n(this,e,i)}emit(e,i,s){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&(o.emit(e,i,s),this.telemetryManager.sendEvent({eventType:e,payload:typeof i=="function"?i():i}))}hasBlockInCtx(e){for(let i of this.blocksRegistry)if(e(i))return!0;return!1}setOrAddState(e,i){this.add$({[e]:i},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(i=>{this.setAttribute(i,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?ri({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),J.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),J.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Re(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new Ue(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new Ve(this)),this.has("*a11y")||this.add("*a11y",new De),this.has("*modalManager")||this.add("*modalManager",new Fe(this)),this.sub(M("locale-id"),i=>{let s=Jt(i);this.style.direction=s==="ltr"?"":s}),this.subConfigValue("testMode",i=>{if(!i||!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"]}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(){var i;super.destroyCallback();let e=this.blocksRegistry;e==null||e.delete(this),(i=this.localeManager)==null||i.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,E.deleteCtx(this),(e==null?void 0:e.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e,i;E.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.destroy(),this.modalManager&&((i=this.modalManager)==null||i.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:Le(e),cdnUrlModifiers:at(e),fileName:Ie(e)})}catch(i){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",i),this.telemetryManager.sendEventError(i,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?pt(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:i=>window.encodeURIComponent(i)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(i,s,o)=>{if(typeof s!="string")return!1;let n=S(s);return this.has(n)||this.add(n,P[s]),this.$[n]=o,!0},get:(i,s)=>{let o=S(s);return this.has(o)||this.add(o,P[s]),this.$[S(s)]}})}return this.__cfgProxy}subConfigValue(e,i){let s=S(e);this.has(s)||this.add(s,P[e]),this.sub(s,i)}debugPrint(...e){if(!this.cfg.debug)return;let i=e;if(typeof(e==null?void 0:e[0])=="function"){let s=e[0];i=s()}console.log(`[${this.ctxName}]`,...i)}static reg(e){if(!e){super.reg();return}e.startsWith(Hr)&&super.reg(e)}};f(b,"StateConsumerScope",null),f(b,"styleAttrs",[]);var D="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function _i(...r){return r.reduce((t,e)=>{if(typeof e=="string")return t[e]=!0,t;for(let i of Object.keys(e))t[i]=e[i];return t},{})}function C(...r){let t=_i(...r);return Object.keys(t).reduce((e,i)=>(t[i]&&e.push(i),e),[]).join(" ")}function gi(r,...t){let e=_i(...t);for(let i of Object.keys(e))r.classList.toggle(i,e[i])}var _e=["free"],bi=r=>{let t=fe(r);if(!(t!=null&&t.length))return[];let e=[];for(let i=0;i<t.length;i++){let s=t[i].trim();if(!s)continue;let o=s.indexOf(":");if(o===-1&&!_e.includes(s)){console.warn(`Invalid crop preset: ${s}`);continue}let n=Number(s.slice(0,o)),a=Number(s.slice(o+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!_e.includes(s)){console.warn(`Invalid crop preset: ${s}`);continue}e.push({id:ot.generate(),type:"aspect-ratio",width:_e.includes(s)?0:n,height:_e.includes(s)?0:a,hasFreeform:_e.includes(s)})}return e},yi=(r,t,e,i=.1)=>{let s=r/t,o=null,n=1/0;for(let a of e){let[l,c]=[a.width,a.height],u=l/c,h=Math.abs(s-u);h<n&&(n=h,o=a)}if(o){let[a,l]=[o.width,o.height],c=a/l;if(Math.abs(s-c)/c>i)return null}return o};var wi=r=>{if(!r)return k;let t=Y(r).filter(e=>k.includes(e));return t.length===0?k:t};function vi(r){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":k,"*tabId":y.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:D,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:Z(k),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let t=r.querySelectorAll("img");for(let e of t){let i=e.src;e.src=D,e.src=i}r.$["*networkProblems"]=!1},"*on.apply":t=>{if(!t)return;let e=r.$["*originalUrl"],i=B(G(t),"preview"),s=V(e,i),o={originalUrl:e,cdnUrlModifiers:i,cdnUrl:s,transformations:t};r.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),r.remove()},"*on.cancel":()=>{r.remove(),r.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Ei="<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 Ci=`${Ei} <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="${D}" 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 W=class extends b{constructor(){super();f(this,"ctxOwner",!0);f(this,"_debouncedShowLoader",A(this._showLoader.bind(this),300));this.init$={...this.init$,...vi(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((i,s)=>{let o=setTimeout(()=>{s(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),n=new ResizeObserver(([a])=>{a.contentRect.width>0&&a.contentRect.height>0&&(i(),clearTimeout(o),n.disconnect())});n.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=Le(this.$.cdnUrl),i=ct(this.$.cdnUrl,e);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let s=lt(this.$.cdnUrl),o=ht(s);this.$["*editorTransformations"]=o}else if(this.$.uuid){let e=ct(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"]===y.CROP?this.$["*cropperEl"].deactivate({reset:!0}):this.$["*faderEl"].deactivate();try{let e=await this.proxyUrl(V(this.$["*originalUrl"],B("json"))),i=await fetch(e).then(n=>n.json()),{width:s,height:o}=i;this.$["*imageSize"]={width:s,height:o},this.$["*tabId"]===y.CROP?this.$["*cropperEl"].activate(this.$["*imageSize"]):this.$["*faderEl"].activate({url:this.$["*originalUrl"]})}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._imgLoading=!1,this._debouncedShowLoader(!1),this.$.src!==D&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let i=this.ref["img-el"];i.src!==e&&(this._imgLoading=!0,i.src=e||D)}),this.sub("tabs",e=>{this.$["*tabList"]=wi(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=C("uc-image",{"uc-image_hidden_to_cropper":e===y.CROP,"uc-image_hidden_effects":e!==y.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 i=this.$["*originalUrl"],s=B(G(e),"preview"),o=V(i,s),n={originalUrl:i,cdnUrlModifiers:s,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:!0,composed:!0}))},!1),this.sub("uuid",e=>e&&this.updateImage()),this.sub("cdnUrl",e=>e&&this.updateImage()),this.sub("cropPreset",e=>{var o,n,a;let i=bi(e),s=null;if(this.$.cdnUrl){let l=lt(this.$.cdnUrl),c=ht(l);if(Array.isArray((o=c==null?void 0:c.crop)==null?void 0:o.dimensions)){let[u,h]=(n=c==null?void 0:c.crop)==null?void 0:n.dimensions;s=yi(u,h,i,.1)}}this.$["*cropPresetList"]=i,this.$["*currentAspectRatio"]=(a=s!=null?s:i==null?void 0:i[0])!=null?a:null})}};f(W,"styleAttrs",["uc-cloud-image-editor"]);W.template=Ci;W.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var ge=33.333333333333336,m=1,Et=24,Ti=6;function q(r,t){for(let e in t)r.setAttributeNS(null,e,t[e].toString())}function $(r,t={}){let e=document.createElementNS("http://www.w3.org/2000/svg",r);return q(e,t),e}function xi(r,t,e){let{x:i,y:s,width:o,height:n}=r,a=t.includes("w")?0:1,l=t.includes("n")?0:1,c=[-1,1][a],u=[-1,1][l],h=[i+a*o+1.5*c,s+l*n+1.5*u-24*e*u],d=[i+a*o+1.5*c,s+l*n+1.5*u],p=[i+a*o-24*e*c+1.5*c,s+l*n+1.5*u];return{d:`M ${h[0]} ${h[1]} L ${d[0]} ${d[1]} L ${p[0]} ${p[1]}`,center:d}}function Ai(r,t,e){let{x:i,y:s,width:o,height:n}=r,a=["n","s"].includes(t)?.5:{w:0,e:1}[t],l=["w","e"].includes(t)?.5:{n:0,s:1}[t],c=[-1,1][a],u=[-1,1][l],h,d;["n","s"].includes(t)?(h=[i+a*o-34*e/2,s+l*n+1.5*u],d=[i+a*o+34*e/2,s+l*n+1.5*u]):(h=[i+a*o+1.5*c,s+l*n-34*e/2],d=[i+a*o+1.5*c,s+l*n+34*e/2]);let p=`M ${h[0]} ${h[1]} L ${d[0]} ${d[1]}`,g=[d[0]-(d[0]-h[0])/2,d[1]-(d[1]-h[1])/2];return{d:p,center:g}}function Si(r){return r===""?"move":["e","w"].includes(r)?"ew-resize":["n","s"].includes(r)?"ns-resize":["nw","se"].includes(r)?"nwse-resize":"nesw-resize"}function $i({rect:r,delta:[t,e],imageBox:i}){return se({...r,x:r.x+t,y:r.y+e},i)}function se(r,t){let{x:e}=r,{y:i}=r;return r.x<t.x?e=t.x:r.x+r.width>t.x+t.width&&(e=t.x+t.width-r.width),r.y<t.y?i=t.y:r.y+r.height>t.y+t.height&&(i=t.y+t.height-r.height),{...r,x:e,y:i}}function Xr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[,s]=t,{y:o,width:n,height:a}=r;o+=s,a-=s,e&&(n=a*e);let l=r.x+r.width/2-n/2;return o<=i.y&&(o=i.y,a=r.y+r.height-o,e&&(n=a*e,l=r.x+r.width/2-n/2)),l<=i.x&&(l=i.x,o=r.y+r.height-a),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,e&&(a=n/e),o=r.y+r.height-a),a<m&&(a=m,e&&(n=a*e,l=r.x+r.width/2-n/2),o=r.y+r.height-a),n<m&&(n=m,e&&(a=n/e,l=r.x+r.width/2-n/2),o=r.y+r.height-a),{x:l,y:o,width:n,height:a}}function Gr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s]=t,{x:o,width:n,height:a}=r;o+=s,n-=s,e&&(a=n/e);let l=r.y+r.height/2-a/2;return o<=i.x&&(o=i.x,n=r.x+r.width-o,e&&(a=n/e,l=r.y+r.height/2-a/2)),l<=i.y&&(l=i.y,o=r.x+r.width-n),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,e&&(n=a*e),o=r.x+r.width-n),a<m&&(a=m,e&&(n=a*e),l=r.y+r.height/2-a/2,o=r.x+r.width-n),n<m&&(n=m,e&&(a=n/e),l=r.y+r.height/2-a/2,o=r.x+r.width-n),{x:o,y:l,width:n,height:a}}function Wr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[,s]=t,{y:o,width:n,height:a}=r;a+=s,e&&(n=a*e);let l=r.x+r.width/2-n/2;return o+a>=i.y+i.height&&(a=i.y+i.height-o,e&&(n=a*e),l=r.x+r.width/2-n/2),l<=i.x&&(l=i.x,o=r.y),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,e&&(a=n/e),o=r.y),a<m&&(a=m,e&&(n=a*e),l=r.x+r.width/2-n/2),n<m&&(n=m,e&&(a=n/e),l=r.x+r.width/2-n/2),{x:l,y:o,width:n,height:a}}function qr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s]=t,{x:o,width:n,height:a}=r;n+=s,e&&(a=n/e);let l=r.y+r.height/2-a/2;return o+n>=i.x+i.width&&(n=i.x+i.width-o,e&&(a=n/e),l=r.y+r.height/2-a/2),l<=i.y&&(l=i.y,o=r.x),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,e&&(n=a*e),o=r.x),a<m&&(a=m,e&&(n=a*e),l=r.y+r.height/2-a/2),n<m&&(n=m,e&&(a=n/e),l=r.y+r.height/2-a/2),{x:o,y:l,width:n,height:a}}function Kr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+s<i.x&&(s=i.x-n),a+o<i.y&&(o=i.y-a),n+=s,l-=s,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=i.y&&(c=c-(i.y-a),l=c*e,n=r.x+r.width-l,a=i.y)):e&&(s=c*e-l,l=l+s,n-=s,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=r.y+r.height-c)),c<m&&(c=m,e&&(l=c*e),n=r.x+r.width-l,a=r.y+r.height-c),l<m&&(l=m,e&&(c=l/e),n=r.x+r.width-l,a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Yr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+l+s>i.x+i.width&&(s=i.x+i.width-n-l),a+o<i.y&&(o=i.y-a),l+=s,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=i.y&&(c=c-(i.y-a),l=c*e,n=r.x,a=i.y)):e&&(s=c*e-l,l+=s,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=r.y+r.height-c)),c<m&&(c=m,e&&(l=c*e),a=r.y+r.height-c),l<m&&(l=m,e&&(c=l/e),a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Zr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+s<i.x&&(s=i.x-n),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),n+=s,l-=s,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*e,n=r.x+r.width-l,a=i.y+i.height-c)):e&&(s=c*e-l,l+=s,n-=s,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=r.y)),c<m&&(c=m,e&&(l=c*e),n=r.x+r.width-l),l<m&&(l=m,e&&(c=l/e),n=r.x+r.width-l),{x:n,y:a,width:l,height:c}}function Jr({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+l+s>i.x+i.width&&(s=i.x+i.width-n-l),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),l+=s,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*e,n=r.x,a=i.y+i.height-c)):e&&(s=c*e-l,l+=s,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=r.y)),c<m&&(c=m,e&&(l=c*e)),l<m&&(l=m,e&&(c=l/e)),{x:n,y:a,width:l,height:c}}function Oi({direction:r,...t}){switch(r){case"n":return Xr(t);case"w":return Gr(t);case"s":return Wr(t);case"e":return qr(t);case"nw":return Kr(t);case"ne":return Yr(t);case"sw":return Zr(t);case"se":return Jr(t);default:return t.rect}}function ki(r,[t,e]){return r.x<=t&&t<=r.x+r.width&&r.y<=e&&e<=r.y+r.height}function Ii(r,t){return r.x>=t.x&&r.y>=t.y&&r.x+r.width<=t.x+t.width&&r.y+r.height<=t.y+t.height}function Li(r,t){return Math.abs(r.width/r.height-t)<.1}function oe({width:r,height:t},e){let i=e/90%2!==0;return{width:i?t:r,height:i?r:t}}function ne(r){return{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}}function K(r,t,e){return Math.min(Math.max(r,t),e)}var Xe=class extends b{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(t){let e=this.$["*imageBox"];if(!e)return;if(t===""&&e.height<=m&&e.width<=m)return!0;let i=e.height<=m&&(t.includes("n")||t.includes("s")),s=e.width<=m&&(t.includes("e")||t.includes("w"));return i||s}_createBackdrop(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:i,width:s,height:o}=t,n=this.ref["svg-el"],a=$("mask",{id:"backdrop-mask"}),l=$("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=$("rect",{x:e,y:i,width:s,height:o,fill:"black"});a.appendChild(l),a.appendChild(c);let u=$("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});n.appendChild(u),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 t=this.$["*cropBox"];if(!t)return;let{x:e,y:i,width:s,height:o}=t;this._backdropMaskInner&&q(this._backdropMaskInner,{x:e,y:i,width:s,height:o})}_updateFrame(){let t=this.$["*cropBox"];if(!(!t||!this._frameGuides||!this._frameThumbs)){for(let e of Object.values(this._frameThumbs)){let{direction:i,pathNode:s,interactionNode:o,groupNode:n}=e,a=i==="",l=i.length===2,{x:c,y:u,width:h,height:d}=t;if(a)q(o,{x:c,y:u,width:h,height:d});else{let g=K(Math.min(h,d)/(24*2+34)/2,0,1),{d:N,center:O}=l?xi(t,i,g):Ai(t,i,g),T=Math.max(Et*K(Math.min(h,d)/Et/3,0,1),Ti);q(o,{x:O[0]-T,y:O[1]-T,width:T*2,height:T*2}),q(s,{d:N})}let p=this._shouldThumbBeDisabled(i);n.setAttribute("class",C("uc-thumb",{"uc-thumb--hidden":p,"uc-thumb--visible":!p}))}q(this._frameGuides,{x:t.x-1*.5,y:t.y-1*.5,width:t.width+1,height:t.height+1})}}_createThumb(t,e){let i=$("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let s=$("rect",{fill:"transparent"}),o=$("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(o),i.appendChild(s),t[e]={direction:e,pathNode:o,interactionNode:s,groupNode:i},e===""&&(i.style.cursor="move"),s.addEventListener("pointerdown",this._handlePointerDown.bind(this,e))}_createThumbs(){let t={};for(let e=0;e<3;e++)for(let i=0;i<3;i++){let s=`${["n","","s"][e]}${["w","","e"][i]}`;s!==""&&this._createThumb(t,s)}return this._createThumb(t,""),t}_createGuides(){let t=$("svg"),e=$("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});t.appendChild(e);for(let i=1;i<=2;i++){let s=$("line",{x1:`${ge*i}%`,y1:"0%",x2:`${ge*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s)}for(let i=1;i<=2;i++){let s=$("line",{x1:"0%",y1:`${ge*i}%`,x2:"100%",y2:`${ge*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s)}return t.classList.add("uc-guides","uc-guides--semi-hidden"),t}_createFrame(){let t=this.ref["svg-el"],e=document.createDocumentFragment(),i=this._createGuides();e.appendChild(i);let s=this._createThumbs();for(let{groupNode:o}of Object.values(s))e.appendChild(o);t.appendChild(e),this._frameThumbs=s,this._frameGuides=i}_handlePointerDown(t,e){if(!this._frameThumbs)return;let i=this._frameThumbs[t];if(this._shouldThumbBeDisabled(t))return;let s=this.$["*cropBox"],{x:o,y:n}=this.ref["svg-el"].getBoundingClientRect(),a=e.x-o,l=e.y-n;this.$.dragging=!0,this._draggingThumb=i,this._dragStartPoint=[a,l],this._dragStartCrop={...s}}_handlePointerUp_(t){this._updateCursor(),this.$.dragging&&(t.stopPropagation(),t.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(t){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;t.stopPropagation(),t.preventDefault();let e=this.ref["svg-el"],{x:i,y:s}=e.getBoundingClientRect(),o=t.x-i,n=t.y-s,a=o-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,u=this._calcCropBox(c,[a,l]);u&&(this.$["*cropBox"]=u)}_calcCropBox(t,e){var c;let[i,s]=e,o=this.$["*imageBox"],n=(c=this._dragStartCrop)!=null?c:this.$["*cropBox"],a=this.$["*currentAspectRatio"],l=a?a.width/a.height:void 0;if(t===""?n=$i({rect:n,delta:[i,s],imageBox:o}):n=Oi({rect:n,delta:[i,s],direction:t,aspectRatio:l,imageBox:o}),!Object.values(n).every(u=>Number.isFinite(u)&&u>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return se(ne(n),this.$["*imageBox"])}_handleSvgPointerMove_(t){if(!this._frameThumbs)return;let e=Object.values(this._frameThumbs).find(i=>{if(this._shouldThumbBeDisabled(i.direction))return!1;let o=i.interactionNode.getBoundingClientRect(),n={x:o.x,y:o.y,width:o.width,height:o.height};return ki(n,[t.x,t.y])});this._hoverThumb=e,this._updateCursor()}_updateCursor(){let t=this._hoverThumb;this.ref["svg-el"].style.cursor=t?Si(t.direction):"initial"}_createMask(t){if(this._frameImage){this._frameImage.setAttribute("href",t);return}let e=this.ref["svg-el"],i=document.createDocumentFragment(),s=$("image",{href:t});s.setAttribute("class","uc-cloud-mask"),i.appendChild(s),e.appendChild(i),this._frameImage=s}_updateMask(){let t=this.$["*cropBox"];if(!t||!this._frameImage)return;let{x:e,y:i,width:s,height:o}=t;q(this._frameImage,{x:e,y:i,height:o,width:s})}_render(){this._updateBackdrop(),this._updateFrame(),this._updateMask()}toggleThumbs(t){this._frameThumbs&&Object.values(this._frameThumbs).map(({groupNode:e})=>e).forEach(e=>{e.setAttribute("class",C("uc-thumb",{"uc-thumb--hidden":!t,"uc-thumb--visible":t}))})}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",t=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",t=>{t&&(this._guidesHidden=t.height<=m||t.width<=m,window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this._createMask(t)}),this.sub("dragging",t=>{this._frameGuides&&this._frameGuides.setAttribute("class",C({"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(),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}};Xe.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var R=class extends b{constructor(){super(...arguments);f(this,"init$",{...this.init$,active:!1,title:"",icon:"","on.click":null,"title-prop":""})}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this._iconEl=this.ref["icon-el"],this.sub("title",e=>{this._titleEl&&(this._titleEl.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=C({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e})}};R.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>`;function es(r){let t=r+90;return t=t>=360?0:t,t}function ts(r,t){return r==="rotate"?es(t):["mirror","flip"].includes(r)?!t:null}var be=class extends R{initCallback(){super.initCallback(),this.defineAccessor("operation",t=>{t&&(this._operation=t,this.$.icon=t,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(t).toLowerCase()})))}),this.$["on.click"]=t=>{let e=this.$["*cropperEl"].getValue(this._operation),i=ts(this._operation,e);this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:this._operation,next:i,prev:e}),this.$["*cropperEl"].setValue(this._operation,i)}}};var Ge=12,Pi=16,is=r=>{let t=12,e=12;return r.width/r.height>=1?(t=Ge,e=Math.round(Ge*r.height/r.width)):(e=Ge,t=Math.round(Ge*r.width/r.height)),{width:t,height:e}},ae=class extends R{constructor(){super()}initCallback(){super.initCallback(),this.$.icon="arrow-dropdown",this.$["on.click"]=this.handleClick.bind(this),this.sub("*currentAspectRatio",t=>{this.$.title=t.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${t.width}:${t.height}`}),this.bindL10n("title-prop",()=>this.$.title)})}handleClick(){this.$["*showListAspectRatio"]=!0}};ae.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 ye=class extends R{constructor(){super(),this.init$={...this.init$,active:!1,once:!1}}initCallback(){super.initCallback(),this.defineAccessor("aspectRatio",t=>{if(!t)return;let e=!!t.hasFreeform;this.$.title=e?this.l10n("custom"):`${t.width}:${t.height}`,e||this._renderRectBasedOnAspectRatio(t),e&&this.setAttribute("uc-aspect-ratio-freeform",""),this._aspectRatio=t,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:e?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${t.width}:${t.height}`}).toLowerCase(),value:""}))}),this.sub("*currentAspectRatio",t=>{var e,i,s;this.$.active=t&&t.id===((e=this._aspectRatio)==null?void 0:e.id)||(t==null?void 0:t.width)===((i=this._aspectRatio)==null?void 0:i.width)&&(t==null?void 0:t.height)===((s=this._aspectRatio)==null?void 0:s.height)}),this.$["on.click"]=this.handleClick.bind(this)}handleClick(){var t,e;((t=this.$["*currentAspectRatio"])==null?void 0:t.id)!==((e=this._aspectRatio)==null?void 0:e.id)&&(this.$["*currentAspectRatio"]=this._aspectRatio)}_renderRectBasedOnAspectRatio(t){var n,a;let{width:e,height:i}=is(t),s=$("rect",{"stroke-linejoin":"round",fill:"none",stroke:"currentColor","stroke-width":1.2,"fill-rule":"evenodd",x:(Pi-e)/2,y:(Pi-i)/2,rx:2,width:e,height:i}),o=(a=(n=this.ref["icon-el"])==null?void 0:n.ref)==null?void 0:a.svg;o&&(o.innerHTML="",o.appendChild(s))}};var we={FILTER:"filter",COLOR_OPERATION:"color_operation"},z="original",We=class extends b{constructor(){super(...arguments);f(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,i){this._controlType=e==="filter"?we.FILTER:we.COLOR_OPERATION,this._operation=e,this._iconName=e,this._title=e.toUpperCase(),this._filter=i,this._initializeValues(),this.$["*faderEl"].activate({url:this.$["*originalUrl"],operation:this._operation,value:this._filter===z?void 0:this.$.value,filter:this._filter===z?void 0:this._filter,fromViewer:!1})}_initializeValues(){let{range:e,zero:i}=U[this._operation],[s,o]=e;this.$.min=s,this.$.max=o,this.$.zero=i;let n=this.$["*editorTransformations"][this._operation];if(this._controlType===we.FILTER){let a=o;if(n){let{name:l,amount:c}=n;a=l===this._filter?c:o}this.$.value=a,this.$.defaultValue=a}if(this._controlType===we.COLOR_OPERATION){let a=typeof n!="undefined"?n:i;this.$.value=a,this.$.defaultValue=a}}apply(){let e;this._controlType===we.FILTER?this._filter===z?e=null:e={name:this._filter,amount:this.$.value}:e=this.$.value;let i={...this.$["*editorTransformations"],[this._operation]:e};this.$["*editorTransformations"]=i}cancel(){this.$["*faderEl"].deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{this._originalUrl=e}),this.sub("value",e=>{let i=`${this._filter||this._operation} ${e}`;this.$["*operationTooltip"]=i})}};We.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 ve(r){let t=new Image;return{promise:new Promise((s,o)=>{t.src=r,t.onload=s,t.onerror=o}),image:t,cancel:()=>{t.naturalWidth===0&&(t.src=D)}}}function Ee(r){let t=[];for(let o of r){let n=ve(o);t.push(n)}let e=t.map(o=>o.image);return{promise:Promise.allSettled(t.map(o=>o.promise)),images:e,cancel:()=>{t.forEach(o=>{o.cancel()})}}}function le(r){let t=r.match(/^(\w+)\s+(\d+)$/);return t?{filter:t[1],value:Number(t[2])}:null}var ce=class extends R{constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let t=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),e=window.devicePixelRatio,i=Math.ceil(e*t),s=e>=2?"lightest":"normal",o=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==z?{name:this._filter,amount:o}:void 0,V(this._originalUrl,B(Pe,G(n),`quality/${s}`,`scale_crop/${i}x${i}/center`))}async _observerCallback(t,e){var s;if(t[0].isIntersecting){let o=await this.proxyUrl(this._previewSrc()),n=this.ref["preview-el"],{promise:a,cancel:l}=ve(o);this._cancelPreload=l,a.catch(c=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:c})}).finally(()=>{n.style.backgroundImage=`url(${o})`,n.setAttribute("loaded",""),e.unobserve(this)})}else(s=this._cancelPreload)==null||s.call(this)}initCallback(){super.initCallback(),this.$["on.click"]=e=>{this.$.active?this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0):(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*sliderEl"].apply()),this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:le(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",e=>{this._operation="filter",this._filter=e,this.$.isOriginal=e===z,this.$.icon=this.$.isOriginal?"original":"slider",this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()}))}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let t=this.$["*originalUrl"];this._originalUrl=t,this.$.isOriginal?this.ref["icon-el"].classList.add("uc-original-icon"):this._observer.observe(this),this.sub("*currentFilter",e=>{this.$.active=e&&e===this._filter}),this.sub("isOriginal",e=>{this.$.iconSize=e?40:20}),this.sub("active",e=>{if(this.$.isOriginal)return;let i=this.ref["icon-el"];i.style.opacity=e?"1":"0";let s=this.ref["preview-el"];e?s.style.opacity="0":s.style.backgroundImage&&(s.style.opacity="1")}),this.sub("*networkProblems",async e=>{if(!e){let i=await this.proxyUrl(this._previewSrc()),s=this.ref["preview-el"];s.style.backgroundImage&&(s.style.backgroundImage="none",s.style.backgroundImage=`url(${i})`)}})}destroyCallback(){var t,e;super.destroyCallback(),(t=this._observer)==null||t.disconnect(),(e=this._cancelPreload)==null||e.call(this)}};ce.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 Ce=class extends R{constructor(){super(...arguments);f(this,"_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:le(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:i}=U[this._operation],s=e[this._operation],o=typeof s!="undefined"?s!==i:!1;this.$.active=o})}};var Ri=(r,t)=>{let e,i,s,o=(...n)=>{e?(clearTimeout(i),i=setTimeout(()=>{Date.now()-s>=t&&(r(...n),s=Date.now())},Math.max(t-(Date.now()-s),0))):(r(...n),s=Date.now(),e=!0)};return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{clearTimeout(i)}}),o};function Mi(r,t){let e={};for(let i of t){let s=r[i];(r.hasOwnProperty(i)||s!==void 0)&&(e[i]=s)}return e}function he(r,t,e){let s=window.devicePixelRatio,o=Math.min(Math.ceil(t*s),3e3),n=s>=2?"lightest":"normal";return V(r,B(Pe,G(e),`quality/${n}`,`stretch/off/-/resize/${o}x`,`@clib/${je}/${Be}/uc-cloud-image-editor/`))}function rs(r){return r?[({dimensions:e,coords:i})=>[...e,...i].every(s=>Number.isInteger(s)&&Number.isFinite(s)),({dimensions:e,coords:i})=>e.every(s=>s>0)&&i.every(s=>s>=0)].every(e=>e(r)):!0}var qe=class extends b{constructor(){super();f(this,"ctxOwner",!0);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=A(this._commit.bind(this),300),this._handleResizeThrottled=Ri(this._handleResize.bind(this),100),this._imageSize={width:0,height:0}}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let e=this.$["*editorTransformations"],i=Mi(e,Object.keys(this.$["*operations"])),s={...this.$["*operations"],...i};this.$["*operations"]=s}_initCanvas(){let e=this.ref["canvas-el"],i=e.getContext("2d"),s=this.offsetWidth,o=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${s}px`,e.style.height=`${o}px`,e.width=s*n,e.height=o*n,i==null||i.scale(n,n),this._canvas=e,this._ctx=i}_alignImage(){if(!this._isActive||!this.$.image)return;let e=this.$.image,i=this.$["*padding"],s=this.$["*operations"],{rotate:o}=s,n={width:this.offsetWidth,height:this.offsetHeight},a=oe({width:e.naturalWidth,height:e.naturalHeight},o),l;if(a.width>n.width-i*2||a.height>n.height-i*2){let c=a.width/a.height,u=n.width/n.height;if(c>u){let h=n.width-i*2,d=h/c,p=0+i,g=i+(n.height-i*2)/2-d/2;l={x:p,y:g,width:h,height:d}}else{let h=n.height-i*2,d=h*c,p=i+(n.width-i*2)/2-d/2,g=0+i;l={x:p,y:g,width:d,height:h}}}else{let{width:c,height:u}=a,h=i+(n.width-i*2)/2-c/2,d=i+(n.height-i*2)/2-u/2;l={x:h,y:d,width:c,height:u}}this.$["*imageBox"]=ne(l)}_alignCrop(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=this.$["*imageBox"];if(n){let{dimensions:[d,p],coords:[g,N]}=n,{width:O}=oe(this._imageSize,o),T=a/O;e=se(ne({x:l+g*T,y:c+N*T,width:d*T,height:p*T}),this.$["*imageBox"])}let u=this.$["*currentAspectRatio"],h=u?u.width/u.height:void 0;if(!Ii(e,i)||h&&!Li(e,h)){let d=i.width/i.height,p=i.width,g=i.height;h&&(d>h?p=Math.min(i.height*h,i.width):g=Math.min(i.width/h,i.height)),e={x:i.x+i.width/2-p/2,y:i.y+i.height/2-g/2,width:p,height:g}}this.$["*cropBox"]=se(ne(e),this.$["*imageBox"])}_drawImage(){let e=this._ctx;if(!e)return;let i=this.$.image,s=this.$["*imageBox"],o=this.$["*operations"],{mirror:n,flip:a,rotate:l}=o,c=oe({width:s.width,height:s.height},l);e.save(),e.translate(s.x+s.width/2,s.y+s.height/2),e.rotate(l*Math.PI*-1/180),e.scale(n?-1:1,a?-1:1),e.drawImage(i,-c.width/2,-c.height/2,c.width,c.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=C({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a}=i,{width:l,height:c}=oe(this._imageSize,o),{width:u,height:h}=e,d=n/l,p=a/c;return[K(Math.round(u/d),1,l),K(Math.round(h/p),1,c)]}_getCropTransformation(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a,x:l,y:c}=i,{width:u,height:h}=oe(this._imageSize,o),{x:d,y:p}=e,g=n/u,N=a/h,O=this._getCropDimensions(),T={dimensions:O,coords:[K(Math.round((d-l)/g),0,u-O[0]),K(Math.round((p-c)/N),0,h-O[1])]};if(!rs(T)){console.error("Cropper is trying to create invalid crop object",{payload:T});return}if(!(O[0]===u&&O[1]===h))return T}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:i,mirror:s,flip:o}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:i,mirror:s,flip:o};this.$["*editorTransformations"]=l}setValue(e,i){this.$["*operations"]={...this.$["*operations"],[e]:i},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:i}={}){if(!this._isActive){this._isActive=!0,this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{this.$.image=await this._waitForImage(this.$["*originalUrl"],this.$["*editorTransformations"]),this._syncTransformations(),this._animateIn({fromViewer:i})}catch(s){console.error("Failed to activate cropper",{error:s}),this.telemetryManager.sendEventError(s,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(([s])=>{s.contentRect.width>0&&s.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){var i;this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=C({"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}),(i=this._observer)==null||i.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),i=Math.min(this.offsetWidth,e[0])/this.$["*cropBox"].width,s=Math.min(this.offsetHeight,e[1])/this.$["*cropBox"].height,o=Math.min(i,s),n=this.$["*cropBox"].x+this.$["*cropBox"].width/2,a=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform=`scale(${o}) translate(${(this.offsetWidth/2-n)/o}px, ${(this.offsetHeight/2-a)/o}px)`,this.style.transformOrigin=`${n}px ${a}px`}_transitionToImage(){let e=this.$["*cropBox"].x+this.$["*cropBox"].width/2,i=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${e}px ${i}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(e,i){var u;let s=this.offsetWidth;i={...i,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(he(e,s,i)),{promise:n,cancel:a,image:l}=ve(o),c=this._handleImageLoading(o);return l.addEventListener("load",c,{once:!0}),l.addEventListener("error",c,{once:!0}),(u=this._cancelPreload)==null||u.call(this),this._cancelPreload=a,n.then(()=>l).catch(h=>(console.error("Failed to load image",{error:h}),this.$["*networkProblems"]=!0,Promise.resolve(l)))}_handleImageLoading(e){let i="crop",s=this.$["*loadingOperations"];return s.get(i)||s.set(i,new Map),s.get(i).get(e)||(s.set(i,s.get(i).set(e,!0)),this.$["*loadingOperations"]=s),()=>{var o;(o=s==null?void 0:s.get(i))!=null&&o.has(e)&&(s.get(i).delete(e),this.$["*loadingOperations"]=s)}}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(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};qe.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Ct(r,t,e){let i=Array(e);e--;for(let s=e;s>=0;s--)i[s]=Math.ceil((s*t+(e-s)*r)/e);return i}function ss(r){return r.reduce((t,e,i)=>i<r.length-1?[...t,[e,r[i+1]]]:t,[])}function os(r,t,e){let i=ss(r).find(([s,o])=>s<=t&&t<=o);return r.map(s=>{let o=Math.abs(i[0]-i[1]),n=Math.abs(t-i[0])/o;return i[0]===s?t>e?1:1-n:i[1]===s?t>=e?n:1:0})}function ns(r,t){return r.map((e,i)=>e<t?r.length-i:i)}function Ni(r,t){let e=U[r].keypointsNumber,{range:i,zero:s}=U[r];return[...new Set([...Ct(i[0],s,e+1),...Ct(s,i[1],e+1),s,t])].sort((o,n)=>o-n)}var Tt=class extends b{constructor(){super(),this._isActive=!1,this._hidden=!0,this._addKeypointDebounced=A(this._addKeypoint.bind(this),600),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(t){let e=this._operation,i=this.$["*loadingOperations"];return i.get(e)||i.set(e,new Map),i.get(e).get(t)||(i.set(e,i.get(e).set(t,!0)),this.$["*loadingOperations"]=i),()=>{var s;(s=i==null?void 0:i.get(e))!=null&&s.has(t)&&(i.get(e).delete(t),this.$["*loadingOperations"]=i)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let t of this._keypoints){let{image:e}=t;e&&(e.style.opacity=t.opacity.toString(),e.style.zIndex=t.zIndex.toString())}})}async _imageSrc({url:t=this._url,filter:e=this._filter,operation:i,value:s}={}){let o={...this._transformations};i&&(o[i]=e?{name:e,amount:s}:s);let n=this.offsetWidth;return await this.proxyUrl(he(t,n,o))}async _constructKeypoint(t,e){return{src:await this._imageSrc({operation:t,value:e}),image:null,opacity:0,zIndex:0,value:e}}_isSame(t,e){return this._operation===t&&this._filter===e}async _addKeypoint(t,e,i){let s=()=>!this._isSame(t,e)||this._value!==i||!!this._keypoints.find(l=>l.value===i);if(s())return;let o=await this._constructKeypoint(t,i),n=new Image;n.src=o.src;let a=this._handleImageLoading(o.src);n.addEventListener("load",a,{once:!0}),n.addEventListener("error",a,{once:!0}),o.image=n,n.classList.add("uc-fader-image"),n.addEventListener("load",()=>{if(s())return;let l=this._keypoints,c=l.findIndex(h=>h.value>i),u=c<l.length?l[c].image:null;!this._container||u&&!this._container.contains(u)||(l.splice(c,0,o),this._container.insertBefore(n,u),this._update(t,i))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(t){t=typeof t=="string"?parseInt(t,10):t,this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t)}_update(t,e){this._operation=t,this._value=e;let{zero:i}=U[t],s=this._keypoints.map(a=>a.value),o=os(s,e,i),n=ns(s,i);for(let[a,l]of Object.entries(this._keypoints))l.opacity=o[a],l.zIndex=n[a];this._flush()}_createPreviewImage(){let t=new Image;return t.classList.add("uc-fader-image","uc-fader-image--preview"),t.style.opacity="0",t}async _initNodes(){let t=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage(),!this.contains(this._previewImage)&&t.appendChild(this._previewImage);let e=document.createElement("div");t.appendChild(e);let i=this._keypoints.map(c=>c.src),{images:s,promise:o,cancel:n}=Ee(i);s.forEach(c=>{let u=this._handleImageLoading(c.src);c.addEventListener("load",u),c.addEventListener("error",u)}),this._cancelLastImages=()=>{n(),this._cancelLastImages=void 0};let a=this._operation,l=this._filter;await o,this._isActive&&this._isSame(a,l)&&(this._container&&this._container.remove(),this._container=e,this._keypoints.forEach((c,u)=>{let h=s[u];h.classList.add("uc-fader-image"),c.image=h,this._container.appendChild(h)}),this.appendChild(t),this._flush())}async setTransformations(t){if(this._transformations=t,this._previewImage){let e=await this._imageSrc(),i=this._handleImageLoading(e);this._previewImage.src=e,this._previewImage.addEventListener("load",i,{once:!0}),this._previewImage.addEventListener("error",i,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:t,filter:e,operation:i,value:s}){this._cancelBatchPreload&&this._cancelBatchPreload();let o=Ni(i,s),n=await Promise.all(o.map(l=>this._imageSrc({url:t,filter:e,operation:i,value:l}))),{cancel:a}=Ee(n);this._cancelBatchPreload=a}_setOriginalSrc(t){let e=this._previewImage||this._createPreviewImage();if(!this.contains(e)&&this.appendChild(e),this._previewImage=e,e.src===t){e.style.opacity="1",e.style.transform="scale(1)",this.className=C({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}e.style.opacity="0";let i=this._handleImageLoading(t);e.addEventListener("error",i,{once:!0}),e.src=t,e.addEventListener("load",()=>{i(),e&&(e.style.opacity="1",e.style.transform="scale(1)",this.className=C({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),e.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:t,operation:e,value:i,filter:s,fromViewer:o}){if(this._isActive=!0,this._hidden=!1,this._url=t,this._operation=e||"initial",this._value=i,this._filter=s,this._fromViewer=o,typeof i!="number"&&!s){let a=await this._imageSrc({operation:e,value:i});this._setOriginalSrc(a),this._container&&this._container.remove();return}this._keypoints=await Promise.all(Ni(e,i).map(a=>this._constructKeypoint(e,a))),this._update(e,i),this._initNodes()}deactivate({hide:t=!0}={}){this._isActive=!1,this._cancelLastImages&&this._cancelLastImages(),this._cancelBatchPreload&&this._cancelBatchPreload(),t&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=C({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._container&&this._container.remove()},{once:!0})):this._container&&this._container.remove()}};var as=1,Ke=class extends b{initCallback(){super.initCallback(),this.addEventListener("wheel",t=>{t.preventDefault();let{deltaY:e,deltaX:i}=t;Math.abs(i)>as?this.scrollLeft+=i:this.scrollLeft+=e},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};Ke.template=" <slot></slot> ";function ls(r){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${r}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${r}" data-id="${r}" icon="${r}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${r}; title-prop: a11y-editor-tab-${r}" ></uc-btn-ui></uc-presence-toggle>`}function cs(r){return`<uc-presence-toggle id="tab_${r}" class="uc-tab-content" set="visible: presence.tabContent.${r}; 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-${r}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var Ye=class extends b{constructor(){super();f(this,"_updateInfoTooltip",A(()=>{var n,a;let e=this.$["*editorTransformations"],i=this.$["*currentOperation"],s="",o=!1;if(this.$["*tabId"]===y.FILTERS)if(o=!0,this.$["*currentFilter"]&&((n=e==null?void 0:e.filter)==null?void 0:n.name)===this.$["*currentFilter"]){let l=((a=e==null?void 0:e.filter)==null?void 0:a.amount)||100;s=this.$["*currentFilter"]+" "+l}else s=this.l10n(z);else if(this.$["*tabId"]===y.TUNING&&i){o=!0;let l=(e==null?void 0:e[i])||U[i].zero;s=this.l10n(i)+" "+l}o&&(this.$["*operationTooltip"]=s),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)},0));this.init$={...this.init$,"*sliderEl":null,"*listAspectRatioEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*showListAspectRatio":!1,hideSliderOrList:!1,"*currentFilter":z,"*currentOperation":null,showLoader:!1,filters:Kt,colorOperations:qt,cropOperations:Yt,"*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=>{var i;this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),(i=this._cancelPreload)==null||i.call(this),this.$["*on.cancel"]()},"on.apply":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"}),this.$["*on.apply"](this.$["*editorTransformations"])},"on.applySlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:le(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 i=e.currentTarget.getAttribute("data-id");i&&(this.telemetryManager.sendEventCloudImageEditor(e,i),this._activateTab(i,{fromViewer:!1}))},tab_role:"tab",[`tab_${y.TUNING}`]:`tab_${y.TUNING}`,[`tab_${y.CROP}`]:`tab_${y.CROP}`,[`tab_${y.FILTERS}`]:`tab_${y.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=A(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===y.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===y.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let i=new Ce;return i.operation=e,i}_createFilterControl(e){let i=new ce;return i.filter=e,i}_createToggleControl(e){let i=new be;return i.operation=e,i}_createAspectRatioConrol(e){let i=new ye;return i.aspectRatio=e,i}_createFreeformConrol(){return new ae}_clearListAspectRatio(){this.$["*listAspectRatioEl"].innerHTML=""}_renderControlsList(e){let i=this.ref[`controls-list-${e}`],s=document.createDocumentFragment();if(this._clearListAspectRatio(),e===y.CROP){let o=this.$["*cropPresetList"].length>=3;if(o){let n=this._createFreeformConrol();s.appendChild(n)}this.$["*cropPresetList"].forEach(n=>{let a=this._createAspectRatioConrol(n);s.appendChild(a),o&&this.$["*listAspectRatioEl"].appendChild(a)}),this.$.cropOperations.forEach(n=>{let a=this._createToggleControl(n);s.appendChild(a)})}else e===y.FILTERS?[z,...this.$.filters].forEach(o=>{let n=this._createFilterControl(o);s.appendChild(n)}):e===y.TUNING&&this.$.colorOperations.forEach(o=>{let n=this._createOperationControl(o);s.appendChild(n)});[...s.children].forEach((o,n)=>{n===s.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),i.innerHTML="",i.appendChild(s)}_activateTab(e,{fromViewer:i}){this.$["*tabId"]=e,e===y.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:i})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:i}),this.$["*cropperEl"].deactivate());for(let s of k){let o=s===e,n=this.ref[`tab-toggle-${s}`];n.active=o,o?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(s),this.$[`presence.tabContent.${s}`]=o}}_unmountTabControls(e){let i=this.ref[`controls-list-${e}`];i&&(i.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],i=this.ref["tabs-indicator"];i.style.transform=`translateX(${e.offsetLeft}px)`}async _preloadEditedImage(){var e;if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let i=this.$["*imgContainerEl"].offsetWidth,s=await this.proxyUrl(he(this.$["*originalUrl"],i,this.$["*editorTransformations"]));(e=this._cancelPreload)==null||e.call(this);let{cancel:o}=Ee([s]);this._cancelPreload=()=>{o(),this._cancelPreload=void 0}}}_showLoader(e){this.$.showLoader=e}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=>{var s;let i=(s=e==null?void 0:e.filter)==null?void 0:s.name;this.$["*currentFilter"]!==i&&(this.$["*currentFilter"]=i)}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",()=>{this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]&&this.$["*faderEl"].deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]&&this.$["*faderEl"].setTransformations(e)}),this.sub("*loadingOperations",e=>{let i=!1;for(let[,s]of e.entries()){if(i)break;for(let[,o]of s.entries())if(o){i=!0;break}}this._debouncedShowLoader(i)}),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 i of k){this.$[`presence.tabToggle.${i}`]=e.includes(i);let s=this.ref[`tab-toggle-${i}`];s.style.gridColumn=e.indexOf(i)+1}e.includes(this.$["*tabId"])||this._activateTab(e[0],{fromViewer:!1})}),this._updateInfoTooltip()}destroyCallback(){this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}};Ye.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">${k.map(cs).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> ${k.map(ls).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 Te=class extends b{constructor(){super(),this._iconReversed=!1,this._iconSingle=!1,this._iconHidden=!1,this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null,"aria-role":"","aria-controls":"","title-prop":""},this.defineAccessor("active",t=>{t?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return C("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",t=>{this._iconSingle=!this.$.text,this._iconHidden=!t,this.$.iconCss=this._iconCss()}),this.sub("theme",t=>{t!=="custom"&&(this.className=`uc-${t}`)}),this.sub("text",t=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",t=>{this.$["aria-role"]=t||""}),this.defineAccessor("aria-controls",t=>{this.$["aria-controls"]=t||""}),this.defineAccessor("title-prop",t=>{this.$["title-prop"]=t||""})}set reverse(t){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection=null)}};Te.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});Te.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 Ze=class extends b{constructor(){super(),this._active=!1,this._handleTransitionEndRight=()=>{let t=this.ref["line-el"];t.style.transition="initial",t.style.opacity="0",t.style.transform="translateX(-101%)",this._active&&this._start()}}initCallback(){super.initCallback(),this.defineAccessor("active",t=>{typeof t=="boolean"&&(t?this._start():this._stop())})}_start(){this._active=!0;let{width:t}=this.getBoundingClientRect(),e=this.ref["line-el"];e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};Ze.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var Je={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},Qe=class extends b{constructor(){super(),this._visible=!1,this._visibleStyle=Je.visible,this._hiddenStyle=Je.hidden,this._externalTransitions=!1,this.defineAccessor("styles",t=>{t&&(this._externalTransitions=!0,this._visibleStyle=t.visible,this._hiddenStyle=t.hidden)}),this.defineAccessor("visible",t=>{typeof t=="boolean"&&(this._visible=t,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",gi(this,{[Je.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(Je.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};Qe.template="<slot></slot> ";var et=class extends b{constructor(){super();f(this,"init$",{...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:null,"on.sliderInput":()=>{let e=parseInt(this.ref["input-el"].value,10);this._updateValue(e),this.$.onInput&&this.$.onInput(e)},"on.sliderChange":()=>{let e=parseInt(this.ref["input-el"].value,10);this.$.onChange&&this.$.onChange(e)}});this.setAttribute("with-effects","")}initCallback(){super.initCallback(),this.defineAccessor("disabled",i=>{this.$.disabled=i}),this.defineAccessor("min",i=>{this.$.min=i}),this.defineAccessor("max",i=>{this.$.max=i}),this.defineAccessor("defaultValue",i=>{this.$.defaultValue=i,this.ref["input-el"].value=i,this._updateValue(i)}),this.defineAccessor("zero",i=>{this._zero=i}),this.defineAccessor("onInput",i=>{i&&(this.$.onInput=i)}),this.defineAccessor("onChange",i=>{i&&(this.$.onChange=i)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)}),this._observer.observe(this),this._thumbSize=parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)},0),this.sub("disabled",i=>{let s=this.ref["input-el"];i?s.setAttribute("disabled","disabled"):s.removeAttribute("disabled")});let e=this.ref["input-el"];e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_updateValue(e){this._updateZeroDot(e);let{width:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(e-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this.ref["thumb-el"].style.transform=`translateX(${n}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;e===this._zero?this._zeroDotEl.style.opacity="0":this._zeroDotEl.style.opacity="1";let{width:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl.style.transform=`translateX(${n}px)`})}_updateSteps(){let i=this.ref["steps-el"],{width:s}=i.getBoundingClientRect(),o=Math.ceil(s/2),n=Math.ceil(o/15)-2;if(this._stepsCount===n)return;let a=document.createDocumentFragment(),l=document.createElement("div"),c=document.createElement("div");l.className="uc-minor-step",c.className="uc-border-step",a.appendChild(c);for(let h=0;h<n;h++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let h=0;h<n;h++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let u=document.createElement("div");u.className="uc-zero-dot",a.appendChild(u),this._zeroDotEl=u,i.innerHTML="",i.appendChild(a),this._stepsCount=n}destroyCallback(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};et.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 xe=class xe extends W{constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){var t;super.initCallback(),this.emit(dt.INIT_SOLUTION,void 0),(t=this.a11y)==null||t.registerBlock(this)}};f(xe,"styleAttrs",[...Mt(xe,xe,"styleAttrs"),"uc-wgt-common"]);var Ui=xe;var Ae=class extends b{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",t=>{if(!t)return;let e=`#uc-icon-${t}`;this.subConfigValue("iconHrefResolver",i=>{if(i){let s=i(t);e=s!=null?s:e}this.$.href=e})}),this.setAttribute("aria-hidden","true")}};Ae.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;Ae.bindAttributes({name:"name"});function hs(r){for(let t in r){let e=[...t].reduce((i,s)=>(s.toUpperCase()===s&&(s="-"+s.toLowerCase()),i+=s),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e="uc-"+e),r[t].reg&&r[t].reg(e)}}var tt=r=>{var t;return(t=r.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:t.map(e=>e.toLowerCase()).join("-")};var xt=Object.freeze({PHOTO:"photo",VIDEO:"video"}),Xl=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var w=r=>String(r),I=r=>{let t=Number(r);if(Number.isNaN(t))throw new Error(`Invalid number: "${r}"`);return t},v=r=>{if(typeof r=="undefined"||r===null)return!1;if(typeof r=="boolean")return r;if(r==="true"||r==="")return!0;if(r==="false")return!1;throw new Error(`Invalid boolean: "${r}"`)},Di=r=>r==="auto"?r:v(r),Fi=r=>{let t=w(r);if(t!=="user"&&t!=="environment"&&t!=="")throw new Error(`Invalid value: "${t}"`);return t},zi=r=>{let t=w(r);if(!Object.values(xt).includes(t))throw new Error(`Invalid value: "${t}"`);return t},ji=r=>{let t=w(r),e=Y(t);if(e.some(i=>!Object.values(xt).includes(i)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return t},Bi=r=>{if(typeof r=="object"&&!Array.isArray(r)||typeof r=="function")return r;throw new Error("Invalid metadata value. Must be an object or function.")},At=r=>{if(typeof r=="object")return r;throw new Error("Invalid value. Must be an object.")},it=r=>{if(typeof r=="function")return r;throw new Error("Invalid value. Must be a function.")},St=r=>{if(Array.isArray(r))return r;throw new Error("Must be an array.")},Vi=r=>{let t=w(r);if(["grid","list"].includes(t))return t;throw new Error(`Invalid value: "${t}"`)};var us={pubkey:w,multiple:v,multipleMin:I,multipleMax:I,confirmUpload:v,imgOnly:v,accept:w,externalSourcesPreferredTypes:w,externalSourcesEmbedCss:w,store:Di,cameraMirror:v,cameraCapture:Fi,sourceList:w,topLevelOrigin:w,maxLocalFileSizeBytes:I,thumbSize:I,showEmptyList:v,useLocalImageEditor:v,useCloudImageEditor:v,cloudImageEditorTabs:w,removeCopyright:v,cropPreset:w,imageShrink:w,modalScrollLock:v,modalBackdropStrokes:v,sourceListWrap:v,remoteTabSessionKey:w,cdnCname:w,cdnCnamePrefixed:w,baseUrl:w,socialBaseUrl:w,secureSignature:w,secureExpire:w,secureDeliveryProxy:w,retryThrottledRequestMaxTimes:I,retryNetworkErrorMaxTimes:I,multipartMinFileSize:I,multipartChunkSize:I,maxConcurrentRequests:I,multipartMaxConcurrentRequests:I,multipartMaxAttempts:I,checkForUrlDuplicates:v,saveUrlForRecurrentUploads:v,groupOutput:v,userAgentIntegration:w,debug:v,localeName:w,metadata:Bi,secureUploadsExpireThreshold:I,localeDefinitionOverride:At,secureUploadsSignatureResolver:it,secureDeliveryProxyUrlResolver:it,iconHrefResolver:it,fileValidators:St,collectionValidators:St,cameraModes:ji,defaultCameraMode:zi,enableAudioRecording:v,enableVideoRecording:v,mediaRecorderOptions:At,maxVideoRecordingDuration:I,filesViewMode:Vi,gridShowFileNames:v,cloudImageEditorAutoOpen:v,cloudImageEditorMaskHref:w,testMode:v,qualityInsights:v},Hi=(r,t)=>{if(!(typeof t=="undefined"||t===null))try{return us[r](t)}catch(e){return console.error(`Invalid value for config key "${r}".`,e),P[r]}};var Xi=new Set;function Gi(r){Xi.has(r)||(Xi.add(r),console.warn(r))}var ds=[{test:r=>r.accept&&!!r.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:r=>r.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:r=>r.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],Wi=A(r=>{for(let{test:t,message:e}of ds)t(r)&&Gi(e)},0);var qi=(r,t)=>{let e=new URL(t);return e.hostname=`${r}.${e.hostname}`,e.toString().replace(/\/$/,"")},fs="0123456789abcdefghijklmnopqrstuvwxyz",Ki=r=>{if(r<=BigInt(0))return"0";let t="";for(;r>BigInt(0);){let e=r%BigInt(36);t=fs[Number(e)]+t,r=r/BigInt(36)}return t},$t=(r,t)=>{try{let e=new URL(r),i=new URL(t);return e.hostname.endsWith(i.hostname)}catch{return!1}};var ps=async r=>{let t=new TextEncoder().encode(r),e=await window.crypto.subtle.digest("SHA-256",t),i=Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join("");return BigInt(`0x${i}`)},ms=10,_s=async r=>{let t=await ps(r);return Ki(t).slice(0,ms)},Yi=async(r,t)=>{let e=await _s(r);return qi(e,t)};var Zi=r=>r instanceof Promise||!!(r&&typeof r=="object"&&"then"in r&&typeof r.then=="function");var gs=[{key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:r,enableVideoRecording:t})=>{if(t===null)return r;let e=Y(r);return t&&!e.includes("video")?e=e.concat("video"):t||(e=e.filter(i=>i!=="video")),Z(e)}},{key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:r,defaultCameraMode:t})=>{if(t===null)return r;let e=Y(r);return e=e.sort((i,s)=>i===t?-1:s===t?1:0),Z(e)}},{key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:r,cdnCname:t,cdnCnamePrefixed:e})=>r&&(t===ut||$t(t,e))?Yi(r,e):t}],Ot=({key:r,setValue:t,getValue:e})=>{for(let i of gs)if(i.deps.includes(r)){let s={[i.key]:e(i.key),...i.deps.reduce((n,a)=>({...n,[a]:e(a)}),{})},o=i.fn(s);if(Zi(o)){let n=e(i.key);o.then(a=>{e(i.key)===n&&t(i.key,a)}).catch(a=>{console.error(`Failed to compute value for "${i.key}"`,a)})}else t(i.key,o)}};var kt=[...new Set(["debug",...Object.keys(P)])],bs=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],ys=r=>bs.includes(r),ue=kt.filter(r=>!ys(r)),ws={...Object.fromEntries(ue.map(r=>[tt(r),r])),...Object.fromEntries(ue.map(r=>[r.toLowerCase(),r]))},vs={...Object.fromEntries(ue.map(r=>[tt(r),S(r)])),...Object.fromEntries(ue.map(r=>[r.toLowerCase(),S(r)]))},Ji=r=>"__"+r,Se=class extends b{constructor(){super();f(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(P).map(([e,i])=>[S(e),i]))}}_flushValueToAttribute(e,i){if(ue.includes(e)){let s=[...new Set([tt(e),e.toLowerCase()])];for(let o of s)typeof i=="undefined"||i===null?this.removeAttribute(o):this.getAttribute(o)!==i.toString()&&this.setAttribute(o,i.toString())}}_flushValueToState(e,i){this.$[S(e)]!==i&&(typeof i=="undefined"||i===null?this.$[S(e)]=P[e]:this.$[S(e)]=i)}_setValue(e,i){let s=this,o=Hi(e,i),n=Ji(e);s[n]!==o&&(this._assertSameValueDifferentReference(e,s[n],o),s[n]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),Wi(this.cfg),Ot({key:e,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this)}))}_getValue(e){var o;let i=this,s=Ji(e);return(o=i[s])!=null?o:this.$[S(e)]}_assertSameValueDifferentReference(e,i,s){this.cfg.debug&&s!==i&&typeof s=="object"&&typeof i=="object"&&JSON.stringify(s)===JSON.stringify(i)&&(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:`,i),console.warn(`[uc-config] "${e}" new value:`,s))}initCallback(){var i;super.initCallback();let e=this;for(let s of ue)this.sub(S(s),o=>{this._setValue(s,o)},!1);for(let s of kt){let o=(i=e[s])!=null?i:this.$[S(s)];o!==P[s]&&this._setValue(s,o),Object.defineProperty(this,s,{set:n=>{this._setValue(s,n)},get:()=>this._getValue(s)}),Ot({key:s,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this)})}}attributeChangedCallback(e,i,s){if(i===s)return;let o=this,n=ws[e];o[n]=s}};Se.bindAttributes(vs);for(let r of kt)Se.prototype[r]=void 0;var Es=Se;export{Te as BtnUi,Ui as CloudImageEditor,W as CloudImageEditorBlock,Es as Config,Xe as CropFrame,ye as EditorAspectRatioButtonControl,be as EditorCropButtonControl,ce as EditorFilterControl,ae as EditorFreeformButtonControl,qe as EditorImageCropper,Tt as EditorImageFader,Ce as EditorOperationControl,Ke as EditorScroller,We as EditorSlider,Ye as EditorToolbar,Ae as Icon,Ze as LineLoaderUi,Qe as PresenceToggle,et as SliderUi,hs as defineComponents};
|