@authduo/authduo
Version:
Free User-sovereign Authentication for the World
66 lines (64 loc) • 79.7 kB
JavaScript
class t{#t=!1;lock(t){this.#t=!0;const e=t();return this.#t=!1,e}get locked(){return this.#t}}const e=()=>new Map,s=()=>new Set;function n(t){return{guarantee:(e,s)=>function(t,e,s){if(t.has(e))return t.get(e);{const n=s();return t.set(e,n),n}}(t,e,s)}}class r{#e=new WeakMap;grab_keymap(t){const s=n(this.#e).guarantee(t,e);return{keymap:s,grab_symbolmap:t=>n(s).guarantee(t,e)}}clear(){this.#e=new WeakMap}}class i{#s=new Map;stop(t){const e=this.#s.get(t);e&&(this.#s.delete(t),e())}add(t,e){this.#s.set(t,e)}}class o{#n=[];record(t){const s=e();this.#n.push(s);const n=t();return this.#n.pop(),{payload:n,recording:s}}record_that_key_was_accessed(t,e){const r=this.#n.at(-1);if(r){n(r).guarantee(t,s).add(e)}}}class a extends Error{name=this.constructor.name}class l extends a{constructor(t){super(`forbidden circularity, rejected assignment to "${t}"`)}}class c extends a{constructor(t){super(`forbidden assignment to readonly property "${t}"`)}}function u(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new c(e)}})}function d(t,e){let s,n,r=[];function i(){s=[],n&&clearTimeout(n),n=void 0,r=[]}return i(),(...o)=>{s=o,n&&clearTimeout(n);const a=new Promise(((t,e)=>{r.push({resolve:t,reject:e})}));return n=setTimeout((()=>{Promise.resolve().then((()=>e(...s))).then((t=>{for(const{resolve:e}of r)e(t);i()})).catch((t=>{for(const{reject:e}of r)e(t);i()}))}),t),a}}class h{#r=new Map;#i=Promise.resolve();#o=d(0,(()=>{const t=[...this.#r.values()];this.#r.clear();for(const e of t)e()}));get wait(){return this.#i}add(t,e){this.#r.set(t,e),this.#i=this.#o()}}function p(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function f(t,e,s,n){const r=[];for(const[i,o]of e){const{grab_symbolmap:e}=s.grab_keymap(i);for(const s of o){const i=e(s);i.set(t,n),r.push((()=>i.delete(t)))}}return()=>r.forEach((t=>t()))}var m;!function(t){t.proxy=(t,e)=>new Proxy(e,{get:(s,n)=>{const r=e[n],i=t.getAttribute(n);switch(r){case String:return i??void 0;case Number:return null!==i?Number(i):void 0;case Boolean:return null!==i;default:throw new Error(`invalid attribute type for "${n}"`)}},set:(s,n,r)=>{switch(e[n]){case String:return t.setAttribute(n,r),!0;case Number:return t.setAttribute(n,r.toString()),!0;case Boolean:return r?t.setAttribute(n,""):t.removeAttribute(n),!0;default:throw new Error(`invalid attribute type for "${n}"`)}}}),t.on_change=function(t,e){const s=new MutationObserver(e);return s.observe(t,{attributes:!0}),()=>s.disconnect()}}(m||(m={}));class g{#a;constructor(t){this.#a=t}get state(){return this.#a.getter(this.#a.parent.state)}transmute(t){this.#a.parent.transmute((e=>{const s=this.#a.getter(e),n=t(s);return this.#a.setter(e,n)}))}slice({getter:t,setter:e}){return new g({parent:this,getter:t,setter:e})}}const b=t=>"object"==typeof t&&null!==t;const y={clone:function t(e,s=new Set){if(s.has(e))throw new Error("cannot clone circular reference");let n;return"function"==typeof e||null!==e&&"object"==typeof e?(s.add(e),n=Array.isArray(e)?e.map((e=>t(e,new Set(s)))):e.constructor===Object?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,t(n,new Set(s))]))):e instanceof Map?new Map(Array.from(e,(([e,n])=>[e,t(n,new Set(s))]))):e instanceof Set?new Set(Array.from(e,(e=>t(e,new Set(s))))):e instanceof Date?new Date(e.getTime()):e,s.delete(e)):n=e,n},equal:(t,e)=>function t(e,s,n){if(!b(e)||!b(s))return e===s;if(n.includes(e))throw new Error("forbidden circularity detected in deep equal comparison");const r=[...n,e];if(e instanceof Map&&s instanceof Map){if(e.size!==s.size)return!1;for(const[n,i]of e)if(!s.has(n)||!t(i,s.get(n),r))return!1}else if(e instanceof Set&&s instanceof Set){if(e.size!==s.size)return!1;for(const n of e)if(!Array.from(s).some((e=>t(n,e,r))))return!1}else{const n=Object.keys(e),i=Object.keys(s);if(n.length!==i.length)return!1;for(const o of n){if(!i.includes(o))return!1;if(!t(e[o],s[o],r))return!1}}return!0}(t,e,[]),freeze:function(t){return function t(e,s){if(!b(e)||s.includes(e))return e;const n=[...s,e];if(e instanceof Map)for(const s of e.entries())for(const e of s)t(e,n);else if(e instanceof Set)for(const s of e)t(s,n);else if(Array.isArray(e))for(const s of e)t(s,n);else for(const s of Object.values(e))t(s,n);return Object.freeze(e)}(t,[])}};class w{#l;#c;#u;#d=!1;#h(){return y.freeze(structuredClone(this.#l))}constructor(t,e=()=>{}){this.#l=structuredClone(t),this.#c=this.#h(),this.#u=e}get state(){return this.#c}transmute(t){if(this.#d)throw new Error("circular error");this.#d=!0,this.#l=t(structuredClone(this.#l)),this.#c=this.#h(),this.#u(),this.#d=!1}slice({getter:t,setter:e}){return new g({parent:this,getter:t,setter:e})}}const v=Error;var $;function x(t){return{map:e=>_(t,e),filter:e=>k(t,e)}}!function(t){function e(t){return"ready"===t.status?t.payload:void 0}function s(t,e){switch(t.status){case"loading":return e.loading();case"error":return e.error(t.reason);case"ready":return e.ready(t.payload);default:throw console.error("op",t),new v("invalid op status")}}t.loading=()=>({status:"loading"}),t.error=t=>({status:"error",reason:t}),t.ready=t=>({status:"ready",payload:t}),t.is=Object.freeze({loading:t=>"loading"===t.status,error:t=>"error"===t.status,ready:t=>"ready"===t.status}),t.payload=e,t.reason=function(t){return"error"===t.status?t.reason:void 0},t.select=s,t.load=async function(e,s){e(t.loading());try{const n=await s();return e(t.ready(n)),n}catch(s){const n=s instanceof v?s.message:"string"==typeof s?s:"error";throw e(t.error(n)),s}},t.morph=function(e,n){return s(e,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(n(e))})},t.all=function(...s){const n=s.find(t.is.error);return n||(s.every(t.is.ready)?t.ready(s.map(e)):t.loading())}}($||($={})),x.pipe=Object.freeze({map:t=>e=>_(e,t),filter:t=>e=>k(e,t)});const _=(t,e)=>Object.fromEntries(Object.entries(t).map((([t,s])=>[t,e(s,t)]))),k=(t,e)=>Object.fromEntries(Object.entries(t).filter((([t,s])=>e(s,t)))),A=Symbol();class C extends Error{name=this.constructor.name}class S{static unwrap=t=>t instanceof S?t.value:t;#p;#f=!1;#i;#m=new Set;[A]=!1;constructor(t){this.#p=t,this.#i=Promise.resolve(t)}subscribe(t){return this.on(t)}on(t){return this.#m.add(t),()=>{this.#m.delete(t)}}once(t){const e=s=>{t(s),this.#m.delete(e)};return this.#m.add(e),()=>{this.#m.delete(e)}}clear(){return this.#m.clear()}#g=d(0,(()=>{const t=this.#p;this.#f=!0;for(const e of this.#m)e(t);return this.#f=!1,t}));async publish(){this.#i=this.#g(),await this.#i}get wait(){return this.#i}get value(){return this[A]=!0,this.#p}set value(t){if(this.#f)throw new C("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p=t,this.publish()}setValueNoPublish(t){this.#p=t}}class E extends S{#b=0;constructor(t){super(t)}async load(t){const e=++this.#b;return $.load((t=>{this.#b===e&&(this.value=t)}),t)}setLoading(){this.value=$.loading()}setError(t){this.value=$.error(t)}setReady(t){this.value=$.ready(t)}isLoading(){return $.is.loading(this.value)}isError(){return $.is.error(this.value)}isReady(){return $.is.ready(this.value)}get payload(){return $.payload(this.value)}select(t){return $.select(this.value,t)}}class O{#y=!0;#w;#v;#$=new Set;#x=new Set;constructor({all_signals:t,waiters:e}){this.#w=t,this.#v=e}#o=d(0,(t=>{if(this.#y)if("lean"in t)t.actor();else{const{payload:e,recording:s}=this.observe(t.collector);this.add_listeners(t,s),t.responder&&t.responder(e)}}));#_(){for(const t of this.#w)t[A]=!1}get#k(){return[...this.#w].filter((t=>t[A]&&!this.#$.has(t)))}observe(t){this.#_();return{payload:t(),recording:this.#k}}add_listeners(t,e){for(const s of e)this.#$.add(s),this.#x.add(s.subscribe((()=>this.#v.add(this.#o(t)))))}shutdown(){this.#y=!1,this.#x.forEach((t=>t()))}}const D=new class{static readonly=u;static collectivize=p;#A=new r;#C=new o;#S=new t;#E=new i;#O=new h;#D=function(t,e,s,n,r){function i([s,r]){if("lean"in r)r.actor();else{const{payload:i,recording:o}=e.record(r.collector);n.add(s,f(s,o,t,r)),r.responder&&r.responder(i)}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,n,o)=>{if(s.locked)throw new l(n);e[n]=o;const a=[...t.grab_keymap(e).grab_symbolmap(n)];for(const t of a){const[e]=t;r.add(e,(()=>s.lock((()=>i(t)))))}return!0}}}(this.#A,this.#C,this.#S,this.#E,this.#O);get wait(){return this.#O.wait}state(t){return new Proxy(t,this.#D)}reaction(t,e){const s=Symbol(),{recording:n}=this.#C.record((()=>this.#S.lock(t)));return this.#E.add(s,f(s,n,this.#A,{collector:t,responder:e})),()=>this.#E.stop(s)}lean(t){const e=Symbol();return{stop:()=>this.#E.stop(e),collect:s=>{const{payload:n,recording:r}=this.#C.record((()=>this.#S.lock(s)));return this.#E.add(e,f(e,r,this.#A,{lean:!0,actor:t})),n}}}clear(){this.#A.clear()}},M=new class{#M=new Set;#v=new Set;signal(t){const e=new S(t);return this.#M.add(e),e}computed(t){const e=this.signal(t());return this.reaction((()=>{e.value=t()})),e}async computedAsync(t,e){const s=await e(t()),n=this.signal(s);return this.reaction(t,(async t=>{n.value=await e(t)})),n}op(t=$.loading()){const e=new E(t);return this.#M.add(e),e}load(t){const e=this.op($.loading());return e.load(t),e}many(t){return x(t).map((t=>this.signal(t)))}reaction(t,e){const s=new O({waiters:this.#v,all_signals:this.#M}),n={collector:t,responder:e},{recording:r}=s.observe(n.collector);return s.add_listeners(n,r),()=>s.shutdown()}lean(t){const e=new O({waiters:this.#v,all_signals:this.#M}),s={lean:!0,actor:t};return{stop:()=>e.shutdown(),collect:t=>{const{payload:n,recording:r}=e.observe(t);return e.add_listeners(s,r),n}}}get wait(){return Promise.all([...this.#M].map((t=>t.wait))).then((()=>Promise.all([...this.#v]))).then((()=>{this.#v.clear()}))}},P=new class{#M;#P=new Set;#m=new Set;#U=new Map;#j=Promise.resolve();constructor(t){this.#M=t}get wait(){return this.#j}#T=d(0,(()=>{for(const t of this.#P)t();for(const t of this.#m)t()}));dispatch(){this.#j=this.#T()}computed(t){const e=this.#M.signal(t());return this.#P.add((()=>{e.value=t()})),e}track(t,e){let s=!0;const n=()=>{const n=t(),r=this.#U.get(t);!s&&y.equal(n,r)||(s=!1,this.#U.set(t,n),e(n))};n(),this.#m.add(n);return()=>this.#m.delete(n)}stateTree(t){return new w(t,(()=>this.dispatch()))}}(M);D.state.bind(D);const U=M.signal.bind(M);M.computed.bind(M);const j=M.op.bind(M),T=new class{flat;signals;#i=Promise.resolve();constructor(t,e){this.flat=t,this.signals=e}get wait(){return Promise.all([this.flat.wait,this.signals.wait]).then((()=>this.#i))}reaction(t,e){const s=e?()=>e(r()):()=>r(),n=this.lean(s),r=()=>n.collect(t);return r(),n.stop}lean(t){const e=this.flat.lean(t),s=this.signals.lean(t);return{stop(){e.stop(),s.stop()},collect:t=>e.collect((()=>s.collect(t)))}}}(D,M);class R{static with(t){return new this(t)}#R;constructor(t){this.#R=t}to(t){return new R(t(this.#R))}done(){return this.#R}}var N;function z(t){return[t].flat().filter((t=>!!t))}!function(t){function e(...t){return function(e){return class extends e{static get styles(){return H(e.styles,t)}}}}function s(t=T){return function(e){return class extends e{#N=null;render(){return this.#N?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#N=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#N&&(this.#N.stop(),this.#N=null)}}}}t.css=e,t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return H(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#N=null;render(){return this.#N?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#N=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#N&&(this.#N.stop(),this.#N=null)}}}},t.flat=function(t){return function(e){return class extends e{#N=null;render(){return this.#N?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#N=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#N&&(this.#N.stop(),this.#N=null)}}}},t.reactive=s,t.reactor=s,t.setup=function(...t){return function(n){return R.with(n).to(e(...t)).to(s()).done()}}}(N||(N={}));const q=t=>void 0!==t;function H(t,e){return[...z(t),...z(e)].flat().filter(q)}var B;function L(t,e={soft:!1}){for(const[s,n]of Object.entries(t)){const t=s.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase();e.soft&&void 0!==customElements.get(t)||customElements.define(t,n)}}
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/!function(t){t.css=t=>e=>x(e).map((e=>N.css(t)(e))),t.flat=t=>e=>x(e).map((e=>N.flat(t)(e))),t.signals=t=>e=>x(e).map((e=>N.signals(t)(e))),t.reactive=(t=T)=>e=>x(e).map((e=>N.reactive(t)(e))),t.reactor=t.reactive,t.context=e=>s=>R.with(s).to(t.css(e.theme)).to(t.reactive()).done(),t.setup=(...t)=>e=>x(e).map((e=>N.setup(...t)(e)))}(B||(B={}));const I=globalThis,K=I.ShadowRoot&&(void 0===I.ShadyCSS||I.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,V=Symbol(),F=new WeakMap;let J=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==V)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(K&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=F.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&F.set(e,t))}return t}toString(){return this.cssText}};const W=(t,...e)=>{const s=1===t.length?t[0]:e.reduce(((e,s,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1]),t[0]);return new J(s,t,V)},Y=(t,e)=>{if(K)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),n=I.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=s.cssText,t.appendChild(e)}},X=K?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new J("string"==typeof t?t:t+"",void 0,V))(e)})(t):t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,{is:Z,defineProperty:G,getOwnPropertyDescriptor:Q,getOwnPropertyNames:tt,getOwnPropertySymbols:et,getPrototypeOf:st}=Object,nt=globalThis,rt=nt.trustedTypes,it=rt?rt.emptyScript:"",ot=nt.reactiveElementPolyfillSupport,at=(t,e)=>t,lt={toAttribute(t,e){switch(e){case Boolean:t=t?it:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},ct=(t,e)=>!Z(t,e),ut={attribute:!0,type:String,converter:lt,reflect:!1,hasChanged:ct};Symbol.metadata??=Symbol("metadata"),nt.litPropertyMetadata??=new WeakMap;let dt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=ut){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),n=this.getPropertyDescriptor(t,s,e);void 0!==n&&G(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){const{get:n,set:r}=Q(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const i=n?.call(this);r.call(this,e),this.requestUpdate(t,i,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ut}static _$Ei(){if(this.hasOwnProperty(at("elementProperties")))return;const t=st(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(at("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(at("properties"))){const t=this.properties,e=[...tt(t),...et(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(X(t))}else void 0!==t&&e.push(X(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Y(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){const s=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,s);if(void 0!==n&&!0===s.reflect){const r=(void 0!==s.converter?.toAttribute?s.converter:lt).toAttribute(e,s.type);this._$Em=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){const s=this.constructor,n=s._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=s.getPropertyOptions(n),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:lt;this._$Em=n,this[n]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??ct)(this[t],e))return;this.P(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),!0===s.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t)!0!==s.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],s)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}};dt.elementStyles=[],dt.shadowRootOptions={mode:"open"},dt[at("elementProperties")]=new Map,dt[at("finalized")]=new Map,ot?.({ReactiveElement:dt}),(nt.reactiveElementVersions??=[]).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const ht=globalThis,pt=ht.trustedTypes,ft=pt?pt.createPolicy("lit-html",{createHTML:t=>t}):void 0,mt="$lit$",gt=`lit$${Math.random().toFixed(9).slice(2)}$`,bt="?"+gt,yt=`<${bt}>`,wt=document,vt=()=>wt.createComment(""),$t=t=>null===t||"object"!=typeof t&&"function"!=typeof t,xt=Array.isArray,_t="[ \t\n\f\r]",kt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,At=/-->/g,Ct=/>/g,St=RegExp(`>|${_t}(?:([^\\s"'>=/]+)(${_t}*=${_t}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Et=/'/g,Ot=/"/g,Dt=/^(?:script|style|textarea|title)$/i,Mt=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),Pt=Mt(1),Ut=Mt(2),jt=Symbol.for("lit-noChange"),Tt=Symbol.for("lit-nothing"),Rt=new WeakMap,Nt=wt.createTreeWalker(wt,129);function zt(t,e){if(!xt(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==ft?ft.createHTML(e):e}const qt=(t,e)=>{const s=t.length-1,n=[];let r,i=2===e?"<svg>":3===e?"<math>":"",o=kt;for(let e=0;e<s;e++){const s=t[e];let a,l,c=-1,u=0;for(;u<s.length&&(o.lastIndex=u,l=o.exec(s),null!==l);)u=o.lastIndex,o===kt?"!--"===l[1]?o=At:void 0!==l[1]?o=Ct:void 0!==l[2]?(Dt.test(l[2])&&(r=RegExp("</"+l[2],"g")),o=St):void 0!==l[3]&&(o=St):o===St?">"===l[0]?(o=r??kt,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?St:'"'===l[3]?Ot:Et):o===Ot||o===Et?o=St:o===At||o===Ct?o=kt:(o=St,r=void 0);const d=o===St&&t[e+1].startsWith("/>")?" ":"";i+=o===kt?s+yt:c>=0?(n.push(a),s.slice(0,c)+mt+s.slice(c)+gt+d):s+gt+(-2===c?e:d)}return[zt(t,i+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),n]};class Ht{constructor({strings:t,_$litType$:e},s){let n;this.parts=[];let r=0,i=0;const o=t.length-1,a=this.parts,[l,c]=qt(t,e);if(this.el=Ht.createElement(l,s),Nt.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=Nt.nextNode())&&a.length<o;){if(1===n.nodeType){if(n.hasAttributes())for(const t of n.getAttributeNames())if(t.endsWith(mt)){const e=c[i++],s=n.getAttribute(t).split(gt),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:s,ctor:"."===o[1]?Vt:"?"===o[1]?Ft:"@"===o[1]?Jt:Kt}),n.removeAttribute(t)}else t.startsWith(gt)&&(a.push({type:6,index:r}),n.removeAttribute(t));if(Dt.test(n.tagName)){const t=n.textContent.split(gt),e=t.length-1;if(e>0){n.textContent=pt?pt.emptyScript:"";for(let s=0;s<e;s++)n.append(t[s],vt()),Nt.nextNode(),a.push({type:2,index:++r});n.append(t[e],vt())}}}else if(8===n.nodeType)if(n.data===bt)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=n.data.indexOf(gt,t+1));)a.push({type:7,index:r}),t+=gt.length-1}r++}}static createElement(t,e){const s=wt.createElement("template");return s.innerHTML=t,s}}function Bt(t,e,s=t,n){if(e===jt)return e;let r=void 0!==n?s._$Co?.[n]:s._$Cl;const i=$t(e)?void 0:e._$litDirective$;return r?.constructor!==i&&(r?._$AO?.(!1),void 0===i?r=void 0:(r=new i(t),r._$AT(t,s,n)),void 0!==n?(s._$Co??=[])[n]=r:s._$Cl=r),void 0!==r&&(e=Bt(t,r._$AS(t,e.values),r,n)),e}class Lt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,n=(t?.creationScope??wt).importNode(e,!0);Nt.currentNode=n;let r=Nt.nextNode(),i=0,o=0,a=s[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new It(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new Wt(r,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(r=Nt.nextNode(),i++)}return Nt.currentNode=wt,n}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class It{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=Tt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Bt(this,t,e),$t(t)?t===Tt||null==t||""===t?(this._$AH!==Tt&&this._$AR(),this._$AH=Tt):t!==this._$AH&&t!==jt&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>xt(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Tt&&$t(this._$AH)?this._$AA.nextSibling.data=t:this.T(wt.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,n="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Ht.createElement(zt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Lt(n,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=Rt.get(t.strings);return void 0===e&&Rt.set(t.strings,e=new Ht(t)),e}k(t){xt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,n=0;for(const r of t)n===e.length?e.push(s=new It(this.O(vt()),this.O(vt()),this,this.options)):s=e[n],s._$AI(r),n++;n<e.length&&(this._$AR(s&&s._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class Kt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,r){this.type=1,this._$AH=Tt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=Tt}_$AI(t,e=this,s,n){const r=this.strings;let i=!1;if(void 0===r)t=Bt(this,t,e,0),i=!$t(t)||t!==this._$AH&&t!==jt,i&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Bt(this,n[s+o],e,o),a===jt&&(a=this._$AH[o]),i||=!$t(a)||a!==this._$AH[o],a===Tt?t=Tt:t!==Tt&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}i&&!n&&this.j(t)}j(t){t===Tt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Vt extends Kt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Tt?void 0:t}}class Ft extends Kt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Tt)}}class Jt extends Kt{constructor(t,e,s,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=Bt(this,t,e,0)??Tt)===jt)return;const s=this._$AH,n=t===Tt&&s!==Tt||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==Tt&&(s===Tt||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class Wt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Bt(this,t)}}const Yt=ht.litHtmlPolyfillSupport;Yt?.(Ht,It),(ht.litHtmlVersions??=[]).push("3.2.1");const Xt=(t,e,s)=>{const n=s?.renderBefore??e;let r=n._$litPart$;if(void 0===r){const t=s?.renderBefore??null;n._$litPart$=r=new It(e.insertBefore(vt(),t),t,void 0,s??{})}return r._$AI(t),r
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/};let Zt=class extends dt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Xt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return jt}};Zt._$litElement$=!0,Zt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:Zt});const Gt=globalThis.litElementPolyfillSupport;Gt?.({LitElement:Zt}),(globalThis.litElementVersions??=[]).push("4.1.1");class Qt extends(function(t){return class extends t{#z=(new Set).add((()=>this.setup()));#q=new Set;register_setup(t){this.#z.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#z)this.#q.add(t())}disconnectedCallback(){for(const t of this.#q)t();this.#q.clear()}}}(HTMLElement)){}function te(){let t,e;const s=new Promise(((s,n)=>{t=s,e=n}));return{promise:s,resolve:t,reject:e,entangle:function(n){return n.then(t).catch(e),s}}}function ee(t,e){Y(t,function(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(X(t))}else void 0!==t&&e.push(X(t));return e}(e))}class se extends Qt{static get styles(){}#H;#B=te();#i=this.#B.promise;init(){}constructor(){super(),this.#H=this.attachShadow({mode:"open"});const t=this.constructor;ee(this.#H,t.styles),this.init()}get root(){return this.#H}get updateComplete(){return this.#i.then((()=>!0))}render(){}#L=d(0,(()=>{const t=this.#H,e=this.render();e&&Xt(e,t,{host:this})}));async requestUpdate(){const t=this.#L();return this.#B&&(t.then(this.#B.resolve),this.#B=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class ne extends Qt{#B=te();#i=this.#B.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#i.then((()=>!0))}render(){}#L=d(0,(()=>{const t=this.render();Xt(t,this,{host:this})}));async requestUpdate(){const t=this.#L();return this.#B&&(t.then(this.#B.resolve),this.#B=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}const re=Symbol();class ie{#p=0;pull(){return this.#p++}reset(){this.#p=0}}class oe{[re]={wrap:t=>(...e)=>(this.#I.reset(),t(...e)),disconnect:()=>{for(const t of this.#K)t();this.#K.clear();for(const t of this.#V)t();this.#V.clear(),this.#F.clear();for(const{untrack:t}of this.#J.values())t();this.#J.clear()},reconnect:()=>{for(const t of this.#W.values())this.#K.add(t());for(const[t,e]of this.#Y.entries()){const[s,n]=e();this.#F.set(t,s),this.#V.add(n)}},afterRender:()=>{for(const t of this.#X.values())t()}};#Z;#G;#I=new ie;constructor(t,e){this.#G=t,this.#Z=e}get context(){return this.#Z}rerender(){this.#G()}#W=new Map;#K=new Set;mount(t){const e=this.#I.pull();this.#W.has(e)||(this.#W.set(e,t),this.#K.add(t()))}#Y=new Map;#F=new Map;#V=new Set;init(t){const e=this.#I.pull();if(!this.#Y.has(e)){this.#Y.set(e,t);const[s,n]=t();return this.#F.set(e,s),this.#V.add(n),s}return this.#F.get(e)}#Q=new Map;once(t){const e=this.#I.pull();return n(this.#Q).guarantee(e,t)}#X=new Map;defer(t){const e=this.signal(void 0),s=this.#I.pull();return this.#X.has(s)||this.#X.set(s,(()=>{e.value=t()})),e}#tt=new Set;deferOnce(t){this.mount((()=>(this.#tt.clear(),()=>{})));const e=this.signal(void 0),s=this.#I.pull();return this.#X.has(s)||this.#X.set(s,(()=>{this.#tt.has(s)||(this.#tt.add(s),e.value=t())})),e}#et=new Map;state(t){const e=this.#I.pull();return[n(this.#et).guarantee(e,(()=>"function"==typeof t?t():t)),t=>{this.#et.set(e,t),this.#G()},()=>this.#et.get(e)]}#st=new Map;flatstate(t){const e=this.#I.pull();return n(this.#st).guarantee(e,(()=>D.state("function"==typeof t?t():t)))}#M=new Map;signal(t){const e=this.#I.pull();return n(this.#M).guarantee(e,(()=>M.signal("function"==typeof t?t():t)))}computed(t){const e=this.#I.pull();return n(this.#M).guarantee(e,(()=>M.computed(t)))}op(){const t=this.#I.pull();return n(this.#M).guarantee(t,(()=>M.op()))}load(t){const e=this.op();return this.once((()=>e.load(t))),e}#J=new Map;watch(t){const e=this.#I.pull(),{data:s}=n(this.#J).guarantee(e,(()=>{const e={data:t(),untrack:()=>{}};return e.untrack=P.track(t,(t=>{e.data=t,this.#G()})),e}));return s}#nt=new Map;effect(t,e){e=e.map(S.unwrap);const s=this.#I.pull(),n=this.#nt.get(s);if(n){const[r,i]=n;y.equal(e,i)||(r(),this.#nt.set(s,[t(),e]))}else{this.#W.set(s,t);const n=t();this.#K.add(n),this.#nt.set(s,[n,e])}}}class ae extends oe{#rt;get element(){return this.#rt}#it;get shadow(){return this.#it}styles(...t){this.once((()=>ee(this.shadow,[this.context.theme,...t])))}css(...t){return this.styles(...t)}constructor(t,e,s,n){super(s,n),this.#rt=t,this.#it=e}}function le(t){let e;return function(s){return e||(e=function(t,e){return m.on_change(t,(()=>t.requestUpdate())),m.proxy(t,e)}(t,s)),e}}class ce extends ae{attrs;constructor(t,e,s,n){super(t,e,s,n),this.attrs=le(t)}}class ue extends oe{#rt;get element(){return this.#rt}attrs;constructor(t,e,s){super(e,s),this.#rt=t,this.attrs=le(t)}}class de extends ce{}class he extends ue{}class pe extends oe{element;name(t){this.once((()=>this.element.setAttribute("view",t)))}constructor(t,e,s){super(e,s),this.element=t}}class fe extends ae{name(t){this.once((()=>this.element.setAttribute("view",t)))}}class me{#Z;constructor(t){this.#Z=t}get context(){if(this.#Z)return this.#Z;throw new Error("nexus.context was not set, but it's necessary")}set context(t){this.#Z=t}}function ge(t,e){const s=T.lean(e);return{stop:s.stop,render:(...e)=>s.collect((()=>t(...e)))}}const be=t=>e=>class extends se{#ot=new de(this,this.root,(()=>{this.requestUpdate()}),t.context);#at=this.#ot[re].wrap((()=>e(this.#ot)));#lt;render(){return this.updateComplete.then((()=>this.#ot[re].afterRender())),this.#lt?.render()}connectedCallback(){super.connectedCallback(),this.#ot[re].reconnect(),this.#lt=ge(this.#at,(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.#ot[re].disconnect(),this.#lt&&(this.#lt.stop(),this.#lt=void 0)}},ye=2;
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class we{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const ve=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),ve(t,e);return!0},$e=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},xe=t=>{for(let e;e=t._$AM;t=e){let s=e._$AN;if(void 0===s)e._$AN=s=new Set;else if(s.has(t))break;s.add(t),Ae(e)}};function _e(t){void 0!==this._$AN?($e(this),this._$AM=t,xe(this)):this._$AM=t}function ke(t,e=!1,s=0){const n=this._$AH,r=this._$AN;if(void 0!==r&&0!==r.size)if(e)if(Array.isArray(n))for(let t=s;t<n.length;t++)ve(n[t],!1),$e(n[t]);else null!=n&&(ve(n,!1),$e(n));else ve(this,t)}const Ae=t=>{t.type==ye&&(t._$AP??=ke,t._$AQ??=_e)};class Ce extends we{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),xe(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(ve(this,t),$e(this))}setValue(t){if((t=>void 0===t.strings)
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}function Se(){const t=new Set;function e(e){return t.add(e),()=>{t.delete(e)}}return e.publish=e=>{for(const s of t)s(e)},e.clear=()=>t.clear(),e.once=e=>{const s=n=>{e(n),t.delete(s)};return t.add(s),()=>{t.delete(s)}},e}class Ee extends HTMLElement{static tag="slate-view";onConnected=Se();onDisconnected=Se();connectedCallback(){this.onConnected.publish()}disconnectedCallback(){this.onDisconnected.publish()}}function Oe(...t){const e=new Set,s=t.map((t=>t??"")).flatMap(De);for(const t of s)e.add(t);return e}function De(t){return t.split(/\s+/).map((t=>t.trim())).filter((t=>!!t))}function Me(t){return t.split(",").map((t=>t.trim())).filter((t=>!!t)).map((t=>t.includes(":")?t.split(":").map((t=>t.trim()))[1]:t))}function Pe(t,e){const s=Oe(t.getAttribute("part")),n=Oe(t.getAttribute("data-gpart")),r=function(t,e){return Object.fromEntries(Object.entries(e).map((([e,s])=>[e,Array.from(t.querySelectorAll(`[${s}]`)).map((t=>t.getAttribute(s)))])))}(e,{part:"part",gpart:"data-gpart",exportparts:"exportparts",gexportparts:"gexportparts"}),i=new Set([...r.part.flatMap(De),...r.exportparts.flatMap(Me)]),o=new Set([...r.gpart.flatMap(De),...r.gexportparts.flatMap(De)]);i.size&&t.setAttribute("exportparts",[...s].flatMap(function(t,e){return s=>[...t].flatMap((t=>[`${t}:${s}-${t}`,...e.has(t)?[t]:[]]))}(i,o)).join(", ")),(o.size||t.hasAttribute("data-gpart"))&&t.setAttribute("gexportparts",[...o,...[...n].flatMap((t=>[...i].map((e=>`${t}-${e}`))))].join(" "))}function Ue(t,e={},s={}){const{content:n,attrs:r={}}=e,{attrs:i={}}=s;function o(e,s,n,r){e!==s&&(void 0===e?t.removeAttribute(n):t.setAttribute(n,r()))}r&&function(t,e){for(const[s,n]of Object.entries(e))"string"==typeof n?t.setAttribute(s,n):"number"==typeof n?t.setAttribute(s,n.toString()):"boolean"==typeof n?!0===n?t.setAttribute(s,""):t.removeAttribute(s):void 0===n?t.removeAttribute(s):console.warn(`invalid attribute type ${s} is ${typeof n}`)}(t,r),o(r.class,i?.class,"class",(()=>r.class)),o(r.part,i?.part,"part",(()=>r.part)),o(r.gpart,i?.gpart,"data-gpart",(()=>r.gpart)),n&&Xt(n,t,{host:t})}L({SlateView:Ee},{soft:!0});const je=t=>e=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends Ce{#R;#ct=!0;#H=function({afterRender:t,onConnected:e,onDisconnected:s}){const n=document.createElement(Ee.tag);n.onConnected(e),n.onDisconnected(s);const r=n.attachShadow({mode:"open"});let i=!1;return{container:n,shadow:r,set auto_exportparts(t){i=t},render_into_shadow:e=>(Xt(e,r),i&&Pe(n,r),t(),n)}}({afterRender:()=>this.#ot[re].afterRender(),onDisconnected:()=>this.disconnected(),onConnected:()=>{this.#ct||this.reconnected(),this.#ct=!1}});#G=d(0,(()=>{this.#R&&this.isConnected&&this.setValue(this.#H.render_into_shadow(this.render(this.#R)))}));#ot=new fe(this.#H.container,this.#H.shadow,this.#G,t.context);#at=this.#ot[re].wrap(e(this.#ot));#lt=ge(this.#at,this.#G);update(t,e){return this.#H.render_into_shadow(this.render(...e))}render(t){return Ue(this.#H.container,t.meta,this.#R?.meta),this.#R=t,this.#H.auto_exportparts=t.meta.auto_exportparts??!0,this.#lt?.render(...t.props)}reconnected(){this.#ot[re].reconnect(),this.#lt=ge(this.#at,this.#G)}disconnected(){this.#ot[re].disconnect(),this.#lt&&(this.#lt.stop(),this.#lt=void 0)}}),Te=t=>e=>class extends ne{#ot=new he(this,(()=>{this.requestUpdate()}),t.context);#at=this.#ot[re].wrap((()=>e(this.#ot)));#lt;render(){return this.updateComplete.then((()=>this.#ot[re].afterRender())),this.#lt?.render()}connectedCallback(){super.connectedCallback(),this.#lt=ge(this.#at,(()=>{this.requestUpdate()})),this.#ot[re].reconnect()}disconnectedCallback(){super.disconnectedCallback(),this.#lt&&(this.#lt.stop(),this.#lt=void 0),this.#ot[re].disconnect()}},Re=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Ce{#ut;#rt=document.createElement(Ee.tag);#dt(t){return Xt(t,this.#rt),this.#ot[re].afterRender(),this.#rt}#G=d(0,(()=>{this.#ut&&this.isConnected&&this.setValue(this.#dt(this.render(...this.#ut)))}));#ot=new pe(this.#rt,this.#G,t.context);#at=this.#ot[re].wrap(e(this.#ot));#lt=ge(this.#at,this.#G);update(t,e){return this.#dt(this.render(...e))}render(...t){return this.#ut=t,this.#lt?.render(...t)}reconnected(){this.#ot[re].reconnect(),this.#lt=ge(this.#at,this.#G)}disconnected(){this.#ot[re].disconnect(),this.#lt&&(this.#lt.stop(),this.#lt=void 0)}});W`
@layer reset {
* {
margin: 0;
padding: 0;
box-sizing: border-box;
scrollbar-width: thin;
scrollbar-color: #888 transparent;
}
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 1em; }
::-webkit-scrollbar-thumb:hover { background: #444; }
}
`;const Ne=(t,...e)=>Pt(t,...e.map(S.unwrap)),ze=W`
:host {
display: contents;
}
`;const qe=new class extends me{lightComponent;shadowComponent;lightView;shadowView;shadowComponentify;constructor(t){super(t),this.lightComponent=Te(this),this.shadowComponent=be(this),this.lightView=Re(this),this.shadowView=je(this),this.shadowComponentify=(t=>e=>t.shadowComponent((t=>(t.styles(ze),e([])))))(this)}component=t=>N.setup(this.context.theme)(t);components=t=>B.setup(this.context.theme)(t)}(new class{theme=[]}),He=qe;qe.lightView,qe.lightComponent;const Be=qe.shadowView,Le=qe.shadowComponent;function Ie(t,e){const s=setInterval(e,t);return()=>clearInterval(s)}qe.component,qe.components,qe.shadowComponentify,Ie.hz=(t,e)=>Ie(1e3/t,e);const Ke=W`
:host {
color: red;
font-family: monospace;
}
`,Ve=He.shadowView((t=>e=>(t.name("error-indicator"),t.styles(Ke),Ne`${e||"unknown error"}`))),Fe=W`
:host {
font-family: monospace;
}
`,Je=He.shadowView((t=>(e,s)=>{t.name("loading-indicator"),t.styles(Fe);const n=t.signal(0);return t.mount((()=>Ie.hz(e,(()=>{const t=n.value+1;n.value=t<s.length?t:0})))),Ne`${s[n.value]}`})),We=(t,e)=>function({loading:t,error:e}){return function(s,n){const r=s instanceof S?s.value:s;return $.select(r,{loading:t,error:e,ready:n})}}({error:t=>Ve([t]),loading:()=>Je([t,e])}),Ye={binary:We(20,["00000","00001","00010","00101","01011","10110","01100","11001","10011","00111","01110","11101","11011","10110","01101","11010","10100","01000","10000"]),braille:We(20,["⣾","⣷","⣯","⣟","⡿","⢿","⣻","⣽"])},Xe=[..."aeiou"],Ze=[..."bcdfghjklmnprstvwxyz"],Ge=new Set(["fuc","sex","cum","dic","coc","pen","vag","pus","gay","fap","jiz","fag","cun","nig","jew","goy","sem","bal","fat","god","big","dog","cow","pet","vax","sis","rot","zog","ana","uti","cat","bag","cuc","fuk","fak","wet","cux","bug","gey","pig","rat","bat","dik","bed","boy","man","fem","men","nob","rub","fut","jap","tit","gun","job","nip","but","rim","guy","suc","dad","mom","buk","jis","peg","kox","ded","mum","son","nog","hun","wop","cuk"]);function Qe(t,e){const s=e.length-t;if(s<=0)return e;const n=e.length/s,r=[];let i=n;for(let t=0;t<e.length;t++)t>=Math.round(i)?i+=n:r.push(e[t]);return r.slice(0,t)}function ts(t){return[...new Set(t)]}const es=ts(Qe(256,Ze.map((t=>Xe.map((e=>Ze.map((s=>t+e+s)))))).flat(2).filter((t=>!Ge.has(t))))),ss=ts(Qe(256,Xe.map((t=>Ze.map((e=>Xe.map((s=>t+e+s)))))).flat(2).filter((t=>!Ge.has(t))))),ns=ts([...Qe(192,es),...Qe(64,ss)]);if(256!==es.length)throw new Error("xox not 256");if(256!==ss.length)throw new Error("oxo not 256");if(256!==ns.length)throw new Error("syllables not 256");const rs={xox:es,oxo:ss,combo:ns},is={random:t=>crypto.getRandomValues(new Uint8Array(t))};new Set([..."अआइईउऊऋएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलवशषसह",..."அஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநபமயரலவழளறன",..."অআইঈউঊএঐওকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ",..."ਅਆਇਈਉਊਏਐਓਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹ",..."അആഇഈഉഊഎഏഐഒഓകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനപഫബഭമയരലവശസഹളഴറ",..."અઆઇઈઉઊએઐઓકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલવશષસહ",..."ଅଆଇଈଉଊଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଶଷସହ"]);const os={string:t=>[...t].map((t=>t.toString(16).padStart(2,"0"))).join(""),bytes(t){if(t.length%2!=0)throw new Error("must have even number of hex characters");const e=new Uint8Array(t.length/2);for(let s=0;s<t.length;s+=2)e[s/2]=parseInt(t.slice(s,s+2),16);return e},random(t=32){return this.string(is.random(t))}},as={string:t=>"function"==typeof btoa?btoa(String.fromCharCode(...t)):Buffer.from(t).toString("base64"),bytes:t=>"function"==typeof atob?Uint8Array.from(atob(t),(t=>t.charCodeAt(0))):Uint8Array.from(Buffer.from(t,"base64")),random(t=32){return this.string(is.random(t))}},ls={string:t=>as.string(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""),bytes(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");return e.length%4!=0&&(e=e.padEnd(e.length+(4-e.length%4)%4,"=")),as.bytes(e)},random(t=32){return this.string(is.random(t))}},cs=rs.combo,us="Xxxxxx Xxxxxxxxx ",ds={dictionary:cs,string(t,e=us){if(-1===e.indexOf("x"))throw new Error("invalid pattern");const s=[];for(const e of t)s.push(cs.at(e));const n=[...s.join("")].toReversed(),r=[];let i=0;for(;n.length>0;){const t=e.at(i%e.length);r.push("x"===t?n.pop():"X"===t?n.pop().toUpperCase():t),i++}return r.join("")},bytes(t){const e=t.toLowerCase().trim().replace(/\s+/g,""),s=e.length/3;if(s%1!=0)throw new Error(`invalid triplet count, ${e.length} does not divide into triplets`);const n=[];for(const t of Array(s).keys()){const s=3*t;n.push(e[s]+e[s+1]+e[s+2])}return new Uint8Array(n.map((t=>{const e=cs.findIndex((e=>e===t));if(-1===e)throw new Error(`unknown triplet ${t}`);return e})))},equal(t,e){return this.string(this.bytes(t),"x")===this.string(this.bytes(e),"x")},random(t=5,e=us){return this.string(is.random(t),e)}},hs={string:t=>(new TextDecoder).decode(t),bytes:t=>(new TextEncoder).encode(t)},ps=t=>Ut(t.strings,...t.values);function fs(t=32){const e=new Uint8Array(t);return[...crypto.getRandomValues(e)].map((t=>t.toString(16).padStart(2,"0"))).join("")}var ms;!function(t){t.actualize=function t(e,s){return x(s).map((s=>"function"==typeof s?(...t)=>{e.transmute((e=>(s(e,(t=>{e=t}))(...t),e)))}:t(e,s)))},t.fn=function(){return t=>t},t.blueprint=function(){return t=>t},t.prepFn=t=>e=>(s,n)=>(...r)=>(e(t(s,n))(...r),s),t.prepBlueprint=e=>s=>s(t.prepFn(e)),t.prep=function(e){return{action:t.prepFn(e),blueprint:t.prepBlueprint(e)}}}(ms||(ms={}));class gs{static formats={public:"spki",private:"pkcs8"};static algos={generate:{name:"ECDSA",namedCurve:"P-256"},signing:{name:"ECDSA",hash:{name:"SHA-256"}},thumbprint:"SHA-256"}}class bs extends Error{name=this.constructor.name}class ys{static header=Object.freeze({typ:"JWT",alg:"ES256"});static toJsTime=t=>1e3*t;static fromJsTime=t=>t/1e3;static params=t=>({jti:fs(),iat:Date.now(),exp:ys.fromJsTime(t.expiresAt),nbf:t.notBefore,iss:t.issuer,aud:t.audience});static async sign(t,e){const s=hs.bytes(JSON.stringify(ys.header)),n=ls.string(s),r=hs.bytes(JSON.stringify(e)),i=`${n}.${ls.string(r)}`,o=(new TextEncoder).encode(i);return`${i}.${ls.string(new Uint8Array(await crypto.subtle.sign(gs.algos.signing,t,o)))}`}static decode(t){const[e,s,n]=t.split(".");if(!e||!s||!n)throw new Error("invalid jwt structure");const r=ls.bytes(e),i=hs.string(r),o=JSON.parse(i),a=ls.bytes(s),l=hs.string(a);return{header:o,payload:JSON.parse(l),signature:ls.bytes(n).buffer}}static async verify(t,e,s={}){const[n,r]=e.split("."),{payload:i,signature:o}=ys.decode(e),a=`${n}.${r}`,l=(new TextEncoder).encode(a);if(!await crypto.subtle.verify(gs.algos.signing,t,o,l))throw new bs("token signature invalid");if(i.exp){const t=ys.toJsTime(i.exp);if(Date.now()>t)throw new bs("token expired")}if(i.nbf){const t=ys.toJsTime(i.nbf);if(Date.now()<t)throw new bs("token not ready")}if(s.allowedIssuers){if(!i.iss)throw new bs("required iss (issuer) is missing");if(!s.allowedIssuers.includes(i.iss))throw new bs(`invalid iss (issuer) "${i.iss}"`)}if(s.allowedAudiences){if(!i.aud)throw new bs("required aud (audience) is missing");if(!s.allowedAudiences.includes(i.aud))throw new bs(`invalid aud (audience) "${i.aud}"`)}if(i.aud&&!s.allowedAudiences)throw new bs('allowedAudiences verification option was not provided, but is required because the token included "aud"');return i}}class ws{thumbprint;publicKey;constructor(t,e){this.thumbprint=t,this.publicKey=e}static async fromData(t){const e=os.bytes(t.publicKey).buffer,s=os.string(new Uint8Array(await crypto.subtle.digest(gs.algos.thumbprint,e)));if(t.thumbprint!==s)throw new bs("incorrect thumbprint");return new this(s,await crypto.subtle.importKey(gs.formats.public,e,gs.algos.generate,!0,["verify"]))}async toData(){const t=await crypto.subtle.exportKey(gs.formats.public,this.publicKey);return{thumbprint:os.string(new Uint8Array(await crypto.subtle.digest(gs.algos.thumbprint,t))),publicKey:os.string(new Uint8Array(t))}}async verify(t,e={}){return await ys.verify(this.publicKey,t,e)}}class vs extends ws{privateKey;constructor(t,e,s){super(t,e),this.privateKey=s}static async generate(){const t=await crypto.subtle.generateKey(gs.algos.generate,!0,["sign","verify"]),e=await crypto.subtle.exportKey(gs.formats.public,t.publicKey);return new this(os.string(new Uint8Array(await crypto.subtle.digest(gs.algos.thumbprint,e))),t.publicKey,t.privateKey)}static async fromData(t){const e=await ws.fromData(t),s=os.bytes(t.privateKey).buffer,n=await crypto.subtle.importKey(gs.formats.private,s,gs.algos.generate,!0,["sign"]);return new this(e.thumbprint,e.publicKey,n)}async toData(){const t=await super.toData(),e=await crypto.subtle.exportKey(gs.formats.private,this.privateKey);return{thumbprint:t.thumbprint,publicKey:t.publicKey,privateKey:os.string(new Uint8Array(e))}}toPubkey(){return new ws(this.thumbprint,this.publicKey)}async sign(t){return await ys.sign(this.privateKey,t)}}class $s{keypairData;name;created;constructor(t,e,s){this.keypairData=t,this.name=e,this.created=s}get thumbprint(){return this.keypairData.thumbprint}static async generate(){const t=await vs.generate(),e=await t.toData(),s=os.bytes(t.thumbprint).slice(0,5);return new this(e,ds.string(s,"Xxxxxx Xxxxxxxxx "),Date.now())}static fromData(t){const{keypair:e,name:s,created:n}=t;return new this(e,s,n)}toData(){return y.clone({keypair:this.keypairData,name:this.name,created:this.created})}async getKeypair(){return await vs.fromData(this.keypairData)}async signLoginTokens(t){const e=await this.getKeypair(),s=await vs.generate(),n=ys.fromJsTime(t.expiresAt),r=this.name,i=t.issuer,o=t.audience,a=fs();return{proofToken:await e.sign({exp:n,iss:i,aud:o,jti:a,data:{loginPubkey:await s.toPubkey().toData(),passportPubkey:await e.toPubkey().toData()}}),keysToken:await e.sign({sub:this.thumbprint,exp:n,iss:i,aud:o,jti:a,data:{name:r,loginKeypair:await s.toData()}})}}}class xs extends Error{constructor(t){super(`failed validation: ${t}`)}}function _s(t,e){return(s,n)=>{if(!e(n))throw new xs(`${s} should be ${t}`);return n}}const ks={string:_s("string",(t=>"string"==typeof t)),number:_s("number",(t=>"number"==typeof t)),boolean:_s("boolean",(t=>"boolean"==typeof t)),array:_s("array",(t=>Array.isArray(t))),object:_s("object",(t=>"object"==typeof t&&!Array.isArray(t)))};class As{static format=