@pod-os/elements 0.32.1-rc.0fc2066.0 → 0.32.1-rc.650bacd.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/dist/cjs/{dist-O5YU2L4C-731be513.js → dist-O5YU2L4C-25f1cfd1.js} +2 -2
- package/dist/cjs/{dist-O5YU2L4C-731be513.js.map → dist-O5YU2L4C-25f1cfd1.js.map} +1 -1
- package/dist/cjs/{index-ad3152fe.js → index-8e51b348.js} +9 -3
- package/dist/cjs/index-8e51b348.js.map +1 -0
- package/dist/cjs/ion-badge_4.cjs.entry.js +1 -1
- package/dist/cjs/ion-icon_31.cjs.entry.js +1 -1
- package/dist/cjs/{jsonld-X74JI4TL-57175b0c.js → jsonld-X74JI4TL-75fcce98.js} +2 -2
- package/dist/cjs/{jsonld-X74JI4TL-57175b0c.js.map → jsonld-X74JI4TL-75fcce98.js.map} +1 -1
- package/dist/cjs/pos-container-contents.cjs.entry.js +1 -1
- package/dist/cjs/pos-subjects.cjs.entry.js +1 -1
- package/dist/components/index10.js +6 -0
- package/dist/components/index10.js.map +1 -1
- package/dist/elements/elements.esm.js +1 -1
- package/dist/elements/{p-9553f91e.entry.js → p-9fc880cd.entry.js} +2 -2
- package/dist/elements/{p-6f41afe0.js → p-a794df9b.js} +2 -2
- package/dist/elements/p-a962c4b4.js +72 -0
- package/dist/elements/p-a962c4b4.js.map +1 -0
- package/dist/elements/{p-dc36a132.entry.js → p-aff3b672.entry.js} +2 -2
- package/dist/elements/{p-a16916b7.js → p-b044cf9a.js} +2 -2
- package/dist/elements/{p-ed5c0c18.entry.js → p-b9400211.entry.js} +2 -2
- package/dist/elements/{p-226b6778.entry.js → p-d6be765b.entry.js} +2 -2
- package/dist/esm/{dist-O5YU2L4C-d78d21aa.js → dist-O5YU2L4C-a27a7092.js} +2 -2
- package/dist/esm/{dist-O5YU2L4C-d78d21aa.js.map → dist-O5YU2L4C-a27a7092.js.map} +1 -1
- package/dist/esm/{index-f791fd66.js → index-e9875204.js} +9 -3
- package/dist/esm/index-e9875204.js.map +1 -0
- package/dist/esm/ion-badge_4.entry.js +1 -1
- package/dist/esm/ion-icon_31.entry.js +1 -1
- package/dist/esm/{jsonld-X74JI4TL-4f85395c.js → jsonld-X74JI4TL-4325758a.js} +2 -2
- package/dist/esm/{jsonld-X74JI4TL-4f85395c.js.map → jsonld-X74JI4TL-4325758a.js.map} +1 -1
- package/dist/esm/pos-container-contents.entry.js +1 -1
- package/dist/esm/pos-subjects.entry.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/index-ad3152fe.js.map +0 -1
- package/dist/elements/p-a004ecd1.js +0 -72
- package/dist/elements/p-a004ecd1.js.map +0 -1
- package/dist/esm/index-f791fd66.js.map +0 -1
- /package/dist/elements/{p-9553f91e.entry.js.map → p-9fc880cd.entry.js.map} +0 -0
- /package/dist/elements/{p-6f41afe0.js.map → p-a794df9b.js.map} +0 -0
- /package/dist/elements/{p-dc36a132.entry.js.map → p-aff3b672.entry.js.map} +0 -0
- /package/dist/elements/{p-a16916b7.js.map → p-b044cf9a.js.map} +0 -0
- /package/dist/elements/{p-ed5c0c18.entry.js.map → p-b9400211.entry.js.map} +0 -0
- /package/dist/elements/{p-226b6778.entry.js.map → p-d6be765b.entry.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,r as t,h as n,H as i,e as r,f as s,i as o,j as a}from"./p-99602d8c.js";import{c}from"./p-4ab8d4da.js";import{c as l,h as d}from"./p-669fab6c.js";import{c as h,g as u}from"./p-9ff1da1c.js";import{c as f,s as p,B as b}from"./p-3d182668.js";import{P as m,N as g,L as w}from"./p-a004ecd1.js";import{S as v,t as y,d as k}from"./p-5cade8cd.js";import{s as x}from"./p-f6671856.js";import{i as S,x as _,E,c as A,S as C,_ as T,a as I,r as z,n as $,w as R,b as P,f as D}from"./p-9be91e78.js";import{e as W,a as O,s as L,L as j,b as U,g as J,c as K,w as H,S as N,i as M,t as B,d as X}from"./p-50aca1ca.js";import{s as F}from"./p-182f722d.js";import"./p-c066fd50.js";let V;const q=()=>{if(typeof window==="undefined"){return new Map}else{if(!V){const e=window;e.Ionicons=e.Ionicons||{};V=e.Ionicons.map=e.Ionicons.map||new Map}return V}};const G=e=>{let t=Q(e.src);if(t){return t}t=Z(e.name,e.icon,e.mode,e.ios,e.md);if(t){return Y(t,e)}if(e.icon){t=Q(e.icon);if(t){return t}t=Q(e.icon[e.mode]);if(t){return t}}return null};const Y=(t,n)=>{const i=q().get(t);if(i){return i}try{return e(`svg/${t}.svg`)}catch(e){console.warn(`[Ionicons Warning]: Could not load icon with name "${t}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`,n)}};const Z=(e,t,n,i,r)=>{n=(n&&ne(n))==="ios"?"ios":"md";if(i&&n==="ios"){e=ne(i)}else if(r&&n==="md"){e=ne(r)}else{if(!e&&t&&!ee(t)){e=t}if(te(e)){e=ne(e)}}if(!te(e)||e.trim()===""){return null}const s=e.replace(/[a-z]|-|\d/gi,"");if(s!==""){return null}return e};const Q=e=>{if(te(e)){e=e.trim();if(ee(e)){return e}}return null};const ee=e=>e.length>0&&/(\/|\.)/.test(e);const te=e=>typeof e==="string";const ne=e=>e.toLowerCase();const ie=(e,t=[])=>{const n={};t.forEach((t=>{if(e.hasAttribute(t)){const i=e.getAttribute(t);if(i!==null){n[t]=e.getAttribute(t)}e.removeAttribute(t)}}));return n};const re=e=>{if(e){if(e.dir!==""){return e.dir.toLowerCase()==="rtl"}}return(document===null||document===void 0?void 0:document.dir.toLowerCase())==="rtl"};const se=e=>{const t=document.createElement("div");t.innerHTML=e;for(let e=t.childNodes.length-1;e>=0;e--){if(t.childNodes[e].nodeName.toLowerCase()!=="svg"){t.removeChild(t.childNodes[e])}}const n=t.firstElementChild;if(n&&n.nodeName.toLowerCase()==="svg"){const e=n.getAttribute("class")||"";n.setAttribute("class",(e+" s-ion-icon").trim());if(oe(n)){return t.innerHTML}}return""};const oe=e=>{if(e.nodeType===1){if(e.nodeName.toLowerCase()==="script"){return false}for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t].name;if(te(n)&&n.toLowerCase().indexOf("on")===0){return false}}for(let t=0;t<e.childNodes.length;t++){if(!oe(e.childNodes[t])){return false}}}return true};const ae=e=>e.startsWith("data:image/svg+xml");const ce=e=>e.indexOf(";utf8,")!==-1;const le=new Map;const de=new Map;let he;const ue=(e,t)=>{let n=de.get(e);if(!n){if(typeof fetch!=="undefined"&&typeof document!=="undefined"){if(ae(e)&&ce(e)){if(!he){he=new DOMParser}const t=he.parseFromString(e,"text/html");const n=t.querySelector("svg");if(n){le.set(e,n.outerHTML)}return Promise.resolve()}else{n=fetch(e).then((n=>{if(n.ok){return n.text().then((n=>{if(n&&t!==false){n=se(n)}le.set(e,n||"")}))}le.set(e,"")}));de.set(e,n)}}else{le.set(e,"");return Promise.resolve()}}return n};const fe=":host{display:inline-block;width:1em;height:1em;contain:strict;fill:currentColor;box-sizing:content-box !important}:host .ionicon{stroke:currentColor}.ionicon-fill-none{fill:none}.ionicon-stroke-width{stroke-width:32px;stroke-width:var(--ionicon-stroke-width, 32px)}.icon-inner,.ionicon,svg{display:block;height:100%;width:100%}@supports (background: -webkit-named-image(i)){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}@supports not selector(:dir(rtl)) and selector(:host-context([dir='rtl'])){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}:host(.flip-rtl):host-context([dir='rtl']) .icon-inner{transform:scaleX(-1)}@supports selector(:dir(rtl)){:host(.flip-rtl:dir(rtl)) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(ltr)) .icon-inner{transform:scaleX(1)}}:host(.icon-small){font-size:1.125rem !important}:host(.icon-large){font-size:2rem !important}:host(.ion-color){color:var(--ion-color-base) !important}:host(.ion-color-primary){--ion-color-base:var(--ion-color-primary, #3880ff)}:host(.ion-color-secondary){--ion-color-base:var(--ion-color-secondary, #0cd1e8)}:host(.ion-color-tertiary){--ion-color-base:var(--ion-color-tertiary, #f4a942)}:host(.ion-color-success){--ion-color-base:var(--ion-color-success, #10dc60)}:host(.ion-color-warning){--ion-color-base:var(--ion-color-warning, #ffce00)}:host(.ion-color-danger){--ion-color-base:var(--ion-color-danger, #f14141)}:host(.ion-color-light){--ion-color-base:var(--ion-color-light, #f4f5f8)}:host(.ion-color-medium){--ion-color-base:var(--ion-color-medium, #989aa2)}:host(.ion-color-dark){--ion-color-base:var(--ion-color-dark, #222428)}";const pe=fe;const be=class{constructor(e){t(this,e);this.iconName=null;this.inheritedAttributes={};this.didLoadIcon=false;this.svgContent=undefined;this.isVisible=false;this.mode=me();this.color=undefined;this.ios=undefined;this.md=undefined;this.flipRtl=undefined;this.name=undefined;this.src=undefined;this.icon=undefined;this.size=undefined;this.lazy=false;this.sanitize=true}componentWillLoad(){this.inheritedAttributes=ie(this.el,["aria-label"])}connectedCallback(){this.waitUntilVisible(this.el,"50px",(()=>{this.isVisible=true;this.loadIcon()}))}componentDidLoad(){if(!this.didLoadIcon){this.loadIcon()}}disconnectedCallback(){if(this.io){this.io.disconnect();this.io=undefined}}waitUntilVisible(e,t,n){if(this.lazy&&typeof window!=="undefined"&&window.IntersectionObserver){const i=this.io=new window.IntersectionObserver((e=>{if(e[0].isIntersecting){i.disconnect();this.io=undefined;n()}}),{rootMargin:t});i.observe(e)}else{n()}}loadIcon(){if(this.isVisible){const e=G(this);if(e){if(le.has(e)){this.svgContent=le.get(e)}else{ue(e,this.sanitize).then((()=>this.svgContent=le.get(e)))}this.didLoadIcon=true}}this.iconName=Z(this.name,this.icon,this.mode,this.ios,this.md)}render(){const{flipRtl:e,iconName:t,inheritedAttributes:r,el:s}=this;const o=this.mode||"md";const a=t?(t.includes("arrow")||t.includes("chevron"))&&e!==false:false;const c=e||a;return n(i,Object.assign({role:"img",class:Object.assign(Object.assign({[o]:true},ge(this.color)),{[`icon-${this.size}`]:!!this.size,"flip-rtl":c,"icon-rtl":c&&re(s)})},r),this.svgContent?n("div",{class:"icon-inner",innerHTML:this.svgContent}):n("div",{class:"icon-inner"}))}static get assetsDirs(){return["svg"]}get el(){return r(this)}static get watchers(){return{name:["loadIcon"],src:["loadIcon"],icon:["loadIcon"],ios:["loadIcon"],md:["loadIcon"]}}};const me=()=>typeof document!=="undefined"&&document.documentElement.getAttribute("mode")||"md";const ge=e=>e?{"ion-color":true,[`ion-color-${e}`]:true}:null;be.style=pe;const we=":host{--background:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.3);--progress-background:var(--ion-color-primary, #3880ff);--buffer-background:var(--background);display:block;position:relative;width:100%;contain:strict;direction:ltr;overflow:hidden}.progress,.progress-indeterminate,.indeterminate-bar-primary,.indeterminate-bar-secondary,.progress-buffer-bar{left:0;right:0;top:0;bottom:0;position:absolute;width:100%;height:100%}.buffer-circles-container,.buffer-circles{left:0;right:0;top:0;bottom:0;position:absolute}.buffer-circles{right:-10px;left:-10px;}.progress,.progress-buffer-bar,.buffer-circles-container{transform-origin:left top;transition:transform 150ms linear}.progress,.progress-indeterminate{background:var(--progress-background);z-index:2}.progress-buffer-bar{background:var(--buffer-background);z-index:1}.buffer-circles-container{overflow:hidden}.indeterminate-bar-primary{top:0;right:0;bottom:0;left:-145.166611%;animation:primary-indeterminate-translate 2s infinite linear}.indeterminate-bar-primary .progress-indeterminate{animation:primary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.indeterminate-bar-secondary{top:0;right:0;bottom:0;left:-54.888891%;animation:secondary-indeterminate-translate 2s infinite linear}.indeterminate-bar-secondary .progress-indeterminate{animation:secondary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.buffer-circles{background-image:radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%);background-repeat:repeat-x;background-position:5px center;background-size:10px 10px;z-index:0;animation:buffering 450ms infinite linear}:host(.progress-bar-reversed){transform:scaleX(-1)}:host(.progress-paused) .indeterminate-bar-secondary,:host(.progress-paused) .indeterminate-bar-primary,:host(.progress-paused) .buffer-circles{animation-play-state:paused}:host(.ion-color) .progress-buffer-bar{background:rgba(var(--ion-color-base-rgb), 0.3)}:host(.ion-color) .buffer-circles{background-image:radial-gradient(ellipse at center, rgba(var(--ion-color-base-rgb), 0.3) 0%, rgba(var(--ion-color-base-rgb), 0.3) 30%, transparent 30%)}:host(.ion-color) .progress,:host(.ion-color) .progress-indeterminate{background:var(--ion-color-base)}@keyframes primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes buffering{to{transform:translateX(-10px)}}:host{height:3px}";const ve=we;const ye=":host{--background:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.3);--progress-background:var(--ion-color-primary, #3880ff);--buffer-background:var(--background);display:block;position:relative;width:100%;contain:strict;direction:ltr;overflow:hidden}.progress,.progress-indeterminate,.indeterminate-bar-primary,.indeterminate-bar-secondary,.progress-buffer-bar{left:0;right:0;top:0;bottom:0;position:absolute;width:100%;height:100%}.buffer-circles-container,.buffer-circles{left:0;right:0;top:0;bottom:0;position:absolute}.buffer-circles{right:-10px;left:-10px;}.progress,.progress-buffer-bar,.buffer-circles-container{transform-origin:left top;transition:transform 150ms linear}.progress,.progress-indeterminate{background:var(--progress-background);z-index:2}.progress-buffer-bar{background:var(--buffer-background);z-index:1}.buffer-circles-container{overflow:hidden}.indeterminate-bar-primary{top:0;right:0;bottom:0;left:-145.166611%;animation:primary-indeterminate-translate 2s infinite linear}.indeterminate-bar-primary .progress-indeterminate{animation:primary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.indeterminate-bar-secondary{top:0;right:0;bottom:0;left:-54.888891%;animation:secondary-indeterminate-translate 2s infinite linear}.indeterminate-bar-secondary .progress-indeterminate{animation:secondary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.buffer-circles{background-image:radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%);background-repeat:repeat-x;background-position:5px center;background-size:10px 10px;z-index:0;animation:buffering 450ms infinite linear}:host(.progress-bar-reversed){transform:scaleX(-1)}:host(.progress-paused) .indeterminate-bar-secondary,:host(.progress-paused) .indeterminate-bar-primary,:host(.progress-paused) .buffer-circles{animation-play-state:paused}:host(.ion-color) .progress-buffer-bar{background:rgba(var(--ion-color-base-rgb), 0.3)}:host(.ion-color) .buffer-circles{background-image:radial-gradient(ellipse at center, rgba(var(--ion-color-base-rgb), 0.3) 0%, rgba(var(--ion-color-base-rgb), 0.3) 30%, transparent 30%)}:host(.ion-color) .progress,:host(.ion-color) .progress-indeterminate{background:var(--ion-color-base)}@keyframes primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes buffering{to{transform:translateX(-10px)}}:host{height:4px}";const ke=ye;const xe=class{constructor(e){t(this,e);this.type="determinate";this.reversed=false;this.value=0;this.buffer=1;this.color=undefined}render(){const{color:e,type:t,reversed:r,value:s,buffer:o}=this;const a=h.getBoolean("_testing");const c=u(this);return n(i,{key:"944b79ed6fce1b2c0ed48681cd8517a5abbddd80",role:"progressbar","aria-valuenow":t==="determinate"?s:null,"aria-valuemin":"0","aria-valuemax":"1",class:l(e,{[c]:true,[`progress-bar-${t}`]:true,"progress-paused":a,"progress-bar-reversed":document.dir==="rtl"?!r:r})},t==="indeterminate"?Se():_e(s,o))}};const Se=()=>n("div",{part:"track",class:"progress-buffer-bar"},n("div",{class:"indeterminate-bar-primary"},n("span",{part:"progress",class:"progress-indeterminate"})),n("div",{class:"indeterminate-bar-secondary"},n("span",{part:"progress",class:"progress-indeterminate"})));const _e=(e,t)=>{const i=c(0,e,1);const r=c(0,t,1);return[n("div",{part:"progress",class:"progress",style:{transform:`scaleX(${i})`}}),n("div",{class:{"buffer-circles-container":true,"ion-hide":r===1},style:{transform:`translateX(${r*100}%)`}},n("div",{class:"buffer-circles-container",style:{transform:`translateX(-${r*100}%)`}},n("div",{part:"stream",class:"buffer-circles"}))),n("div",{part:"track",class:"progress-buffer-bar",style:{transform:`scaleX(${r})`}})]};xe.style={ios:ve,md:ke};const Ee=":host{--background:rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065);border-radius:var(--border-radius, inherit);display:block;width:100%;height:inherit;margin-top:4px;margin-bottom:4px;background:var(--background);line-height:10px;user-select:none;pointer-events:none}span{display:inline-block}:host(.in-media){margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;height:100%}:host(.skeleton-text-animated){position:relative;background:linear-gradient(to right, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 8%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.135) 18%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 33%);background-size:800px 104px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:shimmer;animation-timing-function:linear}@keyframes shimmer{0%{background-position:-400px 0}100%{background-position:400px 0}}";const Ae=Ee;const Ce=class{constructor(e){t(this,e);this.ionStyle=s(this,"ionStyle",7);this.animated=false}componentWillLoad(){this.emitStyle()}emitStyle(){const e={"skeleton-text":true};this.ionStyle.emit(e)}render(){const e=this.animated&&h.getBoolean("animated",true);const t=d("ion-avatar",this.el)||d("ion-thumbnail",this.el);const r=u(this);return n(i,{key:"4dab0fd2de666de12ad8f6dc6ed1e1de0be67ddd",class:{[r]:true,"skeleton-text-animated":e,"in-media":t}},n("span",{key:"f8f908ec24d65e63b14d9a54640a5f18f0fa8fa5"}," "))}get el(){return r(this)}};Ce.style=Ae;const Te=":host{font-family:var(--font-sans);display:block}button#new{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;width:var(--size-10);height:var(--size-10);background-color:var(--pos-primary-color);color:var(--pos-primary-text-color);font-size:var(--scale-6);border-radius:var(--radius-xs)}button#new:hover,button#new:focus{outline:none;filter:brightness(110%);box-shadow:var(--shadow-sm)}pos-new-thing-form{margin:var(--scale-3)}";const Ie=Te;const ze=class{constructor(e){t(this,e)}openDialog(){this.dialog.showModal()}render(){return n(i,{key:"6142a141ef03ca93a362a6b00ebe8d515c3a677a"},n("button",{key:"72ecf353cd3a7d2d68f9ef28eb1bbe7fdb88b700",id:"new",title:"Add a new thing",onClick:()=>this.openDialog()},n("ion-icon",{key:"bd05d75c42c10de6df519575787fc66eafb22930",name:"add-circle-outline"})),n("pos-dialog",{key:"23cf0118149704dfca16758970e4f4658e87e946",ref:e=>this.dialog=e},n("span",{key:"5af7b7f618cc20684c39134b5ea295400e651cb6",slot:"title"},"Add a new thing"),n("pos-new-thing-form",{key:"895496c2f6ede3c8677d9d918e0b13582090baed",slot:"content",referenceUri:this.referenceUri})))}};ze.style=Ie;const $e=localStorage.getItem("settings");const Re=$e?JSON.parse($e):{offlineCache:false};const Pe=f(Re);De();We();function De(){Pe.on("set",(()=>{const e=JSON.stringify(Pe.state);localStorage.setItem("settings",e)}))}function We(){window.addEventListener("storage",(e=>{if(e.key==="settings"&&e.newValue){const t=JSON.parse(e.newValue);Pe.state.offlineCache=t.offlineCache}}))}const Oe=(e,t)=>t.some((t=>e instanceof t));let Le;let je;function Ue(){return Le||(Le=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Je(){return je||(je=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Ke=new WeakMap;const He=new WeakMap;const Ne=new WeakMap;function Me(e){const t=new Promise(((t,n)=>{const i=()=>{e.removeEventListener("success",r);e.removeEventListener("error",s)};const r=()=>{t(Ge(e.result));i()};const s=()=>{n(e.error);i()};e.addEventListener("success",r);e.addEventListener("error",s)}));Ne.set(t,e);return t}function Be(e){if(Ke.has(e))return;const t=new Promise(((t,n)=>{const i=()=>{e.removeEventListener("complete",r);e.removeEventListener("error",s);e.removeEventListener("abort",s)};const r=()=>{t();i()};const s=()=>{n(e.error||new DOMException("AbortError","AbortError"));i()};e.addEventListener("complete",r);e.addEventListener("error",s);e.addEventListener("abort",s)}));Ke.set(e,t)}let Xe={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return Ke.get(e);if(t==="store"){return n.objectStoreNames[1]?undefined:n.objectStore(n.objectStoreNames[0])}}return Ge(e[t])},set(e,t,n){e[t]=n;return true},has(e,t){if(e instanceof IDBTransaction&&(t==="done"||t==="store")){return true}return t in e}};function Fe(e){Xe=e(Xe)}function Ve(e){if(Je().includes(e)){return function(...t){e.apply(Ye(this),t);return Ge(this.request)}}return function(...t){return Ge(e.apply(Ye(this),t))}}function qe(e){if(typeof e==="function")return Ve(e);if(e instanceof IDBTransaction)Be(e);if(Oe(e,Ue()))return new Proxy(e,Xe);return e}function Ge(e){if(e instanceof IDBRequest)return Me(e);if(He.has(e))return He.get(e);const t=qe(e);if(t!==e){He.set(e,t);Ne.set(t,e)}return t}const Ye=e=>Ne.get(e);function Ze(e,t,{blocked:n,upgrade:i,blocking:r,terminated:s}={}){const o=indexedDB.open(e,t);const a=Ge(o);if(i){o.addEventListener("upgradeneeded",(e=>{i(Ge(o.result),e.oldVersion,e.newVersion,Ge(o.transaction),e)}))}if(n){o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e)))}a.then((e=>{if(s)e.addEventListener("close",(()=>s()));if(r){e.addEventListener("versionchange",(e=>r(e.oldVersion,e.newVersion,e)))}})).catch((()=>{}));return a}const Qe=["get","getKey","getAll","getAllKeys","count"];const et=["put","add","delete","clear"];const tt=new Map;function nt(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==="string")){return}if(tt.get(t))return tt.get(t);const n=t.replace(/FromIndex$/,"");const i=t!==n;const r=et.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!(r||Qe.includes(n))){return}const s=async function(e,...t){const s=this.transaction(e,r?"readwrite":"readonly");let o=s.store;if(i)o=o.index(t.shift());return(await Promise.all([o[n](...t),r&&s.done]))[0]};tt.set(t,s);return s}Fe((e=>({...e,get:(t,n,i)=>nt(t,n)||e.get(t,n,i),has:(t,n)=>!!nt(t,n)||e.has(t,n)})));const it=["continue","continuePrimaryKey","advance"];const rt={};const st=new WeakMap;const ot=new WeakMap;const at={get(e,t){if(!it.includes(t))return e[t];let n=rt[t];if(!n){n=rt[t]=function(...e){st.set(this,ot.get(this)[t](...e))}}return n}};async function*ct(...e){let t=this;if(!(t instanceof IDBCursor)){t=await t.openCursor(...e)}if(!t)return;t=t;const n=new Proxy(t,at);ot.set(n,t);Ne.set(n,Ye(t));while(t){yield n;t=await(st.get(n)||t.continue());st.delete(n)}}function lt(e,t){return t===Symbol.asyncIterator&&Oe(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Oe(e,[IDBIndex,IDBObjectStore])}Fe((e=>({...e,get(t,n,i){if(lt(t,n))return ct;return e.get(t,n,i)},has(t,n){return lt(t,n)||e.has(t,n)}})));class dt{constructor(){this.dbPromise=Ze("OfflineCacheDB",1,{upgrade(e){if(!e.objectStoreNames.contains("documents")){const t=e.createObjectStore("documents",{keyPath:"url"});t.createIndex("url-revision",["url","revision"])}}})}async clear(){const e=await this.dbPromise;return e.clear("documents")}async get(e){const t=await this.dbPromise;return await t.get("documents",e)}async put(e){const t=await this.dbPromise;const n=await t.getFromIndex("documents","url-revision",[e.url,e.revision]);if(n){return}await t.put("documents",e)}}class ht{isOnline(){return navigator.onLine}}const ut=(e,t)=>new m({session:e,offlineCache:t.offlineCache?new dt:new g,onlineStatus:new ht});class ft extends v{constructor(e){super();this._value=e}get value(){return this.getValue()}_subscribe(e){const t=super._subscribe(e);!t.closed&&e.next(this._value);return t}getValue(){const{hasError:e,thrownError:t,_value:n}=this;if(e){throw t}this._throwIfClosed();return n}next(e){super.next(this._value=e)}}var pt=crypto;const bt=e=>e instanceof CryptoKey;const mt=async(e,t)=>{const n=`SHA-${e.slice(-3)}`;return new Uint8Array(await pt.subtle.digest(n,t))};var gt=mt;const wt=new TextEncoder;const vt=new TextDecoder;function yt(...e){const t=e.reduce(((e,{length:t})=>e+t),0);const n=new Uint8Array(t);let i=0;for(const t of e){n.set(t,i);i+=t.length}return n}const kt=e=>{let t=e;if(typeof t==="string"){t=wt.encode(t)}const n=32768;const i=[];for(let e=0;e<t.length;e+=n){i.push(String.fromCharCode.apply(null,t.subarray(e,e+n)))}return btoa(i.join(""))};const xt=e=>kt(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");const St=e=>{const t=atob(e);const n=new Uint8Array(t.length);for(let e=0;e<t.length;e++){n[e]=t.charCodeAt(e)}return n};const _t=e=>{let t=e;if(t instanceof Uint8Array){t=vt.decode(t)}t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return St(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class Et extends Error{constructor(e,t){super(e,t);this.code="ERR_JOSE_GENERIC";this.name=this.constructor.name;Error.captureStackTrace?.(this,this.constructor)}}Et.code="ERR_JOSE_GENERIC";class At extends Et{constructor(e,t,n="unspecified",i="unspecified"){super(e,{cause:{claim:n,reason:i,payload:t}});this.code="ERR_JWT_CLAIM_VALIDATION_FAILED";this.claim=n;this.reason=i;this.payload=t}}At.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Ct extends Et{constructor(e,t,n="unspecified",i="unspecified"){super(e,{cause:{claim:n,reason:i,payload:t}});this.code="ERR_JWT_EXPIRED";this.claim=n;this.reason=i;this.payload=t}}Ct.code="ERR_JWT_EXPIRED";class Tt extends Et{constructor(){super(...arguments);this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Tt.code="ERR_JOSE_ALG_NOT_ALLOWED";class It extends Et{constructor(){super(...arguments);this.code="ERR_JOSE_NOT_SUPPORTED"}}It.code="ERR_JOSE_NOT_SUPPORTED";class zt extends Et{constructor(e="decryption operation failed",t){super(e,t);this.code="ERR_JWE_DECRYPTION_FAILED"}}zt.code="ERR_JWE_DECRYPTION_FAILED";class $t extends Et{constructor(){super(...arguments);this.code="ERR_JWE_INVALID"}}$t.code="ERR_JWE_INVALID";class Rt extends Et{constructor(){super(...arguments);this.code="ERR_JWS_INVALID"}}Rt.code="ERR_JWS_INVALID";class Pt extends Et{constructor(){super(...arguments);this.code="ERR_JWT_INVALID"}}Pt.code="ERR_JWT_INVALID";class Dt extends Et{constructor(){super(...arguments);this.code="ERR_JWK_INVALID"}}Dt.code="ERR_JWK_INVALID";class Wt extends Et{constructor(){super(...arguments);this.code="ERR_JWKS_INVALID"}}Wt.code="ERR_JWKS_INVALID";class Ot extends Et{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t);this.code="ERR_JWKS_NO_MATCHING_KEY"}}Ot.code="ERR_JWKS_NO_MATCHING_KEY";class Lt extends Et{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t);this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Lt.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class jt extends Et{constructor(e="request timed out",t){super(e,t);this.code="ERR_JWKS_TIMEOUT"}}jt.code="ERR_JWKS_TIMEOUT";class Ut extends Et{constructor(e="signature verification failed",t){super(e,t);this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}Ut.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function Jt(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function Kt(e,t){return e.name===t}function Ht(e){return parseInt(e.name.slice(4),10)}function Nt(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Mt(e,t){if(t.length&&!t.some((t=>e.usages.includes(t)))){let e="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const n=t.pop();e+=`one of ${t.join(", ")}, or ${n}.`}else if(t.length===2){e+=`one of ${t[0]} or ${t[1]}.`}else{e+=`${t[0]}.`}throw new TypeError(e)}}function Bt(e,t,...n){switch(t){case"HS256":case"HS384":case"HS512":{if(!Kt(e.algorithm,"HMAC"))throw Jt("HMAC");const n=parseInt(t.slice(2),10);const i=Ht(e.algorithm.hash);if(i!==n)throw Jt(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!Kt(e.algorithm,"RSASSA-PKCS1-v1_5"))throw Jt("RSASSA-PKCS1-v1_5");const n=parseInt(t.slice(2),10);const i=Ht(e.algorithm.hash);if(i!==n)throw Jt(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!Kt(e.algorithm,"RSA-PSS"))throw Jt("RSA-PSS");const n=parseInt(t.slice(2),10);const i=Ht(e.algorithm.hash);if(i!==n)throw Jt(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448"){throw Jt("Ed25519 or Ed448")}break}case"Ed25519":{if(!Kt(e.algorithm,"Ed25519"))throw Jt("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!Kt(e.algorithm,"ECDSA"))throw Jt("ECDSA");const n=Nt(t);const i=e.algorithm.namedCurve;if(i!==n)throw Jt(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Mt(e,n)}function Xt(e,t,...n){n=n.filter(Boolean);if(n.length>2){const t=n.pop();e+=`one of type ${n.join(", ")}, or ${t}.`}else if(n.length===2){e+=`one of type ${n[0]} or ${n[1]}.`}else{e+=`of type ${n[0]}.`}if(t==null){e+=` Received ${t}`}else if(typeof t==="function"&&t.name){e+=` Received function ${t.name}`}else if(typeof t==="object"&&t!=null){if(t.constructor?.name){e+=` Received an instance of ${t.constructor.name}`}}return e}var Ft=(e,...t)=>Xt("Key must be ",e,...t);function Vt(e,t,...n){return Xt(`Key for the ${e} algorithm must be `,t,...n)}var qt=e=>{if(bt(e)){return true}return e?.[Symbol.toStringTag]==="KeyObject"};const Gt=["CryptoKey"];const Yt=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1){return true}let n;for(const e of t){const t=Object.keys(e);if(!n||n.size===0){n=new Set(t);continue}for(const e of t){if(n.has(e)){return false}n.add(e)}}return true};var Zt=Yt;function Qt(e){return typeof e==="object"&&e!==null}function en(e){if(!Qt(e)||Object.prototype.toString.call(e)!=="[object Object]"){return false}if(Object.getPrototypeOf(e)===null){return true}let t=e;while(Object.getPrototypeOf(t)!==null){t=Object.getPrototypeOf(t)}return Object.getPrototypeOf(e)===t}var tn=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:n}=t.algorithm;if(typeof n!=="number"||n<2048){throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}};function nn(e){return en(e)&&typeof e.kty==="string"}function rn(e){return e.kty!=="oct"&&typeof e.d==="string"}function sn(e){return e.kty!=="oct"&&typeof e.d==="undefined"}function on(e){return nn(e)&&e.kty==="oct"&&typeof e.k==="string"}function an(e){let t;let n;switch(e.kty){case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`};n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`};n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`};n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"};n=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"};n=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"};n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv};n=e.d?["deriveBits"]:[];break;default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(e.alg){case"Ed25519":t={name:"Ed25519"};n=e.d?["sign"]:["verify"];break;case"EdDSA":t={name:e.crv};n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv};n=e.d?["deriveBits"]:[];break;default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new It('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:n}}const cn=async e=>{if(!e.alg){throw new TypeError('"alg" argument is required when "jwk.alg" is not present')}const{algorithm:t,keyUsages:n}=an(e);const i=[t,e.ext??false,e.key_ops??n];const r={...e};delete r.alg;delete r.use;return pt.subtle.importKey("jwk",r,...i)};var ln=cn;const dn=e=>_t(e);let hn;let un;const fn=e=>e?.[Symbol.toStringTag]==="KeyObject";const pn=async(e,t,n,i,r=false)=>{let s=e.get(t);if(s?.[i]){return s[i]}const o=await ln({...n,alg:i});if(r)Object.freeze(t);if(!s){e.set(t,{[i]:o})}else{s[i]=o}return o};const bn=(e,t)=>{if(fn(e)){let n=e.export({format:"jwk"});delete n.d;delete n.dp;delete n.dq;delete n.p;delete n.q;delete n.qi;if(n.k){return dn(n.k)}un||(un=new WeakMap);return pn(un,e,n,t)}if(nn(e)){if(e.k)return _t(e.k);un||(un=new WeakMap);const n=pn(un,e,e,t,true);return n}return e};const mn=(e,t)=>{if(fn(e)){let n=e.export({format:"jwk"});if(n.k){return dn(n.k)}hn||(hn=new WeakMap);return pn(hn,e,n,t)}if(nn(e)){if(e.k)return _t(e.k);hn||(hn=new WeakMap);const n=pn(hn,e,e,t,true);return n}return e};var gn={normalizePublicKey:bn,normalizePrivateKey:mn};async function wn(e,t){if(!en(e)){throw new TypeError("JWK must be an object")}t||(t=e.alg);switch(e.kty){case"oct":if(typeof e.k!=="string"||!e.k){throw new TypeError('missing "k" (Key Value) Parameter value')}return _t(e.k);case"RSA":if("oth"in e&&e.oth!==undefined){throw new It('RSA JWK "oth" (Other Primes Info) Parameter value is not supported')}case"EC":case"OKP":return ln({...e,alg:t});default:throw new It('Unsupported "kty" (Key Type) Parameter value')}}const vn=e=>e?.[Symbol.toStringTag];const yn=(e,t,n)=>{if(t.use!==undefined&&t.use!=="sig"){throw new TypeError("Invalid key for this operation, when present its use must be sig")}if(t.key_ops!==undefined&&t.key_ops.includes?.(n)!==true){throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${n}`)}if(t.alg!==undefined&&t.alg!==e){throw new TypeError(`Invalid key for this operation, when present its alg must be ${e}`)}return true};const kn=(e,t,n,i)=>{if(t instanceof Uint8Array)return;if(i&&nn(t)){if(on(t)&&yn(e,t,n))return;throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!qt(t)){throw new TypeError(Vt(e,t,...Gt,"Uint8Array",i?"JSON Web Key":null))}if(t.type!=="secret"){throw new TypeError(`${vn(t)} instances for symmetric algorithms must be of type "secret"`)}};const xn=(e,t,n,i)=>{if(i&&nn(t)){switch(n){case"sign":if(rn(t)&&yn(e,t,n))return;throw new TypeError(`JSON Web Key for this operation be a private JWK`);case"verify":if(sn(t)&&yn(e,t,n))return;throw new TypeError(`JSON Web Key for this operation be a public JWK`)}}if(!qt(t)){throw new TypeError(Vt(e,t,...Gt,i?"JSON Web Key":null))}if(t.type==="secret"){throw new TypeError(`${vn(t)} instances for asymmetric algorithms must not be of type "secret"`)}if(n==="sign"&&t.type==="public"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm signing must be of type "private"`)}if(n==="decrypt"&&t.type==="public"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.algorithm&&n==="verify"&&t.type==="private"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm verifying must be of type "public"`)}if(t.algorithm&&n==="encrypt"&&t.type==="private"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm encryption must be of type "public"`)}};function Sn(e,t,n,i){const r=t.startsWith("HS")||t==="dir"||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t);if(r){kn(t,n,i,e)}else{xn(t,n,i,e)}}Sn.bind(undefined,false);const _n=Sn.bind(undefined,true);function En(e,t,n,i,r){if(r.crit!==undefined&&i?.crit===undefined){throw new e('"crit" (Critical) Header Parameter MUST be integrity protected')}if(!i||i.crit===undefined){return new Set}if(!Array.isArray(i.crit)||i.crit.length===0||i.crit.some((e=>typeof e!=="string"||e.length===0))){throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present')}let s;if(n!==undefined){s=new Map([...Object.entries(n),...t.entries()])}else{s=t}for(const t of i.crit){if(!s.has(t)){throw new It(`Extension Header Parameter "${t}" is not recognized`)}if(r[t]===undefined){throw new e(`Extension Header Parameter "${t}" is missing`)}if(s.get(t)&&i[t]===undefined){throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}}return new Set(i.crit)}const An=(e,t)=>{if(t!==undefined&&(!Array.isArray(t)||t.some((e=>typeof e!=="string")))){throw new TypeError(`"${e}" option must be an array of strings`)}if(!t){return undefined}return new Set(t)};var Cn=An;const Tn=async e=>{if(e instanceof Uint8Array){return{kty:"oct",k:xt(e)}}if(!bt(e)){throw new TypeError(Ft(e,...Gt,"Uint8Array"))}if(!e.extractable){throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK")}const{ext:t,key_ops:n,alg:i,use:r,...s}=await pt.subtle.exportKey("jwk",e);return s};var In=Tn;async function zn(e){return In(e)}function $n(e,t){const n=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:t.name};default:throw new It(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function Rn(e,t,n){if(n==="sign"){t=await gn.normalizePrivateKey(t,e)}if(n==="verify"){t=await gn.normalizePublicKey(t,e)}if(bt(t)){Bt(t,e,n);return t}if(t instanceof Uint8Array){if(!e.startsWith("HS")){throw new TypeError(Ft(t,...Gt))}return pt.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},false,[n])}throw new TypeError(Ft(t,...Gt,"Uint8Array","JSON Web Key"))}const Pn=async(e,t,n,i)=>{const r=await Rn(e,t,"verify");tn(e,r);const s=$n(e,r.algorithm);try{return await pt.subtle.verify(s,r,n,i)}catch{return false}};var Dn=Pn;async function Wn(e,t,n){if(!en(e)){throw new Rt("Flattened JWS must be an object")}if(e.protected===undefined&&e.header===undefined){throw new Rt('Flattened JWS must have either of the "protected" or "header" members')}if(e.protected!==undefined&&typeof e.protected!=="string"){throw new Rt("JWS Protected Header incorrect type")}if(e.payload===undefined){throw new Rt("JWS Payload missing")}if(typeof e.signature!=="string"){throw new Rt("JWS Signature missing or incorrect type")}if(e.header!==undefined&&!en(e.header)){throw new Rt("JWS Unprotected Header incorrect type")}let i={};if(e.protected){try{const t=_t(e.protected);i=JSON.parse(vt.decode(t))}catch{throw new Rt("JWS Protected Header is invalid")}}if(!Zt(i,e.header)){throw new Rt("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const r={...i,...e.header};const s=En(Rt,new Map([["b64",true]]),n?.crit,i,r);let o=true;if(s.has("b64")){o=i.b64;if(typeof o!=="boolean"){throw new Rt('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:a}=r;if(typeof a!=="string"||!a){throw new Rt('JWS "alg" (Algorithm) Header Parameter missing or invalid')}const c=n&&Cn("algorithms",n.algorithms);if(c&&!c.has(a)){throw new Tt('"alg" (Algorithm) Header Parameter value not allowed')}if(o){if(typeof e.payload!=="string"){throw new Rt("JWS Payload must be a string")}}else if(typeof e.payload!=="string"&&!(e.payload instanceof Uint8Array)){throw new Rt("JWS Payload must be a string or an Uint8Array instance")}let l=false;if(typeof t==="function"){t=await t(i,e);l=true;_n(a,t,"verify");if(nn(t)){t=await wn(t,a)}}else{_n(a,t,"verify")}const d=yt(wt.encode(e.protected??""),wt.encode("."),typeof e.payload==="string"?wt.encode(e.payload):e.payload);let h;try{h=_t(e.signature)}catch{throw new Rt("Failed to base64url decode the signature")}const u=await Dn(a,t,h,d);if(!u){throw new Ut}let f;if(o){try{f=_t(e.payload)}catch{throw new Rt("Failed to base64url decode the payload")}}else if(typeof e.payload==="string"){f=wt.encode(e.payload)}else{f=e.payload}const p={payload:f};if(e.protected!==undefined){p.protectedHeader=i}if(e.header!==undefined){p.unprotectedHeader=e.header}if(l){return{...p,key:t}}return p}async function On(e,t,n){if(e instanceof Uint8Array){e=vt.decode(e)}if(typeof e!=="string"){throw new Rt("Compact JWS must be a string or Uint8Array")}const{0:i,1:r,2:s,length:o}=e.split(".");if(o!==3){throw new Rt("Invalid Compact JWS")}const a=await Wn({payload:r,protected:i,signature:s},t,n);const c={payload:a.payload,protectedHeader:a.protectedHeader};if(typeof t==="function"){return{...c,key:a.key}}return c}var Ln=e=>Math.floor(e.getTime()/1e3);const jn=60;const Un=jn*60;const Jn=Un*24;const Kn=Jn*7;const Hn=Jn*365.25;const Nn=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;var Mn=e=>{const t=Nn.exec(e);if(!t||t[4]&&t[1]){throw new TypeError("Invalid time period format")}const n=parseFloat(t[2]);const i=t[3].toLowerCase();let r;switch(i){case"sec":case"secs":case"second":case"seconds":case"s":r=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":r=Math.round(n*jn);break;case"hour":case"hours":case"hr":case"hrs":case"h":r=Math.round(n*Un);break;case"day":case"days":case"d":r=Math.round(n*Jn);break;case"week":case"weeks":case"w":r=Math.round(n*Kn);break;default:r=Math.round(n*Hn);break}if(t[1]==="-"||t[4]==="ago"){return-r}return r};const Bn=e=>e.toLowerCase().replace(/^application\//,"");const Xn=(e,t)=>{if(typeof e==="string"){return t.includes(e)}if(Array.isArray(e)){return t.some(Set.prototype.has.bind(new Set(e)))}return false};var Fn=(e,t,n={})=>{let i;try{i=JSON.parse(vt.decode(t))}catch{}if(!en(i)){throw new Pt("JWT Claims Set must be a top-level JSON object")}const{typ:r}=n;if(r&&(typeof e.typ!=="string"||Bn(e.typ)!==Bn(r))){throw new At('unexpected "typ" JWT header value',i,"typ","check_failed")}const{requiredClaims:s=[],issuer:o,subject:a,audience:c,maxTokenAge:l}=n;const d=[...s];if(l!==undefined)d.push("iat");if(c!==undefined)d.push("aud");if(a!==undefined)d.push("sub");if(o!==undefined)d.push("iss");for(const e of new Set(d.reverse())){if(!(e in i)){throw new At(`missing required "${e}" claim`,i,e,"missing")}}if(o&&!(Array.isArray(o)?o:[o]).includes(i.iss)){throw new At('unexpected "iss" claim value',i,"iss","check_failed")}if(a&&i.sub!==a){throw new At('unexpected "sub" claim value',i,"sub","check_failed")}if(c&&!Xn(i.aud,typeof c==="string"?[c]:c)){throw new At('unexpected "aud" claim value',i,"aud","check_failed")}let h;switch(typeof n.clockTolerance){case"string":h=Mn(n.clockTolerance);break;case"number":h=n.clockTolerance;break;case"undefined":h=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:u}=n;const f=Ln(u||new Date);if((i.iat!==undefined||l)&&typeof i.iat!=="number"){throw new At('"iat" claim must be a number',i,"iat","invalid")}if(i.nbf!==undefined){if(typeof i.nbf!=="number"){throw new At('"nbf" claim must be a number',i,"nbf","invalid")}if(i.nbf>f+h){throw new At('"nbf" claim timestamp check failed',i,"nbf","check_failed")}}if(i.exp!==undefined){if(typeof i.exp!=="number"){throw new At('"exp" claim must be a number',i,"exp","invalid")}if(i.exp<=f-h){throw new Ct('"exp" claim timestamp check failed',i,"exp","check_failed")}}if(l){const e=f-i.iat;const t=typeof l==="number"?l:Mn(l);if(e-h>t){throw new Ct('"iat" claim timestamp check failed (too far in the past)',i,"iat","check_failed")}if(e<0-h){throw new At('"iat" claim timestamp check failed (it should be in the past)',i,"iat","check_failed")}}return i};async function Vn(e,t,n){const i=await On(e,t,n);if(i.protectedHeader.crit?.includes("b64")&&i.protectedHeader.b64===false){throw new Pt("JWTs MUST NOT use unencoded payload")}const r=Fn(i.protectedHeader,i.payload,n);const s={payload:r,protectedHeader:i.protectedHeader};if(typeof t==="function"){return{...s,key:i.key}}return s}const qn=async(e,t,n)=>{const i=await Rn(e,t,"sign");tn(e,i);const r=await pt.subtle.sign($n(e,i.algorithm),i,n);return new Uint8Array(r)};var Gn=qn;class Yn{constructor(e){if(!(e instanceof Uint8Array)){throw new TypeError("payload must be an instance of Uint8Array")}this._payload=e}setProtectedHeader(e){if(this._protectedHeader){throw new TypeError("setProtectedHeader can only be called once")}this._protectedHeader=e;return this}setUnprotectedHeader(e){if(this._unprotectedHeader){throw new TypeError("setUnprotectedHeader can only be called once")}this._unprotectedHeader=e;return this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader){throw new Rt("either setProtectedHeader or setUnprotectedHeader must be called before #sign()")}if(!Zt(this._protectedHeader,this._unprotectedHeader)){throw new Rt("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const n={...this._protectedHeader,...this._unprotectedHeader};const i=En(Rt,new Map([["b64",true]]),t?.crit,this._protectedHeader,n);let r=true;if(i.has("b64")){r=this._protectedHeader.b64;if(typeof r!=="boolean"){throw new Rt('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:s}=n;if(typeof s!=="string"||!s){throw new Rt('JWS "alg" (Algorithm) Header Parameter missing or invalid')}_n(s,e,"sign");let o=this._payload;if(r){o=wt.encode(xt(o))}let a;if(this._protectedHeader){a=wt.encode(xt(JSON.stringify(this._protectedHeader)))}else{a=wt.encode("")}const c=yt(a,wt.encode("."),o);const l=await Gn(s,e,c);const d={signature:xt(l),payload:""};if(r){d.payload=vt.decode(o)}if(this._unprotectedHeader){d.header=this._unprotectedHeader}if(this._protectedHeader){d.protected=vt.decode(a)}return d}}class Zn{constructor(e){this._flattened=new Yn(e)}setProtectedHeader(e){this._flattened.setProtectedHeader(e);return this}async sign(e,t){const n=await this._flattened.sign(e,t);if(n.payload===undefined){throw new TypeError("use the flattened module for creating JWS with b64: false")}return`${n.protected}.${n.payload}.${n.signature}`}}function Qn(e,t){if(!Number.isFinite(t)){throw new TypeError(`Invalid ${e} input`)}return t}class ei{constructor(e={}){if(!en(e)){throw new TypeError("JWT Claims Set MUST be an object")}this._payload=e}setIssuer(e){this._payload={...this._payload,iss:e};return this}setSubject(e){this._payload={...this._payload,sub:e};return this}setAudience(e){this._payload={...this._payload,aud:e};return this}setJti(e){this._payload={...this._payload,jti:e};return this}setNotBefore(e){if(typeof e==="number"){this._payload={...this._payload,nbf:Qn("setNotBefore",e)}}else if(e instanceof Date){this._payload={...this._payload,nbf:Qn("setNotBefore",Ln(e))}}else{this._payload={...this._payload,nbf:Ln(new Date)+Mn(e)}}return this}setExpirationTime(e){if(typeof e==="number"){this._payload={...this._payload,exp:Qn("setExpirationTime",e)}}else if(e instanceof Date){this._payload={...this._payload,exp:Qn("setExpirationTime",Ln(e))}}else{this._payload={...this._payload,exp:Ln(new Date)+Mn(e)}}return this}setIssuedAt(e){if(typeof e==="undefined"){this._payload={...this._payload,iat:Ln(new Date)}}else if(e instanceof Date){this._payload={...this._payload,iat:Qn("setIssuedAt",Ln(e))}}else if(typeof e==="string"){this._payload={...this._payload,iat:Qn("setIssuedAt",Ln(new Date)+Mn(e))}}else{this._payload={...this._payload,iat:Qn("setIssuedAt",e)}}return this}}class ti extends ei{setProtectedHeader(e){this._protectedHeader=e;return this}async sign(e,t){const n=new Zn(wt.encode(JSON.stringify(this._payload)));n.setProtectedHeader(this._protectedHeader);if(Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===false){throw new Pt("JWTs MUST NOT use unencoded payload")}return n.sign(e,t)}}const ni=(e,t)=>{if(typeof e!=="string"||!e){throw new Dt(`${t} missing or invalid`)}};async function ii(e,t){if(!en(e)){throw new TypeError("JWK must be an object")}t??(t="sha256");if(t!=="sha256"&&t!=="sha384"&&t!=="sha512"){throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"')}let n;switch(e.kty){case"EC":ni(e.crv,'"crv" (Curve) Parameter');ni(e.x,'"x" (X Coordinate) Parameter');ni(e.y,'"y" (Y Coordinate) Parameter');n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":ni(e.crv,'"crv" (Subtype of Key Pair) Parameter');ni(e.x,'"x" (Public Key) Parameter');n={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":ni(e.e,'"e" (Exponent) Parameter');ni(e.n,'"n" (Modulus) Parameter');n={e:e.e,kty:e.kty,n:e.n};break;case"oct":ni(e.k,'"k" (Key Value) Parameter');n={k:e.k,kty:e.kty};break;default:throw new It('"kty" (Key Type) Parameter missing or unsupported')}const i=wt.encode(JSON.stringify(n));return xt(await gt(t,i))}function ri(e){switch(typeof e==="string"&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new It('Unsupported "alg" value for a JSON Web Key Set')}}function si(e){return e&&typeof e==="object"&&Array.isArray(e.keys)&&e.keys.every(oi)}function oi(e){return en(e)}function ai(e){if(typeof structuredClone==="function"){return structuredClone(e)}return JSON.parse(JSON.stringify(e))}class ci{constructor(e){this._cached=new WeakMap;if(!si(e)){throw new Wt("JSON Web Key Set malformed")}this._jwks=ai(e)}async getKey(e,t){const{alg:n,kid:i}={...e,...t?.header};const r=ri(n);const s=this._jwks.keys.filter((e=>{let t=r===e.kty;if(t&&typeof i==="string"){t=i===e.kid}if(t&&typeof e.alg==="string"){t=n===e.alg}if(t&&typeof e.use==="string"){t=e.use==="sig"}if(t&&Array.isArray(e.key_ops)){t=e.key_ops.includes("verify")}if(t){switch(n){case"ES256":t=e.crv==="P-256";break;case"ES256K":t=e.crv==="secp256k1";break;case"ES384":t=e.crv==="P-384";break;case"ES512":t=e.crv==="P-521";break;case"Ed25519":t=e.crv==="Ed25519";break;case"EdDSA":t=e.crv==="Ed25519"||e.crv==="Ed448";break}}return t}));const{0:o,length:a}=s;if(a===0){throw new Ot}if(a!==1){const e=new Lt;const{_cached:t}=this;e[Symbol.asyncIterator]=async function*(){for(const e of s){try{yield await li(t,e,n)}catch{}}};throw e}return li(this._cached,o,n)}}async function li(e,t,n){const i=e.get(t)||e.set(t,{}).get(t);if(i[n]===undefined){const e=await wn({...t,ext:true},n);if(e instanceof Uint8Array||e.type!=="public"){throw new Wt("JSON Web Key Set members must be public keys")}i[n]=e}return i[n]}function di(e){const t=new ci(e);const n=async(e,n)=>t.getKey(e,n);Object.defineProperties(n,{jwks:{value:()=>ai(t._jwks),enumerable:true,configurable:false,writable:false}});return n}const hi=async(e,t,n)=>{let i;let r;let s=false;if(typeof AbortController==="function"){i=new AbortController;r=setTimeout((()=>{s=true;i.abort()}),t)}const o=await fetch(e.href,{signal:i?i.signal:undefined,redirect:"manual",headers:n.headers}).catch((e=>{if(s)throw new jt;throw e}));if(r!==undefined)clearTimeout(r);if(o.status!==200){throw new Et("Expected 200 OK from the JSON Web Key Set HTTP response")}try{return await o.json()}catch{throw new Et("Failed to parse the JSON Web Key Set HTTP response as JSON")}};var ui=hi;function fi(){return typeof WebSocketPair!=="undefined"||typeof navigator!=="undefined"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime!=="undefined"&&EdgeRuntime==="vercel"}let pi;if(typeof navigator==="undefined"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 ")){const e="jose";const t="v5.10.0";pi=`${e}/${t}`}const bi=Symbol();function mi(e,t){if(typeof e!=="object"||e===null){return false}if(!("uat"in e)||typeof e.uat!=="number"||Date.now()-e.uat>=t){return false}if(!("jwks"in e)||!en(e.jwks)||!Array.isArray(e.jwks.keys)||!Array.prototype.every.call(e.jwks.keys,en)){return false}return true}class gi{constructor(e,t){if(!(e instanceof URL)){throw new TypeError("url must be an instance of URL")}this._url=new URL(e.href);this._options={agent:t?.agent,headers:t?.headers};this._timeoutDuration=typeof t?.timeoutDuration==="number"?t?.timeoutDuration:5e3;this._cooldownDuration=typeof t?.cooldownDuration==="number"?t?.cooldownDuration:3e4;this._cacheMaxAge=typeof t?.cacheMaxAge==="number"?t?.cacheMaxAge:6e5;if(t?.[bi]!==undefined){this._cache=t?.[bi];if(mi(t?.[bi],this._cacheMaxAge)){this._jwksTimestamp=this._cache.uat;this._local=di(this._cache.jwks)}}}coolingDown(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cooldownDuration:false}fresh(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cacheMaxAge:false}async getKey(e,t){if(!this._local||!this.fresh()){await this.reload()}try{return await this._local(e,t)}catch(n){if(n instanceof Ot){if(this.coolingDown()===false){await this.reload();return this._local(e,t)}}throw n}}async reload(){if(this._pendingFetch&&fi()){this._pendingFetch=undefined}const e=new Headers(this._options.headers);if(pi&&!e.has("User-Agent")){e.set("User-Agent",pi);this._options.headers=Object.fromEntries(e.entries())}this._pendingFetch||(this._pendingFetch=ui(this._url,this._timeoutDuration,this._options).then((e=>{this._local=di(e);if(this._cache){this._cache.uat=Date.now();this._cache.jwks=e}this._jwksTimestamp=Date.now();this._pendingFetch=undefined})).catch((e=>{this._pendingFetch=undefined;throw e})));await this._pendingFetch}}function wi(e,t){const n=new gi(e,t);const i=async(e,t)=>n.getKey(e,t);Object.defineProperties(i,{coolingDown:{get:()=>n.coolingDown(),enumerable:true,configurable:false},fresh:{get:()=>n.fresh(),enumerable:true,configurable:false},reload:{value:()=>n.reload(),enumerable:true,configurable:false,writable:false},reloading:{get:()=>!!n._pendingFetch,enumerable:true,configurable:false},jwks:{value:()=>n._local?.jwks(),enumerable:true,configurable:false,writable:false}});return i}const vi=_t;function yi(e){if(typeof e!=="string")throw new Pt("JWTs must use Compact JWS serialization, JWT must be a string");const{1:t,length:n}=e.split(".");if(n===5)throw new Pt("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new Pt("Invalid JWT");if(!t)throw new Pt("JWTs must contain a payload");let i;try{i=vi(t)}catch{throw new Pt("Failed to base64url decode the payload")}let r;try{r=JSON.parse(vt.decode(i))}catch{throw new Pt("Failed to parse the decoded payload as JSON")}if(!en(r))throw new Pt("Invalid JWT Claims Set");return r}function ki(e){const t=e?.modulusLength??2048;if(typeof t!=="number"||t<2048){throw new It("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used")}return t}async function xi(e,t){let n;let i;switch(e){case"PS256":case"PS384":case"PS512":n={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:ki(t)};i=["sign","verify"];break;case"RS256":case"RS384":case"RS512":n={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:ki(t)};i=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":n={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:ki(t)};i=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":n={name:"ECDSA",namedCurve:"P-256"};i=["sign","verify"];break;case"ES384":n={name:"ECDSA",namedCurve:"P-384"};i=["sign","verify"];break;case"ES512":n={name:"ECDSA",namedCurve:"P-521"};i=["sign","verify"];break;case"Ed25519":n={name:"Ed25519"};i=["sign","verify"];break;case"EdDSA":{i=["sign","verify"];const e=t?.crv??"Ed25519";switch(e){case"Ed25519":case"Ed448":n={name:e};break;default:throw new It("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{i=["deriveKey","deriveBits"];const e=t?.crv??"P-256";switch(e){case"P-256":case"P-384":case"P-521":{n={name:"ECDH",namedCurve:e};break}case"X25519":case"X448":n={name:e};break;default:throw new It("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return pt.subtle.generateKey(n,t?.extractable??false,i)}async function Si(e,t){return xi(e,t)}const _i=async(e,t)=>{const n={...t,grant_types:["authorization_code","refresh_token"],id_token_signed_response_alg:"ES256",token_endpoint_auth_method:"none",application_type:"web",subject_type:"public"};return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})};class Ei{dbName;storeName;dbVersion;db=null;constructor(e="soidc",t="session",n=1){this.dbName=e;this.storeName=t;this.dbVersion=n}async init(){return new Promise(((e,t)=>{const n=indexedDB.open(this.dbName,this.dbVersion);n.onerror=e=>{t(new Error(`Database error: ${e.target.error}`))};n.onsuccess=t=>{this.db=t.target.result;e(this)};n.onupgradeneeded=e=>{const t=e.target.result;if(!t.objectStoreNames.contains(this.storeName)){t.createObjectStore(this.storeName)}}}))}async setItem(e,t){if(!this.db){await this.init()}return new Promise(((n,i)=>{const r=this.db.transaction(this.storeName,"readwrite");r.oncomplete=()=>{n()};r.onerror=t=>{i(new Error(`Transaction error for setItem(${e},...): ${t.target.error}`))};r.onabort=t=>{i(new Error(`Transaction aborted for setItem(${e},...): ${t.target.error}`))};const s=r.objectStore(this.storeName);s.put(t,e)}))}async getItem(e){if(!this.db){await this.init()}return new Promise(((t,n)=>{const i=this.db.transaction(this.storeName,"readonly");i.onerror=t=>{n(new Error(`Transaction error for getItem(${e}): ${t.target.error}`))};i.onabort=t=>{n(new Error(`Transaction aborted for getItem(${e}): ${t.target.error}`))};const r=i.objectStore(this.storeName);const s=r.get(e);s.onsuccess=()=>{t(s.result||null)}}))}async deleteItem(e){if(!this.db){await this.init()}return new Promise(((t,n)=>{const i=this.db.transaction(this.storeName,"readwrite");i.oncomplete=()=>{t()};i.onerror=t=>{n(new Error(`Transaction error for deleteItem(${e}): ${t.target.error}`))};i.onabort=t=>{n(new Error(`Transaction aborted for deleteItem(${e}): ${t.target.error}`))};const r=i.objectStore(this.storeName);r.delete(e)}))}async clear(){if(!this.db){await this.init()}return new Promise(((e,t)=>{const n=this.db.transaction(this.storeName,"readwrite");n.oncomplete=()=>{e()};n.onerror=e=>{t(new Error(`Transaction error for clear(): ${e.target.error}`))};n.onabort=e=>{t(new Error(`Transaction aborted for clear(): ${e.target.error}`))};const i=n.objectStore(this.storeName);i.clear()}))}close(){if(this.db){this.db.close();this.db=null}}}const Ai=async(e,t,n)=>{const i=new URL(t);const r=i.origin+i.pathname+i.search;const s=new URL(e).origin;const o=await fetch(`${s}/.well-known/openid-configuration`).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));const a=o["issuer"];const c=e=>e.endsWith("/")?e.slice(0,-1):e;if(c(e)!==c(a)){throw new Error("RFC 9207 - iss != idp - "+a+" != "+e)}sessionStorage.setItem("idp",a);sessionStorage.setItem("token_endpoint",o["token_endpoint"]);sessionStorage.setItem("jwks_uri",o["jwks_uri"]);let l=n?.client_id;if(!l){const e=o["registration_endpoint"];const t=await _i(e,n??{redirect_uris:[r]}).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));l=t["client_id"];sessionStorage.setItem("client_id",l)}const{pkce_code_verifier:d,pkce_code_challenge:h}=await Ci();sessionStorage.setItem("pkce_code_verifier",d);const u=window.crypto.randomUUID();sessionStorage.setItem("csrf_token",u);const f=o["authorization_endpoint"]+`?response_type=code`+`&redirect_uri=${encodeURIComponent(r)}`+`&scope=openid offline_access webid`+`&client_id=${encodeURIComponent(l)}`+`&code_challenge_method=S256`+`&code_challenge=${h}`+`&state=${u}`+`&prompt=consent`;window.location.href=f};const Ci=async()=>{const e=window.crypto.randomUUID()+"-"+window.crypto.randomUUID();const t=new Uint8Array(await window.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e)));const n=btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return{pkce_code_verifier:e,pkce_code_challenge:n}};const Ti=async e=>{const t=new URL(window.location.href);const n=t.searchParams.get("code");if(n===null){return{clientDetails:e}}const i=sessionStorage.getItem("idp");if(i===null||t.searchParams.get("iss")!=i){throw new Error("RFC 9207 - iss != idp - "+t.searchParams.get("iss")+" != "+i)}if(t.searchParams.get("state")!=sessionStorage.getItem("csrf_token")){throw new Error("RFC 6749 - state != csrf_token - "+t.searchParams.get("state")+" != "+sessionStorage.getItem("csrf_token"))}t.searchParams.delete("iss");t.searchParams.delete("state");t.searchParams.delete("code");window.history.pushState({},document.title,t.toString());const r=sessionStorage.getItem("pkce_code_verifier");if(r===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: pkce_code_verifier")}const s=e?.client_id||sessionStorage.getItem("client_id");if(!s){throw new Error("Access Token Request preparation - Could not find in sessionStorage: client_id (dynamic registration)")}const o=sessionStorage.getItem("token_endpoint");if(o===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: token_endpoint")}const a=await Si("ES256");const c=await Ii(n,r,t.toString(),s,o,a).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));const l=c["access_token"];const d=sessionStorage.getItem("jwks_uri");if(d===null){throw new Error("Access Token validation preparation - Could not find in sessionStorage: jwks_uri")}const h=wi(new URL(d));const{payload:u}=await Vn(l,h,{issuer:i,audience:"solid"});const f=await ii(await zn(a.publicKey));if(u["cnf"]["jkt"]!=f){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+u["cnf"]["jkt"]+" != "+f)}if(u["client_id"]!=s){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+u["client_id"]+" != "+s)}const p={...c,dpop_key_pair:a};const b={idp:i,jwks_uri:d,token_endpoint:o};if(!e)e={redirect_uris:[window.location.href]};e.client_id=s;const m=await(new Ei).init();await Promise.all([m.setItem("idp",i),m.setItem("jwks_uri",d),m.setItem("token_endpoint",o),m.setItem("client_id",s),m.setItem("dpop_keypair",a),m.setItem("refresh_token",c["refresh_token"])]);m.close();sessionStorage.removeItem("csrf_token");sessionStorage.removeItem("pkce_code_verifier");sessionStorage.removeItem("idp");sessionStorage.removeItem("jwks_uri");sessionStorage.removeItem("token_endpoint");sessionStorage.removeItem("client_id");return{clientDetails:e,idpDetails:b,tokenDetails:p}};const Ii=async(e,t,n,i,r,s)=>{const o=await zn(s.publicKey);o.alg="ES256";const a=await new ti({htu:r,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:o}).sign(s.privateKey);return fetch(r,{method:"POST",headers:{dpop:a,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:n,client_id:i})})};const zi=async()=>{const e=await(new Ei).init();const t=await e.getItem("client_id");const n=await e.getItem("token_endpoint");const i=await e.getItem("dpop_keypair");const r=await e.getItem("refresh_token");if(t===null||n===null||i===null||r===null){throw new Error("Could not refresh tokens: details missing from database.")}const s=await $i(r,t,n,i).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));const o=s["access_token"];const a=await e.getItem("idp");if(a===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: idp")}const c=await e.getItem("jwks_uri");if(c===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: jwks_uri")}const l=wi(new URL(c));const{payload:d}=await Vn(o,l,{issuer:a,audience:"solid"});const h=await ii(await zn(i.publicKey));if(d["cnf"]["jkt"]!=h){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+d["cnf"]["jkt"]+" != "+h)}if(d["client_id"]!=t){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+d["client_id"]+" != "+t)}await e.setItem("refresh_token",s["refresh_token"]);e.close();return{...s,dpop_key_pair:i}};const $i=async(e,t,n,i)=>{const r=await zn(i.publicKey);r.alg="ES256";const s=await new ti({htu:n,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:r}).sign(i.privateKey);return fetch(n,{method:"POST",headers:{dpop:s,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:t})})};class Ri{sessionInformation;isActive_=false;webId_=undefined;currentAth_=undefined;tokenRefreshTimeout;sessionDeactivateTimeout;onSessionExpirationWarning;constructor(e,t){this.sessionInformation={clientDetails:e};this.onSessionExpirationWarning=t?.onSessionExpirationWarning}async login(e,t){await Ai(e,t,this.sessionInformation.clientDetails)}async logout(){if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=undefined;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=undefined;this.sessionInformation.idpDetails=undefined;this.sessionInformation.tokenDetails=undefined;this.isActive_=false;this.webId_=undefined;if(this.sessionInformation.clientDetails?.client_id)try{new URL(this.sessionInformation.clientDetails.client_id)}catch(e){this.sessionInformation.clientDetails.client_id=undefined}const e=await(new Ei).init();await e.clear();e.close()}async handleRedirectFromLogin(){const e=await Ti(this.sessionInformation.clientDetails);if(!e.tokenDetails){return}this.sessionInformation=e;await this.setSessionDetails()}async restore(){await zi().then((e=>{this.sessionInformation.tokenDetails=e;return this.setSessionDetails()})).catch((e=>{}))}async createSignedDPoPToken(e){if(!this.sessionInformation.tokenDetails||!this.currentAth_){throw new Error("Session not established.")}e.ath=this.currentAth_;const t=await zn(this.sessionInformation.tokenDetails.dpop_key_pair.publicKey);return new ti(e).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:t}).sign(this.sessionInformation.tokenDetails.dpop_key_pair.privateKey)}async authFetch(e,t,n){let i;let r;let s;if(e instanceof Request){i=new URL(e.url);r=t?.method||e?.method||"GET";s=new Headers(e.headers)}else{t=t||{};i=new URL(e.toString());r=t.method||"GET";s=t.headers?new Headers(t.headers):new Headers}if(this.sessionInformation.tokenDetails){n=n??{htu:`${i.origin}${i.pathname}`,htm:r.toUpperCase()};const e=await this.createSignedDPoPToken(n);s.set("dpop",e);s.set("authorization",`DPoP ${this.sessionInformation.tokenDetails.access_token}`)}if(e instanceof Request){return fetch(new Request(e,{...t,headers:s}))}return fetch(i,{...t,headers:s})}get isActive(){return this.isActive_}get webId(){return this.webId_}async setSessionDetails(){if(!this.sessionInformation.tokenDetails?.access_token){this.logout()}this.currentAth_=await this.computeAth(this.sessionInformation.tokenDetails.access_token);this.webId_=yi(this.sessionInformation.tokenDetails.access_token)["webid"];this.isActive_=this.webId!==undefined;this.setSessionDeactivateTimeout();this.setTokenRefreshTimeout()}setSessionDeactivateTimeout(){const e=5;const t=(this.sessionInformation.tokenDetails.expires_in-e)*1e3;if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=setTimeout((()=>this.logout()),t)}setTokenRefreshTimeout(){const e=95;const t=(this.sessionInformation.tokenDetails.expires_in-e)*1e3;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=setTimeout((async()=>{const e=await zi().catch((e=>{if(this.onSessionExpirationWarning)this.onSessionExpirationWarning();return undefined}));if(!e){return}this.sessionInformation.tokenDetails=e;this.setSessionDetails()}),t)}async computeAth(e){const t=new TextEncoder;const n=t.encode(e);const i=await crypto.subtle.digest("SHA-256",n);const r=Array.from(new Uint8Array(i));const s=btoa(String.fromCharCode(...r));const o=s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return o}}class Pi{get authenticatedFetch(){return this._authenticatedFetch}constructor(){this.onSessionRestoreCallback=()=>{};this.sessionInfo$=new ft({isLoggedIn:false,webId:undefined});this.session=new Ri;this._authenticatedFetch=this.session.authFetch.bind(this.session)}async handleIncomingRedirect(e=false){await this.session.handleRedirectFromLogin();if(e){await this.session.restore();if(this.session.isActive){this.onSessionRestoreCallback(window.location.href)}}this.sessionInfo$.next({isLoggedIn:this.session.isActive,webId:this.session.webId})}async login(e){return this.session.login(e,window.location.href)}async logout(){await this.session.logout();this.sessionInfo$.next({isLoggedIn:false,webId:undefined})}observeSession(){return this.sessionInfo$}onSessionRestore(e){this.onSessionRestoreCallback=e}}const Di=class{constructor(e){t(this,e);this.sessionRestoredEmitter=s(this,"pod-os:session-restored",7);this.podOsLoadedEmitter=s(this,"pod-os:loaded",7);this.restorePreviousSession=false;this.disconnected$=new v;this.loading=true}async componentWillLoad(){const e=new Pi;this.unsubscribeSettings=Pe.on("set",(()=>{this.os=ut(e,Pe.state)}));this.os=ut(e,Pe.state);e.onSessionRestore((e=>{this.sessionRestoredEmitter.emit({url:e})}));try{await e.handleIncomingRedirect(this.restorePreviousSession)}catch(e){console.error(e)}this.os.observeSession().pipe(y(this.disconnected$)).subscribe((async e=>{p.state.webId=e.webId;if(e.isLoggedIn){const t=await this.os.fetchProfile(e.webId);p.state.profile=t}p.state.isLoggedIn=e.isLoggedIn;this.loading=false}));this.podOsLoadedEmitter.emit({os:this.os,authenticatedFetch:e.authenticatedFetch})}disconnectedCallback(){this.unsubscribeSettings();this.disconnected$.next();this.disconnected$.unsubscribe()}async initializeOs(e){e.stopPropagation();e.detail(this.os)}async loadModule(e){e.stopPropagation();if(e.detail.module==="contacts"){const t=await this.os.loadContactsModule();e.detail.receiver(t)}else{throw Error(`Unknown module "${e.detail.module}"`)}}render(){return this.loading?n("ion-progress-bar",{type:"indeterminate"}):n("slot",null)}};const Wi="pos-router {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\npos-navigation {\n max-width: var(--width-lg);\n margin: 0;\n min-width: var(--size-32);\n flex-shrink: 1; /* Ensure navigation can shrink */\n}\n\npos-add-new-thing,\npos-login {\n flex: 0 1 auto;\n flex-shrink: 0; /* Ensure those items don't shrink */\n}\n\nheader,\nfooter {\n display: flex;\n gap: var(--size-1);\n height: auto;\n justify-content: center;\n align-items: center;\n padding: var(--size-1);\n}\n\nfooter svg {\n width: var(--size-5);\n height: var(--size-5);\n}\n\nfooter {\n font-size: var(--scale-fluid-000);\n\n .settings {\n padding: 0 var(--size-1);\n text-decoration: none;\n background-color: var(--pos-background-color);\n border: 1px solid var(--pos-secondary-border-color);\n color: var(--pos-secondary-border-color);\n border-radius: var(--radius-xs);\n\n &:hover {\n background-color: var(--pos-secondary-border-color);\n color: var(--pos-background-color);\n }\n }\n}\n\nheader {\n flex-wrap: nowrap;\n padding: var(--size-1) var(--size-8);\n}\n\nmain {\n flex: 1;\n max-height: 100vh;\n overflow: auto;\n}\n\n@media (max-width: 640px) {\n header {\n padding: var(--size-1);\n justify-content: space-between;\n }\n footer {\n display: none;\n }\n}\n";const Oi=Wi;const Li=class{constructor(e){t(this,e);this.restorePreviousSession=false;this.mode="standalone";this.uri=""}render(){return n(i,{key:"08b186d2f354d6c07df02707eb4ada81aef7dec3"},n("pos-app",{key:"54c372343e916ab5d77584381b3965c925ae0cd0",restorePreviousSession:this.restorePreviousSession},n("pos-error-toast",{key:"ab63e18121ca16670f81da141219a782dde0694b"},n("pos-router",{key:"69b6f3bf8ce3720c6c39cdb4be69e640e27ccc5b",mode:this.mode,"onPod-os:route-changed":e=>this.uri=e.detail},n("header",{key:"5cd3412caf13b6d99da517ae7e6f5877234e65d7"},n("pos-add-new-thing",{key:"9b83b3cf03b7038303975386176df539b35ff547",referenceUri:this.uri}),n("pos-navigation",{key:"26bfed9b1c8dd1be018babc6ef40ae42808a5c42",uri:this.uri==="pod-os:dashboard"?"":this.uri}),n("pos-login",{key:"e29f18dcde866d8ac1e317fcd7b71ef584e69034"},n("pos-user-menu",{key:"be796f0914649eb4e8525a9d8acdfd535626303c",webId:p.state.webId,slot:"if-logged-in"}))),n("main",{key:"f99dfb2d43e949528bc767b94801c99bf04a7eea"},this.mainContent()),n("footer",{key:"64744d1246356fa00da9c6b561785e2b794a7907"},n(ji,{key:"a648f7f88e12c79348bda33152f2759d2b93e738"}),n("span",{key:"f22e2f9904ba517fc2e579a05018704b5ade6302"},"PodOS Browser"))))))}mainContent(){if(this.uri===""){return null}if(this.uri.startsWith("pod-os:")){return n("pos-internal-router",{uri:this.uri})}return n("pos-resource",{key:this.uri,uri:this.uri},n("pos-type-router",null))}};const ji=()=>n("svg",{viewBox:"0 0 400 400",xmlns:"http://www.w3.org/2000/svg"},n("path",{d:"M50 350 L50 100 L200 50 L350 100 L350 350 Z",style:{fill:"#008BF8",stroke:"#008BF8","stroke-width":"70"},"stroke-linejoin":"round"}),n("path",{d:"M100 300 L100 150 L200 120 L300 150 L300 300 L130 300 L130 370 L100 370Z",style:{fill:"white",stroke:"white","stroke-width":"45"},"stroke-linejoin":"round"}),n("path",{d:"M150 250 L150 200 L200 180 L250 200 L250 250 Z",style:{fill:"#DC0073",stroke:"#DC0073","stroke-width":"20"},"stroke-linejoin":"round"}));Li.style=Oi;const Ui=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const Ji=Ui;const Ki=class{constructor(e){t(this,e)}render(){return n(i,{key:"18dc165b7be1c796136804a2ba7643b2a6fffc73"},n("pos-getting-started",{key:"e3f7a22641e4c24168a36f96463515cd1a89ca5e"}),n("pos-example-resources",{key:"1044dd873049118e165ff6d38449c85695f63a50"}))}};Ki.style=Ji;const Hi=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const Ni=Hi;const Mi=class{constructor(e){t(this,e)}render(){return n("pos-setting-offline-cache",{key:"f065206f6291089773a19045243f04b6ce35eeb9"})}};Mi.style=Ni;const Bi=class{constructor(e){t(this,e);this.subscribeResource=s(this,"pod-os:resource",7);this.receiveResource=e=>{this.resource=e}}componentWillLoad(){x(this)}render(){return this.resource?this.resource.description():null}};const Xi="dialog{background-color:var(--pos-background-color);color:var(--pos-normal-text-color);border:none;border-radius:var(--radius-md);box-shadow:var(--shadow-md);max-width:var(--width-xs);animation:slideIn 0.2s ease-out}dialog::backdrop{background:rgba(0, 0, 0, 0.5);backdrop-filter:var(--blur-sm);animation:fadeIn 0.2s ease-out}@media (prefers-color-scheme: dark){dialog::backdrop{background:rgb(100, 100, 100, 0.5)}}dialog header>:first-child{flex-grow:1;font-weight:var(--weight-light);font-size:var(--scale-2);font-family:var(--font-sans);margin:0}dialog header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;gap:var(--scale-0);border-bottom-style:inset;padding:0 0 var(--scale-0) 0}dialog>:last-child{display:block;margin-top:var(--scale-3)}button#close{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;background:none;font-size:var(--scale-3);color:var(--color-grey-500)}button#close:hover{color:var(--pos-secondary-border-color)}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-20px) scale(0.95)}to{opacity:1;transform:translateY(0) scale(1)}}";const Fi=Xi;const Vi=class{constructor(e){t(this,e)}async showModal(){this.dialog.showModal()}async close(){this.dialog.close()}render(){return n(i,{key:"42ee67fc5636f2c5d1a44613d0c39b0e98112a79"},n("dialog",{key:"e05b18b7ed8cae7ac010ecdcb3f58367f742fe77",ref:e=>this.dialog=e},n("header",{key:"4e3b2a6c0fc069c425d8bc9dcedee4e7f5c95c01"},n("slot",{key:"7617853cebf80d86469956af01761970fa68aa7b",name:"title"}),n("button",{key:"c6858cb4b90ab1cef16adb77a148aa2bec405cf7",tabindex:-1,id:"close",title:"Close",onClick:()=>this.close()},n("ion-icon",{key:"58737ce0aac7b5047557b81c15daed713490a5ce",name:"close-outline"}))),n("slot",{key:"868baba59e97e691735759af250cffed8766c913",name:"content"})))}};Vi.style=Fi;var qi=e=>{var t;const{activeElement:n}=document;if(n&&e.contains(n)){(t=document.activeElement)==null?void 0:t.blur()}};var Gi=S`
|
|
1
|
+
import{d as e,r as t,h as n,H as i,e as r,f as s,i as o,j as a}from"./p-99602d8c.js";import{c}from"./p-4ab8d4da.js";import{c as l,h as d}from"./p-669fab6c.js";import{c as h,g as u}from"./p-9ff1da1c.js";import{c as f,s as p,B as b}from"./p-3d182668.js";import{P as m,N as g,L as w}from"./p-a962c4b4.js";import{S as v,t as y,d as k}from"./p-5cade8cd.js";import{s as x}from"./p-f6671856.js";import{i as S,x as _,E,c as A,S as C,_ as T,a as I,r as z,n as $,w as R,b as P,f as D}from"./p-9be91e78.js";import{e as W,a as O,s as L,L as j,b as U,g as J,c as K,w as H,S as N,i as M,t as B,d as X}from"./p-50aca1ca.js";import{s as F}from"./p-182f722d.js";import"./p-c066fd50.js";let V;const q=()=>{if(typeof window==="undefined"){return new Map}else{if(!V){const e=window;e.Ionicons=e.Ionicons||{};V=e.Ionicons.map=e.Ionicons.map||new Map}return V}};const G=e=>{let t=Q(e.src);if(t){return t}t=Z(e.name,e.icon,e.mode,e.ios,e.md);if(t){return Y(t,e)}if(e.icon){t=Q(e.icon);if(t){return t}t=Q(e.icon[e.mode]);if(t){return t}}return null};const Y=(t,n)=>{const i=q().get(t);if(i){return i}try{return e(`svg/${t}.svg`)}catch(e){console.warn(`[Ionicons Warning]: Could not load icon with name "${t}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`,n)}};const Z=(e,t,n,i,r)=>{n=(n&&ne(n))==="ios"?"ios":"md";if(i&&n==="ios"){e=ne(i)}else if(r&&n==="md"){e=ne(r)}else{if(!e&&t&&!ee(t)){e=t}if(te(e)){e=ne(e)}}if(!te(e)||e.trim()===""){return null}const s=e.replace(/[a-z]|-|\d/gi,"");if(s!==""){return null}return e};const Q=e=>{if(te(e)){e=e.trim();if(ee(e)){return e}}return null};const ee=e=>e.length>0&&/(\/|\.)/.test(e);const te=e=>typeof e==="string";const ne=e=>e.toLowerCase();const ie=(e,t=[])=>{const n={};t.forEach((t=>{if(e.hasAttribute(t)){const i=e.getAttribute(t);if(i!==null){n[t]=e.getAttribute(t)}e.removeAttribute(t)}}));return n};const re=e=>{if(e){if(e.dir!==""){return e.dir.toLowerCase()==="rtl"}}return(document===null||document===void 0?void 0:document.dir.toLowerCase())==="rtl"};const se=e=>{const t=document.createElement("div");t.innerHTML=e;for(let e=t.childNodes.length-1;e>=0;e--){if(t.childNodes[e].nodeName.toLowerCase()!=="svg"){t.removeChild(t.childNodes[e])}}const n=t.firstElementChild;if(n&&n.nodeName.toLowerCase()==="svg"){const e=n.getAttribute("class")||"";n.setAttribute("class",(e+" s-ion-icon").trim());if(oe(n)){return t.innerHTML}}return""};const oe=e=>{if(e.nodeType===1){if(e.nodeName.toLowerCase()==="script"){return false}for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t].name;if(te(n)&&n.toLowerCase().indexOf("on")===0){return false}}for(let t=0;t<e.childNodes.length;t++){if(!oe(e.childNodes[t])){return false}}}return true};const ae=e=>e.startsWith("data:image/svg+xml");const ce=e=>e.indexOf(";utf8,")!==-1;const le=new Map;const de=new Map;let he;const ue=(e,t)=>{let n=de.get(e);if(!n){if(typeof fetch!=="undefined"&&typeof document!=="undefined"){if(ae(e)&&ce(e)){if(!he){he=new DOMParser}const t=he.parseFromString(e,"text/html");const n=t.querySelector("svg");if(n){le.set(e,n.outerHTML)}return Promise.resolve()}else{n=fetch(e).then((n=>{if(n.ok){return n.text().then((n=>{if(n&&t!==false){n=se(n)}le.set(e,n||"")}))}le.set(e,"")}));de.set(e,n)}}else{le.set(e,"");return Promise.resolve()}}return n};const fe=":host{display:inline-block;width:1em;height:1em;contain:strict;fill:currentColor;box-sizing:content-box !important}:host .ionicon{stroke:currentColor}.ionicon-fill-none{fill:none}.ionicon-stroke-width{stroke-width:32px;stroke-width:var(--ionicon-stroke-width, 32px)}.icon-inner,.ionicon,svg{display:block;height:100%;width:100%}@supports (background: -webkit-named-image(i)){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}@supports not selector(:dir(rtl)) and selector(:host-context([dir='rtl'])){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}:host(.flip-rtl):host-context([dir='rtl']) .icon-inner{transform:scaleX(-1)}@supports selector(:dir(rtl)){:host(.flip-rtl:dir(rtl)) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(ltr)) .icon-inner{transform:scaleX(1)}}:host(.icon-small){font-size:1.125rem !important}:host(.icon-large){font-size:2rem !important}:host(.ion-color){color:var(--ion-color-base) !important}:host(.ion-color-primary){--ion-color-base:var(--ion-color-primary, #3880ff)}:host(.ion-color-secondary){--ion-color-base:var(--ion-color-secondary, #0cd1e8)}:host(.ion-color-tertiary){--ion-color-base:var(--ion-color-tertiary, #f4a942)}:host(.ion-color-success){--ion-color-base:var(--ion-color-success, #10dc60)}:host(.ion-color-warning){--ion-color-base:var(--ion-color-warning, #ffce00)}:host(.ion-color-danger){--ion-color-base:var(--ion-color-danger, #f14141)}:host(.ion-color-light){--ion-color-base:var(--ion-color-light, #f4f5f8)}:host(.ion-color-medium){--ion-color-base:var(--ion-color-medium, #989aa2)}:host(.ion-color-dark){--ion-color-base:var(--ion-color-dark, #222428)}";const pe=fe;const be=class{constructor(e){t(this,e);this.iconName=null;this.inheritedAttributes={};this.didLoadIcon=false;this.svgContent=undefined;this.isVisible=false;this.mode=me();this.color=undefined;this.ios=undefined;this.md=undefined;this.flipRtl=undefined;this.name=undefined;this.src=undefined;this.icon=undefined;this.size=undefined;this.lazy=false;this.sanitize=true}componentWillLoad(){this.inheritedAttributes=ie(this.el,["aria-label"])}connectedCallback(){this.waitUntilVisible(this.el,"50px",(()=>{this.isVisible=true;this.loadIcon()}))}componentDidLoad(){if(!this.didLoadIcon){this.loadIcon()}}disconnectedCallback(){if(this.io){this.io.disconnect();this.io=undefined}}waitUntilVisible(e,t,n){if(this.lazy&&typeof window!=="undefined"&&window.IntersectionObserver){const i=this.io=new window.IntersectionObserver((e=>{if(e[0].isIntersecting){i.disconnect();this.io=undefined;n()}}),{rootMargin:t});i.observe(e)}else{n()}}loadIcon(){if(this.isVisible){const e=G(this);if(e){if(le.has(e)){this.svgContent=le.get(e)}else{ue(e,this.sanitize).then((()=>this.svgContent=le.get(e)))}this.didLoadIcon=true}}this.iconName=Z(this.name,this.icon,this.mode,this.ios,this.md)}render(){const{flipRtl:e,iconName:t,inheritedAttributes:r,el:s}=this;const o=this.mode||"md";const a=t?(t.includes("arrow")||t.includes("chevron"))&&e!==false:false;const c=e||a;return n(i,Object.assign({role:"img",class:Object.assign(Object.assign({[o]:true},ge(this.color)),{[`icon-${this.size}`]:!!this.size,"flip-rtl":c,"icon-rtl":c&&re(s)})},r),this.svgContent?n("div",{class:"icon-inner",innerHTML:this.svgContent}):n("div",{class:"icon-inner"}))}static get assetsDirs(){return["svg"]}get el(){return r(this)}static get watchers(){return{name:["loadIcon"],src:["loadIcon"],icon:["loadIcon"],ios:["loadIcon"],md:["loadIcon"]}}};const me=()=>typeof document!=="undefined"&&document.documentElement.getAttribute("mode")||"md";const ge=e=>e?{"ion-color":true,[`ion-color-${e}`]:true}:null;be.style=pe;const we=":host{--background:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.3);--progress-background:var(--ion-color-primary, #3880ff);--buffer-background:var(--background);display:block;position:relative;width:100%;contain:strict;direction:ltr;overflow:hidden}.progress,.progress-indeterminate,.indeterminate-bar-primary,.indeterminate-bar-secondary,.progress-buffer-bar{left:0;right:0;top:0;bottom:0;position:absolute;width:100%;height:100%}.buffer-circles-container,.buffer-circles{left:0;right:0;top:0;bottom:0;position:absolute}.buffer-circles{right:-10px;left:-10px;}.progress,.progress-buffer-bar,.buffer-circles-container{transform-origin:left top;transition:transform 150ms linear}.progress,.progress-indeterminate{background:var(--progress-background);z-index:2}.progress-buffer-bar{background:var(--buffer-background);z-index:1}.buffer-circles-container{overflow:hidden}.indeterminate-bar-primary{top:0;right:0;bottom:0;left:-145.166611%;animation:primary-indeterminate-translate 2s infinite linear}.indeterminate-bar-primary .progress-indeterminate{animation:primary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.indeterminate-bar-secondary{top:0;right:0;bottom:0;left:-54.888891%;animation:secondary-indeterminate-translate 2s infinite linear}.indeterminate-bar-secondary .progress-indeterminate{animation:secondary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.buffer-circles{background-image:radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%);background-repeat:repeat-x;background-position:5px center;background-size:10px 10px;z-index:0;animation:buffering 450ms infinite linear}:host(.progress-bar-reversed){transform:scaleX(-1)}:host(.progress-paused) .indeterminate-bar-secondary,:host(.progress-paused) .indeterminate-bar-primary,:host(.progress-paused) .buffer-circles{animation-play-state:paused}:host(.ion-color) .progress-buffer-bar{background:rgba(var(--ion-color-base-rgb), 0.3)}:host(.ion-color) .buffer-circles{background-image:radial-gradient(ellipse at center, rgba(var(--ion-color-base-rgb), 0.3) 0%, rgba(var(--ion-color-base-rgb), 0.3) 30%, transparent 30%)}:host(.ion-color) .progress,:host(.ion-color) .progress-indeterminate{background:var(--ion-color-base)}@keyframes primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes buffering{to{transform:translateX(-10px)}}:host{height:3px}";const ve=we;const ye=":host{--background:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.3);--progress-background:var(--ion-color-primary, #3880ff);--buffer-background:var(--background);display:block;position:relative;width:100%;contain:strict;direction:ltr;overflow:hidden}.progress,.progress-indeterminate,.indeterminate-bar-primary,.indeterminate-bar-secondary,.progress-buffer-bar{left:0;right:0;top:0;bottom:0;position:absolute;width:100%;height:100%}.buffer-circles-container,.buffer-circles{left:0;right:0;top:0;bottom:0;position:absolute}.buffer-circles{right:-10px;left:-10px;}.progress,.progress-buffer-bar,.buffer-circles-container{transform-origin:left top;transition:transform 150ms linear}.progress,.progress-indeterminate{background:var(--progress-background);z-index:2}.progress-buffer-bar{background:var(--buffer-background);z-index:1}.buffer-circles-container{overflow:hidden}.indeterminate-bar-primary{top:0;right:0;bottom:0;left:-145.166611%;animation:primary-indeterminate-translate 2s infinite linear}.indeterminate-bar-primary .progress-indeterminate{animation:primary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.indeterminate-bar-secondary{top:0;right:0;bottom:0;left:-54.888891%;animation:secondary-indeterminate-translate 2s infinite linear}.indeterminate-bar-secondary .progress-indeterminate{animation:secondary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.buffer-circles{background-image:radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%);background-repeat:repeat-x;background-position:5px center;background-size:10px 10px;z-index:0;animation:buffering 450ms infinite linear}:host(.progress-bar-reversed){transform:scaleX(-1)}:host(.progress-paused) .indeterminate-bar-secondary,:host(.progress-paused) .indeterminate-bar-primary,:host(.progress-paused) .buffer-circles{animation-play-state:paused}:host(.ion-color) .progress-buffer-bar{background:rgba(var(--ion-color-base-rgb), 0.3)}:host(.ion-color) .buffer-circles{background-image:radial-gradient(ellipse at center, rgba(var(--ion-color-base-rgb), 0.3) 0%, rgba(var(--ion-color-base-rgb), 0.3) 30%, transparent 30%)}:host(.ion-color) .progress,:host(.ion-color) .progress-indeterminate{background:var(--ion-color-base)}@keyframes primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes buffering{to{transform:translateX(-10px)}}:host{height:4px}";const ke=ye;const xe=class{constructor(e){t(this,e);this.type="determinate";this.reversed=false;this.value=0;this.buffer=1;this.color=undefined}render(){const{color:e,type:t,reversed:r,value:s,buffer:o}=this;const a=h.getBoolean("_testing");const c=u(this);return n(i,{key:"944b79ed6fce1b2c0ed48681cd8517a5abbddd80",role:"progressbar","aria-valuenow":t==="determinate"?s:null,"aria-valuemin":"0","aria-valuemax":"1",class:l(e,{[c]:true,[`progress-bar-${t}`]:true,"progress-paused":a,"progress-bar-reversed":document.dir==="rtl"?!r:r})},t==="indeterminate"?Se():_e(s,o))}};const Se=()=>n("div",{part:"track",class:"progress-buffer-bar"},n("div",{class:"indeterminate-bar-primary"},n("span",{part:"progress",class:"progress-indeterminate"})),n("div",{class:"indeterminate-bar-secondary"},n("span",{part:"progress",class:"progress-indeterminate"})));const _e=(e,t)=>{const i=c(0,e,1);const r=c(0,t,1);return[n("div",{part:"progress",class:"progress",style:{transform:`scaleX(${i})`}}),n("div",{class:{"buffer-circles-container":true,"ion-hide":r===1},style:{transform:`translateX(${r*100}%)`}},n("div",{class:"buffer-circles-container",style:{transform:`translateX(-${r*100}%)`}},n("div",{part:"stream",class:"buffer-circles"}))),n("div",{part:"track",class:"progress-buffer-bar",style:{transform:`scaleX(${r})`}})]};xe.style={ios:ve,md:ke};const Ee=":host{--background:rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065);border-radius:var(--border-radius, inherit);display:block;width:100%;height:inherit;margin-top:4px;margin-bottom:4px;background:var(--background);line-height:10px;user-select:none;pointer-events:none}span{display:inline-block}:host(.in-media){margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;height:100%}:host(.skeleton-text-animated){position:relative;background:linear-gradient(to right, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 8%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.135) 18%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 33%);background-size:800px 104px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:shimmer;animation-timing-function:linear}@keyframes shimmer{0%{background-position:-400px 0}100%{background-position:400px 0}}";const Ae=Ee;const Ce=class{constructor(e){t(this,e);this.ionStyle=s(this,"ionStyle",7);this.animated=false}componentWillLoad(){this.emitStyle()}emitStyle(){const e={"skeleton-text":true};this.ionStyle.emit(e)}render(){const e=this.animated&&h.getBoolean("animated",true);const t=d("ion-avatar",this.el)||d("ion-thumbnail",this.el);const r=u(this);return n(i,{key:"4dab0fd2de666de12ad8f6dc6ed1e1de0be67ddd",class:{[r]:true,"skeleton-text-animated":e,"in-media":t}},n("span",{key:"f8f908ec24d65e63b14d9a54640a5f18f0fa8fa5"}," "))}get el(){return r(this)}};Ce.style=Ae;const Te=":host{font-family:var(--font-sans);display:block}button#new{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;width:var(--size-10);height:var(--size-10);background-color:var(--pos-primary-color);color:var(--pos-primary-text-color);font-size:var(--scale-6);border-radius:var(--radius-xs)}button#new:hover,button#new:focus{outline:none;filter:brightness(110%);box-shadow:var(--shadow-sm)}pos-new-thing-form{margin:var(--scale-3)}";const Ie=Te;const ze=class{constructor(e){t(this,e)}openDialog(){this.dialog.showModal()}render(){return n(i,{key:"6142a141ef03ca93a362a6b00ebe8d515c3a677a"},n("button",{key:"72ecf353cd3a7d2d68f9ef28eb1bbe7fdb88b700",id:"new",title:"Add a new thing",onClick:()=>this.openDialog()},n("ion-icon",{key:"bd05d75c42c10de6df519575787fc66eafb22930",name:"add-circle-outline"})),n("pos-dialog",{key:"23cf0118149704dfca16758970e4f4658e87e946",ref:e=>this.dialog=e},n("span",{key:"5af7b7f618cc20684c39134b5ea295400e651cb6",slot:"title"},"Add a new thing"),n("pos-new-thing-form",{key:"895496c2f6ede3c8677d9d918e0b13582090baed",slot:"content",referenceUri:this.referenceUri})))}};ze.style=Ie;const $e=localStorage.getItem("settings");const Re=$e?JSON.parse($e):{offlineCache:false};const Pe=f(Re);De();We();function De(){Pe.on("set",(()=>{const e=JSON.stringify(Pe.state);localStorage.setItem("settings",e)}))}function We(){window.addEventListener("storage",(e=>{if(e.key==="settings"&&e.newValue){const t=JSON.parse(e.newValue);Pe.state.offlineCache=t.offlineCache}}))}const Oe=(e,t)=>t.some((t=>e instanceof t));let Le;let je;function Ue(){return Le||(Le=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Je(){return je||(je=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Ke=new WeakMap;const He=new WeakMap;const Ne=new WeakMap;function Me(e){const t=new Promise(((t,n)=>{const i=()=>{e.removeEventListener("success",r);e.removeEventListener("error",s)};const r=()=>{t(Ge(e.result));i()};const s=()=>{n(e.error);i()};e.addEventListener("success",r);e.addEventListener("error",s)}));Ne.set(t,e);return t}function Be(e){if(Ke.has(e))return;const t=new Promise(((t,n)=>{const i=()=>{e.removeEventListener("complete",r);e.removeEventListener("error",s);e.removeEventListener("abort",s)};const r=()=>{t();i()};const s=()=>{n(e.error||new DOMException("AbortError","AbortError"));i()};e.addEventListener("complete",r);e.addEventListener("error",s);e.addEventListener("abort",s)}));Ke.set(e,t)}let Xe={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return Ke.get(e);if(t==="store"){return n.objectStoreNames[1]?undefined:n.objectStore(n.objectStoreNames[0])}}return Ge(e[t])},set(e,t,n){e[t]=n;return true},has(e,t){if(e instanceof IDBTransaction&&(t==="done"||t==="store")){return true}return t in e}};function Fe(e){Xe=e(Xe)}function Ve(e){if(Je().includes(e)){return function(...t){e.apply(Ye(this),t);return Ge(this.request)}}return function(...t){return Ge(e.apply(Ye(this),t))}}function qe(e){if(typeof e==="function")return Ve(e);if(e instanceof IDBTransaction)Be(e);if(Oe(e,Ue()))return new Proxy(e,Xe);return e}function Ge(e){if(e instanceof IDBRequest)return Me(e);if(He.has(e))return He.get(e);const t=qe(e);if(t!==e){He.set(e,t);Ne.set(t,e)}return t}const Ye=e=>Ne.get(e);function Ze(e,t,{blocked:n,upgrade:i,blocking:r,terminated:s}={}){const o=indexedDB.open(e,t);const a=Ge(o);if(i){o.addEventListener("upgradeneeded",(e=>{i(Ge(o.result),e.oldVersion,e.newVersion,Ge(o.transaction),e)}))}if(n){o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e)))}a.then((e=>{if(s)e.addEventListener("close",(()=>s()));if(r){e.addEventListener("versionchange",(e=>r(e.oldVersion,e.newVersion,e)))}})).catch((()=>{}));return a}const Qe=["get","getKey","getAll","getAllKeys","count"];const et=["put","add","delete","clear"];const tt=new Map;function nt(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==="string")){return}if(tt.get(t))return tt.get(t);const n=t.replace(/FromIndex$/,"");const i=t!==n;const r=et.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!(r||Qe.includes(n))){return}const s=async function(e,...t){const s=this.transaction(e,r?"readwrite":"readonly");let o=s.store;if(i)o=o.index(t.shift());return(await Promise.all([o[n](...t),r&&s.done]))[0]};tt.set(t,s);return s}Fe((e=>({...e,get:(t,n,i)=>nt(t,n)||e.get(t,n,i),has:(t,n)=>!!nt(t,n)||e.has(t,n)})));const it=["continue","continuePrimaryKey","advance"];const rt={};const st=new WeakMap;const ot=new WeakMap;const at={get(e,t){if(!it.includes(t))return e[t];let n=rt[t];if(!n){n=rt[t]=function(...e){st.set(this,ot.get(this)[t](...e))}}return n}};async function*ct(...e){let t=this;if(!(t instanceof IDBCursor)){t=await t.openCursor(...e)}if(!t)return;t=t;const n=new Proxy(t,at);ot.set(n,t);Ne.set(n,Ye(t));while(t){yield n;t=await(st.get(n)||t.continue());st.delete(n)}}function lt(e,t){return t===Symbol.asyncIterator&&Oe(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Oe(e,[IDBIndex,IDBObjectStore])}Fe((e=>({...e,get(t,n,i){if(lt(t,n))return ct;return e.get(t,n,i)},has(t,n){return lt(t,n)||e.has(t,n)}})));class dt{constructor(){this.dbPromise=Ze("OfflineCacheDB",1,{upgrade(e){if(!e.objectStoreNames.contains("documents")){const t=e.createObjectStore("documents",{keyPath:"url"});t.createIndex("url-revision",["url","revision"])}}})}async clear(){const e=await this.dbPromise;return e.clear("documents")}async get(e){const t=await this.dbPromise;return await t.get("documents",e)}async put(e){const t=await this.dbPromise;const n=await t.getFromIndex("documents","url-revision",[e.url,e.revision]);if(n){return}await t.put("documents",e)}}class ht{isOnline(){return navigator.onLine}}const ut=(e,t)=>new m({session:e,offlineCache:t.offlineCache?new dt:new g,onlineStatus:new ht});class ft extends v{constructor(e){super();this._value=e}get value(){return this.getValue()}_subscribe(e){const t=super._subscribe(e);!t.closed&&e.next(this._value);return t}getValue(){const{hasError:e,thrownError:t,_value:n}=this;if(e){throw t}this._throwIfClosed();return n}next(e){super.next(this._value=e)}}var pt=crypto;const bt=e=>e instanceof CryptoKey;const mt=async(e,t)=>{const n=`SHA-${e.slice(-3)}`;return new Uint8Array(await pt.subtle.digest(n,t))};var gt=mt;const wt=new TextEncoder;const vt=new TextDecoder;function yt(...e){const t=e.reduce(((e,{length:t})=>e+t),0);const n=new Uint8Array(t);let i=0;for(const t of e){n.set(t,i);i+=t.length}return n}const kt=e=>{let t=e;if(typeof t==="string"){t=wt.encode(t)}const n=32768;const i=[];for(let e=0;e<t.length;e+=n){i.push(String.fromCharCode.apply(null,t.subarray(e,e+n)))}return btoa(i.join(""))};const xt=e=>kt(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");const St=e=>{const t=atob(e);const n=new Uint8Array(t.length);for(let e=0;e<t.length;e++){n[e]=t.charCodeAt(e)}return n};const _t=e=>{let t=e;if(t instanceof Uint8Array){t=vt.decode(t)}t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return St(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class Et extends Error{constructor(e,t){super(e,t);this.code="ERR_JOSE_GENERIC";this.name=this.constructor.name;Error.captureStackTrace?.(this,this.constructor)}}Et.code="ERR_JOSE_GENERIC";class At extends Et{constructor(e,t,n="unspecified",i="unspecified"){super(e,{cause:{claim:n,reason:i,payload:t}});this.code="ERR_JWT_CLAIM_VALIDATION_FAILED";this.claim=n;this.reason=i;this.payload=t}}At.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Ct extends Et{constructor(e,t,n="unspecified",i="unspecified"){super(e,{cause:{claim:n,reason:i,payload:t}});this.code="ERR_JWT_EXPIRED";this.claim=n;this.reason=i;this.payload=t}}Ct.code="ERR_JWT_EXPIRED";class Tt extends Et{constructor(){super(...arguments);this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Tt.code="ERR_JOSE_ALG_NOT_ALLOWED";class It extends Et{constructor(){super(...arguments);this.code="ERR_JOSE_NOT_SUPPORTED"}}It.code="ERR_JOSE_NOT_SUPPORTED";class zt extends Et{constructor(e="decryption operation failed",t){super(e,t);this.code="ERR_JWE_DECRYPTION_FAILED"}}zt.code="ERR_JWE_DECRYPTION_FAILED";class $t extends Et{constructor(){super(...arguments);this.code="ERR_JWE_INVALID"}}$t.code="ERR_JWE_INVALID";class Rt extends Et{constructor(){super(...arguments);this.code="ERR_JWS_INVALID"}}Rt.code="ERR_JWS_INVALID";class Pt extends Et{constructor(){super(...arguments);this.code="ERR_JWT_INVALID"}}Pt.code="ERR_JWT_INVALID";class Dt extends Et{constructor(){super(...arguments);this.code="ERR_JWK_INVALID"}}Dt.code="ERR_JWK_INVALID";class Wt extends Et{constructor(){super(...arguments);this.code="ERR_JWKS_INVALID"}}Wt.code="ERR_JWKS_INVALID";class Ot extends Et{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t);this.code="ERR_JWKS_NO_MATCHING_KEY"}}Ot.code="ERR_JWKS_NO_MATCHING_KEY";class Lt extends Et{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t);this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Lt.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class jt extends Et{constructor(e="request timed out",t){super(e,t);this.code="ERR_JWKS_TIMEOUT"}}jt.code="ERR_JWKS_TIMEOUT";class Ut extends Et{constructor(e="signature verification failed",t){super(e,t);this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}Ut.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function Jt(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function Kt(e,t){return e.name===t}function Ht(e){return parseInt(e.name.slice(4),10)}function Nt(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Mt(e,t){if(t.length&&!t.some((t=>e.usages.includes(t)))){let e="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const n=t.pop();e+=`one of ${t.join(", ")}, or ${n}.`}else if(t.length===2){e+=`one of ${t[0]} or ${t[1]}.`}else{e+=`${t[0]}.`}throw new TypeError(e)}}function Bt(e,t,...n){switch(t){case"HS256":case"HS384":case"HS512":{if(!Kt(e.algorithm,"HMAC"))throw Jt("HMAC");const n=parseInt(t.slice(2),10);const i=Ht(e.algorithm.hash);if(i!==n)throw Jt(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!Kt(e.algorithm,"RSASSA-PKCS1-v1_5"))throw Jt("RSASSA-PKCS1-v1_5");const n=parseInt(t.slice(2),10);const i=Ht(e.algorithm.hash);if(i!==n)throw Jt(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!Kt(e.algorithm,"RSA-PSS"))throw Jt("RSA-PSS");const n=parseInt(t.slice(2),10);const i=Ht(e.algorithm.hash);if(i!==n)throw Jt(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448"){throw Jt("Ed25519 or Ed448")}break}case"Ed25519":{if(!Kt(e.algorithm,"Ed25519"))throw Jt("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!Kt(e.algorithm,"ECDSA"))throw Jt("ECDSA");const n=Nt(t);const i=e.algorithm.namedCurve;if(i!==n)throw Jt(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Mt(e,n)}function Xt(e,t,...n){n=n.filter(Boolean);if(n.length>2){const t=n.pop();e+=`one of type ${n.join(", ")}, or ${t}.`}else if(n.length===2){e+=`one of type ${n[0]} or ${n[1]}.`}else{e+=`of type ${n[0]}.`}if(t==null){e+=` Received ${t}`}else if(typeof t==="function"&&t.name){e+=` Received function ${t.name}`}else if(typeof t==="object"&&t!=null){if(t.constructor?.name){e+=` Received an instance of ${t.constructor.name}`}}return e}var Ft=(e,...t)=>Xt("Key must be ",e,...t);function Vt(e,t,...n){return Xt(`Key for the ${e} algorithm must be `,t,...n)}var qt=e=>{if(bt(e)){return true}return e?.[Symbol.toStringTag]==="KeyObject"};const Gt=["CryptoKey"];const Yt=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1){return true}let n;for(const e of t){const t=Object.keys(e);if(!n||n.size===0){n=new Set(t);continue}for(const e of t){if(n.has(e)){return false}n.add(e)}}return true};var Zt=Yt;function Qt(e){return typeof e==="object"&&e!==null}function en(e){if(!Qt(e)||Object.prototype.toString.call(e)!=="[object Object]"){return false}if(Object.getPrototypeOf(e)===null){return true}let t=e;while(Object.getPrototypeOf(t)!==null){t=Object.getPrototypeOf(t)}return Object.getPrototypeOf(e)===t}var tn=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:n}=t.algorithm;if(typeof n!=="number"||n<2048){throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}};function nn(e){return en(e)&&typeof e.kty==="string"}function rn(e){return e.kty!=="oct"&&typeof e.d==="string"}function sn(e){return e.kty!=="oct"&&typeof e.d==="undefined"}function on(e){return nn(e)&&e.kty==="oct"&&typeof e.k==="string"}function an(e){let t;let n;switch(e.kty){case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`};n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`};n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`};n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"};n=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"};n=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"};n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv};n=e.d?["deriveBits"]:[];break;default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(e.alg){case"Ed25519":t={name:"Ed25519"};n=e.d?["sign"]:["verify"];break;case"EdDSA":t={name:e.crv};n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv};n=e.d?["deriveBits"]:[];break;default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new It('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:n}}const cn=async e=>{if(!e.alg){throw new TypeError('"alg" argument is required when "jwk.alg" is not present')}const{algorithm:t,keyUsages:n}=an(e);const i=[t,e.ext??false,e.key_ops??n];const r={...e};delete r.alg;delete r.use;return pt.subtle.importKey("jwk",r,...i)};var ln=cn;const dn=e=>_t(e);let hn;let un;const fn=e=>e?.[Symbol.toStringTag]==="KeyObject";const pn=async(e,t,n,i,r=false)=>{let s=e.get(t);if(s?.[i]){return s[i]}const o=await ln({...n,alg:i});if(r)Object.freeze(t);if(!s){e.set(t,{[i]:o})}else{s[i]=o}return o};const bn=(e,t)=>{if(fn(e)){let n=e.export({format:"jwk"});delete n.d;delete n.dp;delete n.dq;delete n.p;delete n.q;delete n.qi;if(n.k){return dn(n.k)}un||(un=new WeakMap);return pn(un,e,n,t)}if(nn(e)){if(e.k)return _t(e.k);un||(un=new WeakMap);const n=pn(un,e,e,t,true);return n}return e};const mn=(e,t)=>{if(fn(e)){let n=e.export({format:"jwk"});if(n.k){return dn(n.k)}hn||(hn=new WeakMap);return pn(hn,e,n,t)}if(nn(e)){if(e.k)return _t(e.k);hn||(hn=new WeakMap);const n=pn(hn,e,e,t,true);return n}return e};var gn={normalizePublicKey:bn,normalizePrivateKey:mn};async function wn(e,t){if(!en(e)){throw new TypeError("JWK must be an object")}t||(t=e.alg);switch(e.kty){case"oct":if(typeof e.k!=="string"||!e.k){throw new TypeError('missing "k" (Key Value) Parameter value')}return _t(e.k);case"RSA":if("oth"in e&&e.oth!==undefined){throw new It('RSA JWK "oth" (Other Primes Info) Parameter value is not supported')}case"EC":case"OKP":return ln({...e,alg:t});default:throw new It('Unsupported "kty" (Key Type) Parameter value')}}const vn=e=>e?.[Symbol.toStringTag];const yn=(e,t,n)=>{if(t.use!==undefined&&t.use!=="sig"){throw new TypeError("Invalid key for this operation, when present its use must be sig")}if(t.key_ops!==undefined&&t.key_ops.includes?.(n)!==true){throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${n}`)}if(t.alg!==undefined&&t.alg!==e){throw new TypeError(`Invalid key for this operation, when present its alg must be ${e}`)}return true};const kn=(e,t,n,i)=>{if(t instanceof Uint8Array)return;if(i&&nn(t)){if(on(t)&&yn(e,t,n))return;throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!qt(t)){throw new TypeError(Vt(e,t,...Gt,"Uint8Array",i?"JSON Web Key":null))}if(t.type!=="secret"){throw new TypeError(`${vn(t)} instances for symmetric algorithms must be of type "secret"`)}};const xn=(e,t,n,i)=>{if(i&&nn(t)){switch(n){case"sign":if(rn(t)&&yn(e,t,n))return;throw new TypeError(`JSON Web Key for this operation be a private JWK`);case"verify":if(sn(t)&&yn(e,t,n))return;throw new TypeError(`JSON Web Key for this operation be a public JWK`)}}if(!qt(t)){throw new TypeError(Vt(e,t,...Gt,i?"JSON Web Key":null))}if(t.type==="secret"){throw new TypeError(`${vn(t)} instances for asymmetric algorithms must not be of type "secret"`)}if(n==="sign"&&t.type==="public"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm signing must be of type "private"`)}if(n==="decrypt"&&t.type==="public"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.algorithm&&n==="verify"&&t.type==="private"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm verifying must be of type "public"`)}if(t.algorithm&&n==="encrypt"&&t.type==="private"){throw new TypeError(`${vn(t)} instances for asymmetric algorithm encryption must be of type "public"`)}};function Sn(e,t,n,i){const r=t.startsWith("HS")||t==="dir"||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t);if(r){kn(t,n,i,e)}else{xn(t,n,i,e)}}Sn.bind(undefined,false);const _n=Sn.bind(undefined,true);function En(e,t,n,i,r){if(r.crit!==undefined&&i?.crit===undefined){throw new e('"crit" (Critical) Header Parameter MUST be integrity protected')}if(!i||i.crit===undefined){return new Set}if(!Array.isArray(i.crit)||i.crit.length===0||i.crit.some((e=>typeof e!=="string"||e.length===0))){throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present')}let s;if(n!==undefined){s=new Map([...Object.entries(n),...t.entries()])}else{s=t}for(const t of i.crit){if(!s.has(t)){throw new It(`Extension Header Parameter "${t}" is not recognized`)}if(r[t]===undefined){throw new e(`Extension Header Parameter "${t}" is missing`)}if(s.get(t)&&i[t]===undefined){throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}}return new Set(i.crit)}const An=(e,t)=>{if(t!==undefined&&(!Array.isArray(t)||t.some((e=>typeof e!=="string")))){throw new TypeError(`"${e}" option must be an array of strings`)}if(!t){return undefined}return new Set(t)};var Cn=An;const Tn=async e=>{if(e instanceof Uint8Array){return{kty:"oct",k:xt(e)}}if(!bt(e)){throw new TypeError(Ft(e,...Gt,"Uint8Array"))}if(!e.extractable){throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK")}const{ext:t,key_ops:n,alg:i,use:r,...s}=await pt.subtle.exportKey("jwk",e);return s};var In=Tn;async function zn(e){return In(e)}function $n(e,t){const n=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:t.name};default:throw new It(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function Rn(e,t,n){if(n==="sign"){t=await gn.normalizePrivateKey(t,e)}if(n==="verify"){t=await gn.normalizePublicKey(t,e)}if(bt(t)){Bt(t,e,n);return t}if(t instanceof Uint8Array){if(!e.startsWith("HS")){throw new TypeError(Ft(t,...Gt))}return pt.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},false,[n])}throw new TypeError(Ft(t,...Gt,"Uint8Array","JSON Web Key"))}const Pn=async(e,t,n,i)=>{const r=await Rn(e,t,"verify");tn(e,r);const s=$n(e,r.algorithm);try{return await pt.subtle.verify(s,r,n,i)}catch{return false}};var Dn=Pn;async function Wn(e,t,n){if(!en(e)){throw new Rt("Flattened JWS must be an object")}if(e.protected===undefined&&e.header===undefined){throw new Rt('Flattened JWS must have either of the "protected" or "header" members')}if(e.protected!==undefined&&typeof e.protected!=="string"){throw new Rt("JWS Protected Header incorrect type")}if(e.payload===undefined){throw new Rt("JWS Payload missing")}if(typeof e.signature!=="string"){throw new Rt("JWS Signature missing or incorrect type")}if(e.header!==undefined&&!en(e.header)){throw new Rt("JWS Unprotected Header incorrect type")}let i={};if(e.protected){try{const t=_t(e.protected);i=JSON.parse(vt.decode(t))}catch{throw new Rt("JWS Protected Header is invalid")}}if(!Zt(i,e.header)){throw new Rt("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const r={...i,...e.header};const s=En(Rt,new Map([["b64",true]]),n?.crit,i,r);let o=true;if(s.has("b64")){o=i.b64;if(typeof o!=="boolean"){throw new Rt('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:a}=r;if(typeof a!=="string"||!a){throw new Rt('JWS "alg" (Algorithm) Header Parameter missing or invalid')}const c=n&&Cn("algorithms",n.algorithms);if(c&&!c.has(a)){throw new Tt('"alg" (Algorithm) Header Parameter value not allowed')}if(o){if(typeof e.payload!=="string"){throw new Rt("JWS Payload must be a string")}}else if(typeof e.payload!=="string"&&!(e.payload instanceof Uint8Array)){throw new Rt("JWS Payload must be a string or an Uint8Array instance")}let l=false;if(typeof t==="function"){t=await t(i,e);l=true;_n(a,t,"verify");if(nn(t)){t=await wn(t,a)}}else{_n(a,t,"verify")}const d=yt(wt.encode(e.protected??""),wt.encode("."),typeof e.payload==="string"?wt.encode(e.payload):e.payload);let h;try{h=_t(e.signature)}catch{throw new Rt("Failed to base64url decode the signature")}const u=await Dn(a,t,h,d);if(!u){throw new Ut}let f;if(o){try{f=_t(e.payload)}catch{throw new Rt("Failed to base64url decode the payload")}}else if(typeof e.payload==="string"){f=wt.encode(e.payload)}else{f=e.payload}const p={payload:f};if(e.protected!==undefined){p.protectedHeader=i}if(e.header!==undefined){p.unprotectedHeader=e.header}if(l){return{...p,key:t}}return p}async function On(e,t,n){if(e instanceof Uint8Array){e=vt.decode(e)}if(typeof e!=="string"){throw new Rt("Compact JWS must be a string or Uint8Array")}const{0:i,1:r,2:s,length:o}=e.split(".");if(o!==3){throw new Rt("Invalid Compact JWS")}const a=await Wn({payload:r,protected:i,signature:s},t,n);const c={payload:a.payload,protectedHeader:a.protectedHeader};if(typeof t==="function"){return{...c,key:a.key}}return c}var Ln=e=>Math.floor(e.getTime()/1e3);const jn=60;const Un=jn*60;const Jn=Un*24;const Kn=Jn*7;const Hn=Jn*365.25;const Nn=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;var Mn=e=>{const t=Nn.exec(e);if(!t||t[4]&&t[1]){throw new TypeError("Invalid time period format")}const n=parseFloat(t[2]);const i=t[3].toLowerCase();let r;switch(i){case"sec":case"secs":case"second":case"seconds":case"s":r=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":r=Math.round(n*jn);break;case"hour":case"hours":case"hr":case"hrs":case"h":r=Math.round(n*Un);break;case"day":case"days":case"d":r=Math.round(n*Jn);break;case"week":case"weeks":case"w":r=Math.round(n*Kn);break;default:r=Math.round(n*Hn);break}if(t[1]==="-"||t[4]==="ago"){return-r}return r};const Bn=e=>e.toLowerCase().replace(/^application\//,"");const Xn=(e,t)=>{if(typeof e==="string"){return t.includes(e)}if(Array.isArray(e)){return t.some(Set.prototype.has.bind(new Set(e)))}return false};var Fn=(e,t,n={})=>{let i;try{i=JSON.parse(vt.decode(t))}catch{}if(!en(i)){throw new Pt("JWT Claims Set must be a top-level JSON object")}const{typ:r}=n;if(r&&(typeof e.typ!=="string"||Bn(e.typ)!==Bn(r))){throw new At('unexpected "typ" JWT header value',i,"typ","check_failed")}const{requiredClaims:s=[],issuer:o,subject:a,audience:c,maxTokenAge:l}=n;const d=[...s];if(l!==undefined)d.push("iat");if(c!==undefined)d.push("aud");if(a!==undefined)d.push("sub");if(o!==undefined)d.push("iss");for(const e of new Set(d.reverse())){if(!(e in i)){throw new At(`missing required "${e}" claim`,i,e,"missing")}}if(o&&!(Array.isArray(o)?o:[o]).includes(i.iss)){throw new At('unexpected "iss" claim value',i,"iss","check_failed")}if(a&&i.sub!==a){throw new At('unexpected "sub" claim value',i,"sub","check_failed")}if(c&&!Xn(i.aud,typeof c==="string"?[c]:c)){throw new At('unexpected "aud" claim value',i,"aud","check_failed")}let h;switch(typeof n.clockTolerance){case"string":h=Mn(n.clockTolerance);break;case"number":h=n.clockTolerance;break;case"undefined":h=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:u}=n;const f=Ln(u||new Date);if((i.iat!==undefined||l)&&typeof i.iat!=="number"){throw new At('"iat" claim must be a number',i,"iat","invalid")}if(i.nbf!==undefined){if(typeof i.nbf!=="number"){throw new At('"nbf" claim must be a number',i,"nbf","invalid")}if(i.nbf>f+h){throw new At('"nbf" claim timestamp check failed',i,"nbf","check_failed")}}if(i.exp!==undefined){if(typeof i.exp!=="number"){throw new At('"exp" claim must be a number',i,"exp","invalid")}if(i.exp<=f-h){throw new Ct('"exp" claim timestamp check failed',i,"exp","check_failed")}}if(l){const e=f-i.iat;const t=typeof l==="number"?l:Mn(l);if(e-h>t){throw new Ct('"iat" claim timestamp check failed (too far in the past)',i,"iat","check_failed")}if(e<0-h){throw new At('"iat" claim timestamp check failed (it should be in the past)',i,"iat","check_failed")}}return i};async function Vn(e,t,n){const i=await On(e,t,n);if(i.protectedHeader.crit?.includes("b64")&&i.protectedHeader.b64===false){throw new Pt("JWTs MUST NOT use unencoded payload")}const r=Fn(i.protectedHeader,i.payload,n);const s={payload:r,protectedHeader:i.protectedHeader};if(typeof t==="function"){return{...s,key:i.key}}return s}const qn=async(e,t,n)=>{const i=await Rn(e,t,"sign");tn(e,i);const r=await pt.subtle.sign($n(e,i.algorithm),i,n);return new Uint8Array(r)};var Gn=qn;class Yn{constructor(e){if(!(e instanceof Uint8Array)){throw new TypeError("payload must be an instance of Uint8Array")}this._payload=e}setProtectedHeader(e){if(this._protectedHeader){throw new TypeError("setProtectedHeader can only be called once")}this._protectedHeader=e;return this}setUnprotectedHeader(e){if(this._unprotectedHeader){throw new TypeError("setUnprotectedHeader can only be called once")}this._unprotectedHeader=e;return this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader){throw new Rt("either setProtectedHeader or setUnprotectedHeader must be called before #sign()")}if(!Zt(this._protectedHeader,this._unprotectedHeader)){throw new Rt("JWS Protected and JWS Unprotected Header Parameter names must be disjoint")}const n={...this._protectedHeader,...this._unprotectedHeader};const i=En(Rt,new Map([["b64",true]]),t?.crit,this._protectedHeader,n);let r=true;if(i.has("b64")){r=this._protectedHeader.b64;if(typeof r!=="boolean"){throw new Rt('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg:s}=n;if(typeof s!=="string"||!s){throw new Rt('JWS "alg" (Algorithm) Header Parameter missing or invalid')}_n(s,e,"sign");let o=this._payload;if(r){o=wt.encode(xt(o))}let a;if(this._protectedHeader){a=wt.encode(xt(JSON.stringify(this._protectedHeader)))}else{a=wt.encode("")}const c=yt(a,wt.encode("."),o);const l=await Gn(s,e,c);const d={signature:xt(l),payload:""};if(r){d.payload=vt.decode(o)}if(this._unprotectedHeader){d.header=this._unprotectedHeader}if(this._protectedHeader){d.protected=vt.decode(a)}return d}}class Zn{constructor(e){this._flattened=new Yn(e)}setProtectedHeader(e){this._flattened.setProtectedHeader(e);return this}async sign(e,t){const n=await this._flattened.sign(e,t);if(n.payload===undefined){throw new TypeError("use the flattened module for creating JWS with b64: false")}return`${n.protected}.${n.payload}.${n.signature}`}}function Qn(e,t){if(!Number.isFinite(t)){throw new TypeError(`Invalid ${e} input`)}return t}class ei{constructor(e={}){if(!en(e)){throw new TypeError("JWT Claims Set MUST be an object")}this._payload=e}setIssuer(e){this._payload={...this._payload,iss:e};return this}setSubject(e){this._payload={...this._payload,sub:e};return this}setAudience(e){this._payload={...this._payload,aud:e};return this}setJti(e){this._payload={...this._payload,jti:e};return this}setNotBefore(e){if(typeof e==="number"){this._payload={...this._payload,nbf:Qn("setNotBefore",e)}}else if(e instanceof Date){this._payload={...this._payload,nbf:Qn("setNotBefore",Ln(e))}}else{this._payload={...this._payload,nbf:Ln(new Date)+Mn(e)}}return this}setExpirationTime(e){if(typeof e==="number"){this._payload={...this._payload,exp:Qn("setExpirationTime",e)}}else if(e instanceof Date){this._payload={...this._payload,exp:Qn("setExpirationTime",Ln(e))}}else{this._payload={...this._payload,exp:Ln(new Date)+Mn(e)}}return this}setIssuedAt(e){if(typeof e==="undefined"){this._payload={...this._payload,iat:Ln(new Date)}}else if(e instanceof Date){this._payload={...this._payload,iat:Qn("setIssuedAt",Ln(e))}}else if(typeof e==="string"){this._payload={...this._payload,iat:Qn("setIssuedAt",Ln(new Date)+Mn(e))}}else{this._payload={...this._payload,iat:Qn("setIssuedAt",e)}}return this}}class ti extends ei{setProtectedHeader(e){this._protectedHeader=e;return this}async sign(e,t){const n=new Zn(wt.encode(JSON.stringify(this._payload)));n.setProtectedHeader(this._protectedHeader);if(Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===false){throw new Pt("JWTs MUST NOT use unencoded payload")}return n.sign(e,t)}}const ni=(e,t)=>{if(typeof e!=="string"||!e){throw new Dt(`${t} missing or invalid`)}};async function ii(e,t){if(!en(e)){throw new TypeError("JWK must be an object")}t??(t="sha256");if(t!=="sha256"&&t!=="sha384"&&t!=="sha512"){throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"')}let n;switch(e.kty){case"EC":ni(e.crv,'"crv" (Curve) Parameter');ni(e.x,'"x" (X Coordinate) Parameter');ni(e.y,'"y" (Y Coordinate) Parameter');n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":ni(e.crv,'"crv" (Subtype of Key Pair) Parameter');ni(e.x,'"x" (Public Key) Parameter');n={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":ni(e.e,'"e" (Exponent) Parameter');ni(e.n,'"n" (Modulus) Parameter');n={e:e.e,kty:e.kty,n:e.n};break;case"oct":ni(e.k,'"k" (Key Value) Parameter');n={k:e.k,kty:e.kty};break;default:throw new It('"kty" (Key Type) Parameter missing or unsupported')}const i=wt.encode(JSON.stringify(n));return xt(await gt(t,i))}function ri(e){switch(typeof e==="string"&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new It('Unsupported "alg" value for a JSON Web Key Set')}}function si(e){return e&&typeof e==="object"&&Array.isArray(e.keys)&&e.keys.every(oi)}function oi(e){return en(e)}function ai(e){if(typeof structuredClone==="function"){return structuredClone(e)}return JSON.parse(JSON.stringify(e))}class ci{constructor(e){this._cached=new WeakMap;if(!si(e)){throw new Wt("JSON Web Key Set malformed")}this._jwks=ai(e)}async getKey(e,t){const{alg:n,kid:i}={...e,...t?.header};const r=ri(n);const s=this._jwks.keys.filter((e=>{let t=r===e.kty;if(t&&typeof i==="string"){t=i===e.kid}if(t&&typeof e.alg==="string"){t=n===e.alg}if(t&&typeof e.use==="string"){t=e.use==="sig"}if(t&&Array.isArray(e.key_ops)){t=e.key_ops.includes("verify")}if(t){switch(n){case"ES256":t=e.crv==="P-256";break;case"ES256K":t=e.crv==="secp256k1";break;case"ES384":t=e.crv==="P-384";break;case"ES512":t=e.crv==="P-521";break;case"Ed25519":t=e.crv==="Ed25519";break;case"EdDSA":t=e.crv==="Ed25519"||e.crv==="Ed448";break}}return t}));const{0:o,length:a}=s;if(a===0){throw new Ot}if(a!==1){const e=new Lt;const{_cached:t}=this;e[Symbol.asyncIterator]=async function*(){for(const e of s){try{yield await li(t,e,n)}catch{}}};throw e}return li(this._cached,o,n)}}async function li(e,t,n){const i=e.get(t)||e.set(t,{}).get(t);if(i[n]===undefined){const e=await wn({...t,ext:true},n);if(e instanceof Uint8Array||e.type!=="public"){throw new Wt("JSON Web Key Set members must be public keys")}i[n]=e}return i[n]}function di(e){const t=new ci(e);const n=async(e,n)=>t.getKey(e,n);Object.defineProperties(n,{jwks:{value:()=>ai(t._jwks),enumerable:true,configurable:false,writable:false}});return n}const hi=async(e,t,n)=>{let i;let r;let s=false;if(typeof AbortController==="function"){i=new AbortController;r=setTimeout((()=>{s=true;i.abort()}),t)}const o=await fetch(e.href,{signal:i?i.signal:undefined,redirect:"manual",headers:n.headers}).catch((e=>{if(s)throw new jt;throw e}));if(r!==undefined)clearTimeout(r);if(o.status!==200){throw new Et("Expected 200 OK from the JSON Web Key Set HTTP response")}try{return await o.json()}catch{throw new Et("Failed to parse the JSON Web Key Set HTTP response as JSON")}};var ui=hi;function fi(){return typeof WebSocketPair!=="undefined"||typeof navigator!=="undefined"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime!=="undefined"&&EdgeRuntime==="vercel"}let pi;if(typeof navigator==="undefined"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 ")){const e="jose";const t="v5.10.0";pi=`${e}/${t}`}const bi=Symbol();function mi(e,t){if(typeof e!=="object"||e===null){return false}if(!("uat"in e)||typeof e.uat!=="number"||Date.now()-e.uat>=t){return false}if(!("jwks"in e)||!en(e.jwks)||!Array.isArray(e.jwks.keys)||!Array.prototype.every.call(e.jwks.keys,en)){return false}return true}class gi{constructor(e,t){if(!(e instanceof URL)){throw new TypeError("url must be an instance of URL")}this._url=new URL(e.href);this._options={agent:t?.agent,headers:t?.headers};this._timeoutDuration=typeof t?.timeoutDuration==="number"?t?.timeoutDuration:5e3;this._cooldownDuration=typeof t?.cooldownDuration==="number"?t?.cooldownDuration:3e4;this._cacheMaxAge=typeof t?.cacheMaxAge==="number"?t?.cacheMaxAge:6e5;if(t?.[bi]!==undefined){this._cache=t?.[bi];if(mi(t?.[bi],this._cacheMaxAge)){this._jwksTimestamp=this._cache.uat;this._local=di(this._cache.jwks)}}}coolingDown(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cooldownDuration:false}fresh(){return typeof this._jwksTimestamp==="number"?Date.now()<this._jwksTimestamp+this._cacheMaxAge:false}async getKey(e,t){if(!this._local||!this.fresh()){await this.reload()}try{return await this._local(e,t)}catch(n){if(n instanceof Ot){if(this.coolingDown()===false){await this.reload();return this._local(e,t)}}throw n}}async reload(){if(this._pendingFetch&&fi()){this._pendingFetch=undefined}const e=new Headers(this._options.headers);if(pi&&!e.has("User-Agent")){e.set("User-Agent",pi);this._options.headers=Object.fromEntries(e.entries())}this._pendingFetch||(this._pendingFetch=ui(this._url,this._timeoutDuration,this._options).then((e=>{this._local=di(e);if(this._cache){this._cache.uat=Date.now();this._cache.jwks=e}this._jwksTimestamp=Date.now();this._pendingFetch=undefined})).catch((e=>{this._pendingFetch=undefined;throw e})));await this._pendingFetch}}function wi(e,t){const n=new gi(e,t);const i=async(e,t)=>n.getKey(e,t);Object.defineProperties(i,{coolingDown:{get:()=>n.coolingDown(),enumerable:true,configurable:false},fresh:{get:()=>n.fresh(),enumerable:true,configurable:false},reload:{value:()=>n.reload(),enumerable:true,configurable:false,writable:false},reloading:{get:()=>!!n._pendingFetch,enumerable:true,configurable:false},jwks:{value:()=>n._local?.jwks(),enumerable:true,configurable:false,writable:false}});return i}const vi=_t;function yi(e){if(typeof e!=="string")throw new Pt("JWTs must use Compact JWS serialization, JWT must be a string");const{1:t,length:n}=e.split(".");if(n===5)throw new Pt("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new Pt("Invalid JWT");if(!t)throw new Pt("JWTs must contain a payload");let i;try{i=vi(t)}catch{throw new Pt("Failed to base64url decode the payload")}let r;try{r=JSON.parse(vt.decode(i))}catch{throw new Pt("Failed to parse the decoded payload as JSON")}if(!en(r))throw new Pt("Invalid JWT Claims Set");return r}function ki(e){const t=e?.modulusLength??2048;if(typeof t!=="number"||t<2048){throw new It("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used")}return t}async function xi(e,t){let n;let i;switch(e){case"PS256":case"PS384":case"PS512":n={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:ki(t)};i=["sign","verify"];break;case"RS256":case"RS384":case"RS512":n={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:ki(t)};i=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":n={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:ki(t)};i=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":n={name:"ECDSA",namedCurve:"P-256"};i=["sign","verify"];break;case"ES384":n={name:"ECDSA",namedCurve:"P-384"};i=["sign","verify"];break;case"ES512":n={name:"ECDSA",namedCurve:"P-521"};i=["sign","verify"];break;case"Ed25519":n={name:"Ed25519"};i=["sign","verify"];break;case"EdDSA":{i=["sign","verify"];const e=t?.crv??"Ed25519";switch(e){case"Ed25519":case"Ed448":n={name:e};break;default:throw new It("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{i=["deriveKey","deriveBits"];const e=t?.crv??"P-256";switch(e){case"P-256":case"P-384":case"P-521":{n={name:"ECDH",namedCurve:e};break}case"X25519":case"X448":n={name:e};break;default:throw new It("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new It('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return pt.subtle.generateKey(n,t?.extractable??false,i)}async function Si(e,t){return xi(e,t)}const _i=async(e,t)=>{const n={...t,grant_types:["authorization_code","refresh_token"],id_token_signed_response_alg:"ES256",token_endpoint_auth_method:"none",application_type:"web",subject_type:"public"};return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})};class Ei{dbName;storeName;dbVersion;db=null;constructor(e="soidc",t="session",n=1){this.dbName=e;this.storeName=t;this.dbVersion=n}async init(){return new Promise(((e,t)=>{const n=indexedDB.open(this.dbName,this.dbVersion);n.onerror=e=>{t(new Error(`Database error: ${e.target.error}`))};n.onsuccess=t=>{this.db=t.target.result;e(this)};n.onupgradeneeded=e=>{const t=e.target.result;if(!t.objectStoreNames.contains(this.storeName)){t.createObjectStore(this.storeName)}}}))}async setItem(e,t){if(!this.db){await this.init()}return new Promise(((n,i)=>{const r=this.db.transaction(this.storeName,"readwrite");r.oncomplete=()=>{n()};r.onerror=t=>{i(new Error(`Transaction error for setItem(${e},...): ${t.target.error}`))};r.onabort=t=>{i(new Error(`Transaction aborted for setItem(${e},...): ${t.target.error}`))};const s=r.objectStore(this.storeName);s.put(t,e)}))}async getItem(e){if(!this.db){await this.init()}return new Promise(((t,n)=>{const i=this.db.transaction(this.storeName,"readonly");i.onerror=t=>{n(new Error(`Transaction error for getItem(${e}): ${t.target.error}`))};i.onabort=t=>{n(new Error(`Transaction aborted for getItem(${e}): ${t.target.error}`))};const r=i.objectStore(this.storeName);const s=r.get(e);s.onsuccess=()=>{t(s.result||null)}}))}async deleteItem(e){if(!this.db){await this.init()}return new Promise(((t,n)=>{const i=this.db.transaction(this.storeName,"readwrite");i.oncomplete=()=>{t()};i.onerror=t=>{n(new Error(`Transaction error for deleteItem(${e}): ${t.target.error}`))};i.onabort=t=>{n(new Error(`Transaction aborted for deleteItem(${e}): ${t.target.error}`))};const r=i.objectStore(this.storeName);r.delete(e)}))}async clear(){if(!this.db){await this.init()}return new Promise(((e,t)=>{const n=this.db.transaction(this.storeName,"readwrite");n.oncomplete=()=>{e()};n.onerror=e=>{t(new Error(`Transaction error for clear(): ${e.target.error}`))};n.onabort=e=>{t(new Error(`Transaction aborted for clear(): ${e.target.error}`))};const i=n.objectStore(this.storeName);i.clear()}))}close(){if(this.db){this.db.close();this.db=null}}}const Ai=async(e,t,n)=>{const i=new URL(t);const r=i.origin+i.pathname+i.search;const s=new URL(e).origin;const o=await fetch(`${s}/.well-known/openid-configuration`).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));const a=o["issuer"];const c=e=>e.endsWith("/")?e.slice(0,-1):e;if(c(e)!==c(a)){throw new Error("RFC 9207 - iss != idp - "+a+" != "+e)}sessionStorage.setItem("idp",a);sessionStorage.setItem("token_endpoint",o["token_endpoint"]);sessionStorage.setItem("jwks_uri",o["jwks_uri"]);let l=n?.client_id;if(!l){const e=o["registration_endpoint"];const t=await _i(e,n??{redirect_uris:[r]}).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));l=t["client_id"];sessionStorage.setItem("client_id",l)}const{pkce_code_verifier:d,pkce_code_challenge:h}=await Ci();sessionStorage.setItem("pkce_code_verifier",d);const u=window.crypto.randomUUID();sessionStorage.setItem("csrf_token",u);const f=o["authorization_endpoint"]+`?response_type=code`+`&redirect_uri=${encodeURIComponent(r)}`+`&scope=openid offline_access webid`+`&client_id=${encodeURIComponent(l)}`+`&code_challenge_method=S256`+`&code_challenge=${h}`+`&state=${u}`+`&prompt=consent`;window.location.href=f};const Ci=async()=>{const e=window.crypto.randomUUID()+"-"+window.crypto.randomUUID();const t=new Uint8Array(await window.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e)));const n=btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return{pkce_code_verifier:e,pkce_code_challenge:n}};const Ti=async e=>{const t=new URL(window.location.href);const n=t.searchParams.get("code");if(n===null){return{clientDetails:e}}const i=sessionStorage.getItem("idp");if(i===null||t.searchParams.get("iss")!=i){throw new Error("RFC 9207 - iss != idp - "+t.searchParams.get("iss")+" != "+i)}if(t.searchParams.get("state")!=sessionStorage.getItem("csrf_token")){throw new Error("RFC 6749 - state != csrf_token - "+t.searchParams.get("state")+" != "+sessionStorage.getItem("csrf_token"))}t.searchParams.delete("iss");t.searchParams.delete("state");t.searchParams.delete("code");window.history.pushState({},document.title,t.toString());const r=sessionStorage.getItem("pkce_code_verifier");if(r===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: pkce_code_verifier")}const s=e?.client_id||sessionStorage.getItem("client_id");if(!s){throw new Error("Access Token Request preparation - Could not find in sessionStorage: client_id (dynamic registration)")}const o=sessionStorage.getItem("token_endpoint");if(o===null){throw new Error("Access Token Request preparation - Could not find in sessionStorage: token_endpoint")}const a=await Si("ES256");const c=await Ii(n,r,t.toString(),s,o,a).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));const l=c["access_token"];const d=sessionStorage.getItem("jwks_uri");if(d===null){throw new Error("Access Token validation preparation - Could not find in sessionStorage: jwks_uri")}const h=wi(new URL(d));const{payload:u}=await Vn(l,h,{issuer:i,audience:"solid"});const f=await ii(await zn(a.publicKey));if(u["cnf"]["jkt"]!=f){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+u["cnf"]["jkt"]+" != "+f)}if(u["client_id"]!=s){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+u["client_id"]+" != "+s)}const p={...c,dpop_key_pair:a};const b={idp:i,jwks_uri:d,token_endpoint:o};if(!e)e={redirect_uris:[window.location.href]};e.client_id=s;const m=await(new Ei).init();await Promise.all([m.setItem("idp",i),m.setItem("jwks_uri",d),m.setItem("token_endpoint",o),m.setItem("client_id",s),m.setItem("dpop_keypair",a),m.setItem("refresh_token",c["refresh_token"])]);m.close();sessionStorage.removeItem("csrf_token");sessionStorage.removeItem("pkce_code_verifier");sessionStorage.removeItem("idp");sessionStorage.removeItem("jwks_uri");sessionStorage.removeItem("token_endpoint");sessionStorage.removeItem("client_id");return{clientDetails:e,idpDetails:b,tokenDetails:p}};const Ii=async(e,t,n,i,r,s)=>{const o=await zn(s.publicKey);o.alg="ES256";const a=await new ti({htu:r,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:o}).sign(s.privateKey);return fetch(r,{method:"POST",headers:{dpop:a,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:n,client_id:i})})};const zi=async()=>{const e=await(new Ei).init();const t=await e.getItem("client_id");const n=await e.getItem("token_endpoint");const i=await e.getItem("dpop_keypair");const r=await e.getItem("refresh_token");if(t===null||n===null||i===null||r===null){throw new Error("Could not refresh tokens: details missing from database.")}const s=await $i(r,t,n,i).then((e=>{if(!e.ok){throw new Error(`HTTP error! Status: ${e.status}`)}return e.json()}));const o=s["access_token"];const a=await e.getItem("idp");if(a===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: idp")}const c=await e.getItem("jwks_uri");if(c===null){throw new Error("Access Token validation preparation - Could not find in sessionDatabase: jwks_uri")}const l=wi(new URL(c));const{payload:d}=await Vn(o,l,{issuer:a,audience:"solid"});const h=await ii(await zn(i.publicKey));if(d["cnf"]["jkt"]!=h){throw new Error("Access Token validation failed on `jkt`: jkt != DPoP thumbprint - "+d["cnf"]["jkt"]+" != "+h)}if(d["client_id"]!=t){throw new Error("Access Token validation failed on `client_id`: JWT payload != client_id - "+d["client_id"]+" != "+t)}await e.setItem("refresh_token",s["refresh_token"]);e.close();return{...s,dpop_key_pair:i}};const $i=async(e,t,n,i)=>{const r=await zn(i.publicKey);r.alg="ES256";const s=await new ti({htu:n,htm:"POST"}).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:r}).sign(i.privateKey);return fetch(n,{method:"POST",headers:{dpop:s,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:t})})};class Ri{sessionInformation;isActive_=false;webId_=undefined;currentAth_=undefined;tokenRefreshTimeout;sessionDeactivateTimeout;onSessionExpirationWarning;constructor(e,t){this.sessionInformation={clientDetails:e};this.onSessionExpirationWarning=t?.onSessionExpirationWarning}async login(e,t){await Ai(e,t,this.sessionInformation.clientDetails)}async logout(){if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=undefined;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=undefined;this.sessionInformation.idpDetails=undefined;this.sessionInformation.tokenDetails=undefined;this.isActive_=false;this.webId_=undefined;if(this.sessionInformation.clientDetails?.client_id)try{new URL(this.sessionInformation.clientDetails.client_id)}catch(e){this.sessionInformation.clientDetails.client_id=undefined}const e=await(new Ei).init();await e.clear();e.close()}async handleRedirectFromLogin(){const e=await Ti(this.sessionInformation.clientDetails);if(!e.tokenDetails){return}this.sessionInformation=e;await this.setSessionDetails()}async restore(){await zi().then((e=>{this.sessionInformation.tokenDetails=e;return this.setSessionDetails()})).catch((e=>{}))}async createSignedDPoPToken(e){if(!this.sessionInformation.tokenDetails||!this.currentAth_){throw new Error("Session not established.")}e.ath=this.currentAth_;const t=await zn(this.sessionInformation.tokenDetails.dpop_key_pair.publicKey);return new ti(e).setIssuedAt().setJti(window.crypto.randomUUID()).setProtectedHeader({alg:"ES256",typ:"dpop+jwt",jwk:t}).sign(this.sessionInformation.tokenDetails.dpop_key_pair.privateKey)}async authFetch(e,t,n){let i;let r;let s;if(e instanceof Request){i=new URL(e.url);r=t?.method||e?.method||"GET";s=new Headers(e.headers)}else{t=t||{};i=new URL(e.toString());r=t.method||"GET";s=t.headers?new Headers(t.headers):new Headers}if(this.sessionInformation.tokenDetails){n=n??{htu:`${i.origin}${i.pathname}`,htm:r.toUpperCase()};const e=await this.createSignedDPoPToken(n);s.set("dpop",e);s.set("authorization",`DPoP ${this.sessionInformation.tokenDetails.access_token}`)}if(e instanceof Request){return fetch(new Request(e,{...t,headers:s}))}return fetch(i,{...t,headers:s})}get isActive(){return this.isActive_}get webId(){return this.webId_}async setSessionDetails(){if(!this.sessionInformation.tokenDetails?.access_token){this.logout()}this.currentAth_=await this.computeAth(this.sessionInformation.tokenDetails.access_token);this.webId_=yi(this.sessionInformation.tokenDetails.access_token)["webid"];this.isActive_=this.webId!==undefined;this.setSessionDeactivateTimeout();this.setTokenRefreshTimeout()}setSessionDeactivateTimeout(){const e=5;const t=(this.sessionInformation.tokenDetails.expires_in-e)*1e3;if(this.sessionDeactivateTimeout)clearTimeout(this.sessionDeactivateTimeout);this.sessionDeactivateTimeout=setTimeout((()=>this.logout()),t)}setTokenRefreshTimeout(){const e=95;const t=(this.sessionInformation.tokenDetails.expires_in-e)*1e3;if(this.tokenRefreshTimeout)clearTimeout(this.tokenRefreshTimeout);this.tokenRefreshTimeout=setTimeout((async()=>{const e=await zi().catch((e=>{if(this.onSessionExpirationWarning)this.onSessionExpirationWarning();return undefined}));if(!e){return}this.sessionInformation.tokenDetails=e;this.setSessionDetails()}),t)}async computeAth(e){const t=new TextEncoder;const n=t.encode(e);const i=await crypto.subtle.digest("SHA-256",n);const r=Array.from(new Uint8Array(i));const s=btoa(String.fromCharCode(...r));const o=s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return o}}class Pi{get authenticatedFetch(){return this._authenticatedFetch}constructor(){this.onSessionRestoreCallback=()=>{};this.sessionInfo$=new ft({isLoggedIn:false,webId:undefined});this.session=new Ri;this._authenticatedFetch=this.session.authFetch.bind(this.session)}async handleIncomingRedirect(e=false){await this.session.handleRedirectFromLogin();if(e){await this.session.restore();if(this.session.isActive){this.onSessionRestoreCallback(window.location.href)}}this.sessionInfo$.next({isLoggedIn:this.session.isActive,webId:this.session.webId})}async login(e){return this.session.login(e,window.location.href)}async logout(){await this.session.logout();this.sessionInfo$.next({isLoggedIn:false,webId:undefined})}observeSession(){return this.sessionInfo$}onSessionRestore(e){this.onSessionRestoreCallback=e}}const Di=class{constructor(e){t(this,e);this.sessionRestoredEmitter=s(this,"pod-os:session-restored",7);this.podOsLoadedEmitter=s(this,"pod-os:loaded",7);this.restorePreviousSession=false;this.disconnected$=new v;this.loading=true}async componentWillLoad(){const e=new Pi;this.unsubscribeSettings=Pe.on("set",(()=>{this.os=ut(e,Pe.state)}));this.os=ut(e,Pe.state);e.onSessionRestore((e=>{this.sessionRestoredEmitter.emit({url:e})}));try{await e.handleIncomingRedirect(this.restorePreviousSession)}catch(e){console.error(e)}this.os.observeSession().pipe(y(this.disconnected$)).subscribe((async e=>{p.state.webId=e.webId;if(e.isLoggedIn){const t=await this.os.fetchProfile(e.webId);p.state.profile=t}p.state.isLoggedIn=e.isLoggedIn;this.loading=false}));this.podOsLoadedEmitter.emit({os:this.os,authenticatedFetch:e.authenticatedFetch})}disconnectedCallback(){this.unsubscribeSettings();this.disconnected$.next();this.disconnected$.unsubscribe()}async initializeOs(e){e.stopPropagation();e.detail(this.os)}async loadModule(e){e.stopPropagation();if(e.detail.module==="contacts"){const t=await this.os.loadContactsModule();e.detail.receiver(t)}else{throw Error(`Unknown module "${e.detail.module}"`)}}render(){return this.loading?n("ion-progress-bar",{type:"indeterminate"}):n("slot",null)}};const Wi="pos-router {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\npos-navigation {\n max-width: var(--width-lg);\n margin: 0;\n min-width: var(--size-32);\n flex-shrink: 1; /* Ensure navigation can shrink */\n}\n\npos-add-new-thing,\npos-login {\n flex: 0 1 auto;\n flex-shrink: 0; /* Ensure those items don't shrink */\n}\n\nheader,\nfooter {\n display: flex;\n gap: var(--size-1);\n height: auto;\n justify-content: center;\n align-items: center;\n padding: var(--size-1);\n}\n\nfooter svg {\n width: var(--size-5);\n height: var(--size-5);\n}\n\nfooter {\n font-size: var(--scale-fluid-000);\n\n .settings {\n padding: 0 var(--size-1);\n text-decoration: none;\n background-color: var(--pos-background-color);\n border: 1px solid var(--pos-secondary-border-color);\n color: var(--pos-secondary-border-color);\n border-radius: var(--radius-xs);\n\n &:hover {\n background-color: var(--pos-secondary-border-color);\n color: var(--pos-background-color);\n }\n }\n}\n\nheader {\n flex-wrap: nowrap;\n padding: var(--size-1) var(--size-8);\n}\n\nmain {\n flex: 1;\n max-height: 100vh;\n overflow: auto;\n}\n\n@media (max-width: 640px) {\n header {\n padding: var(--size-1);\n justify-content: space-between;\n }\n footer {\n display: none;\n }\n}\n";const Oi=Wi;const Li=class{constructor(e){t(this,e);this.restorePreviousSession=false;this.mode="standalone";this.uri=""}render(){return n(i,{key:"08b186d2f354d6c07df02707eb4ada81aef7dec3"},n("pos-app",{key:"54c372343e916ab5d77584381b3965c925ae0cd0",restorePreviousSession:this.restorePreviousSession},n("pos-error-toast",{key:"ab63e18121ca16670f81da141219a782dde0694b"},n("pos-router",{key:"69b6f3bf8ce3720c6c39cdb4be69e640e27ccc5b",mode:this.mode,"onPod-os:route-changed":e=>this.uri=e.detail},n("header",{key:"5cd3412caf13b6d99da517ae7e6f5877234e65d7"},n("pos-add-new-thing",{key:"9b83b3cf03b7038303975386176df539b35ff547",referenceUri:this.uri}),n("pos-navigation",{key:"26bfed9b1c8dd1be018babc6ef40ae42808a5c42",uri:this.uri==="pod-os:dashboard"?"":this.uri}),n("pos-login",{key:"e29f18dcde866d8ac1e317fcd7b71ef584e69034"},n("pos-user-menu",{key:"be796f0914649eb4e8525a9d8acdfd535626303c",webId:p.state.webId,slot:"if-logged-in"}))),n("main",{key:"f99dfb2d43e949528bc767b94801c99bf04a7eea"},this.mainContent()),n("footer",{key:"64744d1246356fa00da9c6b561785e2b794a7907"},n(ji,{key:"a648f7f88e12c79348bda33152f2759d2b93e738"}),n("span",{key:"f22e2f9904ba517fc2e579a05018704b5ade6302"},"PodOS Browser"))))))}mainContent(){if(this.uri===""){return null}if(this.uri.startsWith("pod-os:")){return n("pos-internal-router",{uri:this.uri})}return n("pos-resource",{key:this.uri,uri:this.uri},n("pos-type-router",null))}};const ji=()=>n("svg",{viewBox:"0 0 400 400",xmlns:"http://www.w3.org/2000/svg"},n("path",{d:"M50 350 L50 100 L200 50 L350 100 L350 350 Z",style:{fill:"#008BF8",stroke:"#008BF8","stroke-width":"70"},"stroke-linejoin":"round"}),n("path",{d:"M100 300 L100 150 L200 120 L300 150 L300 300 L130 300 L130 370 L100 370Z",style:{fill:"white",stroke:"white","stroke-width":"45"},"stroke-linejoin":"round"}),n("path",{d:"M150 250 L150 200 L200 180 L250 200 L250 250 Z",style:{fill:"#DC0073",stroke:"#DC0073","stroke-width":"20"},"stroke-linejoin":"round"}));Li.style=Oi;const Ui=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const Ji=Ui;const Ki=class{constructor(e){t(this,e)}render(){return n(i,{key:"18dc165b7be1c796136804a2ba7643b2a6fffc73"},n("pos-getting-started",{key:"e3f7a22641e4c24168a36f96463515cd1a89ca5e"}),n("pos-example-resources",{key:"1044dd873049118e165ff6d38449c85695f63a50"}))}};Ki.style=Ji;const Hi=":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";const Ni=Hi;const Mi=class{constructor(e){t(this,e)}render(){return n("pos-setting-offline-cache",{key:"f065206f6291089773a19045243f04b6ce35eeb9"})}};Mi.style=Ni;const Bi=class{constructor(e){t(this,e);this.subscribeResource=s(this,"pod-os:resource",7);this.receiveResource=e=>{this.resource=e}}componentWillLoad(){x(this)}render(){return this.resource?this.resource.description():null}};const Xi="dialog{background-color:var(--pos-background-color);color:var(--pos-normal-text-color);border:none;border-radius:var(--radius-md);box-shadow:var(--shadow-md);max-width:var(--width-xs);animation:slideIn 0.2s ease-out}dialog::backdrop{background:rgba(0, 0, 0, 0.5);backdrop-filter:var(--blur-sm);animation:fadeIn 0.2s ease-out}@media (prefers-color-scheme: dark){dialog::backdrop{background:rgb(100, 100, 100, 0.5)}}dialog header>:first-child{flex-grow:1;font-weight:var(--weight-light);font-size:var(--scale-2);font-family:var(--font-sans);margin:0}dialog header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;gap:var(--scale-0);border-bottom-style:inset;padding:0 0 var(--scale-0) 0}dialog>:last-child{display:block;margin-top:var(--scale-3)}button#close{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;background:none;font-size:var(--scale-3);color:var(--color-grey-500)}button#close:hover{color:var(--pos-secondary-border-color)}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-20px) scale(0.95)}to{opacity:1;transform:translateY(0) scale(1)}}";const Fi=Xi;const Vi=class{constructor(e){t(this,e)}async showModal(){this.dialog.showModal()}async close(){this.dialog.close()}render(){return n(i,{key:"42ee67fc5636f2c5d1a44613d0c39b0e98112a79"},n("dialog",{key:"e05b18b7ed8cae7ac010ecdcb3f58367f742fe77",ref:e=>this.dialog=e},n("header",{key:"4e3b2a6c0fc069c425d8bc9dcedee4e7f5c95c01"},n("slot",{key:"7617853cebf80d86469956af01761970fa68aa7b",name:"title"}),n("button",{key:"c6858cb4b90ab1cef16adb77a148aa2bec405cf7",tabindex:-1,id:"close",title:"Close",onClick:()=>this.close()},n("ion-icon",{key:"58737ce0aac7b5047557b81c15daed713490a5ce",name:"close-outline"}))),n("slot",{key:"868baba59e97e691735759af250cffed8766c913",name:"content"})))}};Vi.style=Fi;var qi=e=>{var t;const{activeElement:n}=document;if(n&&e.contains(n)){(t=document.activeElement)==null?void 0:t.blur()}};var Gi=S`
|
|
2
2
|
:host {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
color: var(--sl-color-neutral-600);
|
|
@@ -731,4 +731,4 @@ import{d as e,r as t,h as n,H as i,e as r,f as s,i as o,j as a}from"./p-99602d8c
|
|
|
731
731
|
margin: 0 var(--spacing);
|
|
732
732
|
}
|
|
733
733
|
`;var ho=class extends I{constructor(){super(...arguments);this.vertical=false}connectedCallback(){super.connectedCallback();this.setAttribute("role","separator")}handleVerticalChange(){this.setAttribute("aria-orientation",this.vertical?"vertical":"horizontal")}};ho.styles=[A,lo];T([$({type:Boolean,reflect:true})],ho.prototype,"vertical",2);T([R("vertical")],ho.prototype,"handleVerticalChange",1);ho.define("sl-divider");const uo="button {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n margin: 0;\n border: none;\n background: none;\n cursor: pointer;\n border-radius: 50%;\n pos-picture {\n --width: 40px;\n --height: 40px;\n --border-radius: 50%;\n }\n sl-avatar {\n --size: 40px;\n }\n}\n\nsl-dropdown {\n display: block;\n}\n";const fo=uo;const po=class{constructor(e){t(this,e);this.logout=s(this,"pod-os:logout",7);this.link=s(this,"pod-os:link",7)}onSelect(e){const{value:t}=e.detail.item;if(t==="logout"){this.logout.emit()}else if(t==="profile"){this.link.emit(this.webId)}else if(t==="dashboard"){this.link.emit("pod-os:dashboard")}else if(t==="settings"){this.link.emit("pod-os:settings")}}render(){if(!this.webId)return null;return n("pos-resource",{uri:this.webId},n("sl-dropdown",null,n("button",{slot:"trigger","aria-label":"User menu"},n("pos-picture",null,n("sl-avatar",null))),n("sl-menu",null,n("sl-menu-item",{value:"dashboard"},"Dashboard"),n("sl-menu-item",{value:"profile"},n("pos-label",null)),n("sl-menu-item",{value:"settings"},"Settings"),n("sl-divider",null),n("sl-menu-item",{value:"logout"},"Logout"))))}};po.style=fo;export{be as ion_icon,xe as ion_progress_bar,Ce as ion_skeleton_text,ze as pos_add_new_thing,Di as pos_app,Li as pos_app_browser,Ki as pos_app_dashboard,Mi as pos_app_settings,Bi as pos_description,Vi as pos_dialog,dr as pos_error_toast,fr as pos_example_resources,mr as pos_getting_started,vr as pos_image,yr as pos_internal_router,kr as pos_label,_r as pos_login,Cr as pos_login_form,os as pos_make_findable,hs as pos_navigation,ps as pos_navigation_bar,gs as pos_new_thing_form,ys as pos_picture,Ss as pos_resource,As as pos_rich_link,Ks as pos_router,Ms as pos_select_term,Fs as pos_setting_offline_cache,Gs as pos_tool_select,oo as pos_type_router,po as pos_user_menu};
|
|
734
|
-
//# sourceMappingURL=p-
|
|
734
|
+
//# sourceMappingURL=p-b9400211.entry.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,f as e,h as s,H as i}from"./p-99602d8c.js";import{a as n}from"./p-
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,f as e,h as s,H as i}from"./p-99602d8c.js";import{a as n}from"./p-a962c4b4.js";import{s as o}from"./p-f6671856.js";const r="ul{list-style:none;padding:0;margin:0}li{padding:0;margin:0}";const l=r;const a=class{constructor(s){t(this,s);this.subscribeResource=e(this,"pod-os:resource",7);this.contents=[];this.loading=true;this.createNewItem=null;this.receiveResource=t=>{this.container=t.assume(n);this.loading=false;this.contents=this.container.contains().sort(((t,e)=>t.name.localeCompare(e.name)))}}onCreateNewFile(){this.createNewItem="file"}onCreateNewFolder(){this.createNewItem="folder"}componentWillLoad(){o(this)}handleKeyDown(t){if(t.key==="Escape"){this.createNewItem=null}}render(){if(this.loading)return null;const t=this.contents.map((t=>s("li",{key:t.uri},s("pos-resource",{lazy:true,uri:t.uri},s("pos-container-item",null,t.name)))));if(this.createNewItem!==null){t.unshift(s("li",{key:"new-item"},s("pos-create-new-container-item",{type:this.createNewItem,container:this.container})))}return s(i,null,s("pos-container-toolbar",{"onPod-os:create-new-file":()=>this.onCreateNewFile(),"onPod-os:create-new-folder":()=>this.onCreateNewFolder()}),t.length>0?s("ul",{"aria-label":"Container contents"},t):s("p",null,"The container is empty"))}};a.style=l;export{a as pos_container_contents};
|
|
2
|
+
//# sourceMappingURL=p-d6be765b.entry.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __toESM, r as require_short_unique_id, b as Namespace, n as namedNode2, s as st, c as lit, i as isNamedNode } from './index-
|
|
1
|
+
import { _ as __toESM, r as require_short_unique_id, b as Namespace, n as namedNode2, s as st, c as lit, i as isNamedNode } from './index-e9875204.js';
|
|
2
2
|
|
|
3
3
|
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/namespaces.js
|
|
4
4
|
var vcard = Namespace("http://www.w3.org/2006/vcard/ns#");
|
|
@@ -682,4 +682,4 @@ var dist_default = ContactsModuleRdfLib;
|
|
|
682
682
|
|
|
683
683
|
export { dist_default as default };
|
|
684
684
|
|
|
685
|
-
//# sourceMappingURL=dist-O5YU2L4C-
|
|
685
|
+
//# sourceMappingURL=dist-O5YU2L4C-a27a7092.js.map
|