@muze-nl/jsfs-solid 0.1.0
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/.eslintrc.cjs +26 -0
- package/dist/browser.js +3039 -0
- package/dist/browser.js.map +7 -0
- package/dist/browser.min.js +2 -0
- package/dist/browser.min.js.map +7 -0
- package/eslint.config.js +7 -0
- package/package.json +37 -0
- package/src/SolidAdapter.js +47 -0
- package/src/browser.js +5 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(()=>{var Ze=Object.defineProperty;var Qe=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})};var x=class e{#e;constructor(t){this.#e=e.collapse(t)}get value(){return this.#e}toString(){return this.#e}get length(){return this.#e.length}static collapse(t,r=""){if(t instanceof e)return t.value;if(typeof t!="string")throw new TypeError("path argument must be a string or an instance of Path");if(r&&!(r instanceof e)&&(r=new e(r)),t=t.trim(),t.length===0)return r.value;e.isRelative(t)&&(t=r+t);let n=e.reduce(t,(i,s)=>(s==".."?i.pop():s!=="."&&i.push(s),i),[]),o="/";return n.length&&(o+=n.join("/"),e.isFolder(t)&&(o+="/")),o}static isAbsolute(t){return t instanceof e?!0:t.length&&t[0]==="/"}static isRelative(t){return!e.isAbsolute(t)}static isFolder(t){return t instanceof e&&(t=t.value),t.length&&t[t.length-1]=="/"}static isPath(t){return t instanceof e?!0:typeof t!="string"?!1:(t=t.trim(),new URL(t,document.location).pathname==t)}static reduce(t,r,n){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).reduce(r,n)}static map(t,r){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).map(r)}static parent(t){t instanceof e&&(t=t.value),t=t.split("/").filter(Boolean),t.pop();let r="/";return t.length&&(r+=t.join("/")+"/"),r}static filename(t){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).pop()}static head(t){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).shift()}static tail(t){t instanceof e&&(t=t.value),t=t.split("/").filter(Boolean),t.shift();let r="/";return t.length&&(r+=t.join("/")+"/"),r}};var V=class e{#e;#r;#o;#t;constructor(t,r="/",n=null,o={}){this.#e=new URL(t,window.location.href),this.#r=new x(r),this.#o=n,this.#t=o}get name(){return"HttpAdapter"}get path(){return this.#r}supportsWrite(){return!0}supportsStreamingWrite(){return Xe}supportsStreamingRead(){return!0}cd(t){if(!x.isPath(t))throw new TypeError(t+" is not a valid path");return new e(this.#e.href,t)}async write(t,r,n=null){let o=Object.assign({},this.#t,{method:"PUT",body:r});return this.#n(t,o)}writeStream(t,r,n=null){throw new Error("Not yet implemented")}async read(t){let r=Object.assign({},this.#t,{method:"GET"}),n=await this.#n(t,r),o={type:this.#s(n),name:x.filename(t),http:{headers:n.headers,status:n.status,url:n.url}};return o.type.match(/text\/.*/)?o.contents=await n.text():o.type.match(/application\/json.*/)?o.contents=await n.json():o.contents=await n.blob(),o}readStream(t,r){throw new Error("Not yet implemented")}async exists(t){let r=Object.assign({},this.#t,{method:"HEAD"});return this.#n(t,r)}async delete(t){let r=Object.assign({},this.#t,{method:"DELETE"});return this.#n(t,r)}async list(t){let r=["text/html","text/xhtml","text/xhtml+xml","text/xml"],n=await this.read(t);if(r.includes(n.type.split(";")[0]))var o=n.contents;else{let d=this.#i(t);throw new TypeError("URL "+d+" is not of a supported content type",{cause:n})}let i=x.collapse(this.#e.pathname),s=this.#i(t),a=document.createElement("template");a.innerHTML=o;let p=a.content.querySelectorAll("a[href]");return Array.from(p).map(d=>{let u=new URL(d.getAttribute("href"),s.href);return d.href=u.href,{filename:x.filename(d.pathname),path:d.pathname,name:d.innerText,href:d.href}}).filter(d=>{let u=new URL(d.href);return u.pathname=x.parent(u.pathname),u.href===s.href}).map(d=>({filename:d.filename,path:d.path.substring(i.length-1),name:d.name}))}#i(t){return t=x.collapse(this.#e.pathname+x.collapse(t)),new URL(t,this.#e)}async#n(t,r){return fetch(this.#i(t),r).catch(n=>{if(!this.#o||!this.#o(url,r,n))throw n})}#s(t){return t.headers.has("Content-Type")?t.headers.get("Content-Type"):null}},Xe=(async()=>new Request("",{body:new ReadableStream,method:"POST",duplex:"half"}).headers.has("Content-Type")?!1:fetch("data:a/a;charset=utf-8,",{method:"POST",body:new ReadableStream,duplex:"half"}).then(()=>!0,()=>!1))();var B={};Qe(B,{Client:()=>v,client:()=>T,deepClone:()=>z,formdata:()=>Pe,metroError:()=>g,request:()=>F,response:()=>I,trace:()=>et,url:()=>_});var D="https://metro.muze.nl/details/";Symbol.metroProxy||(Symbol.metroProxy=Symbol("isProxy"));Symbol.metroSource||(Symbol.metroSource=Symbol("source"));var v=class e{clientOptions={url:_(typeof window<"u"?window.location:"https://localhost"),verbs:["get","post","put","delete","patch","head","options","query"]};static tracers={};constructor(...t){for(let r of t)if(typeof r=="string"||r instanceof String)this.clientOptions.url=_(this.clientOptions.url.href,r);else if(r instanceof Function)this.#e([r]);else if(r&&typeof r=="object")for(let n in r)n=="middlewares"?this.#e(r[n]):n=="url"?this.clientOptions.url=_(this.clientOptions.url.href,r[n]):typeof r[n]=="function"?this.clientOptions[n]=r[n](this.clientOptions[n],this.clientOptions):this.clientOptions[n]=r[n];for(let r of this.clientOptions.verbs)this[r]=async function(...n){return this.fetch(F(this.clientOptions,...n,{method:r.toUpperCase()}))}}#e(t){typeof t=="function"&&(t=[t]);let r=t.findIndex(n=>typeof n!="function");if(r>=0)throw g("metro.client: middlewares must be a function or an array of functions "+D+"client/invalid-middlewares/",t[r]);Array.isArray(this.clientOptions.middlewares)||(this.clientOptions.middlewares=[]),this.clientOptions.middlewares=this.clientOptions.middlewares.concat(t)}fetch(t,r){if(t=F(t,r),!t.url)throw g("metro.client."+t.method.toLowerCase()+": Missing url parameter "+D+"client/fetch-missing-url/",t);if(r||(r={}),typeof r!="object"||r instanceof String)throw g("metro.client.fetch: Invalid options parameter "+D+"client/fetch-invalid-options/",r);let o=[async function(a){a[Symbol.metroProxy]&&(a=a[Symbol.metroSource]);let p=await fetch(a);return I(p)}].concat(this.clientOptions?.middlewares?.slice()||[]);r=Object.assign({},this.clientOptions,r);let i;for(let s of o)i=(function(a,p){return async function(d){let u,f=Object.values(e.tracers);for(let l of f)l.request&&l.request.call(l,d,p);u=await p(d,a);for(let l of f)l.response&&l.response.call(l,u,p);return u}})(i,s);return i(t)}with(...t){return new e(z(this.clientOptions),...t)}get location(){return this.clientOptions.url}};function T(...e){return new v(...z(e))}function qe(e,t){let r=t||{};!r.url&&t.url&&(r.url=t.url);for(let n of["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","priority","url"]){let o=e[n];if(!(typeof o>"u"||o==null))if(o?.[Symbol.metroProxy]&&(o=o[Symbol.metroSource]),typeof o=="function")r[n]=o(r[n],r);else if(n=="url")r.url=_(r.url,o);else if(n=="headers"){r.headers=new Headers(t.headers),o instanceof Headers||(o=new Headers(e.headers));for(let[i,s]of o.entries())r.headers.set(i,s)}else r[n]=o}return e instanceof Request&&e.data&&(r.body=e.data),r}function F(...e){let t={url:_(typeof window<"u"?window.location:"https://localhost/"),duplex:"half"};for(let o of e)typeof o=="string"||o instanceof URL||o instanceof URLSearchParams?t.url=_(t.url,o):o&&(o instanceof FormData||o instanceof ReadableStream||o instanceof Blob||o instanceof ArrayBuffer||o instanceof DataView)?t.body=o:o&&typeof o=="object"&&Object.assign(t,qe(o,t));let r=new Request(t.url,t),n=t.body;return n&&typeof n=="object"&&!(n instanceof String)&&!(n instanceof ReadableStream)&&!(n instanceof Blob)&&!(n instanceof ArrayBuffer)&&!(n instanceof DataView)&&!(n instanceof FormData)&&!(n instanceof URLSearchParams)&&(typeof globalThis.TypedArray>"u"||!(n instanceof globalThis.TypedArray))&&typeof n.toString=="function"&&(t.body=n.toString({headers:r.headers}),r=new Request(t.url,t)),Object.freeze(r),new Proxy(r,{get(o,i){let s;switch(i){case Symbol.metroSource:s=o;break;case Symbol.metroProxy:s=!0;break;case"with":s=function(...a){return n&&a.unshift({body:n}),F(o,...a)};break;case"data":s=n;break;default:o[i]instanceof Function?s=o[i].bind(o):s=o[i];break}return s}})}function Ae(e,t){let r=t||{};!r.url&&t.url&&(r.url=t.url);for(let n of["status","statusText","headers","body","url","type","redirected"]){let o=e[n];typeof o>"u"||o==null||(o?.[Symbol.metroProxy]&&(o=o[Symbol.metroSource]),typeof o=="function"?r[n]=o(r[n],r):n=="url"?r.url=new URL(o,r.url||"https://localhost/"):r[n]=o)}return e instanceof Response&&e.data&&(r.body=e.data),r}function I(...e){let t={};for(let o of e)typeof o=="string"?t.body=o:o instanceof Response?Object.assign(t,Ae(o,t)):o&&typeof o=="object"&&(o instanceof FormData||o instanceof Blob||o instanceof ArrayBuffer||o instanceof DataView||o instanceof ReadableStream||o instanceof URLSearchParams||o instanceof String||typeof globalThis.TypedArray<"u"&&o instanceof globalThis.TypedArray?t.body=o:Object.assign(t,Ae(o,t)));let r;t.body&&(r=t.body),[101,204,205,304].includes(t.status)&&(t.body=null);let n=new Response(t.body,t);return Object.freeze(n),new Proxy(n,{get(o,i){let s;switch(i){case Symbol.metroProxy:s=!0;break;case Symbol.metroSource:s=o;break;case"with":s=function(...a){return I(o,...a)};break;case"data":s=r;break;case"ok":s=o.status>=200&&o.status<400;break;default:typeof o[i]=="function"?s=o[i].bind(o):s=o[i];break}return s}})}function ve(e,t){typeof t=="function"?t(e.searchParams,e):(t=new URLSearchParams(t),t.forEach((r,n)=>{e.searchParams.append(n,r)}))}function _(...e){let t=["hash","host","hostname","href","password","pathname","port","protocol","username","search","searchParams"],r=new URL("https://localhost/");for(let n of e)if(typeof n=="string"||n instanceof String)r=new URL(n,r);else if(n instanceof URL||typeof Location<"u"&&n instanceof Location)r=new URL(n);else if(n instanceof URLSearchParams)ve(r,n);else if(n&&typeof n=="object")for(let o in n)switch(o){case"search":typeof n.search=="function"?n.search(r.search,r):r.search=new URLSearchParams(n.search);break;case"searchParams":ve(r,n.searchParams);break;default:if(!t.includes(o))throw g("metro.url: unknown url parameter "+D+"url/unknown-param-name/",o);if(typeof n[o]=="function")n[o](r[o],r);else if(typeof n[o]=="string"||n[o]instanceof String||typeof n[o]=="number"||n[o]instanceof Number||typeof n[o]=="boolean"||n[o]instanceof Boolean)r[o]=""+n[o];else if(typeof n[o]=="object"&&n[o].toString)r[o]=n[o].toString();else throw g("metro.url: unsupported value for "+o+" "+D+"url/unsupported-param-value/",e[o]);break}else throw g("metro.url: unsupported option value "+D+"url/unsupported-option-value/",n);return Object.freeze(r),new Proxy(r,{get(n,o){let i;switch(o){case Symbol.metroProxy:i=!0;break;case Symbol.metroSource:i=n;break;case"with":i=function(...s){return _(n,...s)};break;case"filename":i=n.pathname.split("/").pop();break;case"folderpath":i=n.pathname.substring(0,n.pathname.lastIndexOf("\\")+1);break;case"authority":i=n.username??"",i+=n.password?":"+n.password:"",i+=i?"@":"",i+=n.hostname,i+=n.port?":"+n.port:"",i+="/",i=n.protocol+"//"+i;break;case"origin":i=n.protocol+"//"+n.hostname,i+=n.port?":"+n.port:"",i+="/";break;case"fragment":i=n.hash.substring(1);break;case"scheme":n.protocol?i=n.protocol.substring(0,n.protocol.length-1):i="";break;default:n[o]instanceof Function?i=n[o].bind(n):i=n[o];break}return i}})}function Pe(...e){var t=new FormData;for(let r of e)if(r instanceof HTMLFormElement&&(r=new FormData(r)),r instanceof FormData)for(let n of r.entries())t.append(n[0],n[1]);else if(r&&typeof r=="object")for(let n of Object.entries(r))if(Array.isArray(n[1]))for(let o of n[1])t.append(n[0],o);else t.append(n[0],n[1]);else throw new g("metro.formdata: unknown option type "+D+"formdata/unknown-option-value/",r);return Object.freeze(t),new Proxy(t,{get(r,n){let o;switch(n){case Symbol.metroProxy:o=!0;break;case Symbol.metroSource:o=r;break;case"with":o=function(...i){return Pe(r,...i)};break;default:r[n]instanceof Function?o=r[n].bind(r):o=r[n];break}return o}})}var W={error:(e,...t)=>{console.error("\u24C2\uFE0F ",e,...t)},info:(e,...t)=>{console.info("\u24C2\uFE0F ",e,...t)},group:e=>{console.group("\u24C2\uFE0F "+e)},groupEnd:e=>{console.groupEnd("\u24C2\uFE0F "+e)}};function g(e,...t){return W.error(e,...t),new Error(e,...t)}var et={add(e,t){v.tracers[e]=t},delete(e){delete v.tracers[e]},clear(){v.tracers={}},group(){let e=0;return{request:(t,r)=>{e++,W.group(e),W.info(t?.url,t,r)},response:(t,r)=>{W.info(t?.body?t.body[Symbol.metroSource]:null,t,r),W.groupEnd(e),e--}}}};function z(e){if(Array.isArray(e))return e.slice().map(z);if(e&&typeof e=="object")if(e.__proto__.constructor==Object||!e.__proto__){let t=Object.assign({},e);return Object.keys(t).forEach(r=>{t[r]=z(e[r])}),t}else return e;return e}function re(){return async function(t,r){let n=await r(t);return n.ok&&n.data?n.data:n}}function R(e){return e=Object.assign({contentType:"application/json",reviver:null,replacer:null,space:""},e),async function(r,n){if(r.headers.get("Accept")||(r=r.with({headers:{Accept:e.accept??e.contentType}})),r.method!=="GET"&&r.method!=="HEAD"&&r.data&&typeof r.data=="object"&&!(r.data instanceof ReadableStream)){let i=r.headers.get("Content-Type");(!i||rt(i))&&(r=r.with({headers:{"Content-Type":e.contentType}})),je(r.headers.get("Content-Type"))&&(r=r.with({body:JSON.stringify(r.data,e.replacer,e.space)}))}let o=await n(r);if(je(o.headers.get("Content-Type"))){let s=await o.clone().text();try{let a=JSON.parse(s,e.reviver);return o.with({body:a})}catch{}}return o}}var tt=/^application\/([a-zA-Z0-9\-_]+\+)?json\b/;function je(e){return tt.exec(e)}function rt(e){return/^text\/plain\b/.exec(e)}function O(e){return async function(r,n){let o=await n(r);if(!o.ok)if(e&&typeof e[o.status]=="function")o=e[o.status].apply(o,r);else throw new Error(o.status+": "+o.statusText,{cause:o});return o}}var ne=class extends v{constructor(t,r,n=null){t instanceof v?super(t.clientOptions,O(),re()):super(t,O(),re()),n||(n=this);for(let o in r)typeof r[o]=="function"?this[o]=r[o].bind(n):r[o]&&typeof r[o]=="object"?this[o]=new this.constructor(t,r[o],n):this[o]=r[o]}},fe=class extends ne{constructor(t,r,n=null){t instanceof v?super(t.with(R()),r,n):super(T(t,R()),r,n)}};function Te(...e){return new ne(...z(e))}function Re(...e){return new fe(...z(e))}var Oe=Object.assign({},B,{mw:{jsonmw:R,thrower:O},api:Te,jsonApi:Re});globalThis.metro||(globalThis.metro=Oe);var E=Oe;globalThis.assertEnabled=!1;function b(e,t){if(globalThis.assertEnabled){let r=A(e,t);if(r)throw console.error("\u{1F170}\uFE0F Assertions failed because of:",r,"in this source:",e),new Error("Assertions failed",{cause:{problems:r,source:e}})}}function c(e){return function(r,n,o){if(typeof r<"u"&&r!=null&&typeof e<"u")return A(r,e,n,o)}}function m(e){return function(r,n,o){return r==null||typeof r>"u"?w("data is required",r,e||"any value",o):typeof e<"u"?A(r,e,n,o):!1}}function $(e){return function(r,n,o){return r==null||typeof r>"u"?(nt("data does not contain recommended value",r,e,o),!1):A(r,e,n,o)}}function S(...e){return function(r,n,o){for(let i of e)if(!A(r,i,n,o))return!1;return w("data does not match oneOf patterns",r,e,o)}}function H(...e){return function(r,n,o){if(!Array.isArray(r))return w("data is not an array",r,"anyOf",o);for(let i of r)if(S(...e)(i))return w("data does not match anyOf patterns",i,e,o);return!1}}function Ee(...e){return function(r,n,o){let i=[];for(let s of e)i=i.concat(A(r,s,n,o));if(i=i.filter(Boolean),i.length)return w("data does not match all given patterns",r,e,o,i)}}function h(e,t,r){try{e instanceof URL&&(e=e.href);let n=new URL(e);if(n.href!=e&&!(n.href+"/"==e||n.href==e+"/"))return w("data is not a valid url",e,"validURL",r)}catch{return w("data is not a valid url",e,"validURL",r)}}function Le(e,t,r){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return w("data is not a valid email",e,"validEmail",r)}function K(e){return function(r,n,o){if(!(r instanceof e))return w("data is not an instanceof pattern",r,e,o)}}function G(e){return function(r,n,o){if(!A(r,e,n,o))return w("data matches pattern, when required not to",r,e,o)}}function A(e,t,r,n=""){r||(r=e);let o=[];if(t===Boolean)typeof e!="boolean"&&!(e instanceof Boolean)&&o.push(w("data is not a boolean",e,t,n));else if(t===Number)typeof e!="number"&&!(e instanceof Number)&&o.push(w("data is not a number",e,t,n));else if(t===String)typeof e!="string"&&!(e instanceof String)&&o.push(w("data is not a string",e,t,n)),e==""&&o.push(w("data is an empty string, which is not allowed",e,t,n));else if(t instanceof RegExp)if(Array.isArray(e)){let i=e.findIndex((s,a)=>A(s,t,r,n+"["+a+"]"));i>-1&&o.push(w("data["+i+"] does not match pattern",e[i],t,n+"["+i+"]"))}else typeof e>"u"?o.push(w("data is undefined, should match pattern",e,t,n)):t.test(e)||o.push(w("data does not match pattern",e,t,n));else if(t instanceof Function){let i=t(e,r,n);i&&(Array.isArray(i)?o=o.concat(i):o.push(i))}else if(Array.isArray(t)){Array.isArray(e)||o.push(w("data is not an array",e,[],n));for(let i of t)for(let s of e.keys()){let a=A(e[s],i,r,n+"["+s+"]");Array.isArray(a)?o=o.concat(a):a&&o.push(a)}}else if(t&&typeof t=="object")if(Array.isArray(e)){let i=e.findIndex((s,a)=>A(s,t,r,n+"["+a+"]"));i>-1&&o.push(w("data["+i+"] does not match pattern",e[i],t,n+"["+i+"]"))}else if(!e||typeof e!="object")o.push(w("data is not an object, pattern is",e,t,n));else if(e instanceof URLSearchParams&&(e=Object.fromEntries(e)),t instanceof Function){let i=A(e,t,r,n);i&&(o=o.concat(i))}else for(let[i,s]of Object.entries(t)){let a=A(e[i],s,r,n+"."+i);a&&(o=o.concat(a))}else t!=e&&o.push(w("data and pattern are not equal",e,t,n));return o.length?o:!1}function w(e,t,r,n,o){let i={path:n,message:e,found:t,expected:r};return o&&(i.problems=o),i}function nt(e,t,r,n){console.warn("\u{1F170}\uFE0F Assert: "+n,e,r,t)}function Ue(e){let t,r;if(typeof localStorage<"u")t={get:()=>localStorage.getItem("metro/state:"+e),set:n=>localStorage.setItem("metro/state:"+e,n),has:()=>localStorage.getItem("metro/state:"+e)!==null,delete:()=>localStorage.remoteItem("metro/state:"+e)},r={get:n=>JSON.parse(localStorage.getItem(e+":"+n)),set:(n,o)=>localStorage.setItem(e+":"+n,JSON.stringify(o)),has:n=>localStorage.getItem(e+":"+n)!==null,delete:n=>localStorage.removeItem(e+":"+n)};else{let n=new Map;t={get:()=>n.get("metro/state:"+e),set:o=>n.set("metro/state:"+e,o),has:()=>n.has("metro/state:"+e),delete:()=>n.delete("metro/state:"+e)},r=new Map}return{state:t,tokens:r}}function de(e){let t={client:T(),force_authorization:!1,site:"default",oauth2_configuration:{authorization_endpoint:"/authorize",token_endpoint:"/token",redirect_uri:globalThis.document?.location.href,grant_type:"authorization_code",code_verifier:it(64)},authorize_callback:async u=>(window.location.href!=u.href&&window.location.replace(u.href),!1)};b(e,{});let r=Object.assign({},t.oauth2_configuration,e?.oauth2_configuration);e=Object.assign({},t,e),e.oauth2_configuration=r;let n=Ue(e.site);e.tokens||(e.tokens=n.tokens),e.state||(e.state=n.state),b(e,{oauth2_configuration:{client_id:m(/.+/),grant_type:"authorization_code",authorization_endpoint:m(h),token_endpoint:m(h),redirect_uri:m(h)}});for(let u in r)switch(u){case"access_token":case"authorization_code":case"refresh_token":e.tokens.set(u,r[u]);break}return async function(u,f){if(e.force_authorization)return o(u,f);let l;try{if(l=await f(u),l.ok)return l}catch(y){switch(l?.status){case 400:case 401:return o(u,f)}throw y}if(!l.ok)switch(l.status){case 400:case 401:return o(u,f)}return l};async function o(u,f){i();let l=e.tokens.get("access_token"),y=e.tokens.get("refresh_token"),k=ot(l);if(!l||k&&!y){try{if(!await s())return I("false")}catch(j){throw j}return o(u,f)}else if(k&&y){try{if(!await a())return I("false")}catch(j){throw j}return o(u,f)}else return u=F(u,{headers:{Authorization:l.type+" "+l.value}}),f(u)}function i(){if(typeof window<"u"&&window?.location){let u=_(window.location),f,l,y;if(u.searchParams.has("code"))y=u.searchParams,u=u.with({search:""}),history.pushState({},"",u.href);else if(u.hash){let k=u.hash.substr(1);y=new URLSearchParams("?"+k),u=u.with({hash:""}),history.pushState({},"",u.href)}if(y){f=y.get("code"),l=y.get("state");let k=e.state.get("metro/state");if(!l||l!==k)return;f&&e.tokens.set("authorization_code",f)}}}async function s(){if(r.grant_type==="authorization_code"&&!e.tokens.has("authorization_code")){let y=await p();if(!e.authorize_callback||typeof e.authorize_callback!="function")throw g("oauth2mw: oauth2 with grant_type:authorization_code requires a callback function in client options.authorize_callback");let k=await e.authorize_callback(y);if(k)e.tokens.set("authorization_code",k);else return!1}let u=d(),f=await e.client.post(u);if(!f.ok){let y=await f.text();throw g("OAuth2mw: fetch access_token: "+f.status+": "+f.statusText,{cause:u})}let l=await f.json();if(e.tokens.set("access_token",{value:l.access_token,expires:ze(l.expires_in),type:l.token_type,scope:l.scope}),l.refresh_token){let y={value:l.refresh_token};e.tokens.set("refresh_token",y)}return e.tokens.delete("authorization_code"),l}async function a(){let u=d("refresh_token"),f=await e.client.post(u);if(!f.ok)throw g("OAuth2mw: refresh access_token: "+f.status+": "+f.statusText,{cause:u});let l=await f.json();if(e.tokens.set("access_token",{value:l.access_token,expires:ze(l.expires_in),type:l.token_type,scope:l.scope}),l.refresh_token){let y={value:l.refresh_token};e.tokens.set("refresh_token",y)}else return!1;return l}async function p(){if(!r.authorization_endpoint)throw g("oauth2mw: Missing options.oauth2_configuration.authorization_endpoint");let u=_(r.authorization_endpoint,{hash:""});b(r,{client_id:/.+/,redirect_uri:/.+/,scope:/.*/});let f={response_type:"code",client_id:r.client_id,redirect_uri:r.redirect_uri,state:r.state||at(40)};return r.response_type&&(f.response_type=r.response_type),r.response_mode&&(f.response_mode=r.response_mode),e.state.set(f.state),r.client_secret&&(f.client_secret=r.client_secret),r.code_verifier&&(e.tokens.set("code_verifier",r.code_verifier),f.code_challenge=await st(r.code_verifier),f.code_challenge_method="S256"),r.scope&&(f.scope=r.scope),r.prompt&&(f.prompt=r.prompt),_(u,{search:f})}function d(u=null){if(b(r,{client_id:/.+/,redirect_uri:/.+/}),!r.token_endpoint)throw g("oauth2mw: Missing options.endpoints.token url");let f=_(r.token_endpoint,{hash:""}),l={grant_type:u||r.grant_type,client_id:r.client_id};switch(r.client_secret&&(l.client_secret=r.client_secret),r.scope&&(l.scope=r.scope),l.grant_type){case"authorization_code":l.redirect_uri=r.redirect_uri,l.code=e.tokens.get("authorization_code");let y=e.tokens.get("code_verifier");y&&(l.code_verifier=y);break;case"client_credentials":break;case"refresh_token":let k=e.tokens.get("refresh_token");l.refresh_token=k.value;break;default:throw new Error("Unknown grant_type: ".oauth2.grant_type)}return F(f,{method:"POST",body:new URLSearchParams(l)})}}function ot(e){if(!e)return!0;let t=new Date(e.expires);return new Date().getTime()>t.getTime()}function ze(e){if(e instanceof Date)return new Date(e.getTime());if(typeof e=="number"){let t=new Date;return t.setSeconds(t.getSeconds()+e),t}throw new TypeError("Unknown expires type "+e)}function it(e=64){let t=new Uint8Array(e);return globalThis.crypto.getRandomValues(t),Ce(t)}async function st(e){let r=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",r);return Ce(n)}function Ce(e){let t=Array.from(new Uint8Array(e),r=>String.fromCharCode(r)).join("");return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function at(e){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r="",n=0;for(;n<e;)r+=t.charAt(Math.floor(Math.random()*t.length)),n++;return r}function Ne(){let e=new URL(document.location.href);if(!e.searchParams.has("code")){if(e.hash){let t=e.hash.substr(1);if(params=new URLSearchParams("?"+t),params.has("code"))return!0}return!1}return!0}function pe(){return new Promise((e,t)=>{let r=globalThis.indexedDB.open("metro",1);r.onupgradeneeded=()=>r.result.createObjectStore("keyPairs",{keyPath:"domain"}),r.onerror=n=>{t(n)},r.onsuccess=n=>{let o=n.target.result;e({set:function(i,s){return new Promise((a,p)=>{let d=o.transaction("keyPairs","readwrite",{durability:"strict"}),u=d.objectStore("keyPairs");d.oncomplete=()=>{a()},d.onerror=p,u.put(i,s)})},get:function(i){return new Promise((s,a)=>{let p=o.transaction("keyPairs","readonly"),u=p.objectStore("keyPairs").get(i);u.onsuccess=()=>{s(u.result)},u.onerror=a,p.onerror=a})},clear:function(){return new Promise((i,s)=>{let a=o.transaction("keyPairs","readwrite"),d=a.objectStore("keyPairs").clear();d.onsuccess=()=>{i()},d.onerror=s,a.onerror=s})}})}})}var ut=new TextEncoder,lt=new TextDecoder;function oe(e){return typeof e=="string"?ut.encode(e):lt.decode(e)}function De(e){if(typeof e.modulusLength!="number"||e.modulusLength<2048)throw new he(`${e.name} modulusLength must be at least 2048 bits`)}function ft(e){switch(e.algorithm.name){case"ECDSA":return{name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return De(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return De(e.algorithm),{name:e.algorithm.name};case"Ed25519":return{name:e.algorithm.name}}throw new C}async function dt(e,t,r){if(r.usages.includes("sign")===!1)throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');let n=`${Y(oe(JSON.stringify(e)))}.${Y(oe(JSON.stringify(t)))}`,o=Y(await crypto.subtle.sign(ft(r),r,oe(n)));return`${n}.${o}`}var Fe=32768;function pt(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));let t=[];for(let r=0;r<e.byteLength;r+=Fe)t.push(String.fromCharCode.apply(null,e.subarray(r,r+Fe)));return btoa(t.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Y(e){return pt(e)}function ht(){return Y(crypto.getRandomValues(new Uint8Array(32)))}var C=class extends Error{constructor(t){super(t??"operation not supported"),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},he=class extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};function mt(e){switch(e.algorithm.hash.name){case"SHA-256":return"PS256";default:throw new C("unsupported RsaHashedKeyAlgorithm hash name")}}function yt(e){switch(e.algorithm.hash.name){case"SHA-256":return"RS256";default:throw new C("unsupported RsaHashedKeyAlgorithm hash name")}}function wt(e){switch(e.algorithm.namedCurve){case"P-256":return"ES256";default:throw new C("unsupported EcKeyAlgorithm namedCurve")}}function gt(e){switch(e.algorithm.name){case"RSA-PSS":return mt(e);case"RSASSA-PKCS1-v1_5":return yt(e);case"ECDSA":return wt(e);case"Ed25519":return"EdDSA";default:throw new C("unsupported CryptoKey algorithm name")}}function Ie(e){return e instanceof CryptoKey}function _t(e){return Ie(e)&&e.type==="private"}function bt(e){return Ie(e)&&e.type==="public"}function xt(){return Math.floor(Date.now()/1e3)}async function ie(e,t,r,n,o,i){let s=e?.privateKey,a=e?.publicKey;if(!_t(s))throw new TypeError('"keypair.privateKey" must be a private CryptoKey');if(!bt(a))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(a.extractable!==!0)throw new TypeError('"keypair.publicKey.extractable" must be true');if(typeof t!="string")throw new TypeError('"htu" must be a string');if(typeof r!="string")throw new TypeError('"htm" must be a string');if(n!==void 0&&typeof n!="string")throw new TypeError('"nonce" must be a string or undefined');if(o!==void 0&&typeof o!="string")throw new TypeError('"accessToken" must be a string or undefined');if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new TypeError('"additional" must be an object');return dt({alg:gt(s),typ:"dpop+jwt",jwk:await St(a)},{...i,iat:xt(),jti:ht(),htm:r,nonce:n,htu:t,ath:o?Y(await crypto.subtle.digest("SHA-256",oe(o))):void 0},s)}async function St(e){let{kty:t,e:r,n,x:o,y:i,crv:s}=await crypto.subtle.exportKey("jwk",e);return{kty:t,crv:s,e:r,n,x:o,y:i}}async function Be(e,t){let r;if(typeof e!="string"||e.length===0)throw new TypeError('"alg" must be a non-empty string');switch(e){case"PS256":r={name:"RSA-PSS",hash:"SHA-256",modulusLength:t?.modulusLength??2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":r={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:t?.modulusLength??2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"};break;case"EdDSA":r={name:"Ed25519"};break;default:throw new C}return crypto.subtle.generateKey(r,t?.extractable??!1,["sign","verify"])}function me(e){return b(e,{site:m(h),authorization_endpoint:m(h),token_endpoint:m(h),dpop_signing_alg_values_supported:c([])}),async(t,r)=>{let n=await pe(),o=await n.get(e.site);if(!o){let a=await Be("ES256");o={domain:e.site,keyPair:a},await n.set(o)}let i=E.url(t.url);if(t.url.startsWith(e.authorization_endpoint)){let a=t.body;a instanceof URLSearchParams||a instanceof FormData?a.set("dpop_jkt",o.keyPair.publicKey):a.dpop_jkt=o.keyPair.publicKey}else if(t.url.startsWith(e.token_endpoint)){let a=await ie(o.keyPair,t.url,t.method);t=t.with({headers:{DPoP:a}})}else if(t.headers.has("Authorization")){let a=localStorage.getItem(i.host+":nonce")||void 0,p=t.headers.get("Authorization").split(" ")[1],d=await ie(o.keyPair,t.url,t.method,a,p);t=t.with({headers:{Authorization:"DPoP "+p,DPoP:d}})}let s=await r(t);return s.headers.get("DPoP-Nonce")&&localStorage.setItem(i.host+":nonce",s.headers.get("DPoP-Nonce")),s}}var Z=(...e)=>(t,r)=>e.filter(n=>r.hasOwnKey(n)).length>0?!1:w("root data must have all of",r,e),N=(...e)=>t=>Array.isArray(t)&&e.filter(r=>!t.includes(r)).length==0?!1:w("data must be an array which includes",t,e);var P=["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512"],se=["client_secret_post","client_secret_basic","client_secret_jwt","private_key_jwt"];async function Q(e={}){b(e,{client:c(K(E.client().constructor)),issuer:m(h)});let t={client:E.client().with(O()).with(R()),requireDynamicRegistration:!1};e=Object.assign({},t,e);let r=!1;function n(p){return r}let o={issuer:m(Ee(e.issuer,n)),authorization_endpoint:m(h),token_endpoint:m(h),userinfo_endpoint:$(h),jwks_uri:m(h),registration_endpoint:e.requireDynamicRegistration?m(h):$(h),scopes_supported:$(N("openid")),response_types_supported:e.requireDynamicRegistration?m(N("code","id_token","id_token token")):m([]),response_modes_supported:c([]),grant_types_supported:e.requireDynamicRegistration?c(N("authorization_code")):c([]),acr_values_supported:c([]),subject_types_supported:m([]),id_token_signing_alg_values_supported:m(N("RS256")),id_token_encryption_alg_values_supported:c([]),id_token_encryption_enc_values_supported:c([]),userinfo_signing_alg_values_supported:c([]),userinfo_encryption_alg_values_supported:c([]),userinfo_encryption_enc_values_supported:c([]),request_object_signing_alg_values_supported:c(N("RS256")),request_object_encryption_alg_values_supported:c([]),request_object_encryption_enc_values_supported:c([]),token_endpoint_auth_methods_supported:c(H(...se)),token_endpoint_auth_signing_alg_values_supported:c(N("RS256"),G(N("none"))),display_values_supported:c(H("page","popup","touch","wap")),claim_types_supported:c(H("normal","aggregated","distributed")),claims_supported:$([]),service_documentation:c(h),claims_locales_supported:c([]),ui_locales_supported:c([]),claims_parameter_supported:c(Boolean),request_parameter_supported:c(Boolean),request_uri_parameter_supported:c(Boolean),op_policy_uri:c(h),op_tos_uri:c(h)},i=E.url(e.issuer,".well-known/openid-configuration"),a=(await e.client.get(i)).data;return b(a,o),b(a.issuer,e.issuer),a}async function X(e){let t={redirect_uris:m([h]),response_types:c([]),grant_types:c(H("authorization_code","refresh_token")),application_type:c(S("native","web")),contacts:c([Le]),client_name:c(String),logo_uri:c(h),client_uri:c(h),policy_uri:c(h),tos_uri:c(h),jwks_uri:c(h,G(Z("jwks"))),jwks:c(h,G(Z("jwks_uri"))),sector_identifier_uri:c(h),subject_type:c(String),id_token_signed_response_alg:c(S(...P)),id_token_encrypted_response_alg:c(S(...P)),id_token_encrypted_response_enc:c(S(...P),Z("id_token_encrypted_response_alg")),userinfo_signed_response_alg:c(S(...P)),userinfo_encrypted_response_alg:c(S(...P)),userinfo_encrypted_response_enc:c(S(...P),Z("userinfo_encrypted_response_alg")),request_object_signing_alg:c(S(...P)),request_object_encryption_alg:c(S(...P)),request_object_encryption_enc:c(S(...P)),token_endpoint_auth_method:c(S(...se)),token_endpoint_auth_signing_alg:c(S(...P)),default_max_age:c(Number),require_auth_time:c(Boolean),default_acr_values:c([String]),initiate_login_uri:c([h]),request_uris:c([h])};b(e,{client:c(K(E.client().constructor)),registration_endpoint:h,client_info:t});let r={client:E.client().with(O()).with(R()),client_info:{redirect_uris:[globalThis.document?.location.href]}};e=Object.assign({},r,e),e.client_info||(e.client_info={}),e.client_info.redirect_uris||(e.client_info.redirect_uris=[globalThis.document?.location.href]);let n=await e.client.post(e.registration_endpoint,{body:e.client_info}),o=n.data;if(!o.client_id||!o.client_secret)throw E.metroError("metro.oidc: Error: dynamic registration of client failed, no client_id or client_secret returned",n);return e.client_info=Object.assign(e.client_info,o),e.client_info}function ae(e){let t;if(typeof localStorage<"u")t={get:r=>JSON.parse(localStorage.getItem("metro/oidc:"+e+":"+r)),set:(r,n)=>localStorage.setItem("metro/oidc:"+e+":"+r,JSON.stringify(n)),has:r=>localStorage.getItem("metro/oidc:"+e+":"+r)!==null};else{let r=new Map;t={get:n=>JSON.parse(r.get("metro/oidc:"+e+":"+n)||null),set:(n,o)=>r.set("metro/oidc:"+e+":"+n,JSON.stringify(o)),has:n=>r.has("metro/oidc:"+e+":"+n)}}return t}function ye(e={}){let t={client:T(),force_authorization:!1,use_dpop:!0,authorize_callback:async r=>(window.location.href!=r.href&&window.location.replace(r.href),!1)};return e=Object.assign({},t,e),b(e,{client:m(K(T().constructor)),client_info:m(),issuer:m(h),oauth2:c({}),openid_configuration:c()}),e.store||(e.store=ae(e.issuer)),!e.openid_configuration&&e.store.has("openid_configuration")&&(e.openid_configuration=e.store.get("openid_configuration")),!e.client_info?.client_id&&e.store.has("client_info")&&(e.client_info=e.store.get("client_info")),async(r,n)=>{let o;if(!e.force_authorization){try{o=await n(r)}catch(d){if(o.status!=401&&o.status!=403)throw d}if(o.ok||o.status!=401&&o.status!=403)return o}if(e.openid_configuration||(e.openid_configuration=await Q({issuer:e.issuer}),e.store.set("openid_configuration",e.openid_configuration)),!e.client_info?.client_id){if(!e.openid_configuration.registration_endpoint)throw g("metro.oidcmw: Error: issuer "+e.issuer+" does not support dynamic client registration, but you haven't specified a client_id");e.client_info=await X({registration_endpoint:e.openid_configuration.registration_endpoint,client_info:e.client_info}),e.store.set("client_info",e.client_info)}let i=e.scope||"openid",s=Object.assign({site:e.issuer,client:e.client,force_authorization:!0,authorize_callback:e.authorize_callback,oauth2_configuration:{client_id:e.client_info?.client_id,client_secret:e.client_info?.client_secret,grant_type:"authorization_code",response_type:"code",response_mode:"query",authorization_endpoint:e.openid_configuration.authorization_endpoint,token_endpoint:e.openid_configuration.token_endpoint,scope:i,redirect_uri:e.client_info.redirect_uris[0]}}),a=async(d,u)=>{let f=await u(d);if(f.headers.get("content-type")?.startsWith("application/json")){let y=f.data?.id_token;if(!y){let k=f.clone();try{let j=await k.json();j&&j.id_token&&(y=j.id_token)}catch{}}y&&e.store.set("id_token",y)}return f},p=e.client.with(e.issuer).with(a);if(e.use_dpop){let d={site:e.issuer,authorization_endpoint:e.openid_configuration.authorization_endpoint,token_endpoint:e.openid_configuration.token_endpoint,dpop_signing_alg_values_supported:e.openid_configuration.dpop_signing_alg_values_supported};p=p.with(me(d)),s.client=p}return p=p.with(de(s)),o=await p.fetch(r),o}}function He(){return Ne()}function Ke(e){if(!e.store){if(!e.issuer)throw g("Must supply options.issuer or options.store to get the id_token");e.store=ae(e.issuer)}return e.store.get("id_token")}var Me={oidcmw:ye,discover:Q,register:X,isRedirected:He,idToken:Ke};globalThis.metro.oidc||(globalThis.metro.oidc=Me);var Je=Me;function q(e){return new we(e)}var kt="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",At={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",solid:"http://www.w3.org/ns/solid/terms#",schema:"http://schema.org/",vcard:"http://www.w3.org/2006/vcard/ns#"},we=class{constructor(t){this.prefixes={...At,...t?.prefixes},this.prefixes.xsd||(this.prefixes.xsd="http://www.w3.org/2001/XMLSchema#"),this.parser=t?.parser,this.writer=t?.writer,this.sources=Object.create(null),this.separator=t?.separator??"$"}parse(t,r,n){let{quads:o,prefixes:i}=this.parser(t,r,n);if(i)for(let s in i){let a=i[s];if(a.match(/^http(s?):\/\/$/i))a+=r.substring(a.length);else try{a=new URL(i[s],r).href}catch(p){console.error("Could not parse prefix",i[s],p.message)}this.prefixes[s]||(this.prefixes[s]=a)}return this.sources[r]=new ge(o,r,n,i,this),this.sources[r]}setType(t,r){if(!r)return t;if(typeof t=="string"?t=new String(t):typeof result=="number"&&(t=new Number(t)),typeof t!="object")throw new Error("cannot set type on ",t,r);return t.type=r,t}getType(t){return t&&typeof t=="object"?t.type:null}},ge=class{#e=Object.create(null);constructor(t,r,n,o,i){this.mimetype=n,this.url=r,this.prefixes=o,this.context=i,this.subjects=Object.create(null);for(let s of t){let a;if(s.subject.termType=="BlankNode"){let p=this.shortURI(s.predicate.id,":"),d;switch(p){case"rdf:first":if(a=this.addCollection(s.subject.id),d=this.shortURI(s.object.id,":"),d!="rdf:nil"){let u=this.getValue(s.object);u&&a.push(u)}continue;case"rdf:rest":this.#e[s.object.id]=this.#e[s.subject.id];continue;default:a=this.addBlankNode(s.subject.id);break}}else a=this.addNamedNode(s.subject.id);a.addPredicate(s.predicate.id,s.object)}this.subjects[r]?this.primary=this.subjects[r]:this.primary=null,Object.defineProperty(this,"data",{get(){return Object.values(this.subjects)}})}addNamedNode(t){let r=new URL(t,this.url).href;return this.subjects[r]||(this.subjects[r]=new _e(r,this)),this.subjects[r]}addBlankNode(t){return this.#e[t]||(this.#e[t]=new ce(this)),this.#e[t]}addCollection(t){return this.#e[t]||(this.#e[t]=new be(this)),this.#e[t]}write(){return this.context.writer(this)}get(t){return this.subjects[this.fullURI(t)]}fullURI(t,r=null){r||(r=this.context.separator);let[n,o]=t.split(r);return o?this.prefixes[n]+o:t}shortURI(t,r=null){r||(r=this.context.separator);for(let n in this.context.prefixes)if(t.startsWith(this.context.prefixes[n]))return n+r+t.substring(this.context.prefixes[n].length);return this.url&&t.startsWith(this.url)?t.substring(this.url.length):t}setType(t,r){let n=this.shortURI(r);return this.context.setType(t,n)}getType(t){return this.context.getType(t)}setLanguage(t,r){if(typeof t=="string"?t=new String(t):typeof result=="number"&&(t=new Number(t)),typeof t!="object")throw new Error("cannot set language on ",t);return t.language=r,t}getValue(t){let r;if(t.termType=="Literal"){r=t.value;let n=t.datatype?.id;n&&(r=this.setType(r,n));let o=t.language;o&&(r=this.setLanguage(r,o))}else t.termType=="BlankNode"?r=this.addBlankNode(t.id):r=this.addNamedNode(t.id);return r}},ce=class{constructor(t){Object.defineProperty(this,"graph",{value:t,writable:!1,enumerable:!1})}addPredicate(t,r){if(t.id&&(t=t.id),t==kt){let n=this.graph.shortURI(r.id);this.addType(n)}else{let n=this.graph.getValue(r);t=this.graph.shortURI(t),this[t]?Array.isArray(this[t])?this[t].push(n):this[t]=[this[t],n]:this[t]=n}}addType(t){this.a?(Array.isArray(this.a)||(this.a=[this.a]),this.a.push(t)):this.a=t}},_e=class extends ce{constructor(t,r){super(r),Object.defineProperty(this,"id",{value:t,writable:!1,enumerable:!0})}},be=class extends Array{constructor(t,r){super(),Object.defineProperty(this,"graph",{value:r,writable:!1,enumerable:!1})}};function ue(e){e=Object.assign({contentType:"text/turtle",prefixes:{ldp:"http://www.w3.org/ns/ldp#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",dct:"http://purl.org/dc/terms/",stat:"http://www.w3.org/ns/posix/stat#",turtle:"http://www.w3.org/ns/iana/media-types/text/turtle#",schem:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",acl:"http://www.w3.org/ns/auth/acl#",pims:"http://www.w3.org/ns/pim/space#",vcard:"http://www.w3.org/2006/vcard/ns#",foaf:"http://xmlns.com/foaf/0.1/"},parser:q.n3Parser,writer:q.n3Writer},e),e.prefixes.ldp||(e.prefixes.ldp="http://www.w3.org/ns/ldp#");let t=q(e);return async function(n,o){if(n.headers.get("Accept")||(n=n.with({headers:{Accept:e.accept??e.contentType}})),n.method!=="GET"&&n.method!=="HEAD"&&n.data&&typeof n.data=="object"&&!(n.data instanceof ReadableStream)){let s=n.headers.get("Content-Type");(!s||isPlainText(s))&&(n=n.with({headers:{"Content-Type":e.contentType}})),isLinkedData(n.headers.get("Content-Type"))&&(n=n.with({body:await t.writer(n.data)}))}let i=await o(n)}}globalThis.oldmmw=ue;var Ve=ue;function L(e){return[String,Boolean,Number,BigInt].includes(e?.constructor)}function xe(e){let t=[];if(e instanceof Function)t.push(e);else for(let[r,n]of Object.entries(e))n instanceof Function?t.push(o=>({[r]:n(o,r,"select")})):L(n)?t.push(()=>({[r]:n})):t.push(o=>({[r]:te(o[r]).select(n)}));return t.length==1?t[0]:r=>{let n={};for(let o of t)Object.assign(n,o(r));return n}}function Se(e){let t=[];if(Array.isArray(e))t.push(Tt(...e));else if(e instanceof RegExp)t.push(r=>e.test(r));else if(e instanceof Function)t.push(r=>e(r));else if(L(e))t.push(r=>Array.isArray(r)?r.filter(n=>e==n).length>0:e==r);else{let r={};for(let[o,i]of Object.entries(e))r[o]=Se(i);let n=o=>{if(Array.isArray(o))return o.filter(i=>n(i)).length>0;if(L(o))return!1;for(let i in r){let s=r[i];if(!s(o?.[i]))return!1}return!0};t.push(n)}return t.length==1?t[0]:r=>{for(let n of t)if(!n(r))return!1;return!0}}var vt=Symbol("asc"),Pt=Symbol("desc");function We(e){let t=Object.entries(e),r=[];for(let[n,o]of t)if(o instanceof Function)r.push(o);else if(o===vt)r.push((i,s)=>i[n]>s[n]?1:i[n]<s[n]?-1:0);else if(o===Pt)r.push((i,s)=>i[n]<s[n]?1:i[n]>s[n]?-1:0);else{if(L(o))throw new Error("Unknown sort order",o);{let i=We(o);r.push((s,a)=>i(s[n],a[n]))}}return r.length==1?r[0]:(n,o)=>{for(let i of r){let s=i(n,o);if(s!==0)return s}return 0}}function $e(e){let t=[];if(e instanceof Function)t.push(e);else for(let[r,n]of Object.entries(e))n instanceof Function?t.push((o,i,s,a)=>(L(o)&&(o={}),i.reduce?o[r]=i.reduce(n,o[r]||[]):o[r]=n(o[r]||[],i,s,a),o)):L(n)?t.push(o=>(L(o)&&(o={}),o[r]=n,o)):t.push((o,i)=>(L(o)&&(o={}),o[r]=te(i[r]).reduce(n,[]),o));return t.length==1?t[0]:(r,n,o,i)=>{let s={};for(let a of t)Object.assign(s,a(r,n,o,i));return s}}function jt(e,t){let r={};for(let n of e){let o=t(n);Array.isArray(o)||(o=[o]);for(let i of o){if(typeof i!="string"&&!(i instanceof String)){console.warn("JAQT: groupBy(selector) can only handle string values, got:",i);continue}r[i]||(r[i]=[]),r[i].push(n)}}return r}function Ge(e,t){let r=t.shift(),n=jt(e,r);if(t.length)for(let o in n)n[o]=Ge(n[o],t);return n}function Tt(...e){let t=e.map(r=>Se(r));return r=>t.some(n=>n(r))}var Rt={apply(e,t,r){let n=e.apply(t,r);return typeof n=="object"?new Proxy(n,U):n}},U={get(e,t){let r=null;if(typeof t=="symbol"&&(r=e[t]),Array.isArray(e))switch(t){case"where":r=function(n){let o=Se(n);return new Proxy(e.filter(i=>o(i)),U)};break;case"select":r=function(n){let o=xe(n);return new Proxy(e.map(o),U)};break;case"reduce":r=function(n,o=[]){let i=$e(n),s=e.reduce(i,o);return Array.isArray(s)?new Proxy(s,U):L(s)?s:new Proxy(s,ee)};break;case"orderBy":r=function(n){let o=We(n);return new Proxy(e.toSorted(o),U)};break;case"groupBy":r=function(...n){let o=Ge(e,n);return new Proxy(o,ee)};break}return!r&&e&&typeof e=="object"&&t==="select"&&(r=function(n){let o=xe(n);return new Proxy(o(e),U)}),!r&&e&&typeof e[t]=="function"&&(r=new Proxy(e[t],Rt)),r||(r=e[t]),r}},ee={get(e,t){let r=null;switch(t){case"select":r=function(n){let o=xe(n),i={};for(let s in e)Array.isArray(e[s])?i[s]=new Proxy(e[s].map(o),U):i[s]=new Proxy(e[s],ee);return i};break;case"reduce":r=function(n,o=[]){let i=$e(n),s={};for(let a in e)if(Array.isArray(e[a])){let p=e[a].reduce(i,o);Array.isArray(p)?s[a]=new Proxy(p,U):L(p)?s[a]=p:s[a]=new Proxy(p,ee)}else s[a]=new Proxy(e[a],ee);return s};break;default:Array.isArray(e[t])?r=te(e[t]):r=e[t];break}return r}},le={get(e,t){let r=null;switch(t){case"where":r=function(){return new Proxy(new M,le)};break;case"reduce":case"select":r=function(){return null};break;case"orderBy":r=function(){return new Proxy(new M,le)};break;case"groupBy":r=function(){return new Proxy(new M,le)};break}return!r&&typeof e?.[t]=="function"&&(r=e[t]),r}},M=class{toJSON(){return null}};function te(e){return!e||typeof e!="object"?new Proxy(new M,le):new Proxy(e,U)}function ke(e){return(t,r)=>{if(e?.length>0){let n=e.slice(),o=n.shift();for(;o;){if(Array.isArray(t)&&parseInt(o)!=o)return n.unshift(o),t.map(ke(n));typeof t?.[o]<"u"?t=t[o]:t=null,o=n.shift()}return t}else return r?typeof t?.[r]<"u"?t[r]:null:t}}var Ye=e=>(e||(e=[]),{get(t,r){if(r=="constructor"||typeof r=="symbol")return t[r];let n=e.concat([r]);return new Proxy(ke(n),Ye(n))},apply(t,r,n){let o=t(...n);return Array.isArray(o)&&(o=o.flat(1/0)),o}}),Nr=new Proxy(ke(),Ye());var J=class extends V{#e;#r;constructor(t,r="/",n={}){this.#e=T(t).with(Je.oidcmw(n)).with(Ve(n)),this.#r=new x(r)}get name(){return"SolidAdapter"}async list(t){let r=["text/turtle"],n=await this.read(t);if(n.data)te(n.data).where({a:"ldp$Resource"}).select({filename:o=>jsfs.path.filename(metro.url(o.id).pathname),path:o=>metro.url(o.id).pathname,type:o=>o.a.includes("ldp$Container")?"folder":"file"});else throw new Error(t+" could not be parsed",{cause:n})}};var Zr=J;globalThis.SolidAdapter=J;})();
|
|
2
|
+
//# sourceMappingURL=browser.min.js.map
|