@d1g1tal/transportr 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/E2K75FBD.js +9 -0
- package/dist/E2K75FBD.js.map +7 -0
- package/dist/iife/transportr.js +9 -9
- package/dist/iife/transportr.js.map +4 -4
- package/dist/transportr.js +2 -2
- package/dist/transportr.js.map +2 -2
- package/package.json +11 -11
- package/dist/FPFIT6Y7.js +0 -9
- package/dist/FPFIT6Y7.js.map +0 -7
package/dist/transportr.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var I=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,xe=/(["\\])/ug,ke=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,L=n=>{for(let e=0,t=n.length;e<t;e++){let s=n.charCodeAt(e);if(s>=65&&s<=90)return n.toLowerCase()}return n},oe=class ie extends Map{constructor(e=[]){super(e)}static isValid(e,t){return I.test(e)&&ke.test(t)}get(e){return super.get(L(e))}has(e){return super.has(L(e))}set(e,t){if(!ie.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(L(e),t),this}delete(e){return super.delete(L(e))}toString(){let e="";for(let[t,s]of this)e+=";",e+=t,e+="=",s.length===0||!I.test(s)?(e+='"',e+=s.replace(xe,"\\$1"),e+='"'):e+=s;return e}get[Symbol.toStringTag](){return"MediaTypeParameters"}},v=n=>n===32||n===9||n===10||n===13,Le=Map.prototype.set,Ie=Map.prototype.has,Me=class b{constructor(){}static parse(e){let t=0,s=e.length;for(;t<s&&v(e.charCodeAt(t));)t++;for(;s>t&&v(e.charCodeAt(s-1));)s--;(t!==0||s!==e.length)&&(e=e.slice(t,s));let r=e.length,o=0;for(;o<r&&e.charCodeAt(o)!==47;)o++;if(o===0||o>=r)throw new TypeError(b.#s("type",e.slice(0,o)));let i=e.slice(0,o);if(!I.test(i))throw new TypeError(b.#s("type",i));i=i.toLowerCase(),o++;let a=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let d=o;for(;d>a&&v(e.charCodeAt(d-1));)d--;if(d===a)throw new TypeError(b.#s("subtype",""));let u=e.slice(a,d);if(!I.test(u))throw new TypeError(b.#s("subtype",u));u=u.toLowerCase();let l=new oe;for(;o<r;){for(o++;o<r&&v(e.charCodeAt(o));)o++;let c=o;for(;o<r;){let p=e.charCodeAt(o);if(p===59||p===61)break;o++}let f=c===o?"":e.slice(c,o);if(o>=r||e.charCodeAt(o)===59)continue;o++;let R;if(o<r&&e.charCodeAt(o)===34){o=b.#t(e,o,r),R=b.#e;let p=e.indexOf(";",o);o=p===-1?r:p}else{let p=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let y=o;for(;y>p&&v(e.charCodeAt(y-1));)y--;if(y===p)continue;R=e.slice(p,y)}if(f.length!==0&&oe.isValid(f,R)){let p=f.toLowerCase();Ie.call(l,p)||Le.call(l,p,R)}}return{type:i,subtype:u,parameters:l}}static#e="";static#t(e,t,s){t++;let r=t;for(;t<s;){let i=e.charCodeAt(t);if(i===34||i===92)break;t++}if(t>=s)return b.#e=e.slice(r,t),t;if(e.charCodeAt(t)===34)return b.#e=e.slice(r,t),t+1;let o=e.slice(r,t);for(;t<s;){let i=e.charCodeAt(t);if(i===34){t++;break}i===92&&t+1<s&&t++,o+=e[t],t++}return b.#e=o,t}static#s(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},M=class ae{#e;#t;#s;#n;constructor(e,t){if({type:this.#e,subtype:this.#t,parameters:this.#n}=Me.parse(e),this.#s=this.#e+"/"+this.#t,t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.#n.set(s,t[s])}}static parse(e){try{return new ae(e)}catch{}return null}get type(){return this.#e}get subtype(){return this.#t}get essence(){return this.#s}get parameters(){return this.#n}matches(e){return typeof e=="string"?this.#s===e:this.#e===e.#e&&this.#t===e.#t}toString(){return this.#s+this.#n.toString()}get[Symbol.toStringTag](){return"MediaType"}};var Ue=class extends Map{set(n,e){return super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),this}getOrInsert(n,e){return this.has(n)?super.get(n):(super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),e)}getOrInsertComputed(n,e){if(this.has(n))return super.get(n);let t=e(n);return super.set(n,t instanceof Set?t:(super.get(n)??new Set).add(t)),t}find(n,e){let t=this.get(n);if(t!==void 0)return Array.from(t).find(e)}hasValue(n,e){let t=super.get(n);return t?t.has(e):!1}deleteValue(n,e){if(e===void 0)return this.delete(n);let t=super.get(n);if(t){let s=t.delete(e);return t.size===0&&super.delete(n),s}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},Ne=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}handle(n,e){this.#t.call(this.#e,n,e)}get[Symbol.toStringTag](){return"ContextEventHandler"}},De=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}get eventName(){return this.#e}get contextEventHandler(){return this.#t}get[Symbol.toStringTag](){return"Subscription"}},U=class{#e=new Ue;#t;setErrorHandler(n){this.#t=n}subscribe(n,e,t=e,s){if(this.#s(n),s?.once){let i=e;e=(a,d)=>{i.call(t,a,d),this.unsubscribe(o)}}let r=new Ne(t,e);this.#e.set(n,r);let o=new De(n,r);return o}unsubscribe({eventName:n,contextEventHandler:e}){let t=this.#e.get(n);if(!t)return!1;let s=t.delete(e);return s&&t.size===0&&this.#e.delete(n),s}publish(n,e=new CustomEvent(n),t){this.#s(n),this.#e.get(n)?.forEach(s=>{try{s.handle(e,t)}catch(r){this.#t?this.#t(r,n,e,t):console.error(`Error in event handler for '${n}':`,r)}})}isSubscribed({eventName:n,contextEventHandler:e}){return this.#e.get(n)?.has(e)??!1}#s(n){if(!n||typeof n!="string")throw new TypeError("Event name must be a non-empty string");if(n.trim()!==n)throw new Error("Event name cannot have leading or trailing whitespace")}destroy(){this.#e.clear()}get[Symbol.toStringTag](){return"Subscribr"}};var O=class extends Error{#e;#t;#s;#n;#o;constructor(e,{message:t,cause:s,entity:r,url:o,method:i,timing:a}={}){super(t,{cause:s}),this.#e=r,this.#t=e,this.#s=o,this.#n=i,this.#o=a}get entity(){return this.#e}get statusCode(){return this.#t.code}get statusText(){return this.#t?.text}get url(){return this.#s}get method(){return this.#n}get timing(){return this.#o}get name(){return"HttpError"}get[Symbol.toStringTag](){return this.name}};var E=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get code(){return this.#e}get text(){return this.#t}get[Symbol.toStringTag](){return"ResponseStatus"}toString(){return`${this.#e} ${this.#t}`}};var ue="XSRF-TOKEN",de="X-XSRF-TOKEN",h={PNG:"image/png",TEXT:"text/plain",JSON:"application/json",HTML:"text/html",JAVA_SCRIPT:"text/javascript",CSS:"text/css",XML:"application/xml",BIN:"application/octet-stream",EVENT_STREAM:"text/event-stream",NDJSON:"application/x-ndjson"},Fe={charset:"utf-8"},A=new M(h.JSON,Fe),W=globalThis.location?.origin??"http://localhost",le={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},m={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},q={ABORT:"abort",TIMEOUT:"timeout"},w={ABORT:"AbortError",TIMEOUT:"TimeoutError"},B={once:!0,passive:!0},N=()=>new CustomEvent(q.ABORT,{detail:{cause:w.ABORT}}),ce=()=>new CustomEvent(q.TIMEOUT,{detail:{cause:w.TIMEOUT}}),pe=["POST","PUT","PATCH","DELETE"],fe=new E(500,"Internal Server Error"),Re=new E(499,"Aborted"),he=new E(504,"Request Timeout"),K=[408,413,429,500,502,503,504],Y=["GET","PUT","HEAD","DELETE","OPTIONS"],D=300,F=2;var j=class{#e;#t=new AbortController;#s;#n;constructor({signal:e,timeout:t=1/0}={}){if(t<0)throw new RangeError("The timeout cannot be negative");let s=e!=null,r=t!==1/0;if(!s&&!r){this.#e=this.#t.signal,this.#n=!1;return}let o=[this.#t.signal];s&&o.push(e),r&&o.push(AbortSignal.timeout(t)),this.#e=AbortSignal.any(o),this.#n=!0,r&&this.#e.addEventListener(q.ABORT,this,B)}handleEvent({target:{reason:e}}){this.#t.signal.aborted||e instanceof DOMException&&e.name===w.TIMEOUT&&this.#e.dispatchEvent(ce())}get signal(){return this.#e}onAbort(e){return this.#o(q.ABORT,e)}onTimeout(e){return this.#o(q.TIMEOUT,e)}abort(e=N()){this.#t.abort(e.detail?.cause)}destroy(){this.#n&&this.#e.removeEventListener(q.ABORT,this,B);let e=this.#s;if(e!==void 0){for(let[t,s]of e)this.#e.removeEventListener(s,t,B);e.clear()}return this}#o(e,t){return this.#e.addEventListener(e,t,B),(this.#s??=new Map).set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var J,$,G=()=>J||(J=(typeof document>"u"||typeof DOMParser>"u"||typeof DocumentFragment>"u"?import("jsdom").then(({JSDOM:e})=>{let{window:t}=new e("<!DOCTYPE html><html><head></head><body></body></html>",{url:"http://localhost"});globalThis.window=t,Object.assign(globalThis,{document:t.document,DOMParser:t.DOMParser,DocumentFragment:t.DocumentFragment})}).catch(()=>{throw J=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}):Promise.resolve()).then(()=>import("./
|
|
1
|
+
var I=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,xe=/(["\\])/ug,ke=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,L=n=>{for(let e=0,t=n.length;e<t;e++){let s=n.charCodeAt(e);if(s>=65&&s<=90)return n.toLowerCase()}return n},oe=class ie extends Map{constructor(e=[]){super(e)}static isValid(e,t){return I.test(e)&&ke.test(t)}get(e){return super.get(L(e))}has(e){return super.has(L(e))}set(e,t){if(!ie.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(L(e),t),this}delete(e){return super.delete(L(e))}toString(){let e="";for(let[t,s]of this)e+=";",e+=t,e+="=",s.length===0||!I.test(s)?(e+='"',e+=s.replace(xe,"\\$1"),e+='"'):e+=s;return e}get[Symbol.toStringTag](){return"MediaTypeParameters"}},v=n=>n===32||n===9||n===10||n===13,Le=Map.prototype.set,Ie=Map.prototype.has,Me=class b{constructor(){}static parse(e){let t=0,s=e.length;for(;t<s&&v(e.charCodeAt(t));)t++;for(;s>t&&v(e.charCodeAt(s-1));)s--;(t!==0||s!==e.length)&&(e=e.slice(t,s));let r=e.length,o=0;for(;o<r&&e.charCodeAt(o)!==47;)o++;if(o===0||o>=r)throw new TypeError(b.#s("type",e.slice(0,o)));let i=e.slice(0,o);if(!I.test(i))throw new TypeError(b.#s("type",i));i=i.toLowerCase(),o++;let a=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let d=o;for(;d>a&&v(e.charCodeAt(d-1));)d--;if(d===a)throw new TypeError(b.#s("subtype",""));let u=e.slice(a,d);if(!I.test(u))throw new TypeError(b.#s("subtype",u));u=u.toLowerCase();let l=new oe;for(;o<r;){for(o++;o<r&&v(e.charCodeAt(o));)o++;let c=o;for(;o<r;){let p=e.charCodeAt(o);if(p===59||p===61)break;o++}let f=c===o?"":e.slice(c,o);if(o>=r||e.charCodeAt(o)===59)continue;o++;let R;if(o<r&&e.charCodeAt(o)===34){o=b.#t(e,o,r),R=b.#e;let p=e.indexOf(";",o);o=p===-1?r:p}else{let p=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let y=o;for(;y>p&&v(e.charCodeAt(y-1));)y--;if(y===p)continue;R=e.slice(p,y)}if(f.length!==0&&oe.isValid(f,R)){let p=f.toLowerCase();Ie.call(l,p)||Le.call(l,p,R)}}return{type:i,subtype:u,parameters:l}}static#e="";static#t(e,t,s){t++;let r=t;for(;t<s;){let i=e.charCodeAt(t);if(i===34||i===92)break;t++}if(t>=s)return b.#e=e.slice(r,t),t;if(e.charCodeAt(t)===34)return b.#e=e.slice(r,t),t+1;let o=e.slice(r,t);for(;t<s;){let i=e.charCodeAt(t);if(i===34){t++;break}i===92&&t+1<s&&t++,o+=e[t],t++}return b.#e=o,t}static#s(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},M=class ae{#e;#t;#s;#n;constructor(e,t){if({type:this.#e,subtype:this.#t,parameters:this.#n}=Me.parse(e),this.#s=this.#e+"/"+this.#t,t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.#n.set(s,t[s])}}static parse(e){try{return new ae(e)}catch{}return null}get type(){return this.#e}get subtype(){return this.#t}get essence(){return this.#s}get parameters(){return this.#n}matches(e){return typeof e=="string"?this.#s===e:this.#e===e.#e&&this.#t===e.#t}toString(){return this.#s+this.#n.toString()}get[Symbol.toStringTag](){return"MediaType"}};var Ue=class extends Map{set(n,e){return super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),this}getOrInsert(n,e){return this.has(n)?super.get(n):(super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),e)}getOrInsertComputed(n,e){if(this.has(n))return super.get(n);let t=e(n);return super.set(n,t instanceof Set?t:(super.get(n)??new Set).add(t)),t}find(n,e){let t=this.get(n);if(t!==void 0)return Array.from(t).find(e)}hasValue(n,e){let t=super.get(n);return t?t.has(e):!1}deleteValue(n,e){if(e===void 0)return this.delete(n);let t=super.get(n);if(t){let s=t.delete(e);return t.size===0&&super.delete(n),s}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},Ne=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}handle(n,e){this.#t.call(this.#e,n,e)}get[Symbol.toStringTag](){return"ContextEventHandler"}},De=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}get eventName(){return this.#e}get contextEventHandler(){return this.#t}get[Symbol.toStringTag](){return"Subscription"}},U=class{#e=new Ue;#t;setErrorHandler(n){this.#t=n}subscribe(n,e,t=e,s){if(this.#s(n),s?.once){let i=e;e=(a,d)=>{i.call(t,a,d),this.unsubscribe(o)}}let r=new Ne(t,e);this.#e.set(n,r);let o=new De(n,r);return o}unsubscribe({eventName:n,contextEventHandler:e}){let t=this.#e.get(n);if(!t)return!1;let s=t.delete(e);return s&&t.size===0&&this.#e.delete(n),s}publish(n,e=new CustomEvent(n),t){this.#s(n),this.#e.get(n)?.forEach(s=>{try{s.handle(e,t)}catch(r){this.#t?this.#t(r,n,e,t):console.error(`Error in event handler for '${n}':`,r)}})}isSubscribed({eventName:n,contextEventHandler:e}){return this.#e.get(n)?.has(e)??!1}#s(n){if(!n||typeof n!="string")throw new TypeError("Event name must be a non-empty string");if(n.trim()!==n)throw new Error("Event name cannot have leading or trailing whitespace")}destroy(){this.#e.clear()}get[Symbol.toStringTag](){return"Subscribr"}};var O=class extends Error{#e;#t;#s;#n;#o;constructor(e,{message:t,cause:s,entity:r,url:o,method:i,timing:a}={}){super(t,{cause:s}),this.#e=r,this.#t=e,this.#s=o,this.#n=i,this.#o=a}get entity(){return this.#e}get statusCode(){return this.#t.code}get statusText(){return this.#t?.text}get url(){return this.#s}get method(){return this.#n}get timing(){return this.#o}get name(){return"HttpError"}get[Symbol.toStringTag](){return this.name}};var E=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get code(){return this.#e}get text(){return this.#t}get[Symbol.toStringTag](){return"ResponseStatus"}toString(){return`${this.#e} ${this.#t}`}};var ue="XSRF-TOKEN",de="X-XSRF-TOKEN",h={PNG:"image/png",TEXT:"text/plain",JSON:"application/json",HTML:"text/html",JAVA_SCRIPT:"text/javascript",CSS:"text/css",XML:"application/xml",BIN:"application/octet-stream",EVENT_STREAM:"text/event-stream",NDJSON:"application/x-ndjson"},Fe={charset:"utf-8"},A=new M(h.JSON,Fe),W=globalThis.location?.origin??"http://localhost",le={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},m={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},q={ABORT:"abort",TIMEOUT:"timeout"},w={ABORT:"AbortError",TIMEOUT:"TimeoutError"},B={once:!0,passive:!0},N=()=>new CustomEvent(q.ABORT,{detail:{cause:w.ABORT}}),ce=()=>new CustomEvent(q.TIMEOUT,{detail:{cause:w.TIMEOUT}}),pe=["POST","PUT","PATCH","DELETE"],fe=new E(500,"Internal Server Error"),Re=new E(499,"Aborted"),he=new E(504,"Request Timeout"),K=[408,413,429,500,502,503,504],Y=["GET","PUT","HEAD","DELETE","OPTIONS"],D=300,F=2;var j=class{#e;#t=new AbortController;#s;#n;constructor({signal:e,timeout:t=1/0}={}){if(t<0)throw new RangeError("The timeout cannot be negative");let s=e!=null,r=t!==1/0;if(!s&&!r){this.#e=this.#t.signal,this.#n=!1;return}let o=[this.#t.signal];s&&o.push(e),r&&o.push(AbortSignal.timeout(t)),this.#e=AbortSignal.any(o),this.#n=!0,r&&this.#e.addEventListener(q.ABORT,this,B)}handleEvent({target:{reason:e}}){this.#t.signal.aborted||e instanceof DOMException&&e.name===w.TIMEOUT&&this.#e.dispatchEvent(ce())}get signal(){return this.#e}onAbort(e){return this.#o(q.ABORT,e)}onTimeout(e){return this.#o(q.TIMEOUT,e)}abort(e=N()){this.#t.abort(e.detail?.cause)}destroy(){this.#n&&this.#e.removeEventListener(q.ABORT,this,B);let e=this.#s;if(e!==void 0){for(let[t,s]of e)this.#e.removeEventListener(s,t,B);e.clear()}return this}#o(e,t){return this.#e.addEventListener(e,t,B),(this.#s??=new Map).set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var J,$,G=()=>J||(J=(typeof document>"u"||typeof DOMParser>"u"||typeof DocumentFragment>"u"?import("jsdom").then(({JSDOM:e})=>{let{window:t}=new e("<!DOCTYPE html><html><head></head><body></body></html>",{url:"http://localhost"});globalThis.window=t,Object.assign(globalThis,{document:t.document,DOMParser:t.DOMParser,DocumentFragment:t.DocumentFragment})}).catch(()=>{throw J=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}):Promise.resolve()).then(()=>import("./E2K75FBD.js")).then(({default:e})=>{$=e})),ge=async(n,e)=>(await G(),new DOMParser().parseFromString($.sanitize(await n.text()),e)),Z=async(n,e)=>{await G();let t=URL.createObjectURL(await n.blob());try{return new Promise((s,r)=>e(t,s,r))}finally{URL.revokeObjectURL(t)}},me=n=>n.text(),Q=n=>Z(n,(e,t,s)=>{let r=Object.assign(document.createElement("script"),{src:e,type:"text/javascript",async:!0});r.onload=()=>{document.head.removeChild(r),t()},r.onerror=()=>{document.head.removeChild(r),s(new Error("Script failed to load"))},document.head.appendChild(r)}),_=n=>Z(n,(e,t,s)=>{let r=Object.assign(document.createElement("link"),{href:e,type:"text/css",rel:"stylesheet"});r.onload=()=>t(),r.onerror=()=>{document.head.removeChild(r),s(new Error("Stylesheet load failed"))},document.head.appendChild(r)}),H=n=>n.json(),ye=n=>n.blob(),ee=n=>Z(n,(e,t,s)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>s(new Error("Image failed to load")),r.src=e}),be=n=>n.arrayBuffer(),te=n=>Promise.resolve(n.body),C=async n=>ge(n,"application/xml"),ne=async n=>ge(n,"text/html"),Te=async n=>(await G(),document.createRange().createContextualFragment($.sanitize(await n.text()))),Oe=async n=>(await G(),document.createRange().createContextualFragment($.sanitize(await n.text(),{ADD_TAGS:["script"]})));async function*Ee(n,e,t){let s=n.getReader(),r=new TextDecoder,o=e.length,i="",a=0;try{for(;;){let d;for(;(d=i.indexOf(e,a))!==-1;)yield i.slice(a,d),a=d+o;a>0&&a>=i.length-a&&(i=a<i.length?i.slice(a):"",a=0);let{done:u,value:l}=await s.read();if(u)break;i+=r.decode(l,{stream:!0})}if(t){let u=((a<i.length?i.slice(a):"")+r.decode()).trim();u&&(yield u)}}finally{await s.cancel()}}var je=n=>{let e="message",t="",s,r,o,i=n.split(`
|
|
2
2
|
`);for(let d=0,u,l=i.length;d<l;d++){if(u=i[d],u.charCodeAt(0)===58)continue;let c=u.indexOf(":"),f,R;switch(c===-1?(f=u,R=""):(f=u.slice(0,c),R=u.charCodeAt(c+1)===32?u.slice(c+2):u.slice(c+1)),f){case"event":{e=R;break}case"data":{r===void 0?r=R:(o??=[]).push(R);break}case"id":{t=R;break}case"retry":{let p=parseInt(R,10);isNaN(p)||(s=p);break}}}if(r===void 0&&e==="message")return;let a=o===void 0?r??"":`${r}
|
|
3
3
|
${o.join(`
|
|
4
4
|
`)}`;return{event:e,data:a,id:t,retry:s}},qe=n=>({async*[Symbol.asyncIterator](){for await(let e of Ee(n.body,`
|
|
5
5
|
|
|
6
6
|
`,!1)){if(!e)continue;let t=je(e);t&&(yield t)}}}),we=n=>({async*[Symbol.asyncIterator](){for await(let e of Ee(n.body,`
|
|
7
|
-
`,!0)){let t=e.trim();t&&(yield JSON.parse(t))}}});var Se=n=>n!==void 0&&pe.includes(n),Pe=n=>n instanceof FormData||n instanceof Blob||n instanceof ArrayBuffer||n instanceof ReadableStream||n instanceof URLSearchParams||ArrayBuffer.isView(n),ve=n=>{if(typeof document>"u")return;let e=document.cookie;if(!e)return;let t=`${n}=`,s=t.length,r=e.length,o=0;for(;o<r;){for(;o<r&&e.charCodeAt(o)===32;)o++;let i=e.indexOf(";",o);if(i===-1&&(i=r),i-o>=s&&e.startsWith(t,o))return decodeURIComponent(e.slice(o+s,i));o=i+1}},Ae=n=>JSON.stringify(n),z=n=>n!==null&&typeof n=="string",Be=n=>n instanceof ArrayBuffer||Object.prototype.toString.call(n)==="[object ArrayBuffer]",g=n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype,X=(...n)=>{let e=n.length;if(e===0)return;if(e===1){let[s]=n;return g(s)?se(s):s}let t={};for(let s=0,r=n.length;s<r;s++){let o=n[s];if(!g(o))return;let i=Object.keys(o);for(let a=0,d=i.length;a<d;a++){let u=i[a],l=o[u],c=t[u];if(Array.isArray(l))if(Array.isArray(c)){let f=l.slice();for(let R=0,p=c.length;R<p;R++){let y=c[R];l.includes(y)||f.push(y)}t[u]=f}else t[u]=l.slice();else g(l)?t[u]=g(c)?X(c,l):se(l):t[u]=l}}return t};function se(n){if(g(n)){let e={},t=Object.keys(n);for(let s=0,r=t.length,o;s<r;s++)o=t[s],e[o]=se(n[o]);return e}return n}var He=class n{#e;#t;#s;#n;#o;#h;#a={beforeRequest:[],afterResponse:[],beforeError:[]};#f={beforeRequest:0,afterResponse:0,beforeError:0};#u=Object.create(null);static#O=new U;static#c={beforeRequest:[],afterResponse:[],beforeError:[]};static#R={beforeRequest:0,afterResponse:0,beforeError:0};static#p=Object.create(null);static#g=new Set;static#E=new Map;static#L={limit:0,statusCodes:[],methods:[],delay:D,backoffFactor:F};static#C=new WeakMap;static#m=new Map([[A.toString(),A]]);static#d=new Map;static#q=[[h.TEXT,me],[h.JSON,H],[h.BIN,te],[h.HTML,ne],[h.XML,C],[h.PNG,ee],[h.JAVA_SCRIPT,Q],[h.CSS,_]];constructor(e=W,t={}){g(e)&&([e,t]=[W,e]),this.#e=n.#j(e),this.#t=this.#e.origin;let s=this.#e.pathname;this.#s=s.length>0&&s.charCodeAt(s.length-1)===47?s.slice(0,-1):s,this.#n=n.#F(t,n.#I),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type"),this.#h=new U}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestMode={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriority={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicy={ERROR:"error",FOLLOW:"follow",MANUAL:"manual"};static ReferrerPolicy={NO_REFERRER:"no-referrer",NO_REFERRER_WHEN_DOWNGRADE:"no-referrer-when-downgrade",ORIGIN:"origin",ORIGIN_WHEN_CROSS_ORIGIN:"origin-when-cross-origin",SAME_ORIGIN:"same-origin",STRICT_ORIGIN:"strict-origin",STRICT_ORIGIN_WHEN_CROSS_ORIGIN:"strict-origin-when-cross-origin",UNSAFE_URL:"unsafe-url"};static RequestEvent=m;static#I={body:void 0,cache:le.NO_STORE,credentials:n.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":A.toString(),accept:A.toString()}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:n.RequestMode.CORS,priority:n.RequestPriority.AUTO,redirect:n.RedirectPolicy.FOLLOW,referrer:"about:client",referrerPolicy:n.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,s){let r=n.#O.subscribe(e,t,s);return n.#p[e]=(n.#p[e]??0)+1,r}static unregister(e){let t=n.#O.unsubscribe(e);if(t){let s=e.eventName,r=(n.#p[s]??1)-1;r<=0?delete n.#p[s]:n.#p[s]=r}return t}static abortAll(){for(let e of this.#g)e.abort(N());this.#g.clear()}static all(e){return Promise.all(e)}static async race(e){let t=[],s=new Array(e.length);for(let r=0;r<e.length;r++){let o=new AbortController;t.push(o),s[r]=e[r](o.signal)}try{return await Promise.race(s)}finally{for(let r of t)r.abort()}}static registerContentTypeHandler(e,t){n.#q.unshift([e,t]),n.#d.clear()}static unregisterContentTypeHandler(e){let t=n.#q.findIndex(([s])=>s===e);return t===-1?!1:(n.#q.splice(t,1),n.#d.clear(),!0)}static addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;t&&(n.#c.beforeRequest.push(...t),n.#R.beforeRequest+=t.length),s&&(n.#c.afterResponse.push(...s),n.#R.afterResponse+=s.length),r&&(n.#c.beforeError.push(...r),n.#R.beforeError+=r.length)}static clearHooks(){n.#c={beforeRequest:[],afterResponse:[],beforeError:[]},n.#R.beforeRequest=0,n.#R.afterResponse=0,n.#R.beforeError=0}static unregisterAll(){n.abortAll(),n.#O=new U,n.#p=Object.create(null),n.clearHooks(),n.#E.clear()}get baseUrl(){return this.#e}register(e,t,s){let r=this.#h.subscribe(e,t,s);return this.#u[e]=(this.#u[e]??0)+1,r}unregister(e){let t=this.#h.unsubscribe(e);if(t){let s=e.eventName,r=(this.#u[s]??1)-1;r<=0?delete this.#u[s]:this.#u[s]=r}return t}addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;return t&&(this.#a.beforeRequest.push(...t),this.#f.beforeRequest+=t.length),s&&(this.#a.afterResponse.push(...s),this.#f.afterResponse+=s.length),r&&(this.#a.beforeError.push(...r),this.#f.beforeError+=r.length),this}clearHooks(){return this.#a.beforeRequest.length=0,this.#a.afterResponse.length=0,this.#a.beforeError.length=0,this.#f.beforeRequest=0,this.#f.afterResponse=0,this.#f.beforeError=0,this}configure({headers:e,searchParams:t,hooks:s,...r}){return e&&(n.#B(this.#n.headers,e),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type")),t&&n.#b(this.#n.searchParams,t),Object.assign(this.#n,r),s&&this.addHooks(s),this}destroy(){this.clearHooks(),this.#h.destroy();for(let e in this.#u)delete this.#u[e]}async get(e,t){return this.#i(e,t)}async post(e,t,s){return this.#S("POST",e,t,s)}async put(e,t,s){return this.#S("PUT",e,t,s)}async patch(e,t,s){return this.#S("PATCH",e,t,s)}async delete(e,t,s){return this.#S("DELETE",e,t,s)}async head(e,t){return this.#A(e,t,{method:"HEAD"})}async options(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{method:"OPTIONS"}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s);d=await this.#v(d,r,i?.afterResponse);let u=d.headers.get("allow"),l;if(u){let c=u.split(",");l=new Array(c.length);for(let f=0,R=c.length;f<R;f++)l[f]=c[f].trim()}return this.#r({name:m.SUCCESS,data:l,global:t.global}),o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async request(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{}),r=s.requestOptions.unwrap!==!1;try{let o=await this.#y(e,s);return this.#r({name:m.SUCCESS,data:o,global:t.global}),r?o:[!0,o]}catch(o){if(!r)return[!1,o];throw o}}async getJson(e,t){return this.#i(e,t,{headers:{accept:`${h.JSON}`}},H)}async getXml(e,t){return this.#i(e,t,{headers:{accept:`${h.XML}`}},C)}async getHtml(e,t,s){let r=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},ne);return Array.isArray(r)?r:s&&r?r.querySelector(s):r}async getHtmlFragment(e,t,s){let r=(g(e)?e:t)?.allowScripts===!0,o=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},r?Oe:Te);return Array.isArray(o)?o:s&&o?o.querySelector(s):o}async getScript(e,t){return this.#i(e,t,{headers:{accept:`${h.JAVA_SCRIPT}`}},Q)}async getStylesheet(e,t){return this.#i(e,t,{headers:{accept:`${h.CSS}`}},_)}async getBlob(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},ye)}async getImage(e,t){return this.#i(e,t,{headers:{accept:"image/*"}},ee)}async getBuffer(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},be)}async getStream(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},te)}async getEventStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:t?.body?"POST":"GET",headers:{accept:`${h.EVENT_STREAM}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:m.SUCCESS,data:u,global:s.global});let l=qe(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async getJsonStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:"GET",headers:{accept:`${h.NDJSON}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:m.SUCCESS,data:u,global:s.global});let l=we(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async#i(e,t,s={},r){return s.method="GET",s.body=void 0,this.#A(e,t,s,r)}async#y(e,t){let{signalController:s,requestOptions:r,global:o}=t;n.#g.add(s);let i=n.#N(r.retry),a=r.method??"GET",d=i.limit>0&&i.methods.includes(a),u=r.dedupe===!0&&(a==="GET"||a==="HEAD"),l=performance.now();try{let c=n.#l(this,e,r.searchParams),f;if(u){f=`${a}:${c.href}`;let x=n.#E.get(f);if(x)return(await x).clone()}let R=r.onUploadProgress,p=r.body;R&&p!=null&&(r.duplex="half");let y=this.#M(c,r,e,a,d,i,p,R,l,o);if(u){n.#E.set(f,y);try{return n.#x(await y,r)}finally{n.#E.delete(f)}}return n.#x(await y,r)}finally{if(n.#g.delete(s.destroy()),!r.signal?.aborted){let c=performance.now();this.#r({name:m.COMPLETE,data:{timing:{start:l,end:c,duration:c-l}},global:o}),n.#g.size===0&&this.#r({name:m.ALL_COMPLETE,global:o})}}}async#M(e,t,s,r,o,i,a,d,u,l){let c=0;for(;;)try{d&&await n.#U(t,a,d);let f=await fetch(e,t);if(!f.ok){if(o&&c<i.limit&&i.statusCodes.includes(f.status)){c++,this.#r({name:m.RETRY,data:{attempt:c,status:f.status,method:r,path:s,timing:n.#w(u)},global:l}),await n.#k(i,c);continue}let R;if(t.captureErrorBody!==!1)try{R=await f.text()}catch{}throw await this.#H(s,f,{entity:R,url:e,method:r,timing:n.#w(u)},t)}return f}catch(f){if(f instanceof O)throw f;if(o&&c<i.limit){c++,this.#r({name:m.RETRY,data:{attempt:c,error:f.message,method:r,path:s,timing:n.#w(u)},global:l}),await n.#k(i,c);continue}throw await this.#H(s,void 0,{cause:f,url:e,method:r,timing:n.#w(u)},t)}}static async#U(e,t,s){if(t==null)return;let r=null;if(typeof t=="string")r=new TextEncoder().encode(t);else if(t instanceof Blob)r=new Uint8Array(await t.arrayBuffer());else if(Be(t))r=new Uint8Array(t);else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(!(t instanceof ReadableStream))return;let o=r?r.byteLength:null,i=r?new ReadableStream({start(u){u.enqueue(r),u.close()}}):t,a=0,d=new TransformStream({transform(u,l){a+=u.byteLength,s({loaded:a,total:o,percentage:o!==null&&o>0?Math.round(a/o*100):null}),l.enqueue(u)}});e.body=i.pipeThrough(d)}static#x(e,t){let s=t.onDownloadProgress;if(!s||!e.body)return e;let r=e.headers.get("content-length"),o=r?parseInt(r,10):null,i=0,a=new TransformStream({transform(d,u){i+=d.byteLength,s({loaded:i,total:o,percentage:o!==null&&o>0?Math.round(i/o*100):null}),u.enqueue(d)}});return new Response(e.body.pipeThrough(a),{status:e.status,statusText:e.statusText,headers:e.headers})}static#w(e){let t=performance.now();return{start:e,end:t,duration:t-e}}static#N(e){if(e===void 0)return n.#L;if(typeof e=="number")return{limit:e,statusCodes:K,methods:Y,delay:D,backoffFactor:F};let t=n.#C.get(e);if(t!==void 0)return t;let s={limit:e.limit??0,statusCodes:e.statusCodes??K,methods:e.methods??Y,delay:e.delay??D,backoffFactor:e.backoffFactor??F};return n.#C.set(e,s),s}static#k(e,t){let s=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(r=>setTimeout(r,s))}#S(e,t,s,r,o){let[i,a,d]=z(t)?[t,s,r]:[void 0,t,s],u=d!==void 0?Object.assign({},d,{body:a,method:e}):{body:a,method:e};return this.#A(i,u,{},o)}async#P(e,t,s,r){let o=n.#c.beforeRequest,i=this.#a.beforeRequest,a=r===void 0?0:r.length;if(o.length===0&&i.length===0&&a===0)return t;for(let d=0,u=o.length;d<u;d++){let l=await o[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0,u=i.length;d<u;d++){let l=await i[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0;d<a;d++){let u=await r[d](e,t);u&&(Object.assign(e,u),u.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}return t}async#v(e,t,s){let r=n.#c.afterResponse,o=this.#a.afterResponse,i=s===void 0?0:s.length;if(r.length===0&&o.length===0&&i===0)return e;for(let a=0,d=r.length;a<d;a++){let u=await r[a](e,t);u&&(e=u)}for(let a=0,d=o.length;a<d;a++){let u=await o[a](e,t);u&&(e=u)}for(let a=0;a<i;a++){let d=await s[a](e,t);d&&(e=d)}return e}async#D(e,t){let s=n.#c.beforeError,r=this.#a.beforeError,o=t===void 0?0:t.length;if(s.length===0&&r.length===0&&o===0)return e;for(let i=0,a=s.length;i<a;i++){let d=await s[i](e);d instanceof O&&(e=d)}for(let i=0,a=r.length;i<a;i++){let d=await r[i](e);d instanceof O&&(e=d)}for(let i=0;i<o;i++){let a=await t[i](e);a instanceof O&&(e=a)}return e}async#A(e,t={},s={},r){g(e)&&([e,t]=[void 0,e]);let o=this.#T(t,s),{requestOptions:i}=o,a=i.unwrap!==!1,d=i.hooks;try{let u=n.#l(this,e,i.searchParams);await this.#P(i,u,e,d?.beforeRequest);let l=await this.#y(e,o);l=await this.#v(l,i,d?.afterResponse);try{!r&&l.status!==204&&(r=this.#G(l.headers.get("content-type")));let c=await r?.(l);return this.#r({name:m.SUCCESS,data:c,global:o.global}),a?c:[!0,c]}catch(c){throw await this.#H(e,l,{cause:c},i)}}catch(u){if(!a)return[!1,u];throw u}}static#F({headers:e,searchParams:t,...s},{headers:r,searchParams:o,...i}){return r=n.#B(new Headers,e,r),o=n.#b(new URLSearchParams,t,o),{...X(i,s),headers:r,searchParams:o}}static#B(e,...t){for(let s of t)if(s!==void 0)if(s instanceof Headers)s.forEach((r,o)=>e.set(o,r));else if(Array.isArray(s))for(let[r,o]of s)e.set(r,o);else{let r=Object.keys(s);for(let o=0,i=r.length;o<i;o++){let a=r[o],d=s[a];d!==void 0&&e.set(a,d)}}return e}static#b(e,...t){for(let s of t)if(s!==void 0)if(s instanceof URLSearchParams)s.forEach((r,o)=>e.set(o,r));else if(z(s)||Array.isArray(s))for(let[r,o]of new URLSearchParams(s))e.set(r,o);else{let r=Object.keys(s);for(let o=0;o<r.length;o++){let i=r[o],a=s[i];a!==void 0&&e.set(i,typeof a=="string"?a:String(a))}}return e}#T(e,t){let s=e.headers,r=e.searchParams,o=e.body,i=t.headers,a=t.searchParams,d=t.method??e.method??this.#n.method??"GET",u=Se(d),l;!u&&s===void 0&&i===void 0?l=new Headers(this.#o):(l=new Headers(this.#n.headers),(s!==void 0||i!==void 0)&&n.#B(l,s,i));let c=this.#n.searchParams,f=c!==void 0&&c.size>0,R;!f&&r===void 0&&a===void 0?R=new URLSearchParams:(R=new URLSearchParams(c),(r!==void 0||a!==void 0)&&n.#b(R,r,a));let p=Object.assign({},this.#n,e,t);if(p.headers=l,p.searchParams=R,u)if(Pe(o))p.body=o,l.delete("content-type");else{let T=this.#n.body,S=g(T)&&g(o)?X(T,o):o!==void 0?o:T,P=l.get("content-type"),Ce=P!==null&&P.includes("json");p.body=Ce&&g(S)?Ae(S):S}else p.body instanceof URLSearchParams&&n.#b(R,p.body),p.body=void 0,(s!==void 0||i!==void 0)&&l.delete("content-type");let y=p.signal,x=p.timeout,k=p.global??!1,V=p.xsrf;if(V){let{cookieName:T,headerName:S}=typeof V=="object"?V:{},P=ve(T??ue);P&&l.set(S??de,P)}let re=new j({signal:y,timeout:x}).onAbort(T=>this.#r({name:m.ABORTED,event:T,global:k})).onTimeout(T=>this.#r({name:m.TIMEOUT,event:T,global:k}));return p.signal=re.signal,this.#r({name:m.CONFIGURED,data:p,global:k}),{signalController:re,requestOptions:p,global:k}}static#j(e){if(e instanceof URL)return e;if(!z(e))throw new TypeError("Invalid URL");return new URL(e,e.startsWith("/")?globalThis.location.origin:void 0)}static#J(e){if(e===null)return;let t=n.#m.get(e);return t!==void 0||(t=M.parse(e)??void 0,t!==void 0&&(n.#m.size>=100&&n.#m.delete(n.#m.keys().next().value),n.#m.set(e,t))),t}static#l(e,t,s){let r;if(e instanceof URL){let o=e.pathname,i=o.charCodeAt(o.length-1)===47?o.slice(0,-1):o;r=t?new URL(`${i}${t}`,e.origin):new URL(e)}else r=t?new URL(`${e.#s}${t}`,e.#t):new URL(e.#e);return s&&n.#b(r.searchParams,s),r}static#$(e,{status:t,statusText:s}=new Response){switch(e){case w.ABORT:return Re;case w.TIMEOUT:return he;default:return t>=400?new E(t,s):fe}}async#H(e,t,{cause:s,entity:r,url:o,method:i,timing:a}={},d){let u=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,l=new O(n.#$(s?.name,t),{message:u,cause:s,entity:r,url:o,method:i,timing:a});return l=await this.#D(l,d?.hooks?.beforeError),this.#r({name:m.ERROR,data:l}),l}#r({name:e,event:t,data:s,global:r=!0}){let o=r&&(n.#p[e]??0)>0,i=(this.#u[e]??0)>0;if(!o&&!i)return;let a=t??new CustomEvent(e);o&&n.#O.publish(e,a,s),i&&this.#h.publish(e,a,s)}#G(e){if(!e)return;let t=n.#d.get(e);if(t!==void 0)return t===null?void 0:t;let s=n.#J(e);if(!s){n.#d.set(e,null);return}let r=n.#q;for(let i=0,a=r.length;i<a;i++){let d=r[i];if(s.matches(d[0])){let u=d[1];return n.#d.set(e,u),u}}let o=s.subtype;if(o.endsWith("+json"))return n.#d.set(e,H),H;if(o.endsWith("+xml"))return n.#d.set(e,C),C;n.#d.set(e,null)}get[Symbol.toStringTag](){return"Transportr"}};export{He as Transportr};
|
|
7
|
+
`,!0)){let t=e.trim();t&&(yield JSON.parse(t))}}});var Se=n=>n!==void 0&&pe.includes(n),Pe=n=>n instanceof FormData||n instanceof Blob||n instanceof ArrayBuffer||n instanceof ReadableStream||n instanceof URLSearchParams||ArrayBuffer.isView(n),ve=n=>{if(typeof document>"u")return;let e=document.cookie;if(!e)return;let t=`${n}=`,s=t.length,r=e.length,o=0;for(;o<r;){for(;o<r&&e.charCodeAt(o)===32;)o++;let i=e.indexOf(";",o);if(i===-1&&(i=r),i-o>=s&&e.startsWith(t,o))return decodeURIComponent(e.slice(o+s,i));o=i+1}},Ae=n=>JSON.stringify(n),z=n=>n!==null&&typeof n=="string",Be=n=>n instanceof ArrayBuffer||Object.prototype.toString.call(n)==="[object ArrayBuffer]",g=n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype,X=(...n)=>{let e=n.length;if(e===0)return;if(e===1){let[s]=n;return g(s)?se(s):s}let t={};for(let s=0,r=n.length;s<r;s++){let o=n[s];if(!g(o))return;let i=Object.keys(o);for(let a=0,d=i.length;a<d;a++){let u=i[a],l=o[u],c=t[u];if(Array.isArray(l))if(Array.isArray(c)){let f=l.slice();for(let R=0,p=c.length;R<p;R++){let y=c[R];l.includes(y)||f.push(y)}t[u]=f}else t[u]=l.slice();else g(l)?t[u]=g(c)?X(c,l):se(l):t[u]=l}}return t};function se(n){if(g(n)){let e={},t=Object.keys(n);for(let s=0,r=t.length,o;s<r;s++)o=t[s],e[o]=se(n[o]);return e}return n}var He=class n{#e;#t;#s;#n;#o;#h;#a={beforeRequest:[],afterResponse:[],beforeError:[]};#f={beforeRequest:0,afterResponse:0,beforeError:0};#u=Object.create(null);static#O=new U;static#c={beforeRequest:[],afterResponse:[],beforeError:[]};static#R={beforeRequest:0,afterResponse:0,beforeError:0};static#p=Object.create(null);static#g=new Set;static#E=new Map;static#L={limit:0,statusCodes:[],methods:[],delay:D,backoffFactor:F};static#C=new WeakMap;static#m=new Map([[A.toString(),A]]);static#d=new Map;static#q=[[h.TEXT,me],[h.JSON,H],[h.BIN,te],[h.HTML,ne],[h.XML,C],[h.PNG,ee],[h.JAVA_SCRIPT,Q],[h.CSS,_]];constructor(e=W,t={}){g(e)&&([e,t]=[W,e]),this.#e=n.#j(e),this.#t=this.#e.origin;let s=this.#e.pathname;this.#s=s.length>0&&s.charCodeAt(s.length-1)===47?s.slice(0,-1):s,this.#n=n.#F(t,n.#I),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type"),this.#h=new U}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestMode={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriority={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicy={ERROR:"error",FOLLOW:"follow",MANUAL:"manual"};static ReferrerPolicy={NO_REFERRER:"no-referrer",NO_REFERRER_WHEN_DOWNGRADE:"no-referrer-when-downgrade",ORIGIN:"origin",ORIGIN_WHEN_CROSS_ORIGIN:"origin-when-cross-origin",SAME_ORIGIN:"same-origin",STRICT_ORIGIN:"strict-origin",STRICT_ORIGIN_WHEN_CROSS_ORIGIN:"strict-origin-when-cross-origin",UNSAFE_URL:"unsafe-url"};static RequestEvent=m;static#I={body:void 0,cache:le.NO_STORE,credentials:n.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":A.toString(),accept:A.toString()}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:n.RequestMode.CORS,priority:n.RequestPriority.AUTO,redirect:n.RedirectPolicy.FOLLOW,referrer:"about:client",referrerPolicy:n.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,s){let r=n.#O.subscribe(e,t,s);return n.#p[e]=(n.#p[e]??0)+1,r}static unregister(e){let t=n.#O.unsubscribe(e);if(t){let s=e.eventName,r=(n.#p[s]??1)-1;r<=0?delete n.#p[s]:n.#p[s]=r}return t}static abortAll(){for(let e of this.#g)e.abort(N());this.#g.clear()}static all(e){return Promise.all(e)}static async race(e){let t=[],s=new Array(e.length);for(let r=0;r<e.length;r++){let o=new AbortController;t.push(o),s[r]=e[r](o.signal)}try{return await Promise.race(s)}finally{for(let r of t)r.abort()}}static registerContentTypeHandler(e,t){n.#q.unshift([e,t]),n.#d.clear()}static unregisterContentTypeHandler(e){let t=n.#q.findIndex(([s])=>s===e);return t===-1?!1:(n.#q.splice(t,1),n.#d.clear(),!0)}static addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;t&&(n.#c.beforeRequest.push(...t),n.#R.beforeRequest+=t.length),s&&(n.#c.afterResponse.push(...s),n.#R.afterResponse+=s.length),r&&(n.#c.beforeError.push(...r),n.#R.beforeError+=r.length)}static clearHooks(){n.#c={beforeRequest:[],afterResponse:[],beforeError:[]},n.#R.beforeRequest=0,n.#R.afterResponse=0,n.#R.beforeError=0}static unregisterAll(){n.abortAll(),n.#O=new U,n.#p=Object.create(null),n.clearHooks(),n.#E.clear()}get baseUrl(){return this.#e}register(e,t,s){let r=this.#h.subscribe(e,t,s);return this.#u[e]=(this.#u[e]??0)+1,r}unregister(e){let t=this.#h.unsubscribe(e);if(t){let s=e.eventName,r=(this.#u[s]??1)-1;r<=0?delete this.#u[s]:this.#u[s]=r}return t}addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;return t&&(this.#a.beforeRequest.push(...t),this.#f.beforeRequest+=t.length),s&&(this.#a.afterResponse.push(...s),this.#f.afterResponse+=s.length),r&&(this.#a.beforeError.push(...r),this.#f.beforeError+=r.length),this}clearHooks(){return this.#a.beforeRequest.length=0,this.#a.afterResponse.length=0,this.#a.beforeError.length=0,this.#f.beforeRequest=0,this.#f.afterResponse=0,this.#f.beforeError=0,this}configure({headers:e,searchParams:t,hooks:s,...r}){return e&&(n.#B(this.#n.headers,e),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type")),t&&n.#b(this.#n.searchParams,t),Object.assign(this.#n,r),s&&this.addHooks(s),this}destroy(){this.clearHooks(),this.#h.destroy();for(let e in this.#u)delete this.#u[e]}async get(e,t){return this.#i(e,t)}async post(e,t,s){return this.#S("POST",e,t,s)}async put(e,t,s){return this.#S("PUT",e,t,s)}async patch(e,t,s){return this.#S("PATCH",e,t,s)}async delete(e,t,s){return this.#S("DELETE",e,t,s)}async head(e,t){return this.#A(e,t,{method:"HEAD"})}async options(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{method:"OPTIONS"}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s);d=await this.#v(d,r,i?.afterResponse);let u=d.headers.get("allow"),l;if(u){let c=u.split(",");l=new Array(c.length);for(let f=0,R=c.length;f<R;f++)l[f]=c[f].trim()}return this.#r({name:m.SUCCESS,data:l,global:t.global}),o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async request(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{}),r=s.requestOptions.unwrap!==!1;try{let o=await this.#y(e,s);return this.#r({name:m.SUCCESS,data:o,global:t.global}),r?o:[!0,o]}catch(o){if(!r)return[!1,o];throw o}}async getJson(e,t){return this.#i(e,t,{headers:{accept:`${h.JSON}`}},H)}async getXml(e,t){return this.#i(e,t,{headers:{accept:`${h.XML}`}},C)}async getHtml(e,t,s){let r=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},ne);return Array.isArray(r)?r:s&&r?r.querySelector(s):r}async getHtmlFragment(e,t,s){let o=((g(e)?e:t)?.allowScripts??this.#n.allowScripts)===!0,i=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},o?Oe:Te);return Array.isArray(i)?i:s&&i?i.querySelector(s):i}async getScript(e,t){return this.#i(e,t,{headers:{accept:`${h.JAVA_SCRIPT}`}},Q)}async getStylesheet(e,t){return this.#i(e,t,{headers:{accept:`${h.CSS}`}},_)}async getBlob(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},ye)}async getImage(e,t){return this.#i(e,t,{headers:{accept:"image/*"}},ee)}async getBuffer(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},be)}async getStream(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},te)}async getEventStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:t?.body?"POST":"GET",headers:{accept:`${h.EVENT_STREAM}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:m.SUCCESS,data:u,global:s.global});let l=qe(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async getJsonStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:"GET",headers:{accept:`${h.NDJSON}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:m.SUCCESS,data:u,global:s.global});let l=we(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async#i(e,t,s={},r){return s.method="GET",s.body=void 0,this.#A(e,t,s,r)}async#y(e,t){let{signalController:s,requestOptions:r,global:o}=t;n.#g.add(s);let i=n.#N(r.retry),a=r.method??"GET",d=i.limit>0&&i.methods.includes(a),u=r.dedupe===!0&&(a==="GET"||a==="HEAD"),l=performance.now();try{let c=n.#l(this,e,r.searchParams),f;if(u){f=`${a}:${c.href}`;let x=n.#E.get(f);if(x)return(await x).clone()}let R=r.onUploadProgress,p=r.body;R&&p!=null&&(r.duplex="half");let y=this.#M(c,r,e,a,d,i,p,R,l,o);if(u){n.#E.set(f,y);try{return n.#x(await y,r)}finally{n.#E.delete(f)}}return n.#x(await y,r)}finally{if(n.#g.delete(s.destroy()),!r.signal?.aborted){let c=performance.now();this.#r({name:m.COMPLETE,data:{timing:{start:l,end:c,duration:c-l}},global:o}),n.#g.size===0&&this.#r({name:m.ALL_COMPLETE,global:o})}}}async#M(e,t,s,r,o,i,a,d,u,l){let c=0;for(;;)try{d&&await n.#U(t,a,d);let f=await fetch(e,t);if(!f.ok){if(o&&c<i.limit&&i.statusCodes.includes(f.status)){c++,this.#r({name:m.RETRY,data:{attempt:c,status:f.status,method:r,path:s,timing:n.#w(u)},global:l}),await n.#k(i,c);continue}let R;if(t.captureErrorBody!==!1)try{R=await f.text()}catch{}throw await this.#H(s,f,{entity:R,url:e,method:r,timing:n.#w(u)},t)}return f}catch(f){if(f instanceof O)throw f;if(o&&c<i.limit){c++,this.#r({name:m.RETRY,data:{attempt:c,error:f.message,method:r,path:s,timing:n.#w(u)},global:l}),await n.#k(i,c);continue}throw await this.#H(s,void 0,{cause:f,url:e,method:r,timing:n.#w(u)},t)}}static async#U(e,t,s){if(t==null)return;let r=null;if(typeof t=="string")r=new TextEncoder().encode(t);else if(t instanceof Blob)r=new Uint8Array(await t.arrayBuffer());else if(Be(t))r=new Uint8Array(t);else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(!(t instanceof ReadableStream))return;let o=r?r.byteLength:null,i=r?new ReadableStream({start(u){u.enqueue(r),u.close()}}):t,a=0,d=new TransformStream({transform(u,l){a+=u.byteLength,s({loaded:a,total:o,percentage:o!==null&&o>0?Math.round(a/o*100):null}),l.enqueue(u)}});e.body=i.pipeThrough(d)}static#x(e,t){let s=t.onDownloadProgress;if(!s||!e.body)return e;let r=e.headers.get("content-length"),o=r?parseInt(r,10):null,i=0,a=new TransformStream({transform(d,u){i+=d.byteLength,s({loaded:i,total:o,percentage:o!==null&&o>0?Math.round(i/o*100):null}),u.enqueue(d)}});return new Response(e.body.pipeThrough(a),{status:e.status,statusText:e.statusText,headers:e.headers})}static#w(e){let t=performance.now();return{start:e,end:t,duration:t-e}}static#N(e){if(e===void 0)return n.#L;if(typeof e=="number")return{limit:e,statusCodes:K,methods:Y,delay:D,backoffFactor:F};let t=n.#C.get(e);if(t!==void 0)return t;let s={limit:e.limit??0,statusCodes:e.statusCodes??K,methods:e.methods??Y,delay:e.delay??D,backoffFactor:e.backoffFactor??F};return n.#C.set(e,s),s}static#k(e,t){let s=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(r=>setTimeout(r,s))}#S(e,t,s,r,o){let[i,a,d]=z(t)?[t,s,r]:[void 0,t,s],u=d!==void 0?Object.assign({},d,{body:a,method:e}):{body:a,method:e};return this.#A(i,u,{},o)}async#P(e,t,s,r){let o=n.#c.beforeRequest,i=this.#a.beforeRequest,a=r===void 0?0:r.length;if(o.length===0&&i.length===0&&a===0)return t;for(let d=0,u=o.length;d<u;d++){let l=await o[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0,u=i.length;d<u;d++){let l=await i[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0;d<a;d++){let u=await r[d](e,t);u&&(Object.assign(e,u),u.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}return t}async#v(e,t,s){let r=n.#c.afterResponse,o=this.#a.afterResponse,i=s===void 0?0:s.length;if(r.length===0&&o.length===0&&i===0)return e;for(let a=0,d=r.length;a<d;a++){let u=await r[a](e,t);u&&(e=u)}for(let a=0,d=o.length;a<d;a++){let u=await o[a](e,t);u&&(e=u)}for(let a=0;a<i;a++){let d=await s[a](e,t);d&&(e=d)}return e}async#D(e,t){let s=n.#c.beforeError,r=this.#a.beforeError,o=t===void 0?0:t.length;if(s.length===0&&r.length===0&&o===0)return e;for(let i=0,a=s.length;i<a;i++){let d=await s[i](e);d instanceof O&&(e=d)}for(let i=0,a=r.length;i<a;i++){let d=await r[i](e);d instanceof O&&(e=d)}for(let i=0;i<o;i++){let a=await t[i](e);a instanceof O&&(e=a)}return e}async#A(e,t={},s={},r){g(e)&&([e,t]=[void 0,e]);let o=this.#T(t,s),{requestOptions:i}=o,a=i.unwrap!==!1,d=i.hooks;try{let u=n.#l(this,e,i.searchParams);await this.#P(i,u,e,d?.beforeRequest);let l=await this.#y(e,o);l=await this.#v(l,i,d?.afterResponse);try{!r&&l.status!==204&&(r=this.#G(l.headers.get("content-type")));let c=await r?.(l);return this.#r({name:m.SUCCESS,data:c,global:o.global}),a?c:[!0,c]}catch(c){throw await this.#H(e,l,{cause:c},i)}}catch(u){if(!a)return[!1,u];throw u}}static#F({headers:e,searchParams:t,...s},{headers:r,searchParams:o,...i}){return r=n.#B(new Headers,e,r),o=n.#b(new URLSearchParams,t,o),{...X(i,s),headers:r,searchParams:o}}static#B(e,...t){for(let s of t)if(s!==void 0)if(s instanceof Headers)s.forEach((r,o)=>e.set(o,r));else if(Array.isArray(s))for(let[r,o]of s)e.set(r,o);else{let r=Object.keys(s);for(let o=0,i=r.length;o<i;o++){let a=r[o],d=s[a];d!==void 0&&e.set(a,d)}}return e}static#b(e,...t){for(let s of t)if(s!==void 0)if(s instanceof URLSearchParams)s.forEach((r,o)=>e.set(o,r));else if(z(s)||Array.isArray(s))for(let[r,o]of new URLSearchParams(s))e.set(r,o);else{let r=Object.keys(s);for(let o=0;o<r.length;o++){let i=r[o],a=s[i];a!==void 0&&e.set(i,typeof a=="string"?a:String(a))}}return e}#T(e,t){let s=e.headers,r=e.searchParams,o=e.body,i=t.headers,a=t.searchParams,d=t.method??e.method??this.#n.method??"GET",u=Se(d),l;!u&&s===void 0&&i===void 0?l=new Headers(this.#o):(l=new Headers(this.#n.headers),(s!==void 0||i!==void 0)&&n.#B(l,s,i));let c=this.#n.searchParams,f=c!==void 0&&c.size>0,R;!f&&r===void 0&&a===void 0?R=new URLSearchParams:(R=new URLSearchParams(c),(r!==void 0||a!==void 0)&&n.#b(R,r,a));let p=Object.assign({},this.#n,e,t);if(p.headers=l,p.searchParams=R,u)if(Pe(o))p.body=o,l.delete("content-type");else{let T=this.#n.body,S=g(T)&&g(o)?X(T,o):o!==void 0?o:T,P=l.get("content-type"),Ce=P!==null&&P.includes("json");p.body=Ce&&g(S)?Ae(S):S}else p.body instanceof URLSearchParams&&n.#b(R,p.body),p.body=void 0,(s!==void 0||i!==void 0)&&l.delete("content-type");let y=p.signal,x=p.timeout,k=p.global??!1,V=p.xsrf;if(V){let{cookieName:T,headerName:S}=typeof V=="object"?V:{},P=ve(T??ue);P&&l.set(S??de,P)}let re=new j({signal:y,timeout:x}).onAbort(T=>this.#r({name:m.ABORTED,event:T,global:k})).onTimeout(T=>this.#r({name:m.TIMEOUT,event:T,global:k}));return p.signal=re.signal,this.#r({name:m.CONFIGURED,data:p,global:k}),{signalController:re,requestOptions:p,global:k}}static#j(e){if(e instanceof URL)return e;if(!z(e))throw new TypeError("Invalid URL");return new URL(e,e.startsWith("/")?globalThis.location.origin:void 0)}static#J(e){if(e===null)return;let t=n.#m.get(e);return t!==void 0||(t=M.parse(e)??void 0,t!==void 0&&(n.#m.size>=100&&n.#m.delete(n.#m.keys().next().value),n.#m.set(e,t))),t}static#l(e,t,s){let r;if(e instanceof URL){let o=e.pathname,i=o.charCodeAt(o.length-1)===47?o.slice(0,-1):o;r=t?new URL(`${i}${t}`,e.origin):new URL(e)}else r=t?new URL(`${e.#s}${t}`,e.#t):new URL(e.#e);return s&&n.#b(r.searchParams,s),r}static#$(e,{status:t,statusText:s}=new Response){switch(e){case w.ABORT:return Re;case w.TIMEOUT:return he;default:return t>=400?new E(t,s):fe}}async#H(e,t,{cause:s,entity:r,url:o,method:i,timing:a}={},d){let u=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,l=new O(n.#$(s?.name,t),{message:u,cause:s,entity:r,url:o,method:i,timing:a});return l=await this.#D(l,d?.hooks?.beforeError),this.#r({name:m.ERROR,data:l}),l}#r({name:e,event:t,data:s,global:r=!0}){let o=r&&(n.#p[e]??0)>0,i=(this.#u[e]??0)>0;if(!o&&!i)return;let a=t??new CustomEvent(e);o&&n.#O.publish(e,a,s),i&&this.#h.publish(e,a,s)}#G(e){if(!e)return;let t=n.#d.get(e);if(t!==void 0)return t===null?void 0:t;let s=n.#J(e);if(!s){n.#d.set(e,null);return}let r=n.#q;for(let i=0,a=r.length;i<a;i++){let d=r[i];if(s.matches(d[0])){let u=d[1];return n.#d.set(e,u),u}}let o=s.subtype;if(o.endsWith("+json"))return n.#d.set(e,H),H;if(o.endsWith("+xml"))return n.#d.set(e,C),C;n.#d.set(e,null)}get[Symbol.toStringTag](){return"Transportr"}};export{He as Transportr};
|
|
8
8
|
//# sourceMappingURL=transportr.js.map
|