ketting 8.0.0-alpha.2 → 8.0.0-alpha.3
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/browser/ketting.min.js +1 -1
- package/browser/ketting.min.js.map +1 -1
- package/dist/middlewares/cache.js +2 -2
- package/dist/middlewares/cache.js.map +1 -1
- package/package.json +1 -1
- package/src/middlewares/cache.ts +2 -2
- package/dist/http/fetch-polyfill.d.ts +0 -1
- package/dist/http/fetch-polyfill.js +0 -9
- package/dist/http/fetch-polyfill.js.map +0 -1
- package/dist/http/fetch-polyfill.web.d.ts +0 -0
- package/dist/http/fetch-polyfill.web.js +0 -4
- package/dist/http/fetch-polyfill.web.js.map +0 -1
- package/dist/src/action.d.ts +0 -83
- package/dist/src/cache/forever.d.ts +0 -40
- package/dist/src/cache/index.d.ts +0 -33
- package/dist/src/cache/never.d.ts +0 -35
- package/dist/src/cache/short.d.ts +0 -31
- package/dist/src/client.d.ts +0 -120
- package/dist/src/field.d.ts +0 -163
- package/dist/src/follow-promise.d.ts +0 -102
- package/dist/src/http/basic-auth.d.ts +0 -3
- package/dist/src/http/bearer-auth.d.ts +0 -3
- package/dist/src/http/error.d.ts +0 -41
- package/dist/src/http/fetch-polyfill.d.ts +0 -1
- package/dist/src/http/fetch-polyfill.web.d.ts +0 -0
- package/dist/src/http/fetcher.d.ts +0 -37
- package/dist/src/http/oauth2.d.ts +0 -4
- package/dist/src/http/util.d.ts +0 -16
- package/dist/src/index.d.ts +0 -15
- package/dist/src/link.d.ts +0 -109
- package/dist/src/middlewares/accept-header.d.ts +0 -9
- package/dist/src/middlewares/cache.d.ts +0 -12
- package/dist/src/middlewares/warning.d.ts +0 -8
- package/dist/src/resource.d.ts +0 -231
- package/dist/src/state/base-state.d.ts +0 -117
- package/dist/src/state/binary.d.ts +0 -5
- package/dist/src/state/collection-json.d.ts +0 -12
- package/dist/src/state/hal.d.ts +0 -14
- package/dist/src/state/head.d.ts +0 -9
- package/dist/src/state/html.d.ts +0 -5
- package/dist/src/state/index.d.ts +0 -10
- package/dist/src/state/interface.d.ts +0 -108
- package/dist/src/state/jsonapi.d.ts +0 -42
- package/dist/src/state/siren.d.ts +0 -20
- package/dist/src/state/text.d.ts +0 -5
- package/dist/src/types.d.ts +0 -39
- package/dist/src/util/base64.d.ts +0 -4
- package/dist/src/util/base64.web.d.ts +0 -4
- package/dist/src/util/fetch-body-helper.d.ts +0 -1
- package/dist/src/util/fetch-body-helper.web.d.ts +0 -1
- package/dist/src/util/html.d.ts +0 -14
- package/dist/src/util/html.web.d.ts +0 -14
- package/dist/src/util/uri-template.d.ts +0 -3
- package/dist/src/util/uri.d.ts +0 -18
- package/dist/src/util/uri.web.d.ts +0 -18
- package/dist/test/integration/basic-auth.d.ts +0 -1
- package/dist/test/integration/bearer-auth.d.ts +0 -1
- package/dist/test/integration/delete.d.ts +0 -1
- package/dist/test/integration/fetch-api.d.ts +0 -1
- package/dist/test/integration/follow-hal-template.d.ts +0 -1
- package/dist/test/integration/follow-hal.d.ts +0 -1
- package/dist/test/integration/follow-jsonapi.d.ts +0 -1
- package/dist/test/integration/get.d.ts +0 -1
- package/dist/test/integration/head.d.ts +0 -1
- package/dist/test/integration/oauth2.d.ts +0 -1
- package/dist/test/integration/patch.d.ts +0 -1
- package/dist/test/integration/post-follow.d.ts +0 -1
- package/dist/test/integration/put.d.ts +0 -1
- package/dist/test/integration/resource.d.ts +0 -1
- package/dist/test/test-entrypoint.d.ts +0 -4
- package/dist/test/unit/cache/forever.d.ts +0 -1
- package/dist/test/unit/cache/never.d.ts +0 -1
- package/dist/test/unit/cache/shortcache.d.ts +0 -1
- package/dist/test/unit/client.d.ts +0 -1
- package/dist/test/unit/error.d.ts +0 -1
- package/dist/test/unit/follower.d.ts +0 -1
- package/dist/test/unit/link.d.ts +0 -1
- package/dist/test/unit/middleware/warning.d.ts +0 -1
- package/dist/test/unit/resource-events.d.ts +0 -1
- package/dist/test/unit/resource.d.ts +0 -1
- package/dist/test/unit/state/collection-json.d.ts +0 -1
- package/dist/test/unit/state/hal-forms.d.ts +0 -1
- package/dist/test/unit/state/hal.d.ts +0 -1
- package/dist/test/unit/state/html.d.ts +0 -1
- package/dist/test/unit/state/jsonapi.d.ts +0 -1
- package/dist/test/unit/state/siren.d.ts +0 -1
- package/dist/test/unit/util/uri-template.d.ts +0 -1
- package/dist/test/unit/util/url.d.ts +0 -1
- package/dist/util/base64.d.ts +0 -4
- package/dist/util/base64.js +0 -11
- package/dist/util/base64.js.map +0 -1
- package/dist/util/base64.web.d.ts +0 -4
- package/dist/util/base64.web.js +0 -11
- package/dist/util/base64.web.js.map +0 -1
- package/dist/util/uri.web.d.ts +0 -18
- package/dist/util/uri.web.js +0 -51
- package/dist/util/uri.web.js.map +0 -1
package/browser/ketting.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Ketting=t():e.Ketting=t()}(self,(function(){return function(){var e={880:function(e){var t;self,t=()=>(()=>{var e={934:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateQueryString=t.tokenResponseToOAuth2Token=t.OAuth2Client=void 0;const n=r(443),i=r(618);function o(e,t){return new URL(e,t).toString()}function s(e){return e.then((e=>{var t;return{accessToken:e.access_token,expiresAt:e.expires_in?Date.now()+1e3*e.expires_in:null,refreshToken:null!==(t=e.refresh_token)&&void 0!==t?t:null}}))}function a(e){return new URLSearchParams(Object.fromEntries(Object.entries(e).filter((([e,t])=>void 0!==t)))).toString()}t.OAuth2Client=class{constructor(e){this.discoveryDone=!1,this.serverMetadata=null,this.settings=e}async refreshToken(e){if(!e.refreshToken)throw new Error("This token didn't have a refreshToken. It's not possible to refresh this");const t={grant_type:"refresh_token",refresh_token:e.refreshToken};return this.settings.clientSecret||(t.client_id=this.settings.clientId),s(this.request("tokenEndpoint",t))}async clientCredentials(e){var t;const r={grant_type:"client_credentials",scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" ")};if(!this.settings.clientSecret)throw new Error("A clientSecret must be provied to use client_credentials");return s(this.request("tokenEndpoint",r))}async password(e){var t;const r={grant_type:"password",...e,scope:null===(t=e.scope)||void 0===t?void 0:t.join(" ")};if(!this.settings.clientSecret)throw new Error("A clientSecret must be provied to use client_credentials");return s(this.request("tokenEndpoint",r))}get authorizationCode(){return new i.OAuth2AuthorizationCodeClient(this)}async introspect(e){const t={token:e.accessToken,token_type_hint:"access_token"};return this.request("introspectionEndpoint",t)}async getEndpoint(e){if(void 0!==this.settings[e])return o(this.settings[e],this.settings.server);if("discoveryEndpoint"!==e&&(await this.discover(),void 0!==this.settings[e]))return o(this.settings[e],this.settings.server);if(!this.settings.server)throw new Error(`Could not determine the location of ${e}. Either specify ${e} in the settings, or the "server" endpoint to let the client discover it.`);switch(e){case"authorizationEndpoint":return o("/authorize",this.settings.server);case"tokenEndpoint":return o("/token",this.settings.server);case"discoveryEndpoint":return o("/.well-known/oauth-authorization-server",this.settings.server);case"introspectionEndpoint":return o("/introspect",this.settings.server)}}async discover(){var e;if(this.discoveryDone)return;let t;this.discoveryDone=!0;try{t=await this.getEndpoint("discoveryEndpoint")}catch(e){return void console.warn('[oauth2] OAuth2 discovery endpoint could not be determined. Either specify the "server" or "discoveryEndpoint')}const r=await fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)return;if(!(null===(e=r.headers.get("Content-Type"))||void 0===e?void 0:e.startsWith("application/json")))return void console.warn("[oauth2] OAuth2 discovery endpoint was not a JSON response. Response is ignored");this.serverMetadata=await r.json();const n=[["authorization_endpoint","authorizationEndpoint"],["token_endpoint","tokenEndpoint"],["introspection_endpoint","introspectionEndpoint"]];if(null!==this.serverMetadata)for(const[e,r]of n)this.serverMetadata[e]&&(this.settings[r]=o(this.serverMetadata[e],t))}async request(e,t){const r=await this.getEndpoint(e),i={"Content-Type":"application/x-www-form-urlencoded"};if(this.settings.clientSecret){const e=btoa(this.settings.clientId+":"+this.settings.clientSecret);i.Authorization="Basic "+e}else"authorization_code"===t.grant_type&&(t.client_id=this.settings.clientId);const o=await fetch(r,{method:"POST",body:a(t),headers:i});if(o.ok)return await o.json();let s,c,u;throw o.headers.has("Content-Type")&&o.headers.get("Content-Type").startsWith("application/json")&&(s=await o.json()),(null==s?void 0:s.error)?(c="OAuth2 error "+s.error+".",s.error_description&&(c+=" "+s.error_description),u=s.error):(c="HTTP Error "+o.status+" "+o.statusText,401===o.status&&this.settings.clientSecret&&(c+=". It's likely that the clientId and/or clientSecret was incorrect"),u=null),new n.OAuth2Error(c,u,o.status)}},t.tokenResponseToOAuth2Token=s,t.generateQueryString=a},618:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getCodeChallenge=t.generateCodeVerifier=t.OAuth2AuthorizationCodeClient=void 0;const n=r(934),i=r(443);async function o(e){const t=s();if(null==t?void 0:t.subtle)return["S256",c(await t.subtle.digest("SHA-256",a(e)))];{const t=r(212).createHash("sha256");return t.update(a(e)),["S256",t.digest("base64url")]}}function s(){if("undefined"!=typeof window&&window.crypto)return window.crypto;if("undefined"!=typeof self&&self.crypto)return self.crypto;const e=r(212);return e.webcrypto?e.webcrypto:null}function a(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=255&e.charCodeAt(r);return t}function c(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}t.OAuth2AuthorizationCodeClient=class{constructor(e){this.client=e}async getAuthorizeUri(e){const[t,r]=await Promise.all([e.codeVerifier?o(e.codeVerifier):void 0,this.client.getEndpoint("authorizationEndpoint")]),i={client_id:this.client.settings.clientId,response_type:"code",redirect_uri:e.redirectUri,code_challenge_method:null==t?void 0:t[0],code_challenge:null==t?void 0:t[1]};return e.state&&(i.state=e.state),e.scope&&(i.scope=e.scope.join(" ")),r+"?"+(0,n.generateQueryString)(i)}async getTokenFromCodeRedirect(e,t){const{code:r}=await this.validateResponse(e,{state:t.state});return this.getToken({code:r,redirectUri:t.redirectUri,codeVerifier:t.codeVerifier})}async validateResponse(e,t){var r;const n=new URL(e).searchParams;if(n.has("error"))throw new i.OAuth2Error(null!==(r=n.get("error_description"))&&void 0!==r?r:"OAuth2 error",n.get("error"),0);if(!n.has("code"))throw new Error(`The url did not contain a code parameter ${e}`);if(!n.has("state"))throw new Error(`The url did not contain state parameter ${e}`);if(t.state&&t.state!==n.get("state"))throw new Error(`The "state" parameter in the url did not match the expected value of ${t.state}`);return{code:n.get("code"),scope:n.has("scope")?n.get("scope").split(" "):void 0}}async getToken(e){const t={grant_type:"authorization_code",code:e.code,redirect_uri:e.redirectUri,code_verifier:e.codeVerifier};return(0,n.tokenResponseToOAuth2Token)(this.client.request("tokenEndpoint",t))}},t.generateCodeVerifier=async function(){const e=s();if(e){const t=new Uint8Array(32);return e.getRandomValues(t),c(t)}{const e=r(212);return new Promise(((t,r)=>{e.randomBytes(32,((e,n)=>{e&&r(e),t(n.toString("base64url"))}))}))}},t.getCodeChallenge=o},443:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Error=void 0;class r extends Error{constructor(e,t,r){super(e),this.oauth2Code=t,this.httpCode=r}}t.OAuth2Error=r},13:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Fetch=void 0,t.OAuth2Fetch=class{constructor(e){this.token=null,this.activeRefresh=null,this.refreshTimer=null,this.options=e,e.getStoredToken&&(async()=>{this.token=await e.getStoredToken()})(),this.scheduleRefresh()}async fetch(e,t){const r=new Request(e,t);return this.mw()(r,(e=>fetch(e)))}mw(){return async(e,t)=>{const r=await this.getAccessToken();let n=e.clone();n.headers.set("Authorization","Bearer "+r);let i=await t(n);if(!i.ok&&401===i.status){const r=await this.refreshToken();n=e.clone(),n.headers.set("Authorization","Bearer "+r.accessToken),i=await t(n)}return i}}async getToken(){return this.token&&(null===this.token.expiresAt||this.token.expiresAt>Date.now())?this.token:this.refreshToken()}async getAccessToken(){return(await this.getToken()).accessToken}async refreshToken(){var e,t;if(this.activeRefresh)return this.activeRefresh;const r=this.token;this.activeRefresh=(async()=>{var e,t;let n=null;try{(null==r?void 0:r.refreshToken)&&(n=await this.options.client.refreshToken(r))}catch(e){console.warn("[oauth2] refresh token not accepted, we'll try reauthenticating")}if(n||(n=await this.options.getNewToken()),!n){const r=new Error("Unableto obtain OAuth2 tokens, a full reauth may be needed");throw null===(t=(e=this.options).onError)||void 0===t||t.call(e,r),r}return n})();try{const r=await this.activeRefresh;return this.token=r,null===(t=(e=this.options).storeToken)||void 0===t||t.call(e,r),this.scheduleRefresh(),r}catch(e){throw this.options.onError&&this.options.onError(e),e}finally{this.activeRefresh=null}}scheduleRefresh(){if(this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),!this.token||!this.token.expiresAt||!this.token.refreshToken)return;const e=this.token.expiresAt-Date.now();e<12e4||(this.refreshTimer=setTimeout((async()=>{try{await this.refreshToken()}catch(e){console.error("[fetch-mw-oauth2] error while doing a background OAuth2 auto-refresh",e)}}),e-6e4))}}},212:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}var n={};return(()=>{"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.OAuth2Error=e.OAuth2Fetch=e.generateCodeVerifier=e.OAuth2AuthorizationCodeClient=e.OAuth2Client=void 0;var t=r(934);Object.defineProperty(e,"OAuth2Client",{enumerable:!0,get:function(){return t.OAuth2Client}});var i=r(618);Object.defineProperty(e,"OAuth2AuthorizationCodeClient",{enumerable:!0,get:function(){return i.OAuth2AuthorizationCodeClient}}),Object.defineProperty(e,"generateCodeVerifier",{enumerable:!0,get:function(){return i.generateCodeVerifier}});var o=r(13);Object.defineProperty(e,"OAuth2Fetch",{enumerable:!0,get:function(){return o.OAuth2Fetch}});var s=r(443);Object.defineProperty(e,"OAuth2Error",{enumerable:!0,get:function(){return s.OAuth2Error}})})(),n})(),e.exports=t()},187:function(e){"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}y(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function f(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function d(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function y(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){n.once&&e.removeEventListener(t,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)n(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},475:function(e){"use strict";var t=/^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i,r=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,n=/\s|\uFEFF|\xA0/,i=/\r?\n[\x20\x09]+/g,o=/[;,"]/,s=/[;,"]|\s/,a=/^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/;function c(e){return e.replace(r,"")}function u(e){return n.test(e)}function l(e,t){for(;u(e[t]);)t++;return t}function h(e){return s.test(e)||!a.test(e)}class f{constructor(e){this.refs=[],e&&this.parse(e)}rel(e){for(var t=[],r=e.toLowerCase(),n=0;n<this.refs.length;n++)this.refs[n].rel.toLowerCase()===r&&t.push(this.refs[n]);return t}get(e,t){e=e.toLowerCase();for(var r=[],n=0;n<this.refs.length;n++)this.refs[n][e]===t&&r.push(this.refs[n]);return r}set(e){return this.refs.push(e),this}setUnique(e){return this.refs.some((t=>{return r=t,n=e,Object.keys(r).length===Object.keys(n).length&&Object.keys(r).every((e=>e in n&&r[e]===n[e]));var r,n}))||this.refs.push(e),this}has(e,t){e=e.toLowerCase();for(var r=0;r<this.refs.length;r++)if(this.refs[r][e]===t)return!0;return!1}parse(e,t){for(var r=1,n=(e=c(e=(t=t||0)?e.slice(t):e).replace(i,"")).length,s=(t=0,null);t<n;)if(1===r){if(u(e[t])){t++;continue}if("<"!==e[t])throw new Error('Unexpected character "'+e[t]+'" at offset '+t);if(null!=s&&(null!=s.rel?this.refs.push(...f.expandRelations(s)):this.refs.push(s)),-1===(d=e.indexOf(">",t)))throw new Error("Expected end of URI delimiter at offset "+t);s={uri:e.slice(t+1,d)},t=d,r=2,t++}else if(2===r){if(u(e[t])){t++;continue}if(";"===e[t])r=4,t++;else{if(","!==e[t])throw new Error('Unexpected character "'+e[t]+'" at offset '+t);r=1,t++}}else{if(4!==r)throw new Error('Unknown parser state "'+r+'"');if(";"===e[t]||u(e[t])){t++;continue}if(-1===(d=e.indexOf("=",t)))throw new Error("Expected attribute delimiter at offset "+t);var a=c(e.slice(t,d)).toLowerCase(),h="";if('"'===e[t=l(e,t=d+1)])for(t++;t<n;){if('"'===e[t]){t++;break}"\\"===e[t]&&t++,h+=e[t],t++}else{for(var d=t+1;!o.test(e[d])&&d<n;)d++;h=e.slice(t,d),t=d}switch(s[a]&&f.isSingleOccurenceAttr(a)||("*"===a[a.length-1]?s[a]=f.parseExtendedValue(h):(h="type"===a?h.toLowerCase():h,null!=s[a]?Array.isArray(s[a])?s[a].push(h):s[a]=[s[a],h]:s[a]=h)),e[t]){case",":r=1;break;case";":r=4}t++}return null!=s&&(null!=s.rel?this.refs.push(...f.expandRelations(s)):this.refs.push(s)),s=null,this}toString(){for(var e=[],t="",r=null,n=0;n<this.refs.length;n++)r=this.refs[n],t=Object.keys(this.refs[n]).reduce((function(e,t){return"uri"===t?e:e+"; "+f.formatAttribute(t,r[t])}),"<"+r.uri+">"),e.push(t);return e.join(", ")}}f.isCompatibleEncoding=function(e){return t.test(e)},f.parse=function(e,t){return(new f).parse(e,t)},f.isSingleOccurenceAttr=function(e){return"rel"===e||"type"===e||"media"===e||"title"===e||"title*"===e},f.isTokenAttr=function(e){return"rel"===e||"type"===e||"anchor"===e},f.escapeQuotes=function(e){return e.replace(/"/g,'\\"')},f.expandRelations=function(e){return e.rel.split(" ").map((function(t){var r=Object.assign({},e);return r.rel=t,r}))},f.parseExtendedValue=function(e){var t=/([^']+)?(?:'([^']*)')?(.+)/.exec(e);return{language:t[2].toLowerCase(),encoding:f.isCompatibleEncoding(t[1])?null:t[1].toLowerCase(),value:f.isCompatibleEncoding(t[1])?decodeURIComponent(t[3]):t[3]}},f.formatExtendedAttribute=function(e,t){var r=(t.encoding||"utf-8").toUpperCase();return e+"="+r+"'"+(t.language||"en")+"'"+(Buffer.isBuffer(t.value)&&f.isCompatibleEncoding(r)?t.value.toString(r):Buffer.isBuffer(t.value)?t.value.toString("hex").replace(/[0-9a-f]{2}/gi,"%$1"):encodeURIComponent(t.value))},f.formatAttribute=function(e,t){return Array.isArray(t)?t.map((t=>f.formatAttribute(e,t))).join("; "):"*"===e[e.length-1]||"string"!=typeof t?f.formatExtendedAttribute(e,t):(f.isTokenAttr(e)?t=h(t)?'"'+f.escapeQuotes(t)+'"':f.escapeQuotes(t):h(t)&&(t='"'+(t=(t=encodeURIComponent(t)).replace(/%20/g," ").replace(/%2C/g,",").replace(/%3B/g,";"))+'"'),e+"="+t)},e.exports=f},129:function(e){e.exports=function(e){return e=e||/\W/g,function(t){return(t=String(t)).replace(e,(function(e){var t=e[0].charCodeAt(0),r=[];return t<128?r.push(t):128<=t&&t<2048?(r.push(t>>6|192),r.push(63&t|128)):(r.push(t>>12|224),r.push(t>>6&63|128),r.push(63&t|128)),r.map((function(e){return"%"+e.toString(16).toUpperCase()})).join("")}))}}},779:function(e,t,r){"use strict";var n=t,i=r(94).Buffer;function o(e,t){try{return decodeURIComponent(e)}catch(r){return n.unescapeBuffer(e,t).toString()}}n.unescapeBuffer=function(e,t){for(var r,n,o,s=new i(e.length),a=0,c=0,u=0;c<=e.length;c++){var l=c<e.length?e.charCodeAt(c):NaN;switch(a){case 0:switch(l){case 37:r=0,n=0,a=1;break;case 43:t&&(l=32);default:s[u++]=l}break;case 1:if(o=l,l>=48&&l<=57)r=l-48;else if(l>=65&&l<=70)r=l-65+10;else{if(!(l>=97&&l<=102)){s[u++]=37,s[u++]=l,a=0;break}r=l-97+10}a=2;break;case 2:if(a=0,l>=48&&l<=57)n=l-48;else if(l>=65&&l<=70)n=l-65+10;else{if(!(l>=97&&l<=102)){s[u++]=37,s[u++]=o,s[u++]=l;break}n=l-97+10}s[u++]=16*r+n}}return s.slice(0,u-1)},n.unescape=o;for(var s=new Array(256),a=0;a<256;++a)s[a]="%"+((a<16?"0":"")+a.toString(16)).toUpperCase();n.escape=function(e){"string"!=typeof e&&(e+="");for(var t="",r=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);if(!(33===i||45===i||46===i||95===i||126===i||i>=39&&i<=42||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122))if(n-r>0&&(t+=e.slice(r,n)),i<128)r=n+1,t+=s[i];else if(i<2048)r=n+1,t+=s[192|i>>6]+s[128|63&i];else if(i<55296||i>=57344)r=n+1,t+=s[224|i>>12]+s[128|i>>6&63]+s[128|63&i];else{var o;if(!(++n<e.length))throw new URIError("URI malformed");o=1023&e.charCodeAt(n),r=n+1,t+=s[240|(i=65536+((1023&i)<<10|o))>>18]+s[128|i>>12&63]+s[128|i>>6&63]+s[128|63&i]}}return 0===r?e:r<e.length?t+e.slice(r):t};var c=function(e){return"string"==typeof e?e:"number"==typeof e&&isFinite(e)?""+e:"boolean"==typeof e?e?"true":"false":""};function u(e,t){try{return t(e)}catch(t){return n.unescape(e,!0)}}n.stringify=n.encode=function(e,t,r,i){t=t||"&",r=r||"=";var o=n.escape;if(i&&"function"==typeof i.encodeURIComponent&&(o=i.encodeURIComponent),null!==e&&"object"==typeof e){for(var s=Object.keys(e),a=s.length,u=a-1,l="",h=0;h<a;++h){var f=s[h],d=e[f],p=o(c(f))+r;if(Array.isArray(d)){for(var y=d.length,v=y-1,g=0;g<y;++g)l+=p+o(c(d[g])),g<v&&(l+=t);y&&h<u&&(l+=t)}else l+=p+o(c(d)),h<u&&(l+=t)}return l}return""},n.parse=n.decode=function(e,t,r,i){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;"string"!=typeof t&&(t+="");var a=r.length,c=t.length,l=1e3;i&&"number"==typeof i.maxKeys&&(l=i.maxKeys);var h=1/0;l>0&&(h=l);var f=n.unescape;i&&"function"==typeof i.decodeURIComponent&&(f=i.decodeURIComponent);for(var d=f!==o,p=[],y=0,v=0,g=0,m="",w="",b=d,k=d,O=0,S=0;S<e.length;++S){var A=e.charCodeAt(S);if(A!==t.charCodeAt(v)){if(v=0,k||(37===A?O=1:O>0&&(A>=48&&A<=57||A>=65&&A<=70||A>=97&&A<=102)?3==++O&&(k=!0):O=0),g<a){if(A===r.charCodeAt(g)){++g===a&&(y<(x=S-g+1)&&(m+=e.slice(y,x)),O=0,y=S+1);continue}g=0,b||(37===A?O=1:O>0&&(A>=48&&A<=57||A>=65&&A<=70||A>=97&&A<=102)?3==++O&&(b=!0):O=0)}43===A&&(g<a?(S-y>0&&(m+=e.slice(y,S)),m+="%20",b=!0):(S-y>0&&(w+=e.slice(y,S)),w+="%20",k=!0),y=S+1)}else if(++v===c){var j,x=S-v+1;if(g<a?y<x&&(m+=e.slice(y,x)):y<x&&(w+=e.slice(y,x)),b&&(m=u(m,f)),k&&(w=u(w,f)),-1===p.indexOf(m)?(s[m]=w,p[p.length]=m):(j=s[m])instanceof Array?j[j.length]=w:s[m]=[j,w],0==--h)break;b=k=d,O=0,m=w="",y=S+1,v=g=0}}return h>0&&(y<e.length||g>0)&&(y<e.length&&(g<a?m+=e.slice(y):v<c&&(w+=e.slice(y))),b&&(m=u(m,f)),k&&(w=u(w,f)),-1===p.indexOf(m)?(s[m]=w,p[p.length]=m):(j=s[m])instanceof Array?j[j.length]=w:s[m]=[j,w]),s}},34:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionNotFound=t.SimpleAction=void 0;const n=r(779);t.SimpleAction=class{constructor(e,t){this.client=e;for(const[e,r]of Object.entries(t))this[e]=r}async submit(e){const t=new URL(this.uri),r={...e};for(const t of this.fields)if(!(t.name in e))if(t.value)r[t.name]=t.value;else if(t.required)throw new Error(`The ${t.name} field is required in this form`);if("GET"===this.method)return t.search=n.stringify(r),this.client.go(t.toString()).get();let i;switch(this.contentType){case"application/x-www-form-urlencoded":i=n.stringify(r);break;case"application/json":i=JSON.stringify(r);break;default:throw new Error(`Serializing mimetype ${this.contentType} is not yet supported in actions`)}const o=await this.client.fetcher.fetchOrThrow(t.toString(),{method:this.method,body:i,headers:{"Content-Type":this.contentType}});return this.client.getStateForResponse(t.toString(),o)}};class i extends Error{}t.ActionNotFound=i},651:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ForeverCache=void 0,t.ForeverCache=class{constructor(){this.cache=new Map}store(e){this.cache.set(e.uri,e.clone())}get(e){const t=this.cache.get(e);return t?t.clone():null}has(e){return this.cache.has(e)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}}},689:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NeverCache=t.ShortCache=t.ForeverCache=void 0;var n=r(651);Object.defineProperty(t,"ForeverCache",{enumerable:!0,get:function(){return n.ForeverCache}});var i=r(478);Object.defineProperty(t,"ShortCache",{enumerable:!0,get:function(){return i.ShortCache}});var o=r(575);Object.defineProperty(t,"NeverCache",{enumerable:!0,get:function(){return o.NeverCache}})},575:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NeverCache=void 0,t.NeverCache=class{store(e){}get(e){return null}has(e){return!1}delete(e){}clear(){}}},478:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCache=void 0;const n=r(651);class i extends n.ForeverCache{constructor(e=3e4){super(),this.cacheTimeout=e,this.activeTimers=new Map}store(e){super.store(e),this.setTimer(e.uri)}setTimer(e){this.activeTimers.has(e)&&clearTimeout(this.activeTimers.get(e)),this.activeTimers.set(e,setTimeout((()=>{this.delete(e),this.activeTimers.delete(e)}),this.cacheTimeout))}}t.ShortCache=i},934:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(66),i=r(871),o=r(24),s=r(963),a=r(458),c=r(689),u=r(549),l=r(736),h=r(941);function f(e,t,r){r||(r=new Set);for(const n of e)r.has(n)||(r.add(n),t.has(n)&&f(t.get(n),t,r));return r}function d(e,t=new Set){t.add(e);for(const r of e.getEmbedded())d(r,t);return t}t.default=class{constructor(e){this.contentTypeMap={"application/prs.hal-forms+json":[o.halStateFactory,"1.0"],"application/hal+json":[o.halStateFactory,"0.9"],"application/vnd.api+json":[o.jsonApiStateFactory,"0.8"],"application/vnd.siren+json":[o.sirenStateFactory,"0.8"],"application/vnd.collection+json":[o.cjStateFactory,"0.8"],"application/json":[o.halStateFactory,"0.7"],"text/html":[o.htmlStateFactory,"0.6"]},this.cacheDependencies=new Map,this.bookmarkUri=e,this.fetcher=new n.Fetcher,this.fetcher.use((0,u.default)(this)),this.fetcher.use((0,l.default)(this)),this.fetcher.use((0,h.default)()),this.cache=new c.ForeverCache,this.resources=new Map}follow(e,t){return this.go().follow(e,t)}go(e){let t;if(t=void 0===e?this.bookmarkUri:"string"==typeof e?(0,a.resolve)(this.bookmarkUri,e):(0,a.resolve)(e),!this.resources.has(t)){const e=new i.default(this,t);return this.resources.set(t,e),e}return this.resources.get(t)}use(e,t="*"){this.fetcher.use(e,t)}clearCache(){this.cache.clear(),this.cacheDependencies=new Map}cacheState(e){const t=d(e);for(const e of t)for(const t of e.links.getMany("inv-by"))this.addCacheDependency((0,a.resolve)(t),e.uri);for(const e of t)this.cache.store(e);for(const e of t){const t=this.resources.get(e.uri);t&&t.emit("update",e)}}addCacheDependency(e,t){this.cacheDependencies.has(e)?this.cacheDependencies.get(e).add(t):this.cacheDependencies.set(e,new Set([t]))}clearResourceCache(e,t){let r=new Set;const n=new Set;for(const t of e)r.add((0,a.resolve)(this.bookmarkUri,t));for(const e of t)r.add((0,a.resolve)(this.bookmarkUri,e)),n.add((0,a.resolve)(this.bookmarkUri,e));r=f(new Set([...r,...n]),this.cacheDependencies);for(const e of r){this.cache.delete(e);const t=this.resources.get(e);t&&(n.has(e)?t.emit("delete"):t.emit("stale"))}}async getStateForResponse(e,t){const r=(0,s.parseContentType)(t.headers.get("Content-Type"));return r&&204!==t.status?r in this.contentTypeMap?this.contentTypeMap[r][0](this,e,t):r.startsWith("text/")?(0,o.textStateFactory)(this,e,t):r.match(/^application\/[A-Za-z-.]+\+json/)?(0,o.halStateFactory)(this,e,t):(0,o.binaryStateFactory)(this,e,t):(0,o.binaryStateFactory)(this,e,t)}}},761:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FollowPromiseMany=t.FollowPromiseOne=void 0;class r{constructor(){this.prefetchEnabled=!1,this.preferTranscludeEnabled=!1,this.useHeadEnabled=!1}preFetch(){return this.prefetchEnabled=!0,this}preferTransclude(){return this.preferTranscludeEnabled=!0,this}useHead(){return this.useHeadEnabled=!0,this}}class n extends r{constructor(e,t,r){super(),this.resource=e,this.rel=t,this.variables=r}then(e,t){return this.fetchLinkedResource().then(e,t)}catch(e){return this.fetchLinkedResource().then(void 0,e)}finally(e){return this.then((()=>e()),(()=>e()))}follow(e,t){return new n(this.fetchLinkedResource(),e,t)}followAll(e){return new i(this.fetchLinkedResource(),e)}async fetchLinkedResource(){const e=await this.resource,t={};let r;!this.useHeadEnabled&&this.preferTranscludeEnabled&&(t.Prefer="transclude="+this.rel),r=this.useHeadEnabled?await e.head({headers:t}):await e.get({headers:t});const n=r.follow(this.rel,this.variables);return this.prefetchEnabled&&n.get().catch((e=>{console.warn("Error while prefetching linked resource",e)})),n}}t.FollowPromiseOne=n;class i extends r{constructor(e,t){super(),this.resource=e,this.rel=t}then(e,t){return this.fetchLinkedResources().then(e,t)}catch(e){return this.fetchLinkedResources().then(void 0,e)}finally(e){return this.then((()=>e()),(()=>e()))}async fetchLinkedResources(){const e=await this.resource,t={};let r;!this.useHeadEnabled&&this.preferTranscludeEnabled&&(t.Prefer="transclude="+this.rel),r=this.useHeadEnabled?await e.head({headers:t}):await e.get({headers:t});const n=r.followAll(this.rel);return this.prefetchEnabled&&n.map((e=>{e.get().catch((e=>{console.warn("Error while prefetching linked resource",e)}))})),n}}t.FollowPromiseMany=i},530:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=(e,t)=>{const r="Basic "+btoa(e+":"+t);return(e,t)=>(e.headers.set("Authorization",r),t(e))}},409:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=e=>{const t="Bearer "+e;return(e,r)=>(e.headers.set("Authorization",t),r(e))}},682:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Problem=t.HttpError=void 0;class r extends Error{constructor(e){super("HTTP error "+e.status),this.response=e,this.status=e.status}}t.HttpError=r;class n extends r{constructor(e,t){super(e),this.body={type:t.type??"about:blank",status:t.status??this.status,...t},this.body.title&&(this.message="HTTP Error "+this.status+": "+this.body.title)}}t.Problem=n,t.default=async function(e){const t=e.headers.get("Content-Type");if(t?.match(/^application\/problem\+json/i)){const t=await e.json();return new n(e,t)}return new r(e)}},66:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetcher=void 0;const n=r(682);class i{constructor(){this.middlewares=[],this.advertiseKetting=!0}fetch(e,t){const n=new Request(e,t),i=new URL(n.url).origin,s=this.getMiddlewaresByOrigin(i);return s.push((e=>(!e.headers.has("User-Agent")&&this.advertiseKetting&&e.headers.set("User-Agent","Ketting/"+r(147).i8),fetch(e)))),o(s,n)}getMiddlewaresByOrigin(e){return this.middlewares.filter((([t])=>t.test(e))).map((([,e])=>e))}use(e,t="*"){const r=t.split("*").map((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).join("(.*)"),n=new RegExp("^"+r+"$");this.middlewares.push([n,e])}async fetchOrThrow(e,t){const r=await this.fetch(e,t);if(r.ok)return r;throw await(0,n.default)(r)}}function o(e,t){return e[0](t,(t=>o(e.slice(1),t)))}t.Fetcher=i,t.default=i},686:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(880);t.default=function(e,t){console.warn("The OAuth2 middleware in Ketting is deprecated, and will be removed in the next major version of Ketting. You should upgrade to the OAuth2Fetch from the @badgateway/oauth2-client project");const r={clientId:e.clientId,clientSecret:"clientSecret"in e?e.clientSecret:void 0,tokenEndpoint:e.tokenEndpoint},i=new n.OAuth2Client(r);return new n.OAuth2Fetch({client:i,getNewToken:async()=>{switch(e.grantType){case"password":return i.password({username:e.userName,password:e.password,scope:e.scope});case"client_credentials":return i.clientCredentials({scope:e.scope});case"authorization_code":return i.authorizationCode.getToken({code:e.code,codeVerifier:e.codeVerifier,redirectUri:e.redirectUri});case void 0:return null}},getStoredToken:()=>t??null,storeToken:t=>{e.onTokenUpdate&&e.onTokenUpdate(t)},onError:t=>{e.onAuthError&&e.onAuthError(t)}}).mw()}},963:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.entityHeaderNames=t.isSafeMethod=t.parseLink=t.parseContentType=void 0;const n=r(475),i=r(173);t.parseContentType=function(e){return e?(e.includes(";")&&(e=e.split(";")[0]),e.trim()):null},t.parseLink=function(e,t){const r=new i.Links(e);if(!t)return r;for(const i of n.parse(t).refs)for(const t of i.rel.split(" ")){const n={rel:t,href:i.uri,context:e,title:i.title,hreflang:i.hreflang,type:i.type};r.add(n)}return r};const o=["GET","HEAD","OPTIONS","PRI","PROPFIND","REPORT","SEARCH","TRACE"];t.isSafeMethod=function(e){return o.includes(e)},t.entityHeaderNames=["Content-Type","Content-Language","Content-Location","Deprecation","ETag","Expires","Last-Modified","Sunset","Title","Warning"]},173:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LinkNotFound=t.Links=void 0;const n=r(458);class i{constructor(e,t){if(this.defaultContext=e,this.store=new Map,t)if(t instanceof i)this.add(...t.getAll());else for(const e of t)this.add(e)}add(...e){let t;t="string"==typeof e[0]?[{rel:e[0],href:e[1],context:this.defaultContext}]:e.map((e=>({context:this.defaultContext,...e})));for(const e of t)this.store.has(e.rel)?this.store.get(e.rel).push(e):this.store.set(e.rel,[e])}set(e,t){let r;r="string"==typeof e?{rel:e,href:t,context:this.defaultContext}:{context:this.defaultContext,...e},this.store.set(r.rel,[r])}get(e){const t=this.store.get(e);if(t&&!(t.length<0))return t[0]}delete(e,t){if(void 0===t)return void this.store.delete(e);const r=this.store.get(e);if(!r)return;this.store.delete(e);const i=(0,n.resolve)(this.defaultContext,t);this.store.set(e,r.filter((e=>(0,n.resolve)(e)!==i)))}getMany(e){return this.store.get(e)||[]}getAll(){const e=[];for(const t of this.store.values())e.push(...t);return e}has(e){return this.store.has(e)}}t.Links=i;class o extends Error{}t.LinkNotFound=o},736:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return async(t,r)=>{if(!t.headers.has("Accept")){const r=Object.entries(e.contentTypeMap).map((([e,[,t]])=>e+";q="+t)).join(", ");t.headers.set("Accept",r)}return r(t)}}},549:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(963),i=r(475),o=r(458);t.default=function(e){return async(t,r)=>{let s=!1;t.headers.has("X-KETTING-NO-STALE")&&(s=!0,t.headers.delete("X-KETTING-NO-STALE"));const a=await r(t);if((0,n.isSafeMethod)(t.method))return a;if(!a.ok)return a;const c=[],u=[];if("DELETE"===t.method?u.push(t.url):s||c.push(t.url),a.headers.has("Link"))for(const e of i.parse(a.headers.get("Link")).rel("invalidates")){const r=(0,o.resolve)(t.url,e.uri);c.push(r)}if(a.headers.has("Location")&&c.push((0,o.resolve)(t.url,a.headers.get("Location"))),e.clearResourceCache(c,u),a.headers.has("Content-Location")){const r=(0,o.resolve)(t.url,a.headers.get("Content-Location")),n=await e.getStateForResponse(r,a);e.cacheState(n)}return a}}},941:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(475),i=r(458);t.default=function(){return async(e,t)=>{const r=await t(e);if(r.headers.get("Deprecation")){const t=r.headers.get("Sunset");let o=`[Ketting] The resource ${e.url} is deprecated.`;if(t&&(o+=" It will no longer respond "+t),r.headers.has("Link"))for(const t of n.parse(r.headers.get("Link")).rel("deprecation"))o+=`See ${(0,i.resolve)(e.url,t.uri)} for more information.`;console.warn(o)}return r}}},871:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Resource=void 0;const n=r(24),i=r(458),o=r(761),s=r(173),a=r(187),c=r(595);class u extends a.EventEmitter{constructor(e,t){super(),this.activeRefresh=new Map,this.client=e,this.uri=t,this.setMaxListeners(500)}get(e){const t=this.getCache();if(t)return Promise.resolve(t);const r=l("GET",e),n=this.uri,i=h(this.uri,e);return this.activeRefresh.has(i)||this.activeRefresh.set(i,(async()=>{try{const e=await this.fetchOrThrow(r),t=await this.client.getStateForResponse(n,e);return this.updateCache(t),t}finally{this.activeRefresh.delete(i)}})()),this.activeRefresh.get(i)}async head(e){let t=this.client.cache.get(this.uri);if(t)return t;const r=await this.fetchOrThrow(l("HEAD",e));return t=await(0,n.headStateFactory)(this.client,this.uri,r),t}refresh(e){const t=l("GET",e);t.cache="no-cache";const r=this.uri,n=h(this.uri,e);return this.activeRefresh.has(n)||this.activeRefresh.set(n,(async()=>{try{const e=await this.fetchOrThrow(t),n=await this.client.getStateForResponse(r,e);return this.updateCache(n),n}finally{this.activeRefresh.delete(n)}})()),this.activeRefresh.get(n)}async put(e){const t=l("PUT",e);(0,n.isState)(e)&&t.headers.set("X-KETTING-NO-STALE","1"),await this.fetchOrThrow(t),(0,n.isState)(e)&&this.updateCache(e)}async delete(){await this.fetchOrThrow({method:"DELETE"})}async post(e){const t=await this.fetchOrThrow(l("POST",e));return this.client.getStateForResponse(this.uri,t)}async postFollow(e){const t=await this.fetchOrThrow(l("POST",e));switch(t.status){case 201:if(t.headers.has("location"))return this.go(t.headers.get("location"));throw new Error('Could not follow after a 201 request, because the server did not reply with a Location header. If you sent a Location header, check if your service is returning "Access-Control-Expose-Headers: Location".');case 204:case 205:return this;default:throw new Error("Did not receive a 201, 204 or 205 status code so we could not follow to the next resource")}}async patch(e){const t=await this.fetchOrThrow(l("PATCH",e));if(200===t.status)return await this.client.getStateForResponse(this.uri,t)}follow(e,t){return new o.FollowPromiseOne(this,e,t)}followAll(e){return new o.FollowPromiseMany(this,e)}go(e){return"string"==typeof e?this.client.go((0,i.resolve)(this.uri,e)):this.client.go(e)}fetch(e){return this.client.fetcher.fetch(this.uri,e)}fetchOrThrow(e){return this.client.fetcher.fetchOrThrow(this.uri,e)}updateCache(e){if(e.uri!==this.uri)throw new Error("When calling updateCache on a resource, the uri of the State object must match the uri of the Resource");this.client.cacheState(e)}clearCache(){this.client.clearResourceCache([this.uri],[])}getCache(){return this.client.cache.get(this.uri)}async link(e){const t=(await this.get()).links.get(e);if(!t)throw new s.LinkNotFound(`Link with rel: ${e} not found on ${this.uri}`);return t}async links(e){const t=await this.get();return e?t.links.getMany(e):t.links.getAll()}async hasLink(e){return(await this.get()).links.has(e)}}function l(e,t){if(!t)return{method:e,headers:new Headers};let r,n;return r=t.getContentHeaders?new Headers(t.getContentHeaders()):t.headers?new Headers(t.headers):new Headers,r.has("Content-Type")||r.set("Content-Type","application/json"),void 0!==t.serializeBody?n=t.serializeBody():t.data?(n=t.data,(0,c.needsJsonStringify)(n)&&(n=JSON.stringify(n))):n=null,{method:e,body:n,headers:r}}function h(e,t){const r={};return t&&new Headers(t.getContentHeaders?.()||t.headers).forEach(((e,t)=>{r[t]=e})),e+"|"+Object.entries(r).map((([e,t])=>e.toLowerCase()+":"+t)).join(",")}t.Resource=u,t.default=u},0:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseState=t.BaseHeadState=void 0;const n=r(173),i=r(34),o=r(458),s=r(640),a=r(963);class c{constructor(e){this.client=e.client,this.uri=e.uri,this.headers=e.headers,this.timestamp=Date.now(),this.links=e.links}follow(e,t){const r=this.links.get(e);if(!r)throw new n.LinkNotFound(`Link with rel ${e} on ${this.uri} not found`);let i;return i=r.templated?(0,s.expand)(r,t||{}):(0,o.resolve)(r),"deprecated"===r.hints?.status&&console.warn(`[ketting] The ${r.rel} link on ${this.uri} is marked deprecated.`,r),this.client.go(i)}followAll(e){return this.links.getMany(e).map((e=>{"deprecated"===e.hints?.status&&console.warn(`[ketting] The ${e.rel} link on ${this.uri} is marked deprecated.`,e);const t=(0,o.resolve)(e);return this.client.go(t)}))}contentHeaders(){const e={};for(const t of a.entityHeaderNames)this.headers.has(t)&&(e[t]=this.headers.get(t));return new Headers(e)}}t.BaseHeadState=c;class u extends c{constructor(e){super(e),this.data=e.data,this.actionInfo=e.actions||[],this.embedded=e.embedded||[]}action(e){if(!this.actionInfo.length)throw new i.ActionNotFound("This State does not define any actions");if(void 0===e)return new i.SimpleAction(this.client,this.actionInfo[0]);for(const t of this.actionInfo)if(t.name===e)return new i.SimpleAction(this.client,t);throw new i.ActionNotFound("This State defines no action")}actions(){return this.actionInfo.map((e=>new i.SimpleAction(this.client,e)))}hasAction(e){if(void 0===e)return this.actionInfo.length>0;for(const t of this.actionInfo)if(e===t.name)return!0;return!1}serializeBody(){return r.g.Buffer&&this.data instanceof Buffer||r.g.Blob&&this.data instanceof Blob||"string"==typeof this.data?this.data:JSON.stringify(this.data)}getEmbedded(){return this.embedded}clone(){return new u({client:this.client,uri:this.uri,data:this.data,headers:new Headers(this.headers),links:new n.Links(this.links.defaultContext,this.links.getAll()),actions:this.actionInfo})}}t.BaseState=u},909:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);t.factory=async(e,t,r)=>new n.BaseState({client:e,uri:t,data:await r.blob(),headers:r.headers,links:(0,i.parseLink)(t,r.headers.get("Link"))})},287:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=t.CjState=void 0;const n=r(0),i=r(963);class o extends n.BaseState{serializeBody(){throw new Error("Reserializing Collection+JSON states is not yet supported. Please log an issue in the Ketting project to help figure out how this should be done")}}t.CjState=o,t.factory=async(e,t,r)=>{const n=await r.json(),s=(0,i.parseLink)(t,r.headers.get("Link"));s.add(...function(e,t){const r=[];if(void 0!==t.collection.links)for(const n of t.collection.links)r.push({context:e,href:n.href,rel:n.rel,title:n.name});if(void 0!==t.collection.items)for(const n of t.collection.items)n.href&&r.push({context:e,href:n.href,rel:"item"});if(void 0!==t.collection.queries)for(const n of t.collection.queries)n.data?r.push({context:e,href:n.href+n.data.map((e=>"{?"+e.name+"}")).join(""),templated:!0,rel:n.rel,title:n.name}):r.push({context:e,href:n.href,rel:n.rel,title:n.name});return r}(t,n));const{_embedded:a,_links:c,...u}=n;return new o({client:e,uri:t,data:u,headers:r.headers,links:s})}},842:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=t.HalState=void 0;const n=r(0),i=r(963),o=r(173),s=r(458);class a extends n.BaseState{serializeBody(){return JSON.stringify({_links:this.serializeLinks(),...this.data})}serializeLinks(){const e={self:{href:this.uri}};for(const t of this.links.getAll()){const{rel:r,context:n,...i}=t;"self"!==r&&(void 0===e[r]?e[r]=i:Array.isArray(e[r])?e[r].push(i):e[r]=[e[r],i])}return e}clone(){return new a({client:this.client,uri:this.uri,data:this.data,headers:new Headers(this.headers),links:new o.Links(this.links.defaultContext,this.links.getAll()),actions:this.actionInfo})}}function c(e,t){if(void 0===t._links)return[];const r=[],n=new Set;for(const[i,o]of Object.entries(t._links)){const t=Array.isArray(o)?o:[o];for(const e of t)n.add(i+";"+e.href);r.push(...u(e,i,t))}if(t._embedded)for(let[i,o]of Object.entries(t._embedded)){Array.isArray(o)||(o=[o]);for(const t of o){const o=t?._links?.self?.href;o&&(n.has(i+";"+o)||r.push({rel:i,href:o,context:e}))}}return r}function u(e,t,r){const n=[];for(const i of r)n.push({rel:t,context:e,...i});return n}function l(e,t,r,n){if(void 0===r._embedded||!r._embedded)return[];const i=[];for(const u of Object.values(r._embedded)){let r;r=Array.isArray(u)?u:[u];for(const u of r){if(void 0===u._links?.self?.href){console.warn('An item in _embedded was ignored. Each item must have a single "self" link');continue}const r=(0,s.resolve)(t,u._links.self.href),{_embedded:f,_links:d,...p}=u;i.push(new a({client:e,uri:r,data:p,headers:new Headers({"Content-Type":n.get("Content-Type")}),links:new o.Links(r,c(t,u)),embedded:l(e,r,u,n),actions:h(r,u)}))}}return i}function h(e,t){return t._templates?Object.entries(t._templates).map((([t,r])=>({uri:(0,s.resolve)(e,r.target||""),name:t,title:r.title,method:r.method,contentType:r.contentType||"application/json",fields:r.properties?r.properties.map((e=>function(e){switch(e.type){case void 0:case"text":case"search":case"tel":case"url":case"email":if(e.options){const t={name:e.name,type:"select",label:e.prompt,required:e.required||!1,readOnly:e.readOnly||!1,multiple:e.options.multiple,value:e.options.selectedValues||e.value},r=e.options.promptField||"prompt",n=e.options.valueField||"value";if(void 0!==e.options.inline){const i={};for(const t of e.options.inline)"string"==typeof t?i[t]=t:i[t[n]]=t[r];return{...t,options:i}}return{...t,dataSource:{href:e.options.link.href,type:e.options.link.type,labelField:r,valueField:n}}}return{name:e.name,type:e.type??"text",required:e.required||!1,readOnly:e.readOnly||!1,value:e.value,pattern:e.regex?new RegExp(e.regex):void 0,label:e.prompt,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength};case"hidden":return{name:e.name,type:"hidden",required:e.required||!1,readOnly:e.readOnly||!1,value:e.value,label:e.prompt,placeholder:e.placeholder};case"textarea":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,value:e.value,label:e.prompt,placeholder:e.placeholder,cols:e.cols,rows:e.rows,minLength:e.minLength,maxLength:e.maxLength};case"password":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength};case"date":case"month":case"week":case"time":return{name:e.name,type:e.type,value:e.value,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,min:e.min,max:e.max,step:e.step};case"number":case"range":return{name:e.name,type:e.type,value:e.value?+e.value:void 0,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,min:e.min,max:e.max,step:e.step};case"datetime-local":return{name:e.name,type:e.type,value:e.value?new Date(e.value):void 0,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,min:e.min,max:e.max,step:e.step};case"color":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,value:e.value};case"radio":case"checkbox":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,value:!!e.value}}}(e))):[]}))):[]}t.HalState=a,t.factory=async(e,t,r)=>{const n=await r.json(),o=(0,i.parseLink)(t,r.headers.get("Link"));if(Array.isArray(n))return new a({client:e,uri:t,data:n,headers:r.headers,links:o});o.add(...c(t,n));const{_embedded:s,_links:u,_templates:f,...d}=n;return new a({client:e,uri:t,data:d,headers:r.headers,links:o,embedded:l(e,t,n,r.headers),actions:h(t,n)})}},770:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);t.factory=async(e,t,r)=>{const o=(0,i.parseLink)(t,r.headers.get("Link"));return new n.BaseHeadState({client:e,uri:t,headers:r.headers,links:o})}},154:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963),o=r(730),s=r(458);t.factory=async(e,t,r)=>{const a=await r.text(),c=(0,i.parseLink)(t,r.headers.get("Link")),u=(0,o.parseHtml)(t,a);return c.add(...u.links),new n.BaseState({client:e,uri:t,data:a,headers:r.headers,links:c,actions:u.forms.map((e=>function(e,t){return{uri:(0,s.resolve)(e,t.action),name:t.rel||t.id||"",method:t.method||"GET",contentType:t.enctype||"application/x-www-form-urlencoded",fields:[]}}(t,e)))})}},24:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.headStateFactory=t.htmlStateFactory=t.CjState=t.cjStateFactory=t.textStateFactory=t.SirenState=t.sirenStateFactory=t.jsonApiStateFactory=t.binaryStateFactory=t.HalState=t.halStateFactory=t.BaseHeadState=t.BaseState=t.isState=void 0;var n=r(269);Object.defineProperty(t,"isState",{enumerable:!0,get:function(){return n.isState}});var i=r(0);Object.defineProperty(t,"BaseState",{enumerable:!0,get:function(){return i.BaseState}}),Object.defineProperty(t,"BaseHeadState",{enumerable:!0,get:function(){return i.BaseHeadState}});var o=r(842);Object.defineProperty(t,"halStateFactory",{enumerable:!0,get:function(){return o.factory}}),Object.defineProperty(t,"HalState",{enumerable:!0,get:function(){return o.HalState}});var s=r(909);Object.defineProperty(t,"binaryStateFactory",{enumerable:!0,get:function(){return s.factory}});var a=r(60);Object.defineProperty(t,"jsonApiStateFactory",{enumerable:!0,get:function(){return a.factory}});var c=r(389);Object.defineProperty(t,"sirenStateFactory",{enumerable:!0,get:function(){return c.factory}}),Object.defineProperty(t,"SirenState",{enumerable:!0,get:function(){return c.SirenState}});var u=r(945);Object.defineProperty(t,"textStateFactory",{enumerable:!0,get:function(){return u.factory}});var l=r(287);Object.defineProperty(t,"cjStateFactory",{enumerable:!0,get:function(){return l.factory}}),Object.defineProperty(t,"CjState",{enumerable:!0,get:function(){return l.CjState}});var h=r(154);Object.defineProperty(t,"htmlStateFactory",{enumerable:!0,get:function(){return h.factory}});var f=r(770);Object.defineProperty(t,"headStateFactory",{enumerable:!0,get:function(){return f.factory}})},269:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isState=void 0;const n=r(173);t.isState=function(e){return"string"==typeof e.uri&&e.links instanceof n.Links&&e.headers instanceof Headers}},60:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);function o(e,t,r){return{context:e,rel:t,href:"string"==typeof r?r:r.href}}t.factory=async(e,t,r)=>{const s=await r.json(),a=(0,i.parseLink)(t,r.headers.get("Link"));return a.add(...function(e,t){const r=[];if(void 0===t.links)return r;for(const[n,i]of Object.entries(t.links))Array.isArray(i)?r.push(...i.map((t=>o(e,n,t)))):r.push(o(e,n,i));return r}(t,s),...function(e,t){if(!Array.isArray(t.data))return[];const r=[];for(const n of t.data)if("links"in n&&"self"in n.links){const t=o(e,"self",n.links.self);r.push({context:e,href:t.href,rel:"item"})}return r}(t,s)),new n.BaseState({client:e,uri:t,data:s,headers:r.headers,links:a})}},389:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=t.SirenState=void 0;const n=r(0),i=r(963),o=r(173),s=r(458);class a extends n.BaseState{serializeBody(){throw new Error("Reserializing Siren states is not yet supported. Please log an issue in the Ketting project to help figure out how this should be done")}clone(){return new a({client:this.client,uri:this.uri,data:this.data,headers:new Headers(this.headers),links:new o.Links(this.uri,this.links),actions:this.actionInfo})}}function c(e,t){const r=[];if(void 0!==t.links)for(const n of t.links)r.push(...u(e,n));if(void 0!==t.entities)for(const n of t.entities)void 0!==n.href?r.push(...u(e,n)):r.push(...h(e,n));return r}function u(e,t){const r=[],{rel:n,...i}=t;for(const t of n){const n={rel:t,context:e,...i};r.push(n)}return r}function l(e,t,r,n){if(void 0===r.entities)return[];const i=[];for(const o of r.entities)if(void 0===o.href){const r=f(e,t,o,n);null!==r&&i.push(r)}return i}function h(e,t){if(void 0===t.links)return[];let r=null;for(const e of t.links)e.rel.includes("self")&&(r=e.href);return null===r?[]:t.rel.map((n=>{const i=t.title,o={href:r,rel:n,context:e};return i&&(o.title=i),o}))}function f(e,t,r,n){if(void 0===r.links)return null;let i=null;for(const e of r.links)e.rel.includes("self")&&(i=e.href);if(!i)return null;const u=(0,s.resolve)(t,i);return new a({client:e,uri:u,data:r.properties,headers:n,links:new o.Links(i,c(i,r))})}t.SirenState=a,t.factory=async(e,t,r)=>{const n=await r.json(),o=(0,i.parseLink)(t,r.headers.get("Link"));return o.add(...c(t,n)),new a({client:e,uri:t,data:n.properties,headers:r.headers,links:o,embedded:l(e,t,n,r.headers),actions:n.actions?n.actions.map((e=>function(e,t){return{uri:(0,s.resolve)(e,t.href),name:t.name,title:t.title,method:t.method||"GET",contentType:t.type||"application/x-www-form-urlencoded",fields:t.fields?t.fields.map((e=>function(e){const t={name:e.name,type:e.type||"text",required:!1,readOnly:!1};return e.value&&(t.value=e.value),e.title&&(t.label=e.title),t}(e))):[]}}(t,e))):[]})}},945:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);t.factory=async(e,t,r)=>new n.BaseState({client:e,uri:t,data:await r.text(),headers:r.headers,links:(0,i.parseLink)(t,r.headers.get("Link"))})},595:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.needsJsonStringify=void 0,t.needsJsonStringify=function(e){return"string"!=typeof e&&!(e instanceof Blob)}},730:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseHtml=void 0;const n=r(458);function i(e,t){const r=[];for(const n of t){const t=n.getAttribute("rel"),i=n.getAttribute("href"),o=n.getAttribute("type")||void 0;if(t&&i)for(const n of t.split(" ")){const t={rel:n,context:e,href:i};o&&(t.type=o),r.push(t)}}return r}function o(e,t){const r=[];for(const i of t){const t=i.getAttribute("rel"),o=i.getAttribute("action"),s=i.getAttribute("enctype")||"application/x-www-form-urlencoded",a=i.getAttribute("id"),c=i.getAttribute("method")||"GET";if(t)for(const i of t.split(" ")){const t={rel:i,action:(0,n.resolve)(e,o),enctype:s,id:a,method:c};r.push(t)}else r.push({rel:null,action:(0,n.resolve)(e,o),enctype:s,id:a,method:c})}return r}t.parseHtml=function(e,t){const r=(new DOMParser).parseFromString(t,"text/html");return{forms:o(e,r.getElementsByTagName("form")),links:[...i(e,r.getElementsByTagName("link")),...i(e,r.getElementsByTagName("a"))]}}},640:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.expand=void 0;const n=r(493),i=r(458);t.expand=function(e,t,r){let o,s,a;"string"==typeof e?(o=e,s=t,a=r):(o=e.context,s=e.href,a=t);const c=n.parse(s).expand(a);return(0,i.resolve)(o,c)}},458:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=t.resolve=void 0,t.resolve=function(e,t){let r,n;"string"==typeof e?(r=e,n=t):(r=e.context,n=e.href);const i=new URL(n,new URL(r,"http://ketting.invalid"));return"ketting.invalid"===i.hostname?i.pathname+i.search+i.hash:r.startsWith("//")?"//"+i.host+i.pathname+i.search+i.hash:i.toString()},t.parse=function(e){const t=new URL(e,"http://ketting.invalid");return"ketting.invalid"===t.hostname?{host:null}:{host:t.host}}},9:function(e,t){"use strict";t.__esModule=!0,t.toString=void 0,t.toString=function e(t){var r,n;switch(t.type){case"template":return t.parts.map(e).join("");case"literal":return t.value;case"expression":return"{"+t.operator+t.variables.map(e).join(",")+"}";case"variable":var i=t.name;return"explode"==(null===(r=t.modifier)||void 0===r?void 0:r.type)?i+="*":"substr"==(null===(n=t.modifier)||void 0===n?void 0:n.type)&&(i+=":"+t.modifier.length),t.extension&&(i+="("+t.extension+")"),i}}},644:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0,t.expandExpression=t.expandTemplate=void 0;var o=i(r(129)),s={UrlSafe:(0,o.default)(/[^\w~.-]/g),Restricted:(0,o.default)(/[^\w.~:\/\?#\[\]@!\$&'()*+,;=%-]|%(?!\d\d)/g)};t.expandTemplate=function(e,t){return e.parts.map((function(e){switch(e.type){case"literal":return e.value;case"expression":return u(e,t)}})).join("")};var a={first:"",sep:",",empty:"",encode:s.UrlSafe,named:!1},c={"":n({},a),"+":n(n({},a),{encode:s.Restricted}),"#":n(n({},a),{encode:s.Restricted,first:"#",empty:"#"}),"/":n(n({},a),{first:"/",sep:"/"}),".":n(n({},a),{first:".",sep:".",empty:"."}),";":n(n({},a),{first:";",sep:";",named:!0}),"?":n(n({},a),{first:"?",sep:"&",empty:"=",named:!0}),"&":n(n({},a),{first:"&",sep:"&",empty:"=",named:!0})};function u(e,t){var r=c[e.operator],n=[];if(e.variables.forEach((function(e){var i=t[e.name];if(function(e){switch(typeof e){case"undefined":return!1;case"object":if(null==e)return!1;if(Array.isArray(e))return e.length>0;for(var t in e)if(null!=e[t])return!0;return!1;default:return!0}}(i)){var o=function(e,t,r){var n;if(null==t)throw new TypeError("tried to expand null value for variable "+e.name+", this is a bug in uri-template");return"explode"===(null===(n=e.modifier)||void 0===n?void 0:n.type)?function(e,t,r){var n=r.encode,i=r.named,o=r.sep;if(Array.isArray(t)){var s=t.map(n);return i&&(s=s.map((function(t){return e.name+"="+t}))),s.join(o)}if("object"==typeof t){var a=[];return Object.entries(t).forEach((function(e){var t=e[0],r=e[1];t=n(t),Array.isArray(r)?r.forEach((function(e){a.push(t+"="+n(e))})):a.push(t+"="+n(r))})),a.join(o)}var c=t.toString();return n(c)}(e,t,r):function(e,t,r){var n,i,o,s=r.empty,a=r.encode,c=r.named;if("object"==typeof t&&"substr"===(null===(n=e.modifier)||void 0===n?void 0:n.type))throw new Error("Prefixed variables do not support lists/maps. Check "+e.name);return Array.isArray(t)?o=t.map(a).join(","):"object"==typeof t?o=Object.entries(t).map((function(e){return e.map(a).join(",")})).join(","):(o=t.toString(),"substr"===(null===(i=e.modifier)||void 0===i?void 0:i.type)&&(o=o.substring(0,e.modifier.length)),o=a(o)),c&&(o=o?e.name+"="+o:""+e.name+s),o}(e,t,r)}(e,i,r);n.push(o||"")}})),0===n.length)return"";var i=n.join(r.sep);return 0===i.length?r.empty:r.first+i}t.expandExpression=u},115:function(e){"use strict";function t(e,r,n,i){var o=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(o,t.prototype),o.expected=r,o.found=n,o.location=i,o.name="SyntaxError",o}function r(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}!function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(t,Error),t.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var n,i=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){i=e[n].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,s=this.location.source+":"+o.line+":"+o.column;if(i){var a=this.location.end,c=r("",o.line.toString().length),u=i[o.line-1],l=o.line===a.line?a.column:u.length+1;t+="\n --\x3e "+s+"\n"+c+" |\n"+o.line+" | "+u+"\n"+c+" | "+r("",o.column-1)+r("",l-o.column,"^")}else t+="\n at "+s}return t},t.buildMessage=function(e,t){var r={literal:function(e){return'"'+i(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e)}));return"["+(e.inverted?"^":"")+t+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function s(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(s);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+i(e)+'"':"end of input"}(t)+" found."},e.exports={SyntaxError:t,parse:function(e,r){var n,i,o,s,a={},c=(r=void 0!==r?r:{}).grammarSource,u={template:ee},l=ee,h="{",f="}",d=",",p="*",y=":",v="(",g=")",m=/^[\/;.?&+#]/,w=/^[a-zA-Z0-9_.%]/,b=/^[0-9]/,k=/^[^{]/,O=/^[^)]/,S=W("{",!1),A=W("}",!1),j=Q(["/",";",".","?","&","+","#"],!1,!1),x=W(",",!1),_=Q([["a","z"],["A","Z"],["0","9"],"_",".","%"],!1,!1),C=W("*",!1),E=W(":",!1),T=Q([["0","9"]],!1,!1),L=Q(["{"],!0,!1),P=W("(",!1),F=Q([")"],!0,!1),R=W(")",!1),M=function(e){return{type:"template",parts:e}},H=function(e,t){return{type:"expression",operator:e,variables:t}},B=function(e,t){return t},U=function(e,t){return t.unshift(e),t},N=function(e,t,r){return{type:"variable",name:e,modifier:t,extension:r}},I=function(){return{type:"explode"}},z=function(e){return{type:"substr",length:parseInt(e)}},q=function(e){return{type:"literal",value:e}},D=function(e){return e},$=0,K=[{line:1,column:1}],V=0,G=[],J=0;if("startRule"in r){if(!(r.startRule in u))throw new Error("Can't start parsing from rule \""+r.startRule+'".');l=u[r.startRule]}function W(e,t){return{type:"literal",text:e,ignoreCase:t}}function Q(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function Z(t){var r,n=K[t];if(n)return n;for(r=t-1;!K[r];)r--;for(n={line:(n=K[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return K[t]=n,n}function X(e,t){var r=Z(e),n=Z(t);return{source:c,start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function Y(e){$<V||($>V&&(V=$,G=[]),G.push(e))}function ee(){var e,t;for($,e=[],(t=ne())===a&&(t=te());t!==a;)e.push(t),(t=ne())===a&&(t=te());return M(e)}function te(){var t,r,n,i,o;return t=$,123===e.charCodeAt($)?(r=h,$++):(r=a,0===J&&Y(S)),r!==a?(n=function(){var t;return m.test(e.charAt($))?(t=e.charAt($),$++):(t=a,0===J&&Y(j)),t===a&&(t=""),t}(),n!==a?(i=function(){var t,r,n,i,o,s;if(t=$,(r=re())!==a){for(n=[],i=$,44===e.charCodeAt($)?(o=d,$++):(o=a,0===J&&Y(x)),o!==a&&(s=re())!==a?i=B(r,s):($=i,i=a);i!==a;)n.push(i),i=$,44===e.charCodeAt($)?(o=d,$++):(o=a,0===J&&Y(x)),o!==a&&(s=re())!==a?i=B(r,s):($=i,i=a);t=U(r,n)}else $=t,t=a;return t}(),i!==a?(125===e.charCodeAt($)?(o=f,$++):(o=a,0===J&&Y(A)),o!==a?t=H(n,i):($=t,t=a)):($=t,t=a)):($=t,t=a)):($=t,t=a),t}function re(){var t,r,n,i;if(t=$,r=$,n=[],w.test(e.charAt($))?(i=e.charAt($),$++):(i=a,0===J&&Y(_)),i!==a)for(;i!==a;)n.push(i),w.test(e.charAt($))?(i=e.charAt($),$++):(i=a,0===J&&Y(_));else n=a;return(r=n!==a?e.substring(r,$):n)!==a?(n=function(){var t,r,n,i,o;if(t=$,58===e.charCodeAt($)?(r=y,$++):(r=a,0===J&&Y(E)),r!==a){if(n=$,i=[],b.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(T)),o!==a)for(;o!==a;)i.push(o),b.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(T));else i=a;(n=i!==a?e.substring(n,$):i)!==a?t=z(n):($=t,t=a)}else $=t,t=a;return t}(),n===a&&(n=function(){var t;return $,42===e.charCodeAt($)?(t=p,$++):(t=a,0===J&&Y(C)),t!==a&&(t=I()),t}()),n===a&&(n=null),i=function(){var t,r,n,i,o;if(t=$,40===e.charCodeAt($)?(r=v,$++):(r=a,0===J&&Y(P)),r!==a){if(n=$,i=[],O.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(F)),o!==a)for(;o!==a;)i.push(o),O.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(F));else i=a;(n=i!==a?e.substring(n,$):i)!==a?(41===e.charCodeAt($)?(i=g,$++):(i=a,0===J&&Y(R)),i!==a?t=D(n):($=t,t=a)):($=t,t=a)}else $=t,t=a;return t}(),i===a&&(i=null),t=N(r,n,i)):($=t,t=a),t}function ne(){var t,r,n;if($,t=$,r=[],k.test(e.charAt($))?(n=e.charAt($),$++):(n=a,0===J&&Y(L)),n!==a)for(;n!==a;)r.push(n),k.test(e.charAt($))?(n=e.charAt($),$++):(n=a,0===J&&Y(L));else r=a;return(t=r!==a?e.substring(t,$):r)!==a&&(t=q(t)),t}if((n=l())!==a&&$===e.length)return n;throw n!==a&&$<e.length&&Y({type:"end"}),i=G,o=V<e.length?e.charAt(V):null,s=V<e.length?X(V,V+1):X(V,V),new t(t.buildMessage(i,o),i,o,s)}}},493:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};t.__esModule=!0,t.parseRule=t.parse=void 0;var a=o(r(115)),c=o(r(9)),u=r(644);function l(e,t){return void 0===t&&(t="template"),a.parse(e,{startRule:t})}t.parse=function(e){var t=l(e,"template");return{ast:t,expand:function(e){return(0,u.expandTemplate)(t,e)},toString:function(){return c.toString(t)}}},t.parseRule=l,s(r(644),t)},94:function(){},147:function(e){"use strict";e.exports=JSON.parse('{"i8":"8.0.0-alpha.2"}')}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var n={};return function(){"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.FollowPromiseMany=e.FollowPromiseOne=e.Problem=e.oauth2=e.bearerAuth=e.basicAuth=e.NeverCache=e.ShortCache=e.ForeverCache=e.isState=e.CjState=e.SirenState=e.HalState=e.BaseHeadState=e.BaseState=e.resolve=e.Links=e.LinkNotFound=e.Resource=e.default=e.Ketting=e.Client=void 0;var t=r(934);Object.defineProperty(e,"Client",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"Ketting",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.default}});var i=r(871);Object.defineProperty(e,"Resource",{enumerable:!0,get:function(){return i.default}});var o=r(173);Object.defineProperty(e,"LinkNotFound",{enumerable:!0,get:function(){return o.LinkNotFound}}),Object.defineProperty(e,"Links",{enumerable:!0,get:function(){return o.Links}});var s=r(458);Object.defineProperty(e,"resolve",{enumerable:!0,get:function(){return s.resolve}});var a=r(24);Object.defineProperty(e,"BaseState",{enumerable:!0,get:function(){return a.BaseState}}),Object.defineProperty(e,"BaseHeadState",{enumerable:!0,get:function(){return a.BaseHeadState}}),Object.defineProperty(e,"HalState",{enumerable:!0,get:function(){return a.HalState}}),Object.defineProperty(e,"SirenState",{enumerable:!0,get:function(){return a.SirenState}}),Object.defineProperty(e,"CjState",{enumerable:!0,get:function(){return a.CjState}}),Object.defineProperty(e,"isState",{enumerable:!0,get:function(){return a.isState}});var c=r(651);Object.defineProperty(e,"ForeverCache",{enumerable:!0,get:function(){return c.ForeverCache}});var u=r(478);Object.defineProperty(e,"ShortCache",{enumerable:!0,get:function(){return u.ShortCache}});var l=r(575);Object.defineProperty(e,"NeverCache",{enumerable:!0,get:function(){return l.NeverCache}});var h=r(530);Object.defineProperty(e,"basicAuth",{enumerable:!0,get:function(){return h.default}});var f=r(409);Object.defineProperty(e,"bearerAuth",{enumerable:!0,get:function(){return f.default}});var d=r(686);Object.defineProperty(e,"oauth2",{enumerable:!0,get:function(){return d.default}});var p=r(682);Object.defineProperty(e,"Problem",{enumerable:!0,get:function(){return p.Problem}});var y=r(761);Object.defineProperty(e,"FollowPromiseOne",{enumerable:!0,get:function(){return y.FollowPromiseOne}}),Object.defineProperty(e,"FollowPromiseMany",{enumerable:!0,get:function(){return y.FollowPromiseMany}})}(),n}()}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Ketting=t():e.Ketting=t()}(self,(function(){return function(){var e={880:function(e){var t;self,t=()=>(()=>{var e={934:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateQueryString=t.tokenResponseToOAuth2Token=t.OAuth2Client=void 0;const n=r(443),i=r(618);function o(e,t){return new URL(e,t).toString()}function s(e){return e.then((e=>{var t;return{accessToken:e.access_token,expiresAt:e.expires_in?Date.now()+1e3*e.expires_in:null,refreshToken:null!==(t=e.refresh_token)&&void 0!==t?t:null}}))}function a(e){return new URLSearchParams(Object.fromEntries(Object.entries(e).filter((([e,t])=>void 0!==t)))).toString()}t.OAuth2Client=class{constructor(e){this.discoveryDone=!1,this.serverMetadata=null,(null==e?void 0:e.fetch)||(e.fetch=fetch),this.settings=e}async refreshToken(e){if(!e.refreshToken)throw new Error("This token didn't have a refreshToken. It's not possible to refresh this");const t={grant_type:"refresh_token",refresh_token:e.refreshToken};return this.settings.clientSecret||(t.client_id=this.settings.clientId),s(this.request("tokenEndpoint",t))}async clientCredentials(e){var t;const r=["client_id","client_secret","grant_type","scope"];if((null==e?void 0:e.extraParams)&&Object.keys(e.extraParams).filter((e=>r.includes(e))).length>0)throw new Error(`The following extraParams are disallowed: '${r.join("', '")}'`);const n={grant_type:"client_credentials",scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),...null==e?void 0:e.extraParams};if(!this.settings.clientSecret)throw new Error("A clientSecret must be provided to use client_credentials");return s(this.request("tokenEndpoint",n))}async password(e){var t;const r={grant_type:"password",...e,scope:null===(t=e.scope)||void 0===t?void 0:t.join(" ")};return s(this.request("tokenEndpoint",r))}get authorizationCode(){return new i.OAuth2AuthorizationCodeClient(this)}async introspect(e){const t={token:e.accessToken,token_type_hint:"access_token"};return this.request("introspectionEndpoint",t)}async getEndpoint(e){if(void 0!==this.settings[e])return o(this.settings[e],this.settings.server);if("discoveryEndpoint"!==e&&(await this.discover(),void 0!==this.settings[e]))return o(this.settings[e],this.settings.server);if(!this.settings.server)throw new Error(`Could not determine the location of ${e}. Either specify ${e} in the settings, or the "server" endpoint to let the client discover it.`);switch(e){case"authorizationEndpoint":return o("/authorize",this.settings.server);case"tokenEndpoint":return o("/token",this.settings.server);case"discoveryEndpoint":return o("/.well-known/oauth-authorization-server",this.settings.server);case"introspectionEndpoint":return o("/introspect",this.settings.server)}}async discover(){var e;if(this.discoveryDone)return;let t;this.discoveryDone=!0;try{t=await this.getEndpoint("discoveryEndpoint")}catch(e){return void console.warn('[oauth2] OAuth2 discovery endpoint could not be determined. Either specify the "server" or "discoveryEndpoint')}const r=await this.settings.fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)return;if(!(null===(e=r.headers.get("Content-Type"))||void 0===e?void 0:e.startsWith("application/json")))return void console.warn("[oauth2] OAuth2 discovery endpoint was not a JSON response. Response is ignored");this.serverMetadata=await r.json();const n=[["authorization_endpoint","authorizationEndpoint"],["token_endpoint","tokenEndpoint"],["introspection_endpoint","introspectionEndpoint"]];if(null!==this.serverMetadata){for(const[e,r]of n)this.serverMetadata[e]&&(this.settings[r]=o(this.serverMetadata[e],t));this.serverMetadata.token_endpoint_auth_methods_supported&&!this.settings.authenticationMethod&&(this.settings.authenticationMethod=this.serverMetadata.token_endpoint_auth_methods_supported[0])}}async request(e,t){const r=await this.getEndpoint(e),i={"Content-Type":"application/x-www-form-urlencoded"};let o=this.settings.authenticationMethod;switch(o||(o=this.settings.clientSecret?"client_secret_basic":"client_secret_post"),o){case"client_secret_basic":i.Authorization="Basic "+btoa(this.settings.clientId+":"+this.settings.clientSecret);break;case"client_secret_post":t.client_id=this.settings.clientId,this.settings.clientSecret&&(t.client_secret=this.settings.clientSecret);break;default:throw new Error("Authentication method not yet supported:"+o+". Open a feature request if you want this!")}const s=await this.settings.fetch(r,{method:"POST",body:a(t),headers:i});if(s.ok)return await s.json();let c,u,l;throw s.headers.has("Content-Type")&&s.headers.get("Content-Type").startsWith("application/json")&&(c=await s.json()),(null==c?void 0:c.error)?(u="OAuth2 error "+c.error+".",c.error_description&&(u+=" "+c.error_description),l=c.error):(u="HTTP Error "+s.status+" "+s.statusText,401===s.status&&this.settings.clientSecret&&(u+=". It's likely that the clientId and/or clientSecret was incorrect"),l=null),new n.OAuth2Error(u,l,s.status)}},t.tokenResponseToOAuth2Token=s,t.generateQueryString=a},618:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getCodeChallenge=t.generateCodeVerifier=t.OAuth2AuthorizationCodeClient=void 0;const n=r(934),i=r(443);async function o(e){const t=s();if(null==t?void 0:t.subtle)return["S256",c(await t.subtle.digest("SHA-256",a(e)))];{const t=r(212).createHash("sha256");return t.update(a(e)),["S256",t.digest("base64url")]}}function s(){if("undefined"!=typeof window&&window.crypto)return window.crypto;if("undefined"!=typeof self&&self.crypto)return self.crypto;const e=r(212);return e.webcrypto?e.webcrypto:null}function a(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=255&e.charCodeAt(r);return t}function c(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}t.OAuth2AuthorizationCodeClient=class{constructor(e){this.client=e}async getAuthorizeUri(e){const[t,r]=await Promise.all([e.codeVerifier?o(e.codeVerifier):void 0,this.client.getEndpoint("authorizationEndpoint")]),i={client_id:this.client.settings.clientId,response_type:"code",redirect_uri:e.redirectUri,code_challenge_method:null==t?void 0:t[0],code_challenge:null==t?void 0:t[1]};return e.state&&(i.state=e.state),e.scope&&(i.scope=e.scope.join(" ")),r+"?"+(0,n.generateQueryString)(i)}async getTokenFromCodeRedirect(e,t){const{code:r}=await this.validateResponse(e,{state:t.state});return this.getToken({code:r,redirectUri:t.redirectUri,codeVerifier:t.codeVerifier})}async validateResponse(e,t){var r;const n=new URL(e).searchParams;if(n.has("error"))throw new i.OAuth2Error(null!==(r=n.get("error_description"))&&void 0!==r?r:"OAuth2 error",n.get("error"),0);if(!n.has("code"))throw new Error(`The url did not contain a code parameter ${e}`);if(t.state&&t.state!==n.get("state"))throw new Error(`The "state" parameter in the url did not match the expected value of ${t.state}`);return{code:n.get("code"),scope:n.has("scope")?n.get("scope").split(" "):void 0}}async getToken(e){const t={grant_type:"authorization_code",code:e.code,redirect_uri:e.redirectUri,code_verifier:e.codeVerifier};return(0,n.tokenResponseToOAuth2Token)(this.client.request("tokenEndpoint",t))}},t.generateCodeVerifier=async function(){const e=s();if(e){const t=new Uint8Array(32);return e.getRandomValues(t),c(t)}{const e=r(212);return new Promise(((t,r)=>{e.randomBytes(32,((e,n)=>{e&&r(e),t(n.toString("base64url"))}))}))}},t.getCodeChallenge=o},443:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Error=void 0;class r extends Error{constructor(e,t,r){super(e),this.oauth2Code=t,this.httpCode=r}}t.OAuth2Error=r},13:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Fetch=void 0,t.OAuth2Fetch=class{constructor(e){this.token=null,this.activeRefresh=null,this.refreshTimer=null,void 0===(null==e?void 0:e.scheduleRefresh)&&(e.scheduleRefresh=!0),this.options=e,e.getStoredToken&&(async()=>{this.token=await e.getStoredToken()})(),this.scheduleRefresh()}async fetch(e,t){const r=new Request(e,t);return this.mw()(r,(e=>fetch(e)))}mw(){return async(e,t)=>{const r=await this.getAccessToken();let n=e.clone();n.headers.set("Authorization","Bearer "+r);let i=await t(n);if(!i.ok&&401===i.status){const r=await this.refreshToken();n=e.clone(),n.headers.set("Authorization","Bearer "+r.accessToken),i=await t(n)}return i}}async getToken(){return this.token&&(null===this.token.expiresAt||this.token.expiresAt>Date.now())?this.token:this.refreshToken()}async getAccessToken(){return(await this.getToken()).accessToken}async refreshToken(){var e,t;if(this.activeRefresh)return this.activeRefresh;const r=this.token;this.activeRefresh=(async()=>{var e,t;let n=null;try{(null==r?void 0:r.refreshToken)&&(n=await this.options.client.refreshToken(r))}catch(e){console.warn("[oauth2] refresh token not accepted, we'll try reauthenticating")}if(n||(n=await this.options.getNewToken()),!n){const r=new Error("Unableto obtain OAuth2 tokens, a full reauth may be needed");throw null===(t=(e=this.options).onError)||void 0===t||t.call(e,r),r}return n})();try{const r=await this.activeRefresh;return this.token=r,null===(t=(e=this.options).storeToken)||void 0===t||t.call(e,r),this.scheduleRefresh(),r}catch(e){throw this.options.onError&&this.options.onError(e),e}finally{this.activeRefresh=null}}scheduleRefresh(){var e;if(!this.options.scheduleRefresh)return;if(this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),!(null===(e=this.token)||void 0===e?void 0:e.expiresAt)||!this.token.refreshToken)return;const t=this.token.expiresAt-Date.now();t<12e4||(this.refreshTimer=setTimeout((async()=>{try{await this.refreshToken()}catch(e){console.error("[fetch-mw-oauth2] error while doing a background OAuth2 auto-refresh",e)}}),t-6e4))}}},212:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}var n={};return(()=>{"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.OAuth2Error=e.OAuth2Fetch=e.generateCodeVerifier=e.OAuth2AuthorizationCodeClient=e.OAuth2Client=void 0;var t=r(934);Object.defineProperty(e,"OAuth2Client",{enumerable:!0,get:function(){return t.OAuth2Client}});var i=r(618);Object.defineProperty(e,"OAuth2AuthorizationCodeClient",{enumerable:!0,get:function(){return i.OAuth2AuthorizationCodeClient}}),Object.defineProperty(e,"generateCodeVerifier",{enumerable:!0,get:function(){return i.generateCodeVerifier}});var o=r(13);Object.defineProperty(e,"OAuth2Fetch",{enumerable:!0,get:function(){return o.OAuth2Fetch}});var s=r(443);Object.defineProperty(e,"OAuth2Error",{enumerable:!0,get:function(){return s.OAuth2Error}})})(),n})(),e.exports=t()},187:function(e){"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}y(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function f(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function d(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function y(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){n.once&&e.removeEventListener(t,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)n(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},475:function(e){"use strict";var t=/^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i,r=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,n=/\s|\uFEFF|\xA0/,i=/\r?\n[\x20\x09]+/g,o=/[;,"]/,s=/[;,"]|\s/,a=/^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/;function c(e){return e.replace(r,"")}function u(e){return n.test(e)}function l(e,t){for(;u(e[t]);)t++;return t}function h(e){return s.test(e)||!a.test(e)}class f{constructor(e){this.refs=[],e&&this.parse(e)}rel(e){for(var t=[],r=e.toLowerCase(),n=0;n<this.refs.length;n++)this.refs[n].rel.toLowerCase()===r&&t.push(this.refs[n]);return t}get(e,t){e=e.toLowerCase();for(var r=[],n=0;n<this.refs.length;n++)this.refs[n][e]===t&&r.push(this.refs[n]);return r}set(e){return this.refs.push(e),this}setUnique(e){return this.refs.some((t=>{return r=t,n=e,Object.keys(r).length===Object.keys(n).length&&Object.keys(r).every((e=>e in n&&r[e]===n[e]));var r,n}))||this.refs.push(e),this}has(e,t){e=e.toLowerCase();for(var r=0;r<this.refs.length;r++)if(this.refs[r][e]===t)return!0;return!1}parse(e,t){for(var r=1,n=(e=c(e=(t=t||0)?e.slice(t):e).replace(i,"")).length,s=(t=0,null);t<n;)if(1===r){if(u(e[t])){t++;continue}if("<"!==e[t])throw new Error('Unexpected character "'+e[t]+'" at offset '+t);if(null!=s&&(null!=s.rel?this.refs.push(...f.expandRelations(s)):this.refs.push(s)),-1===(d=e.indexOf(">",t)))throw new Error("Expected end of URI delimiter at offset "+t);s={uri:e.slice(t+1,d)},t=d,r=2,t++}else if(2===r){if(u(e[t])){t++;continue}if(";"===e[t])r=4,t++;else{if(","!==e[t])throw new Error('Unexpected character "'+e[t]+'" at offset '+t);r=1,t++}}else{if(4!==r)throw new Error('Unknown parser state "'+r+'"');if(";"===e[t]||u(e[t])){t++;continue}-1===(d=e.indexOf("=",t))&&(d=e.indexOf(";",t)),-1===d&&(d=e.length);var a=c(e.slice(t,d)).toLowerCase(),h="";if('"'===e[t=l(e,t=d+1)])for(t++;t<n;){if('"'===e[t]){t++;break}"\\"===e[t]&&t++,h+=e[t],t++}else{for(var d=t+1;!o.test(e[d])&&d<n;)d++;h=e.slice(t,d),t=d}switch(s[a]&&f.isSingleOccurenceAttr(a)||("*"===a[a.length-1]?s[a]=f.parseExtendedValue(h):(h="type"===a?h.toLowerCase():h,null!=s[a]?Array.isArray(s[a])?s[a].push(h):s[a]=[s[a],h]:s[a]=h)),e[t]){case",":r=1;break;case";":r=4}t++}return null!=s&&(null!=s.rel?this.refs.push(...f.expandRelations(s)):this.refs.push(s)),s=null,this}toString(){for(var e=[],t="",r=null,n=0;n<this.refs.length;n++)r=this.refs[n],t=Object.keys(this.refs[n]).reduce((function(e,t){return"uri"===t?e:e+"; "+f.formatAttribute(t,r[t])}),"<"+r.uri+">"),e.push(t);return e.join(", ")}}f.isCompatibleEncoding=function(e){return t.test(e)},f.parse=function(e,t){return(new f).parse(e,t)},f.isSingleOccurenceAttr=function(e){return"rel"===e||"type"===e||"media"===e||"title"===e||"title*"===e},f.isTokenAttr=function(e){return"rel"===e||"type"===e||"anchor"===e},f.escapeQuotes=function(e){return e.replace(/"/g,'\\"')},f.expandRelations=function(e){return e.rel.split(" ").map((function(t){var r=Object.assign({},e);return r.rel=t,r}))},f.parseExtendedValue=function(e){var t=/([^']+)?(?:'([^']*)')?(.+)/.exec(e);return{language:t[2].toLowerCase(),encoding:f.isCompatibleEncoding(t[1])?null:t[1].toLowerCase(),value:f.isCompatibleEncoding(t[1])?decodeURIComponent(t[3]):t[3]}},f.formatExtendedAttribute=function(e,t){var r=(t.encoding||"utf-8").toUpperCase();return e+"="+r+"'"+(t.language||"en")+"'"+(Buffer.isBuffer(t.value)&&f.isCompatibleEncoding(r)?t.value.toString(r):Buffer.isBuffer(t.value)?t.value.toString("hex").replace(/[0-9a-f]{2}/gi,"%$1"):encodeURIComponent(t.value))},f.formatAttribute=function(e,t){return Array.isArray(t)?t.map((t=>f.formatAttribute(e,t))).join("; "):"*"===e[e.length-1]||"string"!=typeof t?f.formatExtendedAttribute(e,t):(f.isTokenAttr(e)?t=h(t)?'"'+f.escapeQuotes(t)+'"':f.escapeQuotes(t):h(t)&&(t='"'+(t=(t=encodeURIComponent(t)).replace(/%20/g," ").replace(/%2C/g,",").replace(/%3B/g,";"))+'"'),e+"="+t)},e.exports=f},129:function(e){e.exports=function(e){return e=e||/\W/g,function(t){return(t=String(t)).replace(e,(function(e){var t=e[0].charCodeAt(0),r=[];return t<128?r.push(t):128<=t&&t<2048?(r.push(t>>6|192),r.push(63&t|128)):(r.push(t>>12|224),r.push(t>>6&63|128),r.push(63&t|128)),r.map((function(e){return"%"+e.toString(16).toUpperCase()})).join("")}))}}},779:function(e,t,r){"use strict";var n=t,i=r(94).Buffer;function o(e,t){try{return decodeURIComponent(e)}catch(r){return n.unescapeBuffer(e,t).toString()}}n.unescapeBuffer=function(e,t){for(var r,n,o,s=new i(e.length),a=0,c=0,u=0;c<=e.length;c++){var l=c<e.length?e.charCodeAt(c):NaN;switch(a){case 0:switch(l){case 37:r=0,n=0,a=1;break;case 43:t&&(l=32);default:s[u++]=l}break;case 1:if(o=l,l>=48&&l<=57)r=l-48;else if(l>=65&&l<=70)r=l-65+10;else{if(!(l>=97&&l<=102)){s[u++]=37,s[u++]=l,a=0;break}r=l-97+10}a=2;break;case 2:if(a=0,l>=48&&l<=57)n=l-48;else if(l>=65&&l<=70)n=l-65+10;else{if(!(l>=97&&l<=102)){s[u++]=37,s[u++]=o,s[u++]=l;break}n=l-97+10}s[u++]=16*r+n}}return s.slice(0,u-1)},n.unescape=o;for(var s=new Array(256),a=0;a<256;++a)s[a]="%"+((a<16?"0":"")+a.toString(16)).toUpperCase();n.escape=function(e){"string"!=typeof e&&(e+="");for(var t="",r=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);if(!(33===i||45===i||46===i||95===i||126===i||i>=39&&i<=42||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122))if(n-r>0&&(t+=e.slice(r,n)),i<128)r=n+1,t+=s[i];else if(i<2048)r=n+1,t+=s[192|i>>6]+s[128|63&i];else if(i<55296||i>=57344)r=n+1,t+=s[224|i>>12]+s[128|i>>6&63]+s[128|63&i];else{var o;if(!(++n<e.length))throw new URIError("URI malformed");o=1023&e.charCodeAt(n),r=n+1,t+=s[240|(i=65536+((1023&i)<<10|o))>>18]+s[128|i>>12&63]+s[128|i>>6&63]+s[128|63&i]}}return 0===r?e:r<e.length?t+e.slice(r):t};var c=function(e){return"string"==typeof e?e:"number"==typeof e&&isFinite(e)?""+e:"boolean"==typeof e?e?"true":"false":""};function u(e,t){try{return t(e)}catch(t){return n.unescape(e,!0)}}n.stringify=n.encode=function(e,t,r,i){t=t||"&",r=r||"=";var o=n.escape;if(i&&"function"==typeof i.encodeURIComponent&&(o=i.encodeURIComponent),null!==e&&"object"==typeof e){for(var s=Object.keys(e),a=s.length,u=a-1,l="",h=0;h<a;++h){var f=s[h],d=e[f],p=o(c(f))+r;if(Array.isArray(d)){for(var y=d.length,v=y-1,g=0;g<y;++g)l+=p+o(c(d[g])),g<v&&(l+=t);y&&h<u&&(l+=t)}else l+=p+o(c(d)),h<u&&(l+=t)}return l}return""},n.parse=n.decode=function(e,t,r,i){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;"string"!=typeof t&&(t+="");var a=r.length,c=t.length,l=1e3;i&&"number"==typeof i.maxKeys&&(l=i.maxKeys);var h=1/0;l>0&&(h=l);var f=n.unescape;i&&"function"==typeof i.decodeURIComponent&&(f=i.decodeURIComponent);for(var d=f!==o,p=[],y=0,v=0,g=0,m="",w="",b=d,k=d,O=0,S=0;S<e.length;++S){var _=e.charCodeAt(S);if(_!==t.charCodeAt(v)){if(v=0,k||(37===_?O=1:O>0&&(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)?3==++O&&(k=!0):O=0),g<a){if(_===r.charCodeAt(g)){++g===a&&(y<(x=S-g+1)&&(m+=e.slice(y,x)),O=0,y=S+1);continue}g=0,b||(37===_?O=1:O>0&&(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)?3==++O&&(b=!0):O=0)}43===_&&(g<a?(S-y>0&&(m+=e.slice(y,S)),m+="%20",b=!0):(S-y>0&&(w+=e.slice(y,S)),w+="%20",k=!0),y=S+1)}else if(++v===c){var A,x=S-v+1;if(g<a?y<x&&(m+=e.slice(y,x)):y<x&&(w+=e.slice(y,x)),b&&(m=u(m,f)),k&&(w=u(w,f)),-1===p.indexOf(m)?(s[m]=w,p[p.length]=m):(A=s[m])instanceof Array?A[A.length]=w:s[m]=[A,w],0==--h)break;b=k=d,O=0,m=w="",y=S+1,v=g=0}}return h>0&&(y<e.length||g>0)&&(y<e.length&&(g<a?m+=e.slice(y):v<c&&(w+=e.slice(y))),b&&(m=u(m,f)),k&&(w=u(w,f)),-1===p.indexOf(m)?(s[m]=w,p[p.length]=m):(A=s[m])instanceof Array?A[A.length]=w:s[m]=[A,w]),s}},34:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionNotFound=t.SimpleAction=void 0;const n=r(779);t.SimpleAction=class{constructor(e,t){this.client=e;for(const[e,r]of Object.entries(t))this[e]=r}async submit(e){const t=new URL(this.uri),r={...e};for(const t of this.fields)if(!(t.name in e))if(t.value)r[t.name]=t.value;else if(t.required)throw new Error(`The ${t.name} field is required in this form`);if("GET"===this.method)return t.search=n.stringify(r),this.client.go(t.toString()).get();let i;switch(this.contentType){case"application/x-www-form-urlencoded":i=n.stringify(r);break;case"application/json":i=JSON.stringify(r);break;default:throw new Error(`Serializing mimetype ${this.contentType} is not yet supported in actions`)}const o=await this.client.fetcher.fetchOrThrow(t.toString(),{method:this.method,body:i,headers:{"Content-Type":this.contentType}});return this.client.getStateForResponse(t.toString(),o)}};class i extends Error{}t.ActionNotFound=i},651:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ForeverCache=void 0,t.ForeverCache=class{constructor(){this.cache=new Map}store(e){this.cache.set(e.uri,e.clone())}get(e){const t=this.cache.get(e);return t?t.clone():null}has(e){return this.cache.has(e)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}}},689:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NeverCache=t.ShortCache=t.ForeverCache=void 0;var n=r(651);Object.defineProperty(t,"ForeverCache",{enumerable:!0,get:function(){return n.ForeverCache}});var i=r(478);Object.defineProperty(t,"ShortCache",{enumerable:!0,get:function(){return i.ShortCache}});var o=r(575);Object.defineProperty(t,"NeverCache",{enumerable:!0,get:function(){return o.NeverCache}})},575:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NeverCache=void 0,t.NeverCache=class{store(e){}get(e){return null}has(e){return!1}delete(e){}clear(){}}},478:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCache=void 0;const n=r(651);class i extends n.ForeverCache{constructor(e=3e4){super(),this.cacheTimeout=e,this.activeTimers=new Map}store(e){super.store(e),this.setTimer(e.uri)}setTimer(e){this.activeTimers.has(e)&&clearTimeout(this.activeTimers.get(e)),this.activeTimers.set(e,setTimeout((()=>{this.delete(e),this.activeTimers.delete(e)}),this.cacheTimeout))}}t.ShortCache=i},934:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(66),i=r(871),o=r(24),s=r(963),a=r(458),c=r(689),u=r(549),l=r(736),h=r(941);function f(e,t,r){r||(r=new Set);for(const n of e)r.has(n)||(r.add(n),t.has(n)&&f(t.get(n),t,r));return r}function d(e,t=new Set){t.add(e);for(const r of e.getEmbedded())d(r,t);return t}t.default=class{constructor(e){this.contentTypeMap={"application/prs.hal-forms+json":[o.halStateFactory,"1.0"],"application/hal+json":[o.halStateFactory,"0.9"],"application/vnd.api+json":[o.jsonApiStateFactory,"0.8"],"application/vnd.siren+json":[o.sirenStateFactory,"0.8"],"application/vnd.collection+json":[o.cjStateFactory,"0.8"],"application/json":[o.halStateFactory,"0.7"],"text/html":[o.htmlStateFactory,"0.6"]},this.cacheDependencies=new Map,this.bookmarkUri=e,this.fetcher=new n.Fetcher,this.fetcher.use((0,u.default)(this)),this.fetcher.use((0,l.default)(this)),this.fetcher.use((0,h.default)()),this.cache=new c.ForeverCache,this.resources=new Map}follow(e,t){return this.go().follow(e,t)}go(e){let t;if(t=void 0===e?this.bookmarkUri:"string"==typeof e?(0,a.resolve)(this.bookmarkUri,e):(0,a.resolve)(e),!this.resources.has(t)){const e=new i.default(this,t);return this.resources.set(t,e),e}return this.resources.get(t)}use(e,t="*"){this.fetcher.use(e,t)}clearCache(){this.cache.clear(),this.cacheDependencies=new Map}cacheState(e){const t=d(e);for(const e of t)for(const t of e.links.getMany("inv-by"))this.addCacheDependency((0,a.resolve)(t),e.uri);for(const e of t)this.cache.store(e);for(const e of t){const t=this.resources.get(e.uri);t&&t.emit("update",e)}}addCacheDependency(e,t){this.cacheDependencies.has(e)?this.cacheDependencies.get(e).add(t):this.cacheDependencies.set(e,new Set([t]))}clearResourceCache(e,t){let r=new Set;const n=new Set;for(const t of e)r.add((0,a.resolve)(this.bookmarkUri,t));for(const e of t)r.add((0,a.resolve)(this.bookmarkUri,e)),n.add((0,a.resolve)(this.bookmarkUri,e));r=f(new Set([...r,...n]),this.cacheDependencies);for(const e of r){this.cache.delete(e);const t=this.resources.get(e);t&&(n.has(e)?t.emit("delete"):t.emit("stale"))}}async getStateForResponse(e,t){const r=(0,s.parseContentType)(t.headers.get("Content-Type"));return r&&204!==t.status?r in this.contentTypeMap?this.contentTypeMap[r][0](this,e,t):r.startsWith("text/")?(0,o.textStateFactory)(this,e,t):r.match(/^application\/[A-Za-z-.]+\+json/)?(0,o.halStateFactory)(this,e,t):(0,o.binaryStateFactory)(this,e,t):(0,o.binaryStateFactory)(this,e,t)}}},761:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FollowPromiseMany=t.FollowPromiseOne=void 0;class r{constructor(){this.prefetchEnabled=!1,this.preferTranscludeEnabled=!1,this.useHeadEnabled=!1}preFetch(){return this.prefetchEnabled=!0,this}preferTransclude(){return this.preferTranscludeEnabled=!0,this}useHead(){return this.useHeadEnabled=!0,this}}class n extends r{constructor(e,t,r){super(),this.resource=e,this.rel=t,this.variables=r}then(e,t){return this.fetchLinkedResource().then(e,t)}catch(e){return this.fetchLinkedResource().then(void 0,e)}finally(e){return this.then((()=>e()),(()=>e()))}follow(e,t){return new n(this.fetchLinkedResource(),e,t)}followAll(e){return new i(this.fetchLinkedResource(),e)}async fetchLinkedResource(){const e=await this.resource,t={};let r;!this.useHeadEnabled&&this.preferTranscludeEnabled&&(t.Prefer="transclude="+this.rel),r=this.useHeadEnabled?await e.head({headers:t}):await e.get({headers:t});const n=r.follow(this.rel,this.variables);return this.prefetchEnabled&&n.get().catch((e=>{console.warn("Error while prefetching linked resource",e)})),n}}t.FollowPromiseOne=n;class i extends r{constructor(e,t){super(),this.resource=e,this.rel=t}then(e,t){return this.fetchLinkedResources().then(e,t)}catch(e){return this.fetchLinkedResources().then(void 0,e)}finally(e){return this.then((()=>e()),(()=>e()))}async fetchLinkedResources(){const e=await this.resource,t={};let r;!this.useHeadEnabled&&this.preferTranscludeEnabled&&(t.Prefer="transclude="+this.rel),r=this.useHeadEnabled?await e.head({headers:t}):await e.get({headers:t});const n=r.followAll(this.rel);return this.prefetchEnabled&&n.map((e=>{e.get().catch((e=>{console.warn("Error while prefetching linked resource",e)}))})),n}}t.FollowPromiseMany=i},530:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=(e,t)=>{const r="Basic "+btoa(e+":"+t);return(e,t)=>(e.headers.set("Authorization",r),t(e))}},409:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=e=>{const t="Bearer "+e;return(e,r)=>(e.headers.set("Authorization",t),r(e))}},682:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Problem=t.HttpError=void 0;class r extends Error{constructor(e){super("HTTP error "+e.status),this.response=e,this.status=e.status}}t.HttpError=r;class n extends r{constructor(e,t){super(e),this.body={type:t.type??"about:blank",status:t.status??this.status,...t},this.body.title&&(this.message="HTTP Error "+this.status+": "+this.body.title)}}t.Problem=n,t.default=async function(e){const t=e.headers.get("Content-Type");if(t?.match(/^application\/problem\+json/i)){const t=await e.json();return new n(e,t)}return new r(e)}},66:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetcher=void 0;const n=r(682);class i{constructor(){this.middlewares=[],this.advertiseKetting=!0}fetch(e,t){const n=new Request(e,t),i=new URL(n.url).origin,s=this.getMiddlewaresByOrigin(i);return s.push((e=>(!e.headers.has("User-Agent")&&this.advertiseKetting&&e.headers.set("User-Agent","Ketting/"+r(147).i8),fetch(e)))),o(s,n)}getMiddlewaresByOrigin(e){return this.middlewares.filter((([t])=>t.test(e))).map((([,e])=>e))}use(e,t="*"){const r=t.split("*").map((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).join("(.*)"),n=new RegExp("^"+r+"$");this.middlewares.push([n,e])}async fetchOrThrow(e,t){const r=await this.fetch(e,t);if(r.ok)return r;throw await(0,n.default)(r)}}function o(e,t){return e[0](t,(t=>o(e.slice(1),t)))}t.Fetcher=i,t.default=i},686:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(880);t.default=function(e,t){console.warn("The OAuth2 middleware in Ketting is deprecated, and will be removed in the next major version of Ketting. You should upgrade to the OAuth2Fetch from the @badgateway/oauth2-client project");const r={clientId:e.clientId,clientSecret:"clientSecret"in e?e.clientSecret:void 0,tokenEndpoint:e.tokenEndpoint},i=new n.OAuth2Client(r);return new n.OAuth2Fetch({client:i,getNewToken:async()=>{switch(e.grantType){case"password":return i.password({username:e.userName,password:e.password,scope:e.scope});case"client_credentials":return i.clientCredentials({scope:e.scope});case"authorization_code":return i.authorizationCode.getToken({code:e.code,codeVerifier:e.codeVerifier,redirectUri:e.redirectUri});case void 0:return null}},getStoredToken:()=>t??null,storeToken:t=>{e.onTokenUpdate&&e.onTokenUpdate(t)},onError:t=>{e.onAuthError&&e.onAuthError(t)}}).mw()}},963:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.entityHeaderNames=t.isSafeMethod=t.parseLink=t.parseContentType=void 0;const n=r(475),i=r(173);t.parseContentType=function(e){return e?(e.includes(";")&&(e=e.split(";")[0]),e.trim()):null},t.parseLink=function(e,t){const r=new i.Links(e);if(!t)return r;for(const i of n.parse(t).refs)for(const t of i.rel.split(" ")){const n={rel:t,href:i.uri,context:e,title:i.title,hreflang:i.hreflang,type:i.type};r.add(n)}return r};const o=["GET","HEAD","OPTIONS","PRI","PROPFIND","REPORT","SEARCH","TRACE"];t.isSafeMethod=function(e){return o.includes(e)},t.entityHeaderNames=["Content-Type","Content-Language","Content-Location","Deprecation","ETag","Expires","Last-Modified","Sunset","Title","Warning"]},173:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LinkNotFound=t.Links=void 0;const n=r(458);class i{constructor(e,t){if(this.defaultContext=e,this.store=new Map,t)if(t instanceof i)this.add(...t.getAll());else for(const e of t)this.add(e)}add(...e){let t;t="string"==typeof e[0]?[{rel:e[0],href:e[1],context:this.defaultContext}]:e.map((e=>({context:this.defaultContext,...e})));for(const e of t)this.store.has(e.rel)?this.store.get(e.rel).push(e):this.store.set(e.rel,[e])}set(e,t){let r;r="string"==typeof e?{rel:e,href:t,context:this.defaultContext}:{context:this.defaultContext,...e},this.store.set(r.rel,[r])}get(e){const t=this.store.get(e);if(t&&!(t.length<0))return t[0]}delete(e,t){if(void 0===t)return void this.store.delete(e);const r=this.store.get(e);if(!r)return;this.store.delete(e);const i=(0,n.resolve)(this.defaultContext,t);this.store.set(e,r.filter((e=>(0,n.resolve)(e)!==i)))}getMany(e){return this.store.get(e)||[]}getAll(){const e=[];for(const t of this.store.values())e.push(...t);return e}has(e){return this.store.has(e)}}t.Links=i;class o extends Error{}t.LinkNotFound=o},736:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return async(t,r)=>{if(!t.headers.has("Accept")){const r=Object.entries(e.contentTypeMap).map((([e,[,t]])=>e+";q="+t)).join(", ");t.headers.set("Accept",r)}return r(t)}}},549:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(963),i=r(475),o=r(458);t.default=function(e){return async(t,r)=>{let s=!1;t.headers.has("X-KETTING-NO-STALE")&&(s=!0,t.headers.delete("X-KETTING-NO-STALE"));const a=await r(t);if((0,n.isSafeMethod)(t.method))return a;if(!a.ok)return a;const c=[],u=[];if("DELETE"===t.method?u.push(t.url):s||c.push(t.url),a.headers.has("Link"))for(const e of i.parse(a.headers.get("Link")).rel("invalidates")){const r=(0,o.resolve)(t.url,e.uri);c.push(r)}if(a.headers.has("Location")&&c.push((0,o.resolve)(t.url,a.headers.get("Location"))),e.clearResourceCache(c,u),"no-store"!==t.cache&&a.headers.has("Content-Location")){const r=(0,o.resolve)(t.url,a.headers.get("Content-Location")),n=await e.getStateForResponse(r,a.clone());e.cacheState(n)}return a}}},941:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(475),i=r(458);t.default=function(){return async(e,t)=>{const r=await t(e);if(r.headers.get("Deprecation")){const t=r.headers.get("Sunset");let o=`[Ketting] The resource ${e.url} is deprecated.`;if(t&&(o+=" It will no longer respond "+t),r.headers.has("Link"))for(const t of n.parse(r.headers.get("Link")).rel("deprecation"))o+=`See ${(0,i.resolve)(e.url,t.uri)} for more information.`;console.warn(o)}return r}}},871:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Resource=void 0;const n=r(24),i=r(458),o=r(761),s=r(173),a=r(187),c=r(595);class u extends a.EventEmitter{constructor(e,t){super(),this.activeRefresh=new Map,this.client=e,this.uri=t,this.setMaxListeners(500)}get(e){const t=this.getCache();if(t)return Promise.resolve(t);const r=l("GET",e),n=this.uri,i=h(this.uri,e);return this.activeRefresh.has(i)||this.activeRefresh.set(i,(async()=>{try{const e=await this.fetchOrThrow(r),t=await this.client.getStateForResponse(n,e);return this.updateCache(t),t}finally{this.activeRefresh.delete(i)}})()),this.activeRefresh.get(i)}async head(e){let t=this.client.cache.get(this.uri);if(t)return t;const r=await this.fetchOrThrow(l("HEAD",e));return t=await(0,n.headStateFactory)(this.client,this.uri,r),t}refresh(e){const t=l("GET",e);t.cache="no-cache";const r=this.uri,n=h(this.uri,e);return this.activeRefresh.has(n)||this.activeRefresh.set(n,(async()=>{try{const e=await this.fetchOrThrow(t),n=await this.client.getStateForResponse(r,e);return this.updateCache(n),n}finally{this.activeRefresh.delete(n)}})()),this.activeRefresh.get(n)}async put(e){const t=l("PUT",e);(0,n.isState)(e)&&t.headers.set("X-KETTING-NO-STALE","1"),await this.fetchOrThrow(t),(0,n.isState)(e)&&this.updateCache(e)}async delete(){await this.fetchOrThrow({method:"DELETE"})}async post(e){const t=await this.fetchOrThrow(l("POST",e));return this.client.getStateForResponse(this.uri,t)}async postFollow(e){const t=await this.fetchOrThrow(l("POST",e));switch(t.status){case 201:if(t.headers.has("location"))return this.go(t.headers.get("location"));throw new Error('Could not follow after a 201 request, because the server did not reply with a Location header. If you sent a Location header, check if your service is returning "Access-Control-Expose-Headers: Location".');case 204:case 205:return this;default:throw new Error("Did not receive a 201, 204 or 205 status code so we could not follow to the next resource")}}async patch(e){const t=await this.fetchOrThrow(l("PATCH",e));if(200===t.status)return await this.client.getStateForResponse(this.uri,t)}follow(e,t){return new o.FollowPromiseOne(this,e,t)}followAll(e){return new o.FollowPromiseMany(this,e)}go(e){return"string"==typeof e?this.client.go((0,i.resolve)(this.uri,e)):this.client.go(e)}fetch(e){return this.client.fetcher.fetch(this.uri,e)}fetchOrThrow(e){return this.client.fetcher.fetchOrThrow(this.uri,e)}updateCache(e){if(e.uri!==this.uri)throw new Error("When calling updateCache on a resource, the uri of the State object must match the uri of the Resource");this.client.cacheState(e)}clearCache(){this.client.clearResourceCache([this.uri],[])}getCache(){return this.client.cache.get(this.uri)}async link(e){const t=(await this.get()).links.get(e);if(!t)throw new s.LinkNotFound(`Link with rel: ${e} not found on ${this.uri}`);return t}async links(e){const t=await this.get();return e?t.links.getMany(e):t.links.getAll()}async hasLink(e){return(await this.get()).links.has(e)}}function l(e,t){if(!t)return{method:e,headers:new Headers};let r,n;return r=t.getContentHeaders?new Headers(t.getContentHeaders()):t.headers?new Headers(t.headers):new Headers,r.has("Content-Type")||r.set("Content-Type","application/json"),void 0!==t.serializeBody?n=t.serializeBody():t.data?(n=t.data,(0,c.needsJsonStringify)(n)&&(n=JSON.stringify(n))):n=null,{method:e,body:n,headers:r}}function h(e,t){const r={};return t&&new Headers(t.getContentHeaders?.()||t.headers).forEach(((e,t)=>{r[t]=e})),e+"|"+Object.entries(r).map((([e,t])=>e.toLowerCase()+":"+t)).join(",")}t.Resource=u,t.default=u},0:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseState=t.BaseHeadState=void 0;const n=r(173),i=r(34),o=r(458),s=r(640),a=r(963);class c{constructor(e){this.client=e.client,this.uri=e.uri,this.headers=e.headers,this.timestamp=Date.now(),this.links=e.links}follow(e,t){const r=this.links.get(e);if(!r)throw new n.LinkNotFound(`Link with rel ${e} on ${this.uri} not found`);let i;return i=r.templated?(0,s.expand)(r,t||{}):(0,o.resolve)(r),"deprecated"===r.hints?.status&&console.warn(`[ketting] The ${r.rel} link on ${this.uri} is marked deprecated.`,r),this.client.go(i)}followAll(e){return this.links.getMany(e).map((e=>{"deprecated"===e.hints?.status&&console.warn(`[ketting] The ${e.rel} link on ${this.uri} is marked deprecated.`,e);const t=(0,o.resolve)(e);return this.client.go(t)}))}contentHeaders(){const e={};for(const t of a.entityHeaderNames)this.headers.has(t)&&(e[t]=this.headers.get(t));return new Headers(e)}}t.BaseHeadState=c;class u extends c{constructor(e){super(e),this.data=e.data,this.actionInfo=e.actions||[],this.embedded=e.embedded||[]}action(e){if(!this.actionInfo.length)throw new i.ActionNotFound("This State does not define any actions");if(void 0===e)return new i.SimpleAction(this.client,this.actionInfo[0]);for(const t of this.actionInfo)if(t.name===e)return new i.SimpleAction(this.client,t);throw new i.ActionNotFound("This State defines no action")}actions(){return this.actionInfo.map((e=>new i.SimpleAction(this.client,e)))}hasAction(e){if(void 0===e)return this.actionInfo.length>0;for(const t of this.actionInfo)if(e===t.name)return!0;return!1}serializeBody(){return r.g.Buffer&&this.data instanceof Buffer||r.g.Blob&&this.data instanceof Blob||"string"==typeof this.data?this.data:JSON.stringify(this.data)}getEmbedded(){return this.embedded}clone(){return new u({client:this.client,uri:this.uri,data:this.data,headers:new Headers(this.headers),links:new n.Links(this.links.defaultContext,this.links.getAll()),actions:this.actionInfo})}}t.BaseState=u},909:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);t.factory=async(e,t,r)=>new n.BaseState({client:e,uri:t,data:await r.blob(),headers:r.headers,links:(0,i.parseLink)(t,r.headers.get("Link"))})},287:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=t.CjState=void 0;const n=r(0),i=r(963);class o extends n.BaseState{serializeBody(){throw new Error("Reserializing Collection+JSON states is not yet supported. Please log an issue in the Ketting project to help figure out how this should be done")}}t.CjState=o,t.factory=async(e,t,r)=>{const n=await r.json(),s=(0,i.parseLink)(t,r.headers.get("Link"));s.add(...function(e,t){const r=[];if(void 0!==t.collection.links)for(const n of t.collection.links)r.push({context:e,href:n.href,rel:n.rel,title:n.name});if(void 0!==t.collection.items)for(const n of t.collection.items)n.href&&r.push({context:e,href:n.href,rel:"item"});if(void 0!==t.collection.queries)for(const n of t.collection.queries)n.data?r.push({context:e,href:n.href+n.data.map((e=>"{?"+e.name+"}")).join(""),templated:!0,rel:n.rel,title:n.name}):r.push({context:e,href:n.href,rel:n.rel,title:n.name});return r}(t,n));const{_embedded:a,_links:c,...u}=n;return new o({client:e,uri:t,data:u,headers:r.headers,links:s})}},842:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=t.HalState=void 0;const n=r(0),i=r(963),o=r(173),s=r(458);class a extends n.BaseState{serializeBody(){return JSON.stringify({_links:this.serializeLinks(),...this.data})}serializeLinks(){const e={self:{href:this.uri}};for(const t of this.links.getAll()){const{rel:r,context:n,...i}=t;"self"!==r&&(void 0===e[r]?e[r]=i:Array.isArray(e[r])?e[r].push(i):e[r]=[e[r],i])}return e}clone(){return new a({client:this.client,uri:this.uri,data:this.data,headers:new Headers(this.headers),links:new o.Links(this.links.defaultContext,this.links.getAll()),actions:this.actionInfo})}}function c(e,t){if(void 0===t._links)return[];const r=[],n=new Set;for(const[i,o]of Object.entries(t._links)){const t=Array.isArray(o)?o:[o];for(const e of t)n.add(i+";"+e.href);r.push(...u(e,i,t))}if(t._embedded)for(let[i,o]of Object.entries(t._embedded)){Array.isArray(o)||(o=[o]);for(const t of o){const o=t?._links?.self?.href;o&&(n.has(i+";"+o)||r.push({rel:i,href:o,context:e}))}}return r}function u(e,t,r){const n=[];for(const i of r)n.push({rel:t,context:e,...i});return n}function l(e,t,r,n){if(void 0===r._embedded||!r._embedded)return[];const i=[];for(const u of Object.values(r._embedded)){let r;r=Array.isArray(u)?u:[u];for(const u of r){if(void 0===u._links?.self?.href){console.warn('An item in _embedded was ignored. Each item must have a single "self" link');continue}const r=(0,s.resolve)(t,u._links.self.href),{_embedded:f,_links:d,...p}=u;i.push(new a({client:e,uri:r,data:p,headers:new Headers({"Content-Type":n.get("Content-Type")}),links:new o.Links(r,c(t,u)),embedded:l(e,r,u,n),actions:h(r,u)}))}}return i}function h(e,t){return t._templates?Object.entries(t._templates).map((([t,r])=>({uri:(0,s.resolve)(e,r.target||""),name:t,title:r.title,method:r.method,contentType:r.contentType||"application/json",fields:r.properties?r.properties.map((e=>function(e){switch(e.type){case void 0:case"text":case"search":case"tel":case"url":case"email":if(e.options){const t={name:e.name,type:"select",label:e.prompt,required:e.required||!1,readOnly:e.readOnly||!1,multiple:e.options.multiple,value:e.options.selectedValues||e.value},r=e.options.promptField||"prompt",n=e.options.valueField||"value";if(void 0!==e.options.inline){const i={};for(const t of e.options.inline)"string"==typeof t?i[t]=t:i[t[n]]=t[r];return{...t,options:i}}return{...t,dataSource:{href:e.options.link.href,type:e.options.link.type,labelField:r,valueField:n}}}return{name:e.name,type:e.type??"text",required:e.required||!1,readOnly:e.readOnly||!1,value:e.value,pattern:e.regex?new RegExp(e.regex):void 0,label:e.prompt,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength};case"hidden":return{name:e.name,type:"hidden",required:e.required||!1,readOnly:e.readOnly||!1,value:e.value,label:e.prompt,placeholder:e.placeholder};case"textarea":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,value:e.value,label:e.prompt,placeholder:e.placeholder,cols:e.cols,rows:e.rows,minLength:e.minLength,maxLength:e.maxLength};case"password":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength};case"date":case"month":case"week":case"time":return{name:e.name,type:e.type,value:e.value,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,min:e.min,max:e.max,step:e.step};case"number":case"range":return{name:e.name,type:e.type,value:e.value?+e.value:void 0,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,min:e.min,max:e.max,step:e.step};case"datetime-local":return{name:e.name,type:e.type,value:e.value?new Date(e.value):void 0,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,min:e.min,max:e.max,step:e.step};case"color":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,value:e.value};case"radio":case"checkbox":return{name:e.name,type:e.type,required:e.required||!1,readOnly:e.readOnly||!1,label:e.prompt,value:!!e.value}}}(e))):[]}))):[]}t.HalState=a,t.factory=async(e,t,r)=>{const n=await r.json(),o=(0,i.parseLink)(t,r.headers.get("Link"));if(Array.isArray(n))return new a({client:e,uri:t,data:n,headers:r.headers,links:o});o.add(...c(t,n));const{_embedded:s,_links:u,_templates:f,...d}=n;return new a({client:e,uri:t,data:d,headers:r.headers,links:o,embedded:l(e,t,n,r.headers),actions:h(t,n)})}},770:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);t.factory=async(e,t,r)=>{const o=(0,i.parseLink)(t,r.headers.get("Link"));return new n.BaseHeadState({client:e,uri:t,headers:r.headers,links:o})}},154:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963),o=r(730),s=r(458);t.factory=async(e,t,r)=>{const a=await r.text(),c=(0,i.parseLink)(t,r.headers.get("Link")),u=(0,o.parseHtml)(t,a);return c.add(...u.links),new n.BaseState({client:e,uri:t,data:a,headers:r.headers,links:c,actions:u.forms.map((e=>function(e,t){return{uri:(0,s.resolve)(e,t.action),name:t.rel||t.id||"",method:t.method||"GET",contentType:t.enctype||"application/x-www-form-urlencoded",fields:[]}}(t,e)))})}},24:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.headStateFactory=t.htmlStateFactory=t.CjState=t.cjStateFactory=t.textStateFactory=t.SirenState=t.sirenStateFactory=t.jsonApiStateFactory=t.binaryStateFactory=t.HalState=t.halStateFactory=t.BaseHeadState=t.BaseState=t.isState=void 0;var n=r(269);Object.defineProperty(t,"isState",{enumerable:!0,get:function(){return n.isState}});var i=r(0);Object.defineProperty(t,"BaseState",{enumerable:!0,get:function(){return i.BaseState}}),Object.defineProperty(t,"BaseHeadState",{enumerable:!0,get:function(){return i.BaseHeadState}});var o=r(842);Object.defineProperty(t,"halStateFactory",{enumerable:!0,get:function(){return o.factory}}),Object.defineProperty(t,"HalState",{enumerable:!0,get:function(){return o.HalState}});var s=r(909);Object.defineProperty(t,"binaryStateFactory",{enumerable:!0,get:function(){return s.factory}});var a=r(60);Object.defineProperty(t,"jsonApiStateFactory",{enumerable:!0,get:function(){return a.factory}});var c=r(389);Object.defineProperty(t,"sirenStateFactory",{enumerable:!0,get:function(){return c.factory}}),Object.defineProperty(t,"SirenState",{enumerable:!0,get:function(){return c.SirenState}});var u=r(945);Object.defineProperty(t,"textStateFactory",{enumerable:!0,get:function(){return u.factory}});var l=r(287);Object.defineProperty(t,"cjStateFactory",{enumerable:!0,get:function(){return l.factory}}),Object.defineProperty(t,"CjState",{enumerable:!0,get:function(){return l.CjState}});var h=r(154);Object.defineProperty(t,"htmlStateFactory",{enumerable:!0,get:function(){return h.factory}});var f=r(770);Object.defineProperty(t,"headStateFactory",{enumerable:!0,get:function(){return f.factory}})},269:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isState=void 0;const n=r(173);t.isState=function(e){return"string"==typeof e.uri&&e.links instanceof n.Links&&e.headers instanceof Headers}},60:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);function o(e,t,r){return{context:e,rel:t,href:"string"==typeof r?r:r.href}}t.factory=async(e,t,r)=>{const s=await r.json(),a=(0,i.parseLink)(t,r.headers.get("Link"));return a.add(...function(e,t){const r=[];if(void 0===t.links)return r;for(const[n,i]of Object.entries(t.links))Array.isArray(i)?r.push(...i.map((t=>o(e,n,t)))):r.push(o(e,n,i));return r}(t,s),...function(e,t){if(!Array.isArray(t.data))return[];const r=[];for(const n of t.data)if("links"in n&&"self"in n.links){const t=o(e,"self",n.links.self);r.push({context:e,href:t.href,rel:"item"})}return r}(t,s)),new n.BaseState({client:e,uri:t,data:s,headers:r.headers,links:a})}},389:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=t.SirenState=void 0;const n=r(0),i=r(963),o=r(173),s=r(458);class a extends n.BaseState{serializeBody(){throw new Error("Reserializing Siren states is not yet supported. Please log an issue in the Ketting project to help figure out how this should be done")}clone(){return new a({client:this.client,uri:this.uri,data:this.data,headers:new Headers(this.headers),links:new o.Links(this.uri,this.links),actions:this.actionInfo})}}function c(e,t){const r=[];if(void 0!==t.links)for(const n of t.links)r.push(...u(e,n));if(void 0!==t.entities)for(const n of t.entities)void 0!==n.href?r.push(...u(e,n)):r.push(...h(e,n));return r}function u(e,t){const r=[],{rel:n,...i}=t;for(const t of n){const n={rel:t,context:e,...i};r.push(n)}return r}function l(e,t,r,n){if(void 0===r.entities)return[];const i=[];for(const o of r.entities)if(void 0===o.href){const r=f(e,t,o,n);null!==r&&i.push(r)}return i}function h(e,t){if(void 0===t.links)return[];let r=null;for(const e of t.links)e.rel.includes("self")&&(r=e.href);return null===r?[]:t.rel.map((n=>{const i=t.title,o={href:r,rel:n,context:e};return i&&(o.title=i),o}))}function f(e,t,r,n){if(void 0===r.links)return null;let i=null;for(const e of r.links)e.rel.includes("self")&&(i=e.href);if(!i)return null;const u=(0,s.resolve)(t,i);return new a({client:e,uri:u,data:r.properties,headers:n,links:new o.Links(i,c(i,r))})}t.SirenState=a,t.factory=async(e,t,r)=>{const n=await r.json(),o=(0,i.parseLink)(t,r.headers.get("Link"));return o.add(...c(t,n)),new a({client:e,uri:t,data:n.properties,headers:r.headers,links:o,embedded:l(e,t,n,r.headers),actions:n.actions?n.actions.map((e=>function(e,t){return{uri:(0,s.resolve)(e,t.href),name:t.name,title:t.title,method:t.method||"GET",contentType:t.type||"application/x-www-form-urlencoded",fields:t.fields?t.fields.map((e=>function(e){const t={name:e.name,type:e.type||"text",required:!1,readOnly:!1};return e.value&&(t.value=e.value),e.title&&(t.label=e.title),t}(e))):[]}}(t,e))):[]})}},945:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.factory=void 0;const n=r(0),i=r(963);t.factory=async(e,t,r)=>new n.BaseState({client:e,uri:t,data:await r.text(),headers:r.headers,links:(0,i.parseLink)(t,r.headers.get("Link"))})},595:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.needsJsonStringify=void 0,t.needsJsonStringify=function(e){return"string"!=typeof e&&!(e instanceof Blob)}},730:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseHtml=void 0;const n=r(458);function i(e,t){const r=[];for(const n of t){const t=n.getAttribute("rel"),i=n.getAttribute("href"),o=n.getAttribute("type")||void 0;if(t&&i)for(const n of t.split(" ")){const t={rel:n,context:e,href:i};o&&(t.type=o),r.push(t)}}return r}function o(e,t){const r=[];for(const i of t){const t=i.getAttribute("rel"),o=i.getAttribute("action"),s=i.getAttribute("enctype")||"application/x-www-form-urlencoded",a=i.getAttribute("id"),c=i.getAttribute("method")||"GET";if(t)for(const i of t.split(" ")){const t={rel:i,action:(0,n.resolve)(e,o),enctype:s,id:a,method:c};r.push(t)}else r.push({rel:null,action:(0,n.resolve)(e,o),enctype:s,id:a,method:c})}return r}t.parseHtml=function(e,t){const r=(new DOMParser).parseFromString(t,"text/html");return{forms:o(e,r.getElementsByTagName("form")),links:[...i(e,r.getElementsByTagName("link")),...i(e,r.getElementsByTagName("a"))]}}},640:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.expand=void 0;const n=r(493),i=r(458);t.expand=function(e,t,r){let o,s,a;"string"==typeof e?(o=e,s=t,a=r):(o=e.context,s=e.href,a=t);const c=n.parse(s).expand(a);return(0,i.resolve)(o,c)}},458:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=t.resolve=void 0,t.resolve=function(e,t){let r,n;"string"==typeof e?(r=e,n=t):(r=e.context,n=e.href);const i=new URL(n,new URL(r,"http://ketting.invalid"));return"ketting.invalid"===i.hostname?i.pathname+i.search+i.hash:r.startsWith("//")?"//"+i.host+i.pathname+i.search+i.hash:i.toString()},t.parse=function(e){const t=new URL(e,"http://ketting.invalid");return"ketting.invalid"===t.hostname?{host:null}:{host:t.host}}},9:function(e,t){"use strict";t.__esModule=!0,t.toString=void 0,t.toString=function e(t){var r,n;switch(t.type){case"template":return t.parts.map(e).join("");case"literal":return t.value;case"expression":return"{"+t.operator+t.variables.map(e).join(",")+"}";case"variable":var i=t.name;return"explode"==(null===(r=t.modifier)||void 0===r?void 0:r.type)?i+="*":"substr"==(null===(n=t.modifier)||void 0===n?void 0:n.type)&&(i+=":"+t.modifier.length),t.extension&&(i+="("+t.extension+")"),i}}},644:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0,t.expandExpression=t.expandTemplate=void 0;var o=i(r(129)),s={UrlSafe:(0,o.default)(/[^\w~.-]/g),Restricted:(0,o.default)(/[^\w.~:\/\?#\[\]@!\$&'()*+,;=%-]|%(?!\d\d)/g)};t.expandTemplate=function(e,t){return e.parts.map((function(e){switch(e.type){case"literal":return e.value;case"expression":return u(e,t)}})).join("")};var a={first:"",sep:",",empty:"",encode:s.UrlSafe,named:!1},c={"":n({},a),"+":n(n({},a),{encode:s.Restricted}),"#":n(n({},a),{encode:s.Restricted,first:"#",empty:"#"}),"/":n(n({},a),{first:"/",sep:"/"}),".":n(n({},a),{first:".",sep:".",empty:"."}),";":n(n({},a),{first:";",sep:";",named:!0}),"?":n(n({},a),{first:"?",sep:"&",empty:"=",named:!0}),"&":n(n({},a),{first:"&",sep:"&",empty:"=",named:!0})};function u(e,t){var r=c[e.operator],n=[];if(e.variables.forEach((function(e){var i=t[e.name];if(function(e){switch(typeof e){case"undefined":return!1;case"object":if(null==e)return!1;if(Array.isArray(e))return e.length>0;for(var t in e)if(null!=e[t])return!0;return!1;default:return!0}}(i)){var o=function(e,t,r){var n;if(null==t)throw new TypeError("tried to expand null value for variable "+e.name+", this is a bug in uri-template");return"explode"===(null===(n=e.modifier)||void 0===n?void 0:n.type)?function(e,t,r){var n=r.encode,i=r.named,o=r.sep;if(Array.isArray(t)){var s=t.map(n);return i&&(s=s.map((function(t){return e.name+"="+t}))),s.join(o)}if("object"==typeof t){var a=[];return Object.entries(t).forEach((function(e){var t=e[0],r=e[1];t=n(t),Array.isArray(r)?r.forEach((function(e){a.push(t+"="+n(e))})):a.push(t+"="+n(r))})),a.join(o)}var c=t.toString();return n(c)}(e,t,r):function(e,t,r){var n,i,o,s=r.empty,a=r.encode,c=r.named;if("object"==typeof t&&"substr"===(null===(n=e.modifier)||void 0===n?void 0:n.type))throw new Error("Prefixed variables do not support lists/maps. Check "+e.name);return Array.isArray(t)?o=t.map(a).join(","):"object"==typeof t?o=Object.entries(t).map((function(e){return e.map(a).join(",")})).join(","):(o=t.toString(),"substr"===(null===(i=e.modifier)||void 0===i?void 0:i.type)&&(o=o.substring(0,e.modifier.length)),o=a(o)),c&&(o=o?e.name+"="+o:""+e.name+s),o}(e,t,r)}(e,i,r);n.push(o||"")}})),0===n.length)return"";var i=n.join(r.sep);return 0===i.length?r.empty:r.first+i}t.expandExpression=u},115:function(e){"use strict";function t(e,r,n,i){var o=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(o,t.prototype),o.expected=r,o.found=n,o.location=i,o.name="SyntaxError",o}function r(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}!function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(t,Error),t.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var n,i=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){i=e[n].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,s=this.location.source+":"+o.line+":"+o.column;if(i){var a=this.location.end,c=r("",o.line.toString().length),u=i[o.line-1],l=o.line===a.line?a.column:u.length+1;t+="\n --\x3e "+s+"\n"+c+" |\n"+o.line+" | "+u+"\n"+c+" | "+r("",o.column-1)+r("",l-o.column,"^")}else t+="\n at "+s}return t},t.buildMessage=function(e,t){var r={literal:function(e){return'"'+i(e.text)+'"'},class:function(e){var t=e.parts.map((function(e){return Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e)}));return"["+(e.inverted?"^":"")+t+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function s(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(s);if(n.sort(),n.length>0){for(t=1,r=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+function(e){return e?'"'+i(e)+'"':"end of input"}(t)+" found."},e.exports={SyntaxError:t,parse:function(e,r){var n,i,o,s,a={},c=(r=void 0!==r?r:{}).grammarSource,u={template:ee},l=ee,h="{",f="}",d=",",p="*",y=":",v="(",g=")",m=/^[\/;.?&+#]/,w=/^[a-zA-Z0-9_.%]/,b=/^[0-9]/,k=/^[^{]/,O=/^[^)]/,S=W("{",!1),_=W("}",!1),A=Q(["/",";",".","?","&","+","#"],!1,!1),x=W(",",!1),j=Q([["a","z"],["A","Z"],["0","9"],"_",".","%"],!1,!1),C=W("*",!1),T=W(":",!1),E=Q([["0","9"]],!1,!1),P=Q(["{"],!0,!1),L=W("(",!1),F=Q([")"],!0,!1),R=W(")",!1),M=function(e){return{type:"template",parts:e}},H=function(e,t){return{type:"expression",operator:e,variables:t}},B=function(e,t){return t},U=function(e,t){return t.unshift(e),t},N=function(e,t,r){return{type:"variable",name:e,modifier:t,extension:r}},I=function(){return{type:"explode"}},q=function(e){return{type:"substr",length:parseInt(e)}},z=function(e){return{type:"literal",value:e}},D=function(e){return e},$=0,K=[{line:1,column:1}],V=0,G=[],J=0;if("startRule"in r){if(!(r.startRule in u))throw new Error("Can't start parsing from rule \""+r.startRule+'".');l=u[r.startRule]}function W(e,t){return{type:"literal",text:e,ignoreCase:t}}function Q(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function Z(t){var r,n=K[t];if(n)return n;for(r=t-1;!K[r];)r--;for(n={line:(n=K[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return K[t]=n,n}function X(e,t){var r=Z(e),n=Z(t);return{source:c,start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function Y(e){$<V||($>V&&(V=$,G=[]),G.push(e))}function ee(){var e,t;for($,e=[],(t=ne())===a&&(t=te());t!==a;)e.push(t),(t=ne())===a&&(t=te());return M(e)}function te(){var t,r,n,i,o;return t=$,123===e.charCodeAt($)?(r=h,$++):(r=a,0===J&&Y(S)),r!==a?(n=function(){var t;return m.test(e.charAt($))?(t=e.charAt($),$++):(t=a,0===J&&Y(A)),t===a&&(t=""),t}(),n!==a?(i=function(){var t,r,n,i,o,s;if(t=$,(r=re())!==a){for(n=[],i=$,44===e.charCodeAt($)?(o=d,$++):(o=a,0===J&&Y(x)),o!==a&&(s=re())!==a?i=B(r,s):($=i,i=a);i!==a;)n.push(i),i=$,44===e.charCodeAt($)?(o=d,$++):(o=a,0===J&&Y(x)),o!==a&&(s=re())!==a?i=B(r,s):($=i,i=a);t=U(r,n)}else $=t,t=a;return t}(),i!==a?(125===e.charCodeAt($)?(o=f,$++):(o=a,0===J&&Y(_)),o!==a?t=H(n,i):($=t,t=a)):($=t,t=a)):($=t,t=a)):($=t,t=a),t}function re(){var t,r,n,i;if(t=$,r=$,n=[],w.test(e.charAt($))?(i=e.charAt($),$++):(i=a,0===J&&Y(j)),i!==a)for(;i!==a;)n.push(i),w.test(e.charAt($))?(i=e.charAt($),$++):(i=a,0===J&&Y(j));else n=a;return(r=n!==a?e.substring(r,$):n)!==a?(n=function(){var t,r,n,i,o;if(t=$,58===e.charCodeAt($)?(r=y,$++):(r=a,0===J&&Y(T)),r!==a){if(n=$,i=[],b.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(E)),o!==a)for(;o!==a;)i.push(o),b.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(E));else i=a;(n=i!==a?e.substring(n,$):i)!==a?t=q(n):($=t,t=a)}else $=t,t=a;return t}(),n===a&&(n=function(){var t;return $,42===e.charCodeAt($)?(t=p,$++):(t=a,0===J&&Y(C)),t!==a&&(t=I()),t}()),n===a&&(n=null),i=function(){var t,r,n,i,o;if(t=$,40===e.charCodeAt($)?(r=v,$++):(r=a,0===J&&Y(L)),r!==a){if(n=$,i=[],O.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(F)),o!==a)for(;o!==a;)i.push(o),O.test(e.charAt($))?(o=e.charAt($),$++):(o=a,0===J&&Y(F));else i=a;(n=i!==a?e.substring(n,$):i)!==a?(41===e.charCodeAt($)?(i=g,$++):(i=a,0===J&&Y(R)),i!==a?t=D(n):($=t,t=a)):($=t,t=a)}else $=t,t=a;return t}(),i===a&&(i=null),t=N(r,n,i)):($=t,t=a),t}function ne(){var t,r,n;if($,t=$,r=[],k.test(e.charAt($))?(n=e.charAt($),$++):(n=a,0===J&&Y(P)),n!==a)for(;n!==a;)r.push(n),k.test(e.charAt($))?(n=e.charAt($),$++):(n=a,0===J&&Y(P));else r=a;return(t=r!==a?e.substring(t,$):r)!==a&&(t=z(t)),t}if((n=l())!==a&&$===e.length)return n;throw n!==a&&$<e.length&&Y({type:"end"}),i=G,o=V<e.length?e.charAt(V):null,s=V<e.length?X(V,V+1):X(V,V),new t(t.buildMessage(i,o),i,o,s)}}},493:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};t.__esModule=!0,t.parseRule=t.parse=void 0;var a=o(r(115)),c=o(r(9)),u=r(644);function l(e,t){return void 0===t&&(t="template"),a.parse(e,{startRule:t})}t.parse=function(e){var t=l(e,"template");return{ast:t,expand:function(e){return(0,u.expandTemplate)(t,e)},toString:function(){return c.toString(t)}}},t.parseRule=l,s(r(644),t)},94:function(){},147:function(e){"use strict";e.exports=JSON.parse('{"i8":"8.0.0-alpha.3"}')}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var n={};return function(){"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.FollowPromiseMany=e.FollowPromiseOne=e.Problem=e.oauth2=e.bearerAuth=e.basicAuth=e.NeverCache=e.ShortCache=e.ForeverCache=e.isState=e.CjState=e.SirenState=e.HalState=e.BaseHeadState=e.BaseState=e.resolve=e.Links=e.LinkNotFound=e.Resource=e.default=e.Ketting=e.Client=void 0;var t=r(934);Object.defineProperty(e,"Client",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"Ketting",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.default}});var i=r(871);Object.defineProperty(e,"Resource",{enumerable:!0,get:function(){return i.default}});var o=r(173);Object.defineProperty(e,"LinkNotFound",{enumerable:!0,get:function(){return o.LinkNotFound}}),Object.defineProperty(e,"Links",{enumerable:!0,get:function(){return o.Links}});var s=r(458);Object.defineProperty(e,"resolve",{enumerable:!0,get:function(){return s.resolve}});var a=r(24);Object.defineProperty(e,"BaseState",{enumerable:!0,get:function(){return a.BaseState}}),Object.defineProperty(e,"BaseHeadState",{enumerable:!0,get:function(){return a.BaseHeadState}}),Object.defineProperty(e,"HalState",{enumerable:!0,get:function(){return a.HalState}}),Object.defineProperty(e,"SirenState",{enumerable:!0,get:function(){return a.SirenState}}),Object.defineProperty(e,"CjState",{enumerable:!0,get:function(){return a.CjState}}),Object.defineProperty(e,"isState",{enumerable:!0,get:function(){return a.isState}});var c=r(651);Object.defineProperty(e,"ForeverCache",{enumerable:!0,get:function(){return c.ForeverCache}});var u=r(478);Object.defineProperty(e,"ShortCache",{enumerable:!0,get:function(){return u.ShortCache}});var l=r(575);Object.defineProperty(e,"NeverCache",{enumerable:!0,get:function(){return l.NeverCache}});var h=r(530);Object.defineProperty(e,"basicAuth",{enumerable:!0,get:function(){return h.default}});var f=r(409);Object.defineProperty(e,"bearerAuth",{enumerable:!0,get:function(){return f.default}});var d=r(686);Object.defineProperty(e,"oauth2",{enumerable:!0,get:function(){return d.default}});var p=r(682);Object.defineProperty(e,"Problem",{enumerable:!0,get:function(){return p.Problem}});var y=r(761);Object.defineProperty(e,"FollowPromiseOne",{enumerable:!0,get:function(){return y.FollowPromiseOne}}),Object.defineProperty(e,"FollowPromiseMany",{enumerable:!0,get:function(){return y.FollowPromiseMany}})}(),n}()}));
|
|
2
2
|
//# sourceMappingURL=ketting.min.js.map
|