@mountainpass/waychaser 5.0.14 → 5.0.16

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.
@@ -1 +1 @@
1
- var e=function(r,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])})(r,t)};function r(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var t=function(){return(t=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function n(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}function o(e,r,t,n){return new(t||(t=Promise))((function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(a,s)}l((n=n.apply(e,r||[])).next())}))}function i(e,r){var t,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(t=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=r.call(e,i)}catch(e){s=[6,e],n=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function a(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,i=t.call(e),a=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function l(e,r,t){if(t||2===arguments.length)for(var n,o=0,i=r.length;o<i;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))}"function"==typeof SuppressedError&&SuppressedError;var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},c={};!function(e){var r=/[!'()]/g,t={"":",","+":",","#":",","?":"&"},n=/[$-\/?[-^{|}]/g,o=/\{([#&+.\/;?]?)((?:[-\w%.]+(\*|:\d+)?,?)+)\}/g,i=RegExp(o.source+"|.[^{]*?","g");function a(e){return encodeURIComponent(e).replace(r,escape)}function s(e){return null!=e}function l(e,r,t){return(e=e.map(r).filter(s)).length&&e.join(t)}function u(e,r){return e.replace(o,(function(e,n,o){var i=t[n]||n,s=";"==i||"&"==i,u=n&&","==i?encodeURI:a,c=l(o.split(","),(function(e){var t=e.split(/[*:]/),n=t[0],o=r[n];if(null!=o){if("object"==typeof o){if(t=n!=e,Array.isArray(o)?o=l(o,u,t?s?i+n+"=":i:","):(o=l(Object.keys(o),(function(e){return u(e)+(t?"=":",")+u(o[e])}),t&&(s||"/"==i)?i:","),t&&(s=0)),!o)return}else o=u(t[1]?o.slice(0,t[1]):o);return s?n+(o||"&"==i?"="+o:o):o}}),i);return c||""===c?"+"!=n?n+c:c:""}))}e.expand=u,e.Template=function(e){var r=this,o=0,a={},s="",l="^"+e.replace(i,(function(e,r,n){if(!n)return p(e);var i=t[r]||r,l=";"==i||"&"==i,u=n.split(",").map((function(e){var r=e.split(/[*:]/),t=r[0],n=(a[t]||"(")+".*?)";return o++,r[1]&&(n="((?:%..|.){1,"+r[1]+"})",a[t]="(\\"+o),s+="t=($["+o+"]||'').split('"+i+"').map(decodeURIComponent);",s+='o["'+t+'"]=t.length>1?t:t[0];',l?p(t)+"(?:="+n+")?":"&"==i?p(t+"=")+n:n})).join(p(i));return"+"!=r?p(r)+u:u}))+"$",c=RegExp(l),f=Function("$","var t,o={};"+s+"return o");function p(e){return e.replace(n,"\\$&")}r.template=e,r.match=function(e){var r=c.exec(e);return r&&f(r)},r.expand=u.bind(r,e)}}(u.URI||(u.URI={}));const f=function(){const e="undefined"==typeof window?c.URI||global.URI:window.URI||c.URI;return e.parameters=function(e){return new f.Template(e).match(e)},e}();var p=Object.prototype.hasOwnProperty,d=function e(r,t){var n=[];for(var o in r)if(p.call(r,o)){var i,a=r[o],s=encodeURIComponent(o);i="object"==typeof a?e(a,t?t+"["+s+"]":s):(t?t+"["+s+"]":s)+"="+encodeURIComponent(a),n.push(i)}return n.join("&")},h="object"==typeof self?self.FormData:window.FormData;function y(e,r,t){if(e){return function(e){return e.split(",").map((function(e){var r,t,n=e.split(";"),o=n.shift(),i=null==o?void 0:o.split("/"),s={type:o,parentType:null==i?void 0:i[0],subType:null==i?void 0:i[1],q:1};try{for(var l=a(n),u=l.next();!u.done;u=l.next()){var c=u.value,f=c.split("=");"q"===c[0]&&(s[f[0]]=Number.parseFloat(f[1]))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(t=l.return)&&t.call(l)}finally{if(r)throw r.error}}return s})).sort((function(e,r){return e.q>r.q?-1:e.q<r.q||"*"===e.parentType&&"*"!==r.parentType?1:"*"!==e.parentType&&"*"===r.parentType?-1:"*"===e.subType&&"*"!==r.subType?1:"*"!==e.subType&&"*"===r.subType?-1:0})).map((function(e){return{type:e.type||""}})).filter((function(e){return""!==e.type}))}(e).find((e=>r.includes(e.type))).type}return t}var v=w;function b(e){return e&&e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function m(e){return e}function w(e,r){const t=(r=r||{}).delimiter||".",n=r.maxDepth,o=r.transformKey||m,i={};return function e(a,s,l){l=l||1,Object.keys(a).forEach((function(u){const c=a[u],f=r.safe&&Array.isArray(c),p=Object.prototype.toString.call(c),d=b(c),h="[object Object]"===p||"[object Array]"===p,y=s?s+t+o(u):o(u);if(!f&&!d&&h&&Object.keys(c).length&&(!r.maxDepth||l<n))return e(c,y,l+1);i[y]=c}))}(e),i}w.flatten=w,w.unflatten=function e(r,t){const n=(t=t||{}).delimiter||".",o=t.overwrite||!1,i=t.transformKey||m,a={};if(b(r)||"[object Object]"!==Object.prototype.toString.call(r))return r;function s(e){const r=Number(e);return isNaN(r)||-1!==e.indexOf(".")||t.object?e:r}return r=Object.keys(r).reduce((function(e,o){const i=Object.prototype.toString.call(r[o]);return!("[object Object]"===i||"[object Array]"===i)||function(e){const r=Object.prototype.toString.call(e),t="[object Array]"===r,n="[object Object]"===r;if(!e)return!0;if(t)return!e.length;if(n)return!Object.keys(e).length}(r[o])?(e[o]=r[o],e):function(e,r,t){return Object.keys(t).reduce((function(r,o){return r[e+n+o]=t[o],r}),r)}(o,e,w(r[o],t))}),{}),Object.keys(r).forEach((function(l){const u=l.split(n).map(i);let c=s(u.shift()),f=s(u[0]),p=a;for(;void 0!==f;){if("__proto__"===c)return;const e=Object.prototype.toString.call(p[c]),r="[object Object]"===e||"[object Array]"===e;if(!o&&!r&&void 0!==p[c])return;(o&&!r||!o&&null==p[c])&&(p[c]="number"!=typeof f||t.object?{}:[]),p=p[c],u.length>0&&(c=s(u.shift()),f=s(u[0]))}p[c]=e(r[l],t)})),a};var g={},O=/~/,j=/~[01]/g;function x(e){switch(e){case"~1":return"/";case"~0":return"~"}throw new Error("Invalid tilde escape: "+e)}function k(e){return O.test(e)?e.replace(j,x):e}function A(e){if("string"==typeof e){if(""===(e=e.split("/"))[0])return e;throw new Error("Invalid JSON pointer.")}if(Array.isArray(e)){for(const r of e)if("string"!=typeof r&&"number"!=typeof r)throw new Error("Invalid JSON pointer. Must be of type string or number.");return e}throw new Error("Invalid JSON pointer.")}function E(e,r){if("object"!=typeof e)throw new Error("Invalid input object.");var t=(r=A(r)).length;if(1===t)return e;for(var n=1;n<t;){if(e=e[k(r[n++])],t===n)return e;if("object"!=typeof e||null===e)return}}function I(e,r,t){if("object"!=typeof e)throw new Error("Invalid input object.");if(0===(r=A(r)).length)throw new Error("Invalid JSON pointer for set.");return function(e,r,t){for(var n,o,i=1,a=r.length;i<a;){if("constructor"===r[i]||"prototype"===r[i]||"__proto__"===r[i])return e;if(n=k(r[i++]),o=a>i,void 0===e[n]&&(Array.isArray(e)&&"-"===n&&(n=e.length),o&&(""!==r[i]&&r[i]<1/0||"-"===r[i]?e[n]=[]:e[n]={})),!o)break;e=e[n]}var s=e[n];return void 0===t?delete e[n]:e[n]=t,s}(e,r,t)}g.get=E,g.set=I,g.compile=function(e){var r=A(e);return{get:function(e){return E(e,r)},set:function(e,t){return I(e,r,t)}}};var R={};Object.defineProperty(R,"__esModule",{value:!0});var C=R.ProblemDocument=void 0;C=R.ProblemDocument=class{constructor(e){Object.assign(this,e)}};var S=function(e){var r=e.rel,t=e.uri,o=e.method,i=e.parameters,a=e.accept,s=e.anchor,l=n(e,["rel","uri","method","parameters","accept","anchor"]);this.rel=r,this.uri=t,this.method=o,this.parameters=i||{},this.accept=a,this.anchor=s,Object.assign(this,l)},P=function(e){function t(r,t,n,o){var i=e.call(this,r)||this;return i.response=t,i.defaultOptions=n,i.uri.includes("{this.")&&(i.uri=f.expand(i.uri,o)),i}return r(t,e),t.prototype.invokeAsFragment=function(e,r){if(this.uri.startsWith("#/")){var t=this.expandUrl(e).toString(),n=this.response.fullContent&&g.get(this.response.fullContent,t.slice(1));if(void 0===n)return;if(r){var o=r(n);if(se(o))return new le({defaultOptions:this.defaultOptions,baseResponse:this.response.response,content:o.content,fullContent:this.response.fullContent,anchor:t,parentOperations:this.response.allOperations,parameters:e});throw new ue({problem:o.problem,response:new le({defaultOptions:this.defaultOptions,baseResponse:this.response.response,content:n,fullContent:this.response.fullContent,parameters:e})})}return new le({defaultOptions:this.defaultOptions,baseResponse:this.response.response,content:n,fullContent:this.response.fullContent,anchor:t,parentOperations:this.response.allOperations,parameters:e})}},t.prototype.invokeAll=function(e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(t){return this.uri.startsWith("#/")&&this.response instanceof le?(r=this.doInvokeAll((null==e?void 0:e.parameters)||{}),[2,Promise.all(r)]):[2,Promise.all([this.invoke(e)])]}))}))},t.prototype.doInvokeAll=function(e,r){var t=this,n=this.response,o=new f.Template(this.uri),i=Object.assign(f.parameters(this.uri),e),a=o.expand(i).replace(/%7B/g,"{").replace(/%7D/g,"}"),u=f.parameters(a),c=Object.keys(u);if(0!==c.length){var p=u[c[0]],d=a.slice(1,a.indexOf(p)-1),h=""===d?n.content:g.get(n.content,d);if(h)return(Array.isArray(h)?l([],s(Array.from({length:h.length}).keys()),!1):Object.keys(h)).flatMap((function(n){var o,i=Object.assign({},e,((o={})[c[0]]=n,o));return t.doInvokeAll(i,r)}));throw new ue({response:this.response,problem:new C({type:"https://waychaser.io/fragment-uri-error",title:"The fragment URI does not match the content structure",uri:d,content:n.content,parameters:e})})}return[this.invokeAsFragment(e,r)]},t.prototype.invoke=function(e){return o(this,void 0,void 0,(function(){var r,t,n,o,s,l,u,c,f,p,v,b,m,w,g,O,j,x;return i(this,(function(i){if(this.uri.startsWith("#/"))return[2,this.invokeAsFragment(null==e?void 0:e.parameters)];if(r=this.parameters||{},t=Object.assign({},this.defaultOptions.parameters,null==e?void 0:e.parameters),n=this.url(t),o={},Array.isArray(r))try{for(s=a(r),l=s.next();!l.done;l=s.next())f=l.value,o[f]=null==t?void 0:t[f]}catch(e){g={error:e}}finally{try{l&&!l.done&&(O=s.return)&&O.call(s)}finally{if(g)throw g.error}}else try{for(u=a(Object.keys(r)),c=u.next();!c.done;c=u.next())f=c.value,o[f]=null==t?void 0:t[f]}catch(e){j={error:e}}finally{try{c&&!c.done&&(x=u.return)&&x.call(u)}finally{if(j)throw j.error}}if(p=void 0,v={},(b=Object.assign({},e)).method=this.method,0!==Object.keys(this.parameters).length&&(k=this.method||"GET",!["GET","DELETE","TRACE","OPTIONS","HEAD"].includes(k))){switch(m=y(this.accept,["application/x-www-form-urlencoded","application/json","multipart/form-data"],"application/x-www-form-urlencoded")){case"application/x-www-form-urlencoded":p=d(o);break;case"application/json":p=JSON.stringify(o);break;case"multipart/form-data":for(w in p=new h,o)p.append(w,o[w])}"multipart/form-data"!==m&&(v={"content-type":m}),b.body=p,b.headers=Object.assign(v,null==e?void 0:e.headers)}return[2,fe(n.toString(),this.defaultOptions,b)];var k}))}))},t.prototype.url=function(e){var r=this.expandUrl(e);return new URL(r,this.response.url)},t.prototype.expandUrl=function(e){return f.expand(this.uri,v(e||{}))},t}(S),_=function(e){function t(r){return e.apply(this,l([],s(r||[]),!1))||this}return r(t,e),t.create=function(){return Object.create(t.prototype)},t.prototype.find=function(e,r){var t=Array.prototype.find.bind(this);return t("string"==typeof e?T({rel:e}):"object"==typeof e?T(e):e,r)},t.prototype.filter=function(e,r){if("string"==typeof e)return this.filter({rel:e},r);if("object"==typeof e)return this.filter(T(e),r);var n=Array.prototype.filter.bind(this)(e);return Object.setPrototypeOf(n,t.prototype),n},t.prototype.invoke=function(e,r){var t=this.find(e);return t?t.invoke(r):void 0},t.prototype.invokeAll=function(e,r){var t=this.filter(e);return Promise.all(t.map((function(e){return e.invokeAll(r)}))).then((function(e){return e.flat()}))},t}(Array);function T(e){return function(r){for(var t in e)if(e[t]!==r[t])return!1;return!0}}function U(e){var r,t,n,o,i=[],s=/{\[(\d+)..(\d+)]}/,l=e.uri.toString(),u=l.match(s);if(u)for(var c=Number.parseInt(u[1]);c<=Number.parseInt(u[2]);++c){var f=U(new S(Object.assign(e,{uri:l.replace(s,c.toFixed(0))})));try{for(var p=(r=void 0,a(f)),d=p.next();!d.done;d=p.next()){var h=d.value;i.push(h)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(t=p.return)&&t.call(p)}finally{if(r)throw r.error}}}else{var y=e.anchor,v=null==y?void 0:y.match(s);if(y&&v)for(c=Number.parseInt(v[1]);c<=Number.parseInt(v[2]);++c){f=U(new S(Object.assign(e,{anchor:y.replace(s,c.toFixed(0))})));try{for(var b=(n=void 0,a(f)),m=b.next();!m.done;m=b.next()){var w=m.value;i.push(w)}}catch(e){n={error:e}}finally{try{m&&!m.done&&(o=b.return)&&o.call(b)}finally{if(n)throw n.error}}}else i.push(e)}return i}const q="application/hal+json",N="application/vnd.siren+json";function F(e,r){const t=e.split(/:(.+)/);if(t.length>1){const[n,o]=t;return r[n]?f.expand(r[n],{rel:o}):e}return e}function L(e,r,t){const{href:n,templated:o,...i}=r;return new S({rel:F(e,t),uri:n,...i})}var H=/^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i,D=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,$=/\s|\uFEFF|\xA0/,B=/\r?\n[\x20\x09]+/g,J=/[;,"]/,W=/[;,"]|\s/,G=/^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/,M=1,Q=2,K=4;function V(e){return e.replace(D,"")}function z(e){return $.test(e)}function Z(e,r){for(;z(e[r]);)r++;return r}function X(e){return W.test(e)||!G.test(e)}class Y{constructor(e){this.refs=[],e&&this.parse(e)}rel(e){for(var r=[],t=e.toLowerCase(),n=0;n<this.refs.length;n++)"string"==typeof this.refs[n].rel&&this.refs[n].rel.toLowerCase()===t&&r.push(this.refs[n]);return r}get(e,r){e=e.toLowerCase(),r=r.toLowerCase();for(var t=[],n=0;n<this.refs.length;n++)"string"==typeof this.refs[n][e]&&this.refs[n][e].toLowerCase()===r&&t.push(this.refs[n]);return t}set(e){return this.refs.push(e),this}setUnique(e){return this.refs.some((r=>{return t=r,n=e,Object.keys(t).length===Object.keys(n).length&&Object.keys(t).every((e=>e in n&&t[e]===n[e]));var t,n}))||this.refs.push(e),this}has(e,r){e=e.toLowerCase(),r=r.toLowerCase();for(var t=0;t<this.refs.length;t++)if("string"==typeof this.refs[t][e]&&this.refs[t][e].toLowerCase()===r)return!0;return!1}parse(e,r){e=V(e=(r=r||0)?e.slice(r):e).replace(B,"");for(var t=M,n=e.length,o=(r=0,null);r<n;)if(t===M){if(z(e[r])){r++;continue}if("<"!==e[r])throw new Error('Unexpected character "'+e[r]+'" at offset '+r);if(null!=o&&(null!=o.rel?this.refs.push(...Y.expandRelations(o)):this.refs.push(o)),-1===(s=e.indexOf(">",r)))throw new Error("Expected end of URI delimiter at offset "+r);o={uri:e.slice(r+1,s)},r=s,t=Q,r++}else if(t===Q){if(z(e[r])){r++;continue}if(";"===e[r])t=K,r++;else{if(","!==e[r])throw new Error('Unexpected character "'+e[r]+'" at offset '+r);t=M,r++}}else{if(t!==K)throw new Error('Unknown parser state "'+t+'"');if(";"===e[r]||z(e[r])){r++;continue}-1===(s=e.indexOf("=",r))&&(s=e.indexOf(";",r)),-1===s&&(s=e.length);var i=V(e.slice(r,s)).toLowerCase(),a="";if('"'===e[r=Z(e,r=s+1)])for(r++;r<n;){if('"'===e[r]){r++;break}"\\"===e[r]&&r++,a+=e[r],r++}else{for(var s=r+1;!J.test(e[s])&&s<n;)s++;a=e.slice(r,s),r=s}switch(o[i]&&Y.isSingleOccurenceAttr(i)||("*"===i[i.length-1]?o[i]=Y.parseExtendedValue(a):(a="type"===i?a.toLowerCase():a,null!=o[i]?Array.isArray(o[i])?o[i].push(a):o[i]=[o[i],a]:o[i]=a)),e[r]){case",":t=M;break;case";":t=K}r++}return null!=o&&(null!=o.rel?this.refs.push(...Y.expandRelations(o)):this.refs.push(o)),o=null,this}toString(){for(var e=[],r="",t=null,n=0;n<this.refs.length;n++)t=this.refs[n],r=Object.keys(this.refs[n]).reduce((function(e,r){return"uri"===r?e:e+"; "+Y.formatAttribute(r,t[r])}),"<"+t.uri+">"),e.push(r);return e.join(", ")}}Y.isCompatibleEncoding=function(e){return H.test(e)},Y.parse=function(e,r){return(new Y).parse(e,r)},Y.isSingleOccurenceAttr=function(e){return"rel"===e||"type"===e||"media"===e||"title"===e||"title*"===e},Y.isTokenAttr=function(e){return"rel"===e||"type"===e||"anchor"===e},Y.escapeQuotes=function(e){return e.replace(/"/g,'\\"')},Y.expandRelations=function(e){return e.rel.split(" ").map((function(r){var t=Object.assign({},e);return t.rel=r,t}))},Y.parseExtendedValue=function(e){var r=/([^']+)?(?:'([^']*)')?(.+)/.exec(e);return{language:r[2].toLowerCase(),encoding:Y.isCompatibleEncoding(r[1])?null:r[1].toLowerCase(),value:Y.isCompatibleEncoding(r[1])?decodeURIComponent(r[3]):r[3]}},Y.formatExtendedAttribute=function(e,r){var t=(r.encoding||"utf-8").toUpperCase();return e+"="+t+"'"+(r.language||"en")+"'"+(Buffer.isBuffer(r.value)&&Y.isCompatibleEncoding(t)?r.value.toString(t):Buffer.isBuffer(r.value)?r.value.toString("hex").replace(/[0-9a-f]{2}/gi,"%$1"):encodeURIComponent(r.value))},Y.formatAttribute=function(e,r){return Array.isArray(r)?r.map((r=>Y.formatAttribute(e,r))).join("; "):"*"===e[e.length-1]||"string"!=typeof r?Y.formatExtendedAttribute(e,r):(Y.isTokenAttr(e)?r=X(r)?'"'+Y.escapeQuotes(r)+'"':Y.escapeQuotes(r):X(r)&&(r='"'+(r=(r=encodeURIComponent(r)).replace(/%20/g," ").replace(/%2C/g,",").replace(/%3B/g,";"))+'"'),e+"="+r)};var ee,re,te=Y;function ne(e){return e?te.parse(e).refs.map((function(e){var r=e.rel,o=e.uri,i=e.method,a=e["accept*"],s=e["params*"],l=n(e,["rel","uri","method","accept*","params*"]),u=(null==s?void 0:s.value)?JSON.parse(null==s?void 0:s.value):void 0;return new S(t({rel:r,uri:o,method:i,parameters:u,accept:null==a?void 0:a.value},l))})):[]}function oe(e){var r,o,i=e.name,s=e.href,l=e.fields,u=e.type,c=n(e,["name","href","fields","type"]),f={};if(l)try{for(var p=a(l),d=p.next();!d.done;d=p.next()){f[d.value.name]={}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}return t({rel:i,uri:s,accept:u,parameters:l&&f},c)}function ie(e,r){var o=r.href;r.rel;var i=n(r,["href","rel"]);return new S(t({rel:e,uri:o},i))}function ae(e,r){var o=e.handlers,i=e.defaultHandlers,a=e.headers,u=e.contentParser,c=n(e,["handlers","defaultHandlers","headers","contentParser"]),f=r||{},p=f.handlers,d=f.defaultHandlers,h=f.headers,y=f.contentParser,v=n(f,["handlers","defaultHandlers","headers","contentParser"]),b=ce(l(l([],s(p||o||[]),!1),s(d||i||[]),!1)),m=y?function(e){return y(e,u)}:u;return t(t(t({},c),v),{defaultHandlers:b,handlers:[],headers:t(t({},a),h),contentParser:m})}function se(e){return e.success}var le=function(){function e(e){var r,t,n,o,i,s,l=e.handlers,u=e.defaultOptions,c=e.baseResponse,p=e.content,d=e.fullContent,h=e.anchor,y=e.parentOperations,b=e.parameters;this.response=c,this.anchor=h,this.parameters=b||{},this.fullContent=d||p,this.content=p,this.operations=_.create();var m=v({this:p});if(y&&h&&u){this.allOperations=y;try{for(var w=a(this.allOperations[h]||[]),g=w.next();!g.done;g=w.next()){var O=g.value;this.operations.push(new P(O,this,u,m))}}catch(e){r={error:e}}finally{try{g&&!g.done&&(t=w.return)&&t.call(w)}finally{if(r)throw r.error}}for(var j in this.allOperations)if(""!==j){var x=new f.Template(j),k=x.match(this.anchor);if(x.expand(k)===this.anchor){var A=Object.assign({},u,{parameters:Object.assign(k,u.parameters)});try{for(var E=(n=void 0,a(this.allOperations[j])),I=E.next();!I.done;I=E.next()){O=I.value;this.operations.push(new P(O,this,A,m))}}catch(e){n={error:e}}finally{try{I&&!I.done&&(o=E.return)&&o.call(E)}finally{if(n)throw n.error}}}}}else if(c&&l&&u){this.allOperations=function(e){var r,t,n,o,i,s,l,u,c=e.handlers,f=e.baseResponse,p=e.content,d=[],h=!1;try{for(var y=a(c),v=y.next();!v.done;v=y.next()){var b=v.value.handler(f,p,(function(){h=!0}));if(b)try{for(var m=(n=void 0,a(b)),w=m.next();!w.done;w=m.next()){var g=w.value;d.push(g)}}catch(e){n={error:e}}finally{try{w&&!w.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}if(h)break}}catch(e){r={error:e}}finally{try{v&&!v.done&&(t=y.return)&&t.call(y)}finally{if(r)throw r.error}}var O={};try{for(var j=a(d),x=j.next();!x.done;x=j.next()){var k=U(g=x.value);try{for(var A=(l=void 0,a(k)),E=A.next();!E.done;E=A.next()){var I=E.value,R=I.anchor||"";O[R]||(O[R]=[]),O[R].push(I)}}catch(e){l={error:e}}finally{try{E&&!E.done&&(u=A.return)&&u.call(A)}finally{if(l)throw l.error}}}}catch(e){i={error:e}}finally{try{x&&!x.done&&(s=j.return)&&s.call(j)}finally{if(i)throw i.error}}return O}({baseResponse:c,content:p,handlers:l}),this.operations=_.create();try{for(var R=a(this.allOperations[""]||[]),C=R.next();!C.done;C=R.next()){O=C.value;var S=new P(O,this,u,m);this.operations.push(S)}}catch(e){i={error:e}}finally{try{C&&!C.done&&(s=R.return)&&s.call(R)}finally{if(i)throw i.error}}}}return e.create=function(r,t,n,o){if(t instanceof C)throw new ue({response:new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:t,parameters:o.parameters}),problem:t});if(o.validator){var i=o.validator(t);if(se(i))return new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:i.content,parameters:o.parameters});throw new ue({response:new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:t,parameters:o.parameters}),problem:i.problem})}return new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:t,parameters:o.parameters})},Object.defineProperty(e.prototype,"ops",{get:function(){return this.operations},enumerable:!1,configurable:!0}),e.prototype.invoke=function(e,r){return this.operations.invoke(e,r)},e.prototype.invokeAll=function(e,r){return this.operations.invokeAll(e,r)},Object.defineProperty(e.prototype,"body",{get:function(){throw new Error("Not Implemented. Use `.content` instead")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bodyUsed",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"headers",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.headers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ok",{get:function(){return!!this.response&&this.response.ok},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"redirected",{get:function(){return!!this.response&&this.response.redirected},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statusText",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.statusText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.url},enumerable:!1,configurable:!0}),e.prototype.arrayBuffer=function(){throw new Error("Not Implemented. Use `.content` instead")},e.prototype.blob=function(){throw new Error("Not Implemented. Use `.content` instead")},e.prototype.clone=function(){throw new Error("Not Implemented")},e.prototype.formData=function(){throw new Error("Not Implemented. Use `.content` instead")},e.prototype.text=function(){throw new Error("Not Implemented. Use `.content` instead")},e}(),ue=function(e){function t(r){var t=this.constructor,n=r.response,o=r.problem,i=e.call(this,o.detail)||this,a=t.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(i,a):i.__proto__=a,i.problem=o,i.response=n,i}return r(t,e),t}(Error);function ce(e){return e.sort((function(e,r){return(r.q||1)-(e.q||1)}))}function fe(e,r,n){var u;return o(this,void 0,void 0,(function(){var o,c,f,p,d,h,y,v,b,m,w,g,O,j,x,k,A,E,I,R,S,P,_,T,U;return i(this,(function(i){switch(i.label){case 0:if(o=ae(r,n),c=o.defaultHandlers,!o.fetch)throw new Error("No global fetch and fetch not provided in options");f=function(e){var r,t,n,o,i=[];try{for(var s=a(e),l=s.next();!l.done;l=s.next()){var u=l.value;try{for(var c=(n=void 0,a(u.mediaRanges)),f=c.next();!f.done;f=c.next()){var p=f.value;"object"==typeof p?u.q?i.push({type:p.mediaType,q:u.q*(p.q||1)}):i.push({type:p.mediaType,q:p.q||1}):u.q?i.push({type:p,q:u.q}):i.push({type:p,q:1})}}catch(e){n={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(t=s.return)&&t.call(s)}finally{if(r)throw r.error}}var d=i.sort((function(e,r){return e.q-r.q})),h=new Set;return d.filter((function(e){var r=e.type;return!h.has(r)&&h.add(r)}))}(c),p=f.map((function(e){return 1===e.q?e.type:"".concat(e.type,";q=").concat(e.q)})),d=(null===(u=null==n?void 0:n.headers)||void 0===u?void 0:u.accept)?[n.headers.accept]:[],h=l(l([],s(d),!1),s(p),!1).join(","),y=t(t({},o),{headers:t(t({},o.headers),{accept:h})}),v=!1;try{for(b=a(y.preInterceptors||[]),m=b.next();!m.done&&((0,m.value)(e,y,(function(){return v=!0})),!v);m=b.next());}catch(e){R={error:e}}finally{try{m&&!m.done&&(S=b.return)&&S.call(b)}finally{if(R)throw R.error}}return[4,o.fetch(e.toString(),y)];case 1:w=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,o.contentParser(w)];case 3:g=i.sent(),k=le.create(w,g,r,o),v=!1;try{for(O=a(y.postInterceptors),j=O.next();!j.done&&((0,j.value)(k,(function(){return v=!0})),!v);j=O.next());}catch(e){P={error:e}}finally{try{j&&!j.done&&(_=O.return)&&_.call(O)}finally{if(P)throw P.error}}return[2,k];case 4:x=i.sent(),k=new le({handlers:o.defaultHandlers,defaultOptions:r,baseResponse:w,content:x,parameters:o.parameters}),A=new ue(x instanceof C?{response:k,problem:x}:{response:k,problem:new C({type:"https://waychaser.io/unexected-error",title:"An unexpected error occurred",error:x})}),v=!1;try{for(E=a(y.postErrorInterceptors),I=E.next();!I.done&&((0,I.value)(A,(function(){return v=!0})),!v);I=E.next());}catch(e){T={error:e}}finally{try{I&&!I.done&&(U=E.return)&&U.call(E)}finally{if(T)throw T.error}}throw A;case 5:return[2]}}))}))}var pe={fetch:"undefined"!=typeof window?null===(ee=window.fetch)||void 0===ee?void 0:ee.bind(window):null===(re="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0)||void 0===re?void 0:re.fetch,handlers:[],defaultHandlers:ce([{handler:function(e){var r=null==e?void 0:e.headers.get("location");return r?[new S({rel:"related",uri:r})]:[]},mediaRanges:["*/*"],q:.4},{handler:function(e,r,t){return l(l([],s(ne(e.headers.get("link"))),!1),s(ne(e.headers.get("link-template"))),!1)},mediaRanges:["*/*"],q:.5},{handler:function(e,r){var t,n,o,i,s,l,u,c=[],f=null===(u=e.headers.get("content-type"))||void 0===u?void 0:u.split(";");if((null==f?void 0:f[0])===q&&r&&"object"==typeof r&&"_links"in r){var p=r,d={};if(p._links.curies)if(Array.isArray(p._links.curies))try{for(var h=a(p._links.curies),y=h.next();!y.done;y=h.next()){var v=y.value;d[v.name]=v.href}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}else d[p._links.curies.name]=p._links.curies.href;try{for(var b=a(Object.keys(p._links).filter((function(e){return"curies"!==e}))),m=b.next();!m.done;m=b.next()){var w=m.value;if(Array.isArray(p._links[w]))try{for(var g=(s=void 0,a(p._links[w])),O=g.next();!O.done;O=g.next()){var j=O.value;c.push(L(w,j,d))}}catch(e){s={error:e}}finally{try{O&&!O.done&&(l=g.return)&&l.call(g)}finally{if(s)throw s.error}}else c.push(L(w,p._links[w],d))}}catch(e){o={error:e}}finally{try{m&&!m.done&&(i=b.return)&&i.call(b)}finally{if(o)throw o.error}}}return c},mediaRanges:[q],q:.5},{handler:function(e,r){var t,n=null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";");return(null==n?void 0:n[0])===N?l(l([],s(function(e){var r,t,n,o,i=[];if(e&&"object"==typeof e&&"links"in e){var s=e;if(s.links)try{for(var l=a(s.links),u=l.next();!u.done;u=l.next()){var c=u.value;try{for(var f=(n=void 0,a(c.rel)),p=f.next();!p.done;p=f.next()){var d=ie(p.value,c);i.push(d)}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{u&&!u.done&&(t=l.return)&&t.call(l)}finally{if(r)throw r.error}}}return i}(r)),!1),s(function(e){var r,t,n=[];if(e&&"object"==typeof e&&"actions"in e){var o=e;if(o.actions)try{for(var i=a(o.actions),s=i.next();!s.done;s=i.next()){var l=oe(s.value);n.push(l)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}}return n}(r)),!1):[]},mediaRanges:[N],q:.5}]),preInterceptors:[],postInterceptors:[],postErrorInterceptors:[],contentParser:function(e){return o(void 0,void 0,void 0,(function(){var r,t,n,o,a;return i(this,(function(i){switch(i.label){case 0:return e.headers.get("content-length")&&"0"!==e.headers.get("content-length")?[4,e.text()]:[3,2];case 1:if(r=i.sent(),null==(t=null===(a=null===(o=e.headers.get("content-type"))||void 0===o?void 0:o.split(";"))||void 0===a?void 0:a[0])?void 0:t.endsWith("json")){if(n=function(e,r){try{return JSON.parse(e)}catch(t){throw new C({type:"https://waychaser.io/invalid-json",title:"JSON response could not be parsed",detail:"The response document with content type '".concat(r,"' could not be parsed as json"),content:e,error:t})}}(r,t),"application/problem+json"===t)throw Object.assign(new C(n),n);return[2,n]}i.label=2;case 2:return[2]}}))}))}};function de(e,r){var t=ae(r,e),n=function(e,r){return fe(e,t,r)};return n.currentDefaults=t,n.defaults=function(e){return de(e,t)},n}var he=Object.assign((function(e,r){return fe(e,pe,r)}),{currentDefaults:pe,defaults:function(e){return de(e,pe)}});export{ue as WayChaserProblem,le as WayChaserResponse,fe as _waychaser,se as isValidationSuccess,ce as sortHandlers,he as waychaser};
1
+ var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};function r(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var t=function(){return t=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},t.apply(this,arguments)};function n(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}function o(e,r,t,n){return new(t||(t=Promise))(function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(a,s)}l((n=n.apply(e,r||[])).next())})}function i(e,r){var t,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(t=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=r.call(e,i)}catch(e){s=[6,e],n=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function a(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,i=t.call(e),a=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function l(e,r,t){if(t||2===arguments.length)for(var n,o=0,i=r.length;o<i;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))}function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var c,f={};var p=(c||(c=1,function(e){var r=/[!'()]/g,t={"":",","+":",","#":",","?":"&"},n=/[$-\/?[-^{|}]/g,o=/\{([#&+.\/;?]?)((?:[-\w%.]+(\*|:\d+)?,?)+)\}/g,i=RegExp(o.source+"|.[^{]*?","g");function a(e){return encodeURIComponent(e).replace(r,escape)}function s(e){return null!=e}function l(e,r,t){return(e=e.map(r).filter(s)).length&&e.join(t)}function u(e,r){return e.replace(o,function(e,n,o){var i=t[n]||n,s=";"==i||"&"==i,u=n&&","==i?encodeURI:a,c=l(o.split(","),function(e){var t=e.split(/[*:]/),n=t[0],o=r[n];if(null!=o){if("object"==typeof o){if(t=n!=e,Array.isArray(o)?o=l(o,u,t?s?i+n+"=":i:","):(o=l(Object.keys(o),function(e){return u(e)+(t?"=":",")+u(o[e])},t&&(s||"/"==i)?i:","),t&&(s=0)),!o)return}else o=u(t[1]?o.slice(0,t[1]):o);return s?n+(o||"&"==i?"="+o:o):o}},i);return c||""===c?"+"!=n?n+c:c:""})}e.expand=u,e.Template=function(e){var r=this,o=0,a={},s="",l="^"+e.replace(i,function(e,r,n){if(!n)return p(e);var i=t[r]||r,l=";"==i||"&"==i,u=n.split(",").map(function(e){var r=e.split(/[*:]/),t=r[0],n=(a[t]||"(")+".*?)";return o++,r[1]&&(n="((?:%..|.){1,"+r[1]+"})",a[t]="(\\"+o),s+="t=($["+o+"]||'').split('"+i+"').map(decodeURIComponent);",s+='o["'+t+'"]=t.length>1?t:t[0];',l?p(t)+"(?:="+n+")?":"&"==i?p(t+"=")+n:n}).join(p(i));return"+"!=r?p(r)+u:u})+"$",c=RegExp(l),f=Function("$","var t,o={};"+s+"return o");function p(e){return e.replace(n,"\\$&")}r.template=e,r.match=function(e){var r=c.exec(e);return r&&f(r)},r.expand=u.bind(r,e)}}(f.URI||(f.URI={}))),f);var h,d,y,v=((h="undefined"==typeof window?p.URI||global.URI:window.URI||p.URI).parameters=function(e){return new v.Template(e).match(e)},h);var b,m,w=u(function(){if(y)return d;y=1;var e=Object.prototype.hasOwnProperty;return d=function r(t,n){var o=[];for(var i in t)if(e.call(t,i)){var a,s=t[i],l=encodeURIComponent(i);a="object"==typeof s?r(s,n?n+"["+l+"]":l):(n?n+"["+l+"]":l)+"="+encodeURIComponent(s),o.push(a)}return o.join("&")}}());var g,O,j=u(m?b:(m=1,b="object"==typeof self?self.FormData:window.FormData));function x(e,r,t){if(e){var n=function(e){return e.split(",").map(function(e){var r,t,n=e.split(";"),o=n.shift(),i=null==o?void 0:o.split("/"),s={type:o,parentType:null==i?void 0:i[0],subType:null==i?void 0:i[1],q:1};try{for(var l=a(n),u=l.next();!u.done;u=l.next()){var c=u.value,f=c.split("=");"q"===c[0]&&(s[f[0]]=Number.parseFloat(f[1]))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(t=l.return)&&t.call(l)}finally{if(r)throw r.error}}return s}).sort(function(e,r){return e.q>r.q?-1:e.q<r.q||"*"===e.parentType&&"*"!==r.parentType?1:"*"!==e.parentType&&"*"===r.parentType?-1:"*"===e.subType&&"*"!==r.subType?1:"*"!==e.subType&&"*"===r.subType?-1:0}).map(function(e){return{type:e.type||""}}).filter(function(e){return""!==e.type})}(e);return n.find(function(e){return r.includes(e.type)}).type}return t}var k,A=function(){if(O)return g;function e(e){return e&&e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return e}function t(t,n){const o=(n=n||{}).delimiter||".",i=n.maxDepth,a=n.transformKey||r,s={};return function r(t,l,u){u=u||1,Object.keys(t).forEach(function(c){const f=t[c],p=n.safe&&Array.isArray(f),h=Object.prototype.toString.call(f),d=e(f),y="[object Object]"===h||"[object Array]"===h,v=l?l+o+a(c):a(c);if(!p&&!d&&y&&Object.keys(f).length&&(!n.maxDepth||u<i))return r(f,v,u+1);s[v]=f})}(t),s}return O=1,g=t,t.flatten=t,t.unflatten=function n(o,i){const a=(i=i||{}).delimiter||".",s=i.overwrite||!1,l=i.transformKey||r,u={};if(e(o)||"[object Object]"!==Object.prototype.toString.call(o))return o;function c(e){const r=Number(e);return isNaN(r)||-1!==e.indexOf(".")||i.object?e:r}return o=Object.keys(o).reduce(function(e,r){const n=Object.prototype.toString.call(o[r]);return!("[object Object]"===n||"[object Array]"===n)||function(e){const r=Object.prototype.toString.call(e),t="[object Array]"===r,n="[object Object]"===r;if(!e)return!0;if(t)return!e.length;if(n)return!Object.keys(e).length}(o[r])?(e[r]=o[r],e):function(e,r,t){return Object.keys(t).reduce(function(r,n){return r[e+a+n]=t[n],r},r)}(r,e,t(o[r],i))},{}),Object.keys(o).forEach(function(e){const r=e.split(a).map(l);let t=c(r.shift()),f=c(r[0]),p=u;for(;void 0!==f;){if("__proto__"===t)return;const e=Object.prototype.toString.call(p[t]),n="[object Object]"===e||"[object Array]"===e;if(!s&&!n&&void 0!==p[t])return;(s&&!n||!s&&null==p[t])&&(p[t]="number"!=typeof f||i.object?{}:[]),p=p[t],r.length>0&&(t=c(r.shift()),f=c(r[0]))}p[t]=n(o[e],i)}),u},g}(),E=u(A),I={};var P=function(){if(k)return I;k=1;var e=/~/,r=/~[01]/g;function t(e){switch(e){case"~1":return"/";case"~0":return"~"}throw new Error("Invalid tilde escape: "+e)}function n(n){return e.test(n)?n.replace(r,t):n}function o(e){if("string"==typeof e){if(""===(e=e.split("/"))[0])return e;throw new Error("Invalid JSON pointer.")}if(Array.isArray(e)){for(const r of e)if("string"!=typeof r&&"number"!=typeof r)throw new Error("Invalid JSON pointer. Must be of type string or number.");return e}throw new Error("Invalid JSON pointer.")}function i(e,r){if("object"!=typeof e)throw new Error("Invalid input object.");var t=(r=o(r)).length;if(1===t)return e;for(var i=1;i<t;){if(e=e[n(r[i++])],t===i)return e;if("object"!=typeof e||null===e)return}}function a(e,r,t){if("object"!=typeof e)throw new Error("Invalid input object.");if(0===(r=o(r)).length)throw new Error("Invalid JSON pointer for set.");return function(e,r,t){for(var o,i,a=1,s=r.length;a<s;){if("constructor"===r[a]||"prototype"===r[a]||"__proto__"===r[a])return e;if(o=n(r[a++]),i=s>a,void 0===e[o]&&(Array.isArray(e)&&"-"===o&&(o=e.length),i&&(""!==r[a]&&r[a]<1/0||"-"===r[a]?e[o]=[]:e[o]={})),!i)break;e=e[o]}var l=e[o];return void 0===t?delete e[o]:e[o]=t,l}(e,r,t)}return I.get=i,I.set=a,I.compile=function(e){var r=o(e);return{get:function(e){return i(e,r)},set:function(e,t){return a(e,r,t)}}},I}(),R=u(P);var C,S={};var _=(C||(C=1,Object.defineProperty(S,"__esModule",{value:!0}),S.ProblemDocument=void 0,S.ProblemDocument=class{constructor(e){Object.assign(this,e)}}),S),U=function(e){var r=e.rel,t=e.uri,o=e.method,i=e.parameters,a=e.accept,s=e.anchor,l=n(e,["rel","uri","method","parameters","accept","anchor"]);this.rel=r,this.uri=t,this.method=o,this.parameters=i||{},this.accept=a,this.anchor=s,Object.assign(this,l)},T=function(e){function t(r,t,n,o){var i=e.call(this,r)||this;return i.response=t,i.defaultOptions=n,i.uri.includes("{this.")&&(i.uri=v.expand(i.uri,o)),i}return r(t,e),t.prototype.invokeAsFragment=function(e,r){if(this.uri.startsWith("#/")){var t=this.expandUrl(e).toString(),n=this.response.fullContent&&R.get(this.response.fullContent,t.slice(1));if(void 0===n)return;if(r){var o=r(n);if(X(o))return new Y({defaultOptions:this.defaultOptions,baseResponse:this.response.response,content:o.content,fullContent:this.response.fullContent,anchor:t,parentOperations:this.response.allOperations,parameters:e});throw new ee({problem:o.problem,response:new Y({defaultOptions:this.defaultOptions,baseResponse:this.response.response,content:n,fullContent:this.response.fullContent,parameters:e})})}return new Y({defaultOptions:this.defaultOptions,baseResponse:this.response.response,content:n,fullContent:this.response.fullContent,anchor:t,parentOperations:this.response.allOperations,parameters:e})}},t.prototype.invokeAll=function(e){return o(this,void 0,void 0,function(){var r;return i(this,function(t){return this.uri.startsWith("#/")&&this.response instanceof Y?(r=this.doInvokeAll((null==e?void 0:e.parameters)||{}),[2,Promise.all(r)]):[2,Promise.all([this.invoke(e)])]})})},t.prototype.doInvokeAll=function(e,r){var t=this,n=this.response,o=new v.Template(this.uri),i=Object.assign(v.parameters(this.uri),e),a=o.expand(i).replace(/%7B/g,"{").replace(/%7D/g,"}"),u=v.parameters(a),c=Object.keys(u);if(0!==c.length){var f=u[c[0]],p=a.slice(1,a.indexOf(f)-1),h=""===p?n.content:R.get(n.content,p);if(h)return(Array.isArray(h)?l([],s(Array.from({length:h.length}).keys()),!1):Object.keys(h)).flatMap(function(n){var o,i=Object.assign({},e,((o={})[c[0]]=n,o));return t.doInvokeAll(i,r)});throw new ee({response:this.response,problem:new _.ProblemDocument({type:"https://waychaser.io/fragment-uri-error",title:"The fragment URI does not match the content structure",uri:p,content:n.content,parameters:e})})}return[this.invokeAsFragment(e,r)]},t.prototype.invoke=function(e){return o(this,void 0,void 0,function(){var r,t,n,o,s,l,u,c,f,p,h,d,y,v,b,m,g,O;return i(this,function(i){if(this.uri.startsWith("#/"))return[2,this.invokeAsFragment(null==e?void 0:e.parameters)];if(r=this.parameters||{},t=Object.assign({},this.defaultOptions.parameters,null==e?void 0:e.parameters),n=this.url(t),o={},Array.isArray(r))try{for(s=a(r),l=s.next();!l.done;l=s.next())f=l.value,o[f]=null==t?void 0:t[f]}catch(e){b={error:e}}finally{try{l&&!l.done&&(m=s.return)&&m.call(s)}finally{if(b)throw b.error}}else try{for(u=a(Object.keys(r)),c=u.next();!c.done;c=u.next())f=c.value,o[f]=null==t?void 0:t[f]}catch(e){g={error:e}}finally{try{c&&!c.done&&(O=u.return)&&O.call(u)}finally{if(g)throw g.error}}if(p=void 0,h={},(d=Object.assign({},e)).method=this.method,0!==Object.keys(this.parameters).length&&(k=this.method||"GET",!["GET","DELETE","TRACE","OPTIONS","HEAD"].includes(k))){switch(y=x(this.accept,["application/x-www-form-urlencoded","application/json","multipart/form-data"],"application/x-www-form-urlencoded")){case"application/x-www-form-urlencoded":p=w(o);break;case"application/json":p=JSON.stringify(o);break;case"multipart/form-data":for(v in p=new j,o)p.append(v,o[v])}"multipart/form-data"!==y&&(h={"content-type":y}),d.body=p,d.headers=Object.assign(h,null==e?void 0:e.headers)}return[2,te(n.toString(),this.defaultOptions,d)];var k})})},t.prototype.url=function(e){var r=this.expandUrl(e);return new URL(r,this.response.url)},t.prototype.expandUrl=function(e){return v.expand(this.uri,E(e||{}))},t}(U),q=function(e){function t(r){return e.apply(this,l([],s(r||[]),!1))||this}return r(t,e),t.create=function(){return Object.create(t.prototype)},t.prototype.find=function(e,r){var t=Array.prototype.find.bind(this);return t("string"==typeof e?N({rel:e}):"object"==typeof e?N(e):e,r)},t.prototype.filter=function(e,r){if("string"==typeof e)return this.filter({rel:e},r);if("object"==typeof e)return this.filter(N(e),r);var n=Array.prototype.filter.bind(this)(e);return Object.setPrototypeOf(n,t.prototype),n},t.prototype.invoke=function(e,r){var t=this.find(e);return t?t.invoke(r):void 0},t.prototype.invokeAll=function(e,r){var t=this.filter(e);return Promise.all(t.map(function(e){return e.invokeAll(r)})).then(function(e){return e.flat()})},t}(Array);function N(e){return function(r){for(var t in e)if(e[t]!==r[t])return!1;return!0}}function D(e){var r,t,n,o,i=[],s=/{\[(\d+)..(\d+)]}/,l=e.uri.toString(),u=l.match(s);if(u)for(var c=Number.parseInt(u[1]);c<=Number.parseInt(u[2]);++c){var f=D(new U(Object.assign(e,{uri:l.replace(s,c.toFixed(0))})));try{for(var p=(r=void 0,a(f)),h=p.next();!h.done;h=p.next()){var d=h.value;i.push(d)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(t=p.return)&&t.call(p)}finally{if(r)throw r.error}}}else{var y=e.anchor,v=null==y?void 0:y.match(s);if(y&&v)for(c=Number.parseInt(v[1]);c<=Number.parseInt(v[2]);++c){f=D(new U(Object.assign(e,{anchor:y.replace(s,c.toFixed(0))})));try{for(var b=(n=void 0,a(f)),m=b.next();!m.done;m=b.next()){var w=m.value;i.push(w)}}catch(e){n={error:e}}finally{try{m&&!m.done&&(o=b.return)&&o.call(b)}finally{if(n)throw n.error}}}else i.push(e)}return i}var F,L,H="application/hal+json",$="application/vnd.siren+json";function B(e,r){var t=e.split(/:(.+)/);if(t.length>1){var n=s(t,2),o=n[0],i=n[1];return r[o]?v.expand(r[o],{rel:i}):e}return e}function J(e,r,o){var i=r.href;r.templated;var a=n(r,["href","templated"]);return new U(t({rel:B(e,o),uri:i},a))}var M,W,G=function(){if(L)return F;L=1;var e=/^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i,r=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/\s|\uFEFF|\xA0/,n=/\r?\n[\x20\x09]+/g,o=/[;,"]/,i=/[;,"]|\s/,a=/^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/,s=1,l=2,u=4;function c(e){return e.replace(r,"")}function f(e){return t.test(e)}function p(e,r){for(;f(e[r]);)r++;return r}function h(e){return i.test(e)||!a.test(e)}class d{constructor(e){this.refs=[],e&&this.parse(e)}rel(e){for(var r=[],t=e.toLowerCase(),n=0;n<this.refs.length;n++)"string"==typeof this.refs[n].rel&&this.refs[n].rel.toLowerCase()===t&&r.push(this.refs[n]);return r}get(e,r){e=e.toLowerCase(),r=r.toLowerCase();for(var t=[],n=0;n<this.refs.length;n++)"string"==typeof this.refs[n][e]&&this.refs[n][e].toLowerCase()===r&&t.push(this.refs[n]);return t}set(e){return this.refs.push(e),this}setUnique(e){return this.refs.some(r=>{return t=r,n=e,Object.keys(t).length===Object.keys(n).length&&Object.keys(t).every(e=>e in n&&t[e]===n[e]);var t,n})||this.refs.push(e),this}has(e,r){e=e.toLowerCase(),r=r.toLowerCase();for(var t=0;t<this.refs.length;t++)if("string"==typeof this.refs[t][e]&&this.refs[t][e].toLowerCase()===r)return!0;return!1}parse(e,r){e=c(e=(r=r||0)?e.slice(r):e).replace(n,"");for(var t=s,i=e.length,a=(r=0,null);r<i;)if(t===s){if(f(e[r])){r++;continue}if("<"!==e[r])throw new Error('Unexpected character "'+e[r]+'" at offset '+r);if(null!=a&&(null!=a.rel?this.refs.push(...d.expandRelations(a)):this.refs.push(a)),-1===(v=e.indexOf(">",r)))throw new Error("Expected end of URI delimiter at offset "+r);a={uri:e.slice(r+1,v)},r=v,t=l,r++}else if(t===l){if(f(e[r])){r++;continue}if(";"===e[r])t=u,r++;else{if(","!==e[r])throw new Error('Unexpected character "'+e[r]+'" at offset '+r);t=s,r++}}else{if(t!==u)throw new Error('Unknown parser state "'+t+'"');if(";"===e[r]||f(e[r])){r++;continue}-1===(v=e.indexOf("=",r))&&(v=e.indexOf(";",r)),-1===v&&(v=e.length);var h=c(e.slice(r,v)).toLowerCase(),y="";if('"'===e[r=p(e,r=v+1)])for(r++;r<i;){if('"'===e[r]){r++;break}"\\"===e[r]&&r++,y+=e[r],r++}else{for(var v=r+1;!o.test(e[v])&&v<i;)v++;y=e.slice(r,v),r=v}switch(a[h]&&d.isSingleOccurenceAttr(h)||("*"===h[h.length-1]?a[h]=d.parseExtendedValue(y):(y="type"===h?y.toLowerCase():y,null!=a[h]?Array.isArray(a[h])?a[h].push(y):a[h]=[a[h],y]:a[h]=y)),e[r]){case",":t=s;break;case";":t=u}r++}return null!=a&&(null!=a.rel?this.refs.push(...d.expandRelations(a)):this.refs.push(a)),a=null,this}toString(){for(var e=[],r="",t=null,n=0;n<this.refs.length;n++)t=this.refs[n],r=Object.keys(this.refs[n]).reduce(function(e,r){return"uri"===r?e:e+"; "+d.formatAttribute(r,t[r])},"<"+t.uri+">"),e.push(r);return e.join(", ")}}return d.isCompatibleEncoding=function(r){return e.test(r)},d.parse=function(e,r){return(new d).parse(e,r)},d.isSingleOccurenceAttr=function(e){return"rel"===e||"type"===e||"media"===e||"title"===e||"title*"===e},d.isTokenAttr=function(e){return"rel"===e||"type"===e||"anchor"===e},d.escapeQuotes=function(e){return e.replace(/"/g,'\\"')},d.expandRelations=function(e){return e.rel.split(" ").map(function(r){var t=Object.assign({},e);return t.rel=r,t})},d.parseExtendedValue=function(e){var r=/([^']+)?(?:'([^']*)')?(.+)/.exec(e);return{language:r[2].toLowerCase(),encoding:d.isCompatibleEncoding(r[1])?null:r[1].toLowerCase(),value:d.isCompatibleEncoding(r[1])?decodeURIComponent(r[3]):r[3]}},d.formatExtendedAttribute=function(e,r){var t=(r.encoding||"utf-8").toUpperCase();return e+"="+t+"'"+(r.language||"en")+"'"+(Buffer.isBuffer(r.value)&&d.isCompatibleEncoding(t)?r.value.toString(t):Buffer.isBuffer(r.value)?r.value.toString("hex").replace(/[0-9a-f]{2}/gi,"%$1"):encodeURIComponent(r.value))},d.formatAttribute=function(e,r){return Array.isArray(r)?r.map(r=>d.formatAttribute(e,r)).join("; "):"*"===e[e.length-1]||"string"!=typeof r?d.formatExtendedAttribute(e,r):(d.isTokenAttr(e)?r=h(r)?'"'+d.escapeQuotes(r)+'"':d.escapeQuotes(r):h(r)&&(r='"'+(r=(r=encodeURIComponent(r)).replace(/%20/g," ").replace(/%2C/g,",").replace(/%3B/g,";"))+'"'),e+"="+r)},F=d}(),Q=u(G);function K(e){return e?Q.parse(e).refs.map(function(e){var r=e.rel,o=e.uri,i=e.method,a=e["accept*"],s=e["params*"],l=n(e,["rel","uri","method","accept*","params*"]),u=(null==s?void 0:s.value)?JSON.parse(null==s?void 0:s.value):void 0;return new U(t({rel:r,uri:o,method:i,parameters:u,accept:null==a?void 0:a.value},l))}):[]}function V(e){var r,o,i=e.name,s=e.href,l=e.fields,u=e.type,c=n(e,["name","href","fields","type"]),f={};if(l)try{for(var p=a(l),h=p.next();!h.done;h=p.next()){f[h.value.name]={}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}return t({rel:i,uri:s,accept:u,parameters:l&&f},c)}function z(e,r){var o=r.href;r.rel;var i=n(r,["href","rel"]);return new U(t({rel:e,uri:o},i))}function Z(e,r){var o=e.handlers,i=e.defaultHandlers,a=e.headers,u=e.contentParser,c=n(e,["handlers","defaultHandlers","headers","contentParser"]),f=r||{},p=f.handlers,h=f.defaultHandlers,d=f.headers,y=f.contentParser,v=n(f,["handlers","defaultHandlers","headers","contentParser"]),b=re(l(l([],s(p||o||[]),!1),s(h||i||[]),!1)),m=y?function(e){return y(e,u)}:u;return t(t(t({},c),v),{defaultHandlers:b,handlers:[],headers:t(t({},a),d),contentParser:m})}function X(e){return e.success}var Y=function(){function e(e){var r,t,n,o,i,s,l=e.handlers,u=e.defaultOptions,c=e.baseResponse,f=e.content,p=e.fullContent,h=e.anchor,d=e.parentOperations,y=e.parameters;this.response=c,this.anchor=h,this.parameters=y||{},this.fullContent=p||f,this.content=f,this.operations=q.create();var b=E({this:f});if(d&&h&&u){this.allOperations=d;try{for(var m=a(this.allOperations[h]||[]),w=m.next();!w.done;w=m.next()){var g=w.value;this.operations.push(new T(g,this,u,b))}}catch(e){r={error:e}}finally{try{w&&!w.done&&(t=m.return)&&t.call(m)}finally{if(r)throw r.error}}for(var O in this.allOperations)if(""!==O){var j=new v.Template(O),x=j.match(this.anchor);if(j.expand(x)===this.anchor){var k=Object.assign({},u,{parameters:Object.assign(x,u.parameters)});try{for(var A=(n=void 0,a(this.allOperations[O])),I=A.next();!I.done;I=A.next()){g=I.value;this.operations.push(new T(g,this,k,b))}}catch(e){n={error:e}}finally{try{I&&!I.done&&(o=A.return)&&o.call(A)}finally{if(n)throw n.error}}}}}else if(c&&l&&u){this.allOperations=function(e){var r,t,n,o,i,s,l,u,c=e.handlers,f=e.baseResponse,p=e.content,h=[],d=!1;try{for(var y=a(c),v=y.next();!v.done;v=y.next()){var b=v.value.handler(f,p,function(){d=!0});if(b)try{for(var m=(n=void 0,a(b)),w=m.next();!w.done;w=m.next()){var g=w.value;h.push(g)}}catch(e){n={error:e}}finally{try{w&&!w.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}if(d)break}}catch(e){r={error:e}}finally{try{v&&!v.done&&(t=y.return)&&t.call(y)}finally{if(r)throw r.error}}var O={};try{for(var j=a(h),x=j.next();!x.done;x=j.next()){var k=D(g=x.value);try{for(var A=(l=void 0,a(k)),E=A.next();!E.done;E=A.next()){var I=E.value,P=I.anchor||"";O[P]||(O[P]=[]),O[P].push(I)}}catch(e){l={error:e}}finally{try{E&&!E.done&&(u=A.return)&&u.call(A)}finally{if(l)throw l.error}}}}catch(e){i={error:e}}finally{try{x&&!x.done&&(s=j.return)&&s.call(j)}finally{if(i)throw i.error}}return O}({baseResponse:c,content:f,handlers:l}),this.operations=q.create();try{for(var P=a(this.allOperations[""]||[]),R=P.next();!R.done;R=P.next()){g=R.value;var C=new T(g,this,u,b);this.operations.push(C)}}catch(e){i={error:e}}finally{try{R&&!R.done&&(s=P.return)&&s.call(P)}finally{if(i)throw i.error}}}}return e.create=function(r,t,n,o){if(t instanceof _.ProblemDocument)throw new ee({response:new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:t,parameters:o.parameters}),problem:t});if(o.validator){var i=o.validator(t);if(X(i))return new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:i.content,parameters:o.parameters});throw new ee({response:new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:t,parameters:o.parameters}),problem:i.problem})}return new e({handlers:o.defaultHandlers,defaultOptions:n,baseResponse:r,content:t,parameters:o.parameters})},Object.defineProperty(e.prototype,"ops",{get:function(){return this.operations},enumerable:!1,configurable:!0}),e.prototype.invoke=function(e,r){return this.operations.invoke(e,r)},e.prototype.invokeAll=function(e,r){return this.operations.invokeAll(e,r)},Object.defineProperty(e.prototype,"body",{get:function(){throw new Error("Not Implemented. Use `.content` instead")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bodyUsed",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"headers",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.headers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ok",{get:function(){return!!this.response&&this.response.ok},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"redirected",{get:function(){return!!this.response&&this.response.redirected},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statusText",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.statusText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){var e;return null===(e=this.response)||void 0===e?void 0:e.url},enumerable:!1,configurable:!0}),e.prototype.arrayBuffer=function(){throw new Error("Not Implemented. Use `.content` instead")},e.prototype.blob=function(){throw new Error("Not Implemented. Use `.content` instead")},e.prototype.clone=function(){throw new Error("Not Implemented")},e.prototype.formData=function(){throw new Error("Not Implemented. Use `.content` instead")},e.prototype.text=function(){throw new Error("Not Implemented. Use `.content` instead")},e}(),ee=function(e){function t(r){var t=this.constructor,n=r.response,o=r.problem,i=e.call(this,o.detail)||this,a=t.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(i,a):i.__proto__=a,i.problem=o,i.response=n,i}return r(t,e),t}(Error);function re(e){return e.sort(function(e,r){return(r.q||1)-(e.q||1)})}function te(e,r,n){var u;return o(this,void 0,void 0,function(){var o,c,f,p,h,d,y,v,b,m,w,g,O,j,x,k,A,E,I,P,R,C,S,U,T;return i(this,function(i){switch(i.label){case 0:if(o=Z(r,n),c=o.defaultHandlers,!o.fetch)throw new Error("No global fetch and fetch not provided in options");f=function(e){var r,t,n,o,i=[];try{for(var s=a(e),l=s.next();!l.done;l=s.next()){var u=l.value;try{for(var c=(n=void 0,a(u.mediaRanges)),f=c.next();!f.done;f=c.next()){var p=f.value;"object"==typeof p?u.q?i.push({type:p.mediaType,q:u.q*(p.q||1)}):i.push({type:p.mediaType,q:p.q||1}):u.q?i.push({type:p,q:u.q}):i.push({type:p,q:1})}}catch(e){n={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(t=s.return)&&t.call(s)}finally{if(r)throw r.error}}var h=i.sort(function(e,r){return e.q-r.q}),d=new Set;return h.filter(function(e){var r=e.type;return!d.has(r)&&d.add(r)})}(c),p=f.map(function(e){return 1===e.q?e.type:"".concat(e.type,";q=").concat(e.q)}),h=(null===(u=null==n?void 0:n.headers)||void 0===u?void 0:u.accept)?[n.headers.accept]:[],d=l(l([],s(h),!1),s(p),!1).join(","),y=t(t({},o),{headers:t(t({},o.headers),{accept:d})}),v=!1;try{for(b=a(y.preInterceptors||[]),m=b.next();!m.done&&((0,m.value)(e,y,function(){return v=!0}),!v);m=b.next());}catch(e){P={error:e}}finally{try{m&&!m.done&&(R=b.return)&&R.call(b)}finally{if(P)throw P.error}}return[4,o.fetch(e.toString(),y)];case 1:w=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,o.contentParser(w)];case 3:g=i.sent(),k=Y.create(w,g,r,o),v=!1;try{for(O=a(y.postInterceptors),j=O.next();!j.done&&((0,j.value)(k,function(){return v=!0}),!v);j=O.next());}catch(e){C={error:e}}finally{try{j&&!j.done&&(S=O.return)&&S.call(O)}finally{if(C)throw C.error}}return[2,k];case 4:x=i.sent(),k=new Y({handlers:o.defaultHandlers,defaultOptions:r,baseResponse:w,content:x,parameters:o.parameters}),A=x instanceof _.ProblemDocument?new ee({response:k,problem:x}):new ee({response:k,problem:new _.ProblemDocument({type:"https://waychaser.io/unexected-error",title:"An unexpected error occurred",error:x})}),v=!1;try{for(E=a(y.postErrorInterceptors),I=E.next();!I.done&&((0,I.value)(A,function(){return v=!0}),!v);I=E.next());}catch(e){U={error:e}}finally{try{I&&!I.done&&(T=E.return)&&T.call(E)}finally{if(U)throw U.error}}throw A;case 5:return[2]}})})}var ne={fetch:"undefined"!=typeof window?null===(M=window.fetch)||void 0===M?void 0:M.bind(window):null===(W="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0)||void 0===W?void 0:W.fetch,handlers:[],defaultHandlers:re([{handler:function(e){var r=null==e?void 0:e.headers.get("location");return r?[new U({rel:"related",uri:r})]:[]},mediaRanges:["*/*"],q:.4},{handler:function(e,r,t){return l(l([],s(K(e.headers.get("link"))),!1),s(K(e.headers.get("link-template"))),!1)},mediaRanges:["*/*"],q:.5},{handler:function(e,r){var t,n,o,i,s,l,u,c=[],f=null===(u=e.headers.get("content-type"))||void 0===u?void 0:u.split(";");if((null==f?void 0:f[0])===H&&r&&"object"==typeof r&&"_links"in r){var p=r,h={};if(p._links.curies)if(Array.isArray(p._links.curies))try{for(var d=a(p._links.curies),y=d.next();!y.done;y=d.next()){var v=y.value;h[v.name]=v.href}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}else h[p._links.curies.name]=p._links.curies.href;try{for(var b=a(Object.keys(p._links).filter(function(e){return"curies"!==e})),m=b.next();!m.done;m=b.next()){var w=m.value;if(Array.isArray(p._links[w]))try{for(var g=(s=void 0,a(p._links[w])),O=g.next();!O.done;O=g.next()){var j=O.value;c.push(J(w,j,h))}}catch(e){s={error:e}}finally{try{O&&!O.done&&(l=g.return)&&l.call(g)}finally{if(s)throw s.error}}else c.push(J(w,p._links[w],h))}}catch(e){o={error:e}}finally{try{m&&!m.done&&(i=b.return)&&i.call(b)}finally{if(o)throw o.error}}}return c},mediaRanges:[H],q:.5},{handler:function(e,r){var t,n=null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";");return(null==n?void 0:n[0])===$?l(l([],s(function(e){var r,t,n,o,i=[];if(e&&"object"==typeof e&&"links"in e){var s=e;if(s.links)try{for(var l=a(s.links),u=l.next();!u.done;u=l.next()){var c=u.value;try{for(var f=(n=void 0,a(c.rel)),p=f.next();!p.done;p=f.next()){var h=z(p.value,c);i.push(h)}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{u&&!u.done&&(t=l.return)&&t.call(l)}finally{if(r)throw r.error}}}return i}(r)),!1),s(function(e){var r,t,n=[];if(e&&"object"==typeof e&&"actions"in e){var o=e;if(o.actions)try{for(var i=a(o.actions),s=i.next();!s.done;s=i.next()){var l=V(s.value);n.push(l)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}}return n}(r)),!1):[]},mediaRanges:[$],q:.5}]),preInterceptors:[],postInterceptors:[],postErrorInterceptors:[],contentParser:function(e){return o(void 0,void 0,void 0,function(){var r,t,n,o,a;return i(this,function(i){switch(i.label){case 0:return e.headers.get("content-length")&&"0"!==e.headers.get("content-length")?[4,e.text()]:[3,2];case 1:if(r=i.sent(),null==(t=null===(a=null===(o=e.headers.get("content-type"))||void 0===o?void 0:o.split(";"))||void 0===a?void 0:a[0])?void 0:t.endsWith("json")){if(n=function(e,r){try{return JSON.parse(e)}catch(t){throw new _.ProblemDocument({type:"https://waychaser.io/invalid-json",title:"JSON response could not be parsed",detail:"The response document with content type '".concat(r,"' could not be parsed as json"),content:e,error:t})}}(r,t),"application/problem+json"===t)throw Object.assign(new _.ProblemDocument(n),n);return[2,n]}i.label=2;case 2:return[2]}})})}};function oe(e,r){var t=Z(r,e),n=function(e,r){return te(e,t,r)};return n.currentDefaults=t,n.defaults=function(e){return oe(e,t)},n}var ie=Object.assign(function(e,r){return te(e,ne,r)},{currentDefaults:ne,defaults:function(e){return oe(e,ne)}});export{ee as WayChaserProblem,Y as WayChaserResponse,te as _waychaser,X as isValidationSuccess,re as sortHandlers,ie as waychaser};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mountainpass/waychaser",
3
- "version": "5.0.14",
3
+ "version": "5.0.16",
4
4
  "description": "Client library for HATEOAS level 3 RESTful APIs that provide hypermedia controls",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,13 +40,16 @@
40
40
  "engines": {
41
41
  "node": ">=14.17.0"
42
42
  },
43
+ "overrides": {
44
+ "serialize-javascript": "^6.0.2"
45
+ },
43
46
  "config": {
44
47
  "TEST_API_PORT": 6060
45
48
  },
46
49
  "scripts": {
47
50
  "dry-aged-deps": "dry-aged-deps --check",
48
51
  "env": "env",
49
- "build:browser": "rollup --config rollup.config.${npm_lifecycle_event#build:}.js",
52
+ "build:browser": "rollup --config rollup.config.${npm_lifecycle_event#build:}.mjs",
50
53
  "build:node": "tsc --project tsconfig.production.json",
51
54
  "build": "npm-run-all --sequential build:*",
52
55
  "serve": "npm run build && API_PORT=${npm_package_config_TEST_API_PORT} ts-node scripts/development-server.js",
@@ -137,7 +140,8 @@
137
140
  "/dist/**/*.d.ts"
138
141
  ],
139
142
  "dependencies": {
140
- "@mountainpass/problem-document": "^0.0.45",
143
+ "@mountainpass/problem-document": "^0.0.56",
144
+ "@rollup/plugin-terser": "^1.0.0",
141
145
  "@types/flat": "^5.0.2",
142
146
  "flat": "^5.0.2",
143
147
  "form-data": "^4.0.0",
@@ -150,31 +154,30 @@
150
154
  "@commitlint/cli": "^13.1.0",
151
155
  "@commitlint/config-conventional": "^12.0.0",
152
156
  "@cucumber/cucumber": "^7.3.2",
153
- "@rollup/plugin-commonjs": "^20.0.0",
154
- "@rollup/plugin-json": "^4.1.0",
155
- "@rollup/plugin-node-resolve": "^13.0.0",
156
- "@rollup/plugin-typescript": "^8.3.0",
157
+ "@rollup/plugin-commonjs": "^29.0.2",
158
+ "@rollup/plugin-json": "^6.1.0",
159
+ "@rollup/plugin-node-resolve": "^16.0.3",
160
+ "@rollup/plugin-typescript": "^12.3.0",
157
161
  "@types/chai": "^4.3.0",
158
162
  "@types/node": "^17.0.8",
159
163
  "@typescript-eslint/eslint-plugin": "^5.12.0",
160
164
  "@typescript-eslint/parser": "^5.12.0",
161
165
  "aws4": "^1.11.0",
162
- "body-parser": "^1.19.0",
166
+ "body-parser": "^2.2.2",
163
167
  "browserstack-local": "^1.4.8",
164
168
  "bufferutil": "^4.0.2",
165
169
  "chai": "^4.2.0",
166
170
  "chai-as-promised": "^7.1.1",
167
171
  "chromedriver": "^95.0.0",
168
- "concurrently": "^6.0.0",
172
+ "concurrently": "^9.2.1",
169
173
  "conventional-changelog-cli": "^2.1.1",
170
174
  "conventional-recommended-bump": "^6.1.0",
171
175
  "core-js": "^3.7.0",
172
- "cross-fetch": "^3.1.5",
176
+ "cross-fetch": "^4.1.0",
173
177
  "cucumber-tsflow": "^4.0.0-preview.7",
174
178
  "dateformat": "^4.4.1",
175
179
  "debug": "^4.3.3",
176
180
  "depcheck": "^1.2.0",
177
- "dirty-chai": "^2.0.1",
178
181
  "dry-aged-deps": "^2.6.0",
179
182
  "eslint": "^8.18.0",
180
183
  "eslint-config-prettier": "^8.5.0",
@@ -194,7 +197,7 @@
194
197
  "eslint-plugin-security": "^1.4.0",
195
198
  "eslint-plugin-unicorn": "^42.0.0",
196
199
  "express": "^4.16.3",
197
- "fs-extra": "^10.0.0",
200
+ "fs-extra": "^11.3.4",
198
201
  "geckodriver": "^1.20.0",
199
202
  "http-terminator": "^3.0.0",
200
203
  "humanize-duration": "^3.24.0",
@@ -206,19 +209,18 @@
206
209
  "lint-staged": "^11.0.0",
207
210
  "localtunnel": "^2.0.1",
208
211
  "markdownlint": "^0.23.0",
209
- "moment-timezone": "^0.5.31",
210
- "multer": "^1.4.2",
211
- "nodemon": "^2.0.4",
212
+ "moment-timezone": "^0.6.0",
213
+ "multer": "^2.1.1",
214
+ "nodemon": "^3.1.14",
212
215
  "npm-check": "^5.9.0",
213
216
  "npm-run-all": "^4.1.5",
214
217
  "nyc": "^15.1.0",
215
218
  "prettier": "2.3.1",
216
- "rollup": "^2.52.1",
217
- "rollup-plugin-terser": "^7.0.2",
219
+ "rollup": "^4.59.0",
218
220
  "selenium-webdriver": "^4.0.0-beta.4",
219
221
  "shellcheck": "^1.0.0",
220
222
  "snyk": "^1.431.1",
221
- "start-server-and-test": "^1.11.7",
223
+ "start-server-and-test": "^2.1.5",
222
224
  "temp": "^0.9.4",
223
225
  "ts-node": "^10.5.0",
224
226
  "tslib": "^2.3.1",