@maveio/components 0.0.151 → 0.0.152
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/{chunk-XSVNMS3S.cjs → chunk-22UX4SY2.cjs} +1 -1
- package/dist/{chunk-BRZI5I43.cjs → chunk-2P6HF22Q.cjs} +3 -3
- package/dist/{chunk-S6WN4NLN.js → chunk-6QHPCMNQ.js} +1 -1
- package/dist/{chunk-FDSTNWZP.js → chunk-ALJZRKHQ.js} +1 -1
- package/dist/{chunk-ZXCHPIGV.js → chunk-HKHV3KLY.js} +3 -3
- package/dist/{chunk-LX6MMRGQ.js → chunk-JDU4LP6W.js} +1 -1
- package/dist/chunk-KJFAZKNJ.js +1807 -0
- package/dist/chunk-MB72HBHH.cjs +1 -0
- package/dist/chunk-NV7C4TBM.js +1 -0
- package/dist/{chunk-VGWLQHAV.cjs → chunk-OMKGLQZE.cjs} +2 -2
- package/dist/{chunk-SM4RPLYQ.cjs → chunk-WEZKG6QZ.cjs} +2 -2
- package/dist/chunk-ZXKSNEJF.cjs +1807 -0
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/player.cjs +1 -1
- package/dist/components/player.js +1 -1
- package/dist/components/pop.cjs +1 -1
- package/dist/components/pop.js +1 -1
- package/dist/components/upload.cjs +1 -1
- package/dist/components/upload.js +1 -1
- package/dist/embed/socket.cjs +1 -1
- package/dist/embed/socket.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/themes/default.cjs +19 -47
- package/dist/themes/default.js +19 -47
- package/dist/themes/dolphin.cjs +29 -33
- package/dist/themes/dolphin.js +29 -33
- package/dist/themes/loader.cjs +1 -1
- package/dist/themes/loader.d.cts +4 -1
- package/dist/themes/loader.d.ts +4 -1
- package/dist/themes/loader.js +1 -1
- package/dist/themes/synthwave.cjs +22 -40
- package/dist/themes/synthwave.js +22 -40
- package/package.json +8 -8
- package/dist/chunk-AEGY4JNC.js +0 -1209
- package/dist/chunk-APKCPW3V.cjs +0 -1209
- package/dist/chunk-KTP5LV2E.cjs +0 -1
- package/dist/chunk-MAOTHFPC.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkOMKGLQZE_cjs=require('./chunk-OMKGLQZE.cjs'),chunkY7NYUH3P_cjs=require('./chunk-Y7NYUH3P.cjs'),chunkVW7IKXVI_cjs=require('./chunk-VW7IKXVI.cjs'),chunkFUBUUA7Y_cjs=require('./chunk-FUBUUA7Y.cjs'),chunk5NSCV6C2_cjs=require('./chunk-5NSCV6C2.cjs'),chunkIPA5Q26W_cjs=require('./chunk-IPA5Q26W.cjs');var n,E,f,h,u=class extends chunkVW7IKXVI_cjs.a{constructor(){super(...arguments);chunkIPA5Q26W_cjs.e(this,n);this.order="newest";this.embedController=new chunkY7NYUH3P_cjs.b(this,0);}connectedCallback(){super.connectedCallback(),this.embedController.token=this.token;}requestUpdate(t,o){super.requestUpdate(t,o),t==="embed"&&(this.embedController.token=this.token);}get _slottedChildren(){return this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:true})||[]}updated(){this.shadowRoot&&chunkOMKGLQZE_cjs.b(this.shadowRoot);}refresh(){return this.embedController.refresh()}containsEmbed(t){return this._collection?.videos?.some(o=>o.id===t)}getNextForEmbed(t){let o=chunkIPA5Q26W_cjs.f(this,n,E).call(this),e=o.findIndex(i=>i.id===t);if(e!==-1)return o[e+1]}render(){return chunk5NSCV6C2_cjs.c`
|
|
2
2
|
${this.embedController.render({pending:this.renderPending,error:t=>chunk5NSCV6C2_cjs.c`<p>${t instanceof Error?t.message:chunk5NSCV6C2_cjs.f}</p>`,complete:t=>{if(this._collection=t,!t)return this.renderPending();if(t.error)return console.warn(t.error);let o=this._slottedChildren.map(e=>{function i(){let s;return e.nodeName==="TEMPLATE"?s=e.content.cloneNode(true):s=e.cloneNode(true),s}if(e.getAttribute("name")=="list-title"){let s=i();return s.textContent=this._collection?.name,chunk5NSCV6C2_cjs.c`${s}`}if(e.getAttribute("name")=="mave-list-root"&&this.embedController.embed){let s=i(),r=s.querySelector('[slot="root-link"]');return r&&(r.addEventListener("click",a=>{a.preventDefault(),this.emit(this.EVENT_TYPES.CLICK,{action:"back",embedId:""}),this.embedController.embed="";}),r.removeAttribute("slot")),chunk5NSCV6C2_cjs.c`${s}`}if(e.getAttribute("name")=="mave-list-folder"){let s=this._collection.collections?.map(r=>{let a=i(),l=a.querySelector('[slot="folder-link"]');return [e,l].forEach(d=>{d&&(d.addEventListener("click",p=>{p.preventDefault(),this.emit(this.EVENT_TYPES.CLICK,{action:"show_collection",collectionId:r.id}),this.embedController.embed=r.id;}),d.removeAttribute("slot"));}),chunkIPA5Q26W_cjs.f(this,n,h).call(this,a,'[slot="folder-title"]',r.name),typeof r.video_count=="number"&&chunkIPA5Q26W_cjs.f(this,n,h).call(this,a,'[slot="folder-count"]',r.video_count.toString()),chunk5NSCV6C2_cjs.c`${a}`});return chunk5NSCV6C2_cjs.c`${s}`}if(e.getAttribute("name")=="mave-list-item"||!["mave-list-folder","mave-list-item","mave-list-root","list-title"].includes(e.hasAttribute("name")?e.getAttribute("name"):"")&&e.nodeName=="TEMPLATE"){let s=chunkIPA5Q26W_cjs.f(this,n,E).call(this).map((r,a)=>{let l=i(),d=a+1;chunkIPA5Q26W_cjs.f(this,n,h).call(this,l,'[slot="item-title"]',r.name),chunkIPA5Q26W_cjs.f(this,n,h).call(this,l,'[slot="item-position"]',d.toString()),chunkIPA5Q26W_cjs.f(this,n,h).call(this,l,'[slot="item-duration"]',this.durationToTime(r.duration)),chunkIPA5Q26W_cjs.f(this,n,f).call(this,l,"mave-clip",r.id),chunkIPA5Q26W_cjs.f(this,n,f).call(this,l,"mave-player",r.id),chunkIPA5Q26W_cjs.f(this,n,f).call(this,l,"mave-img",r.id);let p=l.querySelector("mave-clip"),T=l.querySelector('[slot="item-title"]'),A=l.querySelector("mave-img");return [p,T,A,l].forEach(S=>{S?.addEventListener("click",$=>{this.emit(this.EVENT_TYPES.CLICK,{action:"show_embed",embedId:r.id,position:d});});}),chunk5NSCV6C2_cjs.c`${l}`});return chunk5NSCV6C2_cjs.c`${s}`}}).filter(e=>e);return chunk5NSCV6C2_cjs.c`${this._stylesheets} ${o}`}})}
|
|
3
3
|
`}renderPending(){return chunk5NSCV6C2_cjs.c`<slot style="display: none"></slot>`}};n=new WeakSet,E=function(){if(!this._collection)return [];let t=this._collection.videos;return this.order=="newest"&&(t=this._collection.videos?.sort((o,e)=>e.created-o.created)),this.order=="oldest"&&(t=this._collection.videos?.sort((o,e)=>o.created-e.created)),this.order=="az"&&(t=this._collection.videos?.sort((o,e)=>o.name.localeCompare(e.name))),this.order=="za"&&(t=this._collection.videos?.sort((o,e)=>e.name.localeCompare(o.name))),t},f=function(t,o,e){let i=t.querySelector(o);i&&(i.setAttribute("embed",e),i.removeAttribute("slot"));},h=function(t,o,e){let i=t.querySelector(o);i&&(i.textContent=e,i.removeAttribute("slot"));},u.styles=chunk5NSCV6C2_cjs.h`
|
|
4
4
|
:host {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var chunk5STN56TL_cjs=require('./chunk-5STN56TL.cjs');var v=e=>typeof e=="function"?e:function(){return e},L=typeof self<"u"?self:null,T=typeof window<"u"?window:null,g=L||T||g,
|
|
2
|
-
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=false,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",false)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]);});}close(e,t,i){for(let n of this.reqs)n.abort();this.readyState=f.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:true},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s);}ajax(e,t,i,s,n){let r,h=()=>{this.reqs.delete(r),s();};r=E.request(e,this.endpointURL(),t,i,this.timeout,h,o=>{this.reqs.delete(r),this.isActive()&&n(o);}),this.reqs.add(r);}};var C={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,r,h]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:r,payload:h})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:r}=e,h=this.META_LENGTH+t.length+i.length+n.length+s.length,o=new ArrayBuffer(this.HEADER_LENGTH+h),a=new DataView(o),l=0;a.setUint8(l++,this.KINDS.push),a.setUint8(l++,t.length),a.setUint8(l++,i.length),a.setUint8(l++,n.length),a.setUint8(l++,s.length),Array.from(t,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(i,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(n,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(s,u=>a.setUint8(l++,u.charCodeAt(0)));var p=new Uint8Array(o.byteLength+r.byteLength);return p.set(new Uint8Array(o),0),p.set(new Uint8Array(r),o.byteLength),p.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=this.HEADER_LENGTH+this.META_LENGTH-1,o=i.decode(e.slice(h,h+s));h=h+s;let a=i.decode(e.slice(h,h+n));h=h+n;let l=i.decode(e.slice(h,h+r));h=h+r;let p=e.slice(h,e.byteLength);return {join_ref:o,ref:null,topic:a,event:l,payload:p}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+n));o=o+n;let p=i.decode(e.slice(o,o+r));o=o+r;let u=i.decode(e.slice(o,o+h));o=o+h;let w=e.slice(o,e.byteLength),A={status:u,response:w};return {join_ref:a,ref:l,topic:p,event:d.reply,payload:A}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=this.HEADER_LENGTH+2,h=i.decode(e.slice(r,r+s));r=r+s;let o=i.decode(e.slice(r,r+n));r=r+n;let a=e.slice(r,e.byteLength);return {join_ref:null,ref:null,topic:h,event:o,payload:a}}},k=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||H,this.transport=t.transport||g.WebSocket||m,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||g.sessionStorage,this.establishedConnections=0,this.defaultEncoder=C.encode.bind(C),this.defaultDecoder=C.decode.bind(C),this.closeWasClean=false,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==m?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;T&&T.addEventListener&&(T.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock);}),T.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect());})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(s,n,r)=>{console.log(`${s}: ${n}`,r);}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=v(t.params||{}),this.endPoint=`${e}/${R.websocket}`,this.vsn=t.vsn||B,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new y(()=>{this.teardown(()=>this.connect());},this.reconnectAfterMs);}getLongPollTransport(){return m}replaceTransport(e){this.connectClock++,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e;}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=E.appendParams(E.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,i){this.connectClock++,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(e,t,i);}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=v(e)),!this.conn&&(this.longPollFallbackMs&&this.transport!==m?this.connectWithFallback(m,this.longPollFallbackMs):this.transportConnect());}log(e,t,i){this.logger&&this.logger(e,t,i);}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return false;let t=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(n=>{n.ref===t&&(this.off([s]),e(Date.now()-i));});return true}transportConnect(){this.connectClock++,this.closeWasClean=false,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e);}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t);}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=false,s=true,n,r,h=o=>{this.log("transport",`falling back to ${e.name}...`,o),this.off([n,r]),s=false,this.storeSession("phx:longpoll","true"),this.replaceTransport(e),this.transportConnect();};if(this.getSession("phx:longpoll"))return h("memorized");this.fallbackTimer=setTimeout(h,t),r=this.onError(o=>{this.log("transport","error",o),s&&!i&&(clearTimeout(this.fallbackTimer),h(o));}),this.onOpen(()=>{if(i=true,!s)return console.log("transport",`established ${e.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(h,t),this.ping(o=>{this.log("transport","connected to primary after",o),clearTimeout(this.fallbackTimer);});}),this.transportConnect();}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer);}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=false,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e());}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=false,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),P,"heartbeat timeout"));}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs));}teardown(e,t,i){if(!this.conn)return e&&e();this.waitForBufferDone(()=>{this.conn&&(t?this.conn.close(t,i||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e();});});}waitForBufferDone(e,t=1){if(t===5||!this.conn||!this.conn.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(e,t+1);},150*t);}waitForSocketClosed(e,t=1){if(t===5||!this.conn||this.conn.readyState===f.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(e,t+1);},150*t);}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&t!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(e));}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(e,t,i);}),(t===this.transport||i>0)&&this.triggerChanError();}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(d.error);});}connectionState(){switch(this.conn&&this.conn.readyState){case f.connecting:return "connecting";case f.open:return "open";case f.closing:return "closing";default:return "closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t.joinRef()!==e.joinRef());}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([i])=>e.indexOf(i)===-1);}channel(e,t={}){let i=new x(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:n,join_ref:r}=e;this.log("push",`${t} ${i} (${r}, ${n})`,s);}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)));}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs));}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[]);}onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:s,payload:n,ref:r,join_ref:h}=t;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,n);for(let o=0;o<this.channels.length;o++){let a=this.channels[o];a.isMember(i,s,n,h)&&a.trigger(s,n,r,h);}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,a]=this.stateChangeCallbacks.message[o];a(t);}});}leaveOpenTopic(e){let t=this.channels.find(i=>i.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave());}};var S=class e{constructor(){this.channels=[];}static connect(t){e.instance||(e.instance=new e,window&&(e.instance.socket=new k(chunk5STN56TL_cjs.a.upload.socket,{params:{token:t},reconnectAfterMs:s=>[1e3,3e3,5e3,1e4][s-1]||1e4}),e.instance.socket.connect()));let i=e.instance.channels.find(s=>s.token===t);if(i)return i;{let s=e.instance.socket.channel(`embed:${t}`);s.join();let n={token:t,channel:s};return s.on("initiate",({upload_id:r})=>{e.instance.channels.push({...n,upload_id:r});}),n}}};
|
|
3
|
-
exports.a=
|
|
1
|
+
'use strict';var chunk5STN56TL_cjs=require('./chunk-5STN56TL.cjs');var v=e=>typeof e=="function"?e:function(){return e},L=typeof self<"u"?self:null,T=typeof window<"u"?window:null,g=L||T||g,H="2.0.0",f={connecting:0,open:1,closing:2,closed:3},P=1e4,B=1e3,c={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},d={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},k={longpoll:"longpoll",websocket:"websocket"},_={complete:4},C=class{constructor(e,t,i,s){this.channel=e,this.event=t,this.payload=i||function(){return {}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=false;}resend(e){this.timeout=e,this.reset(),this.send();}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=true,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}));}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=false;}matchReceive({status:e,response:t,_ref:i}){this.recHooks.filter(s=>s.status===e).forEach(s=>s.callback(t));}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent);}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null;}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e);}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{});},this.timeout);}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t});}},y=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=null,this.tries=0;}reset(){this.tries=0,clearTimeout(this.timer);}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback();},this.timerCalc(this.tries+1));}},x=class{constructor(e,t,i){this.state=c.closed,this.topic=e,this.params=v(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=false,this.joinPush=new C(this,d.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new y(()=>{this.socket.isConnected()&&this.rejoin();},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin();})),this.joinPush.receive("ok",()=>{this.state=c.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[];}),this.joinPush.receive("error",()=>{this.state=c.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout();}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=c.closed,this.socket.remove(this);}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=c.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout();}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new C(this,d.leave,v({}),this.timeout).send(),this.state=c.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout();}),this.on(d.reply,(s,n)=>{this.trigger(this.replyEventName(n),s);});}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=true,this.rejoin(),this.joinPush}onClose(e){this.on(d.close,e);}onError(e){return this.on(d.error,t=>e(t))}on(e,t){let i=this.bindingRef++;return this.bindings.push({event:e,ref:i,callback:t}),i}off(e,t){this.bindings=this.bindings.filter(i=>!(i.event===e&&(typeof t>"u"||t===i.ref)));}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,i=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new C(this,e,function(){return t},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=c.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(d.close,"leave");},i=new C(this,d.leave,v({}),e);return i.receive("ok",()=>t()).receive("timeout",()=>t()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(e,t,i){return t}isMember(e,t,i,s){return this.topic!==e?false:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:i,joinRef:s}),false):true}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=c.joining,this.joinPush.resend(e));}trigger(e,t,i,s){let n=this.onMessage(e,t,i,s);if(t&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(h=>h.event===e);for(let h=0;h<r.length;h++)r[h].callback(n,i,s||this.joinRef());}replyEventName(e){return `chan_reply_${e}`}isClosed(){return this.state===c.closed}isErrored(){return this.state===c.errored}isJoined(){return this.state===c.joined}isJoining(){return this.state===c.joining}isLeaving(){return this.state===c.leaving}},E=class{static request(e,t,i,s,n,r,h){if(g.XDomainRequest){let o=new g.XDomainRequest;return this.xdomainRequest(o,e,t,s,n,r,h)}else {let o=new g.XMLHttpRequest;return this.xhrRequest(o,e,t,i,s,n,r,h)}}static xdomainRequest(e,t,i,s,n,r,h){return e.timeout=n,e.open(t,i),e.onload=()=>{let o=this.parseJSON(e.responseText);h&&h(o);},r&&(e.ontimeout=r),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,i,s,n,r,h,o){return e.open(t,i,true),e.timeout=r,e.setRequestHeader("Content-Type",s),e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{if(e.readyState===_.complete&&o){let a=this.parseJSON(e.responseText);o(a);}},h&&(e.ontimeout=h),e.send(n),e}static parseJSON(e){if(!e||e==="")return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let i=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let n=t?`${t}[${s}]`:s,r=e[s];typeof r=="object"?i.push(this.serialize(r,n)):i.push(encodeURIComponent(n)+"="+encodeURIComponent(r));}return i.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let i=e.match(/\?/)?"&":"?";return `${e}${i}${this.serialize(t)}`}},$=e=>{let t="",i=new Uint8Array(e),s=i.byteLength;for(let n=0;n<s;n++)t+=String.fromCharCode(i[n]);return btoa(t)},m=class{constructor(e){this.endPoint=null,this.token=null,this.skipHeartbeat=true,this.reqs=new Set,this.awaitingBatchAck=false,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=f.connecting,setTimeout(()=>this.poll(),0);}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+k.websocket),"$1/"+k.longpoll)}endpointURL(){return E.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,i){this.close(e,t,i),this.readyState=f.connecting;}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",false);}isActive(){return this.readyState===f.open||this.readyState===f.connecting}poll(){this.ajax("GET","application/json",null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:i,messages:s}=e;this.token=i;}else t=0;switch(t){case 200:s.forEach(n=>{setTimeout(()=>this.onmessage({data:n}),0);}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=f.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",false);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${t}`)}});}send(e){typeof e!="string"&&(e=$(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null;},0));}batchSend(e){this.awaitingBatchAck=true,this.ajax("POST","application/x-ndjson",e.join(`
|
|
2
|
+
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=false,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",false)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]);});}close(e,t,i){for(let n of this.reqs)n.abort();this.readyState=f.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:true},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s);}ajax(e,t,i,s,n){let r,h=()=>{this.reqs.delete(r),s();};r=E.request(e,this.endpointURL(),t,i,this.timeout,h,o=>{this.reqs.delete(r),this.isActive()&&n(o);}),this.reqs.add(r);}};var b={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,r,h]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:r,payload:h})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:r}=e,h=this.META_LENGTH+t.length+i.length+n.length+s.length,o=new ArrayBuffer(this.HEADER_LENGTH+h),a=new DataView(o),l=0;a.setUint8(l++,this.KINDS.push),a.setUint8(l++,t.length),a.setUint8(l++,i.length),a.setUint8(l++,n.length),a.setUint8(l++,s.length),Array.from(t,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(i,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(n,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(s,u=>a.setUint8(l++,u.charCodeAt(0)));var p=new Uint8Array(o.byteLength+r.byteLength);return p.set(new Uint8Array(o),0),p.set(new Uint8Array(r),o.byteLength),p.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=this.HEADER_LENGTH+this.META_LENGTH-1,o=i.decode(e.slice(h,h+s));h=h+s;let a=i.decode(e.slice(h,h+n));h=h+n;let l=i.decode(e.slice(h,h+r));h=h+r;let p=e.slice(h,e.byteLength);return {join_ref:o,ref:null,topic:a,event:l,payload:p}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+n));o=o+n;let p=i.decode(e.slice(o,o+r));o=o+r;let u=i.decode(e.slice(o,o+h));o=o+h;let w=e.slice(o,e.byteLength),A={status:u,response:w};return {join_ref:a,ref:l,topic:p,event:d.reply,payload:A}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=this.HEADER_LENGTH+2,h=i.decode(e.slice(r,r+s));r=r+s;let o=i.decode(e.slice(r,r+n));r=r+n;let a=e.slice(r,e.byteLength);return {join_ref:null,ref:null,topic:h,event:o,payload:a}}},j=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||P,this.transport=t.transport||g.WebSocket||m,this.primaryPassedHealthCheck=false,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||g&&g.sessionStorage,this.establishedConnections=0,this.defaultEncoder=b.encode.bind(b),this.defaultDecoder=b.decode.bind(b),this.closeWasClean=false,this.disconnecting=false,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==m?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;T&&T.addEventListener&&(T.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock);}),T.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect());})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(s,n,r)=>{console.log(`${s}: ${n}`,r);}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=v(t.params||{}),this.endPoint=`${e}/${k.websocket}`,this.vsn=t.vsn||H,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new y(()=>{this.teardown(()=>this.connect());},this.reconnectAfterMs);}getLongPollTransport(){return m}replaceTransport(e){this.connectClock++,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e;}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=E.appendParams(E.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,i){this.connectClock++,this.disconnecting=true,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=false,e&&e();},t,i);}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=v(e)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==m?this.connectWithFallback(m,this.longPollFallbackMs):this.transportConnect());}log(e,t,i){this.logger&&this.logger(e,t,i);}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return false;let t=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(n=>{n.ref===t&&(this.off([s]),e(Date.now()-i));});return true}transportConnect(){this.connectClock++,this.closeWasClean=false,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e);}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t);}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=false,s=true,n,r,h=o=>{this.log("transport",`falling back to ${e.name}...`,o),this.off([n,r]),s=false,this.replaceTransport(e),this.transportConnect();};if(this.getSession(`phx:fallback:${e.name}`))return h("memorized");this.fallbackTimer=setTimeout(h,t),r=this.onError(o=>{this.log("transport","error",o),s&&!i&&(clearTimeout(this.fallbackTimer),h(o));}),this.onOpen(()=>{if(i=true,!s)return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${e.name}`,"true"),this.log("transport",`established ${e.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(h,t),this.ping(o=>{this.log("transport","connected to primary after",o),this.primaryPassedHealthCheck=true,clearTimeout(this.fallbackTimer);});}),this.transportConnect();}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer);}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=false,this.disconnecting=false,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e());}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=false,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),B,"heartbeat timeout"));}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs));}teardown(e,t,i){if(!this.conn)return e&&e();let s=this.connectClock;this.waitForBufferDone(()=>{s===this.connectClock&&(this.conn&&(t?this.conn.close(t,i||""):this.conn.close()),this.waitForSocketClosed(()=>{s===this.connectClock&&(this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e());}));});}waitForBufferDone(e,t=1){if(t===5||!this.conn||!this.conn.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(e,t+1);},150*t);}waitForSocketClosed(e,t=1){if(t===5||!this.conn||this.conn.readyState===f.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(e,t+1);},150*t);}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&t!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(e));}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(e,t,i);}),(t===this.transport||i>0)&&this.triggerChanError();}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(d.error);});}connectionState(){switch(this.conn&&this.conn.readyState){case f.connecting:return "connecting";case f.open:return "open";case f.closing:return "closing";default:return "closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e);}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([i])=>e.indexOf(i)===-1);}channel(e,t={}){let i=new x(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:n,join_ref:r}=e;this.log("push",`${t} ${i} (${r}, ${n})`,s);}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)));}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs));}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[]);}onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:s,payload:n,ref:r,join_ref:h}=t;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,n);for(let o=0;o<this.channels.length;o++){let a=this.channels[o];a.isMember(i,s,n,h)&&a.trigger(s,n,r,h);}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,a]=this.stateChangeCallbacks.message[o];a(t);}});}leaveOpenTopic(e){let t=this.channels.find(i=>i.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave());}};var R=class e{constructor(){this.channels=[];}static connect(t){e.instance||(e.instance=new e,window&&(e.instance.socket=new j(chunk5STN56TL_cjs.a.upload.socket,{params:{token:t},reconnectAfterMs:s=>[1e3,3e3,5e3,1e4][s-1]||1e4}),e.instance.socket.connect()));let i=e.instance.channels.find(s=>s.token===t);if(i)return i;{let s=e.instance.socket.channel(`embed:${t}`);s.join();let n={token:t,channel:s};return s.on("initiate",({upload_id:r})=>{e.instance.channels.push({...n,upload_id:r});}),n}}};
|
|
3
|
+
exports.a=R;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$2,d,b as b$2}from'./chunk-5OEIKFAN.js';import {a as a$3}from'./chunk-ZXCHPIGV.js';import {a as a$5}from'./chunk-MS5NFI3Q.js';import {a as a$1,b as b$1}from'./chunk-HMISRRKC.js';import {h,i,c as c$1}from'./chunk-A4GZBQEB.js';import {a as a$4}from'./chunk-JBV2AYRP.js';import {a,b,c}from'./chunk-NDDFZTBA.js';var Pt=a((ro,Et)=>{Et.exports=function(t,r){if(r=r.split(":")[0],t=+t,!t)return false;switch(r){case "http":case "ws":return t!==80;case "https":case "wss":return t!==443;case "ftp":return t!==21;case "gopher":return t!==70;case "file":return false}return t!==0};});var Rt=a(Te=>{var Wr=Object.prototype.hasOwnProperty,Xr;function Ot(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function kt(e){try{return encodeURIComponent(e)}catch{return null}}function Yr(e){for(var t=/([^=?#&]+)=?([^&]*)/g,r={},n;n=t.exec(e);){var o=Ot(n[1]),s=Ot(n[2]);o===null||s===null||o in r||(r[o]=s);}return r}function Zr(e,t){t=t||"";var r=[],n,o;typeof t!="string"&&(t="?");for(o in e)if(Wr.call(e,o)){if(n=e[o],!n&&(n===null||n===Xr||isNaN(n))&&(n=""),o=kt(o),n=kt(n),o===null||n===null)continue;r.push(o+"="+n);}return r.length?t+r.join("&"):""}Te.stringify=Zr;Te.parse=Yr;});var It=a((oo,Ft)=>{var Ct=Pt(),ge=Rt(),Vr=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Lt=/[\n\r\t]/g,Jr=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Tt=/:\d+$/,Qr=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,en=/^[a-zA-Z]:/;function De(e){return (e||"").toString().replace(Vr,"")}var Ae=[["#","hash"],["?","query"],function(t,r){return A(r.protocol)?t.replace(/\\/g,"/"):t},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],jt={hash:1,query:1};function At(e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={};var r=t.location||{};e=e||r;var n={},o=typeof e,s;if(e.protocol==="blob:")n=new D(unescape(e.pathname),{});else if(o==="string"){n=new D(e,{});for(s in jt)delete n[s];}else if(o==="object"){for(s in e)s in jt||(n[s]=e[s]);n.slashes===void 0&&(n.slashes=Jr.test(e.href));}return n}function A(e){return e==="file:"||e==="ftp:"||e==="http:"||e==="https:"||e==="ws:"||e==="wss:"}function Dt(e,t){e=De(e),e=e.replace(Lt,""),t=t||{};var r=Qr.exec(e),n=r[1]?r[1].toLowerCase():"",o=!!r[2],s=!!r[3],l=0,p;return o?s?(p=r[2]+r[3]+r[4],l=r[2].length+r[3].length):(p=r[2]+r[4],l=r[2].length):s?(p=r[3]+r[4],l=r[3].length):p=r[4],n==="file:"?l>=2&&(p=p.slice(2)):A(n)?p=r[4]:n?o&&(p=p.slice(2)):l>=2&&A(t.protocol)&&(p=r[4]),{protocol:n,slashes:o||A(n),slashesCount:l,rest:p}}function tn(e,t){if(e==="")return t;for(var r=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=r.length,o=r[n-1],s=false,l=0;n--;)r[n]==="."?r.splice(n,1):r[n]===".."?(r.splice(n,1),l++):l&&(n===0&&(s=true),r.splice(n,1),l--);return s&&r.unshift(""),(o==="."||o==="..")&&r.push(""),r.join("/")}function D(e,t,r){if(e=De(e),e=e.replace(Lt,""),!(this instanceof D))return new D(e,t,r);var n,o,s,l,p,h,m=Ae.slice(),g=typeof t,y=this,j=0;for(g!=="object"&&g!=="string"&&(r=t,t=null),r&&typeof r!="function"&&(r=ge.parse),t=At(t),o=Dt(e||"",t),n=!o.protocol&&!o.slashes,y.slashes=o.slashes||n&&t.slashes,y.protocol=o.protocol||t.protocol||"",e=o.rest,(o.protocol==="file:"&&(o.slashesCount!==2||en.test(e))||!o.slashes&&(o.protocol||o.slashesCount<2||!A(y.protocol)))&&(m[3]=[/(.*)/,"pathname"]);j<m.length;j++){if(l=m[j],typeof l=="function"){e=l(e,y);continue}s=l[0],h=l[1],s!==s?y[h]=e:typeof s=="string"?(p=s==="@"?e.lastIndexOf(s):e.indexOf(s),~p&&(typeof l[2]=="number"?(y[h]=e.slice(0,p),e=e.slice(p+l[2])):(y[h]=e.slice(p),e=e.slice(0,p)))):(p=s.exec(e))&&(y[h]=p[1],e=e.slice(0,p.index)),y[h]=y[h]||n&&l[3]&&t[h]||"",l[4]&&(y[h]=y[h].toLowerCase());}r&&(y.query=r(y.query)),n&&t.slashes&&y.pathname.charAt(0)!=="/"&&(y.pathname!==""||t.pathname!=="")&&(y.pathname=tn(y.pathname,t.pathname)),y.pathname.charAt(0)!=="/"&&A(y.protocol)&&(y.pathname="/"+y.pathname),Ct(y.port,y.protocol)||(y.host=y.hostname,y.port=""),y.username=y.password="",y.auth&&(p=y.auth.indexOf(":"),~p?(y.username=y.auth.slice(0,p),y.username=encodeURIComponent(decodeURIComponent(y.username)),y.password=y.auth.slice(p+1),y.password=encodeURIComponent(decodeURIComponent(y.password))):y.username=encodeURIComponent(decodeURIComponent(y.auth)),y.auth=y.password?y.username+":"+y.password:y.username),y.origin=y.protocol!=="file:"&&A(y.protocol)&&y.host?y.protocol+"//"+y.host:"null",y.href=y.toString();}function rn(e,t,r){var n=this;switch(e){case "query":typeof t=="string"&&t.length&&(t=(r||ge.parse)(t)),n[e]=t;break;case "port":n[e]=t,Ct(t,n.protocol)?t&&(n.host=n.hostname+":"+t):(n.host=n.hostname,n[e]="");break;case "hostname":n[e]=t,n.port&&(t+=":"+n.port),n.host=t;break;case "host":n[e]=t,Tt.test(t)?(t=t.split(":"),n.port=t.pop(),n.hostname=t.join(":")):(n.hostname=t,n.port="");break;case "protocol":n.protocol=t.toLowerCase(),n.slashes=!r;break;case "pathname":case "hash":if(t){var o=e==="pathname"?"/":"#";n[e]=t.charAt(0)!==o?o+t:t;}else n[e]=t;break;case "username":case "password":n[e]=encodeURIComponent(t);break;case "auth":var s=t.indexOf(":");~s?(n.username=t.slice(0,s),n.username=encodeURIComponent(decodeURIComponent(n.username)),n.password=t.slice(s+1),n.password=encodeURIComponent(decodeURIComponent(n.password))):n.username=encodeURIComponent(decodeURIComponent(t));}for(var l=0;l<Ae.length;l++){var p=Ae[l];p[4]&&(n[p[1]]=n[p[1]].toLowerCase());}return n.auth=n.password?n.username+":"+n.password:n.username,n.origin=n.protocol!=="file:"&&A(n.protocol)&&n.host?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function nn(e){(!e||typeof e!="function")&&(e=ge.stringify);var t,r=this,n=r.host,o=r.protocol;o&&o.charAt(o.length-1)!==":"&&(o+=":");var s=o+(r.protocol&&r.slashes||A(r.protocol)?"//":"");return r.username?(s+=r.username,r.password&&(s+=":"+r.password),s+="@"):r.password?(s+=":"+r.password,s+="@"):r.protocol!=="file:"&&A(r.protocol)&&!n&&r.pathname!=="/"&&(s+="@"),(n[n.length-1]===":"||Tt.test(r.hostname)&&!r.port)&&(n+=":"),s+=n+r.pathname,t=typeof r.query=="object"?e(r.query):r.query,t&&(s+=t.charAt(0)!=="?"?"?"+t:t),r.hash&&(s+=r.hash),s}D.prototype={set:rn,toString:nn};D.extractProtocol=Dt;D.location=At;D.trimLeft=De;D.qs=ge;Ft.exports=D;});function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function br(e,t,r){return Object.defineProperty(e,"prototype",{writable:false}),e}function xr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Sr(e,t,r){return t=ue(t),Ur(e,ke()?Reflect.construct(t,r||[],ue(e).constructor):t.apply(e,r))}function Ur(e,t){if(t&&(Z(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Er(e)}function Er(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Pr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&se(e,t);}function Oe(e){var t=typeof Map=="function"?new Map:void 0;return Oe=function(n){if(n===null||!kr(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,o);}function o(){return Or(n,arguments,ue(this).constructor)}return o.prototype=Object.create(n.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}}),se(o,n)},Oe(e)}function Or(e,t,r){if(ke())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&se(o,r.prototype),o}function ke(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch{}return (ke=function(){return !!e})()}function kr(e){try{return Function.toString.call(e).indexOf("[native code]")!==-1}catch{return typeof e=="function"}}function se(e,t){return se=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},se(e,t)}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(e)}var Rr=function(e){function t(r){var n,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(xr(this,t),n=Sr(this,t,[r]),n.originalRequest=s,n.originalResponse=l,n.causingError=o,o!=null&&(r+=", caused by ".concat(o.toString())),s!=null){var p=s.getHeader("X-Request-ID")||"n/a",h=s.getMethod(),m=s.getURL(),g=l?l.getStatus():"n/a",y=l?l.getBody()||"":"n/a";r+=", originated from request (method: ".concat(h,", url: ").concat(m,", response code: ").concat(g,", response text: ").concat(y,", request id: ").concat(p,")");}return n.message=r,n}return Pr(t,e),br(t)}(Oe(Error)),V=Rr;function z(e){}function le(e){"@babel/helpers - typeof";return le=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},le(e)}function Cr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ot(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Tr(n.key),n);}}function Lr(e,t,r){return t&&ot(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Tr(e){var t=Ar(e,"string");return le(t)=="symbol"?t:t+""}function Ar(e,t){if(le(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(le(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var it=function(){function e(){Cr(this,e);}return Lr(e,[{key:"listAllUploads",value:function(){return Promise.resolve([])}},{key:"findUploadsByFingerprint",value:function(r){return Promise.resolve([])}},{key:"removeUpload",value:function(r){return Promise.resolve()}},{key:"addUpload",value:function(r,n){return Promise.resolve(null)}}])}();var ct="3.7.5",Dr=ct,Fr=typeof atob=="function",Ir=typeof btoa=="function",Q=typeof Buffer=="function",at=typeof TextDecoder=="function"?new TextDecoder:void 0,st=typeof TextEncoder=="function"?new TextEncoder:void 0,Nr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",fe=Array.prototype.slice.call(Nr),me=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(fe),Br=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,U=String.fromCharCode.bind(String),ut=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),pt=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),ht=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),dt=e=>{let t,r,n,o,s="",l=e.length%3;for(let p=0;p<e.length;){if((r=e.charCodeAt(p++))>255||(n=e.charCodeAt(p++))>255||(o=e.charCodeAt(p++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|o,s+=fe[t>>18&63]+fe[t>>12&63]+fe[t>>6&63]+fe[t&63];}return l?s.slice(0,l-3)+"===".substring(l):s},Ce=Ir?e=>btoa(e):Q?e=>Buffer.from(e,"binary").toString("base64"):dt,Re=Q?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,o=e.length;n<o;n+=4096)r.push(U.apply(null,e.subarray(n,n+4096)));return Ce(r.join(""))},ve=(e,t=false)=>t?pt(Re(e)):Re(e),zr=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?U(192|t>>>6)+U(128|t&63):U(224|t>>>12&15)+U(128|t>>>6&63)+U(128|t&63)}else {var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return U(240|t>>>18&7)+U(128|t>>>12&63)+U(128|t>>>6&63)+U(128|t&63)}},Hr=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,yt=e=>e.replace(Hr,zr),lt=Q?e=>Buffer.from(e,"utf8").toString("base64"):st?e=>Re(st.encode(e)):e=>Ce(yt(e)),J=(e,t=false)=>t?pt(lt(e)):lt(e),ft=e=>J(e,true),qr=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Mr=e=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return U((r>>>10)+55296)+U((r&1023)+56320);case 3:return U((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return U((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},mt=e=>e.replace(qr,Mr),vt=e=>{if(e=e.replace(/\s+/g,""),!Br.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,o;for(let s=0;s<e.length;)t=me[e.charAt(s++)]<<18|me[e.charAt(s++)]<<12|(n=me[e.charAt(s++)])<<6|(o=me[e.charAt(s++)]),r+=n===64?U(t>>16&255):o===64?U(t>>16&255,t>>8&255):U(t>>16&255,t>>8&255,t&255);return r},Le=Fr?e=>atob(ht(e)):Q?e=>Buffer.from(e,"base64").toString("binary"):vt,gt=Q?e=>ut(Buffer.from(e,"base64")):e=>ut(Le(e).split("").map(t=>t.charCodeAt(0))),bt=e=>gt(_t(e)),Gr=Q?e=>Buffer.from(e,"base64").toString("utf8"):at?e=>at.decode(gt(e)):e=>mt(Le(e)),_t=e=>ht(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),je=e=>Gr(_t(e)),Kr=e=>{if(typeof e!="string")return false;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return !/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},wt=e=>({value:e,enumerable:false,writable:true,configurable:true}),xt=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,wt(r));e("fromBase64",function(){return je(this)}),e("toBase64",function(t){return J(this,t)}),e("toBase64URI",function(){return J(this,true)}),e("toBase64URL",function(){return J(this,true)}),e("toUint8Array",function(){return bt(this)});},St=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,wt(r));e("toBase64",function(t){return ve(this,t)}),e("toBase64URI",function(){return ve(this,true)}),e("toBase64URL",function(){return ve(this,true)});},$r=()=>{xt(),St();},Ut={version:ct,VERSION:Dr,atob:Le,atobPolyfill:vt,btoa:Ce,btoaPolyfill:dt,fromBase64:je,toBase64:J,encode:J,encodeURI:ft,encodeURL:ft,utob:yt,btou:mt,decode:je,isValid:Kr,fromUint8Array:ve,toUint8Array:bt,extendString:xt,extendUint8Array:St,extendBuiltins:$r};var Zt=b(It());function Fe(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,r=e==="x"?t:t&3|8;return r.toString(16)})}function Ie(){Ie=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(u,i,a){u[i]=a.value;},s=typeof Symbol=="function"?Symbol:{},l=s.iterator||"@@iterator",p=s.asyncIterator||"@@asyncIterator",h=s.toStringTag||"@@toStringTag";function m(u,i,a){return Object.defineProperty(u,i,{value:a,enumerable:true,configurable:true,writable:true}),u[i]}try{m({},"");}catch{m=function(a,f,d){return a[f]=d};}function g(u,i,a,f){var d=i&&i.prototype instanceof F?i:F,c=Object.create(d.prototype),v=new G(f||[]);return o(c,"_invoke",{value:Ue(u,a,v)}),c}function y(u,i,a){try{return {type:"normal",arg:u.call(i,a)}}catch(f){return {type:"throw",arg:f}}}t.wrap=g;var j="suspendedStart",oe="suspendedYield",H="executing",L="completed",w={};function F(){}function k(){}function x(){}var C={};m(C,l,function(){return this});var q=Object.getPrototypeOf,I=q&&q(q(K([])));I&&I!==r&&n.call(I,l)&&(C=I);var R=x.prototype=F.prototype=Object.create(C);function ie(u){["next","throw","return"].forEach(function(i){m(u,i,function(a){return this._invoke(i,a)});});}function N(u,i){function a(d,c,v,b){var _=y(u[d],u,c);if(_.type!=="throw"){var E=_.arg,S=E.value;return S&&X(S)=="object"&&n.call(S,"__await")?i.resolve(S.__await).then(function(P){a("next",P,v,b);},function(P){a("throw",P,v,b);}):i.resolve(S).then(function(P){E.value=P,v(E);},function(P){return a("throw",P,v,b)})}b(_.arg);}var f;o(this,"_invoke",{value:function(c,v){function b(){return new i(function(_,E){a(c,v,_,E);})}return f=f?f.then(b,b):b()}});}function Ue(u,i,a){var f=j;return function(d,c){if(f===H)throw Error("Generator is already running");if(f===L){if(d==="throw")throw c;return {value:e,done:true}}for(a.method=d,a.arg=c;;){var v=a.delegate;if(v){var b=ae(v,a);if(b){if(b===w)continue;return b}}if(a.method==="next")a.sent=a._sent=a.arg;else if(a.method==="throw"){if(f===j)throw f=L,a.arg;a.dispatchException(a.arg);}else a.method==="return"&&a.abrupt("return",a.arg);f=H;var _=y(u,i,a);if(_.type==="normal"){if(f=a.done?L:oe,_.arg===w)continue;return {value:_.arg,done:a.done}}_.type==="throw"&&(f=L,a.method="throw",a.arg=_.arg);}}}function ae(u,i){var a=i.method,f=u.iterator[a];if(f===e)return i.delegate=null,a==="throw"&&u.iterator.return&&(i.method="return",i.arg=e,ae(u,i),i.method==="throw")||a!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+a+"' method")),w;var d=y(f,u.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,w;var c=d.arg;return c?c.done?(i[u.resultName]=c.value,i.next=u.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,w):c:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,w)}function Ee(u){var i={tryLoc:u[0]};1 in u&&(i.catchLoc=u[1]),2 in u&&(i.finallyLoc=u[2],i.afterLoc=u[3]),this.tryEntries.push(i);}function M(u){var i=u.completion||{};i.type="normal",delete i.arg,u.completion=i;}function G(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(Ee,this),this.reset(true);}function K(u){if(u||u===""){var i=u[l];if(i)return i.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var a=-1,f=function d(){for(;++a<u.length;)if(n.call(u,a))return d.value=u[a],d.done=false,d;return d.value=e,d.done=true,d};return f.next=f}}throw new TypeError(X(u)+" is not iterable")}return k.prototype=x,o(R,"constructor",{value:x,configurable:true}),o(x,"constructor",{value:k,configurable:true}),k.displayName=m(x,h,"GeneratorFunction"),t.isGeneratorFunction=function(u){var i=typeof u=="function"&&u.constructor;return !!i&&(i===k||(i.displayName||i.name)==="GeneratorFunction")},t.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,x):(u.__proto__=x,m(u,h,"GeneratorFunction")),u.prototype=Object.create(R),u},t.awrap=function(u){return {__await:u}},ie(N.prototype),m(N.prototype,p,function(){return this}),t.AsyncIterator=N,t.async=function(u,i,a,f,d){d===void 0&&(d=Promise);var c=new N(g(u,i,a,f),d);return t.isGeneratorFunction(i)?c:c.next().then(function(v){return v.done?v.value:c.next()})},ie(R),m(R,h,"Generator"),m(R,l,function(){return this}),m(R,"toString",function(){return "[object Generator]"}),t.keys=function(u){var i=Object(u),a=[];for(var f in i)a.push(f);return a.reverse(),function d(){for(;a.length;){var c=a.pop();if(c in i)return d.value=c,d.done=false,d}return d.done=true,d}},t.values=K,G.prototype={constructor:G,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=false,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!i)for(var a in this)a.charAt(0)==="t"&&n.call(this,a)&&!isNaN(+a.slice(1))&&(this[a]=e);},stop:function(){this.done=true;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var a=this;function f(E,S){return v.type="throw",v.arg=i,a.next=E,S&&(a.method="next",a.arg=e),!!S}for(var d=this.tryEntries.length-1;d>=0;--d){var c=this.tryEntries[d],v=c.completion;if(c.tryLoc==="root")return f("end");if(c.tryLoc<=this.prev){var b=n.call(c,"catchLoc"),_=n.call(c,"finallyLoc");if(b&&_){if(this.prev<c.catchLoc)return f(c.catchLoc,true);if(this.prev<c.finallyLoc)return f(c.finallyLoc)}else if(b){if(this.prev<c.catchLoc)return f(c.catchLoc,true)}else {if(!_)throw Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return f(c.finallyLoc)}}}},abrupt:function(i,a){for(var f=this.tryEntries.length-1;f>=0;--f){var d=this.tryEntries[f];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var c=d;break}}c&&(i==="break"||i==="continue")&&c.tryLoc<=a&&a<=c.finallyLoc&&(c=null);var v=c?c.completion:{};return v.type=i,v.arg=a,c?(this.method="next",this.next=c.finallyLoc,w):this.complete(v)},complete:function(i,a){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&a&&(this.next=a),w},finish:function(i){for(var a=this.tryEntries.length-1;a>=0;--a){var f=this.tryEntries[a];if(f.finallyLoc===i)return this.complete(f.completion,f.afterLoc),M(f),w}},catch:function(i){for(var a=this.tryEntries.length-1;a>=0;--a){var f=this.tryEntries[a];if(f.tryLoc===i){var d=f.completion;if(d.type==="throw"){var c=d.arg;M(f);}return c}}throw Error("illegal catch attempt")},delegateYield:function(i,a,f){return this.delegate={iterator:K(i),resultName:a,nextLoc:f},this.method==="next"&&(this.arg=e),w}},t}function Nt(e,t,r,n,o,s,l){try{var p=e[s](l),h=p.value;}catch(m){r(m);return}p.done?t(h):Promise.resolve(h).then(n,o);}function on(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var s=e.apply(t,r);function l(h){Nt(s,n,o,l,p,"next",h);}function p(h){Nt(s,n,o,l,p,"throw",h);}l(void 0);})}}function Wt(e,t){return un(e)||sn(e,t)||Xt(e,t)||an()}function an(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1
|
+
import {a as a$2,d,b as b$2}from'./chunk-5OEIKFAN.js';import {a as a$3}from'./chunk-HKHV3KLY.js';import {a as a$5}from'./chunk-MS5NFI3Q.js';import {a as a$1,b as b$1}from'./chunk-HMISRRKC.js';import {h,i,c as c$1}from'./chunk-A4GZBQEB.js';import {a as a$4}from'./chunk-JBV2AYRP.js';import {a,b,c}from'./chunk-NDDFZTBA.js';var Pt=a((ro,Et)=>{Et.exports=function(t,r){if(r=r.split(":")[0],t=+t,!t)return false;switch(r){case "http":case "ws":return t!==80;case "https":case "wss":return t!==443;case "ftp":return t!==21;case "gopher":return t!==70;case "file":return false}return t!==0};});var Rt=a(Te=>{var Wr=Object.prototype.hasOwnProperty,Xr;function Ot(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function kt(e){try{return encodeURIComponent(e)}catch{return null}}function Yr(e){for(var t=/([^=?#&]+)=?([^&]*)/g,r={},n;n=t.exec(e);){var o=Ot(n[1]),s=Ot(n[2]);o===null||s===null||o in r||(r[o]=s);}return r}function Zr(e,t){t=t||"";var r=[],n,o;typeof t!="string"&&(t="?");for(o in e)if(Wr.call(e,o)){if(n=e[o],!n&&(n===null||n===Xr||isNaN(n))&&(n=""),o=kt(o),n=kt(n),o===null||n===null)continue;r.push(o+"="+n);}return r.length?t+r.join("&"):""}Te.stringify=Zr;Te.parse=Yr;});var It=a((oo,Ft)=>{var Ct=Pt(),ge=Rt(),Vr=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Lt=/[\n\r\t]/g,Jr=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Tt=/:\d+$/,Qr=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,en=/^[a-zA-Z]:/;function De(e){return (e||"").toString().replace(Vr,"")}var Ae=[["#","hash"],["?","query"],function(t,r){return A(r.protocol)?t.replace(/\\/g,"/"):t},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],jt={hash:1,query:1};function At(e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={};var r=t.location||{};e=e||r;var n={},o=typeof e,s;if(e.protocol==="blob:")n=new D(unescape(e.pathname),{});else if(o==="string"){n=new D(e,{});for(s in jt)delete n[s];}else if(o==="object"){for(s in e)s in jt||(n[s]=e[s]);n.slashes===void 0&&(n.slashes=Jr.test(e.href));}return n}function A(e){return e==="file:"||e==="ftp:"||e==="http:"||e==="https:"||e==="ws:"||e==="wss:"}function Dt(e,t){e=De(e),e=e.replace(Lt,""),t=t||{};var r=Qr.exec(e),n=r[1]?r[1].toLowerCase():"",o=!!r[2],s=!!r[3],l=0,p;return o?s?(p=r[2]+r[3]+r[4],l=r[2].length+r[3].length):(p=r[2]+r[4],l=r[2].length):s?(p=r[3]+r[4],l=r[3].length):p=r[4],n==="file:"?l>=2&&(p=p.slice(2)):A(n)?p=r[4]:n?o&&(p=p.slice(2)):l>=2&&A(t.protocol)&&(p=r[4]),{protocol:n,slashes:o||A(n),slashesCount:l,rest:p}}function tn(e,t){if(e==="")return t;for(var r=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=r.length,o=r[n-1],s=false,l=0;n--;)r[n]==="."?r.splice(n,1):r[n]===".."?(r.splice(n,1),l++):l&&(n===0&&(s=true),r.splice(n,1),l--);return s&&r.unshift(""),(o==="."||o==="..")&&r.push(""),r.join("/")}function D(e,t,r){if(e=De(e),e=e.replace(Lt,""),!(this instanceof D))return new D(e,t,r);var n,o,s,l,p,h,m=Ae.slice(),g=typeof t,y=this,j=0;for(g!=="object"&&g!=="string"&&(r=t,t=null),r&&typeof r!="function"&&(r=ge.parse),t=At(t),o=Dt(e||"",t),n=!o.protocol&&!o.slashes,y.slashes=o.slashes||n&&t.slashes,y.protocol=o.protocol||t.protocol||"",e=o.rest,(o.protocol==="file:"&&(o.slashesCount!==2||en.test(e))||!o.slashes&&(o.protocol||o.slashesCount<2||!A(y.protocol)))&&(m[3]=[/(.*)/,"pathname"]);j<m.length;j++){if(l=m[j],typeof l=="function"){e=l(e,y);continue}s=l[0],h=l[1],s!==s?y[h]=e:typeof s=="string"?(p=s==="@"?e.lastIndexOf(s):e.indexOf(s),~p&&(typeof l[2]=="number"?(y[h]=e.slice(0,p),e=e.slice(p+l[2])):(y[h]=e.slice(p),e=e.slice(0,p)))):(p=s.exec(e))&&(y[h]=p[1],e=e.slice(0,p.index)),y[h]=y[h]||n&&l[3]&&t[h]||"",l[4]&&(y[h]=y[h].toLowerCase());}r&&(y.query=r(y.query)),n&&t.slashes&&y.pathname.charAt(0)!=="/"&&(y.pathname!==""||t.pathname!=="")&&(y.pathname=tn(y.pathname,t.pathname)),y.pathname.charAt(0)!=="/"&&A(y.protocol)&&(y.pathname="/"+y.pathname),Ct(y.port,y.protocol)||(y.host=y.hostname,y.port=""),y.username=y.password="",y.auth&&(p=y.auth.indexOf(":"),~p?(y.username=y.auth.slice(0,p),y.username=encodeURIComponent(decodeURIComponent(y.username)),y.password=y.auth.slice(p+1),y.password=encodeURIComponent(decodeURIComponent(y.password))):y.username=encodeURIComponent(decodeURIComponent(y.auth)),y.auth=y.password?y.username+":"+y.password:y.username),y.origin=y.protocol!=="file:"&&A(y.protocol)&&y.host?y.protocol+"//"+y.host:"null",y.href=y.toString();}function rn(e,t,r){var n=this;switch(e){case "query":typeof t=="string"&&t.length&&(t=(r||ge.parse)(t)),n[e]=t;break;case "port":n[e]=t,Ct(t,n.protocol)?t&&(n.host=n.hostname+":"+t):(n.host=n.hostname,n[e]="");break;case "hostname":n[e]=t,n.port&&(t+=":"+n.port),n.host=t;break;case "host":n[e]=t,Tt.test(t)?(t=t.split(":"),n.port=t.pop(),n.hostname=t.join(":")):(n.hostname=t,n.port="");break;case "protocol":n.protocol=t.toLowerCase(),n.slashes=!r;break;case "pathname":case "hash":if(t){var o=e==="pathname"?"/":"#";n[e]=t.charAt(0)!==o?o+t:t;}else n[e]=t;break;case "username":case "password":n[e]=encodeURIComponent(t);break;case "auth":var s=t.indexOf(":");~s?(n.username=t.slice(0,s),n.username=encodeURIComponent(decodeURIComponent(n.username)),n.password=t.slice(s+1),n.password=encodeURIComponent(decodeURIComponent(n.password))):n.username=encodeURIComponent(decodeURIComponent(t));}for(var l=0;l<Ae.length;l++){var p=Ae[l];p[4]&&(n[p[1]]=n[p[1]].toLowerCase());}return n.auth=n.password?n.username+":"+n.password:n.username,n.origin=n.protocol!=="file:"&&A(n.protocol)&&n.host?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function nn(e){(!e||typeof e!="function")&&(e=ge.stringify);var t,r=this,n=r.host,o=r.protocol;o&&o.charAt(o.length-1)!==":"&&(o+=":");var s=o+(r.protocol&&r.slashes||A(r.protocol)?"//":"");return r.username?(s+=r.username,r.password&&(s+=":"+r.password),s+="@"):r.password?(s+=":"+r.password,s+="@"):r.protocol!=="file:"&&A(r.protocol)&&!n&&r.pathname!=="/"&&(s+="@"),(n[n.length-1]===":"||Tt.test(r.hostname)&&!r.port)&&(n+=":"),s+=n+r.pathname,t=typeof r.query=="object"?e(r.query):r.query,t&&(s+=t.charAt(0)!=="?"?"?"+t:t),r.hash&&(s+=r.hash),s}D.prototype={set:rn,toString:nn};D.extractProtocol=Dt;D.location=At;D.trimLeft=De;D.qs=ge;Ft.exports=D;});function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function br(e,t,r){return Object.defineProperty(e,"prototype",{writable:false}),e}function xr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Sr(e,t,r){return t=ue(t),Ur(e,ke()?Reflect.construct(t,r||[],ue(e).constructor):t.apply(e,r))}function Ur(e,t){if(t&&(Z(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Er(e)}function Er(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Pr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&se(e,t);}function Oe(e){var t=typeof Map=="function"?new Map:void 0;return Oe=function(n){if(n===null||!kr(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,o);}function o(){return Or(n,arguments,ue(this).constructor)}return o.prototype=Object.create(n.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}}),se(o,n)},Oe(e)}function Or(e,t,r){if(ke())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&se(o,r.prototype),o}function ke(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch{}return (ke=function(){return !!e})()}function kr(e){try{return Function.toString.call(e).indexOf("[native code]")!==-1}catch{return typeof e=="function"}}function se(e,t){return se=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},se(e,t)}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(e)}var Rr=function(e){function t(r){var n,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(xr(this,t),n=Sr(this,t,[r]),n.originalRequest=s,n.originalResponse=l,n.causingError=o,o!=null&&(r+=", caused by ".concat(o.toString())),s!=null){var p=s.getHeader("X-Request-ID")||"n/a",h=s.getMethod(),m=s.getURL(),g=l?l.getStatus():"n/a",y=l?l.getBody()||"":"n/a";r+=", originated from request (method: ".concat(h,", url: ").concat(m,", response code: ").concat(g,", response text: ").concat(y,", request id: ").concat(p,")");}return n.message=r,n}return Pr(t,e),br(t)}(Oe(Error)),V=Rr;function z(e){}function le(e){"@babel/helpers - typeof";return le=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},le(e)}function Cr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ot(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Tr(n.key),n);}}function Lr(e,t,r){return t&&ot(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Tr(e){var t=Ar(e,"string");return le(t)=="symbol"?t:t+""}function Ar(e,t){if(le(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(le(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var it=function(){function e(){Cr(this,e);}return Lr(e,[{key:"listAllUploads",value:function(){return Promise.resolve([])}},{key:"findUploadsByFingerprint",value:function(r){return Promise.resolve([])}},{key:"removeUpload",value:function(r){return Promise.resolve()}},{key:"addUpload",value:function(r,n){return Promise.resolve(null)}}])}();var ct="3.7.5",Dr=ct,Fr=typeof atob=="function",Ir=typeof btoa=="function",Q=typeof Buffer=="function",at=typeof TextDecoder=="function"?new TextDecoder:void 0,st=typeof TextEncoder=="function"?new TextEncoder:void 0,Nr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",fe=Array.prototype.slice.call(Nr),me=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(fe),Br=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,U=String.fromCharCode.bind(String),ut=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),pt=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),ht=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),dt=e=>{let t,r,n,o,s="",l=e.length%3;for(let p=0;p<e.length;){if((r=e.charCodeAt(p++))>255||(n=e.charCodeAt(p++))>255||(o=e.charCodeAt(p++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|o,s+=fe[t>>18&63]+fe[t>>12&63]+fe[t>>6&63]+fe[t&63];}return l?s.slice(0,l-3)+"===".substring(l):s},Ce=Ir?e=>btoa(e):Q?e=>Buffer.from(e,"binary").toString("base64"):dt,Re=Q?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,o=e.length;n<o;n+=4096)r.push(U.apply(null,e.subarray(n,n+4096)));return Ce(r.join(""))},ve=(e,t=false)=>t?pt(Re(e)):Re(e),zr=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?U(192|t>>>6)+U(128|t&63):U(224|t>>>12&15)+U(128|t>>>6&63)+U(128|t&63)}else {var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return U(240|t>>>18&7)+U(128|t>>>12&63)+U(128|t>>>6&63)+U(128|t&63)}},Hr=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,yt=e=>e.replace(Hr,zr),lt=Q?e=>Buffer.from(e,"utf8").toString("base64"):st?e=>Re(st.encode(e)):e=>Ce(yt(e)),J=(e,t=false)=>t?pt(lt(e)):lt(e),ft=e=>J(e,true),qr=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Mr=e=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return U((r>>>10)+55296)+U((r&1023)+56320);case 3:return U((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return U((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},mt=e=>e.replace(qr,Mr),vt=e=>{if(e=e.replace(/\s+/g,""),!Br.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,o;for(let s=0;s<e.length;)t=me[e.charAt(s++)]<<18|me[e.charAt(s++)]<<12|(n=me[e.charAt(s++)])<<6|(o=me[e.charAt(s++)]),r+=n===64?U(t>>16&255):o===64?U(t>>16&255,t>>8&255):U(t>>16&255,t>>8&255,t&255);return r},Le=Fr?e=>atob(ht(e)):Q?e=>Buffer.from(e,"base64").toString("binary"):vt,gt=Q?e=>ut(Buffer.from(e,"base64")):e=>ut(Le(e).split("").map(t=>t.charCodeAt(0))),bt=e=>gt(_t(e)),Gr=Q?e=>Buffer.from(e,"base64").toString("utf8"):at?e=>at.decode(gt(e)):e=>mt(Le(e)),_t=e=>ht(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),je=e=>Gr(_t(e)),Kr=e=>{if(typeof e!="string")return false;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return !/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},wt=e=>({value:e,enumerable:false,writable:true,configurable:true}),xt=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,wt(r));e("fromBase64",function(){return je(this)}),e("toBase64",function(t){return J(this,t)}),e("toBase64URI",function(){return J(this,true)}),e("toBase64URL",function(){return J(this,true)}),e("toUint8Array",function(){return bt(this)});},St=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,wt(r));e("toBase64",function(t){return ve(this,t)}),e("toBase64URI",function(){return ve(this,true)}),e("toBase64URL",function(){return ve(this,true)});},$r=()=>{xt(),St();},Ut={version:ct,VERSION:Dr,atob:Le,atobPolyfill:vt,btoa:Ce,btoaPolyfill:dt,fromBase64:je,toBase64:J,encode:J,encodeURI:ft,encodeURL:ft,utob:yt,btou:mt,decode:je,isValid:Kr,fromUint8Array:ve,toUint8Array:bt,extendString:xt,extendUint8Array:St,extendBuiltins:$r};var Zt=b(It());function Fe(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,r=e==="x"?t:t&3|8;return r.toString(16)})}function Ie(){Ie=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(u,i,a){u[i]=a.value;},s=typeof Symbol=="function"?Symbol:{},l=s.iterator||"@@iterator",p=s.asyncIterator||"@@asyncIterator",h=s.toStringTag||"@@toStringTag";function m(u,i,a){return Object.defineProperty(u,i,{value:a,enumerable:true,configurable:true,writable:true}),u[i]}try{m({},"");}catch{m=function(a,f,d){return a[f]=d};}function g(u,i,a,f){var d=i&&i.prototype instanceof F?i:F,c=Object.create(d.prototype),v=new G(f||[]);return o(c,"_invoke",{value:Ue(u,a,v)}),c}function y(u,i,a){try{return {type:"normal",arg:u.call(i,a)}}catch(f){return {type:"throw",arg:f}}}t.wrap=g;var j="suspendedStart",oe="suspendedYield",H="executing",L="completed",w={};function F(){}function k(){}function x(){}var C={};m(C,l,function(){return this});var q=Object.getPrototypeOf,I=q&&q(q(K([])));I&&I!==r&&n.call(I,l)&&(C=I);var R=x.prototype=F.prototype=Object.create(C);function ie(u){["next","throw","return"].forEach(function(i){m(u,i,function(a){return this._invoke(i,a)});});}function N(u,i){function a(d,c,v,b){var _=y(u[d],u,c);if(_.type!=="throw"){var E=_.arg,S=E.value;return S&&X(S)=="object"&&n.call(S,"__await")?i.resolve(S.__await).then(function(P){a("next",P,v,b);},function(P){a("throw",P,v,b);}):i.resolve(S).then(function(P){E.value=P,v(E);},function(P){return a("throw",P,v,b)})}b(_.arg);}var f;o(this,"_invoke",{value:function(c,v){function b(){return new i(function(_,E){a(c,v,_,E);})}return f=f?f.then(b,b):b()}});}function Ue(u,i,a){var f=j;return function(d,c){if(f===H)throw Error("Generator is already running");if(f===L){if(d==="throw")throw c;return {value:e,done:true}}for(a.method=d,a.arg=c;;){var v=a.delegate;if(v){var b=ae(v,a);if(b){if(b===w)continue;return b}}if(a.method==="next")a.sent=a._sent=a.arg;else if(a.method==="throw"){if(f===j)throw f=L,a.arg;a.dispatchException(a.arg);}else a.method==="return"&&a.abrupt("return",a.arg);f=H;var _=y(u,i,a);if(_.type==="normal"){if(f=a.done?L:oe,_.arg===w)continue;return {value:_.arg,done:a.done}}_.type==="throw"&&(f=L,a.method="throw",a.arg=_.arg);}}}function ae(u,i){var a=i.method,f=u.iterator[a];if(f===e)return i.delegate=null,a==="throw"&&u.iterator.return&&(i.method="return",i.arg=e,ae(u,i),i.method==="throw")||a!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+a+"' method")),w;var d=y(f,u.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,w;var c=d.arg;return c?c.done?(i[u.resultName]=c.value,i.next=u.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,w):c:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,w)}function Ee(u){var i={tryLoc:u[0]};1 in u&&(i.catchLoc=u[1]),2 in u&&(i.finallyLoc=u[2],i.afterLoc=u[3]),this.tryEntries.push(i);}function M(u){var i=u.completion||{};i.type="normal",delete i.arg,u.completion=i;}function G(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(Ee,this),this.reset(true);}function K(u){if(u||u===""){var i=u[l];if(i)return i.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var a=-1,f=function d(){for(;++a<u.length;)if(n.call(u,a))return d.value=u[a],d.done=false,d;return d.value=e,d.done=true,d};return f.next=f}}throw new TypeError(X(u)+" is not iterable")}return k.prototype=x,o(R,"constructor",{value:x,configurable:true}),o(x,"constructor",{value:k,configurable:true}),k.displayName=m(x,h,"GeneratorFunction"),t.isGeneratorFunction=function(u){var i=typeof u=="function"&&u.constructor;return !!i&&(i===k||(i.displayName||i.name)==="GeneratorFunction")},t.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,x):(u.__proto__=x,m(u,h,"GeneratorFunction")),u.prototype=Object.create(R),u},t.awrap=function(u){return {__await:u}},ie(N.prototype),m(N.prototype,p,function(){return this}),t.AsyncIterator=N,t.async=function(u,i,a,f,d){d===void 0&&(d=Promise);var c=new N(g(u,i,a,f),d);return t.isGeneratorFunction(i)?c:c.next().then(function(v){return v.done?v.value:c.next()})},ie(R),m(R,h,"Generator"),m(R,l,function(){return this}),m(R,"toString",function(){return "[object Generator]"}),t.keys=function(u){var i=Object(u),a=[];for(var f in i)a.push(f);return a.reverse(),function d(){for(;a.length;){var c=a.pop();if(c in i)return d.value=c,d.done=false,d}return d.done=true,d}},t.values=K,G.prototype={constructor:G,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=false,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!i)for(var a in this)a.charAt(0)==="t"&&n.call(this,a)&&!isNaN(+a.slice(1))&&(this[a]=e);},stop:function(){this.done=true;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var a=this;function f(E,S){return v.type="throw",v.arg=i,a.next=E,S&&(a.method="next",a.arg=e),!!S}for(var d=this.tryEntries.length-1;d>=0;--d){var c=this.tryEntries[d],v=c.completion;if(c.tryLoc==="root")return f("end");if(c.tryLoc<=this.prev){var b=n.call(c,"catchLoc"),_=n.call(c,"finallyLoc");if(b&&_){if(this.prev<c.catchLoc)return f(c.catchLoc,true);if(this.prev<c.finallyLoc)return f(c.finallyLoc)}else if(b){if(this.prev<c.catchLoc)return f(c.catchLoc,true)}else {if(!_)throw Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return f(c.finallyLoc)}}}},abrupt:function(i,a){for(var f=this.tryEntries.length-1;f>=0;--f){var d=this.tryEntries[f];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var c=d;break}}c&&(i==="break"||i==="continue")&&c.tryLoc<=a&&a<=c.finallyLoc&&(c=null);var v=c?c.completion:{};return v.type=i,v.arg=a,c?(this.method="next",this.next=c.finallyLoc,w):this.complete(v)},complete:function(i,a){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&a&&(this.next=a),w},finish:function(i){for(var a=this.tryEntries.length-1;a>=0;--a){var f=this.tryEntries[a];if(f.finallyLoc===i)return this.complete(f.completion,f.afterLoc),M(f),w}},catch:function(i){for(var a=this.tryEntries.length-1;a>=0;--a){var f=this.tryEntries[a];if(f.tryLoc===i){var d=f.completion;if(d.type==="throw"){var c=d.arg;M(f);}return c}}throw Error("illegal catch attempt")},delegateYield:function(i,a,f){return this.delegate={iterator:K(i),resultName:a,nextLoc:f},this.method==="next"&&(this.arg=e),w}},t}function Nt(e,t,r,n,o,s,l){try{var p=e[s](l),h=p.value;}catch(m){r(m);return}p.done?t(h):Promise.resolve(h).then(n,o);}function on(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var s=e.apply(t,r);function l(h){Nt(s,n,o,l,p,"next",h);}function p(h){Nt(s,n,o,l,p,"throw",h);}l(void 0);})}}function Wt(e,t){return un(e)||sn(e,t)||Xt(e,t)||an()}function an(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sn(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,l,p=[],h=true,m=false;try{if(s=(r=r.call(e)).next,t===0);else for(;!(h=(n=s.call(r)).done)&&(p.push(n.value),p.length!==t);h=!0);}catch(g){m=true,o=g;}finally{try{if(!h&&r.return!=null&&(l=r.return(),Object(l)!==l))return}finally{if(m)throw o}}return p}}function un(e){if(Array.isArray(e))return e}function X(e){"@babel/helpers - typeof";return X=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(e)}function ln(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Xt(e))||t){r&&(e=r);var n=0,o=function(){};return {s:o,n:function(){return n>=e.length?{done:true}:{done:false,value:e[n++]}},e:function(m){throw m},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=true,l=false,p;return {s:function(){r=r.call(e);},n:function(){var m=r.next();return s=m.done,m},e:function(m){l=true,p=m;},f:function(){try{!s&&r.return!=null&&r.return();}finally{if(l)throw p}}}}function Xt(e,t){if(e){if(typeof e=="string")return Bt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Bt(e,t)}}function Bt(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function zt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n);}return r}function ee(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?zt(Object(r),true).forEach(function(n){fn(e,n,r[n]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zt(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n));});}return e}function fn(e,t,r){return t=Yt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function cn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ht(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Yt(n.key),n);}}function pn(e,t,r){return t&&Ht(e.prototype,t),r&&Ht(e,r),Object.defineProperty(e,"prototype",{writable:false}),e}function Yt(e){var t=hn(e,"string");return X(t)=="symbol"?t:t+""}function hn(e,t){if(X(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(X(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var Ne="tus-v1",be="ietf-draft-03",dn={endpoint:null,uploadUrl:null,metadata:{},metadataForPartialUploads:{},fingerprint:null,uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,onUploadUrlAvailable:null,overridePatchMethod:false,headers:{},addRequestId:false,onBeforeRequest:null,onAfterResponse:null,onShouldRetry:Jt,chunkSize:Number.POSITIVE_INFINITY,retryDelays:[0,1e3,3e3,5e3],parallelUploads:1,parallelUploadBoundaries:null,storeFingerprintForResuming:true,removeFingerprintOnSuccess:false,uploadLengthDeferred:false,uploadDataDuringCreation:false,urlStorage:null,fileReader:null,httpStack:null,protocol:Ne},Vt=function(){function e(t,r){cn(this,e),"resume"in r&&console.log("tus: The `resume` option has been removed in tus-js-client v2. Please use the URL storage API instead."),this.options=r,this.options.chunkSize=Number(this.options.chunkSize),this._urlStorage=this.options.urlStorage,this.file=t,this.url=null,this._req=null,this._fingerprint=null,this._urlStorageKey=null,this._offset=null,this._aborted=false,this._size=null,this._source=null,this._retryAttempt=0,this._retryTimeout=null,this._offsetBeforeRetry=0,this._parallelUploads=null,this._parallelUploadUrls=null;}return pn(e,[{key:"findPreviousUploads",value:function(){var r=this;return this.options.fingerprint(this.file,this.options).then(function(n){return r._urlStorage.findUploadsByFingerprint(n)})}},{key:"resumeFromPreviousUpload",value:function(r){this.url=r.uploadUrl||null,this._parallelUploadUrls=r.parallelUploadUrls||null,this._urlStorageKey=r.urlStorageKey;}},{key:"start",value:function(){var r=this,n=this.file;if(!n){this._emitError(new Error("tus: no file or stream to upload provided"));return}if(![Ne,be].includes(this.options.protocol)){this._emitError(new Error("tus: unsupported protocol ".concat(this.options.protocol)));return}if(!this.options.endpoint&&!this.options.uploadUrl&&!this.url){this._emitError(new Error("tus: neither an endpoint or an upload URL is provided"));return}var o=this.options.retryDelays;if(o!=null&&Object.prototype.toString.call(o)!=="[object Array]"){this._emitError(new Error("tus: the `retryDelays` option must either be an array or null"));return}if(this.options.parallelUploads>1)for(var s=0,l=["uploadUrl","uploadSize","uploadLengthDeferred"];s<l.length;s++){var p=l[s];if(this.options[p]){this._emitError(new Error("tus: cannot use the ".concat(p," option when parallelUploads is enabled")));return}}if(this.options.parallelUploadBoundaries){if(this.options.parallelUploads<=1){this._emitError(new Error("tus: cannot use the `parallelUploadBoundaries` option when `parallelUploads` is disabled"));return}if(this.options.parallelUploads!==this.options.parallelUploadBoundaries.length){this._emitError(new Error("tus: the `parallelUploadBoundaries` must have the same length as the value of `parallelUploads`"));return}}this.options.fingerprint(n,this.options).then(function(h){return r._fingerprint=h,r._source?r._source:r.options.fileReader.openFile(n,r.options.chunkSize)}).then(function(h){if(r._source=h,r.options.uploadLengthDeferred)r._size=null;else if(r.options.uploadSize!=null){if(r._size=Number(r.options.uploadSize),Number.isNaN(r._size)){r._emitError(new Error("tus: cannot convert `uploadSize` option into a number"));return}}else if(r._size=r._source.size,r._size==null){r._emitError(new Error("tus: cannot automatically derive upload's size from input. Specify it manually using the `uploadSize` option or use the `uploadLengthDeferred` option"));return}r.options.parallelUploads>1||r._parallelUploadUrls!=null?r._startParallelUpload():r._startSingleUpload();}).catch(function(h){r._emitError(h);});}},{key:"_startParallelUpload",value:function(){var r,n=this,o=this._size,s=0;this._parallelUploads=[];var l=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,p=(r=this.options.parallelUploadBoundaries)!==null&&r!==void 0?r:mn(this._source.size,l);this._parallelUploadUrls&&p.forEach(function(g,y){g.uploadUrl=n._parallelUploadUrls[y]||null;}),this._parallelUploadUrls=new Array(p.length);var h=p.map(function(g,y){var j=0;return n._source.slice(g.start,g.end).then(function(oe){var H=oe.value;return new Promise(function(L,w){var F=ee(ee({},n.options),{},{uploadUrl:g.uploadUrl||null,storeFingerprintForResuming:false,removeFingerprintOnSuccess:false,parallelUploads:1,parallelUploadBoundaries:null,metadata:n.options.metadataForPartialUploads,headers:ee(ee({},n.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:L,onError:w,onProgress:function(C){s=s-j+C,j=C,n._emitProgress(s,o);},onUploadUrlAvailable:function(){n._parallelUploadUrls[y]=k.url,n._parallelUploadUrls.filter(function(C){return !!C}).length===p.length&&n._saveUploadInUrlStorage();}}),k=new e(H,F);k.start(),n._parallelUploads.push(k);})})}),m;Promise.all(h).then(function(){m=n._openRequest("POST",n.options.endpoint),m.setHeader("Upload-Concat","final;".concat(n._parallelUploadUrls.join(" ")));var g=qt(n.options.metadata);return g!==""&&m.setHeader("Upload-Metadata",g),n._sendRequest(m,null)}).then(function(g){if(!te(g.getStatus(),200)){n._emitHttpError(m,g,"tus: unexpected response while creating upload");return}var y=g.getHeader("Location");if(y==null){n._emitHttpError(m,g,"tus: invalid or missing Location header");return}n.url=$t(n.options.endpoint,y),z("Created upload at ".concat(n.url)),n._emitSuccess(g);}).catch(function(g){n._emitError(g);});}},{key:"_startSingleUpload",value:function(){if(this._aborted=false,this.url!=null){z("Resuming upload from previous URL: ".concat(this.url)),this._resumeUpload();return}if(this.options.uploadUrl!=null){z("Resuming upload from provided URL: ".concat(this.options.uploadUrl)),this.url=this.options.uploadUrl,this._resumeUpload();return}this._createUpload();}},{key:"abort",value:function(r){var n=this;if(this._parallelUploads!=null){var o=ln(this._parallelUploads),s;try{for(o.s();!(s=o.n()).done;){var l=s.value;l.abort(r);}}catch(p){o.e(p);}finally{o.f();}}return this._req!==null&&this._req.abort(),this._aborted=true,this._retryTimeout!=null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),!r||this.url==null?Promise.resolve():e.terminate(this.url,this.options).then(function(){return n._removeFromUrlStorage()})}},{key:"_emitHttpError",value:function(r,n,o,s){this._emitError(new V(o,s,r,n));}},{key:"_emitError",value:function(r){var n=this;if(!this._aborted){if(this.options.retryDelays!=null){var o=this._offset!=null&&this._offset>this._offsetBeforeRetry;if(o&&(this._retryAttempt=0),Kt(r,this._retryAttempt,this.options)){var s=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){n.start();},s);return}}if(typeof this.options.onError=="function")this.options.onError(r);else throw r}}},{key:"_emitSuccess",value:function(r){this.options.removeFingerprintOnSuccess&&this._removeFromUrlStorage(),typeof this.options.onSuccess=="function"&&this.options.onSuccess({lastResponse:r});}},{key:"_emitProgress",value:function(r,n){typeof this.options.onProgress=="function"&&this.options.onProgress(r,n);}},{key:"_emitChunkComplete",value:function(r,n,o){typeof this.options.onChunkComplete=="function"&&this.options.onChunkComplete(r,n,o);}},{key:"_createUpload",value:function(){var r=this;if(!this.options.endpoint){this._emitError(new Error("tus: unable to create upload because no endpoint is provided"));return}var n=this._openRequest("POST",this.options.endpoint);this.options.uploadLengthDeferred?n.setHeader("Upload-Defer-Length","1"):n.setHeader("Upload-Length","".concat(this._size));var o=qt(this.options.metadata);o!==""&&n.setHeader("Upload-Metadata",o);var s;this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred?(this._offset=0,s=this._addChunkToRequest(n)):(this.options.protocol===be&&n.setHeader("Upload-Complete","?0"),s=this._sendRequest(n,null)),s.then(function(l){if(!te(l.getStatus(),200)){r._emitHttpError(n,l,"tus: unexpected response while creating upload");return}var p=l.getHeader("Location");if(p==null){r._emitHttpError(n,l,"tus: invalid or missing Location header");return}if(r.url=$t(r.options.endpoint,p),z("Created upload at ".concat(r.url)),typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._size===0){r._emitSuccess(l),r._source.close();return}r._saveUploadInUrlStorage().then(function(){r.options.uploadDataDuringCreation?r._handleUploadResponse(n,l):(r._offset=0,r._performUpload());});}).catch(function(l){r._emitHttpError(n,null,"tus: failed to create upload",l);});}},{key:"_resumeUpload",value:function(){var r=this,n=this._openRequest("HEAD",this.url),o=this._sendRequest(n,null);o.then(function(s){var l=s.getStatus();if(!te(l,200)){if(l===423){r._emitHttpError(n,s,"tus: upload is currently locked; retry later");return}if(te(l,400)&&r._removeFromUrlStorage(),!r.options.endpoint){r._emitHttpError(n,s,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}r.url=null,r._createUpload();return}var p=Number.parseInt(s.getHeader("Upload-Offset"),10);if(Number.isNaN(p)){r._emitHttpError(n,s,"tus: invalid or missing offset value");return}var h=Number.parseInt(s.getHeader("Upload-Length"),10);if(Number.isNaN(h)&&!r.options.uploadLengthDeferred&&r.options.protocol===Ne){r._emitHttpError(n,s,"tus: invalid or missing length value");return}typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._saveUploadInUrlStorage().then(function(){if(p===h){r._emitProgress(h,h),r._emitSuccess(s);return}r._offset=p,r._performUpload();});}).catch(function(s){r._emitHttpError(n,null,"tus: failed to resume upload",s);});}},{key:"_performUpload",value:function(){var r=this;if(!this._aborted){var n;this.options.overridePatchMethod?(n=this._openRequest("POST",this.url),n.setHeader("X-HTTP-Method-Override","PATCH")):n=this._openRequest("PATCH",this.url),n.setHeader("Upload-Offset","".concat(this._offset));var o=this._addChunkToRequest(n);o.then(function(s){if(!te(s.getStatus(),200)){r._emitHttpError(n,s,"tus: unexpected response while uploading chunk");return}r._handleUploadResponse(n,s);}).catch(function(s){r._aborted||r._emitHttpError(n,null,"tus: failed to upload chunk at offset ".concat(r._offset),s);});}}},{key:"_addChunkToRequest",value:function(r){var n=this,o=this._offset,s=this._offset+this.options.chunkSize;return r.setProgressHandler(function(l){n._emitProgress(o+l,n._size);}),r.setHeader("Content-Type","application/offset+octet-stream"),(s===Number.POSITIVE_INFINITY||s>this._size)&&!this.options.uploadLengthDeferred&&(s=this._size),this._source.slice(o,s).then(function(l){var p=l.value,h=l.done,m=p!=null&&p.size?p.size:0;n.options.uploadLengthDeferred&&h&&(n._size=n._offset+m,r.setHeader("Upload-Length","".concat(n._size)));var g=n._offset+m;return !n.options.uploadLengthDeferred&&h&&g!==n._size?Promise.reject(new Error("upload was configured with a size of ".concat(n._size," bytes, but the source is done after ").concat(g," bytes"))):p===null?n._sendRequest(r):(n.options.protocol===be&&r.setHeader("Upload-Complete",h?"?1":"?0"),n._emitProgress(n._offset,n._size),n._sendRequest(r,p))})}},{key:"_handleUploadResponse",value:function(r,n){var o=Number.parseInt(n.getHeader("Upload-Offset"),10);if(Number.isNaN(o)){this._emitHttpError(r,n,"tus: invalid or missing offset value");return}if(this._emitProgress(o,this._size),this._emitChunkComplete(o-this._offset,o,this._size),this._offset=o,o===this._size){this._emitSuccess(n),this._source.close();return}this._performUpload();}},{key:"_openRequest",value:function(r,n){var o=Mt(r,n,this.options);return this._req=o,o}},{key:"_removeFromUrlStorage",value:function(){var r=this;this._urlStorageKey&&(this._urlStorage.removeUpload(this._urlStorageKey).catch(function(n){r._emitError(n);}),this._urlStorageKey=null);}},{key:"_saveUploadInUrlStorage",value:function(){var r=this;if(!this.options.storeFingerprintForResuming||!this._fingerprint||this._urlStorageKey!==null)return Promise.resolve();var n={size:this._size,metadata:this.options.metadata,creationTime:new Date().toString()};return this._parallelUploads?n.parallelUploadUrls=this._parallelUploadUrls:n.uploadUrl=this.url,this._urlStorage.addUpload(this._fingerprint,n).then(function(o){r._urlStorageKey=o;})}},{key:"_sendRequest",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return Gt(r,n,this.options)}}],[{key:"terminate",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=Mt("DELETE",r,n);return Gt(o,null,n).then(function(s){if(s.getStatus()!==204)throw new V("tus: unexpected response while terminating upload",null,o,s)}).catch(function(s){if(s instanceof V||(s=new V("tus: failed to terminate upload",s,o,null)),!Kt(s,0,n))throw s;var l=n.retryDelays[0],p=n.retryDelays.slice(1),h=ee(ee({},n),{},{retryDelays:p});return new Promise(function(m){return setTimeout(m,l)}).then(function(){return e.terminate(r,h)})})}}])}();function qt(e){return Object.entries(e).map(function(t){var r=Wt(t,2),n=r[0],o=r[1];return "".concat(n," ").concat(Ut.encode(String(o)))}).join(",")}function te(e,t){return e>=t&&e<t+100}function Mt(e,t,r){var n=r.httpStack.createRequest(e,t);r.protocol===be?n.setHeader("Upload-Draft-Interop-Version","5"):n.setHeader("Tus-Resumable","1.0.0");for(var o=r.headers||{},s=0,l=Object.entries(o);s<l.length;s++){var p=Wt(l[s],2),h=p[0],m=p[1];n.setHeader(h,m);}if(r.addRequestId){var g=Fe();n.setHeader("X-Request-ID",g);}return n}function Gt(e,t,r){return Be.apply(this,arguments)}function Be(){return Be=on(Ie().mark(function e(t,r,n){var o;return Ie().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(typeof n.onBeforeRequest!="function"){l.next=3;break}return l.next=3,n.onBeforeRequest(t);case 3:return l.next=5,t.send(r);case 5:if(o=l.sent,typeof n.onAfterResponse!="function"){l.next=9;break}return l.next=9,n.onAfterResponse(t,o);case 9:return l.abrupt("return",o);case 10:case "end":return l.stop()}},e)})),Be.apply(this,arguments)}function yn(){var e=true;return typeof navigator<"u"&&navigator.onLine===false&&(e=false),e}function Kt(e,t,r){return r.retryDelays==null||t>=r.retryDelays.length||e.originalRequest==null?false:r&&typeof r.onShouldRetry=="function"?r.onShouldRetry(e,t,r):Jt(e)}function Jt(e){var t=e.originalResponse?e.originalResponse.getStatus():0;return (!te(t,400)||t===409||t===423)&&yn()}function $t(e,t){return new Zt.default(t,e).toString()}function mn(e,t){for(var r=Math.floor(e/t),n=[],o=0;o<t;o++)n.push({start:r*o,end:r*(o+1)});return n[t-1].end=e,n}Vt.defaultOptions=dn;var _e=Vt;var vn=function(){return typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative"},we=vn;function ze(e){return new Promise(function(t,r){var n=new XMLHttpRequest;n.responseType="blob",n.onload=function(){var o=n.response;t(o);},n.onerror=function(o){r(o);},n.open("GET",e),n.send();})}var gn=function(){return typeof window<"u"&&(typeof window.PhoneGap<"u"||typeof window.Cordova<"u"||typeof window.cordova<"u")},Qt=gn;function He(e){return new Promise(function(t,r){var n=new FileReader;n.onload=function(){var o=new Uint8Array(n.result);t({value:o});},n.onerror=function(o){r(o);},n.readAsArrayBuffer(e);})}function ce(e){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ce(e)}function bn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function er(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,wn(n.key),n);}}function _n(e,t,r){return t&&er(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function wn(e){var t=xn(e,"string");return ce(t)=="symbol"?t:t+""}function xn(e,t){if(ce(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ce(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var qe=function(){function e(t){bn(this,e),this._file=t,this.size=t.size;}return _n(e,[{key:"slice",value:function(r,n){if(Qt())return He(this._file.slice(r,n));var o=this._file.slice(r,n),s=n>=this.size;return Promise.resolve({value:o,done:s})}},{key:"close",value:function(){}}])}();function pe(e){"@babel/helpers - typeof";return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pe(e)}function Sn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,En(n.key),n);}}function Un(e,t,r){return t&&tr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function En(e){var t=Pn(e,"string");return pe(t)=="symbol"?t:t+""}function Pn(e,t){if(pe(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(pe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}function rr(e){return e===void 0?0:e.size!==void 0?e.size:e.length}function On(e,t){if(e.concat)return e.concat(t);if(e instanceof Blob)return new Blob([e,t],{type:e.type});if(e.set){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r}throw new Error("Unknown data type")}var nr=function(){function e(t){Sn(this,e),this._buffer=void 0,this._bufferOffset=0,this._reader=t,this._done=false;}return Un(e,[{key:"slice",value:function(r,n){return r<this._bufferOffset?Promise.reject(new Error("Requested data is before the reader's current offset")):this._readUntilEnoughDataOrDone(r,n)}},{key:"_readUntilEnoughDataOrDone",value:function(r,n){var o=this,s=n<=this._bufferOffset+rr(this._buffer);if(this._done||s){var l=this._getDataFromBuffer(r,n),p=l==null?this._done:false;return Promise.resolve({value:l,done:p})}return this._reader.read().then(function(h){var m=h.value,g=h.done;return g?o._done=true:o._buffer===void 0?o._buffer=m:o._buffer=On(o._buffer,m),o._readUntilEnoughDataOrDone(r,n)})}},{key:"_getDataFromBuffer",value:function(r,n){r>this._bufferOffset&&(this._buffer=this._buffer.slice(r-this._bufferOffset),this._bufferOffset=r);var o=rr(this._buffer)===0;return this._done&&o?null:this._buffer.slice(0,n-r)}},{key:"close",value:function(){this._reader.cancel&&this._reader.cancel();}}])}();function Y(e){"@babel/helpers - typeof";return Y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(e)}function Me(){Me=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(u,i,a){u[i]=a.value;},s=typeof Symbol=="function"?Symbol:{},l=s.iterator||"@@iterator",p=s.asyncIterator||"@@asyncIterator",h=s.toStringTag||"@@toStringTag";function m(u,i,a){return Object.defineProperty(u,i,{value:a,enumerable:true,configurable:true,writable:true}),u[i]}try{m({},"");}catch{m=function(a,f,d){return a[f]=d};}function g(u,i,a,f){var d=i&&i.prototype instanceof F?i:F,c=Object.create(d.prototype),v=new G(f||[]);return o(c,"_invoke",{value:Ue(u,a,v)}),c}function y(u,i,a){try{return {type:"normal",arg:u.call(i,a)}}catch(f){return {type:"throw",arg:f}}}t.wrap=g;var j="suspendedStart",oe="suspendedYield",H="executing",L="completed",w={};function F(){}function k(){}function x(){}var C={};m(C,l,function(){return this});var q=Object.getPrototypeOf,I=q&&q(q(K([])));I&&I!==r&&n.call(I,l)&&(C=I);var R=x.prototype=F.prototype=Object.create(C);function ie(u){["next","throw","return"].forEach(function(i){m(u,i,function(a){return this._invoke(i,a)});});}function N(u,i){function a(d,c,v,b){var _=y(u[d],u,c);if(_.type!=="throw"){var E=_.arg,S=E.value;return S&&Y(S)=="object"&&n.call(S,"__await")?i.resolve(S.__await).then(function(P){a("next",P,v,b);},function(P){a("throw",P,v,b);}):i.resolve(S).then(function(P){E.value=P,v(E);},function(P){return a("throw",P,v,b)})}b(_.arg);}var f;o(this,"_invoke",{value:function(c,v){function b(){return new i(function(_,E){a(c,v,_,E);})}return f=f?f.then(b,b):b()}});}function Ue(u,i,a){var f=j;return function(d,c){if(f===H)throw Error("Generator is already running");if(f===L){if(d==="throw")throw c;return {value:e,done:true}}for(a.method=d,a.arg=c;;){var v=a.delegate;if(v){var b=ae(v,a);if(b){if(b===w)continue;return b}}if(a.method==="next")a.sent=a._sent=a.arg;else if(a.method==="throw"){if(f===j)throw f=L,a.arg;a.dispatchException(a.arg);}else a.method==="return"&&a.abrupt("return",a.arg);f=H;var _=y(u,i,a);if(_.type==="normal"){if(f=a.done?L:oe,_.arg===w)continue;return {value:_.arg,done:a.done}}_.type==="throw"&&(f=L,a.method="throw",a.arg=_.arg);}}}function ae(u,i){var a=i.method,f=u.iterator[a];if(f===e)return i.delegate=null,a==="throw"&&u.iterator.return&&(i.method="return",i.arg=e,ae(u,i),i.method==="throw")||a!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+a+"' method")),w;var d=y(f,u.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,w;var c=d.arg;return c?c.done?(i[u.resultName]=c.value,i.next=u.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,w):c:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,w)}function Ee(u){var i={tryLoc:u[0]};1 in u&&(i.catchLoc=u[1]),2 in u&&(i.finallyLoc=u[2],i.afterLoc=u[3]),this.tryEntries.push(i);}function M(u){var i=u.completion||{};i.type="normal",delete i.arg,u.completion=i;}function G(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(Ee,this),this.reset(true);}function K(u){if(u||u===""){var i=u[l];if(i)return i.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var a=-1,f=function d(){for(;++a<u.length;)if(n.call(u,a))return d.value=u[a],d.done=false,d;return d.value=e,d.done=true,d};return f.next=f}}throw new TypeError(Y(u)+" is not iterable")}return k.prototype=x,o(R,"constructor",{value:x,configurable:true}),o(x,"constructor",{value:k,configurable:true}),k.displayName=m(x,h,"GeneratorFunction"),t.isGeneratorFunction=function(u){var i=typeof u=="function"&&u.constructor;return !!i&&(i===k||(i.displayName||i.name)==="GeneratorFunction")},t.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,x):(u.__proto__=x,m(u,h,"GeneratorFunction")),u.prototype=Object.create(R),u},t.awrap=function(u){return {__await:u}},ie(N.prototype),m(N.prototype,p,function(){return this}),t.AsyncIterator=N,t.async=function(u,i,a,f,d){d===void 0&&(d=Promise);var c=new N(g(u,i,a,f),d);return t.isGeneratorFunction(i)?c:c.next().then(function(v){return v.done?v.value:c.next()})},ie(R),m(R,h,"Generator"),m(R,l,function(){return this}),m(R,"toString",function(){return "[object Generator]"}),t.keys=function(u){var i=Object(u),a=[];for(var f in i)a.push(f);return a.reverse(),function d(){for(;a.length;){var c=a.pop();if(c in i)return d.value=c,d.done=false,d}return d.done=true,d}},t.values=K,G.prototype={constructor:G,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=false,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!i)for(var a in this)a.charAt(0)==="t"&&n.call(this,a)&&!isNaN(+a.slice(1))&&(this[a]=e);},stop:function(){this.done=true;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var a=this;function f(E,S){return v.type="throw",v.arg=i,a.next=E,S&&(a.method="next",a.arg=e),!!S}for(var d=this.tryEntries.length-1;d>=0;--d){var c=this.tryEntries[d],v=c.completion;if(c.tryLoc==="root")return f("end");if(c.tryLoc<=this.prev){var b=n.call(c,"catchLoc"),_=n.call(c,"finallyLoc");if(b&&_){if(this.prev<c.catchLoc)return f(c.catchLoc,true);if(this.prev<c.finallyLoc)return f(c.finallyLoc)}else if(b){if(this.prev<c.catchLoc)return f(c.catchLoc,true)}else {if(!_)throw Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return f(c.finallyLoc)}}}},abrupt:function(i,a){for(var f=this.tryEntries.length-1;f>=0;--f){var d=this.tryEntries[f];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var c=d;break}}c&&(i==="break"||i==="continue")&&c.tryLoc<=a&&a<=c.finallyLoc&&(c=null);var v=c?c.completion:{};return v.type=i,v.arg=a,c?(this.method="next",this.next=c.finallyLoc,w):this.complete(v)},complete:function(i,a){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&a&&(this.next=a),w},finish:function(i){for(var a=this.tryEntries.length-1;a>=0;--a){var f=this.tryEntries[a];if(f.finallyLoc===i)return this.complete(f.completion,f.afterLoc),M(f),w}},catch:function(i){for(var a=this.tryEntries.length-1;a>=0;--a){var f=this.tryEntries[a];if(f.tryLoc===i){var d=f.completion;if(d.type==="throw"){var c=d.arg;M(f);}return c}}throw Error("illegal catch attempt")},delegateYield:function(i,a,f){return this.delegate={iterator:K(i),resultName:a,nextLoc:f},this.method==="next"&&(this.arg=e),w}},t}function or(e,t,r,n,o,s,l){try{var p=e[s](l),h=p.value;}catch(m){r(m);return}p.done?t(h):Promise.resolve(h).then(n,o);}function kn(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var s=e.apply(t,r);function l(h){or(s,n,o,l,p,"next",h);}function p(h){or(s,n,o,l,p,"throw",h);}l(void 0);})}}function Rn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ir(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Cn(n.key),n);}}function jn(e,t,r){return t&&ir(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Cn(e){var t=Ln(e,"string");return Y(t)=="symbol"?t:t+""}function Ln(e,t){if(Y(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Y(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var ar=function(){function e(){Rn(this,e);}return jn(e,[{key:"openFile",value:function(){var t=kn(Me().mark(function n(o,s){var l;return Me().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!(we()&&o&&typeof o.uri<"u")){h.next=11;break}return h.prev=1,h.next=4,ze(o.uri);case 4:return l=h.sent,h.abrupt("return",new qe(l));case 8:throw h.prev=8,h.t0=h.catch(1),new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. ".concat(h.t0));case 11:if(!(typeof o.slice=="function"&&typeof o.size<"u")){h.next=13;break}return h.abrupt("return",Promise.resolve(new qe(o)));case 13:if(typeof o.read!="function"){h.next=18;break}if(s=Number(s),Number.isFinite(s)){h.next=17;break}return h.abrupt("return",Promise.reject(new Error("cannot create source for stream without a finite value for the `chunkSize` option")));case 17:return h.abrupt("return",Promise.resolve(new nr(o,s)));case 18:return h.abrupt("return",Promise.reject(new Error("source object may only be an instance of File, Blob, or Reader in this environment")));case 19:case "end":return h.stop()}},n,null,[[1,8]])}));function r(n,o){return t.apply(this,arguments)}return r}()}])}();function Ge(e,t){return we()?Promise.resolve(Tn(e,t)):Promise.resolve(["tus-br",e.name,e.type,e.size,e.lastModified,t.endpoint].join("-"))}function Tn(e,t){var r=e.exif?An(JSON.stringify(e.exif)):"noexif";return ["tus-rn",e.name||"noname",e.size||"nosize",r,t.endpoint].join("/")}function An(e){var t=0;if(e.length===0)return t;for(var r=0;r<e.length;r++){var n=e.charCodeAt(r);t=(t<<5)-t+n,t&=t;}return t}function he(e){"@babel/helpers - typeof";return he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(e)}function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function sr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Dn(n.key),n);}}function $e(e,t,r){return t&&sr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Dn(e){var t=Fn(e,"string");return he(t)=="symbol"?t:t+""}function Fn(e,t){if(he(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(he(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var ur=function(){function e(){Ke(this,e);}return $e(e,[{key:"createRequest",value:function(r,n){return new In(r,n)}},{key:"getName",value:function(){return "XHRHttpStack"}}])}();var In=function(){function e(t,r){Ke(this,e),this._xhr=new XMLHttpRequest,this._xhr.open(t,r,true),this._method=t,this._url=r,this._headers={};}return $e(e,[{key:"getMethod",value:function(){return this._method}},{key:"getURL",value:function(){return this._url}},{key:"setHeader",value:function(r,n){this._xhr.setRequestHeader(r,n),this._headers[r]=n;}},{key:"getHeader",value:function(r){return this._headers[r]}},{key:"setProgressHandler",value:function(r){"upload"in this._xhr&&(this._xhr.upload.onprogress=function(n){n.lengthComputable&&r(n.loaded);});}},{key:"send",value:function(){var r=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return new Promise(function(o,s){r._xhr.onload=function(){o(new Nn(r._xhr));},r._xhr.onerror=function(l){s(l);},r._xhr.send(n);})}},{key:"abort",value:function(){return this._xhr.abort(),Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._xhr}}])}(),Nn=function(){function e(t){Ke(this,e),this._xhr=t;}return $e(e,[{key:"getStatus",value:function(){return this._xhr.status}},{key:"getHeader",value:function(r){return this._xhr.getResponseHeader(r)}},{key:"getBody",value:function(){return this._xhr.responseText}},{key:"getUnderlyingObject",value:function(){return this._xhr}}])}();function de(e){"@babel/helpers - typeof";return de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},de(e)}function Bn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function lr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Hn(n.key),n);}}function zn(e,t,r){return t&&lr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Hn(e){var t=qn(e,"string");return de(t)=="symbol"?t:t+""}function qn(e,t){if(de(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(de(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var Xe=false;try{Xe="localStorage"in window,xe="tusSupport",We=localStorage.getItem(xe),localStorage.setItem(xe,We),We===null&&localStorage.removeItem(xe);}catch(e){if(e.code===e.SECURITY_ERR||e.code===e.QUOTA_EXCEEDED_ERR)Xe=false;else throw e}var xe,We,fr=Xe,cr=function(){function e(){Bn(this,e);}return zn(e,[{key:"findAllUploads",value:function(){var r=this._findEntries("tus::");return Promise.resolve(r)}},{key:"findUploadsByFingerprint",value:function(r){var n=this._findEntries("tus::".concat(r,"::"));return Promise.resolve(n)}},{key:"removeUpload",value:function(r){return localStorage.removeItem(r),Promise.resolve()}},{key:"addUpload",value:function(r,n){var o=Math.round(Math.random()*1e12),s="tus::".concat(r,"::").concat(o);return localStorage.setItem(s,JSON.stringify(n)),Promise.resolve(s)}},{key:"_findEntries",value:function(r){for(var n=[],o=0;o<localStorage.length;o++){var s=localStorage.key(o);if(s.indexOf(r)===0)try{var l=JSON.parse(localStorage.getItem(s));l.urlStorageKey=s,n.push(l);}catch{}}return n}}])}();function ne(e){"@babel/helpers - typeof";return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(e)}function Mn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,mr(n.key),n);}}function Gn(e,t,r){return r&&pr(e,r),Object.defineProperty(e,"prototype",{writable:false}),e}function Kn(e,t,r){return t=Se(t),$n(e,yr()?Reflect.construct(t,r||[],Se(e).constructor):t.apply(e,r))}function $n(e,t){if(t&&(ne(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(e)}function Wn(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch{}return (yr=function(){return !!e})()}function Se(e){return Se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Se(e)}function Xn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&Ye(e,t);}function Ye(e,t){return Ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},Ye(e,t)}function hr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n);}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?hr(Object(r),true).forEach(function(n){Yn(e,n,r[n]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hr(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n));});}return e}function Yn(e,t,r){return t=mr(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function mr(e){var t=Zn(e,"string");return ne(t)=="symbol"?t:t+""}function Zn(e,t){if(ne(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ne(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (t==="string"?String:Number)(e)}var dr=re(re({},_e.defaultOptions),{},{httpStack:new ur,fileReader:new ar,urlStorage:fr?new cr:new it,fingerprint:Ge}),vr=function(e){function t(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Mn(this,t),n=re(re({},dr),n),Kn(this,t,[r,n])}return Xn(t,e),Gn(t,null,[{key:"terminate",value:function(n){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return o=re(re({},dr),o),_e.terminate(n,o)}}])}(_e);var O=class extends i{constructor(){super(...arguments);this.disableCompletion=false;this._completed=false;this.languageController=new d(this);}connectedCallback(){super.connectedCallback(),window.customElements.get("lottie-player")||import('./lottie-player.esm-BBAKIFYQ.js'),this.languageController.locale=this.locale||"en",this.embedChannel=a$3.connect(this.token),this.embedChannel.upload_id&&(this._upload_id=this.embedChannel.upload_id),this.embedChannel.channel.on("initiate",({upload_id:r})=>{this._upload_id=r,this.embedChannel.upload_id=r;}),this.embedChannel.channel.on("completed",this.completed.bind(this)),this.embedChannel.channel.on("rendition",this.rendition.bind(this)),this.embedChannel.channel.on("error",this.error.bind(this));}requestUpdate(r,n){super.requestUpdate(r,n),r==="locale"&&(this.languageController.locale=this.locale);}reset(){this._progress=0,this._completed=false,this.embedChannel.channel.push("reset",{});}disconnectedCallback(){super.disconnectedCallback();}handleDrop(r){if(r.preventDefault(),r.dataTransfer&&r.dataTransfer.items){for(let n of r.dataTransfer.items)if(n.kind==="file"){let o=n.getAsFile();o&&(o.type.startsWith("video/")||o.type.startsWith("audio/"))&&(this._progress=1,this.upload(o));}}else if(r.dataTransfer&&r.dataTransfer.files)for(let n of r.dataTransfer.files)(n.type.startsWith("video/")||n.type.startsWith("audio/"))&&(this._progress=1,this.upload(n));}handleForm(r){this._progress=1;let n=r.target;if(n.files)for(let o of n.files)(o.type.startsWith("video/")||o.type.startsWith("audio/"))&&this.upload(o);}upload(r){this.dispatchEvent(new CustomEvent("upload",{bubbles:true,composed:true,detail:{file:r}}));let n=new vr(r,{endpoint:a$4.upload.endpoint,retryDelays:[0,3e3,5e3,1e4,2e4,6e4,6e4],metadata:{title:r.name,filetype:r.type,token:this.token,upload_id:this._upload_id},onError:o=>{console.log(o),this.dispatchEvent(new CustomEvent("failed",{bubbles:true,composed:true,detail:o}));},onProgress:(o,s)=>{let l=Math.round(o/s*100);l>this._progress&&(this._progress=l),this.dispatchEvent(new CustomEvent("progress",{bubbles:true,composed:true,detail:{progress:l}}));},onSuccess:()=>{this._progress=100,this.dispatchEvent(new CustomEvent("processing",{bubbles:true,composed:true}));},removeFingerprintOnSuccess:true});n.findPreviousUploads().then(o=>{o.length&&n.resumeFromPreviousUpload(o[0]),n.start();});}completed(r){this.disableCompletion||(this._completed=true),this.dispatchEvent(new CustomEvent("completed",{bubbles:true,composed:true,detail:r}));}rendition(r){this.dispatchEvent(new CustomEvent("rendition",{bubbles:true,composed:true,detail:r}));}error(r){console.warn(`[mave-upload] ${r.message}`),this.dispatchEvent(new CustomEvent("error",{bubbles:true,detail:r}));}render(){return c$1` ${this._progress?this.renderProgress():this.renderUpload()} `}styleOpacity(){return this.languageController.loaded?this._upload_id?{}:{pointerEvents:"none",opacity:"0.5"}:{pointerEvents:"none",opacity:"0"}}styleFont(){return this.font?{fontFamily:this.font}:{fontFamily:"system-ui"}}renderUpload(){return c$1`<form
|
|
4
4
|
class="state"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-
|
|
1
|
+
import {a as a$2}from'./chunk-KJFAZKNJ.js';import {a as a$1}from'./chunk-MS5NFI3Q.js';import {c as c$1,a}from'./chunk-HMISRRKC.js';import {h,i as i$1,c as c$2}from'./chunk-A4GZBQEB.js';import {c}from'./chunk-NDDFZTBA.js';var i=class extends i$1{get backdrop(){return this._backdropColor||"black"}set backdrop(t){this._backdropColor!=t&&(this._backdropColor=t);}get backdropFilter(){return this._backdropFilter}set backdropFilter(t){this._backdropFilter!=t&&(this._backdropFilter=t);}get styles(){let t={"--backdrop":this.backdrop,"--backdrop-filter":this.backdropFilter};return a$1(t)}open(t){if(this._player=t,t.aspect_ratio){let[o,d]=t.aspect_ratio.split("/");this.style.setProperty("--frame-ratio-w",o),this.style.setProperty("--frame-ratio-h",d);}this.style.display="block";let n=o=>{this._frame.appendChild(t),setTimeout(()=>{this._dialog.showModal();},25),this._dialog.addEventListener("close",d=>{d.preventDefault(),this.close();},{once:true}),o(this);};return new Promise(o=>{if(this._dialog)n(o);else {let d=setInterval(()=>{this._dialog&&(n(o),clearInterval(d));},100);return}})}possibleClose(t){t.target!=this._player&&this.close();}close(){this._dialog.close(),this._backdrop.addEventListener("transitionend",()=>{this._frame.innerHTML="",this.dispatchEvent(new Event("closed",{bubbles:true}));},{once:true});}render(){return c$2`
|
|
2
2
|
<dialog style=${this.styles}>
|
|
3
3
|
<div class="backdrop"></div>
|
|
4
4
|
<div class="content" @click=${this.possibleClose}>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {a}from'./chunk-JBV2AYRP.js';var v=e=>typeof e=="function"?e:function(){return e},L=typeof self<"u"?self:null,T=typeof window<"u"?window:null,g=L||T||g,
|
|
2
|
-
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=false,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",false)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]);});}close(e,t,i){for(let n of this.reqs)n.abort();this.readyState=f.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:true},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s);}ajax(e,t,i,s,n){let r,h=()=>{this.reqs.delete(r),s();};r=E.request(e,this.endpointURL(),t,i,this.timeout,h,o=>{this.reqs.delete(r),this.isActive()&&n(o);}),this.reqs.add(r);}};var C={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,r,h]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:r,payload:h})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:r}=e,h=this.META_LENGTH+t.length+i.length+n.length+s.length,o=new ArrayBuffer(this.HEADER_LENGTH+h),a=new DataView(o),l=0;a.setUint8(l++,this.KINDS.push),a.setUint8(l++,t.length),a.setUint8(l++,i.length),a.setUint8(l++,n.length),a.setUint8(l++,s.length),Array.from(t,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(i,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(n,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(s,u=>a.setUint8(l++,u.charCodeAt(0)));var p=new Uint8Array(o.byteLength+r.byteLength);return p.set(new Uint8Array(o),0),p.set(new Uint8Array(r),o.byteLength),p.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=this.HEADER_LENGTH+this.META_LENGTH-1,o=i.decode(e.slice(h,h+s));h=h+s;let a=i.decode(e.slice(h,h+n));h=h+n;let l=i.decode(e.slice(h,h+r));h=h+r;let p=e.slice(h,e.byteLength);return {join_ref:o,ref:null,topic:a,event:l,payload:p}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+n));o=o+n;let p=i.decode(e.slice(o,o+r));o=o+r;let u=i.decode(e.slice(o,o+h));o=o+h;let w=e.slice(o,e.byteLength),A={status:u,response:w};return {join_ref:a,ref:l,topic:p,event:d.reply,payload:A}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=this.HEADER_LENGTH+2,h=i.decode(e.slice(r,r+s));r=r+s;let o=i.decode(e.slice(r,r+n));r=r+n;let a=e.slice(r,e.byteLength);return {join_ref:null,ref:null,topic:h,event:o,payload:a}}},k=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||H,this.transport=t.transport||g.WebSocket||m,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||g.sessionStorage,this.establishedConnections=0,this.defaultEncoder=C.encode.bind(C),this.defaultDecoder=C.decode.bind(C),this.closeWasClean=false,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==m?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;T&&T.addEventListener&&(T.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock);}),T.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect());})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(s,n,r)=>{console.log(`${s}: ${n}`,r);}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=v(t.params||{}),this.endPoint=`${e}/${R.websocket}`,this.vsn=t.vsn||B,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new y(()=>{this.teardown(()=>this.connect());},this.reconnectAfterMs);}getLongPollTransport(){return m}replaceTransport(e){this.connectClock++,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e;}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=E.appendParams(E.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,i){this.connectClock++,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(e,t,i);}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=v(e)),!this.conn&&(this.longPollFallbackMs&&this.transport!==m?this.connectWithFallback(m,this.longPollFallbackMs):this.transportConnect());}log(e,t,i){this.logger&&this.logger(e,t,i);}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return false;let t=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(n=>{n.ref===t&&(this.off([s]),e(Date.now()-i));});return true}transportConnect(){this.connectClock++,this.closeWasClean=false,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e);}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t);}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=false,s=true,n,r,h=o=>{this.log("transport",`falling back to ${e.name}...`,o),this.off([n,r]),s=false,this.storeSession("phx:longpoll","true"),this.replaceTransport(e),this.transportConnect();};if(this.getSession("phx:longpoll"))return h("memorized");this.fallbackTimer=setTimeout(h,t),r=this.onError(o=>{this.log("transport","error",o),s&&!i&&(clearTimeout(this.fallbackTimer),h(o));}),this.onOpen(()=>{if(i=true,!s)return console.log("transport",`established ${e.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(h,t),this.ping(o=>{this.log("transport","connected to primary after",o),clearTimeout(this.fallbackTimer);});}),this.transportConnect();}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer);}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=false,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e());}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=false,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),P,"heartbeat timeout"));}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs));}teardown(e,t,i){if(!this.conn)return e&&e();this.waitForBufferDone(()=>{this.conn&&(t?this.conn.close(t,i||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e();});});}waitForBufferDone(e,t=1){if(t===5||!this.conn||!this.conn.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(e,t+1);},150*t);}waitForSocketClosed(e,t=1){if(t===5||!this.conn||this.conn.readyState===f.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(e,t+1);},150*t);}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&t!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(e));}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(e,t,i);}),(t===this.transport||i>0)&&this.triggerChanError();}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(d.error);});}connectionState(){switch(this.conn&&this.conn.readyState){case f.connecting:return "connecting";case f.open:return "open";case f.closing:return "closing";default:return "closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t.joinRef()!==e.joinRef());}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([i])=>e.indexOf(i)===-1);}channel(e,t={}){let i=new x(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:n,join_ref:r}=e;this.log("push",`${t} ${i} (${r}, ${n})`,s);}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)));}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs));}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[]);}onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:s,payload:n,ref:r,join_ref:h}=t;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,n);for(let o=0;o<this.channels.length;o++){let a=this.channels[o];a.isMember(i,s,n,h)&&a.trigger(s,n,r,h);}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,a]=this.stateChangeCallbacks.message[o];a(t);}});}leaveOpenTopic(e){let t=this.channels.find(i=>i.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave());}};var S=class e{constructor(){this.channels=[];}static connect(t){e.instance||(e.instance=new e,window&&(e.instance.socket=new k(a.upload.socket,{params:{token:t},reconnectAfterMs:s=>[1e3,3e3,5e3,1e4][s-1]||1e4}),e.instance.socket.connect()));let i=e.instance.channels.find(s=>s.token===t);if(i)return i;{let s=e.instance.socket.channel(`embed:${t}`);s.join();let n={token:t,channel:s};return s.on("initiate",({upload_id:r})=>{e.instance.channels.push({...n,upload_id:r});}),n}}};
|
|
3
|
-
export{
|
|
1
|
+
import {a}from'./chunk-JBV2AYRP.js';var v=e=>typeof e=="function"?e:function(){return e},L=typeof self<"u"?self:null,T=typeof window<"u"?window:null,g=L||T||g,H="2.0.0",f={connecting:0,open:1,closing:2,closed:3},P=1e4,B=1e3,c={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},d={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},k={longpoll:"longpoll",websocket:"websocket"},_={complete:4},C=class{constructor(e,t,i,s){this.channel=e,this.event=t,this.payload=i||function(){return {}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=false;}resend(e){this.timeout=e,this.reset(),this.send();}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=true,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}));}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=false;}matchReceive({status:e,response:t,_ref:i}){this.recHooks.filter(s=>s.status===e).forEach(s=>s.callback(t));}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent);}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null;}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e);}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{});},this.timeout);}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t});}},y=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=null,this.tries=0;}reset(){this.tries=0,clearTimeout(this.timer);}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback();},this.timerCalc(this.tries+1));}},x=class{constructor(e,t,i){this.state=c.closed,this.topic=e,this.params=v(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=false,this.joinPush=new C(this,d.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new y(()=>{this.socket.isConnected()&&this.rejoin();},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin();})),this.joinPush.receive("ok",()=>{this.state=c.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[];}),this.joinPush.receive("error",()=>{this.state=c.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout();}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=c.closed,this.socket.remove(this);}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=c.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout();}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new C(this,d.leave,v({}),this.timeout).send(),this.state=c.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout();}),this.on(d.reply,(s,n)=>{this.trigger(this.replyEventName(n),s);});}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=true,this.rejoin(),this.joinPush}onClose(e){this.on(d.close,e);}onError(e){return this.on(d.error,t=>e(t))}on(e,t){let i=this.bindingRef++;return this.bindings.push({event:e,ref:i,callback:t}),i}off(e,t){this.bindings=this.bindings.filter(i=>!(i.event===e&&(typeof t>"u"||t===i.ref)));}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,i=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new C(this,e,function(){return t},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=c.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(d.close,"leave");},i=new C(this,d.leave,v({}),e);return i.receive("ok",()=>t()).receive("timeout",()=>t()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(e,t,i){return t}isMember(e,t,i,s){return this.topic!==e?false:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:i,joinRef:s}),false):true}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=c.joining,this.joinPush.resend(e));}trigger(e,t,i,s){let n=this.onMessage(e,t,i,s);if(t&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(h=>h.event===e);for(let h=0;h<r.length;h++)r[h].callback(n,i,s||this.joinRef());}replyEventName(e){return `chan_reply_${e}`}isClosed(){return this.state===c.closed}isErrored(){return this.state===c.errored}isJoined(){return this.state===c.joined}isJoining(){return this.state===c.joining}isLeaving(){return this.state===c.leaving}},E=class{static request(e,t,i,s,n,r,h){if(g.XDomainRequest){let o=new g.XDomainRequest;return this.xdomainRequest(o,e,t,s,n,r,h)}else {let o=new g.XMLHttpRequest;return this.xhrRequest(o,e,t,i,s,n,r,h)}}static xdomainRequest(e,t,i,s,n,r,h){return e.timeout=n,e.open(t,i),e.onload=()=>{let o=this.parseJSON(e.responseText);h&&h(o);},r&&(e.ontimeout=r),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,i,s,n,r,h,o){return e.open(t,i,true),e.timeout=r,e.setRequestHeader("Content-Type",s),e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{if(e.readyState===_.complete&&o){let a=this.parseJSON(e.responseText);o(a);}},h&&(e.ontimeout=h),e.send(n),e}static parseJSON(e){if(!e||e==="")return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let i=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let n=t?`${t}[${s}]`:s,r=e[s];typeof r=="object"?i.push(this.serialize(r,n)):i.push(encodeURIComponent(n)+"="+encodeURIComponent(r));}return i.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let i=e.match(/\?/)?"&":"?";return `${e}${i}${this.serialize(t)}`}},$=e=>{let t="",i=new Uint8Array(e),s=i.byteLength;for(let n=0;n<s;n++)t+=String.fromCharCode(i[n]);return btoa(t)},m=class{constructor(e){this.endPoint=null,this.token=null,this.skipHeartbeat=true,this.reqs=new Set,this.awaitingBatchAck=false,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=f.connecting,setTimeout(()=>this.poll(),0);}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+k.websocket),"$1/"+k.longpoll)}endpointURL(){return E.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,i){this.close(e,t,i),this.readyState=f.connecting;}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",false);}isActive(){return this.readyState===f.open||this.readyState===f.connecting}poll(){this.ajax("GET","application/json",null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:i,messages:s}=e;this.token=i;}else t=0;switch(t){case 200:s.forEach(n=>{setTimeout(()=>this.onmessage({data:n}),0);}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=f.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",false);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${t}`)}});}send(e){typeof e!="string"&&(e=$(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null;},0));}batchSend(e){this.awaitingBatchAck=true,this.ajax("POST","application/x-ndjson",e.join(`
|
|
2
|
+
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=false,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",false)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]);});}close(e,t,i){for(let n of this.reqs)n.abort();this.readyState=f.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:true},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s);}ajax(e,t,i,s,n){let r,h=()=>{this.reqs.delete(r),s();};r=E.request(e,this.endpointURL(),t,i,this.timeout,h,o=>{this.reqs.delete(r),this.isActive()&&n(o);}),this.reqs.add(r);}};var b={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,r,h]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:r,payload:h})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:r}=e,h=this.META_LENGTH+t.length+i.length+n.length+s.length,o=new ArrayBuffer(this.HEADER_LENGTH+h),a=new DataView(o),l=0;a.setUint8(l++,this.KINDS.push),a.setUint8(l++,t.length),a.setUint8(l++,i.length),a.setUint8(l++,n.length),a.setUint8(l++,s.length),Array.from(t,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(i,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(n,u=>a.setUint8(l++,u.charCodeAt(0))),Array.from(s,u=>a.setUint8(l++,u.charCodeAt(0)));var p=new Uint8Array(o.byteLength+r.byteLength);return p.set(new Uint8Array(o),0),p.set(new Uint8Array(r),o.byteLength),p.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=this.HEADER_LENGTH+this.META_LENGTH-1,o=i.decode(e.slice(h,h+s));h=h+s;let a=i.decode(e.slice(h,h+n));h=h+n;let l=i.decode(e.slice(h,h+r));h=h+r;let p=e.slice(h,e.byteLength);return {join_ref:o,ref:null,topic:a,event:l,payload:p}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),h=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+n));o=o+n;let p=i.decode(e.slice(o,o+r));o=o+r;let u=i.decode(e.slice(o,o+h));o=o+h;let w=e.slice(o,e.byteLength),A={status:u,response:w};return {join_ref:a,ref:l,topic:p,event:d.reply,payload:A}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=this.HEADER_LENGTH+2,h=i.decode(e.slice(r,r+s));r=r+s;let o=i.decode(e.slice(r,r+n));r=r+n;let a=e.slice(r,e.byteLength);return {join_ref:null,ref:null,topic:h,event:o,payload:a}}},j=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||P,this.transport=t.transport||g.WebSocket||m,this.primaryPassedHealthCheck=false,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||g&&g.sessionStorage,this.establishedConnections=0,this.defaultEncoder=b.encode.bind(b),this.defaultDecoder=b.decode.bind(b),this.closeWasClean=false,this.disconnecting=false,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==m?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;T&&T.addEventListener&&(T.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock);}),T.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect());})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(s,n,r)=>{console.log(`${s}: ${n}`,r);}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=v(t.params||{}),this.endPoint=`${e}/${k.websocket}`,this.vsn=t.vsn||H,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new y(()=>{this.teardown(()=>this.connect());},this.reconnectAfterMs);}getLongPollTransport(){return m}replaceTransport(e){this.connectClock++,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e;}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=E.appendParams(E.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,i){this.connectClock++,this.disconnecting=true,this.closeWasClean=true,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=false,e&&e();},t,i);}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=v(e)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==m?this.connectWithFallback(m,this.longPollFallbackMs):this.transportConnect());}log(e,t,i){this.logger&&this.logger(e,t,i);}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return false;let t=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(n=>{n.ref===t&&(this.off([s]),e(Date.now()-i));});return true}transportConnect(){this.connectClock++,this.closeWasClean=false,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e);}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t);}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=false,s=true,n,r,h=o=>{this.log("transport",`falling back to ${e.name}...`,o),this.off([n,r]),s=false,this.replaceTransport(e),this.transportConnect();};if(this.getSession(`phx:fallback:${e.name}`))return h("memorized");this.fallbackTimer=setTimeout(h,t),r=this.onError(o=>{this.log("transport","error",o),s&&!i&&(clearTimeout(this.fallbackTimer),h(o));}),this.onOpen(()=>{if(i=true,!s)return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${e.name}`,"true"),this.log("transport",`established ${e.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(h,t),this.ping(o=>{this.log("transport","connected to primary after",o),this.primaryPassedHealthCheck=true,clearTimeout(this.fallbackTimer);});}),this.transportConnect();}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer);}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=false,this.disconnecting=false,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e());}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=false,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),B,"heartbeat timeout"));}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs));}teardown(e,t,i){if(!this.conn)return e&&e();let s=this.connectClock;this.waitForBufferDone(()=>{s===this.connectClock&&(this.conn&&(t?this.conn.close(t,i||""):this.conn.close()),this.waitForSocketClosed(()=>{s===this.connectClock&&(this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e());}));});}waitForBufferDone(e,t=1){if(t===5||!this.conn||!this.conn.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(e,t+1);},150*t);}waitForSocketClosed(e,t=1){if(t===5||!this.conn||this.conn.readyState===f.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(e,t+1);},150*t);}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&t!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(e));}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(e,t,i);}),(t===this.transport||i>0)&&this.triggerChanError();}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(d.error);});}connectionState(){switch(this.conn&&this.conn.readyState){case f.connecting:return "connecting";case f.open:return "open";case f.closing:return "closing";default:return "closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e);}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([i])=>e.indexOf(i)===-1);}channel(e,t={}){let i=new x(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:n,join_ref:r}=e;this.log("push",`${t} ${i} (${r}, ${n})`,s);}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)));}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs));}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[]);}onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:s,payload:n,ref:r,join_ref:h}=t;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,n);for(let o=0;o<this.channels.length;o++){let a=this.channels[o];a.isMember(i,s,n,h)&&a.trigger(s,n,r,h);}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,a]=this.stateChangeCallbacks.message[o];a(t);}});}leaveOpenTopic(e){let t=this.channels.find(i=>i.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave());}};var R=class e{constructor(){this.channels=[];}static connect(t){e.instance||(e.instance=new e,window&&(e.instance.socket=new j(a.upload.socket,{params:{token:t},reconnectAfterMs:s=>[1e3,3e3,5e3,1e4][s-1]||1e4}),e.instance.socket.connect()));let i=e.instance.channels.find(s=>s.token===t);if(i)return i;{let s=e.instance.socket.channel(`embed:${t}`);s.join();let n={token:t,channel:s};return s.on("initiate",({upload_id:r})=>{e.instance.channels.push({...n,upload_id:r});}),n}}};
|
|
3
|
+
export{R as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b as b$1}from'./chunk-
|
|
1
|
+
import {b as b$1}from'./chunk-ALJZRKHQ.js';import {b}from'./chunk-DH5I55F5.js';import {a as a$1}from'./chunk-3PLBZPRP.js';import {a}from'./chunk-HMISRRKC.js';import {h as h$1,c as c$1,f as f$2}from'./chunk-A4GZBQEB.js';import {c,e,f as f$1}from'./chunk-NDDFZTBA.js';var n,E,f,h,u=class extends a$1{constructor(){super(...arguments);e(this,n);this.order="newest";this.embedController=new b(this,0);}connectedCallback(){super.connectedCallback(),this.embedController.token=this.token;}requestUpdate(t,o){super.requestUpdate(t,o),t==="embed"&&(this.embedController.token=this.token);}get _slottedChildren(){return this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:true})||[]}updated(){this.shadowRoot&&b$1(this.shadowRoot);}refresh(){return this.embedController.refresh()}containsEmbed(t){return this._collection?.videos?.some(o=>o.id===t)}getNextForEmbed(t){let o=f$1(this,n,E).call(this),e=o.findIndex(i=>i.id===t);if(e!==-1)return o[e+1]}render(){return c$1`
|
|
2
2
|
${this.embedController.render({pending:this.renderPending,error:t=>c$1`<p>${t instanceof Error?t.message:f$2}</p>`,complete:t=>{if(this._collection=t,!t)return this.renderPending();if(t.error)return console.warn(t.error);let o=this._slottedChildren.map(e=>{function i(){let s;return e.nodeName==="TEMPLATE"?s=e.content.cloneNode(true):s=e.cloneNode(true),s}if(e.getAttribute("name")=="list-title"){let s=i();return s.textContent=this._collection?.name,c$1`${s}`}if(e.getAttribute("name")=="mave-list-root"&&this.embedController.embed){let s=i(),r=s.querySelector('[slot="root-link"]');return r&&(r.addEventListener("click",a=>{a.preventDefault(),this.emit(this.EVENT_TYPES.CLICK,{action:"back",embedId:""}),this.embedController.embed="";}),r.removeAttribute("slot")),c$1`${s}`}if(e.getAttribute("name")=="mave-list-folder"){let s=this._collection.collections?.map(r=>{let a=i(),l=a.querySelector('[slot="folder-link"]');return [e,l].forEach(d=>{d&&(d.addEventListener("click",p=>{p.preventDefault(),this.emit(this.EVENT_TYPES.CLICK,{action:"show_collection",collectionId:r.id}),this.embedController.embed=r.id;}),d.removeAttribute("slot"));}),f$1(this,n,h).call(this,a,'[slot="folder-title"]',r.name),typeof r.video_count=="number"&&f$1(this,n,h).call(this,a,'[slot="folder-count"]',r.video_count.toString()),c$1`${a}`});return c$1`${s}`}if(e.getAttribute("name")=="mave-list-item"||!["mave-list-folder","mave-list-item","mave-list-root","list-title"].includes(e.hasAttribute("name")?e.getAttribute("name"):"")&&e.nodeName=="TEMPLATE"){let s=f$1(this,n,E).call(this).map((r,a)=>{let l=i(),d=a+1;f$1(this,n,h).call(this,l,'[slot="item-title"]',r.name),f$1(this,n,h).call(this,l,'[slot="item-position"]',d.toString()),f$1(this,n,h).call(this,l,'[slot="item-duration"]',this.durationToTime(r.duration)),f$1(this,n,f).call(this,l,"mave-clip",r.id),f$1(this,n,f).call(this,l,"mave-player",r.id),f$1(this,n,f).call(this,l,"mave-img",r.id);let p=l.querySelector("mave-clip"),T=l.querySelector('[slot="item-title"]'),A=l.querySelector("mave-img");return [p,T,A,l].forEach(S=>{S?.addEventListener("click",$=>{this.emit(this.EVENT_TYPES.CLICK,{action:"show_embed",embedId:r.id,position:d});});}),c$1`${l}`});return c$1`${s}`}}).filter(e=>e);return c$1`${this._stylesheets} ${o}`}})}
|
|
3
3
|
`}renderPending(){return c$1`<slot style="display: none"></slot>`}};n=new WeakSet,E=function(){if(!this._collection)return [];let t=this._collection.videos;return this.order=="newest"&&(t=this._collection.videos?.sort((o,e)=>e.created-o.created)),this.order=="oldest"&&(t=this._collection.videos?.sort((o,e)=>o.created-e.created)),this.order=="az"&&(t=this._collection.videos?.sort((o,e)=>o.name.localeCompare(e.name))),this.order=="za"&&(t=this._collection.videos?.sort((o,e)=>e.name.localeCompare(o.name))),t},f=function(t,o,e){let i=t.querySelector(o);i&&(i.setAttribute("embed",e),i.removeAttribute("slot"));},h=function(t,o,e){let i=t.querySelector(o);i&&(i.textContent=e,i.removeAttribute("slot"));},u.styles=h$1`
|
|
4
4
|
:host {
|