@uploadcare/react-uploader 0.3.0 → 0.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-uploader.cjs +239 -463
- package/dist/react-uploader.d.ts +6 -2
- package/dist/react-uploader.js +178 -9295
- package/dist/style.css +3 -0
- package/package.json +8 -7
- package/LICENSE +0 -21
package/dist/react-uploader.cjs
CHANGED
|
@@ -1,463 +1,239 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
`));return}window.customElements.define(s,i?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(s){this.observedAttributes=Object.keys(s),this.__attrDesc=s}attributeChangedCallback(s,i,e){var t;if(i===e)return;let r=(t=this.constructor.__attrDesc)==null?void 0:t[s];r?this.__dataCtxInitialized?this.$[r]=e:this.init$[r]=e:this[s]=e}getCssData(s,i=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(s)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(s).trim();try{this.__cssDataCache[s]=xr(e)}catch{!i&&console.warn(`CSS Data error: ${s}`),this.__cssDataCache[s]=null}}return this.__cssDataCache[s]}__extractCssName(s){return s.split("--").map((i,e)=>e===0?"":i).join("--")}__initStyleAttrObserver(){se||(se=new Set),se.add(this.updateCssData),$e||($e=new MutationObserver(s=>{s[0].type==="attributes"&&se.forEach(i=>{i()})}),$e.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(s,i=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(s);let e=this.getCssData(this.__extractCssName(s),!0);e===null&&(e=i),this.add(s,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(s,i,e){let t="__"+s;this[t]=this[s],Object.defineProperty(this,s,{set:r=>{this[t]=r,e?window.setTimeout(()=>{i==null||i(r)}):i==null||i(r)},get:()=>this[t]}),this[s]=this[t]}static set shadowStyles(s){let i=new Blob([s],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(i)}static set rootStyles(s){if(!this.__rootStylesLink){let i=new Blob([s],{type:"text/css"}),e=URL.createObjectURL(i),t=document.createElement("link");t.href=e,t.rel="stylesheet",this.__rootStylesLink=t}}},ht=he;Nt(ht,"template");function Gi(s,i){for(let e in i)e.includes("-")?s.style.setProperty(e,i[e]):s.style[e]=i[e]}function Ir(s,i){for(let e in i)i[e].constructor===Boolean?i[e]?s.setAttribute(e,""):s.removeAttribute(e):s.setAttribute(e,i[e])}function Dt(s={tag:"div"}){let i=document.createElement(s.tag);if(s.attributes&&Ir(i,s.attributes),s.styles&&Gi(i,s.styles),s.properties)for(let e in s.properties)i[e]=s.properties[e];return s.processors&&s.processors.forEach(e=>{e(i)}),s.children&&s.children.forEach(e=>{let t=Dt(e);i.appendChild(t)}),i}var Xi="idb-store-ready",kr="symbiote-db",Or="symbiote-idb-update_",Pr=class{_notifyWhenReady(s=null){window.dispatchEvent(new CustomEvent(Xi,{detail:{dbName:this.name,storeName:this.storeName,event:s}}))}get _updEventName(){return Or+this.name}_getUpdateEvent(s){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:s}})}_notifySubscribers(s){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,s),window.dispatchEvent(this._getUpdateEvent(s))}constructor(s,i){this.name=s,this.storeName=i,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=e=>{this.db=e.target.result,this.objStore=this.db.createObjectStore(i,{keyPath:"_key"}),this.objStore.transaction.oncomplete=t=>{this._notifyWhenReady(t)}},this.request.onsuccess=e=>{this.db=e.target.result,this._notifyWhenReady(e)},this.request.onerror=e=>{console.error(e)},this._subscriptionsMap={},this._updateHandler=e=>{e.key===this.name&&this._subscriptionsMap[e.newValue]&&this._subscriptionsMap[e.newValue].forEach(async r=>{r(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(s){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(s);return new Promise((t,r)=>{e.onsuccess=n=>{var o;(o=n.target.result)!=null&&o._value?t(n.target.result._value):(t(null),console.warn(`IDB: cannot read "${s}"`))},e.onerror=n=>{r(n)}})}write(s,i,e=!1){let t={_key:s,_value:i},n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(t);return new Promise((o,l)=>{n.onsuccess=a=>{e||this._notifySubscribers(s),o(a.target.result)},n.onerror=a=>{l(a)}})}delete(s,i=!1){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(s);return new Promise((r,n)=>{t.onsuccess=o=>{i||this._notifySubscribers(s),r(o)},t.onerror=o=>{n(o)}})}getAll(){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,t)=>{i.onsuccess=r=>{let n=r.target.result;e(n.map(o=>o._value))},i.onerror=r=>{t(r)}})}subscribe(s,i){this._subscriptionsMap[s]||(this._subscriptionsMap[s]=new Set);let e=this._subscriptionsMap[s];return e.add(i),{remove:()=>{e.delete(i),e.size||delete this._subscriptionsMap[s]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,Ki.clear(this.name)}},Ki=class{static get readyEventName(){return Xi}static open(s=kr,i="store"){let e=s+"/"+i;return this._reg[e]||(this._reg[e]=new Pr(s,i)),this._reg[e]}static clear(s){window.indexedDB.deleteDatabase(s);for(let i in this._reg)i.split("/")[0]===s&&delete this._reg[i]}};Nt(Ki,"_reg",Object.create(null));const Lr=20,x=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created"});class Ur{constructor(i){u(this,"_timeoutStore",new Map);u(this,"_targets",new Set);u(this,"_debugPrint",null);this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){var t;for(const r of this._targets)r.dispatchEvent(new CustomEvent(i,{detail:e}));(t=this._debugPrint)==null||t.call(this,()=>{const r=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,r]})}emit(i,e,{debounce:t}={}){if(typeof t!="number"&&!t){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));const r=typeof t=="number"?t:Lr,n=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},r);this._timeoutStore.set(i,n)}}function H(s,i){let e;const t=(...r)=>{clearTimeout(e),e=setTimeout(()=>s(...r),i)};return t.cancel=()=>{clearTimeout(e)},t}const bi="--uploadcare-blocks-window-height";class rt{static registerClient(i){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(i)}static unregisterClient(i){this.clientsRegistry.delete(i),this.clientsRegistry.size===0&&this.detachTracker()}static attachTracker(){window.addEventListener("resize",this.flush,{passive:!0,capture:!0}),this.flush()}static detachTracker(){window.removeEventListener("resize",this.flush,{capture:!0}),document.documentElement.style.removeProperty(bi)}}u(rt,"clientsRegistry",new Set),u(rt,"flush",H(()=>{document.documentElement.style.setProperty(bi,`${window.innerHeight}px`)},100));const Yi=(s,i)=>new Intl.PluralRules(s).select(i),Rr=s=>s,kt="{{",Ji="}}",_i="plural:";function Ot(s,i,e={}){var o;let{openToken:t=kt,closeToken:r=Ji,transform:n=Rr}=e;for(let l in i){let a=(o=i[l])==null?void 0:o.toString();s=s.replaceAll(t+l+r,typeof a=="string"?n(a):a)}return s}function Mr(s){const i=[];let e=s.indexOf(kt);for(;e!==-1;){const t=s.indexOf(Ji,e),r=s.substring(e+2,t);if(r.startsWith(_i)){const n=s.substring(e+2,t).replace(_i,""),o=n.substring(0,n.indexOf("(")),l=n.substring(n.indexOf("(")+1,n.indexOf(")"));i.push({variable:r,pluralKey:o,countVariable:l})}e=s.indexOf(kt,t)}return i}const Ce=s=>{var i;return(i=s.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:i.map(e=>e.toLowerCase()).join("-")},Zi=({element:s,attribute:i,onSuccess:e,onTimeout:t,timeout:r=300})=>{const n=s.getAttribute(i);if(n!==null){e(n);return}const o=new MutationObserver(c=>{const h=c[c.length-1];a(h)});o.observe(s,{attributes:!0,attributeFilter:[i]});const l=setTimeout(()=>{o.disconnect(),t()},r),a=c=>{const h=s.getAttribute(i);c.type==="attributes"&&c.attributeName===i&&h!==null&&(clearTimeout(l),o.disconnect(),e(h))}},yi=new Set;function nt(s){yi.has(s)||(yi.add(s),console.warn(s))}function vi(s){return Object.prototype.toString.call(s)==="[object Object]"}const Fr=/\W|_/g;function Nr(s){return s.split(Fr).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}function Ci(s,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(s)?s.map(e=>ce(e,{ignoreKeys:i})):s}function ce(s,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(s))return Ci(s,{ignoreKeys:i});if(!vi(s))return s;const e={};for(const t of Object.keys(s)){let r=s[t];if(i.includes(t)){e[t]=r;continue}vi(r)?r=ce(r,{ignoreKeys:i}):Array.isArray(r)&&(r=Ci(r,{ignoreKeys:i})),e[Nr(t)]=r}return e}const Dr=s=>new Promise(i=>setTimeout(i,s));function Qi({libraryName:s,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){const n="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:s,libraryVersion:i,languageName:n,integration:r});const o=[s,i,t].filter(Boolean).join("/"),l=[n,r].filter(Boolean).join("; ");return`${o} (${l})`}const zr={factor:2,time:100};function Vr(s,i=zr){let e=0;function t(r){const n=Math.round(i.time*i.factor**e);return r({attempt:e,retry:l=>Dr(l??n).then(()=>(e+=1,t(r)))})}return t(s)}class zt extends Error{}class Ge extends zt{constructor(e){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,Ge.prototype),this.originalProgressEvent=e}}const ut=(s,i)=>{s&&(s.aborted?Promise.resolve().then(i):s.addEventListener("abort",()=>i(),{once:!0}))};class Ee extends zt{constructor(e="Request canceled"){super(e);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,Ee.prototype)}}const Br=500,es=({check:s,interval:i=Br,timeout:e,signal:t})=>new Promise((r,n)=>{let o,l;ut(t,()=>{o&&clearTimeout(o),n(new Ee("Poll cancelled"))}),e&&(l=setTimeout(()=>{o&&clearTimeout(o),n(new Ee("Timed out"))},e));const a=()=>{try{Promise.resolve(s(t)).then(c=>{c?(l&&clearTimeout(l),r(c)):o=setTimeout(a,i)}).catch(c=>{l&&clearTimeout(l),n(c)})}catch(c){l&&clearTimeout(l),n(c)}};o=setTimeout(a,0)}),E={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"},dt="application/octet-stream",ts="original",me=({method:s,url:i,data:e,headers:t={},signal:r,onProgress:n})=>new Promise((o,l)=>{const a=new XMLHttpRequest,c=(s==null?void 0:s.toUpperCase())||"GET";let h=!1;a.open(c,i,!0),t&&Object.entries(t).forEach(d=>{const[f,m]=d;typeof m<"u"&&!Array.isArray(m)&&a.setRequestHeader(f,m)}),a.responseType="text",ut(r,()=>{h=!0,a.abort(),l(new Ee)}),a.onload=()=>{if(a.status!=200)l(new Error(`Error ${a.status}: ${a.statusText}`));else{const d={method:c,url:i,data:e,headers:t||void 0,signal:r,onProgress:n},f=a.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};f.forEach(function(A){const w=A.split(": "),C=w.shift(),y=w.join(": ");C&&typeof C<"u"&&(m[C]=y)});const p=a.response,g=a.status;o({request:d,data:p,headers:m,status:g})}},a.onerror=d=>{h||l(new Ge(d))},n&&typeof n=="function"&&(a.upload.onprogress=d=>{d.lengthComputable?n({isComputable:!0,value:d.loaded/d.total}):n({isComputable:!1})}),e?a.send(e):a.send()});function jr(s,...i){return s}const Hr=({name:s})=>s?[s]:[],Wr=jr;var qr=()=>new FormData;const is=s=>!1,ft=s=>typeof Blob<"u"&&s instanceof Blob,pt=s=>typeof File<"u"&&s instanceof File,mt=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&"uri"in s&&typeof s.uri=="string",Re=s=>ft(s)||pt(s)||is()||mt(s),Gr=s=>typeof s=="string"||typeof s=="number"||typeof s>"u",Xr=s=>!!s&&typeof s=="object"&&!Array.isArray(s),Kr=s=>!!s&&typeof s=="object"&&"data"in s&&Re(s.data);function ss(s,i,e){if(Array.isArray(e))for(const t of e)ss(s,`${i}[]`,t);else if(Kr(e)){const{name:t,contentType:r}=e,n=Wr(e.data,t,r??dt),o=Hr({name:t,contentType:r});s.push([i,n,...o])}else if(Xr(e))for(const[t,r]of Object.entries(e))typeof r<"u"&&s.push([`${i}[${t}]`,String(r)]);else Gr(e)&&e&&s.push([i,e.toString()])}function Yr(s){const i=[];for(const[e,t]of Object.entries(s))ss(i,e,t);return i}function gt(s){const i=qr(),e=Yr(s);for(const t of e){const[r,n,...o]=t;i.append(r,n,...o)}return i}class D extends zt{constructor(e,t,r,n,o){super();u(this,"code");u(this,"request");u(this,"response");u(this,"headers");this.name="UploadError",this.message=e,this.code=t,this.request=r,this.response=n,this.headers=o,Object.setPrototypeOf(this,D.prototype)}}const Jr=s=>{const i=new URLSearchParams;for(const[e,t]of Object.entries(s))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()},oe=(s,i,e)=>{const t=new URL(s);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=Jr(e)),t.toString()};var Zr="6.14.1";const Qr="UploadcareUploadClient",en=Zr;function Te(s){return Qi({libraryName:Qr,libraryVersion:en,...s})}const tn="RequestThrottledError",wi=15e3,sn=1e3;function rn(s){const{headers:i}=s||{};if(!i||typeof i["retry-after"]!="string")return wi;const e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:wi}function ge(s,i){const{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return Vr(({attempt:r,retry:n})=>s().catch(o=>{if("response"in o&&(o==null?void 0:o.code)===tn&&r<e)return n(rn(o));if(o instanceof Ge&&r<t)return n((r+1)*sn);throw o}))}const rs=s=>{let i="";return(ft(s)||pt(s)||mt(s))&&(i=s.type),i||dt},ns=s=>{let i="";return pt(s)&&s.name?i=s.name:ft(s)||is()?i="":mt(s)&&s.name&&(i=s.name),i||ts};function Vt(s){return typeof s>"u"||s==="auto"?"auto":s?"1":"0"}function nn(s,{publicKey:i,fileName:e,contentType:t,baseURL:r=E.baseURL,secureSignature:n,secureExpire:o,store:l,signal:a,onProgress:c,source:h="local",integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=E.retryNetworkErrorMaxTimes,metadata:g}){return ge(()=>me({method:"POST",url:oe(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Te({publicKey:i,integration:d,userAgent:f})},data:gt({file:{data:s,name:e||ns(s),contentType:t||rs(s)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:Vt(l),signature:n,expire:o,source:h,metadata:g}),signal:a,onProgress:c}).then(({data:A,headers:w,request:C})=>{const y=ce(JSON.parse(A));if("error"in y)throw new D(y.error.content,y.error.errorCode,C,y,w);return y}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:m})}var Pt;(function(s){s.Token="token",s.FileInfo="file_info"})(Pt||(Pt={}));function on(s,{publicKey:i,baseURL:e=E.baseURL,store:t,fileName:r,checkForUrlDuplicates:n,saveUrlForRecurrentUploads:o,secureSignature:l,secureExpire:a,source:c="url",signal:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=E.retryNetworkErrorMaxTimes,metadata:g}){return ge(()=>me({method:"POST",headers:{"X-UC-User-Agent":Te({publicKey:i,integration:d,userAgent:f})},url:oe(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:s,store:Vt(t),filename:r,check_URL_duplicates:n?1:void 0,save_URL_duplicates:o?1:void 0,signature:l,expire:a,source:c,metadata:g}),signal:h}).then(({data:A,headers:w,request:C})=>{const y=ce(JSON.parse(A));if("error"in y)throw new D(y.error.content,y.error.errorCode,C,y,w);return y}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:m})}var N;(function(s){s.Unknown="unknown",s.Waiting="waiting",s.Progress="progress",s.Error="error",s.Success="success"})(N||(N={}));const ln=s=>"status"in s&&s.status===N.Error;function an(s,{publicKey:i,baseURL:e=E.baseURL,signal:t,integration:r,userAgent:n,retryThrottledRequestMaxTimes:o=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=E.retryNetworkErrorMaxTimes}={}){return ge(()=>me({method:"GET",headers:i?{"X-UC-User-Agent":Te({publicKey:i,integration:r,userAgent:n})}:void 0,url:oe(e,"/from_url/status/",{jsonerrors:1,token:s}),signal:t}).then(({data:a,headers:c,request:h})=>{const d=ce(JSON.parse(a));if("error"in d&&!ln(d))throw new D(d.error.content,d.error.errorCode,h,d,c);return d}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:o})}function cn(s,{publicKey:i,baseURL:e=E.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:n,signal:o,source:l,integration:a,userAgent:c,retryThrottledRequestMaxTimes:h=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:d=E.retryNetworkErrorMaxTimes}){return ge(()=>me({method:"POST",headers:{"X-UC-User-Agent":Te({publicKey:i,integration:a,userAgent:c})},url:oe(e,"/group/",{jsonerrors:1}),data:gt({files:s,callback:t,pub_key:i,signature:r,expire:n,source:l}),signal:o}).then(({data:f,headers:m,request:p})=>{const g=ce(JSON.parse(f));if("error"in g)throw new D(g.error.content,g.error.errorCode,p,g,m);return g}),{retryNetworkErrorMaxTimes:d,retryThrottledRequestMaxTimes:h})}function os(s,{publicKey:i,baseURL:e=E.baseURL,signal:t,source:r,integration:n,userAgent:o,retryThrottledRequestMaxTimes:l=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=E.retryNetworkErrorMaxTimes}){return ge(()=>me({method:"GET",headers:{"X-UC-User-Agent":Te({publicKey:i,integration:n,userAgent:o})},url:oe(e,"/info/",{jsonerrors:1,pub_key:i,file_id:s,source:r}),signal:t}).then(({data:c,headers:h,request:d})=>{const f=ce(JSON.parse(c));if("error"in f)throw new D(f.error.content,f.error.errorCode,d,f,h);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function hn(s,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=E.multipartChunkSize,baseURL:n="",secureSignature:o,secureExpire:l,store:a,signal:c,source:h="local",integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=E.retryNetworkErrorMaxTimes,metadata:g}){return ge(()=>me({method:"POST",url:oe(n,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Te({publicKey:i,integration:d,userAgent:f})},data:gt({filename:t||ts,size:s,content_type:e||dt,part_size:r,UPLOADCARE_STORE:Vt(a),UPLOADCARE_PUB_KEY:i,signature:o,expire:l,source:h,metadata:g}),signal:c}).then(({data:A,headers:w,request:C})=>{const y=ce(JSON.parse(A));if("error"in y)throw new D(y.error.content,y.error.errorCode,C,y,w);return y.parts=Object.keys(y.parts).map(U=>y.parts[Number(U)]),y}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p})}function un(s,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:n=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:o=E.retryNetworkErrorMaxTimes}){return ge(()=>me({method:"PUT",url:i,data:s,onProgress:r,signal:t,headers:{"Content-Type":e||dt}}).then(l=>(r&&r({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:o})}function dn(s,{publicKey:i,baseURL:e=E.baseURL,source:t="local",signal:r,integration:n,userAgent:o,retryThrottledRequestMaxTimes:l=E.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=E.retryNetworkErrorMaxTimes}){return ge(()=>me({method:"POST",url:oe(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Te({publicKey:i,integration:n,userAgent:o})},data:gt({uuid:s,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:c,headers:h,request:d})=>{const f=ce(JSON.parse(c));if("error"in f)throw new D(f.error.content,f.error.errorCode,d,f,h);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Bt(s,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:n,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:l,signal:a,onProgress:c}){return es({check:h=>os(s,{publicKey:i,baseURL:e,signal:h,source:t,integration:r,userAgent:n,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:l}).then(d=>d.isReady?d:(c&&c({isComputable:!0,value:1}),!1)),signal:a})}function fn(s){return"defaultEffects"in s}class Me{constructor(i,{baseCDN:e=E.baseCDN,fileName:t}={}){u(this,"uuid");u(this,"name",null);u(this,"size",null);u(this,"isStored",null);u(this,"isImage",null);u(this,"mimeType",null);u(this,"cdnUrl",null);u(this,"s3Url",null);u(this,"originalFilename",null);u(this,"imageInfo",null);u(this,"videoInfo",null);u(this,"contentInfo",null);u(this,"metadata",null);u(this,"s3Bucket",null);u(this,"defaultEffects",null);const{uuid:r,s3Bucket:n}=i,o=oe(e,`${r}/`),l=n?oe(`https://${n}.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=o,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=n||null,this.s3Url=l,fn(i)&&(this.defaultEffects=i.defaultEffects)}}const pn=(s,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:n,store:o,contentType:l,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,baseCDN:g,metadata:A})=>nn(s,{publicKey:i,fileName:e,contentType:l,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,metadata:A}).then(({file:w})=>Bt(w,{publicKey:i,baseURL:t,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,onProgress:c,signal:a})).then(w=>new Me(w,{baseCDN:g})),mn=(s,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:n,source:o,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h,baseCDN:d})=>os(s,{publicKey:i,baseURL:t,signal:r,source:o,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h}).then(f=>new Me(f,{baseCDN:d,fileName:e})).then(f=>(n&&n({isComputable:!0,value:1}),f)),gn=(s,{signal:i}={})=>{let e=null,t=null;const r=s.map(()=>new AbortController),n=o=>()=>{t=o,r.forEach((l,a)=>a!==o&&l.abort())};return ut(i,()=>{r.forEach(o=>o.abort())}),Promise.all(s.map((o,l)=>{const a=n(l);return Promise.resolve().then(()=>o({stopRace:a,signal:r[l].signal})).then(c=>(a(),c)).catch(c=>(e=c,null))})).then(o=>{if(t===null)throw e;return o[t]})};var bn=window.WebSocket;class _n{constructor(){u(this,"events",Object.create({}))}emit(i,e){var t;(t=this.events[i])==null||t.forEach(r=>r(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]=[]}}const yn=(s,i)=>s==="success"?{status:N.Success,...i}:s==="progress"?{status:N.Progress,...i}:{status:N.Error,...i};class vn{constructor(i,e=3e4){u(this,"key");u(this,"disconnectTime");u(this,"ws");u(this,"queue",[]);u(this,"isConnected",!1);u(this,"subscribers",0);u(this,"emmitter",new _n);u(this,"disconnectTimeoutId",null);this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){const i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new bn(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=>{const 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,yn(t.event,JSON.parse(t.data)))}})}}disconnect(){const i=()=>{var e;(e=this.ws)==null||e.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){var r;const t=JSON.stringify({event:i,data:e});(r=this.ws)==null||r.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();const 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;const 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)}}let Et=null;const jt=s=>{if(!Et){const i=typeof window>"u"?0:3e4;Et=new vn(s,i)}return Et},Cn=s=>{jt(s).connect()};function wn({token:s,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:o,onProgress:l,signal:a}){return es({check:c=>an(s,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:o,signal:c}).then(h=>{switch(h.status){case N.Error:return new D(h.error,h.errorCode);case N.Waiting:return!1;case N.Unknown:return new D(`Token "${s}" was not found.`);case N.Progress:return l&&(h.total==="unknown"?l({isComputable:!1}):l({isComputable:!0,value:h.done/h.total})),!1;case N.Success:return l&&l({isComputable:!0,value:h.done/h.total}),h;default:throw new Error("Unknown status")}}),signal:a})}const En=({token:s,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,n)=>{const o=jt(i),l=o.onError(n),a=()=>{l(),o.unsubscribe(s)};ut(e,()=>{a(),n(new Ee("pusher cancelled"))}),o.subscribe(s,c=>{switch(c.status){case N.Progress:{t&&(c.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:c.done/c.total}));break}case N.Success:{a(),t&&t({isComputable:!0,value:c.done/c.total}),r(c);break}case N.Error:a(),n(new D(c.msg,c.error_code))}})}),An=(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:n,saveUrlForRecurrentUploads:o,secureSignature:l,secureExpire:a,store:c,signal:h,onProgress:d,source:f,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,pusherKey:A=E.pusherKey,metadata:w})=>Promise.resolve(Cn(A)).then(()=>on(s,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:n,saveUrlForRecurrentUploads:o,secureSignature:l,secureExpire:a,store:c,signal:h,source:f,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,metadata:w})).catch(C=>{const y=jt(A);return y==null||y.disconnect(),Promise.reject(C)}).then(C=>C.type===Pt.FileInfo?C:gn([({signal:y})=>wn({token:C.token,publicKey:i,baseURL:t,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,onProgress:d,signal:y}),({signal:y})=>En({token:C.token,pusherKey:A,signal:y,onProgress:d})],{signal:h})).then(C=>{if(C instanceof D)throw C;return C}).then(C=>Bt(C.uuid,{publicKey:i,baseURL:t,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,onProgress:d,signal:h})).then(C=>new Me(C,{baseCDN:r})),At=new WeakMap,Tn=async s=>{if(At.has(s))return At.get(s);const i=await fetch(s.uri).then(e=>e.blob());return At.set(s,i),i},ls=async s=>{if(pt(s)||ft(s))return s.size;if(mt(s))return(await Tn(s)).size;throw new Error("Unknown file type. Cannot determine file size.")},$n=(s,i=E.multipartMinFileSize)=>s>=i,as=s=>{const 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!Re(s)&&e.test(s)},Ht=s=>{const i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!Re(s)&&e.test(s)},Sn=(s,i)=>new Promise((e,t)=>{const r=[];let n=!1,o=i.length;const l=[...i],a=()=>{const c=i.length-l.length,h=l.shift();h&&h().then(d=>{n||(r[c]=d,o-=1,o?a():e(r))}).catch(d=>{n=!0,t(d)})};for(let c=0;c<s;c++)a()}),xn=(s,i,e,t)=>{const r=t*i,n=Math.min(r+t,e);return s.slice(r,n)},In=async(s,i,e)=>t=>xn(s,t,i,e),kn=(s,i,{publicKey:e,contentType:t,onProgress:r,signal:n,integration:o,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})=>un(s,i,{publicKey:e,contentType:t,onProgress:r,signal:n,integration:o,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a}),On=async(s,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:n,secureExpire:o,store:l,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,contentType:g,multipartChunkSize:A=E.multipartChunkSize,maxConcurrentRequests:w=E.maxConcurrentRequests,baseCDN:C,metadata:y})=>{const U=t??await ls(s);let te;const _e=(O,R)=>{if(!c)return;te||(te=Array(O).fill(0));const W=K=>K.reduce((ie,wt)=>ie+wt,0);return K=>{K.isComputable&&(te[R]=K.value,c({isComputable:!0,value:W(te)/O}))}};return g||(g=rs(s)),hn(U,{publicKey:i,contentType:g,fileName:e||ns(s),baseURL:r,secureSignature:n,secureExpire:o,store:l,signal:a,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,metadata:y}).then(async({uuid:O,parts:R})=>{const W=await In(s,U,A);return Promise.all([O,Sn(w,R.map((K,ie)=>()=>kn(W(ie),K,{publicKey:i,contentType:g,onProgress:_e(R.length,ie),signal:a,integration:d,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p})))])}).then(([O])=>dn(O,{publicKey:i,baseURL:r,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p})).then(O=>O.isReady?O:Bt(O.uuid,{publicKey:i,baseURL:r,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,onProgress:c,signal:a})).then(O=>new Me(O,{baseCDN:C}))};async function cs(s,{publicKey:i,fileName:e,baseURL:t=E.baseURL,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:p,multipartMinFileSize:g,multipartChunkSize:A,maxConcurrentRequests:w,baseCDN:C=E.baseCDN,checkForUrlDuplicates:y,saveUrlForRecurrentUploads:U,pusherKey:te,metadata:_e}){if(Re(s)){const O=await ls(s);return $n(O,g)?On(s,{publicKey:i,contentType:p,multipartChunkSize:A,fileSize:O,fileName:e,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,maxConcurrentRequests:w,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:C,metadata:_e}):pn(s,{publicKey:i,fileName:e,contentType:p,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:C,metadata:_e})}if(Ht(s))return An(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:C,checkForUrlDuplicates:y,saveUrlForRecurrentUploads:U,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,pusherKey:te,metadata:_e});if(as(s))return mn(s,{publicKey:i,fileName:e,baseURL:t,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:C});throw new TypeError(`File uploading from "${s}" is not supported`)}class Pn{constructor(i,{baseCDN:e=E.baseCDN}={}){u(this,"uuid");u(this,"filesCount");u(this,"totalSize");u(this,"isStored");u(this,"isImage");u(this,"cdnUrl");u(this,"files");u(this,"createdAt");u(this,"storedAt",null);this.uuid=i.id,this.filesCount=i.filesCount;const t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,n)=>r+n.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 Me(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}}const Ln=s=>{for(const i of s)if(!Re(i))return!1;return!0},Un=s=>{for(const i of s)if(!as(i))return!1;return!0},Rn=s=>{for(const i of s)if(!Ht(i))return!1;return!0};function Mn(s,{publicKey:i,fileName:e,baseURL:t=E.baseURL,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:p,multipartChunkSize:g=E.multipartChunkSize,baseCDN:A=E.baseCDN,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:C,jsonpCallback:y}){if(!Ln(s)&&!Rn(s)&&!Un(s))throw new TypeError(`Group uploading from "${s}" is not supported`);let U,te=!0;const _e=s.length,O=(R,W)=>{if(!a)return;U||(U=Array(R).fill(0));const K=ie=>ie.reduce((wt,ar)=>wt+ar)/R;return ie=>{if(!ie.isComputable||!te){te=!1,a({isComputable:!1});return}U[W]=ie.value,a({isComputable:!0,value:K(U)})}};return Promise.all(s.map((R,W)=>Re(R)||Ht(R)?cs(R,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:O(_e,W),source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:p,multipartChunkSize:g,baseCDN:A,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:C}).then(K=>K.uuid):R)).then(R=>cn(R,{publicKey:i,baseURL:t,jsonpCallback:y,secureSignature:r,secureExpire:n,signal:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m}).then(W=>new Pn(W,{baseCDN:A})).then(W=>(a&&a({isComputable:!0,value:1}),W)))}class Fn{constructor(i){u(this,"_concurrency",1);u(this,"_pending",[]);u(this,"_running",0);u(this,"_resolvers",new Map);u(this,"_rejectors",new Map);this._concurrency=i}_run(){const i=this._concurrency-this._running;for(let e=0;e<i;e++){const t=this._pending.shift();if(!t)return;const r=this._resolvers.get(t),n=this._rejectors.get(t);if(!r||!n)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(o=>r(o)).catch(o=>n(o))}}add(i){return new Promise((e,t)=>{this._resolvers.set(i,e),this._rejectors.set(i,t),this._pending.push(i),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}}const hs=()=>({"*blocksRegistry":new Set,"*eventEmitter":null}),us=s=>({...hs(),"*currentActivity":"","*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{s.set$({"*modalActive":!1,"*currentActivity":""})}}),ds=s=>({...us(s),"*commonProgress":0,"*uploadList":[],"*focusedEntry":null,"*uploadMetadata":null,"*uploadQueue":new Fn(1),"*uploadCollection":null,"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set});function Nn(s,i){[...s.querySelectorAll("[l10n]")].forEach(e=>{let t=e.getAttribute("l10n"),r="textContent";if(t.includes(":")){let o=t.split(":");r=o[0],t=o[1]}let n="l10n:"+t;i.__l10nKeys.push(n),i.add(n,t),i.sub(n,o=>{e[r]=i.l10n(o)}),e.removeAttribute("l10n")})}const z=s=>`*cfg/${s}`,Tt="lr-";class k extends ht{constructor(){super();u(this,"requireCtxName",!1);u(this,"allowCustomTemplate",!0);u(this,"activityType",null);u(this,"init$",hs());u(this,"updateCtxCssData",()=>{nt("Using CSS variables for configuration is deprecated. Please use `lr-config` instead. See migration guide: https://uploadcare.com/docs/file-uploader/migration-to-0.25.0/");let e=this.$["*blocksRegistry"];for(let t of e)t.isConnected&&t.updateCssData()});this.addTemplateProcessor(Nn),this.__l10nKeys=[]}l10n(e,t={}){if(!e)return"";let r=this.getCssData("--l10n-"+e,!0)||e,n=Mr(r);for(let l of n)t[l.variable]=this.pluralize(l.pluralKey,Number(t[l.countVariable]));return Ot(r,t)}pluralize(e,t){const r=this.l10n("locale-name")||"en-US",n=Yi(r,t);return this.l10n(`${e}__${n}`)}emit(e,t,r){const n=this.has("*eventEmitter")&&this.$["*eventEmitter"];n&&n.emit(e,t,r)}applyL10nKey(e,t){let r="l10n:"+e;this.$[r]=t,this.__l10nKeys.push(e)}hasBlockInCtx(e){let t=this.$["*blocksRegistry"];for(let r of t)if(e(r))return!0;return!1}setOrAddState(e,t){this.add$({[e]:t},!0)}setActivity(e){if(this.hasBlockInCtx(t=>t.activityType===e)){this.$["*currentActivity"]=e;return}console.warn(`Activity type "${e}" not found in the context`)}connectedCallback(){const e=this.constructor.className;e&&this.classList.toggle(`${Tt}${e}`,!0),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?Zi({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),rt.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),rt.unregisterClient(this)}initCallback(){this.$["*blocksRegistry"].add(this),this.$["*eventEmitter"]||(this.$["*eventEmitter"]=new Ur(this.debugPrint.bind(this)))}destroyCallback(){let e=this.$["*blocksRegistry"];e.delete(this),T.deleteCtx(this),e.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){T.deleteCtx(this.ctxName)}fileSizeFmt(e,t=2){let r=["B","KB","MB","GB","TB"],n=c=>this.getCssData("--l10n-unit-"+c.toLowerCase(),!0)||c;if(e===0)return`0 ${n(r[0])}`;let o=1024,l=t<0?0:t,a=Math.floor(Math.log(e)/Math.log(o));return parseFloat((e/o**a).toFixed(l))+" "+n(r[a])}proxyUrl(e){let t=this.cfg.secureDeliveryProxy;return t?Ot(t,{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}parseCfgProp(e){return{ctx:this.nodeCtx,name:e.replace("*","")}}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(t,r,n)=>{if(typeof r!="string")return!1;const o=z(r);return this.$[o]=n,!0},get:(t,r)=>{const n=z(r),o=this.parseCfgProp(n);return o.ctx.has(o.name)?o.ctx.read(o.name):(nt("Using CSS variables for configuration is deprecated. Please use `lr-config` instead. See migration guide: https://uploadcare.com/docs/file-uploader/migration-to-0.25.0/"),this.getCssData(`--cfg-${Ce(r)}`))}})}return this.__cfgProxy}subConfigValue(e,t){const r=this.parseCfgProp(z(e));r.ctx.has(r.name)?this.sub(z(e),t):(this.bindCssData(`--cfg-${Ce(e)}`),this.sub(`--cfg-${Ce(e)}`,t))}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof(e==null?void 0:e[0])=="function"){const r=e[0];t=r()}console.log(`[${this.debugCtxName}]`,...t)}get debugCtxName(){return this.ctxName}static reg(e){if(!e){super.reg();return}super.reg(e.startsWith(Tt)?e:Tt+e)}}u(k,"StateConsumerScope",null),u(k,"className","");const Ei="active",Ne="___ACTIVITY_IS_ACTIVE___",G=class G extends k{constructor(){super(...arguments);u(this,"historyTracked",!1);u(this,"init$",us(this));u(this,"_debouncedHistoryFlush",H(this._historyFlush.bind(this),10))}_deactivate(){var t;let e=G._activityRegistry[this.activityKey];this[Ne]=!1,this.removeAttribute(Ei),(t=e==null?void 0:e.deactivateCallback)==null||t.call(e)}_activate(){var t;let e=G._activityRegistry[this.activityKey];this.$["*historyBack"]=this.historyBack.bind(this),this[Ne]=!0,this.setAttribute(Ei,""),(t=e==null?void 0:e.activateCallback)==null||t.call(e),this._debouncedHistoryFlush(),this.emit(x.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.hasAttribute("current-activity")&&this.sub("*currentActivity",e=>{this.setAttribute("current-activity",e)}),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{this.activityType!==e&&this[Ne]?this._deactivate():this.activityType===e&&!this[Ne]&&this._activate(),e||(this.$["*history"]=[])}),this.has("*modalActive")&&this.sub("*modalActive",e=>{!e&&this.activityType===this.$["*currentActivity"]&&(this.$["*currentActivity"]=null)}))}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e)}_isActivityRegistered(){return this.activityType&&!!G._activityRegistry[this.activityKey]}get isActivityActive(){return this[Ne]}get couldOpenActivity(){return!0}registerActivity(e,t={}){const{onActivate:r,onDeactivate:n}=t;G._activityRegistry||(G._activityRegistry=Object.create(null)),G._activityRegistry[this.activityKey]={activateCallback:r,deactivateCallback:n}}unregisterActivity(){this.isActivityActive&&this._deactivate(),G._activityRegistry[this.activityKey]=void 0}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity(),Object.keys(G._activityRegistry).length===0&&(this.$["*currentActivity"]=null)}get activityKey(){return this.ctxName+this.activityType}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")}get doneActivity(){return this.getCssData("--cfg-done-activity")}historyBack(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let r=!!t;if(t){const o=[...this.$["*blocksRegistry"]].find(l=>l.activityType===t);r=(o==null?void 0:o.couldOpenActivity)??!1}t=r?t:void 0,this.$["*currentActivity"]=t,this.$["*history"]=e,t||this.setOrAddState("*modalActive",!1)}}};u(G,"_activityRegistry",Object.create(null));let b=G;b.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CONFIRMATION:"confirmation",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external",DETAILS:"details"});const Dn=20,Lt=24,je=34,fs=3,Z=fs/2,ye=1,Ye=100/3,v=1,Ai=24,zn=6;function Ie(s,i){for(let e in i)s.setAttributeNS(null,e,i[e].toString())}function q(s,i={}){let e=document.createElementNS("http://www.w3.org/2000/svg",s);return Ie(e,i),e}function Vn(s,i,e){let{x:t,y:r,width:n,height:o}=s,l=i.includes("w")?0:1,a=i.includes("n")?0:1,c=[-1,1][l],h=[-1,1][a],d=[t+l*n+Z*c,r+a*o+Z*h-Lt*e*h],f=[t+l*n+Z*c,r+a*o+Z*h],m=[t+l*n-Lt*e*c+Z*c,r+a*o+Z*h];return{d:`M ${d[0]} ${d[1]} L ${f[0]} ${f[1]} L ${m[0]} ${m[1]}`,center:f}}function Bn(s,i,e){let{x:t,y:r,width:n,height:o}=s,l=["n","s"].includes(i)?.5:{w:0,e:1}[i],a=["w","e"].includes(i)?.5:{n:0,s:1}[i],c=[-1,1][l],h=[-1,1][a],d,f;["n","s"].includes(i)?(d=[t+l*n-je*e/2,r+a*o+Z*h],f=[t+l*n+je*e/2,r+a*o+Z*h]):(d=[t+l*n+Z*c,r+a*o-je*e/2],f=[t+l*n+Z*c,r+a*o+je*e/2]);let m=`M ${d[0]} ${d[1]} L ${f[0]} ${f[1]}`,p=[f[0]-(f[0]-d[0])/2,f[1]-(f[1]-d[1])/2];return{d:m,center:p}}function jn(s){return s===""?"move":["e","w"].includes(s)?"ew-resize":["n","s"].includes(s)?"ns-resize":["nw","se"].includes(s)?"nwse-resize":"nesw-resize"}function Hn({rect:s,delta:[i,e],imageBox:t}){return ot({...s,x:s.x+i,y:s.y+e},t)}function ot(s,i){let{x:e}=s,{y:t}=s;return s.x<i.x?e=i.x:s.x+s.width>i.x+i.width&&(e=i.x+i.width-s.width),s.y<i.y?t=i.y:s.y+s.height>i.y+i.height&&(t=i.y+i.height-s.height),{...s,x:e,y:t}}function Wn({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[,r]=i;let{y:n,width:o,height:l}=s;n+=r,l-=r,e&&(o=l*e);let a=s.x+s.width/2-o/2;return n<=t.y&&(n=t.y,l=s.y+s.height-n,e&&(o=l*e,a=s.x+s.width/2-o/2)),a<=t.x&&(a=t.x,n=s.y+s.height-l),a+o>=t.x+t.width&&(a=Math.max(t.x,t.x+t.width-o),o=t.x+t.width-a,e&&(l=o/e),n=s.y+s.height-l),l<v&&(l=v,e&&(o=l*e,a=s.x+s.width/2-o/2),n=s.y+s.height-l),o<v&&(o=v,e&&(l=o/e,a=s.x+s.width/2-o/2),n=s.y+s.height-l),{x:a,y:n,width:o,height:l}}function qn({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[r]=i;let{x:n,width:o,height:l}=s;n+=r,o-=r,e&&(l=o/e);let a=s.y+s.height/2-l/2;return n<=t.x&&(n=t.x,o=s.x+s.width-n,e&&(l=o/e,a=s.y+s.height/2-l/2)),a<=t.y&&(a=t.y,n=s.x+s.width-o),a+l>=t.y+t.height&&(a=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-a,e&&(o=l*e),n=s.x+s.width-o),l<v&&(l=v,e&&(o=l*e),a=s.y+s.height/2-l/2,n=s.x+s.width-o),o<v&&(o=v,e&&(l=o/e),a=s.y+s.height/2-l/2,n=s.x+s.width-o),{x:n,y:a,width:o,height:l}}function Gn({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[,r]=i;let{y:n,width:o,height:l}=s;l+=r,e&&(o=l*e);let a=s.x+s.width/2-o/2;return n+l>=t.y+t.height&&(l=t.y+t.height-n,e&&(o=l*e),a=s.x+s.width/2-o/2),a<=t.x&&(a=t.x,n=s.y),a+o>=t.x+t.width&&(a=Math.max(t.x,t.x+t.width-o),o=t.x+t.width-a,e&&(l=o/e),n=s.y),l<v&&(l=v,e&&(o=l*e),a=s.x+s.width/2-o/2),o<v&&(o=v,e&&(l=o/e),a=s.x+s.width/2-o/2),{x:a,y:n,width:o,height:l}}function Xn({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[r]=i;let{x:n,width:o,height:l}=s;o+=r,e&&(l=o/e);let a=s.y+s.height/2-l/2;return n+o>=t.x+t.width&&(o=t.x+t.width-n,e&&(l=o/e),a=s.y+s.height/2-l/2),a<=t.y&&(a=t.y,n=s.x),a+l>=t.y+t.height&&(a=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-a,e&&(o=l*e),n=s.x),l<v&&(l=v,e&&(o=l*e),a=s.y+s.height/2-l/2),o<v&&(o=v,e&&(l=o/e),a=s.y+s.height/2-l/2),{x:n,y:a,width:o,height:l}}function Kn({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+r<t.x&&(r=t.x-o),l+n<t.y&&(n=t.y-l),o+=r,a-=r,l+=n,c-=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l-=n,l<=t.y&&(c=c-(t.y-l),a=c*e,o=s.x+s.width-a,l=t.y)):e&&(r=c*e-a,a=a+r,o-=r,o<=t.x&&(a=a-(t.x-o),c=a/e,o=t.x,l=s.y+s.height-c)),c<v&&(c=v,e&&(a=c*e),o=s.x+s.width-a,l=s.y+s.height-c),a<v&&(a=v,e&&(c=a/e),o=s.x+s.width-a,l=s.y+s.height-c),{x:o,y:l,width:a,height:c}}function Yn({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+a+r>t.x+t.width&&(r=t.x+t.width-o-a),l+n<t.y&&(n=t.y-l),a+=r,l+=n,c-=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l-=n,l<=t.y&&(c=c-(t.y-l),a=c*e,o=s.x,l=t.y)):e&&(r=c*e-a,a+=r,o+a>=t.x+t.width&&(a=t.x+t.width-o,c=a/e,o=t.x+t.width-a,l=s.y+s.height-c)),c<v&&(c=v,e&&(a=c*e),l=s.y+s.height-c),a<v&&(a=v,e&&(c=a/e),l=s.y+s.height-c),{x:o,y:l,width:a,height:c}}function Jn({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+r<t.x&&(r=t.x-o),l+c+n>t.y+t.height&&(n=t.y+t.height-l-c),o+=r,a-=r,c+=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l+c>=t.y+t.height&&(c=t.y+t.height-l,a=c*e,o=s.x+s.width-a,l=t.y+t.height-c)):e&&(r=c*e-a,a+=r,o-=r,o<=t.x&&(a=a-(t.x-o),c=a/e,o=t.x,l=s.y)),c<v&&(c=v,e&&(a=c*e),o=s.x+s.width-a),a<v&&(a=v,e&&(c=a/e),o=s.x+s.width-a),{x:o,y:l,width:a,height:c}}function Zn({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+a+r>t.x+t.width&&(r=t.x+t.width-o-a),l+c+n>t.y+t.height&&(n=t.y+t.height-l-c),a+=r,c+=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l+c>=t.y+t.height&&(c=t.y+t.height-l,a=c*e,o=s.x,l=t.y+t.height-c)):e&&(r=c*e-a,a+=r,o+a>=t.x+t.width&&(a=t.x+t.width-o,c=a/e,o=t.x+t.width-a,l=s.y)),c<v&&(c=v,e&&(a=c*e)),a<v&&(a=v,e&&(c=a/e)),{x:o,y:l,width:a,height:c}}function Qn({direction:s,...i}){switch(s){case"n":return Wn(i);case"w":return qn(i);case"s":return Gn(i);case"e":return Xn(i);case"nw":return Kn(i);case"ne":return Yn(i);case"sw":return Jn(i);case"se":return Zn(i);default:return i.rect}}function eo(s,[i,e]){return s.x<=i&&i<=s.x+s.width&&s.y<=e&&e<=s.y+s.height}function to(s,i){return s.x>=i.x&&s.y>=i.y&&s.x+s.width<=i.x+i.width&&s.y+s.height<=i.y+i.height}function io(s,i){return Math.abs(s.width/s.height-i)<.1}function De({width:s,height:i},e){let t=e/90%2!==0;return{width:t?i:s,height:t?s:i}}function so(s,i,e){const t=s/i;let r,n;t>e?(r=Math.round(i*e),n=i):(r=s,n=Math.round(s/e));const o=Math.round((s-r)/2),l=Math.round((i-n)/2);return o+r>s&&(r=s-o),l+n>i&&(n=i-l),{x:o,y:l,width:r,height:n}}function it(s){return{x:Math.round(s.x),y:Math.round(s.y),width:Math.round(s.width),height:Math.round(s.height)}}function ke(s,i,e){return Math.min(Math.max(s,i),e)}const ps=s=>{if(!s)return[];const[i,e]=s.split(":").map(Number);if(!Number.isFinite(i)||!Number.isFinite(e)){console.error(`Invalid crop preset: ${s}`);return}return[{type:"aspect-ratio",width:i,height:e}]},Q=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",URL_TAB:"url-tab",CAMERA:"camera",EXTERNAL:"external",API:"js-api"}),ro=s=>s?s.split(",").map(i=>i.trim()):[],Wt=s=>s?s.join(","):"",qt="blocks",bt="0.36.0";function no(s){return Qi({...s,libraryName:qt,libraryVersion:bt})}const ms=({type:s,message:i,...e})=>({type:s,message:i,...e}),Se=ms,$t=ms,gs=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},Gt=(...s)=>s.filter(i=>typeof i=="string"&&i).map(i=>gs(i)).join("/-/"),le=(...s)=>{let i=Gt(...s);return i?`-/${i}/`:""};function bs(s){let i=new URL(s),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),n="";return t>=0?n=e.slice(t):r>=0&&(n=e.slice(r+1)),n}function oo(s){let i=new URL(s),{pathname:e}=i;const t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}function lo(s){let i=_s(s),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?[]:e.pathname.substring(t).split("/-/").filter(Boolean).map(n=>gs(n))}function _s(s){let i=new URL(s),e=bs(s),t=ys(e)?vs(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}function ys(s){return s.startsWith("http")}function vs(s){let i=new URL(s);return{pathname:i.origin+i.pathname||"",search:i.search||"",hash:i.hash||""}}const V=(s,i,e)=>{let t=new URL(_s(s));if(e=e||bs(s),t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),ys(e)){let r=vs(e);t.pathname=t.pathname+(i||"")+(r.pathname||""),t.search=r.search,t.hash=r.hash}else t.pathname=t.pathname+(i||"")+(e||"");return t.toString()},We=(s,i)=>{let e=new URL(s);return e.pathname=i+"/",e.toString()},ae=(s,i=",")=>s.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0),Ut=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],Ti=s=>s?s.filter(i=>typeof i=="string").map(i=>ae(i)).flat():[],Cs=(s,i)=>i.some(e=>e.endsWith("*")?(e=e.replace("*",""),s.startsWith(e)):s===e),ao=(s,i)=>i.some(e=>e.startsWith(".")?s.toLowerCase().endsWith(e.toLowerCase()):!1),Rt=s=>{let i=s==null?void 0:s.type;return i?Cs(i,Ut):!1},Y=1e3,ve=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),ze=s=>Math.ceil(s*100)/100,co=(s,i=ve.AUTO)=>{const e=i===ve.AUTO;if(i===ve.BYTE||e&&s<Y**1){const t=Yi("en-US",s),r={one:"byte",other:"bytes"}[t];return`${s} ${r}`}return i===ve.KB||e&&s<Y**2?`${ze(s/Y**1)} KB`:i===ve.MB||e&&s<Y**3?`${ze(s/Y**2)} MB`:i===ve.GB||e&&s<Y**4?`${ze(s/Y**3)} GB`:i===ve.TB||e&&s<Y**5?`${ze(s/Y**4)} TB`:`${ze(s/Y**5)} PB`},$i="[Typed State] Wrong property name: ",ho="[Typed State] Wrong property type: ";class uo{constructor(i,e){this.__typedSchema=i,this.__ctxId=e||Ae.generate(),this.__schema=Object.keys(i).reduce((t,r)=>(t[r]=i[r].value,t),{}),this.__data=T.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(i,e){if(!this.__typedSchema.hasOwnProperty(i)){console.warn($i+i);return}let t=this.__typedSchema[i];if((e==null?void 0:e.constructor)===t.type||e instanceof t.type||t.nullable&&e===null){this.__data.pub(i,e);return}console.warn(ho+i)}setMultipleValues(i){for(let e in i)this.setValue(e,i[e])}getValue(i){if(!this.__typedSchema.hasOwnProperty(i)){console.warn($i+i);return}return this.__data.read(i)}subscribe(i,e){return this.__data.sub(i,e)}remove(){T.deleteCtx(this.__ctxId)}}class fo{constructor(i){this.__typedSchema=i.typedSchema,this.__ctxId=i.ctxName||Ae.generate(),this.__data=T.registerCtx({},this.__ctxId),this.__watchList=i.watchList||[],this.__subsMap=Object.create(null),this.__propertyObservers=new Set,this.__collectionObservers=new Set,this.__items=new Set,this.__removed=new Set,this.__added=new Set;let e=Object.create(null);this.__notifyObservers=(t,r)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[t]||(e[t]=new Set),e[t].add(r),this.__observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this.__propertyObservers.forEach(n=>{n({...e})}),e=Object.create(null))})}}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let i=new Set(this.__added),e=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(const t of this.__collectionObservers)t==null||t([...this.__items],i,e)})}observeCollection(i){return this.__collectionObservers.add(i),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(i)}}unobserveCollection(i){var e;(e=this.__collectionObservers)==null||e.delete(i)}add(i){let e=new uo(this.__typedSchema);for(let t in i)e.setValue(t,i[t]);return this.__items.add(e.uid),this.notify(),this.__data.add(e.uid,e),this.__added.add(e),this.__watchList.forEach(t=>{this.__subsMap[e.uid]||(this.__subsMap[e.uid]=[]),this.__subsMap[e.uid].push(e.subscribe(t,()=>{this.__notifyObservers(t,e.uid)}))}),e.uid}read(i){return this.__data.read(i)}readProp(i,e){return this.read(i).getValue(e)}publishProp(i,e,t){this.read(i).setValue(e,t)}remove(i){this.__removed.add(this.__data.read(i)),this.__items.delete(i),this.notify(),this.__data.pub(i,null),delete this.__subsMap[i]}clearAll(){this.__items.forEach(i=>{this.remove(i)})}observeProperties(i){return this.__propertyObservers.add(i),()=>{this.unobserveProperties(i)}}unobserveProperties(i){var e;(e=this.__propertyObservers)==null||e.delete(i)}findItems(i){let e=[];return this.__items.forEach(t=>{let r=this.read(t);i(r)&&e.push(t)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){T.deleteCtx(this.__ctxId),this.__propertyObservers=null,this.__collectionObservers=null;for(let i in this.__subsMap)this.__subsMap[i].forEach(e=>{e.remove()}),delete this.__subsMap[i]}}const po=s=>{const i=new Map;return(...e)=>{const t=JSON.stringify(e);if(i.has(t))return i.get(t);const r=s(...e);return i.set(t,r),r}};function mo(s){let i=!1;return setTimeout(()=>{i=!0},0),t=>(...r)=>(i&&nt(s),t(...r))}function go(s){const i={progress:()=>s.$["*commonProgress"],errors:()=>s.$["*collectionErrors"],group:()=>s.$["*groupInfo"],totalCount:()=>s.uploadCollection.size,failedCount:()=>e.failedEntries.length,successCount:()=>e.successEntries.length,uploadingCount:()=>e.uploadingEntries.length,status:()=>e.isFailed?"failed":e.isUploading?"uploading":e.isSuccess?"success":"idle",isSuccess:()=>e.errors.length===0&&e.successEntries.length===e.allEntries.length,isUploading:()=>e.allEntries.some(r=>r.status==="uploading"),isFailed:()=>e.errors.length>0||e.failedEntries.length>0,allEntries:()=>s.getOutputData(),successEntries:()=>e.allEntries.filter(r=>r.status==="success"),failedEntries:()=>e.allEntries.filter(r=>r.status==="failed"),uploadingEntries:()=>e.allEntries.filter(r=>r.status==="uploading"),idleEntries:()=>e.allEntries.filter(r=>r.status==="idle")},e={},t=mo("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(const[r,n]of Object.entries(i)){const o=r,a=po(t(n));Object.defineProperty(e,o,{get:a,enumerable:!0})}return e}const bo=Object.freeze({file:{type:File,value:null},externalUrl:{type:String,value:null},fileName:{type:String,value:null,nullable:!0},fileSize:{type:Number,value:null,nullable:!0},lastModified:{type:Number,value:Date.now()},uploadProgress:{type:Number,value:0},uuid:{type:String,value:null},isImage:{type:Boolean,value:!1},mimeType:{type:String,value:null,nullable:!0},ctxName:{type:String,value:null},cdnUrl:{type:String,value:null},cdnUrlModifiers:{type:String,value:null},fileInfo:{type:Me,value:null},isUploading:{type:Boolean,value:!1},abortController:{type:AbortController,value:null,nullable:!0},thumbUrl:{type:String,value:null,nullable:!0},silent:{type:Boolean,value:!1},source:{type:String,value:!1,nullable:!0},fullPath:{type:String,value:null,nullable:!0},metadata:{type:Object,value:null,nullable:!0},errors:{type:Array,value:[]},uploadError:{type:Error,value:null,nullable:!0},isRemoved:{type:Boolean,value:!1}}),_o=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,yo=new RegExp(`^/?(${_o.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),vo=({url:s,cdnBase:i})=>{const e=new URL(i),t=new URL(s);if(e.host!==t.host)return null;const[,r,n,o]=yo.exec(t.pathname);return{uuid:r,cdnUrlModifiers:n||"",filename:o||null}};class $ extends b{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!1);u(this,"isCtxOwner",!1);u(this,"init$",ds(this));u(this,"__initialUploadMetadata",null);u(this,"_fileValidators",[this._validateIsImage.bind(this),this._validateFileType.bind(this),this._validateMaxSizeLimit.bind(this),this._validateUploadError.bind(this)]);u(this,"_collectionValidators",[e=>{const t=e.size,r=this.cfg.multiple?this.cfg.multipleMin:0,n=this.cfg.multiple?this.cfg.multipleMax:1;if(r&&t<r){const o=this.l10n("files-count-limit-error-too-few",{min:r,max:n,total:t});return $t({type:"TOO_FEW_FILES",message:o,total:t,min:r,max:n})}if(n&&t>n){const o=this.l10n("files-count-limit-error-too-many",{min:r,max:n,total:t});return $t({type:"TOO_MANY_FILES",message:o,total:t,min:r,max:n})}},e=>{if(e.items().some(t=>e.readProp(t,"errors").length>0))return $t({type:"SOME_FILES_HAS_ERRORS",message:this.l10n("some-files-were-not-uploaded")})}]);u(this,"uploadAll",()=>{const e=this.uploadCollection.items().filter(t=>{const r=this.uploadCollection.read(t);return!r.getValue("isRemoved")&&!r.getValue("isUploading")&&!r.getValue("fileInfo")});e.length!==0&&(this.$["*uploadTrigger"]=new Set(e),this.emit(x.COMMON_UPLOAD_START,this.getOutputCollectionState()))});u(this,"_flushOutputItems",H(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;const t=this.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(x.CHANGE,()=>this.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300));u(this,"_handleCollectionUpdate",(e,t,r)=>{var n;(t.size||r.size)&&(this.$["*groupInfo"]=null),this._runFileValidators(),this._runCollectionValidators();for(const o of t)o.getValue("silent")||this.emit(x.FILE_ADDED,this.getOutputItem(o.uid));for(const o of r)this.$["*uploadTrigger"].delete(o.uid),(n=o.getValue("abortController"))==null||n.abort(),o.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0}),URL.revokeObjectURL(o==null?void 0:o.getValue("thumbUrl")),this.emit(x.FILE_REMOVED,this.getOutputItem(o.uid));this.$["*uploadList"]=e.map(o=>({uid:o})),this._flushCommonUploadProgress(),this._flushOutputItems()});u(this,"_handleCollectionPropertiesUpdate",e=>{this._flushOutputItems();const t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([n])=>["uploadError","fileInfo"].includes(n)).map(([,n])=>[...n]).flat())];if(r.length>0&&setTimeout(()=>{this._runFileValidators(r)}),e.uploadProgress){for(const n of e.uploadProgress){const{isUploading:o,silent:l}=T.getCtx(n).store;o&&!l&&this.emit(x.FILE_UPLOAD_PROGRESS,this.getOutputItem(n))}this._flushCommonUploadProgress()}if(e.isUploading)for(const n of e.isUploading){const{isUploading:o,silent:l}=T.getCtx(n).store;o&&!l&&this.emit(x.FILE_UPLOAD_START,this.getOutputItem(n))}if(e.fileInfo){for(const l of e.fileInfo){const{fileInfo:a,silent:c}=T.getCtx(l).store;a&&!c&&this.emit(x.FILE_UPLOAD_SUCCESS,this.getOutputItem(l))}this.cfg.cropPreset&&this.setInitialCrop();let n=t.findItems(l=>!!l.getValue("fileInfo"));t.findItems(l=>l.getValue("errors").length>0).length===0&&t.size===n.length&&this.emit(x.COMMON_UPLOAD_SUCCESS,this.getOutputCollectionState())}if(e.errors)for(const n of e.errors){const{errors:o}=T.getCtx(n).store;o.length>0&&(this.emit(x.FILE_UPLOAD_FAILED,this.getOutputItem(n)),this.emit(x.COMMON_UPLOAD_FAILED,()=>this.getOutputCollectionState(),{debounce:!0}))}e.cdnUrl&&([...e.cdnUrl].filter(o=>{var l;return!!((l=this.uploadCollection.read(o))!=null&&l.getValue("cdnUrl"))}).forEach(o=>{this.emit(x.FILE_URL_CHANGED,this.getOutputItem(o))}),this.$["*groupInfo"]=null)});u(this,"_flushCommonUploadProgress",()=>{let e=0;const r=[...this.$["*uploadTrigger"]].filter(o=>!!this.uploadCollection.read(o));r.forEach(o=>{const l=this.uploadCollection.readProp(o,"uploadProgress");e+=l});const n=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==n&&(this.$["*commonProgress"]=n,this.emit(x.COMMON_UPLOAD_PROGRESS,this.getOutputCollectionState()))})}setUploadMetadata(e){nt("setUploadMetadata is deprecated. Use `metadata` instance property on `lr-config` block instead. See migration guide: https://uploadcare.com/docs/file-uploader/migration-to-0.25.0/"),this.connectedOnce?this.$["*uploadMetadata"]=e:this.__initialUploadMetadata=e}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof $?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.$["*uploadCollection"]){let e=new fo({typedSchema:bo,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading"]});this.$["*uploadCollection"]=e}!this.hasCtxOwner&&this.couldBeCtxOwner&&this.initCtxOwner()}destroyCtxCallback(){var e,t;(e=this._unobserveCollectionProperties)==null||e.call(this),(t=this._unobserveCollection)==null||t.call(this),this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}initCtxOwner(){this.isCtxOwner=!0,this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate);const e=()=>{this._runFileValidators(),this._runCollectionValidators()};this.subConfigValue("maxLocalFileSizeBytes",e),this.subConfigValue("multipleMin",e),this.subConfigValue("multipleMax",e),this.subConfigValue("multiple",e),this.subConfigValue("imgOnly",e),this.subConfigValue("accept",e),this.subConfigValue("maxConcurrentRequests",t=>{this.$["*uploadQueue"].concurrency=Number(t)||1}),this.__initialUploadMetadata&&(this.$["*uploadMetadata"]=this.__initialUploadMetadata)}addFileFromUrl(e,{silent:t,fileName:r,source:n}={}){const o=this.uploadCollection.add({externalUrl:e,fileName:r??null,silent:t??!1,source:n??Q.API});return this.getOutputItem(o)}addFileFromUuid(e,{silent:t,fileName:r,source:n}={}){const o=this.uploadCollection.add({uuid:e,fileName:r??null,silent:t??!1,source:n??Q.API});return this.getOutputItem(o)}addFileFromCdnUrl(e,{silent:t,fileName:r,source:n}={}){const o=vo({url:e,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");const l=this.uploadCollection.add({uuid:o.uuid,cdnUrl:e,cdnUrlModifiers:o.cdnUrlModifiers,fileName:r??o.filename??null,silent:t??!1,source:n??Q.API});return this.getOutputItem(l)}addFileFromObject(e,{silent:t,fileName:r,source:n,fullPath:o}={}){const l=this.uploadCollection.add({file:e,isImage:Rt(e),mimeType:e.type,fileName:r??e.name,fileSize:e.size,silent:t??!1,source:n??Q.API,fullPath:o??null});return this.getOutputItem(l)}addFiles(e){return console.warn("`addFiles` method is deprecated. Please use `addFileFromObject`, `addFileFromUrl` or `addFileFromUuid` instead."),e.map(t=>{const r=this.uploadCollection.add({file:t,isImage:Rt(t),mimeType:t.type,fileName:t.name,fileSize:t.size});return this.getOutputItem(r)})}removeFileByInternalId(e){if(!this.uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this.uploadCollection.remove(e)}removeAllFiles(){this.uploadCollection.clearAll()}openSystemDialog(e={}){let t=Wt(Ti([this.cfg.accept??"",...this.cfg.imgOnly?Ut:[]]));this.cfg.accept&&this.cfg.imgOnly&&console.warn("There could be a mistake.\nBoth `accept` and `imgOnly` parameters are set.\nThe value of `accept` will be concatenated with the internal image mime types list."),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.multiple=this.cfg.multiple,e.captureCamera?(this.fileInput.capture=this.cfg.cameraCapture,this.fileInput.accept="image/*"):this.fileInput.accept=t,this.fileInput.dispatchEvent(new MouseEvent("click")),this.fileInput.onchange=()=>{[...this.fileInput.files].forEach(r=>this.addFileFromObject(r,{source:e.captureCamera?Q.CAMERA:Q.LOCAL})),this.$["*currentActivity"]=b.activities.UPLOAD_LIST,this.setOrAddState("*modalActive",!0),this.fileInput.value="",this.fileInput=null}}get sourceList(){let e=[];return this.cfg.sourceList&&(e=ae(this.cfg.sourceList)),e}initFlow(e=!1){var t;if(this.uploadCollection.size>0&&!e)this.set$({"*currentActivity":b.activities.UPLOAD_LIST}),this.setOrAddState("*modalActive",!0);else if(((t=this.sourceList)==null?void 0:t.length)===1){const r=this.sourceList[0];if(r==="local"){this.$["*currentActivity"]=b.activities.UPLOAD_LIST,this==null||this.openSystemDialog();return}const n=this.$["*blocksRegistry"],o=a=>"type"in a&&a.type===r,l=[...n].find(o);l==null||l.activate(),this.$["*currentActivity"]&&this.setOrAddState("*modalActive",!0)}else this.set$({"*currentActivity":b.activities.START_FROM}),this.setOrAddState("*modalActive",!0)}doneFlow(){this.set$({"*currentActivity":this.doneActivity,"*history":this.doneActivity?[this.doneActivity]:[]}),this.$["*currentActivity"]||this.setOrAddState("*modalActive",!1)}get uploadCollection(){return this.$["*uploadCollection"]}_validateFileType(e){const t=this.cfg.imgOnly,r=this.cfg.accept,n=Ti([...t?Ut:[],r]);if(!n.length)return;const o=e.mimeType,l=e.name;if(!o||!l)return;const a=Cs(o,n),c=ao(l,n);if(!a&&!c)return Se({type:"FORBIDDEN_FILE_TYPE",message:this.l10n("file-type-not-allowed"),entry:e})}_validateMaxSizeLimit(e){const t=this.cfg.maxLocalFileSizeBytes,r=e.size;if(t&&r&&r>t)return Se({type:"FILE_SIZE_EXCEEDED",message:this.l10n("files-max-size-limit-error",{maxFileSize:co(t)}),entry:e})}_validateUploadError(e,t){const r=t==null?void 0:t.getValue("uploadError");if(r){if(r instanceof D)return Se({type:"UPLOAD_ERROR",message:r.message,entry:e,error:r});if(r instanceof Ge)return Se({type:"NETWORK_ERROR",message:r.message,entry:e,error:r});{const n=r instanceof Error?r:new Error("Unknown error",{cause:r});return Se({type:"UNKNOWN_ERROR",message:n.message,entry:e,error:n})}}}_validateIsImage(e){const t=this.cfg.imgOnly,r=e.isImage;if(!(!t||r)&&!(!e.fileInfo&&e.externalUrl)&&!(!e.fileInfo&&!e.mimeType))return Se({type:"NOT_AN_IMAGE",message:this.l10n("images-only-accepted"),entry:e})}_runFileValidatorsForEntry(e){const t=this.getOutputItem(e.uid),r=[];for(const n of this._fileValidators){const o=n(t,e);o&&r.push(o)}e.setValue("errors",r)}_runFileValidators(e){const t=e??this.uploadCollection.items();for(const r of t){const n=this.uploadCollection.read(r);n&&this._runFileValidatorsForEntry(n)}}_runCollectionValidators(){const e=this.uploadCollection,t=[];for(const r of this._collectionValidators){const n=r(e);n&&(Array.isArray(n)?t.push(...n):t.push(n))}this.$["*collectionErrors"]=t,t.length>0&&this.emit(x.COMMON_UPLOAD_FAILED,()=>this.getOutputCollectionState(),{debounce:!0})}async _createGroup(e){const t=this.getUploadClientOptions(),r=e.allEntries.map(a=>a.uuid+(a.cdnUrlModifiers?`/${a.cdnUrlModifiers}`:"")),n=new AbortController,o=await Mn(r,{...t,signal:n.signal});if(this.$["*collectionState"]!==e){n.abort();return}this.$["*groupInfo"]=o;const l=this.getOutputCollectionState();this.emit(x.GROUP_CREATED,l),this.emit(x.CHANGE,()=>this.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=l}setInitialCrop(){const e=ps(this.cfg.cropPreset);if(e){const[t]=e,r=this.uploadCollection.findItems(n=>{var o;return n.getValue("fileInfo")&&n.getValue("isImage")&&!((o=n.getValue("cdnUrlModifiers"))!=null&&o.includes("/crop/"))}).map(n=>this.uploadCollection.read(n));for(const n of r){const o=n.getValue("fileInfo"),{width:l,height:a}=o.imageInfo,c=t.width/t.height,h=so(l,a,c),d=le(`crop/${h.width}x${h.height}/${h.x},${h.y}`,"preview");n.setMultipleValues({cdnUrlModifiers:d,cdnUrl:V(n.getValue("cdnUrl"),d)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(f=>f.activityType===b.activities.CLOUD_IMG_EDIT)&&(this.$["*focusedEntry"]=n,this.$["*currentActivity"]=b.activities.CLOUD_IMG_EDIT)}}}async getMetadataFor(e){const t=this.cfg.metadata??this.$["*uploadMetadata"];if(typeof t=="function"){const r=this.getOutputItem(e);return await t(r)}return t}getUploadClientOptions(){return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:no,integration:this.cfg.userAgentIntegration,secureSignature:this.cfg.secureSignature,secureExpire:this.cfg.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputItem(e){const t=T.getCtx(e).store,r=t.fileInfo;let n=t.isRemoved?"removed":t.errors.length>0?"failed":t.fileInfo?"success":t.isUploading?"uploading":"idle";return{uuid:(r==null?void 0:r.uuid)??t.uuid??null,internalId:e,name:(r==null?void 0:r.originalFilename)??t.fileName,size:(r==null?void 0:r.size)??t.fileSize,isImage:(r==null?void 0:r.isImage)??t.isImage,mimeType:(r==null?void 0:r.mimeType)??t.mimeType,file:t.file,externalUrl:t.externalUrl,cdnUrlModifiers:t.cdnUrlModifiers,cdnUrl:t.cdnUrl??(r==null?void 0:r.cdnUrl)??null,fullPath:t.fullPath,uploadProgress:t.uploadProgress,fileInfo:r??null,metadata:t.metadata??(r==null?void 0:r.metadata)??null,isSuccess:n==="success",isUploading:n==="uploading",isFailed:n==="failed",isRemoved:n==="removed",errors:t.errors,status:n}}getOutputData(e){return(e?this.uploadCollection.findItems(e):this.uploadCollection.items()).map(n=>this.getOutputItem(n))}getOutputCollectionState(){return go(this)}}$.extSrcList=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",INSTAGRAM:"instagram",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"});$.sourceTypes=Object.freeze({LOCAL:"local",URL:"url",CAMERA:"camera",DRAW:"draw",...$.extSrcList});const j=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}),ws=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Co(s,i){if(typeof i=="number"){const e=i;return j[s]!==e?`${s}/${e}`:""}if(typeof i=="boolean"){const e=i;return j[s]!==e?`${s}`:""}if(s==="filter"&&i){const{name:e,amount:t}=i;return j.filter===t?"":`${s}/${e}/${t}`}if(s==="crop"&&i){let{dimensions:e,coords:t}=i;return`${s}/${e.join("x")}/${t.join(",")}`}return""}function _t(s){return Gt(...ws.filter(i=>typeof s[i]<"u"&&s[i]!==null).map(i=>{let e=s[i];return Co(i,e)}).filter(i=>!!i))}const Es=Gt("format/auto","progressive/yes"),re=([s])=>typeof s<"u"?Number(s):void 0,Si=()=>!0,wo=([s,i])=>({name:s,amount:typeof i<"u"?Number(i):100}),Eo=([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:ae(s,"x").map(Number),coords:ae(i).map(Number)}},Ao=Object.freeze({enhance:re,brightness:re,exposure:re,gamma:re,contrast:re,saturation:re,vibrance:re,warmth:re,filter:wo,mirror:Si,flip:Si,rotate:re,crop:Eo});function To(s){const i={};for(const e of s){const[t,...r]=e.split("/");if(!ws.includes(t))continue;const n=t,o=Ao[n];try{const l=o(r);i[n]=l}catch(l){console.warn([`Failed to parse URL operation "${e}". It will be ignored.`,l instanceof Error?`Error message: "${l.message}"`:l,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
<lr-icon size="20" name="sad"></lr-icon>
|
|
241
|
-
</div>
|
|
242
|
-
<div class="network_problems_text">Network error</div>
|
|
243
|
-
</div>
|
|
244
|
-
<div class="network_problems_footer">
|
|
245
|
-
<lr-btn-ui theme="primary" text="Retry" set="onclick: *on.retryNetwork"></lr-btn-ui>
|
|
246
|
-
</div>
|
|
247
|
-
</lr-presence-toggle>
|
|
248
|
-
<div class="viewport">
|
|
249
|
-
<div class="file_type_outer">
|
|
250
|
-
<div class="file_type">{{fileType}}</div>
|
|
251
|
-
</div>
|
|
252
|
-
<div class="image_container" ref="img-container-el">
|
|
253
|
-
<img src="${pe}" class="image image_visible_from_editor" ref="img-el" />
|
|
254
|
-
<lr-editor-image-cropper ref="cropper-el"></lr-editor-image-cropper>
|
|
255
|
-
<lr-editor-image-fader ref="fader-el"></lr-editor-image-fader>
|
|
256
|
-
</div>
|
|
257
|
-
<div class="info_pan">{{msg}}</div>
|
|
258
|
-
</div>
|
|
259
|
-
<div class="toolbar">
|
|
260
|
-
<lr-line-loader-ui set="active: showLoader"></lr-line-loader-ui>
|
|
261
|
-
<div class="toolbar_content toolbar_content__editor">
|
|
262
|
-
<lr-editor-toolbar></lr-editor-toolbar>
|
|
263
|
-
</div>
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
`;class Fe extends be{constructor(){super();u(this,"_debouncedShowLoader",H(this._showLoader.bind(this),300));this.init$={...this.init$,...Pl(this)}}get ctxName(){return this.autoCtxName}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((t,r)=>{const n=setTimeout(()=>{r(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),o=new ResizeObserver(([l])=>{l.contentRect.width>0&&l.contentRect.height>0&&(t(),clearTimeout(n),o.disconnect())});o.observe(this)})}initCallback(){super.initCallback(),this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.$.cdnUrl){const e=oo(this.$.cdnUrl),t=We(this.$.cdnUrl,e);if(t===this.$["*originalUrl"])return;this.$["*originalUrl"]=t;const r=lo(this.$.cdnUrl),n=To(r);this.$["*editorTransformations"]=n}else if(this.$.uuid){const e=We(this.cfg.cdnCname,this.$.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===L.CROP?this.$["*cropperEl"].deactivate({reset:!0}):this.$["*faderEl"].deactivate();try{const e=V(this.$["*originalUrl"],le("json")),t=await fetch(e).then(o=>o.json()),{width:r,height:n}=t;this.$["*imageSize"]={width:r,height:n},this.$["*tabId"]===L.CROP?this.$["*cropperEl"].activate(this.$["*imageSize"]):this.$["*faderEl"].activate({url:this.$["*originalUrl"]})}catch(e){e&&console.error("Failed to load image info",e)}}}async initEditor(){try{await this._waitForSize()}catch(e){this.isConnected&&console.error(e.message);return}this.ref["img-el"].addEventListener("load",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$.src!==pe&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let t=this.ref["img-el"];t.src!==e&&(this._imgLoading=!0,t.src=e||pe)}),this.sub("cropPreset",e=>{this.$["*cropPresetList"]=ps(e)}),this.sub("tabs",e=>{this.$["*tabList"]=Ol(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=X("image",{image_hidden_to_cropper:e===L.CROP,image_hidden_effects:e!==L.CROP})}),this.classList.add("editor_ON"),this.sub("*networkProblems",e=>{this.$["presence.networkProblems"]=e,this.$["presence.modalCaption"]=!e}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],r=le(_t(e),"preview"),n=V(t,r),o={originalUrl:t,cdnUrlModifiers:r,cdnUrl:n,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:o,bubbles:!0,composed:!0}))},!1),this.sub("uuid",e=>e&&this.updateImage()),this.sub("cdnUrl",e=>e&&this.updateImage())}}u(Fe,"className","cloud-image-editor");Fe.template=Ll;Fe.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});class Gs extends be{constructor(){super(),this.init$={...this.init$,dragging:!1},this._handlePointerUp=this._handlePointerUp_.bind(this),this._handlePointerMove=this._handlePointerMove_.bind(this),this._handleSvgPointerMove=this._handleSvgPointerMove_.bind(this)}_shouldThumbBeDisabled(i){let e=this.$["*imageBox"];if(!e)return;if(i===""&&e.height<=v&&e.width<=v)return!0;let t=e.height<=v&&(i.includes("n")||i.includes("s")),r=e.width<=v&&(i.includes("e")||i.includes("w"));return t||r}_createBackdrop(){let i=this.$["*cropBox"];if(!i)return;let{x:e,y:t,width:r,height:n}=i,o=this.ref["svg-el"],l=q("mask",{id:"backdrop-mask"}),a=q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=q("rect",{x:e,y:t,width:r,height:n,fill:"black"});l.appendChild(a),l.appendChild(c);let h=q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});o.appendChild(h),o.appendChild(l),this._backdropMask=l,this._backdropMaskInner=c}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block")}))}_updateBackdrop(){let i=this.$["*cropBox"];if(!i)return;let{x:e,y:t,width:r,height:n}=i;this._backdropMaskInner&&Ie(this._backdropMaskInner,{x:e,y:t,width:r,height:n})}_updateFrame(){let i=this.$["*cropBox"];if(!(!i||!this._frameGuides||!this._frameThumbs)){for(let e of Object.values(this._frameThumbs)){let{direction:t,pathNode:r,interactionNode:n,groupNode:o}=e,l=t==="",a=t.length===2,{x:c,y:h,width:d,height:f}=i;if(l){const p={x:c+d/3,y:h+f/3,width:d/3,height:f/3};Ie(n,p)}else{const p=ke(Math.min(d,f)/(Lt*2+je)/2,0,1);let{d:g,center:A}=a?Vn(i,t,p):Bn(i,t,p);const w=Math.max(Ai*ke(Math.min(d,f)/Ai/3,0,1),zn);Ie(n,{x:A[0]-w,y:A[1]-w,width:w*2,height:w*2}),Ie(r,{d:g})}let m=this._shouldThumbBeDisabled(t);o.setAttribute("class",X("thumb",{"thumb--hidden":m,"thumb--visible":!m}))}Ie(this._frameGuides,{x:i.x-ye*.5,y:i.y-ye*.5,width:i.width+ye,height:i.height+ye})}}_createThumbs(){const i={};for(let e=0;e<3;e++)for(let t=0;t<3;t++){let r=`${["n","","s"][e]}${["w","","e"][t]}`,n=q("g");n.classList.add("thumb"),n.setAttribute("with-effects","");let o=q("rect",{fill:"transparent"}),l=q("path",{stroke:"currentColor",fill:"none","stroke-width":fs});n.appendChild(l),n.appendChild(o),i[r]={direction:r,pathNode:l,interactionNode:o,groupNode:n},o.addEventListener("pointerdown",this._handlePointerDown.bind(this,r))}return i}_createGuides(){let i=q("svg"),e=q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"#000000","stroke-width":ye,"stroke-opacity":.5});i.appendChild(e);for(let t=1;t<=2;t++){let r=q("line",{x1:`${Ye*t}%`,y1:"0%",x2:`${Ye*t}%`,y2:"100%",stroke:"#000000","stroke-width":ye,"stroke-opacity":.3});i.appendChild(r)}for(let t=1;t<=2;t++){let r=q("line",{x1:"0%",y1:`${Ye*t}%`,x2:"100%",y2:`${Ye*t}%`,stroke:"#000000","stroke-width":ye,"stroke-opacity":.3});i.appendChild(r)}return i.classList.add("guides","guides--semi-hidden"),i}_createFrame(){let i=this.ref["svg-el"],e=document.createDocumentFragment(),t=this._createGuides();e.appendChild(t);let r=this._createThumbs();for(let{groupNode:n}of Object.values(r))e.appendChild(n);i.appendChild(e),this._frameThumbs=r,this._frameGuides=t}_handlePointerDown(i,e){if(!this._frameThumbs)return;let t=this._frameThumbs[i];if(this._shouldThumbBeDisabled(i))return;let r=this.$["*cropBox"],{x:n,y:o}=this.ref["svg-el"].getBoundingClientRect(),l=e.x-n,a=e.y-o;this.$.dragging=!0,this._draggingThumb=t,this._dragStartPoint=[l,a],this._dragStartCrop={...r}}_handlePointerUp_(i){this._updateCursor(),this.$.dragging&&(i.stopPropagation(),i.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(i){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;i.stopPropagation(),i.preventDefault();let e=this.ref["svg-el"],{x:t,y:r}=e.getBoundingClientRect(),n=i.x-t,o=i.y-r,l=n-this._dragStartPoint[0],a=o-this._dragStartPoint[1],{direction:c}=this._draggingThumb;const h=this._calcCropBox(c,[l,a]);h&&(this.$["*cropBox"]=h)}_calcCropBox(i,e){var c;const[t,r]=e;let n=this.$["*imageBox"],o=this._dragStartCrop??this.$["*cropBox"];const l=(c=this.$["*cropPresetList"])==null?void 0:c[0],a=l?l.width/l.height:void 0;if(i===""?o=Hn({rect:o,delta:[t,r],imageBox:n}):o=Qn({rect:o,delta:[t,r],direction:i,aspectRatio:a,imageBox:n}),!Object.values(o).every(h=>Number.isFinite(h)&&h>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:o});return}return ot(it(o),this.$["*imageBox"])}_handleSvgPointerMove_(i){if(!this._frameThumbs)return;let e=Object.values(this._frameThumbs).find(t=>{if(this._shouldThumbBeDisabled(t.direction))return!1;let n=t.interactionNode.getBoundingClientRect(),o={x:n.x,y:n.y,width:n.width,height:n.height};return eo(o,[i.x,i.y])});this._hoverThumb=e,this._updateCursor()}_updateCursor(){let i=this._hoverThumb;this.ref["svg-el"].style.cursor=i?jn(i.direction):"initial"}_render(){this._updateBackdrop(),this._updateFrame()}toggleThumbs(i){this._frameThumbs&&Object.values(this._frameThumbs).map(({groupNode:e})=>e).forEach(e=>{e.setAttribute("class",X("thumb",{"thumb--hidden":!i,"thumb--visible":i}))})}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",()=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",i=>{i&&(this._guidesHidden=i.height<=v||i.width<=v,window.requestAnimationFrame(()=>{this._render()}))}),this.sub("dragging",i=>{this._frameGuides&&this._frameGuides.setAttribute("class",X({"guides--hidden":this._guidesHidden,"guides--visible":!this._guidesHidden&&i,"guides--semi-hidden":!this._guidesHidden&&!i}))}),this.ref["svg-el"].addEventListener("pointermove",this._handleSvgPointerMove,!0),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}destroyCallback(){super.destroyCallback(),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}}Gs.template=' <svg class="svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg> ';class vt extends be{constructor(){super(...arguments);u(this,"init$",{...this.init$,active:!1,title:"",icon:"","on.click":null})}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this._iconEl=this.ref["icon-el"],this.setAttribute("role","button"),this.tabIndex===-1&&(this.tabIndex=0),this.sub("title",e=>{this._titleEl&&(this._titleEl.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=X({active:e,not_active:!e})}),this.sub("on.click",e=>{this.onclick=e})}}vt.template=`
|
|
267
|
-
<div class="before"></div>
|
|
268
|
-
<lr-icon size="20" set="@name: icon;"></lr-icon>
|
|
269
|
-
<div class="title" ref="title-el">{{title}}</div>
|
|
270
|
-
`;function Ul(s){let i=s+90;return i=i>=360?0:i,i}function Rl(s,i){return s==="rotate"?Ul(i):["mirror","flip"].includes(s)?!i:null}class Xs extends vt{initCallback(){super.initCallback(),this.defineAccessor("operation",i=>{i&&(this._operation=i,this.$.icon=i)}),this.$["on.click"]=i=>{let e=this.$["*cropperEl"].getValue(this._operation),t=Rl(this._operation,e);this.$["*cropperEl"].setValue(this._operation,t)}}}const Ve={FILTER:"filter",COLOR_OPERATION:"color_operation"},de="original";class Ks extends be{constructor(){super(...arguments);u(this,"init$",{...this.init$,disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0,"on.input":e=>{this.$["*faderEl"].set(e),this.$.value=e}})}setOperation(e,t){this._controlType=e==="filter"?Ve.FILTER:Ve.COLOR_OPERATION,this._operation=e,this._iconName=e,this._title=e.toUpperCase(),this._filter=t,this._initializeValues(),this.$["*faderEl"].activate({url:this.$["*originalUrl"],operation:this._operation,value:this._filter===de?void 0:this.$.value,filter:this._filter===de?void 0:this._filter,fromViewer:!1})}_initializeValues(){let{range:e,zero:t}=Le[this._operation],[r,n]=e;this.$.min=r,this.$.max=n,this.$.zero=t;let o=this.$["*editorTransformations"][this._operation];if(this._controlType===Ve.FILTER){let l=n;if(o){let{name:a,amount:c}=o;l=a===this._filter?c:n}this.$.value=l,this.$.defaultValue=l}if(this._controlType===Ve.COLOR_OPERATION){let l=typeof o<"u"?o:t;this.$.value=l,this.$.defaultValue=l}}apply(){let e;this._controlType===Ve.FILTER?this._filter===de?e=null:e={name:this._filter,amount:this.$.value}:e=this.$.value;let t={...this.$["*editorTransformations"],[this._operation]:e};this.$["*editorTransformations"]=t}cancel(){this.$["*faderEl"].deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{this._originalUrl=e}),this.sub("value",e=>{let t=`${this._filter||this._operation} ${e}`;this.$["*operationTooltip"]=t})}}Ks.template=`
|
|
271
|
-
<lr-slider-ui
|
|
272
|
-
ref="slider-el"
|
|
273
|
-
set="disabled: disabled; min: min; max: max; defaultValue: defaultValue; zero: zero; onInput: on.input;"
|
|
274
|
-
></lr-slider-ui>
|
|
275
|
-
`;function ti(s){let i=new Image;return{promise:new Promise((r,n)=>{i.src=s,i.onload=r,i.onerror=n}),image:i,cancel:()=>{i.naturalWidth===0&&(i.src=pe)}}}function Ft(s){let i=[];for(let n of s){let o=ti(n);i.push(o)}let e=i.map(n=>n.image);return{promise:Promise.allSettled(i.map(n=>n.promise)),images:e,cancel:()=>{i.forEach(n=>{n.cancel()})}}}class ii extends vt{constructor(){super(...arguments);u(this,"init$",{...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null})}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=window.devicePixelRatio,r=Math.ceil(t*e),n=t>=2?"lightest":"normal",o=100,l={...this.$["*editorTransformations"]};return l[this._operation]=this._filter!==de?{name:this._filter,amount:o}:void 0,V(this._originalUrl,le(Es,_t(l),`quality/${n}`,`scale_crop/${r}x${r}/center`))}_observerCallback(e,t){if(e[0].isIntersecting){let n=this.proxyUrl(this._previewSrc()),o=this.ref["preview-el"],{promise:l,cancel:a}=ti(n);this._cancelPreload=a,l.catch(c=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:c})}).finally(()=>{o.style.backgroundImage=`url(${n})`,o.setAttribute("loaded",""),t.unobserve(this)})}else this._cancelPreload&&this._cancelPreload()}initCallback(){super.initCallback(),this.$["on.click"]=t=>{this.$.active?this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0):(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*sliderEl"].apply()),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",t=>{this._operation="filter",this._filter=t,this.$.isOriginal=t===de,this.$.icon=this.$.isOriginal?"original":"slider"}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let e=this.$["*originalUrl"];this._originalUrl=e,this.$.isOriginal?this.ref["icon-el"].classList.add("original-icon"):this._observer.observe(this),this.sub("*currentFilter",t=>{this.$.active=t&&t===this._filter}),this.sub("isOriginal",t=>{this.$.iconSize=t?40:20}),this.sub("active",t=>{if(this.$.isOriginal)return;let r=this.ref["icon-el"];r.style.opacity=t?"1":"0";let n=this.ref["preview-el"];t?n.style.opacity="0":n.style.backgroundImage&&(n.style.opacity="1")}),this.sub("*networkProblems",t=>{if(!t){let r=this.proxyUrl(this._previewSrc()),n=this.ref["preview-el"];n.style.backgroundImage&&(n.style.backgroundImage="none",n.style.backgroundImage=`url(${r})`)}})}destroyCallback(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect(),this._cancelPreload&&this._cancelPreload()}}ii.template=`
|
|
276
|
-
<div class="before"></div>
|
|
277
|
-
<div class="preview" ref="preview-el"></div>
|
|
278
|
-
<lr-icon size="40" ref="icon-el" set="@name: icon; @size: iconSize;"></lr-icon>
|
|
279
|
-
`;class Ys extends vt{constructor(){super(...arguments);u(this,"_operation","")}initCallback(){super.initCallback(),this.$["on.click"]=e=>{this.$["*sliderEl"].setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation},this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.$.title=this.l10n(e))}),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=Le[this._operation],r=e[this._operation],n=typeof r<"u"?r!==t:!1;this.$.active=n})}}function Ml(s,i){let e={};for(let t of i){let r=s[t];(s.hasOwnProperty(t)||r!==void 0)&&(e[t]=r)}return e}function si(s,i,e){let r=window.devicePixelRatio,n=Math.min(Math.ceil(i*r),3e3),o=r>=2?"lightest":"normal";return V(s,le(Es,_t(e),`quality/${o}`,`stretch/off/-/resize/${n}x`))}function Fl(s){return s?[({dimensions:e,coords:t})=>[...e,...t].every(r=>Number.isInteger(r)&&Number.isFinite(r)),({dimensions:e,coords:t})=>e.every(r=>r>0)&&t.every(r=>r>=0)].every(e=>e(s)):!0}class Js extends be{constructor(){super(),this.init$={...this.init$,image:null,"*padding":Dn,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=H(this._commit.bind(this),300),this._handleResizeThrottled=Fs(this._handleResize.bind(this),100),this._imageSize={width:0,height:0}}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let i=this.$["*editorTransformations"],e=Ml(i,Object.keys(this.$["*operations"])),t={...this.$["*operations"],...e};this.$["*operations"]=t}_initCanvas(){let i=this.ref["canvas-el"],e=i.getContext("2d"),t=this.offsetWidth,r=this.offsetHeight,n=window.devicePixelRatio;i.style.width=`${t}px`,i.style.height=`${r}px`,i.width=t*n,i.height=r*n,e==null||e.scale(n,n),this._canvas=i,this._ctx=e}_alignImage(){if(!this._isActive||!this.$.image)return;let i=this.$.image,e=this.$["*padding"],t=this.$["*operations"],{rotate:r}=t,n={width:this.offsetWidth,height:this.offsetHeight},o=De({width:i.naturalWidth,height:i.naturalHeight},r),l;if(o.width>n.width-e*2||o.height>n.height-e*2){let a=o.width/o.height,c=n.width/n.height;if(a>c){let h=n.width-e*2,d=h/a,f=0+e,m=e+(n.height-e*2)/2-d/2;l={x:f,y:m,width:h,height:d}}else{let h=n.height-e*2,d=h*a,f=e+(n.width-e*2)/2-d/2,m=0+e;l={x:f,y:m,width:d,height:h}}}else{let{width:a,height:c}=o,h=e+(n.width-e*2)/2-a/2,d=e+(n.height-e*2)/2-c/2;l={x:h,y:d,width:a,height:c}}this.$["*imageBox"]=it(l)}_alignCrop(){var d;let i=this.$["*cropBox"],e=this.$["*imageBox"],t=this.$["*operations"],{rotate:r}=t,n=this.$["*editorTransformations"].crop,{width:o,x:l,y:a}=this.$["*imageBox"];if(n){let{dimensions:[f,m],coords:[p,g]}=n,{width:A}=De(this._imageSize,r),w=o/A;i=ot(it({x:l+p*w,y:a+g*w,width:f*w,height:m*w}),this.$["*imageBox"])}const c=(d=this.$["*cropPresetList"])==null?void 0:d[0],h=c?c.width/c.height:void 0;if(!to(i,e)||h&&!io(i,h)){const f=e.width/e.height;let m=e.width,p=e.height;h&&(f>h?m=Math.min(e.height*h,e.width):p=Math.min(e.width/h,e.height)),i={x:e.x+e.width/2-m/2,y:e.y+e.height/2-p/2,width:m,height:p}}this.$["*cropBox"]=ot(it(i),this.$["*imageBox"])}_drawImage(){let i=this._ctx;if(!i)return;let e=this.$.image,t=this.$["*imageBox"],r=this.$["*operations"],{mirror:n,flip:o,rotate:l}=r,a=De({width:t.width,height:t.height},l);i.save(),i.translate(t.x+t.width/2,t.y+t.height/2),i.rotate(l*Math.PI*-1/180),i.scale(n?-1:1,o?-1:1),i.drawImage(e,-a.width/2,-a.height/2,a.width,a.height),i.restore()}_draw(){if(!this._isActive||!this.$.image||!this._canvas||!this._ctx)return;let i=this._canvas;this._ctx.clearRect(0,0,i.width,i.height),this._drawImage()}_animateIn({fromViewer:i}){this.$.image&&(this.ref["frame-el"].toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=X({active_from_viewer:i,active_from_editor:!i,inactive_to_editor:!1})}))}_getCropDimensions(){let i=this.$["*cropBox"],e=this.$["*imageBox"],t=this.$["*operations"],{rotate:r}=t,{width:n,height:o}=e,{width:l,height:a}=De(this._imageSize,r),{width:c,height:h}=i,d=n/l,f=o/a;return[ke(Math.round(c/d),1,l),ke(Math.round(h/f),1,a)]}_getCropTransformation(){let i=this.$["*cropBox"],e=this.$["*imageBox"],t=this.$["*operations"],{rotate:r}=t,{width:n,height:o,x:l,y:a}=e,{width:c,height:h}=De(this._imageSize,r),{x:d,y:f}=i,m=n/c,p=o/h,g=this._getCropDimensions(),A={dimensions:g,coords:[ke(Math.round((d-l)/m),0,c-g[0]),ke(Math.round((f-a)/p),0,h-g[1])]};if(!Fl(A)){console.error("Cropper is trying to create invalid crop object",{payload:A});return}if(!(g[0]===c&&g[1]===h))return A}_commit(){if(!this.isConnected)return;let i=this.$["*operations"],{rotate:e,mirror:t,flip:r}=i,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:e,mirror:t,flip:r};this.$["*editorTransformations"]=l}setValue(i,e){this.$["*operations"]={...this.$["*operations"],[i]:e},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(i){return this.$["*operations"][i]}async activate(i,{fromViewer:e}={}){if(!this._isActive){this._isActive=!0,this._imageSize=i,this.removeEventListener("transitionend",this._reset);try{this.$.image=await this._waitForImage(this.$["*originalUrl"],this.$["*editorTransformations"]),this._syncTransformations(),this._animateIn({fromViewer:e})}catch(t){console.error("Failed to activate cropper",{error:t})}this._observer=new ResizeObserver(([t])=>{t.contentRect.width>0&&t.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:i=!1}={}){var e;this._isActive&&(!i&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=X({active_from_viewer:!1,active_from_editor:!1,inactive_to_editor:!0}),this.ref["frame-el"].toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),(e=this._observer)==null||e.disconnect())}_transitionToCrop(){let i=this._getCropDimensions(),e=Math.min(this.offsetWidth,i[0])/this.$["*cropBox"].width,t=Math.min(this.offsetHeight,i[1])/this.$["*cropBox"].height,r=Math.min(e,t),n=this.$["*cropBox"].x+this.$["*cropBox"].width/2,o=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform=`scale(${r}) translate(${(this.offsetWidth/2-n)/r}px, ${(this.offsetHeight/2-o)/r}px)`,this.style.transformOrigin=`${n}px ${o}px`}_transitionToImage(){let i=this.$["*cropBox"].x+this.$["*cropBox"].width/2,e=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${i}px ${e}px`}_reset(){this._isActive||(this.$.image=null)}_waitForImage(i,e){let t=this.offsetWidth;e={...e,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let r=this.proxyUrl(si(i,t,e)),{promise:n,cancel:o,image:l}=ti(r),a=this._handleImageLoading(r);return l.addEventListener("load",a,{once:!0}),l.addEventListener("error",a,{once:!0}),this._cancelPreload&&this._cancelPreload(),this._cancelPreload=o,n.then(()=>l).catch(c=>(console.error("Failed to load image",{error:c}),this.$["*networkProblems"]=!0,Promise.resolve(l)))}_handleImageLoading(i){let e="crop",t=this.$["*loadingOperations"];return t.get(e)||t.set(e,new Map),t.get(e).get(i)||(t.set(e,t.get(e).set(i,!0)),this.$["*loadingOperations"]=t),()=>{var r;(r=t==null?void 0:t.get(e))!=null&&r.has(i)&&(t.get(e).delete(i),this.$["*loadingOperations"]=t)}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw()}),this.sub("*cropBox",()=>{this.$.image&&this._commitDebounced()}),this.sub("*cropPresetList",()=>{this._alignCrop()}),setTimeout(()=>{this.sub("*networkProblems",i=>{i||this._isActive&&this.activate(this._imageSize,{fromViewer:!1})})},0)}destroyCallback(){var i;super.destroyCallback(),(i=this._observer)==null||i.disconnect()}}Js.template=`
|
|
280
|
-
<canvas class="canvas" ref="canvas-el"></canvas>
|
|
281
|
-
<lr-crop-frame ref="frame-el"></lr-crop-frame>
|
|
282
|
-
`;function Di(s,i,e){let t=Array(e);e--;for(let r=e;r>=0;r--)t[r]=Math.ceil((r*i+(e-r)*s)/e);return t}function Nl(s){return s.reduce((i,e,t)=>t<s.length-1?[...i,[e,s[t+1]]]:i,[])}function Dl(s,i,e){let t=Nl(s).find(([r,n])=>r<=i&&i<=n);return s.map(r=>{let n=Math.abs(t[0]-t[1]),o=Math.abs(i-t[0])/n;return t[0]===r?i>e?1:1-o:t[1]===r?i>=e?o:1:0})}function zl(s,i){return s.map((e,t)=>e<i?s.length-t:t)}function zi(s,i){let e=Le[s].keypointsNumber,{range:t,zero:r}=Le[s];return[...new Set([...Di(t[0],r,e+1),...Di(r,t[1],e+1),r,i])].sort((n,o)=>n-o)}class Vl extends be{constructor(){super(),this._isActive=!1,this._hidden=!0,this._addKeypointDebounced=H(this._addKeypoint.bind(this),600),this.classList.add("inactive_to_cropper")}_handleImageLoading(i){let e=this._operation,t=this.$["*loadingOperations"];return t.get(e)||t.set(e,new Map),t.get(e).get(i)||(t.set(e,t.get(e).set(i,!0)),this.$["*loadingOperations"]=t),()=>{var r;(r=t==null?void 0:t.get(e))!=null&&r.has(i)&&(t.get(e).delete(i),this.$["*loadingOperations"]=t)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let i of this._keypoints){let{image:e}=i;e&&(e.style.opacity=i.opacity.toString(),e.style.zIndex=i.zIndex.toString())}})}_imageSrc({url:i=this._url,filter:e=this._filter,operation:t,value:r}={}){let n={...this._transformations};t&&(n[t]=e?{name:e,amount:r}:r);let o=this.offsetWidth;return this.proxyUrl(si(i,o,n))}_constructKeypoint(i,e){return{src:this._imageSrc({operation:i,value:e}),image:null,opacity:0,zIndex:0,value:e}}_isSame(i,e){return this._operation===i&&this._filter===e}_addKeypoint(i,e,t){let r=()=>!this._isSame(i,e)||this._value!==t||!!this._keypoints.find(a=>a.value===t);if(r())return;let n=this._constructKeypoint(i,t),o=new Image;o.src=n.src;let l=this._handleImageLoading(n.src);o.addEventListener("load",l,{once:!0}),o.addEventListener("error",l,{once:!0}),n.image=o,o.classList.add("fader-image"),o.addEventListener("load",()=>{if(r())return;let a=this._keypoints,c=a.findIndex(d=>d.value>t),h=c<a.length?a[c].image:null;!this._container||h&&!this._container.contains(h)||(a.splice(c,0,n),this._container.insertBefore(o,h),this._update(i,t))},{once:!0}),o.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(i){i=typeof i=="string"?parseInt(i,10):i,this._update(this._operation,i),this._addKeypointDebounced(this._operation,this._filter,i)}_update(i,e){this._operation=i,this._value=e;let{zero:t}=Le[i],r=this._keypoints.map(l=>l.value),n=Dl(r,e,t),o=zl(r,t);for(let[l,a]of Object.entries(this._keypoints))a.opacity=n[l],a.zIndex=o[l];this._flush()}_createPreviewImage(){let i=new Image;return i.classList.add("fader-image","fader-image--preview"),i.style.opacity="0",i}async _initNodes(){let i=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage(),!this.contains(this._previewImage)&&i.appendChild(this._previewImage);let e=document.createElement("div");i.appendChild(e);let t=this._keypoints.map(c=>c.src),{images:r,promise:n,cancel:o}=Ft(t);r.forEach(c=>{let h=this._handleImageLoading(c.src);c.addEventListener("load",h),c.addEventListener("error",h)}),this._cancelLastImages=()=>{o(),this._cancelLastImages=void 0};let l=this._operation,a=this._filter;await n,this._isActive&&this._isSame(l,a)&&(this._container&&this._container.remove(),this._container=e,this._keypoints.forEach((c,h)=>{let d=r[h];d.classList.add("fader-image"),c.image=d,this._container.appendChild(d)}),this.appendChild(i),this._flush())}setTransformations(i){if(this._transformations=i,this._previewImage){let e=this._imageSrc(),t=this._handleImageLoading(e);this._previewImage.src=e,this._previewImage.addEventListener("load",t,{once:!0}),this._previewImage.addEventListener("error",t,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}preload({url:i,filter:e,operation:t,value:r}){this._cancelBatchPreload&&this._cancelBatchPreload();let o=zi(t,r).map(a=>this._imageSrc({url:i,filter:e,operation:t,value:a})),{cancel:l}=Ft(o);this._cancelBatchPreload=l}_setOriginalSrc(i){let e=this._previewImage||this._createPreviewImage();if(!this.contains(e)&&this.appendChild(e),this._previewImage=e,e.src===i){e.style.opacity="1",e.style.transform="scale(1)",this.className=X({active_from_viewer:this._fromViewer,active_from_cropper:!this._fromViewer,inactive_to_cropper:!1});return}e.style.opacity="0";let t=this._handleImageLoading(i);e.addEventListener("error",t,{once:!0}),e.src=i,e.addEventListener("load",()=>{t(),e&&(e.style.opacity="1",e.style.transform="scale(1)",this.className=X({active_from_viewer:this._fromViewer,active_from_cropper:!this._fromViewer,inactive_to_cropper:!1}))},{once:!0}),e.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}activate({url:i,operation:e,value:t,filter:r,fromViewer:n}){if(this._isActive=!0,this._hidden=!1,this._url=i,this._operation=e||"initial",this._value=t,this._filter=r,this._fromViewer=n,typeof t!="number"&&!r){let l=this._imageSrc({operation:e,value:t});this._setOriginalSrc(l),this._container&&this._container.remove();return}this._keypoints=zi(e,t).map(l=>this._constructKeypoint(e,l)),this._update(e,t),this._initNodes()}deactivate({hide:i=!0}={}){this._isActive=!1,this._cancelLastImages&&this._cancelLastImages(),this._cancelBatchPreload&&this._cancelBatchPreload(),i&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=X({active_from_viewer:!1,active_from_cropper:!1,inactive_to_cropper:!0}),this.addEventListener("transitionend",()=>{this._container&&this._container.remove()},{once:!0})):this._container&&this._container.remove()}}const Bl=1;class Zs extends be{initCallback(){super.initCallback(),this.addEventListener("wheel",i=>{i.preventDefault();let{deltaY:e,deltaX:t}=i;Math.abs(t)>Bl?this.scrollLeft+=t:this.scrollLeft+=e})}}Zs.template=" <slot></slot> ";function jl(s){return`
|
|
283
|
-
<lr-presence-toggle class="tab-toggle" set="visible: presence.tabToggle.${s}; styles: presence.tabToggleStyles;">
|
|
284
|
-
<lr-btn-ui
|
|
285
|
-
theme="boring"
|
|
286
|
-
ref="tab-toggle-${s}"
|
|
287
|
-
data-id="${s}"
|
|
288
|
-
icon="${s}"
|
|
289
|
-
tabindex="0"
|
|
290
|
-
set="onclick: on.clickTab;"
|
|
291
|
-
>
|
|
292
|
-
</lr-btn-ui>
|
|
293
|
-
</lr-presence-toggle>
|
|
294
|
-
`}function Hl(s){return`
|
|
295
|
-
<lr-presence-toggle class="tab-content" set="visible: presence.tabContent.${s}; styles: presence.tabContentStyles">
|
|
296
|
-
<lr-editor-scroller hidden-scrollbar>
|
|
297
|
-
<div class="controls-list_align">
|
|
298
|
-
<div class="controls-list_inner" ref="controls-list-${s}"></div>
|
|
299
|
-
</div>
|
|
300
|
-
</lr-editor-scroller>
|
|
301
|
-
</lr-presence-toggle>
|
|
302
|
-
`}class Qs extends be{constructor(){super();u(this,"_updateInfoTooltip",H(()=>{var o,l;const e=this.$["*editorTransformations"],t=this.$["*currentOperation"];let r="",n=!1;if(this.$["*tabId"]===L.FILTERS)if(n=!0,this.$["*currentFilter"]&&((o=e==null?void 0:e.filter)==null?void 0:o.name)===this.$["*currentFilter"]){let a=((l=e==null?void 0:e.filter)==null?void 0:l.amount)||100;r=this.l10n(this.$["*currentFilter"])+" "+a}else r=this.l10n(de);else if(this.$["*tabId"]===L.TUNING&&t){n=!0;let a=(e==null?void 0:e[t])||Le[t].zero;r=t+" "+a}n&&(this.$["*operationTooltip"]=r),this.ref["tooltip-el"].classList.toggle("info-tooltip_visible",n)},0));this.init$={...this.init$,"*sliderEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*currentFilter":de,"*currentOperation":null,showLoader:!1,filters:So,colorOperations:$o,cropOperations:xo,"*operationTooltip":null,"l10n.cancel":this.l10n("cancel"),"l10n.apply":this.l10n("apply"),"presence.mainToolbar":!0,"presence.subToolbar":!1,"presence.tabToggles":!0,"presence.tabContent.crop":!1,"presence.tabContent.tuning":!1,"presence.tabContent.filters":!1,"presence.tabToggle.crop":!0,"presence.tabToggle.tuning":!0,"presence.tabToggle.filters":!0,"presence.subTopToolbarStyles":{hidden:"sub-toolbar--top-hidden",visible:"sub-toolbar--visible"},"presence.subBottomToolbarStyles":{hidden:"sub-toolbar--bottom-hidden",visible:"sub-toolbar--visible"},"presence.tabContentStyles":{hidden:"tab-content--hidden",visible:"tab-content--visible"},"presence.tabToggleStyles":{hidden:"tab-toggle--hidden",visible:"tab-toggle--visible"},"presence.tabTogglesStyles":{hidden:"tab-toggles--hidden",visible:"tab-toggles--visible"},"on.cancel":()=>{this._cancelPreload&&this._cancelPreload(),this.$["*on.cancel"]()},"on.apply":()=>{this.$["*on.apply"](this.$["*editorTransformations"])},"on.applySlider":()=>{this.ref["slider-el"].apply(),this._onSliderClose()},"on.cancelSlider":()=>{this.ref["slider-el"].cancel(),this._onSliderClose()},"on.clickTab":e=>{const t=e.currentTarget.getAttribute("data-id");t&&this._activateTab(t,{fromViewer:!1})}},this._debouncedShowLoader=H(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===L.TUNING&&this.ref["tooltip-el"].classList.toggle("info-tooltip_visible",!1)}_createOperationControl(e){let t=new Ys;return t.operation=e,t}_createFilterControl(e){let t=new ii;return t.filter=e,t}_createToggleControl(e){let t=new Xs;return t.operation=e,t}_renderControlsList(e){let t=this.ref[`controls-list-${e}`],r=document.createDocumentFragment();e===L.CROP?this.$.cropOperations.forEach(n=>{let o=this._createToggleControl(n);r.appendChild(o)}):e===L.FILTERS?[de,...this.$.filters].forEach(n=>{let o=this._createFilterControl(n);r.appendChild(o)}):e===L.TUNING&&this.$.colorOperations.forEach(n=>{let o=this._createOperationControl(n);r.appendChild(o)}),[...r.children].forEach((n,o)=>{o===r.childNodes.length-1&&n.classList.add("controls-list_last-item")}),t.innerHTML="",t.appendChild(r)}_activateTab(e,{fromViewer:t}){this.$["*tabId"]=e,e===L.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:t})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:t}),this.$["*cropperEl"].deactivate());for(let r of ee){let n=r===e,o=this.ref[`tab-toggle-${r}`];o.active=n,n?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(r),this.$[`presence.tabContent.${r}`]=n}}_unmountTabControls(e){let t=this.ref[`controls-list-${e}`];t&&(t.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],t=this.ref["tabs-indicator"];t.style.transform=`translateX(${e.offsetLeft}px)`}_preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=this.proxyUrl(si(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload&&this._cancelPreload();let{cancel:r}=Ft([t]);this._cancelPreload=()=>{r(),this._cancelPreload=void 0}}}_showLoader(e){this.$.showLoader=e}initCallback(){super.initCallback(),this.$["*sliderEl"]=this.ref["slider-el"],this.sub("*imageSize",e=>{e&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",e=>{var r;let t=(r=e==null?void 0:e.filter)==null?void 0:r.name;this.$["*currentFilter"]!==t&&(this.$["*currentFilter"]=t)}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",()=>{this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]&&this.$["*faderEl"].deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]&&this.$["*faderEl"].setTransformations(e)}),this.sub("*loadingOperations",e=>{let t=!1;for(let[,r]of e.entries()){if(t)break;for(let[,n]of r.entries())if(n){t=!0;break}}this._debouncedShowLoader(t)}),this.sub("*showSlider",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e}),this.sub("*tabList",e=>{this.$["presence.tabToggles"]=e.length>1;for(const t of ee){this.$[`presence.tabToggle.${t}`]=e.includes(t);const r=this.ref[`tab-toggle-${t}`];r.style.gridColumn=e.indexOf(t)+1}e.includes(this.$["*tabId"])||this._activateTab(e[0],{fromViewer:!1})}),this._updateInfoTooltip()}}Qs.template=`
|
|
303
|
-
<lr-line-loader-ui set="active: showLoader"></lr-line-loader-ui>
|
|
304
|
-
<div class="info-tooltip_container">
|
|
305
|
-
<div class="info-tooltip_wrapper">
|
|
306
|
-
<div ref="tooltip-el" class="info-tooltip info-tooltip_hidden">{{*operationTooltip}}</div>
|
|
307
|
-
</div>
|
|
308
|
-
</div>
|
|
309
|
-
<div class="toolbar-container">
|
|
310
|
-
<lr-presence-toggle class="sub-toolbar" set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles">
|
|
311
|
-
<div class="tab-content-row">${ee.map(Hl).join("")}</div>
|
|
312
|
-
<div class="controls-row">
|
|
313
|
-
<lr-btn-ui theme="boring" icon="closeMax" set="onclick: on.cancel"> </lr-btn-ui>
|
|
314
|
-
<lr-presence-toggle class="tab-toggles" set="visible: presence.tabToggles; styles: presence.tabTogglesStyles">
|
|
315
|
-
<div ref="tabs-indicator" class="tab-toggles_indicator"></div>
|
|
316
|
-
${ee.map(jl).join("")}
|
|
317
|
-
</lr-presence-toggle>
|
|
318
|
-
<lr-btn-ui theme="primary" icon="done" set="onclick: on.apply"> </lr-btn-ui>
|
|
319
|
-
</div>
|
|
320
|
-
</lr-presence-toggle>
|
|
321
|
-
<lr-presence-toggle class="sub-toolbar" set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles">
|
|
322
|
-
<div class="slider">
|
|
323
|
-
<lr-editor-slider ref="slider-el"></lr-editor-slider>
|
|
324
|
-
</div>
|
|
325
|
-
<div class="controls-row">
|
|
326
|
-
<lr-btn-ui theme="boring" set="@text: l10n.cancel; onclick: on.cancelSlider;"> </lr-btn-ui>
|
|
327
|
-
<lr-btn-ui theme="primary" set="@text: l10n.apply; onclick: on.applySlider;"> </lr-btn-ui>
|
|
328
|
-
</div>
|
|
329
|
-
</lr-presence-toggle>
|
|
330
|
-
</div>
|
|
331
|
-
`;class ri extends k{constructor(){super(),this._iconReversed=!1,this._iconSingle=!1,this._iconHidden=!1,this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null},this.defineAccessor("active",i=>{i?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return X("icon",{icon_left:!this._iconReversed,icon_right:this._iconReversed,icon_hidden:this._iconHidden,icon_single:this._iconSingle})}initCallback(){super.initCallback(),this.sub("icon",i=>{this._iconSingle=!this.$.text,this._iconHidden=!i,this.$.iconCss=this._iconCss()}),this.sub("theme",i=>{i!=="custom"&&(this.className=i)}),this.sub("text",i=>{this._iconSingle=!1}),this.setAttribute("role","button"),this.tabIndex===-1&&(this.tabIndex=0),this.hasAttribute("theme")||this.setAttribute("theme","default")}set reverse(i){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection=null)}}ri.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});ri.template=`
|
|
332
|
-
<lr-icon size="20" set="className: iconCss; @name: icon;"></lr-icon>
|
|
333
|
-
<div class="text">{{text}}</div>
|
|
334
|
-
`;class er extends k{constructor(){super(),this._active=!1,this._handleTransitionEndRight=()=>{let i=this.ref["line-el"];i.style.transition="initial",i.style.opacity="0",i.style.transform="translateX(-101%)",this._active&&this._start()}}initCallback(){super.initCallback(),this.defineAccessor("active",i=>{typeof i=="boolean"&&(i?this._start():this._stop())})}_start(){this._active=!0;let{width:i}=this.getBoundingClientRect(),e=this.ref["line-el"];e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${i}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}}er.template=`
|
|
335
|
-
<div class="inner">
|
|
336
|
-
<div class="line" ref="line-el"></div>
|
|
337
|
-
</div>
|
|
338
|
-
`;const et={transition:"transition",visible:"visible",hidden:"hidden"};class tr extends k{constructor(){super(),this._visible=!1,this._visibleStyle=et.visible,this._hiddenStyle=et.hidden,this._externalTransitions=!1,this.defineAccessor("styles",i=>{i&&(this._externalTransitions=!0,this._visibleStyle=i.visible,this._hiddenStyle=i.hidden)}),this.defineAccessor("visible",i=>{typeof i=="boolean"&&(this._visible=i,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",kl(this,{[et.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.setAttribute("aria-hidden",this._visible?"false":"true")}initCallback(){super.initCallback(),this.setAttribute("hidden",""),this._externalTransitions||this.classList.add(et.transition),this._handleVisible(),setTimeout(()=>this.removeAttribute("hidden"),0)}}tr.template=" <slot></slot> ";class ir extends k{constructor(){super();u(this,"init$",{...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:null,"on.sliderInput":()=>{let e=parseInt(this.ref["input-el"].value,10);this._updateValue(e),this.$.onInput&&this.$.onInput(e)},"on.sliderChange":()=>{let e=parseInt(this.ref["input-el"].value,10);this.$.onChange&&this.$.onChange(e)}});this.setAttribute("with-effects","")}initCallback(){super.initCallback(),this.defineAccessor("disabled",t=>{this.$.disabled=t}),this.defineAccessor("min",t=>{this.$.min=t}),this.defineAccessor("max",t=>{this.$.max=t}),this.defineAccessor("defaultValue",t=>{this.$.defaultValue=t,this.ref["input-el"].value=t,this._updateValue(t)}),this.defineAccessor("zero",t=>{this._zero=t}),this.defineAccessor("onInput",t=>{t&&(this.$.onInput=t)}),this.defineAccessor("onChange",t=>{t&&(this.$.onChange=t)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let t=parseInt(this.ref["input-el"].value,10);this._updateValue(t)}),this._observer.observe(this),this._thumbSize=parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let t=parseInt(this.ref["input-el"].value,10);this._updateValue(t)},0),this.sub("disabled",t=>{let r=this.ref["input-el"];t?r.setAttribute("disabled","disabled"):r.removeAttribute("disabled")});let e=this.ref["input-el"];e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_updateValue(e){this._updateZeroDot(e);let{width:t}=this.getBoundingClientRect(),o=100/(this.$.max-this.$.min)*(e-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this.ref["thumb-el"].style.transform=`translateX(${o}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;e===this._zero?this._zeroDotEl.style.opacity="0":this._zeroDotEl.style.opacity="0.2";let{width:t}=this.getBoundingClientRect(),o=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl.style.transform=`translateX(${o}px)`})}_updateSteps(){let t=this.ref["steps-el"],{width:r}=t.getBoundingClientRect(),n=Math.ceil(r/2),o=Math.ceil(n/15)-2;if(this._stepsCount===o)return;let l=document.createDocumentFragment(),a=document.createElement("div"),c=document.createElement("div");a.className="minor-step",c.className="border-step",l.appendChild(c);for(let d=0;d<o;d++)l.appendChild(a.cloneNode());l.appendChild(c.cloneNode());for(let d=0;d<o;d++)l.appendChild(a.cloneNode());l.appendChild(c.cloneNode());let h=document.createElement("div");h.className="zero-dot",l.appendChild(h),this._zeroDotEl=h,t.innerHTML="",t.appendChild(l),this._stepsCount=o}destroyCallback(){var e;(e=this._observer)==null||e.disconnect()}}ir.template=`
|
|
339
|
-
<div class="steps" ref="steps-el"></div>
|
|
340
|
-
<div ref="thumb-el" class="thumb"></div>
|
|
341
|
-
<input
|
|
342
|
-
class="input"
|
|
343
|
-
type="range"
|
|
344
|
-
ref="input-el"
|
|
345
|
-
tabindex="0"
|
|
346
|
-
set="oninput: on.sliderInput; onchange: on.sliderChange; @min: min; @max: max; @value: defaultValue;"
|
|
347
|
-
/>
|
|
348
|
-
`;class Wl extends ${constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",b.activities.CLOUD_IMG_EDIT);this.init$={...this.init$,cdnUrl:null}}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.mountEditor(),onDeactivate:()=>this.unmountEditor()}),this.sub("*focusedEntry",e=>{e&&(this.entry=e,this.entry.subscribe("cdnUrl",t=>{t&&(this.$.cdnUrl=t)}))}),this.subConfigValue("cropPreset",e=>{this._instance&&this._instance.getAttribute("crop-preset")!==e&&this._instance.setAttribute("crop-preset",e)}),this.subConfigValue("cloudImageEditorTabs",e=>{this._instance&&this._instance.getAttribute("tabs")!==e&&this._instance.setAttribute("tabs",e)})}handleApply(e){if(!this.entry)return;let t=e.detail;this.entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.historyBack()}handleCancel(){this.historyBack()}mountEditor(){const e=new Fe,t=this.$.cdnUrl,r=this.cfg.cropPreset,n=this.cfg.cloudImageEditorTabs;e.setAttribute("ctx-name",this.ctxName),e.setAttribute("cdn-url",t),r&&e.setAttribute("crop-preset",r),n&&e.setAttribute("tabs",n),e.addEventListener("apply",o=>{const l=o;this.handleApply(l),this.debugPrint('editor event "apply"',l.detail)}),e.addEventListener("cancel",o=>{const l=o;this.handleCancel(),this.debugPrint('editor event "cancel"',l.detail)}),e.addEventListener("change",o=>{const l=o;this.debugPrint('editor event "change"',l.detail)}),this.innerHTML="",this.appendChild(e),this._mounted=!0,this._instance=e}unmountEditor(){this._instance=void 0,this.innerHTML=""}}const ql=function(s){return s.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},Gl=function(s,i="i"){const e=s.split("*").map(ql);return new RegExp("^"+e.join(".+")+"$",i)};let Xl=s=>Object.keys(s).reduce((e,t)=>{let r=s[t],n=Object.keys(r).reduce((o,l)=>{let a=r[l];return o+`${l}: ${a};`},"");return e+`${t}{${n}}`},"");function Kl({textColor:s,backgroundColor:i,linkColor:e,linkColorHover:t,shadeColor:r}){let n=`solid 1px ${r}`;return Xl({body:{color:s,"background-color":i},".side-bar":{background:"inherit","border-right":n},".main-content":{background:"inherit"},".main-content-header":{background:"inherit"},".main-content-footer":{background:"inherit"},".list-table-row":{color:"inherit"},".list-table-row:hover":{background:r},".list-table-row .list-table-cell-a, .list-table-row .list-table-cell-b":{"border-top":n},".list-table-body .list-items":{"border-bottom":n},".bread-crumbs a":{color:e},".bread-crumbs a:hover":{color:t},".main-content.loading":{background:`${i} url(/static/images/loading_spinner.gif) center no-repeat`,"background-size":"25px 25px"},".list-icons-item":{"background-color":r},".source-gdrive .side-bar-menu a, .source-gphotos .side-bar-menu a":{color:e},".source-gdrive .side-bar-menu a, .source-gphotos .side-bar-menu a:hover":{color:t},".side-bar-menu a":{color:e},".side-bar-menu a:hover":{color:t},".source-gdrive .side-bar-menu .current, .source-gdrive .side-bar-menu a:hover, .source-gphotos .side-bar-menu .current, .source-gphotos .side-bar-menu a:hover":{color:t},".source-vk .side-bar-menu a":{color:e},".source-vk .side-bar-menu a:hover":{color:t,background:"none"}})}let fe={};window.addEventListener("message",s=>{let i;try{i=JSON.parse(s.data)}catch{return}if((i==null?void 0:i.type)in fe){let e=fe[i.type];for(let[t,r]of e)s.source===t&&r(i)}});const Yl=function(s,i,e){s in fe||(fe[s]=[]),fe[s].push([i,e])},Jl=function(s,i){s in fe&&(fe[s]=fe[s].filter(e=>e[0]!==i))};function Zl(s){let i=[];for(let[e,t]of Object.entries(s))t==null||typeof t=="string"&&t.length===0||i.push(`${e}=${encodeURIComponent(t)}`);return i.join("&")}class sr extends ${constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",b.activities.EXTERNAL);u(this,"_iframe",null);u(this,"updateCssData",()=>{this.isActivityActive&&(this._inheritedUpdateCssData(),this.applyStyles())});u(this,"_inheritedUpdateCssData",this.updateCssData);this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],counter:0,multiple:!1,onDone:()=>{for(const e of this.$.selectedList){const t=this.extractUrlFromMessage(e),{filename:r}=e,{externalSourceType:n}=this.activityParams;this.addFileFromUrl(t,{fileName:r,source:n})}this.$["*currentActivity"]=b.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()}}}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:e}=this.activityParams;this.set$({activityCaption:`${e==null?void 0:e[0].toUpperCase()}${e==null?void 0:e.slice(1)}`,activityIcon:e}),this.mountIframe()}}),this.sub("*currentActivity",e=>{e!==this.activityType&&this.unmountIframe()}),this.sub("selectedList",e=>{this.$.counter=e.length}),this.subConfigValue("multiple",e=>{this.$.multiple=e})}extractUrlFromMessage(e){if(e.alternatives){const t=ae(this.cfg.externalSourcesPreferredTypes);for(const r of t){const n=Gl(r);for(const[o,l]of Object.entries(e.alternatives))if(n.test(o))return l}}return e.url}sendMessage(e){var t,r;(r=(t=this._iframe)==null?void 0:t.contentWindow)==null||r.postMessage(JSON.stringify(e),"*")}async handleFileSelected(e){!this.$.multiple&&this.$.selectedList.length||(this.$.selectedList=[...this.$.selectedList,e],this.$.multiple||this.$.onDone())}handleIframeLoad(){this.applyStyles()}getCssValue(e){return window.getComputedStyle(this).getPropertyValue(e).trim()}applyStyles(){let e={backgroundColor:this.getCssValue("--clr-background-light"),textColor:this.getCssValue("--clr-txt"),shadeColor:this.getCssValue("--clr-shade-lv1"),linkColor:"#157cfc",linkColorHover:"#3891ff"};this.sendMessage({type:"embed-css",style:Kl(e)})}remoteUrl(){var l,a;let e=this.cfg.pubkey,t="false",{externalSourceType:r}=this.activityParams,n={lang:((a=(l=this.getCssData("--l10n-locale-name"))==null?void 0:l.split("-"))==null?void 0:a[0])||"en",public_key:e,images_only:t,pass_window_open:!1,session_key:this.cfg.remoteTabSessionKey},o=new URL(this.cfg.socialBaseUrl);return o.pathname=`/window3/${r}`,o.search=Zl(n),o.toString()}mountIframe(){let e=Dt({tag:"iframe",attributes:{src:this.remoteUrl(),marginheight:0,marginwidth:0,frameborder:0,allowTransparency:!0}});e.addEventListener("load",this.handleIframeLoad.bind(this)),this.ref.iframeWrapper.innerHTML="",this.ref.iframeWrapper.appendChild(e),Yl("file-selected",e.contentWindow,this.handleFileSelected.bind(this)),this._iframe=e,this.$.selectedList=[]}unmountIframe(){this._iframe&&Jl("file-selected",this._iframe.contentWindow),this.ref.iframeWrapper.innerHTML="",this._iframe=null,this.$.selectedList=[],this.$.counter=0}}sr.template=`
|
|
349
|
-
<lr-activity-header>
|
|
350
|
-
<button type="button" class="mini-btn" set="onclick: *historyBack">
|
|
351
|
-
<lr-icon name="back"></lr-icon>
|
|
352
|
-
</button>
|
|
353
|
-
<div>
|
|
354
|
-
<lr-icon set="@name: activityIcon"></lr-icon>
|
|
355
|
-
<span>{{activityCaption}}</span>
|
|
356
|
-
</div>
|
|
357
|
-
<button type="button" class="mini-btn close-btn" set="onclick: *historyBack">
|
|
358
|
-
<lr-icon name="close"></lr-icon>
|
|
359
|
-
</button>
|
|
360
|
-
</lr-activity-header>
|
|
361
|
-
<div class="content">
|
|
362
|
-
<div ref="iframeWrapper" class="iframe-wrapper"></div>
|
|
363
|
-
<div class="toolbar">
|
|
364
|
-
<button type="button" class="cancel-btn secondary-btn" set="onclick: onCancel" l10n="cancel"></button>
|
|
365
|
-
<div></div>
|
|
366
|
-
<div set="@hidden: !multiple" class="selected-counter"><span l10n="selected-count"></span>{{counter}}</div>
|
|
367
|
-
<button type="button" class="done-btn primary-btn" set="onclick: onDone; @disabled: !counter">
|
|
368
|
-
<lr-icon name="check"></lr-icon>
|
|
369
|
-
</button>
|
|
370
|
-
</div>
|
|
371
|
-
</div>
|
|
372
|
-
`;class ni extends k{setCurrentTab(i){if(!i)return;[...this.ref.context.querySelectorAll("[tab-ctx]")].forEach(t=>{t.getAttribute("tab-ctx")===i?t.removeAttribute("hidden"):t.setAttribute("hidden","")});for(let t in this._tabMap)t===i?this._tabMap[t].setAttribute("current",""):this._tabMap[t].removeAttribute("current")}initCallback(){super.initCallback(),this._tabMap={},this.defineAccessor("tab-list",i=>{if(!i)return;ae(i).forEach(t=>{let r=Dt({tag:"div",attributes:{class:"tab"},properties:{onclick:()=>{this.setCurrentTab(t)}}});r.textContent=this.l10n(t),this.ref.row.appendChild(r),this._tabMap[t]=r})}),this.defineAccessor("default",i=>{this.setCurrentTab(i)}),this.hasAttribute("default")||this.setCurrentTab(Object.keys(this._tabMap)[0])}}ni.bindAttributes({"tab-list":null,default:null});ni.template=`
|
|
373
|
-
<div ref="row" class="tabs-row"></div>
|
|
374
|
-
<div ref="context" class="tabs-context">
|
|
375
|
-
<slot></slot>
|
|
376
|
-
</div>
|
|
377
|
-
`;class Ql extends ${constructor(){super(...arguments);u(this,"requireCtxName",!0)}_createValidationInput(){const e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,Gi(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{var t;{if(this._dynamicInputsContainer||(this._dynamicInputsContainer=document.createElement("div"),this.appendChild(this._dynamicInputsContainer)),!this._validationInputElement){const l=this._createValidationInput();this.appendChild(l),this._validationInputElement=l}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){const l=(t=e.errors[0])==null?void 0:t.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(l);return}const r=e.group?e.group:null;if(r){this._validationInputElement.value=r.cdnUrl,this._validationInputElement.setCustomValidity("");return}const n=e.allEntries.map(l=>l.cdnUrl);if(!this.cfg.multiple&&n.length===1){this._validationInputElement.value=n[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;const o=new DocumentFragment;for(let l of n){const a=document.createElement("input");a.type="hidden",a.name=`${this.ctxName}[]`,a.value=l,o.appendChild(a)}this._dynamicInputsContainer.replaceChildren(o)}},!1)}}class ea extends b{}class rr extends k{constructor(){super(...arguments);u(this,"init$",{...this.init$,currentText:"",options:[],selectHtml:"",onSelect:e=>{var t;e.preventDefault(),e.stopPropagation(),this.value=this.ref.select.value,this.$.currentText=((t=this.$.options.find(r=>r.value==this.value))==null?void 0:t.text)||"",this.dispatchEvent(new Event("change"))}})}initCallback(){super.initCallback(),this.sub("options",e=>{var r;this.$.currentText=((r=e==null?void 0:e[0])==null?void 0:r.text)||"";let t="";e==null||e.forEach(n=>{t+=`<option value="${n.value}">${n.text}</option>`}),this.$.selectHtml=t})}}rr.template=`
|
|
378
|
-
<button>
|
|
379
|
-
{{currentText}}
|
|
380
|
-
<lr-icon name="select"></lr-icon>
|
|
381
|
-
<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>
|
|
382
|
-
</button>
|
|
383
|
-
`;const M={PLAY:"play",PAUSE:"pause",FS_ON:"fullscreen-on",FS_OFF:"fullscreen-off",VOL_ON:"unmute",VOL_OFF:"mute",CAP_ON:"captions",CAP_OFF:"captions-off"},Vi={requestFullscreen:s=>{s.requestFullscreen?s.requestFullscreen():s.webkitRequestFullscreen&&s.webkitRequestFullscreen()},exitFullscreen:()=>{document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}};class ne extends k{constructor(){super(...arguments);u(this,"init$",{...this.init$,src:"",ppIcon:M.PLAY,fsIcon:M.FS_ON,volIcon:M.VOL_ON,capIcon:M.CAP_OFF,totalTime:"00:00",currentTime:"00:00",progressCssWidth:"0",hasSubtitles:!1,volumeDisabled:!1,volumeValue:0,onPP:()=>{this.togglePlay()},onFs:()=>{this.toggleFullscreen()},onCap:()=>{this.toggleCaptions()},onMute:()=>{this.toggleSound()},onVolChange:e=>{let t=parseFloat(e.currentTarget.$.value);this.setVolume(t)},progressClicked:e=>{let t=this.progress.getBoundingClientRect();this._video.currentTime=this._video.duration*(e.offsetX/t.width)}})}togglePlay(){this._video.paused||this._video.ended?this._video.play():this._video.pause()}toggleFullscreen(){(document.fullscreenElement||document.webkitFullscreenElement)===this?Vi.exitFullscreen():Vi.requestFullscreen(this)}toggleCaptions(){this.$.capIcon===M.CAP_OFF?(this.$.capIcon=M.CAP_ON,this._video.textTracks[0].mode="showing",window.localStorage.setItem(ne.is+":captions","1")):(this.$.capIcon=M.CAP_OFF,this._video.textTracks[0].mode="hidden",window.localStorage.removeItem(ne.is+":captions"))}toggleSound(){this.$.volIcon===M.VOL_ON?(this.$.volIcon=M.VOL_OFF,this.$.volumeDisabled=!0,this._video.muted=!0):(this.$.volIcon=M.VOL_ON,this.$.volumeDisabled=!1,this._video.muted=!1)}setVolume(e){window.localStorage.setItem(ne.is+":volume",e);let t=e?e/100:0;this._video.volume=t}get progress(){return this.ref.progress}_getUrl(e){return e.includes("/")?e:`https://ucarecdn.com/${e}/`}_desc2attrs(e){let t=[];for(let r in e){let n=r==="src"?this._getUrl(e[r]):e[r];t.push(`${r}="${n}"`)}return t.join(" ")}_timeFmt(e){let t=new Date(Math.round(e)*1e3);return[t.getMinutes(),t.getSeconds()].map(r=>r<10?"0"+r:r).join(":")}_initTracks(){[...this._video.textTracks].forEach(e=>{e.mode="hidden"}),window.localStorage.getItem(ne.is+":captions")&&this.toggleCaptions()}_castAttributes(){let e=["autoplay","loop","muted"];[...this.attributes].forEach(t=>{e.includes(t.name)&&this._video.setAttribute(t.name,t.value)})}initCallback(){super.initCallback(),this._video=this.ref.video,this._castAttributes(),this._video.addEventListener("play",()=>{this.$.ppIcon=M.PAUSE,this.setAttribute("playback","")}),this._video.addEventListener("pause",()=>{this.$.ppIcon=M.PLAY,this.removeAttribute("playback")}),this.addEventListener("fullscreenchange",t=>{console.log(t),document.fullscreenElement===this?this.$.fsIcon=M.FS_OFF:this.$.fsIcon=M.FS_ON}),this.sub("src",t=>{if(!t)return;let r=this._getUrl(t);this._video.src=r}),this.sub("video",async t=>{if(!t)return;let r=await(await window.fetch(this._getUrl(t))).json();r.poster&&(this._video.poster=this._getUrl(r.poster));let n="";r==null||r.sources.forEach(o=>{n+=`<source ${this._desc2attrs(o)} />`}),r.tracks&&(r.tracks.forEach(o=>{n+=`<track ${this._desc2attrs(o)} />`}),this.$.hasSubtitles=!0),this._video.innerHTML+=n,this._initTracks(),console.log(r)}),this._video.addEventListener("loadedmetadata",t=>{this.$.currentTime=this._timeFmt(this._video.currentTime),this.$.totalTime=this._timeFmt(this._video.duration)}),this._video.addEventListener("timeupdate",t=>{let r=Math.round(100*(this._video.currentTime/this._video.duration));this.$.progressCssWidth=r+"%",this.$.currentTime=this._timeFmt(this._video.currentTime)});let e=window.localStorage.getItem(ne.is+":volume");if(e){let t=parseFloat(e);this.setVolume(t),this.$.volumeValue=t}}}ne.template=`
|
|
384
|
-
<div class="video-wrapper">
|
|
385
|
-
<video ref="video" preload="metadata" crossorigin="anonymous"></video>
|
|
386
|
-
</div>
|
|
387
|
-
|
|
388
|
-
<div class="toolbar">
|
|
389
|
-
<div class="progress" ref="progress" set -onclick="progressClicked">
|
|
390
|
-
<div class="bar" set -style.width="progressCssWidth"></div>
|
|
391
|
-
</div>
|
|
392
|
-
|
|
393
|
-
<div class="tb-block">
|
|
394
|
-
<button set -onclick="onPP">
|
|
395
|
-
<lr-icon set -@name="ppIcon"></lr-icon>
|
|
396
|
-
</button>
|
|
397
|
-
<div class="timer">{{currentTime}} / {{totalTime}}</div>
|
|
398
|
-
</div>
|
|
399
|
-
|
|
400
|
-
<div class="tb-block">
|
|
401
|
-
<button set -onclick="onCap" -@hidden="!hasSubtitles">
|
|
402
|
-
<lr-icon set -@name="capIcon"></lr-icon>
|
|
403
|
-
</button>
|
|
404
|
-
|
|
405
|
-
<button set -onclick="onMute">
|
|
406
|
-
<lr-icon set -@name="volIcon"></lr-icon>
|
|
407
|
-
</button>
|
|
408
|
-
|
|
409
|
-
<lr-range type="range" set -onchange="onVolChange" -@disabled="volumeDisabled" -value="volumeValue"> </lr-range>
|
|
410
|
-
|
|
411
|
-
<button set -onclick="onFs">
|
|
412
|
-
<lr-icon set -@name="fsIcon"></lr-icon>
|
|
413
|
-
</button>
|
|
414
|
-
</div>
|
|
415
|
-
</div>
|
|
416
|
-
`;ne.bindAttributes({video:"video",src:"src"});const ta="css-src";function oi(s){return class extends s{constructor(){super(...arguments);u(this,"renderShadow",!0);u(this,"pauseRender",!0);u(this,"requireCtxName",!0)}shadowReadyCallback(){}async _waitForShadowStylesLoad(){if(!this.shadowRoot)return;const e=this.constructor.__shadowStylesUrl,t=this.shadowRoot.querySelector(`link[href="${e}"]`);t&&await new Promise((r,n)=>{t.addEventListener("load",r),t.addEventListener("error",n)})}initCallback(){super.initCallback(),this.setAttribute("hidden",""),Zi({element:this,attribute:ta,onSuccess:e=>{this.attachShadow({mode:"open"});let t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.href=e,t.onload=()=>{window.requestAnimationFrame(async()=>{this.render(),await this._waitForShadowStylesLoad(),window.setTimeout(()=>{this.removeAttribute("hidden"),this.shadowReadyCallback()})})},this.shadowRoot.prepend(t)},onTimeout:()=>{console.error("Attribute `css-src` is required and it is not set. See migration guide: https://uploadcare.com/docs/file-uploader/migration-to-0.25.0/")}})}}}class nr extends oi(k){}class or extends k{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i)})}}u(or,"template",`
|
|
417
|
-
<a
|
|
418
|
-
href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4"
|
|
419
|
-
target="_blank noopener"
|
|
420
|
-
class="credits"
|
|
421
|
-
>Powered by Uploadcare</a
|
|
422
|
-
>
|
|
423
|
-
`);class li extends nr{constructor(){super(...arguments);u(this,"requireCtxName",!0);u(this,"init$",ds(this));u(this,"_template",null)}static set template(e){this._template=e+"<slot></slot>"}static get template(){return this._template}}let ai=class extends li{shadowReadyCallback(){super.shadowReadyCallback(),this.sub("*modalActive",i=>{this._lastModalActive!==i&&this.emit(i?x.MODAL_OPEN:x.MODAL_CLOSE,void 0,{debounce:!0}),this._lastModalActive=i},!1)}};ai.template=`
|
|
424
|
-
<lr-simple-btn></lr-simple-btn>
|
|
425
|
-
|
|
426
|
-
<lr-modal strokes block-body-scrolling>
|
|
427
|
-
<lr-start-from>
|
|
428
|
-
<lr-drop-area with-icon clickable></lr-drop-area>
|
|
429
|
-
<lr-source-list wrap></lr-source-list>
|
|
430
|
-
<button type="button" l10n="start-from-cancel" class="secondary-btn" set="onclick: *historyBack"></button>
|
|
431
|
-
<lr-copyright></lr-copyright>
|
|
432
|
-
</lr-start-from>
|
|
433
|
-
<lr-upload-list></lr-upload-list>
|
|
434
|
-
<lr-camera-source></lr-camera-source>
|
|
435
|
-
<lr-url-source></lr-url-source>
|
|
436
|
-
<lr-external-source></lr-external-source>
|
|
437
|
-
<lr-cloud-image-editor-activity></lr-cloud-image-editor-activity>
|
|
438
|
-
</lr-modal>
|
|
439
|
-
|
|
440
|
-
<lr-progress-bar-common></lr-progress-bar-common>
|
|
441
|
-
`;let Ct=class extends li{constructor(){super(...arguments);u(this,"pauseRender",!0)}shadowReadyCallback(){const e=this.ref.uBlock;this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e.initActivity||b.activities.START_FROM)}),this.sub("*uploadList",t=>{(t==null?void 0:t.length)>0?this.$["*currentActivity"]=b.activities.UPLOAD_LIST:this.$["*currentActivity"]=e.initActivity||b.activities.START_FROM}),this.subConfigValue("sourceList",t=>{t!=="local"&&(this.cfg.sourceList="local")}),this.subConfigValue("confirmUpload",t=>{t!==!1&&(this.cfg.confirmUpload=!1)})}};Ct.template=`
|
|
442
|
-
<lr-start-from>
|
|
443
|
-
<lr-drop-area clickable l10n="choose-file"></lr-drop-area>
|
|
444
|
-
<lr-copyright></lr-copyright>
|
|
445
|
-
</lr-start-from>
|
|
446
|
-
<lr-upload-list ref="uBlock"></lr-upload-list>
|
|
447
|
-
`;let lr=class extends li{constructor(){super(),this.init$={...this.init$,couldCancel:!1,cancel:()=>{this.couldHistoryBack?this.$["*historyBack"]():this.couldShowList&&(this.$["*currentActivity"]=b.activities.UPLOAD_LIST)}}}get couldHistoryBack(){const i=this.$["*history"];return i.length>1&&i[i.length-1]!==b.activities.START_FROM}get couldShowList(){return this.cfg.showEmptyList||this.$["*uploadList"].length>0}shadowReadyCallback(){const i=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=i.initActivity||b.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0&&this.$["*currentActivity"]===(i.initActivity||b.activities.START_FROM)&&(this.$["*currentActivity"]=b.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList})}};lr.template=` <lr-start-from>
|
|
448
|
-
<lr-drop-area with-icon clickable></lr-drop-area>
|
|
449
|
-
<lr-source-list wrap></lr-source-list>
|
|
450
|
-
<button
|
|
451
|
-
type="button"
|
|
452
|
-
l10n="start-from-cancel"
|
|
453
|
-
class="cancel-btn secondary-btn"
|
|
454
|
-
set="onclick: cancel; @hidden: !couldCancel"
|
|
455
|
-
></button>
|
|
456
|
-
<lr-copyright></lr-copyright>
|
|
457
|
-
</lr-start-from>
|
|
458
|
-
<lr-upload-list ref="uBlock"></lr-upload-list>
|
|
459
|
-
<lr-camera-source></lr-camera-source>
|
|
460
|
-
<lr-url-source></lr-url-source>
|
|
461
|
-
<lr-external-source></lr-external-source>
|
|
462
|
-
<lr-progress-bar></lr-progress-bar>
|
|
463
|
-
<lr-cloud-image-editor-activity></lr-cloud-image-editor-activity>`;class ia extends oi(Fe){shadowReadyCallback(){this.__shadowReady=!0,this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async initEditor(){this.__shadowReady&&await super.initEditor()}}function Xe(s){for(let i in s){let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r="-"+r.toLowerCase()),t+=r),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("lr-")||(e="lr-"+e),s[i].reg&&s[i].reg(e)}}const It="LR";async function sa(s,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[It]){e(window[It]);return}let r=document.createElement("script");r.async=!0,r.src=s,r.onerror=()=>{t()},r.onload=()=>{let n=window[It];i&&Xe(n),e(n)},document.head.appendChild(r)})}const ci=Object.freeze(Object.defineProperty({__proto__:null,ActivityBlock:b,ActivityHeader:ea,BaseComponent:ht,Block:k,CameraSource:zs,CloudImageEditor:ia,CloudImageEditorActivity:Wl,CloudImageEditorBlock:Fe,Config:As,ConfirmationDialog:js,Copyright:or,CropFrame:Gs,Data:T,DropArea:Jt,EditorCropButtonControl:Xs,EditorFilterControl:ii,EditorImageCropper:Js,EditorImageFader:Vl,EditorOperationControl:Ys,EditorScroller:Zs,EditorSlider:Ks,EditorToolbar:Qs,ExternalSource:sr,FileItem:we,FilePreview:ei,FileUploaderInline:lr,FileUploaderMinimal:Ct,FileUploaderRegular:ai,FormInput:Ql,Icon:Kt,Img:Wo,LineLoaderUi:er,LrBtnUi:ri,Modal:Qt,PACKAGE_NAME:qt,PACKAGE_VERSION:bt,PresenceToggle:tr,ProgressBar:Ws,ProgressBarCommon:Hs,Select:rr,ShadowWrapper:nr,SimpleBtn:Yt,SliderUi:ir,SourceBtn:Zt,SourceList:Zo,StartFrom:$s,Tabs:ni,UID:Ae,UploadCtxProvider:ct,UploadDetails:Bs,UploadList:Ns,UploaderBlock:$,UrlSource:Ds,Video:ne,connectBlocksFrom:sa,registerBlocks:Xe,shadowed:oi,toKebabCase:Ce},Symbol.toStringTag,{value:"Module"})),ra=new Set(["children","ref","style","className"]),na=(s={})=>Object==null?void 0:Object.keys(s).reduce((i,e)=>{var t,r;const n=s==null?void 0:s[e],o=`on${(r=(t=n==null?void 0:n.split("-"))==null?void 0:t.map(l=>l.charAt(0).toUpperCase()+l.slice(1)))==null?void 0:r.join("")}`;return i[o]=n,i},{}),Bi=new WeakMap,oa=s=>{let i=Bi.get(s);return i||(i=new Map,Bi.set(s,i)),i},ji=({node:s,nameProp:i,valueProp:e,prevValueProp:t,event:r})=>{if(r!==void 0&&e!==t){const n=oa(s),o=n.has(r);if(e){const l={handleEvent:e};o||s.addEventListener(r,l),n.set(r,l)}else if(o){const l=n.get(r);s.removeEventListener(r,l),n.delete(r)}return}s[i]=e,e==null&&i in HTMLElement.prototype&&s.removeAttribute(i)},la=(s,i,e)=>{const t={},r={};return Object.entries(s).forEach(([n,o])=>{ra.has(n)?t[n==="className"?"class":n]=o:i.has(n)||n in e.prototype?r[n]=o:t[n]=o}),{reactProps:t,customElProps:r}},Ke=({react:s,tag:i,elClass:e,schemaEvents:t})=>{const r=na(t),n=new Set(Object.keys(r??{})),o=s.forwardRef((l,a)=>{const c=s.useRef(new Map),h=s.useRef(null),{reactProps:d,customElProps:f}=la(l,n,e);return s.useLayoutEffect(()=>{if(h.current===null)return;const m=new Map;for(const p in f)ji({node:h.current,nameProp:p,valueProp:f[p],prevValueProp:c.current.get(p),event:r[p]}),c.current.delete(p),m.set(p,l[p]);for(const[p,g]of c.current)ji({node:h.current,nameProp:p,valueProp:void 0,prevValueProp:g,event:r[p]});c.current=m}),s.createElement(i??e.__tag,{...d,ref:s.useCallback(m=>{h.current=m,typeof a=="function"?a(m):a!==null&&(a.current=m)},[a])})});return o.displayName=e.name,o},hi=Ke({react:S,tag:"lr-config",elClass:As}),ui=Ke({react:S,tag:"lr-upload-ctx-provider",elClass:ct,schemaEvents:ct.EventType}),di=s=>`https://cdn.jsdelivr.net/npm/@uploadcare/blocks@${bt}/web/lr-file-uploader-${s}.min.css`,fi=s=>{const i={},e={};return Object.entries(s).forEach(([t,r])=>{t.startsWith("on")?i[t]=r:e[t]=r}),{eventHandlers:i,config:e}},aa="0.2.0",ca="React-Uploader",pi=()=>`${ca}/${aa}`;Xe(ci);const ha=Ke({react:S,tag:"lr-file-uploader-regular",elClass:ai}),ua=di("regular"),da=({ctxName:s,className:i,apiRef:e,...t})=>{const r=S.useMemo(()=>s??Ae.generate(),[s]),{eventHandlers:n,config:o}=S.useMemo(()=>fi(t),[t]);return S.createElement("div",{className:i},S.createElement(hi,{userAgentIntegration:pi(),"ctx-name":r,...o}),S.createElement(ui,{ref:e,"ctx-name":r,...n}),S.createElement(ha,{"ctx-name":r,"css-src":ua}))};Xe(ci);const fa=Ke({react:S,tag:"lr-file-uploader-minimal",elClass:Ct}),pa=di("minimal"),ma=({ctxName:s,className:i,apiRef:e,...t})=>{const r=S.useMemo(()=>s??Ae.generate(),[s]),{eventHandlers:n,config:o}=S.useMemo(()=>fi(t),[t]);return S.createElement("div",{className:i},S.createElement(hi,{userAgentIntegration:pi(),"ctx-name":r,...o}),S.createElement(ui,{ref:e,"ctx-name":r,...n}),S.createElement(fa,{"ctx-name":r,"css-src":pa}))};Xe(ci);const ga=Ke({react:S,tag:"lr-file-uploader-inline",elClass:Ct}),ba=di("inline"),_a=({ctxName:s,className:i,apiRef:e,...t})=>{const r=S.useMemo(()=>s??Ae.generate(),[s]),{eventHandlers:n,config:o}=S.useMemo(()=>fi(t),[t]);return S.createElement("div",{className:i},S.createElement(hi,{userAgentIntegration:pi(),"ctx-name":r,...o}),S.createElement(ui,{ref:e,"ctx-name":r,...n}),S.createElement(ga,{"ctx-name":r,"css-src":ba}))};exports.FileUploaderInline=_a;exports.FileUploaderMinimal=ma;exports.FileUploaderRegular=da;exports.UploadCtxProvider=ct;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const LR = require("@uploadcare/blocks");
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
+
if (e) {
|
|
8
|
+
for (const k in e) {
|
|
9
|
+
if (k !== "default") {
|
|
10
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => e[k]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
const LR__namespace = /* @__PURE__ */ _interopNamespaceDefault(LR);
|
|
22
|
+
const P = /* @__PURE__ */ new Set([
|
|
23
|
+
"children",
|
|
24
|
+
"ref",
|
|
25
|
+
"style",
|
|
26
|
+
"className"
|
|
27
|
+
]), w = (e = {}) => Object == null ? void 0 : Object.keys(e).reduce((r, s) => {
|
|
28
|
+
var t, c;
|
|
29
|
+
const o = e == null ? void 0 : e[s], n = `on${(c = (t = o == null ? void 0 : o.split("-")) == null ? void 0 : t.map((i) => i.charAt(0).toUpperCase() + i.slice(1))) == null ? void 0 : c.join("")}`;
|
|
30
|
+
return r[n] = o, r;
|
|
31
|
+
}, {}), m = /* @__PURE__ */ new WeakMap(), g = (e) => {
|
|
32
|
+
let r = m.get(e);
|
|
33
|
+
return r === void 0 && (r = /* @__PURE__ */ new Map(), m.set(e, r)), r;
|
|
34
|
+
}, E = ({
|
|
35
|
+
node: e,
|
|
36
|
+
nameProp: r,
|
|
37
|
+
valueProp: s,
|
|
38
|
+
prevValueProp: o,
|
|
39
|
+
event: n
|
|
40
|
+
}) => {
|
|
41
|
+
if (n !== void 0) {
|
|
42
|
+
if (s !== o) {
|
|
43
|
+
const t = g(e), c = t.has(n);
|
|
44
|
+
let i = t.get(n);
|
|
45
|
+
s !== void 0 ? c ? i.handleEvent = s : (i = { handleEvent: s }, t.set(n, i), e.addEventListener(
|
|
46
|
+
n,
|
|
47
|
+
(a) => i.handleEvent(a.detail)
|
|
48
|
+
)) : c && (t.delete(n), e.removeEventListener(n, i));
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
e[r] = s, s == null && r in HTMLElement.prototype && e.removeAttribute(r);
|
|
53
|
+
}, M = (e, r, s) => {
|
|
54
|
+
const o = {}, n = {};
|
|
55
|
+
return Object.entries(e).forEach(([t, c]) => {
|
|
56
|
+
P.has(t) ? o[t === "className" ? "class" : t] = c : r.has(t) || t in s.prototype ? n[t] = c : o[t] = c;
|
|
57
|
+
}), { reactProps: o, customElProps: n };
|
|
58
|
+
}, b = ({
|
|
59
|
+
react: e,
|
|
60
|
+
// https://react.dev/warnings/invalid-hook-call-warning
|
|
61
|
+
tag: r,
|
|
62
|
+
elClass: s,
|
|
63
|
+
schemaEvents: o
|
|
64
|
+
}) => {
|
|
65
|
+
const n = w(o), t = new Set(Object.keys(n ?? {})), c = e.forwardRef(
|
|
66
|
+
(i, a) => {
|
|
67
|
+
const f = e.useRef(/* @__PURE__ */ new Map()), p = e.useRef(null), { reactProps: h, customElProps: d } = M(i, t, s);
|
|
68
|
+
return e.useLayoutEffect(() => {
|
|
69
|
+
if (p.current === null)
|
|
70
|
+
return;
|
|
71
|
+
const u = /* @__PURE__ */ new Map();
|
|
72
|
+
for (const l in d)
|
|
73
|
+
E({
|
|
74
|
+
node: p.current,
|
|
75
|
+
nameProp: l,
|
|
76
|
+
valueProp: d[l],
|
|
77
|
+
prevValueProp: f.current.get(l),
|
|
78
|
+
event: n[l]
|
|
79
|
+
}), f.current.delete(l), u.set(l, i[l]);
|
|
80
|
+
for (const [l, v] of f.current)
|
|
81
|
+
E({
|
|
82
|
+
node: p.current,
|
|
83
|
+
nameProp: l,
|
|
84
|
+
valueProp: void 0,
|
|
85
|
+
prevValueProp: v,
|
|
86
|
+
event: n[l]
|
|
87
|
+
});
|
|
88
|
+
f.current = u;
|
|
89
|
+
}), e.createElement(r ?? s.__tag, {
|
|
90
|
+
...h,
|
|
91
|
+
ref: e.useCallback(
|
|
92
|
+
(u) => {
|
|
93
|
+
p.current = u, typeof a == "function" ? a(u) : a !== null && (a.current = u);
|
|
94
|
+
},
|
|
95
|
+
[a]
|
|
96
|
+
)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
return c.displayName = s.name, c;
|
|
101
|
+
};
|
|
102
|
+
const AdapterConfig = b({
|
|
103
|
+
react: React,
|
|
104
|
+
tag: "lr-config",
|
|
105
|
+
elClass: LR__namespace.Config
|
|
106
|
+
});
|
|
107
|
+
const AdapterUploadCtxProvider = b({
|
|
108
|
+
react: React,
|
|
109
|
+
tag: "lr-upload-ctx-provider",
|
|
110
|
+
elClass: LR__namespace.UploadCtxProvider,
|
|
111
|
+
schemaEvents: LR__namespace.UploadCtxProvider.EventType
|
|
112
|
+
});
|
|
113
|
+
const getCalcPropertyOfProps = (props) => {
|
|
114
|
+
const eventHandlers = {};
|
|
115
|
+
const config = {};
|
|
116
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
117
|
+
if (key.startsWith("on")) {
|
|
118
|
+
eventHandlers[key] = value;
|
|
119
|
+
} else {
|
|
120
|
+
config[key] = value;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
eventHandlers,
|
|
125
|
+
config
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const version = "0.4.0-alpha.0";
|
|
129
|
+
const NAME_EXTENTION = "React-Uploader";
|
|
130
|
+
const getUserAgentIntegration = () => {
|
|
131
|
+
return `${NAME_EXTENTION}/${version}`;
|
|
132
|
+
};
|
|
133
|
+
const ConditionalSuspense = ({ condition, fallback, children, ...rest }) => {
|
|
134
|
+
return condition ? /* @__PURE__ */ React.createElement(React.Suspense, { fallback, ...rest }, children) : /* @__PURE__ */ React.createElement(React.Fragment, null, fallback);
|
|
135
|
+
};
|
|
136
|
+
const useIsBrowser = () => {
|
|
137
|
+
const [isBrowser, setIsBrowser] = React.useState(false);
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (typeof window !== "undefined") {
|
|
140
|
+
setIsBrowser(true);
|
|
141
|
+
}
|
|
142
|
+
}, []);
|
|
143
|
+
return isBrowser;
|
|
144
|
+
};
|
|
145
|
+
LR__namespace.registerBlocks(LR__namespace);
|
|
146
|
+
const AdapterFileUploaderRegular = b({
|
|
147
|
+
react: React,
|
|
148
|
+
tag: "lr-file-uploader-regular",
|
|
149
|
+
elClass: LR__namespace.FileUploaderRegular
|
|
150
|
+
});
|
|
151
|
+
const FileUploaderRegular = ({
|
|
152
|
+
ctxName,
|
|
153
|
+
className,
|
|
154
|
+
classNameUploader,
|
|
155
|
+
apiRef,
|
|
156
|
+
...props
|
|
157
|
+
}) => {
|
|
158
|
+
const CTX_NAME = React.useMemo(() => ctxName ?? LR__namespace.UID.generate(), [ctxName]);
|
|
159
|
+
const { eventHandlers, config } = React.useMemo(
|
|
160
|
+
() => getCalcPropertyOfProps(props),
|
|
161
|
+
[props]
|
|
162
|
+
);
|
|
163
|
+
const isBrowser = useIsBrowser();
|
|
164
|
+
return /* @__PURE__ */ React.createElement(ConditionalSuspense, { condition: isBrowser, fallback: /* @__PURE__ */ React.createElement("h1", null, "Loading ...") }, /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(AdapterConfig, { userAgentIntegration: getUserAgentIntegration(), "ctx-name": CTX_NAME, ...config }), /* @__PURE__ */ React.createElement(
|
|
165
|
+
AdapterUploadCtxProvider,
|
|
166
|
+
{
|
|
167
|
+
ref: apiRef,
|
|
168
|
+
"ctx-name": CTX_NAME,
|
|
169
|
+
...eventHandlers
|
|
170
|
+
}
|
|
171
|
+
), /* @__PURE__ */ React.createElement(AdapterFileUploaderRegular, { class: classNameUploader, "ctx-name": CTX_NAME })));
|
|
172
|
+
};
|
|
173
|
+
LR__namespace.registerBlocks(LR__namespace);
|
|
174
|
+
const AdapterFileUploaderMinimal = b({
|
|
175
|
+
react: React,
|
|
176
|
+
tag: "lr-file-uploader-minimal",
|
|
177
|
+
elClass: LR__namespace.FileUploaderMinimal
|
|
178
|
+
});
|
|
179
|
+
const FileUploaderMinimal = ({
|
|
180
|
+
ctxName,
|
|
181
|
+
className,
|
|
182
|
+
classNameUploader,
|
|
183
|
+
apiRef,
|
|
184
|
+
...props
|
|
185
|
+
}) => {
|
|
186
|
+
const CTX_NAME = React.useMemo(() => ctxName ?? LR__namespace.UID.generate(), [ctxName]);
|
|
187
|
+
const { eventHandlers, config } = React.useMemo(
|
|
188
|
+
() => getCalcPropertyOfProps(props),
|
|
189
|
+
[props]
|
|
190
|
+
);
|
|
191
|
+
const isBrowser = useIsBrowser();
|
|
192
|
+
return /* @__PURE__ */ React.createElement(ConditionalSuspense, { condition: isBrowser, fallback: /* @__PURE__ */ React.createElement("h1", null, "Loading ...") }, /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(AdapterConfig, { userAgentIntegration: getUserAgentIntegration(), "ctx-name": CTX_NAME, ...config }), /* @__PURE__ */ React.createElement(
|
|
193
|
+
AdapterUploadCtxProvider,
|
|
194
|
+
{
|
|
195
|
+
ref: apiRef,
|
|
196
|
+
"ctx-name": CTX_NAME,
|
|
197
|
+
...eventHandlers
|
|
198
|
+
}
|
|
199
|
+
), /* @__PURE__ */ React.createElement(AdapterFileUploaderMinimal, { class: classNameUploader, "ctx-name": CTX_NAME })));
|
|
200
|
+
};
|
|
201
|
+
LR__namespace.registerBlocks(LR__namespace);
|
|
202
|
+
const AdapterFileUploaderInline = b({
|
|
203
|
+
react: React,
|
|
204
|
+
tag: "lr-file-uploader-inline",
|
|
205
|
+
elClass: LR__namespace.FileUploaderMinimal
|
|
206
|
+
});
|
|
207
|
+
const FileUploaderInline = ({
|
|
208
|
+
ctxName,
|
|
209
|
+
className,
|
|
210
|
+
classNameUploader,
|
|
211
|
+
apiRef,
|
|
212
|
+
...props
|
|
213
|
+
}) => {
|
|
214
|
+
const CTX_NAME = React.useMemo(() => ctxName ?? LR__namespace.UID.generate(), [ctxName]);
|
|
215
|
+
const { eventHandlers, config } = React.useMemo(
|
|
216
|
+
() => getCalcPropertyOfProps(props),
|
|
217
|
+
[props]
|
|
218
|
+
);
|
|
219
|
+
const isBrowser = useIsBrowser();
|
|
220
|
+
return /* @__PURE__ */ React.createElement(ConditionalSuspense, { condition: isBrowser, fallback: /* @__PURE__ */ React.createElement("h1", null, "Loading ...") }, /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(AdapterConfig, { userAgentIntegration: getUserAgentIntegration(), "ctx-name": CTX_NAME, ...config }), /* @__PURE__ */ React.createElement(
|
|
221
|
+
AdapterUploadCtxProvider,
|
|
222
|
+
{
|
|
223
|
+
ref: apiRef,
|
|
224
|
+
"ctx-name": CTX_NAME,
|
|
225
|
+
...eventHandlers
|
|
226
|
+
}
|
|
227
|
+
), /* @__PURE__ */ React.createElement(AdapterFileUploaderInline, { class: classNameUploader, "ctx-name": CTX_NAME })));
|
|
228
|
+
};
|
|
229
|
+
Object.defineProperty(exports, "UploadCtxProvider", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: () => LR.UploadCtxProvider
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(exports, "defineLocale", {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: () => LR.defineLocale
|
|
236
|
+
});
|
|
237
|
+
exports.FileUploaderInline = FileUploaderInline;
|
|
238
|
+
exports.FileUploaderMinimal = FileUploaderMinimal;
|
|
239
|
+
exports.FileUploaderRegular = FileUploaderRegular;
|