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