@uploadcare/file-uploader 1.25.0-alpha.0 → 1.25.0-alpha.1

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.
@@ -24,7 +24,7 @@
24
24
  *
25
25
  */
26
26
  var Ut=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var ar=Object.prototype.hasOwnProperty;var Dt=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of nr(i))!ar.call(s,r)&&r!==e&&Ut(s,r,{get:()=>i[r],enumerable:!(t=Ft(i,r))||t.enumerable});return s},u=(s,i,e)=>(Dt(s,i,"default"),e&&Dt(e,i,"default"));var p=(s,i,e,t)=>{for(var r=t>1?void 0:t?Ft(i,e):i,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(t?n(i,e,r):n(r))||r);return t&&r&&Ut(i,e,r),r};var m={};u(m,_s);u(m,Ts);import"@lit/reactive-element";import"lit-html";import*as _s from"lit-element/lit-element.js";import*as Ts from"lit-html/is-server.js";var c={};u(c,ws);u(c,Cs);u(c,Es);u(c,xs);u(c,Ss);u(c,ks);u(c,Rs);u(c,Os);u(c,As);import*as ws from"@lit/reactive-element/decorators/custom-element.js";import*as Cs from"@lit/reactive-element/decorators/property.js";import*as Es from"@lit/reactive-element/decorators/state.js";import*as xs from"@lit/reactive-element/decorators/event-options.js";import*as Ss from"@lit/reactive-element/decorators/query.js";import*as ks from"@lit/reactive-element/decorators/query-all.js";import*as Rs from"@lit/reactive-element/decorators/query-async.js";import*as Os from"@lit/reactive-element/decorators/query-assigned-elements.js";import*as As from"@lit/reactive-element/decorators/query-assigned-nodes.js";var g={};u(g,Is);import*as Is from"lit-html/directives/ref.js";var fe={};u(fe,Ps);import*as Ps from"lit-html/directives/unsafe-svg.js";var O={BIND_ATTR:"bind",ATTR_BIND_PX:"@",SHARED_CTX_PX:"*",PARENT_CTX_PX:"^",NAMED_CTX_SPLTR:"/",COMPUTED_PX:"+",CSS_DATA_PX:"--",CTX_NAME_ATTR:"ctx",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx",EL_REF_ATTR:"ref",AUTO_TAG_PX:"sym",LIST_ATTR:"itemize",LIST_ITEM_TAG_ATTR:"item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL_ATTR:"use-template",DEFAULT_SLOT_KEY:"__default__",TEXT_NODE_SKIP_ATTR:"skip-text-nodes",TEXT_NODE_OPEN_TOKEN:"{{",TEXT_NODE_CLOSE_TOKEN:"}}"};function lr(s){let i=e=>{for(let t in e)e[t]?.constructor===Object&&(e[t]=i(e[t]));return{...e}};return i(s)}var X=class s{#i;#r;#e;constructor(i){i.constructor===Object?this.store=lr(i):(this.#e=!0,this.store=i),this.callbackMap=Object.create(null)}static#t(i,e){console.warn(`Symbiote PubSub: cannot ${i}. Prop name: `+e)}read(i){if(!this.#e&&!this.store.hasOwnProperty(i))return s.#t("read",i),null;if(typeof i=="string"&&i.startsWith(O.COMPUTED_PX)){let e=this.store[i];if(e?.constructor!==Function){s.#t("compute",i);return}this.__computedMap||(this.__computedMap={});let t=e();return Object.keys(this.__computedMap).includes(i)||(this.__computedMap[i]=t,this.notify(i)),t}else return this.store[i]}has(i){return this.#e?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this.#e&&!this.store.hasOwnProperty(i)){s.#t("publish",i);return}if(i?.startsWith(O.COMPUTED_PX)&&e.constructor!==Function){s.#t("publish computed",i);return}!(this.store[i]===null||e===null)&&typeof this.store[i]!=typeof e&&console.warn(`Symbiote PubSub: type warning for "${i}" [${typeof this.store[i]} -> ${typeof e}]`),this.store[i]=e,this.notify(i)}get proxy(){if(!this.#r){let i=Object.create(null);this.#r=new Proxy(i,{set:(e,t,r)=>(this.pub(t,r),!0),get:(e,t)=>{this.read(t)}})}return this.#r}multiPub(i){for(let e in i)this.pub(e,i[e])}static#s(i,e){this.globalStore.forEach(t=>{t.__computedMap&&Object.keys(t.__computedMap).forEach(r=>{if(t===i&&e===r)return;let o=`__${r}_timeout`;t[o]&&window.clearTimeout(t[o]),t[o]=window.setTimeout(()=>{let n=t.read(r);n!==t.__computedMap[r]&&(t.__computedMap[r]=n,t.notify(r))})})})}notify(i){let e=i?.startsWith(O.COMPUTED_PX);if(this.callbackMap[i]){let t=this.read(i);this.callbackMap[i].forEach(r=>{r(t)}),e&&(this.__computedMap[i]=t)}!e&&s.#s(this,i)}sub(i,e,t=!0){return!this.#e&&!this.store.hasOwnProperty(i)?(s.#t("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.read(i)),{remove:()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},callback:e})}set uid(i){!this.#i&&(this.#i=i)}get uid(){return this.#i}static registerCtx(i,e=Symbol()){let t=s.globalStore.get(e);return t?console.warn('PubSub: context UID "'+e+'" is already in use'):(t=new s(i),t.uid=e,s.globalStore.set(e,t)),t}static deleteCtx(i){s.globalStore.delete(i)}static getCtx(i,e=!0){return s.globalStore.get(i)||(e&&console.warn('PubSub: wrong context UID - "'+i+'"'),null)}};X.globalStore=new Map;var Vt="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",cr=Vt.length-1,me=class{static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:Vt.charAt(Math.random()*cr);return e}};var qs=[O.LIST_ATTR,O.LIST_ITEM_TAG_ATTR,O.EL_REF_ATTR,O.USE_TPL_ATTR,O.CTX_NAME_ATTR,O.CTX_OWNER_ATTR];function z(s,...i){let e="",t=new CSSStyleSheet;return s.forEach((r,o)=>{e+=r+i[o]}),z.processors.forEach(r=>{e=r(e)}),z.clearProcessors(),t.replaceSync(e),t}z.processors=[];z.clearProcessors=function(){z.processors=[]};z.useProcessor=function(...s){return z.processors=[...z.processors,...s],z};var Uo={baseCDN:"https://ucarecdn.com",baseURL:"https://upload.uploadcare.com",maxContentLength:50*1024*1024,retryThrottledRequestMaxTimes:1,retryNetworkErrorMaxTimes:3,multipartMinFileSize:25*1024*1024,multipartChunkSize:5*1024*1024,multipartMinLastPartSize:1024*1024,maxConcurrentRequests:4,pollingTimeoutMilliseconds:1e4,pusherKey:"79ae88bd931ea68464d9"};var jt;(function(s){s.Token="token",s.FileInfo="file_info"})(jt||(jt={}));var Kt;(function(s){s.Unknown="unknown",s.Waiting="waiting",s.Progress="progress",s.Error="error",s.Success="success"})(Kt||(Kt={}));var Fo=window.WebSocket;var De=class{_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(i){this._concurrency=i}run(){let i=this._concurrency-this._running;for(let e=0;e<i;e++){let t=this._pending.shift();if(!t)return;let r=this._resolvers.get(t),o=this._rejectors.get(t);if(!r||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this.run()}).then(n=>r(n)).catch(n=>o(n))}}add(i,{autoRun:e}={autoRun:!0}){return new Promise((t,r)=>{this._resolvers.set(i,t),this._rejectors.set(i,r),this._pending.push(i),e&&this.run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this.run()}get concurrency(){return this._concurrency}};var Ht=()=>({});var hr={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function xe(s,i){i.tabIndex=0,i.focus(),s.tabIndex=-1}function pt(s){let i=s.role||s.type||s.tagName;if(!i)return null;let e=hr[i.toLowerCase()];if(!e)return null;for(let t of e){let r=s.closest(`[role=${t}]`);if(r)return r}}function ft(s,i){return i.role==="toolbar"?pr(i):i.querySelectorAll(`[role=${s.role}]`)}function pr(s){return[...s.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function fr(s){let i=s.getAttribute("aria-orientation");if(i==="vertical")return!1;if(i==="horizontal")return!0;let e=s.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function Bt(s){return i=>{let e=!1,t=s?.searchDelayMs||300,r=0,o="";function n(h){let y=pt(h.target);if(!y){a();return}let b=ft(h.target,y),_=Array.from(b).indexOf(h.target),I="ArrowDown",R="ArrowUp";if(fr(y)&&(i.document.dir==="rtl"?(I="ArrowLeft",R="ArrowRight"):(I="ArrowRight",R="ArrowLeft")),h.key===I)h.preventDefault(),xe(h.target,b[_+1]||b[0]);else if(h.key===R)h.preventDefault(),xe(h.target,b[_-1]||b[b.length-1]);else if(h.key==="Home")h.preventDefault(),xe(h.target,b[0]);else if(h.key==="End")h.preventDefault(),xe(h.target,b[b.length-1]);else if(h.key.length===1&&y.role!=="tablist"){let P=Date.now();P-r<=t?o+=h.key.toLowerCase():o=h.key.toLowerCase(),r=P;let le=Array.from(b).find(or=>or.textContent?.trim()?.toLowerCase()?.startsWith(o));le&&(h.preventDefault(),xe(h.target,le))}}function a(){e=!1,i.removeEventListener("keydown",n)}function l(h){let y=pt(h.target);if(y){e||(e=!0,i.addEventListener("keydown",n));let b=ft(h.target,y);for(let _ of b)_!==h.target&&_.setAttribute("tabindex",-1)}else e&&a()}function d(h){(!h.relatedTarget||h.relatedTarget===i.document)&&a()}function f(h){let y=pt(h.target);if(y){let b=ft(h.target,y);for(let _ of b)_!==h.target&&_.setAttribute("tabindex",-1);h.target.setAttribute("tabindex",0)}}return i.addEventListener("click",f),i.addEventListener("focusin",l),i.addEventListener("focusout",d),()=>{a(),i.removeEventListener("click",f),i.removeEventListener("focusin",l),i.removeEventListener("focusout",d)}}}function Gt(){return s=>{let i,e;function t(o){if(o.target.getAttribute("aria-hidden")==="true"){i=o.target,i.setAttribute("aria-hidden","false"),e=i.hidden,e&&(i.hidden=!1);let n=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function r(o){i&&i.contains(o.target)&&(!o.relatedTarget||!i.contains(o.relatedTarget))&&(o.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),e&&(i.hidden=!0),i=null)}return s.addEventListener("keyuxJump",t),s.addEventListener("focusout",r),()=>{s.removeEventListener("keyuxJump",t),s.removeEventListener("focusout",r)}}}function Xt(){return s=>{let i=[];function e(l){let d=s.document.activeElement;d&&d!==s.document.body&&i.push(new WeakRef(d)),l.focus({focusVisible:!0})}function t(){let l=i.pop();if(!l){s.document.activeElement.blur();return}let d=l.deref();d&&d.isConnected?d.focus():t()}let r=0,o;function n(l){clearInterval(o);let d=l.getAttribute("aria-controls");o=setInterval(()=>{if(r++>50){clearInterval(o);return}let f=s.document.getElementById(d);if(f){let h=f.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');h&&(clearInterval(o),f.dispatchEvent(new s.CustomEvent("keyuxJump",{bubbles:!0})),e(h))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&t()}return s.addEventListener("keydown",a),()=>{s.removeEventListener("keydown",a)}}}function qt(s){let i,e=s.split(" "),t;function r(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(o(),a.target.classList.add(...e),i=a.target,t=a.target)}function o(){i&&i.classList.remove(...e),t=null}function n(a){a.clientX===0&&a.clientY===0&&t!==a.target&&(o(),a.target.classList.add(...e),i=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",r),a.addEventListener("keyup",o),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",r),a.removeEventListener("keyup",o)})}function Wt(s,i){let e=i.map(t=>t(s));return()=>{e.forEach(t=>t())}}var mt=class{constructor(){this._listeners=new Map;this._scope=[]}addEventListener(i,e){let t=r=>{let o=r.target;o instanceof Node&&this._scope.some(n=>n===o||n.contains(o))&&e(r)};this._listeners.set(e,t),window.addEventListener(i,t)}removeEventListener(i,e){let t=this._listeners.get(e);t&&window.removeEventListener(i,t),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this._scope.push(i)}destroy(){this._scope=[];for(let i of this._listeners.values())window.removeEventListener("keydown",i),window.removeEventListener("keyup",i);this._listeners.clear()}},Ue=class{constructor(){this._scopedWindow=new mt,this._destroyKeyUX=Wt(this._scopedWindow,[Bt(),qt("is-pressed"),Xt(),Gt()])}registerBlock(i){this._scopedWindow.registerScope(i)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var Se={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"OneDrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var Fe=new Map,gt=new Map,Yt=(s,i)=>{Fe.has(s)&&console.log(`Locale ${s} is already defined. Overwriting...`),Fe.set(s,{...Se,...i})},mr=(s,i)=>{gt.set(s,i)},gr=(s,i)=>{typeof i=="function"?mr(s,i):Yt(s,i)},Qt=async s=>{if(!Fe.has(s)){if(!gt.has(s))throw new Error(`Locale ${s} is not defined`);let e=await gt.get(s)();Yt(s,e)}return Fe.get(s)};gr("en",Se);var te=s=>`*l10n/${s}`,yr="en",Ve=class{constructor(i){this._blockInstance=null;this._localeName="";this._blockInstance=i;for(let[e,t]of Object.entries(Se)){let r=this._blockInstance.has(te(e))?!this._blockInstance.$[te(e)]:!0;this._blockInstance.add(te(e),t,r)}setTimeout(()=>{i.subConfigValue("localeName",async e=>{if(!this._blockInstance||!e)return;this._localeName=e;let t=await Qt(e);if(e!==yr&&this._localeName!==e)return;let r=this._blockInstance.cfg.localeDefinitionOverride?.[e];for(let[o,n]of Object.entries(t)){let a=r?.[o];this._blockInstance.add(te(o),a??n,!0)}}),i.subConfigValue("localeDefinitionOverride",e=>{if(!e)return;let t=e[this._localeName];if(t)for(let[r,o]of Object.entries(t))this._blockInstance?.add(te(r),o,!0)})})}};var ge=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),ze=class{constructor(i){this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;this._block=i}_debugPrint(...i){this._block.debugPrint("[modal-manager]",...i)}registerModal(i,e){this._modals.set(i,e),this._notify(ge.ADD,{id:i,modal:e})}deleteModal(i){if(!this._modals.has(i))return!1;let e=this._modals.get(i);return this._modals.delete(i),this._activeModals.delete(i),this._notify(ge.DELETE,{id:i,modal:e}),!0}open(i){if(!this._modals.has(i))return this._debugPrint(`Modal with ID "${i}" not found`),!1;let e=this._modals.get(i);return this._activeModals.add(i),this._notify(ge.OPEN,{modal:e,id:i}),!0}close(i){if(!this._modals.has(i)||!this._activeModals.has(i))return this._debugPrint(`Modal with ID "${i}" not found or not active`),!1;let e=this._modals.get(i);return this._activeModals.delete(i),this._notify(ge.CLOSE,{id:i,modal:e}),!0}toggle(i){return this._modals.has(i)?this._activeModals.has(i)?this.close(i):this.open(i):(this._debugPrint(`Modal with ID "${i}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let i=Array.from(this._activeModals).pop();return i?this.close(i):!1}closeAll(){let i=this._activeModals.size;return this._activeModals.clear(),this._notify(ge.CLOSE_ALL,{}),i}subscribe(i,e){return this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(e),()=>this.unsubscribe(i,e)}unsubscribe(i,e){this._subscribers.has(i)&&this._subscribers.get(i)?.delete(e)}_notify(i,e){if(this._subscribers.has(i))for(let t of this._subscribers.get(i)??new Set)try{t(e)}catch(r){this._block.telemetryManager.sendEventError(r,"modal subscriber"),this._debugPrint("Error in modal subscriber:",r)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(ge.DESTROY,{})}};function br(s){return s.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`).replace(/__/g,"_")}function bt(s){return Array.isArray(s)?s.map(i=>typeof i=="object"&&i!==null?bt(i):i):typeof s!="object"||s===null?s:Object.fromEntries(Object.entries(s).map(([i,e])=>{let t=br(i);return typeof e=="object"&&e!==null?[t,bt(e)]:[t,e]}))}function vr(s){return{ok:!0,value:s}}function yt(s){return{ok:!1,error:s}}var _r="https://tlm.uploadcare.com/api/",vt=class{constructor(i=_r){this.baseUrl=i}async base(i,e={}){let t=`${this.baseUrl}${i}`;try{let r=await fetch(t,e);if(!r.ok)return yt(new Error(`Got non-200 response from "${t}". Status: ${r.status.toString()}`));try{let o=await r.json();return vr(o)}catch(o){return yt(new Error(`Error parsing JSON from "${t}". Error: ${o}`))}}catch(r){return yt(new Error(`Error fetching data from "${t}". Error: ${r}`))}}async post(i,e,t={}){return await this.base(i,{...t,method:"POST",body:JSON.stringify(bt(e)),headers:{"Content-Type":"application/json",...t.headers||{}}})}async get(i,e={}){return await this.base(i,{method:"GET",...e})}},Tr=async(s,i)=>({success:!0,data:i}),je=class extends vt{constructor(){super()}async sendEvent(i,e){let t=await Tr(void 0,i);if(!t.success)throw console.error("TelemetryAPIService: events: body is invalid",t.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",i,e)}};var ce=s=>s?s.split(",").map(i=>i.trim()).filter(Boolean):[],de=s=>s.join(",");var Zt=s=>{if(typeof s!="string"||!s)return"";let i=s.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},Ke=(...s)=>s.filter(i=>typeof i=="string"&&!!i).map(i=>Zt(i)).join("/-/"),q=(...s)=>{let i=Ke(...s);return i?`-/${i}/`:""};function He(s){let i=new URL(s),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),o="";return t>=0?o=e.slice(t):r>=0&&(o=e.slice(r+1)),o}function Be(s){let i=new URL(s),{pathname:e}=i,t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}function _t(s){let i=Jt(s),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}function Tt(s){return _t(s).split("/-/").filter(Boolean).map(e=>Zt(e))}function Jt(s){let i=new URL(s),e=He(s),t=ei(e)?ti(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}function ei(s){return s.startsWith("http")}function ti(s){let i=new URL(s);return{pathname:`${i.origin}${i.pathname??""}`,search:i.search??"",hash:i.hash??""}}var W=(s,i,e)=>{let t=new URL(Jt(s)),r=e??He(s),o=i??"";if(t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),r&&ei(r)){let n=ti(r);t.pathname=`${t.pathname}${o}${n.pathname||""}`,t.search=n.search,t.hash=n.hash}else t.pathname=`${t.pathname}${o}${r||""}`;return t.toString()},wt=(s,i)=>{let e=new URL(s);return e.pathname=`${i}/`,e.toString()};var ke=(s,i=",")=>s.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0);var Re=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:!1,flip:!1,crop:void 0}),ri=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function wr(s,i){if(typeof i=="number"){let e=i;return Re[s]!==e?`${s}/${e}`:""}if(typeof i=="boolean"){let e=i;return Re[s]!==e?`${s}`:""}if(s==="filter"&&i){let{name:e,amount:t}=i;return Re.filter===t?"":`${s}/${e}/${t}`}if(s==="crop"&&i){let{dimensions:e,coords:t}=i;return`${s}/${e.join("x")}/${t.join(",")}`}return""}function ie(s){return Ke(...ri.filter(i=>typeof s[i]<"u"&&s[i]!==null).map(i=>{let e=s[i];return wr(i,e)}).filter(i=>!!i))}var Ge=Ke("format/auto","progressive/yes"),Y=([s])=>typeof s<"u"?Number(s):void 0,ii=()=>!0,Cr=([s,i])=>({name:s,amount:typeof i<"u"?Number(i):100}),Er=([s,i])=>{if(!/\d+x\d+/.test(s)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:ke(s,"x").map(Number),coords:ke(i).map(Number)}},xr=Object.freeze({enhance:Y,brightness:Y,exposure:Y,gamma:Y,contrast:Y,saturation:Y,vibrance:Y,warmth:Y,filter:Cr,mirror:ii,flip:ii,rotate:Y,crop:s=>{let[i,e]=s,{dimensions:t,coords:r}=Er([i,e]);return{dimensions:t,coords:r}}});function Ct(s){let i={};for(let e of s){let[t,...r]=e.split("/");if(!t||!ri.includes(t))continue;let o=t,n=xr[o];try{let a=n(r);i[o]=a}catch(a){console.warn([`Failed to parse URL operation "${e}". It will be ignored.`,a instanceof Error?`Error message: "${a.message}"`:a,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
27
- `))}}return i}var E=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),L=Object.freeze([E.CROP,E.TUNING,E.FILTERS]),si=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),oi=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"]),ni=Object.freeze(["rotate","mirror","flip"]),Q=Re,j=Object.freeze({brightness:{zero:Q.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Q.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Q.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Q.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Q.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Q.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Q.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Q.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Q.filter,range:[0,100],keypointsNumber:1}});var Et="https://ucarecdn.com",Sr="https://upload.uploadcare.com",kr="https://social.uploadcare.com",Rr="https://ucarecd.net",Or={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:de(L),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Et,cdnCnamePrefixed:Rr,baseUrl:Sr,socialBaseUrl:kr,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},N=Object.freeze(Or);var Z=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),J=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"}),Xe=class{constructor(i){this._timeoutStore=new Map;this._targets=new Set;this._debugPrint=null;this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){for(let t of this._targets)t.dispatchEvent(new CustomEvent(i,{detail:e}));this._debugPrint?.(()=>{let t=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,t]})}emit(i,e,t={}){let{debounce:r}=t;if(typeof r!="number"&&!r){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let o=typeof r=="number"?r:20,n=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},o);this._timeoutStore.set(i,n)}};var ai="1.25.0-alpha.0";var qe="blocks",We=ai;var Ye=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(N);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new je,this._queue=new De(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:Z.CHANGE_CONFIG}),this._setConfig(e,t)})}_init(i){i===Z.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===Z.INIT_SOLUTION||i.eventType===Z.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:We,appName:qe,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[J.CHANGE,J.COMMON_UPLOAD_PROGRESS,J.FILE_ADDED,J.FILE_REMOVED,J.FILE_UPLOAD_START,J.FILE_UPLOAD_PROGRESS,J.FILE_UPLOAD_SUCCESS,J.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:Z.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:Z.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let o of t)if(!Object.hasOwn(e,o)||!this._checkObj(i[o],e[o]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var k=s=>`*cfg/${s}`;var li=s=>{let i=new Intl.Locale(s),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e};var ci=(s,i)=>new Intl.PluralRules(s).select(i);var Ir=s=>s;var di="plural:";function xt(s,i={},e={}){let{openToken:t="{{",closeToken:r="}}",transform:o=Ir}=e;for(let n in i){let a=i[n],l=a?.toString(),d=typeof l=="string"?o(l):String(l);s=s.replaceAll(t+n+r,d)}return s}function ui(s){let i=[],e=s.indexOf("{{");for(;e!==-1;){let t=s.indexOf("}}",e);if(t===-1)break;let r=s.substring(e+2,t);if(r.startsWith(di)){let o=s.substring(e+2,t).replace(di,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=s.indexOf("{{",t)}return i}function M(s,i){let e,t=((...r)=>{e&&clearTimeout(e),e=setTimeout(()=>s(...r),i)});return t.cancel=()=>{e&&clearTimeout(e)},t}var hi="--uploadcare-blocks-window-height",Oe=class s{static{this.clientsRegistry=new Set}static{this.flush=M(()=>{document.documentElement.style.setProperty(hi,`${window.innerHeight}px`)},100)}static registerClient(i){s.clientsRegistry.size===0&&s.attachTracker(),s.clientsRegistry.add(i)}static unregisterClient(i){s.clientsRegistry.delete(i),s.clientsRegistry.size===0&&s.detachTracker()}static attachTracker(){window.addEventListener("resize",s.flush,{passive:!0,capture:!0}),s.flush()}static detachTracker(){window.removeEventListener("resize",s.flush,{capture:!0}),document.documentElement.style.removeProperty(hi)}};var Pr=/\\([0-9a-fA-F]{1,6} ?)/g;function Lr(s){return s.length<2?!1:(s[0]==='"'||s[0]==="'")&&(s[s.length-1]==='"'||s[s.length-1]==="'")}function Mr(s){let i=s;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function $r(s){let i="",e="";for(let t=0;t<s.length;t++){let r=s[t+1];s[t]==="\\"&&r==='"'?(i+='\\"',t++):s[t]==='"'&&e!=="\\"?i+='\\"':i+=s[t],e=s[t]??""}return i}function pi(s){let i=s;Lr(s)&&(i=Mr(i),i=i.replace(Pr,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
27
+ `))}}return i}var E=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),L=Object.freeze([E.CROP,E.TUNING,E.FILTERS]),si=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),oi=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"]),ni=Object.freeze(["rotate","mirror","flip"]),Q=Re,j=Object.freeze({brightness:{zero:Q.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Q.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Q.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Q.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Q.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Q.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Q.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Q.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Q.filter,range:[0,100],keypointsNumber:1}});var Et="https://ucarecdn.com",Sr="https://upload.uploadcare.com",kr="https://social.uploadcare.com",Rr="https://ucarecd.net",Or={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:de(L),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Et,cdnCnamePrefixed:Rr,baseUrl:Sr,socialBaseUrl:kr,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},N=Object.freeze(Or);var Z=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),J=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"}),Xe=class{constructor(i){this._timeoutStore=new Map;this._targets=new Set;this._debugPrint=null;this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){for(let t of this._targets)t.dispatchEvent(new CustomEvent(i,{detail:e}));this._debugPrint?.(()=>{let t=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,t]})}emit(i,e,t={}){let{debounce:r}=t;if(typeof r!="number"&&!r){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let o=typeof r=="number"?r:20,n=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},o);this._timeoutStore.set(i,n)}};var ai="1.25.0-alpha.1";var qe="blocks",We=ai;var Ye=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(N);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new je,this._queue=new De(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:Z.CHANGE_CONFIG}),this._setConfig(e,t)})}_init(i){i===Z.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===Z.INIT_SOLUTION||i.eventType===Z.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:We,appName:qe,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[J.CHANGE,J.COMMON_UPLOAD_PROGRESS,J.FILE_ADDED,J.FILE_REMOVED,J.FILE_UPLOAD_START,J.FILE_UPLOAD_PROGRESS,J.FILE_UPLOAD_SUCCESS,J.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:Z.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:Z.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let o of t)if(!Object.hasOwn(e,o)||!this._checkObj(i[o],e[o]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var k=s=>`*cfg/${s}`;var li=s=>{let i=new Intl.Locale(s),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e};var ci=(s,i)=>new Intl.PluralRules(s).select(i);var Ir=s=>s;var di="plural:";function xt(s,i={},e={}){let{openToken:t="{{",closeToken:r="}}",transform:o=Ir}=e;for(let n in i){let a=i[n],l=a?.toString(),d=typeof l=="string"?o(l):String(l);s=s.replaceAll(t+n+r,d)}return s}function ui(s){let i=[],e=s.indexOf("{{");for(;e!==-1;){let t=s.indexOf("}}",e);if(t===-1)break;let r=s.substring(e+2,t);if(r.startsWith(di)){let o=s.substring(e+2,t).replace(di,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=s.indexOf("{{",t)}return i}function M(s,i){let e,t=((...r)=>{e&&clearTimeout(e),e=setTimeout(()=>s(...r),i)});return t.cancel=()=>{e&&clearTimeout(e)},t}var hi="--uploadcare-blocks-window-height",Oe=class s{static{this.clientsRegistry=new Set}static{this.flush=M(()=>{document.documentElement.style.setProperty(hi,`${window.innerHeight}px`)},100)}static registerClient(i){s.clientsRegistry.size===0&&s.attachTracker(),s.clientsRegistry.add(i)}static unregisterClient(i){s.clientsRegistry.delete(i),s.clientsRegistry.size===0&&s.detachTracker()}static attachTracker(){window.addEventListener("resize",s.flush,{passive:!0,capture:!0}),s.flush()}static detachTracker(){window.removeEventListener("resize",s.flush,{capture:!0}),document.documentElement.style.removeProperty(hi)}};var Pr=/\\([0-9a-fA-F]{1,6} ?)/g;function Lr(s){return s.length<2?!1:(s[0]==='"'||s[0]==="'")&&(s[s.length-1]==='"'||s[s.length-1]==="'")}function Mr(s){let i=s;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function $r(s){let i="",e="";for(let t=0;t<s.length;t++){let r=s[t+1];s[t]==="\\"&&r==='"'?(i+='\\"',t++):s[t]==='"'&&e!=="\\"?i+='\\"':i+=s[t],e=s[t]??""}return i}function pi(s){let i=s;Lr(s)&&(i=Mr(i),i=i.replace(Pr,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
28
28
  `,"\\n"),i=$r(i),i='"'+i+'"');try{return JSON.parse(i)}catch{return}}function fi(s){class i extends s{constructor(){super(...arguments);this.cssDataCache=null;this.computedStyle=null}getCssData(r,o=!1){let n=this.cssDataCache??Object.create(null);if(!Object.keys(n).includes(r)||!n[r]){this.computedStyle||(this.computedStyle=window.getComputedStyle(this));let a=this.computedStyle.getPropertyValue(r).trim();try{n[r]=pi(a)}catch(l){o||console.warn(`CSS Data error: ${r}`,l),n[r]=null}}return this.cssDataCache=n,n[r]}}return i}function mi(s){class i extends s{constructor(){super(...arguments);this.__slots={};this.__willYield=!0;this.__initialLightDomChildren=null;this.__hasAdoptedChildren=!1}createRenderRoot(){return this}connectedCallback(){this.__initialLightDomChildren||(this.__initialLightDomChildren=Array.from(this.childNodes)),super.connectedCallback()}__adoptChildren(){if(this.__hasAdoptedChildren)return;this.__hasAdoptedChildren=!0,this.__slots={};let r=Array.from(this.childNodes),o=r.length?r:this.__initialLightDomChildren??[];for(let n of o){let a=this.__getSlotNameForChild(n),l=this.__slots[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this.__slots[a]=l}this.__initialLightDomChildren=null}__getSlotNameForChild(r){return r instanceof Comment&&r.nextSibling instanceof Element?this.__getSlotNameForChild(r.nextSibling):"contentFor"in r?r.contentFor||"":r instanceof Element&&r.hasAttribute("content-for")&&r.getAttribute("content-for")||""}__isTextNodeEmpty(r){return!r.textContent||!r.textContent.trim()}__isSlotEmpty(r){let o=this.__slots[r];return!o||o.every(n=>n instanceof Comment||n instanceof Text&&this.__isTextNodeEmpty(n))}update(r){!this.hasUpdated&&this.__willYield&&this.__adoptChildren(),super.update(r)}yield(r,o){if(r===""&&!this.__slots[r]&&!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.__slots[r]=a,this.__hasAdoptedChildren=!0,this.__initialLightDomChildren=null}let n=this.__slots[r];return m.html`
29
29
  ${n}
30
30
  ${this.__isSlotEmpty(r)?o:void 0}
@@ -1,6 +1,7 @@
1
1
  import { PubSub } from '@symbiotejs/symbiote';
2
2
  export { PubSub as Data, PubSub, UID } from '@symbiotejs/symbiote';
3
3
  import * as lit_html from 'lit-html';
4
+ import * as lit_html_directives_ref_js from 'lit-html/directives/ref.js';
4
5
  import { nothing, LitElement, PropertyValues, TemplateResult } from 'lit';
5
6
  import { TelemetryRequest } from '@uploadcare/quality-insights';
6
7
  import * as _uploadcare_upload_client from '@uploadcare/upload-client';
@@ -1359,7 +1360,7 @@ declare class LitBlock extends LitBlockBase {
1359
1360
  declare class Modal extends LitBlock {
1360
1361
  static styleAttrs: string[];
1361
1362
  private _mouseDownTarget;
1362
- private dialogEl;
1363
+ protected dialogEl: lit_html_directives_ref_js.Ref<HTMLDialogElement>;
1363
1364
  handleModalOpen: ModalCb;
1364
1365
  handleModalClose: ModalCb;
1365
1366
  handleModalCloseAll: ModalCb;
@@ -24,7 +24,7 @@
24
24
  *
25
25
  */
26
26
  var yo=Object.defineProperty;var bo=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Rn=Object.prototype.hasOwnProperty;var vo=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of Ln(i))!Rn.call(o,r)&&r!==e&&yo(o,r,{get:()=>i[r],enumerable:!(t=bo(i,r))||t.enumerable});return o},v=(o,i,e)=>(vo(o,i,"default"),e&&vo(e,i,"default"));var h=(o,i,e,t)=>{for(var r=t>1?void 0:t?bo(i,e):i,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(t?n(i,e,r):n(r))||r);return t&&r&&yo(i,e,r),r};var X={BIND_ATTR:"bind",ATTR_BIND_PX:"@",SHARED_CTX_PX:"*",PARENT_CTX_PX:"^",NAMED_CTX_SPLTR:"/",COMPUTED_PX:"+",CSS_DATA_PX:"--",CTX_NAME_ATTR:"ctx",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx",EL_REF_ATTR:"ref",AUTO_TAG_PX:"sym",LIST_ATTR:"itemize",LIST_ITEM_TAG_ATTR:"item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL_ATTR:"use-template",DEFAULT_SLOT_KEY:"__default__",TEXT_NODE_SKIP_ATTR:"skip-text-nodes",TEXT_NODE_OPEN_TOKEN:"{{",TEXT_NODE_CLOSE_TOKEN:"}}"};function Pn(o){let i=e=>{for(let t in e)e[t]?.constructor===Object&&(e[t]=i(e[t]));return{...e}};return i(o)}var U=class o{#i;#r;#e;constructor(i){i.constructor===Object?this.store=Pn(i):(this.#e=!0,this.store=i),this.callbackMap=Object.create(null)}static#t(i,e){console.warn(`Symbiote PubSub: cannot ${i}. Prop name: `+e)}read(i){if(!this.#e&&!this.store.hasOwnProperty(i))return o.#t("read",i),null;if(typeof i=="string"&&i.startsWith(X.COMPUTED_PX)){let e=this.store[i];if(e?.constructor!==Function){o.#t("compute",i);return}this.__computedMap||(this.__computedMap={});let t=e();return Object.keys(this.__computedMap).includes(i)||(this.__computedMap[i]=t,this.notify(i)),t}else return this.store[i]}has(i){return this.#e?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this.#e&&!this.store.hasOwnProperty(i)){o.#t("publish",i);return}if(i?.startsWith(X.COMPUTED_PX)&&e.constructor!==Function){o.#t("publish computed",i);return}!(this.store[i]===null||e===null)&&typeof this.store[i]!=typeof e&&console.warn(`Symbiote PubSub: type warning for "${i}" [${typeof this.store[i]} -> ${typeof e}]`),this.store[i]=e,this.notify(i)}get proxy(){if(!this.#r){let i=Object.create(null);this.#r=new Proxy(i,{set:(e,t,r)=>(this.pub(t,r),!0),get:(e,t)=>{this.read(t)}})}return this.#r}multiPub(i){for(let e in i)this.pub(e,i[e])}static#o(i,e){this.globalStore.forEach(t=>{t.__computedMap&&Object.keys(t.__computedMap).forEach(r=>{if(t===i&&e===r)return;let s=`__${r}_timeout`;t[s]&&window.clearTimeout(t[s]),t[s]=window.setTimeout(()=>{let n=t.read(r);n!==t.__computedMap[r]&&(t.__computedMap[r]=n,t.notify(r))})})})}notify(i){let e=i?.startsWith(X.COMPUTED_PX);if(this.callbackMap[i]){let t=this.read(i);this.callbackMap[i].forEach(r=>{r(t)}),e&&(this.__computedMap[i]=t)}!e&&o.#o(this,i)}sub(i,e,t=!0){return!this.#e&&!this.store.hasOwnProperty(i)?(o.#t("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.read(i)),{remove:()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},callback:e})}set uid(i){!this.#i&&(this.#i=i)}get uid(){return this.#i}static registerCtx(i,e=Symbol()){let t=o.globalStore.get(e);return t?console.warn('PubSub: context UID "'+e+'" is already in use'):(t=new o(i),t.uid=e,o.globalStore.set(e,t)),t}static deleteCtx(i){o.globalStore.delete(i)}static getCtx(i,e=!0){return o.globalStore.get(i)||(e&&console.warn('PubSub: wrong context UID - "'+i+'"'),null)}};U.globalStore=new Map;var _o="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Un=_o.length-1,ge=class{static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:_o.charAt(Math.random()*Un);return e}};var Zc=[X.LIST_ATTR,X.LIST_ITEM_TAG_ATTR,X.EL_REF_ATTR,X.USE_TPL_ATTR,X.CTX_NAME_ATTR,X.CTX_OWNER_ATTR];function ve(o,...i){let e="",t=new CSSStyleSheet;return o.forEach((r,s)=>{e+=r+i[s]}),ve.processors.forEach(r=>{e=r(e)}),ve.clearProcessors(),t.replaceSync(e),t}ve.processors=[];ve.clearProcessors=function(){ve.processors=[]};ve.useProcessor=function(...o){return ve.processors=[...ve.processors,...o],ve};function kt(o,i){for(let e in i)e.includes("-")?o.style.setProperty(e,i[e]):o.style[e]=i[e]}var Vn=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function tr(o){for(let i in o){if(Vn.includes(i))continue;let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r=`-${r.toLowerCase()}`),t+=r,t),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),o[i].reg&&o[i].reg(e)}}var ir="UC";function Fn(o,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[ir]){e(window[ir]);return}let r=document.createElement("script");r.async=!0,r.src=o,r.onerror=()=>{t()},r.onload=()=>{let s=window[ir];i&&tr(s),e(s)},document.head.appendChild(r)})}var Ot={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"OneDrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var Zt=new Map,rr=new Map,Co=(o,i)=>{Zt.has(o)&&console.log(`Locale ${o} is already defined. Overwriting...`),Zt.set(o,{...Ot,...i})},Nn=(o,i)=>{rr.set(o,i)},To=(o,i)=>{typeof i=="function"?Nn(o,i):Co(o,i)},Eo=async o=>{if(!Zt.has(o)){if(!rr.has(o))throw new Error(`Locale ${o} is not defined`);let e=await rr.get(o)();Co(o,e)}return Zt.get(o)};To("en",Ot);var z=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Qt=class{constructor(i){this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;this._block=i}_debugPrint(...i){this._block.debugPrint("[modal-manager]",...i)}registerModal(i,e){this._modals.set(i,e),this._notify(z.ADD,{id:i,modal:e})}deleteModal(i){if(!this._modals.has(i))return!1;let e=this._modals.get(i);return this._modals.delete(i),this._activeModals.delete(i),this._notify(z.DELETE,{id:i,modal:e}),!0}open(i){if(!this._modals.has(i))return this._debugPrint(`Modal with ID "${i}" not found`),!1;let e=this._modals.get(i);return this._activeModals.add(i),this._notify(z.OPEN,{modal:e,id:i}),!0}close(i){if(!this._modals.has(i)||!this._activeModals.has(i))return this._debugPrint(`Modal with ID "${i}" not found or not active`),!1;let e=this._modals.get(i);return this._activeModals.delete(i),this._notify(z.CLOSE,{id:i,modal:e}),!0}toggle(i){return this._modals.has(i)?this._activeModals.has(i)?this.close(i):this.open(i):(this._debugPrint(`Modal with ID "${i}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let i=Array.from(this._activeModals).pop();return i?this.close(i):!1}closeAll(){let i=this._activeModals.size;return this._activeModals.clear(),this._notify(z.CLOSE_ALL,{}),i}subscribe(i,e){return this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(e),()=>this.unsubscribe(i,e)}unsubscribe(i,e){this._subscribers.has(i)&&this._subscribers.get(i)?.delete(e)}_notify(i,e){if(this._subscribers.has(i))for(let t of this._subscribers.get(i)??new Set)try{t(e)}catch(r){this._block.telemetryManager.sendEventError(r,"modal subscriber"),this._debugPrint("Error in modal subscriber:",r)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(z.DESTROY,{})}};function xo(o){return Object.prototype.toString.call(o)==="[object Object]"}var Bn=/\W|_/g;function zn(o){return o.split(Bn).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}function So(o,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(o)?o.map(e=>Oe(e,{ignoreKeys:i})):o}function Oe(o,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(o))return So(o,{ignoreKeys:i});if(!xo(o))return o;let e={};for(let t of Object.keys(o)){let r=o[t];if(i.includes(t)){e[t]=r;continue}xo(r)?r=Oe(r,{ignoreKeys:i}):Array.isArray(r)&&(r=So(r,{ignoreKeys:i})),e[zn(t)]=r}return e}var Hn=o=>new Promise(i=>setTimeout(i,o));function dr({libraryName:o,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){let s="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:o,libraryVersion:i,languageName:s,integration:r});let n=[o,i,t].filter(Boolean).join("/"),a=[s,r].filter(Boolean).join("; ");return`${n} (${a})`}var jn={factor:2,time:100};function Kn(o,i=jn){let e=0;function t(r){let s=Math.round(i.time*i.factor**e);return r({attempt:e,retry:a=>Hn(a??s).then(()=>(e+=1,t(r)))})}return t(o)}var Ye=class extends Error{},lt=class o extends Ye{originalProgressEvent;constructor(i){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,o.prototype),this.originalProgressEvent=i}},Yt=(o,i)=>{o&&(o.aborted?Promise.resolve().then(i):o.addEventListener("abort",()=>i(),{once:!0}))},$e=class o extends Ye{isCancel=!0;constructor(i="Request canceled"){super(i),this.name="CancelError",Object.setPrototypeOf(this,o.prototype)}},Gn=500,Io=({check:o,interval:i=Gn,timeout:e,signal:t})=>new Promise((r,s)=>{let n,a;Yt(t,()=>{n&&clearTimeout(n),s(new $e("Poll cancelled"))}),e&&(a=setTimeout(()=>{n&&clearTimeout(n),s(new $e("Timed out"))},e));let l=()=>{try{Promise.resolve(o(t)).then(d=>{d?(a&&clearTimeout(a),r(d)):n=setTimeout(l,i)}).catch(d=>{a&&clearTimeout(a),s(d)})}catch(d){a&&clearTimeout(a),s(d)}};n=setTimeout(l,0)}),O={baseCDN:"https://ucarecdn.com",baseURL:"https://upload.uploadcare.com",maxContentLength:50*1024*1024,retryThrottledRequestMaxTimes:1,retryNetworkErrorMaxTimes:3,multipartMinFileSize:25*1024*1024,multipartChunkSize:5*1024*1024,multipartMinLastPartSize:1024*1024,maxConcurrentRequests:4,pollingTimeoutMilliseconds:1e4,pusherKey:"79ae88bd931ea68464d9"},Jt="application/octet-stream",ko="original",Ve=({method:o,url:i,data:e,headers:t={},signal:r,onProgress:s})=>new Promise((n,a)=>{let l=new XMLHttpRequest,d=o?.toUpperCase()||"GET",u=!1;l.open(d,i,!0),t&&Object.entries(t).forEach(p=>{let[f,g]=p;typeof g<"u"&&!Array.isArray(g)&&l.setRequestHeader(f,g)}),l.responseType="text",Yt(r,()=>{u=!0,l.abort(),a(new $e)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let p={method:d,url:i,data:e,headers:t||void 0,signal:r,onProgress:s},f=l.getAllResponseHeaders().trim().split(/[\r\n]+/),g={};f.forEach(function(C){let E=C.split(": "),x=E.shift(),k=E.join(": ");x&&typeof x<"u"&&(g[x]=k)});let y=l.response,w=l.status;n({request:p,data:y,headers:g,status:w})}},l.onerror=p=>{u||a(new lt(p))},s&&typeof s=="function"&&(l.upload.onprogress=p=>{p.lengthComputable?s({isComputable:!0,value:p.loaded/p.total}):s({isComputable:!1})}),e?l.send(e):l.send()});function Wn(o,...i){return o}var qn=({name:o})=>o?[o]:[],Xn=Wn,Zn=()=>new FormData,Oo=o=>!1,ei=o=>typeof Blob<"u"&&o instanceof Blob,ti=o=>typeof File<"u"&&o instanceof File,ii=o=>!!o&&typeof o=="object"&&!Array.isArray(o)&&"uri"in o&&typeof o.uri=="string",ct=o=>ei(o)||ti(o)||Oo()||ii(o),Qn=o=>typeof o=="string"||typeof o=="number"||typeof o>"u",Yn=o=>!!o&&typeof o=="object"&&!Array.isArray(o),Jn=o=>!!o&&typeof o=="object"&&"data"in o&&ct(o.data);function Mo(o,i,e){if(Array.isArray(e))for(let t of e)Mo(o,`${i}[]`,t);else if(Jn(e)){let{name:t,contentType:r}=e,s=Xn(e.data,t,r??Jt),n=qn({name:t,contentType:r});o.push([i,s,...n])}else if(Yn(e))for(let[t,r]of Object.entries(e))typeof r<"u"&&o.push([`${i}[${t}]`,String(r)]);else Qn(e)&&e&&o.push([i,e.toString()])}function ea(o){let i=[];for(let[e,t]of Object.entries(o))Mo(i,e,t);return i}function ri(o){let i=Zn(),e=ea(o);for(let t of e){let[r,s,...n]=t;i.append(r,s,...n)}return i}var Q=class o extends Ye{code;request;response;headers;constructor(i,e,t,r,s){super(),this.name="UploadError",this.message=i,this.code=e,this.request=t,this.response=r,this.headers=s,Object.setPrototypeOf(this,o.prototype)}},ta=o=>{let i=new URLSearchParams;for(let[e,t]of Object.entries(o))t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).filter(r=>r[1]??!1).forEach(r=>i.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(t)?t.forEach(r=>{i.append(`${e}[]`,r)}):typeof t=="string"&&t?i.set(e,t):typeof t=="number"&&i.set(e,t.toString());return i.toString()},Ie=(o,i,e)=>{let t=new URL(o);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=ta(e)),t.toString()},ia="6.18.2",ra="UploadcareUploadClient",oa=ia;function Je(o){return dr({libraryName:ra,libraryVersion:oa,...o})}var sa="RequestThrottledError",Ao=15e3,na=1e3;function aa(o){let{headers:i}=o||{};if(!i||typeof i["retry-after"]!="string")return Ao;let e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:Ao}function Fe(o,i){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return Kn(({attempt:r,retry:s})=>o().catch(n=>{if("response"in n&&n?.code===sa&&r<e)return s(aa(n));if(n instanceof lt&&r<t)return s((r+1)*na);throw n}))}var Lo=o=>{let i="";return(ei(o)||ti(o)||ii(o))&&(i=o.type),i||Jt},Ro=o=>{let i="";return ti(o)&&o.name?i=o.name:ei(o)||Oo()?i="":ii(o)&&o.name&&(i=o.name),i||ko};function ur(o){return typeof o>"u"||o==="auto"?"auto":o?"1":"0"}function la(o,{publicKey:i,fileName:e,contentType:t,baseURL:r=O.baseURL,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:d,source:u="local",integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",url:Ie(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},data:ri({file:{data:o,name:e||Ro(o),contentType:t||Lo(o)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:ur(a),signature:s,expire:n,source:u,metadata:w}),signal:l,onProgress:d}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k}),{retryNetworkErrorMaxTimes:y,retryThrottledRequestMaxTimes:g})}var nr;(function(o){o.Token="token",o.FileInfo="file_info"})(nr||(nr={}));function ca(o,{publicKey:i,baseURL:e=O.baseURL,store:t,fileName:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:d="url",signal:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},url:Ie(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:o,store:ur(t),filename:r,check_URL_duplicates:s?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:d,metadata:w}),signal:u}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k}),{retryNetworkErrorMaxTimes:y,retryThrottledRequestMaxTimes:g})}var re;(function(o){o.Unknown="unknown",o.Waiting="waiting",o.Progress="progress",o.Error="error",o.Success="success"})(re||(re={}));var da=o=>"status"in o&&o.status===re.Error;function ua(o,{publicKey:i,baseURL:e=O.baseURL,signal:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=O.retryNetworkErrorMaxTimes}={}){return Fe(()=>Ve({method:"GET",headers:i?{"X-UC-User-Agent":Je({publicKey:i,integration:r,userAgent:s})}:void 0,url:Ie(e,"/from_url/status/",{jsonerrors:1,token:o}),signal:t}).then(({data:l,headers:d,request:u})=>{let p=Oe(JSON.parse(l));if("error"in p&&!da(p))throw new Q(p.error.content,p.error.errorCode,u,p,d);return p}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function pa(o,{publicKey:i,baseURL:e=O.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:s,signal:n,source:a,integration:l,userAgent:d,retryThrottledRequestMaxTimes:u=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"POST",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:l,userAgent:d})},url:Ie(e,"/group/",{jsonerrors:1}),data:ri({files:o,callback:t,pub_key:i,signature:r,expire:s,source:a}),signal:n}).then(({data:f,headers:g,request:y})=>{let w=Oe(JSON.parse(f));if("error"in w)throw new Q(w.error.content,w.error.errorCode,y,w,g);return w}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:u})}function Po(o,{publicKey:i,baseURL:e=O.baseURL,signal:t,source:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"GET",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:s,userAgent:n})},url:Ie(e,"/info/",{jsonerrors:1,pub_key:i,file_id:o,source:r}),signal:t}).then(({data:d,headers:u,request:p})=>{let f=Oe(JSON.parse(d));if("error"in f)throw new Q(f.error.content,f.error.errorCode,p,f,u);return f}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function ha(o,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=O.multipartChunkSize,baseURL:s="",secureSignature:n,secureExpire:a,store:l,signal:d,source:u="local",integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",url:Ie(s,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},data:ri({filename:t||ko,size:o,content_type:e||Jt,part_size:r,UPLOADCARE_STORE:ur(l),UPLOADCARE_PUB_KEY:i,signature:n,expire:a,source:u,metadata:w}),signal:d}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k.parts=Object.keys(k.parts).map(ue=>k.parts[Number(ue)]),k}),{retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})}function ma(o,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:s=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"PUT",url:i,data:o,onProgress:r,signal:t,headers:{"Content-Type":e||Jt}}).then(a=>(r&&r({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n})}function fa(o,{publicKey:i,baseURL:e=O.baseURL,source:t="local",signal:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"POST",url:Ie(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:s,userAgent:n})},data:ri({uuid:o,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:d,headers:u,request:p})=>{let f=Oe(JSON.parse(d));if("error"in f)throw new Q(f.error.content,f.error.errorCode,p,f,u);return f}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function pr(o,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:d}){return Io({check:u=>Po(o,{publicKey:i,baseURL:e,signal:u,source:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(p=>p.isReady?p:(d&&d({isComputable:!0,value:1}),!1)),signal:l})}function ga(o){return"defaultEffects"in o}var ke=class{uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(i,{baseCDN:e=O.baseCDN,fileName:t}={}){let{uuid:r,s3Bucket:s}=i,n=Ie(e,`${r}/`),a=s?Ie(`https://${s}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=t||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=n,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=s||null,this.s3Url=a,ga(i)&&(this.defaultEffects=i.defaultEffects)}},va=(o,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,contentType:a,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,baseCDN:w,metadata:C})=>la(o,{publicKey:i,fileName:e,contentType:a,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,metadata:C}).then(({file:E})=>pr(E,{publicKey:i,baseURL:t,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,onProgress:d,signal:l})).then(E=>new ke(E,{baseCDN:w})),ya=(o,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:s,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u,baseCDN:p})=>Po(o,{publicKey:i,baseURL:t,signal:r,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u}).then(f=>new ke(f,{baseCDN:p,fileName:e})).then(f=>(s&&s({isComputable:!0,value:1}),f)),ba=(o,{signal:i}={})=>{let e=null,t=null,r=o.map(()=>new AbortController),s=n=>()=>{t=n,r.forEach((a,l)=>l!==n&&a.abort())};return Yt(i,()=>{r.forEach(n=>n.abort())}),Promise.all(o.map((n,a)=>{let l=s(a);return Promise.resolve().then(()=>n({stopRace:l,signal:r[a].signal})).then(d=>(l(),d)).catch(d=>(e=d,null))})).then(n=>{if(t===null)throw e;return n[t]})},_a=window.WebSocket,ar=class{events=Object.create({});emit(i,e){this.events[i]?.forEach(t=>t(e))}on(i,e){this.events[i]=this.events[i]||[],this.events[i].push(e)}off(i,e){e?this.events[i]=this.events[i].filter(t=>t!==e):this.events[i]=[]}},wa=(o,i)=>o==="success"?{status:re.Success,...i}:o==="progress"?{status:re.Progress,...i}:{status:re.Error,...i},lr=class{key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new ar;disconnectTimeoutId=null;constructor(i,e=3e4){this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new _a(i),this.ws.addEventListener("error",e=>{this.emmitter.emit("error",new Error(e.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(e=>this.send(e.event,e.data)),this.queue=[]}),this.ws.addEventListener("message",e=>{let t=JSON.parse(e.data.toString());switch(t.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(t.channel,wa(t.event,JSON.parse(t.data)))}})}}disconnect(){let i=()=>{this.ws?.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){let t=JSON.stringify({event:i,data:e});this.ws?.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();let t=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:t}};this.emmitter.on(t,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}unsubscribe(i){this.subscribers-=1;let e=`task-status-${i}`,t={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(t.event,t.data):this.queue=this.queue.filter(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}},or=null,hr=o=>{if(!or){let i=typeof window>"u"?0:3e4;or=new lr(o,i)}return or},Ca=o=>{hr(o).connect()};function Ta({token:o,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Io({check:d=>ua(o,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,signal:d}).then(u=>{switch(u.status){case re.Error:return new Q(u.error,u.errorCode);case re.Waiting:return!1;case re.Unknown:return new Q(`Token "${o}" was not found.`);case re.Progress:return a&&(u.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:u.done/u.total})),!1;case re.Success:return a&&a({isComputable:!0,value:u.done/u.total}),u;default:throw new Error("Unknown status")}}),signal:l})}var Ea=({token:o,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,s)=>{let n=hr(i),a=n.onError(s),l=()=>{a(),n.unsubscribe(o)};Yt(e,()=>{l(),s(new $e("pusher cancelled"))}),n.subscribe(o,d=>{switch(d.status){case re.Progress:{t&&(d.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:d.done/d.total}));break}case re.Success:{l(),t&&t({isComputable:!0,value:d.done/d.total}),r(d);break}case re.Error:l(),s(new Q(d.msg,d.error_code))}})}),xa=(o,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:d,signal:u,onProgress:p,source:f,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,pusherKey:C=O.pusherKey,metadata:E})=>Promise.resolve(Ca(C)).then(()=>ca(o,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:d,signal:u,source:f,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,metadata:E})).catch(x=>(hr(C)?.disconnect(),Promise.reject(x))).then(x=>x.type===nr.FileInfo?x:ba([({signal:k})=>Ta({token:x.token,publicKey:i,baseURL:t,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,onProgress:p,signal:k}),({signal:k})=>Ea({token:x.token,pusherKey:C,signal:k,onProgress:p})],{signal:u})).then(x=>{if(x instanceof Q)throw x;return x}).then(x=>pr(x.uuid,{publicKey:i,baseURL:t,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,onProgress:p,signal:u})).then(x=>new ke(x,{baseCDN:r})),sr=new WeakMap,Sa=async o=>{if(sr.has(o))return sr.get(o);let i=await fetch(o.uri).then(e=>e.blob());return sr.set(o,i),i},Uo=async o=>{if(ti(o)||ei(o))return o.size;if(ii(o))return(await Sa(o)).size;throw new Error("Unknown file type. Cannot determine file size.")},Aa=(o,i=O.multipartMinFileSize)=>o>=i,$o=o=>{let i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(i);return!ct(o)&&e.test(o)},mr=o=>{let i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!ct(o)&&e.test(o)},Ia=(o,i)=>new Promise((e,t)=>{let r=[],s=!1,n=i.length,a=[...i],l=()=>{let d=i.length-a.length,u=a.shift();u&&u().then(p=>{s||(r[d]=p,n-=1,n?l():e(r))}).catch(p=>{s=!0,t(p)})};for(let d=0;d<o;d++)l()}),ka=(o,i,e,t)=>{let r=t*i,s=Math.min(r+t,e);return o.slice(r,s)},Oa=async(o,i,e)=>t=>ka(o,t,i,e),Ma=(o,i,{publicKey:e,contentType:t,onProgress:r,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>ma(o,i,{publicKey:e,contentType:t,onProgress:r,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),La=async(o,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,contentType:w,multipartChunkSize:C=O.multipartChunkSize,maxConcurrentRequests:E=O.maxConcurrentRequests,baseCDN:x,metadata:k})=>{let ue=t??await Uo(o),pe,Qe=(W,ie)=>{if(!d)return;pe||(pe=Array(W).fill(0));let fe=we=>we.reduce((Ae,er)=>Ae+er,0);return we=>{we.isComputable&&(pe[ie]=we.value,d({isComputable:!0,value:fe(pe)/W}))}};return w||=Lo(o),ha(ue,{publicKey:i,contentType:w,fileName:e||Ro(o),baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,metadata:k,multipartChunkSize:C}).then(async({uuid:W,parts:ie})=>{let fe=await Oa(o,ue,C);return Promise.all([W,Ia(E,ie.map((we,Ae)=>()=>Ma(fe(Ae),we,{publicKey:i,contentType:w,onProgress:Qe(ie.length,Ae),signal:l,integration:p,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})))])}).then(([W])=>fa(W,{publicKey:i,baseURL:r,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})).then(W=>W.isReady?W:pr(W.uuid,{publicKey:i,baseURL:r,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,onProgress:d,signal:l})).then(W=>new ke(W,{baseCDN:x}))};async function fr(o,{publicKey:i,fileName:e,baseURL:t=O.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartMinFileSize:w,multipartChunkSize:C,maxConcurrentRequests:E,baseCDN:x=O.baseCDN,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:ue,pusherKey:pe,metadata:Qe}){if(ct(o)){let W=await Uo(o);return Aa(W,w)?La(o,{publicKey:i,contentType:y,multipartChunkSize:C,fileSize:W,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,maxConcurrentRequests:E,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x,metadata:Qe}):va(o,{publicKey:i,fileName:e,contentType:y,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x,metadata:Qe})}if(mr(o))return xa(o,{publicKey:i,fileName:e,baseURL:t,baseCDN:x,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:ue,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,pusherKey:pe,metadata:Qe});if($o(o))return ya(o,{publicKey:i,fileName:e,baseURL:t,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x});throw new TypeError(`File uploading from "${o}" is not supported`)}var cr=class{uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(i,{baseCDN:e=O.baseCDN}={}){this.uuid=i.id,this.filesCount=i.filesCount;let t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,s)=>r+s.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(t).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=t.map(r=>new ke(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}},Ra=o=>{for(let i of o)if(!ct(i))return!1;return!0},Pa=o=>{for(let i of o)if(!$o(i))return!1;return!0},Ua=o=>{for(let i of o)if(!mr(i))return!1;return!0};function Do(o,{publicKey:i,fileName:e,baseURL:t=O.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartChunkSize:w=O.multipartChunkSize,baseCDN:C=O.baseCDN,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x,jsonpCallback:k}){if(!Ra(o)&&!Ua(o)&&!Pa(o))throw new TypeError(`Group uploading from "${o}" is not supported`);let ue,pe=!0,Qe=o.length,W=(ie,fe)=>{if(!l)return;ue||(ue=Array(ie).fill(0));let we=Ae=>Ae.reduce((er,Mn)=>er+Mn)/ie;return Ae=>{if(!Ae.isComputable||!pe){pe=!1,l({isComputable:!1});return}ue[fe]=Ae.value,l({isComputable:!0,value:we(ue)})}};return Promise.all(o.map((ie,fe)=>ct(ie)||mr(ie)?fr(ie,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:W(Qe,fe),source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartChunkSize:w,baseCDN:C,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x}).then(we=>we.uuid):ie)).then(ie=>pa(ie,{publicKey:i,baseURL:t,jsonpCallback:k,secureSignature:r,secureExpire:s,signal:a,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g}).then(fe=>new cr(fe,{baseCDN:C})).then(fe=>(l&&l({isComputable:!0,value:1}),fe)))}var De=class{_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(i){this._concurrency=i}run(){let i=this._concurrency-this._running;for(let e=0;e<i;e++){let t=this._pending.shift();if(!t)return;let r=this._resolvers.get(t),s=this._rejectors.get(t);if(!r||!s)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this.run()}).then(n=>r(n)).catch(n=>s(n))}}add(i,{autoRun:e}={autoRun:!0}){return new Promise((t,r)=>{this._resolvers.set(i,t),this._rejectors.set(i,r),this._pending.push(i),e&&this.run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this.run()}get concurrency(){return this._concurrency}};var gr=()=>({}),vr=o=>({...gr(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{o.modalManager?.close(o.$["*currentActivity"]),o.set$({"*currentActivity":null})}}),yr=o=>({...vr(o),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new De(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),Vo=o=>({...yr(o),"*solution":null});var P=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),I=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"}),oi=class{constructor(i){this._timeoutStore=new Map;this._targets=new Set;this._debugPrint=null;this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){for(let t of this._targets)t.dispatchEvent(new CustomEvent(i,{detail:e}));this._debugPrint?.(()=>{let t=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,t]})}emit(i,e,t={}){let{debounce:r}=t;if(typeof r!="number"&&!r){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let s=typeof r=="number"?r:20,n=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},s);this._timeoutStore.set(i,n)}};function L(o,i){let e,t=((...r)=>{e&&clearTimeout(e),e=setTimeout(()=>o(...r),i)});return t.cancel=()=>{e&&clearTimeout(e)},t}var m={};v(m,Yd);v(m,Jd);import"@lit/reactive-element";import"lit-html";import*as Yd from"lit-element/lit-element.js";import*as Jd from"lit-html/is-server.js";var $a={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function Mt(o,i){i.tabIndex=0,i.focus(),o.tabIndex=-1}function br(o){let i=o.role||o.type||o.tagName;if(!i)return null;let e=$a[i.toLowerCase()];if(!e)return null;for(let t of e){let r=o.closest(`[role=${t}]`);if(r)return r}}function _r(o,i){return i.role==="toolbar"?Da(i):i.querySelectorAll(`[role=${o.role}]`)}function Da(o){return[...o.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function Va(o){let i=o.getAttribute("aria-orientation");if(i==="vertical")return!1;if(i==="horizontal")return!0;let e=o.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function Fo(o){return i=>{let e=!1,t=o?.searchDelayMs||300,r=0,s="";function n(p){let f=br(p.target);if(!f){a();return}let g=_r(p.target,f),y=Array.from(g).indexOf(p.target),w="ArrowDown",C="ArrowUp";if(Va(f)&&(i.document.dir==="rtl"?(w="ArrowLeft",C="ArrowRight"):(w="ArrowRight",C="ArrowLeft")),p.key===w)p.preventDefault(),Mt(p.target,g[y+1]||g[0]);else if(p.key===C)p.preventDefault(),Mt(p.target,g[y-1]||g[g.length-1]);else if(p.key==="Home")p.preventDefault(),Mt(p.target,g[0]);else if(p.key==="End")p.preventDefault(),Mt(p.target,g[g.length-1]);else if(p.key.length===1&&f.role!=="tablist"){let E=Date.now();E-r<=t?s+=p.key.toLowerCase():s=p.key.toLowerCase(),r=E;let x=Array.from(g).find(k=>k.textContent?.trim()?.toLowerCase()?.startsWith(s));x&&(p.preventDefault(),Mt(p.target,x))}}function a(){e=!1,i.removeEventListener("keydown",n)}function l(p){let f=br(p.target);if(f){e||(e=!0,i.addEventListener("keydown",n));let g=_r(p.target,f);for(let y of g)y!==p.target&&y.setAttribute("tabindex",-1)}else e&&a()}function d(p){(!p.relatedTarget||p.relatedTarget===i.document)&&a()}function u(p){let f=br(p.target);if(f){let g=_r(p.target,f);for(let y of g)y!==p.target&&y.setAttribute("tabindex",-1);p.target.setAttribute("tabindex",0)}}return i.addEventListener("click",u),i.addEventListener("focusin",l),i.addEventListener("focusout",d),()=>{a(),i.removeEventListener("click",u),i.removeEventListener("focusin",l),i.removeEventListener("focusout",d)}}}function No(){return o=>{let i,e;function t(s){if(s.target.getAttribute("aria-hidden")==="true"){i=s.target,i.setAttribute("aria-hidden","false"),e=i.hidden,e&&(i.hidden=!1);let n=s.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function r(s){i&&i.contains(s.target)&&(!s.relatedTarget||!i.contains(s.relatedTarget))&&(s.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),e&&(i.hidden=!0),i=null)}return o.addEventListener("keyuxJump",t),o.addEventListener("focusout",r),()=>{o.removeEventListener("keyuxJump",t),o.removeEventListener("focusout",r)}}}function Bo(){return o=>{let i=[];function e(l){let d=o.document.activeElement;d&&d!==o.document.body&&i.push(new WeakRef(d)),l.focus({focusVisible:!0})}function t(){let l=i.pop();if(!l){o.document.activeElement.blur();return}let d=l.deref();d&&d.isConnected?d.focus():t()}let r=0,s;function n(l){clearInterval(s);let d=l.getAttribute("aria-controls");s=setInterval(()=>{if(r++>50){clearInterval(s);return}let u=o.document.getElementById(d);if(u){let p=u.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');p&&(clearInterval(s),u.dispatchEvent(new o.CustomEvent("keyuxJump",{bubbles:!0})),e(p))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&t()}return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}}}function zo(o){let i,e=o.split(" "),t;function r(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(s(),a.target.classList.add(...e),i=a.target,t=a.target)}function s(){i&&i.classList.remove(...e),t=null}function n(a){a.clientX===0&&a.clientY===0&&t!==a.target&&(s(),a.target.classList.add(...e),i=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",r),a.addEventListener("keyup",s),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",r),a.removeEventListener("keyup",s)})}function Ho(o,i){let e=i.map(t=>t(o));return()=>{e.forEach(t=>t())}}var wr=class{constructor(){this._listeners=new Map;this._scope=[]}addEventListener(i,e){let t=r=>{let s=r.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&e(r)};this._listeners.set(e,t),window.addEventListener(i,t)}removeEventListener(i,e){let t=this._listeners.get(e);t&&window.removeEventListener(i,t),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this._scope.push(i)}destroy(){this._scope=[];for(let i of this._listeners.values())window.removeEventListener("keydown",i),window.removeEventListener("keyup",i);this._listeners.clear()}},si=class{constructor(){this._scopedWindow=new wr,this._destroyKeyUX=Ho(this._scopedWindow,[Fo(),zo("is-pressed"),Bo(),No()])}registerBlock(i){this._scopedWindow.registerScope(i)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var Ne=o=>`*l10n/${o}`,Fa="en",ni=class{constructor(i){this._blockInstance=null;this._localeName="";this._blockInstance=i;for(let[e,t]of Object.entries(Ot)){let r=this._blockInstance.has(Ne(e))?!this._blockInstance.$[Ne(e)]:!0;this._blockInstance.add(Ne(e),t,r)}setTimeout(()=>{i.subConfigValue("localeName",async e=>{if(!this._blockInstance||!e)return;this._localeName=e;let t=await Eo(e);if(e!==Fa&&this._localeName!==e)return;let r=this._blockInstance.cfg.localeDefinitionOverride?.[e];for(let[s,n]of Object.entries(t)){let a=r?.[s];this._blockInstance.add(Ne(s),a??n,!0)}}),i.subConfigValue("localeDefinitionOverride",e=>{if(!e)return;let t=e[this._localeName];if(t)for(let[r,s]of Object.entries(t))this._blockInstance?.add(Ne(r),s,!0)})})}};function Na(o){return o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`).replace(/__/g,"_")}function Tr(o){return Array.isArray(o)?o.map(i=>typeof i=="object"&&i!==null?Tr(i):i):typeof o!="object"||o===null?o:Object.fromEntries(Object.entries(o).map(([i,e])=>{let t=Na(i);return typeof e=="object"&&e!==null?[t,Tr(e)]:[t,e]}))}function Ba(o){return{ok:!0,value:o}}function Cr(o){return{ok:!1,error:o}}var za="https://tlm.uploadcare.com/api/",Er=class{constructor(i=za){this.baseUrl=i}async base(i,e={}){let t=`${this.baseUrl}${i}`;try{let r=await fetch(t,e);if(!r.ok)return Cr(new Error(`Got non-200 response from "${t}". Status: ${r.status.toString()}`));try{let s=await r.json();return Ba(s)}catch(s){return Cr(new Error(`Error parsing JSON from "${t}". Error: ${s}`))}}catch(r){return Cr(new Error(`Error fetching data from "${t}". Error: ${r}`))}}async post(i,e,t={}){return await this.base(i,{...t,method:"POST",body:JSON.stringify(Tr(e)),headers:{"Content-Type":"application/json",...t.headers||{}}})}async get(i,e={}){return await this.base(i,{method:"GET",...e})}},Ha=async(o,i)=>({success:!0,data:i}),ai=class extends Er{constructor(){super()}async sendEvent(i,e){let t=await Ha(void 0,i);if(!t.success)throw console.error("TelemetryAPIService: events: body is invalid",t.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",i,e)}};var oe=o=>o?o.split(",").map(i=>i.trim()).filter(Boolean):[],Me=o=>o.join(",");var jo=o=>{if(typeof o!="string"||!o)return"";let i=o.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},li=(...o)=>o.filter(i=>typeof i=="string"&&!!i).map(i=>jo(i)).join("/-/"),Y=(...o)=>{let i=li(...o);return i?`-/${i}/`:""};function ci(o){let i=new URL(o),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),s="";return t>=0?s=e.slice(t):r>=0&&(s=e.slice(r+1)),s}function di(o){let i=new URL(o),{pathname:e}=i,t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}function xr(o){let i=Ko(o),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}function Sr(o){return xr(o).split("/-/").filter(Boolean).map(e=>jo(e))}function Ko(o){let i=new URL(o),e=ci(o),t=Go(e)?Wo(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}function Go(o){return o.startsWith("http")}function Wo(o){let i=new URL(o);return{pathname:`${i.origin}${i.pathname??""}`,search:i.search??"",hash:i.hash??""}}var H=(o,i,e)=>{let t=new URL(Ko(o)),r=e??ci(o),s=i??"";if(t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),r&&Go(r)){let n=Wo(r);t.pathname=`${t.pathname}${s}${n.pathname||""}`,t.search=n.search,t.hash=n.hash}else t.pathname=`${t.pathname}${s}${r||""}`;return t.toString()},Be=(o,i)=>{let e=new URL(o);return e.pathname=`${i}/`,e.toString()};var j=(o,i=",")=>o.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0);var Lt=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:!1,flip:!1,crop:void 0}),Xo=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function ja(o,i){if(typeof i=="number"){let e=i;return Lt[o]!==e?`${o}/${e}`:""}if(typeof i=="boolean"){let e=i;return Lt[o]!==e?`${o}`:""}if(o==="filter"&&i){let{name:e,amount:t}=i;return Lt.filter===t?"":`${o}/${e}/${t}`}if(o==="crop"&&i){let{dimensions:e,coords:t}=i;return`${o}/${e.join("x")}/${t.join(",")}`}return""}function ze(o){return li(...Xo.filter(i=>typeof o[i]<"u"&&o[i]!==null).map(i=>{let e=o[i];return ja(i,e)}).filter(i=>!!i))}var ui=li("format/auto","progressive/yes"),Le=([o])=>typeof o<"u"?Number(o):void 0,qo=()=>!0,Ka=([o,i])=>({name:o,amount:typeof i<"u"?Number(i):100}),Ga=([o,i])=>{if(!/\d+x\d+/.test(o)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:j(o,"x").map(Number),coords:j(i).map(Number)}},Wa=Object.freeze({enhance:Le,brightness:Le,exposure:Le,gamma:Le,contrast:Le,saturation:Le,vibrance:Le,warmth:Le,filter:Ka,mirror:qo,flip:qo,rotate:Le,crop:o=>{let[i,e]=o,{dimensions:t,coords:r}=Ga([i,e]);return{dimensions:t,coords:r}}});function Ar(o){let i={};for(let e of o){let[t,...r]=e.split("/");if(!t||!Xo.includes(t))continue;let s=t,n=Wa[s];try{let a=n(r);i[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(`
27
- `))}}return i}var V=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),J=Object.freeze([V.CROP,V.TUNING,V.FILTERS]),Zo=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Qo=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"]),Yo=Object.freeze(["rotate","mirror","flip"]),Re=Lt,ye=Object.freeze({brightness:{zero:Re.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Re.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Re.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Re.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Re.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Re.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Re.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Re.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Re.filter,range:[0,100],keypointsNumber:1}});var Rt="https://ucarecdn.com",qa="https://upload.uploadcare.com",Xa="https://social.uploadcare.com",Za="https://ucarecd.net",Qa={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Me(J),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Rt,cdnCnamePrefixed:Za,baseUrl:qa,socialBaseUrl:Xa,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},se=Object.freeze(Qa);var Jo="1.25.0-alpha.0";var He="blocks",je=Jo;var pi=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(se);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new ai,this._queue=new De(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:P.CHANGE_CONFIG}),this._setConfig(e,t)})}_init(i){i===P.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===P.INIT_SOLUTION||i.eventType===P.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:je,appName:He,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[I.CHANGE,I.COMMON_UPLOAD_PROGRESS,I.FILE_ADDED,I.FILE_REMOVED,I.FILE_UPLOAD_START,I.FILE_UPLOAD_PROGRESS,I.FILE_UPLOAD_SUCCESS,I.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:P.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s of t)if(!Object.hasOwn(e,s)||!this._checkObj(i[s],e[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var q=o=>`*cfg/${o}`;var es=o=>{let i=new Intl.Locale(o),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e};var hi=(o,i)=>new Intl.PluralRules(o).select(i);var Ja=o=>o;var ts="plural:";function Pt(o,i={},e={}){let{openToken:t="{{",closeToken:r="}}",transform:s=Ja}=e;for(let n in i){let a=i[n],l=a?.toString(),d=typeof l=="string"?s(l):String(l);o=o.replaceAll(t+n+r,d)}return o}function is(o){let i=[],e=o.indexOf("{{");for(;e!==-1;){let t=o.indexOf("}}",e);if(t===-1)break;let r=o.substring(e+2,t);if(r.startsWith(ts)){let s=o.substring(e+2,t).replace(ts,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=o.indexOf("{{",t)}return i}var rs="--uploadcare-blocks-window-height",Ut=class o{static{this.clientsRegistry=new Set}static{this.flush=L(()=>{document.documentElement.style.setProperty(rs,`${window.innerHeight}px`)},100)}static registerClient(i){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(i)}static unregisterClient(i){o.clientsRegistry.delete(i),o.clientsRegistry.size===0&&o.detachTracker()}static attachTracker(){window.addEventListener("resize",o.flush,{passive:!0,capture:!0}),o.flush()}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:!0}),document.documentElement.style.removeProperty(rs)}};var el=/\\([0-9a-fA-F]{1,6} ?)/g;function tl(o){return o.length<2?!1:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function il(o){let i=o;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function rl(o){let i="",e="";for(let t=0;t<o.length;t++){let r=o[t+1];o[t]==="\\"&&r==='"'?(i+='\\"',t++):o[t]==='"'&&e!=="\\"?i+='\\"':i+=o[t],e=o[t]??""}return i}function os(o){let i=o;tl(o)&&(i=il(i),i=i.replace(el,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
27
+ `))}}return i}var V=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),J=Object.freeze([V.CROP,V.TUNING,V.FILTERS]),Zo=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Qo=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"]),Yo=Object.freeze(["rotate","mirror","flip"]),Re=Lt,ye=Object.freeze({brightness:{zero:Re.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Re.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Re.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Re.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Re.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Re.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Re.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Re.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Re.filter,range:[0,100],keypointsNumber:1}});var Rt="https://ucarecdn.com",qa="https://upload.uploadcare.com",Xa="https://social.uploadcare.com",Za="https://ucarecd.net",Qa={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Me(J),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Rt,cdnCnamePrefixed:Za,baseUrl:qa,socialBaseUrl:Xa,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},se=Object.freeze(Qa);var Jo="1.25.0-alpha.1";var He="blocks",je=Jo;var pi=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(se);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new ai,this._queue=new De(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:P.CHANGE_CONFIG}),this._setConfig(e,t)})}_init(i){i===P.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===P.INIT_SOLUTION||i.eventType===P.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:je,appName:He,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[I.CHANGE,I.COMMON_UPLOAD_PROGRESS,I.FILE_ADDED,I.FILE_REMOVED,I.FILE_UPLOAD_START,I.FILE_UPLOAD_PROGRESS,I.FILE_UPLOAD_SUCCESS,I.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:P.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s of t)if(!Object.hasOwn(e,s)||!this._checkObj(i[s],e[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var q=o=>`*cfg/${o}`;var es=o=>{let i=new Intl.Locale(o),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e};var hi=(o,i)=>new Intl.PluralRules(o).select(i);var Ja=o=>o;var ts="plural:";function Pt(o,i={},e={}){let{openToken:t="{{",closeToken:r="}}",transform:s=Ja}=e;for(let n in i){let a=i[n],l=a?.toString(),d=typeof l=="string"?s(l):String(l);o=o.replaceAll(t+n+r,d)}return o}function is(o){let i=[],e=o.indexOf("{{");for(;e!==-1;){let t=o.indexOf("}}",e);if(t===-1)break;let r=o.substring(e+2,t);if(r.startsWith(ts)){let s=o.substring(e+2,t).replace(ts,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=o.indexOf("{{",t)}return i}var rs="--uploadcare-blocks-window-height",Ut=class o{static{this.clientsRegistry=new Set}static{this.flush=L(()=>{document.documentElement.style.setProperty(rs,`${window.innerHeight}px`)},100)}static registerClient(i){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(i)}static unregisterClient(i){o.clientsRegistry.delete(i),o.clientsRegistry.size===0&&o.detachTracker()}static attachTracker(){window.addEventListener("resize",o.flush,{passive:!0,capture:!0}),o.flush()}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:!0}),document.documentElement.style.removeProperty(rs)}};var el=/\\([0-9a-fA-F]{1,6} ?)/g;function tl(o){return o.length<2?!1:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function il(o){let i=o;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function rl(o){let i="",e="";for(let t=0;t<o.length;t++){let r=o[t+1];o[t]==="\\"&&r==='"'?(i+='\\"',t++):o[t]==='"'&&e!=="\\"?i+='\\"':i+=o[t],e=o[t]??""}return i}function os(o){let i=o;tl(o)&&(i=il(i),i=i.replace(el,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
28
28
  `,"\\n"),i=rl(i),i='"'+i+'"');try{return JSON.parse(i)}catch{return}}function mi(o){class i extends o{constructor(){super(...arguments);this.cssDataCache=null;this.computedStyle=null}getCssData(r,s=!1){let n=this.cssDataCache??Object.create(null);if(!Object.keys(n).includes(r)||!n[r]){this.computedStyle||(this.computedStyle=window.getComputedStyle(this));let a=this.computedStyle.getPropertyValue(r).trim();try{n[r]=os(a)}catch(l){s||console.warn(`CSS Data error: ${r}`,l),n[r]=null}}return this.cssDataCache=n,n[r]}}return i}function ss(o){class i extends o{constructor(){super(...arguments);this.__slots={};this.__willYield=!0;this.__initialLightDomChildren=null;this.__hasAdoptedChildren=!1}createRenderRoot(){return this}connectedCallback(){this.__initialLightDomChildren||(this.__initialLightDomChildren=Array.from(this.childNodes)),super.connectedCallback()}__adoptChildren(){if(this.__hasAdoptedChildren)return;this.__hasAdoptedChildren=!0,this.__slots={};let r=Array.from(this.childNodes),s=r.length?r:this.__initialLightDomChildren??[];for(let n of s){let a=this.__getSlotNameForChild(n),l=this.__slots[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this.__slots[a]=l}this.__initialLightDomChildren=null}__getSlotNameForChild(r){return r instanceof Comment&&r.nextSibling instanceof Element?this.__getSlotNameForChild(r.nextSibling):"contentFor"in r?r.contentFor||"":r instanceof Element&&r.hasAttribute("content-for")&&r.getAttribute("content-for")||""}__isTextNodeEmpty(r){return!r.textContent||!r.textContent.trim()}__isSlotEmpty(r){let s=this.__slots[r];return!s||s.every(n=>n instanceof Comment||n instanceof Text&&this.__isTextNodeEmpty(n))}update(r){!this.hasUpdated&&this.__willYield&&this.__adoptChildren(),super.update(r)}yield(r,s){if(r===""&&!this.__slots[r]&&!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.__slots[r]=a,this.__hasAdoptedChildren=!0,this.__initialLightDomChildren=null}let n=this.__slots[r];return m.html`
29
29
  ${n}
30
30
  ${this.__isSlotEmpty(r)?s:void 0}
@@ -1,6 +1,7 @@
1
1
  import { PubSub } from '@symbiotejs/symbiote';
2
2
  export { PubSub as Data, PubSub, UID } from '@symbiotejs/symbiote';
3
3
  import * as lit_html from 'lit-html';
4
+ import * as lit_html_directives_ref_js from 'lit-html/directives/ref.js';
4
5
  import { nothing, LitElement, PropertyValues, TemplateResult } from 'lit';
5
6
  import { TelemetryRequest } from '@uploadcare/quality-insights';
6
7
  import * as _uploadcare_upload_client from '@uploadcare/upload-client';
@@ -1359,7 +1360,7 @@ declare class LitBlock extends LitBlockBase {
1359
1360
  declare class Modal extends LitBlock {
1360
1361
  static styleAttrs: string[];
1361
1362
  private _mouseDownTarget;
1362
- private dialogEl;
1363
+ protected dialogEl: lit_html_directives_ref_js.Ref<HTMLDialogElement>;
1363
1364
  handleModalOpen: ModalCb;
1364
1365
  handleModalClose: ModalCb;
1365
1366
  handleModalCloseAll: ModalCb;
@@ -24,7 +24,7 @@
24
24
  *
25
25
  */
26
26
  var yo=Object.defineProperty;var bo=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Rn=Object.prototype.hasOwnProperty;var vo=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of Ln(i))!Rn.call(o,r)&&r!==e&&yo(o,r,{get:()=>i[r],enumerable:!(t=bo(i,r))||t.enumerable});return o},v=(o,i,e)=>(vo(o,i,"default"),e&&vo(e,i,"default"));var h=(o,i,e,t)=>{for(var r=t>1?void 0:t?bo(i,e):i,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(t?n(i,e,r):n(r))||r);return t&&r&&yo(i,e,r),r};var X={BIND_ATTR:"bind",ATTR_BIND_PX:"@",SHARED_CTX_PX:"*",PARENT_CTX_PX:"^",NAMED_CTX_SPLTR:"/",COMPUTED_PX:"+",CSS_DATA_PX:"--",CTX_NAME_ATTR:"ctx",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx",EL_REF_ATTR:"ref",AUTO_TAG_PX:"sym",LIST_ATTR:"itemize",LIST_ITEM_TAG_ATTR:"item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL_ATTR:"use-template",DEFAULT_SLOT_KEY:"__default__",TEXT_NODE_SKIP_ATTR:"skip-text-nodes",TEXT_NODE_OPEN_TOKEN:"{{",TEXT_NODE_CLOSE_TOKEN:"}}"};function Pn(o){let i=e=>{for(let t in e)e[t]?.constructor===Object&&(e[t]=i(e[t]));return{...e}};return i(o)}var U=class o{#i;#r;#e;constructor(i){i.constructor===Object?this.store=Pn(i):(this.#e=!0,this.store=i),this.callbackMap=Object.create(null)}static#t(i,e){console.warn(`Symbiote PubSub: cannot ${i}. Prop name: `+e)}read(i){if(!this.#e&&!this.store.hasOwnProperty(i))return o.#t("read",i),null;if(typeof i=="string"&&i.startsWith(X.COMPUTED_PX)){let e=this.store[i];if(e?.constructor!==Function){o.#t("compute",i);return}this.__computedMap||(this.__computedMap={});let t=e();return Object.keys(this.__computedMap).includes(i)||(this.__computedMap[i]=t,this.notify(i)),t}else return this.store[i]}has(i){return this.#e?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this.#e&&!this.store.hasOwnProperty(i)){o.#t("publish",i);return}if(i?.startsWith(X.COMPUTED_PX)&&e.constructor!==Function){o.#t("publish computed",i);return}!(this.store[i]===null||e===null)&&typeof this.store[i]!=typeof e&&console.warn(`Symbiote PubSub: type warning for "${i}" [${typeof this.store[i]} -> ${typeof e}]`),this.store[i]=e,this.notify(i)}get proxy(){if(!this.#r){let i=Object.create(null);this.#r=new Proxy(i,{set:(e,t,r)=>(this.pub(t,r),!0),get:(e,t)=>{this.read(t)}})}return this.#r}multiPub(i){for(let e in i)this.pub(e,i[e])}static#o(i,e){this.globalStore.forEach(t=>{t.__computedMap&&Object.keys(t.__computedMap).forEach(r=>{if(t===i&&e===r)return;let s=`__${r}_timeout`;t[s]&&window.clearTimeout(t[s]),t[s]=window.setTimeout(()=>{let n=t.read(r);n!==t.__computedMap[r]&&(t.__computedMap[r]=n,t.notify(r))})})})}notify(i){let e=i?.startsWith(X.COMPUTED_PX);if(this.callbackMap[i]){let t=this.read(i);this.callbackMap[i].forEach(r=>{r(t)}),e&&(this.__computedMap[i]=t)}!e&&o.#o(this,i)}sub(i,e,t=!0){return!this.#e&&!this.store.hasOwnProperty(i)?(o.#t("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.read(i)),{remove:()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},callback:e})}set uid(i){!this.#i&&(this.#i=i)}get uid(){return this.#i}static registerCtx(i,e=Symbol()){let t=o.globalStore.get(e);return t?console.warn('PubSub: context UID "'+e+'" is already in use'):(t=new o(i),t.uid=e,o.globalStore.set(e,t)),t}static deleteCtx(i){o.globalStore.delete(i)}static getCtx(i,e=!0){return o.globalStore.get(i)||(e&&console.warn('PubSub: wrong context UID - "'+i+'"'),null)}};U.globalStore=new Map;var _o="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Un=_o.length-1,ge=class{static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:_o.charAt(Math.random()*Un);return e}};var Zc=[X.LIST_ATTR,X.LIST_ITEM_TAG_ATTR,X.EL_REF_ATTR,X.USE_TPL_ATTR,X.CTX_NAME_ATTR,X.CTX_OWNER_ATTR];function ve(o,...i){let e="",t=new CSSStyleSheet;return o.forEach((r,s)=>{e+=r+i[s]}),ve.processors.forEach(r=>{e=r(e)}),ve.clearProcessors(),t.replaceSync(e),t}ve.processors=[];ve.clearProcessors=function(){ve.processors=[]};ve.useProcessor=function(...o){return ve.processors=[...ve.processors,...o],ve};function kt(o,i){for(let e in i)e.includes("-")?o.style.setProperty(e,i[e]):o.style[e]=i[e]}var Vn=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function tr(o){for(let i in o){if(Vn.includes(i))continue;let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r=`-${r.toLowerCase()}`),t+=r,t),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),o[i].reg&&o[i].reg(e)}}var ir="UC";function Fn(o,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[ir]){e(window[ir]);return}let r=document.createElement("script");r.async=!0,r.src=o,r.onerror=()=>{t()},r.onload=()=>{let s=window[ir];i&&tr(s),e(s)},document.head.appendChild(r)})}var Ot={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"OneDrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var Zt=new Map,rr=new Map,Co=(o,i)=>{Zt.has(o)&&console.log(`Locale ${o} is already defined. Overwriting...`),Zt.set(o,{...Ot,...i})},Nn=(o,i)=>{rr.set(o,i)},To=(o,i)=>{typeof i=="function"?Nn(o,i):Co(o,i)},Eo=async o=>{if(!Zt.has(o)){if(!rr.has(o))throw new Error(`Locale ${o} is not defined`);let e=await rr.get(o)();Co(o,e)}return Zt.get(o)};To("en",Ot);var z=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Qt=class{constructor(i){this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;this._block=i}_debugPrint(...i){this._block.debugPrint("[modal-manager]",...i)}registerModal(i,e){this._modals.set(i,e),this._notify(z.ADD,{id:i,modal:e})}deleteModal(i){if(!this._modals.has(i))return!1;let e=this._modals.get(i);return this._modals.delete(i),this._activeModals.delete(i),this._notify(z.DELETE,{id:i,modal:e}),!0}open(i){if(!this._modals.has(i))return this._debugPrint(`Modal with ID "${i}" not found`),!1;let e=this._modals.get(i);return this._activeModals.add(i),this._notify(z.OPEN,{modal:e,id:i}),!0}close(i){if(!this._modals.has(i)||!this._activeModals.has(i))return this._debugPrint(`Modal with ID "${i}" not found or not active`),!1;let e=this._modals.get(i);return this._activeModals.delete(i),this._notify(z.CLOSE,{id:i,modal:e}),!0}toggle(i){return this._modals.has(i)?this._activeModals.has(i)?this.close(i):this.open(i):(this._debugPrint(`Modal with ID "${i}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let i=Array.from(this._activeModals).pop();return i?this.close(i):!1}closeAll(){let i=this._activeModals.size;return this._activeModals.clear(),this._notify(z.CLOSE_ALL,{}),i}subscribe(i,e){return this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(e),()=>this.unsubscribe(i,e)}unsubscribe(i,e){this._subscribers.has(i)&&this._subscribers.get(i)?.delete(e)}_notify(i,e){if(this._subscribers.has(i))for(let t of this._subscribers.get(i)??new Set)try{t(e)}catch(r){this._block.telemetryManager.sendEventError(r,"modal subscriber"),this._debugPrint("Error in modal subscriber:",r)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(z.DESTROY,{})}};function xo(o){return Object.prototype.toString.call(o)==="[object Object]"}var Bn=/\W|_/g;function zn(o){return o.split(Bn).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}function So(o,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(o)?o.map(e=>Oe(e,{ignoreKeys:i})):o}function Oe(o,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(o))return So(o,{ignoreKeys:i});if(!xo(o))return o;let e={};for(let t of Object.keys(o)){let r=o[t];if(i.includes(t)){e[t]=r;continue}xo(r)?r=Oe(r,{ignoreKeys:i}):Array.isArray(r)&&(r=So(r,{ignoreKeys:i})),e[zn(t)]=r}return e}var Hn=o=>new Promise(i=>setTimeout(i,o));function dr({libraryName:o,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){let s="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:o,libraryVersion:i,languageName:s,integration:r});let n=[o,i,t].filter(Boolean).join("/"),a=[s,r].filter(Boolean).join("; ");return`${n} (${a})`}var jn={factor:2,time:100};function Kn(o,i=jn){let e=0;function t(r){let s=Math.round(i.time*i.factor**e);return r({attempt:e,retry:a=>Hn(a??s).then(()=>(e+=1,t(r)))})}return t(o)}var Ye=class extends Error{},lt=class o extends Ye{originalProgressEvent;constructor(i){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,o.prototype),this.originalProgressEvent=i}},Yt=(o,i)=>{o&&(o.aborted?Promise.resolve().then(i):o.addEventListener("abort",()=>i(),{once:!0}))},$e=class o extends Ye{isCancel=!0;constructor(i="Request canceled"){super(i),this.name="CancelError",Object.setPrototypeOf(this,o.prototype)}},Gn=500,Io=({check:o,interval:i=Gn,timeout:e,signal:t})=>new Promise((r,s)=>{let n,a;Yt(t,()=>{n&&clearTimeout(n),s(new $e("Poll cancelled"))}),e&&(a=setTimeout(()=>{n&&clearTimeout(n),s(new $e("Timed out"))},e));let l=()=>{try{Promise.resolve(o(t)).then(d=>{d?(a&&clearTimeout(a),r(d)):n=setTimeout(l,i)}).catch(d=>{a&&clearTimeout(a),s(d)})}catch(d){a&&clearTimeout(a),s(d)}};n=setTimeout(l,0)}),O={baseCDN:"https://ucarecdn.com",baseURL:"https://upload.uploadcare.com",maxContentLength:50*1024*1024,retryThrottledRequestMaxTimes:1,retryNetworkErrorMaxTimes:3,multipartMinFileSize:25*1024*1024,multipartChunkSize:5*1024*1024,multipartMinLastPartSize:1024*1024,maxConcurrentRequests:4,pollingTimeoutMilliseconds:1e4,pusherKey:"79ae88bd931ea68464d9"},Jt="application/octet-stream",ko="original",Ve=({method:o,url:i,data:e,headers:t={},signal:r,onProgress:s})=>new Promise((n,a)=>{let l=new XMLHttpRequest,d=o?.toUpperCase()||"GET",u=!1;l.open(d,i,!0),t&&Object.entries(t).forEach(p=>{let[f,g]=p;typeof g<"u"&&!Array.isArray(g)&&l.setRequestHeader(f,g)}),l.responseType="text",Yt(r,()=>{u=!0,l.abort(),a(new $e)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let p={method:d,url:i,data:e,headers:t||void 0,signal:r,onProgress:s},f=l.getAllResponseHeaders().trim().split(/[\r\n]+/),g={};f.forEach(function(C){let E=C.split(": "),x=E.shift(),k=E.join(": ");x&&typeof x<"u"&&(g[x]=k)});let y=l.response,w=l.status;n({request:p,data:y,headers:g,status:w})}},l.onerror=p=>{u||a(new lt(p))},s&&typeof s=="function"&&(l.upload.onprogress=p=>{p.lengthComputable?s({isComputable:!0,value:p.loaded/p.total}):s({isComputable:!1})}),e?l.send(e):l.send()});function Wn(o,...i){return o}var qn=({name:o})=>o?[o]:[],Xn=Wn,Zn=()=>new FormData,Oo=o=>!1,ei=o=>typeof Blob<"u"&&o instanceof Blob,ti=o=>typeof File<"u"&&o instanceof File,ii=o=>!!o&&typeof o=="object"&&!Array.isArray(o)&&"uri"in o&&typeof o.uri=="string",ct=o=>ei(o)||ti(o)||Oo()||ii(o),Qn=o=>typeof o=="string"||typeof o=="number"||typeof o>"u",Yn=o=>!!o&&typeof o=="object"&&!Array.isArray(o),Jn=o=>!!o&&typeof o=="object"&&"data"in o&&ct(o.data);function Mo(o,i,e){if(Array.isArray(e))for(let t of e)Mo(o,`${i}[]`,t);else if(Jn(e)){let{name:t,contentType:r}=e,s=Xn(e.data,t,r??Jt),n=qn({name:t,contentType:r});o.push([i,s,...n])}else if(Yn(e))for(let[t,r]of Object.entries(e))typeof r<"u"&&o.push([`${i}[${t}]`,String(r)]);else Qn(e)&&e&&o.push([i,e.toString()])}function ea(o){let i=[];for(let[e,t]of Object.entries(o))Mo(i,e,t);return i}function ri(o){let i=Zn(),e=ea(o);for(let t of e){let[r,s,...n]=t;i.append(r,s,...n)}return i}var Q=class o extends Ye{code;request;response;headers;constructor(i,e,t,r,s){super(),this.name="UploadError",this.message=i,this.code=e,this.request=t,this.response=r,this.headers=s,Object.setPrototypeOf(this,o.prototype)}},ta=o=>{let i=new URLSearchParams;for(let[e,t]of Object.entries(o))t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).filter(r=>r[1]??!1).forEach(r=>i.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(t)?t.forEach(r=>{i.append(`${e}[]`,r)}):typeof t=="string"&&t?i.set(e,t):typeof t=="number"&&i.set(e,t.toString());return i.toString()},Ie=(o,i,e)=>{let t=new URL(o);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=ta(e)),t.toString()},ia="6.18.2",ra="UploadcareUploadClient",oa=ia;function Je(o){return dr({libraryName:ra,libraryVersion:oa,...o})}var sa="RequestThrottledError",Ao=15e3,na=1e3;function aa(o){let{headers:i}=o||{};if(!i||typeof i["retry-after"]!="string")return Ao;let e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:Ao}function Fe(o,i){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return Kn(({attempt:r,retry:s})=>o().catch(n=>{if("response"in n&&n?.code===sa&&r<e)return s(aa(n));if(n instanceof lt&&r<t)return s((r+1)*na);throw n}))}var Lo=o=>{let i="";return(ei(o)||ti(o)||ii(o))&&(i=o.type),i||Jt},Ro=o=>{let i="";return ti(o)&&o.name?i=o.name:ei(o)||Oo()?i="":ii(o)&&o.name&&(i=o.name),i||ko};function ur(o){return typeof o>"u"||o==="auto"?"auto":o?"1":"0"}function la(o,{publicKey:i,fileName:e,contentType:t,baseURL:r=O.baseURL,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:d,source:u="local",integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",url:Ie(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},data:ri({file:{data:o,name:e||Ro(o),contentType:t||Lo(o)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:ur(a),signature:s,expire:n,source:u,metadata:w}),signal:l,onProgress:d}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k}),{retryNetworkErrorMaxTimes:y,retryThrottledRequestMaxTimes:g})}var nr;(function(o){o.Token="token",o.FileInfo="file_info"})(nr||(nr={}));function ca(o,{publicKey:i,baseURL:e=O.baseURL,store:t,fileName:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:d="url",signal:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},url:Ie(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:o,store:ur(t),filename:r,check_URL_duplicates:s?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:d,metadata:w}),signal:u}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k}),{retryNetworkErrorMaxTimes:y,retryThrottledRequestMaxTimes:g})}var re;(function(o){o.Unknown="unknown",o.Waiting="waiting",o.Progress="progress",o.Error="error",o.Success="success"})(re||(re={}));var da=o=>"status"in o&&o.status===re.Error;function ua(o,{publicKey:i,baseURL:e=O.baseURL,signal:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=O.retryNetworkErrorMaxTimes}={}){return Fe(()=>Ve({method:"GET",headers:i?{"X-UC-User-Agent":Je({publicKey:i,integration:r,userAgent:s})}:void 0,url:Ie(e,"/from_url/status/",{jsonerrors:1,token:o}),signal:t}).then(({data:l,headers:d,request:u})=>{let p=Oe(JSON.parse(l));if("error"in p&&!da(p))throw new Q(p.error.content,p.error.errorCode,u,p,d);return p}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function pa(o,{publicKey:i,baseURL:e=O.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:s,signal:n,source:a,integration:l,userAgent:d,retryThrottledRequestMaxTimes:u=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"POST",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:l,userAgent:d})},url:Ie(e,"/group/",{jsonerrors:1}),data:ri({files:o,callback:t,pub_key:i,signature:r,expire:s,source:a}),signal:n}).then(({data:f,headers:g,request:y})=>{let w=Oe(JSON.parse(f));if("error"in w)throw new Q(w.error.content,w.error.errorCode,y,w,g);return w}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:u})}function Po(o,{publicKey:i,baseURL:e=O.baseURL,signal:t,source:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"GET",headers:{"X-UC-User-Agent":Je({publicKey:i,integration:s,userAgent:n})},url:Ie(e,"/info/",{jsonerrors:1,pub_key:i,file_id:o,source:r}),signal:t}).then(({data:d,headers:u,request:p})=>{let f=Oe(JSON.parse(d));if("error"in f)throw new Q(f.error.content,f.error.errorCode,p,f,u);return f}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function ha(o,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=O.multipartChunkSize,baseURL:s="",secureSignature:n,secureExpire:a,store:l,signal:d,source:u="local",integration:p,userAgent:f,retryThrottledRequestMaxTimes:g=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:y=O.retryNetworkErrorMaxTimes,metadata:w}){return Fe(()=>Ve({method:"POST",url:Ie(s,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:p,userAgent:f})},data:ri({filename:t||ko,size:o,content_type:e||Jt,part_size:r,UPLOADCARE_STORE:ur(l),UPLOADCARE_PUB_KEY:i,signature:n,expire:a,source:u,metadata:w}),signal:d}).then(({data:C,headers:E,request:x})=>{let k=Oe(JSON.parse(C));if("error"in k)throw new Q(k.error.content,k.error.errorCode,x,k,E);return k.parts=Object.keys(k.parts).map(ue=>k.parts[Number(ue)]),k}),{retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})}function ma(o,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:s=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"PUT",url:i,data:o,onProgress:r,signal:t,headers:{"Content-Type":e||Jt}}).then(a=>(r&&r({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n})}function fa(o,{publicKey:i,baseURL:e=O.baseURL,source:t="local",signal:r,integration:s,userAgent:n,retryThrottledRequestMaxTimes:a=O.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=O.retryNetworkErrorMaxTimes}){return Fe(()=>Ve({method:"POST",url:Ie(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Je({publicKey:i,integration:s,userAgent:n})},data:ri({uuid:o,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:d,headers:u,request:p})=>{let f=Oe(JSON.parse(d));if("error"in f)throw new Q(f.error.content,f.error.errorCode,p,f,u);return f}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function pr(o,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:d}){return Io({check:u=>Po(o,{publicKey:i,baseURL:e,signal:u,source:t,integration:r,userAgent:s,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(p=>p.isReady?p:(d&&d({isComputable:!0,value:1}),!1)),signal:l})}function ga(o){return"defaultEffects"in o}var ke=class{uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(i,{baseCDN:e=O.baseCDN,fileName:t}={}){let{uuid:r,s3Bucket:s}=i,n=Ie(e,`${r}/`),a=s?Ie(`https://${s}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=t||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=n,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=s||null,this.s3Url=a,ga(i)&&(this.defaultEffects=i.defaultEffects)}},va=(o,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,contentType:a,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,baseCDN:w,metadata:C})=>la(o,{publicKey:i,fileName:e,contentType:a,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,metadata:C}).then(({file:E})=>pr(E,{publicKey:i,baseURL:t,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,onProgress:d,signal:l})).then(E=>new ke(E,{baseCDN:w})),ya=(o,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:s,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u,baseCDN:p})=>Po(o,{publicKey:i,baseURL:t,signal:r,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:u}).then(f=>new ke(f,{baseCDN:p,fileName:e})).then(f=>(s&&s({isComputable:!0,value:1}),f)),ba=(o,{signal:i}={})=>{let e=null,t=null,r=o.map(()=>new AbortController),s=n=>()=>{t=n,r.forEach((a,l)=>l!==n&&a.abort())};return Yt(i,()=>{r.forEach(n=>n.abort())}),Promise.all(o.map((n,a)=>{let l=s(a);return Promise.resolve().then(()=>n({stopRace:l,signal:r[a].signal})).then(d=>(l(),d)).catch(d=>(e=d,null))})).then(n=>{if(t===null)throw e;return n[t]})},_a=window.WebSocket,ar=class{events=Object.create({});emit(i,e){this.events[i]?.forEach(t=>t(e))}on(i,e){this.events[i]=this.events[i]||[],this.events[i].push(e)}off(i,e){e?this.events[i]=this.events[i].filter(t=>t!==e):this.events[i]=[]}},wa=(o,i)=>o==="success"?{status:re.Success,...i}:o==="progress"?{status:re.Progress,...i}:{status:re.Error,...i},lr=class{key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new ar;disconnectTimeoutId=null;constructor(i,e=3e4){this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new _a(i),this.ws.addEventListener("error",e=>{this.emmitter.emit("error",new Error(e.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(e=>this.send(e.event,e.data)),this.queue=[]}),this.ws.addEventListener("message",e=>{let t=JSON.parse(e.data.toString());switch(t.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(t.channel,wa(t.event,JSON.parse(t.data)))}})}}disconnect(){let i=()=>{this.ws?.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){let t=JSON.stringify({event:i,data:e});this.ws?.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();let t=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:t}};this.emmitter.on(t,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}unsubscribe(i){this.subscribers-=1;let e=`task-status-${i}`,t={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(t.event,t.data):this.queue=this.queue.filter(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}},or=null,hr=o=>{if(!or){let i=typeof window>"u"?0:3e4;or=new lr(o,i)}return or},Ca=o=>{hr(o).connect()};function Ta({token:o,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Io({check:d=>ua(o,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:s,retryNetworkErrorMaxTimes:n,signal:d}).then(u=>{switch(u.status){case re.Error:return new Q(u.error,u.errorCode);case re.Waiting:return!1;case re.Unknown:return new Q(`Token "${o}" was not found.`);case re.Progress:return a&&(u.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:u.done/u.total})),!1;case re.Success:return a&&a({isComputable:!0,value:u.done/u.total}),u;default:throw new Error("Unknown status")}}),signal:l})}var Ea=({token:o,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,s)=>{let n=hr(i),a=n.onError(s),l=()=>{a(),n.unsubscribe(o)};Yt(e,()=>{l(),s(new $e("pusher cancelled"))}),n.subscribe(o,d=>{switch(d.status){case re.Progress:{t&&(d.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:d.done/d.total}));break}case re.Success:{l(),t&&t({isComputable:!0,value:d.done/d.total}),r(d);break}case re.Error:l(),s(new Q(d.msg,d.error_code))}})}),xa=(o,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:d,signal:u,onProgress:p,source:f,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,pusherKey:C=O.pusherKey,metadata:E})=>Promise.resolve(Ca(C)).then(()=>ca(o,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:s,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:d,signal:u,source:f,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,metadata:E})).catch(x=>(hr(C)?.disconnect(),Promise.reject(x))).then(x=>x.type===nr.FileInfo?x:ba([({signal:k})=>Ta({token:x.token,publicKey:i,baseURL:t,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,onProgress:p,signal:k}),({signal:k})=>Ea({token:x.token,pusherKey:C,signal:k,onProgress:p})],{signal:u})).then(x=>{if(x instanceof Q)throw x;return x}).then(x=>pr(x.uuid,{publicKey:i,baseURL:t,integration:g,userAgent:y,retryThrottledRequestMaxTimes:w,onProgress:p,signal:u})).then(x=>new ke(x,{baseCDN:r})),sr=new WeakMap,Sa=async o=>{if(sr.has(o))return sr.get(o);let i=await fetch(o.uri).then(e=>e.blob());return sr.set(o,i),i},Uo=async o=>{if(ti(o)||ei(o))return o.size;if(ii(o))return(await Sa(o)).size;throw new Error("Unknown file type. Cannot determine file size.")},Aa=(o,i=O.multipartMinFileSize)=>o>=i,$o=o=>{let i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(i);return!ct(o)&&e.test(o)},mr=o=>{let i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!ct(o)&&e.test(o)},Ia=(o,i)=>new Promise((e,t)=>{let r=[],s=!1,n=i.length,a=[...i],l=()=>{let d=i.length-a.length,u=a.shift();u&&u().then(p=>{s||(r[d]=p,n-=1,n?l():e(r))}).catch(p=>{s=!0,t(p)})};for(let d=0;d<o;d++)l()}),ka=(o,i,e,t)=>{let r=t*i,s=Math.min(r+t,e);return o.slice(r,s)},Oa=async(o,i,e)=>t=>ka(o,t,i,e),Ma=(o,i,{publicKey:e,contentType:t,onProgress:r,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>ma(o,i,{publicKey:e,contentType:t,onProgress:r,signal:s,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),La=async(o,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,onProgress:d,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,contentType:w,multipartChunkSize:C=O.multipartChunkSize,maxConcurrentRequests:E=O.maxConcurrentRequests,baseCDN:x,metadata:k})=>{let ue=t??await Uo(o),pe,Qe=(W,ie)=>{if(!d)return;pe||(pe=Array(W).fill(0));let fe=we=>we.reduce((Ae,er)=>Ae+er,0);return we=>{we.isComputable&&(pe[ie]=we.value,d({isComputable:!0,value:fe(pe)/W}))}};return w||=Lo(o),ha(ue,{publicKey:i,contentType:w,fileName:e||Ro(o),baseURL:r,secureSignature:s,secureExpire:n,store:a,signal:l,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,metadata:k,multipartChunkSize:C}).then(async({uuid:W,parts:ie})=>{let fe=await Oa(o,ue,C);return Promise.all([W,Ia(E,ie.map((we,Ae)=>()=>Ma(fe(Ae),we,{publicKey:i,contentType:w,onProgress:Qe(ie.length,Ae),signal:l,integration:p,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})))])}).then(([W])=>fa(W,{publicKey:i,baseURL:r,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y})).then(W=>W.isReady?W:pr(W.uuid,{publicKey:i,baseURL:r,source:u,integration:p,userAgent:f,retryThrottledRequestMaxTimes:g,retryNetworkErrorMaxTimes:y,onProgress:d,signal:l})).then(W=>new ke(W,{baseCDN:x}))};async function fr(o,{publicKey:i,fileName:e,baseURL:t=O.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartMinFileSize:w,multipartChunkSize:C,maxConcurrentRequests:E,baseCDN:x=O.baseCDN,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:ue,pusherKey:pe,metadata:Qe}){if(ct(o)){let W=await Uo(o);return Aa(W,w)?La(o,{publicKey:i,contentType:y,multipartChunkSize:C,fileSize:W,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,maxConcurrentRequests:E,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x,metadata:Qe}):va(o,{publicKey:i,fileName:e,contentType:y,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x,metadata:Qe})}if(mr(o))return xa(o,{publicKey:i,fileName:e,baseURL:t,baseCDN:x,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:ue,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,pusherKey:pe,metadata:Qe});if($o(o))return ya(o,{publicKey:i,fileName:e,baseURL:t,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:x});throw new TypeError(`File uploading from "${o}" is not supported`)}var cr=class{uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(i,{baseCDN:e=O.baseCDN}={}){this.uuid=i.id,this.filesCount=i.filesCount;let t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,s)=>r+s.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(t).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=t.map(r=>new ke(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}},Ra=o=>{for(let i of o)if(!ct(i))return!1;return!0},Pa=o=>{for(let i of o)if(!$o(i))return!1;return!0},Ua=o=>{for(let i of o)if(!mr(i))return!1;return!0};function Do(o,{publicKey:i,fileName:e,baseURL:t=O.baseURL,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:l,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartChunkSize:w=O.multipartChunkSize,baseCDN:C=O.baseCDN,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x,jsonpCallback:k}){if(!Ra(o)&&!Ua(o)&&!Pa(o))throw new TypeError(`Group uploading from "${o}" is not supported`);let ue,pe=!0,Qe=o.length,W=(ie,fe)=>{if(!l)return;ue||(ue=Array(ie).fill(0));let we=Ae=>Ae.reduce((er,Mn)=>er+Mn)/ie;return Ae=>{if(!Ae.isComputable||!pe){pe=!1,l({isComputable:!1});return}ue[fe]=Ae.value,l({isComputable:!0,value:we(ue)})}};return Promise.all(o.map((ie,fe)=>ct(ie)||mr(ie)?fr(ie,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:s,store:n,signal:a,onProgress:W(Qe,fe),source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:y,multipartChunkSize:w,baseCDN:C,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x}).then(we=>we.uuid):ie)).then(ie=>pa(ie,{publicKey:i,baseURL:t,jsonpCallback:k,secureSignature:r,secureExpire:s,signal:a,source:d,integration:u,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g}).then(fe=>new cr(fe,{baseCDN:C})).then(fe=>(l&&l({isComputable:!0,value:1}),fe)))}var De=class{_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(i){this._concurrency=i}run(){let i=this._concurrency-this._running;for(let e=0;e<i;e++){let t=this._pending.shift();if(!t)return;let r=this._resolvers.get(t),s=this._rejectors.get(t);if(!r||!s)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this.run()}).then(n=>r(n)).catch(n=>s(n))}}add(i,{autoRun:e}={autoRun:!0}){return new Promise((t,r)=>{this._resolvers.set(i,t),this._rejectors.set(i,r),this._pending.push(i),e&&this.run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this.run()}get concurrency(){return this._concurrency}};var gr=()=>({}),vr=o=>({...gr(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{o.modalManager?.close(o.$["*currentActivity"]),o.set$({"*currentActivity":null})}}),yr=o=>({...vr(o),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new De(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),Vo=o=>({...yr(o),"*solution":null});var P=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),I=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"}),oi=class{constructor(i){this._timeoutStore=new Map;this._targets=new Set;this._debugPrint=null;this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){for(let t of this._targets)t.dispatchEvent(new CustomEvent(i,{detail:e}));this._debugPrint?.(()=>{let t=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,t]})}emit(i,e,t={}){let{debounce:r}=t;if(typeof r!="number"&&!r){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let s=typeof r=="number"?r:20,n=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},s);this._timeoutStore.set(i,n)}};function L(o,i){let e,t=((...r)=>{e&&clearTimeout(e),e=setTimeout(()=>o(...r),i)});return t.cancel=()=>{e&&clearTimeout(e)},t}var m={};v(m,Yd);v(m,Jd);import"@lit/reactive-element";import"lit-html";import*as Yd from"lit-element/lit-element.js";import*as Jd from"lit-html/is-server.js";var $a={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function Mt(o,i){i.tabIndex=0,i.focus(),o.tabIndex=-1}function br(o){let i=o.role||o.type||o.tagName;if(!i)return null;let e=$a[i.toLowerCase()];if(!e)return null;for(let t of e){let r=o.closest(`[role=${t}]`);if(r)return r}}function _r(o,i){return i.role==="toolbar"?Da(i):i.querySelectorAll(`[role=${o.role}]`)}function Da(o){return[...o.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function Va(o){let i=o.getAttribute("aria-orientation");if(i==="vertical")return!1;if(i==="horizontal")return!0;let e=o.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function Fo(o){return i=>{let e=!1,t=o?.searchDelayMs||300,r=0,s="";function n(p){let f=br(p.target);if(!f){a();return}let g=_r(p.target,f),y=Array.from(g).indexOf(p.target),w="ArrowDown",C="ArrowUp";if(Va(f)&&(i.document.dir==="rtl"?(w="ArrowLeft",C="ArrowRight"):(w="ArrowRight",C="ArrowLeft")),p.key===w)p.preventDefault(),Mt(p.target,g[y+1]||g[0]);else if(p.key===C)p.preventDefault(),Mt(p.target,g[y-1]||g[g.length-1]);else if(p.key==="Home")p.preventDefault(),Mt(p.target,g[0]);else if(p.key==="End")p.preventDefault(),Mt(p.target,g[g.length-1]);else if(p.key.length===1&&f.role!=="tablist"){let E=Date.now();E-r<=t?s+=p.key.toLowerCase():s=p.key.toLowerCase(),r=E;let x=Array.from(g).find(k=>k.textContent?.trim()?.toLowerCase()?.startsWith(s));x&&(p.preventDefault(),Mt(p.target,x))}}function a(){e=!1,i.removeEventListener("keydown",n)}function l(p){let f=br(p.target);if(f){e||(e=!0,i.addEventListener("keydown",n));let g=_r(p.target,f);for(let y of g)y!==p.target&&y.setAttribute("tabindex",-1)}else e&&a()}function d(p){(!p.relatedTarget||p.relatedTarget===i.document)&&a()}function u(p){let f=br(p.target);if(f){let g=_r(p.target,f);for(let y of g)y!==p.target&&y.setAttribute("tabindex",-1);p.target.setAttribute("tabindex",0)}}return i.addEventListener("click",u),i.addEventListener("focusin",l),i.addEventListener("focusout",d),()=>{a(),i.removeEventListener("click",u),i.removeEventListener("focusin",l),i.removeEventListener("focusout",d)}}}function No(){return o=>{let i,e;function t(s){if(s.target.getAttribute("aria-hidden")==="true"){i=s.target,i.setAttribute("aria-hidden","false"),e=i.hidden,e&&(i.hidden=!1);let n=s.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function r(s){i&&i.contains(s.target)&&(!s.relatedTarget||!i.contains(s.relatedTarget))&&(s.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),e&&(i.hidden=!0),i=null)}return o.addEventListener("keyuxJump",t),o.addEventListener("focusout",r),()=>{o.removeEventListener("keyuxJump",t),o.removeEventListener("focusout",r)}}}function Bo(){return o=>{let i=[];function e(l){let d=o.document.activeElement;d&&d!==o.document.body&&i.push(new WeakRef(d)),l.focus({focusVisible:!0})}function t(){let l=i.pop();if(!l){o.document.activeElement.blur();return}let d=l.deref();d&&d.isConnected?d.focus():t()}let r=0,s;function n(l){clearInterval(s);let d=l.getAttribute("aria-controls");s=setInterval(()=>{if(r++>50){clearInterval(s);return}let u=o.document.getElementById(d);if(u){let p=u.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');p&&(clearInterval(s),u.dispatchEvent(new o.CustomEvent("keyuxJump",{bubbles:!0})),e(p))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&t()}return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}}}function zo(o){let i,e=o.split(" "),t;function r(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(s(),a.target.classList.add(...e),i=a.target,t=a.target)}function s(){i&&i.classList.remove(...e),t=null}function n(a){a.clientX===0&&a.clientY===0&&t!==a.target&&(s(),a.target.classList.add(...e),i=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",r),a.addEventListener("keyup",s),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",r),a.removeEventListener("keyup",s)})}function Ho(o,i){let e=i.map(t=>t(o));return()=>{e.forEach(t=>t())}}var wr=class{constructor(){this._listeners=new Map;this._scope=[]}addEventListener(i,e){let t=r=>{let s=r.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&e(r)};this._listeners.set(e,t),window.addEventListener(i,t)}removeEventListener(i,e){let t=this._listeners.get(e);t&&window.removeEventListener(i,t),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this._scope.push(i)}destroy(){this._scope=[];for(let i of this._listeners.values())window.removeEventListener("keydown",i),window.removeEventListener("keyup",i);this._listeners.clear()}},si=class{constructor(){this._scopedWindow=new wr,this._destroyKeyUX=Ho(this._scopedWindow,[Fo(),zo("is-pressed"),Bo(),No()])}registerBlock(i){this._scopedWindow.registerScope(i)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var Ne=o=>`*l10n/${o}`,Fa="en",ni=class{constructor(i){this._blockInstance=null;this._localeName="";this._blockInstance=i;for(let[e,t]of Object.entries(Ot)){let r=this._blockInstance.has(Ne(e))?!this._blockInstance.$[Ne(e)]:!0;this._blockInstance.add(Ne(e),t,r)}setTimeout(()=>{i.subConfigValue("localeName",async e=>{if(!this._blockInstance||!e)return;this._localeName=e;let t=await Eo(e);if(e!==Fa&&this._localeName!==e)return;let r=this._blockInstance.cfg.localeDefinitionOverride?.[e];for(let[s,n]of Object.entries(t)){let a=r?.[s];this._blockInstance.add(Ne(s),a??n,!0)}}),i.subConfigValue("localeDefinitionOverride",e=>{if(!e)return;let t=e[this._localeName];if(t)for(let[r,s]of Object.entries(t))this._blockInstance?.add(Ne(r),s,!0)})})}};function Na(o){return o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`).replace(/__/g,"_")}function Tr(o){return Array.isArray(o)?o.map(i=>typeof i=="object"&&i!==null?Tr(i):i):typeof o!="object"||o===null?o:Object.fromEntries(Object.entries(o).map(([i,e])=>{let t=Na(i);return typeof e=="object"&&e!==null?[t,Tr(e)]:[t,e]}))}function Ba(o){return{ok:!0,value:o}}function Cr(o){return{ok:!1,error:o}}var za="https://tlm.uploadcare.com/api/",Er=class{constructor(i=za){this.baseUrl=i}async base(i,e={}){let t=`${this.baseUrl}${i}`;try{let r=await fetch(t,e);if(!r.ok)return Cr(new Error(`Got non-200 response from "${t}". Status: ${r.status.toString()}`));try{let s=await r.json();return Ba(s)}catch(s){return Cr(new Error(`Error parsing JSON from "${t}". Error: ${s}`))}}catch(r){return Cr(new Error(`Error fetching data from "${t}". Error: ${r}`))}}async post(i,e,t={}){return await this.base(i,{...t,method:"POST",body:JSON.stringify(Tr(e)),headers:{"Content-Type":"application/json",...t.headers||{}}})}async get(i,e={}){return await this.base(i,{method:"GET",...e})}},Ha=async(o,i)=>({success:!0,data:i}),ai=class extends Er{constructor(){super()}async sendEvent(i,e){let t=await Ha(void 0,i);if(!t.success)throw console.error("TelemetryAPIService: events: body is invalid",t.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",i,e)}};var oe=o=>o?o.split(",").map(i=>i.trim()).filter(Boolean):[],Me=o=>o.join(",");var jo=o=>{if(typeof o!="string"||!o)return"";let i=o.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},li=(...o)=>o.filter(i=>typeof i=="string"&&!!i).map(i=>jo(i)).join("/-/"),Y=(...o)=>{let i=li(...o);return i?`-/${i}/`:""};function ci(o){let i=new URL(o),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),s="";return t>=0?s=e.slice(t):r>=0&&(s=e.slice(r+1)),s}function di(o){let i=new URL(o),{pathname:e}=i,t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}function xr(o){let i=Ko(o),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}function Sr(o){return xr(o).split("/-/").filter(Boolean).map(e=>jo(e))}function Ko(o){let i=new URL(o),e=ci(o),t=Go(e)?Wo(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}function Go(o){return o.startsWith("http")}function Wo(o){let i=new URL(o);return{pathname:`${i.origin}${i.pathname??""}`,search:i.search??"",hash:i.hash??""}}var H=(o,i,e)=>{let t=new URL(Ko(o)),r=e??ci(o),s=i??"";if(t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),r&&Go(r)){let n=Wo(r);t.pathname=`${t.pathname}${s}${n.pathname||""}`,t.search=n.search,t.hash=n.hash}else t.pathname=`${t.pathname}${s}${r||""}`;return t.toString()},Be=(o,i)=>{let e=new URL(o);return e.pathname=`${i}/`,e.toString()};var j=(o,i=",")=>o.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0);var Lt=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:!1,flip:!1,crop:void 0}),Xo=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function ja(o,i){if(typeof i=="number"){let e=i;return Lt[o]!==e?`${o}/${e}`:""}if(typeof i=="boolean"){let e=i;return Lt[o]!==e?`${o}`:""}if(o==="filter"&&i){let{name:e,amount:t}=i;return Lt.filter===t?"":`${o}/${e}/${t}`}if(o==="crop"&&i){let{dimensions:e,coords:t}=i;return`${o}/${e.join("x")}/${t.join(",")}`}return""}function ze(o){return li(...Xo.filter(i=>typeof o[i]<"u"&&o[i]!==null).map(i=>{let e=o[i];return ja(i,e)}).filter(i=>!!i))}var ui=li("format/auto","progressive/yes"),Le=([o])=>typeof o<"u"?Number(o):void 0,qo=()=>!0,Ka=([o,i])=>({name:o,amount:typeof i<"u"?Number(i):100}),Ga=([o,i])=>{if(!/\d+x\d+/.test(o)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:j(o,"x").map(Number),coords:j(i).map(Number)}},Wa=Object.freeze({enhance:Le,brightness:Le,exposure:Le,gamma:Le,contrast:Le,saturation:Le,vibrance:Le,warmth:Le,filter:Ka,mirror:qo,flip:qo,rotate:Le,crop:o=>{let[i,e]=o,{dimensions:t,coords:r}=Ga([i,e]);return{dimensions:t,coords:r}}});function Ar(o){let i={};for(let e of o){let[t,...r]=e.split("/");if(!t||!Xo.includes(t))continue;let s=t,n=Wa[s];try{let a=n(r);i[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(`
27
- `))}}return i}var V=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),J=Object.freeze([V.CROP,V.TUNING,V.FILTERS]),Zo=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Qo=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"]),Yo=Object.freeze(["rotate","mirror","flip"]),Re=Lt,ye=Object.freeze({brightness:{zero:Re.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Re.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Re.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Re.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Re.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Re.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Re.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Re.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Re.filter,range:[0,100],keypointsNumber:1}});var Rt="https://ucarecdn.com",qa="https://upload.uploadcare.com",Xa="https://social.uploadcare.com",Za="https://ucarecd.net",Qa={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Me(J),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Rt,cdnCnamePrefixed:Za,baseUrl:qa,socialBaseUrl:Xa,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},se=Object.freeze(Qa);var Jo="1.25.0-alpha.0";var He="blocks",je=Jo;var pi=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(se);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new ai,this._queue=new De(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:P.CHANGE_CONFIG}),this._setConfig(e,t)})}_init(i){i===P.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===P.INIT_SOLUTION||i.eventType===P.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:je,appName:He,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[I.CHANGE,I.COMMON_UPLOAD_PROGRESS,I.FILE_ADDED,I.FILE_REMOVED,I.FILE_UPLOAD_START,I.FILE_UPLOAD_PROGRESS,I.FILE_UPLOAD_SUCCESS,I.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:P.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s of t)if(!Object.hasOwn(e,s)||!this._checkObj(i[s],e[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var q=o=>`*cfg/${o}`;var es=o=>{let i=new Intl.Locale(o),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e};var hi=(o,i)=>new Intl.PluralRules(o).select(i);var Ja=o=>o;var ts="plural:";function Pt(o,i={},e={}){let{openToken:t="{{",closeToken:r="}}",transform:s=Ja}=e;for(let n in i){let a=i[n],l=a?.toString(),d=typeof l=="string"?s(l):String(l);o=o.replaceAll(t+n+r,d)}return o}function is(o){let i=[],e=o.indexOf("{{");for(;e!==-1;){let t=o.indexOf("}}",e);if(t===-1)break;let r=o.substring(e+2,t);if(r.startsWith(ts)){let s=o.substring(e+2,t).replace(ts,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=o.indexOf("{{",t)}return i}var rs="--uploadcare-blocks-window-height",Ut=class o{static{this.clientsRegistry=new Set}static{this.flush=L(()=>{document.documentElement.style.setProperty(rs,`${window.innerHeight}px`)},100)}static registerClient(i){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(i)}static unregisterClient(i){o.clientsRegistry.delete(i),o.clientsRegistry.size===0&&o.detachTracker()}static attachTracker(){window.addEventListener("resize",o.flush,{passive:!0,capture:!0}),o.flush()}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:!0}),document.documentElement.style.removeProperty(rs)}};var el=/\\([0-9a-fA-F]{1,6} ?)/g;function tl(o){return o.length<2?!1:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function il(o){let i=o;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function rl(o){let i="",e="";for(let t=0;t<o.length;t++){let r=o[t+1];o[t]==="\\"&&r==='"'?(i+='\\"',t++):o[t]==='"'&&e!=="\\"?i+='\\"':i+=o[t],e=o[t]??""}return i}function os(o){let i=o;tl(o)&&(i=il(i),i=i.replace(el,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
27
+ `))}}return i}var V=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),J=Object.freeze([V.CROP,V.TUNING,V.FILTERS]),Zo=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Qo=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"]),Yo=Object.freeze(["rotate","mirror","flip"]),Re=Lt,ye=Object.freeze({brightness:{zero:Re.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:Re.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:Re.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:Re.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:Re.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:Re.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:Re.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:Re.enhance,range:[0,100],keypointsNumber:1},filter:{zero:Re.filter,range:[0,100],keypointsNumber:1}});var Rt="https://ucarecdn.com",qa="https://upload.uploadcare.com",Xa="https://social.uploadcare.com",Za="https://ucarecd.net",Qa={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Me(J),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Rt,cdnCnamePrefixed:Za,baseUrl:qa,socialBaseUrl:Xa,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0},se=Object.freeze(Qa);var Jo="1.25.0-alpha.1";var He="blocks",je=Jo;var pi=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(se);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new ai,this._queue=new De(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:P.CHANGE_CONFIG}),this._setConfig(e,t)})}_init(i){i===P.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===P.INIT_SOLUTION||i.eventType===P.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:je,appName:He,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[I.CHANGE,I.COMMON_UPLOAD_PROGRESS,I.FILE_ADDED,I.FILE_REMOVED,I.FILE_UPLOAD_START,I.FILE_UPLOAD_PROGRESS,I.FILE_UPLOAD_SUCCESS,I.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:P.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:P.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s of t)if(!Object.hasOwn(e,s)||!this._checkObj(i[s],e[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var q=o=>`*cfg/${o}`;var es=o=>{let i=new Intl.Locale(o),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e};var hi=(o,i)=>new Intl.PluralRules(o).select(i);var Ja=o=>o;var ts="plural:";function Pt(o,i={},e={}){let{openToken:t="{{",closeToken:r="}}",transform:s=Ja}=e;for(let n in i){let a=i[n],l=a?.toString(),d=typeof l=="string"?s(l):String(l);o=o.replaceAll(t+n+r,d)}return o}function is(o){let i=[],e=o.indexOf("{{");for(;e!==-1;){let t=o.indexOf("}}",e);if(t===-1)break;let r=o.substring(e+2,t);if(r.startsWith(ts)){let s=o.substring(e+2,t).replace(ts,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=o.indexOf("{{",t)}return i}var rs="--uploadcare-blocks-window-height",Ut=class o{static{this.clientsRegistry=new Set}static{this.flush=L(()=>{document.documentElement.style.setProperty(rs,`${window.innerHeight}px`)},100)}static registerClient(i){o.clientsRegistry.size===0&&o.attachTracker(),o.clientsRegistry.add(i)}static unregisterClient(i){o.clientsRegistry.delete(i),o.clientsRegistry.size===0&&o.detachTracker()}static attachTracker(){window.addEventListener("resize",o.flush,{passive:!0,capture:!0}),o.flush()}static detachTracker(){window.removeEventListener("resize",o.flush,{capture:!0}),document.documentElement.style.removeProperty(rs)}};var el=/\\([0-9a-fA-F]{1,6} ?)/g;function tl(o){return o.length<2?!1:(o[0]==='"'||o[0]==="'")&&(o[o.length-1]==='"'||o[o.length-1]==="'")}function il(o){let i=o;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function rl(o){let i="",e="";for(let t=0;t<o.length;t++){let r=o[t+1];o[t]==="\\"&&r==='"'?(i+='\\"',t++):o[t]==='"'&&e!=="\\"?i+='\\"':i+=o[t],e=o[t]??""}return i}function os(o){let i=o;tl(o)&&(i=il(i),i=i.replace(el,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
28
28
  `,"\\n"),i=rl(i),i='"'+i+'"');try{return JSON.parse(i)}catch{return}}function mi(o){class i extends o{constructor(){super(...arguments);this.cssDataCache=null;this.computedStyle=null}getCssData(r,s=!1){let n=this.cssDataCache??Object.create(null);if(!Object.keys(n).includes(r)||!n[r]){this.computedStyle||(this.computedStyle=window.getComputedStyle(this));let a=this.computedStyle.getPropertyValue(r).trim();try{n[r]=os(a)}catch(l){s||console.warn(`CSS Data error: ${r}`,l),n[r]=null}}return this.cssDataCache=n,n[r]}}return i}function ss(o){class i extends o{constructor(){super(...arguments);this.__slots={};this.__willYield=!0;this.__initialLightDomChildren=null;this.__hasAdoptedChildren=!1}createRenderRoot(){return this}connectedCallback(){this.__initialLightDomChildren||(this.__initialLightDomChildren=Array.from(this.childNodes)),super.connectedCallback()}__adoptChildren(){if(this.__hasAdoptedChildren)return;this.__hasAdoptedChildren=!0,this.__slots={};let r=Array.from(this.childNodes),s=r.length?r:this.__initialLightDomChildren??[];for(let n of s){let a=this.__getSlotNameForChild(n),l=this.__slots[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this.__slots[a]=l}this.__initialLightDomChildren=null}__getSlotNameForChild(r){return r instanceof Comment&&r.nextSibling instanceof Element?this.__getSlotNameForChild(r.nextSibling):"contentFor"in r?r.contentFor||"":r instanceof Element&&r.hasAttribute("content-for")&&r.getAttribute("content-for")||""}__isTextNodeEmpty(r){return!r.textContent||!r.textContent.trim()}__isSlotEmpty(r){let s=this.__slots[r];return!s||s.every(n=>n instanceof Comment||n instanceof Text&&this.__isTextNodeEmpty(n))}update(r){!this.hasUpdated&&this.__willYield&&this.__adoptChildren(),super.update(r)}yield(r,s){if(r===""&&!this.__slots[r]&&!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.__slots[r]=a,this.__hasAdoptedChildren=!0,this.__initialLightDomChildren=null}let n=this.__slots[r];return m.html`
29
29
  ${n}
30
30
  ${this.__isSlotEmpty(r)?s:void 0}
@@ -1,6 +1,7 @@
1
1
  import { PubSub } from '@symbiotejs/symbiote';
2
2
  export { PubSub as Data, PubSub, UID } from '@symbiotejs/symbiote';
3
3
  import * as lit_html from 'lit-html';
4
+ import * as lit_html_directives_ref_js from 'lit-html/directives/ref.js';
4
5
  import { nothing, LitElement, PropertyValues, TemplateResult } from 'lit';
5
6
  import { TelemetryRequest } from '@uploadcare/quality-insights';
6
7
  import * as _uploadcare_upload_client from '@uploadcare/upload-client';
@@ -1359,7 +1360,7 @@ declare class LitBlock extends LitBlockBase {
1359
1360
  declare class Modal extends LitBlock {
1360
1361
  static styleAttrs: string[];
1361
1362
  private _mouseDownTarget;
1362
- private dialogEl;
1363
+ protected dialogEl: lit_html_directives_ref_js.Ref<HTMLDialogElement>;
1363
1364
  handleModalOpen: ModalCb;
1364
1365
  handleModalClose: ModalCb;
1365
1366
  handleModalCloseAll: ModalCb;