import{B as Mt,R as Gt,E as Kt,f as Xt,a as Zt,h as we,i as Wt,N as Yt}from"./aws-s3-98528360.js";import{g as Vt,d as ze}from"../vendor-8efd6c0a.js";const bt="3.7.7",Jt=bt,J=typeof Buffer=="function",He=typeof TextDecoder=="function"?new TextDecoder:void 0,Me=typeof TextEncoder=="function"?new TextEncoder:void 0,Qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",re=Array.prototype.slice.call(Qt),pe=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(re),er=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,R=String.fromCharCode.bind(String),Ge=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),_t=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),wt=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),St=e=>{let t,r,n,o,a="";const l=e.length%3;for(let f=0;f255||(n=e.charCodeAt(f++))>255||(o=e.charCodeAt(f++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|o,a+=re[t>>18&63]+re[t>>12&63]+re[t>>6&63]+re[t&63]}return l?a.slice(0,l-3)+"===".substring(l):a},qe=typeof btoa=="function"?e=>btoa(e):J?e=>Buffer.from(e,"binary").toString("base64"):St,Pe=J?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,o=e.length;nt?_t(Pe(e)):Pe(e),tr=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?R(192|t>>>6)+R(128|t&63):R(224|t>>>12&15)+R(128|t>>>6&63)+R(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return R(240|t>>>18&7)+R(128|t>>>12&63)+R(128|t>>>6&63)+R(128|t&63)}},rr=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Ut=e=>e.replace(rr,tr),Ke=J?e=>Buffer.from(e,"utf8").toString("base64"):Me?e=>Pe(Me.encode(e)):e=>qe(Ut(e)),W=(e,t=!1)=>t?_t(Ke(e)):Ke(e),Xe=e=>W(e,!0),nr=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,or=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 R((r>>>10)+55296)+R((r&1023)+56320);case 3:return R((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return R((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},Pt=e=>e.replace(nr,or),xt=e=>{if(e=e.replace(/\s+/g,""),!er.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,o;for(let a=0;a>16&255):o===64?R(t>>16&255,t>>8&255):R(t>>16&255,t>>8&255,t&255);return r},$e=typeof atob=="function"?e=>atob(wt(e)):J?e=>Buffer.from(e,"base64").toString("binary"):xt,Et=J?e=>Ge(Buffer.from(e,"base64")):e=>Ge($e(e).split("").map(t=>t.charCodeAt(0))),Ot=e=>Et(Rt(e)),ir=J?e=>Buffer.from(e,"base64").toString("utf8"):He?e=>He.decode(Et(e)):e=>Pt($e(e)),Rt=e=>wt(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),xe=e=>ir(Rt(e)),ar=e=>{if(typeof e!="string")return!1;const t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},kt=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),jt=function(){const e=(t,r)=>Object.defineProperty(String.prototype,t,kt(r));e("fromBase64",function(){return xe(this)}),e("toBase64",function(t){return W(this,t)}),e("toBase64URI",function(){return W(this,!0)}),e("toBase64URL",function(){return W(this,!0)}),e("toUint8Array",function(){return Ot(this)})},Lt=function(){const e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,kt(r));e("toBase64",function(t){return de(this,t)}),e("toBase64URI",function(){return de(this,!0)}),e("toBase64URL",function(){return de(this,!0)})},ur=()=>{jt(),Lt()},sr={version:bt,VERSION:Jt,atob:$e,atobPolyfill:xt,btoa:qe,btoaPolyfill:St,fromBase64:xe,toBase64:W,encode:W,encodeURI:Xe,encodeURL:Xe,utob:Ut,btou:Pt,decode:xe,isValid:ar,fromUint8Array:de,toUint8Array:Ot,extendString:jt,extendUint8Array:Lt,extendBuiltins:ur};var lr=function(t,r){if(r=r.split(":")[0],t=+t,!t)return!1;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!1}return t!==0},De={},fr=Object.prototype.hasOwnProperty,cr;function Ze(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function We(e){try{return encodeURIComponent(e)}catch{return null}}function pr(e){for(var t=/([^=?#&]+)=?([^&]*)/g,r={},n;n=t.exec(e);){var o=Ze(n[1]),a=Ze(n[2]);o===null||a===null||o in r||(r[o]=a)}return r}function hr(e,t){t=t||"";var r=[],n,o;typeof t!="string"&&(t="?");for(o in e)if(fr.call(e,o)){if(n=e[o],!n&&(n===null||n===cr||isNaN(n))&&(n=""),o=We(o),n=We(n),o===null||n===null)continue;r.push(o+"="+n)}return r.length?t+r.join("&"):""}De.stringify=hr;De.parse=pr;var At=lr,ge=De,dr=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Ft=/[\n\r\t]/g,yr=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Ct=/:\d+$/,mr=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,vr=/^[a-zA-Z]:/;function Be(e){return(e||"").toString().replace(dr,"")}var Ee=[["#","hash"],["?","query"],function(t,r){return q(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]],Ye={hash:1,query:1};function Tt(e){var t;typeof window<"u"?t=window:typeof ze<"u"?t=ze:typeof self<"u"?t=self:t={};var r=t.location||{};e=e||r;var n={},o=typeof e,a;if(e.protocol==="blob:")n=new $(unescape(e.pathname),{});else if(o==="string"){n=new $(e,{});for(a in Ye)delete n[a]}else if(o==="object"){for(a in e)a in Ye||(n[a]=e[a]);n.slashes===void 0&&(n.slashes=yr.test(e.href))}return n}function q(e){return e==="file:"||e==="ftp:"||e==="http:"||e==="https:"||e==="ws:"||e==="wss:"}function qt(e,t){e=Be(e),e=e.replace(Ft,""),t=t||{};var r=mr.exec(e),n=r[1]?r[1].toLowerCase():"",o=!!r[2],a=!!r[3],l=0,f;return o?a?(f=r[2]+r[3]+r[4],l=r[2].length+r[3].length):(f=r[2]+r[4],l=r[2].length):a?(f=r[3]+r[4],l=r[3].length):f=r[4],n==="file:"?l>=2&&(f=f.slice(2)):q(n)?f=r[4]:n?o&&(f=f.slice(2)):l>=2&&q(t.protocol)&&(f=r[4]),{protocol:n,slashes:o||q(n),slashesCount:l,rest:f}}function gr(e,t){if(e==="")return t;for(var r=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=r.length,o=r[n-1],a=!1,l=0;n--;)r[n]==="."?r.splice(n,1):r[n]===".."?(r.splice(n,1),l++):l&&(n===0&&(a=!0),r.splice(n,1),l--);return a&&r.unshift(""),(o==="."||o==="..")&&r.push(""),r.join("/")}function $(e,t,r){if(e=Be(e),e=e.replace(Ft,""),!(this instanceof $))return new $(e,t,r);var n,o,a,l,f,h,m=Ee.slice(),w=typeof t,y=this,E=0;for(w!=="object"&&w!=="string"&&(r=t,t=null),r&&typeof r!="function"&&(r=ge.parse),t=Tt(t),o=qt(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||vr.test(e))||!o.slashes&&(o.protocol||o.slashesCount<2||!q(y.protocol)))&&(m[3]=[/(.*)/,"pathname"]);E"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Lr(e){try{return Function.toString.call(e).indexOf("[native code]")!==-1}catch{return typeof e=="function"}}function oe(e,t){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},oe(e,t)}function ie(e){return ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ie(e)}var he=function(e){Or(r,e);var t=Rr(r);function r(n){var o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,f=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(Er(this,r),o=t.call(this,n),o.originalRequest=l,o.originalResponse=f,o.causingError=a,a!=null&&(n+=", caused by ".concat(a.toString())),l!=null){var h=l.getHeader("X-Request-ID")||"n/a",m=l.getMethod(),w=l.getURL(),y=f?f.getStatus():"n/a",E=f?f.getBody()||"":"n/a";n+=", originated from request (method: ".concat(m,", url: ").concat(w,", response code: ").concat(y,", response text: ").concat(E,", request id: ").concat(h,")")}return o.message=n,o}return Ur(r)}(Oe(Error));function Ar(){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 Re(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Re=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(s,i,u){s[i]=u.value},a=typeof Symbol=="function"?Symbol:{},l=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function m(s,i,u){return Object.defineProperty(s,i,{value:u,enumerable:!0,configurable:!0,writable:!0}),s[i]}try{m({},"")}catch{m=function(u,c,d){return u[c]=d}}function w(s,i,u,c){var d=i&&i.prototype instanceof v?i:v,p=Object.create(d.prototype),g=new I(c||[]);return o(p,"_invoke",{value:be(s,u,g)}),p}function y(s,i,u){try{return{type:"normal",arg:s.call(i,u)}}catch(c){return{type:"throw",arg:c}}}t.wrap=w;var E="suspendedStart",B="suspendedYield",F="executing",C="completed",U={};function v(){}function b(){}function _(){}var x={};m(x,l,function(){return this});var L=Object.getPrototypeOf,T=L&&L(L(z([])));T&&T!==r&&n.call(T,l)&&(x=T);var A=_.prototype=v.prototype=Object.create(x);function Q(s){["next","throw","return"].forEach(function(i){m(s,i,function(u){return this._invoke(i,u)})})}function D(s,i){function u(d,p,g,S){var P=y(s[d],s,p);if(P.type!=="throw"){var k=P.arg,O=k.value;return O&&M(O)=="object"&&n.call(O,"__await")?i.resolve(O.__await).then(function(j){u("next",j,g,S)},function(j){u("throw",j,g,S)}):i.resolve(O).then(function(j){k.value=j,g(k)},function(j){return u("throw",j,g,S)})}S(P.arg)}var c;o(this,"_invoke",{value:function(p,g){function S(){return new i(function(P,k){u(p,g,P,k)})}return c=c?c.then(S,S):S()}})}function be(s,i,u){var c=E;return function(d,p){if(c===F)throw new Error("Generator is already running");if(c===C){if(d==="throw")throw p;return{value:e,done:!0}}for(u.method=d,u.arg=p;;){var g=u.delegate;if(g){var S=ee(g,u);if(S){if(S===U)continue;return S}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(c===E)throw c=C,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);c=F;var P=y(s,i,u);if(P.type==="normal"){if(c=u.done?C:B,P.arg===U)continue;return{value:P.arg,done:u.done}}P.type==="throw"&&(c=C,u.method="throw",u.arg=P.arg)}}}function ee(s,i){var u=i.method,c=s.iterator[u];if(c===e)return i.delegate=null,u==="throw"&&s.iterator.return&&(i.method="return",i.arg=e,ee(s,i),i.method==="throw")||u!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+u+"' method")),U;var d=y(c,s.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,U;var p=d.arg;return p?p.done?(i[s.resultName]=p.value,i.next=s.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,U):p:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,U)}function _e(s){var i={tryLoc:s[0]};1 in s&&(i.catchLoc=s[1]),2 in s&&(i.finallyLoc=s[2],i.afterLoc=s[3]),this.tryEntries.push(i)}function N(s){var i=s.completion||{};i.type="normal",delete i.arg,s.completion=i}function I(s){this.tryEntries=[{tryLoc:"root"}],s.forEach(_e,this),this.reset(!0)}function z(s){if(s||s===""){var i=s[l];if(i)return i.call(s);if(typeof s.next=="function")return s;if(!isNaN(s.length)){var u=-1,c=function d(){for(;++u=0;--d){var p=this.tryEntries[d],g=p.completion;if(p.tryLoc==="root")return c("end");if(p.tryLoc<=this.prev){var S=n.call(p,"catchLoc"),P=n.call(p,"finallyLoc");if(S&&P){if(this.prev=0;--c){var d=this.tryEntries[c];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev=0;--u){var c=this.tryEntries[u];if(c.finallyLoc===i)return this.complete(c.completion,c.afterLoc),N(c),U}},catch:function(i){for(var u=this.tryEntries.length-1;u>=0;--u){var c=this.tryEntries[u];if(c.tryLoc===i){var d=c.completion;if(d.type==="throw"){var p=d.arg;N(c)}return p}}throw new Error("illegal catch attempt")},delegateYield:function(i,u,c){return this.delegate={iterator:z(i),resultName:u,nextLoc:c},this.method==="next"&&(this.arg=e),U}},t}function Je(e,t,r,n,o,a,l){try{var f=e[a](l),h=f.value}catch(m){r(m);return}f.done?t(h):Promise.resolve(h).then(n,o)}function Fr(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(h){Je(a,n,o,l,f,"next",h)}function f(h){Je(a,n,o,l,f,"throw",h)}l(void 0)})}}function Dt(e,t){return $r(e)||qr(e,t)||Tr(e,t)||Cr()}function Cr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tr(e,t){if(e){if(typeof e=="string")return Qe(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 Qe(e,t)}}function Qe(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r1)for(var a=0,l=["uploadUrl","uploadSize","uploadLengthDeferred"];a1||r._parallelUploadUrls!=null?r._startParallelUpload():r._startSingleUpload()}).catch(function(h){r._emitError(h)})}},{key:"_startParallelUpload",value:function(){var r,n=this,o=this._size,a=0;this._parallelUploads=[];var l=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,f=(r=this.options.parallelUploadBoundaries)!==null&&r!==void 0?r:Mr(this._source.size,l);this._parallelUploadUrls&&f.forEach(function(w,y){w.uploadUrl=n._parallelUploadUrls[y]||null}),this._parallelUploadUrls=new Array(f.length);var h=f.map(function(w,y){var E=0;return n._source.slice(w.start,w.end).then(function(B){var F=B.value;return new Promise(function(C,U){var v=K(K({},n.options),{},{uploadUrl:w.uploadUrl||null,storeFingerprintForResuming:!1,removeFingerprintOnSuccess:!1,parallelUploads:1,parallelUploadBoundaries:null,metadata:{},headers:K(K({},n.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:C,onError:U,onProgress:function(x){a=a-E+x,E=x,n._emitProgress(a,o)},onUploadUrlAvailable:function(){n._parallelUploadUrls[y]=b.url,n._parallelUploadUrls.filter(function(x){return!!x}).length===f.length&&n._saveUploadInUrlStorage()}}),b=new e(F,v);b.start(),n._parallelUploads.push(b)})})}),m;Promise.all(h).then(function(){m=n._openRequest("POST",n.options.endpoint),m.setHeader("Upload-Concat","final;".concat(n._parallelUploadUrls.join(" ")));var w=rt(n.options.metadata);return w!==""&&m.setHeader("Upload-Metadata",w),n._sendRequest(m,null)}).then(function(w){if(!X(w.getStatus(),200)){n._emitHttpError(m,w,"tus: unexpected response while creating upload");return}var y=w.getHeader("Location");if(y==null){n._emitHttpError(m,w,"tus: invalid or missing Location header");return}n.url=at(n.options.endpoint,y),"Created upload at ".concat(n.url),n._emitSuccess()}).catch(function(w){n._emitError(w)})}},{key:"_startSingleUpload",value:function(){if(this._aborted=!1,this.url!=null){"Resuming upload from previous URL: ".concat(this.url),this._resumeUpload();return}if(this.options.uploadUrl!=null){"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;return this._parallelUploads!=null&&this._parallelUploads.forEach(function(o){o.abort(r)}),this._req!==null&&this._req.abort(),this._aborted=!0,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,a){this._emitError(new he(o,a,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),it(r,this._retryAttempt,this.options)){var a=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){n.start()},a);return}}if(typeof this.options.onError=="function")this.options.onError(r);else throw r}}},{key:"_emitSuccess",value:function(){this.options.removeFingerprintOnSuccess&&this._removeFromUrlStorage(),typeof this.options.onSuccess=="function"&&this.options.onSuccess()}},{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",this._size);var o=rt(this.options.metadata);o!==""&&n.setHeader("Upload-Metadata",o);var a;this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred?(this._offset=0,a=this._addChunkToRequest(n)):a=this._sendRequest(n,null),a.then(function(l){if(!X(l.getStatus(),200)){r._emitHttpError(n,l,"tus: unexpected response while creating upload");return}var f=l.getHeader("Location");if(f==null){r._emitHttpError(n,l,"tus: invalid or missing Location header");return}if(r.url=at(r.options.endpoint,f),"Created upload at ".concat(r.url),typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._size===0){r._emitSuccess(),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(a){var l=a.getStatus();if(!X(l,200)){if(l===423){r._emitHttpError(n,a,"tus: upload is currently locked; retry later");return}if(X(l,400)&&r._removeFromUrlStorage(),!r.options.endpoint){r._emitHttpError(n,a,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}r.url=null,r._createUpload();return}var f=parseInt(a.getHeader("Upload-Offset"),10);if(Number.isNaN(f)){r._emitHttpError(n,a,"tus: invalid or missing offset value");return}var h=parseInt(a.getHeader("Upload-Length"),10);if(Number.isNaN(h)&&!r.options.uploadLengthDeferred){r._emitHttpError(n,a,"tus: invalid or missing length value");return}typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._saveUploadInUrlStorage().then(function(){if(f===h){r._emitProgress(h,h),r._emitSuccess();return}r._offset=f,r._performUpload()})}).catch(function(a){r._emitHttpError(n,null,"tus: failed to resume upload",a)})}},{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",this._offset);var o=this._addChunkToRequest(n);o.then(function(a){if(!X(a.getStatus(),200)){r._emitHttpError(n,a,"tus: unexpected response while uploading chunk");return}r._handleUploadResponse(n,a)}).catch(function(a){r._aborted||r._emitHttpError(n,null,"tus: failed to upload chunk at offset ".concat(r._offset),a)})}}},{key:"_addChunkToRequest",value:function(r){var n=this,o=this._offset,a=this._offset+this.options.chunkSize;return r.setProgressHandler(function(l){n._emitProgress(o+l,n._size)}),r.setHeader("Content-Type","application/offset+octet-stream"),(a===1/0||a>this._size)&&!this.options.uploadLengthDeferred&&(a=this._size),this._source.slice(o,a).then(function(l){var f=l.value,h=l.done,m=f&&f.size?f.size:0;n.options.uploadLengthDeferred&&h&&(n._size=n._offset+m,r.setHeader("Upload-Length",n._size));var w=n._offset+m;return!n.options.uploadLengthDeferred&&h&&w!==n._size?Promise.reject(new Error("upload was configured with a size of ".concat(n._size," bytes, but the source is done after ").concat(w," bytes"))):f===null?n._sendRequest(r):(n._emitProgress(n._offset,n._size),n._sendRequest(r,f))})}},{key:"_handleUploadResponse",value:function(r,n){var o=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(),this._source.close();return}this._performUpload()}},{key:"_openRequest",value:function(r,n){var o=nt(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 ot(r,n,this.options)}}],[{key:"terminate",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=nt("DELETE",r,n);return ot(o,null,n).then(function(a){if(a.getStatus()!==204)throw new he("tus: unexpected response while terminating upload",null,o,a)}).catch(function(a){if(a instanceof he||(a=new he("tus: failed to terminate upload",a,o,null)),!it(a,0,n))throw a;var l=n.retryDelays[0],f=n.retryDelays.slice(1),h=K(K({},n),{},{retryDelays:f});return new Promise(function(m){return setTimeout(m,l)}).then(function(){return e.terminate(r,h)})})}}]),e}();function rt(e){return Object.entries(e).map(function(t){var r=Dt(t,2),n=r[0],o=r[1];return"".concat(n," ").concat(sr.encode(String(o)))}).join(",")}function X(e,t){return e>=t&&e=r.retryDelays.length||e.originalRequest==null?!1:r&&typeof r.onShouldRetry=="function"?r.onShouldRetry(e,t,r):Nt(e)}function Nt(e){var t=e.originalResponse?e.originalResponse.getStatus():0;return(!X(t,400)||t===409||t===423)&&Hr()}function at(e,t){return new Sr(t,e).toString()}function Mr(e,t){for(var r=Math.floor(e/t),n=[],o=0;o0&&arguments[0]!==void 0?arguments[0]:null;return new Promise(function(o,a){r._xhr.onload=function(){o(new un(r._xhr))},r._xhr.onerror=function(l){a(l)},r._xhr.send(n)})}},{key:"abort",value:function(){return this._xhr.abort(),Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._xhr}}]),e}(),un=function(){function e(t){Ne(this,e),this._xhr=t}return Ie(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}}]),e}(),It=function(){return typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative"};function sn(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 ln=function(){return typeof window<"u"&&(typeof window.PhoneGap<"u"||typeof window.Cordova<"u"||typeof window.cordova<"u")};function fn(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 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 cn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ct(e,t){for(var r=0;r=this.size;return Promise.resolve({value:o,done:a})}},{key:"close",value:function(){}}]),e}();function fe(e){"@babel/helpers - typeof";return fe=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},fe(e)}function yn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ht(e,t){for(var r=0;rthis._bufferOffset&&(this._buffer=this._buffer.slice(r-this._bufferOffset),this._bufferOffset=r);var o=dt(this._buffer)===0;return this._done&&o?null:this._buffer.slice(0,n-r)}},{key:"close",value:function(){this._reader.cancel&&this._reader.cancel()}}]),e}();function G(e){"@babel/helpers - typeof";return G=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},G(e)}function Le(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Le=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(s,i,u){s[i]=u.value},a=typeof Symbol=="function"?Symbol:{},l=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function m(s,i,u){return Object.defineProperty(s,i,{value:u,enumerable:!0,configurable:!0,writable:!0}),s[i]}try{m({},"")}catch{m=function(u,c,d){return u[c]=d}}function w(s,i,u,c){var d=i&&i.prototype instanceof v?i:v,p=Object.create(d.prototype),g=new I(c||[]);return o(p,"_invoke",{value:be(s,u,g)}),p}function y(s,i,u){try{return{type:"normal",arg:s.call(i,u)}}catch(c){return{type:"throw",arg:c}}}t.wrap=w;var E="suspendedStart",B="suspendedYield",F="executing",C="completed",U={};function v(){}function b(){}function _(){}var x={};m(x,l,function(){return this});var L=Object.getPrototypeOf,T=L&&L(L(z([])));T&&T!==r&&n.call(T,l)&&(x=T);var A=_.prototype=v.prototype=Object.create(x);function Q(s){["next","throw","return"].forEach(function(i){m(s,i,function(u){return this._invoke(i,u)})})}function D(s,i){function u(d,p,g,S){var P=y(s[d],s,p);if(P.type!=="throw"){var k=P.arg,O=k.value;return O&&G(O)=="object"&&n.call(O,"__await")?i.resolve(O.__await).then(function(j){u("next",j,g,S)},function(j){u("throw",j,g,S)}):i.resolve(O).then(function(j){k.value=j,g(k)},function(j){return u("throw",j,g,S)})}S(P.arg)}var c;o(this,"_invoke",{value:function(p,g){function S(){return new i(function(P,k){u(p,g,P,k)})}return c=c?c.then(S,S):S()}})}function be(s,i,u){var c=E;return function(d,p){if(c===F)throw new Error("Generator is already running");if(c===C){if(d==="throw")throw p;return{value:e,done:!0}}for(u.method=d,u.arg=p;;){var g=u.delegate;if(g){var S=ee(g,u);if(S){if(S===U)continue;return S}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(c===E)throw c=C,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);c=F;var P=y(s,i,u);if(P.type==="normal"){if(c=u.done?C:B,P.arg===U)continue;return{value:P.arg,done:u.done}}P.type==="throw"&&(c=C,u.method="throw",u.arg=P.arg)}}}function ee(s,i){var u=i.method,c=s.iterator[u];if(c===e)return i.delegate=null,u==="throw"&&s.iterator.return&&(i.method="return",i.arg=e,ee(s,i),i.method==="throw")||u!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+u+"' method")),U;var d=y(c,s.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,U;var p=d.arg;return p?p.done?(i[s.resultName]=p.value,i.next=s.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,U):p:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,U)}function _e(s){var i={tryLoc:s[0]};1 in s&&(i.catchLoc=s[1]),2 in s&&(i.finallyLoc=s[2],i.afterLoc=s[3]),this.tryEntries.push(i)}function N(s){var i=s.completion||{};i.type="normal",delete i.arg,s.completion=i}function I(s){this.tryEntries=[{tryLoc:"root"}],s.forEach(_e,this),this.reset(!0)}function z(s){if(s||s===""){var i=s[l];if(i)return i.call(s);if(typeof s.next=="function")return s;if(!isNaN(s.length)){var u=-1,c=function d(){for(;++u=0;--d){var p=this.tryEntries[d],g=p.completion;if(p.tryLoc==="root")return c("end");if(p.tryLoc<=this.prev){var S=n.call(p,"catchLoc"),P=n.call(p,"finallyLoc");if(S&&P){if(this.prev=0;--c){var d=this.tryEntries[c];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev=0;--u){var c=this.tryEntries[u];if(c.finallyLoc===i)return this.complete(c.completion,c.afterLoc),N(c),U}},catch:function(i){for(var u=this.tryEntries.length-1;u>=0;--u){var c=this.tryEntries[u];if(c.tryLoc===i){var d=c.completion;if(d.type==="throw"){var p=d.arg;N(c)}return p}}throw new Error("illegal catch attempt")},delegateYield:function(i,u,c){return this.delegate={iterator:z(i),resultName:u,nextLoc:c},this.method==="next"&&(this.arg=e),U}},t}function yt(e,t,r,n,o,a,l){try{var f=e[a](l),h=f.value}catch(m){r(m);return}f.done?t(h):Promise.resolve(h).then(n,o)}function wn(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(h){yt(a,n,o,l,f,"next",h)}function f(h){yt(a,n,o,l,f,"throw",h)}l(void 0)})}}function Sn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mt(e,t){for(var r=0;r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ve(e){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ve(e)}function gt(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 Z(e){for(var t=1;t0&&arguments[0]!==void 0?arguments[0]:null,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return jn(this,r),o=Z(Z({},Fe),o),t.call(this,n,o)}return Ln(r,null,[{key:"terminate",value:function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return a=Z(Z({},Fe),a),me.terminate(o,a)}}]),r}(me);function Nn(){return typeof window<"u"&&(typeof window.PhoneGap<"u"||typeof window.Cordova<"u"||typeof window.cordova<"u")}function In(){return typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative"}function zn(e){return(t,r)=>{if(Nn()||In())return Fe.fingerprint(t,r);const n=["tus",e.id,r.endpoint].join("-");return Promise.resolve(n)}}function H(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var Hn=0;function ce(e){return"__private_"+Hn+++"_"+e}const Mn={version:"3.5.5"},Ht={endpoint:"",uploadUrl:null,metadata:{},uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,overridePatchMethod:!1,headers:{},addRequestId:!1,chunkSize:1/0,retryDelays:[100,1e3,3e3,5e3],parallelUploads:1,removeFingerprintOnSuccess:!1,uploadLengthDeferred:!1,uploadDataDuringCreation:!1},Gn={limit:20,retryDelays:Ht.retryDelays,withCredentials:!1};var ne=ce("retryDelayIterator"),Ce=ce("uploadLocalFile"),Te=ce("getCompanionClientArgs"),Ue=ce("uploadFiles"),te=ce("handleUpload");class Kn extends Mt{constructor(t,r){var n,o;if(super(t,{...Gn,...r}),Object.defineProperty(this,Ue,{value:Wn}),Object.defineProperty(this,Te,{value:Zn}),Object.defineProperty(this,Ce,{value:Xn}),Object.defineProperty(this,ne,{writable:!0,value:void 0}),Object.defineProperty(this,te,{writable:!0,value:async a=>{if(a.length===0){this.uppy.log("[Tus] No files to upload");return}this.opts.limit===0&&this.uppy.log("[Tus] When uploading multiple files at once, consider setting the `limit` option (to `10` for example), to limit the number of concurrent uploads, which helps prevent memory and network issues: https://uppy.io/docs/tus/#limit-0","warning"),this.uppy.log("[Tus] Uploading...");const l=this.uppy.getFilesByIds(a);await H(this,Ue)[Ue](l)}}),this.type="uploader",this.id=this.opts.id||"Tus",(r==null?void 0:r.allowedMetaFields)===void 0&&"metaFields"in this.opts)throw new Error("The `metaFields` option has been renamed to `allowedMetaFields`.");if("autoRetry"in r)throw new Error("The `autoRetry` option was deprecated and has been removed.");this.requests=(n=this.opts.rateLimitedQueue)!=null?n:new Gt(this.opts.limit),H(this,ne)[ne]=(o=this.opts.retryDelays)==null?void 0:o.values(),this.uploaders=Object.create(null),this.uploaderEvents=Object.create(null),this.handleResetProgress=this.handleResetProgress.bind(this)}handleResetProgress(){const t={...this.uppy.getState().files};Object.keys(t).forEach(r=>{var n;if((n=t[r])!=null&&(n=n.tus)!=null&&n.uploadUrl){const o={...t[r].tus};delete o.uploadUrl,t[r]={...t[r],tus:o}}}),this.uppy.setState({files:t})}resetUploaderReferences(t,r){const n=this.uploaders[t];n&&(n.abort(),r!=null&&r.abort&&n.abort(!0),this.uploaders[t]=null),this.uploaderEvents[t]&&(this.uploaderEvents[t].remove(),this.uploaderEvents[t]=null)}onReceiveUploadUrl(t,r){const n=this.uppy.getFile(t.id);n&&(!n.tus||n.tus.uploadUrl!==r)&&(this.uppy.log("[Tus] Storing upload url"),this.uppy.setFileState(n.id,{tus:{...n.tus,uploadUrl:r}}))}install(){this.uppy.setState({capabilities:{...this.uppy.getState().capabilities,resumableUploads:!0}}),this.uppy.addUploader(H(this,te)[te]),this.uppy.on("reset-progress",this.handleResetProgress)}uninstall(){this.uppy.setState({capabilities:{...this.uppy.getState().capabilities,resumableUploads:!1}}),this.uppy.removeUploader(H(this,te)[te])}}function Xn(e){var t=this;return this.resetUploaderReferences(e.id),new Promise((r,n)=>{let o,a,l;const f={...this.opts,...e.tus||{}};typeof f.headers=="function"&&(f.headers=f.headers(e));const{onShouldRetry:h,onBeforeRequest:m,...w}=f,y={...Ht,...w};y.fingerprint=zn(e),y.onBeforeRequest=async v=>{const b=v.getUnderlyingObject();b.withCredentials=!!f.withCredentials;let _;if(typeof m=="function"&&(_=m(v,e)),we(o,"shouldBeRequeued")){if(!o.shouldBeRequeued)return Promise.reject();let x;const L=new Promise(T=>{x=T});o=this.requests.run(()=>(e.isPaused&&o.abort(),x(),()=>{})),await Promise.all([L,_]);return}return _},y.onError=v=>{var b;this.uppy.log(v);const _=v.originalRequest!=null?v.originalRequest.getUnderlyingObject():null;Wt(_)&&(v=new Yt(v,_)),this.resetUploaderReferences(e.id),(b=o)==null||b.abort(),this.uppy.emit("upload-error",e,v),typeof f.onError=="function"&&f.onError(v),n(v)},y.onProgress=(v,b)=>{this.onReceiveUploadUrl(e,l.url),typeof f.onProgress=="function"&&f.onProgress(v,b),this.uppy.emit("upload-progress",this.uppy.getFile(e.id),{uploader:this,bytesUploaded:v,bytesTotal:b})},y.onSuccess=()=>{var v;const b={uploadURL:(v=l.url)!=null?v:void 0,status:200,body:{}};if(this.resetUploaderReferences(e.id),o.done(),this.uppy.emit("upload-success",this.uppy.getFile(e.id),b),l.url){const{name:_}=l.file;this.uppy.log(`Download ${_} from ${l.url}`)}typeof f.onSuccess=="function"&&f.onSuccess(),r(l)};const E=v=>{var b;const _=v==null||(b=v.originalResponse)==null?void 0:b.getStatus();if(_===429){if(!this.requests.isPaused){var x;const L=(x=H(this,ne)[ne])==null?void 0:x.next();if(L==null||L.done)return!1;this.requests.rateLimit(L.value)}}else{if(_!=null&&_>400&&_<500&&_!==409&&_!==423)return!1;typeof navigator<"u"&&navigator.onLine===!1&&(this.requests.isPaused||(this.requests.pause(),window.addEventListener("online",()=>{this.requests.resume()},{once:!0})))}return o.abort(),o={shouldBeRequeued:!0,abort(){this.shouldBeRequeued=!1},done(){throw new Error("Cannot mark a queued request as done: this indicates a bug")},fn(){throw new Error("Cannot run a queued request: this indicates a bug")}},!0};h!=null?y.onShouldRetry=(v,b)=>h(v,b,f,E):y.onShouldRetry=E;const B=(v,b,_)=>{we(v,b)&&!we(v,_)&&(v[_]=v[b])},F={};(Array.isArray(f.allowedMetaFields)?f.allowedMetaFields:Object.keys(e.meta)).forEach(v=>{F[v]=String(e.meta[v])}),B(F,"type","filetype"),B(F,"name","filename"),y.metadata=F,l=new Bn(e.data,y),this.uploaders[e.id]=l;const U=new Kt(this.uppy);this.uploaderEvents[e.id]=U,a=()=>(e.isPaused||l.start(),()=>{}),l.findPreviousUploads().then(v=>{const b=v[0];b&&(this.uppy.log(`[Tus] Resuming upload of ${e.id} started at ${b.creationTime}`),l.resumeFromPreviousUpload(b))}),o=this.requests.run(a),U.onFileRemove(e.id,v=>{o.abort(),this.resetUploaderReferences(e.id,{abort:!!l.url}),r(`upload ${v} was removed`)}),U.onPause(e.id,v=>{o.abort(),v?l.abort():o=this.requests.run(a)}),U.onPauseAll(e.id,()=>{o.abort(),l.abort()}),U.onCancelAll(e.id,function(v){let{reason:b}=v===void 0?{}:v;b==="user"&&(o.abort(),t.resetUploaderReferences(e.id,{abort:!!l.url})),r(`upload ${e.id} was canceled`)}),U.onResumeAll(e.id,()=>{o.abort(),e.error&&l.abort(),o=this.requests.run(a)})}).catch(r=>{throw this.uppy.emit("upload-error",e,r),r})}function Zn(e){var t;const r={...this.opts};return e.tus&&Object.assign(r,e.tus),typeof r.headers=="function"&&(r.headers=r.headers(e)),{...(t=e.remote)==null?void 0:t.body,endpoint:r.endpoint,uploadUrl:r.uploadUrl,protocol:"tus",size:e.data.size,headers:r.headers,metadata:e.meta}}async function Wn(e){const t=Xt(e),r=Zt(t);this.uppy.emit("upload-start",r),await Promise.allSettled(t.map(n=>{if(n.isRemote){const o=()=>this.requests,a=new AbortController,l=h=>{h.id===n.id&&a.abort()};this.uppy.on("file-removed",l);const f=this.uppy.getRequestClientForFile(n).uploadRemoteFile(n,H(this,Te)[Te](n),{signal:a.signal,getQueue:o});return this.requests.wrapSyncFunction(()=>{this.uppy.off("file-removed",l)},{priority:-1})(),f}return H(this,Ce)[Ce](n)}))}Kn.VERSION=Mn.version;export{Kn as T};