@authlocal/authlocal
Version:
User-sovereign Logins For All
66 lines (64 loc) • 87.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 y=t=>"object"==typeof t&&null!==t;const b={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(!y(e)||!y(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(!y(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 b.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.#p=t,this.publish())}setDeep(t){if(this.#f)throw new C("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");b.equal(t,this.#p)||(this.#p=t,this.publish())}setAndPublish(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()}setWithoutPublish(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}setValueNoPublish(t){return this.setWithoutPublish(t)}}class E extends S{#y=0;constructor(t){super(t)}async load(t){const e=++this.#y;return $.load((t=>{this.#y===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{#b=!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.#b)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.on((()=>this.#v.add(this.#o(t)))))}shutdown(){this.#b=!1,this.#x.forEach((t=>t()))}}const P=new class{static readonly=u;static collectivize=p;#A=new r;#C=new o;#S=new t;#E=new i;#O=new h;#P=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.#P)}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}}}async#U(){return await Promise.all([...this.#M].map((t=>t.wait))).then((()=>Promise.all([...this.#v]))).then((()=>{this.#v.clear()}))}get wait(){return Promise.resolve().then((()=>this.#U())).then((()=>this.#U()))}},U=new class{#M;#D=new Set;#m=new Set;#T=new Map;#j=Promise.resolve();constructor(t){this.#M=t}get wait(){return this.#j}#N=d(0,(()=>{for(const t of this.#D)t();for(const t of this.#m)t()}));dispatch(){this.#j=this.#N()}computed(t){const e=this.#M.signal(t());return this.#D.add((()=>{e.value=t()})),e}track(t,e){let s=!0;const n=()=>{const n=t(),r=this.#T.get(t);!s&&b.equal(n,r)||(s=!1,this.#T.set(t,n),e(n))};n(),this.#m.add(n);return()=>this.#m.delete(n)}stateTree(t){return new w(t,(()=>this.dispatch()))}}(M);P.state.bind(P);const D=M.signal.bind(M);M.computed.bind(M);const T=M.op.bind(M),j=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)))}}}(P,M);class N{static with(t){return new this(t)}#z;constructor(t){this.#z=t}to(t){return new N(t(this.#z))}done(){return this.#z}}var z;function R(t){return[t].flat().filter((t=>!!t))}!function(t){function e(...t){return function(e){return class extends e{static get styles(){return L(e.styles,t)}}}}function s(t=j){return function(e){return class extends e{#R=null;render(){return this.#R?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#R=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#R&&(this.#R.stop(),this.#R=null)}}}}t.css=e,t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return L(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#R=null;render(){return this.#R?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#R=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#R&&(this.#R.stop(),this.#R=null)}}}},t.flat=function(t){return function(e){return class extends e{#R=null;render(){return this.#R?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#R=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#R&&(this.#R.stop(),this.#R=null)}}}},t.reactive=s,t.reactor=s,t.setup=function(...t){return function(n){return N.with(n).to(e(...t)).to(s()).done()}}}(z||(z={}));const B=t=>void 0!==t;function L(t,e){return[...R(t)??[],...R(e)].flat().filter(B)}var H;function q(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=>z.css(t)(e))),t.flat=t=>e=>x(e).map((e=>z.flat(t)(e))),t.signals=t=>e=>x(e).map((e=>z.signals(t)(e))),t.reactive=(t=j)=>e=>x(e).map((e=>z.reactive(t)(e))),t.reactor=t.reactive,t.context=e=>s=>N.with(s).to(t.css(e.theme)).to(t.reactive()).done(),t.setup=(...t)=>e=>x(e).map((e=>z.setup(...t)(e)))}(H||(H={}));const I=globalThis,K=I.ShadowRoot&&(void 0===I.ShadyCSS||I.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,F=Symbol(),V=new WeakMap;let W=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==F)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=V.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&V.set(e,t))}return t}toString(){return this.cssText}};const J=(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 W(s,t,F)},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)}},G=K?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new W("string"==typeof t?t:t+"",void 0,F))(e)})(t):t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,{is:Z,defineProperty:Q,getOwnPropertyDescriptor:X,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&&Q(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){const{get:n,set:r}=X(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(G(t))}else void 0!==t&&e.push(G(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)}$`,yt="?"+gt,bt=`<${yt}>`,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,Pt=/^(?:script|style|textarea|title)$/i,Mt=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),Ut=Mt(1),Dt=Mt(2),Tt=Symbol.for("lit-noChange"),jt=Symbol.for("lit-nothing"),Nt=new WeakMap,zt=wt.createTreeWalker(wt,129);function Rt(t,e){if(!xt(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==ft?ft.createHTML(e):e}const Bt=(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]?(Pt.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+bt:c>=0?(n.push(a),s.slice(0,c)+mt+s.slice(c)+gt+d):s+gt+(-2===c?e:d)}return[Rt(t,i+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),n]};class Lt{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]=Bt(t,e);if(this.el=Lt.createElement(l,s),zt.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=zt.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]?Ft:"?"===o[1]?Vt:"@"===o[1]?Wt:Kt}),n.removeAttribute(t)}else t.startsWith(gt)&&(a.push({type:6,index:r}),n.removeAttribute(t));if(Pt.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()),zt.nextNode(),a.push({type:2,index:++r});n.append(t[e],vt())}}}else if(8===n.nodeType)if(n.data===yt)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 Ht(t,e,s=t,n){if(e===Tt)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=Ht(t,r._$AS(t,e.values),r,n)),e}class qt{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);zt.currentNode=n;let r=zt.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 Jt(r,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(r=zt.nextNode(),i++)}return zt.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=jt,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=Ht(this,t,e),$t(t)?t===jt||null==t||""===t?(this._$AH!==jt&&this._$AR(),this._$AH=jt):t!==this._$AH&&t!==Tt&&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!==jt&&$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=Lt.createElement(Rt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new qt(n,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=Nt.get(t.strings);return void 0===e&&Nt.set(t.strings,e=new Lt(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=jt,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=jt}_$AI(t,e=this,s,n){const r=this.strings;let i=!1;if(void 0===r)t=Ht(this,t,e,0),i=!$t(t)||t!==this._$AH&&t!==Tt,i&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Ht(this,n[s+o],e,o),a===Tt&&(a=this._$AH[o]),i||=!$t(a)||a!==this._$AH[o],a===jt?t=jt:t!==jt&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}i&&!n&&this.j(t)}j(t){t===jt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ft extends Kt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===jt?void 0:t}}class Vt extends Kt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==jt)}}class Wt extends Kt{constructor(t,e,s,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=Ht(this,t,e,0)??jt)===Tt)return;const s=this._$AH,n=t===jt&&s!==jt||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==jt&&(s===jt||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 Jt{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){Ht(this,t)}}const Yt=ht.litHtmlPolyfillSupport;Yt?.(Lt,It),(ht.litHtmlVersions??=[]).push("3.2.1");const Gt=(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=Gt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Tt}};Zt._$litElement$=!0,Zt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:Zt});const Qt=globalThis.litElementPolyfillSupport;Qt?.({LitElement:Zt}),(globalThis.litElementVersions??=[]).push("4.1.1");class Xt extends(function(t){return class extends t{#B=(new Set).add((()=>this.setup()));#L=new Set;register_setup(t){this.#B.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#B)this.#L.add(t())}disconnectedCallback(){for(const t of this.#L)t();this.#L.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(G(t))}else void 0!==t&&e.push(G(t));return e}(e))}class se extends Xt{static get styles(){}#H;#q=te();#i=this.#q.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(){}#I=d(0,(()=>{const t=this.#H,e=this.render();e&&Gt(e,t,{host:this})}));async requestUpdate(){const t=this.#I();return this.#q&&(t.then(this.#q.resolve),this.#q=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class ne extends Xt{#q=te();#i=this.#q.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#i.then((()=>!0))}render(){}#I=d(0,(()=>{const t=this.render();Gt(t,this,{host:this})}));async requestUpdate(){const t=this.#I();return this.#q&&(t.then(this.#q.resolve),this.#q=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.#K.reset(),t(...e)),disconnect:()=>{for(const t of this.#F)t();this.#F.clear();for(const t of this.#V)t();this.#V.clear(),this.#W.clear();for(const{untrack:t}of this.#J.values())t();this.#J.clear()},reconnect:()=>{for(const t of this.#Y.values())this.#F.add(t());for(const[t,e]of this.#G.entries()){const[s,n]=e();this.#W.set(t,s),this.#V.add(n)}},afterRender:()=>{for(const t of this.#Z.values())t()}};#Q;#X;#K=new ie;constructor(t,e){this.#X=t,this.#Q=e}get context(){return this.#Q}rerender(){this.#X()}#Y=new Map;#F=new Set;mount(t){const e=this.#K.pull();this.#Y.has(e)||(this.#Y.set(e,t),this.#F.add(t()))}#G=new Map;#W=new Map;#V=new Set;init(t){const e=this.#K.pull();if(!this.#G.has(e)){this.#G.set(e,t);const[s,n]=t();return this.#W.set(e,s),this.#V.add(n),s}return this.#W.get(e)}#tt=new Map;once(t){const e=this.#K.pull();return n(this.#tt).guarantee(e,t)}#Z=new Map;defer(t){const e=this.signal(void 0),s=this.#K.pull();return this.#Z.has(s)||this.#Z.set(s,(()=>{e.value=t()})),e}#et=new Set;deferOnce(t){this.mount((()=>(this.#et.clear(),()=>{})));const e=this.signal(void 0),s=this.#K.pull();return this.#Z.has(s)||this.#Z.set(s,(()=>{this.#et.has(s)||(this.#et.add(s),e.value=t())})),e}#st=new Map;state(t){const e=this.#K.pull();return[n(this.#st).guarantee(e,(()=>"function"==typeof t?t():t)),t=>{this.#st.set(e,t),this.#X()},()=>this.#st.get(e)]}#nt=new Map;flatstate(t){const e=this.#K.pull();return n(this.#nt).guarantee(e,(()=>P.state("function"==typeof t?t():t)))}#M=new Map;signal(t){const e=this.#K.pull();return n(this.#M).guarantee(e,(()=>M.signal("function"==typeof t?t():t)))}computed(t){const e=this.#K.pull();return n(this.#M).guarantee(e,(()=>M.computed(t)))}op(){const t=this.#K.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.#K.pull(),{data:s}=n(this.#J).guarantee(e,(()=>{const e={data:t(),untrack:()=>{}};return e.untrack=U.track(t,(t=>{e.data=t,this.#X()})),e}));return s}#rt=new Map;effect(t,e){e=e.map(S.unwrap);const s=this.#K.pull(),n=this.#rt.get(s);if(n){const[r,i]=n;b.equal(e,i)||(r(),this.#rt.set(s,[t(),e]))}else{this.#Y.set(s,t);const n=t();this.#F.add(n),this.#rt.set(s,[n,e])}}}class ae extends oe{#it;get element(){return this.#it}#ot;get shadow(){return this.#ot}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.#it=t,this.#ot=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{#it;get element(){return this.#it}attrs;constructor(t,e,s){super(e,s),this.#it=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{#Q;constructor(t){this.#Q=t}get context(){if(this.#Q)return this.#Q;throw new Error("nexus.context was not set, but it's necessary")}set context(t){this.#Q=t}}function ge(t,e){const s=j.lean(e);return{stop:s.stop,render:(...e)=>s.collect((()=>t(...e)))}}const ye=t=>e=>class extends se{#at=new de(this,this.root,(()=>{this.requestUpdate()}),t.context);#lt=this.#at[re].wrap((()=>e(this.#at)));#ct;render(){return this.updateComplete.then((()=>this.#at[re].afterRender())),this.#ct?.render()}connectedCallback(){super.connectedCallback(),this.#at[re].reconnect(),this.#ct=ge(this.#lt,(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.#at[re].disconnect(),this.#ct&&(this.#ct.stop(),this.#ct=void 0)}},be=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==be&&(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(Pe);for(const t of s)e.add(t);return e}function Pe(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 Ue(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(Pe),...r.exportparts.flatMap(Me)]),o=new Set([...r.gpart.flatMap(Pe),...r.gexportparts.flatMap(Pe)]);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 De(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&&Gt(n,t,{host:t})}q({SlateView:Ee},{soft:!0});const Te=t=>e=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends Ce{#z;#ut=!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=>(Gt(e,r),i&&Ue(n,r),t(),n)}}({afterRender:()=>this.#at[re].afterRender(),onDisconnected:()=>this.disconnected(),onConnected:()=>{this.#ut||this.reconnected(),this.#ut=!1}});#X=d(0,(()=>{this.#z&&this.isConnected&&this.setValue(this.#H.render_into_shadow(this.render(this.#z)))}));#at=new fe(this.#H.container,this.#H.shadow,this.#X,t.context);#lt=this.#at[re].wrap(e(this.#at));#ct=ge(this.#lt,this.#X);update(t,e){return this.#H.render_into_shadow(this.render(...e))}render(t){return De(this.#H.container,t.meta,this.#z?.meta),this.#z=t,this.#H.auto_exportparts=t.meta.auto_exportparts??!0,this.#ct?.render(...t.props)}reconnected(){this.#at[re].reconnect(),this.#ct=ge(this.#lt,this.#X)}disconnected(){this.#at[re].disconnect(),this.#ct&&(this.#ct.stop(),this.#ct=void 0)}}),je=t=>e=>class extends ne{#at=new he(this,(()=>{this.requestUpdate()}),t.context);#lt=this.#at[re].wrap((()=>e(this.#at)));#ct;render(){return this.updateComplete.then((()=>this.#at[re].afterRender())),this.#ct?.render()}connectedCallback(){super.connectedCallback(),this.#ct=ge(this.#lt,(()=>{this.requestUpdate()})),this.#at[re].reconnect()}disconnectedCallback(){super.disconnectedCallback(),this.#ct&&(this.#ct.stop(),this.#ct=void 0),this.#at[re].disconnect()}},Ne=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Ce{#dt;#it=document.createElement(Ee.tag);#ht(t){return Gt(t,this.#it),this.#at[re].afterRender(),this.#it}#X=d(0,(()=>{this.#dt&&this.isConnected&&this.setValue(this.#ht(this.render(...this.#dt)))}));#at=new pe(this.#it,this.#X,t.context);#lt=this.#at[re].wrap(e(this.#at));#ct=ge(this.#lt,this.#X);update(t,e){return this.#ht(this.render(...e))}render(...t){return this.#dt=t,this.#ct?.render(...t)}reconnected(){this.#at[re].reconnect(),this.#ct=ge(this.#lt,this.#X)}disconnected(){this.#at[re].disconnect(),this.#ct&&(this.#ct.stop(),this.#ct=void 0)}});J`
@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 ze=(t,...e)=>Ut(t,...e.map(S.unwrap)),Re=J`
:host {
display: contents;
}
`;const Be=new class extends me{lightComponent;shadowComponent;lightView;shadowView;shadowComponentify;constructor(t){super(t),this.lightComponent=je(this),this.shadowComponent=ye(this),this.lightView=Ne(this),this.shadowView=Te(this),this.shadowComponentify=(t=>e=>t.shadowComponent((t=>(t.styles(Re),e([])))))(this)}component=t=>z.setup(this.context.theme)(t);components=t=>H.setup(this.context.theme)(t)}(new class{theme=[]}),Le=Be;Be.lightView,Be.lightComponent;const He=Be.shadowView,qe=Be.shadowComponent;function Ie(t,e){const s=setInterval(e,t);return()=>clearInterval(s)}Be.component,Be.components,Be.shadowComponentify,Ie.hz=(t,e)=>Ie(1e3/t,e);const Ke=J`
:host {
color: red;
font-family: monospace;
}
`,Fe=Le.shadowView((t=>e=>(t.name("error-indicator"),t.styles(Ke),ze`${e||"unknown error"}`))),Ve=J`
:host {
font-family: monospace;
}
`,We=Le.shadowView((t=>(e,s)=>{t.name("loading-indicator"),t.styles(Ve);const n=t.signal(0);return t.mount((()=>Ie.hz(e,(()=>{const t=n.value+1;n.value=t<s.length?t:0})))),ze`${s[n.value]}`})),Je=(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=>Fe([t]),loading:()=>We([t,e])}),Ye={binary:Je(20,["00000","00001","00010","00101","01011","10110","01100","11001","10011","00111","01110","11101","11011","10110","01101","11010","10100","01000","10000"]),braille:Je(20,["⣾","⣷","⣯","⣟","⡿","⢿","⣻","⣽"])},Ge={random:t=>crypto.getRandomValues(new Uint8Array(t))};class Ze{dictionary;patterns;constructor(t,e){this.dictionary=t,this.patterns=e}static dictionary=t=>({patterns:e=>new this(t,e)});generate([t,...e]){const s=this.patterns[t%this.patterns.length];let n=0;const r=t=>{const s=this.dictionary[t];return s[e[n++%e.length]%s.length]};return s.map((t=>t.map(r).join(""))).join(" ")}random(){const t=Ge.random(32);return this.generate(t)}}class Qe{phraseFns;templates;constructor(t,e){this.phraseFns=t,this.templates=e}static phrases=t=>({templates:e=>new this(t,e)});generate([t,...e]){const s=this.templates[t%this.templates.length],n=Object.keys(this.phraseFns).length,r=Math.floor(e.length/n);let i=0;const o=x(this.phraseFns).map((t=>{const s=i++*r,n=Math.min(s+r,e.length-1);return t(new Uint8Array(e.slice(s,n)))}));return s(o)}random(){const t=Ge.random(32);return this.generate(t)}}const Xe=["doz","mar","bin","wan","sam","lit","sig","hid","fid","lis","sog","dir","wac","sab","wis","sib","rig","sol","dop","mod","fog","lid","hop","dar","dor","lor","hod","fol","rin","tog","sil","mir","hol","pas","lac","rov","liv","dal","sat","lib","tab","han","tic","pid","tor","bol","fos","dot","los","dil","for","pil","ram","tir","win","tad","bic","dif","roc","wid","bis","das","mid","lop","ril","nar","dap","mol","san","loc","nov","sit","nid","tip","sic","rop","wit","nat","pan","min","rit","pod","mot","tam","tol","sav","pos","nap","nop","som","fin","fon","ban","mor","wor","sip","ron","nor","bot","wic","soc","wat","dol","mag","pic","dav","bid","bal","tim","tas","mal","lig","siv","tag","pad","sal","div","dac","tan","sid","fab","tar","mon","ran","nis","wol","mis","pal","las","dis","map","rab","tob","rol","lat","lon","nod","nav","fig","nom","nib","pag","sop","ral","bil","had","doc","rid","moc","pac","rav","rip","fal","tod","til","tin","hap","mic","fan","pat","tac","lab","mog","sim","son","pin","lom","ric","tap","fir","has","bos","bat","poc","hac","tid","hav","sap","lin","dib","hos","dab","bit","bar","rac","par","lod","dos","bor","toc","hil","mac","tom","dig","fil","fas","mit","hob","har","mig","hin","rad","mas","hal","rag","lag","fad","top","mop","hab","nil","nos","mil","fop","fam","dat","nol","din","hat","nac","ris","fot","rib","hoc","nim","lar","fit","wal","rap","sar","nal","mos","lan","don","dan","lad","dov","riv","bac","pol","lap","tal","pit","nam","bon","ros","ton","fod","pon","sov","noc","sor","lav","mat","mip","fip"],ts=["zod","nec","bud","wes","sev","per","sut","let","ful","pen","syt","dur","wep","ser","wyl","sun","ryp","syx","dyr","nup","heb","peg","lup","dep","dys","put","lug","hec","ryt","tyv","syd","nex","lun","mep","lut","sep","pes","del","sul","ped","tem","led","tul","met","wen","byn","hex","feb","pyl","dul","het","mev","rut","tyl","wyd","tep","bes","dex","sef","wyc","bur","der","nep","pur","rys","reb","den","nut","sub","pet","rul","syn","reg","tyd","sup","sem","wyn","rec","meg","net","sec","mul","nym","tev","web","sum","mut","nyx","rex","teb","fus","hep","ben","mus","wyx","sym","sel","ruc","dec","wex","syr","wet","dyl","myn","mes","det","bet","bel","tux","tug","myr","pel","syp","ter","meb","set","dut","deg","tex","sur","fel","tud","nux","rux","ren","wyt","nub","med","lyt","dus","neb","rum","tyn","seg","lyx","pun","res","red","fun","rev","ref","mec","ted","rus","bex","leb","dux","ryn","num","pyx","ryg","ryx","fep","tyr","tus","tyc","leg","nem","fer","mer","ten","lus","nus","syl","tec","mex","pub","rym","tuc","fyl","lep","deb","ber","mug","hut","tun","byl","sud","pem","dev","lur","def","bus","bep","run","mel","pex","dyt","byt","typ","lev","myl","wed","duc","fur","fex","nul","luc","len","ner","lex","rup","ned","lec","ryd","lyd","fen","wel","nyd","hus","rel","rud","nes","hes","fet","des","ret","dun","ler","nyr","seb","hul","ryl","lud","rem","lys","fyn","wer","ryc","sug","nys","nyl","lyn","dyn","dem","lux","fed","sed","bec","mun","lyr","tes","mud","nyt","byr","sen","weg","fyr","mur","tel","rep","teg","pec","nel","nev","fes"],es={random(t){return this.string(Ge.random(t))},string(t){const e=[];let s=[];return t.forEach(((t,n)=>{const r=n%2==0?Xe:ts;s.push(r[t]),2===s.length&&(e.push(s.join("")),s=[])})),s.length&&e.push(s.join("")),e.join("_")},bytes(t){const e=t.toLowerCase().trim().replace(/\s+/g,"").replaceAll("_",""),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,e)=>{const s=(e%2==0?Xe:ts).findIndex((e=>e===t));if(-1===s)throw new Error(`unknown triplet ${t}`);return s})))}},ss={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(Ge.random(t))}},ns="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",rs=Object.freeze({string(t){let e=BigInt("0x"+ss.string(t)),s="";for(;e>0;){const t=e%BigInt(58);e/=BigInt(58),s=ns[Number(t)]+s}for(const e of t){if(0!==e)break;s=ns[0]+s}return s},bytes(t){let e=BigInt(0);for(const s of t){const t=ns.indexOf(s);if(-1===t)throw new Error(`Invalid character '${s}' in base58 string`);e=e*BigInt(58)+BigInt(t)}let s=e.toString(16);s.length%2!=0&&(s="0"+s);const n=ss.bytes(s);let r=0;for(const e of t){if(e!==ns[0])break;r++}const i=new Uint8Array(r+n.length);return i.set(n,r),i},random(t=32){return this.string(Ge.random(t))}});class is{bytes;leadCount;static separator=".";static defaultLeadCount=4;hex;string;preview;constructor(t,e=is.defaultLeadCount){if(this.bytes=t,this.leadCount=e,e<1)throw new Error(`badge leadCount must be greater than 0 (was ${e})`);this.hex=ss.string(this.bytes),this.preview=es.string(this.bytes.slice(0,e)),this.string=t.length>e?`${this.preview}.${rs.string(this.bytes.slice(e))}`:this.preview}static parse(t){const[e,s]=t.split(is.separator);if(s){const t=es.bytes(e),n=rs.bytes(s);return new this(new Uint8Array([...t,...n]),t.length)}{const t=es.bytes(e);return new this(t,t.length)}}static fromHex(t,e=this.defaultLeadCount){return new this(ss.bytes(t),e)}static string(t,e=this.defaultLeadCount){return new this(t,e).string}static bytes(t){return this.parse(t)}static hex(t){return this.parse(t).hex}toString(){return this.string}}const os=[..."aeiou"],as=[..."bcdfghjklmnprstvwxyz"],ls=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 cs(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 us(t){return[...new Set(t)]}const ds=us(cs(256,as.map((t=>os.map((e=>as.map((s=>t+e+s)))))).flat(2).filter((t=>!ls.has(t))))),hs=us(cs(256,os.map((t=>as.map((e=>os.map((s=>t+e+s)))))).flat(2).filter((t=>!ls.has(t))))),ps=us([...cs(192,ds),...cs(64,hs)]);if(256!==ds.length)throw new Error("xox not 256");if(256!==hs.length)throw new Error("oxo not 256");if(256!==ps.length)throw new Error("syllables not 256");new Set([..."अआइईउऊऋएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलवशषसह",..."அஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநபமயரலவழளறன",..."অআইঈউঊএঐওকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ",..."ਅਆਇਈਉਊਏਐਓਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹ",..."അആഇഈഉഊഎഏഐഒഓകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനപഫബഭമയരലവശസഹളഴറ",..."અઆઇઈઉઊએઐઓકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલવશષસહ",..."ଅଆଇଈଉଊଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଶଷସହ"]);const fs={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(Ge.random(t))}