@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 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}
package/web/uc-img.min.js CHANGED
@@ -23,6 +23,6 @@
23
23
  * SOFTWARE.
24
24
  *
25
25
  */
26
- var z=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var T=(r,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of F(s))!H.call(r,i)&&i!==t&&z(r,i,{get:()=>s[i],enumerable:!(e=N(s,i))||e.enumerable});return r},u=(r,s,t)=>(T(r,s,"default"),t&&T(t,s,"default"));var W=r=>{if(typeof r!="string"||!r)return"";let s=r.trim();return s.startsWith("-/")?s=s.slice(2):s.startsWith("/")&&(s=s.slice(1)),s.endsWith("/")&&(s=s.slice(0,s.length-1)),s},Q=(...r)=>r.filter(s=>typeof s=="string"&&!!s).map(s=>W(s)).join("/-/"),$=(...r)=>{let s=Q(...r);return s?`-/${s}/`:""};function S(r){let s=new URL(r),t=s.pathname+s.search+s.hash,e=t.lastIndexOf("http"),i=t.lastIndexOf("/"),n="";return e>=0?n=t.slice(e):i>=0&&(n=t.slice(i+1)),n}function G(r){let s=new URL(r),t=S(r),e=O(t)?U(t).pathname:t;return s.pathname=s.pathname.replace(e,""),s.search="",s.hash="",s.toString()}function O(r){return r.startsWith("http")}function U(r){let s=new URL(r);return{pathname:`${s.origin}${s.pathname??""}`,search:s.search??"",hash:s.hash??""}}var d=(r,s,t)=>{let e=new URL(G(r)),i=t??S(r),n=s??"";if(e.pathname.startsWith("//")&&(e.pathname=e.pathname.replace("//","/")),i&&O(i)){let a=U(i);e.pathname=`${e.pathname}${n}${a.pathname||""}`,e.search=a.search,e.hash=a.hash}else e.pathname=`${e.pathname}${n}${i||""}`;return e.toString()},_=(r,s)=>{let t=new URL(r);return t.pathname=`${s}/`,t.toString()};var j=(r,s=",")=>r.trim().split(s).map(t=>t.trim()).filter(t=>t.length>0);var q=r=>r;function L(r,s={},t={}){let{openToken:e="{{",closeToken:i="}}",transform:n=q}=t;for(let a in s){let l=s[a],c=l?.toString(),m=typeof c=="string"?n(c):String(c);r=r.replaceAll(e+a+i,m)}return r}var k=r=>[...new Set(r)];var p="--uc-img-",E="unresolved";var w=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),x=3e3,C=5e3,P=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var o={};u(o,ut);u(o,pt);import"@lit/reactive-element";import"lit-html";import*as ut from"lit-element/lit-element.js";import*as pt from"lit-html/is-server.js";var M="1.25.0-alpha.0";var R="blocks",A=M;var X=/\\([0-9a-fA-F]{1,6} ?)/g;function Y(r){return r.length<2?!1:(r[0]==='"'||r[0]==="'")&&(r[r.length-1]==='"'||r[r.length-1]==="'")}function Z(r){let s=r;return(s[0]==='"'||s[0]==="'")&&(s=s.slice(1)),(s[s.length-1]==='"'||s[s.length-1]==="'")&&(s=s.slice(0,-1)),s}function tt(r){let s="",t="";for(let e=0;e<r.length;e++){let i=r[e+1];r[e]==="\\"&&i==='"'?(s+='\\"',e++):r[e]==='"'&&t!=="\\"?s+='\\"':s+=r[e],t=r[e]??""}return s}function D(r){let s=r;Y(r)&&(s=Z(s),s=s.replace(X,(t,e)=>String.fromCodePoint(parseInt(e.trim(),16))),s=s.replaceAll(`\\
26
+ var z=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var T=(r,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of F(s))!H.call(r,i)&&i!==t&&z(r,i,{get:()=>s[i],enumerable:!(e=N(s,i))||e.enumerable});return r},u=(r,s,t)=>(T(r,s,"default"),t&&T(t,s,"default"));var W=r=>{if(typeof r!="string"||!r)return"";let s=r.trim();return s.startsWith("-/")?s=s.slice(2):s.startsWith("/")&&(s=s.slice(1)),s.endsWith("/")&&(s=s.slice(0,s.length-1)),s},Q=(...r)=>r.filter(s=>typeof s=="string"&&!!s).map(s=>W(s)).join("/-/"),$=(...r)=>{let s=Q(...r);return s?`-/${s}/`:""};function S(r){let s=new URL(r),t=s.pathname+s.search+s.hash,e=t.lastIndexOf("http"),i=t.lastIndexOf("/"),n="";return e>=0?n=t.slice(e):i>=0&&(n=t.slice(i+1)),n}function G(r){let s=new URL(r),t=S(r),e=O(t)?U(t).pathname:t;return s.pathname=s.pathname.replace(e,""),s.search="",s.hash="",s.toString()}function O(r){return r.startsWith("http")}function U(r){let s=new URL(r);return{pathname:`${s.origin}${s.pathname??""}`,search:s.search??"",hash:s.hash??""}}var d=(r,s,t)=>{let e=new URL(G(r)),i=t??S(r),n=s??"";if(e.pathname.startsWith("//")&&(e.pathname=e.pathname.replace("//","/")),i&&O(i)){let a=U(i);e.pathname=`${e.pathname}${n}${a.pathname||""}`,e.search=a.search,e.hash=a.hash}else e.pathname=`${e.pathname}${n}${i||""}`;return e.toString()},_=(r,s)=>{let t=new URL(r);return t.pathname=`${s}/`,t.toString()};var j=(r,s=",")=>r.trim().split(s).map(t=>t.trim()).filter(t=>t.length>0);var q=r=>r;function L(r,s={},t={}){let{openToken:e="{{",closeToken:i="}}",transform:n=q}=t;for(let a in s){let l=s[a],c=l?.toString(),m=typeof c=="string"?n(c):String(c);r=r.replaceAll(e+a+i,m)}return r}var k=r=>[...new Set(r)];var p="--uc-img-",E="unresolved";var w=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),x=3e3,C=5e3,P=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var o={};u(o,ut);u(o,pt);import"@lit/reactive-element";import"lit-html";import*as ut from"lit-element/lit-element.js";import*as pt from"lit-html/is-server.js";var M="1.25.0-alpha.1";var R="blocks",A=M;var X=/\\([0-9a-fA-F]{1,6} ?)/g;function Y(r){return r.length<2?!1:(r[0]==='"'||r[0]==="'")&&(r[r.length-1]==='"'||r[r.length-1]==="'")}function Z(r){let s=r;return(s[0]==='"'||s[0]==="'")&&(s=s.slice(1)),(s[s.length-1]==='"'||s[s.length-1]==="'")&&(s=s.slice(0,-1)),s}function tt(r){let s="",t="";for(let e=0;e<r.length;e++){let i=r[e+1];r[e]==="\\"&&i==='"'?(s+='\\"',e++):r[e]==='"'&&t!=="\\"?s+='\\"':s+=r[e],t=r[e]??""}return s}function D(r){let s=r;Y(r)&&(s=Z(s),s=s.replace(X,(t,e)=>String.fromCodePoint(parseInt(e.trim(),16))),s=s.replaceAll(`\\
27
27
  `,"\\n"),s=tt(s),s='"'+s+'"');try{return JSON.parse(s)}catch{return}}function B(r){class s extends r{constructor(){super(...arguments);this.cssDataCache=null;this.computedStyle=null}getCssData(i,n=!1){let a=this.cssDataCache??Object.create(null);if(!Object.keys(a).includes(i)||!a[i]){this.computedStyle||(this.computedStyle=window.getComputedStyle(this));let l=this.computedStyle.getPropertyValue(i).trim();try{a[i]=D(l)}catch(c){n||console.warn(`CSS Data error: ${i}`,c),a[i]=null}}return this.cssDataCache=a,a[i]}}return s}function K(r){class s extends r{static reg(e){let i=this,n=window.customElements.get(e);if(n){n!==i&&console.warn([`Element with tag name "${e}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
28
28
  `));return}window.customElements.define(e,i)}}return s}var et="https://ucarecdn.com",g=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:et},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var h=class extends B(K(o.LitElement)){constructor(){super();this._state={};this._subscribers=new Map;this._isnObserver=null;this._observed=null;for(let t in g){let e=g[t];this._state[p+t]=e?.default||""}}createRenderRoot(){return this}$$(t){return this._state[p+t]}set$$(t){for(let e in t){let i=p+e,n=t[e];this._state[i]=n,this._notify(i,n)}}sub$$(t,e){let i=p+t;this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i).add(e);let n=this._state[i];n!==null&&n!==""&&e(n)}_notify(t,e){this._subscribers.has(t)&&this._subscribers.get(t).forEach(i=>{e===null||e===""||i(e)})}analyticsParams(){return`-/@clib/${R}/${A}/uc-img/`}initAttributes(t){Array.from(this.attributes).forEach(e=>{let i=e;g[i.name]||t.setAttribute(i.name,i.value)})}initIntersection(t,e){let i={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(n=>{n.forEach(a=>{a.isIntersecting&&(e(),this._isnObserver.unobserve(t))})},i),this._isnObserver.observe(t),this._observed||(this._observed=new Set),this._observed.add(t)}connectedCallback(){super.connectedCallback(),this._initCssProperties()}_initCssProperties(){for(let t in g){let e=p+t,i=this.getCssData(e,!0);i!=null&&(this._state[e]=i)}}disconnectedCallback(){super.disconnectedCallback(),this._isnObserver&&(this._observed?.forEach(t=>{this._isnObserver?.unobserve(t)}),this._isnObserver=null),this._subscribers.clear()}static get observedAttributes(){return Object.keys(g)}attributeChangedCallback(t,e,i){window.setTimeout(()=>{let n=p+t;this._state[n]=i,this._notify(n,i)})}};var V=r=>Object.entries(r).filter(([s,t])=>t!==void 0&&t!=="").map(([s,t])=>s==="cdn-operations"||s==="analytics"?t:`${s}/${t}`);var y=class extends h{constructor(){super(...arguments);this._img=new Image;this._imgPreview=new Image}_fmtAbs(t){return!t.includes("//")&&!w&&(t=new URL(t,document.baseURI).href),t}_validateSize(t){if(t?.trim()!==""){let e=t,i=e.match(/\d+/)[0],n=e.match(/[a-zA-Z]+/)[0],a=parseInt(i,10);if(Number(a)>C&&this.hasFormatJPG)return C+n;if(Number(a)>x&&!this.hasFormatJPG)return x+n}return t}_getCdnModifiers(t,e){let i={format:this._getTypedCssValue("format"),quality:this._getTypedCssValue("quality"),resize:this._validateSize(t),blur:e,"cdn-operations":this._getTypedCssValue("cdn-operations")??void 0,analytics:this.analyticsParams()};return $(...V(i))}_getTypedCssValue(t){let e=this.$$(t);if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e}_getUrlBase(t="",e=""){let i=this.$$("src");if(i.startsWith("data:")||i.startsWith("blob:"))return i;if(w&&i&&!i.includes("//"))return this._proxyUrl(i);let n=this._getCdnModifiers(t,e),a=this.$$("cdn-cname"),l=a;if(i.startsWith(String(a)))return d(i,n);let c=this.$$("uuid");if(l&&c)return this._proxyUrl(d(_(l,c),n));if(c)return this._proxyUrl(d(_(l,c),n));let m=this.$$("proxy-cname");if(m)return this._proxyUrl(d(m,n,this._fmtAbs(i)));let I=this.$$("pubkey");if(I)return this._proxyUrl(d(`https://${I}.ucr.io/`,n,this._fmtAbs(i)))}_proxyUrl(t){let e=this.$$("secure-delivery-proxy");return e?L(e,{previewUrl:t},{transform:i=>window.encodeURIComponent(i)}):t}_getElSize(t,e=1,i=!0){let n=t.getBoundingClientRect(),a=e*Math.round(n.width),l=i?"":e*Math.round(n.height);return a||l?`${a||""}x${l||""}`:null}_setupEventProxy(t){let e=n=>{n.stopPropagation();let a=new Event(n.type,n);this.dispatchEvent(a)},i=["load","error"];for(let n of i)t.addEventListener(n,e)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:P.PREVIEW,img:this._imgPreview}:{type:P.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){let t=this.$$("breakpoints");if(t){let e=j(t);return k(e.map(i=>parseInt(i,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(t){let e=new Set;e.add(`url("${this._getUrlBase(this._getElSize(t))}") 1x`),this.$$("hi-res-support")&&e.add(`url("${this._getUrlBase(this._getElSize(t,2))}") ${2}x`),this.$$("ultra-res-support")&&e.add(`url("${this._getUrlBase(this._getElSize(t,3))}") ${3}x`);let i=`image-set(${[...e].join(", ")})`;t.style.setProperty("background-image",i),t.style.setProperty("background-image","-webkit-"+i)}getSrcset(){let t=new Set;return this.breakpoints?this.breakpoints.forEach(e=>{t.add(`${this._getUrlBase(`${e}x`)} ${this._validateSize(`${e}w`)}`),this.$$("hi-res-support")&&t.add(`${this._getUrlBase(`${e*2}x`)} ${this._validateSize(`${e*2}w`)}`),this.$$("ultra-res-support")&&t.add(`${this._getUrlBase(`${e*3}x`)} ${this._validateSize(`${e*3}w`)}`)}):(t.add(`${this._getUrlBase(this._getElSize(this.currentImg.img))} 1x`),this.$$("hi-res-support")&&t.add(`${this._getUrlBase(this._getElSize(this.currentImg.img,2))} 2x`),this.$$("ultra-res-support")&&t.add(`${this._getUrlBase(this._getElSize(this.currentImg.img,3))} 3x`)),[...t].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){let t=this.bgSelector;[...document.querySelectorAll(t)].forEach(e=>{this.$$("intersection")?this.initIntersection(e,()=>{this.renderBg(e)}):this.renderBg(e)})}_appendURL({elNode:t,src:e,srcset:i}){e&&(t.src=e),i&&(t.srcset=i)}_setupConfigForImage({elNode:t}){this._setupEventProxy(t),this.initAttributes(t)}loaderImage({src:t,srcset:e,elNode:i}){return new Promise((n,a)=>{this._setupConfigForImage({elNode:i}),i.setAttribute(E,""),i.addEventListener("load",()=>{i.removeAttribute(E),n(i)}),i.addEventListener("error",()=>{a(!1)}),this._appendURL({elNode:i,src:t,srcset:e})})}async renderImage(){if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var v=class extends y{connectedCallback(){super.connectedCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",s=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=s?"lazy":"eager")})}};v.reg("uc-img");export{v as Img};