var strapi=function(t){"use strict";class e{_options;constructor(t){this._options=t,this.preflightValidation()}}class r extends Error{constructor(t=void 0,e="An error occurred in the Strapi client. Please check the logs for more information."){super(e),this.cause=t}}class n extends r{constructor(t=void 0,e="Some of the provided values are not valid."){super(t,e)}}class o extends r{constructor(t=void 0,e="Could not initialize the Strapi Client"){super(t,e)}}class i extends Error{}class a extends i{constructor(t){super(`Could not parse invalid URL: "${t}"`)}}class s extends Error{name="HTTPError";response;request;constructor(t,e){const r=`${t.status?.toString()??""} ${t.statusText??""}`.trim();super(`Request failed with ${r?`status code ${r}`:"an unknown error"}: ${e.method} ${e.url}`),this.response=t,this.request=e}}class u extends s{name="HTTPAuthorizationError"}class l extends s{name="HTTPNotFoundError"}class c extends s{name="HTTPBadRequestError"}class p extends s{name="HTTPInternalServerError"}class f extends s{name="HTTPForbiddenError"}class y extends s{name="HTTPTimeoutError"}const d=()=>{};class h extends e{static identifier="api-token";constructor(t){super(t)}get name(){return h.identifier}get _token(){return this._options.token}preflightValidation(){if(d("validating provider configuration"),"string"!=typeof this._token||0===this._token.trim().length)throw d("invalid api token provided: %o (%o)",this._token,typeof this._token),new n(`A valid API token is required when using the api-token auth strategy. Got "${this._token}"`);d("provider configuration validated successfully")}authenticate(){return d("no authentication step is required for the %o auth strategy, skipping",this.name),Promise.resolve()}get headers(){return{Authorization:`Bearer ${this._token}`}}}const g=()=>{},m="/auth/local";class b extends e{static identifier="users-permissions";_token=null;constructor(t){super(t)}get name(){return b.identifier}get _credentials(){return{identifier:this._options.identifier,password:this._options.password}}preflightValidation(){if(g("validating provider configuration"),void 0===this._options||null===this._options||"object"!=typeof this._options)throw g("invalid options provided: %s (%s)",this._options,typeof this._options),new n("Missing valid options for initializing the Users & Permissions auth provider.");const{identifier:t,password:e}=this._options;if("string"!=typeof t)throw g("invalid identifier provided: %s (%s)",t,typeof t),new n(`The "identifier" option must be a string, but got "${typeof t}"`);if("string"!=typeof e)throw g("invalid password provided: %s (%s)",e,typeof e),new n(`The "password" option must be a string, but got "${typeof e}"`);g("provider configuration validated successfully")}get headers(){return null===this._token?{}:{Authorization:`Bearer ${this._token}`}}async authenticate(t){const{identifier:e,password:r}=this._credentials;g("trying to authenticate with %o as %o at %o ",this.name,e,m);const n=await t.post(m,JSON.stringify({identifier:e,password:r}),{headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error(n.statusText);const o=await n.json(),i=o.jwt.slice(0,5)+"..."+o.jwt.slice(-5);g("authentication successful for %o (%o)",e,i),this._token=o.jwt}}const w=()=>{};class v{_registry=new Map;create(t,e){const n=this._registry.get(t);if(!n)throw w("the %o auth strategy is not registered, skipping",t),new r(`Auth strategy "${t}" is not supported.`);const o=n(e);return w("successfully instantiated a new %o provider",t),o}register(t,e){return this._registry.set(t,e),w("registered a new auth strategy: %o",t),this}}const _=()=>{};class S{_authProviderFactory;_authProvider;_isAuthenticated=!1;constructor(t=new v){_("initializing a new auth manager"),this._authProviderFactory=t,this.registerDefaultProviders()}get strategy(){return this._authProvider?.name}get isAuthenticated(){return this._isAuthenticated}handleUnauthorizedError(){_("unauthorized error encountered, resetting authentication status"),this._isAuthenticated=!1}setStrategy(t,e){_("setting strategy to %o",t),this._authProvider=this._authProviderFactory.create(t,e)}async authenticate(t){if(void 0===this._authProvider)return _("no auth provider is set, skipping authentication"),void(this._isAuthenticated=!1);try{_("trying to authenticate with %s",this._authProvider.name);const e=t.create(void 0,!1);await this._authProvider.authenticate(e),this._isAuthenticated=!0,_("authentication successful")}catch(t){_(`authentication failed: ${t}`),this._isAuthenticated=!1}}authenticateRequest(t){if(!this._authProvider)return;const{headers:e}=t;if(!(e instanceof Headers))throw new Error(`Invalid request headers, headers must be an instance of Headers but found "${typeof e}"`);for(const[t,r]of Object.entries(this._authProvider.headers))e.set(t,r)}registerDefaultProviders(){_("registering default authentication providers"),this._authProviderFactory.register(h.identifier,t=>new h(t)).register(b.identifier,t=>new b(t)),_("default authentication providers registered successfully")}}var O,A,E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function P(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function j(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){var r=!1;try{r=this instanceof t}catch(t){}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),r}function R(){return A?O:(A=1,O=TypeError)}var T,x,I,D,U,N,L,F,k,M,C,B,$,q,H,W,z,V,Q,K,G,J,Z,Y,X,tt,et,rt,nt,ot,it,at,st,ut,lt,ct,pt,ft,yt,dt,ht,gt,mt,bt,wt,vt,_t,St,Ot,At,Et,Pt,jt,Rt,Tt,xt,It,Dt,Ut,Nt,Lt,Ft,kt,Mt,Ct,Bt,$t,qt,Ht,Wt,zt,Vt,Qt,Kt,Gt,Jt,Zt,Yt,Xt,te,ee,re,ne,oe,ie,ae,se,ue,le=j(Object.freeze({__proto__:null,default:{}}));function ce(){if(x)return T;x=1;var t="function"==typeof Map&&Map.prototype,e=Object.getOwnPropertyDescriptor&&t?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=t&&e&&"function"==typeof e.get?e.get:null,n=t&&Map.prototype.forEach,o="function"==typeof Set&&Set.prototype,i=Object.getOwnPropertyDescriptor&&o?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,a=o&&i&&"function"==typeof i.get?i.get:null,s=o&&Set.prototype.forEach,u="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,l="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,c="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,f=Object.prototype.toString,y=Function.prototype.toString,d=String.prototype.match,h=String.prototype.slice,g=String.prototype.replace,m=String.prototype.toUpperCase,b=String.prototype.toLowerCase,w=RegExp.prototype.test,v=Array.prototype.concat,_=Array.prototype.join,S=Array.prototype.slice,O=Math.floor,A="function"==typeof BigInt?BigInt.prototype.valueOf:null,P=Object.getOwnPropertySymbols,j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,R="function"==typeof Symbol&&"object"==typeof Symbol.iterator,I="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===R||"symbol")?Symbol.toStringTag:null,D=Object.prototype.propertyIsEnumerable,U=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function N(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||w.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var n=t<0?-O(-t):O(t);if(n!==t){var o=String(n),i=h.call(e,o.length+1);return g.call(o,r,"$&_")+"."+g.call(g.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return g.call(e,r,"$&_")}var L=le,F=L.custom,k=z(F)?F:null,M={__proto__:null,double:'"',single:"'"},C={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};function B(t,e,r){var n=r.quoteStyle||e,o=M[n];return o+t+o}function $(t){return g.call(String(t),/"/g,"&quot;")}function q(t){return!I||!("object"==typeof t&&(I in t||void 0!==t[I]))}function H(t){return"[object Array]"===K(t)&&q(t)}function W(t){return"[object RegExp]"===K(t)&&q(t)}function z(t){if(R)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!j)return!1;try{return j.call(t),!0}catch(t){}return!1}T=function t(e,o,i,f){var m=o||{};if(Q(m,"quoteStyle")&&!Q(M,m.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Q(m,"maxStringLength")&&("number"==typeof m.maxStringLength?m.maxStringLength<0&&m.maxStringLength!==1/0:null!==m.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var w=!Q(m,"customInspect")||m.customInspect;if("boolean"!=typeof w&&"symbol"!==w)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Q(m,"indent")&&null!==m.indent&&"\t"!==m.indent&&!(parseInt(m.indent,10)===m.indent&&m.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Q(m,"numericSeparator")&&"boolean"!=typeof m.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var O=m.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return J(e,m);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var P=String(e);return O?N(e,P):P}if("bigint"==typeof e){var T=String(e)+"n";return O?N(e,T):T}var x=void 0===m.depth?5:m.depth;if(void 0===i&&(i=0),i>=x&&x>0&&"object"==typeof e)return H(e)?"[Array]":"[Object]";var F=function(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=_.call(Array(t.indent+1)," ")}return{base:r,prev:_.call(Array(e+1),r)}}(m,i);if(void 0===f)f=[];else if(G(f,e)>=0)return"[Circular]";function C(e,r,n){if(r&&(f=S.call(f)).push(r),n){var o={depth:m.depth};return Q(m,"quoteStyle")&&(o.quoteStyle=m.quoteStyle),t(e,o,i+1,f)}return t(e,m,i+1,f)}if("function"==typeof e&&!W(e)){var V=function(t){if(t.name)return t.name;var e=d.call(y.call(t),/^function\s*([\w$]+)/);if(e)return e[1];return null}(e),Z=rt(e,C);return"[Function"+(V?": "+V:" (anonymous)")+"]"+(Z.length>0?" { "+_.call(Z,", ")+" }":"")}if(z(e)){var nt=R?g.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):j.call(e);return"object"!=typeof e||R?nt:Y(nt)}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(e)){for(var ot="<"+b.call(String(e.nodeName)),it=e.attributes||[],at=0;at<it.length;at++)ot+=" "+it[at].name+"="+B($(it[at].value),"double",m);return ot+=">",e.childNodes&&e.childNodes.length&&(ot+="..."),ot+="</"+b.call(String(e.nodeName))+">"}if(H(e)){if(0===e.length)return"[]";var st=rt(e,C);return F&&!function(t){for(var e=0;e<t.length;e++)if(G(t[e],"\n")>=0)return!1;return!0}(st)?"["+et(st,F)+"]":"[ "+_.call(st,", ")+" ]"}if(function(t){return"[object Error]"===K(t)&&q(t)}(e)){var ut=rt(e,C);return"cause"in Error.prototype||!("cause"in e)||D.call(e,"cause")?0===ut.length?"["+String(e)+"]":"{ ["+String(e)+"] "+_.call(ut,", ")+" }":"{ ["+String(e)+"] "+_.call(v.call("[cause]: "+C(e.cause),ut),", ")+" }"}if("object"==typeof e&&w){if(k&&"function"==typeof e[k]&&L)return L(e,{depth:x-i});if("symbol"!==w&&"function"==typeof e.inspect)return e.inspect()}if(function(t){if(!r||!t||"object"!=typeof t)return!1;try{r.call(t);try{a.call(t)}catch(t){return!0}return t instanceof Map}catch(t){}return!1}(e)){var lt=[];return n&&n.call(e,function(t,r){lt.push(C(r,e,!0)+" => "+C(t,e))}),tt("Map",r.call(e),lt,F)}if(function(t){if(!a||!t||"object"!=typeof t)return!1;try{a.call(t);try{r.call(t)}catch(t){return!0}return t instanceof Set}catch(t){}return!1}(e)){var ct=[];return s&&s.call(e,function(t){ct.push(C(t,e))}),tt("Set",a.call(e),ct,F)}if(function(t){if(!u||!t||"object"!=typeof t)return!1;try{u.call(t,u);try{l.call(t,l)}catch(t){return!0}return t instanceof WeakMap}catch(t){}return!1}(e))return X("WeakMap");if(function(t){if(!l||!t||"object"!=typeof t)return!1;try{l.call(t,l);try{u.call(t,u)}catch(t){return!0}return t instanceof WeakSet}catch(t){}return!1}(e))return X("WeakSet");if(function(t){if(!c||!t||"object"!=typeof t)return!1;try{return c.call(t),!0}catch(t){}return!1}(e))return X("WeakRef");if(function(t){return"[object Number]"===K(t)&&q(t)}(e))return Y(C(Number(e)));if(function(t){if(!t||"object"!=typeof t||!A)return!1;try{return A.call(t),!0}catch(t){}return!1}(e))return Y(C(A.call(e)));if(function(t){return"[object Boolean]"===K(t)&&q(t)}(e))return Y(p.call(e));if(function(t){return"[object String]"===K(t)&&q(t)}(e))return Y(C(String(e)));if("undefined"!=typeof window&&e===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&e===globalThis||void 0!==E&&e===E)return"{ [object globalThis] }";if(!function(t){return"[object Date]"===K(t)&&q(t)}(e)&&!W(e)){var pt=rt(e,C),ft=U?U(e)===Object.prototype:e instanceof Object||e.constructor===Object,yt=e instanceof Object?"":"null prototype",dt=!ft&&I&&Object(e)===e&&I in e?h.call(K(e),8,-1):yt?"Object":"",ht=(ft||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(dt||yt?"["+_.call(v.call([],dt||[],yt||[]),": ")+"] ":"");return 0===pt.length?ht+"{}":F?ht+"{"+et(pt,F)+"}":ht+"{ "+_.call(pt,", ")+" }"}return String(e)};var V=Object.prototype.hasOwnProperty||function(t){return t in this};function Q(t,e){return V.call(t,e)}function K(t){return f.call(t)}function G(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}function J(t,e){if(t.length>e.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return J(h.call(t,0,e.maxStringLength),e)+n}var o=C[e.quoteStyle||"single"];return o.lastIndex=0,B(g.call(g.call(t,o,"\\$1"),/[\x00-\x1f]/g,Z),"single",e)}function Z(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+m.call(e.toString(16))}function Y(t){return"Object("+t+")"}function X(t){return t+" { ? }"}function tt(t,e,r,n){return t+" ("+e+") {"+(n?et(r,n):_.call(r,", "))+"}"}function et(t,e){if(0===t.length)return"";var r="\n"+e.prev+e.base;return r+_.call(t,","+r)+"\n"+e.prev}function rt(t,e){var r=H(t),n=[];if(r){n.length=t.length;for(var o=0;o<t.length;o++)n[o]=Q(t,o)?e(t[o],t):""}var i,a="function"==typeof P?P(t):[];if(R){i={};for(var s=0;s<a.length;s++)i["$"+a[s]]=a[s]}for(var u in t)Q(t,u)&&(r&&String(Number(u))===u&&u<t.length||R&&i["$"+u]instanceof Symbol||(w.call(/[^\w$]/,u)?n.push(e(u,t)+": "+e(t[u],t)):n.push(u+": "+e(t[u],t))));if("function"==typeof P)for(var l=0;l<a.length;l++)D.call(t,a[l])&&n.push("["+e(a[l])+"]: "+e(t[a[l]],t));return n}return T}function pe(){if(D)return I;D=1;var t=ce(),e=R(),r=function(t,e,r){for(var n,o=t;null!=(n=o.next);o=n)if(n.key===e)return o.next=n.next,r||(n.next=t.next,t.next=n),n};return I=function(){var n,o={assert:function(r){if(!o.has(r))throw new e("Side channel does not contain "+t(r))},delete:function(t){var e=function(t,e){if(t)return r(t,e,!0)}(n,t);return e&&n&&!n.next&&(n=void 0),!!e},get:function(t){return function(t,e){if(t){var n=r(t,e);return n&&n.value}}(n,t)},has:function(t){return function(t,e){return!!t&&!!r(t,e)}(n,t)},set:function(t,e){n||(n={next:void 0}),function(t,e,n){var o=r(t,e);o?o.value=n:t.next={key:e,next:t.next,value:n}}(n,t,e)}};return o}}function fe(){return N?U:(N=1,U=Object)}function ye(){return F?L:(F=1,L=Error)}function de(){return M?k:(M=1,k=EvalError)}function he(){return B?C:(B=1,C=RangeError)}function ge(){return q?$:(q=1,$=ReferenceError)}function me(){return W?H:(W=1,H=SyntaxError)}function be(){return V?z:(V=1,z=URIError)}function we(){return K?Q:(K=1,Q=Math.abs)}function ve(){return J?G:(J=1,G=Math.floor)}function _e(){return Y?Z:(Y=1,Z=Math.max)}function Se(){return tt?X:(tt=1,X=Math.min)}function Oe(){return rt?et:(rt=1,et=Math.pow)}function Ae(){return ot?nt:(ot=1,nt=Math.round)}function Ee(){return at?it:(at=1,it=Number.isNaN||function(t){return t!=t})}function Pe(){if(ut)return st;ut=1;var t=Ee();return st=function(e){return t(e)||0===e?e:e<0?-1:1}}function je(){return ct?lt:(ct=1,lt=Object.getOwnPropertyDescriptor)}function Re(){if(ft)return pt;ft=1;var t=je();if(t)try{t([],"length")}catch(e){t=null}return pt=t}function Te(){if(dt)return yt;dt=1;var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}return yt=t}function xe(){if(bt)return mt;bt=1;var t="undefined"!=typeof Symbol&&Symbol,e=gt?ht:(gt=1,ht=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);if(42!==i.value||!0!==i.enumerable)return!1}return!0});return mt=function(){return"function"==typeof t&&("function"==typeof Symbol&&("symbol"==typeof t("foo")&&("symbol"==typeof Symbol("bar")&&e())))}}function Ie(){return vt?wt:(vt=1,wt="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null)}function De(){return St?_t:(St=1,_t=fe().getPrototypeOf||null)}function Ue(){if(At)return Ot;At=1;var t=Object.prototype.toString,e=Math.max,r=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var o=0;o<e.length;o+=1)r[o+t.length]=e[o];return r};return Ot=function(n){var o=this;if("function"!=typeof o||"[object Function]"!==t.apply(o))throw new TypeError("Function.prototype.bind called on incompatible "+o);for(var i,a=function(t,e){for(var r=[],n=e,o=0;n<t.length;n+=1,o+=1)r[o]=t[n];return r}(arguments,1),s=e(0,o.length-a.length),u=[],l=0;l<s;l++)u[l]="$"+l;if(i=Function("binder","return function ("+function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r}(u,",")+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof i){var t=o.apply(this,r(a,arguments));return Object(t)===t?t:this}return o.apply(n,r(a,arguments))}),o.prototype){var c=function(){};c.prototype=o.prototype,i.prototype=new c,c.prototype=null}return i},Ot}function Ne(){if(Pt)return Et;Pt=1;var t=Ue();return Et=Function.prototype.bind||t}function Le(){return Rt?jt:(Rt=1,jt=Function.prototype.call)}function Fe(){return xt?Tt:(xt=1,Tt=Function.prototype.apply)}function ke(){if(Nt)return Ut;Nt=1;var t=Ne(),e=Fe(),r=Le(),n=Dt?It:(Dt=1,It="undefined"!=typeof Reflect&&Reflect&&Reflect.apply);return Ut=n||t.call(r,e)}function Me(){if(Ft)return Lt;Ft=1;var t=Ne(),e=R(),r=Le(),n=ke();return Lt=function(o){if(o.length<1||"function"!=typeof o[0])throw new e("a function is required");return n(t,r,o)}}function Ce(){if(Mt)return kt;Mt=1;var t,e=Me(),r=Re();try{t=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var n=!!t&&r&&r(Object.prototype,"__proto__"),o=Object,i=o.getPrototypeOf;return kt=n&&"function"==typeof n.get?e([n.get]):"function"==typeof i&&function(t){return i(null==t?t:o(t))}}function Be(){if(Bt)return Ct;Bt=1;var t=Ie(),e=De(),r=Ce();return Ct=t?function(e){return t(e)}:e?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return e(t)}:r?function(t){return r(t)}:null}function $e(){if(qt)return $t;qt=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=Ne();return $t=r.call(t,e)}function qe(){if(Wt)return Ht;var t;Wt=1;var e=fe(),r=ye(),n=de(),o=he(),i=ge(),a=me(),s=R(),u=be(),l=we(),c=ve(),p=_e(),f=Se(),y=Oe(),d=Ae(),h=Pe(),g=Function,m=function(t){try{return g('"use strict"; return ('+t+").constructor;")()}catch(t){}},b=Re(),w=Te(),v=function(){throw new s},_=b?function(){try{return v}catch(t){try{return b(arguments,"callee").get}catch(t){return v}}}():v,S=xe()(),O=Be(),A=De(),E=Ie(),P=Fe(),j=Le(),T={},x="undefined"!=typeof Uint8Array&&O?O(Uint8Array):t,I={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?t:ArrayBuffer,"%ArrayIteratorPrototype%":S&&O?O([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":"undefined"==typeof Atomics?t:Atomics,"%BigInt%":"undefined"==typeof BigInt?t:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?t:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":"undefined"==typeof Float16Array?t:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?t:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?t:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?t:FinalizationRegistry,"%Function%":g,"%GeneratorFunction%":T,"%Int8Array%":"undefined"==typeof Int8Array?t:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?t:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":S&&O?O(O([][Symbol.iterator]())):t,"%JSON%":"object"==typeof JSON?JSON:t,"%Map%":"undefined"==typeof Map?t:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&S&&O?O((new Map)[Symbol.iterator]()):t,"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?t:Promise,"%Proxy%":"undefined"==typeof Proxy?t:Proxy,"%RangeError%":o,"%ReferenceError%":i,"%Reflect%":"undefined"==typeof Reflect?t:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?t:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&S&&O?O((new Set)[Symbol.iterator]()):t,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":S&&O?O(""[Symbol.iterator]()):t,"%Symbol%":S?Symbol:t,"%SyntaxError%":a,"%ThrowTypeError%":_,"%TypedArray%":x,"%TypeError%":s,"%Uint8Array%":"undefined"==typeof Uint8Array?t:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?t:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?t:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?t:Uint32Array,"%URIError%":u,"%WeakMap%":"undefined"==typeof WeakMap?t:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?t:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?t:WeakSet,"%Function.prototype.call%":j,"%Function.prototype.apply%":P,"%Object.defineProperty%":w,"%Object.getPrototypeOf%":A,"%Math.abs%":l,"%Math.floor%":c,"%Math.max%":p,"%Math.min%":f,"%Math.pow%":y,"%Math.round%":d,"%Math.sign%":h,"%Reflect.getPrototypeOf%":E};if(O)try{null.error}catch(t){var D=O(O(t));I["%Error.prototype%"]=D}var U=function t(e){var r;if("%AsyncFunction%"===e)r=m("async function () {}");else if("%GeneratorFunction%"===e)r=m("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=m("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var o=t("%AsyncGenerator%");o&&O&&(r=O(o.prototype))}return I[e]=r,r},N={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},L=Ne(),F=$e(),k=L.call(j,Array.prototype.concat),M=L.call(P,Array.prototype.splice),C=L.call(j,String.prototype.replace),B=L.call(j,String.prototype.slice),$=L.call(j,RegExp.prototype.exec),q=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,H=/\\(\\)?/g,W=function(t,e){var r,n=t;if(F(N,n)&&(n="%"+(r=N[n])[0]+"%"),F(I,n)){var o=I[n];if(o===T&&(o=U(n)),void 0===o&&!e)throw new s("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new a("intrinsic "+t+" does not exist!")};return Ht=function(t,e){if("string"!=typeof t||0===t.length)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new s('"allowMissing" argument must be a boolean');if(null===$(/^%?[^%]*%?$/,t))throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=B(t,0,1),r=B(t,-1);if("%"===e&&"%"!==r)throw new a("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new a("invalid intrinsic syntax, expected opening `%`");var n=[];return C(t,q,function(t,e,r,o){n[n.length]=r?C(o,H,"$1"):e||t}),n}(t),n=r.length>0?r[0]:"",o=W("%"+n+"%",e),i=o.name,u=o.value,l=!1,c=o.alias;c&&(n=c[0],M(r,k([0,1],c)));for(var p=1,f=!0;p<r.length;p+=1){var y=r[p],d=B(y,0,1),h=B(y,-1);if(('"'===d||"'"===d||"`"===d||'"'===h||"'"===h||"`"===h)&&d!==h)throw new a("property names with quotes must have matching quotes");if("constructor"!==y&&f||(l=!0),F(I,i="%"+(n+="."+y)+"%"))u=I[i];else if(null!=u){if(!(y in u)){if(!e)throw new s("base intrinsic for "+t+" exists, but the property is not available.");return}if(b&&p+1>=r.length){var g=b(u,y);u=(f=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:u[y]}else f=F(u,y),u=u[y];f&&!l&&(I[i]=u)}}return u},Ht}function He(){if(Vt)return zt;Vt=1;var t=qe(),e=Me(),r=e([t("%String.prototype.indexOf%")]);return zt=function(n,o){var i=t(n,!!o);return"function"==typeof i&&r(n,".prototype.")>-1?e([i]):i}}function We(){if(Kt)return Qt;Kt=1;var t=qe(),e=He(),r=ce(),n=R(),o=t("%Map%",!0),i=e("Map.prototype.get",!0),a=e("Map.prototype.set",!0),s=e("Map.prototype.has",!0),u=e("Map.prototype.delete",!0),l=e("Map.prototype.size",!0);return Qt=!!o&&function(){var t,e={assert:function(t){if(!e.has(t))throw new n("Side channel does not contain "+r(t))},delete:function(e){if(t){var r=u(t,e);return 0===l(t)&&(t=void 0),r}return!1},get:function(e){if(t)return i(t,e)},has:function(e){return!!t&&s(t,e)},set:function(e,r){t||(t=new o),a(t,e,r)}};return e}}function ze(){if(Yt)return Zt;Yt=1;var t=R(),e=ce(),r=pe(),n=We(),o=function(){if(Jt)return Gt;Jt=1;var t=qe(),e=He(),r=ce(),n=We(),o=R(),i=t("%WeakMap%",!0),a=e("WeakMap.prototype.get",!0),s=e("WeakMap.prototype.set",!0),u=e("WeakMap.prototype.has",!0),l=e("WeakMap.prototype.delete",!0);return Gt=i?function(){var t,e,c={assert:function(t){if(!c.has(t))throw new o("Side channel does not contain "+r(t))},delete:function(r){if(i&&r&&("object"==typeof r||"function"==typeof r)){if(t)return l(t,r)}else if(n&&e)return e.delete(r);return!1},get:function(r){return i&&r&&("object"==typeof r||"function"==typeof r)&&t?a(t,r):e&&e.get(r)},has:function(r){return i&&r&&("object"==typeof r||"function"==typeof r)&&t?u(t,r):!!e&&e.has(r)},set:function(r,o){i&&r&&("object"==typeof r||"function"==typeof r)?(t||(t=new i),s(t,r,o)):n&&(e||(e=n()),e.set(r,o))}};return c}:n}(),i=o||n||r;return Zt=function(){var r,n={assert:function(r){if(!n.has(r))throw new t("Side channel does not contain "+e(r))},delete:function(t){return!!r&&r.delete(t)},get:function(t){return r&&r.get(t)},has:function(t){return!!r&&r.has(t)},set:function(t,e){r||(r=i()),r.set(t,e)}};return n}}function Ve(){if(te)return Xt;te=1;var t=String.prototype.replace,e=/%20/g,r="RFC3986";return Xt={default:r,formatters:{RFC1738:function(r){return t.call(r,e,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:r}}function Qe(){if(re)return ee;re=1;var t=Ve(),e=ze(),r=Object.prototype.hasOwnProperty,n=Array.isArray,o=e(),i=function(t,e){return o.set(t,e),t},a=function(t){return o.has(t)},s=function(t){return o.get(t)},u=function(t,e){o.set(t,e)},l=function(){for(var t=[],e=0;e<256;++e)t[t.length]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return t}(),c=function(t,e){for(var r=e&&e.plainObjects?{__proto__:null}:{},n=0;n<t.length;++n)void 0!==t[n]&&(r[n]=t[n]);return r},p=1024;return ee={arrayToObject:c,assign:function(t,e){return Object.keys(e).reduce(function(t,r){return t[r]=e[r],t},t)},combine:function(t,e,r,n){if(a(t)){var o=s(t)+1;return t[o]=e,u(t,o),t}var l=[].concat(t,e);return l.length>r?i(c(l,{plainObjects:n}),l.length-1):l},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],o=0;o<e.length;++o)for(var i=e[o],a=i.obj[i.prop],s=Object.keys(a),u=0;u<s.length;++u){var l=s[u],c=a[l];"object"==typeof c&&null!==c&&-1===r.indexOf(c)&&(e[e.length]={obj:a,prop:l},r[r.length]=c)}return function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(n(r)){for(var o=[],i=0;i<r.length;++i)void 0!==r[i]&&(o[o.length]=r[i]);e.obj[e.prop]=o}}}(e),t},decode:function(t,e,r){var n=t.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(t){return n}},encode:function(e,r,n,o,i){if(0===e.length)return e;var a=e;if("symbol"==typeof e?a=Symbol.prototype.toString.call(e):"string"!=typeof e&&(a=String(e)),"iso-8859-1"===n)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"});for(var s="",u=0;u<a.length;u+=p){for(var c=a.length>=p?a.slice(u,u+p):a,f=[],y=0;y<c.length;++y){var d=c.charCodeAt(y);45===d||46===d||95===d||126===d||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||i===t.RFC1738&&(40===d||41===d)?f[f.length]=c.charAt(y):d<128?f[f.length]=l[d]:d<2048?f[f.length]=l[192|d>>6]+l[128|63&d]:d<55296||d>=57344?f[f.length]=l[224|d>>12]+l[128|d>>6&63]+l[128|63&d]:(y+=1,d=65536+((1023&d)<<10|1023&c.charCodeAt(y)),f[f.length]=l[240|d>>18]+l[128|d>>12&63]+l[128|d>>6&63]+l[128|63&d])}s+=f.join("")}return s},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isOverflow:a,isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},markOverflow:i,maybeMap:function(t,e){if(n(t)){for(var r=[],o=0;o<t.length;o+=1)r[r.length]=e(t[o]);return r}return e(t)},merge:function t(e,o,l){if(!o)return e;if("object"!=typeof o&&"function"!=typeof o){if(n(e)){var p=e.length;if(l&&"number"==typeof l.arrayLimit&&p>l.arrayLimit)return i(c(e.concat(o),l),p);e[p]=o}else{if(!e||"object"!=typeof e)return[e,o];if(a(e)){var f=s(e)+1;e[f]=o,u(e,f)}else{if(l&&l.strictMerge)return[e,o];(l&&(l.plainObjects||l.allowPrototypes)||!r.call(Object.prototype,o))&&(e[o]=!0)}}return e}if(!e||"object"!=typeof e){if(a(o)){for(var y=Object.keys(o),d=l&&l.plainObjects?{__proto__:null,0:e}:{0:e},h=0;h<y.length;h++){d[parseInt(y[h],10)+1]=o[y[h]]}return i(d,s(o)+1)}var g=[e].concat(o);return l&&"number"==typeof l.arrayLimit&&g.length>l.arrayLimit?i(c(g,l),g.length-1):g}var m=e;return n(e)&&!n(o)&&(m=c(e,l)),n(e)&&n(o)?(o.forEach(function(n,o){if(r.call(e,o)){var i=e[o];i&&"object"==typeof i&&n&&"object"==typeof n?e[o]=t(i,n,l):e[e.length]=n}else e[o]=n}),e):Object.keys(o).reduce(function(e,n){var c=o[n];if(r.call(e,n)?e[n]=t(e[n],c,l):e[n]=c,a(o)&&!a(e)&&i(e,s(o)),a(e)){var p=parseInt(n,10);String(p)===n&&p>=0&&p>s(e)&&u(e,p)}return e},m)}},ee}function Ke(){if(oe)return ne;oe=1;var t=ze(),e=Qe(),r=Ve(),n=Object.prototype.hasOwnProperty,o={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},i=Array.isArray,a=Array.prototype.push,s=function(t,e){a.apply(t,i(e)?e:[e])},u=Date.prototype.toISOString,l=r.default,c={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:e.encode,encodeValuesOnly:!1,filter:void 0,format:l,formatter:r.formatters[l],indices:!1,serializeDate:function(t){return u.call(t)},skipNulls:!1,strictNullHandling:!1},p={},f=function r(n,o,a,u,l,f,y,d,h,g,m,b,w,v,_,S,O,A){for(var E,P=n,j=A,R=0,T=!1;void 0!==(j=j.get(p))&&!T;){var x=j.get(n);if(R+=1,void 0!==x){if(x===R)throw new RangeError("Cyclic object value");T=!0}void 0===j.get(p)&&(R=0)}if("function"==typeof g?P=g(o,P):P instanceof Date?P=w(P):"comma"===a&&i(P)&&(P=e.maybeMap(P,function(t){return t instanceof Date?w(t):t})),null===P){if(f)return _(h&&!S?h(o,c.encoder,O,"key",v):o);P=""}if("string"==typeof(E=P)||"number"==typeof E||"boolean"==typeof E||"symbol"==typeof E||"bigint"==typeof E||e.isBuffer(P))return h?[_(S?o:h(o,c.encoder,O,"key",v))+"="+_(h(P,c.encoder,O,"value",v))]:[_(o)+"="+_(String(P))];var I,D=[];if(void 0===P)return D;if("comma"===a&&i(P))S&&h&&(P=e.maybeMap(P,function(t){return null==t?t:h(t)})),I=[{value:P.length>0?P.join(",")||null:void 0}];else if(i(g))I=g;else{var U=Object.keys(P);I=m?U.sort(m):U}var N=d?String(o).replace(/\./g,"%2E"):String(o),L=u&&i(P)&&1===P.length?N+"[]":N;if(l&&i(P)&&0===P.length)return L+"[]";for(var F=0;F<I.length;++F){var k=I[F],M="object"==typeof k&&k&&void 0!==k.value?k.value:P[k];if(!y||null!==M){var C=b&&d?String(k).replace(/\./g,"%2E"):String(k),B=i(P)?"function"==typeof a?a(L,C):L:L+(b?"."+C:"["+C+"]");A.set(n,R);var $=t();$.set(p,A),s(D,r(M,B,a,u,l,f,y,d,"comma"===a&&S&&i(P)?null:h,g,m,b,w,v,_,S,O,$))}}return D};return ne=function(e,a){var u,l=e,p=function(t){if(!t)return c;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.encodeDotInKeys&&"boolean"!=typeof t.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||c.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var a=r.default;if(void 0!==t.format){if(!n.call(r.formatters,t.format))throw new TypeError("Unknown format option provided.");a=t.format}var s,u=r.formatters[a],l=c.filter;if(("function"==typeof t.filter||i(t.filter))&&(l=t.filter),s=t.arrayFormat in o?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":c.arrayFormat,"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var p=void 0===t.allowDots?!0===t.encodeDotInKeys||c.allowDots:!!t.allowDots;return{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:c.addQueryPrefix,allowDots:p,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:c.allowEmptyArrays,arrayFormat:s,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:c.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:void 0===t.delimiter?c.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:c.encode,encodeDotInKeys:"boolean"==typeof t.encodeDotInKeys?t.encodeDotInKeys:c.encodeDotInKeys,encoder:"function"==typeof t.encoder?t.encoder:c.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:c.encodeValuesOnly,filter:l,format:a,formatter:u,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:c.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:c.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:c.strictNullHandling}}(a);"function"==typeof p.filter?l=(0,p.filter)("",l):i(p.filter)&&(u=p.filter);var y=[];if("object"!=typeof l||null===l)return"";var d=o[p.arrayFormat],h="comma"===d&&p.commaRoundTrip;u||(u=Object.keys(l)),p.sort&&u.sort(p.sort);for(var g=t(),m=0;m<u.length;++m){var b=u[m];if(null!=b){var w=l[b];p.skipNulls&&null===w||s(y,f(w,b,d,h,p.allowEmptyArrays,p.strictNullHandling,p.skipNulls,p.encodeDotInKeys,p.encode?p.encoder:null,p.filter,p.sort,p.allowDots,p.serializeDate,p.format,p.formatter,p.encodeValuesOnly,p.charset,g))}}var v=y.join(p.delimiter),_=!0===p.addQueryPrefix?"?":"";return p.charsetSentinel&&("iso-8859-1"===p.charset?_+="utf8=%26%2310003%3B"+p.delimiter:_+="utf8=%E2%9C%93"+p.delimiter),v.length>0?_+v:""},ne}function Ge(){if(ae)return ie;ae=1;var t=Qe(),e=Object.prototype.hasOwnProperty,r=Array.isArray,n={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:t.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},o=function(t){return t.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},i=function(t,e,r){if(t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1)return t.split(",");if(e.throwOnLimitExceeded&&r>=e.arrayLimit)throw new RangeError("Array limit exceeded. Only "+e.arrayLimit+" element"+(1===e.arrayLimit?"":"s")+" allowed in an array.");return t},a=function(r,n,o,a){if(r){var s=function(t,r){var n=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t;if(r.depth<=0){if(!r.plainObjects&&e.call(Object.prototype,n)&&!r.allowPrototypes)return;return[n]}var o=[],i=n.indexOf("["),a=i>=0?n.slice(0,i):n;if(a){if(!r.plainObjects&&e.call(Object.prototype,a)&&!r.allowPrototypes)return;o[o.length]=a}for(var s=n.length,u=i,l=0;u>=0&&l<r.depth;){for(var c=1,p=u+1,f=-1;p<s&&f<0;){var y=n.charCodeAt(p);91===y?c+=1:93===y&&0==(c-=1)&&(f=p),p+=1}if(f<0)return o[o.length]="["+n.slice(u)+"]",o;var d=n.slice(u,f+1),h=d.slice(1,-1);if(!r.plainObjects&&e.call(Object.prototype,h)&&!r.allowPrototypes)return;o[o.length]=d,l+=1,u=n.indexOf("[",f+1)}if(u>=0){if(!0===r.strictDepth)throw new RangeError("Input depth exceeded depth option of "+r.depth+" and strictDepth is true");o[o.length]="["+n.slice(u)+"]"}return o}(r,o);if(s)return function(e,r,n,o){var a=0;if(e.length>0&&"[]"===e[e.length-1]){var s=e.slice(0,-1).join("");a=Array.isArray(r)&&r[s]?r[s].length:0}for(var u=o?r:i(r,n,a),l=e.length-1;l>=0;--l){var c,p=e[l];if("[]"===p&&n.parseArrays)c=t.isOverflow(u)?u:n.allowEmptyArrays&&(""===u||n.strictNullHandling&&null===u)?[]:t.combine([],u,n.arrayLimit,n.plainObjects);else{c=n.plainObjects?{__proto__:null}:{};var f="["===p.charAt(0)&&"]"===p.charAt(p.length-1)?p.slice(1,-1):p,y=n.decodeDotInKeys?f.replace(/%2E/g,"."):f,d=parseInt(y,10),h=!isNaN(d)&&p!==y&&String(d)===y&&d>=0&&n.parseArrays;if(n.parseArrays||""!==y)if(h&&d<n.arrayLimit)(c=[])[d]=u;else{if(h&&n.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+n.arrayLimit+" element"+(1===n.arrayLimit?"":"s")+" allowed in an array.");h?(c[d]=u,t.markOverflow(c,d)):"__proto__"!==y&&(c[y]=u)}else c={0:u}}u=c}return u}(s,n,o,a)}};return ie=function(s,u){var l=function(e){if(!e)return n;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==e.throwOnLimitExceeded&&"boolean"!=typeof e.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var r=void 0===e.charset?n.charset:e.charset,o=void 0===e.duplicates?n.duplicates:e.duplicates;if("combine"!==o&&"first"!==o&&"last"!==o)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||n.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:n.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:n.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:n.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:n.arrayLimit,charset:r,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:n.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:n.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:n.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:n.decoder,delimiter:"string"==typeof e.delimiter||t.isRegExp(e.delimiter)?e.delimiter:n.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:n.depth,duplicates:o,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:n.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:n.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:n.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:n.strictDepth,strictMerge:"boolean"==typeof e.strictMerge?!!e.strictMerge:n.strictMerge,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:n.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof e.throwOnLimitExceeded&&e.throwOnLimitExceeded}}(u);if(""===s||null==s)return l.plainObjects?{__proto__:null}:{};for(var c="string"==typeof s?function(a,s){var u={__proto__:null},l=s.ignoreQueryPrefix?a.replace(/^\?/,""):a;l=l.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var c=s.parameterLimit===1/0?void 0:s.parameterLimit,p=l.split(s.delimiter,s.throwOnLimitExceeded&&void 0!==c?c+1:c);if(s.throwOnLimitExceeded&&void 0!==c&&p.length>c)throw new RangeError("Parameter limit exceeded. Only "+c+" parameter"+(1===c?"":"s")+" allowed.");var f,y=-1,d=s.charset;if(s.charsetSentinel)for(f=0;f<p.length;++f)0===p[f].indexOf("utf8=")&&("utf8=%E2%9C%93"===p[f]?d="utf-8":"utf8=%26%2310003%3B"===p[f]&&(d="iso-8859-1"),y=f,f=p.length);for(f=0;f<p.length;++f)if(f!==y){var h,g,m=p[f],b=m.indexOf("]="),w=-1===b?m.indexOf("="):b+1;if(-1===w?(h=s.decoder(m,n.decoder,d,"key"),g=s.strictNullHandling?null:""):null!==(h=s.decoder(m.slice(0,w),n.decoder,d,"key"))&&(g=t.maybeMap(i(m.slice(w+1),s,r(u[h])?u[h].length:0),function(t){return s.decoder(t,n.decoder,d,"value")})),g&&s.interpretNumericEntities&&"iso-8859-1"===d&&(g=o(String(g))),m.indexOf("[]=")>-1&&(g=r(g)?[g]:g),s.comma&&r(g)&&g.length>s.arrayLimit){if(s.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+s.arrayLimit+" element"+(1===s.arrayLimit?"":"s")+" allowed in an array.");g=t.combine([],g,s.arrayLimit,s.plainObjects)}if(null!==h){var v=e.call(u,h);v&&("combine"===s.duplicates||m.indexOf("[]=")>-1)?u[h]=t.combine(u[h],g,s.arrayLimit,s.plainObjects):v&&"last"!==s.duplicates||(u[h]=g)}}return u}(s,l):s,p=l.plainObjects?{__proto__:null}:{},f=Object.keys(c),y=0;y<f.length;++y){var d=f[y],h=a(d,c[d],l,"string"==typeof s);p=t.merge(p,h,l)}return!0===l.allowSparse?p:t.compact(p)}}function Je(){if(ue)return se;ue=1;var t=Ke(),e=Ge();return se={formats:Ve(),parse:e,stringify:t}}var Ze=P(Je());const Ye=()=>{};class Xe{static appendQueryParams(t,e){if(Ye("appending query params to %o: %o",t,e),!e)return Ye("no query params provided, returning original URL: %o",t),t;const r=Xe.stringifyQueryParams(e);return r?URL.canParse(t)&&new URL(t).search?`${t}&${r}`:`${t}?${r}`:(Ye("generated an empty query string, skipping..."),t)}static stringifyQueryParams(t){return Ze.stringify(t,{addQueryPrefix:!1,allowEmptyArrays:!0})}static toReadablePath(t){const e=t instanceof URL?t:new URL(t);return`${e.origin}${e.pathname}`}}class tr{static format(t){if(!(t instanceof Request))throw new TypeError("Invalid input, expected a Request instance but found "+typeof t);return`${t.method} - ${Xe.toReadablePath(t.url)}`}}class er{_options;_httpClient;constructor(t,e){this._options=t,this._httpClient=e}get _resource(){return this._options.resource}get _path(){return this._options.path}get _pluginName(){return this._options.plugin?.name}get _pluginPrefix(){return void 0!==this._options.plugin?.prefix?this._options.plugin.prefix:this._pluginName?this._pluginName:void 0}get _rootPath(){if(this._path)return this._path;const t=this._pluginPrefix;return t?`/${t}/${this._resource}`:`/${this._resource}`}}const rr={users:{plugin:{name:"users-permissions",prefix:""},wrapsData:!1}},nr={};function or(t){if(void 0===t)return!0;const e=Object.values({...rr,...nr}).find(e=>e.plugin.name===t);return e?.wrapsData??!0}const ir=()=>{};class ar extends er{constructor(t,e){super(t,e),ir('initialized a new "single" manager with %o',t)}shouldWrapDataBodyAttribute(){return or(this._pluginName)}async find(t){ir("finding document for %o",this._resource);let e=this._rootPath;t&&(e=Xe.appendQueryParams(e,t));const r=await this._httpClient.get(e);return ir("the %o document has been fetched",this._resource),r.json()}async update(t,e){ir("updating document for %o",this._resource);let r=this._rootPath;e&&(r=Xe.appendQueryParams(r,e));const n=await this._httpClient.put(r,JSON.stringify(this.shouldWrapDataBodyAttribute()?{data:t}:t),{headers:{"Content-Type":"application/json"}});return ir("the %o document has been updated",this._resource),n.json()}async delete(t){ir("deleting document for %o",this._resource);let e=this._rootPath;t&&(e=Xe.appendQueryParams(e,t)),await this._httpClient.delete(e),ir("the %o document has been deleted",this._resource)}}const sr=()=>{};class ur extends er{constructor(t,e){super(t,e),sr('initialized a new "collection" manager with %o',t)}shouldWrapDataBodyAttribute(){return or(this._pluginName)}async find(t){sr("finding documents for %o",this._resource);let e=this._rootPath;t&&(e=Xe.appendQueryParams(e,t));const r=await this._httpClient.get(e),n=await r.json();return sr("found %o %o documents",Number(n?.data?.length),this._resource),n}async findOne(t,e){sr("finding a document for %o with id: %o",this._resource,t);let r=`${this._rootPath}/${t}`;e&&(r=Xe.appendQueryParams(r,e));const n=await this._httpClient.get(r);return sr("found the %o document with document id %o",this._resource,t),n.json()}async create(t,e){sr("creating a document for %o",this._resource);let r=this._rootPath;e&&(r=Xe.appendQueryParams(r,e));const n=await this._httpClient.post(r,JSON.stringify(this.shouldWrapDataBodyAttribute()?{data:t}:t),{headers:{"Content-Type":"application/json"}});return sr("created the %o document",this._resource),n.json()}async update(t,e,r){sr("updating a document for %o with id: %o",this._resource,t);let n=`${this._rootPath}/${t}`;r&&(n=Xe.appendQueryParams(n,r));const o=await this._httpClient.put(n,JSON.stringify(this.shouldWrapDataBodyAttribute()?{data:e}:e),{headers:{"Content-Type":"application/json"}});return sr("updated the %o document with id %o",this._resource,t),o.json()}async delete(t,e){sr("deleting a document for %o with id: %o",this._resource,t);let r=`${this._rootPath}/${t}`;e&&(r=Xe.appendQueryParams(r,e)),await this._httpClient.delete(r),sr("deleted the %o document with id %o",this._resource,t)}}class lr extends ur{}class cr extends l{name="FileNotFoundError";fileId;constructor(t,e){super(e.response,e.request),this.fileId=t,this.message=`File with ID ${t} not found. The requested file may have been deleted or never existed.`}}class pr extends f{name="FileForbiddenError";fileId;constructor(t,e){super(t.response,t.request),this.fileId=e,this.message=void 0!==e?`Access to file with ID ${e} is forbidden. You may not have sufficient permissions.`:"Access to files is forbidden. You may not have sufficient permissions."}}class fr{static createMapper(t){return e=>e instanceof l?void 0!==t?new cr(t,e):e:e instanceof f?new pr(e,t):e}}const yr="/upload",dr=()=>{};class hr{_httpClient;constructor(t){this._httpClient=t,dr("initialized files manager")}createFileHttpClient(t){const e=this._httpClient.create(),r=fr.createMapper(t);return e.interceptors.response.use(void 0,t=>{if(t instanceof Error)throw r(t);throw t}),e}async find(t){dr("finding files");try{let e=`${yr}/files`;t&&(e=Xe.appendQueryParams(e,t));const r=this.createFileHttpClient(),n=await r.get(e),o=await n.json();return dr("found %o files",Number(o?.length)),o}catch(t){throw dr("error finding files: %o",t),t}}async findOne(t){dr("finding file with ID %o",t);const e=`${yr}/files/${t}`,r=this.createFileHttpClient(t);try{const n=await r.get(e),o=await n.json();return dr("found file with ID %o",t),o}catch(e){throw dr("error finding file with ID %o: %o",t,e),e}}async update(t,e){dr("updating file with ID %o with data %o",t,e);try{const r=`${yr}?id=${t}`,n=this.createFileHttpClient(t),o=new FormData;o.append("fileInfo",JSON.stringify(e));const i=await n.post(r,o),a=await i.json();return dr("successfully updated file with ID %o",t),a}catch(e){throw dr("error updating file with ID %o: %o",t,e),e}}async delete(t){dr("deleting file with ID %o",t);try{const e=`${yr}/files/${t}`,r=this.createFileHttpClient(t),n=await r.delete(e),o=await n.json();return dr("successfully deleted file with ID %o",t),o}catch(e){throw dr("error deleting file with ID %o: %o",t,e),e}}async upload(t,e){dr("uploading new file");try{const r=yr,n=this.createFileHttpClient();if("undefined"!=typeof Buffer&&Buffer.isBuffer(t)){if(!e||!("filename"in e)||!("mimetype"in e))throw new Error("Filename and mimetype are required when uploading Buffer data");return this.uploadBuffer(t,e,n,r)}return t instanceof Blob||console.warn("Could not determine type of file; attempting upload as Blob"),this.uploadBlob(t,e,n,r)}catch(t){throw dr("error uploading file: %o",t),t}}async uploadBuffer(t,e,r,n){const o=new FormData,i=new Blob([new Uint8Array(t)],{type:e.mimetype});o.append("files",i,e.filename),e.fileInfo&&o.append("fileInfo",JSON.stringify(e.fileInfo));const a=await r.post(n,o),s=await a.json();return dr("successfully uploaded buffer file"),s}async uploadBlob(t,e,r,n){const o=new FormData;o.append("files",t),e?.fileInfo&&o.append("fileInfo",JSON.stringify(e.fileInfo));const i=await r.post(n,o),a=await i.json();return dr("successfully uploaded blob file"),a}}const gr={trailingSlashes:!1,leadingSlashes:!1};class mr{static format(t,e=gr){return t=mr.formatTrailingSlashes(t,e.trailingSlashes),t=mr.formatLeadingSlashes(t,e.leadingSlashes)}static formatTrailingSlashes(t,e=gr.trailingSlashes){return"single"===e?mr.ensureSingleTrailingSlash(t):e?t:mr.removeTrailingSlashes(t)}static removeTrailingSlashes(t){return t.replace(/\/+$/,"")}static ensureSingleTrailingSlash(t){return`${this.removeTrailingSlashes(t)}/`}static formatLeadingSlashes(t,e=gr.leadingSlashes){return"single"===e?mr.ensureSingleLeadingSlash(t):e?t:mr.removeLeadingSlashes(t)}static removeLeadingSlashes(t){return t.replace(/^\/+/,"")}static ensureSingleLeadingSlash(t){return`/${this.removeLeadingSlashes(t)}`}}const br=()=>{};class wr{validate(t){if("string"!=typeof t)throw br("url must be a string, received: %o (%s)",t,typeof t),new a(t);if(!this.canParse(t))throw br("url could not be parsed: %o (%s)",t,typeof t),new a(t);br("validated url successfully: %o",t)}canParse(t){return URL.canParse(t)}}const vr=()=>{};class _r{_urlValidator;constructor(t=new wr){this._urlValidator=t}validateConfig(t){if(vr("validating client config"),null==t||Array.isArray(t)||"object"!=typeof t)throw vr("provided client configuration is not a valid object: %o (%s)",t,typeof t),new n(new TypeError("The provided configuration is not a valid object."));this.validateBaseURL(t.baseURL),this.validateHeaders(t.headers),vr("validated client config successfully")}validateBaseURL(t){try{vr("validating base url"),this._urlValidator.validate(t)}catch(e){if(e instanceof i)throw vr("failed to validate client config, invalid base url %o",t),new n(e);throw e}}validateHeaders(t){if(vr("validating headers"),void 0!==t){if(null===t||"object"!=typeof t||Array.isArray(t))throw vr("invalid headers type: %o (%s)",t,typeof t),new n(new TypeError("Headers must be a valid object."));for(const[e,r]of Object.entries(t))if("string"!=typeof r)throw vr("invalid header value for key %s: %o (%s)",e,r,typeof r),new n(new TypeError("Header values must be strings."));vr("headers validated successfully")}}}var Sr;!function(t){t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.TIMEOUT=408]="TIMEOUT",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR"}(Sr||(Sr={}));class Or{_handlers;constructor(t=[]){this._handlers=t}use(t,e){return this._handlers.push({fulfilled:t,rejected:e}),this}clone(){return new Or([...this._handlers])}async execute(t){let e=t;for(const t of this._handlers)try{t.fulfilled&&(e=await t.fulfilled(e))}catch(r){if(!t.rejected)throw r;e=await t.rejected(r)}return e}async reject(t){let e=t;for(const t of this._handlers)t.rejected&&(e=await t.rejected(e));return e}}const Ar=()=>{};class Er{interceptors;_baseURL;_timeout;_headers;_urlValidator;constructor(t,e=new wr){Ar("initializing new client with base url: %o",t.baseURL),this._baseURL=mr.format(t.baseURL,{trailingSlashes:!1}),this._timeout=t.timeout??1e4,this._headers=t.headers??{},this.interceptors={request:new Or,response:new Or},this._urlValidator=e,this._urlValidator.validate(this._baseURL)}get baseURL(){return this._baseURL}get timeout(){return this._timeout}get headers(){return this._headers}setBaseURL(t){return this._urlValidator.validate(t),this._baseURL=mr.format(t,{trailingSlashes:!1}),Ar("setting new base url: %o",this._baseURL),this}setTimeout(t){if(Ar("setting new timeout: %o",t),!Number.isSafeInteger(t))throw new TypeError("Timeout must be a safe integer");return this._timeout=t,this}async request(t,e){const r=mr.format(t,{leadingSlashes:"single"}),n=new URL(`${this.baseURL}${r}`),o=new Request(n,e);for(const[t,e]of Object.entries(this._headers))o.headers.append(t,e),Ar("%o header set to %o for %o",t,e,tr.format(o));const{request:i}=await this.interceptors.request.execute({request:o}),a=new AbortController,s=setTimeout(()=>a.abort(),this._timeout),u=new Request(i,{signal:a.signal});try{const t=await this.fetch(u);clearTimeout(s);const{response:e}=await this.interceptors.response.execute({request:u,response:t});return e}catch(t){throw clearTimeout(s),await this.interceptors.response.reject(t)}}fetch(t,e){return globalThis.fetch(t,e)}async get(t,e){return this.request(t,{method:"GET",...e})}async post(t,e,r){return this.request(t,{method:"POST",body:e,...r})}async put(t,e,r){return this.request(t,{method:"PUT",body:e,...r})}async delete(t,e){return this.request(t,{method:"DELETE",...e})}create(t={},e=!0){const r=new(Object.getPrototypeOf(this).constructor)({baseURL:t.baseURL??this._baseURL,timeout:t.timeout??this._timeout,headers:t.headers??this._headers},this._urlValidator);if(!(r instanceof Er))throw new Error("The created instance is not an instance of HttpClient");return e&&(r.interceptors.request=this.interceptors.request.clone(),r.interceptors.response=this.interceptors.response.clone()),r}static mapResponseToHTTPError(t,e){switch(t.status){case Sr.BAD_REQUEST:return new c(t,e);case Sr.UNAUTHORIZED:return new u(t,e);case Sr.FORBIDDEN:return new f(t,e);case Sr.NOT_FOUND:return new l(t,e);case Sr.TIMEOUT:return new y(t,e);case Sr.INTERNAL_SERVER_ERROR:return new p(t,e)}return new s(t,e)}}class Pr{static ensurePreAuthentication(t,e){return async({request:r})=>{const{strategy:n,isAuthenticated:o}=t;return n&&!o&&await t.authenticate(e),{request:r}}}static authenticateRequests(t){return({request:e})=>(t.authenticateRequest(e),{request:e})}static notifyOnUnauthorizedResponse(t){const e=()=>t.handleUnauthorizedError();return[({request:t,response:r})=>(!r.ok&&r.status===Sr.UNAUTHORIZED&&e(),{request:t,response:r}),t=>(t instanceof u&&e(),t)]}}class jr{static setDefaultHeaders(){const t=new Map([["Content-Type","application/json"]]);return({request:e})=>{for(const[r,n]of t.entries()){if(!e.headers.has(r)){if("Content-Type"===r&&e.body instanceof FormData)continue;e.headers.set(r,n)}}return{request:e}}}static transformErrors(){return({request:t,response:e})=>{if(e.ok)return{request:t,response:e};throw Er.mapResponseToHTTPError(e,t)}}}const Rr=()=>{};class Tr{_config;_validator;_authManager;_httpClient;files;constructor(t,e=new _r,r=new S,n){this._config=t,this._validator=e,this._authManager=r,Rr("started the initialization process"),this.preflightValidation(),Rr("user config passed the preflight validation"),this._httpClient=n?n({baseURL:t.baseURL,headers:t.headers}):new Er({baseURL:t.baseURL,headers:t.headers}),this.files=new hr(this._httpClient),this.init(),Rr("finished the client initialization process")}preflightValidation(){try{Rr("validating the configuration"),this._validator.validateConfig(this._config)}catch(t){throw new o(t)}}init(){Rr("init modules"),this.initHttp(),this.initAuth()}initHttp(){Rr("init http module"),this._httpClient.interceptors.request.use(jr.setDefaultHeaders()),this._httpClient.interceptors.response.use(jr.transformErrors())}initAuth(){if(Rr("init auth module"),this.auth){const{strategy:t,options:e}=this.auth;Rr("setting up the auth strategy using %o",t);try{this._authManager.setStrategy(t,e)}catch(t){throw new o(t,`Failed to initialize the client auth manager: ${t instanceof r?t.cause:t}`)}}this._httpClient.interceptors.request.use(Pr.ensurePreAuthentication(this._authManager,this._httpClient)).use(Pr.authenticateRequests(this._authManager)),this._httpClient.interceptors.response.use(...Pr.notifyOnUnauthorizedResponse(this._authManager))}get auth(){return this._config.auth}get baseURL(){return this._config.baseURL}fetch(t,e){return this._httpClient.request(t,e)}collection(t,e={}){const{path:r,plugin:n}=e,o=function(t){return rr[t]}(t),i=n??o?.plugin??void 0;if("users"===t&&"users-permissions"===i?.name){return new lr({resource:t,path:r,plugin:i},this._httpClient)}return new ur({resource:t,path:r,plugin:i},this._httpClient)}single(t,e={}){const{path:r,plugin:n}=e,o=function(t){return nr[t]}(t);return new ar({resource:t,path:r,plugin:n??o?.plugin??void 0},this._httpClient)}}return t.HTTPAuthorizationError=u,t.HTTPBadRequestError=c,t.HTTPError=s,t.HTTPForbiddenError=f,t.HTTPInternalServerError=p,t.HTTPNotFoundError=l,t.HTTPTimeoutError=y,t.StrapiError=r,t.StrapiInitializationError=o,t.StrapiValidationError=n,t.URLParsingError=a,t.URLValidationError=i,t.strapi=t=>{const{baseURL:e,auth:r,headers:n}=t,o={baseURL:e,headers:n};return void 0!==r&&(o.auth={strategy:h.identifier,options:{token:r}}),new Tr(o)},t}({});
//# sourceMappingURL=bundle.browser.iife.min.js.map
