@uploadcare/file-uploader 1.30.0-alpha.6 → 1.30.0-alpha.7

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.
Files changed (66) hide show
  1. package/dist/abstract/loadFileUploaderFrom.js +2 -2
  2. package/dist/env.js +3 -3
  3. package/dist/index.css +2 -2
  4. package/dist/index.d.ts +1 -3
  5. package/dist/index.js +3 -3
  6. package/dist/index.layered.css +2 -2
  7. package/dist/index.ssr.js +1 -1
  8. package/dist/locales/file-uploader/ar.js +2 -2
  9. package/dist/locales/file-uploader/az.js +2 -2
  10. package/dist/locales/file-uploader/ca.js +2 -2
  11. package/dist/locales/file-uploader/cs.js +2 -2
  12. package/dist/locales/file-uploader/da.js +2 -2
  13. package/dist/locales/file-uploader/de.js +2 -2
  14. package/dist/locales/file-uploader/el.js +2 -2
  15. package/dist/locales/file-uploader/en.js +2 -2
  16. package/dist/locales/file-uploader/es.js +2 -2
  17. package/dist/locales/file-uploader/et.js +2 -2
  18. package/dist/locales/file-uploader/fi.js +2 -2
  19. package/dist/locales/file-uploader/fr.js +2 -2
  20. package/dist/locales/file-uploader/he.js +2 -2
  21. package/dist/locales/file-uploader/hy.js +2 -2
  22. package/dist/locales/file-uploader/is.js +2 -2
  23. package/dist/locales/file-uploader/it.js +2 -2
  24. package/dist/locales/file-uploader/ja.js +2 -2
  25. package/dist/locales/file-uploader/ka.js +2 -2
  26. package/dist/locales/file-uploader/kk.js +2 -2
  27. package/dist/locales/file-uploader/ko.js +2 -2
  28. package/dist/locales/file-uploader/lv.js +2 -2
  29. package/dist/locales/file-uploader/nb.js +2 -2
  30. package/dist/locales/file-uploader/nl.js +2 -2
  31. package/dist/locales/file-uploader/pl.js +2 -2
  32. package/dist/locales/file-uploader/pt.js +2 -2
  33. package/dist/locales/file-uploader/ro.js +2 -2
  34. package/dist/locales/file-uploader/ru.js +2 -2
  35. package/dist/locales/file-uploader/sk.js +2 -2
  36. package/dist/locales/file-uploader/sr.js +2 -2
  37. package/dist/locales/file-uploader/sv.js +2 -2
  38. package/dist/locales/file-uploader/tr.js +2 -2
  39. package/dist/locales/file-uploader/uk.js +2 -2
  40. package/dist/locales/file-uploader/vi.js +2 -2
  41. package/dist/locales/file-uploader/zh-TW.js +2 -2
  42. package/dist/locales/file-uploader/zh.js +2 -2
  43. package/package.json +1 -1
  44. package/web/file-uploader.iife.min.d.ts +1 -3
  45. package/web/file-uploader.iife.min.js +3 -3
  46. package/web/file-uploader.min.d.ts +1 -3
  47. package/web/file-uploader.min.js +3 -3
  48. package/web/uc-basic.layered.min.css +2 -2
  49. package/web/uc-basic.min.css +2 -2
  50. package/web/uc-cloud-image-editor.layered.min.css +2 -2
  51. package/web/uc-cloud-image-editor.min.css +2 -2
  52. package/web/uc-cloud-image-editor.min.d.ts +1 -3
  53. package/web/uc-cloud-image-editor.min.js +3 -3
  54. package/web/uc-file-uploader-inline.layered.min.css +2 -2
  55. package/web/uc-file-uploader-inline.min.css +2 -2
  56. package/web/uc-file-uploader-inline.min.d.ts +1 -3
  57. package/web/uc-file-uploader-inline.min.js +3 -3
  58. package/web/uc-file-uploader-minimal.layered.min.css +2 -2
  59. package/web/uc-file-uploader-minimal.min.css +2 -2
  60. package/web/uc-file-uploader-minimal.min.d.ts +1 -3
  61. package/web/uc-file-uploader-minimal.min.js +3 -3
  62. package/web/uc-file-uploader-regular.layered.min.css +2 -2
  63. package/web/uc-file-uploader-regular.min.css +2 -2
  64. package/web/uc-file-uploader-regular.min.d.ts +1 -3
  65. package/web/uc-file-uploader-regular.min.js +3 -3
  66. package/web/uc-img.min.js +3 -3
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {subscribeKeys,listenKeys,map}from'nanostores';import {html,LitElement,nothing}from'lit';import {createContext,ContextConsumer,ContextProvider}from'@lit/context';import {property,state}from'lit/decorators.js';import {uploadFile,CancelError,UploadcareError,Queue,uploadFileGroup,getUserAgent,UploadError,NetworkError}from'@uploadcare/upload-client';import {startKeyUX,focusGroupKeyUX,pressKeyUX,jumpKeyUX,hiddenKeyUX}from'keyux';import {TelemetryAPIService}from'@uploadcare/quality-insights';import {unsafeSVG}from'lit/directives/unsafe-svg.js';import {createRef,ref}from'lit/directives/ref.js';import {repeat}from'lit/directives/repeat.js';import {classMap}from'lit/directives/class-map.js';import {isPrefixedCdnBase,getPrefixedCdnBaseAsync}from'@uploadcare/cname-prefix/async';import {cache}from'lit/directives/cache.js';import {when}from'lit/directives/when.js';import {ifDefined}from'lit/directives/if-defined.js';import {styleMap}from'lit/directives/style-map.js';import {shrinkFile}from'@uploadcare/image-shrink';/**
2
2
  * @license
3
- * Package: @uploadcare/file-uploader@1.30.0-alpha.6 (MIT)
3
+ * Package: @uploadcare/file-uploader@1.30.0-alpha.7 (MIT)
4
4
  * License: https://github.com/uploadcare/blob/main/LICENSE
5
- * Built: 2026-05-08T00:44:37.746Z
5
+ * Built: 2026-05-11T20:37:59.449Z
6
6
  */
7
- var ho=Object.defineProperty;var On=Object.getOwnPropertyDescriptor;var mo=(o,r)=>{for(var e in r)ho(o,e,{get:r[e],enumerable:true});};var d=(o,r,e,t)=>{for(var i=t>1?void 0:t?On(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&ho(r,e,i),i};var R=class o{static{this._contexts=new Map;}constructor(r,e){this._ctxId=r,this._store=e;}get id(){return this._ctxId}pub(r,e){r in this._store.get()||console.warn(`PubSub#pub: Key "${String(r)}" not found`),this._store.setKey(r,e);}sub(r,e,t=true){return (t?subscribeKeys:listenKeys)(this._store,[r],s=>{e(s[r]);})}read(r){return r in this._store.get()||console.warn(`PubSub#read: Key "${String(r)}" not found`),this._store.get()[r]}add(r,e,t=false){(!(r in this._store.get())||t)&&this._store.setKey(r,e);}has(r){return r in this._store.get()}get store(){return this._store.get()}static registerCtx(r,e){if(o._contexts.has(e))throw new Error(`PubSub: Context with id "${e}" already exists`);let t=map(r);return o._contexts.set(e,t),new o(e,t)}static deleteCtx(r){o._contexts.delete(r);}static getCtx(r){let e=o._contexts.get(r);return e?new o(r,e):null}static hasCtx(r){return o._contexts.has(r)}};var Vn=/\\([0-9a-fA-F]{1,6} ?)/g;function $n(o){return o.length<2?false:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function Dn(o){let r=o;return (r[0]==='"'||r[0]==="'")&&(r=r.slice(1)),(r[r.length-1]==='"'||r[r.length-1]==="'")&&(r=r.slice(0,-1)),r}function Fn(o){let r="",e="";for(let t=0;t<o.length;t++){let i=o[t+1];o[t]==="\\"&&i==='"'?(r+='\\"',t++):o[t]==='"'&&e!=="\\"?r+='\\"':r+=o[t],e=o[t]??"";}return r}function fo(o){let r=o;$n(o)&&(r=Dn(r),r=r.replace(Vn,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),r=r.replaceAll(`\\ `,"\\n"),r=Fn(r),r='"'+r+'"');try{return JSON.parse(r)}catch{return}}function We(o){class r extends o{constructor(){super(...arguments);this._cssDataCache=null;this._computedStyle=null;}getCssData(i,s=false){let n=this._cssDataCache??Object.create(null);if(!Object.keys(n).includes(i)||!n[i]){this._computedStyle||(this._computedStyle=window.getComputedStyle(this));let a=this._computedStyle.getPropertyValue(i).trim();try{n[i]=fo(a);}catch(l){s||console.warn(`CSS Data error: ${i}`,l),n[i]=null;}}return this._cssDataCache=n,n[i]}}return r}function Yt(o){class r extends o{constructor(){super(...arguments);this.willYield=true;this._slotsMap={};this._initialLightDomChildren=null;this._hasAdoptedChildren=false;}createRenderRoot(){return this}connectedCallback(){this._initialLightDomChildren||(this._initialLightDomChildren=Array.from(this.childNodes)),super.connectedCallback();}_adoptChildren(){if(this._hasAdoptedChildren)return;this._hasAdoptedChildren=true,this._slotsMap={};let i=Array.from(this.childNodes),s=i.length?i:this._initialLightDomChildren??[];for(let n of s){let a=this._getSlotNameForChild(n),l=this._slotsMap[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this._slotsMap[a]=l;}this._initialLightDomChildren=null;}_getSlotNameForChild(i){return i instanceof Comment&&i.nextSibling instanceof Element?this._getSlotNameForChild(i.nextSibling):"contentFor"in i?i.contentFor||"":i instanceof Element&&i.hasAttribute("content-for")&&i.getAttribute("content-for")||""}_isTextNodeEmpty(i){return !i.textContent||!i.textContent.trim()}_isSlotEmpty(i){let s=this._slotsMap[i];return !s||s.every(n=>n instanceof Comment||n instanceof Text&&this._isTextNodeEmpty(n))}update(i){!this.hasUpdated&&this.willYield&&this._adoptChildren(),super.update(i);}yield(i,s){if(i===""&&!this._slotsMap[i]&&!this._hasAdoptedChildren&&this._initialLightDomChildren?.length){let a=[];for(let l of this._initialLightDomChildren)l instanceof Element&&(l.removeAttribute("slot"),l.removeAttribute("content-for")),a.push(l);this._slotsMap[i]=a,this._hasAdoptedChildren=true,this._initialLightDomChildren=null;}let n=this._slotsMap[i];return html` ${n} ${this._isSlotEmpty(i)?s:void 0} `}}return r}function qe(o){class r extends o{static reg(t){let i=this,s=window.customElements.get(t);if(s){s!==i&&console.warn([`Element with tag name "${t}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(` `));return}window.customElements.define(t,i);}}return r}function S(o,r){let e,t=((...i)=>{e&&clearTimeout(e),e=setTimeout(()=>o(...i),r);});return t.cancel=()=>{e&&clearTimeout(e);},t}var go=createContext("ctx-name-context");function Xt(){return function(o){class r extends o{constructor(...i){super(...i);this._symbioteSharedPubSub=null;this._symbioteFirstUpdated=false;this._needsReconnectInit=false;this._ctxNameProvider=void 0;this._pendingSharedAdds=new Map;this._symbioteSubscriptions=new Set;this.init$={};this.ctxOwner=false;this._ctxNameAttrValue=void 0;this._pendingCtxInitOnConnect=false;this.ctxName=this._effectiveCtxName;this._isInitialized=false;this._ctxNameAttrValue=this.getAttribute("ctx-name")||void 0,this.ctxName=this._effectiveCtxName,this._ctxNameConsumer=new ContextConsumer(this,{context:go,callback:s=>{if(!s){console.error("SymbioteMixin: Received invalid ctx-name from context");return}this._ctxNameFromContext=s,this._handleCtxNameSourceChange();},subscribe:true});}static set template(i){console.error("Caution: static 'template' property is deprecated and has no effect. See https://github.com/uploadcare/file-uploader/releases/tag/v1.25.0 for details.");}get _ctxNameAttr(){return this._ctxNameAttrValue}set _ctxNameAttr(i){let s=i??void 0;this._ctxNameAttrValue!==s&&(this._ctxNameAttrValue=s,this._handleCtxNameSourceChange());}shouldUpdate(i){return this._isInitialized?super.shouldUpdate(i):false}get _effectiveCtxName(){return this._ctxNameAttr||this._ctxNameFromContext||void 0}_handleCtxNameSourceChange(){if(this.ctxName=this._effectiveCtxName,!(!this.ctxName||this._symbioteFirstUpdated)){if(this.isConnected){this._performInitialization();return}this._pendingCtxInitOnConnect=true;}}willUpdate(i){super.willUpdate(i),this.ctxName=this._effectiveCtxName,this.ctxName&&(this._ctxNameProvider?this._ctxNameProvider.setValue(this.ctxName):this._ctxNameProvider=new ContextProvider(this,{context:go,initialValue:this.ctxName}));}_applyPendingSharedAdds(){if(!(!this._symbioteSharedPubSub||this._pendingSharedAdds.size===0)){for(let[i,{value:s,rewrite:n}]of this._pendingSharedAdds)this._symbioteSharedPubSub.add(i,s,n);this._pendingSharedAdds.clear();}}_getSharedPubSub(){return !this._symbioteSharedPubSub&&this._effectiveCtxName&&this._initSharedContext(),this._symbioteSharedPubSub&&this._applyPendingSharedAdds(),this._symbioteSharedPubSub}_requireSharedPubSub(){let i=this._getSharedPubSub();if(!i)throw new Error("SymbioteMixin: Shared context is not initialized.");return i}_initSharedContext(){let i=this.init$,s=this._effectiveCtxName;if(!s){console.error("SymbioteMixin: ctx-name is required for components with shared properties (*)");return}if(!this._symbioteSharedPubSub){this._symbioteSharedPubSub=R.getCtx(s)??R.registerCtx(i,s);for(let[n,a]of Object.entries(this.init$))this._symbioteSharedPubSub.add(n,a,this.ctxOwner);this._applyPendingSharedAdds();}}get $(){return this._effectiveCtxName&&this._initSharedContext(),new Proxy({},{get:(i,s)=>{if(typeof s=="string")return this._symbioteSharedPubSub?.read(s)},set:(i,s,n)=>(typeof s!="string"||this._symbioteSharedPubSub?.pub(s,n),true)})}sub(i,s,n=true){let a=this._requireSharedPubSub().sub(i,s,n);if(!a||typeof a!="function")return ()=>{};let l=a.bind(a),c=false,u=()=>{c||(c=true,l(),this._symbioteSubscriptions.delete(u));};return this._symbioteSubscriptions.add(u),u}pub(i,s){this._requireSharedPubSub().pub(i,s);}set$(i){for(let[s,n]of Object.entries(i))this.pub(s,n);}get sharedCtx(){return this._requireSharedPubSub()}has(i){return this._symbioteSharedPubSub?.has(i)??false}add(i,s,n=false){let a=this._getSharedPubSub();if(!a){if(!n&&this._pendingSharedAdds.has(i))return;this._pendingSharedAdds.set(i,{value:s,rewrite:n});return}this._pendingSharedAdds.delete(i),a.add(i,s,n);}add$(i,s=false){for(let[n,a]of Object.entries(i))this.add(n,a,s);}connectedCallback(){super.connectedCallback(),this._symbioteFirstUpdated?this._isInitialized&&this._needsReconnectInit&&(this._needsReconnectInit=false,this.initCallback()):this.ctxName?(this._pendingCtxInitOnConnect=false,this._performInitialization()):this._pendingCtxInitOnConnect&&this._effectiveCtxName&&(this._pendingCtxInitOnConnect=false,this._performInitialization());}_performInitialization(){if(this._symbioteFirstUpdated)return;this._symbioteFirstUpdated=true,this._initSharedContext();let i=this.init$;if(Object.keys(i).length>0){let s=this._requireSharedPubSub();for(let[n,a]of Object.entries(i))s.read(n)===void 0&&s.pub(n,a),this.sub(n,S(async()=>{this.isConnected&&(await this.updateComplete,this.requestUpdate());},0),false);}this.initCallback(),this._isInitialized=true,this.requestUpdate();}firstUpdated(i){super.firstUpdated(i);}disconnectedCallback(){this._cleanupSymbioteSubscriptions(),super.disconnectedCallback(),this._symbioteFirstUpdated&&(this._needsReconnectInit=true);}_cleanupSymbioteSubscriptions(){if(this._symbioteSubscriptions.size!==0){for(let i of [...this._symbioteSubscriptions])i();this._symbioteSubscriptions.clear();}}initCallback(){}}return d([property({type:String,attribute:"ctx-name",noAccessor:true})],r.prototype,"_ctxNameAttr",1),d([state()],r.prototype,"_ctxNameFromContext",2),d([state()],r.prototype,"ctxName",2),d([state()],r.prototype,"_isInitialized",2),r}}var or=class extends qe(Xt()(We(Yt(LitElement)))){};var W=class o{static generateFastUid(){return `uid-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}static generateRandomUUID(){let r=globalThis.crypto;return r&&typeof r.randomUUID=="function"?r.randomUUID():o.generateFastUid()}};var Gn=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function ie(o){for(let r in o){if(Gn.includes(r))continue;let e=[...r].reduce((t,i)=>(i.toUpperCase()===i&&(i=`-${i.toLowerCase()}`),t+=i,t),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),o[r].reg&&o[r].reg(e);}}var sr="UC";function Wn(o,r=false){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[sr]){e(window[sr]);return}let i=document.createElement("script");i.async=true,i.src=o,i.onerror=()=>{t();},i.onload=()=>{let s=window[sr];r&&ie(s),e(s);},document.head.appendChild(i);})}var bt={"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","drop-file-here":"Drop file 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-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-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop","upload-from":"Upload {{source}}","get-from":"Get from {{source}}","capture-with":"Capture with {{source}}",take:"Take {{source}}",record:"Record {{source}}",retake:"Retake",accept:"Accept"};var nr=new Map,vo=new Map,bo=(o,r)=>{nr.has(o)&&console.log(`Locale ${o} is already defined. Overwriting...`);let e={...bt,...r};return nr.set(o,e),e},qn=(o,r)=>{vo.set(o,r);},yo=(o,r)=>{typeof r=="function"?qn(o,r):bo(o,r);},_o=async o=>{let r=nr.get(o);if(!r){let e=vo.get(o);if(!e)throw new Error(`Locale ${o} is not defined`);let t=await e();r=bo(o,t);}return r};yo("en",bt);var v=o=>`*cfg/${o}`;var V=o=>o?o.split(",").map(r=>r.trim()).filter(Boolean):[],_e=o=>o.join(",");var Co=o=>{if(typeof o!="string"||!o)return "";let r=o.trim();return r.startsWith("-/")?r=r.slice(2):r.startsWith("/")&&(r=r.slice(1)),r.endsWith("/")&&(r=r.slice(0,r.length-1)),r},Qt=(...o)=>o.filter(r=>typeof r=="string"&&!!r).map(r=>Co(r)).join("/-/"),q=(...o)=>{let r=Qt(...o);return r?`-/${r}/`:""};function Jt(o){let r=new URL(o),e=r.pathname+r.search+r.hash,t=e.lastIndexOf("http"),i=e.lastIndexOf("/"),s="";return t>=0?s=e.slice(t):i>=0&&(s=e.slice(i+1)),s}function ei(o){let r=new URL(o),{pathname:e}=r,t=e.indexOf("/"),i=e.indexOf("/",t+1);return e.substring(t+1,i)}function ar(o){let r=wo(o),e=new URL(r),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}function lr(o){return ar(o).split("/-/").filter(Boolean).map(e=>Co(e))}function wo(o){let r=new URL(o),e=Jt(o),t=To(e)?Eo(e).pathname:e;return r.pathname=r.pathname.replace(t,""),r.search="",r.hash="",r.toString()}function To(o){return o.startsWith("http")}function Eo(o){let r=new URL(o);return {pathname:`${r.origin}${r.pathname??""}`,search:r.search??"",hash:r.hash??""}}var F=(o,r,e)=>{let t=new URL(wo(o)),i=e??Jt(o),s=r??"";if(t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),i&&To(i)){let n=Eo(i);t.pathname=`${t.pathname}${s}${n.pathname||""}`,t.search=n.search,t.hash=n.hash;}else t.pathname=`${t.pathname}${s}${i||""}`;return t.toString()},Ae=(o,r)=>{let e=new URL(o);return e.pathname=`${r}/`,e.toString()};var N=(o,r=",")=>o.trim().split(r).map(e=>e.trim()).filter(e=>e.length>0);var yt=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:false,flip:false,crop:void 0}),So=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Zn(o,r){if(typeof r=="number"){let e=r;return yt[o]!==e?`${o}/${e}`:""}if(typeof r=="boolean"){let e=r;return yt[o]!==e?`${o}`:""}if(o==="filter"&&r){let{name:e,amount:t}=r;return yt.filter===t?"":`${o}/${e}/${t}`}if(o==="crop"&&r){let{dimensions:e,coords:t}=r;return `${o}/${e.join("x")}/${t.join(",")}`}return ""}function ke(o){return Qt(...So.filter(r=>typeof o[r]<"u"&&o[r]!==null).map(r=>{let e=o[r];return Zn(r,e)}).filter(r=>!!r))}var ti=Qt("format/auto","progressive/yes"),Ce=([o])=>typeof o<"u"?Number(o):void 0,xo=()=>true,Yn=([o,r])=>({name:o,amount:typeof r<"u"?Number(r):100}),Xn=([o,r])=>{if(!/\d+x\d+/.test(o)||!/\d+,\d+/.test(r))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return {dimensions:N(o,"x").map(Number),coords:N(r).map(Number)}},Qn=Object.freeze({enhance:Ce,brightness:Ce,exposure:Ce,gamma:Ce,contrast:Ce,saturation:Ce,vibrance:Ce,warmth:Ce,filter:Yn,mirror:xo,flip:xo,rotate:Ce,crop:o=>{let[r,e]=o,{dimensions:t,coords:i}=Xn([r,e]);return {dimensions:t,coords:i}}});function cr(o){let r={};for(let e of o){let[t,...i]=e.split("/");if(!t||!So.includes(t))continue;let s=t,n=Qn[s];try{let a=n(i);r[s]=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(` `));}}return r}var O=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),Z=Object.freeze([O.CROP,O.TUNING,O.FILTERS]),Io=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Ao=Object.freeze(["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"]),ko=Object.freeze(["rotate","mirror","flip"]),we=yt,ce=Object.freeze({brightness:{zero:we.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:we.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:we.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:we.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:we.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:we.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:we.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:we.enhance,range:[0,100],keypointsNumber:1},filter:{zero:we.filter,range:[0,100],keypointsNumber:1}});var _t="https://ucarecdn.com",Jn="https://upload.uploadcare.com",ea="https://social.uploadcare.com",ta="https://ucarecd.net",ia={pubkey:"",multiple:true,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:false,imgOnly:false,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:false,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:false,useLocalImageEditor:false,removeCopyright:false,cropPreset:"",imageShrink:"",modalScrollLock:true,modalBackdropStrokes:false,sourceListWrap:true,remoteTabSessionKey:"",cdnCname:_t,cdnCnamePrefixed:ta,baseUrl:Jn,socialBaseUrl:ea,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:3,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:false,saveUrlForRecurrentUploads:false,groupOutput:false,userAgentIntegration:"",debug:false,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:true,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:false,useCloudImageEditor:true,cloudImageEditorAutoOpen:false,cloudImageEditorTabs:_e(Z),cloudImageEditorMaskHref:null,testMode:false,qualityInsights:true,pasteScope:"local",plugins:[],smartButtonViewMode:"auto",smartButtonShowFirstIcon:true},z=Object.freeze(ia);var ii=(o,r)=>(...e)=>{let t=o();if(!t.read(v("debug")))return;let i=e;if(typeof e?.[0]=="function"){let n=e[0];i=n();}let s=[t.id,r].filter(Boolean);console.log(`[${s.join("][")}]`,...i);};var U=class{constructor(r){this._subscriptions=new Set;this._cfgProxy=null;this._debugPrint=ii(()=>this._sharedInstancesBag.ctx,this.constructor.name);this._sharedInstancesBag=r,this._ctx=r.ctx;}addSub(r){this._subscriptions.add(r);}get _cfg(){if(!this._cfgProxy){let r={};this._cfgProxy=new Proxy(r,{set:()=>{throw new Error("SharedInstance cfg proxy is read-only")},get:(e,t)=>{if(typeof t!="string")return;let i=v(t);return this._sharedInstancesBag.ctx.has(i)?this._sharedInstancesBag.ctx.read(i):z[t]}});}return this._cfgProxy}destroy(){for(let r of this._subscriptions)try{r();}catch{}this._subscriptions.clear();}},ra={modalManager:"*modalManager",pluginManager:"*pluginManager",telemetryManager:"*telemetryManager",localeManager:"*localeManager",a11y:"*a11y",clipboard:"*clipboard",routerLayer:"*routerLayer",blocksRegistry:"*blocksRegistry",eventEmitter:"*eventEmitter",uploadCollection:"*uploadCollection",secureUploadsManager:"*secureUploadsManager",api:"*publicApi",validationManager:"*validationManager"},ne=(o,r,e=true)=>{let t=o.has(r),i=t?o.read(r):null;if(t&&i||!e)return i;throw new Error(`Unexpected error: shared instance for key "${String(r)}" is not available`)},Mo=o=>({get ctx(){return o()},get modalManager(){return ne(o(),"*modalManager",false)},get pluginManager(){return ne(o(),"*pluginManager")},get telemetryManager(){return ne(o(),"*telemetryManager")},get localeManager(){return ne(o(),"*localeManager")},get a11y(){return ne(o(),"*a11y")},get routerLayer(){return ne(o(),"*routerLayer")},get blocksRegistry(){return ne(o(),"*blocksRegistry")},get eventEmitter(){return ne(o(),"*eventEmitter")},get uploadCollection(){return ne(o(),"*uploadCollection")},get secureUploadsManager(){return ne(o(),"*secureUploadsManager",false)},get api(){return ne(o(),"*publicApi")},get validationManager(){return ne(o(),"*validationManager")},when(r,e){let t=ra[r],i=o(),s=i.has(t)?i.read(t):void 0;if(s)return e(s),()=>{};let n;return n=i.sub(t,a=>{a&&(e(a),n?.());}),n},wait(r){return new Promise(e=>{let t;t=this.when(r,i=>{e(i),t?.();});})}});var B=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),ri=class extends U{constructor(){super(...arguments);this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;}registerModal(e,t){this._modals.set(e,t),this._notify(B.ADD,{id:e,modal:t});}deleteModal(e){let t=this._modals.get(e);return t?(this._modals.delete(e),this._activeModals.delete(e),this._notify(B.DELETE,{id:e,modal:t}),true):false}open(e){let t=this._modals.get(e);return t?(this._activeModals.add(e),this._notify(B.OPEN,{modal:t,id:e}),true):(this._debugPrint(`Modal with ID "${e}" not found`),false)}close(e){let t=this._modals.get(e);return !t||!this._activeModals.has(e)?(this._debugPrint(`Modal with ID "${e}" not found or not active`),false):(this._activeModals.delete(e),this._notify(B.CLOSE,{id:e,modal:t}),true)}toggle(e){return this._modals.has(e)?this._activeModals.has(e)?this.close(e):this.open(e):(this._debugPrint(`Modal with ID "${e}" not found`),false)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),false;let e=Array.from(this._activeModals).pop();return e?this.close(e):false}closeAll(){let e=this._activeModals.size;return this._activeModals.clear(),this._notify(B.CLOSE_ALL,{}),e}subscribe(e,t){return this._subscribers.has(e)||this._subscribers.set(e,new Set),this._subscribers.get(e)?.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){this._subscribers.has(e)&&this._subscribers.get(e)?.delete(t);}_notify(e,t){if(this._subscribers.has(e))for(let i of this._subscribers.get(e)??new Set)try{i(t);}catch(s){this._sharedInstancesBag.telemetryManager.sendEventError(s,"modal subscriber"),this._debugPrint("Error in modal subscriber:",s);}}destroy(){super.destroy(),this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(B.DESTROY,{});}};var oi=o=>o.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(r=>r.toLowerCase()).join("-");var dr=()=>({}),ur=o=>({...dr(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{o.modalManager?.close(o.$["*currentActivity"]),o.pub("*currentActivity",null);}}),pr=o=>({...ur(o),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new Queue(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set}),Po=o=>({...pr(o),"*solution":null,"*lazyPlugins":null});var si=class extends U{constructor(e){super(e);this.scopes=new Set;this.listener=this._listener.bind(this),window.addEventListener("paste",this.listener);}_excludingNodes(e){return !!e.closest("uc-url-source")}openUploadList(){this._sharedInstancesBag.routerLayer.navigateAfterFileAdd();}async _listener(e){if(e.clipboardData){for(let t of this.scopes)if(t.isConnected){if(this._excludingNodes(e.target))return;switch(this._cfg.pasteScope){case "global":await this.handlePaste(e);break;case "local":if(!t.contains(e.target))continue;await this.handlePaste(e);break;default:continue}}}}async handlePaste(e){if(!e.clipboardData)return;let t=Array.from(e.clipboardData.items),i=t.map(n=>n.getAsFile()).filter(n=>n!==null),s=t.filter(n=>n.kind==="string"&&n.type==="text/plain").map(n=>new Promise(a=>{n.getAsString(l=>{a(l);});}));i.length>0&&(i.forEach(n=>{this._sharedInstancesBag.api.addFileFromObject(n,{source:"clipboard"});}),this.openUploadList()),s.length>0&&((await Promise.all(s)).forEach(a=>{this._sharedInstancesBag.api.addFileFromUrl(a,{source:"clipboard"});}),this.openUploadList());}registerBlock(e){return this.scopes.add(e),()=>{this.scopes.delete(e);}}destroy(){super.destroy(),window.removeEventListener("paste",this.listener),this.scopes.clear();}};var A=Object.freeze({START_FROM:"start-from",CAMERA:"camera",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var ni=class extends U{constructor(){super(...arguments);this._afterFileAddHooks=[];}registerAfterFileAddHook(e){return this._afterFileAddHooks.push(e),()=>{this._afterFileAddHooks=this._afterFileAddHooks.filter(t=>t!==e);}}navigateAfterFileAdd(){let t={historyLength:this._sharedInstancesBag.ctx.read("*history").length};this._afterFileAddHooks.some(s=>s(t))||(this._sharedInstancesBag.ctx.pub("*currentActivity",A.UPLOAD_LIST),this._sharedInstancesBag.modalManager?.open(A.UPLOAD_LIST));}};var hr=class{constructor(){this._listeners=new Map;this._scope=[];}addEventListener(r,e){let t=i=>{let s=i.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&e(i);};this._listeners.set(e,t),window.addEventListener(r,t);}removeEventListener(r,e){let t=this._listeners.get(e);t&&window.removeEventListener(r,t),this._listeners.delete(e);}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(r){this._scope.push(r);}destroy(){this._scope=[];for(let r of this._listeners.values())window.removeEventListener("keydown",r),window.removeEventListener("keyup",r);this._listeners.clear();}},ai=class{constructor(){this._scopedWindow=new hr,this._destroyKeyUX=startKeyUX(this._scopedWindow,[focusGroupKeyUX(),pressKeyUX("is-pressed"),jumpKeyUX(),hiddenKeyUX()]);}registerBlock(r){this._scopedWindow.registerScope(r);}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy();}};var Te=o=>`*l10n/${o}`,da="en",li=class extends U{constructor(e){super(e);this._localeName="";for(let[i,s]of Object.entries(bt)){let n=this._ctx.has(Te(i))?!this._ctx.read(Te(i)):true;this._ctx.add(Te(i),s,n);}let t=e.pluginManager;t?.onPluginsChange&&this.addSub(t.onPluginsChange(()=>{this._localeName&&this._applyPluginLocales(this._localeName);})),this.addSub(this._ctx.sub(v("localeName"),async i=>{if(!i)return;this._localeName=i;let s=await _o(i);i!==da&&this._localeName!==i||(this._applyPluginLocales(i),this._applyOverrides(i,s));})),this.addSub(this._ctx.sub(v("localeDefinitionOverride"),i=>{if(!i)return;let s=i[this._localeName];s&&this._applyOverrides(this._localeName,s);}));}_applyOverrides(e,t){let i=this._cfg.localeDefinitionOverride?.[e];for(let[s,n]of Object.entries(t)){let a=i?.[s];this._ctx.add(Te(s),a??n,true);}}_applyPluginLocales(e){let t=this._sharedInstancesBag.pluginManager;if(!t)return;let i=t.snapshot();for(let s of i.l10n){let{pluginId:n,...a}=s,l=a[e];if(l)for(let[c,u]of Object.entries(l))u!==void 0&&this._ctx.add(Te(c),u,true);}}};var ua=()=>{let o=navigator.userAgent;return /Macintosh|Windows/.test(o)&&/Version\/[\d.]+.*Safari/.test(o)&&!/Chrome|Chromium|Edg|OPR/.test(o)},pa=()=>"capture"in document.createElement("input"),ha=()=>({safariDesktop:ua()}),ma=()=>({htmlMediaCapture:pa()}),Oo=ha(),Lo=ma();var Ct="image/*",mr="video/*",fa=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],ga=()=>Oo.safariDesktop?[Ct]:[Ct,...fa],wt=ga(),ci=o=>o?o.filter(r=>typeof r=="string").flatMap(r=>N(r)):[],fr=(o,r)=>r.some(e=>{if(e.endsWith("*")){let t=e.replace("*","");return o.startsWith(t)}return o===e}),Ro=(o,r)=>r.some(e=>e.startsWith(".")?o.toLowerCase().endsWith(e.toLowerCase()):false),Ze=o=>{let r=o?.type;return r?fr(r,wt):false};function Uo(o,r,e,t,i){return {registry:{registerSource:c=>o.addSource(t,c),registerActivity:c=>o.addActivity(t,c),registerFileAction:c=>o.addFileAction(t,c),registerFileHook:c=>o.addFileHook(t,c),registerIcon:c=>o.addIcon(t,c),registerL10n:c=>o.addL10n(t,c),registerConfig:c=>{o.addConfig(t,c);let u=v(c.name);r.has(u)||r.add(u,c.defaultValue);}},config:{get:c=>{let u=v(c);return r.read(u)},subscribe:(c,u)=>{let p=v(c),m=r.sub(p,h=>{u(h);});return i.push(m),m}},activity:{getParams:()=>r.read("*currentActivityParams"),subscribeToParams:c=>{let u=r.sub("*currentActivityParams",p=>{c(p);});return i.push(u),u}},files:{update:(c,u)=>{let p=e.uploadCollection?.read(c);p&&(u.file!==void 0&&(p.setValue("file",u.file),p.setValue("fileSize",u.file.size)),u.cdnUrl!==void 0&&p.setValue("cdnUrl",u.cdnUrl),u.cdnUrlModifiers!==void 0&&p.setValue("cdnUrlModifiers",u.cdnUrlModifiers),u.mimeType!==void 0&&p.setValue("mimeType",u.mimeType));}}}}var va=async({entries:o,signal:r})=>(await Promise.all(o.map(async t=>{if(t.isEnabled())try{let i=await t.load();return r.aborted||!t.isEnabled()?void 0:i??void 0}catch(i){r.aborted||console.warn("Failed to load lazy plugin",i);return}}))).filter(t=>t!==void 0),di=class{constructor(r,e){this._ctx=r;this._onCompute=e;this._subs=new Set;this._unsubLazyPlugins=this._ctx.sub("*lazyPlugins",t=>{this._setEntries(t??[]);});}_setEntries(r){for(let i of this._subs)i();if(this._subs.clear(),r.length===0)return;let e=new Set([v("plugins")]);for(let i of r)for(let s of i.configDeps)e.add(v(s));let t=()=>this._compute(r);for(let i of e)this._subs.add(this._ctx.sub(i,t,false));this._compute(r);}_compute(r){this._abortController?.abort();let e=new AbortController;this._abortController=e;let t=n=>this._ctx.read(v(n)),i=t("plugins"),s=va({entries:r.map(n=>({isEnabled:()=>n.isEnabled(t),load:n.load})),signal:e.signal}).then(n=>{if(!e.signal.aborted)return [...i,...n]});this._onCompute(s);}destroy(){this._unsubLazyPlugins();for(let r of this._subs)r();this._subs.clear(),this._abortController?.abort();}};var ui=class{constructor(){this._definitions=new Map;}register(r,e){if(this._definitions.has(e.name)){console.warn(`[CustomConfig] Config option "${e.name}" is already registered`);return}let t={attribute:true,...e,pluginId:r};this._definitions.set(e.name,t);}unregister(r){this._definitions.delete(r);}unregisterByPlugin(r){for(let[e,t]of this._definitions)t.pluginId===r&&this._definitions.delete(e);}get(r){return this._definitions.get(r)}getAll(){return new Map(this._definitions)}};var pi=class{constructor(){this._sources=[];this._activities=[];this._fileActions=[];this._fileHooks=[];this._icons=[];this._l10n=[];this.config=new ui;}_own(r,e){return {...e,pluginId:r}}addSource(r,e){let t=this._sources.find(i=>i.id===e.id);if(t){console.warn(`[Plugin "${r}"] Source with id "${e.id}" is already registered by plugin "${t.pluginId}". Skipping.`);return}this._sources.push(this._own(r,e));}addActivity(r,e){let t=this._activities.find(i=>i.id===e.id);if(t){console.warn(`[Plugin "${r}"] Activity with id "${e.id}" is already registered by plugin "${t.pluginId}". Skipping.`);return}this._activities.push(this._own(r,e));}addFileAction(r,e){this._fileActions.push(this._own(r,e));}addFileHook(r,e){this._fileHooks.push(this._own(r,{timeout:3e4,...e}));}addIcon(r,e){this._icons.push(this._own(r,e));}addL10n(r,e){this._l10n.push(this._own(r,e));}addConfig(r,e){this.config.register(r,e);}purge(r){this._sources=this._sources.filter(e=>e.pluginId!==r),this._activities=this._activities.filter(e=>e.pluginId!==r),this._fileActions=this._fileActions.filter(e=>e.pluginId!==r),this._fileHooks=this._fileHooks.filter(e=>e.pluginId!==r),this._icons=this._icons.filter(e=>e.pluginId!==r),this._l10n=this._l10n.filter(e=>e.pluginId!==r),this.config.unregisterByPlugin(r);}snapshot(){return {sources:[...this._sources],activities:[...this._activities],fileActions:[...this._fileActions],fileHooks:[...this._fileHooks],icons:[...this._icons],l10n:[...this._l10n]}}};var hi=class extends U{constructor(e){super(e);this._plugins=new Map;this._subscribers=new Set;this._pluginsUpdate=Promise.resolve();this.registry=new pi;this._lazyPluginLoader=new di(this._ctx,t=>{this._pluginsUpdate=this._pluginsUpdate.then(()=>t).then(i=>{if(i)return this._syncPlugins(i)});});}get configRegistry(){return this.registry.config}pluginsReady(){return this._pluginsUpdate}onPluginsChange(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e);}}async _syncPlugins(e){let t=new Set(this._plugins.keys()),i=new Set;for(let s of e){if(!s.id){console.warn('[PluginManager] A plugin is missing the required "id" field, skipping');continue}if(i.has(s.id)){console.warn(`[PluginManager] Plugin "${s.id}" is already in the list, skipping duplicate`);continue}if(i.add(s.id),!this._plugins.has(s.id))try{await this._registerPlugin(s);}catch(n){this.registry.purge(s.id),this._notifySubscribers(),console.error(`[PluginManager] Plugin "${s.id}" setup() threw an error`,n);}t.delete(s.id);}for(let s of t)this._unregisterPlugin(s);}async _registerPlugin(e){this._plugins.has(e.id)&&this._unregisterPlugin(e.id);let t=[],i=Uo(this.registry,this._ctx,this._sharedInstancesBag,e.id,t),s=this._sharedInstancesBag.api,n;try{n=await e.setup({pluginApi:i,uploaderApi:s})??void 0;}catch(a){for(let l of t)try{l();}catch(c){this._debugPrint("Failed to unsubscribe config listener",c);}throw a}this._plugins.set(e.id,{plugin:e,dispose:n,configSubscriptions:t}),this._notifySubscribers();}_unregisterPlugin(e){let t=this._plugins.get(e);if(t){this.registry.purge(e);for(let i of t.configSubscriptions)try{i();}catch(s){this._debugPrint("Failed to unsubscribe config listener",s);}t.dispose?.(),this._plugins.delete(e),this._notifySubscribers();}}snapshot(){return this.registry.snapshot()}async runOnAddHooks(e){let t=e.getValue("file");if(!t)return;let i=this.registry.snapshot().fileHooks.filter(a=>a.type==="onAdd");if(i.length===0)return;let s=t,n=new AbortController;for(let a of i){if(n.signal.aborted)break;try{let l=a.handler({file:s,signal:n.signal}),c=new Promise((u,p)=>setTimeout(()=>p(new Error("onAdd hook timed out")),a.timeout));({file:s}=await Promise.race([l,c]));}catch(l){console.warn(`File hook "onAdd" from plugin "${a.pluginId}" failed`,l);}}s!==t&&(e.setValue("file",s),e.setValue("fileSize",s.size),e.setValue("mimeType",s.type||null),e.setValue("isImage",Ze(s)),s instanceof File&&e.setValue("fileName",s.name));}destroy(){for(let e of Array.from(this._plugins.keys()))this._unregisterPlugin(e);this._lazyPluginLoader.destroy(),super.destroy();}_notifySubscribers(){for(let e of this._subscribers)try{e();}catch{}}};var ba=20,x=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),b=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"}),mi=class extends U{constructor(){super(...arguments);this._timeoutStore=new Map;this._targets=new Set;this._listeners=new Map;}bindTarget(e){return this._targets.add(e),()=>{this._targets.delete(e);}}on(e,t){let i=this._listeners.get(e);return i||(i=new Set,this._listeners.set(e,i)),i.add(t),()=>this._listeners.get(e)?.delete(t)}_dispatch(e,t){for(let s of this._targets)s.dispatchEvent(new CustomEvent(e,{detail:t}));let i=this._listeners.get(e);if(i)for(let s of i)s(t);this._debugPrint?.(()=>{let s=t&&typeof t=="object"?{...t}:t;return [`event "${e}"`,s]});}emit(e,t,i={}){let{debounce:s}=i;if(typeof s!="number"&&!s){this._dispatch(e,typeof t=="function"?t():t);return}this._timeoutStore.has(e)&&window.clearTimeout(this._timeoutStore.get(e));let n=typeof s=="number"?s:ba,a=window.setTimeout(()=>{try{let l=typeof t=="function"?t():t;this._dispatch(e,l),this._timeoutStore.delete(e);}catch(l){this._debugPrint?.(()=>`Error while getting payload for event "${e}"`,l);}},n);this._timeoutStore.set(e,a);}destroy(){for(let e of this._timeoutStore.values())window.clearTimeout(e);this._targets.clear(),this._listeners.clear();}};var Vo="1.30.0-alpha.6";var pe="blocks",he=Vo;var fi=class extends U{constructor(e){super(e);this._sessionId=W.generateRandomUUID();this._config=structuredClone(z);this._initialized=false;this._lastPayload=null;this._isEnabled=false;this._telemetryInstance=new TelemetryAPIService,this._queue=new Queue(10),this.addSub(this._ctx.sub(v("qualityInsights"),t=>{this._isEnabled=!!t;}));for(let t of Object.keys(this._config))this.addSub(this._ctx.sub(v(t),i=>{this._isEnabled&&(this._initialized&&this._config[t]!==i&&this.sendEvent({eventType:x.CHANGE_CONFIG}),this._setConfig(t,i));}));}_init(e){e===x.INIT_SOLUTION&&!this._initialized&&(this._initialized=true);}_setConfig(e,t){this._config[e]!==t&&(this._config[e]=t);}_formattingPayload(e){let t=e.payload?{...e.payload}:{};t.activity&&(t.activity=void 0);let i={...e};return (e.eventType===x.INIT_SOLUTION||e.eventType===x.CHANGE_CONFIG)&&(i.config=this._config),{...i,appVersion:he,appName:pe,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:i.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...t}}}_excludedEvents(e){return !!(e&&[b.CHANGE,b.COMMON_UPLOAD_PROGRESS,b.FILE_ADDED,b.FILE_REMOVED,b.FILE_UPLOAD_START,b.FILE_UPLOAD_PROGRESS,b.FILE_UPLOAD_SUCCESS,b.FILE_UPLOAD_FAILED].includes(e))}sendEvent(e){if(!this._isEnabled)return;let t=this._formattingPayload({eventType:e.eventType,payload:e.payload,config:e.config});this._init(e.eventType),!(this._excludedEvents(e.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,t))&&this._queue.add(async()=>{this._lastPayload=t,await this._telemetryInstance.sendEvent(t);});}sendEventError(e,t="unknown"){this.sendEvent({eventType:x.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${t}`,error:e.message}}});}sendEventCloudImageEditor(e,t,i={}){this.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{tabId:t,node:e.currentTarget?.tagName,event:e.type,...i}}});}_checkObj(e,t){if(JSON.stringify(e)===JSON.stringify(t))return true;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return false;let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return false;for(let n of i)if(!Object.hasOwn(t,n)||!this._checkObj(e[n],t[n]))return false;return true}get _timestamp(){return Date.now()}get _solution(){if(!this._ctx.has("*solution"))return null;let e=this._ctx.read("*solution");return e?e.toLowerCase():null}get _activity(){return this._ctx.has("*currentActivity")?this._ctx.read("*currentActivity"):null}get _location(){return location.origin}};var $o=o=>{let r=new Intl.Locale(o),e="ltr",t=r.getTextInfo?.().direction;return t?e=t:r.textInfo?.direction&&(e=r.textInfo.direction),e};var wa=o=>o;var Do="plural:";function Ye(o,r={},e={}){let{openToken:t="{{",closeToken:i="}}",transform:s=wa}=e;for(let n in r){let a=r[n],l=a?.toString(),c=typeof l=="string"?s(l):String(l);o=o.replaceAll(t+n+i,c);}return o}function Fo(o){let r=[],e=o.indexOf("{{");for(;e!==-1;){let t=o.indexOf("}}",e);if(t===-1)break;let i=o.substring(e+2,t);if(i.startsWith(Do)){let s=o.substring(e+2,t).replace(Do,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));r.push({variable:i,pluralKey:n,countVariable:a});}e=o.indexOf("{{",t);}return r}var No="--uploadcare-blocks-window-height",Tt=class o{static{this.clientsRegistry=new Set;}static{this.flush=S(()=>{document.documentElement.style.setProperty(No,`${window.innerHeight}px`);},100);}static registerClient(r){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(r);}static unregisterClient(r){o.clientsRegistry.delete(r),o.clientsRegistry.size===0&&o.detachTracker();}static attachTracker(){window.addEventListener("resize",o.flush,{passive:true,capture:true}),o.flush();}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:true}),document.documentElement.style.removeProperty(No);}};var gi=(o,r)=>new Intl.PluralRules(o).select(r);var Ta=o=>(r,e)=>{let t=o(),i=t("locale-id")||"en",s=gi(i,e);return t(`${r}__${s}`)},vi=o=>{let r=Ta(()=>e),e=(t,i={})=>{if(!t)return "";let n=o().read(Te(t))||t,a=Fo(n);for(let c of a)i[c.variable]=r(c.pluralKey,Number(i[c.countVariable]));return Ye(n,i)};return e};var Ea=o=>o.tagName?.includes("-")??false,bi=class{constructor(r){this._trackedElements=new Set;this._originalValues=new Map;this._enabled=false;this._host=r,this._host.addController(this);}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=void 0,this._trackedElements.clear(),this._originalValues.clear();}hostUpdated(){if(!this._unsubscribe&&this._host.has(v("testMode"))){let r=this._host.subConfigValue("testMode",e=>{this._enabled=!!e,this._applyTestMode();});this._unsubscribe=r;}this._collectElements(),this._applyTestMode();}_collectElements(){let r=this._host,e=r.renderRoot??r;if(!e)return;let t=this._host,i=t.tagName?.toLowerCase(),s=Array.from(e.querySelectorAll("[data-testid]")).filter(n=>!Ea(n));for(let n of s)if(!(i&&n.closest(i)!==t)&&!this._trackedElements.has(n)){let a=n.getAttribute("data-testid");if(!a)continue;this._trackedElements.add(n),this._originalValues.set(n,a);}for(let n of Array.from(this._trackedElements))(!n.isConnected||i&&n.closest(i)!==t)&&(this._trackedElements.delete(n),this._originalValues.delete(n));}_applyTestMode(){if(!this._trackedElements.size)return;let r=this._host.testId||"";for(let e of this._trackedElements){let t=this._originalValues.get(e);t&&(this._enabled?e.setAttribute("data-testid",`${r}--${t}`):e.removeAttribute("data-testid"));}}};var Sa=qe(Xt()(We(Yt(LitElement)))),g=class extends Sa{constructor(){super();this.init$=dr();this.l10n=vi(()=>this.sharedCtx);this.debugPrint=ii(()=>this.sharedCtx,this.constructor.name);this._sharedInstancesBag=Mo(()=>this.sharedCtx);new bi(this);}static{this.styleAttrs=[];}emit(e,t,i){let s=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;if(!s)return;s.emit(e,t,i);let n=typeof t=="function"?t():t;this.telemetryManager.sendEvent({eventType:e,payload:n??void 0});}hasBlockInCtx(e){for(let t of this.blocksRegistry)if(e(t))return true;return false}connectedCallback(){this.constructor.styleAttrs.forEach(t=>{this.setAttribute(t,"");}),super.connectedCallback(),Tt.registerClient(this);}initCallback(){this._addSharedContextInstance("*blocksRegistry",()=>new Set),this._addSharedContextInstance("*pluginManager",e=>new hi(e)),this._addSharedContextInstance("*eventEmitter",e=>new mi(e)),this._addSharedContextInstance("*localeManager",e=>new li(e)),this._addSharedContextInstance("*modalManager",e=>new ri(e)),this._addSharedContextInstance("*a11y",()=>new ai),this._addSharedContextInstance("*routerLayer",e=>new ni(e)),this._addSharedContextInstance("*clipboard",e=>new si(e)),this._addSharedContextInstance("*telemetryManager",e=>new fi(e)),this.sub(Te("locale-id"),e=>{let t=$o(e);this.style.direction=t==="ltr"?"":t,this.requestUpdate();}),this.subConfigValue("testMode",e=>{if(!e||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId);}),this.blocksRegistry.add(this);}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this._getSharedContextInstance("*modalManager",false)}get telemetryManager(){return this._getSharedContextInstance("*telemetryManager")}get localeManager(){return this._getSharedContextInstance("*localeManager")}get a11y(){return this._getSharedContextInstance("*a11y")}get clipboardLayer(){return this._getSharedContextInstance("*clipboard")}get routerLayer(){return this._getSharedContextInstance("*routerLayer")}get blocksRegistry(){return this._getSharedContextInstance("*blocksRegistry")}get eventEmitter(){return this._getSharedContextInstance("*eventEmitter")}disconnectedCallback(){super.disconnectedCallback(),Tt.unregisterClient(this);let e=this.blocksRegistry;e?.delete(this),e?.size===0&&setTimeout(()=>{this.isConnected||e?.size>0||this.destroyCtxCallback();},0);}destroyCtxCallback(){this._destroySharedContextInstances(),R.deleteCtx(this.ctxName);}_getSharedContextInstances(){let e="*sharedContextInstances";if(!this.has(e)||!this.$[e]){let t=new Map;this.add(e,t,true);}return this.$[e]}_addSharedContextInstance(e,t){let i=this._getSharedContextInstances();if(!i.has(e)&&(!this.has(e)||!this.$[e])){let s=t(this._sharedInstancesBag);this.add(e,s,true),i.set(e,s);return}}_destroySharedContextInstances(){let e=this._getSharedContextInstances();for(let[t,i]of e.entries())i?.destroy?.(),this.pub(t,null);e.clear();}_getSharedContextInstance(e,t=true){if(this.has(e)&&this.$[e])return this.$[e];if(!t)return this.$[e];throw new Error(`Unexpected error: context manager for key "${String(e)}" is not available`)}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:ei(e),cdnUrlModifiers:ar(e),fileName:Jt(e)})}catch(t){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",t),this.telemetryManager.sendEventError(t,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?Ye(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:t=>window.encodeURIComponent(t)}):e}get cfg(){if(!this._cfgProxy){let e={};this._cfgProxy=new Proxy(e,{set:(t,i,s)=>{if(typeof i!="string"||!(i in z))return false;let n=i,a=v(n);return this.has(a)||this.add(a,z[n]),this.$[a]=s,true},get:(t,i)=>{let s=v(i);return this.has(s)||this.add(s,z[i]),this.$[s]}});}return this._cfgProxy}subConfigValue(e,t){let i=v(e);return this.has(i)||this.add(i,z[e]),this.sub(i,t)}};var Bo="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol fill='none' viewBox='0 0 24 24' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path d='M19.248 9.561 12 16.003 4.752 9.561l.996-1.122L12 13.995l6.252-5.556z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-photo-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-ngdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 16 16' id='uc-icon-paperclip' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M13.264 9.743 9.03 13.977a4.217 4.217 0 0 1-5.96-.005 4.217 4.217 0 0 1-.004-5.96l6.416-6.416a2.743 2.743 0 0 1 3.88 3.88L7.637 11.2a1.232 1.232 0 1 1-1.743-1.743L9.42 5.932'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var Ee=class extends g{constructor(){super(...arguments);this.init$=Po(this);}static{this.styleAttrs=["uc-wgt-common"];}static{this.lazyPlugins=null;}initCallback(){super.initCallback(),this.a11y?.registerBlock(this),this.clipboardLayer?.registerBlock(this),this.sharedCtx.pub("*solution",this.tagName);let e=this.constructor.lazyPlugins;e&&this.sharedCtx.pub("*lazyPlugins",e);}render(){return html`${unsafeSVG(Bo)}`}};var Ho=o=>typeof o!="number"?0:Math.floor(o/1e3),zo=(o,{threshold:r})=>{let{secureExpire:e}=o,t=Ho(Date.now()),i=Number(e),s=Ho(r);return t+s>=i};var yi=class extends U{constructor(){super(...arguments);this._secureToken=null;}async getSecureToken(){let{secureSignature:e,secureExpire:t,secureUploadsSignatureResolver:i,secureUploadsExpireThreshold:s}=this._cfg;if((e||t)&&i&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),i){if(!this._secureToken||zo(this._secureToken,{threshold:s})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let n=await i();n?!n.secureSignature||!n.secureExpire?console.error("Secure signature resolver returned an invalid result:",n):(this._debugPrint("Secure signature resolved:",n),this._debugPrint("Secure signature will expire in",new Date(Number(n.secureExpire)*1e3).toISOString()),this._secureToken=n):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null);}catch(n){console.error("Secure signature resolving failed. Falling back to the previous one.",n),this._sharedInstancesBag.telemetryManager.sendEventError(n,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.");}}return this._secureToken}return e&&t?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:e,secureExpire:t}),{secureSignature:e,secureExpire:t}):null}destroy(){super.destroy(),this._secureToken=null;}};var gr=(o,r)=>{if(o.failedCount>0)return {type:"SOME_FILES_HAS_ERRORS",message:r.l10n("some-files-were-not-uploaded")}};var vr=(o,r)=>{let e=o.totalCount,t=r.cfg.multiple?r.cfg.multipleMin:0,i=r.cfg.multiple?r.cfg.multipleMax:1;if(t&&e<t)return {type:"TOO_FEW_FILES",message:r.l10n("files-count-limit-error-too-few",{min:t,max:i,total:e}),payload:{total:e,min:t,max:i}};if(i&&e>i)return {type:"TOO_MANY_FILES",message:r.l10n("files-count-limit-error-too-many",{min:t,max:i,total:e}),payload:{total:e,min:t,max:i}}};var br=(o,r)=>{let e=r.cfg.imgOnly,t=r.cfg.accept,i=ci([...e?wt:[],t]);if(!i.length)return;let s=o.mimeType,n=o.name;if(!s||!n)return;let a=fr(s,i),l=Ro(n,i);if(!a&&!l)return {type:"FORBIDDEN_FILE_TYPE",message:r.l10n("file-type-not-allowed"),payload:{entry:o}}};var yr=(o,r)=>{let e=r.cfg.imgOnly,t=o.isImage;if(!(!e||t)&&!(!o.fileInfo&&o.externalUrl)&&!(!o.fileInfo&&!o.mimeType))return {type:"NOT_AN_IMAGE",message:r.l10n("images-only-accepted"),payload:{entry:o}}};var me=1e3,Ne=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),Et=o=>Math.ceil(o*100)/100,Ko=(o,r=Ne.AUTO)=>{let e=r===Ne.AUTO;if(r===Ne.BYTE||e&&o<me**1){let i=gi("en-US",o)==="one"?"byte":"bytes";return `${o} ${i}`}return r===Ne.KB||e&&o<me**2?`${Et(o/me**1)} KB`:r===Ne.MB||e&&o<me**3?`${Et(o/me**2)} MB`:r===Ne.GB||e&&o<me**4?`${Et(o/me**3)} GB`:r===Ne.TB||e&&o<me**5?`${Et(o/me**4)} TB`:`${Et(o/me**5)} PB`};var _r=(o,r)=>{let e=r.cfg.maxLocalFileSizeBytes,t=o.size;if(e&&t&&t>e)return {type:"FILE_SIZE_EXCEEDED",message:r.l10n("files-max-size-limit-error",{maxFileSize:Ko(e)}),payload:{entry:o}}};var Cr=(o,r)=>{let{internalId:e}=o;if(!r._uploadCollection.hasItem(e))return;let i=r._uploadCollection.read(e)?.getValue("uploadError");if(!i)return;if(i instanceof UploadError)return {type:"UPLOAD_ERROR",message:i.message,payload:{entry:o,error:i}};if(i instanceof NetworkError)return {type:"NETWORK_ERROR",message:i.message,payload:{entry:o,error:i}};let s=i instanceof Error?i:new Error("Unknown error",{cause:i});return {type:"UNKNOWN_ERROR",message:s.message,payload:{entry:o,error:s}}};var Xe={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},Oa=o=>typeof o=="function"?{runOn:"change",validator:o}:o,_i=class extends U{constructor(e){super(e);this._commonFileValidators=[yr,br,_r,Cr];this._commonCollectionValidators=[vr,gr];this._queue=new Queue(20);this._runQueueDebounced=S(()=>{this._queue.run();},500);this._isDestroyed=false;this._entryValidationState=new Map;let t=S(()=>{this.runFileValidators("change"),this.runCollectionValidators();},0);this.addSub(this._ctx.sub(v("maxLocalFileSizeBytes"),t)),this.addSub(this._ctx.sub(v("multipleMin"),t)),this.addSub(this._ctx.sub(v("multipleMax"),t)),this.addSub(this._ctx.sub(v("multiple"),t)),this.addSub(this._ctx.sub(v("imgOnly"),t)),this.addSub(this._ctx.sub(v("accept"),t)),this.addSub(this._ctx.sub(v("validationConcurrency"),i=>{this._queue.concurrency=i;}));}get _uploadCollection(){return this._sharedInstancesBag.uploadCollection}runFileValidators(e,t){if(this._isDestroyed)return;let i=t??this._uploadCollection.items();for(let s of i){let n=this._uploadCollection.read(s);n&&this._runFileValidatorsForEntry(n,e);}}runCollectionValidators(){if(this._isDestroyed)return;let e=this._sharedInstancesBag.api,t=e.getOutputCollectionState(),i=[],s=this._cfg.collectionValidators;for(let n of [...this._commonCollectionValidators,...s])try{let a=n(t,e);if(!a)continue;a&&(i.push(this._addCustomTypeToValidationError(a)),a.message||console.warn(Xe.MISSING_ERROR_MESSAGE));}catch(a){console.warn(Xe.COLLECTION_VALIDATION_FAILED,a);}this._ctx.pub("*collectionErrors",i),i.length>0&&this._sharedInstancesBag.eventEmitter.emit(b.COMMON_UPLOAD_FAILED,()=>e.getOutputCollectionState(),{debounce:true});}cleanupValidationForEntry(e){let t=this._entryValidationState.get(e.uid);t&&(t.abortController?.abort(),this._entryValidationState.delete(e.uid));}async _runFileValidatorsForEntry(e,t){if(this._isDestroyed)return;let i=this._sharedInstancesBag.api,s=this._getEntryValidationState(e),n=s.promise??Promise.resolve(),a=(async()=>{if(this._isDestroyed||(await n,this._isDestroyed))return;let l=this._getValidatorDescriptorsForEntry(e,t);if(l.length===0||!this._uploadCollection.hasItem(e.uid))return;e.setMultipleValues({isQueuedForValidation:true,isValidationPending:true});let c=i.getOutputItem(e.uid),u=new AbortController;s.abortController=u;let p=this._cfg.validationTimeout,m=this._getValidatorDescriptors(),h=new Set(l.map(w=>w.validator)),f=[];for(let w of m)if(!h.has(w.validator)){let L=s.lastErrorThrownByValidator.get(w.validator);L&&f.push(L);}let P=l.map(w=>async()=>{if(this._isDestroyed)return;let L=setTimeout(()=>{s.skippedValidators.add(w.validator),u.abort(),console.warn(Xe.FILE_VALIDATION_TIMEOUT);},p);try{let G=await w.validator(c,i,{signal:u.signal});if(!G||u.signal.aborted){s.lastErrorThrownByValidator.set(w.validator,void 0);return}let Zt=this._addCustomTypeToValidationError(G);s.lastErrorThrownByValidator.set(w.validator,Zt),f.push(Zt),G.message||console.warn(Xe.MISSING_ERROR_MESSAGE);}catch(G){u.signal.aborted||(s.skippedValidators.add(w.validator),console.warn(Xe.FILE_VALIDATION_FAILED,G),this._sharedInstancesBag.telemetryManager.sendEventError(G,`file validator. ${Xe.FILE_VALIDATION_FAILED}`));}finally{clearTimeout(L),w.runOn!=="change"&&s.skippedValidators.add(w.validator);}});if(this._runQueueDebounced(),await this._queue.add(async()=>{this._isDestroyed||(e.setValue("isQueuedForValidation",false),await Promise.all(P.map(w=>w())).catch(()=>{}));},{autoRun:false}),u.signal.aborted){e.setMultipleValues({isQueuedForValidation:false,isValidationPending:false});return}e.setMultipleValues({isValidationPending:false,isQueuedForValidation:false,errors:f});})();s.promise=a;try{await a;}finally{s.promise===a&&(s.promise=void 0);}}_addCustomTypeToValidationError(e){return {...e,type:e.type??"CUSTOM_ERROR"}}_getEntryValidationState(e){let t=this._entryValidationState.get(e.uid);if(t)return t;let i={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(e.uid,i),i}_getValidatorDescriptors(){let e=this._cfg.fileValidators;return [...this._commonFileValidators,...e].map(Oa)}_getValidatorDescriptorsForEntry(e,t){let i=this._getEntryValidationState(e);return this._getValidatorDescriptors().filter(s=>!i.skippedValidators.has(s.validator)).filter(s=>s.runOn===t)}destroy(){this._isDestroyed=true,this._runQueueDebounced.cancel();for(let e of this._entryValidationState.values())e.abortController?.abort(),e.promise=void 0;this._entryValidationState.clear();}};var jo="[Typed State] Wrong property name: ",Ci=class{constructor(r){this._ctxId=W.generateFastUid(),this._data=R.registerCtx(r,this._ctxId);}get uid(){return this._ctxId}setValue(r,e){if(!this._data.has(r)){console.warn(`${jo}${String(r)}`);return}this._data.read(r)!==e&&this._data.pub(r,e);}setMultipleValues(r){for(let[e,t]of Object.entries(r))this.setValue(e,t);}getValue(r){return this._data.has(r)||console.warn(`${jo}${String(r)}`),this._data.read(r)}subscribe(r,e){return this._data.sub(r,e)}destroy(){R.deleteCtx(this._ctxId);}};var wi=class o{constructor(r){this._subsMap=Object.create(null);this._propertyObservers=new Set;this._collectionObservers=new Set;this._items=new Set;this._removed=new Set;this._added=new Set;this._markedToDestroy=new Set;this._initialValue=r.initialValue,this._ctxId=W.generateFastUid(),this._data=R.registerCtx({},this._ctxId),this._watchList=r.watchList||[];let e=Object.create(null);this._notifyObservers=(t,i)=>{this._observeTimeout&&window.clearTimeout(this._observeTimeout),e[t]||(e[t]=new Set),e[t].add(i),this._observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this._propertyObservers.forEach(s=>{s({...e});}),e=Object.create(null));}),this._scheduleDestroyMarkedItems();},r.handler&&this.observeCollection(r.handler);}static{this._destroyDelayMs=1e4;}_notify(){this._notifyTimeout&&window.clearTimeout(this._notifyTimeout),this._notifyTimeout=window.setTimeout(()=>{let r=new Set(this._added),e=new Set(this._removed);this._added.clear(),this._removed.clear();for(let t of this._collectionObservers)t?.([...this._items],r,e);this._scheduleDestroyMarkedItems();});}_scheduleDestroyMarkedItems(){this._markedToDestroy.size!==0&&(this._destroyTimeout&&window.clearTimeout(this._destroyTimeout),this._destroyTimeout=window.setTimeout(()=>{let r=[...this._markedToDestroy];this._markedToDestroy.clear();for(let e of r)e.destroy();},o._destroyDelayMs));}observeCollection(r){return this._collectionObservers.add(r),this._items.size>0&&this._notify(),()=>{this.unobserveCollection(r);}}unobserveCollection(r){this._collectionObservers.delete(r);}add(r){let e=new Ci(this._initialValue);for(let[t,i]of Object.entries(r))e.setValue(t,i);return this._items.add(e.uid),this._notify(),this._data.add(e.uid,e),this._added.add(e),this._watchList.forEach(t=>{this._subsMap[e.uid]||(this._subsMap[e.uid]=[]),this._subsMap[e.uid]?.push(e.subscribe(t,()=>{this._notifyObservers(t,e.uid);}));}),e.uid}hasItem(r){return this._items.has(r)}read(r){return this._data.read(r)??null}readProp(r,e){let t=this.read(r);if(!t)throw new Error(`TypedCollection#readProp: Item with id ${r} not found`);return t.getValue(e)}publishProp(r,e,t){let i=this.read(r);if(!i)throw new Error(`TypedCollection#publishProp: Item with id ${r} not found`);i.setValue(e,t);}remove(r){let e=this.read(r);e&&(this._removed.add(e),this._markedToDestroy.add(e)),this._items.delete(r),this._notify(),this._data.pub(r,void 0),this._subsMap[r]?.forEach(t=>{t();}),delete this._subsMap[r];}abort(r){this.read(r)?.getValue("isUploading")&&this.remove(r);}abortAll(){this._items.forEach(r=>{this.abort(r);});}clearAll(){this._items.forEach(r=>{this.remove(r);});}observeProperties(r){return this._propertyObservers.add(r),()=>{this.unobserveProperties(r);}}unobserveProperties(r){this._propertyObservers.delete(r);}findItems(r){let e=[];return this._items.forEach(t=>{let i=this.read(t);i&&r(i)&&e.push(t);}),e}items(){return [...this._items]}get size(){return this._items.size}destroy(){this._observeTimeout&&window.clearTimeout(this._observeTimeout),this._notifyTimeout&&window.clearTimeout(this._notifyTimeout),this._destroyTimeout&&window.clearTimeout(this._destroyTimeout);for(let r of this._markedToDestroy)r.destroy();this._markedToDestroy.clear(),R.deleteCtx(this._ctxId),this._propertyObservers=new Set,this._collectionObservers=new Set;for(let r of Object.keys(this._subsMap))this._subsMap[r]?.forEach(e=>{e();}),delete this._subsMap[r];}};var C=Object.freeze({PHOTO:"photo",VIDEO:"video"}),ae=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Go=o=>({isVideoRecordingEnabled:V(o.cameraModes).includes(C.VIDEO),isPhotoEnabled:V(o.cameraModes).includes(C.PHOTO)});var Wo=(o,r)=>{for(let e of o)if(r(e))return e};var wr=(o,r,{timeout:e=1e3,onTimeout:t}={})=>new Promise(i=>{let s,n=setTimeout(()=>{cancelAnimationFrame(s),t?.();},e),a=()=>{for(let l of o)if(r(l)){clearTimeout(n),i(l);return}s=requestAnimationFrame(a);};a();});function Ti(o,r){for(let e in r)e.includes("-")?o.style.setProperty(e,String(r[e])):o.style[e]=String(r[e]);}var La=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,Ra=new RegExp(`^/?(${La.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),qo=({url:o,cdnBase:r})=>{let e=new URL(r),t=new URL(_t),i=new URL(o);if(e.host!==i.host&&t.host!==i.host)return null;let s=Ra.exec(i.pathname);if(!s)return null;let[,n,a,l]=s;return n?{uuid:n,cdnUrlModifiers:a||"",filename:l||null}:null};var Q=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",DROPBOX_CHOOSER:"dropboxchooser",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Ua=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),T=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",...Ua,...Q}),Va={[Q.DROPBOX_CHOOSER]:Q.DROPBOX},Zo=o=>Va[o]??o;var Ei=o=>o.uploadCollection.items().map(t=>o.api.getOutputItem(t));function Yo(o){let r=new Map;return (...t)=>{let i=JSON.stringify(t);if(r.has(i))return r.get(i);let s=o(...t);return r.set(i,s),s}}var Xo=new Set;function xi(o){Xo.has(o)||(Xo.add(o),console.warn(o));}function $a(o){let r=false;return setTimeout(()=>{r=true;},0),t=>((...i)=>(r&&xi(o),t(...i)))}function Qo(o){let r={},e=o.ctx,t={progress:()=>e.read("*commonProgress"),errors:()=>e.read("*collectionErrors"),group:()=>e.read("*groupInfo"),totalCount:()=>o.uploadCollection.size,failedCount:()=>r.failedEntries.length,successCount:()=>r.successEntries.length,uploadingCount:()=>r.uploadingEntries.length,status:()=>r.isFailed?"failed":r.isUploading?"uploading":r.isSuccess?"success":"idle",isSuccess:()=>r.allEntries.length>0&&r.errors.length===0&&r.successEntries.length===r.allEntries.length,isUploading:()=>r.allEntries.some(s=>s.status==="uploading"),isFailed:()=>r.errors.length>0||r.failedEntries.length>0,allEntries:()=>Ei(o),successEntries:()=>r.allEntries.filter(s=>s.status==="success"),failedEntries:()=>r.allEntries.filter(s=>s.status==="failed"),uploadingEntries:()=>r.allEntries.filter(s=>s.status==="uploading"),idleEntries:()=>r.allEntries.filter(s=>s.status==="idle")},i=$a("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[s,n]of Object.entries(t)){let a=s,c=Yo(i(n));Object.defineProperty(r,a,{get:c,enumerable:true});}return r}var Si=class extends U{constructor(){super(...arguments);this._l10n=vi(()=>this._ctx);this.addFileFromUrl=(e,{silent:t,fileName:i,source:s}={})=>{let n=this._uploadCollection.add({externalUrl:e,fileName:i??null,silent:t??false,source:s??T.API});return this.getOutputItem(n)};this.addFileFromUuid=(e,{silent:t,fileName:i,source:s}={})=>{let n=this._uploadCollection.add({uuid:e,fileName:i??null,silent:t??false,source:s??T.API});return this.getOutputItem(n)};this.addFileFromCdnUrl=(e,{silent:t,fileName:i,source:s}={})=>{let n=qo({url:e,cdnBase:this.cfg.cdnCname});if(!n)throw new Error("Invalid CDN URL");let a=this._uploadCollection.add({uuid:n.uuid,cdnUrl:e,cdnUrlModifiers:n.cdnUrlModifiers,fileName:i??n.filename??null,silent:t??false,source:s??T.API});return this.getOutputItem(a)};this.addFileFromObject=(e,{silent:t,fileName:i,source:s,fullPath:n}={})=>{let a=this._uploadCollection.add({file:e,isImage:Ze(e),mimeType:e.type||null,fileName:i??e.name,fileSize:e.size,silent:t??false,source:s??T.API,fullPath:n??null});return this.getOutputItem(a)};this.removeFileByInternalId=e=>{if(!this._uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this._uploadCollection.remove(e);};this.uploadAll=()=>{let e=this._uploadCollection.items().filter(t=>{let i=this._uploadCollection.read(t);return i?!i.getValue("isRemoved")&&!i.getValue("isUploading")&&!i.getValue("fileInfo")&&i.getValue("errors").length===0&&!i.getValue("isValidationPending")&&!i.getValue("isQueuedForValidation"):false});e.length!==0&&(this._ctx.pub("*uploadTrigger",new Set(e)),this._sharedInstancesBag.eventEmitter.emit(b.COMMON_UPLOAD_START,this.getOutputCollectionState()));};this.openSystemDialog=(e={})=>{let t=_e(ci([this.cfg.accept??"",...this.cfg.imgOnly?wt:[]])),i="uploadcare-file-input",s=document.createElement("input");if(s.setAttribute(i,""),Ti(s,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),s.type="file",s.multiple=this.cfg.multiple,e.captureCamera){s.capture=this.cfg.cameraCapture;let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=Go(this.cfg);e.modeCamera===C.PHOTO&&n?s.accept=Ct:e.modeCamera===C.VIDEO&&a?s.accept=mr:s.accept=[Ct,a&&mr].filter(Boolean).join(",");}else s.accept=t;s.addEventListener("change",()=>{s.files&&([...s.files].forEach(n=>{this.addFileFromObject(n,{source:e.captureCamera?T.CAMERA:T.LOCAL});}),this._sharedInstancesBag.routerLayer.navigateAfterFileAdd(),s.remove());},{once:true}),document.querySelectorAll(`[${i}]`).forEach(n=>{n.remove();}),document.body.appendChild(s),s.dispatchEvent(new MouseEvent("click"));};this.initFlow=(e=false)=>{if(this._uploadCollection.size>0&&!e)this._ctx.pub("*currentActivity",A.UPLOAD_LIST),this._sharedInstancesBag.modalManager?.open(A.UPLOAD_LIST);else if(this._sourceList?.length===1){let t=this._sourceList[0];this._pluginsReady().then(()=>{let i=this._sharedInstancesBag.pluginManager.snapshot().sources,s=i.find(n=>n.id===t);if(s){let n=s.expand?.()??[t];n.length===1?(i.find(l=>l.id===n[0])??s).onSelect():(this._ctx.pub("*currentActivity",A.START_FROM),this._sharedInstancesBag.modalManager?.open(A.START_FROM));return}this._ctx.read("*currentActivity")&&this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity"));});}else this._ctx.pub("*currentActivity",A.START_FROM),this._sharedInstancesBag.modalManager?.open(A.START_FROM);};this.doneFlow=()=>{let e=Wo(this._sharedInstancesBag.blocksRegistry,t=>"doneActivity"in t);e&&(this._ctx.pub("*currentActivity",e.doneActivity),this._ctx.pub("*history",e.doneActivity?[e.doneActivity]:[]),this._ctx.read("*currentActivity")||this._sharedInstancesBag.modalManager?.closeAll());};this.setCurrentActivity=(e,...t)=>{this._pluginsReady().then(()=>{this._ctx.pub("*currentActivityParams",t[0]??{}),this._ctx.pub("*currentActivity",e),wr(this._sharedInstancesBag.blocksRegistry,i=>i.activityType===e,{onTimeout:()=>console.warn(`Activity type "${e}" not found in the context`),timeout:100});});};this.on=(e,t)=>this._sharedInstancesBag.eventEmitter.on(e,t);this.getCurrentActivity=()=>this._ctx.read("*currentActivity");this.historyBack=()=>{this._ctx.read("*historyBack")?.();};this.setModalState=e=>{this._pluginsReady().then(()=>{if(!e){this._sharedInstancesBag.modalManager?.close(this._ctx.read("*currentActivity")),this._ctx.pub("*currentActivity",null);return}let t=this._ctx.read("*currentActivity");if(!t){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}return wr(this._sharedInstancesBag.blocksRegistry,i=>i.activityType===t,{onTimeout:()=>console.warn(`Activity block "${t}" not found in the context`)}).then(()=>{this._sharedInstancesBag.modalManager?.open(t);})});};}get _uploadCollection(){return this._sharedInstancesBag.uploadCollection}get cfg(){return this._cfg}get l10n(){return this._l10n}removeAllFiles(){this._uploadCollection.clearAll();}getOutputItem(e){let t=R.getCtx(e);if(!t)throw new Error(`UploaderPublicApi#getOutputItem: Entry with ID "${e}" not found in the upload collection`);let i=t.store,s=i.fileInfo,n=i.isRemoved?"removed":i.errors.length>0?"failed":i.fileInfo?"success":i.isUploading?"uploading":"idle";return {uuid:s?.uuid??i.uuid??null,internalId:e,name:s?.originalFilename??i.fileName,size:s?.size??i.fileSize,isImage:s?.isImage??i.isImage,mimeType:s?.mimeType??i.mimeType,file:i.file,externalUrl:i.externalUrl,cdnUrlModifiers:i.cdnUrlModifiers,cdnUrl:i.cdnUrl??s?.cdnUrl??null,fullPath:i.fullPath,uploadProgress:i.uploadProgress,fileInfo:s??null,metadata:i.metadata??s?.metadata??null,isSuccess:n==="success",isUploading:n==="uploading",isFailed:n==="failed",isRemoved:n==="removed",isValidationPending:i.isValidationPending,errors:i.errors,status:n,source:i?.source}}getOutputCollectionState(){return Qo(this._sharedInstancesBag)}async _pluginsReady(){return (await this._sharedInstancesBag.wait("pluginManager")).pluginsReady()}get _sourceList(){let e=[];return this.cfg.sourceList&&(e=N(this.cfg.sourceList)),e}};var Jo={file:null,externalUrl:null,fileName:null,fileSize:null,lastModified:Date.now(),uploadProgress:0,uuid:null,isImage:false,mimeType:null,ctxName:null,cdnUrl:null,cdnUrlModifiers:null,fileInfo:null,isUploading:false,abortController:null,thumbUrl:null,silent:false,source:null,fullPath:null,metadata:null,errors:[],uploadError:null,isRemoved:false,isQueuedForUploading:false,isValidationPending:false,isQueuedForValidation:false};var xt=33.333333333333336,y=1,Tr=24,es=6;function Me(o,r){for(let[e,t]of Object.entries(r))o.setAttributeNS(null,e,t.toString());}function re(o,r={}){let e=document.createElementNS("http://www.w3.org/2000/svg",o);return Me(e,r),e}function ts(o,r,e){let{x:t,y:i,width:s,height:n}=o,a=r.includes("w")?0:1,l=r.includes("n")?0:1,c=a===0?-1:1,u=l===0?-1:1,p=[t+a*s+1.5*c,i+l*n+1.5*u-24*e*u],m=[t+a*s+1.5*c,i+l*n+1.5*u],h=[t+a*s-24*e*c+1.5*c,i+l*n+1.5*u],f=`M ${p[0]} ${p[1]} L ${m[0]} ${m[1]} L ${h[0]} ${h[1]}`,P=[m[0],m[1]];return {d:f,center:P}}function is(o,r,e){let{x:t,y:i,width:s,height:n}=o,a=r==="n"||r==="s",l=r==="w"||r==="e",c=a?.5:r==="w"?0:1,u=l?.5:r==="n"?0:1,p=r==="w"?-1:r==="e"?1:0,m=r==="n"?-1:r==="s"?1:0,h,f;a?(h=[t+c*s-34*e/2,i+u*n+1.5*m],f=[t+c*s+34*e/2,i+u*n+1.5*m]):(h=[t+c*s+1.5*p,i+u*n-34*e/2],f=[t+c*s+1.5*p,i+u*n+34*e/2]);let P=`M ${h[0]} ${h[1]} L ${f[0]} ${f[1]}`,w=[(h[0]+f[0])/2,(h[1]+f[1])/2];return {d:P,center:w}}function rs(o){return o===""?"move":["e","w"].includes(o)?"ew-resize":["n","s"].includes(o)?"ns-resize":["nw","se"].includes(o)?"nwse-resize":"nesw-resize"}function os({rect:o,delta:[r,e],imageBox:t}){return Je({...o,x:o.x+r,y:o.y+e},t)}function Je(o,r){let{x:e}=o,{y:t}=o;return o.x<r.x?e=r.x:o.x+o.width>r.x+r.width&&(e=r.x+r.width-o.width),o.y<r.y?t=r.y:o.y+o.height>r.y+r.height&&(t=r.y+r.height-o.height),{...o,x:e,y:t}}function Da({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[,i]=r,{y:s,width:n,height:a}=o;s+=i,a-=i,e&&(n=a*e);let l=o.x+o.width/2-n/2;return s<=t.y&&(s=t.y,a=o.y+o.height-s,e&&(n=a*e,l=o.x+o.width/2-n/2)),l<=t.x&&(l=t.x,s=o.y+o.height-a),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),s=o.y+o.height-a),a<y&&(a=y,e&&(n=a*e,l=o.x+o.width/2-n/2),s=o.y+o.height-a),n<y&&(n=y,e&&(a=n/e,l=o.x+o.width/2-n/2),s=o.y+o.height-a),{x:l,y:s,width:n,height:a}}function Fa({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i]=r,{x:s,width:n,height:a}=o;s+=i,n-=i,e&&(a=n/e);let l=o.y+o.height/2-a/2;return s<=t.x&&(s=t.x,n=o.x+o.width-s,e&&(a=n/e,l=o.y+o.height/2-a/2)),l<=t.y&&(l=t.y,s=o.x+o.width-n),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),s=o.x+o.width-n),a<y&&(a=y,e&&(n=a*e),l=o.y+o.height/2-a/2,s=o.x+o.width-n),n<y&&(n=y,e&&(a=n/e),l=o.y+o.height/2-a/2,s=o.x+o.width-n),{x:s,y:l,width:n,height:a}}function Na({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[,i]=r,{y:s,width:n,height:a}=o;a+=i,e&&(n=a*e);let l=o.x+o.width/2-n/2;return s+a>=t.y+t.height&&(a=t.y+t.height-s,e&&(n=a*e),l=o.x+o.width/2-n/2),l<=t.x&&(l=t.x,s=o.y),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),s=o.y),a<y&&(a=y,e&&(n=a*e),l=o.x+o.width/2-n/2),n<y&&(n=y,e&&(a=n/e),l=o.x+o.width/2-n/2),{x:l,y:s,width:n,height:a}}function Ba({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i]=r,{x:s,width:n,height:a}=o;n+=i,e&&(a=n/e);let l=o.y+o.height/2-a/2;return s+n>=t.x+t.width&&(n=t.x+t.width-s,e&&(a=n/e),l=o.y+o.height/2-a/2),l<=t.y&&(l=t.y,s=o.x),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),s=o.x),a<y&&(a=y,e&&(n=a*e),l=o.y+o.height/2-a/2),n<y&&(n=y,e&&(a=n/e),l=o.y+o.height/2-a/2),{x:s,y:l,width:n,height:a}}function Ha({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+i<t.x&&(i=t.x-n),a+s<t.y&&(s=t.y-a),n+=i,l-=i,a+=s,c-=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a-=s,a<=t.y&&(c=c-(t.y-a),l=c*e,n=o.x+o.width-l,a=t.y)):e&&(i=c*e-l,l=l+i,n-=i,n<=t.x&&(l=l-(t.x-n),c=l/e,n=t.x,a=o.y+o.height-c)),c<y&&(c=y,e&&(l=c*e),n=o.x+o.width-l,a=o.y+o.height-c),l<y&&(l=y,e&&(c=l/e),n=o.x+o.width-l,a=o.y+o.height-c),{x:n,y:a,width:l,height:c}}function za({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+l+i>t.x+t.width&&(i=t.x+t.width-n-l),a+s<t.y&&(s=t.y-a),l+=i,a+=s,c-=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a-=s,a<=t.y&&(c=c-(t.y-a),l=c*e,n=o.x,a=t.y)):e&&(i=c*e-l,l+=i,n+l>=t.x+t.width&&(l=t.x+t.width-n,c=l/e,n=t.x+t.width-l,a=o.y+o.height-c)),c<y&&(c=y,e&&(l=c*e),a=o.y+o.height-c),l<y&&(l=y,e&&(c=l/e),a=o.y+o.height-c),{x:n,y:a,width:l,height:c}}function Ka({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+i<t.x&&(i=t.x-n),a+c+s>t.y+t.height&&(s=t.y+t.height-a-c),n+=i,l-=i,c+=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a+c>=t.y+t.height&&(c=t.y+t.height-a,l=c*e,n=o.x+o.width-l,a=t.y+t.height-c)):e&&(i=c*e-l,l+=i,n-=i,n<=t.x&&(l=l-(t.x-n),c=l/e,n=t.x,a=o.y)),c<y&&(c=y,e&&(l=c*e),n=o.x+o.width-l),l<y&&(l=y,e&&(c=l/e),n=o.x+o.width-l),{x:n,y:a,width:l,height:c}}function ja({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+l+i>t.x+t.width&&(i=t.x+t.width-n-l),a+c+s>t.y+t.height&&(s=t.y+t.height-a-c),l+=i,c+=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a+c>=t.y+t.height&&(c=t.y+t.height-a,l=c*e,n=o.x,a=t.y+t.height-c)):e&&(i=c*e-l,l+=i,n+l>=t.x+t.width&&(l=t.x+t.width-n,c=l/e,n=t.x+t.width-l,a=o.y)),c<y&&(c=y,e&&(l=c*e)),l<y&&(l=y,e&&(c=l/e)),{x:n,y:a,width:l,height:c}}function ss({direction:o,...r}){switch(o){case "n":return Da(r);case "w":return Fa(r);case "s":return Na(r);case "e":return Ba(r);case "nw":return Ha(r);case "ne":return za(r);case "sw":return Ka(r);case "se":return ja(r);default:return r.rect}}function ns(o,[r,e]){return o.x<=r&&r<=o.x+o.width&&o.y<=e&&e<=o.y+o.height}function as(o,r){return o.x>=r.x&&o.y>=r.y&&o.x+o.width<=r.x+r.width&&o.y+o.height<=r.y+r.height}function ls(o,r){return Math.abs(o.width/o.height-r)<.1}function et({width:o,height:r},e){let t=e/90%2!==0;return {width:t?r:o,height:t?o:r}}function cs(o,r,e){let t=o/r,i,s;t>e?(i=Math.round(r*e),s=r):(i=o,s=Math.round(o/e));let n=Math.round((o-i)/2),a=Math.round((r-s)/2);return n+i>o&&(i=o-n),a+s>r&&(s=r-a),{x:n,y:a,width:i,height:s}}function tt(o){return {x:Math.round(o.x),y:Math.round(o.y),width:Math.round(o.width),height:Math.round(o.height)}}function Pe(o,r,e){return Math.min(Math.max(o,r),e)}var St=["free"],Ai=o=>{let r=N(o);if(!r||r.length===0)return [];let e=[];for(let t of r){let i=t.trim();if(!i)continue;let s=i.indexOf(":");if(s===-1&&!St.includes(i)){console.warn(`Invalid crop preset: ${i}`);continue}let n=Number(i.slice(0,s)),a=Number(i.slice(s+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!St.includes(i)){console.warn(`Invalid crop preset: ${i}`);continue}e.push({id:W.generateFastUid(),type:"aspect-ratio",width:St.includes(i)?0:n,height:St.includes(i)?0:a,hasFreeform:St.includes(i)});}return e},ds=(o,r,e,t=.1)=>{let i=o/r,s=null,n=1/0;for(let a of e){let[l,c]=[a.width,a.height],u=l/c,p=Math.abs(i-u);p<n&&(n=p,s=a);}if(s){let[a,l]=[s.width,s.height],c=a/l;if(Math.abs(i-c)/c>t)return null}return s};function us(o){return getUserAgent({...o,libraryName:pe,libraryVersion:he})}var ps="active",it="___ACTIVITY_IS_ACTIVE___",hs,E=class o extends(hs=g,hs){constructor(){super(...arguments);this.historyTracked=false;this.activityType=null;this.init$=ur(this);this._debouncedHistoryFlush=S(this._historyFlush.bind(this),10);}_deactivate(){let e=o._activityCallbacks.get(this);this[it]=false,this.removeAttribute(ps),e?.deactivateCallback?.();}_activate(){let e=o._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[it]=true,this.setAttribute(ps,""),e?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(b.ACTIVITY_CHANGE,{activity:this.activityType});}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{try{this.activityType!==e&&this[it]?this._deactivate():this.activityType===e&&!this[it]&&this._activate();}catch(t){this.telemetryManager.sendEventError(t,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,t);let i=this.$["*history"][this.$["*history"].length-1];this.$["*currentActivity"]=i??null;}e||(this.$["*history"]=[]);}));}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e);}_isActivityRegistered(){return !!this.activityType&&o._activityCallbacks.has(this)}static{this._activityCallbacks=new Map;}get isActivityActive(){return !!this[it]}get couldOpenActivity(){return true}registerActivity(e,t={}){let{onActivate:i,onDeactivate:s}=t;o._activityCallbacks.set(this,{activateCallback:i,deactivateCallback:s});}_unregisterActivity(){this.isActivityActive&&this._deactivate(),o._activityCallbacks.delete(this);}disconnectedCallback(){super.disconnectedCallback(),this._isActivityRegistered()&&this._unregisterActivity();}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")??null}get doneActivity(){return this.getCssData("--cfg-done-activity")??null}historyBack(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let i=!!t;t&&(i=[...this.blocksRegistry].find(n=>n.activityType===t)?.couldOpenActivity??false),t=i?t:null,this.$["*currentActivity"]=t??null,t&&this.modalManager?.open(t),this.$["*history"]=e,t||this.modalManager?.closeAll();}}};E.activities=A;var _=class o extends E{constructor(){super(...arguments);this.couldBeCtxOwner=false;this._isCtxOwner=false;this.init$=pr(this);this._flushOutputItems=S(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(b.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t);},300);this._handleCollectionUpdate=(e,t,i)=>{if(this.isConnected){(t.size||i.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...t].map(s=>s.uid));for(let s of t)s.getValue("silent")||this.emit(b.FILE_ADDED,this.api.getOutputItem(s.uid)),this._sharedInstancesBag.wait("pluginManager").then(n=>n.runOnAddHooks(s));this.validationManager.runCollectionValidators();for(let s of i){this.$["*uploadTrigger"].delete(s.uid),this.validationManager.cleanupValidationForEntry(s),s.getValue("abortController")?.abort(),s.setMultipleValues({isRemoved:true,abortController:null,isUploading:false,uploadProgress:0});let n=s?.getValue("thumbUrl");n&&URL.revokeObjectURL(n),this.emit(b.FILE_REMOVED,this.api.getOutputItem(s.uid));}this.$["*uploadList"]=e.map(s=>({uid:s})),this._flushCommonUploadProgress(),this._flushOutputItems();}};this._handleCollectionPropertiesUpdate=e=>{if(!this.isConnected)return;this._flushOutputItems();let t=this.uploadCollection,i=[...new Set(Object.entries(e).filter(([s])=>["file","uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(s)).flatMap(([,s])=>[...s]))];if(i.length>0&&setTimeout(()=>{if(!this.isConnected)return;let s=i.filter(n=>e.fileInfo?.has(n)&&!!R.getCtx(n)?.store.fileInfo);s.length>0&&this.validationManager.runFileValidators("upload",s),this.validationManager.runFileValidators("change",i);}),e.uploadProgress){for(let s of e.uploadProgress){let n=R.getCtx(s);if(!n)continue;let{isUploading:a,silent:l}=n.store;a&&!l&&this.emit(b.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(s));}this._flushCommonUploadProgress();}if(e.isUploading)for(let s of e.isUploading){let n=R.getCtx(s);if(!n)continue;let{isUploading:a,silent:l}=n.store;a&&!l&&this.emit(b.FILE_UPLOAD_START,this.api.getOutputItem(s));}if(e.fileInfo){for(let s of e.fileInfo){let n=R.getCtx(s);if(!n)continue;let{fileInfo:a,silent:l}=n.store;a&&!l&&this.emit(b.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(s));}this.cfg.cropPreset&&this._setInitialCrop();}if(e.errors){this.validationManager.runCollectionValidators();for(let a of e.errors){let l=R.getCtx(a);if(!l)continue;let{errors:c}=l.store;c.length>0&&(this.emit(b.FILE_UPLOAD_FAILED,this.api.getOutputItem(a)),this.emit(b.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:true}));}let s=t.findItems(a=>!!a.getValue("fileInfo")),n=t.findItems(a=>a.getValue("errors").length>0);t.size>0&&n.length===0&&t.size===s.length&&this.$["*collectionErrors"].length===0&&this.emit(b.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState());}e.cdnUrl&&([...e.cdnUrl].filter(n=>!!this.uploadCollection.read(n)?.getValue("cdnUrl")).forEach(n=>{this.emit(b.FILE_URL_CHANGED,this.api.getOutputItem(n));}),this.$["*groupInfo"]=null);};this._flushCommonUploadProgress=()=>{let e=0,i=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));i.forEach(n=>{let a=this.uploadCollection.readProp(n,"uploadProgress");typeof a=="number"&&(e+=a);});let s=i.length?Math.round(e/i.length):0;this.$["*commonProgress"]!==s&&(this.$["*commonProgress"]=s,this.emit(b.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()));};}get _hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof o?e._isCtxOwner&&e.isConnected&&e!==this:false)}initCallback(){super.initCallback(),this._addSharedContextInstance("*uploadCollection",()=>new wi({initialValue:Jo,watchList:["file","uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]})),this._addSharedContextInstance("*secureUploadsManager",e=>new yi(e)),this._addSharedContextInstance("*validationManager",e=>new _i(e)),this._addSharedContextInstance("*publicApi",e=>new Si(e)),!this._hasCtxOwner&&this.couldBeCtxOwner&&this._initCtxOwner();}getAPI(){return this.api}get validationManager(){return this._getSharedContextInstance("*validationManager")}get api(){return this._getSharedContextInstance("*publicApi")}get uploadCollection(){return this._getSharedContextInstance("*uploadCollection")}get secureUploadsManager(){return this._getSharedContextInstance("*secureUploadsManager")}disconnectedCallback(){super.disconnectedCallback(),this._isCtxOwner&&this._unobserveUploadCollection(),this._flushOutputItems.cancel();}connectedCallback(){super.connectedCallback(),this._isCtxOwner&&this._observeUploadCollection();}_initCtxOwner(){this._isCtxOwner=true,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1;});}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate);}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0;}async _createGroup(e){let t=await this.getUploadClientOptions(),i=e.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),s=new AbortController,n=await uploadFileGroup(i,{...t,signal:s.signal});if(this.$["*collectionState"]!==e){s.abort();return}this.$["*groupInfo"]=n;let a=this.api.getOutputCollectionState();this.emit(b.GROUP_CREATED,a),this.emit(b.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.$["*collectionState"]=a;}_setInitialCrop(){let e=Ai(this.cfg.cropPreset);if(!e)return;let[t]=e,i=this.uploadCollection.findItems(s=>!!s.getValue("fileInfo")&&s.getValue("isImage")&&!s.getValue("cdnUrlModifiers")?.includes("/crop/")).map(s=>this.uploadCollection.read(s)).filter(Boolean);for(let s of i){let n=s.getValue("fileInfo");if(!n||!n.imageInfo){console.warn("Failed to get image info for entry",s.uid);continue}let{width:a,height:l}=n.imageInfo,c=typeof t?.width=="number"&&typeof t?.height=="number"&&t.width>0&&t.height>0?t.width/t.height:1,u=cs(a,l,c),p=q(`crop/${u.width}x${u.height}/${u.x},${u.y}`,"preview"),m=s.getValue("cdnUrl");if(!m){console.warn("Failed to get cdnUrl for entry",s.uid);continue}s.setMultipleValues({cdnUrlModifiers:p,cdnUrl:F(m,p)});}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let i=this.api.getOutputItem(e);return await t(i)}return t}async getUploadClientOptions(){let e=await this.secureUploadsManager.getSecureToken().catch(()=>null);return {store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:us,integration:this.cfg.userAgentIntegration,secureSignature:e?.secureSignature,secureExpire:e?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return Ei(this._sharedInstancesBag)}};_.extSrcList=Object.freeze({...Q});_.sourceTypes=Object.freeze({...T});var Oe=class extends g{constructor(){super(...arguments);this.name="";this._resolvedHref="";this._pluginSvg=null;this._iconHrefResolver=null;}initCallback(){super.initCallback(),this.setAttribute("aria-hidden","true"),this.subConfigValue("iconHrefResolver",t=>{this._iconHrefResolver=t,this._updateResolvedHref();});let e=this._sharedInstancesBag.pluginManager;e?.onPluginsChange&&(this._unsubscribePlugins=e.onPluginsChange(()=>this._updateResolvedHref()));}willUpdate(e){super.willUpdate(e),e.has("name")&&this._updateResolvedHref();}_updateResolvedHref(){if(!this.name){this._resolvedHref="",this._pluginSvg=null;return}let t=this._sharedInstancesBag.pluginManager?.snapshot().icons.find(n=>n.name===this.name);if(t){this._pluginSvg=t.svg,this._resolvedHref="";return}this._pluginSvg=null;let i=`#uc-icon-${this.name}`,s=this._iconHrefResolver?.(this.name);this._resolvedHref=s??i;}render(){return this._pluginSvg?html`${this.yield("",html`${unsafeSVG(this._pluginSvg)}`)}`:html` ${this.yield("",html`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use href=${this._resolvedHref}></use></svg>`)} `}disconnectedCallback(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,super.disconnectedCallback();}};d([property({type:String})],Oe.prototype,"name",2),d([state()],Oe.prototype,"_resolvedHref",2),d([state()],Oe.prototype,"_pluginSvg",2);var fs=o=>[...new Set(o)];var Be="--uc-img-",Er="unresolved";var xr=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),Sr=3e3,Ir=5e3,Ar=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var Ya="https://ucarecdn.com",rt=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Ya},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Mi=class extends We(qe(LitElement)){constructor(){super();this._state={};this._subscribers=new Map;this._isnObserver=null;this._observed=null;for(let e in rt){let t=rt[e];this._state[Be+e]=t?.default||"";}}createRenderRoot(){return this}$$(e){return this._state[Be+e]}set$$(e){for(let t in e){let i=Be+t,s=e[t];this._state[i]=s,this._notify(i,s);}}sub$$(e,t){let i=Be+e;this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(t);let s=this._state[i];s!==null&&s!==""&&t(s);}_notify(e,t){this._subscribers.has(e)&&this._subscribers.get(e)?.forEach(i=>{t===null||t===""||i(t);});}analyticsParams(){return `-/@clib/${pe}/${he}/uc-img/`}initAttributes(e){Array.from(this.attributes).forEach(t=>{let i=t;rt[i.name]||e.setAttribute(i.name,i.value);});}initIntersection(e,t){let i={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(s=>{s.forEach(n=>{n.isIntersecting&&(t(),this._isnObserver?.unobserve(e));});},i),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e);}connectedCallback(){super.connectedCallback(),this._initCssProperties();}_initCssProperties(){for(let e in rt){let t=Be+e,i=this.getCssData(t,true);i!=null&&(this._state[t]=i);}}disconnectedCallback(){super.disconnectedCallback(),this._isnObserver&&(this._observed?.forEach(e=>{this._isnObserver?.unobserve(e);}),this._isnObserver=null),this._subscribers.clear();}static get observedAttributes(){return Object.keys(rt)}attributeChangedCallback(e,t,i){window.setTimeout(()=>{let s=Be+e;this._state[s]=i,this._notify(s,i);});}};var gs=o=>Object.entries(o).filter(([r,e])=>e!==void 0&&e!=="").map(([r,e])=>r==="cdn-operations"||r==="analytics"?e:`${r}/${e}`);var Li=class extends Mi{constructor(){super(...arguments);this._img=new Image;this._imgPreview=new Image;}_fmtAbs(e){return !e.includes("//")&&!xr&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if(!e)return;let t=e,i=t.match(/\d+/)?.[0],s=t.match(/[a-zA-Z]+/)?.[0];if(!i||!s)return;let n=parseInt(i,10);return Number(n)>Ir&&this._hasFormatJPG?Ir+s:Number(n)>Sr&&!this._hasFormatJPG?Sr+s:e}_getCdnModifiers(e,t){let i={format:this._getTypedCssValue("format"),quality:this._getTypedCssValue("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this._getTypedCssValue("cdn-operations")??void 0,analytics:this.analyticsParams()};return q(...gs(i))}_getTypedCssValue(e){let t=this.$$(e);if(t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t}_getUrlBase(e="",t=""){let i=this.$$("src");if(i.startsWith("data:")||i.startsWith("blob:"))return i;if(xr&&i&&!i.includes("//"))return this._proxyUrl(i);let s=this._getCdnModifiers(e,t),n=this.$$("cdn-cname"),a=n;if(i.startsWith(String(n)))return F(i,s);let l=this.$$("uuid");if(a&&l)return this._proxyUrl(F(Ae(a,l),s));if(l)return this._proxyUrl(F(Ae(a,l),s));let c=this.$$("proxy-cname");if(c)return this._proxyUrl(F(c,s,this._fmtAbs(i)));let u=this.$$("pubkey");if(u)return this._proxyUrl(F(`https://${u}.ucr.io/`,s,this._fmtAbs(i)))}_proxyUrl(e){let t=this.$$("secure-delivery-proxy");return t?Ye(t,{previewUrl:e},{transform:i=>window.encodeURIComponent(i)}):e}_getElSize(e,t=1,i=true){let s=e.getBoundingClientRect(),n=t*Math.round(s.width),a=i?"":t*Math.round(s.height);return n||a?`${n||""}x${a||""}`:null}_setupEventProxy(e){let t=s=>{s.stopPropagation();let n=new Event(s.type,s);this.dispatchEvent(n);},i=["load","error"];for(let s of i)e.addEventListener(s,t);}get img(){return this._hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get _currentImg(){return this._hasPreviewImage?{type:Ar.PREVIEW,img:this._imgPreview}:{type:Ar.MAIN,img:this.img}}get _hasPreviewImage(){return this.$$("is-preview-blur")}get _bgSelector(){return this.$$("is-background-for")}get _breakpoints(){let e=this.$$("breakpoints");if(e){let t=N(e);return fs(t.map(i=>parseInt(i,10)))}else return null}get _hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}_renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let i=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",i),e.style.setProperty("background-image",`-webkit-${i}`);}_getSrcset(){let e=new Set;return this._breakpoints?this._breakpoints.forEach(t=>{e.add(`${this._getUrlBase(`${t}x`)} ${this._validateSize(`${t}w`)}`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(`${t*2}x`)} ${this._validateSize(`${t*2}w`)}`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(`${t*3}x`)} ${this._validateSize(`${t*3}w`)}`);}):(e.add(`${this._getUrlBase(this._getElSize(this._currentImg.img))} 1x`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this._currentImg.img,2))} 2x`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this._currentImg.img,3))} 3x`)),[...e].join()}_getSrc(){return this._getUrlBase()}get _srcUrlPreview(){return this._getUrlBase("100x","100")}_renderBackground(){let e=this._bgSelector;[...document.querySelectorAll(e)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this._renderBg(t);}):this._renderBg(t);});}_appendURL({elNode:e,src:t,srcset:i}){t&&(e.src=t),i&&(e.srcset=i);}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e);}_loaderImage({src:e,srcset:t,elNode:i}){return new Promise((s,n)=>{this._setupConfigForImage({elNode:i}),i.setAttribute(Er,""),i.addEventListener("load",()=>{i.removeAttribute(Er),s(i);}),i.addEventListener("error",()=>{n(false);}),this._appendURL({elNode:i,src:e,srcset:t});})}async _renderImage(){if(this.$$("intersection")){this._hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this._currentImg.img,async()=>{this._hasPreviewImage&&(this._imgPreview.src=this._srcUrlPreview);try{await this._loaderImage({src:this._getSrc(),srcset:this._getSrcset(),elNode:this._img}),this._hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img);}catch{this._hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img);}});return}try{this._hasPreviewImage&&(await this._loaderImage({src:this._srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this._loaderImage({src:this._getSrc(),srcset:this._getSrcset(),elNode:this._img}),this._hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img);}catch{this._hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img);}}init(){this._bgSelector?this._renderBackground():this._renderImage();}};var kr=class extends Li{connectedCallback(){super.connectedCallback(),this.sub$$("src",()=>{this.init();}),this.sub$$("uuid",()=>{this.init();}),this.sub$$("lazy",r=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=r?"lazy":"eager");});}};var Mr=null,It=class extends g{constructor(){super(...arguments);this.dialogEl=createRef();this.strokes=false;this.blockBodyScrolling=false;this.closeDialog=()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="",this.$["*currentActivity"]=null);};this._handleDialogClose=()=>{this.closeDialog();};this._handleDialogMouseDown=e=>{this._mouseDownTarget=e.target;};this._handleDialogMouseUp=e=>{let t=e.target;t===this.dialogEl.value&&t===this._mouseDownTarget&&this.closeDialog();};this._handleModalOpen=({id:e})=>{e===this.id?(Mr=e,this.show(),this.emit(b.MODAL_OPEN,{modalId:e},{debounce:true})):this.hide();};this._handleModalClose=({id:e})=>{e===this.id&&(this.hide(),this.emit(b.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:true}));};this._handleModalCloseAll=e=>{this.hide(),Mr===this.id&&this.emit(b.MODAL_CLOSE,{modalId:Mr,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:true});};}static{this.styleAttrs=[...super.styleAttrs,"uc-modal"];}async show(){await this.updateComplete;let e=this.dialogEl.value;typeof e.showModal=="function"?(this.setAttribute("aria-modal","true"),e.showModal()):e.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden");}hide(){let e=this.dialogEl.value;e&&(typeof e.close=="function"?(this.setAttribute("aria-modal","false"),e.close()):e.removeAttribute("open"));}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this),this.subConfigValue("modalBackdropStrokes",e=>{e?this.setAttribute("strokes",""):this.removeAttribute("strokes");}),this.modalManager?.subscribe(B.OPEN,this._handleModalOpen),this.modalManager?.subscribe(B.CLOSE,this._handleModalClose),this.modalManager?.subscribe(B.CLOSE_ALL,this._handleModalCloseAll);}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0,this.modalManager?.unsubscribe(B.OPEN,this._handleModalOpen),this.modalManager?.unsubscribe(B.CLOSE,this._handleModalClose),this.modalManager?.unsubscribe(B.CLOSE_ALL,this._handleModalCloseAll);}_handleDialogRef(e){this.dialogEl={value:e},this.dialogEl.value?.addEventListener("close",this._handleDialogClose),this.dialogEl.value?.addEventListener("mousedown",this._handleDialogMouseDown),this.dialogEl.value?.addEventListener("mouseup",this._handleDialogMouseUp);}render(){return html`<dialog ${ref(this._handleDialogRef)}>${this.yield("")}</dialog>`}};d([property({type:Boolean,noAccessor:true})],It.prototype,"strokes",2),d([property({type:Boolean,attribute:"block-body-scrolling",noAccessor:true})],It.prototype,"blockBodyScrolling",2);var Ri=class extends _{constructor(){super(...arguments);this._validationInputElement=null;this._dynamicInputsContainer=null;}get _inputName(){return this.nameAttrValue??this.ctxName}_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this._inputName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,Ti(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{if(!e)return;if(!this._dynamicInputsContainer){let n=document.createElement("div");this.appendChild(n),this._dynamicInputsContainer=n;}if(!this._validationInputElement){let n=this._createValidationInput();this.appendChild(n),this._validationInputElement=n;}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let n=e.errors[0]?.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(n??"");return}let t=e.group?e.group:null;if(t){this._validationInputElement.value=t.cdnUrl??"",this._validationInputElement.setCustomValidity("");return}let i=e.allEntries.map(n=>n.cdnUrl).filter(n=>typeof n=="string");if(!this.cfg.multiple&&i.length===1&&i[0]){this._validationInputElement.value=i[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let s=new DocumentFragment;for(let n of i){let a=document.createElement("input");a.type="hidden",a.name=`${this._inputName}[]`,a.value=n,s.appendChild(a);}this._dynamicInputsContainer.replaceChildren(s);},false);}};d([property({type:String,noAccessor:true,attribute:"name"})],Ri.prototype,"nameAttrValue",2);var Pr=class extends g{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",r=>{this.toggleAttribute("hidden",!!r);});}render(){return html`<a href="https://uploadcare.com/?utm_source=copyright&amp;utm_medium=referral&amp;utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`}};var ot=class extends g{constructor(){super(...arguments);this.hasFileName=false;this.value=0;this.visible=true;this._progressValue=0;this._fakeProgressLineRef=createRef();this._handleFakeProgressAnimation=()=>{let e=this._fakeProgressLineRef.value;if(e){if(!this.visible){e.classList.add("uc-fake-progress--hidden");return}this._progressValue>0&&e.classList.add("uc-fake-progress--hidden");}};}firstUpdated(e){super.firstUpdated(e),this._progressValue=this._normalizeProgressValue(this.value),this._updateProgressValueStyle(),this._fakeProgressLineRef.value?.addEventListener("animationiteration",this._handleFakeProgressAnimation);}updated(e){if(super.updated(e),e.has("value")){let t=this._normalizeProgressValue(this.value);if(!this.visible)this._progressValue=t;else {let i=Math.max(this._progressValue,t);i!==this._progressValue&&(this._progressValue=i,this._updateProgressValueStyle());}}e.has("visible")&&(this.classList.toggle("uc-progress-bar--hidden",!this.visible),this.visible?this._updateProgressValueStyle():this._progressValue=this._normalizeProgressValue(this.value));}disconnectedCallback(){super.disconnectedCallback(),this._fakeProgressLineRef.value?.removeEventListener("animationiteration",this._handleFakeProgressAnimation);}_normalizeProgressValue(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}_updateProgressValueStyle(){this.visible&&this.style.setProperty("--l-progress-value",this._progressValue.toString());}render(){return html`<div ${ref(this._fakeProgressLineRef)} class="uc-fake-progress"></div><div class="uc-progress"></div>`}};d([property({type:Boolean,noAccessor:true})],ot.prototype,"hasFileName",2),d([property({type:Number})],ot.prototype,"value",2),d([property({type:Boolean,reflect:true})],ot.prototype,"visible",2);var At=class extends _{constructor(){super();this._visible=false;this._value=0;this.init$={...this.init$,"*commonProgress":0};}initCallback(){super.initCallback(),this._unobserveCollectionCb=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(t=>this.uploadCollection.read(t)?.getValue("isUploading")??false);this._visible=e;}),this.sub("*commonProgress",e=>{this._value=e;});}updated(e){super.updated(e),e.has("visible")&&(this._visible?this.setAttribute("active",""):this.removeAttribute("active"));}disconnectedCallback(){super.disconnectedCallback(),this._unobserveCollectionCb?.(),this._unobserveCollectionCb=void 0;}render(){return html`<uc-progress-bar .value=${this._value} .visible=${this._visible}></uc-progress-bar>`}};d([state()],At.prototype,"_visible",2),d([state()],At.prototype,"_value",2);var st=class extends g{constructor(){super(...arguments);this.value="";this.disabled=false;this.options=[];this._handleChange=e=>{if(this.disabled){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation();let t=e.currentTarget;t&&(this.value=t.value,this.dispatchEvent(new Event("change")));};}render(){return html`<select @change=${this._handleChange} .value=${this.value} ?disabled=${this.disabled}>${this.options.map(e=>html`<option value=${e.value}>${e.text}</option>`)}</select>`}};d([property({type:String,attribute:false})],st.prototype,"value",2),d([property({type:Boolean,reflect:true})],st.prototype,"disabled",2),d([property({type:Array,attribute:false})],st.prototype,"options",2);var Le=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.textOnly=false;this.iconOnly=false;this._iconName="default";this._srcTypeKey="";}willUpdate(e){super.willUpdate(e),e.has("source")&&this._applySource(this.source);}_applySource(e){if(!e){this._srcTypeKey="",this._iconName="default";return}let{label:t,icon:i,id:s}=e;this._srcTypeKey=t,this._iconName=i??s??"default";}activate(){this.source&&(this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{sourceId:this.source.id}}),this.source.onClick());}render(){return html`<button aria-label=${this.l10n(this._srcTypeKey)} type="button" @click=${this.activate}>${this.textOnly?"":html`<uc-icon name=${this._iconName}></uc-icon>`} ${this.iconOnly?"":html`<div class="uc-txt">${this.l10n(this._srcTypeKey)}</div>`}</button>`}};d([property({attribute:false})],Le.prototype,"source",2),d([property({type:Boolean})],Le.prototype,"textOnly",2),d([property({type:Boolean})],Le.prototype,"iconOnly",2),d([state()],Le.prototype,"_iconName",2),d([state()],Le.prototype,"_srcTypeKey",2);var nt=class{constructor(r,e){this._rawSourceList=[];this._ctx=e.ctx,this._sharedInstancesBag=e.sharedInstancesBag,this._onSourcesChange=e.onSourcesChange,r.addController(this);}hostConnected(){this._unsubscribeConfig=this._ctx.sub(v("sourceList"),e=>{this._rawSourceList=N(e),this._updateSources();});let r=this._sharedInstancesBag.pluginManager;r?.onPluginsChange&&(this._unsubscribePlugins=r.onPluginsChange(()=>this._updateSources())),this._updateSources();}hostDisconnected(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,this._unsubscribeConfig?.(),this._unsubscribeConfig=void 0;}_updateSources(){let e=this._sharedInstancesBag.pluginManager?.snapshot().sources??[],t=new Map(e.map(s=>[s.id,s])),i=[];this._rawSourceList.forEach(s=>{let n=this._expandSource(s,t);if(n.length!==1||n[0]!==s){for(let c of n){let u=t.get(c);u&&i.push(this._makePluginSourceConfig(u));}return}let l=t.get(s);l&&i.push(this._makePluginSourceConfig(l));}),this._onSourcesChange(i);}_expandSource(r,e){let t=e.get(r);return t?.expand?t.expand():[r]}_makePluginSourceConfig(r){return {id:r.id,label:r.label,icon:r.icon,onClick:()=>r.onSelect()}}};var kt=class extends _{constructor(){super(...arguments);this._sources=[];this.wrap=false;}initCallback(){super.initCallback(),this._controller=new nt(this,{ctx:this._sharedInstancesBag.ctx,sharedInstancesBag:this._sharedInstancesBag,onSourcesChange:e=>{this._sources=e;}});}updated(e){super.updated(e),this.cfg.sourceListWrap?this.style.removeProperty("display"):this.style.display="contents";}render(){return html`${this._sources.map(e=>html`<uc-source-btn role="listitem" .source=${e} data-source-id=${e.id}></uc-source-btn>`)}`}};d([state()],kt.prototype,"_sources",2),d([property({type:Boolean,attribute:"wrap",noAccessor:true})],kt.prototype,"wrap",2);var Vr=class extends g{render(){return html`<div class="uc-spinner"></div>`}};var de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function He(o){let r=new Image;return {promise:new Promise((i,s)=>{r.src=o,r.onload=()=>i(),r.onerror=n=>s(n);}),image:r,cancel:()=>{r.naturalWidth===0&&(r.src=de);}}}function Mt(o){let r=[];for(let s of o){let n=He(s);r.push(n);}let e=r.map(s=>s.image);return {promise:Promise.allSettled(r.map(s=>s.promise)),images:e,cancel:()=>{r.forEach(s=>{s.cancel();});}}}function $r(o,r=40){if(o.type==="image/svg+xml")return URL.createObjectURL(o);let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return Promise.reject(new Error("Canvas context not supported"));let i=new Image,s=new Promise((n,a)=>{i.onload=()=>{let l=i.height/i.width;l>1?(e.width=r,e.height=r*l):(e.height=r,e.width=r/l),t.fillStyle="rgb(240, 240, 240)",t.fillRect(0,0,e.width,e.height),t.drawImage(i,0,0,e.width,e.height),e.toBlob(c=>{if(!c){a();return}let u=URL.createObjectURL(c);n(u);});},i.onerror=l=>{a(l);};});return i.src=URL.createObjectURL(o),s}var at=class extends _{constructor(){super(...arguments);this._entrySubs=new Set;this.entry=null;}withEntry(e){return (...t)=>{let i=this.entry;if(!i){console.warn("No entry found");return}return e(i,...t)}}subEntry(e,t){this.withEntry((i,s,n)=>{let a=i.subscribe(s,l=>{this.isConnected&&n(l);});this._entrySubs.add(a);})(e,t);}reset(){for(let e of this._entrySubs)e();this._entrySubs=new Set,this.entry=null;}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set;}};function dl(o){let r=new Blob([o],{type:"image/svg+xml"});return URL.createObjectURL(r)}function Ui(o="hsl(209, 21%, 65%)",r=32,e=32){return dl(`<svg width="${r}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${o}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}var hl=3e3,lt=class extends at{constructor(){super(...arguments);this.badgeIcon="";this.uid="";this._thumbUrl="";this._renderedGridOnce=false;this._thumbRect=null;this._isIntersecting=false;this._firstViewMode=this.cfg.filesViewMode;this._generateThumbnail=this.withEntry(async(e,t=false)=>{let i=e.getValue("fileInfo"),s=e.getValue("isImage"),n=e.getValue("uuid"),a=e.getValue("thumbUrl"),l=this._calculateThumbSize(t);if(i&&s&&n){let u=await this.proxyUrl(F(Ae(this.cfg.cdnCname,n),q(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${l}x${l}/center`)));if(a===u)return;let{promise:p}=He(u);p.then(()=>{e.setValue("thumbUrl",u),a?.startsWith("blob:")&&URL.revokeObjectURL(a);}).catch(async()=>{if(!a?.startsWith("blob:"))try{let m=e.getValue("file");if(!m)return;let h=await $r(m,l);e.setValue("thumbUrl",h);}catch(m){this.telemetryManager.sendEventError(m,"thumbnail generation. Failed to generate thumb from file");let h=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ui(h));}});return}if(e.getValue("thumbUrl"))return;let c=e.getValue("file");if(c?.type.includes("image"))try{let u=await $r(c,l);e.setValue("thumbUrl",u);}catch(u){this.telemetryManager.sendEventError(u,"thumbnail generation. Failed to generate thumb from file");let p=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ui(p));}else {let u=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ui(u));}});this._debouncedGenerateThumb=S(this._generateThumbnail.bind(this),100);}_calculateThumbSize(e=false){e&&(this._thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(this?._thumbRect?.height||0),10),parseInt(String(this?._thumbRect?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,hl)}_decodeImage(e,t){return new Promise((i,s)=>{let n=new Image;n.decoding="async";let a=()=>{n&&(n.onload=null,n.onerror=null,n.src=de,t?.removeEventListener("abort",l),n=null);},l=()=>{a(),s(new DOMException("Aborted","AbortError"));};if(t){if(t.aborted){l();return}t.addEventListener("abort",l,{once:true});}let c=()=>{a(),i();},u=p=>{a(),s(p);};if(typeof n.decode=="function"){n.src=e,n.decode().then(c).catch(u);return}n.onload=c,n.onerror=u,n.src=e;})}_cancelPendingThumbUpdate(){this._pendingThumbUpdate?.cancel(),this._pendingThumbUpdate=void 0;}_scheduleThumbUpdate(e){if(this._cancelPendingThumbUpdate(),!e){this._thumbUrl&&(this._thumbUrl="");return}if(e===this._thumbUrl)return;let t=new AbortController,i={controller:t,cancel:()=>{t.abort(),i.rafId!==void 0&&window.cancelAnimationFrame(i.rafId);}};this._pendingThumbUpdate=i,this._decodeImage(e,t.signal).then(()=>{t.signal.aborted||(i.rafId=window.requestAnimationFrame(()=>{t.signal.aborted||(this._thumbUrl=e);}));}).catch(s=>{t.signal.aborted||s instanceof DOMException&&s.name==="AbortError"||console.warn("[Thumb] Failed to decode thumbnail image",s);});}_requestThumbGeneration(e=false){if(this.entry){if(e){this._generateThumbnail(true);return}this._isIntersecting&&this._debouncedGenerateThumb();}}firstUpdated(e){super.firstUpdated(e),this._bindToEntry();}updated(e){super.updated(e),e.has("uid")&&this._bindToEntry();}_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,t.isIntersecting&&(this._thumbRect=t.boundingClientRect,this._requestThumbGeneration(),this._observer?.disconnect()),t.intersectionRatio===0&&this._debouncedGenerateThumb.cancel());}reset(){super.reset(),this._debouncedGenerateThumb.cancel(),this._cancelPendingThumbUpdate(),this._thumbUrl&&(this._thumbUrl="");}_bindToEntry(){let e=this.uid?.trim();if(!e){this.entry&&this.reset();return}let t=this.uploadCollection?.read(e);if(!t||t===this.entry)return;this.reset(),this.entry=t;let i=()=>{this._requestThumbGeneration();};this.subEntry("fileInfo",s=>{s?.isImage&&i();}),this.subEntry("thumbUrl",s=>{this._scheduleThumbUpdate(s??void 0);}),this.subEntry("cdnUrlModifiers",i),this._requestThumbGeneration(true);}initCallback(){super.initCallback(),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this._renderedGridOnce&&(this._firstViewMode==="list"&&this._requestThumbGeneration(true),this._renderedGridOnce=true);});}connectedCallback(){super.connectedCallback(),this._observer?.disconnect(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this._observer.observe(this);}disconnectedCallback(){super.disconnectedCallback(),this._debouncedGenerateThumb.cancel(),this._cancelPendingThumbUpdate(),this._observer?.disconnect();}render(){return html`<div class="uc-thumb"><img class="uc-thumb__img" src=${this._thumbUrl||de} role="img" alt="Preview of uploaded image" ?hidden=${!this._thumbUrl} draggable="false" /><div class="uc-badge"><uc-icon name=${this.badgeIcon}></uc-icon></div></div>`}};d([property({type:String})],lt.prototype,"badgeIcon",2),d([property({attribute:false})],lt.prototype,"uid",2),d([state()],lt.prototype,"_thumbUrl",2);var Dr=class extends E{};var Fr=class extends E{constructor(){super(...arguments);this.historyTracked=true;this.activityType=E.activities.START_FROM;}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"");}render(){return html`<div class="uc-content">${this.yield("")}</div>`}};var Nr=class extends _{constructor(){super(...arguments);this._unbindEventEmitter=null;}static{this.styleAttrs=["uc-wgt-common"];}static{this.EventType=b;}initCallback(){super.initCallback(),this._unbindEventEmitter=this.eventEmitter.bindTarget(this);}disconnectedCallback(){super.disconnectedCallback(),this._unbindEventEmitter?.();}};var Re=(o,r)=>{let e=false,t,i=0,s=((...n)=>{e?(t&&clearTimeout(t),t=setTimeout(()=>{Date.now()-i>=r&&(o(...n),i=Date.now());},Math.max(r-(Date.now()-i),0))):(o(...n),i=Date.now(),e=true);});return Object.defineProperty(s,"cancel",{configurable:false,writable:false,enumerable:false,value:()=>{t&&clearTimeout(t);}}),s};var Ts="file-item-remove-button",ze=class extends _{constructor(){super(...arguments);this.uploading=false;this.failed=false;this.success=false;this.idle=false;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-action-button"];}_handleRemove(){this.dispatchEvent(new CustomEvent("uc:remove",{bubbles:true,composed:true}));}render(){let e=classMap({"uc-remove-btn":true,"uc-mini-btn":true,"uc-idle":this.idle,"uc-uploading":this.uploading,"uc-failed":this.failed,"uc-success":this.success});return html`<button type="button" @click=${this._handleRemove} title=${this.l10n(Ts)} aria-label=${this.l10n(Ts)} class=${e} ><uc-icon name="remove-file"></uc-icon><uc-icon name="close"></uc-icon></button>`}};d([property({type:Boolean})],ze.prototype,"uploading",2),d([property({type:Boolean})],ze.prototype,"failed",2),d([property({type:Boolean})],ze.prototype,"success",2),d([property({type:Boolean})],ze.prototype,"idle",2);var H=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),$=class $ extends at{constructor(){super(...arguments);this.couldBeCtxOwner=true;this._pauseRender=true;this.uid="";this._itemName="";this._errorText="";this._hint="";this._progressValue=0;this._progressVisible=false;this._badgeIcon="";this._isFinished=false;this._isFailed=false;this._isUploading=false;this._isFocused=false;this._showFileNames=false;this._ariaLabelStatusFile="";this._pluginFileActions=[];this._renderedOnce=false;this._handleRemove=()=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uid&&this.uploadCollection.hasItem(this.uid)&&this.uploadCollection.remove(this.uid);};this._handleUploadClick=()=>{this._upload();};this._debouncedCalculateState=S(()=>this._calculateState(),100);this._updateHintAndProgress=this.withEntry(Re((e,t)=>{let i=e.getValue("errors")?.[0]?.message??"",s=e.getValue("source"),n=e.getValue("externalUrl"),a=t===H.FINISHED,l=t===H.UPLOADING,c=t===H.QUEUED_UPLOADING,u=t===H.QUEUED_VALIDATION,p=t===H.VALIDATION,m=e.getValue("fileName"),h="";i?h="":!a&&n&&s&&Object.values(Q).includes(s)&&(h=this.l10n("waiting-for",{source:this.l10n(`src-type-${Zo(s)}`)})),this._hint=h,this._errorText=i,this._progressVisible=l||c||u||p,this._progressValue=u||p?0:e.getValue("uploadProgress"),this._ariaLabelStatusFile=m?this.l10n("a11y-file-item-status",{fileName:m,status:this.l10n(t?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()}):"";},100));this._upload=this.withEntry(async e=>{if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0||e.getValue("isValidationPending"))return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){e.setMultipleValues({isUploading:true,errors:[],isQueuedForUploading:true}),this._debouncedCalculateState();try{let i=new AbortController;e.setValue("abortController",i);let s=async()=>{e.setValue("isQueuedForUploading",!1);let a=e.getValue("file");if(a instanceof File||a instanceof Blob){let m=(this._sharedInstancesBag.pluginManager?.snapshot().fileHooks??[]).filter(h=>h.type==="beforeUpload");for(let h of m)try{let f=h.handler({file:a,signal:i.signal}),P=new Promise((L,G)=>setTimeout(()=>G(new Error("beforeUpload hook timed out")),h.timeout)),{file:w}=await Promise.race([f,P]);w!==a&&(a=w,e.setValue("mimeType",a.type||null),e.setValue("isImage",Ze(a)),e.setValue("fileSize",a.size),a instanceof File&&e.setValue("fileName",a.name));}catch(f){console.warn(`File hook "beforeUpload" from plugin "${h.pluginId}" failed`,f);}}let l=a||e.getValue("externalUrl")||e.getValue("uuid");if(!l)throw new Error("No file input");let u={...await this.getUploadClientOptions(),fileName:e.getValue("fileName")??void 0,source:e.getValue("source")??void 0,onProgress:p=>{if(p.isComputable){let m=p.value*100;e.setValue("uploadProgress",m);}},signal:i.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",l,u),uploadFile(l,u)},n=await this.$["*uploadQueue"].add(s);e.setMultipleValues({fileInfo:n,isQueuedForUploading:!1,isUploading:!1,fileName:n.originalFilename,fileSize:n.size,isImage:n.isImage??!1,mimeType:n.contentInfo?.mime?.mime??n.mimeType,uuid:n.uuid,cdnUrl:e.getValue("cdnUrl")??n.cdnUrl,cdnUrlModifiers:e.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:e.getValue("source")??null}),e===this.entry&&this._debouncedCalculateState();}catch(i){let s=i instanceof CancelError&&i.isCancel;s?e.setMultipleValues({isUploading:false,uploadProgress:0}):i instanceof UploadcareError?e.setMultipleValues({isUploading:false,uploadProgress:0,uploadError:i}):(console.error("Unknown upload error",i),e.setMultipleValues({isUploading:false,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:i})})),e===this.entry&&this._debouncedCalculateState(),this.isConnected&&!s&&this.telemetryManager.sendEventError(i,"file upload. Failed to upload file");}}});}_calculateState(){let e=this.entry;if(!e)return;let t=H.IDLE;e.getValue("errors").length>0?t=H.FAILED:e.getValue("isQueuedForUploading")?t=H.QUEUED_UPLOADING:e.getValue("isQueuedForValidation")?t=H.QUEUED_VALIDATION:e.getValue("isValidationPending")?t=H.VALIDATION:e.getValue("isUploading")?t=H.UPLOADING:e.getValue("fileInfo")&&(t=H.FINISHED),this._handleState(e,t);}_handleState(e,t){t===H.FAILED?this._badgeIcon="badge-error":t===H.FINISHED&&(this._badgeIcon="badge-success"),t===H.UPLOADING&&(this._isFocused=false,this.removeAttribute("focused")),this._isFailed=t===H.FAILED,this._isUploading=t===H.UPLOADING,this._isFinished=t===H.FINISHED,this._updateHintAndProgress(t);}reset(){super.reset(),this._debouncedCalculateState.cancel();}_observerCallback(e){let[t]=e;t&&t.isIntersecting&&!this._renderedOnce&&(this._pauseRender=false,this._renderedOnce=true);}_handleEntryId(e){this.reset();let t=this.uploadCollection?.read(e);if(this.entry=t,!t){this._updatePluginFileActions();return}this.subEntry("isQueuedForValidation",()=>{this._debouncedCalculateState();}),this.subEntry("isValidationPending",()=>{this._debouncedCalculateState();}),this.subEntry("uploadProgress",()=>{this._debouncedCalculateState();}),this.subEntry("isQueuedForUploading",()=>{this._debouncedCalculateState();}),this.subEntry("fileName",i=>{this._itemName=i||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState();}),this.subEntry("externalUrl",i=>{this._itemName=t.getValue("fileName")||i||this.l10n("file-no-name");}),this.subEntry("fileInfo",()=>{this._debouncedCalculateState();}),this.subEntry("errors",()=>this._debouncedCalculateState()),this.subEntry("isUploading",()=>this._debouncedCalculateState()),this.subEntry("fileSize",()=>this._debouncedCalculateState()),this.subEntry("mimeType",()=>this._debouncedCalculateState()),this.subEntry("isImage",()=>this._debouncedCalculateState()),this.subEntry("fileInfo",()=>this._updatePluginFileActions()),this.subEntry("isUploading",()=>this._updatePluginFileActions()),this.subEntry("errors",()=>this._updatePluginFileActions()),this._calculateState(),this._updatePluginFileActions();}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this._showFileNames=true;return}this._showFileNames=e;}willUpdate(e){super.willUpdate(e),e.has("uid")&&this._handleEntryId(this.uid);}_updatePluginFileActions(){let e=this._sharedInstancesBag.pluginManager;if(!e||!this.uid){this._pluginFileActions=[];return}let t=e.snapshot().fileActions,i=this.api.getOutputItem(this.uid);if(!i){this._pluginFileActions=[];return}this._pluginFileActions=t.filter(s=>{try{return s.shouldRender(i)}catch(n){return console.error(`Error in plugin file action shouldRender (${s.id}):`,n),false}});}_handlePluginFileAction(e){if(!this.uid)return;let t=this.api.getOutputItem(this.uid);if(t){this.telemetryManager.sendEvent({payload:{metadata:{event:e.id,node:this.tagName,pluginId:e.pluginId}}});try{e.onClick(t);}catch(i){console.error(`Error in plugin file action onClick (${e.id}):`,i);}}}initCallback(){super.initCallback(),this._handleEntryId(this.uid),this.subConfigValue("filesViewMode",t=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",t);}),this.subConfigValue("gridShowFileNames",t=>{this._updateShowFileNames(t);}),this.onclick=()=>{$.activeInstances.forEach(t=>{t===this?t.setAttribute("focused",""):t.removeAttribute("focused");});},this.sub("*uploadTrigger",t=>{this.entry&&!t.has(this.entry.uid)||setTimeout(()=>this.isConnected&&this._upload());});let e=this._sharedInstancesBag.pluginManager;e?.onPluginsChange&&(this._unsubscribePlugins=e.onPluginsChange(()=>this._updatePluginFileActions())),this._updatePluginFileActions(),$.activeInstances.add(this);}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this);}disconnectedCallback(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,super.disconnectedCallback(),this._observer?.disconnect(),$.activeInstances.delete(this),this.reset();}static{this.activeInstances=new Set;}shouldUpdate(e){return this._pauseRender?false:super.shouldUpdate(e)}render(){return html`<div class="uc-inner" ?data-finished=${this._isFinished} ?data-uploading=${this._isUploading} ?data-failed=${this._isFailed} ?data-focused=${this._isFocused} ><uc-thumb .uid=${this.uid} .badgeIcon=${this._badgeIcon}></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" aria-label=${this._ariaLabelStatusFile}><span class="uc-file-name" ?hidden=${!this._showFileNames}>${this._itemName}</span><span class="uc-file-error" ?hidden=${!this._errorText}>${this._errorText}</span><span class="uc-file-hint" ?hidden=${!this._hint}>${this._hint}</span></div><div class="uc-file-actions">${this._pluginFileActions.map(e=>html`<button type="button" @click=${()=>this._handlePluginFileAction(e)} title=${this.l10n(e.label)} aria-label=${this.l10n(e.label)} class="uc-plugin-action-btn uc-mini-btn" data-plugin-action-id=${e.id} ><uc-icon name=${e.icon}></uc-icon></button>`)}<uc-file-action-button @uc:remove=${this._handleRemove} .uploading=${this._progressVisible} .failed=${this._isFailed} .success=${this._isFinished}></uc-file-action-button><button type="button" class="uc-upload-btn uc-mini-btn" @click=${this._handleUploadClick}><uc-icon name="upload"></uc-icon></button></div></div>`}};d([state()],$.prototype,"_pauseRender",2),d([property({attribute:false})],$.prototype,"uid",2),d([state()],$.prototype,"_itemName",2),d([state()],$.prototype,"_errorText",2),d([state()],$.prototype,"_hint",2),d([state()],$.prototype,"_progressValue",2),d([state()],$.prototype,"_progressVisible",2),d([state()],$.prototype,"_badgeIcon",2),d([state()],$.prototype,"_isFinished",2),d([state()],$.prototype,"_isFailed",2),d([state()],$.prototype,"_isUploading",2),d([state()],$.prototype,"_isFocused",2),d([state()],$.prototype,"_showFileNames",2),d([state()],$.prototype,"_ariaLabelStatusFile",2),d([state()],$.prototype,"_pluginFileActions",2);var Br=$;function Cl(o){return new Promise(r=>{typeof window.FileReader!="function"&&r(false);try{let e=new FileReader;e.onerror=()=>{r(!0);};let t=i=>{i.type!=="loadend"&&e.abort(),r(!1);};e.onloadend=t,e.onprogress=t,e.readAsDataURL(o);}catch{r(false);}})}function wl(o,r){return new Promise(e=>{let t=0,i=[],s=a=>{if(!a){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),e(null);return}a.isFile?(t++,a.file(l=>{t--;let c=new File([l],l.name,{type:l.type||r});i.push({type:"file",file:c,fullPath:a.fullPath}),t===0&&e(i);})):a.isDirectory&&n(a.createReader());},n=a=>{t++,a.readEntries(l=>{t--;for(let c of l)s(c);t===0&&e(i);});};s(o);})}function xs(o){let r=[],e=[];for(let t=0;t<o.items.length;t++){let i=o.items[t];if(i)if(i.kind==="file"){let s=i.type,n=i;if(typeof n.webkitGetAsEntry=="function"||typeof n.getAsEntry=="function"){let l=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():n.getAsEntry?.();l&&e.push(wl(l,s).then(c=>{c&&r.push(...c);}));continue}let a=i.getAsFile();a&&e.push(Cl(a).then(l=>{l||r.push({type:"file",file:a});}));}else i.kind==="string"&&/^text\/uri-list/.test(i.type)&&e.push(new Promise(s=>{i.getAsString(n=>{r.push({type:"url",url:n}),s();});}));}return Promise.all(e).then(()=>r)}var Y=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),Ss=["focus"],Tl=100,Hr=new Map;function El(o,r){let e=Math.max(Math.min(o[0],r.x+r.width),r.x),t=Math.max(Math.min(o[1],r.y+r.height),r.y);return Math.sqrt((o[0]-e)*(o[0]-e)+(o[1]-t)*(o[1]-t))}function zr(o){let r=0,e=document.body,t=new Set,i=f=>{t.add(f);},s=Y.INACTIVE,n=f=>{o.shouldIgnore()&&f!==Y.INACTIVE||(s!==f&&t.forEach(P=>{P(f);}),s=f);},a=()=>r>0;i(f=>o.onChange(f));let l=()=>{r=0,n(Y.INACTIVE);},c=()=>{r+=1,s===Y.INACTIVE&&n(Y.ACTIVE);},u=()=>{r-=1,a()||n(Y.INACTIVE);},p=f=>{f.preventDefault(),r=0,n(Y.INACTIVE);},m=f=>{if(o.shouldIgnore())return;a()||(r+=1);let P=[f.x,f.y],w=o.element.getBoundingClientRect(),L=Math.floor(El(P,w)),G=L<Tl,Zt=f.composedPath().includes(o.element);Hr.set(o.element,L);let po=Math.min(...Hr.values())===L;Zt&&po?(f.preventDefault(),n(Y.OVER)):n(G&&po?Y.NEAR:Y.ACTIVE);},h=async f=>{if(o.shouldIgnore())return;f.preventDefault();let{dataTransfer:P}=f;if(!P)return;let w=await xs(P);o.onItems(w),n(Y.INACTIVE);};return e.addEventListener("drop",p),e.addEventListener("dragleave",u),e.addEventListener("dragenter",c),e.addEventListener("dragover",m),o.element.addEventListener("drop",h),Ss.forEach(f=>{window.addEventListener(f,l);}),()=>{Hr.delete(o.element),e.removeEventListener("drop",p),e.removeEventListener("dragleave",u),e.removeEventListener("dragenter",c),e.removeEventListener("dragover",m),o.element.removeEventListener("drop",h),Ss.forEach(f=>{window.removeEventListener(f,l);});}}var Kr=new Set,oe=class extends _{constructor(){super(...arguments);this.single=false;this.ghost=false;this.disabled=false;this.clickable=false;this.withIcon=false;this.fullscreen=false;this.initflow=false;this._isEnabled=true;this._isVisible=true;this._dropTextKey="drop-files-here";this._isMultiple=false;this._destroyDropzone=null;this._destroyContentWrapperDropzone=null;this._contentWrapperRef=createRef();this._handleAreaInteraction=e=>{if(e instanceof KeyboardEvent){if(e.code!=="Space"&&e.code!=="Enter")return}else if(!(e instanceof MouseEvent))return;if(this.initflow){this.api.initFlow();return}this.api.openSystemDialog();};this._sourceListAllowsLocal=true;this._clickableListenersAttached=false;}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-area"];}_updateDropText(){let e=this.text;if(typeof e=="string"&&e.length>0){this._dropTextKey=e;return}this._dropTextKey=this._isMultiple?"drop-files-here":"drop-file-here";}isActive(){if(!this._isEnabled)return false;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,i=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),s=window.getComputedStyle(this),n=s.visibility!=="hidden"&&s.display!=="none";return t&&n&&i}initCallback(){super.initCallback(),Kr.add(this),this._updateIsEnabled(),this._updateVisibility(),this._updateClickableListeners(),this._updateDragStateAttribute(Y.INACTIVE),this._destroyDropzone=zr({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:e=>{this._updateDragStateAttribute(e);},onItems:e=>{if(!e.length)return;let t=this.uploadCollection.size;e.forEach(i=>{i.type==="url"?this.api.addFileFromUrl(i.url,{source:T.DROP_AREA}):i.type==="file"&&this.api.addFileFromObject(i.file,{source:T.DROP_AREA,fullPath:i.fullPath});}),this.uploadCollection.size>t&&this.routerLayer.navigateAfterFileAdd();}}),this.updateComplete.then(()=>this._setupContentWrapperDropzone()),this.subConfigValue("sourceList",e=>{let t=N(e);this._sourceListAllowsLocal=t.includes(T.LOCAL),this._updateIsEnabled(),this._updateVisibility();}),this.subConfigValue("multiple",e=>{this._isMultiple=!!e,this._updateDropText();});}willUpdate(e){super.willUpdate(e),e.has("disabled")&&(this._updateIsEnabled(),this._updateVisibility()),(e.has("text")||e.has("localeId"))&&this._updateDropText();}updated(e){super.updated(e),e.has("clickable")&&this._updateClickableListeners();}_shouldIgnore(){if(!this._isEnabled||!this._couldHandleFiles())return true;if(!this.fullscreen)return false;let e=Kr;return e.size===0?false:[...e].filter(s=>s!==this).filter(s=>s.isActive()).length>0}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,i=this.uploadCollection.size;return !(e&&t&&i>=t||!e&&i>0)}_updateIsEnabled(){let e=this._sourceListAllowsLocal&&!this.disabled;this._isEnabled=e;}_updateVisibility(){let e=this._isEnabled||!this.querySelector("[data-default-slot]");this._isVisible=e,this.hidden=!e;}_updateDragStateAttribute(e){let t=Object.entries(Y).find(([,i])=>i===e)?.[0].toLowerCase();t&&this.setAttribute("drag-state",t);}_setupContentWrapperDropzone(){if(this._destroyContentWrapperDropzone)return;let e=this._contentWrapperRef.value;e&&(this._destroyContentWrapperDropzone=zr({element:e,onChange:t=>{let i=Object.entries(Y).find(([,s])=>s===t)?.[0].toLowerCase();i&&e.setAttribute("drag-state",i);},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()}));}_updateClickableListeners(){this.clickable&&!this._clickableListenersAttached?(this.addEventListener("keydown",this._handleAreaInteraction),this.addEventListener("click",this._handleAreaInteraction),this._clickableListenersAttached=true):!this.clickable&&this._clickableListenersAttached&&(this.removeEventListener("keydown",this._handleAreaInteraction),this.removeEventListener("click",this._handleAreaInteraction),this._clickableListenersAttached=false);}disconnectedCallback(){super.disconnectedCallback(),Kr.delete(this),this._destroyDropzone?.(),this._destroyContentWrapperDropzone?.(),this._clickableListenersAttached&&(this.removeEventListener("keydown",this._handleAreaInteraction),this.removeEventListener("click",this._handleAreaInteraction),this._clickableListenersAttached=false);}render(){return html` ${this.yield("",html`<div data-default-slot hidden></div><div ${ref(this._contentWrapperRef)} class="uc-content-wrapper" ?hidden=${!this._isVisible} ><div class="uc-icon-container" ?hidden=${!this.withIcon}><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">${this.l10n(this._dropTextKey)}</span></div>`)} `}};d([property({type:Boolean,noAccessor:true})],oe.prototype,"single",2),d([property({type:Boolean,noAccessor:true})],oe.prototype,"ghost",2),d([property({type:Boolean,reflect:true})],oe.prototype,"disabled",2),d([property({type:Boolean,reflect:true})],oe.prototype,"clickable",2),d([property({type:Boolean,attribute:"with-icon",reflect:true})],oe.prototype,"withIcon",2),d([property({type:Boolean,reflect:true})],oe.prototype,"fullscreen",2),d([property({type:Boolean,reflect:true})],oe.prototype,"initflow",2),d([property({type:String})],oe.prototype,"text",2),d([state()],oe.prototype,"_isEnabled",2),d([state()],oe.prototype,"_isVisible",2);var ue=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.historyTracked=true;this.activityType=E.activities.UPLOAD_LIST;this._doneBtnVisible=false;this._doneBtnEnabled=false;this._uploadBtnVisible=false;this._addMoreBtnVisible=false;this._addMoreBtnEnabled=false;this._commonErrorMessage=null;this._hasFiles=false;this._latestSummary=null;this._handleAdd=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(true);};this._handleUpload=()=>{this.emit(b.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate();};this._handleDone=()=>{this.emit(b.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow();};this._handleCancel=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll();};this._throttledHandleCollectionUpdate=Re(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll());},300);}get _headerText(){return this._latestSummary?this._getHeaderText(this._latestSummary):""}_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount,validatingBeforeUploading:e.idleEntries.filter(h=>h.isValidationPending).length},i=!e.errors.some(h=>h.type==="TOO_MANY_FILES"||h.type==="TOO_FEW_FILES"),s=e.errors.some(h=>h.type==="TOO_MANY_FILES"),n=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),a=e.allEntries.some(h=>h.isValidationPending),l=t.failed===0&&e.errors.length===0&&!a,c=false,u=false,p=false;if(t.total-t.succeed-t.uploading-t.failed>0&&i&&l&&this.cfg.confirmUpload)c=true;else {u=true;let h=this.cfg.groupOutput?!!e.group:true;p=t.total===t.succeed&&i&&l&&h;}this._doneBtnVisible=u,this._doneBtnEnabled=p,this._uploadBtnVisible=c,this._addMoreBtnEnabled=t.total===0||!s&&!n,this._addMoreBtnVisible=!n||this.cfg.multiple,this._hasFiles=t.total>0,this._latestSummary=t;}_getHeaderText(e){let t=i=>{let s=e[i];return i==="uploading"&&(s+=e.validatingBeforeUploading),this.l10n(`header-${i}`,{count:s})};return e.uploading>0||e.validatingBeforeUploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",e=>{e&&this._throttledHandleCollectionUpdate();}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e);}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity);}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this.sub("*collectionErrors",e=>{let t=e.filter(i=>i.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this._commonErrorMessage=null;return}this._commonErrorMessage=t.message;});}disconnectedCallback(){super.disconnectedCallback(),this.has("*uploadCollection")&&(this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.unobserveCollection(this._throttledHandleCollectionUpdate));}render(){return html`<uc-activity-header><span aria-live="polite" class="uc-header-text">${this._headerText}</span><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" ?hidden=${this._hasFiles}>${this.yield("empty",html`<span>${this.l10n("no-files")}</span>`)}</div><div class="uc-files"><div class="uc-files-wrapper">${repeat(this.$["*uploadList"]??[],({uid:e})=>e,({uid:e})=>html`<uc-file-item .uid=${e}></uc-file-item>`)}</div><button type="button" class="uc-add-more-btn uc-secondary-btn" @click=${this._handleAdd} ?disabled=${!this._addMoreBtnEnabled} ?hidden=${!this._addMoreBtnVisible} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button></div><div class="uc-common-error" ?hidden=${!this._commonErrorMessage} >${this._commonErrorMessage??""}</div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("clear")}</button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" ?hidden=${!this._addMoreBtnVisible} ?disabled=${!this._addMoreBtnEnabled} @click=${this._handleAdd} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button><button type="button" class="uc-upload-btn uc-primary-btn" ?hidden=${!this._uploadBtnVisible} @click=${this._handleUpload} >${this.l10n("upload")}</button><button type="button" class="uc-done-btn uc-primary-btn" ?hidden=${!this._doneBtnVisible} ?disabled=${!this._doneBtnEnabled} @click=${this._handleDone} >${this.l10n("done")}</button></div><uc-drop-area ghost></uc-drop-area>`}};d([state()],ue.prototype,"_doneBtnVisible",2),d([state()],ue.prototype,"_doneBtnEnabled",2),d([state()],ue.prototype,"_uploadBtnVisible",2),d([state()],ue.prototype,"_addMoreBtnVisible",2),d([state()],ue.prototype,"_addMoreBtnEnabled",2),d([state()],ue.prototype,"_commonErrorMessage",2),d([state()],ue.prototype,"_hasFiles",2),d([state()],ue.prototype,"_latestSummary",2);var Al=[{test:o=>!!o.accept&&!!o.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:o=>o.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:o=>o.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],ks=S(o=>{for(let{test:r,message:e}of Al)r(o)&&xi(e);},0);var Ms=o=>o instanceof Promise||!!(o&&typeof o=="object"&&"then"in o&&typeof o.then=="function");var Gr=o=>o,Pl=[Gr({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:o,enableVideoRecording:r})=>{let e=r();if(e===null)return o();let t=V(o());return e&&!t.includes("video")?t=t.concat("video"):e||(t=t.filter(i=>i!=="video")),_e(t)}}),Gr({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:o,defaultCameraMode:r})=>{let e=r();if(e===null)return o();let t=V(o());return t=t.sort((i,s)=>i===e?-1:s===e?1:0),_e(t)}}),Gr({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:o,cdnCname:r,cdnCnamePrefixed:e})=>{let t=o(),i=r(),s=e();return t&&(i===_t||isPrefixedCdnBase(i,s))?getPrefixedCdnBaseAsync(t,s):i}})],Ps=({key:o,setValue:r,getValue:e,computationControllers:t})=>{for(let i of Pl){if(!i.deps.includes(o))continue;let s={[i.key]:()=>e(i.key)};for(let l of i.deps)s[l]=()=>e(l);let n=new AbortController;t.get(i.fn)?.abort(),t.set(i.fn,n);let a;try{a=i.fn(s,{signal:n.signal});}catch(l){t.get(i.fn)===n&&t.delete(i.fn),console.error(`Failed to compute value for "${i.key}"`,l);return}Ms(a)?a.then(l=>{n.signal.aborted||r(i.key,l);}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${i.key}"`,l);}).finally(()=>{t.get(i.fn)===n&&t.delete(i.fn);}):r(i.key,a);}};var I=o=>String(o),K=o=>{let r=Number(o);if(Number.isNaN(r))throw new Error(`Invalid number: "${o}"`);return r},k=o=>{if(typeof o>"u"||o===null)return false;if(typeof o=="boolean")return o;if(o==="true"||o==="")return true;if(o==="false")return false;throw new Error(`Invalid boolean: "${o}"`)},Os=o=>o==="auto"?o:k(o),Ls=o=>{let r=I(o);if(r!=="user"&&r!=="environment"&&r!=="")throw new Error(`Invalid value: "${r}"`);return r},Rs=o=>{let r=I(o);if(!Object.values(C).includes(r))throw new Error(`Invalid value: "${r}"`);return r},Us=o=>{let r=I(o),e=V(r);if(e.some(t=>!Object.values(C).includes(t)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return r},Vs=o=>{let r=I(o);if(r==="local"||r==="global")return r;if(k(o)===false)return false;throw new Error(`Invalid value: "${r}"`)},$s=o=>{if(typeof o=="object"&&!Array.isArray(o)||typeof o=="function")return o;throw new Error("Invalid metadata value. Must be an object or function.")},Wr=o=>{if(typeof o=="object")return o;throw new Error("Invalid value. Must be an object.")},$i=o=>{if(typeof o=="function")return o;throw new Error("Invalid value. Must be a function.")},Di=o=>{if(Array.isArray(o))return o;throw new Error("Must be an array.")},Ds=o=>{let r=I(o);if(["grid","list"].includes(r))return r;throw new Error(`Invalid value: "${r}"`)},Fs=o=>{let r=I(o);if(["auto","allwrap","nowrap","collapse"].includes(r))return r;throw new Error(`Invalid value: "${r}"`)};var Ol={pubkey:I,multiple:k,multipleMin:K,multipleMax:K,confirmUpload:k,imgOnly:k,accept:I,externalSourcesPreferredTypes:I,externalSourcesEmbedCss:I,store:Os,cameraMirror:k,cameraCapture:Ls,sourceList:I,topLevelOrigin:I,maxLocalFileSizeBytes:K,thumbSize:K,showEmptyList:k,useLocalImageEditor:k,useCloudImageEditor:k,cloudImageEditorTabs:I,removeCopyright:k,cropPreset:I,imageShrink:I,modalScrollLock:k,modalBackdropStrokes:k,sourceListWrap:k,remoteTabSessionKey:I,cdnCname:I,cdnCnamePrefixed:I,baseUrl:I,socialBaseUrl:I,secureSignature:I,secureExpire:I,secureDeliveryProxy:I,retryThrottledRequestMaxTimes:K,retryNetworkErrorMaxTimes:K,multipartMinFileSize:K,multipartChunkSize:K,maxConcurrentRequests:K,multipartMaxConcurrentRequests:K,multipartMaxAttempts:K,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:k,groupOutput:k,userAgentIntegration:I,debug:k,localeName:I,metadata:$s,secureUploadsExpireThreshold:K,localeDefinitionOverride:o=>Wr(o),secureUploadsSignatureResolver:o=>$i(o),secureDeliveryProxyUrlResolver:o=>$i(o),iconHrefResolver:o=>$i(o),plugins:o=>Di(o),fileValidators:Di,collectionValidators:Di,validationTimeout:K,validationConcurrency:K,cameraModes:Us,defaultCameraMode:Rs,enableAudioRecording:k,enableVideoRecording:k,mediaRecorderOptions:Wr,maxVideoRecordingDuration:K,filesViewMode:Ds,gridShowFileNames:k,cloudImageEditorAutoOpen:k,cloudImageEditorMaskHref:I,testMode:k,qualityInsights:k,pasteScope:Vs,smartButtonShowFirstIcon:k,smartButtonViewMode:Fs},Ns=(o,r)=>{if(!(typeof r>"u"||r===null))try{return Ol[o](r)}catch(e){return console.error(`Invalid value for config key "${o}".`,e),z[o]}};var Fi=[...new Set(["debug",...Object.keys(z)])],Ll=["metadata","plugins","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],Hs=o=>Ll.includes(o),Zr=Fi.filter(o=>!Hs(o)),qr={...Object.fromEntries(Zr.map(o=>[oi(o),o])),...Object.fromEntries(Zr.map(o=>[o.toLowerCase(),o]))},Bs=o=>`__${o}`,ct=class extends g{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(z).map(([e,t])=>[v(e),t]))};this._computationControllers=new Map;this._customAttrKeyMapping={};this._customConfigKeys=new Set;this._customConfigSubscriptions=new Map;}_isCustomConfig(e){return this._customConfigKeys.has(e)}_getCustomConfigDefinition(e){let t=this._sharedInstancesBag.pluginManager;if(t)return t.configRegistry.get(e)}_getAttributeNames(e){return [...new Set([oi(e),e.toLowerCase()])]}_flushValueToAttribute(e,t){if(Hs(e)||this._isCustomConfig(e)&&this._getCustomConfigDefinition(e)?.attribute===false)return;let i=this._getAttributeNames(e);for(let s of i)typeof t>"u"||t===null?this.removeAttribute(s):this.getAttribute(s)!==t.toString()&&this.setAttribute(s,t.toString());}_flushValueToState(e,t){let i=v(e);if(this.$[i]!==t)if(typeof t>"u"||t===null){let s=z[e];this.$[i]=s!==void 0?s:t;}else this.$[i]=t;}_setValue(e,t){let i;if(this._isCustomConfig(e)){let a=this._getCustomConfigDefinition(e);try{i=a?.normalize?.(t)??t;}catch(l){console.warn(`[uc-config] normalize() for "${e}" threw an error, keeping previous value`,l);return}}else i=Ns(e,t);let s=this,n=Bs(e);s[n]!==i&&(this._assertSameValueDifferentReference(e,s[n],i),s[n]=i,this._flushValueToAttribute(e,i),this._flushValueToState(e,i),this.debugPrint(`"${e}"`,i),this._isCustomConfig(e)||ks(this.cfg));}_getValue(e){let t=this,i=Bs(e);return t[i]??this.$[v(e)]}_assertSameValueDifferentReference(e,t,i){this.cfg.debug&&i!==t&&typeof i=="object"&&typeof t=="object"&&JSON.stringify(i)===JSON.stringify(t)&&(console.warn(`[uc-config] Option "${e}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${e}" previous value:`,t),console.warn(`[uc-config] "${e}" new value:`,i));}_processCustomConfigs(e){let t=e.configRegistry.getAll();this._customAttrKeyMapping={},this._customConfigKeys=new Set(t.keys());for(let[i,s]of this._customConfigSubscriptions)t.has(i)||(s(),this._customConfigSubscriptions.delete(i));for(let[i,s]of t){let a=v(i);if(s.attribute){let h=this._getAttributeNames(i);for(let f of h)this._customAttrKeyMapping[f]=i;}let l,c=false,u=Object.getOwnPropertyDescriptor(this,i);if(u&&!u.get&&!u.set&&u.value!==void 0&&(l=u.value,c=true),!c&&s.attribute)for(let h of this._getAttributeNames(i)){let f=this.getAttribute(h);if(f!=null){try{l=s.fromAttribute?s.fromAttribute(f):f;}catch(P){console.warn(`[uc-config] fromAttribute() for "${i}" threw an error, using raw attribute value`,P),l=f;}c=true;break}}this.sharedCtx.has(a)||this.sharedCtx.add(a,s.defaultValue);let m=Object.getOwnPropertyDescriptor(this,i);if((!m||!m.set||!m.get)&&Object.defineProperty(this,i,{set:h=>{this._setValue(i,h);},get:()=>this._getValue(i),enumerable:true,configurable:true}),!this._customConfigSubscriptions.has(i)){let h=this.sub(a,f=>{this._setValue(i,f);},false);this._customConfigSubscriptions.set(i,h);}c&&this._setValue(i,l);}}_setupCustomConfigs(){this._sharedInstancesBag.when("pluginManager",e=>{this._processCustomConfigs(e),this._pluginChangeUnsubscribe=e.onPluginsChange(()=>{this._processCustomConfigs(e);});});}_setupMutationObserver(){this._mutationObserver=new MutationObserver(e=>{for(let t of e)if(t.type==="attributes"&&t.attributeName){let i=t.attributeName,s=t.oldValue,n=this.getAttribute(i);if(s===n||i in qr)continue;if(i in this._customAttrKeyMapping){let l=this._customAttrKeyMapping[i],c=this._getCustomConfigDefinition(l);this.attributeChangedCallback(i,s??"",n??c?.defaultValue??"");}}}),this._mutationObserver.observe(this,{attributes:true,attributeOldValue:true});}initCallback(){super.initCallback();let e=this;this._setupCustomConfigs(),this._setupMutationObserver();for(let i of Zr)this.sub(v(i),s=>{this._setValue(i,s);},false);for(let i of Fi){let s=e[i]??this.$[v(i)];s!==z[i]&&this._setValue(i,s);let n=Object.getOwnPropertyDescriptor(this,i);(!n||!n.set||!n.get)&&Object.defineProperty(this,i,{set:a=>{this._setValue(i,a);},get:()=>this._getValue(i)});}let t=i=>{Ps({key:i,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this._computationControllers});};for(let i of Fi)this.sub(v(i),()=>t(i));}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),t===i)return;let s=this,n=qr[e];n?s[n]=i:this._sharedInstancesBag.when("pluginManager",a=>{let l=this.getAttribute(e);if(l&&l!==i)return;let c=this._customAttrKeyMapping[e],u=c?a.configRegistry.get(c):void 0;if(c&&u){let p=u.fromAttribute?u.fromAttribute(i):i;if(this._getValue(c)===p)return;this._setValue(c,p);}});}disconnectedCallback(){super.disconnectedCallback(),this._pluginChangeUnsubscribe&&(this._pluginChangeUnsubscribe(),this._pluginChangeUnsubscribe=void 0),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=void 0);for(let e of this._customConfigSubscriptions.values())e();this._customConfigSubscriptions.clear();}static get observedAttributes(){let e=super.observedAttributes,t=Object.keys(qr);return [...e,...t]}};for(let o of Fi)ct.prototype[o]=void 0;var Pt=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.dropzone=true;this._buttonTextKey="upload-file";this._handleClick=()=>{this.api.initFlow();};}static{this.styleAttrs=[...super.styleAttrs,"uc-simple-btn"];}initCallback(){super.initCallback(),this.subConfigValue("multiple",e=>{this._buttonTextKey=e?"upload-files":"upload-file";});}render(){return html`<uc-drop-area .disabled=${!this.dropzone}><button type="button" @click=${this._handleClick}><uc-icon name="upload"></uc-icon><span>${this.l10n(this._buttonTextKey)}</span>${this.yield("")}<div class="uc-visual-drop-area">${this.l10n("drop-files-here")}</div></button></uc-drop-area>`}};d([property({attribute:"dropzone",type:Boolean})],Pt.prototype,"dropzone",2),d([state()],Pt.prototype,"_buttonTextKey",2);var Ke=class Ke extends _{constructor(){super(...arguments);this.showIcon=false;this._isMultiple=false;}static{this.styleAttrs=[...super.styleAttrs,"uc-primary-action"];}static{this.SOURCE_TEXT_CONFIG={[T.LOCAL]:{action:"upload-from"},[T.URL]:{action:"upload-from"},[T.CAMERA]:{action:"capture-with"},[T.MOBILE_PHOTO_CAMERA]:{action:"take"},[T.MOBILE_VIDEO_CAMERA]:{action:"record"}};}initCallback(){super.initCallback(),this.subConfigValue("smartButtonShowFirstIcon",e=>{this.showIcon=e;}),this.subConfigValue("multiple",e=>{this._isMultiple=e;});}get hasEntries(){return (this.entries?.allEntries?.length??0)>0}get hasSingleSuccessImage(){return this.entries?.allEntries?.length===1&&this.entries.isSuccess&&(this.entries.allEntries[0]?.isImage??false)}get hasMultipleEntries(){return (this.entries?.allEntries?.length??0)>=1}get localizedSourceLabel(){return this.source?.label?["local","url","camera"].includes(this.source?.id)?this.l10n(this.source.label).toLowerCase():this.l10n(this.source.label):""}_translate(e,t){return this.l10n(e,t)}get textBasedOnLocale(){let e=this._headerTextDependentOnEntries();return e||this._getSourceLabelText()}_headerTextDependentOnEntries(){if(this.entries?.status==="uploading")return this._translate("header-uploading",{count:this.entries.uploadingCount});if(this.entries?.status==="failed")return this._translate("header-failed",{count:this.entries.failedCount});if(this.entries?.status==="success")return this._translate("header-succeed",{count:this.entries.successCount});if(this.entries?.totalCount>0)return this._translate("header-total",{count:this.entries?.totalCount??0})}_getSourceLabelText(){if(!this.source?.id)return "";let t=Ke.SOURCE_TEXT_CONFIG[this.source.id]?.action??"get-from",i;return this.source.id===T.MOBILE_PHOTO_CAMERA?i=this.l10n("photo").toLowerCase():this.source.id===T.MOBILE_VIDEO_CAMERA?i=this.l10n("video").toLowerCase():i=this.localizedSourceLabel,this._translate(t,{source:i})}_handleClick(){if(this.hasEntries){this._sharedInstancesBag.ctx.pub("*currentActivity","upload-list"),this._sharedInstancesBag.modalManager?.open("upload-list");return}this.source?.onClick();}_renderThumbnail(){if(!this._isMultiple&&this.hasSingleSuccessImage){let t=this.entries.allEntries[0];return t?html`<uc-thumb .uid=${t.internalId}></uc-thumb>`:null}if(this._isMultiple&&this.hasMultipleEntries)return null;let e=this.source?.icon;return this.showIcon&&e?html`<uc-icon .name=${e}></uc-icon>`:null}render(){return html`<button @click=${this._handleClick} aria-label=${this.textBasedOnLocale}>${this._renderThumbnail()}<span>${this.textBasedOnLocale}</span></button>`}};d([property({type:Object})],Ke.prototype,"source",2),d([property({type:Object})],Ke.prototype,"entries",2),d([state()],Ke.prototype,"showIcon",2),d([state()],Ke.prototype,"_isMultiple",2);var Xr=Ke;var Ni=class extends g{constructor(){super(...arguments);this._id=W.generateFastUid();this._handleContentClick=e=>{e.currentTarget.hidePopover();};}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-down"];}render(){return html`<button class="uc-mini-btn uc-dropdown-btn" popovertarget=${this._id} popovertargetaction="toggle">${this.yield("dd-header-button")}</button><div id=${this._id} class="uc-dropdown-content" popover="auto" @click=${this._handleContentClick}>${this.yield("dd-content")}</div>`}};d([state()],Ni.prototype,"_id",2);var Qr=class extends _{static{this.styleAttrs=[...super.styleAttrs,"uc-no-wrap-mode-smart-btn"];}};var Bl=(o,r)=>r==="collapse"||o.length===0?{main:null,remain:o}:{main:o[0]??null,remain:o.slice(1)},Hl={collapse:"paperclip",allwrap:"arrow-dropdown",auto:"arrow-dropdown"},zl=3,ge=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.dropzone=true;this._mode="auto";this._sources=[];this._status="idle";this._progress=0;this._throttledHandleCollectionUpdate=Re(()=>{this.isConnected&&this._updateButtonBasedOnCollectionState();},300);}static{this.styleAttrs=[...super.styleAttrs,"uc-smart-btn","uc-wgt-common"];}get isIdle(){return this._status==="idle"}get isSuccess(){return this._status==="success"}get isFailed(){return this._status==="failed"}get isUploading(){return this._status==="uploading"}get isCollapsedMode(){return this._mode==="collapse"}get shouldShowPrimaryAction(){return !this.isCollapsedMode||!this.isIdle||this.hasCollectionEntries}get shouldShowInline(){return this.isIdle&&!this.hasCollectionEntries&&this._sources.length>1&&(this._mode==="nowrap"||this._mode==="auto"&&this._sources.length<=zl)}get shouldShowDropdown(){return this.isIdle&&!this.shouldShowInline&&!this.hasCollectionEntries&&(this._sources.length>1||this.isCollapsedMode)}get hasCollectionEntries(){return (this._collection?.allEntries?.length??0)>0}get shouldShowAbortAction(){return !this.isIdle&&this.hasCollectionEntries}_updateButtonBasedOnCollectionState(){let e=this.api?.getOutputCollectionState();if(!e){console.warn("Collection state is undefined");return}this._collection=e,this._status=e.status;}_updateSourceSplit(){this._mainAndRemainSources=Bl(this._sources,this._mode);}initCallback(){super.initCallback(),this.subConfigValue("smartButtonViewMode",e=>{this._mode!==e&&(this._mode=e,this._updateSourceSplit());}),this.sub("*commonProgress",e=>{this._progress=e;}),this._controller=new nt(this,{ctx:this._sharedInstancesBag.ctx,sharedInstancesBag:this._sharedInstancesBag,onSourcesChange:e=>{this._sources=e,this._updateSourceSplit();}}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this._unregisterAfterFileAddHook=this.routerLayer.registerAfterFileAddHook(({historyLength:e})=>{if(e>0)return false;let t=this._sharedInstancesBag.ctx.read("*currentActivity");return t?this.modalManager?.close(t):this.modalManager?.closeAll(),this._sharedInstancesBag.ctx.pub("*currentActivity",null),true});}disconnectedCallback(){typeof this._throttledHandleCollectionUpdate.cancel=="function"&&this._throttledHandleCollectionUpdate.cancel(),this._unregisterAfterFileAddHook?.(),super.disconnectedCallback();}_renderInline(){return html`<uc-no-wrap-mode-smart-btn>${this._mainAndRemainSources?.remain?.map(e=>html`<uc-source-btn .iconOnly=${ true} role="menuitem" .source=${e} ></uc-source-btn>`)}</uc-no-wrap-mode-smart-btn>`}_getDropdownIconName(){return Hl[this._mode]??"arrow-dropdown"}_clearAllEntries(){this.uploadCollection.clearAll();}_clearAllFailedEntries(){this._collection.failedEntries.forEach(e=>{e&&this.uploadCollection.hasItem(e.internalId)&&this.uploadCollection.remove(e.internalId);});}_abortAllEntries(){this.uploadCollection.abortAll();}_handleRemove(){switch(this._status){case "failed":this._clearAllFailedEntries();break;case "uploading":this._abortAllEntries();break;default:this._clearAllEntries();}}_renderDropdown(){return html`<uc-drop-down><uc-icon content-for="dd-header-button" name=${this._getDropdownIconName()} ></uc-icon><div content-for="dd-content" role="menu" class="uc-dropdown-menu">${this._mainAndRemainSources?.remain?.map(e=>html`<uc-source-btn role="menuitem" .source=${e} ></uc-source-btn>`)}</div></uc-drop-down>`}_renderPrimaryAction(){return html`<uc-primary-action .entries=${this._collection} .source=${this._mainAndRemainSources?.main} ></uc-primary-action>`}_renderAbortAction(){return html`<uc-file-action-button @uc:remove=${this._handleRemove} .uploading=${this.isUploading} .failed=${this.isFailed} .success=${this.isSuccess} .idle=${this.isIdle} .progress=${this._progress} ></uc-file-action-button>`}_getInnerClassMap(){return classMap({"uc-smart-btn-inner":true,"uc-failed":this.isFailed,"uc-uploading":this.isUploading,"uc-success":this.isSuccess})}_renderVisualDropArea(){return html`<div class="uc-visual-drop-area"><uc-icon name="arrow-down"></uc-icon></div>`}render(){return html`<uc-drop-area .disabled=${!this.dropzone}><div class=${this._getInnerClassMap()}>${cache(this.shouldShowPrimaryAction?this._renderPrimaryAction():null)} ${cache(this.shouldShowInline?this._renderInline():null)} ${cache(this.shouldShowDropdown?this._renderDropdown():null)} ${cache(this.shouldShowAbortAction||this.hasCollectionEntries?this._renderAbortAction():null)} ${cache(this._renderVisualDropArea())}</div></uc-drop-area>`}};d([property({attribute:"dropzone",type:Boolean})],ge.prototype,"dropzone",2),d([state()],ge.prototype,"_mode",2),d([state()],ge.prototype,"_sources",2),d([state()],ge.prototype,"_status",2),d([state()],ge.prototype,"_mainAndRemainSources",2),d([state()],ge.prototype,"_collection",2),d([state()],ge.prototype,"_progress",2);var Rt=class extends E{constructor(){super(...arguments);this._containerRef=createRef();}initCallback(){this.activityType=this.registration?.id??null,this._ensureRegistered(),super.initCallback();}willUpdate(e){super.willUpdate(e),e.has("registration")&&(this._ensureRegistered(),this.isActivityActive&&(this._disposeActivity(),this._renderActivity()));}_ensureRegistered(){this.registration&&(this._isActivityRegistered()||this.registerActivity(this.activityType??"",{onActivate:()=>this._renderActivity(),onDeactivate:()=>this._disposeActivity()}));}async _renderActivity(){await this.updateComplete;let e=this._containerRef.value;if(!e||!this.registration)return;this._disposeActivity();let t=this.$["*currentActivityParams"];try{this._dispose=this.registration.render(e,t)??void 0;}catch(i){console.error(`[Plugin "${this.registration.pluginId}"] Activity render() threw an error`,i);}}_disposeActivity(){let e=this._containerRef.value;if(e){try{this._dispose?.();}catch(t){console.error(`[Plugin "${this.registration?.pluginId}"] Activity dispose threw an error`,t);}this._dispose=void 0,e.replaceChildren();}}disconnectedCallback(){this._disposeActivity(),super.disconnectedCallback();}render(){return html`<div style="display: contents;" ${ref(this._containerRef)}></div>`}};d([property({attribute:false})],Rt.prototype,"registration",2);var ut=class extends g{constructor(){super(...arguments);this.mode="modal";this._activities=[];}initCallback(){super.initCallback();let e=this._sharedInstancesBag.pluginManager;e?.onPluginsChange&&(this._unsubscribePlugins=e.onPluginsChange(()=>this._syncActivities())),this._syncActivities();}_syncActivities(){let e=this._sharedInstancesBag.pluginManager;if(!e){this._activities=[];return}this._activities=e.snapshot().activities;}disconnectedCallback(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,super.disconnectedCallback();}render(){return this.mode==="inline"?html`${repeat(this._activities,e=>e.id,e=>html`<uc-plugin-activity-host .registration=${e}></uc-plugin-activity-host>`)}`:html`${repeat(this._activities,e=>e.id,e=>html`<uc-modal id=${e.id} strokes block-body-scrolling><uc-plugin-activity-host .registration=${e}></uc-plugin-activity-host></uc-modal>`)}`}};d([property({type:String})],ut.prototype,"mode",2),d([state()],ut.prototype,"_activities",2);function Ws(...o){return o.reduce((r,e)=>{if(typeof e=="string")return r[e]=true,r;for(let t of Object.keys(e))r[t]=e[t];return r},{})}function se(...o){let r=Ws(...o);return Object.keys(r).reduce((e,t)=>(r[t]&&e.push(t),e),[]).join(" ")}function qs(o,...r){let e=Ws(...r);for(let t of Object.keys(e))o.classList.toggle(t,!!e[t]);}var Wl=o=>Z.includes(o),Zs=o=>{if(!o)return Z;let r=V(o).filter(Wl);return r.length===0?Z:r};function Ys(o){return {"*originalUrl":null,"*loadingOperations":new Map,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":false,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":Z,"*tabId":O.CROP,"*on.retryNetwork":()=>{let r=o.querySelectorAll("img");for(let e of r){let t=e.src;e.src=de,e.src=t;}o.$["*networkProblems"]=false;},"*on.apply":r=>{if(!r)return;let e=o.$["*originalUrl"];if(!e){console.warn("Original URL is null, cannot apply transformations");return}let t=q(ke(r),"preview"),i=F(e,t),s={originalUrl:e,cdnUrlModifiers:t,cdnUrl:i,transformations:r};o.dispatchEvent(new CustomEvent("apply",{detail:s,bubbles:true,composed:true})),o.remove();},"*on.cancel":()=>{o.remove(),o.dispatchEvent(new CustomEvent("cancel",{bubbles:true,composed:true}));}}}var Xs="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 24 24' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path d='M19.248 9.561 12 16.003 4.752 9.561l.996-1.122L12 13.995l6.252-5.556z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='ruc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#uuc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#uuc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#uuc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#uuc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#uuc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#uuc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#uuc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>";var je={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},pt=class extends g{constructor(){super(...arguments);this._visible=false;this._styles=je;this._visibleStyle=je.visible;this._hiddenStyle=je.hidden;this._externalTransitions=false;this._initialRenderComplete=false;}set visible(e){this._visible=e,this._handleVisible();}get visible(){return this._visible}set styles(e){this._styles=e,this._externalTransitions=true,this._visibleStyle=e.visible??je.visible,this._hiddenStyle=e.hidden??je.hidden;}get styles(){return this._styles}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",qs(this,{[je.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.toggleAttribute("inert",!this._visible);}_dispatchInitialRenderEvent(){this._initialRenderComplete||(this._initialRenderComplete=true,this.dispatchEvent(new CustomEvent("initial-render",{bubbles:true,composed:true})));}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",true),this._externalTransitions||this.classList.add(je.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",false),this._dispatchInitialRenderEvent();},0);}};d([property({type:Boolean})],pt.prototype,"visible",1),d([property({attribute:false})],pt.prototype,"styles",1);var Ut=class extends g{constructor(){super(...arguments);this.active=false;this._lineRef=createRef();this._isAnimating=false;this._handleTransitionEndRight=()=>{let e=this._lineRef.value;e&&(this._resetLine(e),this._isAnimating&&this.active&&this._start());};}firstUpdated(e){super.firstUpdated(e),this.active&&this._start();}updated(e){super.updated(e),e.has("active")&&(this.active?this._start():this._stop());}_start(){let e=this._lineRef.value;if(!e)return;this._isAnimating=true;let{width:t}=this.getBoundingClientRect();e.removeEventListener("transitionend",this._handleTransitionEndRight),e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:true});}_stop(){let e=this._lineRef.value;e&&(this._isAnimating=false,e.removeEventListener("transitionend",this._handleTransitionEndRight),this._resetLine(e));}_resetLine(e){e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)";}render(){return html`<div class="uc-inner"><div class="uc-line" ${ref(this._lineRef)}></div></div>`}};d([property({type:Boolean,reflect:true})],Ut.prototype,"active",2);var le=class extends g{constructor(){super(...arguments);this.text="";this.icon="";this.reverse=false;this.theme="default";this.ariaRole=void 0;this.ariaControls="";this.titleProp="";this.active=false;}firstUpdated(e){super.firstUpdated(e),this._applyReverse(),this._applyThemeClass();}updated(e){super.updated(e),e.has("reverse")&&this._applyReverse(),e.has("theme")&&this._applyThemeClass();}_applyReverse(){this.style.flexDirection=this.reverse?"row-reverse":"";}_applyThemeClass(){this.theme&&this.theme!=="custom"&&(this.className=`uc-${this.theme}`);}get _iconClassMap(){let e=this._computedIconHidden;return {"uc-icon":true,"uc-icon_left":!this.reverse,"uc-icon_right":this.reverse,"uc-icon_hidden":e,"uc-icon_single":this._computedIconSingle}}get _computedIconHidden(){return !this.icon}get _computedIconSingle(){return !this.text&&!this._computedIconHidden}render(){return html`<button type="button" role=${ifDefined(this.ariaRole||void 0)} aria-controls=${ifDefined(this.ariaControls||void 0)} aria-label=${ifDefined(this.l10n(this.titleProp))} title=${ifDefined(this.l10n(this.titleProp))} ><uc-icon class=${classMap(this._iconClassMap)} name=${ifDefined(this.icon||void 0)} ?hidden=${this._computedIconHidden} ></uc-icon><div class="uc-text">${this.text}</div></button>`}};d([property({type:String})],le.prototype,"text",2),d([property({type:String})],le.prototype,"icon",2),d([property({type:Boolean,reflect:true})],le.prototype,"reverse",2),d([property({type:String,reflect:true})],le.prototype,"theme",2),d([property({attribute:"aria-role"})],le.prototype,"ariaRole",2),d([property({attribute:"aria-controls"})],le.prototype,"ariaControls",2),d([property({attribute:"title-prop"})],le.prototype,"titleProp",2),d([property({type:Boolean,noAccessor:true})],le.prototype,"active",2);function Js(o,r){let e={};for(let t of r){let i=o[t];(Object.hasOwn(o,t)||i!==void 0)&&(e[t]=i);}return e}function ht(o,r,e){let i=window.devicePixelRatio,s=Math.min(Math.ceil(r*i),3e3),n=i>=2?"lightest":"normal";return F(o,q(ti,ke(e),`quality/${n}`,`stretch/off/-/resize/${s}x`,`@clib/${pe}/${he}/uc-cloud-image-editor/`))}var $t=class extends g{constructor(){super(...arguments);this._backdropMaskId=`uc-backdrop-mask-${W.generateFastUid()}`;this._guidesHidden=false;this._draggingValue=false;this._svgRef=createRef();this._svgReady=false;this._pendingMaskHref=null;this._handlePointerUp=e=>{this._updateCursor(),this._dragging&&(e.stopPropagation(),e.preventDefault(),this._dragging=false);};this._handlePointerMove=e=>{if(!this._dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this._svgElement;if(!t)return;let{x:i,y:s}=t.getBoundingClientRect(),n=e.x-i,a=e.y-s,l=n-this._dragStartPoint[0],c=a-this._dragStartPoint[1],{direction:u}=this._draggingThumb,p=this._calcCropBox(u,[l,c]);p&&(this.$["*cropBox"]=p);};this._handleSvgPointerMove=e=>{if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(i=>{if(!i||this._shouldThumbBeDisabled(i.direction))return false;let n=i.interactionNode.getBoundingClientRect(),a={x:n.x,y:n.y,width:n.width,height:n.height};return ns(a,[e.x,e.y])});this._hoverThumb=t,this._updateCursor();};}get _svgElement(){return this._svgRef.value??null}get _dragging(){return this._draggingValue}set _dragging(e){this._draggingValue!==e&&(this._draggingValue=e,this._applyGuidesDragState());}_applyGuidesDragState(){this._frameGuides&&this._frameGuides.setAttribute("class",se({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&this._draggingValue,"uc-guides--semi-hidden":!this._guidesHidden&&!this._draggingValue}));}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return false;if(e===""&&t.height<=y&&t.width<=y)return true;let i=t.height<=y&&(e.includes("n")||e.includes("s")),s=t.width<=y&&(e.includes("e")||e.includes("w"));return i||s}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:s,height:n}=e,a=this._svgElement;if(!a)return;let l=re("mask",{id:this._backdropMaskId}),c=re("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),u=re("rect",{x:t,y:i,width:s,height:n,fill:"black"});l.appendChild(c),l.appendChild(u);let p=re("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:`url(#${this._backdropMaskId})`});a.appendChild(p),a.appendChild(l),this._backdropMask=l,this._backdropMaskInner=u;}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block");}));}_updateBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:s,height:n}=e;this._backdropMaskInner&&Me(this._backdropMaskInner,{x:t,y:i,width:s,height:n});}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:i,pathNode:s,interactionNode:n,groupNode:a}=t,l=i==="",c=i.length===2,{x:u,y:p,width:m,height:h}=e;if(l)Me(n,{x:u,y:p,width:m,height:h});else {let P=Pe(Math.min(m,h)/82/2,0,1),w=c?ts(e,i,P):is(e,i,P),L=w.center;if(!L)continue;let G=Math.max(Tr*Pe(Math.min(m,h)/Tr/3,0,1),es);Me(n,{x:L[0]-G,y:L[1]-G,width:G*2,height:G*2}),Me(s,{d:w.d});}let f=this._shouldThumbBeDisabled(i);a.setAttribute("class",se("uc-thumb",{"uc-thumb--hidden":f,"uc-thumb--visible":!f}));}Me(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1});}}_createThumb(e,t){let i=re("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let s=re("rect",{fill:"transparent"}),n=re("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(n),i.appendChild(s),e[t]={direction:t,pathNode:n,interactionNode:s,groupNode:i},t===""&&(i.style.cursor="move"),s.addEventListener("pointerdown",this._handlePointerDown.bind(this,t));}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let i=0;i<3;i++){let s=`${["n","","s"][t]}${["w","","e"][i]}`;s!==""&&this._createThumb(e,s);}return this._createThumb(e,""),e}_createGuides(){let e=re("svg"),t=re("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let i=1;i<=2;i++){let s=re("line",{x1:`${xt*i}%`,y1:"0%",x2:`${xt*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s);}for(let i=1;i<=2;i++){let s=re("line",{x1:"0%",y1:`${xt*i}%`,x2:"100%",y2:`${xt*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s);}return e.classList.add("uc-guides","uc-guides--semi-hidden"),e}_createFrame(){let e=this._svgElement;if(!e)return;let t=document.createDocumentFragment(),i=this._createGuides();t.appendChild(i);let s=this._createThumbs();for(let{groupNode:n}of Object.values(s))t.appendChild(n);e.appendChild(t),this._frameThumbs=s,this._frameGuides=i,this._applyGuidesDragState();}_handlePointerDown(e,t){if(!this._frameThumbs)return;let i=this._frameThumbs[e];if(!i||this._shouldThumbBeDisabled(e))return;let s=this.$["*cropBox"],n=this._svgElement;if(!n)return;let{x:a,y:l}=n.getBoundingClientRect(),c=t.x-a,u=t.y-l;this._dragging=true,this._draggingThumb=i,this._dragStartPoint=[c,u],this._dragStartCrop={...s};}_calcCropBox(e,t){let[i,s]=t,n=this.$["*imageBox"],a=this._dragStartCrop??this.$["*cropBox"],l=this.$["*currentAspectRatio"],c=l?l.width/l.height:void 0;if(e===""?a=os({rect:a,delta:[i,s],imageBox:n}):a=ss({rect:a,delta:[i,s],direction:e,aspectRatio:c,imageBox:n}),!Object.values(a).every(u=>Number.isFinite(u)&&u>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:a});return}return Je(tt(a),n)}_updateCursor(){let e=this._hoverThumb,t=this._svgElement;t&&(t.style.cursor=e?rs(e.direction):"initial");}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this._svgElement;if(!t){this._pendingMaskHref=e;return}this._pendingMaskHref=null;let i=document.createDocumentFragment(),s=re("image",{href:e});s.setAttribute("class","uc-cloud-mask"),i.appendChild(s),t.appendChild(i),this._frameImage=s;}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:i,width:s,height:n}=e;Me(this._frameImage,{x:t,y:i,height:n,width:s});}_render(){this._svgReady&&(this._updateBackdrop(),this._updateFrame(),this._updateMask());}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:i}=t;i.setAttribute("class",se("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}));}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._resizeBackdrop(),this._svgReady&&window.requestAnimationFrame(()=>{this._render();});}),this.sub("*cropBox",e=>{e&&(this._guidesHidden=e.height<=y||e.width<=y,this._applyGuidesDragState(),this._svgReady&&window.requestAnimationFrame(()=>{this._render();}));}),this.subConfigValue("cloudImageEditorMaskHref",e=>{e&&this._createMask(e);}),document.addEventListener("pointermove",this._handlePointerMove,true),document.addEventListener("pointerup",this._handlePointerUp,true);}firstUpdated(e){super.firstUpdated(e),this._initializeSvg();}_initializeSvg(){let e=this._svgElement;if(!(!e||this._svgReady)){if(this._createBackdrop(),this._createFrame(),this._svgReady=true,e.addEventListener("pointermove",this._handleSvgPointerMove,true),this._pendingMaskHref){let t=this._pendingMaskHref;this._pendingMaskHref=null,this._createMask(t);}this._render();}}disconnectedCallback(){super.disconnectedCallback(),this._svgElement?.removeEventListener("pointermove",this._handleSvgPointerMove,true),document.removeEventListener("pointermove",this._handlePointerMove,true),document.removeEventListener("pointerup",this._handlePointerUp,true);}render(){return html`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${ref(this._svgRef)}></svg>`}};d([state()],$t.prototype,"_draggingValue",2);function ac(o){return o?[({dimensions:e,coords:t})=>[...e,...t].every(i=>Number.isInteger(i)&&Number.isFinite(i)),({dimensions:e,coords:t})=>e.every(i=>i>0)&&t.every(i=>i>=0)].every(e=>e(o)):true}var Dt=class extends g{constructor(){super();this.ctxOwner=true;this._imageSize={width:0,height:0};this._ctx=null;this._isActive=false;this._image=null;this._canvasRef=createRef();this._frameRef=createRef();this.init$={...this.init$,"*padding":20,"*operations":{rotate:0,mirror:false,flip:false},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=S(this._commit.bind(this),300),this._handleResizeThrottled=Re(()=>{!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw());},100);}firstUpdated(e){super.firstUpdated(e),this._initCanvas();}_syncTransformations(){let e=this.$["*editorTransformations"],t=Js(e,Object.keys(this.$["*operations"])),i={...this.$["*operations"],...t};this.$["*operations"]=i;}_initCanvas(){let e=this._canvasRef.value;if(!e)return;let t=e.getContext("2d"),i=this.offsetWidth,s=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${i}px`,e.style.height=`${s}px`,e.width=i*n,e.height=s*n,t?.scale(n,n),this._canvas=e,this._ctx=t;}_alignImage(){if(!this._isActive||!this._image)return;let e=this._image,t=this.$["*padding"],i=this.$["*operations"],{rotate:s}=i,n={width:this.offsetWidth,height:this.offsetHeight},a=et({width:e.naturalWidth,height:e.naturalHeight},s),l;if(a.width>n.width-t*2||a.height>n.height-t*2){let c=a.width/a.height,u=n.width/n.height;if(c>u){let p=n.width-t*2,m=p/c,h=0+t,f=t+(n.height-t*2)/2-m/2;l={x:h,y:f,width:p,height:m};}else {let p=n.height-t*2,m=p*c,h=t+(n.width-t*2)/2-m/2,f=0+t;l={x:h,y:f,width:m,height:p};}}else {let{width:c,height:u}=a,p=t+(n.width-t*2)/2-c/2,m=t+(n.height-t*2)/2-u/2;l={x:p,y:m,width:c,height:u};}this.$["*imageBox"]=tt(l);}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:s}=i,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=t;if(n){let{dimensions:[m,h],coords:[f,P]}=n,{width:w}=et(this._imageSize,s),L=a/w;e=Je(tt({x:l+f*L,y:c+P*L,width:m*L,height:h*L}),t);}let u=this.$["*currentAspectRatio"],p=u?u.width/u.height:void 0;if(!as(e,t)||p&&!ls(e,p)){let m=t.width/t.height,h=t.width,f=t.height;p&&(m>p?h=Math.min(t.height*p,t.width):f=Math.min(t.width/p,t.height)),e={x:t.x+t.width/2-h/2,y:t.y+t.height/2-f/2,width:h,height:f};}this.$["*cropBox"]=Je(tt(e),t);}_drawImage(){let e=this._ctx;if(!e)return;let t=this._image;if(!t)return;let i=this.$["*imageBox"],s=this.$["*operations"],{mirror:n,flip:a,rotate:l}=s,c=et({width:i.width,height:i.height},l);e.save(),e.translate(i.x+i.width/2,i.y+i.height/2),e.rotate(l*Math.PI*-1/180),e.scale(n?-1:1,a?-1:1),e.drawImage(t,-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._frameRef.value?.toggleThumbs(true),this._transitionToImage(),setTimeout(()=>{this.className=se({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":false});}));}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:s}=i,{width:n,height:a}=t,{width:l,height:c}=et(this._imageSize,s),{width:u,height:p}=e,m=n/l,h=a/c;return [Pe(Math.round(u/m),1,l),Pe(Math.round(p/h),1,c)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:s}=i,{width:n,height:a,x:l,y:c}=t,{width:u,height:p}=et(this._imageSize,s),{x:m,y:h}=e,f=n/u,P=a/p,w=this._getCropDimensions(),L={dimensions:w,coords:[Pe(Math.round((m-l)/f),0,u-w[0]),Pe(Math.round((h-c)/P),0,p-w[1])]};if(!ac(L)){console.error("Cropper is trying to create invalid crop object",{payload:L});return}if(!(w[0]===u&&w[1]===p))return L}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:i,flip:s}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:t,mirror:i,flip:s};this.$["*editorTransformations"]=l;}setValue(e,t){this.$["*operations"]={...this.$["*operations"],[e]:t},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw());}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:t}={}){if(!this._isActive){this._isActive=true,await this.updateComplete,this._initCanvas(),this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{let i=this.$["*originalUrl"],s=this.$["*editorTransformations"];this._image=await this._waitForImage(i,s),this._syncTransformations(),this._handleResizeThrottled(),this._animateIn({fromViewer:t});}catch(i){console.error("Failed to activate cropper",{error:i}),this.telemetryManager.sendEventError(i,"cloud editor image. Failed to activate cropper");}this._observer=new ResizeObserver(i=>{let[s]=i;if(!s)return;s.contentRect.width>0&&s.contentRect.height>0&&this._isActive&&this._image&&this._handleResizeThrottled();}),this._observer.observe(this);}}deactivate({reset:e=false}={}){this._isActive&&(!e&&this._commit(),this._isActive=false,this._transitionToCrop(),this.className=se({"uc-active_from_viewer":false,"uc-active_from_editor":false,"uc-inactive_to_editor":true}),this._frameRef.value?.toggleThumbs(false),this.addEventListener("transitionend",this._reset,{once:true}),this._observer?.disconnect());}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],i=Math.min(this.offsetWidth,e[0])/t.width,s=Math.min(this.offsetHeight,e[1])/t.height,n=Math.min(i,s),a=t.x+t.width/2,l=t.y+t.height/2;this.style.transform=`scale(${n}) translate(${(this.offsetWidth/2-a)/n}px, ${(this.offsetHeight/2-l)/n}px)`,this.style.transformOrigin=`${a}px ${l}px`;}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,i=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${i}px`;}_reset(){this._isActive||(this._image=null);}async _waitForImage(e,t){let i=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let s=await this.proxyUrl(ht(e,i,t)),{promise:n,cancel:a,image:l}=He(s),c=this._handleImageLoading(s);return l.addEventListener("load",c,{once:true}),l.addEventListener("error",c,{once:true}),this._cancelPreload?.(),this._cancelPreload=a,n.then(()=>l).catch(u=>(console.error("Failed to load image",{error:u}),this.$["*networkProblems"]=true,l))}_handleImageLoading(e){let t="crop",i=this.$["*loadingOperations"],s=i.get(t);return s||(s=new Map,i.set(t,s)),s.get(e)||(s.set(e,true),this.$["*loadingOperations"]=i),()=>{let n=i.get(t);n?.has(e)&&(n.delete(e),this.$["*loadingOperations"]=i);}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw();}),this.sub("*cropBox",()=>{this._image&&this._commitDebounced();}),this.sub("*currentAspectRatio",()=>{this._alignCrop();}),setTimeout(()=>{this.sub("*networkProblems",e=>{e||this._isActive&&this._imageSize&&this.activate(this._imageSize,{fromViewer:false});});},0);}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._image&&(this._image=null);}render(){return html`<canvas class="uc-canvas" ${ref(this._canvasRef)}></canvas><uc-crop-frame ${ref(this._frameRef)}></uc-crop-frame>`}};d([state()],Dt.prototype,"_image",2);function Jr(o,r,e){let t=e,i=e-1,s=new Array(t);for(let n=i;n>=0;n-=1)s[n]=Math.ceil((n*r+(i-n)*o)/i);return s}function cc(o){return typeof o=="string"&&o in ce}function dc(o){let r=[];for(let e=0;e<o.length-1;e+=1){let t=o[e],i=o[e+1];typeof t=="number"&&typeof i=="number"&&r.push([t,i]);}return r}function uc(o,r,e){let t=dc(o).find(([n,a])=>n<=r&&r<=a);if(!t)return o.map(()=>0);let[i,s]=t;return o.map(n=>{let a=Math.abs(i-s)||1,l=Math.abs(r-i)/a;return i===n?r>e?1:1-l:s===n?r>=e?l:1:0})}function pc(o,r){return o.map((e,t)=>e<r?o.length-t:t)}function sn(o,r){let e=ce[o].keypointsNumber,{range:t,zero:i}=ce[o];return [...new Set([...Jr(t[0],i,e+1),...Jr(i,t[1],e+1),i,r])].sort((s,n)=>s-n)}var Bi=class extends g{constructor(){super();this._isActive=false;this._hidden=true;this._operation="initial";this._transformations={};this._keypoints=[];this._raf=0;this._previewHostRef=createRef();this._layersHostRef=createRef();this.classList.add("uc-inactive_to_cropper"),this._addKeypointDebounced=S(async(e,t,i)=>{let s=()=>!this._isSame(e,t)||this._value!==i||!!this._keypoints.find(c=>c.value===i);if(s())return;let n=await this._constructKeypoint(e,i),a=new Image;a.src=n.src;let l=this._handleImageLoading(n.src);a.addEventListener("load",l,{once:true}),a.addEventListener("error",l,{once:true}),n.image=a,a.classList.add("uc-fader-image"),a.addEventListener("load",()=>{if(s())return;let c=this._keypoints,u=c.findIndex(f=>f.value>i);u===-1&&(u=c.length);let m=c[u]?.image,h=this._layersHostRef.value;!h||m&&!h.contains(m)||(c.splice(u,0,n),m?h.insertBefore(a,m):h.appendChild(a),this._update(e,i));},{once:true}),a.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});},600);}_handleImageLoading(e){let t=this._operation,i=this.$["*loadingOperations"];i.has(t)||i.set(t,new Map);let s=i.get(t);return s&&!s.get(e)&&(s.set(e,true),this.$["*loadingOperations"]=i),()=>{let n=i.get(t);n?.has(e)&&(n.delete(e),this.$["*loadingOperations"]=i);}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let e of this._keypoints){let{image:t}=e;t&&(t.style.opacity=e.opacity.toString(),t.style.zIndex=e.zIndex.toString());}});}_imageSrc({url:e=this._url,filter:t=this._filter??void 0,operation:i,value:s}={}){if(!e)throw new Error("URL is not defined");let n={...this._transformations};i&&(i==="filter"?t&&typeof s=="number"&&(n.filter={name:t,amount:s}):typeof s=="number"&&(n[i]=s));let a=this.offsetWidth;return this.proxyUrl(ht(e,a,n))}async _constructKeypoint(e,t){return {src:await this._imageSrc({operation:e,value:t}),image:void 0,opacity:0,zIndex:0,value:t}}_isSame(e,t){return this._operation===e&&this._filter===t}set(e){let t=typeof e=="string"?parseInt(e,10):e;!cc(this._operation)||!Number.isFinite(t)||(this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t));}_update(e,t){this._operation=e,this._value=t;let{zero:i}=ce[e],s=this._keypoints.map(l=>l.value),n=uc(s,t,i),a=pc(s,i);this._keypoints.forEach((l,c)=>{let u=n[c],p=a[c];typeof u=="number"&&(l.opacity=u),typeof p=="number"&&(l.zIndex=p);}),this._flush();}_createPreviewImage(){let e=new Image;return e.classList.add("uc-fader-image","uc-fader-image--preview"),e.style.opacity="0",e}async _initNodes(){this._previewImage=this._previewImage||this._createPreviewImage();let e=this._previewImage;e&&this._ensurePreviewAttached(e);let t=this._keypoints.map(c=>c.src),{images:i,promise:s,cancel:n}=Mt(t);i.forEach(c=>{let u=this._handleImageLoading(c.src);c.addEventListener("load",u),c.addEventListener("error",u);}),this._cancelLastImages=()=>{n(),this._cancelLastImages=void 0;};let a=this._operation,l=this._filter;if(await s,this._isActive&&this._isSame(a,l)){let c=this._layersHostRef.value;if(!c)return;c.replaceChildren(),this._keypoints.forEach((u,p)=>{let m=i[p];m&&(m.classList.add("uc-fader-image"),u.image=m,c.appendChild(m));}),this._flush();}}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),i=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",i,{once:true}),this._previewImage.addEventListener("error",i,{once:true}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}}async preload({url:e,filter:t,operation:i,value:s}){if(!i||typeof s!="number")return;this._cancelBatchPreload?.();let n=sn(i,s),a=await Promise.all(n.map(c=>this._imageSrc({url:e,filter:t,operation:i,value:c}))),{cancel:l}=Mt(a);this._cancelBatchPreload=l;}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this._ensurePreviewAttached(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=se({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":false});return}t.style.opacity="0";let i=this._handleImageLoading(e);t.addEventListener("error",i,{once:true}),t.src=e,t.addEventListener("load",()=>{i(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=se({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":false}));},{once:true}),t.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}async activate({url:e,operation:t,value:i,filter:s,fromViewer:n}){if(this._isActive=true,this._hidden=false,await this.updateComplete,this._url=e,this._operation=t??"initial",this._value=i,this._filter=s,this._fromViewer=n,typeof i!="number"&&!s){let l=await this._imageSrc({operation:t,value:i});this._setOriginalSrc(l),this._clearLayersHost();return}!t||typeof i!="number"||(this._keypoints=await Promise.all(sn(t,i).map(l=>this._constructKeypoint(t,l))),this._update(t,i),this._initNodes());}deactivate({hide:e=true}={}){this._isActive=false,this._cancelLastImages?.(),this._cancelBatchPreload?.(),e&&!this._hidden?(this._hidden=true,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=se({"uc-active_from_viewer":false,"uc-active_from_cropper":false,"uc-inactive_to_cropper":true}),this.addEventListener("transitionend",()=>{this._clearLayersHost();},{once:true})):this._clearLayersHost();}_ensurePreviewAttached(e){let t=this._previewHostRef.value;t&&(t.contains(e)||t.appendChild(e));}_clearLayersHost(){this._layersHostRef.value?.replaceChildren();}render(){return html`<div class="uc-fader-preview-host" ${ref(this._previewHostRef)}></div><div class="uc-fader-layers-host" ${ref(this._layersHostRef)}></div>`}};var ve=class extends g{constructor(){super();this._thumbSize=0;this._inputRef=createRef();this._thumbRef=createRef();this._stepsRef=createRef();this.disabled=false;this.min=0;this.max=100;this.defaultValue=0;this.zero=0;this._currentValue=0;this._handleSliderInput=e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this._emitSliderEvent("slider-input",t));};this._handleSliderChange=e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&this._setCurrentValue(t);};this._handleInputFocus=()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)");};this._handleInputBlur=()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)");};this.setAttribute("with-effects","");}_emitSliderEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:{value:t},bubbles:true,composed:true}));}firstUpdated(e){super.firstUpdated(e),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10)||0,this._syncInputValue(this._currentValue),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps(),this._updateValue(this._currentValue);}),this._observer.observe(this);let t=this._inputRef.value;t?.addEventListener("focus",this._handleInputFocus),t?.addEventListener("blur",this._handleInputBlur),window.setTimeout(()=>{this._updateValue(this._currentValue);},0);}willUpdate(e){super.willUpdate(e),e.has("defaultValue")&&this.defaultValue!==this._currentValue&&this._setCurrentValue(this.defaultValue),(e.has("min")||e.has("max"))&&this.hasUpdated&&(this._updateSteps(),this._updateValue(this._currentValue)),e.has("zero")&&this.hasUpdated&&this._updateZeroDot(this._currentValue);}_updateValue(e){this._updateZeroDot(e);let t=this.max-this.min;if(t===0)return;let{width:i}=this.getBoundingClientRect(),a=100/t*(e-this.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{let l=this._thumbRef.value;l&&(l.style.transform=`translateX(${a}px)`);});}_updateZeroDot(e){if(!this._zeroDotEl)return;let t=this.max-this.min;if(t===0)return;this._zeroDotEl.style.opacity=e===this.zero?"0":"1";let{width:i}=this.getBoundingClientRect(),a=100/t*(this.zero-this.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${a}px)`);});}_updateSteps(){let t=this._stepsRef.value;if(!t)return;let{width:i}=t.getBoundingClientRect(),s=Math.ceil(i/2),n=Math.ceil(s/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 p=0;p<n;p+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let p=0;p<n;p+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let u=document.createElement("div");u.className="uc-zero-dot",a.appendChild(u),this._zeroDotEl=u,t.innerHTML="",t.appendChild(a),this._stepsCount=n;}disconnectedCallback(){super.disconnectedCallback();let e=this._inputRef.value;e?.removeEventListener("focus",this._handleInputFocus),e?.removeEventListener("blur",this._handleInputBlur),this._observer?.disconnect(),this._observer=void 0;}_setCurrentValue(e){Number.isFinite(e)&&(this._currentValue=e,this.hasUpdated&&(this._syncInputValue(e),this._updateValue(e)));}_syncInputValue(e){let t=this._inputRef.value;t&&(t.value=String(e));}_extractEventValue(e){let t=e.currentTarget;if(!t)return null;let i=Number.parseInt(t.value,10);return Number.isFinite(i)?i:null}render(){return html`<div class="uc-steps" ${ref(this._stepsRef)}></div><div class="uc-thumb" ${ref(this._thumbRef)}></div><input class="uc-input" type="range" ${ref(this._inputRef)} .min=${String(this.min)} .max=${String(this.max)} .value=${String(this._currentValue)} ?disabled=${this.disabled} @input=${this._handleSliderInput} @change=${this._handleSliderChange} />`}};d([property({type:Boolean,reflect:true})],ve.prototype,"disabled",2),d([property({type:Number})],ve.prototype,"min",2),d([property({type:Number})],ve.prototype,"max",2),d([property({type:Number,attribute:false})],ve.prototype,"defaultValue",2),d([property({type:Number})],ve.prototype,"zero",2),d([state()],ve.prototype,"_currentValue",2);var be="original",Nt=class extends g{constructor(){super(...arguments);this.state={operation:"filter",filter:void 0,originalUrl:"",disabled:false,min:0,max:100,value:0,defaultValue:0,zero:0};this._handleInput=e=>{let{value:t}=e.detail;this.$["*faderEl"]?.set(t),this.state={...this.state,value:t};};}setOperation(e,t){this.state={...this.state,operation:e,filter:t},this._initializeValues();let i=this.$["*faderEl"],s=this.state.originalUrl||this.$["*originalUrl"];i&&s&&i.activate({url:s,operation:this.state.operation,value:this.state.filter===be?void 0:this.state.value,filter:this.state.filter===be?void 0:this.state.filter,fromViewer:false});}_initializeValues(){let e=this.state.operation,{range:t,zero:i}=ce[e],[s,n]=t;this.state={...this.state,min:s,max:n,zero:i};let l=this.$["*editorTransformations"][e];if(e==="filter"){let u=Number(n),p=l;if(p){let{name:m,amount:h}=p;u=m===this.state.filter?h:n;}this.state={...this.state,value:u,defaultValue:u};return}let c=typeof l<"u"?l:i;this.state={...this.state,value:c,defaultValue:c};}apply(){let t={...this.$["*editorTransformations"]};this.state.operation==="filter"?!this.state.filter||this.state.filter===be?delete t.filter:t.filter={name:this.state.filter,amount:this.state.value}:t[this.state.operation]=this.state.value,this.$["*editorTransformations"]=t;}cancel(){this.$["*faderEl"]?.deactivate({hide:false});}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{e&&(this.state={...this.state,originalUrl:e});});}updated(e){if(super.updated(e),e.has("state")){let t=`${this.state.filter??this.state.operation} ${this.state.value}`;this.$["*operationTooltip"]=t;}}render(){return html`<uc-slider-ui .disabled=${this.state.disabled} .min=${this.state.min} .max=${this.state.max} .defaultValue=${this.state.defaultValue} .zero=${this.state.zero} @slider-input=${this._handleInput} ></uc-slider-ui>`}};d([state()],Nt.prototype,"state",2);function mt(o){if(!o)return null;let r=o.match(/^([A-Za-z]+)\s+(\d+)$/);if(!r)return null;let[,e,t]=r;return !e||typeof t>"u"?null:{filter:e,value:Number(t)}}var X=class extends g{constructor(){super(...arguments);this.active=false;this.title="";this.icon="";this.titleProp="";}get buttonClasses(){let e=this.active;return {"uc-active":e,"uc-not_active":!e}}_updateHostStateClasses(){let e=this.buttonClasses;for(let[t,i]of Object.entries(e))this.classList.toggle(t,i);}onClick(e){}connectedCallback(){super.connectedCallback(),this._updateHostStateClasses();}updated(e){super.updated(e),e.has("active")&&this._updateHostStateClasses();}render(){let e=this.onClick,t=this.title;return html`<button role="option" type="button" aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${e} ><uc-icon name=${this.icon}></uc-icon><div class="uc-title" ?hidden=${!t}>${t}</div></button>`}};d([state()],X.prototype,"active",2),d([state()],X.prototype,"title",2),d([state()],X.prototype,"icon",2),d([state()],X.prototype,"titleProp",2);var zi=12,Ki=16,yc=o=>{let r=12,e=12;return o.width/o.height>=1?(r=zi,e=Math.round(zi*o.height/o.width)):(e=zi,r=Math.round(zi*o.width/o.height)),{width:r,height:e}},Wi=class extends X{initCallback(){super.initCallback(),this.icon="arrow-dropdown",this.sub("*currentAspectRatio",r=>{let e=this._computeTitle(r);this.title=e,this.titleProp=e;});}onClick(){this.$["*showListAspectRatio"]=true;}_computeTitle(r){return r?r.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${r.width}:${r.height}`}):""}render(){let r=this.onClick,e=this.title;return html`<button role="option" type="button" class=${classMap(this.buttonClasses)} aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${r} ><div class="uc-title" ?hidden=${!e}>${e}</div><uc-icon name=${this.icon}></uc-icon></button>`}},Bt=class extends X{constructor(){super(...arguments);this._aspectRatio=null;}get aspectRatio(){return this._aspectRatio}set aspectRatio(e){if(this._aspectRatio===e)return;let t=this._aspectRatio;this._aspectRatio=e,this.requestUpdate("aspectRatio",t),e?this._updateAspectRatioPresentation(e):(this.removeAttribute("uc-aspect-ratio-freeform"),this.title="",this.titleProp="");}initCallback(){super.initCallback(),this._aspectRatio&&this._updateAspectRatioPresentation(this._aspectRatio),this.sub("*currentAspectRatio",e=>{this.active=e&&e.id===this._aspectRatio?.id||e?.width===this._aspectRatio?.width&&e?.height===this._aspectRatio?.height;});}onClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio);}_updateAspectRatioPresentation(e){if(!this.isConnected)return;let t=!!e.hasFreeform;this.toggleAttribute("uc-aspect-ratio-freeform",t);let i=()=>{let n=t?this.l10n("custom"):`${e.width}:${e.height}`;return this.title=n,n},s=()=>{let n=this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:t?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}).toLowerCase(),value:""});return this.titleProp=n,n};i(),s(),t||this.requestUpdate();}_renderIcon(){let e=this._aspectRatio;if(!e||e.hasFreeform)return html`<uc-icon name=${this.icon}></uc-icon>`;let{width:t,height:i}=yc(e),s=(Ki-t)/2,n=(Ki-i)/2;return html`<uc-icon><svg viewBox="0 0 ${Ki} ${Ki}" aria-hidden="true" focusable="false" ><rect x=${s} y=${n} width=${t} height=${i} rx="2" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" ></rect></svg></uc-icon>`}render(){let e=this.onClick,t=this.title;return html`<button role="option" type="button" class=${classMap(this.buttonClasses)} aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${e} >${this._renderIcon()}<div class="uc-title" ?hidden=${!t}>${t}</div></button>`}};d([property({attribute:false})],Bt.prototype,"aspectRatio",1);function Cc(o){let r=o+90;return r=r>=360?0:r,r}function wc(o,r){if(o==="rotate")return Cc(typeof r=="number"?r:0);if(o==="mirror"||o==="flip")return !r;throw new Error(`Unsupported operation: ${o}`)}var Ht=class extends X{constructor(){super(...arguments);this.operation=void 0;}willUpdate(e){super.willUpdate(e),this.operation?(this.titleProp=this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(this.operation).toLowerCase()}),this.icon=this.operation):(this.icon="",this.titleProp="");}onClick(e){if(!this.operation)return;let t=this.$["*cropperEl"],i=t.getValue(this.operation),s=wc(this.operation,i);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this.operation,next:s,prev:i}),t.setValue(this.operation,s);}};d([property({type:String})],Ht.prototype,"operation",2);var xe=class extends X{constructor(){super(...arguments);this._operation="";this._filter="";this._originalUrl="";this._lastPreviewRequestId=0;this._previewImage=null;this._previewLoaded=false;this.isOriginal=false;this._iconSize=20;}get filter(){return this._filter}set filter(e){let t=e??"";if(this._filter===t)return;let i=this._filter;this._filter=t,this._operation="filter",this.isOriginal=t===be,this.icon=this.isOriginal?"original":"slider",this._iconSize=this.isOriginal?40:20,this.requestUpdate("filter",i),this.isConnected&&this._updateFilterLabels(t);}onClick(e){if(this.active)this.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=true);else {let t=this.$["*sliderEl"];t.setOperation(this._operation,this._filter),t.apply();}this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:mt(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter;}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=Number.isFinite(e)&&e>0?e:this._iconSize||32,i=window.devicePixelRatio,s=Math.ceil(i*t),n=i>=2?"lightest":"normal",a=100,l={...this.$["*editorTransformations"]};return l[this._operation]=this._filter!==be?{name:this._filter,amount:a}:void 0,F(this._originalUrl,q(ti,ke(l),`quality/${n}`,`scale_crop/${s}x${s}/center`,`@clib/${pe}/${he}/uc-cloud-image-editor/`))}async _observerCallback(e,t){e[0]?.isIntersecting?await this._loadPreview(t):this._cancelPreload?.();}initCallback(){super.initCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let e=this.$["*originalUrl"];this._originalUrl=e??"",this.sub("*originalUrl",t=>{this._originalUrl=t??"",!this.isOriginal&&this._originalUrl&&this.isConnected&&!this._previewImage&&(this._observer?.observe(this),this._schedulePreviewVisibilityCheck());}),this.isOriginal||(this._observer?.observe(this),this._schedulePreviewVisibilityCheck()),this._filter&&this._updateFilterLabels(this._filter),this.sub("*currentFilter",t=>{this.active=!!(t&&t===this._filter);}),this.sub("*networkProblems",async t=>{t||(this._previewImage?await this._loadPreview():this._schedulePreviewVisibilityCheck());});}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._cancelPreload?.(),this._clearPreviewVisibilityChecks();}updated(e){super.updated(e),e.has("isOriginal")&&(this.isOriginal?this._observer?.unobserve(this):(this._observer?.observe(this),this._schedulePreviewVisibilityCheck()));}_updateFilterLabels(e){if(!e){this.titleProp="";return}let t=this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()});this.titleProp=t;}async _loadPreview(e){if(!this.isConnected){e?.unobserve(this),this._cancelPreload?.(),this._cancelPreload=void 0;return}if(!this._originalUrl){!this._previewVisibilityCheckTimeout&&!this._previewVisibilityCheckRaf&&this._schedulePreviewVisibilityCheck();return}let t=++this._lastPreviewRequestId,i="";try{i=await this.proxyUrl(this._previewSrc());}catch(a){this.$["*networkProblems"]=true,console.error("Failed to resolve preview URL",{error:a});return}this._previewLoaded=false,this._cancelPreload?.();let{promise:s,cancel:n}=He(i);this._cancelPreload=()=>{n(),this._lastPreviewRequestId===t&&(this._cancelPreload=void 0);};try{if(await s,this._lastPreviewRequestId!==t||!this.isConnected)return;this._previewImage=i,this._previewLoaded=!0,this._clearPreviewVisibilityChecks(),(e??this._observer)?.unobserve(this);}catch(a){this.$["*networkProblems"]=true,console.error("Failed to load image",{error:a}),this._schedulePreviewVisibilityCheck();}finally{this._lastPreviewRequestId===t&&(this._cancelPreload=void 0);}}_schedulePreviewVisibilityCheck(){if(!this.isConnected||this._previewImage||this._previewLoaded||this.isOriginal||this.$["*networkProblems"]){this._clearPreviewVisibilityChecks();return}this._previewVisibilityCheckRaf&&cancelAnimationFrame(this._previewVisibilityCheckRaf),this._previewVisibilityCheckRaf=requestAnimationFrame(()=>{if(this._previewVisibilityCheckRaf=void 0,!this.isConnected||this._previewImage||this._previewLoaded||this.isOriginal){this._clearPreviewVisibilityChecks();return}let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,i=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight;if(t&&e.bottom>0&&e.right>0&&e.top<s&&e.left<i){this._loadPreview();return}this._previewVisibilityCheckTimeout=window.setTimeout(()=>{this._previewVisibilityCheckTimeout=void 0,this._schedulePreviewVisibilityCheck();},500);});}_clearPreviewVisibilityChecks(){this._previewVisibilityCheckRaf&&(cancelAnimationFrame(this._previewVisibilityCheckRaf),this._previewVisibilityCheckRaf=void 0),this._previewVisibilityCheckTimeout&&(window.clearTimeout(this._previewVisibilityCheckTimeout),this._previewVisibilityCheckTimeout=void 0);}get _shouldShowPreview(){return !!(this._previewLoaded&&!this.active&&!this.isOriginal)}render(){let e=this.onClick,t={opacity:this._shouldShowPreview?"1":"0"};this._previewImage&&(t.backgroundImage=`url(${this._previewImage})`);let i={opacity:this.active||this.isOriginal?"1":"0"};return html`<button role="option" type="button" class=${classMap(this.buttonClasses)} aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${e} ><div class="uc-preview" ?data-loaded=${this._previewLoaded} style=${styleMap(t)}></div><uc-icon class=${classMap({"uc-original-icon":this.isOriginal})} name=${this.icon} style=${styleMap(i)} ></uc-icon></button>`}};d([state()],xe.prototype,"_previewImage",2),d([state()],xe.prototype,"_previewLoaded",2),d([state()],xe.prototype,"isOriginal",2),d([state()],xe.prototype,"_iconSize",2),d([property({type:String})],xe.prototype,"filter",1);var zt=class extends X{constructor(){super(...arguments);this._operation="";}get operation(){return this._operation}set operation(e){let t=e??"";if(this._operation===t)return;let i=this._operation;this._operation=t,this.requestUpdate("operation",i),this.isConnected&&t&&this._updateOperationMetadata(t);}_updateOperationMetadata(e){this.icon=e;let t=()=>{let s=this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()});return this.titleProp=s,s},i=()=>{let s=this.l10n(e);return this.title=s,s};t(),i();}initCallback(){super.initCallback(),this._operation&&this._updateOperationMetadata(this._operation),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=ce[this._operation],i=e[this._operation],s=typeof i<"u"?i!==t:false;this.active=s;});}onClick(e){this.$["*sliderEl"]?.setOperation(this._operation),this.$["*showSlider"]=true,this.$["*currentOperation"]=this._operation,this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:mt(this.$["*operationTooltip"])});}};d([property({type:String})],zt.prototype,"operation",1);var Ic=1,un=()=>{},Kt=class extends g{constructor(){super(...arguments);this.hiddenScrollbar=false;this._handleWheel=e=>{e.preventDefault();let{deltaY:t,deltaX:i}=e;if(Math.abs(i)>Ic){this.scrollLeft+=i;return}this.scrollLeft+=t;};}connectedCallback(){super.connectedCallback(),this.addEventListener("wheel",this._handleWheel,{passive:false}),this.addEventListener("scroll",un,{passive:true});}disconnectedCallback(){this.removeEventListener("wheel",this._handleWheel),this.removeEventListener("scroll",un),super.disconnectedCallback();}};d([property({type:Boolean,noAccessor:true,attribute:"hidden-scrollbar"})],Kt.prototype,"hiddenScrollbar",2);var ee=class extends g{constructor(){super(...arguments);this._showLoader=false;this.showMainToolbar=true;this.showSubToolbar=false;this._showTabToggles=true;this.tabList=[...Z];this.activeTab=O.CROP;this._useSliderPanel=true;this._tooltipVisible=false;this._operationTooltip=null;this._tabIndicatorOffset=0;this._tabIndicatorWidth=0;this._sliderRef=createRef();this._tabIndicatorRef=createRef();this.tabToggleRefs={[O.CROP]:createRef(),[O.TUNING]:createRef(),[O.FILTERS]:createRef()};this._handleWindowResize=()=>{this._syncTabIndicator();};this._cropPresets=[];this._debouncedShowLoader=S(e=>{this._showLoader=e;},500);this._updateInfoTooltip=S(()=>{let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],i="",s=false;if(this.$["*tabId"]===O.FILTERS)if(s=true,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let n=e?.filter?.amount||100;i=`${this.$["*currentFilter"]} ${n}`;}else i=this.l10n(be);else if(this.showSubToolbar&&this.$["*tabId"]===O.TUNING&&t){s=true;let n=e?.[t]||ce[t].zero;i=`${this.l10n(t)} ${n}`;}s&&(this.$["*operationTooltip"]=i),this._tooltipVisible=s;},0);this._subTopToolbarStyles={hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"};this._subBottomToolbarStyles={hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"};this._tabToggleStyles={hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"};this._tabTogglesStyles={hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"};this.init$={...this.init$,"*sliderEl":null,"*showSlider":false,"*showListAspectRatio":false,"*currentFilter":be,"*currentOperation":null,"*operationTooltip":null};this._handleCancel=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t?.();};this._handleApply=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t?.(this.$["*editorTransformations"]);};this._handleApplySlider=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:mt(this.$["*operationTooltip"])}),this._sliderRef.value?.apply(),this._onSliderClose();};this._handleCancelSlider=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this._sliderRef.value?.cancel(),this._onSliderClose();};this._handleTabClick=e=>{let i=e.currentTarget?.getAttribute("data-id");i&&(this.telemetryManager.sendEventCloudImageEditor(e,i),this._activateTab(i,{fromViewer:false}));};}_onSliderClose(){this.$["*showSlider"]=false,this.$["*tabId"]===O.CROP&&(this.$["*showListAspectRatio"]=false),this.$["*tabId"]===O.TUNING&&(this._tooltipVisible=false);}_activateTab(e,{fromViewer:t=false,force:i=false}={}){this.$["*tabId"]!==e&&(this.$["*tabId"]=e),this._applyTabState(e,{fromViewer:t,force:i});}_applyTabState(e,{fromViewer:t,force:i=false}){if(!i&&this.activeTab===e){this._syncTabIndicator();return}this.activeTab=e;let s=this.$["*faderEl"],n=this.$["*cropperEl"];e===O.CROP?(s?.deactivate(),this.$["*imageSize"]&&n?.activate(this.$["*imageSize"],{fromViewer:t})):(s?.activate({url:this.$["*originalUrl"],fromViewer:t}),n?.deactivate());for(let a of Z){let l=a===e,u=this.tabToggleRefs[a]?.value;u&&(u.active=l),l&&this._syncTabIndicator();}}_syncTabIndicator(){let t=this.tabToggleRefs[this.activeTab]?.value,i=this._tabIndicatorRef.value;if(!t||!i)return;let s=t.offsetLeft,n=t.offsetWidth||Number(getComputedStyle(t).width.replace("px",""));(this._tabIndicatorOffset!==s||this._tabIndicatorWidth!==n)&&(this._tabIndicatorOffset=s,this._tabIndicatorWidth=n,i.style.transform=`translateX(${s}px)`,i.style.width=`${n}px`);}get _hasAspectRatioPicker(){return this._cropPresets.length>=3}_renderControlsByTab(e){switch(e){case O.CROP:return this._renderCropTabControls();case O.FILTERS:return this._renderFilterTabControls();case O.TUNING:return this._renderTuningTabControls();default:return []}}_renderCropTabControls(){let e=[];if(this._hasAspectRatioPicker)e.push(()=>this._renderFreeformControl());else for(let t of this._cropPresets)e.push(()=>this._renderAspectRatioControl(t));for(let t of ko)e.push(()=>this._renderCropOperationControl(t));return this._renderControlGroup(e)}_renderFilterTabControls(){let t=[be,...Ao].map(i=>()=>this._renderFilterControl(i));return this._renderControlGroup(t)}_renderTuningTabControls(){let e=Io.map(t=>()=>this._renderOperationControl(t));return this._renderControlGroup(e)}_renderControlGroup(e){return e.length?e.map(i=>i()):[]}_renderFreeformControl(){return html`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`}_renderAspectRatioControl(e){return html`<uc-editor-aspect-ratio-button-control .aspectRatio=${e}></uc-editor-aspect-ratio-button-control>`}_renderCropOperationControl(e){return html`<uc-editor-crop-button-control .operation=${e}></uc-editor-crop-button-control>`}_renderFilterControl(e){return html`<uc-editor-filter-control .filter=${e}></uc-editor-filter-control>`}_renderOperationControl(e){return html`<uc-editor-operation-control .operation=${e}></uc-editor-operation-control>`}_renderAspectRatioList(){return this._hasAspectRatioPicker?this._cropPresets.map(e=>this._renderAspectRatioControl(e)):[]}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(ht(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:i}=Mt([t]);this._cancelPreload=()=>{i(),this._cancelPreload=void 0;};}}initCallback(){super.initCallback();let e=this.$["*cropPresetList"]??[];this._cropPresets=[...e],this.sub("*cropPresetList",t=>{this._cropPresets=[...t??[]];}),this.sub("*imageSize",t=>{t&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:true});},0);}),this.sub("*editorTransformations",t=>{let i=t?.filter?.name;this.$["*currentFilter"]!==i&&(this.$["*currentFilter"]=i??"");}),this.sub("*currentFilter",()=>{this._updateInfoTooltip();}),this.sub("*currentOperation",()=>{this._updateInfoTooltip();}),this.sub("*tabId",t=>{this._applyTabState(t,{fromViewer:false,force:true}),this._updateInfoTooltip();}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate();}),this.sub("*editorTransformations",t=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(t);}),this.sub("*loadingOperations",t=>{let i=false;for(let[,s]of t.entries()){if(i)break;for(let[,n]of s.entries())if(n){i=true;break}}this._debouncedShowLoader(i);}),this.sub("*showSlider",t=>{t?(this.showSubToolbar=true,this.showMainToolbar=false,this._useSliderPanel=true):this.$["*showListAspectRatio"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*showListAspectRatio",t=>{t?(this.showSubToolbar=true,this.showMainToolbar=false,this._useSliderPanel=false):this.$["*showSlider"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*tabList",t=>{if(this.tabList=t,this._showTabToggles=t.length>1,!t.includes(this.$["*tabId"])&&t.length>0){let[i]=t;i&&this._activateTab(i,{fromViewer:false});return}this._syncTabIndicator();}),this.sub("*operationTooltip",t=>{this._operationTooltip=t;}),this._updateInfoTooltip();}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._handleWindowResize);}firstUpdated(e){super.firstUpdated(e),this._assignSharedElements(),this._syncTabIndicator();}updated(e){super.updated(e),(e.has("activeTab")||e.has("tabList"))&&this.updateComplete.then(()=>this._syncTabIndicator()),(e.has("showSubToolbar")||e.has("showMainToolbar"))&&this._assignSharedElements();}disconnectedCallback(){window.removeEventListener("resize",this._handleWindowResize),super.disconnectedCallback(),this.$["*showSlider"]=false,this.$["*showListAspectRatio"]=false;}_assignSharedElements(){let e=this._sliderRef.value;e&&(this.$["*sliderEl"]=e);}_renderTabToggle(e){let t=this.tabList.includes(e),i=this.activeTab===e,s=this.tabList.indexOf(e),n=s>=0?styleMap({gridColumn:`${s+1}`}):nothing;return html`<uc-presence-toggle class="uc-tab-toggle" .visible=${t} .styles=${this._tabToggleStyles}><uc-btn-ui theme="tab" data-id=${e} icon=${e} role="tab" aria-controls=${`tab_${e}`} aria-selected=${i?"true":"false"} title-prop=${`a11y-editor-tab-${e}`} .active=${i} style=${n} @click=${this._handleTabClick} ${ref(this.tabToggleRefs[e])} ></uc-btn-ui></uc-presence-toggle>`}_renderTabContent(e){let t=this._renderControlsByTab(e);return html`<div id=${`tab_${e}`} class="uc-tab-content" ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner">${t.length?t:nothing}</div></div></uc-editor-scroller></div>`}render(){let e=["uc-info-tooltip",this._tooltipVisible?"uc-info-tooltip_visible":"uc-info-tooltip_hidden"].join(" "),t=this._hasAspectRatioPicker;return html`<uc-line-loader-ui .active=${this._showLoader}></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div class=${e}>${this._operationTooltip??""}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" .visible=${this.showMainToolbar} .styles=${this._subTopToolbarStyles} ><div class="uc-tab-content-row">${Z.map(i=>when(this.activeTab===i,()=>this._renderTabContent(i)))}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" .visible=${this._showTabToggles} .styles=${this._tabTogglesStyles} @initial-render=${()=>this._syncTabIndicator()} ><div class="uc-tab-toggles_indicator" ${ref(this._tabIndicatorRef)} ></div>${Z.map(i=>this._renderTabToggle(i))}</uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" title-prop="cancel" @click=${this._handleCancel} ></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this._handleApply}></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this._subBottomToolbarStyles}><div class="uc-slider" ?hidden=${!this._useSliderPanel}><uc-editor-slider ${ref(this._sliderRef)}></uc-editor-slider></div><div class="uc-list-aspect-ratio-container" ?hidden=${this._useSliderPanel||!t}>${t?html`<div class="uc-list-aspect-ratio">${this._renderAspectRatioList()}</div>`:nothing}</div><div class="uc-controls-row"><uc-btn-ui theme="secondary" @click=${this._handleCancelSlider} text=${this.l10n("cancel")}></uc-btn-ui><uc-btn-ui theme="primary" @click=${this._handleApplySlider} text=${this.l10n("apply")}></uc-btn-ui></div></uc-presence-toggle></div>`}};d([state()],ee.prototype,"_showLoader",2),d([state()],ee.prototype,"showMainToolbar",2),d([state()],ee.prototype,"showSubToolbar",2),d([state()],ee.prototype,"_showTabToggles",2),d([state()],ee.prototype,"tabList",2),d([state()],ee.prototype,"activeTab",2),d([state()],ee.prototype,"_useSliderPanel",2),d([state()],ee.prototype,"_tooltipVisible",2),d([state()],ee.prototype,"_operationTooltip",2),d([state()],ee.prototype,"_cropPresets",2);var hn=_e([...Z]),j=class extends g{constructor(){super(...arguments);this.ctxOwner=true;this._statusMessage="";this._imageSrc=de;this._fileType="";this._showLoader=false;this.uuid=null;this.cdnUrl=null;this.cropPreset="";this.tabs=hn;this._hasNetworkProblems=false;this._isInitialized=false;this._pendingInitUpdate=null;this._pendingSizeWait=null;this._debouncedShowLoader=S(e=>{this._showLoader=e;},300);this._imgRef=createRef();this._cropperRef=createRef();this._faderRef=createRef();this._imgContainerRef=createRef();this._handleImageLoad=()=>{this._debouncedShowLoader(false),this._imageSrc!==de&&(this.$["*networkProblems"]=false);};this._handleImageError=()=>{this._debouncedShowLoader(false),this.$["*networkProblems"]=true;};this._handleRetryNetwork=()=>{let e=this.$["*on.retryNetwork"];e?.();};this.init$={...this.init$,...Ys(this)};}static{this.styleAttrs=["uc-cloud-image-editor"];}_scheduleInitialization(){this._isInitialized||this._pendingInitUpdate||(this._pendingInitUpdate=this.updateComplete.then(()=>{this._pendingInitUpdate=null,this._isInitialized=true;}));}initCallback(){super.initCallback(),this._syncTabListFromProp(),this._syncCropPresetState();}_assignSharedElements(){let e=this._faderRef.value;e&&(this.$["*faderEl"]=e);let t=this._cropperRef.value;t&&(this.$["*cropperEl"]=t);let i=this._imgContainerRef.value;i&&(this.$["*imgContainerEl"]=i);let s=this._imgRef.value;s&&(this.$["*imgEl"]=s);}_attachImageListeners(){let e=this._imgRef.value;e&&(e.addEventListener("load",this._handleImageLoad),e.addEventListener("error",this._handleImageError));}_detachImageListeners(){let e=this._imgRef.value;e&&(e.removeEventListener("load",this._handleImageLoad),e.removeEventListener("error",this._handleImageError));}get _imageClassName(){let e=this.$["*tabId"];return se("uc-image",{"uc-image_hidden_to_cropper":e===O.CROP,"uc-image_hidden_effects":e!==O.CROP})}_waitForSize(){if(this._pendingSizeWait)return this._pendingSizeWait;let e=3e3;return this._pendingSizeWait=new Promise((t,i)=>{let s=()=>{window.clearTimeout(u),c.disconnect(),this._pendingSizeWait=null;},n=()=>{let{width:p,height:m}=this.getBoundingClientRect();return p>0&&m>0},a=()=>{s(),window.setTimeout(()=>t(),0);},l=()=>{let p=new Error("[cloud-image-editor] timeout waiting for non-zero container size");s(),this.isConnected&&console.error(p.message),i(p);},c=new ResizeObserver(p=>{let[m]=p;m&&m.contentRect.width>0&&m.contentRect.height>0&&a();}),u=window.setTimeout(()=>{l();},e);if(n()){a();return}c.observe(this);}),this._pendingSizeWait}firstUpdated(e){super.firstUpdated(e),this._assignSharedElements(),this._attachImageListeners(),this.initEditor();let t=!!(this.uuid||this.cdnUrl),i=e.has("uuid")||e.has("cdnUrl");t&&!i&&this.updateImage();}disconnectedCallback(){this._detachImageListeners(),super.disconnectedCallback();}render(){let e=this._fileType??"",t=this._statusMessage??"",i=this._imageSrc||de,s=this._showLoader,n=this._hasNetworkProblems;return html` ${unsafeSVG(Xs)}<div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" .visible=${n}><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" @click=${this._handleRetryNetwork}></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">${e}</div></div><div class="uc-image_container" ${ref(this._imgContainerRef)}><img src=${i} class=${this._imageClassName} ${ref(this._imgRef)} />${when(this._isInitialized,()=>html`<uc-editor-image-cropper ${ref(this._cropperRef)}></uc-editor-image-cropper>`)}<uc-editor-image-fader ${ref(this._faderRef)}></uc-editor-image-fader></div><div class="uc-info_pan">${t}</div></div><div class="uc-toolbar"><uc-line-loader-ui .active=${s}></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor">${when(this._isInitialized,()=>html`<uc-editor-toolbar></uc-editor-toolbar>`)}</div></div></div>`}updated(e){super.updated(e),e.has("uuid")&&this.uuid&&this.updateImage(),e.has("cdnUrl")&&this.cdnUrl&&this.updateImage(),e.has("tabs")&&this._syncTabListFromProp(),(e.has("cropPreset")||e.has("cdnUrl"))&&this._syncCropPresetState();}_syncTabListFromProp(){let e=this.tabs||hn;this.$["*tabList"]=Zs(e);}_syncCropPresetState(){let e=Ai(this.cropPreset??""),t=null;if(this.cdnUrl){let i=lr(this.cdnUrl),s=cr(i);if(Array.isArray(s?.crop?.dimensions)){let[n,a]=s.crop.dimensions;t=ds(n,a,e,.1);}}this.$["*cropPresetList"]=e,this.$["*currentAspectRatio"]=t??e?.[0]??null;}async updateImage(){if(this.isConnected){try{await this._waitForSize();}catch{return}if(this.isConnected){if(this.cdnUrl){let e=this.cdnUrl,t=ei(e),i=Ae(e,t);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let s=lr(e),n=cr(s);this.$["*editorTransformations"]=n;}else if(this.uuid){let e=Ae(this.cfg.cdnCname,this.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,Object.keys(this.$["*editorTransformations"]).length>0&&(this.$["*editorTransformations"]={});}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===O.CROP?this.$["*cropperEl"]?.deactivate({reset:true}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(F(e,q("json"))),i=await fetch(t).then(a=>a.json()),{width:s,height:n}=i;this.$["*imageSize"]={width:s,height:n},this.$["*tabId"]===O.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:e});}catch(e){e&&(this.telemetryManager.sendEventError(e,"cloud editor image. Failed to load image info"),console.error("Failed to load image info",e));}this._scheduleInitialization();}}}async initEditor(){try{await this._waitForSize();}catch{return}this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{let t=!!e;this._hasNetworkProblems=t;}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],i=q(ke(e),"preview"),s=F(t,i),n={originalUrl:t,cdnUrlModifiers:i,cdnUrl:s,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:true,composed:true}));},false);}};d([state()],j.prototype,"_statusMessage",2),d([state()],j.prototype,"_imageSrc",2),d([state()],j.prototype,"_fileType",2),d([state()],j.prototype,"_showLoader",2),d([property({type:String,reflect:true})],j.prototype,"uuid",2),d([property({type:String,attribute:"cdn-url",reflect:true})],j.prototype,"cdnUrl",2),d([property({type:String,attribute:"crop-preset",reflect:true})],j.prototype,"cropPreset",2),d([property({type:String,reflect:true})],j.prototype,"tabs",2),d([state()],j.prototype,"_hasNetworkProblems",2),d([state()],j.prototype,"_isInitialized",2);var so={};mo(so,{CloudImageEditorActivity:()=>Gt});var Qi=class extends j{static{this.styleAttrs=[...super.styleAttrs,"uc-wgt-common"];}constructor(){super(),this.init$={...this.init$,"*solution":this.tagName};}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION}),this.a11y?.registerBlock(this);}};var Gt=class extends _{constructor(){super(...arguments);this._editorConfig=null;}get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.subConfigValue("cropPreset",e=>{this._editorConfig&&this._editorConfig.cropPreset!==e&&(this._editorConfig={...this._editorConfig,cropPreset:e});}),this.subConfigValue("cloudImageEditorTabs",e=>{this._editorConfig&&this._editorConfig.tabs!==e&&(this._editorConfig={...this._editorConfig,tabs:e});}),this._mountEditor();}disconnectedCallback(){super.disconnectedCallback(),this._unmountEditor();}_handleApply(e){if(!this._entry)return;this.debugPrint('editor event "apply"',e.detail);let t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager?.close(E.activities.CLOUD_IMG_EDIT),this.historyBack();}_handleCancel(e){let t=e instanceof CustomEvent?e.detail:void 0;this.debugPrint('editor event "cancel"',t),this.modalManager?.close(E.activities.CLOUD_IMG_EDIT),this.historyBack();}handleChange(e){this.debugPrint('editor event "change"',e.detail);}_mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let i=this._entry.getValue("cdnUrl");if(!i)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);this._editorConfig=this._createEditorConfig(i);}_unmountEditor(){this._entry=void 0,this._editorConfig=null;}render(){if(!this._editorConfig)return nothing;let{cdnUrl:e,cropPreset:t,tabs:i}=this._editorConfig;return html`<uc-cloud-image-editor cdn-url=${e} crop-preset=${ifDefined(t)} tabs=${ifDefined(i)} @apply=${this._handleApply} @cancel=${this._handleCancel} @change=${this.handleChange} ></uc-cloud-image-editor>`}_createEditorConfig(e){return {cdnUrl:e,cropPreset:this.cfg.cropPreset,tabs:this.cfg.cloudImageEditorTabs}}};d([state()],Gt.prototype,"_editorConfig",2);var gt=class extends _{constructor(){super(...arguments);this._url="";this._handleInput=e=>{this._url=e.target?.value??"";};this._handleUpload=e=>{e.preventDefault(),this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let t=this._url.trim();t&&(this.api.addFileFromUrl(t,{source:T.URL}),this.routerLayer.navigateAfterFileAdd());};}render(){return html`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.historyBack} title=${this.l10n("back")} aria-label=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span>${this.l10n("caption-from-url")}</span></div><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content" @submit=${this._handleUpload}><label><input placeholder="https://" class="uc-url-input" type="text" autofocus @input=${this._handleInput} /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" ?disabled=${!this._url} >${this.l10n("upload-url")}</button></form>`}};d([state()],gt.prototype,"_url",2);var fn=()=>{let o=globalThis.top??globalThis.parent??globalThis.self;try{return o.location.origin}catch(r){return console.warn("Unable to access top-level window location:",r),globalThis.location.origin}};var Vc=o=>o.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),gn=(o,r="i")=>{let e=o.split("*").map(Vc);return new RegExp(`^${e.join(".+")}$`,r)};var $c=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],Dc=(o,r)=>window.getComputedStyle(o).getPropertyValue(r).trim(),vn=o=>{let r={};for(let e of $c){let t=Dc(o,e);t&&(r[e]=t);}return r};var Fc=["selected-files-change","toolbar-state-change"],Nc=o=>{if(!o||typeof o!="object"||!("type"in o))return false;let r=o.type;return !(typeof r!="string"||!Fc.includes(r))},Ji=class{constructor(r,e){this._handlerMap=new Map;this._handleMessage=r=>{if(r.source!==this._context)return;let e=r.data;if(!Nc(e))return;let t=this._handlerMap.get(e.type);if(t)for(let i of t)i(e);};this._context=r,this._getTargetOrigin=e,window.addEventListener("message",this._handleMessage);}on(r,e){let t=this._handlerMap.get(r)??new Set;this._handlerMap.has(r)||this._handlerMap.set(r,t),t.add(e);}send(r){let e=this._getTargetOrigin();this._context.postMessage(r,e);}destroy(){window.removeEventListener("message",this._handleMessage);}};function bn(o){let r=[];for(let[e,t]of Object.entries(o))t==null||typeof t=="string"&&t.length===0||r.push(`${e}=${encodeURIComponent(t)}`);return r.join("&")}var Kc={[Q.GDRIVE]:"ngdrive"},te=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this._iframeRef=createRef();this._latestSelectionSummary=null;this._selectedList=[];this._isSelectionReady=false;this._isDoneBtnEnabled=false;this._couldSelectAll=false;this._couldDeselectAll=false;this._showSelectionStatus=false;this._showDoneBtn=false;this._doneBtnTextClass="uc-hidden";this._toolbarVisible=true;this._handleDone=()=>{for(let e of this._selectedList){let t=this._extractUrlFromSelectedFile(e),{filename:i}=e,{externalSourceType:s}=this.activityParams;this.api.addFileFromUrl(t,{fileName:i,source:s});}this.routerLayer.navigateAfterFileAdd();};this._handleCancel=()=>{this.historyBack();};this._handleSelectAll=()=>{this._messageBridge?.send({type:"select-all"});};this._handleDeselectAll=()=>{this._messageBridge?.send({type:"deselect-all"});};}get _counterText(){if(!this._latestSelectionSummary)return "";let{selectedCount:e,total:t}=this._latestSelectionSummary;return this.l10n("selected-count",{count:e,total:t})}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback();let{externalSourceType:e}=this.activityParams;e?this._mountIframe():console.error('Param "externalSourceType" is required for external source activity'),this.sub("*currentActivityParams",()=>{setTimeout(()=>{this.isConnected&&(this._unmountIframe(),this._mountIframe());});}),this.subConfigValue("multiple",t=>{this._showSelectionStatus=t;}),this.subConfigValue("localeName",()=>{this._setupL10n();}),this.subConfigValue("externalSourcesEmbedCss",t=>{this._applyEmbedCss(t);});}_extractUrlFromSelectedFile(e){if(e.alternatives){let t=N(this.cfg.externalSourcesPreferredTypes);for(let i of t){let s=gn(i);for(let[n,a]of Object.entries(e.alternatives))if(s.test(n))return a}}return e.url}_handleToolbarStateChange(e){this._toolbarVisible=e.isVisible;}async _handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this._setSelectionSummary(e.selectedCount,e.total),this._doneBtnTextClass=e.isReady?"":"uc-hidden",this._isSelectionReady=e.isReady,this._isDoneBtnEnabled=e.isReady&&e.selectedFiles.length>0,this._showSelectionStatus=e.isMultipleMode&&e.total>0,this._couldSelectAll=e.selectedCount<e.total,this._couldDeselectAll=e.selectedCount===e.total,this._selectedList=e.selectedFiles??[],this._showDoneBtn=e.total>0;}_handleIframeLoad(){this._applyEmbedCss(this.cfg.externalSourcesEmbedCss),this._applyTheme(),this._setupL10n();}_applyTheme(){this._messageBridge?.send({type:"set-theme-definition",theme:vn(this)});}_applyEmbedCss(e){this._messageBridge?.send({type:"set-embed-css",css:e});}_setupL10n(){this._messageBridge?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName});}_remoteUrl(){let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:i,multiple:s}=this.cfg,{externalSourceType:n}=this.activityParams,a=Kc[n]??n,c={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:true,multiple:s.toString(),origin:this.cfg.topLevelOrigin||fn(),debug:this.cfg.debug},u=new URL(`/window4/${a}`,i);return u.search=bn(c),u.toString()}_setSelectionSummary(e,t){this._latestSelectionSummary={selectedCount:e,total:t};}_mountIframe(){let e=document.createElement("iframe");e.src=this._remoteUrl(),e.marginHeight=0,e.marginWidth=0,e.frameBorder="0",e.allowTransparency=true,e.addEventListener("load",this._handleIframeLoad.bind(this)),e.addEventListener("load",this._handleIframeLoad.bind(this)),this._iframeRef.value&&(this._iframeRef.value.innerHTML="",this._iframeRef.value.appendChild(e)),e.contentWindow&&(this._messageBridge?.destroy(),this._messageBridge=new Ji(e.contentWindow,()=>this.cfg.socialBaseUrl),this._messageBridge.on("selected-files-change",this._handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this._handleToolbarStateChange.bind(this)),this._resetSelectionStatus());}_unmountIframe(){this._messageBridge?.destroy(),this._messageBridge=void 0,this._iframeRef.value&&(this._iframeRef.value.innerHTML=""),this._resetSelectionStatus();}_resetSelectionStatus(){this._selectedList=[],this._isSelectionReady=false,this._isDoneBtnEnabled=false,this._couldSelectAll=false,this._couldDeselectAll=false,this._showSelectionStatus=false,this._showDoneBtn=false,this._doneBtnTextClass="uc-hidden",this._latestSelectionSummary=null;}disconnectedCallback(){super.disconnectedCallback(),this._unmountIframe();}render(){return html`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*historyBack"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ${ref(this._iframeRef)} class="uc-iframe-wrapper"></div><div class="uc-toolbar" ?hidden=${!this._toolbarVisible}><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel} >${this.l10n("cancel")}</button><div class="uc-selection-status-box" ?hidden=${!this._showSelectionStatus} ><span>${this._counterText}</span><button type="button" @click=${this._handleSelectAll} ?hidden=${!this._couldSelectAll} >${this.l10n("select-all")}</button><button type="button" @click=${this._handleDeselectAll} ?hidden=${!this._couldDeselectAll} >${this.l10n("deselect-all")}</button></div><button type="button" class="uc-done-btn uc-primary-btn" @click=${this._handleDone} ?disabled=${!this._isDoneBtnEnabled} ?hidden=${!this._showDoneBtn} ><uc-spinner ?hidden=${this._isSelectionReady}></uc-spinner><span class=${this._doneBtnTextClass}>${this.l10n("done")}</span></button></div></div>`}};d([state()],te.prototype,"_selectedList",2),d([state()],te.prototype,"_isSelectionReady",2),d([state()],te.prototype,"_isDoneBtnEnabled",2),d([state()],te.prototype,"_couldSelectAll",2),d([state()],te.prototype,"_couldDeselectAll",2),d([state()],te.prototype,"_showSelectionStatus",2),d([state()],te.prototype,"_showDoneBtn",2),d([state()],te.prototype,"_doneBtnTextClass",2),d([state()],te.prototype,"_toolbarVisible",2);var yn=()=>typeof navigator.permissions<"u";var Wc={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},qc=["camera","microphone"];function er(o){let r=Math.floor(o/60).toString().padStart(2,"0"),e=Math.floor(o%60).toString().padStart(2,"0");return `${r}:${e}`}var Cn="image/jpeg",wn="video/webm",M=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this._unsubPermissions=null;this._capturing=false;this._chunks=[];this._mediaRecorder=null;this._stream=null;this._selectedAudioId=null;this._selectedCameraId=null;this._activeTab=null;this._options={};this._canvas=null;this._ctx=null;this._cameraDevices=[];this._audioDevices=[];this._permissionResponses={};this._permissionCleanupFns=[];this._currentVideoSource=null;this._handlePreviewPlay=()=>{this._startTimeline(),this._currentTimelineIcon="pause";};this._handlePreviewPause=()=>{this._currentTimelineIcon="play",this._stopTimeline();};this._timerRef=createRef();this._lineRef=createRef();this._videoRef=createRef();this._startTime=0;this._elapsedTime=0;this._videoTransformCss=null;this._videoHidden=true;this._messageHidden=true;this._requestBtnHidden=yn();this._cameraSelectOptions=[];this._cameraSelectHidden=true;this._l10nMessage="";this._timerHidden=true;this._cameraHidden=true;this._cameraActionsHidden=true;this._audioSelectOptions=[];this._audioSelectHidden=true;this._audioSelectDisabled=true;this._audioToggleMicrophoneHidden=true;this._tabCameraHidden=true;this._tabVideoHidden=true;this._currentIcon="camera-full";this._currentTimelineIcon="play";this._toggleMicrophoneIcon="microphone";this._mutableClassButton="uc-shot-btn uc-camera-action";this._chooseActionWithCamera=()=>{if(this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this._activeTab}}}),this._activeTab===C.PHOTO&&this._shot(),this._activeTab===C.VIDEO){if(this._mediaRecorder?.state==="recording"){this._stopRecording();return}this._startRecording();}};this._handleCameraSelectChange=e=>{let t=e.target;t&&(this._selectedCameraId=t.value,this._capture());};this._handleAudioSelectChange=e=>{let t=e.target;t&&(this._selectedAudioId=t.value,this._capture());};this._handleRequestPermissions=()=>{this._capture();};this._handleStartCamera=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this._activeTab}}}),this._chooseActionWithCamera();};this._handleToggleRecording=()=>{this._toggleRecording();};this._handleToggleAudio=()=>{this._toggleEnableAudio();};this._handleRetake=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this._activeTab}}}),this._retake();};this._handleAccept=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this._activeTab}}}),this._accept();};this._handleClickTab=e=>{let i=e.currentTarget?.getAttribute("data-id");i&&this._handleActiveTab(i);};this._updateTimer=()=>{let e=Math.floor((performance.now()-this._startTime+this._elapsedTime)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){let s=this._timerRef.value;s&&(s.textContent=er(t)),this._stopRecording();return}let i=this._timerRef.value;i&&(i.textContent=er(t));}else {let t=this._timerRef.value;t&&(t.textContent=er(e));}this._animationFrameId=requestAnimationFrame(this._updateTimer);};this._startTimer=()=>{this._startTime=performance.now(),this._elapsedTime=0,this._updateTimer();};this._stopTimer=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId);};this._startTimeline=()=>{let e=this._videoRef.value;if(!e)return;let t=e.currentTime,i=e.duration||1,s=this._lineRef.value;s&&(s.style.transform=`scaleX(${t/i})`);let n=this._timerRef.value;n&&(n.textContent=er(t)),this._animationFrameId=requestAnimationFrame(this._startTimeline);};this._stopTimeline=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId);};this._animationFrameId=null;this._startRecording=()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(wn)?this._options.mimeType=wn:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data);}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(ae.PLAY));}catch(e){console.error("Failed to start recording",e),this.telemetryManager.sendEventError(e,"camera recording. Failed to start recording");}};this._stopRecording=()=>{this._mediaRecorder?.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(ae.STOP);}),this._mediaRecorder?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this._activeTab}}});};this._toggleRecording=()=>{if(this._mediaRecorder?.state==="recording")return;let e=this._videoRef.value;e&&(!e.paused&&!e.ended&&e.readyState>2?e.pause():e.paused&&e.play());};this._toggleEnableAudio=()=>{this._stream?.getAudioTracks().forEach(e=>{e.enabled=!e.enabled,this._toggleMicrophoneIcon=e.enabled?"microphone":"microphone-mute",this._audioSelectDisabled=!e.enabled;});};this._previewVideo=()=>{try{let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=URL.createObjectURL(e),i=this._videoRef.value;if(!i)return;i.muted=!1,i.volume=1,this._setVideoSource(null),i.src=t,this._attachPreviewListeners(i);}catch(e){console.error("Failed to preview video",e),this.telemetryManager.sendEventError(e,"camera previewing. Failed to preview video");}};this._retake=()=>{if(this._setCameraState(ae.RETAKE),this._activeTab===C.VIDEO){this._setVideoSource(this._stream);let e=this._videoRef.value;e&&(e.muted=true);}this._videoRef.value?.play?.();};this._accept=()=>{if(this._setCameraState(ae.ACCEPT),this._activeTab===C.PHOTO){this._canvas?.toBlob(s=>{if(!s)return;let n=this._createFile("camera","jpeg",Cn,s);this._toSend(n);},Cn);return}let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=this._guessExtensionByMime(this._mediaRecorder?.mimeType),i=this._createFile("video",t,`video/${t}`,e);this._toSend(i),this._chunks=[];};this._handlePhoto=e=>{e===ae.SHOT&&(this._tabVideoHidden=true,this._cameraHidden=true,this._tabCameraHidden=true,this._cameraActionsHidden=false,this._cameraSelectHidden=true),(e===ae.RETAKE||e===ae.ACCEPT)&&(this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._cameraHidden=false,this._cameraActionsHidden=true,this._cameraSelectHidden=this._cameraDevices.length<=1);};this._handleVideo=e=>{e===ae.PLAY&&(this._timerHidden=false,this._tabCameraHidden=true,this._cameraSelectHidden=true,this._audioSelectHidden=true,this._currentTimelineIcon="pause",this._currentIcon="square",this._mutableClassButton="uc-shot-btn uc-camera-action uc-stop-record"),e===ae.STOP&&(this._timerHidden=false,this._cameraHidden=true,this._audioToggleMicrophoneHidden=true,this._cameraActionsHidden=false),(e===ae.RETAKE||e===ae.ACCEPT)&&(this._timerHidden=true,this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._cameraHidden=false,this._cameraActionsHidden=true,this._audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording,this._currentIcon="video-camera-full",this._mutableClassButton="uc-shot-btn uc-camera-action",this._audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._cameraSelectHidden=this._cameraDevices.length<=1);};this._setCameraState=e=>{this._activeTab===C.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===C.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e);};this._handleActiveTab=e=>{e===C.PHOTO&&(this._currentIcon="camera-full",this._audioSelectHidden=true,this._audioToggleMicrophoneHidden=true),e===C.VIDEO&&(this._currentTimelineIcon="play",this._currentIcon="video-camera-full",this._audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording),this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:e}}}),this._activeTab=e;};this._createFile=(e,t,i,s)=>{let n=Date.now(),a=`${e}-${n}.${t}`;return new File([s],a,{lastModified:n,type:i})};this._toSend=e=>{this.api.addFileFromObject(e,{source:T.CAMERA}),this.routerLayer.navigateAfterFileAdd();};this._setPermissionsState=S(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===C.VIDEO&&this.cfg.enableAudioRecording,i=this._activeTab===C.PHOTO?"camera-full":"video-camera-full";e==="granted"?(this._videoHidden=false,this._cameraHidden=false,this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._messageHidden=true,this._timerHidden=true,this._currentIcon=i,this._audioToggleMicrophoneHidden=!t,this._audioSelectHidden=!t):e==="prompt"?(this._l10nMessage="camera-permissions-prompt",this._videoHidden=true,this._cameraHidden=true,this._tabCameraHidden=true,this._messageHidden=false,this._stopCapture()):(this._l10nMessage="camera-permissions-denied",this._videoHidden=true,this._messageHidden=false,this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._cameraActionsHidden=true,this._mutableClassButton="uc-shot-btn uc-camera-action",this._stopCapture());},300);this._makeStreamInactive=()=>{if(!this._stream)return false;let e=this._stream?.getAudioTracks(),t=this._stream?.getVideoTracks();return e.forEach(i=>{i.stop();}),t.forEach(i=>{i.stop();}),true};this._stopCapture=()=>{this._capturing&&(this._videoRef.value&&(this._videoRef.value.volume=0),this._currentVideoSource?.getTracks?.()?.[0]?.stop(),this._detachPreviewListeners(this._videoRef.value),this._setVideoSource(null),this._makeStreamInactive(),this._stopTimer(),this._capturing=false);};this._capture=async()=>{let e={video:{...Wc},audio:this.cfg.enableAudioRecording?{}:false};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this._videoRef.value&&(this._videoRef.value.volume=0);try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied");}),this._setVideoSource(this._stream),this._capturing=!0,this._setPermissionsState("granted");}catch(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t),this.telemetryManager.sendEventError(t,"camera capturing. Failed to capture camera");}};this._handlePermissionsChange=()=>{this._capture();};this._permissionAccess=async()=>{try{this._teardownPermissionListeners();for(let e of qc){let t=await navigator.permissions.query({name:e});this._permissionResponses[e]=t,t.addEventListener("change",this._handlePermissionsChange),this._permissionCleanupFns.push(()=>{t.removeEventListener("change",this._handlePermissionsChange);});}this._unsubPermissions=()=>{this._teardownPermissionListeners();};}catch(e){this._teardownPermissionListeners(),console.log("Failed to use permissions API. Fallback to manual request mode.",e),this.telemetryManager.sendEventError(e,"camera permissions. Failed to use permissions API"),this._capture();}};this._requestDeviceAccess=async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices);}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get user media"),console.log("Failed to get user media",e);}};this._getDevices=async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=e.filter(t=>t.kind==="videoinput").map((t,i)=>({text:t.label.trim()||`${this.l10n("caption-camera")} ${i+1}`,value:t.deviceId})),this._audioDevices=this.cfg.enableAudioRecording?e.filter(t=>t.kind==="audioinput").map(t=>({text:t.label.trim(),value:t.deviceId})):[],this._cameraSelectOptions=this._cameraDevices,this._cameraSelectHidden=this._cameraDevices.length<=1,this._selectedCameraId=this._cameraDevices[0]?.value??null,this._audioSelectOptions=this._audioDevices,this._audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._selectedAudioId=this._audioDevices[0]?.value??null;}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get devices"),console.log("Failed to get devices",e);}};this._onActivate=async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes);};this._onDeactivate=async()=>{this._unsubPermissions&&this._unsubPermissions(),window.chrome||this._setPermissionsState("denied"),this._stopCapture();};this._handleCameraModes=e=>{this._tabVideoHidden=!e.includes(C.VIDEO),this._tabCameraHidden=!e.includes(C.PHOTO);let t=e[0];t&&(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t);};}_attachPreviewListeners(e){this._detachPreviewListeners(e),e.addEventListener("play",this._handlePreviewPlay),e.addEventListener("pause",this._handlePreviewPause);}_detachPreviewListeners(e){e?.removeEventListener("play",this._handlePreviewPlay),e?.removeEventListener("pause",this._handlePreviewPause);}_setVideoSource(e){this._currentVideoSource!==e&&(this._currentVideoSource=e,this._applyVideoSource());}_applyVideoSource(){let e=this._videoRef.value;if(!e)return;let t=this._currentVideoSource??null;e.srcObject!==t&&(e.srcObject=t);}_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");let e=this._videoRef.value;if(!e)throw new Error("Video element not found");this._canvas.height=e.videoHeight,this._canvas.width=e.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(e,0,0),e.pause();}_guessExtensionByMime(e){let t={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return "webm";if(e){let i=e.split("/");if(i?.[0]==="video"){let n=i.slice(1).join("/")?.split(";")[0];if(n&&t[n])return t[n]}}return "avi"}get _cameraModes(){return N(this.cfg.cameraModes).filter(e=>e===C.PHOTO||e===C.VIDEO)}_teardownPermissionListeners(){if(this._permissionCleanupFns.length!==0){for(let e of this._permissionCleanupFns)e();this._permissionCleanupFns=[],this._unsubPermissions=null;}}initCallback(){super.initCallback(),this.subConfigValue("cameraMirror",e=>{this._videoTransformCss=e?"scaleX(-1)":null;}),this.subConfigValue("enableAudioRecording",e=>{this._audioToggleMicrophoneHidden=!e,this._audioSelectDisabled=!e;}),this.subConfigValue("cameraModes",e=>{if(!this.isConnected)return;let t=V(e);this._handleCameraModes(t.filter(i=>i===C.PHOTO||i===C.VIDEO));}),this._onActivate();}firstUpdated(e){super.firstUpdated(e),this._applyVideoSource();}updated(e){super.updated(e),this._applyVideoSource();}_destroy(){this._teardownPermissionListeners(),navigator.mediaDevices?.removeEventListener("devicechange",this._getDevices),this._detachPreviewListeners(this._videoRef.value),this._setVideoSource(null);}disconnectedCallback(){super.disconnectedCallback(),this._onDeactivate(),this._destroy();}render(){return html`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.$["*historyBack"]} title=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div ?hidden=${!this._cameraSelectHidden}><uc-icon name="camera"></uc-icon><span>${this.l10n("caption-camera")}</span></div><uc-select class="uc-camera-select" .options=${this._cameraSelectOptions} ?hidden=${this._cameraSelectHidden} @change=${this._handleCameraSelectChange} ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline style=${styleMap({transform:this._videoTransformCss})} ?hidden=${this._videoHidden} ${ref(this._videoRef)} ></video><div class="uc-message-box" ?hidden=${this._messageHidden}><span>${this.l10n(this._l10nMessage)}</span><button type="button" @click=${this._handleRequestPermissions} ?hidden=${this._requestBtnHidden} >${this.l10n("camera-permissions-request")}</button></div></div><div class="uc-controls"><div class="uc-switcher" ?hidden=${!this._timerHidden}><button data-id="photo" type="button" class=${classMap({"uc-switch":true,"uc-mini-btn":true,"uc-active":this._activeTab===C.PHOTO})} @click=${this._handleClickTab} ?hidden=${this._tabCameraHidden} data-testid="tab-photo" ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class=${classMap({"uc-switch":true,"uc-mini-btn":true,"uc-active":this._activeTab===C.VIDEO})} @click=${this._handleClickTab} ?hidden=${this._tabVideoHidden} data-testid="tab-video" ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" @click=${this._handleToggleRecording} ?hidden=${this._timerHidden} data-testid="recording-timer" ><uc-icon name=${this._currentTimelineIcon}></uc-icon><span ${ref(this._timerRef)}> 00:00 </span><span ${ref(this._lineRef)} class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" ?hidden=${this._cameraActionsHidden} ><button type="button" class="uc-secondary-btn" @click=${this._handleRetake} >${this.l10n("retake")}</button><button type="button" class="uc-primary-btn" @click=${this._handleAccept} data-testid="accept" >${this.l10n("accept")}</button></div><button type="button" data-testid="shot" @click=${this._handleStartCamera} class=${this._mutableClassButton} ?hidden=${this._cameraHidden} ><uc-icon name=${this._currentIcon}></uc-icon></button><div class="uc-select"><button type="button" class="uc-mini-btn uc-btn-microphone" @click=${this._handleToggleAudio} ?hidden=${this._audioToggleMicrophoneHidden} data-testid="toggle-microphone" ><uc-icon name=${this._toggleMicrophoneIcon}></uc-icon></button><uc-select class="uc-audio-select" .options=${this._audioSelectOptions} ?hidden=${this._audioSelectHidden} ?disabled=${this._audioSelectDisabled} @change=${this._handleAudioSelectChange} data-testid="audio-select" ></uc-select></div></div>`}};d([state()],M.prototype,"_videoTransformCss",2),d([state()],M.prototype,"_videoHidden",2),d([state()],M.prototype,"_messageHidden",2),d([state()],M.prototype,"_requestBtnHidden",2),d([state()],M.prototype,"_cameraSelectOptions",2),d([state()],M.prototype,"_cameraSelectHidden",2),d([state()],M.prototype,"_l10nMessage",2),d([state()],M.prototype,"_timerHidden",2),d([state()],M.prototype,"_cameraHidden",2),d([state()],M.prototype,"_cameraActionsHidden",2),d([state()],M.prototype,"_audioSelectOptions",2),d([state()],M.prototype,"_audioSelectHidden",2),d([state()],M.prototype,"_audioSelectDisabled",2),d([state()],M.prototype,"_audioToggleMicrophoneHidden",2),d([state()],M.prototype,"_tabCameraHidden",2),d([state()],M.prototype,"_tabVideoHidden",2),d([state()],M.prototype,"_currentIcon",2),d([state()],M.prototype,"_currentTimelineIcon",2),d([state()],M.prototype,"_toggleMicrophoneIcon",2),d([state()],M.prototype,"_mutableClassButton",2);var Tn={id:"camera",setup:async({pluginApi:o,uploaderApi:r})=>{ie({CameraSource:M}),o.registry.registerSource({id:"camera",label:"src-type-camera",icon:"camera",expand:()=>{if(!Lo.htmlMediaCapture)return ["camera"];let e=V(o.config.get("cameraModes"));return e.length?e.map(t=>`mobile-${t}-camera`):["mobile-photo-camera"]},onSelect:()=>{r.setCurrentActivity(A.CAMERA),r.setModalState(true);}}),o.registry.registerSource({id:"mobile-photo-camera",label:"src-type-mobile-photo-camera",icon:"camera",onSelect:()=>{r.openSystemDialog({captureCamera:true,modeCamera:"photo"});}}),o.registry.registerSource({id:"mobile-video-camera",label:"src-type-mobile-video-camera",icon:"camera",onSelect:()=>{r.openSystemDialog({captureCamera:true,modeCamera:"video"});}}),o.registry.registerActivity({id:A.CAMERA,render:e=>{let t=document.createElement("uc-camera-source");return e.append(t),()=>{e.replaceChildren();}}});}};var lo={};mo(lo,{BtnUi:()=>le,CloudImageEditor:()=>Qi,CloudImageEditorBlock:()=>j,Config:()=>ct,CropFrame:()=>$t,EditorAspectRatioButtonControl:()=>Bt,EditorCropButtonControl:()=>Ht,EditorFilterControl:()=>xe,EditorFreeformButtonControl:()=>Wi,EditorImageCropper:()=>Dt,EditorImageFader:()=>Bi,EditorOperationControl:()=>zt,EditorScroller:()=>Kt,EditorSlider:()=>Nt,EditorToolbar:()=>ee,Icon:()=>Oe,LineLoaderUi:()=>Ut,PresenceToggle:()=>pt,SliderUi:()=>ve,defineComponents:()=>ie});var Zc="cloud-image-editor",Yc="<svg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></svg>",En={id:Zc,setup:async({pluginApi:o,uploaderApi:r})=>(ie({...lo,...so}),o.registry.registerIcon({name:"edit-file",svg:Yc}),o.registry.registerFileAction({id:"edit-file",icon:"edit-file",label:"file-item-edit-button",shouldRender:t=>!!(t.isImage&&t.cdnUrl),onClick:t=>{r.setCurrentActivity?.(A.CLOUD_IMG_EDIT,{internalId:t.internalId}),r.setModalState?.(true);}}),o.registry.registerActivity({id:A.CLOUD_IMG_EDIT,render:t=>{let i=document.createElement("uc-cloud-image-editor-activity");return t.append(i),()=>{t.replaceChildren();}}}),r.on(b.FILE_UPLOAD_SUCCESS,t=>{if(!t.isImage)return;let i=o.config.get("cropPreset"),s=o.config.get("useCloudImageEditor"),n=o.config.get("cloudImageEditorAutoOpen"),a=r._uploadCollection.size;s&&a===1&&(i||n)&&(r.setCurrentActivity?.(A.CLOUD_IMG_EDIT,{internalId:t.internalId}),r.setModalState?.(true));}))};var xn={id:"external-sources",setup:async({pluginApi:o,uploaderApi:r})=>{ie({ExternalSource:te}),o.registry.registerActivity({id:A.EXTERNAL,render:e=>{let t=document.createElement("uc-external-source");return e.append(t),()=>{e.replaceChildren();}}});for(let e of Object.values(Q))o.registry.registerSource({id:e,label:`src-type-${e}`,icon:e,onSelect:()=>{r.setCurrentActivity(A.EXTERNAL,{externalSourceType:e}),r.setModalState(true);}});}};var Xc=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,Sn=o=>{if(typeof o!="string")return false;let r=Xc.exec(o.toLocaleLowerCase())??[];if(r.length===0)return false;let e=Number(r[1])*Number(r[2]),t=16384*16384;return e>t?(console.warn(`Shrinked size can not be larger than ${Math.floor(t/1e3/1e3)}MP. You have set ${r[1]}x${r[2]} (${Math.ceil(e/1e3/100)/10}MP).`),false):{quality:r[3]?Number(r[3])/100:void 0,size:e}};var In={id:"image-shrink",setup({pluginApi:o}){o.registry.registerFileHook({type:"beforeUpload",handler:async({file:r})=>{let e=o.config.get("imageShrink");if(!e)return {file:r};let t=Sn(e);if(!t)return console.warn("[ImageShrinkPlugin] Image shrink settings are invalid, skipping shrinking"),{file:r};try{return {file:await shrinkFile(r,t)}}catch{return {file:r}}}});}};var An={id:"instagram",setup({pluginApi:o}){o.registry.registerSource({id:"instagram",label:"src-type-instagram",icon:"instagram",expand:()=>(console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here: https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US"),[]),onSelect:()=>{}});}};var kn={id:T.LOCAL,setup:({pluginApi:o,uploaderApi:r})=>{o.registry.registerSource({id:T.LOCAL,label:"src-type-local",icon:"local",onSelect:()=>{r.openSystemDialog();}});}};var Mn={id:"url-source",setup:async({pluginApi:o,uploaderApi:r})=>{ie({UrlSource:gt}),o.registry.registerActivity({id:A.URL,render:e=>{let t=document.createElement("uc-url-source");return e.append(t),()=>{e.replaceChildren();}}}),o.registry.registerSource({id:"url",label:"src-type-from-url",icon:"url",onSelect:()=>{r.setCurrentActivity(A.URL),r.setModalState(true);}});}};var vt=[{configDeps:["useCloudImageEditor"],isEnabled:o=>!!o("useCloudImageEditor"),load:()=>En},{configDeps:["imageShrink"],isEnabled:o=>!!o("imageShrink"),load:()=>In},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes(T.LOCAL),load:()=>kn},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes(T.CAMERA),load:()=>Tn},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes("instagram"),load:()=>An},{configDeps:["sourceList"],isEnabled:o=>Object.values(Q).some(r=>V(o("sourceList")).includes(r)),load:()=>xn},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes(T.URL),load:()=>Mn}];var Wt=class extends Ee{constructor(){super();this.headless=false;this.smartButton=false;this.init$={...this.init$};}static{this.lazyPlugins=vt;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"];}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION});}get isSmartBtnActive(){return this.smartButton}_renderSmartButton(){return html`<uc-smart-btn></uc-smart-btn>`}_renderStaticButton(){return html`<uc-simple-btn></uc-simple-btn>`}_renderButton(){return this.headless?null:this.smartButton?this._renderSmartButton():this._renderStaticButton()}render(){return html` ${super.render()} ${this._renderButton()}<uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]}>${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-plugin-activity-renderer mode="modal"></uc-plugin-activity-renderer>`}};d([property({type:Boolean})],Wt.prototype,"headless",2),d([property({attribute:"smart-button",type:Boolean})],Wt.prototype,"smartButton",2);var tr=class extends Ee{constructor(){super();this._couldCancel=false;this._handleCancel=()=>{if(this._couldHistoryBack){let e=this.$["*historyBack"];e?.();return}this._couldShowList&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST);};this.init$={...this.init$};}static{this.lazyPlugins=vt;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"];}get _couldHistoryBack(){let e=this.$["*history"];return !e||e.length<=1?false:e[e.length-1]!==E.activities.START_FROM}get _couldShowList(){let e=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(e)&&e.length>0}_getInitActivity(){return this.getCssData("--cfg-init-activity")||E.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e);}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0&&this.$["*currentActivity"]===e&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST);}),this.sub("*history",()=>{this._couldCancel=this._couldHistoryBack||this._couldShowList;});}render(){return html` ${super.render()}<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel} ?hidden=${!this._couldCancel} >${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-plugin-activity-renderer mode="inline"></uc-plugin-activity-renderer>`}};d([state()],tr.prototype,"_couldCancel",2);var uo="active",ir="",Fe=class extends Ee{constructor(){super();this._singleUpload=false;this._isHiddenStartFrom=false;this._classUploadList=ir;this._classStartFrom=ir;this._buttonTextKey="choose-file";this._handleModalOpen=e=>{e.id===E.activities.CLOUD_IMG_EDIT&&(this._classUploadList=uo),this.$["*currentActivity"]===E.activities.UPLOAD_LIST&&(this._classUploadList=uo,this._isHiddenStartFrom=true);let t=this.$["*uploadList"];(!t||t.length<=0)&&(this._classStartFrom=uo);};this._handleModalClose=e=>{e.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST,this._isHiddenStartFrom=false),e.id===E.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST);};this.init$={...this.init$};}static{this.lazyPlugins=vt;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"];}_getInitActivity(){return this.getCssData("--cfg-init-activity")||E.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t===E.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),t||(this.$["*currentActivity"]=e);}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0?(this.$["*currentActivity"]=E.activities.UPLOAD_LIST,this._classStartFrom=ir):(this._classUploadList=ir,this._isHiddenStartFrom=false,this.$["*currentActivity"]=e);}),this.subConfigValue("confirmUpload",t=>{t!==false&&(this.cfg.confirmUpload=false);}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t),this.subConfigValue("multiple",i=>{t==="grid"?(i?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this._singleUpload=!i):(this.style.removeProperty("--uc-grid-col"),this._singleUpload=false);});}),this.subConfigValue("multiple",t=>{this._buttonTextKey=t?"choose-files":"choose-file";}),this.modalManager?.subscribe(B.OPEN,this._handleModalOpen),this.modalManager?.subscribe(B.CLOSE,this._handleModalClose);}disconnectedCallback(){super.disconnectedCallback(),this.modalManager?.unsubscribe(B.OPEN,this._handleModalOpen),this.modalManager?.unsubscribe(B.CLOSE,this._handleModalClose);}render(){return html` ${super.render()}<uc-start-from ?hidden=${this._isHiddenStartFrom} class=${this._classStartFrom}><uc-drop-area ?single=${this._singleUpload} initflow clickable tabindex="0" ><span>${this.l10n(this._buttonTextKey)}</span></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list class=${this._classUploadList}></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]} >${this.l10n("start-from-cancel")}</button></uc-start-from></uc-modal><uc-plugin-activity-renderer mode="modal"></uc-plugin-activity-renderer>`}};d([state()],Fe.prototype,"_singleUpload",2),d([state()],Fe.prototype,"_isHiddenStartFrom",2),d([state()],Fe.prototype,"_classUploadList",2),d([state()],Fe.prototype,"_classStartFrom",2),d([state()],Fe.prototype,"_buttonTextKey",2);
7
+ var ho=Object.defineProperty;var On=Object.getOwnPropertyDescriptor;var mo=(o,r)=>{for(var e in r)ho(o,e,{get:r[e],enumerable:true});};var d=(o,r,e,t)=>{for(var i=t>1?void 0:t?On(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&ho(r,e,i),i};var R=class o{static{this._contexts=new Map;}constructor(r,e){this._ctxId=r,this._store=e;}get id(){return this._ctxId}pub(r,e){r in this._store.get()||console.warn(`PubSub#pub: Key "${String(r)}" not found`),this._store.setKey(r,e);}sub(r,e,t=true){return (t?subscribeKeys:listenKeys)(this._store,[r],s=>{e(s[r]);})}read(r){return r in this._store.get()||console.warn(`PubSub#read: Key "${String(r)}" not found`),this._store.get()[r]}add(r,e,t=false){(!(r in this._store.get())||t)&&this._store.setKey(r,e);}has(r){return r in this._store.get()}get store(){return this._store.get()}static registerCtx(r,e){if(o._contexts.has(e))throw new Error(`PubSub: Context with id "${e}" already exists`);let t=map(r);return o._contexts.set(e,t),new o(e,t)}static deleteCtx(r){o._contexts.delete(r);}static getCtx(r){let e=o._contexts.get(r);return e?new o(r,e):null}static hasCtx(r){return o._contexts.has(r)}};var Vn=/\\([0-9a-fA-F]{1,6} ?)/g;function $n(o){return o.length<2?false:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function Dn(o){let r=o;return (r[0]==='"'||r[0]==="'")&&(r=r.slice(1)),(r[r.length-1]==='"'||r[r.length-1]==="'")&&(r=r.slice(0,-1)),r}function Fn(o){let r="",e="";for(let t=0;t<o.length;t++){let i=o[t+1];o[t]==="\\"&&i==='"'?(r+='\\"',t++):o[t]==='"'&&e!=="\\"?r+='\\"':r+=o[t],e=o[t]??"";}return r}function fo(o){let r=o;$n(o)&&(r=Dn(r),r=r.replace(Vn,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),r=r.replaceAll(`\\ `,"\\n"),r=Fn(r),r='"'+r+'"');try{return JSON.parse(r)}catch{return}}function We(o){class r extends o{constructor(){super(...arguments);this._cssDataCache=null;this._computedStyle=null;}getCssData(i,s=false){let n=this._cssDataCache??Object.create(null);if(!Object.keys(n).includes(i)||!n[i]){this._computedStyle||(this._computedStyle=window.getComputedStyle(this));let a=this._computedStyle.getPropertyValue(i).trim();try{n[i]=fo(a);}catch(l){s||console.warn(`CSS Data error: ${i}`,l),n[i]=null;}}return this._cssDataCache=n,n[i]}}return r}function Yt(o){class r extends o{constructor(){super(...arguments);this.willYield=true;this._slotsMap={};this._initialLightDomChildren=null;this._hasAdoptedChildren=false;}createRenderRoot(){return this}connectedCallback(){this._initialLightDomChildren||(this._initialLightDomChildren=Array.from(this.childNodes)),super.connectedCallback();}_adoptChildren(){if(this._hasAdoptedChildren)return;this._hasAdoptedChildren=true,this._slotsMap={};let i=Array.from(this.childNodes),s=i.length?i:this._initialLightDomChildren??[];for(let n of s){let a=this._getSlotNameForChild(n),l=this._slotsMap[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this._slotsMap[a]=l;}this._initialLightDomChildren=null;}_getSlotNameForChild(i){return i instanceof Comment&&i.nextSibling instanceof Element?this._getSlotNameForChild(i.nextSibling):"contentFor"in i?i.contentFor||"":i instanceof Element&&i.hasAttribute("content-for")&&i.getAttribute("content-for")||""}_isTextNodeEmpty(i){return !i.textContent||!i.textContent.trim()}_isSlotEmpty(i){let s=this._slotsMap[i];return !s||s.every(n=>n instanceof Comment||n instanceof Text&&this._isTextNodeEmpty(n))}update(i){!this.hasUpdated&&this.willYield&&this._adoptChildren(),super.update(i);}yield(i,s){if(i===""&&!this._slotsMap[i]&&!this._hasAdoptedChildren&&this._initialLightDomChildren?.length){let a=[];for(let l of this._initialLightDomChildren)l instanceof Element&&(l.removeAttribute("slot"),l.removeAttribute("content-for")),a.push(l);this._slotsMap[i]=a,this._hasAdoptedChildren=true,this._initialLightDomChildren=null;}let n=this._slotsMap[i];return html` ${n} ${this._isSlotEmpty(i)?s:void 0} `}}return r}function qe(o){class r extends o{static reg(t){let i=this,s=window.customElements.get(t);if(s){s!==i&&console.warn([`Element with tag name "${t}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(` `));return}window.customElements.define(t,i);}}return r}function S(o,r){let e,t=((...i)=>{e&&clearTimeout(e),e=setTimeout(()=>o(...i),r);});return t.cancel=()=>{e&&clearTimeout(e);},t}var go=createContext("ctx-name-context");function Xt(){return function(o){class r extends o{constructor(...i){super(...i);this._symbioteSharedPubSub=null;this._symbioteFirstUpdated=false;this._needsReconnectInit=false;this._ctxNameProvider=void 0;this._pendingSharedAdds=new Map;this._symbioteSubscriptions=new Set;this.init$={};this.ctxOwner=false;this._ctxNameAttrValue=void 0;this._pendingCtxInitOnConnect=false;this.ctxName=this._effectiveCtxName;this._isInitialized=false;this._ctxNameAttrValue=this.getAttribute("ctx-name")||void 0,this.ctxName=this._effectiveCtxName,this._ctxNameConsumer=new ContextConsumer(this,{context:go,callback:s=>{if(!s){console.error("SymbioteMixin: Received invalid ctx-name from context");return}this._ctxNameFromContext=s,this._handleCtxNameSourceChange();},subscribe:true});}static set template(i){console.error("Caution: static 'template' property is deprecated and has no effect. See https://github.com/uploadcare/file-uploader/releases/tag/v1.25.0 for details.");}get _ctxNameAttr(){return this._ctxNameAttrValue}set _ctxNameAttr(i){let s=i??void 0;this._ctxNameAttrValue!==s&&(this._ctxNameAttrValue=s,this._handleCtxNameSourceChange());}shouldUpdate(i){return this._isInitialized?super.shouldUpdate(i):false}get _effectiveCtxName(){return this._ctxNameAttr||this._ctxNameFromContext||void 0}_handleCtxNameSourceChange(){if(this.ctxName=this._effectiveCtxName,!(!this.ctxName||this._symbioteFirstUpdated)){if(this.isConnected){this._performInitialization();return}this._pendingCtxInitOnConnect=true;}}willUpdate(i){super.willUpdate(i),this.ctxName=this._effectiveCtxName,this.ctxName&&(this._ctxNameProvider?this._ctxNameProvider.setValue(this.ctxName):this._ctxNameProvider=new ContextProvider(this,{context:go,initialValue:this.ctxName}));}_applyPendingSharedAdds(){if(!(!this._symbioteSharedPubSub||this._pendingSharedAdds.size===0)){for(let[i,{value:s,rewrite:n}]of this._pendingSharedAdds)this._symbioteSharedPubSub.add(i,s,n);this._pendingSharedAdds.clear();}}_getSharedPubSub(){return !this._symbioteSharedPubSub&&this._effectiveCtxName&&this._initSharedContext(),this._symbioteSharedPubSub&&this._applyPendingSharedAdds(),this._symbioteSharedPubSub}_requireSharedPubSub(){let i=this._getSharedPubSub();if(!i)throw new Error("SymbioteMixin: Shared context is not initialized.");return i}_initSharedContext(){let i=this.init$,s=this._effectiveCtxName;if(!s){console.error("SymbioteMixin: ctx-name is required for components with shared properties (*)");return}if(!this._symbioteSharedPubSub){this._symbioteSharedPubSub=R.getCtx(s)??R.registerCtx(i,s);for(let[n,a]of Object.entries(this.init$))this._symbioteSharedPubSub.add(n,a,this.ctxOwner);this._applyPendingSharedAdds();}}get $(){return this._effectiveCtxName&&this._initSharedContext(),new Proxy({},{get:(i,s)=>{if(typeof s=="string")return this._symbioteSharedPubSub?.read(s)},set:(i,s,n)=>(typeof s!="string"||this._symbioteSharedPubSub?.pub(s,n),true)})}sub(i,s,n=true){let a=this._requireSharedPubSub().sub(i,s,n);if(!a||typeof a!="function")return ()=>{};let l=a.bind(a),c=false,u=()=>{c||(c=true,l(),this._symbioteSubscriptions.delete(u));};return this._symbioteSubscriptions.add(u),u}pub(i,s){this._requireSharedPubSub().pub(i,s);}set$(i){for(let[s,n]of Object.entries(i))this.pub(s,n);}get sharedCtx(){return this._requireSharedPubSub()}has(i){return this._symbioteSharedPubSub?.has(i)??false}add(i,s,n=false){let a=this._getSharedPubSub();if(!a){if(!n&&this._pendingSharedAdds.has(i))return;this._pendingSharedAdds.set(i,{value:s,rewrite:n});return}this._pendingSharedAdds.delete(i),a.add(i,s,n);}add$(i,s=false){for(let[n,a]of Object.entries(i))this.add(n,a,s);}connectedCallback(){super.connectedCallback(),this._symbioteFirstUpdated?this._isInitialized&&this._needsReconnectInit&&(this._needsReconnectInit=false,this.initCallback()):this.ctxName?(this._pendingCtxInitOnConnect=false,this._performInitialization()):this._pendingCtxInitOnConnect&&this._effectiveCtxName&&(this._pendingCtxInitOnConnect=false,this._performInitialization());}_performInitialization(){if(this._symbioteFirstUpdated)return;this._symbioteFirstUpdated=true,this._initSharedContext();let i=this.init$;if(Object.keys(i).length>0){let s=this._requireSharedPubSub();for(let[n,a]of Object.entries(i))s.read(n)===void 0&&s.pub(n,a),this.sub(n,S(async()=>{this.isConnected&&(await this.updateComplete,this.requestUpdate());},0),false);}this.initCallback(),this._isInitialized=true,this.requestUpdate();}firstUpdated(i){super.firstUpdated(i);}disconnectedCallback(){this._cleanupSymbioteSubscriptions(),super.disconnectedCallback(),this._symbioteFirstUpdated&&(this._needsReconnectInit=true);}_cleanupSymbioteSubscriptions(){if(this._symbioteSubscriptions.size!==0){for(let i of [...this._symbioteSubscriptions])i();this._symbioteSubscriptions.clear();}}initCallback(){}}return d([property({type:String,attribute:"ctx-name",noAccessor:true})],r.prototype,"_ctxNameAttr",1),d([state()],r.prototype,"_ctxNameFromContext",2),d([state()],r.prototype,"ctxName",2),d([state()],r.prototype,"_isInitialized",2),r}}var or=class extends qe(Xt()(We(Yt(LitElement)))){};var W=class o{static generateFastUid(){return `uid-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}static generateRandomUUID(){let r=globalThis.crypto;return r&&typeof r.randomUUID=="function"?r.randomUUID():o.generateFastUid()}};var Gn=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function ie(o){for(let r in o){if(Gn.includes(r))continue;let e=[...r].reduce((t,i)=>(i.toUpperCase()===i&&(i=`-${i.toLowerCase()}`),t+=i,t),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),o[r].reg&&o[r].reg(e);}}var sr="UC";function Wn(o,r=false){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[sr]){e(window[sr]);return}let i=document.createElement("script");i.async=true,i.src=o,i.onerror=()=>{t();},i.onload=()=>{let s=window[sr];r&&ie(s),e(s);},document.head.appendChild(i);})}var bt={"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","drop-file-here":"Drop file 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-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-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop","upload-from":"Upload {{source}}","get-from":"Get from {{source}}","capture-with":"Capture with {{source}}",take:"Take {{source}}",record:"Record {{source}}",retake:"Retake",accept:"Accept"};var nr=new Map,vo=new Map,bo=(o,r)=>{nr.has(o)&&console.log(`Locale ${o} is already defined. Overwriting...`);let e={...bt,...r};return nr.set(o,e),e},qn=(o,r)=>{vo.set(o,r);},yo=(o,r)=>{typeof r=="function"?qn(o,r):bo(o,r);},_o=async o=>{let r=nr.get(o);if(!r){let e=vo.get(o);if(!e)throw new Error(`Locale ${o} is not defined`);let t=await e();r=bo(o,t);}return r};yo("en",bt);var v=o=>`*cfg/${o}`;var V=o=>o?o.split(",").map(r=>r.trim()).filter(Boolean):[],_e=o=>o.join(",");var Co=o=>{if(typeof o!="string"||!o)return "";let r=o.trim();return r.startsWith("-/")?r=r.slice(2):r.startsWith("/")&&(r=r.slice(1)),r.endsWith("/")&&(r=r.slice(0,r.length-1)),r},Qt=(...o)=>o.filter(r=>typeof r=="string"&&!!r).map(r=>Co(r)).join("/-/"),q=(...o)=>{let r=Qt(...o);return r?`-/${r}/`:""};function Jt(o){let r=new URL(o),e=r.pathname+r.search+r.hash,t=e.lastIndexOf("http"),i=e.lastIndexOf("/"),s="";return t>=0?s=e.slice(t):i>=0&&(s=e.slice(i+1)),s}function ei(o){let r=new URL(o),{pathname:e}=r,t=e.indexOf("/"),i=e.indexOf("/",t+1);return e.substring(t+1,i)}function ar(o){let r=wo(o),e=new URL(r),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}function lr(o){return ar(o).split("/-/").filter(Boolean).map(e=>Co(e))}function wo(o){let r=new URL(o),e=Jt(o),t=To(e)?Eo(e).pathname:e;return r.pathname=r.pathname.replace(t,""),r.search="",r.hash="",r.toString()}function To(o){return o.startsWith("http")}function Eo(o){let r=new URL(o);return {pathname:`${r.origin}${r.pathname??""}`,search:r.search??"",hash:r.hash??""}}var F=(o,r,e)=>{let t=new URL(wo(o)),i=e??Jt(o),s=r??"";if(t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),i&&To(i)){let n=Eo(i);t.pathname=`${t.pathname}${s}${n.pathname||""}`,t.search=n.search,t.hash=n.hash;}else t.pathname=`${t.pathname}${s}${i||""}`;return t.toString()},Ae=(o,r)=>{let e=new URL(o);return e.pathname=`${r}/`,e.toString()};var N=(o,r=",")=>o.trim().split(r).map(e=>e.trim()).filter(e=>e.length>0);var yt=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:false,flip:false,crop:void 0}),So=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Zn(o,r){if(typeof r=="number"){let e=r;return yt[o]!==e?`${o}/${e}`:""}if(typeof r=="boolean"){let e=r;return yt[o]!==e?`${o}`:""}if(o==="filter"&&r){let{name:e,amount:t}=r;return yt.filter===t?"":`${o}/${e}/${t}`}if(o==="crop"&&r){let{dimensions:e,coords:t}=r;return `${o}/${e.join("x")}/${t.join(",")}`}return ""}function ke(o){return Qt(...So.filter(r=>typeof o[r]<"u"&&o[r]!==null).map(r=>{let e=o[r];return Zn(r,e)}).filter(r=>!!r))}var ti=Qt("format/auto","progressive/yes"),Ce=([o])=>typeof o<"u"?Number(o):void 0,xo=()=>true,Yn=([o,r])=>({name:o,amount:typeof r<"u"?Number(r):100}),Xn=([o,r])=>{if(!/\d+x\d+/.test(o)||!/\d+,\d+/.test(r))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return {dimensions:N(o,"x").map(Number),coords:N(r).map(Number)}},Qn=Object.freeze({enhance:Ce,brightness:Ce,exposure:Ce,gamma:Ce,contrast:Ce,saturation:Ce,vibrance:Ce,warmth:Ce,filter:Yn,mirror:xo,flip:xo,rotate:Ce,crop:o=>{let[r,e]=o,{dimensions:t,coords:i}=Xn([r,e]);return {dimensions:t,coords:i}}});function cr(o){let r={};for(let e of o){let[t,...i]=e.split("/");if(!t||!So.includes(t))continue;let s=t,n=Qn[s];try{let a=n(i);r[s]=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(` `));}}return r}var O=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),Z=Object.freeze([O.CROP,O.TUNING,O.FILTERS]),Io=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Ao=Object.freeze(["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"]),ko=Object.freeze(["rotate","mirror","flip"]),we=yt,ce=Object.freeze({brightness:{zero:we.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:we.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:we.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:we.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:we.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:we.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:we.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:we.enhance,range:[0,100],keypointsNumber:1},filter:{zero:we.filter,range:[0,100],keypointsNumber:1}});var _t="https://ucarecdn.com",Jn="https://upload.uploadcare.com",ea="https://social.uploadcare.com",ta="https://ucarecd.net",ia={pubkey:"",multiple:true,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:false,imgOnly:false,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:false,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:false,useLocalImageEditor:false,removeCopyright:false,cropPreset:"",imageShrink:"",modalScrollLock:true,modalBackdropStrokes:false,sourceListWrap:true,remoteTabSessionKey:"",cdnCname:_t,cdnCnamePrefixed:ta,baseUrl:Jn,socialBaseUrl:ea,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:3,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:false,saveUrlForRecurrentUploads:false,groupOutput:false,userAgentIntegration:"",debug:false,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:true,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:false,useCloudImageEditor:true,cloudImageEditorAutoOpen:false,cloudImageEditorTabs:_e(Z),cloudImageEditorMaskHref:null,testMode:false,qualityInsights:true,pasteScope:"local",plugins:[],smartButtonViewMode:"auto",smartButtonShowFirstIcon:true},z=Object.freeze(ia);var ii=(o,r)=>(...e)=>{let t=o();if(!t.read(v("debug")))return;let i=e;if(typeof e?.[0]=="function"){let n=e[0];i=n();}let s=[t.id,r].filter(Boolean);console.log(`[${s.join("][")}]`,...i);};var U=class{constructor(r){this._subscriptions=new Set;this._cfgProxy=null;this._debugPrint=ii(()=>this._sharedInstancesBag.ctx,this.constructor.name);this._sharedInstancesBag=r,this._ctx=r.ctx;}addSub(r){this._subscriptions.add(r);}get _cfg(){if(!this._cfgProxy){let r={};this._cfgProxy=new Proxy(r,{set:()=>{throw new Error("SharedInstance cfg proxy is read-only")},get:(e,t)=>{if(typeof t!="string")return;let i=v(t);return this._sharedInstancesBag.ctx.has(i)?this._sharedInstancesBag.ctx.read(i):z[t]}});}return this._cfgProxy}destroy(){for(let r of this._subscriptions)try{r();}catch{}this._subscriptions.clear();}},ra={modalManager:"*modalManager",pluginManager:"*pluginManager",telemetryManager:"*telemetryManager",localeManager:"*localeManager",a11y:"*a11y",clipboard:"*clipboard",routerLayer:"*routerLayer",blocksRegistry:"*blocksRegistry",eventEmitter:"*eventEmitter",uploadCollection:"*uploadCollection",secureUploadsManager:"*secureUploadsManager",api:"*publicApi",validationManager:"*validationManager"},ne=(o,r,e=true)=>{let t=o.has(r),i=t?o.read(r):null;if(t&&i||!e)return i;throw new Error(`Unexpected error: shared instance for key "${String(r)}" is not available`)},Mo=o=>({get ctx(){return o()},get modalManager(){return ne(o(),"*modalManager",false)},get pluginManager(){return ne(o(),"*pluginManager")},get telemetryManager(){return ne(o(),"*telemetryManager")},get localeManager(){return ne(o(),"*localeManager")},get a11y(){return ne(o(),"*a11y")},get routerLayer(){return ne(o(),"*routerLayer")},get blocksRegistry(){return ne(o(),"*blocksRegistry")},get eventEmitter(){return ne(o(),"*eventEmitter")},get uploadCollection(){return ne(o(),"*uploadCollection")},get secureUploadsManager(){return ne(o(),"*secureUploadsManager",false)},get api(){return ne(o(),"*publicApi")},get validationManager(){return ne(o(),"*validationManager")},when(r,e){let t=ra[r],i=o(),s=i.has(t)?i.read(t):void 0;if(s)return e(s),()=>{};let n;return n=i.sub(t,a=>{a&&(e(a),n?.());}),n},wait(r){return new Promise(e=>{let t;t=this.when(r,i=>{e(i),t?.();});})}});var B=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),ri=class extends U{constructor(){super(...arguments);this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;}registerModal(e,t){this._modals.set(e,t),this._notify(B.ADD,{id:e,modal:t});}deleteModal(e){let t=this._modals.get(e);return t?(this._modals.delete(e),this._activeModals.delete(e),this._notify(B.DELETE,{id:e,modal:t}),true):false}open(e){let t=this._modals.get(e);return t?(this._activeModals.add(e),this._notify(B.OPEN,{modal:t,id:e}),true):(this._debugPrint(`Modal with ID "${e}" not found`),false)}close(e){let t=this._modals.get(e);return !t||!this._activeModals.has(e)?(this._debugPrint(`Modal with ID "${e}" not found or not active`),false):(this._activeModals.delete(e),this._notify(B.CLOSE,{id:e,modal:t}),true)}toggle(e){return this._modals.has(e)?this._activeModals.has(e)?this.close(e):this.open(e):(this._debugPrint(`Modal with ID "${e}" not found`),false)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),false;let e=Array.from(this._activeModals).pop();return e?this.close(e):false}closeAll(){let e=this._activeModals.size;return this._activeModals.clear(),this._notify(B.CLOSE_ALL,{}),e}subscribe(e,t){return this._subscribers.has(e)||this._subscribers.set(e,new Set),this._subscribers.get(e)?.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){this._subscribers.has(e)&&this._subscribers.get(e)?.delete(t);}_notify(e,t){if(this._subscribers.has(e))for(let i of this._subscribers.get(e)??new Set)try{i(t);}catch(s){this._sharedInstancesBag.telemetryManager.sendEventError(s,"modal subscriber"),this._debugPrint("Error in modal subscriber:",s);}}destroy(){super.destroy(),this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(B.DESTROY,{});}};var oi=o=>o.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(r=>r.toLowerCase()).join("-");var dr=()=>({}),ur=o=>({...dr(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{o.modalManager?.close(o.$["*currentActivity"]),o.pub("*currentActivity",null);}}),pr=o=>({...ur(o),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new Queue(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set}),Po=o=>({...pr(o),"*solution":null,"*lazyPlugins":null});var si=class extends U{constructor(e){super(e);this.scopes=new Set;this.listener=this._listener.bind(this),window.addEventListener("paste",this.listener);}_excludingNodes(e){return !!e.closest("uc-url-source")}openUploadList(){this._sharedInstancesBag.routerLayer.navigateAfterFileAdd();}async _listener(e){if(e.clipboardData){for(let t of this.scopes)if(t.isConnected){if(this._excludingNodes(e.target))return;switch(this._cfg.pasteScope){case "global":await this.handlePaste(e);break;case "local":if(!t.contains(e.target))continue;await this.handlePaste(e);break;default:continue}}}}async handlePaste(e){if(!e.clipboardData)return;let t=Array.from(e.clipboardData.items),i=t.map(n=>n.getAsFile()).filter(n=>n!==null),s=t.filter(n=>n.kind==="string"&&n.type==="text/plain").map(n=>new Promise(a=>{n.getAsString(l=>{a(l);});}));i.length>0&&(i.forEach(n=>{this._sharedInstancesBag.api.addFileFromObject(n,{source:"clipboard"});}),this.openUploadList()),s.length>0&&((await Promise.all(s)).forEach(a=>{this._sharedInstancesBag.api.addFileFromUrl(a,{source:"clipboard"});}),this.openUploadList());}registerBlock(e){return this.scopes.add(e),()=>{this.scopes.delete(e);}}destroy(){super.destroy(),window.removeEventListener("paste",this.listener),this.scopes.clear();}};var A=Object.freeze({START_FROM:"start-from",CAMERA:"camera",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var ni=class extends U{constructor(){super(...arguments);this._afterFileAddHooks=[];}registerAfterFileAddHook(e){return this._afterFileAddHooks.push(e),()=>{this._afterFileAddHooks=this._afterFileAddHooks.filter(t=>t!==e);}}navigateAfterFileAdd(){let t={historyLength:this._sharedInstancesBag.ctx.read("*history").length};this._afterFileAddHooks.some(s=>s(t))||(this._sharedInstancesBag.ctx.pub("*currentActivity",A.UPLOAD_LIST),this._sharedInstancesBag.modalManager?.open(A.UPLOAD_LIST));}};var hr=class{constructor(){this._listeners=new Map;this._scope=[];}addEventListener(r,e){let t=i=>{let s=i.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&e(i);};this._listeners.set(e,t),window.addEventListener(r,t);}removeEventListener(r,e){let t=this._listeners.get(e);t&&window.removeEventListener(r,t),this._listeners.delete(e);}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(r){this._scope.push(r);}destroy(){this._scope=[];for(let r of this._listeners.values())window.removeEventListener("keydown",r),window.removeEventListener("keyup",r);this._listeners.clear();}},ai=class{constructor(){this._scopedWindow=new hr,this._destroyKeyUX=startKeyUX(this._scopedWindow,[focusGroupKeyUX(),pressKeyUX("is-pressed"),jumpKeyUX(),hiddenKeyUX()]);}registerBlock(r){this._scopedWindow.registerScope(r);}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy();}};var Te=o=>`*l10n/${o}`,da="en",li=class extends U{constructor(e){super(e);this._localeName="";for(let[i,s]of Object.entries(bt)){let n=this._ctx.has(Te(i))?!this._ctx.read(Te(i)):true;this._ctx.add(Te(i),s,n);}let t=e.pluginManager;t?.onPluginsChange&&this.addSub(t.onPluginsChange(()=>{this._localeName&&this._applyPluginLocales(this._localeName);})),this.addSub(this._ctx.sub(v("localeName"),async i=>{if(!i)return;this._localeName=i;let s=await _o(i);i!==da&&this._localeName!==i||(this._applyPluginLocales(i),this._applyOverrides(i,s));})),this.addSub(this._ctx.sub(v("localeDefinitionOverride"),i=>{if(!i)return;let s=i[this._localeName];s&&this._applyOverrides(this._localeName,s);}));}_applyOverrides(e,t){let i=this._cfg.localeDefinitionOverride?.[e];for(let[s,n]of Object.entries(t)){let a=i?.[s];this._ctx.add(Te(s),a??n,true);}}_applyPluginLocales(e){let t=this._sharedInstancesBag.pluginManager;if(!t)return;let i=t.snapshot();for(let s of i.l10n){let{pluginId:n,...a}=s,l=a[e];if(l)for(let[c,u]of Object.entries(l))u!==void 0&&this._ctx.add(Te(c),u,true);}}};var ua=()=>{let o=navigator.userAgent;return /Macintosh|Windows/.test(o)&&/Version\/[\d.]+.*Safari/.test(o)&&!/Chrome|Chromium|Edg|OPR/.test(o)},pa=()=>"capture"in document.createElement("input"),ha=()=>({safariDesktop:ua()}),ma=()=>({htmlMediaCapture:pa()}),Oo=ha(),Lo=ma();var Ct="image/*",mr="video/*",fa=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],ga=()=>Oo.safariDesktop?[Ct]:[Ct,...fa],wt=ga(),ci=o=>o?o.filter(r=>typeof r=="string").flatMap(r=>N(r)):[],fr=(o,r)=>r.some(e=>{if(e.endsWith("*")){let t=e.replace("*","");return o.startsWith(t)}return o===e}),Ro=(o,r)=>r.some(e=>e.startsWith(".")?o.toLowerCase().endsWith(e.toLowerCase()):false),Ze=o=>{let r=o?.type;return r?fr(r,wt):false};function Uo(o,r,e,t,i){return {registry:{registerSource:c=>o.addSource(t,c),registerActivity:c=>o.addActivity(t,c),registerFileAction:c=>o.addFileAction(t,c),registerFileHook:c=>o.addFileHook(t,c),registerIcon:c=>o.addIcon(t,c),registerL10n:c=>o.addL10n(t,c),registerConfig:c=>{o.addConfig(t,c);let u=v(c.name);r.has(u)||r.add(u,c.defaultValue);}},config:{get:c=>{let u=v(c);return r.read(u)},subscribe:(c,u)=>{let p=v(c),m=r.sub(p,h=>{u(h);});return i.push(m),m}},activity:{getParams:()=>r.read("*currentActivityParams"),subscribeToParams:c=>{let u=r.sub("*currentActivityParams",p=>{c(p);});return i.push(u),u}},files:{update:(c,u)=>{let p=e.uploadCollection?.read(c);p&&(u.file!==void 0&&(p.setValue("file",u.file),p.setValue("fileSize",u.file.size)),u.cdnUrl!==void 0&&p.setValue("cdnUrl",u.cdnUrl),u.cdnUrlModifiers!==void 0&&p.setValue("cdnUrlModifiers",u.cdnUrlModifiers),u.mimeType!==void 0&&p.setValue("mimeType",u.mimeType));}}}}var va=async({entries:o,signal:r})=>(await Promise.all(o.map(async t=>{if(t.isEnabled())try{let i=await t.load();return r.aborted||!t.isEnabled()?void 0:i??void 0}catch(i){r.aborted||console.warn("Failed to load lazy plugin",i);return}}))).filter(t=>t!==void 0),di=class{constructor(r,e){this._ctx=r;this._onCompute=e;this._subs=new Set;this._unsubLazyPlugins=this._ctx.sub("*lazyPlugins",t=>{this._setEntries(t??[]);});}_setEntries(r){for(let i of this._subs)i();if(this._subs.clear(),r.length===0)return;let e=new Set([v("plugins")]);for(let i of r)for(let s of i.configDeps)e.add(v(s));let t=()=>this._compute(r);for(let i of e)this._subs.add(this._ctx.sub(i,t,false));this._compute(r);}_compute(r){this._abortController?.abort();let e=new AbortController;this._abortController=e;let t=n=>this._ctx.read(v(n)),i=t("plugins"),s=va({entries:r.map(n=>({isEnabled:()=>n.isEnabled(t),load:n.load})),signal:e.signal}).then(n=>{if(!e.signal.aborted)return [...i,...n]});this._onCompute(s);}destroy(){this._unsubLazyPlugins();for(let r of this._subs)r();this._subs.clear(),this._abortController?.abort();}};var ui=class{constructor(){this._definitions=new Map;}register(r,e){if(this._definitions.has(e.name)){console.warn(`[CustomConfig] Config option "${e.name}" is already registered`);return}let t={attribute:true,...e,pluginId:r};this._definitions.set(e.name,t);}unregister(r){this._definitions.delete(r);}unregisterByPlugin(r){for(let[e,t]of this._definitions)t.pluginId===r&&this._definitions.delete(e);}get(r){return this._definitions.get(r)}getAll(){return new Map(this._definitions)}};var pi=class{constructor(){this._sources=[];this._activities=[];this._fileActions=[];this._fileHooks=[];this._icons=[];this._l10n=[];this.config=new ui;}_own(r,e){return {...e,pluginId:r}}addSource(r,e){let t=this._sources.find(i=>i.id===e.id);if(t){console.warn(`[Plugin "${r}"] Source with id "${e.id}" is already registered by plugin "${t.pluginId}". Skipping.`);return}this._sources.push(this._own(r,e));}addActivity(r,e){let t=this._activities.find(i=>i.id===e.id);if(t){console.warn(`[Plugin "${r}"] Activity with id "${e.id}" is already registered by plugin "${t.pluginId}". Skipping.`);return}this._activities.push(this._own(r,e));}addFileAction(r,e){this._fileActions.push(this._own(r,e));}addFileHook(r,e){this._fileHooks.push(this._own(r,{timeout:3e4,...e}));}addIcon(r,e){this._icons.push(this._own(r,e));}addL10n(r,e){this._l10n.push(this._own(r,e));}addConfig(r,e){this.config.register(r,e);}purge(r){this._sources=this._sources.filter(e=>e.pluginId!==r),this._activities=this._activities.filter(e=>e.pluginId!==r),this._fileActions=this._fileActions.filter(e=>e.pluginId!==r),this._fileHooks=this._fileHooks.filter(e=>e.pluginId!==r),this._icons=this._icons.filter(e=>e.pluginId!==r),this._l10n=this._l10n.filter(e=>e.pluginId!==r),this.config.unregisterByPlugin(r);}snapshot(){return {sources:[...this._sources],activities:[...this._activities],fileActions:[...this._fileActions],fileHooks:[...this._fileHooks],icons:[...this._icons],l10n:[...this._l10n]}}};var hi=class extends U{constructor(e){super(e);this._plugins=new Map;this._subscribers=new Set;this._pluginsUpdate=Promise.resolve();this.registry=new pi;this._lazyPluginLoader=new di(this._ctx,t=>{this._pluginsUpdate=this._pluginsUpdate.then(()=>t).then(i=>{if(i)return this._syncPlugins(i)});});}get configRegistry(){return this.registry.config}pluginsReady(){return this._pluginsUpdate}onPluginsChange(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e);}}async _syncPlugins(e){let t=new Set(this._plugins.keys()),i=new Set;for(let s of e){if(!s.id){console.warn('[PluginManager] A plugin is missing the required "id" field, skipping');continue}if(i.has(s.id)){console.warn(`[PluginManager] Plugin "${s.id}" is already in the list, skipping duplicate`);continue}if(i.add(s.id),!this._plugins.has(s.id))try{await this._registerPlugin(s);}catch(n){this.registry.purge(s.id),this._notifySubscribers(),console.error(`[PluginManager] Plugin "${s.id}" setup() threw an error`,n);}t.delete(s.id);}for(let s of t)this._unregisterPlugin(s);}async _registerPlugin(e){this._plugins.has(e.id)&&this._unregisterPlugin(e.id);let t=[],i=Uo(this.registry,this._ctx,this._sharedInstancesBag,e.id,t),s=this._sharedInstancesBag.api,n;try{n=await e.setup({pluginApi:i,uploaderApi:s})??void 0;}catch(a){for(let l of t)try{l();}catch(c){this._debugPrint("Failed to unsubscribe config listener",c);}throw a}this._plugins.set(e.id,{plugin:e,dispose:n,configSubscriptions:t}),this._notifySubscribers();}_unregisterPlugin(e){let t=this._plugins.get(e);if(t){this.registry.purge(e);for(let i of t.configSubscriptions)try{i();}catch(s){this._debugPrint("Failed to unsubscribe config listener",s);}t.dispose?.(),this._plugins.delete(e),this._notifySubscribers();}}snapshot(){return this.registry.snapshot()}async runOnAddHooks(e){let t=e.getValue("file");if(!t)return;let i=this.registry.snapshot().fileHooks.filter(a=>a.type==="onAdd");if(i.length===0)return;let s=t,n=new AbortController;for(let a of i){if(n.signal.aborted)break;try{let l=a.handler({file:s,signal:n.signal}),c=new Promise((u,p)=>setTimeout(()=>p(new Error("onAdd hook timed out")),a.timeout));({file:s}=await Promise.race([l,c]));}catch(l){console.warn(`File hook "onAdd" from plugin "${a.pluginId}" failed`,l);}}s!==t&&(e.setValue("file",s),e.setValue("fileSize",s.size),e.setValue("mimeType",s.type||null),e.setValue("isImage",Ze(s)),s instanceof File&&e.setValue("fileName",s.name));}destroy(){for(let e of Array.from(this._plugins.keys()))this._unregisterPlugin(e);this._lazyPluginLoader.destroy(),super.destroy();}_notifySubscribers(){for(let e of this._subscribers)try{e();}catch{}}};var ba=20,x=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),b=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"}),mi=class extends U{constructor(){super(...arguments);this._timeoutStore=new Map;this._targets=new Set;this._listeners=new Map;}bindTarget(e){return this._targets.add(e),()=>{this._targets.delete(e);}}on(e,t){let i=this._listeners.get(e);return i||(i=new Set,this._listeners.set(e,i)),i.add(t),()=>this._listeners.get(e)?.delete(t)}_dispatch(e,t){for(let s of this._targets)s.dispatchEvent(new CustomEvent(e,{detail:t}));let i=this._listeners.get(e);if(i)for(let s of i)s(t);this._debugPrint?.(()=>{let s=t&&typeof t=="object"?{...t}:t;return [`event "${e}"`,s]});}emit(e,t,i={}){let{debounce:s}=i;if(typeof s!="number"&&!s){this._dispatch(e,typeof t=="function"?t():t);return}this._timeoutStore.has(e)&&window.clearTimeout(this._timeoutStore.get(e));let n=typeof s=="number"?s:ba,a=window.setTimeout(()=>{try{let l=typeof t=="function"?t():t;this._dispatch(e,l),this._timeoutStore.delete(e);}catch(l){this._debugPrint?.(()=>`Error while getting payload for event "${e}"`,l);}},n);this._timeoutStore.set(e,a);}destroy(){for(let e of this._timeoutStore.values())window.clearTimeout(e);this._targets.clear(),this._listeners.clear();}};var Vo="1.30.0-alpha.7";var pe="blocks",he=Vo;var fi=class extends U{constructor(e){super(e);this._sessionId=W.generateRandomUUID();this._config=structuredClone(z);this._initialized=false;this._lastPayload=null;this._isEnabled=false;this._telemetryInstance=new TelemetryAPIService,this._queue=new Queue(10),this.addSub(this._ctx.sub(v("qualityInsights"),t=>{this._isEnabled=!!t;}));for(let t of Object.keys(this._config))this.addSub(this._ctx.sub(v(t),i=>{this._isEnabled&&(this._initialized&&this._config[t]!==i&&this.sendEvent({eventType:x.CHANGE_CONFIG}),this._setConfig(t,i));}));}_init(e){e===x.INIT_SOLUTION&&!this._initialized&&(this._initialized=true);}_setConfig(e,t){this._config[e]!==t&&(this._config[e]=t);}_formattingPayload(e){let t=e.payload?{...e.payload}:{};t.activity&&(t.activity=void 0);let i={...e};return (e.eventType===x.INIT_SOLUTION||e.eventType===x.CHANGE_CONFIG)&&(i.config=this._config),{...i,appVersion:he,appName:pe,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:i.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...t}}}_excludedEvents(e){return !!(e&&[b.CHANGE,b.COMMON_UPLOAD_PROGRESS,b.FILE_ADDED,b.FILE_REMOVED,b.FILE_UPLOAD_START,b.FILE_UPLOAD_PROGRESS,b.FILE_UPLOAD_SUCCESS,b.FILE_UPLOAD_FAILED].includes(e))}sendEvent(e){if(!this._isEnabled)return;let t=this._formattingPayload({eventType:e.eventType,payload:e.payload,config:e.config});this._init(e.eventType),!(this._excludedEvents(e.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,t))&&this._queue.add(async()=>{this._lastPayload=t,await this._telemetryInstance.sendEvent(t);});}sendEventError(e,t="unknown"){this.sendEvent({eventType:x.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${t}`,error:e.message}}});}sendEventCloudImageEditor(e,t,i={}){this.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{tabId:t,node:e.currentTarget?.tagName,event:e.type,...i}}});}_checkObj(e,t){if(JSON.stringify(e)===JSON.stringify(t))return true;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return false;let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return false;for(let n of i)if(!Object.hasOwn(t,n)||!this._checkObj(e[n],t[n]))return false;return true}get _timestamp(){return Date.now()}get _solution(){if(!this._ctx.has("*solution"))return null;let e=this._ctx.read("*solution");return e?e.toLowerCase():null}get _activity(){return this._ctx.has("*currentActivity")?this._ctx.read("*currentActivity"):null}get _location(){return location.origin}};var $o=o=>{let r=new Intl.Locale(o),e="ltr",t=r.getTextInfo?.().direction;return t?e=t:r.textInfo?.direction&&(e=r.textInfo.direction),e};var wa=o=>o;var Do="plural:";function Ye(o,r={},e={}){let{openToken:t="{{",closeToken:i="}}",transform:s=wa}=e;for(let n in r){let a=r[n],l=a?.toString(),c=typeof l=="string"?s(l):String(l);o=o.replaceAll(t+n+i,c);}return o}function Fo(o){let r=[],e=o.indexOf("{{");for(;e!==-1;){let t=o.indexOf("}}",e);if(t===-1)break;let i=o.substring(e+2,t);if(i.startsWith(Do)){let s=o.substring(e+2,t).replace(Do,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));r.push({variable:i,pluralKey:n,countVariable:a});}e=o.indexOf("{{",t);}return r}var No="--uploadcare-blocks-window-height",Tt=class o{static{this.clientsRegistry=new Set;}static{this.flush=S(()=>{document.documentElement.style.setProperty(No,`${window.innerHeight}px`);},100);}static registerClient(r){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(r);}static unregisterClient(r){o.clientsRegistry.delete(r),o.clientsRegistry.size===0&&o.detachTracker();}static attachTracker(){window.addEventListener("resize",o.flush,{passive:true,capture:true}),o.flush();}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:true}),document.documentElement.style.removeProperty(No);}};var gi=(o,r)=>new Intl.PluralRules(o).select(r);var Ta=o=>(r,e)=>{let t=o(),i=t("locale-id")||"en",s=gi(i,e);return t(`${r}__${s}`)},vi=o=>{let r=Ta(()=>e),e=(t,i={})=>{if(!t)return "";let n=o().read(Te(t))||t,a=Fo(n);for(let c of a)i[c.variable]=r(c.pluralKey,Number(i[c.countVariable]));return Ye(n,i)};return e};var Ea=o=>o.tagName?.includes("-")??false,bi=class{constructor(r){this._trackedElements=new Set;this._originalValues=new Map;this._enabled=false;this._host=r,this._host.addController(this);}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=void 0,this._trackedElements.clear(),this._originalValues.clear();}hostUpdated(){if(!this._unsubscribe&&this._host.has(v("testMode"))){let r=this._host.subConfigValue("testMode",e=>{this._enabled=!!e,this._applyTestMode();});this._unsubscribe=r;}this._collectElements(),this._applyTestMode();}_collectElements(){let r=this._host,e=r.renderRoot??r;if(!e)return;let t=this._host,i=t.tagName?.toLowerCase(),s=Array.from(e.querySelectorAll("[data-testid]")).filter(n=>!Ea(n));for(let n of s)if(!(i&&n.closest(i)!==t)&&!this._trackedElements.has(n)){let a=n.getAttribute("data-testid");if(!a)continue;this._trackedElements.add(n),this._originalValues.set(n,a);}for(let n of Array.from(this._trackedElements))(!n.isConnected||i&&n.closest(i)!==t)&&(this._trackedElements.delete(n),this._originalValues.delete(n));}_applyTestMode(){if(!this._trackedElements.size)return;let r=this._host.testId||"";for(let e of this._trackedElements){let t=this._originalValues.get(e);t&&(this._enabled?e.setAttribute("data-testid",`${r}--${t}`):e.removeAttribute("data-testid"));}}};var Sa=qe(Xt()(We(Yt(LitElement)))),g=class extends Sa{constructor(){super();this.init$=dr();this.l10n=vi(()=>this.sharedCtx);this.debugPrint=ii(()=>this.sharedCtx,this.constructor.name);this._sharedInstancesBag=Mo(()=>this.sharedCtx);new bi(this);}static{this.styleAttrs=[];}emit(e,t,i){let s=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;if(!s)return;s.emit(e,t,i);let n=typeof t=="function"?t():t;this.telemetryManager.sendEvent({eventType:e,payload:n??void 0});}hasBlockInCtx(e){for(let t of this.blocksRegistry)if(e(t))return true;return false}connectedCallback(){this.constructor.styleAttrs.forEach(t=>{this.setAttribute(t,"");}),super.connectedCallback(),Tt.registerClient(this);}initCallback(){this._addSharedContextInstance("*blocksRegistry",()=>new Set),this._addSharedContextInstance("*pluginManager",e=>new hi(e)),this._addSharedContextInstance("*eventEmitter",e=>new mi(e)),this._addSharedContextInstance("*localeManager",e=>new li(e)),this._addSharedContextInstance("*modalManager",e=>new ri(e)),this._addSharedContextInstance("*a11y",()=>new ai),this._addSharedContextInstance("*routerLayer",e=>new ni(e)),this._addSharedContextInstance("*clipboard",e=>new si(e)),this._addSharedContextInstance("*telemetryManager",e=>new fi(e)),this.sub(Te("locale-id"),e=>{let t=$o(e);this.style.direction=t==="ltr"?"":t,this.requestUpdate();}),this.subConfigValue("testMode",e=>{if(!e||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId);}),this.blocksRegistry.add(this);}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this._getSharedContextInstance("*modalManager",false)}get telemetryManager(){return this._getSharedContextInstance("*telemetryManager")}get localeManager(){return this._getSharedContextInstance("*localeManager")}get a11y(){return this._getSharedContextInstance("*a11y")}get clipboardLayer(){return this._getSharedContextInstance("*clipboard")}get routerLayer(){return this._getSharedContextInstance("*routerLayer")}get blocksRegistry(){return this._getSharedContextInstance("*blocksRegistry")}get eventEmitter(){return this._getSharedContextInstance("*eventEmitter")}disconnectedCallback(){super.disconnectedCallback(),Tt.unregisterClient(this);let e=this.blocksRegistry;e?.delete(this),e?.size===0&&setTimeout(()=>{this.isConnected||e?.size>0||this.destroyCtxCallback();},0);}destroyCtxCallback(){this._destroySharedContextInstances(),R.deleteCtx(this.ctxName);}_getSharedContextInstances(){let e="*sharedContextInstances";if(!this.has(e)||!this.$[e]){let t=new Map;this.add(e,t,true);}return this.$[e]}_addSharedContextInstance(e,t){let i=this._getSharedContextInstances();if(!i.has(e)&&(!this.has(e)||!this.$[e])){let s=t(this._sharedInstancesBag);this.add(e,s,true),i.set(e,s);return}}_destroySharedContextInstances(){let e=this._getSharedContextInstances();for(let[t,i]of e.entries())i?.destroy?.(),this.pub(t,null);e.clear();}_getSharedContextInstance(e,t=true){if(this.has(e)&&this.$[e])return this.$[e];if(!t)return this.$[e];throw new Error(`Unexpected error: context manager for key "${String(e)}" is not available`)}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:ei(e),cdnUrlModifiers:ar(e),fileName:Jt(e)})}catch(t){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",t),this.telemetryManager.sendEventError(t,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?Ye(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:t=>window.encodeURIComponent(t)}):e}get cfg(){if(!this._cfgProxy){let e={};this._cfgProxy=new Proxy(e,{set:(t,i,s)=>{if(typeof i!="string"||!(i in z))return false;let n=i,a=v(n);return this.has(a)||this.add(a,z[n]),this.$[a]=s,true},get:(t,i)=>{let s=v(i);return this.has(s)||this.add(s,z[i]),this.$[s]}});}return this._cfgProxy}subConfigValue(e,t){let i=v(e);return this.has(i)||this.add(i,z[e]),this.sub(i,t)}};var Bo="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol fill='none' viewBox='0 0 24 24' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path d='M19.248 9.561 12 16.003 4.752 9.561l.996-1.122L12 13.995l6.252-5.556z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-photo-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-ngdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 16 16' id='uc-icon-paperclip' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M13.264 9.743 9.03 13.977a4.217 4.217 0 0 1-5.96-.005 4.217 4.217 0 0 1-.004-5.96l6.416-6.416a2.743 2.743 0 0 1 3.88 3.88L7.637 11.2a1.232 1.232 0 1 1-1.743-1.743L9.42 5.932'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var Ee=class extends g{constructor(){super(...arguments);this.init$=Po(this);}static{this.styleAttrs=["uc-wgt-common"];}static{this.lazyPlugins=null;}initCallback(){super.initCallback(),this.a11y?.registerBlock(this),this.clipboardLayer?.registerBlock(this),this.sharedCtx.pub("*solution",this.tagName);let e=this.constructor.lazyPlugins;e&&this.sharedCtx.pub("*lazyPlugins",e);}render(){return html`${unsafeSVG(Bo)}`}};var Ho=o=>typeof o!="number"?0:Math.floor(o/1e3),zo=(o,{threshold:r})=>{let{secureExpire:e}=o,t=Ho(Date.now()),i=Number(e),s=Ho(r);return t+s>=i};var yi=class extends U{constructor(){super(...arguments);this._secureToken=null;}async getSecureToken(){let{secureSignature:e,secureExpire:t,secureUploadsSignatureResolver:i,secureUploadsExpireThreshold:s}=this._cfg;if((e||t)&&i&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),i){if(!this._secureToken||zo(this._secureToken,{threshold:s})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let n=await i();n?!n.secureSignature||!n.secureExpire?console.error("Secure signature resolver returned an invalid result:",n):(this._debugPrint("Secure signature resolved:",n),this._debugPrint("Secure signature will expire in",new Date(Number(n.secureExpire)*1e3).toISOString()),this._secureToken=n):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null);}catch(n){console.error("Secure signature resolving failed. Falling back to the previous one.",n),this._sharedInstancesBag.telemetryManager.sendEventError(n,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.");}}return this._secureToken}return e&&t?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:e,secureExpire:t}),{secureSignature:e,secureExpire:t}):null}destroy(){super.destroy(),this._secureToken=null;}};var gr=(o,r)=>{if(o.failedCount>0)return {type:"SOME_FILES_HAS_ERRORS",message:r.l10n("some-files-were-not-uploaded")}};var vr=(o,r)=>{let e=o.totalCount,t=r.cfg.multiple?r.cfg.multipleMin:0,i=r.cfg.multiple?r.cfg.multipleMax:1;if(t&&e<t)return {type:"TOO_FEW_FILES",message:r.l10n("files-count-limit-error-too-few",{min:t,max:i,total:e}),payload:{total:e,min:t,max:i}};if(i&&e>i)return {type:"TOO_MANY_FILES",message:r.l10n("files-count-limit-error-too-many",{min:t,max:i,total:e}),payload:{total:e,min:t,max:i}}};var br=(o,r)=>{let e=r.cfg.imgOnly,t=r.cfg.accept,i=ci([...e?wt:[],t]);if(!i.length)return;let s=o.mimeType,n=o.name;if(!s||!n)return;let a=fr(s,i),l=Ro(n,i);if(!a&&!l)return {type:"FORBIDDEN_FILE_TYPE",message:r.l10n("file-type-not-allowed"),payload:{entry:o}}};var yr=(o,r)=>{let e=r.cfg.imgOnly,t=o.isImage;if(!(!e||t)&&!(!o.fileInfo&&o.externalUrl)&&!(!o.fileInfo&&!o.mimeType))return {type:"NOT_AN_IMAGE",message:r.l10n("images-only-accepted"),payload:{entry:o}}};var me=1e3,Ne=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),Et=o=>Math.ceil(o*100)/100,Ko=(o,r=Ne.AUTO)=>{let e=r===Ne.AUTO;if(r===Ne.BYTE||e&&o<me**1){let i=gi("en-US",o)==="one"?"byte":"bytes";return `${o} ${i}`}return r===Ne.KB||e&&o<me**2?`${Et(o/me**1)} KB`:r===Ne.MB||e&&o<me**3?`${Et(o/me**2)} MB`:r===Ne.GB||e&&o<me**4?`${Et(o/me**3)} GB`:r===Ne.TB||e&&o<me**5?`${Et(o/me**4)} TB`:`${Et(o/me**5)} PB`};var _r=(o,r)=>{let e=r.cfg.maxLocalFileSizeBytes,t=o.size;if(e&&t&&t>e)return {type:"FILE_SIZE_EXCEEDED",message:r.l10n("files-max-size-limit-error",{maxFileSize:Ko(e)}),payload:{entry:o}}};var Cr=(o,r)=>{let{internalId:e}=o;if(!r._uploadCollection.hasItem(e))return;let i=r._uploadCollection.read(e)?.getValue("uploadError");if(!i)return;if(i instanceof UploadError)return {type:"UPLOAD_ERROR",message:i.message,payload:{entry:o,error:i}};if(i instanceof NetworkError)return {type:"NETWORK_ERROR",message:i.message,payload:{entry:o,error:i}};let s=i instanceof Error?i:new Error("Unknown error",{cause:i});return {type:"UNKNOWN_ERROR",message:s.message,payload:{entry:o,error:s}}};var Xe={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},Oa=o=>typeof o=="function"?{runOn:"change",validator:o}:o,_i=class extends U{constructor(e){super(e);this._commonFileValidators=[yr,br,_r,Cr];this._commonCollectionValidators=[vr,gr];this._queue=new Queue(20);this._runQueueDebounced=S(()=>{this._queue.run();},500);this._isDestroyed=false;this._entryValidationState=new Map;let t=S(()=>{this.runFileValidators("change"),this.runCollectionValidators();},0);this.addSub(this._ctx.sub(v("maxLocalFileSizeBytes"),t)),this.addSub(this._ctx.sub(v("multipleMin"),t)),this.addSub(this._ctx.sub(v("multipleMax"),t)),this.addSub(this._ctx.sub(v("multiple"),t)),this.addSub(this._ctx.sub(v("imgOnly"),t)),this.addSub(this._ctx.sub(v("accept"),t)),this.addSub(this._ctx.sub(v("validationConcurrency"),i=>{this._queue.concurrency=i;}));}get _uploadCollection(){return this._sharedInstancesBag.uploadCollection}runFileValidators(e,t){if(this._isDestroyed)return;let i=t??this._uploadCollection.items();for(let s of i){let n=this._uploadCollection.read(s);n&&this._runFileValidatorsForEntry(n,e);}}runCollectionValidators(){if(this._isDestroyed)return;let e=this._sharedInstancesBag.api,t=e.getOutputCollectionState(),i=[],s=this._cfg.collectionValidators;for(let n of [...this._commonCollectionValidators,...s])try{let a=n(t,e);if(!a)continue;a&&(i.push(this._addCustomTypeToValidationError(a)),a.message||console.warn(Xe.MISSING_ERROR_MESSAGE));}catch(a){console.warn(Xe.COLLECTION_VALIDATION_FAILED,a);}this._ctx.pub("*collectionErrors",i),i.length>0&&this._sharedInstancesBag.eventEmitter.emit(b.COMMON_UPLOAD_FAILED,()=>e.getOutputCollectionState(),{debounce:true});}cleanupValidationForEntry(e){let t=this._entryValidationState.get(e.uid);t&&(t.abortController?.abort(),this._entryValidationState.delete(e.uid));}async _runFileValidatorsForEntry(e,t){if(this._isDestroyed)return;let i=this._sharedInstancesBag.api,s=this._getEntryValidationState(e),n=s.promise??Promise.resolve(),a=(async()=>{if(this._isDestroyed||(await n,this._isDestroyed))return;let l=this._getValidatorDescriptorsForEntry(e,t);if(l.length===0||!this._uploadCollection.hasItem(e.uid))return;e.setMultipleValues({isQueuedForValidation:true,isValidationPending:true});let c=i.getOutputItem(e.uid),u=new AbortController;s.abortController=u;let p=this._cfg.validationTimeout,m=this._getValidatorDescriptors(),h=new Set(l.map(w=>w.validator)),f=[];for(let w of m)if(!h.has(w.validator)){let L=s.lastErrorThrownByValidator.get(w.validator);L&&f.push(L);}let P=l.map(w=>async()=>{if(this._isDestroyed)return;let L=setTimeout(()=>{s.skippedValidators.add(w.validator),u.abort(),console.warn(Xe.FILE_VALIDATION_TIMEOUT);},p);try{let G=await w.validator(c,i,{signal:u.signal});if(!G||u.signal.aborted){s.lastErrorThrownByValidator.set(w.validator,void 0);return}let Zt=this._addCustomTypeToValidationError(G);s.lastErrorThrownByValidator.set(w.validator,Zt),f.push(Zt),G.message||console.warn(Xe.MISSING_ERROR_MESSAGE);}catch(G){u.signal.aborted||(s.skippedValidators.add(w.validator),console.warn(Xe.FILE_VALIDATION_FAILED,G),this._sharedInstancesBag.telemetryManager.sendEventError(G,`file validator. ${Xe.FILE_VALIDATION_FAILED}`));}finally{clearTimeout(L),w.runOn!=="change"&&s.skippedValidators.add(w.validator);}});if(this._runQueueDebounced(),await this._queue.add(async()=>{this._isDestroyed||(e.setValue("isQueuedForValidation",false),await Promise.all(P.map(w=>w())).catch(()=>{}));},{autoRun:false}),u.signal.aborted){e.setMultipleValues({isQueuedForValidation:false,isValidationPending:false});return}e.setMultipleValues({isValidationPending:false,isQueuedForValidation:false,errors:f});})();s.promise=a;try{await a;}finally{s.promise===a&&(s.promise=void 0);}}_addCustomTypeToValidationError(e){return {...e,type:e.type??"CUSTOM_ERROR"}}_getEntryValidationState(e){let t=this._entryValidationState.get(e.uid);if(t)return t;let i={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(e.uid,i),i}_getValidatorDescriptors(){let e=this._cfg.fileValidators;return [...this._commonFileValidators,...e].map(Oa)}_getValidatorDescriptorsForEntry(e,t){let i=this._getEntryValidationState(e);return this._getValidatorDescriptors().filter(s=>!i.skippedValidators.has(s.validator)).filter(s=>s.runOn===t)}destroy(){this._isDestroyed=true,this._runQueueDebounced.cancel();for(let e of this._entryValidationState.values())e.abortController?.abort(),e.promise=void 0;this._entryValidationState.clear();}};var jo="[Typed State] Wrong property name: ",Ci=class{constructor(r){this._ctxId=W.generateFastUid(),this._data=R.registerCtx(r,this._ctxId);}get uid(){return this._ctxId}setValue(r,e){if(!this._data.has(r)){console.warn(`${jo}${String(r)}`);return}this._data.read(r)!==e&&this._data.pub(r,e);}setMultipleValues(r){for(let[e,t]of Object.entries(r))this.setValue(e,t);}getValue(r){return this._data.has(r)||console.warn(`${jo}${String(r)}`),this._data.read(r)}subscribe(r,e){return this._data.sub(r,e)}destroy(){R.deleteCtx(this._ctxId);}};var wi=class o{constructor(r){this._subsMap=Object.create(null);this._propertyObservers=new Set;this._collectionObservers=new Set;this._items=new Set;this._removed=new Set;this._added=new Set;this._markedToDestroy=new Set;this._initialValue=r.initialValue,this._ctxId=W.generateFastUid(),this._data=R.registerCtx({},this._ctxId),this._watchList=r.watchList||[];let e=Object.create(null);this._notifyObservers=(t,i)=>{this._observeTimeout&&window.clearTimeout(this._observeTimeout),e[t]||(e[t]=new Set),e[t].add(i),this._observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this._propertyObservers.forEach(s=>{s({...e});}),e=Object.create(null));}),this._scheduleDestroyMarkedItems();},r.handler&&this.observeCollection(r.handler);}static{this._destroyDelayMs=1e4;}_notify(){this._notifyTimeout&&window.clearTimeout(this._notifyTimeout),this._notifyTimeout=window.setTimeout(()=>{let r=new Set(this._added),e=new Set(this._removed);this._added.clear(),this._removed.clear();for(let t of this._collectionObservers)t?.([...this._items],r,e);this._scheduleDestroyMarkedItems();});}_scheduleDestroyMarkedItems(){this._markedToDestroy.size!==0&&(this._destroyTimeout&&window.clearTimeout(this._destroyTimeout),this._destroyTimeout=window.setTimeout(()=>{let r=[...this._markedToDestroy];this._markedToDestroy.clear();for(let e of r)e.destroy();},o._destroyDelayMs));}observeCollection(r){return this._collectionObservers.add(r),this._items.size>0&&this._notify(),()=>{this.unobserveCollection(r);}}unobserveCollection(r){this._collectionObservers.delete(r);}add(r){let e=new Ci(this._initialValue);for(let[t,i]of Object.entries(r))e.setValue(t,i);return this._items.add(e.uid),this._notify(),this._data.add(e.uid,e),this._added.add(e),this._watchList.forEach(t=>{this._subsMap[e.uid]||(this._subsMap[e.uid]=[]),this._subsMap[e.uid]?.push(e.subscribe(t,()=>{this._notifyObservers(t,e.uid);}));}),e.uid}hasItem(r){return this._items.has(r)}read(r){return this._data.read(r)??null}readProp(r,e){let t=this.read(r);if(!t)throw new Error(`TypedCollection#readProp: Item with id ${r} not found`);return t.getValue(e)}publishProp(r,e,t){let i=this.read(r);if(!i)throw new Error(`TypedCollection#publishProp: Item with id ${r} not found`);i.setValue(e,t);}remove(r){let e=this.read(r);e&&(this._removed.add(e),this._markedToDestroy.add(e)),this._items.delete(r),this._notify(),this._data.pub(r,void 0),this._subsMap[r]?.forEach(t=>{t();}),delete this._subsMap[r];}abort(r){this.read(r)?.getValue("isUploading")&&this.remove(r);}abortAll(){this._items.forEach(r=>{this.abort(r);});}clearAll(){this._items.forEach(r=>{this.remove(r);});}observeProperties(r){return this._propertyObservers.add(r),()=>{this.unobserveProperties(r);}}unobserveProperties(r){this._propertyObservers.delete(r);}findItems(r){let e=[];return this._items.forEach(t=>{let i=this.read(t);i&&r(i)&&e.push(t);}),e}items(){return [...this._items]}get size(){return this._items.size}destroy(){this._observeTimeout&&window.clearTimeout(this._observeTimeout),this._notifyTimeout&&window.clearTimeout(this._notifyTimeout),this._destroyTimeout&&window.clearTimeout(this._destroyTimeout);for(let r of this._markedToDestroy)r.destroy();this._markedToDestroy.clear(),R.deleteCtx(this._ctxId),this._propertyObservers=new Set,this._collectionObservers=new Set;for(let r of Object.keys(this._subsMap))this._subsMap[r]?.forEach(e=>{e();}),delete this._subsMap[r];}};var C=Object.freeze({PHOTO:"photo",VIDEO:"video"}),ae=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Go=o=>({isVideoRecordingEnabled:V(o.cameraModes).includes(C.VIDEO),isPhotoEnabled:V(o.cameraModes).includes(C.PHOTO)});var Wo=(o,r)=>{for(let e of o)if(r(e))return e};var wr=(o,r,{timeout:e=1e3,onTimeout:t}={})=>new Promise(i=>{let s,n=setTimeout(()=>{cancelAnimationFrame(s),t?.();},e),a=()=>{for(let l of o)if(r(l)){clearTimeout(n),i(l);return}s=requestAnimationFrame(a);};a();});function Ti(o,r){for(let e in r)e.includes("-")?o.style.setProperty(e,String(r[e])):o.style[e]=String(r[e]);}var La=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,Ra=new RegExp(`^/?(${La.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),qo=({url:o,cdnBase:r})=>{let e=new URL(r),t=new URL(_t),i=new URL(o);if(e.host!==i.host&&t.host!==i.host)return null;let s=Ra.exec(i.pathname);if(!s)return null;let[,n,a,l]=s;return n?{uuid:n,cdnUrlModifiers:a||"",filename:l||null}:null};var Q=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",DROPBOX_CHOOSER:"dropboxchooser",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Ua=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),T=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",...Ua,...Q}),Va={[Q.DROPBOX_CHOOSER]:Q.DROPBOX},Zo=o=>Va[o]??o;var Ei=o=>o.uploadCollection.items().map(t=>o.api.getOutputItem(t));function Yo(o){let r=new Map;return (...t)=>{let i=JSON.stringify(t);if(r.has(i))return r.get(i);let s=o(...t);return r.set(i,s),s}}var Xo=new Set;function xi(o){Xo.has(o)||(Xo.add(o),console.warn(o));}function $a(o){let r=false;return setTimeout(()=>{r=true;},0),t=>((...i)=>(r&&xi(o),t(...i)))}function Qo(o){let r={},e=o.ctx,t={progress:()=>e.read("*commonProgress"),errors:()=>e.read("*collectionErrors"),group:()=>e.read("*groupInfo"),totalCount:()=>o.uploadCollection.size,failedCount:()=>r.failedEntries.length,successCount:()=>r.successEntries.length,uploadingCount:()=>r.uploadingEntries.length,status:()=>r.isFailed?"failed":r.isUploading?"uploading":r.isSuccess?"success":"idle",isSuccess:()=>r.allEntries.length>0&&r.errors.length===0&&r.successEntries.length===r.allEntries.length,isUploading:()=>r.allEntries.some(s=>s.status==="uploading"),isFailed:()=>r.errors.length>0||r.failedEntries.length>0,allEntries:()=>Ei(o),successEntries:()=>r.allEntries.filter(s=>s.status==="success"),failedEntries:()=>r.allEntries.filter(s=>s.status==="failed"),uploadingEntries:()=>r.allEntries.filter(s=>s.status==="uploading"),idleEntries:()=>r.allEntries.filter(s=>s.status==="idle")},i=$a("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[s,n]of Object.entries(t)){let a=s,c=Yo(i(n));Object.defineProperty(r,a,{get:c,enumerable:true});}return r}var Si=class extends U{constructor(){super(...arguments);this._l10n=vi(()=>this._ctx);this.addFileFromUrl=(e,{silent:t,fileName:i,source:s}={})=>{let n=this._uploadCollection.add({externalUrl:e,fileName:i??null,silent:t??false,source:s??T.API});return this.getOutputItem(n)};this.addFileFromUuid=(e,{silent:t,fileName:i,source:s}={})=>{let n=this._uploadCollection.add({uuid:e,fileName:i??null,silent:t??false,source:s??T.API});return this.getOutputItem(n)};this.addFileFromCdnUrl=(e,{silent:t,fileName:i,source:s}={})=>{let n=qo({url:e,cdnBase:this.cfg.cdnCname});if(!n)throw new Error("Invalid CDN URL");let a=this._uploadCollection.add({uuid:n.uuid,cdnUrl:e,cdnUrlModifiers:n.cdnUrlModifiers,fileName:i??n.filename??null,silent:t??false,source:s??T.API});return this.getOutputItem(a)};this.addFileFromObject=(e,{silent:t,fileName:i,source:s,fullPath:n}={})=>{let a=this._uploadCollection.add({file:e,isImage:Ze(e),mimeType:e.type||null,fileName:i??e.name,fileSize:e.size,silent:t??false,source:s??T.API,fullPath:n??null});return this.getOutputItem(a)};this.removeFileByInternalId=e=>{if(!this._uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this._uploadCollection.remove(e);};this.uploadAll=()=>{let e=this._uploadCollection.items().filter(t=>{let i=this._uploadCollection.read(t);return i?!i.getValue("isRemoved")&&!i.getValue("isUploading")&&!i.getValue("fileInfo")&&i.getValue("errors").length===0&&!i.getValue("isValidationPending")&&!i.getValue("isQueuedForValidation"):false});e.length!==0&&(this._ctx.pub("*uploadTrigger",new Set(e)),this._sharedInstancesBag.eventEmitter.emit(b.COMMON_UPLOAD_START,this.getOutputCollectionState()));};this.openSystemDialog=(e={})=>{let t=_e(ci([this.cfg.accept??"",...this.cfg.imgOnly?wt:[]])),i="uploadcare-file-input",s=document.createElement("input");if(s.setAttribute(i,""),Ti(s,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),s.type="file",s.multiple=this.cfg.multiple,e.captureCamera){s.capture=this.cfg.cameraCapture;let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=Go(this.cfg);e.modeCamera===C.PHOTO&&n?s.accept=Ct:e.modeCamera===C.VIDEO&&a?s.accept=mr:s.accept=[Ct,a&&mr].filter(Boolean).join(",");}else s.accept=t;s.addEventListener("change",()=>{s.files&&([...s.files].forEach(n=>{this.addFileFromObject(n,{source:e.captureCamera?T.CAMERA:T.LOCAL});}),this._sharedInstancesBag.routerLayer.navigateAfterFileAdd(),s.remove());},{once:true}),document.querySelectorAll(`[${i}]`).forEach(n=>{n.remove();}),document.body.appendChild(s),s.dispatchEvent(new MouseEvent("click"));};this.initFlow=(e=false)=>{if(this._uploadCollection.size>0&&!e)this._ctx.pub("*currentActivity",A.UPLOAD_LIST),this._sharedInstancesBag.modalManager?.open(A.UPLOAD_LIST);else if(this._sourceList?.length===1){let t=this._sourceList[0];this._pluginsReady().then(()=>{let i=this._sharedInstancesBag.pluginManager.snapshot().sources,s=i.find(n=>n.id===t);if(s){let n=s.expand?.()??[t];n.length===1?(i.find(l=>l.id===n[0])??s).onSelect():(this._ctx.pub("*currentActivity",A.START_FROM),this._sharedInstancesBag.modalManager?.open(A.START_FROM));return}this._ctx.read("*currentActivity")&&this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity"));});}else this._ctx.pub("*currentActivity",A.START_FROM),this._sharedInstancesBag.modalManager?.open(A.START_FROM);};this.doneFlow=()=>{let e=Wo(this._sharedInstancesBag.blocksRegistry,t=>"doneActivity"in t);e&&(this._ctx.pub("*currentActivity",e.doneActivity),this._ctx.pub("*history",e.doneActivity?[e.doneActivity]:[]),this._ctx.read("*currentActivity")||this._sharedInstancesBag.modalManager?.closeAll());};this.setCurrentActivity=(e,...t)=>{this._pluginsReady().then(()=>{this._ctx.pub("*currentActivityParams",t[0]??{}),this._ctx.pub("*currentActivity",e),wr(this._sharedInstancesBag.blocksRegistry,i=>i.activityType===e,{onTimeout:()=>console.warn(`Activity type "${e}" not found in the context`),timeout:100});});};this.on=(e,t)=>this._sharedInstancesBag.eventEmitter.on(e,t);this.getCurrentActivity=()=>this._ctx.read("*currentActivity");this.historyBack=()=>{this._ctx.read("*historyBack")?.();};this.setModalState=e=>{this._pluginsReady().then(()=>{if(!e){this._sharedInstancesBag.modalManager?.close(this._ctx.read("*currentActivity")),this._ctx.pub("*currentActivity",null);return}let t=this._ctx.read("*currentActivity");if(!t){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}return wr(this._sharedInstancesBag.blocksRegistry,i=>i.activityType===t,{onTimeout:()=>console.warn(`Activity block "${t}" not found in the context`)}).then(()=>{this._sharedInstancesBag.modalManager?.open(t);})});};}get _uploadCollection(){return this._sharedInstancesBag.uploadCollection}get cfg(){return this._cfg}get l10n(){return this._l10n}removeAllFiles(){this._uploadCollection.clearAll();}getOutputItem(e){let t=R.getCtx(e);if(!t)throw new Error(`UploaderPublicApi#getOutputItem: Entry with ID "${e}" not found in the upload collection`);let i=t.store,s=i.fileInfo,n=i.isRemoved?"removed":i.errors.length>0?"failed":i.fileInfo?"success":i.isUploading?"uploading":"idle";return {uuid:s?.uuid??i.uuid??null,internalId:e,name:s?.originalFilename??i.fileName,size:s?.size??i.fileSize,isImage:s?.isImage??i.isImage,mimeType:s?.mimeType??i.mimeType,file:i.file,externalUrl:i.externalUrl,cdnUrlModifiers:i.cdnUrlModifiers,cdnUrl:i.cdnUrl??s?.cdnUrl??null,fullPath:i.fullPath,uploadProgress:i.uploadProgress,fileInfo:s??null,metadata:i.metadata??s?.metadata??null,isSuccess:n==="success",isUploading:n==="uploading",isFailed:n==="failed",isRemoved:n==="removed",isValidationPending:i.isValidationPending,errors:i.errors,status:n,source:i?.source}}getOutputCollectionState(){return Qo(this._sharedInstancesBag)}async _pluginsReady(){return (await this._sharedInstancesBag.wait("pluginManager")).pluginsReady()}get _sourceList(){let e=[];return this.cfg.sourceList&&(e=N(this.cfg.sourceList)),e}};var Jo={file:null,externalUrl:null,fileName:null,fileSize:null,lastModified:Date.now(),uploadProgress:0,uuid:null,isImage:false,mimeType:null,ctxName:null,cdnUrl:null,cdnUrlModifiers:null,fileInfo:null,isUploading:false,abortController:null,thumbUrl:null,silent:false,source:null,fullPath:null,metadata:null,errors:[],uploadError:null,isRemoved:false,isQueuedForUploading:false,isValidationPending:false,isQueuedForValidation:false};var xt=33.333333333333336,y=1,Tr=24,es=6;function Me(o,r){for(let[e,t]of Object.entries(r))o.setAttributeNS(null,e,t.toString());}function re(o,r={}){let e=document.createElementNS("http://www.w3.org/2000/svg",o);return Me(e,r),e}function ts(o,r,e){let{x:t,y:i,width:s,height:n}=o,a=r.includes("w")?0:1,l=r.includes("n")?0:1,c=a===0?-1:1,u=l===0?-1:1,p=[t+a*s+1.5*c,i+l*n+1.5*u-24*e*u],m=[t+a*s+1.5*c,i+l*n+1.5*u],h=[t+a*s-24*e*c+1.5*c,i+l*n+1.5*u],f=`M ${p[0]} ${p[1]} L ${m[0]} ${m[1]} L ${h[0]} ${h[1]}`,P=[m[0],m[1]];return {d:f,center:P}}function is(o,r,e){let{x:t,y:i,width:s,height:n}=o,a=r==="n"||r==="s",l=r==="w"||r==="e",c=a?.5:r==="w"?0:1,u=l?.5:r==="n"?0:1,p=r==="w"?-1:r==="e"?1:0,m=r==="n"?-1:r==="s"?1:0,h,f;a?(h=[t+c*s-34*e/2,i+u*n+1.5*m],f=[t+c*s+34*e/2,i+u*n+1.5*m]):(h=[t+c*s+1.5*p,i+u*n-34*e/2],f=[t+c*s+1.5*p,i+u*n+34*e/2]);let P=`M ${h[0]} ${h[1]} L ${f[0]} ${f[1]}`,w=[(h[0]+f[0])/2,(h[1]+f[1])/2];return {d:P,center:w}}function rs(o){return o===""?"move":["e","w"].includes(o)?"ew-resize":["n","s"].includes(o)?"ns-resize":["nw","se"].includes(o)?"nwse-resize":"nesw-resize"}function os({rect:o,delta:[r,e],imageBox:t}){return Je({...o,x:o.x+r,y:o.y+e},t)}function Je(o,r){let{x:e}=o,{y:t}=o;return o.x<r.x?e=r.x:o.x+o.width>r.x+r.width&&(e=r.x+r.width-o.width),o.y<r.y?t=r.y:o.y+o.height>r.y+r.height&&(t=r.y+r.height-o.height),{...o,x:e,y:t}}function Da({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[,i]=r,{y:s,width:n,height:a}=o;s+=i,a-=i,e&&(n=a*e);let l=o.x+o.width/2-n/2;return s<=t.y&&(s=t.y,a=o.y+o.height-s,e&&(n=a*e,l=o.x+o.width/2-n/2)),l<=t.x&&(l=t.x,s=o.y+o.height-a),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),s=o.y+o.height-a),a<y&&(a=y,e&&(n=a*e,l=o.x+o.width/2-n/2),s=o.y+o.height-a),n<y&&(n=y,e&&(a=n/e,l=o.x+o.width/2-n/2),s=o.y+o.height-a),{x:l,y:s,width:n,height:a}}function Fa({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i]=r,{x:s,width:n,height:a}=o;s+=i,n-=i,e&&(a=n/e);let l=o.y+o.height/2-a/2;return s<=t.x&&(s=t.x,n=o.x+o.width-s,e&&(a=n/e,l=o.y+o.height/2-a/2)),l<=t.y&&(l=t.y,s=o.x+o.width-n),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),s=o.x+o.width-n),a<y&&(a=y,e&&(n=a*e),l=o.y+o.height/2-a/2,s=o.x+o.width-n),n<y&&(n=y,e&&(a=n/e),l=o.y+o.height/2-a/2,s=o.x+o.width-n),{x:s,y:l,width:n,height:a}}function Na({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[,i]=r,{y:s,width:n,height:a}=o;a+=i,e&&(n=a*e);let l=o.x+o.width/2-n/2;return s+a>=t.y+t.height&&(a=t.y+t.height-s,e&&(n=a*e),l=o.x+o.width/2-n/2),l<=t.x&&(l=t.x,s=o.y),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),s=o.y),a<y&&(a=y,e&&(n=a*e),l=o.x+o.width/2-n/2),n<y&&(n=y,e&&(a=n/e),l=o.x+o.width/2-n/2),{x:l,y:s,width:n,height:a}}function Ba({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i]=r,{x:s,width:n,height:a}=o;n+=i,e&&(a=n/e);let l=o.y+o.height/2-a/2;return s+n>=t.x+t.width&&(n=t.x+t.width-s,e&&(a=n/e),l=o.y+o.height/2-a/2),l<=t.y&&(l=t.y,s=o.x),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),s=o.x),a<y&&(a=y,e&&(n=a*e),l=o.y+o.height/2-a/2),n<y&&(n=y,e&&(a=n/e),l=o.y+o.height/2-a/2),{x:s,y:l,width:n,height:a}}function Ha({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+i<t.x&&(i=t.x-n),a+s<t.y&&(s=t.y-a),n+=i,l-=i,a+=s,c-=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a-=s,a<=t.y&&(c=c-(t.y-a),l=c*e,n=o.x+o.width-l,a=t.y)):e&&(i=c*e-l,l=l+i,n-=i,n<=t.x&&(l=l-(t.x-n),c=l/e,n=t.x,a=o.y+o.height-c)),c<y&&(c=y,e&&(l=c*e),n=o.x+o.width-l,a=o.y+o.height-c),l<y&&(l=y,e&&(c=l/e),n=o.x+o.width-l,a=o.y+o.height-c),{x:n,y:a,width:l,height:c}}function za({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+l+i>t.x+t.width&&(i=t.x+t.width-n-l),a+s<t.y&&(s=t.y-a),l+=i,a+=s,c-=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a-=s,a<=t.y&&(c=c-(t.y-a),l=c*e,n=o.x,a=t.y)):e&&(i=c*e-l,l+=i,n+l>=t.x+t.width&&(l=t.x+t.width-n,c=l/e,n=t.x+t.width-l,a=o.y+o.height-c)),c<y&&(c=y,e&&(l=c*e),a=o.y+o.height-c),l<y&&(l=y,e&&(c=l/e),a=o.y+o.height-c),{x:n,y:a,width:l,height:c}}function Ka({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+i<t.x&&(i=t.x-n),a+c+s>t.y+t.height&&(s=t.y+t.height-a-c),n+=i,l-=i,c+=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a+c>=t.y+t.height&&(c=t.y+t.height-a,l=c*e,n=o.x+o.width-l,a=t.y+t.height-c)):e&&(i=c*e-l,l+=i,n-=i,n<=t.x&&(l=l-(t.x-n),c=l/e,n=t.x,a=o.y)),c<y&&(c=y,e&&(l=c*e),n=o.x+o.width-l),l<y&&(l=y,e&&(c=l/e),n=o.x+o.width-l),{x:n,y:a,width:l,height:c}}function ja({rect:o,delta:r,aspectRatio:e,imageBox:t}){let[i,s]=r,{x:n,y:a,width:l,height:c}=o;return n+l+i>t.x+t.width&&(i=t.x+t.width-n-l),a+c+s>t.y+t.height&&(s=t.y+t.height-a-c),l+=i,c+=s,e&&Math.abs(l/c)>e?(s=l/e-c,c+=s,a+c>=t.y+t.height&&(c=t.y+t.height-a,l=c*e,n=o.x,a=t.y+t.height-c)):e&&(i=c*e-l,l+=i,n+l>=t.x+t.width&&(l=t.x+t.width-n,c=l/e,n=t.x+t.width-l,a=o.y)),c<y&&(c=y,e&&(l=c*e)),l<y&&(l=y,e&&(c=l/e)),{x:n,y:a,width:l,height:c}}function ss({direction:o,...r}){switch(o){case "n":return Da(r);case "w":return Fa(r);case "s":return Na(r);case "e":return Ba(r);case "nw":return Ha(r);case "ne":return za(r);case "sw":return Ka(r);case "se":return ja(r);default:return r.rect}}function ns(o,[r,e]){return o.x<=r&&r<=o.x+o.width&&o.y<=e&&e<=o.y+o.height}function as(o,r){return o.x>=r.x&&o.y>=r.y&&o.x+o.width<=r.x+r.width&&o.y+o.height<=r.y+r.height}function ls(o,r){return Math.abs(o.width/o.height-r)<.1}function et({width:o,height:r},e){let t=e/90%2!==0;return {width:t?r:o,height:t?o:r}}function cs(o,r,e){let t=o/r,i,s;t>e?(i=Math.round(r*e),s=r):(i=o,s=Math.round(o/e));let n=Math.round((o-i)/2),a=Math.round((r-s)/2);return n+i>o&&(i=o-n),a+s>r&&(s=r-a),{x:n,y:a,width:i,height:s}}function tt(o){return {x:Math.round(o.x),y:Math.round(o.y),width:Math.round(o.width),height:Math.round(o.height)}}function Pe(o,r,e){return Math.min(Math.max(o,r),e)}var St=["free"],Ai=o=>{let r=N(o);if(!r||r.length===0)return [];let e=[];for(let t of r){let i=t.trim();if(!i)continue;let s=i.indexOf(":");if(s===-1&&!St.includes(i)){console.warn(`Invalid crop preset: ${i}`);continue}let n=Number(i.slice(0,s)),a=Number(i.slice(s+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!St.includes(i)){console.warn(`Invalid crop preset: ${i}`);continue}e.push({id:W.generateFastUid(),type:"aspect-ratio",width:St.includes(i)?0:n,height:St.includes(i)?0:a,hasFreeform:St.includes(i)});}return e},ds=(o,r,e,t=.1)=>{let i=o/r,s=null,n=1/0;for(let a of e){let[l,c]=[a.width,a.height],u=l/c,p=Math.abs(i-u);p<n&&(n=p,s=a);}if(s){let[a,l]=[s.width,s.height],c=a/l;if(Math.abs(i-c)/c>t)return null}return s};function us(o){return getUserAgent({...o,libraryName:pe,libraryVersion:he})}var ps="active",it="___ACTIVITY_IS_ACTIVE___",hs,E=class o extends(hs=g,hs){constructor(){super(...arguments);this.historyTracked=false;this.activityType=null;this.init$=ur(this);this._debouncedHistoryFlush=S(this._historyFlush.bind(this),10);}_deactivate(){let e=o._activityCallbacks.get(this);this[it]=false,this.removeAttribute(ps),e?.deactivateCallback?.();}_activate(){let e=o._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[it]=true,this.setAttribute(ps,""),e?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(b.ACTIVITY_CHANGE,{activity:this.activityType});}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{try{this.activityType!==e&&this[it]?this._deactivate():this.activityType===e&&!this[it]&&this._activate();}catch(t){this.telemetryManager.sendEventError(t,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,t);let i=this.$["*history"][this.$["*history"].length-1];this.$["*currentActivity"]=i??null;}e||(this.$["*history"]=[]);}));}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e);}_isActivityRegistered(){return !!this.activityType&&o._activityCallbacks.has(this)}static{this._activityCallbacks=new Map;}get isActivityActive(){return !!this[it]}get couldOpenActivity(){return true}registerActivity(e,t={}){let{onActivate:i,onDeactivate:s}=t;o._activityCallbacks.set(this,{activateCallback:i,deactivateCallback:s});}_unregisterActivity(){this.isActivityActive&&this._deactivate(),o._activityCallbacks.delete(this);}disconnectedCallback(){super.disconnectedCallback(),this._isActivityRegistered()&&this._unregisterActivity();}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")??null}get doneActivity(){return this.getCssData("--cfg-done-activity")??null}historyBack(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let i=!!t;t&&(i=[...this.blocksRegistry].find(n=>n.activityType===t)?.couldOpenActivity??false),t=i?t:null,this.$["*currentActivity"]=t??null,t&&this.modalManager?.open(t),this.$["*history"]=e,t||this.modalManager?.closeAll();}}};E.activities=A;var _=class o extends E{constructor(){super(...arguments);this.couldBeCtxOwner=false;this._isCtxOwner=false;this.init$=pr(this);this._flushOutputItems=S(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(b.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t);},300);this._handleCollectionUpdate=(e,t,i)=>{if(this.isConnected){(t.size||i.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...t].map(s=>s.uid));for(let s of t)s.getValue("silent")||this.emit(b.FILE_ADDED,this.api.getOutputItem(s.uid)),this._sharedInstancesBag.wait("pluginManager").then(n=>n.runOnAddHooks(s));this.validationManager.runCollectionValidators();for(let s of i){this.$["*uploadTrigger"].delete(s.uid),this.validationManager.cleanupValidationForEntry(s),s.getValue("abortController")?.abort(),s.setMultipleValues({isRemoved:true,abortController:null,isUploading:false,uploadProgress:0});let n=s?.getValue("thumbUrl");n&&URL.revokeObjectURL(n),this.emit(b.FILE_REMOVED,this.api.getOutputItem(s.uid));}this.$["*uploadList"]=e.map(s=>({uid:s})),this._flushCommonUploadProgress(),this._flushOutputItems();}};this._handleCollectionPropertiesUpdate=e=>{if(!this.isConnected)return;this._flushOutputItems();let t=this.uploadCollection,i=[...new Set(Object.entries(e).filter(([s])=>["file","uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(s)).flatMap(([,s])=>[...s]))];if(i.length>0&&setTimeout(()=>{if(!this.isConnected)return;let s=i.filter(n=>e.fileInfo?.has(n)&&!!R.getCtx(n)?.store.fileInfo);s.length>0&&this.validationManager.runFileValidators("upload",s),this.validationManager.runFileValidators("change",i);}),e.uploadProgress){for(let s of e.uploadProgress){let n=R.getCtx(s);if(!n)continue;let{isUploading:a,silent:l}=n.store;a&&!l&&this.emit(b.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(s));}this._flushCommonUploadProgress();}if(e.isUploading)for(let s of e.isUploading){let n=R.getCtx(s);if(!n)continue;let{isUploading:a,silent:l}=n.store;a&&!l&&this.emit(b.FILE_UPLOAD_START,this.api.getOutputItem(s));}if(e.fileInfo){for(let s of e.fileInfo){let n=R.getCtx(s);if(!n)continue;let{fileInfo:a,silent:l}=n.store;a&&!l&&this.emit(b.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(s));}this.cfg.cropPreset&&this._setInitialCrop();}if(e.errors){this.validationManager.runCollectionValidators();for(let a of e.errors){let l=R.getCtx(a);if(!l)continue;let{errors:c}=l.store;c.length>0&&(this.emit(b.FILE_UPLOAD_FAILED,this.api.getOutputItem(a)),this.emit(b.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:true}));}let s=t.findItems(a=>!!a.getValue("fileInfo")),n=t.findItems(a=>a.getValue("errors").length>0);t.size>0&&n.length===0&&t.size===s.length&&this.$["*collectionErrors"].length===0&&this.emit(b.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState());}e.cdnUrl&&([...e.cdnUrl].filter(n=>!!this.uploadCollection.read(n)?.getValue("cdnUrl")).forEach(n=>{this.emit(b.FILE_URL_CHANGED,this.api.getOutputItem(n));}),this.$["*groupInfo"]=null);};this._flushCommonUploadProgress=()=>{let e=0,i=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));i.forEach(n=>{let a=this.uploadCollection.readProp(n,"uploadProgress");typeof a=="number"&&(e+=a);});let s=i.length?Math.round(e/i.length):0;this.$["*commonProgress"]!==s&&(this.$["*commonProgress"]=s,this.emit(b.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()));};}get _hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof o?e._isCtxOwner&&e.isConnected&&e!==this:false)}initCallback(){super.initCallback(),this._addSharedContextInstance("*uploadCollection",()=>new wi({initialValue:Jo,watchList:["file","uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]})),this._addSharedContextInstance("*secureUploadsManager",e=>new yi(e)),this._addSharedContextInstance("*validationManager",e=>new _i(e)),this._addSharedContextInstance("*publicApi",e=>new Si(e)),!this._hasCtxOwner&&this.couldBeCtxOwner&&this._initCtxOwner();}getAPI(){return this.api}get validationManager(){return this._getSharedContextInstance("*validationManager")}get api(){return this._getSharedContextInstance("*publicApi")}get uploadCollection(){return this._getSharedContextInstance("*uploadCollection")}get secureUploadsManager(){return this._getSharedContextInstance("*secureUploadsManager")}disconnectedCallback(){super.disconnectedCallback(),this._isCtxOwner&&this._unobserveUploadCollection(),this._flushOutputItems.cancel();}connectedCallback(){super.connectedCallback(),this._isCtxOwner&&this._observeUploadCollection();}_initCtxOwner(){this._isCtxOwner=true,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1;});}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate);}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0;}async _createGroup(e){let t=await this.getUploadClientOptions(),i=e.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),s=new AbortController,n=await uploadFileGroup(i,{...t,signal:s.signal});if(this.$["*collectionState"]!==e){s.abort();return}this.$["*groupInfo"]=n;let a=this.api.getOutputCollectionState();this.emit(b.GROUP_CREATED,a),this.emit(b.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.$["*collectionState"]=a;}_setInitialCrop(){let e=Ai(this.cfg.cropPreset);if(!e)return;let[t]=e,i=this.uploadCollection.findItems(s=>!!s.getValue("fileInfo")&&s.getValue("isImage")&&!s.getValue("cdnUrlModifiers")?.includes("/crop/")).map(s=>this.uploadCollection.read(s)).filter(Boolean);for(let s of i){let n=s.getValue("fileInfo");if(!n||!n.imageInfo){console.warn("Failed to get image info for entry",s.uid);continue}let{width:a,height:l}=n.imageInfo,c=typeof t?.width=="number"&&typeof t?.height=="number"&&t.width>0&&t.height>0?t.width/t.height:1,u=cs(a,l,c),p=q(`crop/${u.width}x${u.height}/${u.x},${u.y}`,"preview"),m=s.getValue("cdnUrl");if(!m){console.warn("Failed to get cdnUrl for entry",s.uid);continue}s.setMultipleValues({cdnUrlModifiers:p,cdnUrl:F(m,p)});}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let i=this.api.getOutputItem(e);return await t(i)}return t}async getUploadClientOptions(){let e=await this.secureUploadsManager.getSecureToken().catch(()=>null);return {store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:us,integration:this.cfg.userAgentIntegration,secureSignature:e?.secureSignature,secureExpire:e?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return Ei(this._sharedInstancesBag)}};_.extSrcList=Object.freeze({...Q});_.sourceTypes=Object.freeze({...T});var Oe=class extends g{constructor(){super(...arguments);this.name="";this._resolvedHref="";this._pluginSvg=null;this._iconHrefResolver=null;}initCallback(){super.initCallback(),this.setAttribute("aria-hidden","true"),this.subConfigValue("iconHrefResolver",t=>{this._iconHrefResolver=t,this._updateResolvedHref();});let e=this._sharedInstancesBag.pluginManager;e?.onPluginsChange&&(this._unsubscribePlugins=e.onPluginsChange(()=>this._updateResolvedHref()));}willUpdate(e){super.willUpdate(e),e.has("name")&&this._updateResolvedHref();}_updateResolvedHref(){if(!this.name){this._resolvedHref="",this._pluginSvg=null;return}let t=this._sharedInstancesBag.pluginManager?.snapshot().icons.find(n=>n.name===this.name);if(t){this._pluginSvg=t.svg,this._resolvedHref="";return}this._pluginSvg=null;let i=`#uc-icon-${this.name}`,s=this._iconHrefResolver?.(this.name);this._resolvedHref=s??i;}render(){return this._pluginSvg?html`${this.yield("",html`${unsafeSVG(this._pluginSvg)}`)}`:html` ${this.yield("",html`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use href=${this._resolvedHref}></use></svg>`)} `}disconnectedCallback(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,super.disconnectedCallback();}};d([property({type:String})],Oe.prototype,"name",2),d([state()],Oe.prototype,"_resolvedHref",2),d([state()],Oe.prototype,"_pluginSvg",2);var fs=o=>[...new Set(o)];var Be="--uc-img-",Er="unresolved";var xr=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),Sr=3e3,Ir=5e3,Ar=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var Ya="https://ucarecdn.com",rt=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Ya},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Mi=class extends We(qe(LitElement)){constructor(){super();this._state={};this._subscribers=new Map;this._isnObserver=null;this._observed=null;for(let e in rt){let t=rt[e];this._state[Be+e]=t?.default||"";}}createRenderRoot(){return this}$$(e){return this._state[Be+e]}set$$(e){for(let t in e){let i=Be+t,s=e[t];this._state[i]=s,this._notify(i,s);}}sub$$(e,t){let i=Be+e;this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(t);let s=this._state[i];s!==null&&s!==""&&t(s);}_notify(e,t){this._subscribers.has(e)&&this._subscribers.get(e)?.forEach(i=>{t===null||t===""||i(t);});}analyticsParams(){return `-/@clib/${pe}/${he}/uc-img/`}initAttributes(e){Array.from(this.attributes).forEach(t=>{let i=t;rt[i.name]||e.setAttribute(i.name,i.value);});}initIntersection(e,t){let i={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(s=>{s.forEach(n=>{n.isIntersecting&&(t(),this._isnObserver?.unobserve(e));});},i),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e);}connectedCallback(){super.connectedCallback(),this._initCssProperties();}_initCssProperties(){for(let e in rt){let t=Be+e,i=this.getCssData(t,true);i!=null&&(this._state[t]=i);}}disconnectedCallback(){super.disconnectedCallback(),this._isnObserver&&(this._observed?.forEach(e=>{this._isnObserver?.unobserve(e);}),this._isnObserver=null),this._subscribers.clear();}static get observedAttributes(){return Object.keys(rt)}attributeChangedCallback(e,t,i){window.setTimeout(()=>{let s=Be+e;this._state[s]=i,this._notify(s,i);});}};var gs=o=>Object.entries(o).filter(([r,e])=>e!==void 0&&e!=="").map(([r,e])=>r==="cdn-operations"||r==="analytics"?e:`${r}/${e}`);var Li=class extends Mi{constructor(){super(...arguments);this._img=new Image;this._imgPreview=new Image;}_fmtAbs(e){return !e.includes("//")&&!xr&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if(!e)return;let t=e,i=t.match(/\d+/)?.[0],s=t.match(/[a-zA-Z]+/)?.[0];if(!i||!s)return;let n=parseInt(i,10);return Number(n)>Ir&&this._hasFormatJPG?Ir+s:Number(n)>Sr&&!this._hasFormatJPG?Sr+s:e}_getCdnModifiers(e,t){let i={format:this._getTypedCssValue("format"),quality:this._getTypedCssValue("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this._getTypedCssValue("cdn-operations")??void 0,analytics:this.analyticsParams()};return q(...gs(i))}_getTypedCssValue(e){let t=this.$$(e);if(t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t}_getUrlBase(e="",t=""){let i=this.$$("src");if(i.startsWith("data:")||i.startsWith("blob:"))return i;if(xr&&i&&!i.includes("//"))return this._proxyUrl(i);let s=this._getCdnModifiers(e,t),n=this.$$("cdn-cname"),a=n;if(i.startsWith(String(n)))return F(i,s);let l=this.$$("uuid");if(a&&l)return this._proxyUrl(F(Ae(a,l),s));if(l)return this._proxyUrl(F(Ae(a,l),s));let c=this.$$("proxy-cname");if(c)return this._proxyUrl(F(c,s,this._fmtAbs(i)));let u=this.$$("pubkey");if(u)return this._proxyUrl(F(`https://${u}.ucr.io/`,s,this._fmtAbs(i)))}_proxyUrl(e){let t=this.$$("secure-delivery-proxy");return t?Ye(t,{previewUrl:e},{transform:i=>window.encodeURIComponent(i)}):e}_getElSize(e,t=1,i=true){let s=e.getBoundingClientRect(),n=t*Math.round(s.width),a=i?"":t*Math.round(s.height);return n||a?`${n||""}x${a||""}`:null}_setupEventProxy(e){let t=s=>{s.stopPropagation();let n=new Event(s.type,s);this.dispatchEvent(n);},i=["load","error"];for(let s of i)e.addEventListener(s,t);}get img(){return this._hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get _currentImg(){return this._hasPreviewImage?{type:Ar.PREVIEW,img:this._imgPreview}:{type:Ar.MAIN,img:this.img}}get _hasPreviewImage(){return this.$$("is-preview-blur")}get _bgSelector(){return this.$$("is-background-for")}get _breakpoints(){let e=this.$$("breakpoints");if(e){let t=N(e);return fs(t.map(i=>parseInt(i,10)))}else return null}get _hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}_renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let i=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",i),e.style.setProperty("background-image",`-webkit-${i}`);}_getSrcset(){let e=new Set;return this._breakpoints?this._breakpoints.forEach(t=>{e.add(`${this._getUrlBase(`${t}x`)} ${this._validateSize(`${t}w`)}`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(`${t*2}x`)} ${this._validateSize(`${t*2}w`)}`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(`${t*3}x`)} ${this._validateSize(`${t*3}w`)}`);}):(e.add(`${this._getUrlBase(this._getElSize(this._currentImg.img))} 1x`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this._currentImg.img,2))} 2x`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this._currentImg.img,3))} 3x`)),[...e].join()}_getSrc(){return this._getUrlBase()}get _srcUrlPreview(){return this._getUrlBase("100x","100")}_renderBackground(){let e=this._bgSelector;[...document.querySelectorAll(e)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this._renderBg(t);}):this._renderBg(t);});}_appendURL({elNode:e,src:t,srcset:i}){t&&(e.src=t),i&&(e.srcset=i);}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e);}_loaderImage({src:e,srcset:t,elNode:i}){return new Promise((s,n)=>{this._setupConfigForImage({elNode:i}),i.setAttribute(Er,""),i.addEventListener("load",()=>{i.removeAttribute(Er),s(i);}),i.addEventListener("error",()=>{n(false);}),this._appendURL({elNode:i,src:e,srcset:t});})}async _renderImage(){if(this.$$("intersection")){this._hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this._currentImg.img,async()=>{this._hasPreviewImage&&(this._imgPreview.src=this._srcUrlPreview);try{await this._loaderImage({src:this._getSrc(),srcset:this._getSrcset(),elNode:this._img}),this._hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img);}catch{this._hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img);}});return}try{this._hasPreviewImage&&(await this._loaderImage({src:this._srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this._loaderImage({src:this._getSrc(),srcset:this._getSrcset(),elNode:this._img}),this._hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img);}catch{this._hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img);}}init(){this._bgSelector?this._renderBackground():this._renderImage();}};var kr=class extends Li{connectedCallback(){super.connectedCallback(),this.sub$$("src",()=>{this.init();}),this.sub$$("uuid",()=>{this.init();}),this.sub$$("lazy",r=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=r?"lazy":"eager");});}};var Mr=null,It=class extends g{constructor(){super(...arguments);this.dialogEl=createRef();this.strokes=false;this.blockBodyScrolling=false;this.closeDialog=()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="",this.$["*currentActivity"]=null);};this._handleDialogClose=()=>{this.closeDialog();};this._handleDialogMouseDown=e=>{this._mouseDownTarget=e.target;};this._handleDialogMouseUp=e=>{let t=e.target;t===this.dialogEl.value&&t===this._mouseDownTarget&&this.closeDialog();};this._handleModalOpen=({id:e})=>{e===this.id?(Mr=e,this.show(),this.emit(b.MODAL_OPEN,{modalId:e},{debounce:true})):this.hide();};this._handleModalClose=({id:e})=>{e===this.id&&(this.hide(),this.emit(b.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:true}));};this._handleModalCloseAll=e=>{this.hide(),Mr===this.id&&this.emit(b.MODAL_CLOSE,{modalId:Mr,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:true});};}static{this.styleAttrs=[...super.styleAttrs,"uc-modal"];}async show(){await this.updateComplete;let e=this.dialogEl.value;typeof e.showModal=="function"?(this.setAttribute("aria-modal","true"),e.showModal()):e.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden");}hide(){let e=this.dialogEl.value;e&&(typeof e.close=="function"?(this.setAttribute("aria-modal","false"),e.close()):e.removeAttribute("open"));}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this),this.subConfigValue("modalBackdropStrokes",e=>{e?this.setAttribute("strokes",""):this.removeAttribute("strokes");}),this.modalManager?.subscribe(B.OPEN,this._handleModalOpen),this.modalManager?.subscribe(B.CLOSE,this._handleModalClose),this.modalManager?.subscribe(B.CLOSE_ALL,this._handleModalCloseAll);}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0,this.modalManager?.unsubscribe(B.OPEN,this._handleModalOpen),this.modalManager?.unsubscribe(B.CLOSE,this._handleModalClose),this.modalManager?.unsubscribe(B.CLOSE_ALL,this._handleModalCloseAll);}_handleDialogRef(e){this.dialogEl={value:e},this.dialogEl.value?.addEventListener("close",this._handleDialogClose),this.dialogEl.value?.addEventListener("mousedown",this._handleDialogMouseDown),this.dialogEl.value?.addEventListener("mouseup",this._handleDialogMouseUp);}render(){return html`<dialog ${ref(this._handleDialogRef)}>${this.yield("")}</dialog>`}};d([property({type:Boolean,noAccessor:true})],It.prototype,"strokes",2),d([property({type:Boolean,attribute:"block-body-scrolling",noAccessor:true})],It.prototype,"blockBodyScrolling",2);var Ri=class extends _{constructor(){super(...arguments);this._validationInputElement=null;this._dynamicInputsContainer=null;}get _inputName(){return this.nameAttrValue??this.ctxName}_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this._inputName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,Ti(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{if(!e)return;if(!this._dynamicInputsContainer){let n=document.createElement("div");this.appendChild(n),this._dynamicInputsContainer=n;}if(!this._validationInputElement){let n=this._createValidationInput();this.appendChild(n),this._validationInputElement=n;}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let n=e.errors[0]?.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(n??"");return}let t=e.group?e.group:null;if(t){this._validationInputElement.value=t.cdnUrl??"",this._validationInputElement.setCustomValidity("");return}let i=e.allEntries.map(n=>n.cdnUrl).filter(n=>typeof n=="string");if(!this.cfg.multiple&&i.length===1&&i[0]){this._validationInputElement.value=i[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let s=new DocumentFragment;for(let n of i){let a=document.createElement("input");a.type="hidden",a.name=`${this._inputName}[]`,a.value=n,s.appendChild(a);}this._dynamicInputsContainer.replaceChildren(s);},false);}};d([property({type:String,noAccessor:true,attribute:"name"})],Ri.prototype,"nameAttrValue",2);var Pr=class extends g{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",r=>{this.toggleAttribute("hidden",!!r);});}render(){return html`<a href="https://uploadcare.com/?utm_source=copyright&amp;utm_medium=referral&amp;utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`}};var ot=class extends g{constructor(){super(...arguments);this.hasFileName=false;this.value=0;this.visible=true;this._progressValue=0;this._fakeProgressLineRef=createRef();this._handleFakeProgressAnimation=()=>{let e=this._fakeProgressLineRef.value;if(e){if(!this.visible){e.classList.add("uc-fake-progress--hidden");return}this._progressValue>0&&e.classList.add("uc-fake-progress--hidden");}};}firstUpdated(e){super.firstUpdated(e),this._progressValue=this._normalizeProgressValue(this.value),this._updateProgressValueStyle(),this._fakeProgressLineRef.value?.addEventListener("animationiteration",this._handleFakeProgressAnimation);}updated(e){if(super.updated(e),e.has("value")){let t=this._normalizeProgressValue(this.value);if(!this.visible)this._progressValue=t;else {let i=Math.max(this._progressValue,t);i!==this._progressValue&&(this._progressValue=i,this._updateProgressValueStyle());}}e.has("visible")&&(this.classList.toggle("uc-progress-bar--hidden",!this.visible),this.visible?this._updateProgressValueStyle():this._progressValue=this._normalizeProgressValue(this.value));}disconnectedCallback(){super.disconnectedCallback(),this._fakeProgressLineRef.value?.removeEventListener("animationiteration",this._handleFakeProgressAnimation);}_normalizeProgressValue(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}_updateProgressValueStyle(){this.visible&&this.style.setProperty("--l-progress-value",this._progressValue.toString());}render(){return html`<div ${ref(this._fakeProgressLineRef)} class="uc-fake-progress"></div><div class="uc-progress"></div>`}};d([property({type:Boolean,noAccessor:true})],ot.prototype,"hasFileName",2),d([property({type:Number})],ot.prototype,"value",2),d([property({type:Boolean,reflect:true})],ot.prototype,"visible",2);var At=class extends _{constructor(){super();this._visible=false;this._value=0;this.init$={...this.init$,"*commonProgress":0};}initCallback(){super.initCallback(),this._unobserveCollectionCb=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(t=>this.uploadCollection.read(t)?.getValue("isUploading")??false);this._visible=e;}),this.sub("*commonProgress",e=>{this._value=e;});}updated(e){super.updated(e),e.has("visible")&&(this._visible?this.setAttribute("active",""):this.removeAttribute("active"));}disconnectedCallback(){super.disconnectedCallback(),this._unobserveCollectionCb?.(),this._unobserveCollectionCb=void 0;}render(){return html`<uc-progress-bar .value=${this._value} .visible=${this._visible}></uc-progress-bar>`}};d([state()],At.prototype,"_visible",2),d([state()],At.prototype,"_value",2);var st=class extends g{constructor(){super(...arguments);this.value="";this.disabled=false;this.options=[];this._handleChange=e=>{if(this.disabled){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation();let t=e.currentTarget;t&&(this.value=t.value,this.dispatchEvent(new Event("change")));};}render(){return html`<select @change=${this._handleChange} .value=${this.value} ?disabled=${this.disabled}>${this.options.map(e=>html`<option value=${e.value}>${e.text}</option>`)}</select>`}};d([property({type:String,attribute:false})],st.prototype,"value",2),d([property({type:Boolean,reflect:true})],st.prototype,"disabled",2),d([property({type:Array,attribute:false})],st.prototype,"options",2);var Le=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.textOnly=false;this.iconOnly=false;this._iconName="default";this._srcTypeKey="";}willUpdate(e){super.willUpdate(e),e.has("source")&&this._applySource(this.source);}_applySource(e){if(!e){this._srcTypeKey="",this._iconName="default";return}let{label:t,icon:i,id:s}=e;this._srcTypeKey=t,this._iconName=i??s??"default";}activate(){this.source&&(this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{sourceId:this.source.id}}),this.source.onClick());}render(){return html`<button aria-label=${this.l10n(this._srcTypeKey)} type="button" @click=${this.activate}>${this.textOnly?"":html`<uc-icon name=${this._iconName}></uc-icon>`} ${this.iconOnly?"":html`<div class="uc-txt">${this.l10n(this._srcTypeKey)}</div>`}</button>`}};d([property({attribute:false})],Le.prototype,"source",2),d([property({type:Boolean})],Le.prototype,"textOnly",2),d([property({type:Boolean})],Le.prototype,"iconOnly",2),d([state()],Le.prototype,"_iconName",2),d([state()],Le.prototype,"_srcTypeKey",2);var nt=class{constructor(r,e){this._rawSourceList=[];this._ctx=e.ctx,this._sharedInstancesBag=e.sharedInstancesBag,this._onSourcesChange=e.onSourcesChange,r.addController(this);}hostConnected(){this._unsubscribeConfig=this._ctx.sub(v("sourceList"),e=>{this._rawSourceList=N(e),this._updateSources();});let r=this._sharedInstancesBag.pluginManager;r?.onPluginsChange&&(this._unsubscribePlugins=r.onPluginsChange(()=>this._updateSources())),this._updateSources();}hostDisconnected(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,this._unsubscribeConfig?.(),this._unsubscribeConfig=void 0;}_updateSources(){let e=this._sharedInstancesBag.pluginManager?.snapshot().sources??[],t=new Map(e.map(s=>[s.id,s])),i=[];this._rawSourceList.forEach(s=>{let n=this._expandSource(s,t);if(n.length!==1||n[0]!==s){for(let c of n){let u=t.get(c);u&&i.push(this._makePluginSourceConfig(u));}return}let l=t.get(s);l&&i.push(this._makePluginSourceConfig(l));}),this._onSourcesChange(i);}_expandSource(r,e){let t=e.get(r);return t?.expand?t.expand():[r]}_makePluginSourceConfig(r){return {id:r.id,label:r.label,icon:r.icon,onClick:()=>r.onSelect()}}};var kt=class extends _{constructor(){super(...arguments);this._sources=[];this.wrap=false;}initCallback(){super.initCallback(),new nt(this,{ctx:this._sharedInstancesBag.ctx,sharedInstancesBag:this._sharedInstancesBag,onSourcesChange:e=>{this._sources=e;}});}updated(e){super.updated(e),this.cfg.sourceListWrap?this.style.removeProperty("display"):this.style.display="contents";}render(){return html`${this._sources.map(e=>html`<uc-source-btn role="listitem" .source=${e} data-source-id=${e.id}></uc-source-btn>`)}`}};d([state()],kt.prototype,"_sources",2),d([property({type:Boolean,attribute:"wrap",noAccessor:true})],kt.prototype,"wrap",2);var Vr=class extends g{render(){return html`<div class="uc-spinner"></div>`}};var de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function He(o){let r=new Image;return {promise:new Promise((i,s)=>{r.src=o,r.onload=()=>i(),r.onerror=n=>s(n);}),image:r,cancel:()=>{r.naturalWidth===0&&(r.src=de);}}}function Mt(o){let r=[];for(let s of o){let n=He(s);r.push(n);}let e=r.map(s=>s.image);return {promise:Promise.allSettled(r.map(s=>s.promise)),images:e,cancel:()=>{r.forEach(s=>{s.cancel();});}}}function $r(o,r=40){if(o.type==="image/svg+xml")return URL.createObjectURL(o);let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return Promise.reject(new Error("Canvas context not supported"));let i=new Image,s=new Promise((n,a)=>{i.onload=()=>{let l=i.height/i.width;l>1?(e.width=r,e.height=r*l):(e.height=r,e.width=r/l),t.fillStyle="rgb(240, 240, 240)",t.fillRect(0,0,e.width,e.height),t.drawImage(i,0,0,e.width,e.height),e.toBlob(c=>{if(!c){a();return}let u=URL.createObjectURL(c);n(u);});},i.onerror=l=>{a(l);};});return i.src=URL.createObjectURL(o),s}var at=class extends _{constructor(){super(...arguments);this._entrySubs=new Set;this.entry=null;}withEntry(e){return (...t)=>{let i=this.entry;if(!i){console.warn("No entry found");return}return e(i,...t)}}subEntry(e,t){this.withEntry((i,s,n)=>{let a=i.subscribe(s,l=>{this.isConnected&&n(l);});this._entrySubs.add(a);})(e,t);}reset(){for(let e of this._entrySubs)e();this._entrySubs=new Set,this.entry=null;}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set;}};function dl(o){let r=new Blob([o],{type:"image/svg+xml"});return URL.createObjectURL(r)}function Ui(o="hsl(209, 21%, 65%)",r=32,e=32){return dl(`<svg width="${r}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${o}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}var hl=3e3,lt=class extends at{constructor(){super(...arguments);this.badgeIcon="";this.uid="";this._thumbUrl="";this._renderedGridOnce=false;this._thumbRect=null;this._isIntersecting=false;this._firstViewMode=this.cfg.filesViewMode;this._generateThumbnail=this.withEntry(async(e,t=false)=>{let i=e.getValue("fileInfo"),s=e.getValue("isImage"),n=e.getValue("uuid"),a=e.getValue("thumbUrl"),l=this._calculateThumbSize(t);if(i&&s&&n){let u=await this.proxyUrl(F(Ae(this.cfg.cdnCname,n),q(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${l}x${l}/center`)));if(a===u)return;let{promise:p}=He(u);p.then(()=>{e.setValue("thumbUrl",u),a?.startsWith("blob:")&&URL.revokeObjectURL(a);}).catch(async()=>{if(!a?.startsWith("blob:"))try{let m=e.getValue("file");if(!m)return;let h=await $r(m,l);e.setValue("thumbUrl",h);}catch(m){this.telemetryManager.sendEventError(m,"thumbnail generation. Failed to generate thumb from file");let h=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ui(h));}});return}if(e.getValue("thumbUrl"))return;let c=e.getValue("file");if(c?.type.includes("image"))try{let u=await $r(c,l);e.setValue("thumbUrl",u);}catch(u){this.telemetryManager.sendEventError(u,"thumbnail generation. Failed to generate thumb from file");let p=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ui(p));}else {let u=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ui(u));}});this._debouncedGenerateThumb=S(this._generateThumbnail.bind(this),100);}_calculateThumbSize(e=false){e&&(this._thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(this?._thumbRect?.height||0),10),parseInt(String(this?._thumbRect?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,hl)}_decodeImage(e,t){return new Promise((i,s)=>{let n=new Image;n.decoding="async";let a=()=>{n&&(n.onload=null,n.onerror=null,n.src=de,t?.removeEventListener("abort",l),n=null);},l=()=>{a(),s(new DOMException("Aborted","AbortError"));};if(t){if(t.aborted){l();return}t.addEventListener("abort",l,{once:true});}let c=()=>{a(),i();},u=p=>{a(),s(p);};if(typeof n.decode=="function"){n.src=e,n.decode().then(c).catch(u);return}n.onload=c,n.onerror=u,n.src=e;})}_cancelPendingThumbUpdate(){this._pendingThumbUpdate?.cancel(),this._pendingThumbUpdate=void 0;}_scheduleThumbUpdate(e){if(this._cancelPendingThumbUpdate(),!e){this._thumbUrl&&(this._thumbUrl="");return}if(e===this._thumbUrl)return;let t=new AbortController,i={controller:t,cancel:()=>{t.abort(),i.rafId!==void 0&&window.cancelAnimationFrame(i.rafId);}};this._pendingThumbUpdate=i,this._decodeImage(e,t.signal).then(()=>{t.signal.aborted||(i.rafId=window.requestAnimationFrame(()=>{t.signal.aborted||(this._thumbUrl=e);}));}).catch(s=>{t.signal.aborted||s instanceof DOMException&&s.name==="AbortError"||console.warn("[Thumb] Failed to decode thumbnail image",s);});}_requestThumbGeneration(e=false){if(this.entry){if(e){this._generateThumbnail(true);return}this._isIntersecting&&this._debouncedGenerateThumb();}}firstUpdated(e){super.firstUpdated(e),this._bindToEntry();}updated(e){super.updated(e),e.has("uid")&&this._bindToEntry();}_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,t.isIntersecting&&(this._thumbRect=t.boundingClientRect,this._requestThumbGeneration(),this._observer?.disconnect()),t.intersectionRatio===0&&this._debouncedGenerateThumb.cancel());}reset(){super.reset(),this._debouncedGenerateThumb.cancel(),this._cancelPendingThumbUpdate(),this._thumbUrl&&(this._thumbUrl="");}_bindToEntry(){let e=this.uid?.trim();if(!e){this.entry&&this.reset();return}let t=this.uploadCollection?.read(e);if(!t||t===this.entry)return;this.reset(),this.entry=t;let i=()=>{this._requestThumbGeneration();};this.subEntry("fileInfo",s=>{s?.isImage&&i();}),this.subEntry("thumbUrl",s=>{this._scheduleThumbUpdate(s??void 0);}),this.subEntry("cdnUrlModifiers",i),this._requestThumbGeneration(true);}initCallback(){super.initCallback(),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this._renderedGridOnce&&(this._firstViewMode==="list"&&this._requestThumbGeneration(true),this._renderedGridOnce=true);});}connectedCallback(){super.connectedCallback(),this._observer?.disconnect(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this._observer.observe(this);}disconnectedCallback(){super.disconnectedCallback(),this._debouncedGenerateThumb.cancel(),this._cancelPendingThumbUpdate(),this._observer?.disconnect();}render(){return html`<div class="uc-thumb"><img class="uc-thumb__img" src=${this._thumbUrl||de} role="img" alt="Preview of uploaded image" ?hidden=${!this._thumbUrl} draggable="false" /><div class="uc-badge"><uc-icon name=${this.badgeIcon}></uc-icon></div></div>`}};d([property({type:String})],lt.prototype,"badgeIcon",2),d([property({attribute:false})],lt.prototype,"uid",2),d([state()],lt.prototype,"_thumbUrl",2);var Dr=class extends E{};var Fr=class extends E{constructor(){super(...arguments);this.historyTracked=true;this.activityType=E.activities.START_FROM;}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"");}render(){return html`<div class="uc-content">${this.yield("")}</div>`}};var Nr=class extends _{constructor(){super(...arguments);this._unbindEventEmitter=null;}static{this.styleAttrs=["uc-wgt-common"];}static{this.EventType=b;}initCallback(){super.initCallback(),this._unbindEventEmitter=this.eventEmitter.bindTarget(this);}disconnectedCallback(){super.disconnectedCallback(),this._unbindEventEmitter?.();}};var Re=(o,r)=>{let e=false,t,i=0,s=((...n)=>{e?(t&&clearTimeout(t),t=setTimeout(()=>{Date.now()-i>=r&&(o(...n),i=Date.now());},Math.max(r-(Date.now()-i),0))):(o(...n),i=Date.now(),e=true);});return Object.defineProperty(s,"cancel",{configurable:false,writable:false,enumerable:false,value:()=>{t&&clearTimeout(t);}}),s};var Ts="file-item-remove-button",ze=class extends _{constructor(){super(...arguments);this.uploading=false;this.failed=false;this.success=false;this.idle=false;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-action-button"];}_handleRemove(){this.dispatchEvent(new CustomEvent("uc:remove",{bubbles:true,composed:true}));}render(){let e=classMap({"uc-remove-btn":true,"uc-mini-btn":true,"uc-idle":this.idle,"uc-uploading":this.uploading,"uc-failed":this.failed,"uc-success":this.success});return html`<button type="button" @click=${this._handleRemove} title=${this.l10n(Ts)} aria-label=${this.l10n(Ts)} class=${e} ><uc-icon name="remove-file"></uc-icon><uc-icon name="close"></uc-icon></button>`}};d([property({type:Boolean})],ze.prototype,"uploading",2),d([property({type:Boolean})],ze.prototype,"failed",2),d([property({type:Boolean})],ze.prototype,"success",2),d([property({type:Boolean})],ze.prototype,"idle",2);var H=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),$=class $ extends at{constructor(){super(...arguments);this.couldBeCtxOwner=true;this._pauseRender=true;this.uid="";this._itemName="";this._errorText="";this._hint="";this._progressValue=0;this._progressVisible=false;this._badgeIcon="";this._isFinished=false;this._isFailed=false;this._isUploading=false;this._isFocused=false;this._showFileNames=false;this._ariaLabelStatusFile="";this._pluginFileActions=[];this._renderedOnce=false;this._handleRemove=()=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uid&&this.uploadCollection.hasItem(this.uid)&&this.uploadCollection.remove(this.uid);};this._handleUploadClick=()=>{this._upload();};this._debouncedCalculateState=S(()=>this._calculateState(),100);this._updateHintAndProgress=this.withEntry(Re((e,t)=>{let i=e.getValue("errors")?.[0]?.message??"",s=e.getValue("source"),n=e.getValue("externalUrl"),a=t===H.FINISHED,l=t===H.UPLOADING,c=t===H.QUEUED_UPLOADING,u=t===H.QUEUED_VALIDATION,p=t===H.VALIDATION,m=e.getValue("fileName"),h="";i?h="":!a&&n&&s&&Object.values(Q).includes(s)&&(h=this.l10n("waiting-for",{source:this.l10n(`src-type-${Zo(s)}`)})),this._hint=h,this._errorText=i,this._progressVisible=l||c||u||p,this._progressValue=u||p?0:e.getValue("uploadProgress"),this._ariaLabelStatusFile=m?this.l10n("a11y-file-item-status",{fileName:m,status:this.l10n(t?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()}):"";},100));this._upload=this.withEntry(async e=>{if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0||e.getValue("isValidationPending"))return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){e.setMultipleValues({isUploading:true,errors:[],isQueuedForUploading:true}),this._debouncedCalculateState();try{let i=new AbortController;e.setValue("abortController",i);let s=async()=>{e.setValue("isQueuedForUploading",!1);let a=e.getValue("file");if(a instanceof File||a instanceof Blob){let m=(this._sharedInstancesBag.pluginManager?.snapshot().fileHooks??[]).filter(h=>h.type==="beforeUpload");for(let h of m)try{let f=h.handler({file:a,signal:i.signal}),P=new Promise((L,G)=>setTimeout(()=>G(new Error("beforeUpload hook timed out")),h.timeout)),{file:w}=await Promise.race([f,P]);w!==a&&(a=w,e.setValue("mimeType",a.type||null),e.setValue("isImage",Ze(a)),e.setValue("fileSize",a.size),a instanceof File&&e.setValue("fileName",a.name));}catch(f){console.warn(`File hook "beforeUpload" from plugin "${h.pluginId}" failed`,f);}}let l=a||e.getValue("externalUrl")||e.getValue("uuid");if(!l)throw new Error("No file input");let u={...await this.getUploadClientOptions(),fileName:e.getValue("fileName")??void 0,source:e.getValue("source")??void 0,onProgress:p=>{if(p.isComputable){let m=p.value*100;e.setValue("uploadProgress",m);}},signal:i.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",l,u),uploadFile(l,u)},n=await this.$["*uploadQueue"].add(s);e.setMultipleValues({fileInfo:n,isQueuedForUploading:!1,isUploading:!1,fileName:n.originalFilename,fileSize:n.size,isImage:n.isImage??!1,mimeType:n.contentInfo?.mime?.mime??n.mimeType,uuid:n.uuid,cdnUrl:e.getValue("cdnUrl")??n.cdnUrl,cdnUrlModifiers:e.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:e.getValue("source")??null}),e===this.entry&&this._debouncedCalculateState();}catch(i){let s=i instanceof CancelError&&i.isCancel;s?e.setMultipleValues({isUploading:false,uploadProgress:0}):i instanceof UploadcareError?e.setMultipleValues({isUploading:false,uploadProgress:0,uploadError:i}):(console.error("Unknown upload error",i),e.setMultipleValues({isUploading:false,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:i})})),e===this.entry&&this._debouncedCalculateState(),this.isConnected&&!s&&this.telemetryManager.sendEventError(i,"file upload. Failed to upload file");}}});}_calculateState(){let e=this.entry;if(!e)return;let t=H.IDLE;e.getValue("errors").length>0?t=H.FAILED:e.getValue("isQueuedForUploading")?t=H.QUEUED_UPLOADING:e.getValue("isQueuedForValidation")?t=H.QUEUED_VALIDATION:e.getValue("isValidationPending")?t=H.VALIDATION:e.getValue("isUploading")?t=H.UPLOADING:e.getValue("fileInfo")&&(t=H.FINISHED),this._handleState(e,t);}_handleState(e,t){t===H.FAILED?this._badgeIcon="badge-error":t===H.FINISHED&&(this._badgeIcon="badge-success"),t===H.UPLOADING&&(this._isFocused=false,this.removeAttribute("focused")),this._isFailed=t===H.FAILED,this._isUploading=t===H.UPLOADING,this._isFinished=t===H.FINISHED,this._updateHintAndProgress(t);}reset(){super.reset(),this._debouncedCalculateState.cancel();}_observerCallback(e){let[t]=e;t&&t.isIntersecting&&!this._renderedOnce&&(this._pauseRender=false,this._renderedOnce=true);}_handleEntryId(e){this.reset();let t=this.uploadCollection?.read(e);if(this.entry=t,!t){this._updatePluginFileActions();return}this.subEntry("isQueuedForValidation",()=>{this._debouncedCalculateState();}),this.subEntry("isValidationPending",()=>{this._debouncedCalculateState();}),this.subEntry("uploadProgress",()=>{this._debouncedCalculateState();}),this.subEntry("isQueuedForUploading",()=>{this._debouncedCalculateState();}),this.subEntry("fileName",i=>{this._itemName=i||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState();}),this.subEntry("externalUrl",i=>{this._itemName=t.getValue("fileName")||i||this.l10n("file-no-name");}),this.subEntry("fileInfo",()=>{this._debouncedCalculateState();}),this.subEntry("errors",()=>this._debouncedCalculateState()),this.subEntry("isUploading",()=>this._debouncedCalculateState()),this.subEntry("fileSize",()=>this._debouncedCalculateState()),this.subEntry("mimeType",()=>this._debouncedCalculateState()),this.subEntry("isImage",()=>this._debouncedCalculateState()),this.subEntry("fileInfo",()=>this._updatePluginFileActions()),this.subEntry("isUploading",()=>this._updatePluginFileActions()),this.subEntry("errors",()=>this._updatePluginFileActions()),this._calculateState(),this._updatePluginFileActions();}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this._showFileNames=true;return}this._showFileNames=e;}willUpdate(e){super.willUpdate(e),e.has("uid")&&this._handleEntryId(this.uid);}_updatePluginFileActions(){let e=this._sharedInstancesBag.pluginManager;if(!e||!this.uid){this._pluginFileActions=[];return}let t=e.snapshot().fileActions,i=this.api.getOutputItem(this.uid);if(!i){this._pluginFileActions=[];return}this._pluginFileActions=t.filter(s=>{try{return s.shouldRender(i)}catch(n){return console.error(`Error in plugin file action shouldRender (${s.id}):`,n),false}});}_handlePluginFileAction(e){if(!this.uid)return;let t=this.api.getOutputItem(this.uid);if(t){this.telemetryManager.sendEvent({payload:{metadata:{event:e.id,node:this.tagName,pluginId:e.pluginId}}});try{e.onClick(t);}catch(i){console.error(`Error in plugin file action onClick (${e.id}):`,i);}}}initCallback(){super.initCallback(),this._handleEntryId(this.uid),this.subConfigValue("filesViewMode",t=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",t);}),this.subConfigValue("gridShowFileNames",t=>{this._updateShowFileNames(t);}),this.onclick=()=>{$.activeInstances.forEach(t=>{t===this?t.setAttribute("focused",""):t.removeAttribute("focused");});},this.sub("*uploadTrigger",t=>{this.entry&&!t.has(this.entry.uid)||setTimeout(()=>this.isConnected&&this._upload());});let e=this._sharedInstancesBag.pluginManager;e?.onPluginsChange&&(this._unsubscribePlugins=e.onPluginsChange(()=>this._updatePluginFileActions())),this._updatePluginFileActions(),$.activeInstances.add(this);}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this);}disconnectedCallback(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,super.disconnectedCallback(),this._observer?.disconnect(),$.activeInstances.delete(this),this.reset();}static{this.activeInstances=new Set;}shouldUpdate(e){return this._pauseRender?false:super.shouldUpdate(e)}render(){return html`<div class="uc-inner" ?data-finished=${this._isFinished} ?data-uploading=${this._isUploading} ?data-failed=${this._isFailed} ?data-focused=${this._isFocused} ><uc-thumb .uid=${this.uid} .badgeIcon=${this._badgeIcon}></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" aria-label=${this._ariaLabelStatusFile}><span class="uc-file-name" ?hidden=${!this._showFileNames}>${this._itemName}</span><span class="uc-file-error" ?hidden=${!this._errorText}>${this._errorText}</span><span class="uc-file-hint" ?hidden=${!this._hint}>${this._hint}</span></div><div class="uc-file-actions">${this._pluginFileActions.map(e=>html`<button type="button" @click=${()=>this._handlePluginFileAction(e)} title=${this.l10n(e.label)} aria-label=${this.l10n(e.label)} class="uc-plugin-action-btn uc-mini-btn" data-plugin-action-id=${e.id} ><uc-icon name=${e.icon}></uc-icon></button>`)}<uc-file-action-button @uc:remove=${this._handleRemove} .uploading=${this._progressVisible} .failed=${this._isFailed} .success=${this._isFinished}></uc-file-action-button><button type="button" class="uc-upload-btn uc-mini-btn" @click=${this._handleUploadClick}><uc-icon name="upload"></uc-icon></button></div></div>`}};d([state()],$.prototype,"_pauseRender",2),d([property({attribute:false})],$.prototype,"uid",2),d([state()],$.prototype,"_itemName",2),d([state()],$.prototype,"_errorText",2),d([state()],$.prototype,"_hint",2),d([state()],$.prototype,"_progressValue",2),d([state()],$.prototype,"_progressVisible",2),d([state()],$.prototype,"_badgeIcon",2),d([state()],$.prototype,"_isFinished",2),d([state()],$.prototype,"_isFailed",2),d([state()],$.prototype,"_isUploading",2),d([state()],$.prototype,"_isFocused",2),d([state()],$.prototype,"_showFileNames",2),d([state()],$.prototype,"_ariaLabelStatusFile",2),d([state()],$.prototype,"_pluginFileActions",2);var Br=$;function Cl(o){return new Promise(r=>{typeof window.FileReader!="function"&&r(false);try{let e=new FileReader;e.onerror=()=>{r(!0);};let t=i=>{i.type!=="loadend"&&e.abort(),r(!1);};e.onloadend=t,e.onprogress=t,e.readAsDataURL(o);}catch{r(false);}})}function wl(o,r){return new Promise(e=>{let t=0,i=[],s=a=>{if(!a){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),e(null);return}a.isFile?(t++,a.file(l=>{t--;let c=new File([l],l.name,{type:l.type||r});i.push({type:"file",file:c,fullPath:a.fullPath}),t===0&&e(i);})):a.isDirectory&&n(a.createReader());},n=a=>{t++,a.readEntries(l=>{t--;for(let c of l)s(c);t===0&&e(i);});};s(o);})}function xs(o){let r=[],e=[];for(let t=0;t<o.items.length;t++){let i=o.items[t];if(i)if(i.kind==="file"){let s=i.type,n=i;if(typeof n.webkitGetAsEntry=="function"||typeof n.getAsEntry=="function"){let l=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():n.getAsEntry?.();l&&e.push(wl(l,s).then(c=>{c&&r.push(...c);}));continue}let a=i.getAsFile();a&&e.push(Cl(a).then(l=>{l||r.push({type:"file",file:a});}));}else i.kind==="string"&&/^text\/uri-list/.test(i.type)&&e.push(new Promise(s=>{i.getAsString(n=>{r.push({type:"url",url:n}),s();});}));}return Promise.all(e).then(()=>r)}var Y=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),Ss=["focus"],Tl=100,Hr=new Map;function El(o,r){let e=Math.max(Math.min(o[0],r.x+r.width),r.x),t=Math.max(Math.min(o[1],r.y+r.height),r.y);return Math.sqrt((o[0]-e)*(o[0]-e)+(o[1]-t)*(o[1]-t))}function zr(o){let r=0,e=document.body,t=new Set,i=f=>{t.add(f);},s=Y.INACTIVE,n=f=>{o.shouldIgnore()&&f!==Y.INACTIVE||(s!==f&&t.forEach(P=>{P(f);}),s=f);},a=()=>r>0;i(f=>o.onChange(f));let l=()=>{r=0,n(Y.INACTIVE);},c=()=>{r+=1,s===Y.INACTIVE&&n(Y.ACTIVE);},u=()=>{r-=1,a()||n(Y.INACTIVE);},p=f=>{f.preventDefault(),r=0,n(Y.INACTIVE);},m=f=>{if(o.shouldIgnore())return;a()||(r+=1);let P=[f.x,f.y],w=o.element.getBoundingClientRect(),L=Math.floor(El(P,w)),G=L<Tl,Zt=f.composedPath().includes(o.element);Hr.set(o.element,L);let po=Math.min(...Hr.values())===L;Zt&&po?(f.preventDefault(),n(Y.OVER)):n(G&&po?Y.NEAR:Y.ACTIVE);},h=async f=>{if(o.shouldIgnore())return;f.preventDefault();let{dataTransfer:P}=f;if(!P)return;let w=await xs(P);o.onItems(w),n(Y.INACTIVE);};return e.addEventListener("drop",p),e.addEventListener("dragleave",u),e.addEventListener("dragenter",c),e.addEventListener("dragover",m),o.element.addEventListener("drop",h),Ss.forEach(f=>{window.addEventListener(f,l);}),()=>{Hr.delete(o.element),e.removeEventListener("drop",p),e.removeEventListener("dragleave",u),e.removeEventListener("dragenter",c),e.removeEventListener("dragover",m),o.element.removeEventListener("drop",h),Ss.forEach(f=>{window.removeEventListener(f,l);});}}var Kr=new Set,oe=class extends _{constructor(){super(...arguments);this.single=false;this.ghost=false;this.disabled=false;this.clickable=false;this.withIcon=false;this.fullscreen=false;this.initflow=false;this._isEnabled=true;this._isVisible=true;this._dropTextKey="drop-files-here";this._isMultiple=false;this._destroyDropzone=null;this._destroyContentWrapperDropzone=null;this._contentWrapperRef=createRef();this._handleAreaInteraction=e=>{if(e instanceof KeyboardEvent){if(e.code!=="Space"&&e.code!=="Enter")return}else if(!(e instanceof MouseEvent))return;if(this.initflow){this.api.initFlow();return}this.api.openSystemDialog();};this._sourceListAllowsLocal=true;this._clickableListenersAttached=false;}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-area"];}_updateDropText(){let e=this.text;if(typeof e=="string"&&e.length>0){this._dropTextKey=e;return}this._dropTextKey=this._isMultiple?"drop-files-here":"drop-file-here";}isActive(){if(!this._isEnabled)return false;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,i=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),s=window.getComputedStyle(this),n=s.visibility!=="hidden"&&s.display!=="none";return t&&n&&i}initCallback(){super.initCallback(),Kr.add(this),this._updateIsEnabled(),this._updateVisibility(),this._updateClickableListeners(),this._updateDragStateAttribute(Y.INACTIVE),this._destroyDropzone=zr({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:e=>{this._updateDragStateAttribute(e);},onItems:e=>{if(!e.length)return;let t=this.uploadCollection.size;e.forEach(i=>{i.type==="url"?this.api.addFileFromUrl(i.url,{source:T.DROP_AREA}):i.type==="file"&&this.api.addFileFromObject(i.file,{source:T.DROP_AREA,fullPath:i.fullPath});}),this.uploadCollection.size>t&&this.routerLayer.navigateAfterFileAdd();}}),this.updateComplete.then(()=>this._setupContentWrapperDropzone()),this.subConfigValue("sourceList",e=>{let t=N(e);this._sourceListAllowsLocal=t.includes(T.LOCAL),this._updateIsEnabled(),this._updateVisibility();}),this.subConfigValue("multiple",e=>{this._isMultiple=!!e,this._updateDropText();});}willUpdate(e){super.willUpdate(e),e.has("disabled")&&(this._updateIsEnabled(),this._updateVisibility()),(e.has("text")||e.has("localeId"))&&this._updateDropText();}updated(e){super.updated(e),e.has("clickable")&&this._updateClickableListeners();}_shouldIgnore(){if(!this._isEnabled||!this._couldHandleFiles())return true;if(!this.fullscreen)return false;let e=Kr;return e.size===0?false:[...e].filter(s=>s!==this).filter(s=>s.isActive()).length>0}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,i=this.uploadCollection.size;return !(e&&t&&i>=t||!e&&i>0)}_updateIsEnabled(){let e=this._sourceListAllowsLocal&&!this.disabled;this._isEnabled=e;}_updateVisibility(){let e=this._isEnabled||!this.querySelector("[data-default-slot]");this._isVisible=e,this.hidden=!e;}_updateDragStateAttribute(e){let t=Object.entries(Y).find(([,i])=>i===e)?.[0].toLowerCase();t&&this.setAttribute("drag-state",t);}_setupContentWrapperDropzone(){if(this._destroyContentWrapperDropzone)return;let e=this._contentWrapperRef.value;e&&(this._destroyContentWrapperDropzone=zr({element:e,onChange:t=>{let i=Object.entries(Y).find(([,s])=>s===t)?.[0].toLowerCase();i&&e.setAttribute("drag-state",i);},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()}));}_updateClickableListeners(){this.clickable&&!this._clickableListenersAttached?(this.addEventListener("keydown",this._handleAreaInteraction),this.addEventListener("click",this._handleAreaInteraction),this._clickableListenersAttached=true):!this.clickable&&this._clickableListenersAttached&&(this.removeEventListener("keydown",this._handleAreaInteraction),this.removeEventListener("click",this._handleAreaInteraction),this._clickableListenersAttached=false);}disconnectedCallback(){super.disconnectedCallback(),Kr.delete(this),this._destroyDropzone?.(),this._destroyContentWrapperDropzone?.(),this._clickableListenersAttached&&(this.removeEventListener("keydown",this._handleAreaInteraction),this.removeEventListener("click",this._handleAreaInteraction),this._clickableListenersAttached=false);}render(){return html` ${this.yield("",html`<div data-default-slot hidden></div><div ${ref(this._contentWrapperRef)} class="uc-content-wrapper" ?hidden=${!this._isVisible} ><div class="uc-icon-container" ?hidden=${!this.withIcon}><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">${this.l10n(this._dropTextKey)}</span></div>`)} `}};d([property({type:Boolean,noAccessor:true})],oe.prototype,"single",2),d([property({type:Boolean,noAccessor:true})],oe.prototype,"ghost",2),d([property({type:Boolean,reflect:true})],oe.prototype,"disabled",2),d([property({type:Boolean,reflect:true})],oe.prototype,"clickable",2),d([property({type:Boolean,attribute:"with-icon",reflect:true})],oe.prototype,"withIcon",2),d([property({type:Boolean,reflect:true})],oe.prototype,"fullscreen",2),d([property({type:Boolean,reflect:true})],oe.prototype,"initflow",2),d([property({type:String})],oe.prototype,"text",2),d([state()],oe.prototype,"_isEnabled",2),d([state()],oe.prototype,"_isVisible",2);var ue=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.historyTracked=true;this.activityType=E.activities.UPLOAD_LIST;this._doneBtnVisible=false;this._doneBtnEnabled=false;this._uploadBtnVisible=false;this._addMoreBtnVisible=false;this._addMoreBtnEnabled=false;this._commonErrorMessage=null;this._hasFiles=false;this._latestSummary=null;this._handleAdd=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(true);};this._handleUpload=()=>{this.emit(b.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate();};this._handleDone=()=>{this.emit(b.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow();};this._handleCancel=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll();};this._throttledHandleCollectionUpdate=Re(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll());},300);}get _headerText(){return this._latestSummary?this._getHeaderText(this._latestSummary):""}_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount,validatingBeforeUploading:e.idleEntries.filter(h=>h.isValidationPending).length},i=!e.errors.some(h=>h.type==="TOO_MANY_FILES"||h.type==="TOO_FEW_FILES"),s=e.errors.some(h=>h.type==="TOO_MANY_FILES"),n=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),a=e.allEntries.some(h=>h.isValidationPending),l=t.failed===0&&e.errors.length===0&&!a,c=false,u=false,p=false;if(t.total-t.succeed-t.uploading-t.failed>0&&i&&l&&this.cfg.confirmUpload)c=true;else {u=true;let h=this.cfg.groupOutput?!!e.group:true;p=t.total===t.succeed&&i&&l&&h;}this._doneBtnVisible=u,this._doneBtnEnabled=p,this._uploadBtnVisible=c,this._addMoreBtnEnabled=t.total===0||!s&&!n,this._addMoreBtnVisible=!n||this.cfg.multiple,this._hasFiles=t.total>0,this._latestSummary=t;}_getHeaderText(e){let t=i=>{let s=e[i];return i==="uploading"&&(s+=e.validatingBeforeUploading),this.l10n(`header-${i}`,{count:s})};return e.uploading>0||e.validatingBeforeUploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",e=>{e&&this._throttledHandleCollectionUpdate();}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e);}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity);}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this.sub("*collectionErrors",e=>{let t=e.filter(i=>i.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this._commonErrorMessage=null;return}this._commonErrorMessage=t.message;});}disconnectedCallback(){super.disconnectedCallback(),this.has("*uploadCollection")&&(this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.unobserveCollection(this._throttledHandleCollectionUpdate));}render(){return html`<uc-activity-header><span aria-live="polite" class="uc-header-text">${this._headerText}</span><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" ?hidden=${this._hasFiles}>${this.yield("empty",html`<span>${this.l10n("no-files")}</span>`)}</div><div class="uc-files"><div class="uc-files-wrapper">${repeat(this.$["*uploadList"]??[],({uid:e})=>e,({uid:e})=>html`<uc-file-item .uid=${e}></uc-file-item>`)}</div><button type="button" class="uc-add-more-btn uc-secondary-btn" @click=${this._handleAdd} ?disabled=${!this._addMoreBtnEnabled} ?hidden=${!this._addMoreBtnVisible} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button></div><div class="uc-common-error" ?hidden=${!this._commonErrorMessage} >${this._commonErrorMessage??""}</div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("clear")}</button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" ?hidden=${!this._addMoreBtnVisible} ?disabled=${!this._addMoreBtnEnabled} @click=${this._handleAdd} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button><button type="button" class="uc-upload-btn uc-primary-btn" ?hidden=${!this._uploadBtnVisible} @click=${this._handleUpload} >${this.l10n("upload")}</button><button type="button" class="uc-done-btn uc-primary-btn" ?hidden=${!this._doneBtnVisible} ?disabled=${!this._doneBtnEnabled} @click=${this._handleDone} >${this.l10n("done")}</button></div><uc-drop-area ghost></uc-drop-area>`}};d([state()],ue.prototype,"_doneBtnVisible",2),d([state()],ue.prototype,"_doneBtnEnabled",2),d([state()],ue.prototype,"_uploadBtnVisible",2),d([state()],ue.prototype,"_addMoreBtnVisible",2),d([state()],ue.prototype,"_addMoreBtnEnabled",2),d([state()],ue.prototype,"_commonErrorMessage",2),d([state()],ue.prototype,"_hasFiles",2),d([state()],ue.prototype,"_latestSummary",2);var Al=[{test:o=>!!o.accept&&!!o.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:o=>o.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:o=>o.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],ks=S(o=>{for(let{test:r,message:e}of Al)r(o)&&xi(e);},0);var Ms=o=>o instanceof Promise||!!(o&&typeof o=="object"&&"then"in o&&typeof o.then=="function");var Gr=o=>o,Pl=[Gr({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:o,enableVideoRecording:r})=>{let e=r();if(e===null)return o();let t=V(o());return e&&!t.includes("video")?t=t.concat("video"):e||(t=t.filter(i=>i!=="video")),_e(t)}}),Gr({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:o,defaultCameraMode:r})=>{let e=r();if(e===null)return o();let t=V(o());return t=t.sort((i,s)=>i===e?-1:s===e?1:0),_e(t)}}),Gr({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:o,cdnCname:r,cdnCnamePrefixed:e})=>{let t=o(),i=r(),s=e();return t&&(i===_t||isPrefixedCdnBase(i,s))?getPrefixedCdnBaseAsync(t,s):i}})],Ps=({key:o,setValue:r,getValue:e,computationControllers:t})=>{for(let i of Pl){if(!i.deps.includes(o))continue;let s={[i.key]:()=>e(i.key)};for(let l of i.deps)s[l]=()=>e(l);let n=new AbortController;t.get(i.fn)?.abort(),t.set(i.fn,n);let a;try{a=i.fn(s,{signal:n.signal});}catch(l){t.get(i.fn)===n&&t.delete(i.fn),console.error(`Failed to compute value for "${i.key}"`,l);return}Ms(a)?a.then(l=>{n.signal.aborted||r(i.key,l);}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${i.key}"`,l);}).finally(()=>{t.get(i.fn)===n&&t.delete(i.fn);}):r(i.key,a);}};var I=o=>String(o),K=o=>{let r=Number(o);if(Number.isNaN(r))throw new Error(`Invalid number: "${o}"`);return r},k=o=>{if(typeof o>"u"||o===null)return false;if(typeof o=="boolean")return o;if(o==="true"||o==="")return true;if(o==="false")return false;throw new Error(`Invalid boolean: "${o}"`)},Os=o=>o==="auto"?o:k(o),Ls=o=>{let r=I(o);if(r!=="user"&&r!=="environment"&&r!=="")throw new Error(`Invalid value: "${r}"`);return r},Rs=o=>{let r=I(o);if(!Object.values(C).includes(r))throw new Error(`Invalid value: "${r}"`);return r},Us=o=>{let r=I(o),e=V(r);if(e.some(t=>!Object.values(C).includes(t)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return r},Vs=o=>{let r=I(o);if(r==="local"||r==="global")return r;if(k(o)===false)return false;throw new Error(`Invalid value: "${r}"`)},$s=o=>{if(typeof o=="object"&&!Array.isArray(o)||typeof o=="function")return o;throw new Error("Invalid metadata value. Must be an object or function.")},Wr=o=>{if(typeof o=="object")return o;throw new Error("Invalid value. Must be an object.")},$i=o=>{if(typeof o=="function")return o;throw new Error("Invalid value. Must be a function.")},Di=o=>{if(Array.isArray(o))return o;throw new Error("Must be an array.")},Ds=o=>{let r=I(o);if(["grid","list"].includes(r))return r;throw new Error(`Invalid value: "${r}"`)},Fs=o=>{let r=I(o);if(["auto","menu","toolbar","compact"].includes(r))return r;throw new Error(`Invalid value: "${r}"`)};var Ol={pubkey:I,multiple:k,multipleMin:K,multipleMax:K,confirmUpload:k,imgOnly:k,accept:I,externalSourcesPreferredTypes:I,externalSourcesEmbedCss:I,store:Os,cameraMirror:k,cameraCapture:Ls,sourceList:I,topLevelOrigin:I,maxLocalFileSizeBytes:K,thumbSize:K,showEmptyList:k,useLocalImageEditor:k,useCloudImageEditor:k,cloudImageEditorTabs:I,removeCopyright:k,cropPreset:I,imageShrink:I,modalScrollLock:k,modalBackdropStrokes:k,sourceListWrap:k,remoteTabSessionKey:I,cdnCname:I,cdnCnamePrefixed:I,baseUrl:I,socialBaseUrl:I,secureSignature:I,secureExpire:I,secureDeliveryProxy:I,retryThrottledRequestMaxTimes:K,retryNetworkErrorMaxTimes:K,multipartMinFileSize:K,multipartChunkSize:K,maxConcurrentRequests:K,multipartMaxConcurrentRequests:K,multipartMaxAttempts:K,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:k,groupOutput:k,userAgentIntegration:I,debug:k,localeName:I,metadata:$s,secureUploadsExpireThreshold:K,localeDefinitionOverride:o=>Wr(o),secureUploadsSignatureResolver:o=>$i(o),secureDeliveryProxyUrlResolver:o=>$i(o),iconHrefResolver:o=>$i(o),plugins:o=>Di(o),fileValidators:Di,collectionValidators:Di,validationTimeout:K,validationConcurrency:K,cameraModes:Us,defaultCameraMode:Rs,enableAudioRecording:k,enableVideoRecording:k,mediaRecorderOptions:Wr,maxVideoRecordingDuration:K,filesViewMode:Ds,gridShowFileNames:k,cloudImageEditorAutoOpen:k,cloudImageEditorMaskHref:I,testMode:k,qualityInsights:k,pasteScope:Vs,smartButtonShowFirstIcon:k,smartButtonViewMode:Fs},Ns=(o,r)=>{if(!(typeof r>"u"||r===null))try{return Ol[o](r)}catch(e){return console.error(`Invalid value for config key "${o}".`,e),z[o]}};var Fi=[...new Set(["debug",...Object.keys(z)])],Ll=["metadata","plugins","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],Hs=o=>Ll.includes(o),Zr=Fi.filter(o=>!Hs(o)),qr={...Object.fromEntries(Zr.map(o=>[oi(o),o])),...Object.fromEntries(Zr.map(o=>[o.toLowerCase(),o]))},Bs=o=>`__${o}`,ct=class extends g{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(z).map(([e,t])=>[v(e),t]))};this._computationControllers=new Map;this._customAttrKeyMapping={};this._customConfigKeys=new Set;this._customConfigSubscriptions=new Map;}_isCustomConfig(e){return this._customConfigKeys.has(e)}_getCustomConfigDefinition(e){let t=this._sharedInstancesBag.pluginManager;if(t)return t.configRegistry.get(e)}_getAttributeNames(e){return [...new Set([oi(e),e.toLowerCase()])]}_flushValueToAttribute(e,t){if(Hs(e)||this._isCustomConfig(e)&&this._getCustomConfigDefinition(e)?.attribute===false)return;let i=this._getAttributeNames(e);for(let s of i)typeof t>"u"||t===null?this.removeAttribute(s):this.getAttribute(s)!==t.toString()&&this.setAttribute(s,t.toString());}_flushValueToState(e,t){let i=v(e);if(this.$[i]!==t)if(typeof t>"u"||t===null){let s=z[e];this.$[i]=s!==void 0?s:t;}else this.$[i]=t;}_setValue(e,t){let i;if(this._isCustomConfig(e)){let a=this._getCustomConfigDefinition(e);try{i=a?.normalize?.(t)??t;}catch(l){console.warn(`[uc-config] normalize() for "${e}" threw an error, keeping previous value`,l);return}}else i=Ns(e,t);let s=this,n=Bs(e);s[n]!==i&&(this._assertSameValueDifferentReference(e,s[n],i),s[n]=i,this._flushValueToAttribute(e,i),this._flushValueToState(e,i),this.debugPrint(`"${e}"`,i),this._isCustomConfig(e)||ks(this.cfg));}_getValue(e){let t=this,i=Bs(e);return t[i]??this.$[v(e)]}_assertSameValueDifferentReference(e,t,i){this.cfg.debug&&i!==t&&typeof i=="object"&&typeof t=="object"&&JSON.stringify(i)===JSON.stringify(t)&&(console.warn(`[uc-config] Option "${e}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${e}" previous value:`,t),console.warn(`[uc-config] "${e}" new value:`,i));}_processCustomConfigs(e){let t=e.configRegistry.getAll();this._customAttrKeyMapping={},this._customConfigKeys=new Set(t.keys());for(let[i,s]of this._customConfigSubscriptions)t.has(i)||(s(),this._customConfigSubscriptions.delete(i));for(let[i,s]of t){let a=v(i);if(s.attribute){let h=this._getAttributeNames(i);for(let f of h)this._customAttrKeyMapping[f]=i;}let l,c=false,u=Object.getOwnPropertyDescriptor(this,i);if(u&&!u.get&&!u.set&&u.value!==void 0&&(l=u.value,c=true),!c&&s.attribute)for(let h of this._getAttributeNames(i)){let f=this.getAttribute(h);if(f!=null){try{l=s.fromAttribute?s.fromAttribute(f):f;}catch(P){console.warn(`[uc-config] fromAttribute() for "${i}" threw an error, using raw attribute value`,P),l=f;}c=true;break}}this.sharedCtx.has(a)||this.sharedCtx.add(a,s.defaultValue);let m=Object.getOwnPropertyDescriptor(this,i);if((!m||!m.set||!m.get)&&Object.defineProperty(this,i,{set:h=>{this._setValue(i,h);},get:()=>this._getValue(i),enumerable:true,configurable:true}),!this._customConfigSubscriptions.has(i)){let h=this.sub(a,f=>{this._setValue(i,f);},false);this._customConfigSubscriptions.set(i,h);}c&&this._setValue(i,l);}}_setupCustomConfigs(){this._sharedInstancesBag.when("pluginManager",e=>{this._processCustomConfigs(e),this._pluginChangeUnsubscribe=e.onPluginsChange(()=>{this._processCustomConfigs(e);});});}_setupMutationObserver(){this._mutationObserver=new MutationObserver(e=>{for(let t of e)if(t.type==="attributes"&&t.attributeName){let i=t.attributeName,s=t.oldValue,n=this.getAttribute(i);if(s===n||i in qr)continue;if(i in this._customAttrKeyMapping){let l=this._customAttrKeyMapping[i],c=this._getCustomConfigDefinition(l);this.attributeChangedCallback(i,s??"",n??c?.defaultValue??"");}}}),this._mutationObserver.observe(this,{attributes:true,attributeOldValue:true});}initCallback(){super.initCallback();let e=this;this._setupCustomConfigs(),this._setupMutationObserver();for(let i of Zr)this.sub(v(i),s=>{this._setValue(i,s);},false);for(let i of Fi){let s=e[i]??this.$[v(i)];s!==z[i]&&this._setValue(i,s);let n=Object.getOwnPropertyDescriptor(this,i);(!n||!n.set||!n.get)&&Object.defineProperty(this,i,{set:a=>{this._setValue(i,a);},get:()=>this._getValue(i)});}let t=i=>{Ps({key:i,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this._computationControllers});};for(let i of Fi)this.sub(v(i),()=>t(i));}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),t===i)return;let s=this,n=qr[e];n?s[n]=i:this._sharedInstancesBag.when("pluginManager",a=>{let l=this.getAttribute(e);if(l&&l!==i)return;let c=this._customAttrKeyMapping[e],u=c?a.configRegistry.get(c):void 0;if(c&&u){let p=u.fromAttribute?u.fromAttribute(i):i;if(this._getValue(c)===p)return;this._setValue(c,p);}});}disconnectedCallback(){super.disconnectedCallback(),this._pluginChangeUnsubscribe&&(this._pluginChangeUnsubscribe(),this._pluginChangeUnsubscribe=void 0),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=void 0);for(let e of this._customConfigSubscriptions.values())e();this._customConfigSubscriptions.clear();}static get observedAttributes(){let e=super.observedAttributes,t=Object.keys(qr);return [...e,...t]}};for(let o of Fi)ct.prototype[o]=void 0;var Pt=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.dropzone=true;this._buttonTextKey="upload-file";this._handleClick=()=>{this.api.initFlow();};}static{this.styleAttrs=[...super.styleAttrs,"uc-simple-btn"];}initCallback(){super.initCallback(),this.subConfigValue("multiple",e=>{this._buttonTextKey=e?"upload-files":"upload-file";});}render(){return html`<uc-drop-area .disabled=${!this.dropzone}><button type="button" @click=${this._handleClick}><uc-icon name="upload"></uc-icon><span>${this.l10n(this._buttonTextKey)}</span>${this.yield("")}<div class="uc-visual-drop-area">${this.l10n("drop-files-here")}</div></button></uc-drop-area>`}};d([property({attribute:"dropzone",type:Boolean})],Pt.prototype,"dropzone",2),d([state()],Pt.prototype,"_buttonTextKey",2);var Ke=class Ke extends _{constructor(){super(...arguments);this.showIcon=false;this._isMultiple=false;}static{this.styleAttrs=[...super.styleAttrs,"uc-primary-action"];}static{this.SOURCE_TEXT_CONFIG={[T.LOCAL]:{action:"upload-from"},[T.URL]:{action:"upload-from"},[T.CAMERA]:{action:"capture-with"},[T.MOBILE_PHOTO_CAMERA]:{action:"take"},[T.MOBILE_VIDEO_CAMERA]:{action:"record"}};}initCallback(){super.initCallback(),this.subConfigValue("smartButtonShowFirstIcon",e=>{this.showIcon=e;}),this.subConfigValue("multiple",e=>{this._isMultiple=e;});}get hasEntries(){return (this.entries?.allEntries?.length??0)>0}get hasSingleSuccessImage(){return this.entries?.allEntries?.length===1&&this.entries.isSuccess&&(this.entries.allEntries[0]?.isImage??false)}get hasMultipleEntries(){return (this.entries?.allEntries?.length??0)>=1}get localizedSourceLabel(){return this.source?.label?["local","url","camera"].includes(this.source?.id)?this.l10n(this.source.label).toLowerCase():this.l10n(this.source.label):""}_translate(e,t){return this.l10n(e,t)}get textBasedOnLocale(){let e=this._headerTextDependentOnEntries();return e||this._getSourceLabelText()}_headerTextDependentOnEntries(){if(this.entries?.status==="uploading")return this._translate("header-uploading",{count:this.entries.uploadingCount});if(this.entries?.status==="failed")return this._translate("header-failed",{count:this.entries.failedCount});if(this.entries?.status==="success")return this._translate("header-succeed",{count:this.entries.successCount});if(this.entries?.totalCount>0)return this._translate("header-total",{count:this.entries?.totalCount??0})}_getSourceLabelText(){if(!this.source?.id)return "";let t=Ke.SOURCE_TEXT_CONFIG[this.source.id]?.action??"get-from",i;return this.source.id===T.MOBILE_PHOTO_CAMERA?i=this.l10n("photo").toLowerCase():this.source.id===T.MOBILE_VIDEO_CAMERA?i=this.l10n("video").toLowerCase():i=this.localizedSourceLabel,this._translate(t,{source:i})}_handleClick(){if(this.hasEntries){this._sharedInstancesBag.ctx.pub("*currentActivity","upload-list"),this._sharedInstancesBag.modalManager?.open("upload-list");return}this.source?.onClick();}_renderThumbnail(){if(!this._isMultiple&&this.hasSingleSuccessImage){let t=this.entries.allEntries[0];return t?html`<uc-thumb .uid=${t.internalId}></uc-thumb>`:null}if(this._isMultiple&&this.hasMultipleEntries)return null;let e=this.source?.icon;return this.showIcon&&e?html`<uc-icon .name=${e}></uc-icon>`:null}render(){return html`<button @click=${this._handleClick} aria-label=${this.textBasedOnLocale}>${this._renderThumbnail()}<span>${this.textBasedOnLocale}</span></button>`}};d([property({type:Object})],Ke.prototype,"source",2),d([property({type:Object})],Ke.prototype,"entries",2),d([state()],Ke.prototype,"showIcon",2),d([state()],Ke.prototype,"_isMultiple",2);var Xr=Ke;var Ni=class extends g{constructor(){super(...arguments);this._id=W.generateFastUid();this._handleContentClick=e=>{e.currentTarget.hidePopover();};}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-down"];}render(){return html`<button class="uc-mini-btn uc-dropdown-btn" popovertarget=${this._id} popovertargetaction="toggle">${this.yield("dd-header-button")}</button><div id=${this._id} class="uc-dropdown-content" popover="auto" @click=${this._handleContentClick}>${this.yield("dd-content")}</div>`}};d([state()],Ni.prototype,"_id",2);var Qr=class extends _{static{this.styleAttrs=[...super.styleAttrs,"uc-no-wrap-mode-smart-btn"];}};var Bl=(o,r)=>r==="compact"||o.length===0?{main:null,remain:o}:{main:o[0]??null,remain:o.slice(1)},Hl={compact:"paperclip",menu:"arrow-dropdown",auto:"arrow-dropdown"},zl=3,ge=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this.dropzone=true;this._mode="auto";this._sources=[];this._status="idle";this._progress=0;this._throttledHandleCollectionUpdate=Re(()=>{this.isConnected&&this._updateButtonBasedOnCollectionState();},300);}static{this.styleAttrs=[...super.styleAttrs,"uc-smart-btn","uc-wgt-common"];}get isIdle(){return this._status==="idle"}get isSuccess(){return this._status==="success"}get isFailed(){return this._status==="failed"}get isUploading(){return this._status==="uploading"}get isCollapsedMode(){return this._mode==="compact"}get shouldShowPrimaryAction(){return !this.isCollapsedMode||!this.isIdle||this.hasCollectionEntries}get shouldShowInline(){return this.isIdle&&!this.hasCollectionEntries&&this._sources.length>1&&(this._mode==="toolbar"||this._mode==="auto"&&this._sources.length<=zl)}get shouldShowDropdown(){return this.isIdle&&!this.shouldShowInline&&!this.hasCollectionEntries&&(this._sources.length>1||this.isCollapsedMode)}get hasCollectionEntries(){return (this._collection?.allEntries?.length??0)>0}get shouldShowAbortAction(){return !this.isIdle&&this.hasCollectionEntries}_updateButtonBasedOnCollectionState(){let e=this.api?.getOutputCollectionState();if(!e){console.warn("Collection state is undefined");return}this._collection=e,this._status=e.status;}_updateSourceSplit(){this._mainAndRemainSources=Bl(this._sources,this._mode);}initCallback(){super.initCallback(),this.subConfigValue("smartButtonViewMode",e=>{this._mode!==e&&(this._mode=e,this._updateSourceSplit());}),this.sub("*commonProgress",e=>{this._progress=e;}),new nt(this,{ctx:this._sharedInstancesBag.ctx,sharedInstancesBag:this._sharedInstancesBag,onSourcesChange:e=>{this._sources=e,this._updateSourceSplit();}}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this._unregisterAfterFileAddHook=this.routerLayer.registerAfterFileAddHook(({historyLength:e})=>{if(e>0)return false;let t=this._sharedInstancesBag.ctx.read("*currentActivity");return t?this.modalManager?.close(t):this.modalManager?.closeAll(),this._sharedInstancesBag.ctx.pub("*currentActivity",null),true});}disconnectedCallback(){typeof this._throttledHandleCollectionUpdate.cancel=="function"&&this._throttledHandleCollectionUpdate.cancel(),this._unregisterAfterFileAddHook?.(),super.disconnectedCallback();}_renderInline(){return html`<uc-no-wrap-mode-smart-btn>${this._mainAndRemainSources?.remain?.map(e=>html`<uc-source-btn .iconOnly=${ true} role="menuitem" .source=${e} ></uc-source-btn>`)}</uc-no-wrap-mode-smart-btn>`}_getDropdownIconName(){return Hl[this._mode]??"arrow-dropdown"}_clearAllEntries(){this.uploadCollection.clearAll();}_clearAllFailedEntries(){this._collection.failedEntries.forEach(e=>{e&&this.uploadCollection.hasItem(e.internalId)&&this.uploadCollection.remove(e.internalId);});}_abortAllEntries(){this.uploadCollection.abortAll();}_handleRemove(){switch(this._status){case "failed":this._clearAllFailedEntries();break;case "uploading":this._abortAllEntries();break;default:this._clearAllEntries();}}_renderDropdown(){return html`<uc-drop-down><uc-icon content-for="dd-header-button" name=${this._getDropdownIconName()} ></uc-icon><div content-for="dd-content" role="menu" class="uc-dropdown-menu">${this._mainAndRemainSources?.remain?.map(e=>html`<uc-source-btn role="menuitem" .source=${e} ></uc-source-btn>`)}</div></uc-drop-down>`}_renderPrimaryAction(){return html`<uc-primary-action .entries=${this._collection} .source=${this._mainAndRemainSources?.main} ></uc-primary-action>`}_renderAbortAction(){return html`<uc-file-action-button @uc:remove=${this._handleRemove} .uploading=${this.isUploading} .failed=${this.isFailed} .success=${this.isSuccess} .idle=${this.isIdle} .progress=${this._progress} ></uc-file-action-button>`}_getInnerClassMap(){return classMap({"uc-smart-btn-inner":true,"uc-failed":this.isFailed,"uc-uploading":this.isUploading,"uc-success":this.isSuccess})}_renderVisualDropArea(){return html`<div class="uc-visual-drop-area"><uc-icon name="arrow-down"></uc-icon></div>`}render(){return html`<uc-drop-area .disabled=${!this.dropzone}><div class=${this._getInnerClassMap()}>${cache(this.shouldShowPrimaryAction?this._renderPrimaryAction():null)} ${cache(this.shouldShowInline?this._renderInline():null)} ${cache(this.shouldShowDropdown?this._renderDropdown():null)} ${cache(this.shouldShowAbortAction||this.hasCollectionEntries?this._renderAbortAction():null)} ${cache(this._renderVisualDropArea())}</div></uc-drop-area>`}};d([property({attribute:"dropzone",type:Boolean})],ge.prototype,"dropzone",2),d([state()],ge.prototype,"_mode",2),d([state()],ge.prototype,"_sources",2),d([state()],ge.prototype,"_status",2),d([state()],ge.prototype,"_mainAndRemainSources",2),d([state()],ge.prototype,"_collection",2),d([state()],ge.prototype,"_progress",2);var Rt=class extends E{constructor(){super(...arguments);this._containerRef=createRef();}initCallback(){this.activityType=this.registration?.id??null,this._ensureRegistered(),super.initCallback();}willUpdate(e){super.willUpdate(e),e.has("registration")&&(this._ensureRegistered(),this.isActivityActive&&(this._disposeActivity(),this._renderActivity()));}_ensureRegistered(){this.registration&&(this._isActivityRegistered()||this.registerActivity(this.activityType??"",{onActivate:()=>this._renderActivity(),onDeactivate:()=>this._disposeActivity()}));}async _renderActivity(){await this.updateComplete;let e=this._containerRef.value;if(!e||!this.registration)return;this._disposeActivity();let t=this.$["*currentActivityParams"];try{this._dispose=this.registration.render(e,t)??void 0;}catch(i){console.error(`[Plugin "${this.registration.pluginId}"] Activity render() threw an error`,i);}}_disposeActivity(){let e=this._containerRef.value;if(e){try{this._dispose?.();}catch(t){console.error(`[Plugin "${this.registration?.pluginId}"] Activity dispose threw an error`,t);}this._dispose=void 0,e.replaceChildren();}}disconnectedCallback(){this._disposeActivity(),super.disconnectedCallback();}render(){return html`<div style="display: contents;" ${ref(this._containerRef)}></div>`}};d([property({attribute:false})],Rt.prototype,"registration",2);var ut=class extends g{constructor(){super(...arguments);this.mode="modal";this._activities=[];}initCallback(){super.initCallback();let e=this._sharedInstancesBag.pluginManager;e?.onPluginsChange&&(this._unsubscribePlugins=e.onPluginsChange(()=>this._syncActivities())),this._syncActivities();}_syncActivities(){let e=this._sharedInstancesBag.pluginManager;if(!e){this._activities=[];return}this._activities=e.snapshot().activities;}disconnectedCallback(){this._unsubscribePlugins?.(),this._unsubscribePlugins=void 0,super.disconnectedCallback();}render(){return this.mode==="inline"?html`${repeat(this._activities,e=>e.id,e=>html`<uc-plugin-activity-host .registration=${e}></uc-plugin-activity-host>`)}`:html`${repeat(this._activities,e=>e.id,e=>html`<uc-modal id=${e.id} strokes block-body-scrolling><uc-plugin-activity-host .registration=${e}></uc-plugin-activity-host></uc-modal>`)}`}};d([property({type:String})],ut.prototype,"mode",2),d([state()],ut.prototype,"_activities",2);function Ws(...o){return o.reduce((r,e)=>{if(typeof e=="string")return r[e]=true,r;for(let t of Object.keys(e))r[t]=e[t];return r},{})}function se(...o){let r=Ws(...o);return Object.keys(r).reduce((e,t)=>(r[t]&&e.push(t),e),[]).join(" ")}function qs(o,...r){let e=Ws(...r);for(let t of Object.keys(e))o.classList.toggle(t,!!e[t]);}var Wl=o=>Z.includes(o),Zs=o=>{if(!o)return Z;let r=V(o).filter(Wl);return r.length===0?Z:r};function Ys(o){return {"*originalUrl":null,"*loadingOperations":new Map,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":false,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":Z,"*tabId":O.CROP,"*on.retryNetwork":()=>{let r=o.querySelectorAll("img");for(let e of r){let t=e.src;e.src=de,e.src=t;}o.$["*networkProblems"]=false;},"*on.apply":r=>{if(!r)return;let e=o.$["*originalUrl"];if(!e){console.warn("Original URL is null, cannot apply transformations");return}let t=q(ke(r),"preview"),i=F(e,t),s={originalUrl:e,cdnUrlModifiers:t,cdnUrl:i,transformations:r};o.dispatchEvent(new CustomEvent("apply",{detail:s,bubbles:true,composed:true})),o.remove();},"*on.cancel":()=>{o.remove(),o.dispatchEvent(new CustomEvent("cancel",{bubbles:true,composed:true}));}}}var Xs="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 24 24' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path d='M19.248 9.561 12 16.003 4.752 9.561l.996-1.122L12 13.995l6.252-5.556z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='ruc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#ruc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#uuc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#uuc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#uuc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#uuc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#uuc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#uuc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#uuc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='uuc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>";var je={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},pt=class extends g{constructor(){super(...arguments);this._visible=false;this._styles=je;this._visibleStyle=je.visible;this._hiddenStyle=je.hidden;this._externalTransitions=false;this._initialRenderComplete=false;}set visible(e){this._visible=e,this._handleVisible();}get visible(){return this._visible}set styles(e){this._styles=e,this._externalTransitions=true,this._visibleStyle=e.visible??je.visible,this._hiddenStyle=e.hidden??je.hidden;}get styles(){return this._styles}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",qs(this,{[je.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.toggleAttribute("inert",!this._visible);}_dispatchInitialRenderEvent(){this._initialRenderComplete||(this._initialRenderComplete=true,this.dispatchEvent(new CustomEvent("initial-render",{bubbles:true,composed:true})));}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",true),this._externalTransitions||this.classList.add(je.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",false),this._dispatchInitialRenderEvent();},0);}};d([property({type:Boolean})],pt.prototype,"visible",1),d([property({attribute:false})],pt.prototype,"styles",1);var Ut=class extends g{constructor(){super(...arguments);this.active=false;this._lineRef=createRef();this._isAnimating=false;this._handleTransitionEndRight=()=>{let e=this._lineRef.value;e&&(this._resetLine(e),this._isAnimating&&this.active&&this._start());};}firstUpdated(e){super.firstUpdated(e),this.active&&this._start();}updated(e){super.updated(e),e.has("active")&&(this.active?this._start():this._stop());}_start(){let e=this._lineRef.value;if(!e)return;this._isAnimating=true;let{width:t}=this.getBoundingClientRect();e.removeEventListener("transitionend",this._handleTransitionEndRight),e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:true});}_stop(){let e=this._lineRef.value;e&&(this._isAnimating=false,e.removeEventListener("transitionend",this._handleTransitionEndRight),this._resetLine(e));}_resetLine(e){e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)";}render(){return html`<div class="uc-inner"><div class="uc-line" ${ref(this._lineRef)}></div></div>`}};d([property({type:Boolean,reflect:true})],Ut.prototype,"active",2);var le=class extends g{constructor(){super(...arguments);this.text="";this.icon="";this.reverse=false;this.theme="default";this.ariaRole=void 0;this.ariaControls="";this.titleProp="";this.active=false;}firstUpdated(e){super.firstUpdated(e),this._applyReverse(),this._applyThemeClass();}updated(e){super.updated(e),e.has("reverse")&&this._applyReverse(),e.has("theme")&&this._applyThemeClass();}_applyReverse(){this.style.flexDirection=this.reverse?"row-reverse":"";}_applyThemeClass(){this.theme&&this.theme!=="custom"&&(this.className=`uc-${this.theme}`);}get _iconClassMap(){let e=this._computedIconHidden;return {"uc-icon":true,"uc-icon_left":!this.reverse,"uc-icon_right":this.reverse,"uc-icon_hidden":e,"uc-icon_single":this._computedIconSingle}}get _computedIconHidden(){return !this.icon}get _computedIconSingle(){return !this.text&&!this._computedIconHidden}render(){return html`<button type="button" role=${ifDefined(this.ariaRole||void 0)} aria-controls=${ifDefined(this.ariaControls||void 0)} aria-label=${ifDefined(this.l10n(this.titleProp))} title=${ifDefined(this.l10n(this.titleProp))} ><uc-icon class=${classMap(this._iconClassMap)} name=${ifDefined(this.icon||void 0)} ?hidden=${this._computedIconHidden} ></uc-icon><div class="uc-text">${this.text}</div></button>`}};d([property({type:String})],le.prototype,"text",2),d([property({type:String})],le.prototype,"icon",2),d([property({type:Boolean,reflect:true})],le.prototype,"reverse",2),d([property({type:String,reflect:true})],le.prototype,"theme",2),d([property({attribute:"aria-role"})],le.prototype,"ariaRole",2),d([property({attribute:"aria-controls"})],le.prototype,"ariaControls",2),d([property({attribute:"title-prop"})],le.prototype,"titleProp",2),d([property({type:Boolean,noAccessor:true})],le.prototype,"active",2);function Js(o,r){let e={};for(let t of r){let i=o[t];(Object.hasOwn(o,t)||i!==void 0)&&(e[t]=i);}return e}function ht(o,r,e){let i=window.devicePixelRatio,s=Math.min(Math.ceil(r*i),3e3),n=i>=2?"lightest":"normal";return F(o,q(ti,ke(e),`quality/${n}`,`stretch/off/-/resize/${s}x`,`@clib/${pe}/${he}/uc-cloud-image-editor/`))}var $t=class extends g{constructor(){super(...arguments);this._backdropMaskId=`uc-backdrop-mask-${W.generateFastUid()}`;this._guidesHidden=false;this._draggingValue=false;this._svgRef=createRef();this._svgReady=false;this._pendingMaskHref=null;this._handlePointerUp=e=>{this._updateCursor(),this._dragging&&(e.stopPropagation(),e.preventDefault(),this._dragging=false);};this._handlePointerMove=e=>{if(!this._dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this._svgElement;if(!t)return;let{x:i,y:s}=t.getBoundingClientRect(),n=e.x-i,a=e.y-s,l=n-this._dragStartPoint[0],c=a-this._dragStartPoint[1],{direction:u}=this._draggingThumb,p=this._calcCropBox(u,[l,c]);p&&(this.$["*cropBox"]=p);};this._handleSvgPointerMove=e=>{if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(i=>{if(!i||this._shouldThumbBeDisabled(i.direction))return false;let n=i.interactionNode.getBoundingClientRect(),a={x:n.x,y:n.y,width:n.width,height:n.height};return ns(a,[e.x,e.y])});this._hoverThumb=t,this._updateCursor();};}get _svgElement(){return this._svgRef.value??null}get _dragging(){return this._draggingValue}set _dragging(e){this._draggingValue!==e&&(this._draggingValue=e,this._applyGuidesDragState());}_applyGuidesDragState(){this._frameGuides&&this._frameGuides.setAttribute("class",se({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&this._draggingValue,"uc-guides--semi-hidden":!this._guidesHidden&&!this._draggingValue}));}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return false;if(e===""&&t.height<=y&&t.width<=y)return true;let i=t.height<=y&&(e.includes("n")||e.includes("s")),s=t.width<=y&&(e.includes("e")||e.includes("w"));return i||s}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:s,height:n}=e,a=this._svgElement;if(!a)return;let l=re("mask",{id:this._backdropMaskId}),c=re("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),u=re("rect",{x:t,y:i,width:s,height:n,fill:"black"});l.appendChild(c),l.appendChild(u);let p=re("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:`url(#${this._backdropMaskId})`});a.appendChild(p),a.appendChild(l),this._backdropMask=l,this._backdropMaskInner=u;}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block");}));}_updateBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:s,height:n}=e;this._backdropMaskInner&&Me(this._backdropMaskInner,{x:t,y:i,width:s,height:n});}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:i,pathNode:s,interactionNode:n,groupNode:a}=t,l=i==="",c=i.length===2,{x:u,y:p,width:m,height:h}=e;if(l)Me(n,{x:u,y:p,width:m,height:h});else {let P=Pe(Math.min(m,h)/82/2,0,1),w=c?ts(e,i,P):is(e,i,P),L=w.center;if(!L)continue;let G=Math.max(Tr*Pe(Math.min(m,h)/Tr/3,0,1),es);Me(n,{x:L[0]-G,y:L[1]-G,width:G*2,height:G*2}),Me(s,{d:w.d});}let f=this._shouldThumbBeDisabled(i);a.setAttribute("class",se("uc-thumb",{"uc-thumb--hidden":f,"uc-thumb--visible":!f}));}Me(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1});}}_createThumb(e,t){let i=re("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let s=re("rect",{fill:"transparent"}),n=re("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(n),i.appendChild(s),e[t]={direction:t,pathNode:n,interactionNode:s,groupNode:i},t===""&&(i.style.cursor="move"),s.addEventListener("pointerdown",this._handlePointerDown.bind(this,t));}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let i=0;i<3;i++){let s=`${["n","","s"][t]}${["w","","e"][i]}`;s!==""&&this._createThumb(e,s);}return this._createThumb(e,""),e}_createGuides(){let e=re("svg"),t=re("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let i=1;i<=2;i++){let s=re("line",{x1:`${xt*i}%`,y1:"0%",x2:`${xt*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s);}for(let i=1;i<=2;i++){let s=re("line",{x1:"0%",y1:`${xt*i}%`,x2:"100%",y2:`${xt*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s);}return e.classList.add("uc-guides","uc-guides--semi-hidden"),e}_createFrame(){let e=this._svgElement;if(!e)return;let t=document.createDocumentFragment(),i=this._createGuides();t.appendChild(i);let s=this._createThumbs();for(let{groupNode:n}of Object.values(s))t.appendChild(n);e.appendChild(t),this._frameThumbs=s,this._frameGuides=i,this._applyGuidesDragState();}_handlePointerDown(e,t){if(!this._frameThumbs)return;let i=this._frameThumbs[e];if(!i||this._shouldThumbBeDisabled(e))return;let s=this.$["*cropBox"],n=this._svgElement;if(!n)return;let{x:a,y:l}=n.getBoundingClientRect(),c=t.x-a,u=t.y-l;this._dragging=true,this._draggingThumb=i,this._dragStartPoint=[c,u],this._dragStartCrop={...s};}_calcCropBox(e,t){let[i,s]=t,n=this.$["*imageBox"],a=this._dragStartCrop??this.$["*cropBox"],l=this.$["*currentAspectRatio"],c=l?l.width/l.height:void 0;if(e===""?a=os({rect:a,delta:[i,s],imageBox:n}):a=ss({rect:a,delta:[i,s],direction:e,aspectRatio:c,imageBox:n}),!Object.values(a).every(u=>Number.isFinite(u)&&u>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:a});return}return Je(tt(a),n)}_updateCursor(){let e=this._hoverThumb,t=this._svgElement;t&&(t.style.cursor=e?rs(e.direction):"initial");}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this._svgElement;if(!t){this._pendingMaskHref=e;return}this._pendingMaskHref=null;let i=document.createDocumentFragment(),s=re("image",{href:e});s.setAttribute("class","uc-cloud-mask"),i.appendChild(s),t.appendChild(i),this._frameImage=s;}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:i,width:s,height:n}=e;Me(this._frameImage,{x:t,y:i,height:n,width:s});}_render(){this._svgReady&&(this._updateBackdrop(),this._updateFrame(),this._updateMask());}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:i}=t;i.setAttribute("class",se("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}));}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._resizeBackdrop(),this._svgReady&&window.requestAnimationFrame(()=>{this._render();});}),this.sub("*cropBox",e=>{e&&(this._guidesHidden=e.height<=y||e.width<=y,this._applyGuidesDragState(),this._svgReady&&window.requestAnimationFrame(()=>{this._render();}));}),this.subConfigValue("cloudImageEditorMaskHref",e=>{e&&this._createMask(e);}),document.addEventListener("pointermove",this._handlePointerMove,true),document.addEventListener("pointerup",this._handlePointerUp,true);}firstUpdated(e){super.firstUpdated(e),this._initializeSvg();}_initializeSvg(){let e=this._svgElement;if(!(!e||this._svgReady)){if(this._createBackdrop(),this._createFrame(),this._svgReady=true,e.addEventListener("pointermove",this._handleSvgPointerMove,true),this._pendingMaskHref){let t=this._pendingMaskHref;this._pendingMaskHref=null,this._createMask(t);}this._render();}}disconnectedCallback(){super.disconnectedCallback(),this._svgElement?.removeEventListener("pointermove",this._handleSvgPointerMove,true),document.removeEventListener("pointermove",this._handlePointerMove,true),document.removeEventListener("pointerup",this._handlePointerUp,true);}render(){return html`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${ref(this._svgRef)}></svg>`}};d([state()],$t.prototype,"_draggingValue",2);function ac(o){return o?[({dimensions:e,coords:t})=>[...e,...t].every(i=>Number.isInteger(i)&&Number.isFinite(i)),({dimensions:e,coords:t})=>e.every(i=>i>0)&&t.every(i=>i>=0)].every(e=>e(o)):true}var Dt=class extends g{constructor(){super();this.ctxOwner=true;this._imageSize={width:0,height:0};this._ctx=null;this._isActive=false;this._image=null;this._canvasRef=createRef();this._frameRef=createRef();this.init$={...this.init$,"*padding":20,"*operations":{rotate:0,mirror:false,flip:false},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=S(this._commit.bind(this),300),this._handleResizeThrottled=Re(()=>{!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw());},100);}firstUpdated(e){super.firstUpdated(e),this._initCanvas();}_syncTransformations(){let e=this.$["*editorTransformations"],t=Js(e,Object.keys(this.$["*operations"])),i={...this.$["*operations"],...t};this.$["*operations"]=i;}_initCanvas(){let e=this._canvasRef.value;if(!e)return;let t=e.getContext("2d"),i=this.offsetWidth,s=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${i}px`,e.style.height=`${s}px`,e.width=i*n,e.height=s*n,t?.scale(n,n),this._canvas=e,this._ctx=t;}_alignImage(){if(!this._isActive||!this._image)return;let e=this._image,t=this.$["*padding"],i=this.$["*operations"],{rotate:s}=i,n={width:this.offsetWidth,height:this.offsetHeight},a=et({width:e.naturalWidth,height:e.naturalHeight},s),l;if(a.width>n.width-t*2||a.height>n.height-t*2){let c=a.width/a.height,u=n.width/n.height;if(c>u){let p=n.width-t*2,m=p/c,h=0+t,f=t+(n.height-t*2)/2-m/2;l={x:h,y:f,width:p,height:m};}else {let p=n.height-t*2,m=p*c,h=t+(n.width-t*2)/2-m/2,f=0+t;l={x:h,y:f,width:m,height:p};}}else {let{width:c,height:u}=a,p=t+(n.width-t*2)/2-c/2,m=t+(n.height-t*2)/2-u/2;l={x:p,y:m,width:c,height:u};}this.$["*imageBox"]=tt(l);}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:s}=i,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=t;if(n){let{dimensions:[m,h],coords:[f,P]}=n,{width:w}=et(this._imageSize,s),L=a/w;e=Je(tt({x:l+f*L,y:c+P*L,width:m*L,height:h*L}),t);}let u=this.$["*currentAspectRatio"],p=u?u.width/u.height:void 0;if(!as(e,t)||p&&!ls(e,p)){let m=t.width/t.height,h=t.width,f=t.height;p&&(m>p?h=Math.min(t.height*p,t.width):f=Math.min(t.width/p,t.height)),e={x:t.x+t.width/2-h/2,y:t.y+t.height/2-f/2,width:h,height:f};}this.$["*cropBox"]=Je(tt(e),t);}_drawImage(){let e=this._ctx;if(!e)return;let t=this._image;if(!t)return;let i=this.$["*imageBox"],s=this.$["*operations"],{mirror:n,flip:a,rotate:l}=s,c=et({width:i.width,height:i.height},l);e.save(),e.translate(i.x+i.width/2,i.y+i.height/2),e.rotate(l*Math.PI*-1/180),e.scale(n?-1:1,a?-1:1),e.drawImage(t,-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._frameRef.value?.toggleThumbs(true),this._transitionToImage(),setTimeout(()=>{this.className=se({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":false});}));}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:s}=i,{width:n,height:a}=t,{width:l,height:c}=et(this._imageSize,s),{width:u,height:p}=e,m=n/l,h=a/c;return [Pe(Math.round(u/m),1,l),Pe(Math.round(p/h),1,c)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:s}=i,{width:n,height:a,x:l,y:c}=t,{width:u,height:p}=et(this._imageSize,s),{x:m,y:h}=e,f=n/u,P=a/p,w=this._getCropDimensions(),L={dimensions:w,coords:[Pe(Math.round((m-l)/f),0,u-w[0]),Pe(Math.round((h-c)/P),0,p-w[1])]};if(!ac(L)){console.error("Cropper is trying to create invalid crop object",{payload:L});return}if(!(w[0]===u&&w[1]===p))return L}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:i,flip:s}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:t,mirror:i,flip:s};this.$["*editorTransformations"]=l;}setValue(e,t){this.$["*operations"]={...this.$["*operations"],[e]:t},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw());}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:t}={}){if(!this._isActive){this._isActive=true,await this.updateComplete,this._initCanvas(),this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{let i=this.$["*originalUrl"],s=this.$["*editorTransformations"];this._image=await this._waitForImage(i,s),this._syncTransformations(),this._handleResizeThrottled(),this._animateIn({fromViewer:t});}catch(i){console.error("Failed to activate cropper",{error:i}),this.telemetryManager.sendEventError(i,"cloud editor image. Failed to activate cropper");}this._observer=new ResizeObserver(i=>{let[s]=i;if(!s)return;s.contentRect.width>0&&s.contentRect.height>0&&this._isActive&&this._image&&this._handleResizeThrottled();}),this._observer.observe(this);}}deactivate({reset:e=false}={}){this._isActive&&(!e&&this._commit(),this._isActive=false,this._transitionToCrop(),this.className=se({"uc-active_from_viewer":false,"uc-active_from_editor":false,"uc-inactive_to_editor":true}),this._frameRef.value?.toggleThumbs(false),this.addEventListener("transitionend",this._reset,{once:true}),this._observer?.disconnect());}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],i=Math.min(this.offsetWidth,e[0])/t.width,s=Math.min(this.offsetHeight,e[1])/t.height,n=Math.min(i,s),a=t.x+t.width/2,l=t.y+t.height/2;this.style.transform=`scale(${n}) translate(${(this.offsetWidth/2-a)/n}px, ${(this.offsetHeight/2-l)/n}px)`,this.style.transformOrigin=`${a}px ${l}px`;}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,i=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${i}px`;}_reset(){this._isActive||(this._image=null);}async _waitForImage(e,t){let i=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let s=await this.proxyUrl(ht(e,i,t)),{promise:n,cancel:a,image:l}=He(s),c=this._handleImageLoading(s);return l.addEventListener("load",c,{once:true}),l.addEventListener("error",c,{once:true}),this._cancelPreload?.(),this._cancelPreload=a,n.then(()=>l).catch(u=>(console.error("Failed to load image",{error:u}),this.$["*networkProblems"]=true,l))}_handleImageLoading(e){let t="crop",i=this.$["*loadingOperations"],s=i.get(t);return s||(s=new Map,i.set(t,s)),s.get(e)||(s.set(e,true),this.$["*loadingOperations"]=i),()=>{let n=i.get(t);n?.has(e)&&(n.delete(e),this.$["*loadingOperations"]=i);}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw();}),this.sub("*cropBox",()=>{this._image&&this._commitDebounced();}),this.sub("*currentAspectRatio",()=>{this._alignCrop();}),setTimeout(()=>{this.sub("*networkProblems",e=>{e||this._isActive&&this._imageSize&&this.activate(this._imageSize,{fromViewer:false});});},0);}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._image&&(this._image=null);}render(){return html`<canvas class="uc-canvas" ${ref(this._canvasRef)}></canvas><uc-crop-frame ${ref(this._frameRef)}></uc-crop-frame>`}};d([state()],Dt.prototype,"_image",2);function Jr(o,r,e){let t=e,i=e-1,s=new Array(t);for(let n=i;n>=0;n-=1)s[n]=Math.ceil((n*r+(i-n)*o)/i);return s}function cc(o){return typeof o=="string"&&o in ce}function dc(o){let r=[];for(let e=0;e<o.length-1;e+=1){let t=o[e],i=o[e+1];typeof t=="number"&&typeof i=="number"&&r.push([t,i]);}return r}function uc(o,r,e){let t=dc(o).find(([n,a])=>n<=r&&r<=a);if(!t)return o.map(()=>0);let[i,s]=t;return o.map(n=>{let a=Math.abs(i-s)||1,l=Math.abs(r-i)/a;return i===n?r>e?1:1-l:s===n?r>=e?l:1:0})}function pc(o,r){return o.map((e,t)=>e<r?o.length-t:t)}function sn(o,r){let e=ce[o].keypointsNumber,{range:t,zero:i}=ce[o];return [...new Set([...Jr(t[0],i,e+1),...Jr(i,t[1],e+1),i,r])].sort((s,n)=>s-n)}var Bi=class extends g{constructor(){super();this._isActive=false;this._hidden=true;this._operation="initial";this._transformations={};this._keypoints=[];this._raf=0;this._previewHostRef=createRef();this._layersHostRef=createRef();this.classList.add("uc-inactive_to_cropper"),this._addKeypointDebounced=S(async(e,t,i)=>{let s=()=>!this._isSame(e,t)||this._value!==i||!!this._keypoints.find(c=>c.value===i);if(s())return;let n=await this._constructKeypoint(e,i),a=new Image;a.src=n.src;let l=this._handleImageLoading(n.src);a.addEventListener("load",l,{once:true}),a.addEventListener("error",l,{once:true}),n.image=a,a.classList.add("uc-fader-image"),a.addEventListener("load",()=>{if(s())return;let c=this._keypoints,u=c.findIndex(f=>f.value>i);u===-1&&(u=c.length);let m=c[u]?.image,h=this._layersHostRef.value;!h||m&&!h.contains(m)||(c.splice(u,0,n),m?h.insertBefore(a,m):h.appendChild(a),this._update(e,i));},{once:true}),a.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});},600);}_handleImageLoading(e){let t=this._operation,i=this.$["*loadingOperations"];i.has(t)||i.set(t,new Map);let s=i.get(t);return s&&!s.get(e)&&(s.set(e,true),this.$["*loadingOperations"]=i),()=>{let n=i.get(t);n?.has(e)&&(n.delete(e),this.$["*loadingOperations"]=i);}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let e of this._keypoints){let{image:t}=e;t&&(t.style.opacity=e.opacity.toString(),t.style.zIndex=e.zIndex.toString());}});}_imageSrc({url:e=this._url,filter:t=this._filter??void 0,operation:i,value:s}={}){if(!e)throw new Error("URL is not defined");let n={...this._transformations};i&&(i==="filter"?t&&typeof s=="number"&&(n.filter={name:t,amount:s}):typeof s=="number"&&(n[i]=s));let a=this.offsetWidth;return this.proxyUrl(ht(e,a,n))}async _constructKeypoint(e,t){return {src:await this._imageSrc({operation:e,value:t}),image:void 0,opacity:0,zIndex:0,value:t}}_isSame(e,t){return this._operation===e&&this._filter===t}set(e){let t=typeof e=="string"?parseInt(e,10):e;!cc(this._operation)||!Number.isFinite(t)||(this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t));}_update(e,t){this._operation=e,this._value=t;let{zero:i}=ce[e],s=this._keypoints.map(l=>l.value),n=uc(s,t,i),a=pc(s,i);this._keypoints.forEach((l,c)=>{let u=n[c],p=a[c];typeof u=="number"&&(l.opacity=u),typeof p=="number"&&(l.zIndex=p);}),this._flush();}_createPreviewImage(){let e=new Image;return e.classList.add("uc-fader-image","uc-fader-image--preview"),e.style.opacity="0",e}async _initNodes(){this._previewImage=this._previewImage||this._createPreviewImage();let e=this._previewImage;e&&this._ensurePreviewAttached(e);let t=this._keypoints.map(c=>c.src),{images:i,promise:s,cancel:n}=Mt(t);i.forEach(c=>{let u=this._handleImageLoading(c.src);c.addEventListener("load",u),c.addEventListener("error",u);}),this._cancelLastImages=()=>{n(),this._cancelLastImages=void 0;};let a=this._operation,l=this._filter;if(await s,this._isActive&&this._isSame(a,l)){let c=this._layersHostRef.value;if(!c)return;c.replaceChildren(),this._keypoints.forEach((u,p)=>{let m=i[p];m&&(m.classList.add("uc-fader-image"),u.image=m,c.appendChild(m));}),this._flush();}}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),i=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",i,{once:true}),this._previewImage.addEventListener("error",i,{once:true}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}}async preload({url:e,filter:t,operation:i,value:s}){if(!i||typeof s!="number")return;this._cancelBatchPreload?.();let n=sn(i,s),a=await Promise.all(n.map(c=>this._imageSrc({url:e,filter:t,operation:i,value:c}))),{cancel:l}=Mt(a);this._cancelBatchPreload=l;}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this._ensurePreviewAttached(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=se({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":false});return}t.style.opacity="0";let i=this._handleImageLoading(e);t.addEventListener("error",i,{once:true}),t.src=e,t.addEventListener("load",()=>{i(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=se({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":false}));},{once:true}),t.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}async activate({url:e,operation:t,value:i,filter:s,fromViewer:n}){if(this._isActive=true,this._hidden=false,await this.updateComplete,this._url=e,this._operation=t??"initial",this._value=i,this._filter=s,this._fromViewer=n,typeof i!="number"&&!s){let l=await this._imageSrc({operation:t,value:i});this._setOriginalSrc(l),this._clearLayersHost();return}!t||typeof i!="number"||(this._keypoints=await Promise.all(sn(t,i).map(l=>this._constructKeypoint(t,l))),this._update(t,i),this._initNodes());}deactivate({hide:e=true}={}){this._isActive=false,this._cancelLastImages?.(),this._cancelBatchPreload?.(),e&&!this._hidden?(this._hidden=true,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=se({"uc-active_from_viewer":false,"uc-active_from_cropper":false,"uc-inactive_to_cropper":true}),this.addEventListener("transitionend",()=>{this._clearLayersHost();},{once:true})):this._clearLayersHost();}_ensurePreviewAttached(e){let t=this._previewHostRef.value;t&&(t.contains(e)||t.appendChild(e));}_clearLayersHost(){this._layersHostRef.value?.replaceChildren();}render(){return html`<div class="uc-fader-preview-host" ${ref(this._previewHostRef)}></div><div class="uc-fader-layers-host" ${ref(this._layersHostRef)}></div>`}};var ve=class extends g{constructor(){super();this._thumbSize=0;this._inputRef=createRef();this._thumbRef=createRef();this._stepsRef=createRef();this.disabled=false;this.min=0;this.max=100;this.defaultValue=0;this.zero=0;this._currentValue=0;this._handleSliderInput=e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this._emitSliderEvent("slider-input",t));};this._handleSliderChange=e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&this._setCurrentValue(t);};this._handleInputFocus=()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)");};this._handleInputBlur=()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)");};this.setAttribute("with-effects","");}_emitSliderEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:{value:t},bubbles:true,composed:true}));}firstUpdated(e){super.firstUpdated(e),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10)||0,this._syncInputValue(this._currentValue),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps(),this._updateValue(this._currentValue);}),this._observer.observe(this);let t=this._inputRef.value;t?.addEventListener("focus",this._handleInputFocus),t?.addEventListener("blur",this._handleInputBlur),window.setTimeout(()=>{this._updateValue(this._currentValue);},0);}willUpdate(e){super.willUpdate(e),e.has("defaultValue")&&this.defaultValue!==this._currentValue&&this._setCurrentValue(this.defaultValue),(e.has("min")||e.has("max"))&&this.hasUpdated&&(this._updateSteps(),this._updateValue(this._currentValue)),e.has("zero")&&this.hasUpdated&&this._updateZeroDot(this._currentValue);}_updateValue(e){this._updateZeroDot(e);let t=this.max-this.min;if(t===0)return;let{width:i}=this.getBoundingClientRect(),a=100/t*(e-this.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{let l=this._thumbRef.value;l&&(l.style.transform=`translateX(${a}px)`);});}_updateZeroDot(e){if(!this._zeroDotEl)return;let t=this.max-this.min;if(t===0)return;this._zeroDotEl.style.opacity=e===this.zero?"0":"1";let{width:i}=this.getBoundingClientRect(),a=100/t*(this.zero-this.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${a}px)`);});}_updateSteps(){let t=this._stepsRef.value;if(!t)return;let{width:i}=t.getBoundingClientRect(),s=Math.ceil(i/2),n=Math.ceil(s/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 p=0;p<n;p+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let p=0;p<n;p+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let u=document.createElement("div");u.className="uc-zero-dot",a.appendChild(u),this._zeroDotEl=u,t.innerHTML="",t.appendChild(a),this._stepsCount=n;}disconnectedCallback(){super.disconnectedCallback();let e=this._inputRef.value;e?.removeEventListener("focus",this._handleInputFocus),e?.removeEventListener("blur",this._handleInputBlur),this._observer?.disconnect(),this._observer=void 0;}_setCurrentValue(e){Number.isFinite(e)&&(this._currentValue=e,this.hasUpdated&&(this._syncInputValue(e),this._updateValue(e)));}_syncInputValue(e){let t=this._inputRef.value;t&&(t.value=String(e));}_extractEventValue(e){let t=e.currentTarget;if(!t)return null;let i=Number.parseInt(t.value,10);return Number.isFinite(i)?i:null}render(){return html`<div class="uc-steps" ${ref(this._stepsRef)}></div><div class="uc-thumb" ${ref(this._thumbRef)}></div><input class="uc-input" type="range" ${ref(this._inputRef)} .min=${String(this.min)} .max=${String(this.max)} .value=${String(this._currentValue)} ?disabled=${this.disabled} @input=${this._handleSliderInput} @change=${this._handleSliderChange} />`}};d([property({type:Boolean,reflect:true})],ve.prototype,"disabled",2),d([property({type:Number})],ve.prototype,"min",2),d([property({type:Number})],ve.prototype,"max",2),d([property({type:Number,attribute:false})],ve.prototype,"defaultValue",2),d([property({type:Number})],ve.prototype,"zero",2),d([state()],ve.prototype,"_currentValue",2);var be="original",Nt=class extends g{constructor(){super(...arguments);this.state={operation:"filter",filter:void 0,originalUrl:"",disabled:false,min:0,max:100,value:0,defaultValue:0,zero:0};this._handleInput=e=>{let{value:t}=e.detail;this.$["*faderEl"]?.set(t),this.state={...this.state,value:t};};}setOperation(e,t){this.state={...this.state,operation:e,filter:t},this._initializeValues();let i=this.$["*faderEl"],s=this.state.originalUrl||this.$["*originalUrl"];i&&s&&i.activate({url:s,operation:this.state.operation,value:this.state.filter===be?void 0:this.state.value,filter:this.state.filter===be?void 0:this.state.filter,fromViewer:false});}_initializeValues(){let e=this.state.operation,{range:t,zero:i}=ce[e],[s,n]=t;this.state={...this.state,min:s,max:n,zero:i};let l=this.$["*editorTransformations"][e];if(e==="filter"){let u=Number(n),p=l;if(p){let{name:m,amount:h}=p;u=m===this.state.filter?h:n;}this.state={...this.state,value:u,defaultValue:u};return}let c=typeof l<"u"?l:i;this.state={...this.state,value:c,defaultValue:c};}apply(){let t={...this.$["*editorTransformations"]};this.state.operation==="filter"?!this.state.filter||this.state.filter===be?delete t.filter:t.filter={name:this.state.filter,amount:this.state.value}:t[this.state.operation]=this.state.value,this.$["*editorTransformations"]=t;}cancel(){this.$["*faderEl"]?.deactivate({hide:false});}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{e&&(this.state={...this.state,originalUrl:e});});}updated(e){if(super.updated(e),e.has("state")){let t=`${this.state.filter??this.state.operation} ${this.state.value}`;this.$["*operationTooltip"]=t;}}render(){return html`<uc-slider-ui .disabled=${this.state.disabled} .min=${this.state.min} .max=${this.state.max} .defaultValue=${this.state.defaultValue} .zero=${this.state.zero} @slider-input=${this._handleInput} ></uc-slider-ui>`}};d([state()],Nt.prototype,"state",2);function mt(o){if(!o)return null;let r=o.match(/^([A-Za-z]+)\s+(\d+)$/);if(!r)return null;let[,e,t]=r;return !e||typeof t>"u"?null:{filter:e,value:Number(t)}}var X=class extends g{constructor(){super(...arguments);this.active=false;this.title="";this.icon="";this.titleProp="";}get buttonClasses(){let e=this.active;return {"uc-active":e,"uc-not_active":!e}}_updateHostStateClasses(){let e=this.buttonClasses;for(let[t,i]of Object.entries(e))this.classList.toggle(t,i);}onClick(e){}connectedCallback(){super.connectedCallback(),this._updateHostStateClasses();}updated(e){super.updated(e),e.has("active")&&this._updateHostStateClasses();}render(){let e=this.onClick,t=this.title;return html`<button role="option" type="button" aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${e} ><uc-icon name=${this.icon}></uc-icon><div class="uc-title" ?hidden=${!t}>${t}</div></button>`}};d([state()],X.prototype,"active",2),d([state()],X.prototype,"title",2),d([state()],X.prototype,"icon",2),d([state()],X.prototype,"titleProp",2);var zi=12,Ki=16,yc=o=>{let r=12,e=12;return o.width/o.height>=1?(r=zi,e=Math.round(zi*o.height/o.width)):(e=zi,r=Math.round(zi*o.width/o.height)),{width:r,height:e}},Wi=class extends X{initCallback(){super.initCallback(),this.icon="arrow-dropdown",this.sub("*currentAspectRatio",r=>{let e=this._computeTitle(r);this.title=e,this.titleProp=e;});}onClick(){this.$["*showListAspectRatio"]=true;}_computeTitle(r){return r?r.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${r.width}:${r.height}`}):""}render(){let r=this.onClick,e=this.title;return html`<button role="option" type="button" class=${classMap(this.buttonClasses)} aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${r} ><div class="uc-title" ?hidden=${!e}>${e}</div><uc-icon name=${this.icon}></uc-icon></button>`}},Bt=class extends X{constructor(){super(...arguments);this._aspectRatio=null;}get aspectRatio(){return this._aspectRatio}set aspectRatio(e){if(this._aspectRatio===e)return;let t=this._aspectRatio;this._aspectRatio=e,this.requestUpdate("aspectRatio",t),e?this._updateAspectRatioPresentation(e):(this.removeAttribute("uc-aspect-ratio-freeform"),this.title="",this.titleProp="");}initCallback(){super.initCallback(),this._aspectRatio&&this._updateAspectRatioPresentation(this._aspectRatio),this.sub("*currentAspectRatio",e=>{this.active=e&&e.id===this._aspectRatio?.id||e?.width===this._aspectRatio?.width&&e?.height===this._aspectRatio?.height;});}onClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio);}_updateAspectRatioPresentation(e){if(!this.isConnected)return;let t=!!e.hasFreeform;this.toggleAttribute("uc-aspect-ratio-freeform",t);let i=()=>{let n=t?this.l10n("custom"):`${e.width}:${e.height}`;return this.title=n,n},s=()=>{let n=this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:t?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}).toLowerCase(),value:""});return this.titleProp=n,n};i(),s(),t||this.requestUpdate();}_renderIcon(){let e=this._aspectRatio;if(!e||e.hasFreeform)return html`<uc-icon name=${this.icon}></uc-icon>`;let{width:t,height:i}=yc(e),s=(Ki-t)/2,n=(Ki-i)/2;return html`<uc-icon><svg viewBox="0 0 ${Ki} ${Ki}" aria-hidden="true" focusable="false" ><rect x=${s} y=${n} width=${t} height=${i} rx="2" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" ></rect></svg></uc-icon>`}render(){let e=this.onClick,t=this.title;return html`<button role="option" type="button" class=${classMap(this.buttonClasses)} aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${e} >${this._renderIcon()}<div class="uc-title" ?hidden=${!t}>${t}</div></button>`}};d([property({attribute:false})],Bt.prototype,"aspectRatio",1);function Cc(o){let r=o+90;return r=r>=360?0:r,r}function wc(o,r){if(o==="rotate")return Cc(typeof r=="number"?r:0);if(o==="mirror"||o==="flip")return !r;throw new Error(`Unsupported operation: ${o}`)}var Ht=class extends X{constructor(){super(...arguments);this.operation=void 0;}willUpdate(e){super.willUpdate(e),this.operation?(this.titleProp=this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(this.operation).toLowerCase()}),this.icon=this.operation):(this.icon="",this.titleProp="");}onClick(e){if(!this.operation)return;let t=this.$["*cropperEl"],i=t.getValue(this.operation),s=wc(this.operation,i);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this.operation,next:s,prev:i}),t.setValue(this.operation,s);}};d([property({type:String})],Ht.prototype,"operation",2);var xe=class extends X{constructor(){super(...arguments);this._operation="";this._filter="";this._originalUrl="";this._lastPreviewRequestId=0;this._previewImage=null;this._previewLoaded=false;this.isOriginal=false;this._iconSize=20;}get filter(){return this._filter}set filter(e){let t=e??"";if(this._filter===t)return;let i=this._filter;this._filter=t,this._operation="filter",this.isOriginal=t===be,this.icon=this.isOriginal?"original":"slider",this._iconSize=this.isOriginal?40:20,this.requestUpdate("filter",i),this.isConnected&&this._updateFilterLabels(t);}onClick(e){if(this.active)this.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=true);else {let t=this.$["*sliderEl"];t.setOperation(this._operation,this._filter),t.apply();}this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:mt(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter;}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=Number.isFinite(e)&&e>0?e:this._iconSize||32,i=window.devicePixelRatio,s=Math.ceil(i*t),n=i>=2?"lightest":"normal",a=100,l={...this.$["*editorTransformations"]};return l[this._operation]=this._filter!==be?{name:this._filter,amount:a}:void 0,F(this._originalUrl,q(ti,ke(l),`quality/${n}`,`scale_crop/${s}x${s}/center`,`@clib/${pe}/${he}/uc-cloud-image-editor/`))}async _observerCallback(e,t){e[0]?.isIntersecting?await this._loadPreview(t):this._cancelPreload?.();}initCallback(){super.initCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let e=this.$["*originalUrl"];this._originalUrl=e??"",this.sub("*originalUrl",t=>{this._originalUrl=t??"",!this.isOriginal&&this._originalUrl&&this.isConnected&&!this._previewImage&&(this._observer?.observe(this),this._schedulePreviewVisibilityCheck());}),this.isOriginal||(this._observer?.observe(this),this._schedulePreviewVisibilityCheck()),this._filter&&this._updateFilterLabels(this._filter),this.sub("*currentFilter",t=>{this.active=!!(t&&t===this._filter);}),this.sub("*networkProblems",async t=>{t||(this._previewImage?await this._loadPreview():this._schedulePreviewVisibilityCheck());});}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._cancelPreload?.(),this._clearPreviewVisibilityChecks();}updated(e){super.updated(e),e.has("isOriginal")&&(this.isOriginal?this._observer?.unobserve(this):(this._observer?.observe(this),this._schedulePreviewVisibilityCheck()));}_updateFilterLabels(e){if(!e){this.titleProp="";return}let t=this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()});this.titleProp=t;}async _loadPreview(e){if(!this.isConnected){e?.unobserve(this),this._cancelPreload?.(),this._cancelPreload=void 0;return}if(!this._originalUrl){!this._previewVisibilityCheckTimeout&&!this._previewVisibilityCheckRaf&&this._schedulePreviewVisibilityCheck();return}let t=++this._lastPreviewRequestId,i="";try{i=await this.proxyUrl(this._previewSrc());}catch(a){this.$["*networkProblems"]=true,console.error("Failed to resolve preview URL",{error:a});return}this._previewLoaded=false,this._cancelPreload?.();let{promise:s,cancel:n}=He(i);this._cancelPreload=()=>{n(),this._lastPreviewRequestId===t&&(this._cancelPreload=void 0);};try{if(await s,this._lastPreviewRequestId!==t||!this.isConnected)return;this._previewImage=i,this._previewLoaded=!0,this._clearPreviewVisibilityChecks(),(e??this._observer)?.unobserve(this);}catch(a){this.$["*networkProblems"]=true,console.error("Failed to load image",{error:a}),this._schedulePreviewVisibilityCheck();}finally{this._lastPreviewRequestId===t&&(this._cancelPreload=void 0);}}_schedulePreviewVisibilityCheck(){if(!this.isConnected||this._previewImage||this._previewLoaded||this.isOriginal||this.$["*networkProblems"]){this._clearPreviewVisibilityChecks();return}this._previewVisibilityCheckRaf&&cancelAnimationFrame(this._previewVisibilityCheckRaf),this._previewVisibilityCheckRaf=requestAnimationFrame(()=>{if(this._previewVisibilityCheckRaf=void 0,!this.isConnected||this._previewImage||this._previewLoaded||this.isOriginal){this._clearPreviewVisibilityChecks();return}let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,i=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight;if(t&&e.bottom>0&&e.right>0&&e.top<s&&e.left<i){this._loadPreview();return}this._previewVisibilityCheckTimeout=window.setTimeout(()=>{this._previewVisibilityCheckTimeout=void 0,this._schedulePreviewVisibilityCheck();},500);});}_clearPreviewVisibilityChecks(){this._previewVisibilityCheckRaf&&(cancelAnimationFrame(this._previewVisibilityCheckRaf),this._previewVisibilityCheckRaf=void 0),this._previewVisibilityCheckTimeout&&(window.clearTimeout(this._previewVisibilityCheckTimeout),this._previewVisibilityCheckTimeout=void 0);}get _shouldShowPreview(){return !!(this._previewLoaded&&!this.active&&!this.isOriginal)}render(){let e=this.onClick,t={opacity:this._shouldShowPreview?"1":"0"};this._previewImage&&(t.backgroundImage=`url(${this._previewImage})`);let i={opacity:this.active||this.isOriginal?"1":"0"};return html`<button role="option" type="button" class=${classMap(this.buttonClasses)} aria-label=${ifDefined(this.titleProp)} title=${ifDefined(this.titleProp)} @click=${e} ><div class="uc-preview" ?data-loaded=${this._previewLoaded} style=${styleMap(t)}></div><uc-icon class=${classMap({"uc-original-icon":this.isOriginal})} name=${this.icon} style=${styleMap(i)} ></uc-icon></button>`}};d([state()],xe.prototype,"_previewImage",2),d([state()],xe.prototype,"_previewLoaded",2),d([state()],xe.prototype,"isOriginal",2),d([state()],xe.prototype,"_iconSize",2),d([property({type:String})],xe.prototype,"filter",1);var zt=class extends X{constructor(){super(...arguments);this._operation="";}get operation(){return this._operation}set operation(e){let t=e??"";if(this._operation===t)return;let i=this._operation;this._operation=t,this.requestUpdate("operation",i),this.isConnected&&t&&this._updateOperationMetadata(t);}_updateOperationMetadata(e){this.icon=e;let t=()=>{let s=this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()});return this.titleProp=s,s},i=()=>{let s=this.l10n(e);return this.title=s,s};t(),i();}initCallback(){super.initCallback(),this._operation&&this._updateOperationMetadata(this._operation),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=ce[this._operation],i=e[this._operation],s=typeof i<"u"?i!==t:false;this.active=s;});}onClick(e){this.$["*sliderEl"]?.setOperation(this._operation),this.$["*showSlider"]=true,this.$["*currentOperation"]=this._operation,this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:mt(this.$["*operationTooltip"])});}};d([property({type:String})],zt.prototype,"operation",1);var Ic=1,un=()=>{},Kt=class extends g{constructor(){super(...arguments);this.hiddenScrollbar=false;this._handleWheel=e=>{e.preventDefault();let{deltaY:t,deltaX:i}=e;if(Math.abs(i)>Ic){this.scrollLeft+=i;return}this.scrollLeft+=t;};}connectedCallback(){super.connectedCallback(),this.addEventListener("wheel",this._handleWheel,{passive:false}),this.addEventListener("scroll",un,{passive:true});}disconnectedCallback(){this.removeEventListener("wheel",this._handleWheel),this.removeEventListener("scroll",un),super.disconnectedCallback();}};d([property({type:Boolean,noAccessor:true,attribute:"hidden-scrollbar"})],Kt.prototype,"hiddenScrollbar",2);var ee=class extends g{constructor(){super(...arguments);this._showLoader=false;this.showMainToolbar=true;this.showSubToolbar=false;this._showTabToggles=true;this.tabList=[...Z];this.activeTab=O.CROP;this._useSliderPanel=true;this._tooltipVisible=false;this._operationTooltip=null;this._tabIndicatorOffset=0;this._tabIndicatorWidth=0;this._sliderRef=createRef();this._tabIndicatorRef=createRef();this.tabToggleRefs={[O.CROP]:createRef(),[O.TUNING]:createRef(),[O.FILTERS]:createRef()};this._handleWindowResize=()=>{this._syncTabIndicator();};this._cropPresets=[];this._debouncedShowLoader=S(e=>{this._showLoader=e;},500);this._updateInfoTooltip=S(()=>{let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],i="",s=false;if(this.$["*tabId"]===O.FILTERS)if(s=true,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let n=e?.filter?.amount||100;i=`${this.$["*currentFilter"]} ${n}`;}else i=this.l10n(be);else if(this.showSubToolbar&&this.$["*tabId"]===O.TUNING&&t){s=true;let n=e?.[t]||ce[t].zero;i=`${this.l10n(t)} ${n}`;}s&&(this.$["*operationTooltip"]=i),this._tooltipVisible=s;},0);this._subTopToolbarStyles={hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"};this._subBottomToolbarStyles={hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"};this._tabToggleStyles={hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"};this._tabTogglesStyles={hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"};this.init$={...this.init$,"*sliderEl":null,"*showSlider":false,"*showListAspectRatio":false,"*currentFilter":be,"*currentOperation":null,"*operationTooltip":null};this._handleCancel=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t?.();};this._handleApply=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t?.(this.$["*editorTransformations"]);};this._handleApplySlider=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:mt(this.$["*operationTooltip"])}),this._sliderRef.value?.apply(),this._onSliderClose();};this._handleCancelSlider=e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this._sliderRef.value?.cancel(),this._onSliderClose();};this._handleTabClick=e=>{let i=e.currentTarget?.getAttribute("data-id");i&&(this.telemetryManager.sendEventCloudImageEditor(e,i),this._activateTab(i,{fromViewer:false}));};}_onSliderClose(){this.$["*showSlider"]=false,this.$["*tabId"]===O.CROP&&(this.$["*showListAspectRatio"]=false),this.$["*tabId"]===O.TUNING&&(this._tooltipVisible=false);}_activateTab(e,{fromViewer:t=false,force:i=false}={}){this.$["*tabId"]!==e&&(this.$["*tabId"]=e),this._applyTabState(e,{fromViewer:t,force:i});}_applyTabState(e,{fromViewer:t,force:i=false}){if(!i&&this.activeTab===e){this._syncTabIndicator();return}this.activeTab=e;let s=this.$["*faderEl"],n=this.$["*cropperEl"];e===O.CROP?(s?.deactivate(),this.$["*imageSize"]&&n?.activate(this.$["*imageSize"],{fromViewer:t})):(s?.activate({url:this.$["*originalUrl"],fromViewer:t}),n?.deactivate());for(let a of Z){let l=a===e,u=this.tabToggleRefs[a]?.value;u&&(u.active=l),l&&this._syncTabIndicator();}}_syncTabIndicator(){let t=this.tabToggleRefs[this.activeTab]?.value,i=this._tabIndicatorRef.value;if(!t||!i)return;let s=t.offsetLeft,n=t.offsetWidth||Number(getComputedStyle(t).width.replace("px",""));(this._tabIndicatorOffset!==s||this._tabIndicatorWidth!==n)&&(this._tabIndicatorOffset=s,this._tabIndicatorWidth=n,i.style.transform=`translateX(${s}px)`,i.style.width=`${n}px`);}get _hasAspectRatioPicker(){return this._cropPresets.length>=3}_renderControlsByTab(e){switch(e){case O.CROP:return this._renderCropTabControls();case O.FILTERS:return this._renderFilterTabControls();case O.TUNING:return this._renderTuningTabControls();default:return []}}_renderCropTabControls(){let e=[];if(this._hasAspectRatioPicker)e.push(()=>this._renderFreeformControl());else for(let t of this._cropPresets)e.push(()=>this._renderAspectRatioControl(t));for(let t of ko)e.push(()=>this._renderCropOperationControl(t));return this._renderControlGroup(e)}_renderFilterTabControls(){let t=[be,...Ao].map(i=>()=>this._renderFilterControl(i));return this._renderControlGroup(t)}_renderTuningTabControls(){let e=Io.map(t=>()=>this._renderOperationControl(t));return this._renderControlGroup(e)}_renderControlGroup(e){return e.length?e.map(i=>i()):[]}_renderFreeformControl(){return html`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`}_renderAspectRatioControl(e){return html`<uc-editor-aspect-ratio-button-control .aspectRatio=${e}></uc-editor-aspect-ratio-button-control>`}_renderCropOperationControl(e){return html`<uc-editor-crop-button-control .operation=${e}></uc-editor-crop-button-control>`}_renderFilterControl(e){return html`<uc-editor-filter-control .filter=${e}></uc-editor-filter-control>`}_renderOperationControl(e){return html`<uc-editor-operation-control .operation=${e}></uc-editor-operation-control>`}_renderAspectRatioList(){return this._hasAspectRatioPicker?this._cropPresets.map(e=>this._renderAspectRatioControl(e)):[]}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(ht(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:i}=Mt([t]);this._cancelPreload=()=>{i(),this._cancelPreload=void 0;};}}initCallback(){super.initCallback();let e=this.$["*cropPresetList"]??[];this._cropPresets=[...e],this.sub("*cropPresetList",t=>{this._cropPresets=[...t??[]];}),this.sub("*imageSize",t=>{t&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:true});},0);}),this.sub("*editorTransformations",t=>{let i=t?.filter?.name;this.$["*currentFilter"]!==i&&(this.$["*currentFilter"]=i??"");}),this.sub("*currentFilter",()=>{this._updateInfoTooltip();}),this.sub("*currentOperation",()=>{this._updateInfoTooltip();}),this.sub("*tabId",t=>{this._applyTabState(t,{fromViewer:false,force:true}),this._updateInfoTooltip();}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate();}),this.sub("*editorTransformations",t=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(t);}),this.sub("*loadingOperations",t=>{let i=false;for(let[,s]of t.entries()){if(i)break;for(let[,n]of s.entries())if(n){i=true;break}}this._debouncedShowLoader(i);}),this.sub("*showSlider",t=>{t?(this.showSubToolbar=true,this.showMainToolbar=false,this._useSliderPanel=true):this.$["*showListAspectRatio"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*showListAspectRatio",t=>{t?(this.showSubToolbar=true,this.showMainToolbar=false,this._useSliderPanel=false):this.$["*showSlider"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*tabList",t=>{if(this.tabList=t,this._showTabToggles=t.length>1,!t.includes(this.$["*tabId"])&&t.length>0){let[i]=t;i&&this._activateTab(i,{fromViewer:false});return}this._syncTabIndicator();}),this.sub("*operationTooltip",t=>{this._operationTooltip=t;}),this._updateInfoTooltip();}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._handleWindowResize);}firstUpdated(e){super.firstUpdated(e),this._assignSharedElements(),this._syncTabIndicator();}updated(e){super.updated(e),(e.has("activeTab")||e.has("tabList"))&&this.updateComplete.then(()=>this._syncTabIndicator()),(e.has("showSubToolbar")||e.has("showMainToolbar"))&&this._assignSharedElements();}disconnectedCallback(){window.removeEventListener("resize",this._handleWindowResize),super.disconnectedCallback(),this.$["*showSlider"]=false,this.$["*showListAspectRatio"]=false;}_assignSharedElements(){let e=this._sliderRef.value;e&&(this.$["*sliderEl"]=e);}_renderTabToggle(e){let t=this.tabList.includes(e),i=this.activeTab===e,s=this.tabList.indexOf(e),n=s>=0?styleMap({gridColumn:`${s+1}`}):nothing;return html`<uc-presence-toggle class="uc-tab-toggle" .visible=${t} .styles=${this._tabToggleStyles}><uc-btn-ui theme="tab" data-id=${e} icon=${e} role="tab" aria-controls=${`tab_${e}`} aria-selected=${i?"true":"false"} title-prop=${`a11y-editor-tab-${e}`} .active=${i} style=${n} @click=${this._handleTabClick} ${ref(this.tabToggleRefs[e])} ></uc-btn-ui></uc-presence-toggle>`}_renderTabContent(e){let t=this._renderControlsByTab(e);return html`<div id=${`tab_${e}`} class="uc-tab-content" ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner">${t.length?t:nothing}</div></div></uc-editor-scroller></div>`}render(){let e=["uc-info-tooltip",this._tooltipVisible?"uc-info-tooltip_visible":"uc-info-tooltip_hidden"].join(" "),t=this._hasAspectRatioPicker;return html`<uc-line-loader-ui .active=${this._showLoader}></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div class=${e}>${this._operationTooltip??""}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" .visible=${this.showMainToolbar} .styles=${this._subTopToolbarStyles} ><div class="uc-tab-content-row">${Z.map(i=>when(this.activeTab===i,()=>this._renderTabContent(i)))}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" .visible=${this._showTabToggles} .styles=${this._tabTogglesStyles} @initial-render=${()=>this._syncTabIndicator()} ><div class="uc-tab-toggles_indicator" ${ref(this._tabIndicatorRef)} ></div>${Z.map(i=>this._renderTabToggle(i))}</uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" title-prop="cancel" @click=${this._handleCancel} ></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this._handleApply}></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this._subBottomToolbarStyles}><div class="uc-slider" ?hidden=${!this._useSliderPanel}><uc-editor-slider ${ref(this._sliderRef)}></uc-editor-slider></div><div class="uc-list-aspect-ratio-container" ?hidden=${this._useSliderPanel||!t}>${t?html`<div class="uc-list-aspect-ratio">${this._renderAspectRatioList()}</div>`:nothing}</div><div class="uc-controls-row"><uc-btn-ui theme="secondary" @click=${this._handleCancelSlider} text=${this.l10n("cancel")}></uc-btn-ui><uc-btn-ui theme="primary" @click=${this._handleApplySlider} text=${this.l10n("apply")}></uc-btn-ui></div></uc-presence-toggle></div>`}};d([state()],ee.prototype,"_showLoader",2),d([state()],ee.prototype,"showMainToolbar",2),d([state()],ee.prototype,"showSubToolbar",2),d([state()],ee.prototype,"_showTabToggles",2),d([state()],ee.prototype,"tabList",2),d([state()],ee.prototype,"activeTab",2),d([state()],ee.prototype,"_useSliderPanel",2),d([state()],ee.prototype,"_tooltipVisible",2),d([state()],ee.prototype,"_operationTooltip",2),d([state()],ee.prototype,"_cropPresets",2);var hn=_e([...Z]),j=class extends g{constructor(){super(...arguments);this.ctxOwner=true;this._statusMessage="";this._imageSrc=de;this._fileType="";this._showLoader=false;this.uuid=null;this.cdnUrl=null;this.cropPreset="";this.tabs=hn;this._hasNetworkProblems=false;this._isInitialized=false;this._pendingInitUpdate=null;this._pendingSizeWait=null;this._debouncedShowLoader=S(e=>{this._showLoader=e;},300);this._imgRef=createRef();this._cropperRef=createRef();this._faderRef=createRef();this._imgContainerRef=createRef();this._handleImageLoad=()=>{this._debouncedShowLoader(false),this._imageSrc!==de&&(this.$["*networkProblems"]=false);};this._handleImageError=()=>{this._debouncedShowLoader(false),this.$["*networkProblems"]=true;};this._handleRetryNetwork=()=>{let e=this.$["*on.retryNetwork"];e?.();};this.init$={...this.init$,...Ys(this)};}static{this.styleAttrs=["uc-cloud-image-editor"];}_scheduleInitialization(){this._isInitialized||this._pendingInitUpdate||(this._pendingInitUpdate=this.updateComplete.then(()=>{this._pendingInitUpdate=null,this._isInitialized=true;}));}initCallback(){super.initCallback(),this._syncTabListFromProp(),this._syncCropPresetState();}_assignSharedElements(){let e=this._faderRef.value;e&&(this.$["*faderEl"]=e);let t=this._cropperRef.value;t&&(this.$["*cropperEl"]=t);let i=this._imgContainerRef.value;i&&(this.$["*imgContainerEl"]=i);let s=this._imgRef.value;s&&(this.$["*imgEl"]=s);}_attachImageListeners(){let e=this._imgRef.value;e&&(e.addEventListener("load",this._handleImageLoad),e.addEventListener("error",this._handleImageError));}_detachImageListeners(){let e=this._imgRef.value;e&&(e.removeEventListener("load",this._handleImageLoad),e.removeEventListener("error",this._handleImageError));}get _imageClassName(){let e=this.$["*tabId"];return se("uc-image",{"uc-image_hidden_to_cropper":e===O.CROP,"uc-image_hidden_effects":e!==O.CROP})}_waitForSize(){if(this._pendingSizeWait)return this._pendingSizeWait;let e=3e3;return this._pendingSizeWait=new Promise((t,i)=>{let s=()=>{window.clearTimeout(u),c.disconnect(),this._pendingSizeWait=null;},n=()=>{let{width:p,height:m}=this.getBoundingClientRect();return p>0&&m>0},a=()=>{s(),window.setTimeout(()=>t(),0);},l=()=>{let p=new Error("[cloud-image-editor] timeout waiting for non-zero container size");s(),this.isConnected&&console.error(p.message),i(p);},c=new ResizeObserver(p=>{let[m]=p;m&&m.contentRect.width>0&&m.contentRect.height>0&&a();}),u=window.setTimeout(()=>{l();},e);if(n()){a();return}c.observe(this);}),this._pendingSizeWait}firstUpdated(e){super.firstUpdated(e),this._assignSharedElements(),this._attachImageListeners(),this.initEditor();let t=!!(this.uuid||this.cdnUrl),i=e.has("uuid")||e.has("cdnUrl");t&&!i&&this.updateImage();}disconnectedCallback(){this._detachImageListeners(),super.disconnectedCallback();}render(){let e=this._fileType??"",t=this._statusMessage??"",i=this._imageSrc||de,s=this._showLoader,n=this._hasNetworkProblems;return html` ${unsafeSVG(Xs)}<div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" .visible=${n}><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" @click=${this._handleRetryNetwork}></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">${e}</div></div><div class="uc-image_container" ${ref(this._imgContainerRef)}><img src=${i} class=${this._imageClassName} ${ref(this._imgRef)} />${when(this._isInitialized,()=>html`<uc-editor-image-cropper ${ref(this._cropperRef)}></uc-editor-image-cropper>`)}<uc-editor-image-fader ${ref(this._faderRef)}></uc-editor-image-fader></div><div class="uc-info_pan">${t}</div></div><div class="uc-toolbar"><uc-line-loader-ui .active=${s}></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor">${when(this._isInitialized,()=>html`<uc-editor-toolbar></uc-editor-toolbar>`)}</div></div></div>`}updated(e){super.updated(e),e.has("uuid")&&this.uuid&&this.updateImage(),e.has("cdnUrl")&&this.cdnUrl&&this.updateImage(),e.has("tabs")&&this._syncTabListFromProp(),(e.has("cropPreset")||e.has("cdnUrl"))&&this._syncCropPresetState();}_syncTabListFromProp(){let e=this.tabs||hn;this.$["*tabList"]=Zs(e);}_syncCropPresetState(){let e=Ai(this.cropPreset??""),t=null;if(this.cdnUrl){let i=lr(this.cdnUrl),s=cr(i);if(Array.isArray(s?.crop?.dimensions)){let[n,a]=s.crop.dimensions;t=ds(n,a,e,.1);}}this.$["*cropPresetList"]=e,this.$["*currentAspectRatio"]=t??e?.[0]??null;}async updateImage(){if(this.isConnected){try{await this._waitForSize();}catch{return}if(this.isConnected){if(this.cdnUrl){let e=this.cdnUrl,t=ei(e),i=Ae(e,t);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let s=lr(e),n=cr(s);this.$["*editorTransformations"]=n;}else if(this.uuid){let e=Ae(this.cfg.cdnCname,this.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,Object.keys(this.$["*editorTransformations"]).length>0&&(this.$["*editorTransformations"]={});}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===O.CROP?this.$["*cropperEl"]?.deactivate({reset:true}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(F(e,q("json"))),i=await fetch(t).then(a=>a.json()),{width:s,height:n}=i;this.$["*imageSize"]={width:s,height:n},this.$["*tabId"]===O.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:e});}catch(e){e&&(this.telemetryManager.sendEventError(e,"cloud editor image. Failed to load image info"),console.error("Failed to load image info",e));}this._scheduleInitialization();}}}async initEditor(){try{await this._waitForSize();}catch{return}this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{let t=!!e;this._hasNetworkProblems=t;}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],i=q(ke(e),"preview"),s=F(t,i),n={originalUrl:t,cdnUrlModifiers:i,cdnUrl:s,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:true,composed:true}));},false);}};d([state()],j.prototype,"_statusMessage",2),d([state()],j.prototype,"_imageSrc",2),d([state()],j.prototype,"_fileType",2),d([state()],j.prototype,"_showLoader",2),d([property({type:String,reflect:true})],j.prototype,"uuid",2),d([property({type:String,attribute:"cdn-url",reflect:true})],j.prototype,"cdnUrl",2),d([property({type:String,attribute:"crop-preset",reflect:true})],j.prototype,"cropPreset",2),d([property({type:String,reflect:true})],j.prototype,"tabs",2),d([state()],j.prototype,"_hasNetworkProblems",2),d([state()],j.prototype,"_isInitialized",2);var so={};mo(so,{CloudImageEditorActivity:()=>Gt});var Qi=class extends j{static{this.styleAttrs=[...super.styleAttrs,"uc-wgt-common"];}constructor(){super(),this.init$={...this.init$,"*solution":this.tagName};}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION}),this.a11y?.registerBlock(this);}};var Gt=class extends _{constructor(){super(...arguments);this._editorConfig=null;}get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.subConfigValue("cropPreset",e=>{this._editorConfig&&this._editorConfig.cropPreset!==e&&(this._editorConfig={...this._editorConfig,cropPreset:e});}),this.subConfigValue("cloudImageEditorTabs",e=>{this._editorConfig&&this._editorConfig.tabs!==e&&(this._editorConfig={...this._editorConfig,tabs:e});}),this._mountEditor();}disconnectedCallback(){super.disconnectedCallback(),this._unmountEditor();}_handleApply(e){if(!this._entry)return;this.debugPrint('editor event "apply"',e.detail);let t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager?.close(E.activities.CLOUD_IMG_EDIT),this.historyBack();}_handleCancel(e){let t=e instanceof CustomEvent?e.detail:void 0;this.debugPrint('editor event "cancel"',t),this.modalManager?.close(E.activities.CLOUD_IMG_EDIT),this.historyBack();}handleChange(e){this.debugPrint('editor event "change"',e.detail);}_mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let i=this._entry.getValue("cdnUrl");if(!i)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);this._editorConfig=this._createEditorConfig(i);}_unmountEditor(){this._entry=void 0,this._editorConfig=null;}render(){if(!this._editorConfig)return nothing;let{cdnUrl:e,cropPreset:t,tabs:i}=this._editorConfig;return html`<uc-cloud-image-editor cdn-url=${e} crop-preset=${ifDefined(t)} tabs=${ifDefined(i)} @apply=${this._handleApply} @cancel=${this._handleCancel} @change=${this.handleChange} ></uc-cloud-image-editor>`}_createEditorConfig(e){return {cdnUrl:e,cropPreset:this.cfg.cropPreset,tabs:this.cfg.cloudImageEditorTabs}}};d([state()],Gt.prototype,"_editorConfig",2);var gt=class extends _{constructor(){super(...arguments);this._url="";this._handleInput=e=>{this._url=e.target?.value??"";};this._handleUpload=e=>{e.preventDefault(),this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let t=this._url.trim();t&&(this.api.addFileFromUrl(t,{source:T.URL}),this.routerLayer.navigateAfterFileAdd());};}render(){return html`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.historyBack} title=${this.l10n("back")} aria-label=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span>${this.l10n("caption-from-url")}</span></div><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content" @submit=${this._handleUpload}><label><input placeholder="https://" class="uc-url-input" type="text" autofocus @input=${this._handleInput} /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" ?disabled=${!this._url} >${this.l10n("upload-url")}</button></form>`}};d([state()],gt.prototype,"_url",2);var fn=()=>{let o=globalThis.top??globalThis.parent??globalThis.self;try{return o.location.origin}catch(r){return console.warn("Unable to access top-level window location:",r),globalThis.location.origin}};var Vc=o=>o.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),gn=(o,r="i")=>{let e=o.split("*").map(Vc);return new RegExp(`^${e.join(".+")}$`,r)};var $c=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],Dc=(o,r)=>window.getComputedStyle(o).getPropertyValue(r).trim(),vn=o=>{let r={};for(let e of $c){let t=Dc(o,e);t&&(r[e]=t);}return r};var Fc=["selected-files-change","toolbar-state-change"],Nc=o=>{if(!o||typeof o!="object"||!("type"in o))return false;let r=o.type;return !(typeof r!="string"||!Fc.includes(r))},Ji=class{constructor(r,e){this._handlerMap=new Map;this._handleMessage=r=>{if(r.source!==this._context)return;let e=r.data;if(!Nc(e))return;let t=this._handlerMap.get(e.type);if(t)for(let i of t)i(e);};this._context=r,this._getTargetOrigin=e,window.addEventListener("message",this._handleMessage);}on(r,e){let t=this._handlerMap.get(r)??new Set;this._handlerMap.has(r)||this._handlerMap.set(r,t),t.add(e);}send(r){let e=this._getTargetOrigin();this._context.postMessage(r,e);}destroy(){window.removeEventListener("message",this._handleMessage);}};function bn(o){let r=[];for(let[e,t]of Object.entries(o))t==null||typeof t=="string"&&t.length===0||r.push(`${e}=${encodeURIComponent(t)}`);return r.join("&")}var Kc={[Q.GDRIVE]:"ngdrive"},te=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this._iframeRef=createRef();this._latestSelectionSummary=null;this._selectedList=[];this._isSelectionReady=false;this._isDoneBtnEnabled=false;this._couldSelectAll=false;this._couldDeselectAll=false;this._showSelectionStatus=false;this._showDoneBtn=false;this._doneBtnTextClass="uc-hidden";this._toolbarVisible=true;this._handleDone=()=>{for(let e of this._selectedList){let t=this._extractUrlFromSelectedFile(e),{filename:i}=e,{externalSourceType:s}=this.activityParams;this.api.addFileFromUrl(t,{fileName:i,source:s});}this.routerLayer.navigateAfterFileAdd();};this._handleCancel=()=>{this.historyBack();};this._handleSelectAll=()=>{this._messageBridge?.send({type:"select-all"});};this._handleDeselectAll=()=>{this._messageBridge?.send({type:"deselect-all"});};}get _counterText(){if(!this._latestSelectionSummary)return "";let{selectedCount:e,total:t}=this._latestSelectionSummary;return this.l10n("selected-count",{count:e,total:t})}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback();let{externalSourceType:e}=this.activityParams;e?this._mountIframe():console.error('Param "externalSourceType" is required for external source activity'),this.sub("*currentActivityParams",()=>{setTimeout(()=>{this.isConnected&&(this._unmountIframe(),this._mountIframe());});}),this.subConfigValue("multiple",t=>{this._showSelectionStatus=t;}),this.subConfigValue("localeName",()=>{this._setupL10n();}),this.subConfigValue("externalSourcesEmbedCss",t=>{this._applyEmbedCss(t);});}_extractUrlFromSelectedFile(e){if(e.alternatives){let t=N(this.cfg.externalSourcesPreferredTypes);for(let i of t){let s=gn(i);for(let[n,a]of Object.entries(e.alternatives))if(s.test(n))return a}}return e.url}_handleToolbarStateChange(e){this._toolbarVisible=e.isVisible;}async _handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this._setSelectionSummary(e.selectedCount,e.total),this._doneBtnTextClass=e.isReady?"":"uc-hidden",this._isSelectionReady=e.isReady,this._isDoneBtnEnabled=e.isReady&&e.selectedFiles.length>0,this._showSelectionStatus=e.isMultipleMode&&e.total>0,this._couldSelectAll=e.selectedCount<e.total,this._couldDeselectAll=e.selectedCount===e.total,this._selectedList=e.selectedFiles??[],this._showDoneBtn=e.total>0;}_handleIframeLoad(){this._applyEmbedCss(this.cfg.externalSourcesEmbedCss),this._applyTheme(),this._setupL10n();}_applyTheme(){this._messageBridge?.send({type:"set-theme-definition",theme:vn(this)});}_applyEmbedCss(e){this._messageBridge?.send({type:"set-embed-css",css:e});}_setupL10n(){this._messageBridge?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName});}_remoteUrl(){let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:i,multiple:s}=this.cfg,{externalSourceType:n}=this.activityParams,a=Kc[n]??n,c={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:true,multiple:s.toString(),origin:this.cfg.topLevelOrigin||fn(),debug:this.cfg.debug},u=new URL(`/window4/${a}`,i);return u.search=bn(c),u.toString()}_setSelectionSummary(e,t){this._latestSelectionSummary={selectedCount:e,total:t};}_mountIframe(){let e=document.createElement("iframe");e.src=this._remoteUrl(),e.marginHeight=0,e.marginWidth=0,e.frameBorder="0",e.allowTransparency=true,e.addEventListener("load",this._handleIframeLoad.bind(this)),e.addEventListener("load",this._handleIframeLoad.bind(this)),this._iframeRef.value&&(this._iframeRef.value.innerHTML="",this._iframeRef.value.appendChild(e)),e.contentWindow&&(this._messageBridge?.destroy(),this._messageBridge=new Ji(e.contentWindow,()=>this.cfg.socialBaseUrl),this._messageBridge.on("selected-files-change",this._handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this._handleToolbarStateChange.bind(this)),this._resetSelectionStatus());}_unmountIframe(){this._messageBridge?.destroy(),this._messageBridge=void 0,this._iframeRef.value&&(this._iframeRef.value.innerHTML=""),this._resetSelectionStatus();}_resetSelectionStatus(){this._selectedList=[],this._isSelectionReady=false,this._isDoneBtnEnabled=false,this._couldSelectAll=false,this._couldDeselectAll=false,this._showSelectionStatus=false,this._showDoneBtn=false,this._doneBtnTextClass="uc-hidden",this._latestSelectionSummary=null;}disconnectedCallback(){super.disconnectedCallback(),this._unmountIframe();}render(){return html`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*historyBack"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ${ref(this._iframeRef)} class="uc-iframe-wrapper"></div><div class="uc-toolbar" ?hidden=${!this._toolbarVisible}><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel} >${this.l10n("cancel")}</button><div class="uc-selection-status-box" ?hidden=${!this._showSelectionStatus} ><span>${this._counterText}</span><button type="button" @click=${this._handleSelectAll} ?hidden=${!this._couldSelectAll} >${this.l10n("select-all")}</button><button type="button" @click=${this._handleDeselectAll} ?hidden=${!this._couldDeselectAll} >${this.l10n("deselect-all")}</button></div><button type="button" class="uc-done-btn uc-primary-btn" @click=${this._handleDone} ?disabled=${!this._isDoneBtnEnabled} ?hidden=${!this._showDoneBtn} ><uc-spinner ?hidden=${this._isSelectionReady}></uc-spinner><span class=${this._doneBtnTextClass}>${this.l10n("done")}</span></button></div></div>`}};d([state()],te.prototype,"_selectedList",2),d([state()],te.prototype,"_isSelectionReady",2),d([state()],te.prototype,"_isDoneBtnEnabled",2),d([state()],te.prototype,"_couldSelectAll",2),d([state()],te.prototype,"_couldDeselectAll",2),d([state()],te.prototype,"_showSelectionStatus",2),d([state()],te.prototype,"_showDoneBtn",2),d([state()],te.prototype,"_doneBtnTextClass",2),d([state()],te.prototype,"_toolbarVisible",2);var yn=()=>typeof navigator.permissions<"u";var Wc={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},qc=["camera","microphone"];function er(o){let r=Math.floor(o/60).toString().padStart(2,"0"),e=Math.floor(o%60).toString().padStart(2,"0");return `${r}:${e}`}var Cn="image/jpeg",wn="video/webm",M=class extends _{constructor(){super(...arguments);this.couldBeCtxOwner=true;this._unsubPermissions=null;this._capturing=false;this._chunks=[];this._mediaRecorder=null;this._stream=null;this._selectedAudioId=null;this._selectedCameraId=null;this._activeTab=null;this._options={};this._canvas=null;this._ctx=null;this._cameraDevices=[];this._audioDevices=[];this._permissionResponses={};this._permissionCleanupFns=[];this._currentVideoSource=null;this._handlePreviewPlay=()=>{this._startTimeline(),this._currentTimelineIcon="pause";};this._handlePreviewPause=()=>{this._currentTimelineIcon="play",this._stopTimeline();};this._timerRef=createRef();this._lineRef=createRef();this._videoRef=createRef();this._startTime=0;this._elapsedTime=0;this._videoTransformCss=null;this._videoHidden=true;this._messageHidden=true;this._requestBtnHidden=yn();this._cameraSelectOptions=[];this._cameraSelectHidden=true;this._l10nMessage="";this._timerHidden=true;this._cameraHidden=true;this._cameraActionsHidden=true;this._audioSelectOptions=[];this._audioSelectHidden=true;this._audioSelectDisabled=true;this._audioToggleMicrophoneHidden=true;this._tabCameraHidden=true;this._tabVideoHidden=true;this._currentIcon="camera-full";this._currentTimelineIcon="play";this._toggleMicrophoneIcon="microphone";this._mutableClassButton="uc-shot-btn uc-camera-action";this._chooseActionWithCamera=()=>{if(this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this._activeTab}}}),this._activeTab===C.PHOTO&&this._shot(),this._activeTab===C.VIDEO){if(this._mediaRecorder?.state==="recording"){this._stopRecording();return}this._startRecording();}};this._handleCameraSelectChange=e=>{let t=e.target;t&&(this._selectedCameraId=t.value,this._capture());};this._handleAudioSelectChange=e=>{let t=e.target;t&&(this._selectedAudioId=t.value,this._capture());};this._handleRequestPermissions=()=>{this._capture();};this._handleStartCamera=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this._activeTab}}}),this._chooseActionWithCamera();};this._handleToggleRecording=()=>{this._toggleRecording();};this._handleToggleAudio=()=>{this._toggleEnableAudio();};this._handleRetake=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this._activeTab}}}),this._retake();};this._handleAccept=()=>{this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this._activeTab}}}),this._accept();};this._handleClickTab=e=>{let i=e.currentTarget?.getAttribute("data-id");i&&this._handleActiveTab(i);};this._updateTimer=()=>{let e=Math.floor((performance.now()-this._startTime+this._elapsedTime)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){let s=this._timerRef.value;s&&(s.textContent=er(t)),this._stopRecording();return}let i=this._timerRef.value;i&&(i.textContent=er(t));}else {let t=this._timerRef.value;t&&(t.textContent=er(e));}this._animationFrameId=requestAnimationFrame(this._updateTimer);};this._startTimer=()=>{this._startTime=performance.now(),this._elapsedTime=0,this._updateTimer();};this._stopTimer=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId);};this._startTimeline=()=>{let e=this._videoRef.value;if(!e)return;let t=e.currentTime,i=e.duration||1,s=this._lineRef.value;s&&(s.style.transform=`scaleX(${t/i})`);let n=this._timerRef.value;n&&(n.textContent=er(t)),this._animationFrameId=requestAnimationFrame(this._startTimeline);};this._stopTimeline=()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId);};this._animationFrameId=null;this._startRecording=()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(wn)?this._options.mimeType=wn:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data);}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(ae.PLAY));}catch(e){console.error("Failed to start recording",e),this.telemetryManager.sendEventError(e,"camera recording. Failed to start recording");}};this._stopRecording=()=>{this._mediaRecorder?.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(ae.STOP);}),this._mediaRecorder?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this._activeTab}}});};this._toggleRecording=()=>{if(this._mediaRecorder?.state==="recording")return;let e=this._videoRef.value;e&&(!e.paused&&!e.ended&&e.readyState>2?e.pause():e.paused&&e.play());};this._toggleEnableAudio=()=>{this._stream?.getAudioTracks().forEach(e=>{e.enabled=!e.enabled,this._toggleMicrophoneIcon=e.enabled?"microphone":"microphone-mute",this._audioSelectDisabled=!e.enabled;});};this._previewVideo=()=>{try{let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=URL.createObjectURL(e),i=this._videoRef.value;if(!i)return;i.muted=!1,i.volume=1,this._setVideoSource(null),i.src=t,this._attachPreviewListeners(i);}catch(e){console.error("Failed to preview video",e),this.telemetryManager.sendEventError(e,"camera previewing. Failed to preview video");}};this._retake=()=>{if(this._setCameraState(ae.RETAKE),this._activeTab===C.VIDEO){this._setVideoSource(this._stream);let e=this._videoRef.value;e&&(e.muted=true);}this._videoRef.value?.play?.();};this._accept=()=>{if(this._setCameraState(ae.ACCEPT),this._activeTab===C.PHOTO){this._canvas?.toBlob(s=>{if(!s)return;let n=this._createFile("camera","jpeg",Cn,s);this._toSend(n);},Cn);return}let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=this._guessExtensionByMime(this._mediaRecorder?.mimeType),i=this._createFile("video",t,`video/${t}`,e);this._toSend(i),this._chunks=[];};this._handlePhoto=e=>{e===ae.SHOT&&(this._tabVideoHidden=true,this._cameraHidden=true,this._tabCameraHidden=true,this._cameraActionsHidden=false,this._cameraSelectHidden=true),(e===ae.RETAKE||e===ae.ACCEPT)&&(this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._cameraHidden=false,this._cameraActionsHidden=true,this._cameraSelectHidden=this._cameraDevices.length<=1);};this._handleVideo=e=>{e===ae.PLAY&&(this._timerHidden=false,this._tabCameraHidden=true,this._cameraSelectHidden=true,this._audioSelectHidden=true,this._currentTimelineIcon="pause",this._currentIcon="square",this._mutableClassButton="uc-shot-btn uc-camera-action uc-stop-record"),e===ae.STOP&&(this._timerHidden=false,this._cameraHidden=true,this._audioToggleMicrophoneHidden=true,this._cameraActionsHidden=false),(e===ae.RETAKE||e===ae.ACCEPT)&&(this._timerHidden=true,this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._cameraHidden=false,this._cameraActionsHidden=true,this._audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording,this._currentIcon="video-camera-full",this._mutableClassButton="uc-shot-btn uc-camera-action",this._audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._cameraSelectHidden=this._cameraDevices.length<=1);};this._setCameraState=e=>{this._activeTab===C.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===C.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e);};this._handleActiveTab=e=>{e===C.PHOTO&&(this._currentIcon="camera-full",this._audioSelectHidden=true,this._audioToggleMicrophoneHidden=true),e===C.VIDEO&&(this._currentTimelineIcon="play",this._currentIcon="video-camera-full",this._audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording),this.telemetryManager.sendEvent({eventType:x.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:e}}}),this._activeTab=e;};this._createFile=(e,t,i,s)=>{let n=Date.now(),a=`${e}-${n}.${t}`;return new File([s],a,{lastModified:n,type:i})};this._toSend=e=>{this.api.addFileFromObject(e,{source:T.CAMERA}),this.routerLayer.navigateAfterFileAdd();};this._setPermissionsState=S(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===C.VIDEO&&this.cfg.enableAudioRecording,i=this._activeTab===C.PHOTO?"camera-full":"video-camera-full";e==="granted"?(this._videoHidden=false,this._cameraHidden=false,this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._messageHidden=true,this._timerHidden=true,this._currentIcon=i,this._audioToggleMicrophoneHidden=!t,this._audioSelectHidden=!t):e==="prompt"?(this._l10nMessage="camera-permissions-prompt",this._videoHidden=true,this._cameraHidden=true,this._tabCameraHidden=true,this._messageHidden=false,this._stopCapture()):(this._l10nMessage="camera-permissions-denied",this._videoHidden=true,this._messageHidden=false,this._tabCameraHidden=!this._cameraModes.includes(C.PHOTO),this._tabVideoHidden=!this._cameraModes.includes(C.VIDEO),this._cameraActionsHidden=true,this._mutableClassButton="uc-shot-btn uc-camera-action",this._stopCapture());},300);this._makeStreamInactive=()=>{if(!this._stream)return false;let e=this._stream?.getAudioTracks(),t=this._stream?.getVideoTracks();return e.forEach(i=>{i.stop();}),t.forEach(i=>{i.stop();}),true};this._stopCapture=()=>{this._capturing&&(this._videoRef.value&&(this._videoRef.value.volume=0),this._currentVideoSource?.getTracks?.()?.[0]?.stop(),this._detachPreviewListeners(this._videoRef.value),this._setVideoSource(null),this._makeStreamInactive(),this._stopTimer(),this._capturing=false);};this._capture=async()=>{let e={video:{...Wc},audio:this.cfg.enableAudioRecording?{}:false};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this._videoRef.value&&(this._videoRef.value.volume=0);try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied");}),this._setVideoSource(this._stream),this._capturing=!0,this._setPermissionsState("granted");}catch(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t),this.telemetryManager.sendEventError(t,"camera capturing. Failed to capture camera");}};this._handlePermissionsChange=()=>{this._capture();};this._permissionAccess=async()=>{try{this._teardownPermissionListeners();for(let e of qc){let t=await navigator.permissions.query({name:e});this._permissionResponses[e]=t,t.addEventListener("change",this._handlePermissionsChange),this._permissionCleanupFns.push(()=>{t.removeEventListener("change",this._handlePermissionsChange);});}this._unsubPermissions=()=>{this._teardownPermissionListeners();};}catch(e){this._teardownPermissionListeners(),console.log("Failed to use permissions API. Fallback to manual request mode.",e),this.telemetryManager.sendEventError(e,"camera permissions. Failed to use permissions API"),this._capture();}};this._requestDeviceAccess=async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices);}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get user media"),console.log("Failed to get user media",e);}};this._getDevices=async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=e.filter(t=>t.kind==="videoinput").map((t,i)=>({text:t.label.trim()||`${this.l10n("caption-camera")} ${i+1}`,value:t.deviceId})),this._audioDevices=this.cfg.enableAudioRecording?e.filter(t=>t.kind==="audioinput").map(t=>({text:t.label.trim(),value:t.deviceId})):[],this._cameraSelectOptions=this._cameraDevices,this._cameraSelectHidden=this._cameraDevices.length<=1,this._selectedCameraId=this._cameraDevices[0]?.value??null,this._audioSelectOptions=this._audioDevices,this._audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._selectedAudioId=this._audioDevices[0]?.value??null;}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get devices"),console.log("Failed to get devices",e);}};this._onActivate=async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes);};this._onDeactivate=async()=>{this._unsubPermissions&&this._unsubPermissions(),window.chrome||this._setPermissionsState("denied"),this._stopCapture();};this._handleCameraModes=e=>{this._tabVideoHidden=!e.includes(C.VIDEO),this._tabCameraHidden=!e.includes(C.PHOTO);let t=e[0];t&&(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t);};}_attachPreviewListeners(e){this._detachPreviewListeners(e),e.addEventListener("play",this._handlePreviewPlay),e.addEventListener("pause",this._handlePreviewPause);}_detachPreviewListeners(e){e?.removeEventListener("play",this._handlePreviewPlay),e?.removeEventListener("pause",this._handlePreviewPause);}_setVideoSource(e){this._currentVideoSource!==e&&(this._currentVideoSource=e,this._applyVideoSource());}_applyVideoSource(){let e=this._videoRef.value;if(!e)return;let t=this._currentVideoSource??null;e.srcObject!==t&&(e.srcObject=t);}_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");let e=this._videoRef.value;if(!e)throw new Error("Video element not found");this._canvas.height=e.videoHeight,this._canvas.width=e.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(e,0,0),e.pause();}_guessExtensionByMime(e){let t={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return "webm";if(e){let i=e.split("/");if(i?.[0]==="video"){let n=i.slice(1).join("/")?.split(";")[0];if(n&&t[n])return t[n]}}return "avi"}get _cameraModes(){return N(this.cfg.cameraModes).filter(e=>e===C.PHOTO||e===C.VIDEO)}_teardownPermissionListeners(){if(this._permissionCleanupFns.length!==0){for(let e of this._permissionCleanupFns)e();this._permissionCleanupFns=[],this._unsubPermissions=null;}}initCallback(){super.initCallback(),this.subConfigValue("cameraMirror",e=>{this._videoTransformCss=e?"scaleX(-1)":null;}),this.subConfigValue("enableAudioRecording",e=>{this._audioToggleMicrophoneHidden=!e,this._audioSelectDisabled=!e;}),this.subConfigValue("cameraModes",e=>{if(!this.isConnected)return;let t=V(e);this._handleCameraModes(t.filter(i=>i===C.PHOTO||i===C.VIDEO));}),this._onActivate();}firstUpdated(e){super.firstUpdated(e),this._applyVideoSource();}updated(e){super.updated(e),this._applyVideoSource();}_destroy(){this._teardownPermissionListeners(),navigator.mediaDevices?.removeEventListener("devicechange",this._getDevices),this._detachPreviewListeners(this._videoRef.value),this._setVideoSource(null);}disconnectedCallback(){super.disconnectedCallback(),this._onDeactivate(),this._destroy();}render(){return html`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.$["*historyBack"]} title=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div ?hidden=${!this._cameraSelectHidden}><uc-icon name="camera"></uc-icon><span>${this.l10n("caption-camera")}</span></div><uc-select class="uc-camera-select" .options=${this._cameraSelectOptions} ?hidden=${this._cameraSelectHidden} @change=${this._handleCameraSelectChange} ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline style=${styleMap({transform:this._videoTransformCss})} ?hidden=${this._videoHidden} ${ref(this._videoRef)} ></video><div class="uc-message-box" ?hidden=${this._messageHidden}><span>${this.l10n(this._l10nMessage)}</span><button type="button" @click=${this._handleRequestPermissions} ?hidden=${this._requestBtnHidden} >${this.l10n("camera-permissions-request")}</button></div></div><div class="uc-controls"><div class="uc-switcher" ?hidden=${!this._timerHidden}><button data-id="photo" type="button" class=${classMap({"uc-switch":true,"uc-mini-btn":true,"uc-active":this._activeTab===C.PHOTO})} @click=${this._handleClickTab} ?hidden=${this._tabCameraHidden} data-testid="tab-photo" ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class=${classMap({"uc-switch":true,"uc-mini-btn":true,"uc-active":this._activeTab===C.VIDEO})} @click=${this._handleClickTab} ?hidden=${this._tabVideoHidden} data-testid="tab-video" ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" @click=${this._handleToggleRecording} ?hidden=${this._timerHidden} data-testid="recording-timer" ><uc-icon name=${this._currentTimelineIcon}></uc-icon><span ${ref(this._timerRef)}> 00:00 </span><span ${ref(this._lineRef)} class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" ?hidden=${this._cameraActionsHidden} ><button type="button" class="uc-secondary-btn" @click=${this._handleRetake} >${this.l10n("retake")}</button><button type="button" class="uc-primary-btn" @click=${this._handleAccept} data-testid="accept" >${this.l10n("accept")}</button></div><button type="button" data-testid="shot" @click=${this._handleStartCamera} class=${this._mutableClassButton} ?hidden=${this._cameraHidden} ><uc-icon name=${this._currentIcon}></uc-icon></button><div class="uc-select"><button type="button" class="uc-mini-btn uc-btn-microphone" @click=${this._handleToggleAudio} ?hidden=${this._audioToggleMicrophoneHidden} data-testid="toggle-microphone" ><uc-icon name=${this._toggleMicrophoneIcon}></uc-icon></button><uc-select class="uc-audio-select" .options=${this._audioSelectOptions} ?hidden=${this._audioSelectHidden} ?disabled=${this._audioSelectDisabled} @change=${this._handleAudioSelectChange} data-testid="audio-select" ></uc-select></div></div>`}};d([state()],M.prototype,"_videoTransformCss",2),d([state()],M.prototype,"_videoHidden",2),d([state()],M.prototype,"_messageHidden",2),d([state()],M.prototype,"_requestBtnHidden",2),d([state()],M.prototype,"_cameraSelectOptions",2),d([state()],M.prototype,"_cameraSelectHidden",2),d([state()],M.prototype,"_l10nMessage",2),d([state()],M.prototype,"_timerHidden",2),d([state()],M.prototype,"_cameraHidden",2),d([state()],M.prototype,"_cameraActionsHidden",2),d([state()],M.prototype,"_audioSelectOptions",2),d([state()],M.prototype,"_audioSelectHidden",2),d([state()],M.prototype,"_audioSelectDisabled",2),d([state()],M.prototype,"_audioToggleMicrophoneHidden",2),d([state()],M.prototype,"_tabCameraHidden",2),d([state()],M.prototype,"_tabVideoHidden",2),d([state()],M.prototype,"_currentIcon",2),d([state()],M.prototype,"_currentTimelineIcon",2),d([state()],M.prototype,"_toggleMicrophoneIcon",2),d([state()],M.prototype,"_mutableClassButton",2);var Tn={id:"camera",setup:async({pluginApi:o,uploaderApi:r})=>{ie({CameraSource:M}),o.registry.registerSource({id:"camera",label:"src-type-camera",icon:"camera",expand:()=>{if(!Lo.htmlMediaCapture)return ["camera"];let e=V(o.config.get("cameraModes"));return e.length?e.map(t=>`mobile-${t}-camera`):["mobile-photo-camera"]},onSelect:()=>{r.setCurrentActivity(A.CAMERA),r.setModalState(true);}}),o.registry.registerSource({id:"mobile-photo-camera",label:"src-type-mobile-photo-camera",icon:"camera",onSelect:()=>{r.openSystemDialog({captureCamera:true,modeCamera:"photo"});}}),o.registry.registerSource({id:"mobile-video-camera",label:"src-type-mobile-video-camera",icon:"camera",onSelect:()=>{r.openSystemDialog({captureCamera:true,modeCamera:"video"});}}),o.registry.registerActivity({id:A.CAMERA,render:e=>{let t=document.createElement("uc-camera-source");return e.append(t),()=>{e.replaceChildren();}}});}};var lo={};mo(lo,{BtnUi:()=>le,CloudImageEditor:()=>Qi,CloudImageEditorBlock:()=>j,Config:()=>ct,CropFrame:()=>$t,EditorAspectRatioButtonControl:()=>Bt,EditorCropButtonControl:()=>Ht,EditorFilterControl:()=>xe,EditorFreeformButtonControl:()=>Wi,EditorImageCropper:()=>Dt,EditorImageFader:()=>Bi,EditorOperationControl:()=>zt,EditorScroller:()=>Kt,EditorSlider:()=>Nt,EditorToolbar:()=>ee,Icon:()=>Oe,LineLoaderUi:()=>Ut,PresenceToggle:()=>pt,SliderUi:()=>ve,defineComponents:()=>ie});var Zc="cloud-image-editor",Yc="<svg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></svg>",En={id:Zc,setup:async({pluginApi:o,uploaderApi:r})=>(ie({...lo,...so}),o.registry.registerIcon({name:"edit-file",svg:Yc}),o.registry.registerFileAction({id:"edit-file",icon:"edit-file",label:"file-item-edit-button",shouldRender:t=>!!(t.isImage&&t.cdnUrl),onClick:t=>{r.setCurrentActivity?.(A.CLOUD_IMG_EDIT,{internalId:t.internalId}),r.setModalState?.(true);}}),o.registry.registerActivity({id:A.CLOUD_IMG_EDIT,render:t=>{let i=document.createElement("uc-cloud-image-editor-activity");return t.append(i),()=>{t.replaceChildren();}}}),r.on(b.FILE_UPLOAD_SUCCESS,t=>{if(!t.isImage)return;let i=o.config.get("cropPreset"),s=o.config.get("useCloudImageEditor"),n=o.config.get("cloudImageEditorAutoOpen"),a=r._uploadCollection.size;s&&a===1&&(i||n)&&(r.setCurrentActivity?.(A.CLOUD_IMG_EDIT,{internalId:t.internalId}),r.setModalState?.(true));}))};var xn={id:"external-sources",setup:async({pluginApi:o,uploaderApi:r})=>{ie({ExternalSource:te}),o.registry.registerActivity({id:A.EXTERNAL,render:e=>{let t=document.createElement("uc-external-source");return e.append(t),()=>{e.replaceChildren();}}});for(let e of Object.values(Q))o.registry.registerSource({id:e,label:`src-type-${e}`,icon:e,onSelect:()=>{r.setCurrentActivity(A.EXTERNAL,{externalSourceType:e}),r.setModalState(true);}});}};var Xc=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,Sn=o=>{if(typeof o!="string")return false;let r=Xc.exec(o.toLocaleLowerCase())??[];if(r.length===0)return false;let e=Number(r[1])*Number(r[2]),t=16384*16384;return e>t?(console.warn(`Shrinked size can not be larger than ${Math.floor(t/1e3/1e3)}MP. You have set ${r[1]}x${r[2]} (${Math.ceil(e/1e3/100)/10}MP).`),false):{quality:r[3]?Number(r[3])/100:void 0,size:e}};var In={id:"image-shrink",setup({pluginApi:o}){o.registry.registerFileHook({type:"beforeUpload",handler:async({file:r})=>{let e=o.config.get("imageShrink");if(!e)return {file:r};let t=Sn(e);if(!t)return console.warn("[ImageShrinkPlugin] Image shrink settings are invalid, skipping shrinking"),{file:r};try{return {file:await shrinkFile(r,t)}}catch{return {file:r}}}});}};var An={id:"instagram",setup({pluginApi:o}){o.registry.registerSource({id:"instagram",label:"src-type-instagram",icon:"instagram",expand:()=>(console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here: https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US"),[]),onSelect:()=>{}});}};var kn={id:T.LOCAL,setup:({pluginApi:o,uploaderApi:r})=>{o.registry.registerSource({id:T.LOCAL,label:"src-type-local",icon:"local",onSelect:()=>{r.openSystemDialog();}});}};var Mn={id:"url-source",setup:async({pluginApi:o,uploaderApi:r})=>{ie({UrlSource:gt}),o.registry.registerActivity({id:A.URL,render:e=>{let t=document.createElement("uc-url-source");return e.append(t),()=>{e.replaceChildren();}}}),o.registry.registerSource({id:"url",label:"src-type-from-url",icon:"url",onSelect:()=>{r.setCurrentActivity(A.URL),r.setModalState(true);}});}};var vt=[{configDeps:["useCloudImageEditor"],isEnabled:o=>!!o("useCloudImageEditor"),load:()=>En},{configDeps:["imageShrink"],isEnabled:o=>!!o("imageShrink"),load:()=>In},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes(T.LOCAL),load:()=>kn},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes(T.CAMERA),load:()=>Tn},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes("instagram"),load:()=>An},{configDeps:["sourceList"],isEnabled:o=>Object.values(Q).some(r=>V(o("sourceList")).includes(r)),load:()=>xn},{configDeps:["sourceList"],isEnabled:o=>V(o("sourceList")).includes(T.URL),load:()=>Mn}];var Wt=class extends Ee{constructor(){super();this.headless=false;this.smartButton=false;this.init$={...this.init$};}static{this.lazyPlugins=vt;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"];}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION});}get isSmartBtnActive(){return this.smartButton}_renderSmartButton(){return html`<uc-smart-btn></uc-smart-btn>`}_renderStaticButton(){return html`<uc-simple-btn></uc-simple-btn>`}_renderButton(){return this.headless?null:this.smartButton?this._renderSmartButton():this._renderStaticButton()}render(){return html` ${super.render()} ${this._renderButton()}<uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]}>${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-plugin-activity-renderer mode="modal"></uc-plugin-activity-renderer>`}};d([property({type:Boolean})],Wt.prototype,"headless",2),d([property({attribute:"smart-button",type:Boolean})],Wt.prototype,"smartButton",2);var tr=class extends Ee{constructor(){super();this._couldCancel=false;this._handleCancel=()=>{if(this._couldHistoryBack){let e=this.$["*historyBack"];e?.();return}this._couldShowList&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST);};this.init$={...this.init$};}static{this.lazyPlugins=vt;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"];}get _couldHistoryBack(){let e=this.$["*history"];return !e||e.length<=1?false:e[e.length-1]!==E.activities.START_FROM}get _couldShowList(){let e=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(e)&&e.length>0}_getInitActivity(){return this.getCssData("--cfg-init-activity")||E.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e);}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0&&this.$["*currentActivity"]===e&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST);}),this.sub("*history",()=>{this._couldCancel=this._couldHistoryBack||this._couldShowList;});}render(){return html` ${super.render()}<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel} ?hidden=${!this._couldCancel} >${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-plugin-activity-renderer mode="inline"></uc-plugin-activity-renderer>`}};d([state()],tr.prototype,"_couldCancel",2);var uo="active",ir="",Fe=class extends Ee{constructor(){super();this._singleUpload=false;this._isHiddenStartFrom=false;this._classUploadList=ir;this._classStartFrom=ir;this._buttonTextKey="choose-file";this._handleModalOpen=e=>{e.id===E.activities.CLOUD_IMG_EDIT&&(this._classUploadList=uo),this.$["*currentActivity"]===E.activities.UPLOAD_LIST&&(this._classUploadList=uo,this._isHiddenStartFrom=true);let t=this.$["*uploadList"];(!t||t.length<=0)&&(this._classStartFrom=uo);};this._handleModalClose=e=>{e.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST,this._isHiddenStartFrom=false),e.id===E.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=E.activities.UPLOAD_LIST);};this.init$={...this.init$};}static{this.lazyPlugins=vt;}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"];}_getInitActivity(){return this.getCssData("--cfg-init-activity")||E.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:x.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t===E.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),t||(this.$["*currentActivity"]=e);}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0?(this.$["*currentActivity"]=E.activities.UPLOAD_LIST,this._classStartFrom=ir):(this._classUploadList=ir,this._isHiddenStartFrom=false,this.$["*currentActivity"]=e);}),this.subConfigValue("confirmUpload",t=>{t!==false&&(this.cfg.confirmUpload=false);}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t),this.subConfigValue("multiple",i=>{t==="grid"?(i?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this._singleUpload=!i):(this.style.removeProperty("--uc-grid-col"),this._singleUpload=false);});}),this.subConfigValue("multiple",t=>{this._buttonTextKey=t?"choose-files":"choose-file";}),this.modalManager?.subscribe(B.OPEN,this._handleModalOpen),this.modalManager?.subscribe(B.CLOSE,this._handleModalClose);}disconnectedCallback(){super.disconnectedCallback(),this.modalManager?.unsubscribe(B.OPEN,this._handleModalOpen),this.modalManager?.unsubscribe(B.CLOSE,this._handleModalClose);}render(){return html` ${super.render()}<uc-start-from ?hidden=${this._isHiddenStartFrom} class=${this._classStartFrom}><uc-drop-area ?single=${this._singleUpload} initflow clickable tabindex="0" ><span>${this.l10n(this._buttonTextKey)}</span></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list class=${this._classUploadList}></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]} >${this.l10n("start-from-cancel")}</button></uc-start-from></uc-modal><uc-plugin-activity-renderer mode="modal"></uc-plugin-activity-renderer>`}};d([state()],Fe.prototype,"_singleUpload",2),d([state()],Fe.prototype,"_isHiddenStartFrom",2),d([state()],Fe.prototype,"_classUploadList",2),d([state()],Fe.prototype,"_classStartFrom",2),d([state()],Fe.prototype,"_buttonTextKey",2);
8
8
  export{E as ActivityBlock,Dr as ActivityHeader,or as BaseComponent,g as Block,le as BtnUi,M as CameraSource,Qi as CloudImageEditor,Gt as CloudImageEditorActivity,j as CloudImageEditorBlock,ct as Config,Pr as Copyright,$t as CropFrame,R as Data,oe as DropArea,Ni as DropDown,Bt as EditorAspectRatioButtonControl,Ht as EditorCropButtonControl,xe as EditorFilterControl,Wi as EditorFreeformButtonControl,Dt as EditorImageCropper,Bi as EditorImageFader,zt as EditorOperationControl,Kt as EditorScroller,Nt as EditorSlider,ee as EditorToolbar,te as ExternalSource,Q as ExternalUploadSource,ze as FileActionButton,Br as FileItem,tr as FileUploaderInline,Fe as FileUploaderMinimal,Wt as FileUploaderRegular,Ri as FormInput,Oe as Icon,kr as Img,Ut as LineLoaderUi,It as Modal,B as ModalEvents,Qr as NoWrapModeSmartBtn,pe as PACKAGE_NAME,he as PACKAGE_VERSION,Rt as PluginActivityHost,ut as PluginActivityRenderer,pt as PresenceToggle,Xr as PrimaryAction,ot as ProgressBar,At as ProgressBarCommon,st as Select,Pt as SimpleBtn,ve as SliderUi,ge as SmartBtn,Ee as SolutionBlock,Le as SourceBtn,kt as SourceList,Vr as Spinner,Fr as StartFrom,lt as Thumb,W as UID,Nr as UploadCtxProvider,ue as UploadList,T as UploadSource,_ as UploaderBlock,gt as UrlSource,ie as defineComponents,yo as defineLocale,Wn as loadFileUploaderFrom,oi as toKebabCase};