@benev/slate
Advanced tools
Comparing version 0.0.0-dev.13 to 0.0.0-dev.14
{ | ||
"name": "@benev/slate", | ||
"version": "0.0.0-dev.13", | ||
"version": "0.0.0-dev.14", | ||
"description": "frontend web stuff", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -157,3 +157,3 @@ | ||
watch<T>(collector: () => T) { | ||
watch<T>(collector: () => T): T { | ||
const count = this.#counter.value++ | ||
@@ -160,0 +160,0 @@ return maptool(this.#watches).grab( |
import {Slice} from "./slice.js" | ||
export interface WatchBox<V> { | ||
readonly value: V | ||
} | ||
export interface SliceAccessors<S, X> { | ||
@@ -5,0 +9,0 @@ getter: (state: S) => X |
@@ -10,4 +10,5 @@ | ||
#readable: S | ||
#circularity_lock = false | ||
#clone() { | ||
#make_frozen_clone() { | ||
return deepFreeze(structuredClone(this.#state)) | ||
@@ -17,4 +18,4 @@ } | ||
constructor(state: S, handleChange = () => {}) { | ||
this.#state = state | ||
this.#readable = this.#clone() | ||
this.#state = structuredClone(state) | ||
this.#readable = this.#make_frozen_clone() | ||
this.#onChange(handleChange) | ||
@@ -30,5 +31,11 @@ } | ||
transmute(fun: (state: S) => S) { | ||
this.#state = fun(this.#state) | ||
this.#readable = this.#clone() | ||
if (this.#circularity_lock) | ||
throw new Error("circular error") | ||
this.#circularity_lock = true | ||
this.#state = fun(structuredClone(this.#state)) | ||
this.#readable = this.#make_frozen_clone() | ||
this.#onChange.publish() | ||
this.#circularity_lock = false | ||
} | ||
@@ -35,0 +42,0 @@ |
import {StateTree} from "./state_tree.js" | ||
import {WatchBox} from "./parts/types.js" | ||
import {deepEqual} from "../tools/deep_equal/deep_equal.js" | ||
@@ -17,3 +18,3 @@ | ||
computed<T>(fun: () => T) { | ||
computed<V>(fun: () => V): WatchBox<V> { | ||
let data = fun() | ||
@@ -20,0 +21,0 @@ this.#computeds.add(() => { data = fun() }) |
@@ -553,8 +553,9 @@ | ||
#readable; | ||
#clone() { | ||
#circularity_lock = false; | ||
#make_frozen_clone() { | ||
return deepFreeze(structuredClone(this.#state)); | ||
} | ||
constructor(state, handleChange = () => { }) { | ||
this.#state = state; | ||
this.#readable = this.#clone(); | ||
this.#state = structuredClone(state); | ||
this.#readable = this.#make_frozen_clone(); | ||
this.#onChange(handleChange); | ||
@@ -567,5 +568,9 @@ } | ||
transmute(fun) { | ||
this.#state = fun(this.#state); | ||
this.#readable = this.#clone(); | ||
if (this.#circularity_lock) | ||
throw new Error("circular error"); | ||
this.#circularity_lock = true; | ||
this.#state = fun(structuredClone(this.#state)); | ||
this.#readable = this.#make_frozen_clone(); | ||
this.#onChange.publish(); | ||
this.#circularity_lock = false; | ||
} | ||
@@ -572,0 +577,0 @@ slice({ getter, setter }) { |
@@ -1,5 +0,5 @@ | ||
Array.prototype.at=function(t){return t>=0?this[t]:this[this.length+t]};const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),r=new WeakMap;let n=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=r.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&r.set(s,t))}return t}toString(){return this.cssText}};const i=(t,...e)=>{const r=1===t.length?t[0]:e.reduce(((e,s,r)=>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[r+1]),t[0]);return new n(r,t,s)},o=(s,r)=>{if(e)s.adoptedStyleSheets=r.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of r){const r=document.createElement("style"),n=t.litNonce;void 0!==n&&r.setAttribute("nonce",n),r.textContent=e.cssText,s.appendChild(r)}},a=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:c,defineProperty:h,getOwnPropertyDescriptor:l,getOwnPropertyNames:u,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,f=globalThis,g=f.trustedTypes,$=g?g.emptyScript:"",_=f.reactiveElementPolyfillSupport,m=(t,e)=>t,y={toAttribute(t,e){switch(e){case Boolean:t=t?$: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}},b=(t,e)=>!c(t,e),w={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:b};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class v 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=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(t,s,e);void 0!==r&&h(this.prototype,t,r)}}static getPropertyDescriptor(t,e,s){const{get:r,set:n}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return r?.call(this)},set(e){const i=r?.call(this);n.call(this,e),this.requestUpdate(t,i,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(m("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(m("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(m("properties"))){const t=this.properties,e=[...u(t),...d(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(a(t))}else void 0!==t&&e.push(a(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._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$ES??=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$ES?.splice(this._$ES.indexOf(t)>>>0,1)}_$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 o(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$ES?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$ES?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EO(t,e){const s=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,s);if(void 0!==r&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:y).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,r=s._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=s.getPropertyOptions(r),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:y;this._$Em=r,this[r]=n.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s,r=!1,n){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??b)(r?n:this[t],e))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(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 _$EP(){this.isUpdatePending=!0;try{await this._$Eg}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._$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.C(e,this[e],s)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$ES?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$ET()}catch(e){throw t=!1,this._$ET(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$ES?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EO(t,this[t]))),this._$ET()}updated(t){}firstUpdated(t){}}v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[m("elementProperties")]=new Map,v[m("finalized")]=new Map,_?.({ReactiveElement:v}),(f.reactiveElementVersions??=[]).push("2.0.0");const A=globalThis,S=A.trustedTypes,x=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,E="$lit$",k=`lit$${(Math.random()+"").slice(9)}$`,C="?"+k,M=`<${C}>`,P=document,U=()=>P.createComment(""),O=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,N="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j=/-->/g,R=/>/g,z=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),q=/'/g,D=/"/g,L=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),I=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),W=new WeakMap,Z=P.createTreeWalker(P,129);function J(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==x?x.createHTML(e):e}const K=(t,e)=>{const s=t.length-1,r=[];let n,i=2===e?"<svg>":"",o=H;for(let e=0;e<s;e++){const s=t[e];let a,c,h=-1,l=0;for(;l<s.length&&(o.lastIndex=l,c=o.exec(s),null!==c);)l=o.lastIndex,o===H?"!--"===c[1]?o=j:void 0!==c[1]?o=R:void 0!==c[2]?(L.test(c[2])&&(n=RegExp("</"+c[2],"g")),o=z):void 0!==c[3]&&(o=z):o===z?">"===c[0]?(o=n??H,h=-1):void 0===c[1]?h=-2:(h=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?z:'"'===c[3]?D:q):o===D||o===q?o=z:o===j||o===R?o=H:(o=z,n=void 0);const u=o===z&&t[e+1].startsWith("/>")?" ":"";i+=o===H?s+M:h>=0?(r.push(a),s.slice(0,h)+E+s.slice(h)+k+u):s+k+(-2===h?e:u)}return[J(t,i+(t[s]||"<?>")+(2===e?"</svg>":"")),r]};class G{constructor({strings:t,_$litType$:e},s){let r;this.parts=[];let n=0,i=0;const o=t.length-1,a=this.parts,[c,h]=K(t,e);if(this.el=G.createElement(c,s),Z.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=Z.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(E)){const e=h[i++],s=r.getAttribute(t).split(k),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:n,name:o[2],strings:s,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?st:Y}),r.removeAttribute(t)}else t.startsWith(k)&&(a.push({type:6,index:n}),r.removeAttribute(t));if(L.test(r.tagName)){const t=r.textContent.split(k),e=t.length-1;if(e>0){r.textContent=S?S.emptyScript:"";for(let s=0;s<e;s++)r.append(t[s],U()),Z.nextNode(),a.push({type:2,index:++n});r.append(t[e],U())}}}else if(8===r.nodeType)if(r.data===C)a.push({type:2,index:n});else{let t=-1;for(;-1!==(t=r.data.indexOf(k,t+1));)a.push({type:7,index:n}),t+=k.length-1}n++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,r){if(e===I)return e;let n=void 0!==r?s._$Co?.[r]:s._$Cl;const i=O(e)?void 0:e._$litDirective$;return n?.constructor!==i&&(n?._$AO?.(!1),void 0===i?n=void 0:(n=new i(t),n._$AT(t,s,r)),void 0!==r?(s._$Co??=[])[r]=n:s._$Cl=n),void 0!==n&&(e=Q(t,n._$AS(t,e.values),n,r)),e}class F{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,r=(t?.creationScope??P).importNode(e,!0);Z.currentNode=r;let n=Z.nextNode(),i=0,o=0,a=s[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new X(n,n.nextSibling,this,t):1===a.type?e=new a.ctor(n,a.name,a.strings,this,t):6===a.type&&(e=new rt(n,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(n=Z.nextNode(),i++)}return Z.currentNode=P,r}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 X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,r){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=r,this._$Cv=r?.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=Q(this,t,e),O(t)?t===V||null==t||""===t?(this._$AH!==V&&this._$AR(),this._$AH=V):t!==this._$AH&&t!==I&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>T(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==V&&O(this._$AH)?this._$AA.nextSibling.data=t:this.$(P.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=G.createElement(J(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new F(r,this),s=t.u(this.options);t.p(e),this.$(s),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new G(t)),e}T(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,r=0;for(const n of t)r===e.length?e.push(s=new X(this.k(U()),this.k(U()),this,this.options)):s=e[r],s._$AI(n),r++;r<e.length&&(this._$AR(s&&s._$AB.nextSibling,r),e.length=r)}_$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 Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,r,n){this.type=1,this._$AH=V,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=V}_$AI(t,e=this,s,r){const n=this.strings;let i=!1;if(void 0===n)t=Q(this,t,e,0),i=!O(t)||t!==this._$AH&&t!==I,i&&(this._$AH=t);else{const r=t;let o,a;for(t=n[0],o=0;o<n.length-1;o++)a=Q(this,r[s+o],e,o),a===I&&(a=this._$AH[o]),i||=!O(a)||a!==this._$AH[o],a===V?t=V:t!==V&&(t+=(a??"")+n[o+1]),this._$AH[o]=a}i&&!r&&this.j(t)}j(t){t===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class tt extends Y{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===V?void 0:t}}class et extends Y{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==V)}}class st extends Y{constructor(t,e,s,r,n){super(t,e,s,r,n),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===I)return;const s=this._$AH,r=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==V&&(s===V||r);r&&this.element.removeEventListener(this.name,this,s),n&&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 rt{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){Q(this,t)}}const nt=A.litHtmlPolyfillSupport;nt?.(G,X),(A.litHtmlVersions??=[]).push("3.0.0");const it=(t,e,s)=>{const r=s?.renderBefore??e;let n=r._$litPart$;if(void 0===n){const t=s?.renderBefore??null;r._$litPart$=n=new X(e.insertBefore(U(),t),t,void 0,s??{})}return n._$AI(t),n};let ot=class extends v{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=it(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return I}};ot._$litElement$=!0,ot.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:ot});const at=globalThis.litElementPolyfillSupport;at?.({LitElement:ot}),(globalThis.litElementVersions??=[]).push("4.0.0");class ct{#t=!1;lock(t){this.#t=!0,t(),this.#t=!1}get locked(){return this.#t}}const ht=()=>new Map,lt=()=>new Set;function ut(t){return new dt(t)}class dt{map;constructor(t){this.map=t}grab(t,e){const{map:s}=this;if(s.has(t))return s.get(t);{const r=e();return s.set(t,r),r}}}class pt{#e=new WeakMap;grab_keymap(t){const e=ut(this.#e).grab(t,ht);return{keymap:e,grab_symbolmap:t=>ut(e).grab(t,ht)}}clear(){this.#e=new WeakMap}}class ft{#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 gt{#r=[];record(t){const e=ht();return this.#r.push(e),t(),this.#r.pop(),e}record_that_key_was_accessed(t,e){const s=this.#r.at(-1);if(s){ut(s).grab(t,lt).add(e)}}}class $t extends Error{name=this.constructor.name}class _t extends $t{constructor(t){super(`forbidden circularity, rejected assignment to "${t}"`)}}class mt extends $t{constructor(t){super(`forbidden assignment to readonly property "${t}"`)}}function yt(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new mt(e)}})}function bt(t,e){let s,r,n=[];function i(){s=[],r&&clearTimeout(r),r=void 0,n=[]}return i(),(...o)=>{s=o,r&&clearTimeout(r);const a=new Promise(((t,e)=>{n.push({resolve:t,reject:e})}));return r=setTimeout((()=>{Promise.resolve().then((()=>e(...s))).then((t=>{for(const{resolve:e}of n)e(t);i()})).catch((t=>{for(const{reject:e}of n)e(t);i()}))}),t),a}}class wt{#n=new Map;#i=Promise.resolve();#o=bt(0,(()=>{const t=[...this.#n.values()];this.#n.clear();for(const e of t)e()}));get wait(){return this.#i}add(t,e){this.#n.set(t,e),this.#i=this.#o()}}function vt(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function At(t,e,s,r){const n=[];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,r),n.push((()=>i.delete(t)))}}return()=>n.forEach((t=>t()))}class St{static readonly=yt;static collectivize=vt;#a=new pt;#c=new gt;#h=new ct;#l=new ft;#u=new wt;#d=function(t,e,s,r,n){function i([n,i]){if(s.lock(i.responder),i.discover){r.stop(n);const o=e.record((()=>s.lock(i.collector)));r.add(n,At(n,o,t,i))}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,r,o)=>{if(s.locked)throw new _t(r);e[r]=o;const a=[...t.grab_keymap(e).grab_symbolmap(r)];for(const t of a){const[e,s]=t;s.debounce?n.add(e,(()=>i(t))):i(t)}return!0}}}(this.#a,this.#c,this.#h,this.#l,this.#u);get wait(){return this.#u.wait}state(t){return new Proxy(t,this.#d)}manual(t){const e=Symbol(),s=this.#c.record((()=>this.#h.lock(t.collector)));return this.#l.add(e,At(e,s,this.#a,t)),()=>this.#l.stop(e)}auto({debounce:t,discover:e,collector:s,responder:r}){return this.manual({debounce:t,discover:e,collector:s,responder:r?()=>r(s()):s})}reaction(t,e){return this.auto({debounce:!0,discover:!1,collector:t,responder:e})}deepReaction(t,e){return this.auto({debounce:!0,discover:!0,collector:t,responder:e})}clear(){this.#a.clear()}}var xt;!function(t){var e;t.map=(t,e)=>Object.fromEntries(Object.entries(t).map((([t,s])=>[t,e(s,t)]))),t.filter=(t,e)=>Object.fromEntries(Object.entries(t).filter((([t,s])=>e(s,t)))),(e=t.pipe||(t.pipe={})).map=e=>s=>t.map(s,e),e.filter=e=>s=>t.filter(s,e)}(xt||(xt={}));class Et extends Error{name=this.constructor.name}class kt{#p;#f=!1;#i;#g=new Set;accessed=!1;constructor(t){this.#p=t,this.#i=Promise.resolve(t)}subscribe(t){return this.#g.add(t),()=>{this.#g.delete(t)}}clear(){return this.#g.clear()}#$=bt(0,(()=>{const t=this.#p;this.#f=!0;for(const e of this.#g)e(t);return this.#f=!1,t}));async publish(){this.#i=this.#$(),await this.#i}get wait(){return this.#i}get value(){return this.accessed=!0,this.#p}set value(t){if(this.#f)throw new Et("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p=t,this.publish()}}const Ct=Error;var Mt;!function(t){function e(t,e){switch(t.mode){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 Ct("invalid op mode")}}t.loading=()=>({mode:"loading"}),t.error=t=>({mode:"error",reason:t}),t.ready=t=>({mode:"ready",payload:t}),t.is=Object.freeze({loading:t=>"loading"===t.mode,error:t=>"error"===t.mode,ready:t=>"ready"===t.mode}),t.payload=function(t){return"ready"===t.mode?t.payload:void 0},t.select=e,t.run=async function(e,s){e(t.loading());try{const r=await s();return e(t.ready(r)),r}catch(s){const r=s instanceof Ct?s.message:"string"==typeof s?s:"error";e(t.error(r))}},t.morph=function(s,r){return e(s,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(r(e))})}}(Mt||(Mt={}));class Pt extends kt{constructor(){super(Mt.loading())}async run(t){return Mt.run((t=>this.value=t),t)}setLoading(){this.value=Mt.loading()}setError(t){this.value=Mt.error(t)}setReady(t){this.value=Mt.ready(t)}get loading(){return Mt.is.loading(this.value)}get error(){return Mt.is.error(this.value)}get ready(){return Mt.is.ready(this.value)}get payload(){return Mt.payload(this.value)}select(t){return Mt.select(this.value,t)}}class Ut{#_=new Set;#m=new Set;signal(t){const e=new kt(t);return this.#_.add(e),e}computed(t){const e=this.signal(t());return this.track((()=>{e.value=t()})),e}op(){const t=new Pt;return this.#_.add(t),t}many(t){return xt.map(t,(t=>this.signal(t)))}track(t,e=t){const s=bt(0,e),r=[];for(const t of this.#_)t.accessed=!1;t();for(const t of this.#_)t.accessed&&r.push(t);const n=r.map((t=>t.subscribe((()=>{const t=s();this.#m.add(t)}))));return()=>n.forEach((t=>t()))}get wait(){return Promise.all([...this.#_].map((t=>t.wait))).then((()=>Promise.all([...this.#m]))).then((()=>{this.#m.clear()}))}}class Ot{#y;constructor(t){this.#y=t}get state(){return this.#y.getter(this.#y.parent.state)}transmute(t){this.#y.parent.transmute((e=>{const s=this.#y.getter(e),r=t(s);return this.#y.setter(e,r)}))}slice({getter:t,setter:e}){return new Ot({parent:this,getter:t,setter:e})}}function Tt(t){return null===t||"object"!=typeof t?t:(Object.values(t).forEach((t=>{"object"==typeof t&&null!==t&&Tt(t)})),Object.freeze(t))}class Nt{#b;#w;#v(){return Tt(structuredClone(this.#b))}constructor(t,e=(()=>{})){this.#b=t,this.#w=this.#v(),this.#A(e)}#A=function(){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}();get state(){return this.#w}transmute(t){this.#b=t(this.#b),this.#w=this.#v(),this.#A.publish()}slice({getter:t,setter:e}){return new Ot({parent:this,getter:t,setter:e})}}const Ht=(t,e)=>{if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const s=Object.keys(t),r=Object.keys(e);if(s.length!==r.length)return!1;for(const n of s){if(!r.includes(n))return!1;if(!Ht(t[n],e[n]))return!1}return!0};class jt{#S=new Set;#g=new Set;#x=new Map;dispatch(){for(const t of this.#S)t();for(const t of this.#g)t()}computed(t){let e=t();return this.#S.add((()=>{e=t()})),{get value(){return e}}}track(t,e){let s=!0;const r=()=>{const r=t(),n=this.#x.get(t);!s&&Ht(r,n)||(s=!1,this.#x.set(t,r),e(r))};return r(),this.#g.add(r),t()}stateTree(t){return new Nt(t,(()=>this.dispatch()))}}class Rt{theme=i``;flat=new St;tower=new Ut;watch=new jt}class zt{static with(t){return new this(t)}#E;constructor(t){this.#E=t}to(t){return new zt(t(this.#E))}done(){return this.#E}}class qt extends(function(t){return class extends t{#k=(new Set).add((()=>this.setup()));#C=new Set;register_setup(t){this.#k.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#k)this.#C.add(t())}disconnectedCallback(){for(const t of this.#C)t();this.#C.clear()}}}(HTMLElement)){}function Dt(){let t,e;return{promise:new Promise(((s,r)=>{t=s,e=r})),resolve:t,reject:e}}function Lt(t,e){o(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(a(t))}else void 0!==t&&e.push(a(t));return e}(e))}class Bt extends qt{static get styles(){}#M;#P=Dt();#i=this.#P.promise;init(){}constructor(){super(),this.#M=this.attachShadow({mode:"open"});const t=this.constructor;Lt(this.#M,t.styles),this.init()}get root(){return this.#M}get updateComplete(){return this.#i.then((()=>!0))}render(){}#U=bt(0,(()=>{const t=this.#M,e=this.render();e&&it(e,t,{host:this})}));async requestUpdate(){const t=this.#U();return this.#P&&(t.then(this.#P.resolve),this.#P=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class It{static wrap(t,e){return(...s)=>(t.#O.value=0,e(...s))}static disconnect(t){for(const e of t.#C)e();t.#C.clear();for(const e of t.#T)e();t.#T.clear(),t.#N.clear()}static reconnect(t){for(const e of t.#k.values())t.#C.add(e());for(const[e,s]of t.#H.entries()){const[r,n]=s();t.#N.set(e,r),t.#T.add(n)}}#j;#R;#O={value:0};#k=new Map;#C=new Set;#H=new Map;#N=new Map;#T=new Set;#z=new Map;#q=new Map;#D=new Map;#_=new Map;constructor(t,e){this.#R=t,this.#j=e}get context(){return this.#j}rerender(){this.#R()}setup(t){const e=this.#O.value;this.#k.has(e)||(this.#k.set(e,t),this.#C.add(t()))}init(t){const e=this.#O.value;if(!this.#H.has(e)){this.#H.set(e,t);const[s,r]=t();return this.#N.set(e,s),this.#T.add(r),s}return this.#N.get(e)}prepare(t){const e=this.#O.value++;return ut(this.#q).grab(e,t)}state(t){const e=this.#O.value++;return[ut(this.#z).grab(e,(()=>"function"==typeof t?t():t)),t=>{this.#z.set(e,t),this.#R()},()=>this.#z.get(e)]}flatstate(t){const e=this.#O.value++;return ut(this.#D).grab(e,(()=>this.#j.flat.state("function"==typeof t?t():t)))}signal(t){const e=this.#O.value++;return ut(this.#_).grab(e,(()=>this.#j.tower.signal("function"==typeof t?t():t)))}computed(t){const e=this.#O.value++;return ut(this.#_).grab(e,(()=>this.#j.tower.computed(t)))}op(){const t=this.#O.value++;return ut(this.#_).grab(t,(()=>this.#j.tower.op()))}#L=new Map;watch(t){const e=this.#O.value++;return ut(this.#L).grab(e,(()=>this.#j.watch.track(t,(t=>{this.#L.set(e,t),this.#R()}))))}}class Vt extends It{#B;get element(){return this.#B}#I;get shadow(){return this.#I}constructor(t,e,s,r){super(s,r),this.#B=t,this.#I=e}}var Wt;function Zt(t){let e;return function(s){return e||(e=Wt.base(t,s)),e}}!function(t){function e(t,e){const s=new MutationObserver(e);return s.observe(t,{attributes:!0}),()=>s.disconnect()}t.proxy=(t,e)=>new Proxy(e,{get:(s,r)=>{const n=e[r],i=t.getAttribute(r);switch(n){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 "${r}"`)}},set:(s,r,n)=>{switch(e[r]){case String:return t.setAttribute(r,n),!0;case Number:return t.setAttribute(r,n.toString()),!0;case Boolean:return n?t.setAttribute(r,""):t.removeAttribute(r),!0;default:throw new Error(`invalid attribute type for "${r}"`)}}}),t.on_change=e,t.base=function(s,r){return e(s,(()=>s.requestUpdate())),t.proxy(s,r)}}(Wt||(Wt={}));class Jt extends Vt{attrs;constructor(t,e,s,r){super(t,e,s,r),this.attrs=Zt(t)}}class Kt extends It{#B;get element(){return this.#B}attrs;constructor(t,e,s){super(e,s),this.#B=t,this.attrs=Zt(t)}}class Gt extends Jt{}class Qt extends Kt{}class Ft extends It{}class Xt extends Vt{}function Yt(t,e,s){let r,n;return function(...i){let o;return n&&n(),n=t.flat.manual({debounce:!0,discover:!1,collector:()=>{o=function(...n){let i;return r&&r(),r=t.tower.track((()=>{i=e(...n)}),s),i}(...i)},responder:s}),o}}const te=t=>(e,s)=>class extends Bt{static name=e.name;static get styles(){return[t.theme,e.styles??i``]}#V=new Gt(this,this.root,(()=>{this.requestUpdate()}),t);#W=Gt.wrap(this.#V,(()=>s(this.#V)));#Z=Yt(t,this.#W,(()=>{this.requestUpdate()}));render(){return this.#Z()}connectedCallback(){super.connectedCallback(),Gt.reconnect(this.#V)}disconnectedCallback(){super.disconnectedCallback(),Gt.disconnect(this.#V)}};class ee extends qt{#P=Dt();#i=this.#P.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#i.then((()=>!0))}render(){}#U=bt(0,(()=>{const t=this.render();it(t,this,{host:this})}));async requestUpdate(){const t=this.#U();return this.#P&&(t.then(this.#P.resolve),this.#P=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}const se=t=>e=>class extends ee{#V=new Qt(this,(()=>{this.requestUpdate()}),t);#W=Qt.wrap(this.#V,(()=>e(this.#V)));#Z=Yt(t,this.#W,(()=>{this.requestUpdate()}));render(){return this.#Z()}connectedCallback(){super.connectedCallback(),Qt.reconnect(this.#V)}disconnectedCallback(){super.disconnectedCallback(),Qt.disconnect(this.#V)}},re=2;class ne{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)}}const ie=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),ie(t,e);return!0},oe=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},ae=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),le(e)}};function ce(t){void 0!==this._$AN?(oe(this),this._$AM=t,ae(this)):this._$AM=t}function he(t,e=!1,s=0){const r=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(e)if(Array.isArray(r))for(let t=s;t<r.length;t++)ie(r[t],!1),oe(r[t]);else null!=r&&(ie(r,!1),oe(r));else ie(this,t)}const le=t=>{t.type==re&&(t._$AP??=he,t._$AQ??=ce)};class ue extends ne{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),ae(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(ie(this,t),oe(this))}setValue(t){if((t=>void 0===t.strings)(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(){}}const de=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends ue{#J;#R=bt(0,(()=>{this.#J&&this.setValue(this.render(...this.#J))}));#V=new Ft(this.#R,t);#W=Ft.wrap(this.#V,e(this.#V));#Z=Yt(t,this.#W,this.#R);render(...t){return this.#J=t,this.#Z(...t)}reconnected(){Ft.reconnect(this.#V)}disconnected(){Ft.disconnect(this.#V)}});var pe;function fe(t){return[t].flat().filter((t=>!!t))}!function(t){t.css=function(...t){return function(e){return class extends e{static get styles(){return $e(e.styles,t)}}}},t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return $e(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#K=[];connectedCallback(){super.connectedCallback(),this.#K.push(t.track((()=>this.render()),(()=>this.requestUpdate())))}disconnectedCallback(){super.disconnectedCallback();for(const t of this.#K)t();this.#K=[]}}}},t.flat=function(t){return function(e){return class extends e{#G=void 0;render(){let e;return this.#G&&this.#G(),this.#G=t.manual({debounce:!1,discover:!1,collector:()=>{e=super.render()},responder:()=>{this.requestUpdate()}}),e}disconnectedCallback(){super.disconnectedCallback(),this.#G&&this.#G(),this.#G=void 0}}}}}(pe||(pe={}));const ge=t=>void 0!==t;function $e(t,e){return[...fe(t)??[],...fe(e)].flat().filter(ge)}const _e=t=>{for(const[e,s]of Object.entries(t))customElements.define(e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase(),s)};class me extends HTMLElement{static tag="obsidian-view"}function ye(...t){const e=new Set,s=t.map((t=>t??"")).flatMap(be);for(const t of s)e.add(t);return e}function be(t){return t.split(/\s+/).map((t=>t.trim())).filter((t=>!!t))}function we(t){return t.split(",").map((t=>t.trim())).filter((t=>!!t)).map((t=>t.includes(":")?t.split(":").map((t=>t.trim()))[1]:t))}function ve(t,e){const s=ye(t.getAttribute("part")),r=ye(t.getAttribute("data-gpart")),n=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([...n.part.flatMap(be),...n.exportparts.flatMap(we)]),o=new Set([...n.gpart.flatMap(be),...n.gexportparts.flatMap(be)]);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,...[...r].flatMap((t=>[...i].map((e=>`${t}-${e}`))))].join(" "))}function Ae(t,e={},s={}){const{content:r,attrs:n={}}=e,{attrs:i={}}=s;function o(e,s,r,n){e!==s&&(void 0===e?t.removeAttribute(r):t.setAttribute(r,n()))}n&&function(t,e){for(const[s,r]of Object.entries(e))"string"==typeof r?t.setAttribute(s,r):"number"==typeof r?t.setAttribute(s,r.toString()):"boolean"==typeof r?!0===r?t.setAttribute(s,""):t.removeAttribute(s):void 0===r?t.removeAttribute(s):console.warn(`invalid attribute type ${s} is ${typeof r}`)}(t,n),o(n.class,i?.class,"class",(()=>n.class)),o(n.part,i?.part,"part",(()=>n.part)),o(n.gpart,i?.gpart,"data-gpart",(()=>n.gpart)),r&&it(r,t,{host:t})}_e({ObsidianView:me});const Se=t=>(e={},s)=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends ue{#E;#M=function(t,e){const s=document.createElement(me.tag);s.setAttribute("view",t);const r=s.attachShadow({mode:"open"});Lt(r,e);let n=!1;return{container:s,shadow:r,set auto_exportparts(t){n=t},render_into_shadow:t=>(it(t,r),n&&ve(s,r),s)}}(e.name??"",[t.theme,e.styles??i``]);#R=bt(0,(()=>{this.#E&&this.setValue(this.#M.render_into_shadow(this.render(this.#E)))}));#V=new Xt(this.#M.container,this.#M.shadow,this.#R,t);#W=Xt.wrap(this.#V,s(this.#V));#Z=Yt(t,this.#W,this.#R);update(t,e){return this.#M.render_into_shadow(this.render(...e))}render(t){return Ae(this.#M.container,t.meta,this.#E?.meta),this.#E=t,this.#M.auto_exportparts=t.meta.auto_exportparts??e.auto_exportparts??!0,this.#Z(...t.props)}reconnected(){Xt.reconnect(this.#V)}disconnected(){Xt.disconnect(this.#V)}});const xe=new class extends Rt{},{oxygen:Ee,carbon:ke,quartz:Ce,obsidian:Me,component:Pe}={oxygen:se(Ue=xe),carbon:te(Ue),quartz:de(Ue),obsidian:Se(Ue),component:t=>zt.with(t(Ue)).to(pe.css_deferred((()=>[Ue.theme]))).to(pe.flat(Ue.flat)).to(pe.signals(Ue.tower)).done()};var Ue;const Oe=Pe((t=>class extends Bt{static styles=i`span {color: orange}`;#b=t.flat.state({count:0});render(){return B` | ||
Array.prototype.at=function(t){return t>=0?this[t]:this[this.length+t]};const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),r=new WeakMap;let n=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=r.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&r.set(s,t))}return t}toString(){return this.cssText}};const i=(t,...e)=>{const r=1===t.length?t[0]:e.reduce(((e,s,r)=>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[r+1]),t[0]);return new n(r,t,s)},o=(s,r)=>{if(e)s.adoptedStyleSheets=r.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of r){const r=document.createElement("style"),n=t.litNonce;void 0!==n&&r.setAttribute("nonce",n),r.textContent=e.cssText,s.appendChild(r)}},a=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:c,defineProperty:h,getOwnPropertyDescriptor:l,getOwnPropertyNames:u,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,f=globalThis,_=f.trustedTypes,g=_?_.emptyScript:"",$=f.reactiveElementPolyfillSupport,m=(t,e)=>t,y={toAttribute(t,e){switch(e){case Boolean:t=t?g: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}},b=(t,e)=>!c(t,e),w={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:b};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class v 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=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(t,s,e);void 0!==r&&h(this.prototype,t,r)}}static getPropertyDescriptor(t,e,s){const{get:r,set:n}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return r?.call(this)},set(e){const i=r?.call(this);n.call(this,e),this.requestUpdate(t,i,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(m("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(m("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(m("properties"))){const t=this.properties,e=[...u(t),...d(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(a(t))}else void 0!==t&&e.push(a(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._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$ES??=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$ES?.splice(this._$ES.indexOf(t)>>>0,1)}_$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 o(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$ES?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$ES?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EO(t,e){const s=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,s);if(void 0!==r&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:y).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,r=s._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=s.getPropertyOptions(r),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:y;this._$Em=r,this[r]=n.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s,r=!1,n){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??b)(r?n:this[t],e))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(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 _$EP(){this.isUpdatePending=!0;try{await this._$Eg}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._$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.C(e,this[e],s)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$ES?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$ET()}catch(e){throw t=!1,this._$ET(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$ES?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EO(t,this[t]))),this._$ET()}updated(t){}firstUpdated(t){}}v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[m("elementProperties")]=new Map,v[m("finalized")]=new Map,$?.({ReactiveElement:v}),(f.reactiveElementVersions??=[]).push("2.0.0");const A=globalThis,S=A.trustedTypes,k=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,x="$lit$",E=`lit$${(Math.random()+"").slice(9)}$`,C="?"+E,M=`<${C}>`,P=document,U=()=>P.createComment(""),O=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,N="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j=/-->/g,R=/>/g,z=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),q=/'/g,D=/"/g,L=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),I=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),W=new WeakMap,Z=P.createTreeWalker(P,129);function J(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==k?k.createHTML(e):e}const K=(t,e)=>{const s=t.length-1,r=[];let n,i=2===e?"<svg>":"",o=H;for(let e=0;e<s;e++){const s=t[e];let a,c,h=-1,l=0;for(;l<s.length&&(o.lastIndex=l,c=o.exec(s),null!==c);)l=o.lastIndex,o===H?"!--"===c[1]?o=j:void 0!==c[1]?o=R:void 0!==c[2]?(L.test(c[2])&&(n=RegExp("</"+c[2],"g")),o=z):void 0!==c[3]&&(o=z):o===z?">"===c[0]?(o=n??H,h=-1):void 0===c[1]?h=-2:(h=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?z:'"'===c[3]?D:q):o===D||o===q?o=z:o===j||o===R?o=H:(o=z,n=void 0);const u=o===z&&t[e+1].startsWith("/>")?" ":"";i+=o===H?s+M:h>=0?(r.push(a),s.slice(0,h)+x+s.slice(h)+E+u):s+E+(-2===h?e:u)}return[J(t,i+(t[s]||"<?>")+(2===e?"</svg>":"")),r]};class G{constructor({strings:t,_$litType$:e},s){let r;this.parts=[];let n=0,i=0;const o=t.length-1,a=this.parts,[c,h]=K(t,e);if(this.el=G.createElement(c,s),Z.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=Z.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(x)){const e=h[i++],s=r.getAttribute(t).split(E),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:n,name:o[2],strings:s,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?st:Y}),r.removeAttribute(t)}else t.startsWith(E)&&(a.push({type:6,index:n}),r.removeAttribute(t));if(L.test(r.tagName)){const t=r.textContent.split(E),e=t.length-1;if(e>0){r.textContent=S?S.emptyScript:"";for(let s=0;s<e;s++)r.append(t[s],U()),Z.nextNode(),a.push({type:2,index:++n});r.append(t[e],U())}}}else if(8===r.nodeType)if(r.data===C)a.push({type:2,index:n});else{let t=-1;for(;-1!==(t=r.data.indexOf(E,t+1));)a.push({type:7,index:n}),t+=E.length-1}n++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,r){if(e===I)return e;let n=void 0!==r?s._$Co?.[r]:s._$Cl;const i=O(e)?void 0:e._$litDirective$;return n?.constructor!==i&&(n?._$AO?.(!1),void 0===i?n=void 0:(n=new i(t),n._$AT(t,s,r)),void 0!==r?(s._$Co??=[])[r]=n:s._$Cl=n),void 0!==n&&(e=Q(t,n._$AS(t,e.values),n,r)),e}class F{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,r=(t?.creationScope??P).importNode(e,!0);Z.currentNode=r;let n=Z.nextNode(),i=0,o=0,a=s[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new X(n,n.nextSibling,this,t):1===a.type?e=new a.ctor(n,a.name,a.strings,this,t):6===a.type&&(e=new rt(n,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(n=Z.nextNode(),i++)}return Z.currentNode=P,r}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 X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,r){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=r,this._$Cv=r?.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=Q(this,t,e),O(t)?t===V||null==t||""===t?(this._$AH!==V&&this._$AR(),this._$AH=V):t!==this._$AH&&t!==I&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>T(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==V&&O(this._$AH)?this._$AA.nextSibling.data=t:this.$(P.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=G.createElement(J(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new F(r,this),s=t.u(this.options);t.p(e),this.$(s),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new G(t)),e}T(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,r=0;for(const n of t)r===e.length?e.push(s=new X(this.k(U()),this.k(U()),this,this.options)):s=e[r],s._$AI(n),r++;r<e.length&&(this._$AR(s&&s._$AB.nextSibling,r),e.length=r)}_$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 Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,r,n){this.type=1,this._$AH=V,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=V}_$AI(t,e=this,s,r){const n=this.strings;let i=!1;if(void 0===n)t=Q(this,t,e,0),i=!O(t)||t!==this._$AH&&t!==I,i&&(this._$AH=t);else{const r=t;let o,a;for(t=n[0],o=0;o<n.length-1;o++)a=Q(this,r[s+o],e,o),a===I&&(a=this._$AH[o]),i||=!O(a)||a!==this._$AH[o],a===V?t=V:t!==V&&(t+=(a??"")+n[o+1]),this._$AH[o]=a}i&&!r&&this.j(t)}j(t){t===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class tt extends Y{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===V?void 0:t}}class et extends Y{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==V)}}class st extends Y{constructor(t,e,s,r,n){super(t,e,s,r,n),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===I)return;const s=this._$AH,r=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==V&&(s===V||r);r&&this.element.removeEventListener(this.name,this,s),n&&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 rt{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){Q(this,t)}}const nt=A.litHtmlPolyfillSupport;nt?.(G,X),(A.litHtmlVersions??=[]).push("3.0.0");const it=(t,e,s)=>{const r=s?.renderBefore??e;let n=r._$litPart$;if(void 0===n){const t=s?.renderBefore??null;r._$litPart$=n=new X(e.insertBefore(U(),t),t,void 0,s??{})}return n._$AI(t),n};let ot=class extends v{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=it(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return I}};ot._$litElement$=!0,ot.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:ot});const at=globalThis.litElementPolyfillSupport;at?.({LitElement:ot}),(globalThis.litElementVersions??=[]).push("4.0.0");class ct{#t=!1;lock(t){this.#t=!0,t(),this.#t=!1}get locked(){return this.#t}}const ht=()=>new Map,lt=()=>new Set;function ut(t){return new dt(t)}class dt{map;constructor(t){this.map=t}grab(t,e){const{map:s}=this;if(s.has(t))return s.get(t);{const r=e();return s.set(t,r),r}}}class pt{#e=new WeakMap;grab_keymap(t){const e=ut(this.#e).grab(t,ht);return{keymap:e,grab_symbolmap:t=>ut(e).grab(t,ht)}}clear(){this.#e=new WeakMap}}class ft{#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 _t{#r=[];record(t){const e=ht();return this.#r.push(e),t(),this.#r.pop(),e}record_that_key_was_accessed(t,e){const s=this.#r.at(-1);if(s){ut(s).grab(t,lt).add(e)}}}class gt extends Error{name=this.constructor.name}class $t extends gt{constructor(t){super(`forbidden circularity, rejected assignment to "${t}"`)}}class mt extends gt{constructor(t){super(`forbidden assignment to readonly property "${t}"`)}}function yt(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new mt(e)}})}function bt(t,e){let s,r,n=[];function i(){s=[],r&&clearTimeout(r),r=void 0,n=[]}return i(),(...o)=>{s=o,r&&clearTimeout(r);const a=new Promise(((t,e)=>{n.push({resolve:t,reject:e})}));return r=setTimeout((()=>{Promise.resolve().then((()=>e(...s))).then((t=>{for(const{resolve:e}of n)e(t);i()})).catch((t=>{for(const{reject:e}of n)e(t);i()}))}),t),a}}class wt{#n=new Map;#i=Promise.resolve();#o=bt(0,(()=>{const t=[...this.#n.values()];this.#n.clear();for(const e of t)e()}));get wait(){return this.#i}add(t,e){this.#n.set(t,e),this.#i=this.#o()}}function vt(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function At(t,e,s,r){const n=[];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,r),n.push((()=>i.delete(t)))}}return()=>n.forEach((t=>t()))}class St{static readonly=yt;static collectivize=vt;#a=new pt;#c=new _t;#h=new ct;#l=new ft;#u=new wt;#d=function(t,e,s,r,n){function i([n,i]){if(s.lock(i.responder),i.discover){r.stop(n);const o=e.record((()=>s.lock(i.collector)));r.add(n,At(n,o,t,i))}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,r,o)=>{if(s.locked)throw new $t(r);e[r]=o;const a=[...t.grab_keymap(e).grab_symbolmap(r)];for(const t of a){const[e,s]=t;s.debounce?n.add(e,(()=>i(t))):i(t)}return!0}}}(this.#a,this.#c,this.#h,this.#l,this.#u);get wait(){return this.#u.wait}state(t){return new Proxy(t,this.#d)}manual(t){const e=Symbol(),s=this.#c.record((()=>this.#h.lock(t.collector)));return this.#l.add(e,At(e,s,this.#a,t)),()=>this.#l.stop(e)}auto({debounce:t,discover:e,collector:s,responder:r}){return this.manual({debounce:t,discover:e,collector:s,responder:r?()=>r(s()):s})}reaction(t,e){return this.auto({debounce:!0,discover:!1,collector:t,responder:e})}deepReaction(t,e){return this.auto({debounce:!0,discover:!0,collector:t,responder:e})}clear(){this.#a.clear()}}var kt;!function(t){var e;t.map=(t,e)=>Object.fromEntries(Object.entries(t).map((([t,s])=>[t,e(s,t)]))),t.filter=(t,e)=>Object.fromEntries(Object.entries(t).filter((([t,s])=>e(s,t)))),(e=t.pipe||(t.pipe={})).map=e=>s=>t.map(s,e),e.filter=e=>s=>t.filter(s,e)}(kt||(kt={}));class xt extends Error{name=this.constructor.name}class Et{#p;#f=!1;#i;#_=new Set;accessed=!1;constructor(t){this.#p=t,this.#i=Promise.resolve(t)}subscribe(t){return this.#_.add(t),()=>{this.#_.delete(t)}}clear(){return this.#_.clear()}#g=bt(0,(()=>{const t=this.#p;this.#f=!0;for(const e of this.#_)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.accessed=!0,this.#p}set value(t){if(this.#f)throw new xt("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p=t,this.publish()}}const Ct=Error;var Mt;!function(t){function e(t,e){switch(t.mode){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 Ct("invalid op mode")}}t.loading=()=>({mode:"loading"}),t.error=t=>({mode:"error",reason:t}),t.ready=t=>({mode:"ready",payload:t}),t.is=Object.freeze({loading:t=>"loading"===t.mode,error:t=>"error"===t.mode,ready:t=>"ready"===t.mode}),t.payload=function(t){return"ready"===t.mode?t.payload:void 0},t.select=e,t.run=async function(e,s){e(t.loading());try{const r=await s();return e(t.ready(r)),r}catch(s){const r=s instanceof Ct?s.message:"string"==typeof s?s:"error";e(t.error(r))}},t.morph=function(s,r){return e(s,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(r(e))})}}(Mt||(Mt={}));class Pt extends Et{constructor(){super(Mt.loading())}async run(t){return Mt.run((t=>this.value=t),t)}setLoading(){this.value=Mt.loading()}setError(t){this.value=Mt.error(t)}setReady(t){this.value=Mt.ready(t)}get loading(){return Mt.is.loading(this.value)}get error(){return Mt.is.error(this.value)}get ready(){return Mt.is.ready(this.value)}get payload(){return Mt.payload(this.value)}select(t){return Mt.select(this.value,t)}}class Ut{#$=new Set;#m=new Set;signal(t){const e=new Et(t);return this.#$.add(e),e}computed(t){const e=this.signal(t());return this.track((()=>{e.value=t()})),e}op(){const t=new Pt;return this.#$.add(t),t}many(t){return kt.map(t,(t=>this.signal(t)))}track(t,e=t){const s=bt(0,e),r=[];for(const t of this.#$)t.accessed=!1;t();for(const t of this.#$)t.accessed&&r.push(t);const n=r.map((t=>t.subscribe((()=>{const t=s();this.#m.add(t)}))));return()=>n.forEach((t=>t()))}get wait(){return Promise.all([...this.#$].map((t=>t.wait))).then((()=>Promise.all([...this.#m]))).then((()=>{this.#m.clear()}))}}class Ot{#y;constructor(t){this.#y=t}get state(){return this.#y.getter(this.#y.parent.state)}transmute(t){this.#y.parent.transmute((e=>{const s=this.#y.getter(e),r=t(s);return this.#y.setter(e,r)}))}slice({getter:t,setter:e}){return new Ot({parent:this,getter:t,setter:e})}}function Tt(t){return null===t||"object"!=typeof t?t:(Object.values(t).forEach((t=>{"object"==typeof t&&null!==t&&Tt(t)})),Object.freeze(t))}class Nt{#b;#w;#v=!1;#A(){return Tt(structuredClone(this.#b))}constructor(t,e=(()=>{})){this.#b=structuredClone(t),this.#w=this.#A(),this.#S(e)}#S=function(){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}();get state(){return this.#w}transmute(t){if(this.#v)throw new Error("circular error");this.#v=!0,this.#b=t(structuredClone(this.#b)),this.#w=this.#A(),this.#S.publish(),this.#v=!1}slice({getter:t,setter:e}){return new Ot({parent:this,getter:t,setter:e})}}const Ht=(t,e)=>{if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const s=Object.keys(t),r=Object.keys(e);if(s.length!==r.length)return!1;for(const n of s){if(!r.includes(n))return!1;if(!Ht(t[n],e[n]))return!1}return!0};class jt{#k=new Set;#_=new Set;#x=new Map;dispatch(){for(const t of this.#k)t();for(const t of this.#_)t()}computed(t){let e=t();return this.#k.add((()=>{e=t()})),{get value(){return e}}}track(t,e){let s=!0;const r=()=>{const r=t(),n=this.#x.get(t);!s&&Ht(r,n)||(s=!1,this.#x.set(t,r),e(r))};return r(),this.#_.add(r),t()}stateTree(t){return new Nt(t,(()=>this.dispatch()))}}class Rt{theme=i``;flat=new St;tower=new Ut;watch=new jt}class zt{static with(t){return new this(t)}#E;constructor(t){this.#E=t}to(t){return new zt(t(this.#E))}done(){return this.#E}}class qt extends(function(t){return class extends t{#C=(new Set).add((()=>this.setup()));#M=new Set;register_setup(t){this.#C.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#C)this.#M.add(t())}disconnectedCallback(){for(const t of this.#M)t();this.#M.clear()}}}(HTMLElement)){}function Dt(){let t,e;return{promise:new Promise(((s,r)=>{t=s,e=r})),resolve:t,reject:e}}function Lt(t,e){o(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(a(t))}else void 0!==t&&e.push(a(t));return e}(e))}class Bt extends qt{static get styles(){}#P;#U=Dt();#i=this.#U.promise;init(){}constructor(){super(),this.#P=this.attachShadow({mode:"open"});const t=this.constructor;Lt(this.#P,t.styles),this.init()}get root(){return this.#P}get updateComplete(){return this.#i.then((()=>!0))}render(){}#O=bt(0,(()=>{const t=this.#P,e=this.render();e&&it(e,t,{host:this})}));async requestUpdate(){const t=this.#O();return this.#U&&(t.then(this.#U.resolve),this.#U=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class It{static wrap(t,e){return(...s)=>(t.#T.value=0,e(...s))}static disconnect(t){for(const e of t.#M)e();t.#M.clear();for(const e of t.#N)e();t.#N.clear(),t.#H.clear()}static reconnect(t){for(const e of t.#C.values())t.#M.add(e());for(const[e,s]of t.#j.entries()){const[r,n]=s();t.#H.set(e,r),t.#N.add(n)}}#R;#z;#T={value:0};#C=new Map;#M=new Set;#j=new Map;#H=new Map;#N=new Set;#q=new Map;#D=new Map;#L=new Map;#$=new Map;constructor(t,e){this.#z=t,this.#R=e}get context(){return this.#R}rerender(){this.#z()}setup(t){const e=this.#T.value;this.#C.has(e)||(this.#C.set(e,t),this.#M.add(t()))}init(t){const e=this.#T.value;if(!this.#j.has(e)){this.#j.set(e,t);const[s,r]=t();return this.#H.set(e,s),this.#N.add(r),s}return this.#H.get(e)}prepare(t){const e=this.#T.value++;return ut(this.#D).grab(e,t)}state(t){const e=this.#T.value++;return[ut(this.#q).grab(e,(()=>"function"==typeof t?t():t)),t=>{this.#q.set(e,t),this.#z()},()=>this.#q.get(e)]}flatstate(t){const e=this.#T.value++;return ut(this.#L).grab(e,(()=>this.#R.flat.state("function"==typeof t?t():t)))}signal(t){const e=this.#T.value++;return ut(this.#$).grab(e,(()=>this.#R.tower.signal("function"==typeof t?t():t)))}computed(t){const e=this.#T.value++;return ut(this.#$).grab(e,(()=>this.#R.tower.computed(t)))}op(){const t=this.#T.value++;return ut(this.#$).grab(t,(()=>this.#R.tower.op()))}#B=new Map;watch(t){const e=this.#T.value++;return ut(this.#B).grab(e,(()=>this.#R.watch.track(t,(t=>{this.#B.set(e,t),this.#z()}))))}}class Vt extends It{#I;get element(){return this.#I}#V;get shadow(){return this.#V}constructor(t,e,s,r){super(s,r),this.#I=t,this.#V=e}}var Wt;function Zt(t){let e;return function(s){return e||(e=Wt.base(t,s)),e}}!function(t){function e(t,e){const s=new MutationObserver(e);return s.observe(t,{attributes:!0}),()=>s.disconnect()}t.proxy=(t,e)=>new Proxy(e,{get:(s,r)=>{const n=e[r],i=t.getAttribute(r);switch(n){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 "${r}"`)}},set:(s,r,n)=>{switch(e[r]){case String:return t.setAttribute(r,n),!0;case Number:return t.setAttribute(r,n.toString()),!0;case Boolean:return n?t.setAttribute(r,""):t.removeAttribute(r),!0;default:throw new Error(`invalid attribute type for "${r}"`)}}}),t.on_change=e,t.base=function(s,r){return e(s,(()=>s.requestUpdate())),t.proxy(s,r)}}(Wt||(Wt={}));class Jt extends Vt{attrs;constructor(t,e,s,r){super(t,e,s,r),this.attrs=Zt(t)}}class Kt extends It{#I;get element(){return this.#I}attrs;constructor(t,e,s){super(e,s),this.#I=t,this.attrs=Zt(t)}}class Gt extends Jt{}class Qt extends Kt{}class Ft extends It{}class Xt extends Vt{}function Yt(t,e,s){let r,n;return function(...i){let o;return n&&n(),n=t.flat.manual({debounce:!0,discover:!1,collector:()=>{o=function(...n){let i;return r&&r(),r=t.tower.track((()=>{i=e(...n)}),s),i}(...i)},responder:s}),o}}const te=t=>(e,s)=>class extends Bt{static name=e.name;static get styles(){return[t.theme,e.styles??i``]}#W=new Gt(this,this.root,(()=>{this.requestUpdate()}),t);#Z=Gt.wrap(this.#W,(()=>s(this.#W)));#J=Yt(t,this.#Z,(()=>{this.requestUpdate()}));render(){return this.#J()}connectedCallback(){super.connectedCallback(),Gt.reconnect(this.#W)}disconnectedCallback(){super.disconnectedCallback(),Gt.disconnect(this.#W)}};class ee extends qt{#U=Dt();#i=this.#U.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#i.then((()=>!0))}render(){}#O=bt(0,(()=>{const t=this.render();it(t,this,{host:this})}));async requestUpdate(){const t=this.#O();return this.#U&&(t.then(this.#U.resolve),this.#U=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}const se=t=>e=>class extends ee{#W=new Qt(this,(()=>{this.requestUpdate()}),t);#Z=Qt.wrap(this.#W,(()=>e(this.#W)));#J=Yt(t,this.#Z,(()=>{this.requestUpdate()}));render(){return this.#J()}connectedCallback(){super.connectedCallback(),Qt.reconnect(this.#W)}disconnectedCallback(){super.disconnectedCallback(),Qt.disconnect(this.#W)}},re=2;class ne{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)}}const ie=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),ie(t,e);return!0},oe=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},ae=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),le(e)}};function ce(t){void 0!==this._$AN?(oe(this),this._$AM=t,ae(this)):this._$AM=t}function he(t,e=!1,s=0){const r=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(e)if(Array.isArray(r))for(let t=s;t<r.length;t++)ie(r[t],!1),oe(r[t]);else null!=r&&(ie(r,!1),oe(r));else ie(this,t)}const le=t=>{t.type==re&&(t._$AP??=he,t._$AQ??=ce)};class ue extends ne{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),ae(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(ie(this,t),oe(this))}setValue(t){if((t=>void 0===t.strings)(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(){}}const de=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends ue{#K;#z=bt(0,(()=>{this.#K&&this.setValue(this.render(...this.#K))}));#W=new Ft(this.#z,t);#Z=Ft.wrap(this.#W,e(this.#W));#J=Yt(t,this.#Z,this.#z);render(...t){return this.#K=t,this.#J(...t)}reconnected(){Ft.reconnect(this.#W)}disconnected(){Ft.disconnect(this.#W)}});var pe;function fe(t){return[t].flat().filter((t=>!!t))}!function(t){t.css=function(...t){return function(e){return class extends e{static get styles(){return ge(e.styles,t)}}}},t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return ge(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#G=[];connectedCallback(){super.connectedCallback(),this.#G.push(t.track((()=>this.render()),(()=>this.requestUpdate())))}disconnectedCallback(){super.disconnectedCallback();for(const t of this.#G)t();this.#G=[]}}}},t.flat=function(t){return function(e){return class extends e{#Q=void 0;render(){let e;return this.#Q&&this.#Q(),this.#Q=t.manual({debounce:!1,discover:!1,collector:()=>{e=super.render()},responder:()=>{this.requestUpdate()}}),e}disconnectedCallback(){super.disconnectedCallback(),this.#Q&&this.#Q(),this.#Q=void 0}}}}}(pe||(pe={}));const _e=t=>void 0!==t;function ge(t,e){return[...fe(t)??[],...fe(e)].flat().filter(_e)}const $e=t=>{for(const[e,s]of Object.entries(t))customElements.define(e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase(),s)};class me extends HTMLElement{static tag="obsidian-view"}function ye(...t){const e=new Set,s=t.map((t=>t??"")).flatMap(be);for(const t of s)e.add(t);return e}function be(t){return t.split(/\s+/).map((t=>t.trim())).filter((t=>!!t))}function we(t){return t.split(",").map((t=>t.trim())).filter((t=>!!t)).map((t=>t.includes(":")?t.split(":").map((t=>t.trim()))[1]:t))}function ve(t,e){const s=ye(t.getAttribute("part")),r=ye(t.getAttribute("data-gpart")),n=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([...n.part.flatMap(be),...n.exportparts.flatMap(we)]),o=new Set([...n.gpart.flatMap(be),...n.gexportparts.flatMap(be)]);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,...[...r].flatMap((t=>[...i].map((e=>`${t}-${e}`))))].join(" "))}function Ae(t,e={},s={}){const{content:r,attrs:n={}}=e,{attrs:i={}}=s;function o(e,s,r,n){e!==s&&(void 0===e?t.removeAttribute(r):t.setAttribute(r,n()))}n&&function(t,e){for(const[s,r]of Object.entries(e))"string"==typeof r?t.setAttribute(s,r):"number"==typeof r?t.setAttribute(s,r.toString()):"boolean"==typeof r?!0===r?t.setAttribute(s,""):t.removeAttribute(s):void 0===r?t.removeAttribute(s):console.warn(`invalid attribute type ${s} is ${typeof r}`)}(t,n),o(n.class,i?.class,"class",(()=>n.class)),o(n.part,i?.part,"part",(()=>n.part)),o(n.gpart,i?.gpart,"data-gpart",(()=>n.gpart)),r&&it(r,t,{host:t})}$e({ObsidianView:me});const Se=t=>(e={},s)=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends ue{#E;#P=function(t,e){const s=document.createElement(me.tag);s.setAttribute("view",t);const r=s.attachShadow({mode:"open"});Lt(r,e);let n=!1;return{container:s,shadow:r,set auto_exportparts(t){n=t},render_into_shadow:t=>(it(t,r),n&&ve(s,r),s)}}(e.name??"",[t.theme,e.styles??i``]);#z=bt(0,(()=>{this.#E&&this.setValue(this.#P.render_into_shadow(this.render(this.#E)))}));#W=new Xt(this.#P.container,this.#P.shadow,this.#z,t);#Z=Xt.wrap(this.#W,s(this.#W));#J=Yt(t,this.#Z,this.#z);update(t,e){return this.#P.render_into_shadow(this.render(...e))}render(t){return Ae(this.#P.container,t.meta,this.#E?.meta),this.#E=t,this.#P.auto_exportparts=t.meta.auto_exportparts??e.auto_exportparts??!0,this.#J(...t.props)}reconnected(){Xt.reconnect(this.#W)}disconnected(){Xt.disconnect(this.#W)}});const ke=new class extends Rt{},{oxygen:xe,carbon:Ee,quartz:Ce,obsidian:Me,component:Pe}={oxygen:se(Ue=ke),carbon:te(Ue),quartz:de(Ue),obsidian:Se(Ue),component:t=>zt.with(t(Ue)).to(pe.css_deferred((()=>[Ue.theme]))).to(pe.flat(Ue.flat)).to(pe.signals(Ue.tower)).done()};var Ue;const Oe=Pe((t=>class extends Bt{static styles=i`span {color: orange}`;#b=t.flat.state({count:0});render(){return B` | ||
<span>${this.#b.count}</span> | ||
<button @click=${()=>this.#b.count++}>gold</button> | ||
`}})),Te=(t,...e)=>B(t,...e.map((t=>t instanceof kt?t.value:t))),Ne=Ce((t=>e=>{const[s,r]=t.state(e),n=t.flatstate({count:e}),i=t.signal(e);return Te` | ||
`}})),Te=(t,...e)=>B(t,...e.map((t=>t instanceof Et?t.value:t))),Ne=Ce((t=>e=>{const[s,r]=t.state(e),n=t.flatstate({count:e}),i=t.signal(e);return Te` | ||
<span>${s}</span> | ||
@@ -19,9 +19,9 @@ <button @click=${()=>r(3*s)}>quartz-a</button> | ||
${He([33])} | ||
`}})),Re=()=>Math.ceil(1e3*Math.random()),ze=ke({styles:i`button { color: green }`},(t=>{const e=t.signal(Re);return Te` | ||
`}})),Re=()=>Math.ceil(1e3*Math.random()),ze=Ee({styles:i`button { color: green }`},(t=>{const e=t.signal(Re);return Te` | ||
<span>${e}</span> | ||
<button @click=${()=>e.value=Re()}>carbon</button> | ||
`})),qe=Ee((t=>{const e=t.signal(256);return Te` | ||
`})),qe=xe((t=>{const e=t.signal(256);return Te` | ||
<span>${e}</span> | ||
<button @click=${()=>e.value-=8}>oxygen</button> | ||
`}));xe.theme=i` | ||
`}));ke.theme=i` | ||
button { | ||
@@ -31,2 +31,2 @@ font-weight: bold; | ||
} | ||
`,_e({SlateCarbon:ze,SlateGold:Oe,SlateOxygen:qe,SlateSilver:je}); | ||
`,$e({SlateCarbon:ze,SlateGold:Oe,SlateOxygen:qe,SlateSilver:je}); |
@@ -24,4 +24,4 @@ import { Context } from "../../../context.js"; | ||
op<T>(): OpSignal<T>; | ||
watch<T>(collector: () => T): any; | ||
watch<T>(collector: () => T): T; | ||
} | ||
export {}; |
import { Slice } from "./slice.js"; | ||
export interface WatchBox<V> { | ||
readonly value: V; | ||
} | ||
export interface SliceAccessors<S, X> { | ||
@@ -3,0 +6,0 @@ getter: (state: S) => X; |
@@ -7,8 +7,9 @@ import { pub } from "../tools/pub.js"; | ||
#readable; | ||
#clone() { | ||
#circularity_lock = false; | ||
#make_frozen_clone() { | ||
return deepFreeze(structuredClone(this.#state)); | ||
} | ||
constructor(state, handleChange = () => { }) { | ||
this.#state = state; | ||
this.#readable = this.#clone(); | ||
this.#state = structuredClone(state); | ||
this.#readable = this.#make_frozen_clone(); | ||
this.#onChange(handleChange); | ||
@@ -21,5 +22,9 @@ } | ||
transmute(fun) { | ||
this.#state = fun(this.#state); | ||
this.#readable = this.#clone(); | ||
if (this.#circularity_lock) | ||
throw new Error("circular error"); | ||
this.#circularity_lock = true; | ||
this.#state = fun(structuredClone(this.#state)); | ||
this.#readable = this.#make_frozen_clone(); | ||
this.#onChange.publish(); | ||
this.#circularity_lock = false; | ||
} | ||
@@ -26,0 +31,0 @@ slice({ getter, setter }) { |
import { StateTree } from "./state_tree.js"; | ||
import { WatchBox } from "./parts/types.js"; | ||
export declare class WatchTower { | ||
#private; | ||
dispatch(): void; | ||
computed<T>(fun: () => T): { | ||
readonly value: T; | ||
}; | ||
computed<V>(fun: () => V): WatchBox<V>; | ||
track<T>(collector: () => T, responder: (data: T) => void): T; | ||
stateTree<S>(state: S): StateTree<S>; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
621035
10313